Skip to content

Commit

Permalink
Fix the fact that genesis_verification_key is now mandatory on comm…
Browse files Browse the repository at this point in the history
…ands that don't need it
  • Loading branch information
dlachaume committed Dec 14, 2023
1 parent 2670a43 commit 8d0796d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{collections::HashMap, sync::Arc};

use mithril_client::ClientBuilder;
use mithril_client_cli::configuration::ConfigParameters;
use mithril_common::StdResult;
use mithril_common::{test_utils::fake_keys, StdResult};

/// Mithril stake distribution LIST command
#[derive(Parser, Debug, Clone)]
Expand All @@ -23,9 +23,15 @@ impl MithrilStakeDistributionListCommand {
let params = Arc::new(ConfigParameters::new(
config.try_deserialize::<HashMap<String, String>>()?,
));
// TODO: This should not be done this way.
// Now that mithril-client-cli use the mithril-client library, the genesis verification key is required for all commands
let fallback_genesis_verification_key =
fake_keys::genesis_verification_key()[0].to_string();
let client = ClientBuilder::aggregator(
&params.require("aggregator_endpoint")?,
&params.require("genesis_verification_key")?,
&params
.require("genesis_verification_key")
.unwrap_or(fallback_genesis_verification_key),
)
.with_logger(logger())
.build()?;
Expand Down
9 changes: 8 additions & 1 deletion mithril-client-cli/src/commands/snapshot/list.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use clap::Parser;
use cli_table::{format::Justify, print_stdout, Cell, Table};
use config::{builder::DefaultState, ConfigBuilder};
use mithril_common::test_utils::fake_keys;
use slog_scope::logger;
use std::{collections::HashMap, sync::Arc};

Expand All @@ -22,9 +23,15 @@ impl SnapshotListCommand {
let params = Arc::new(ConfigParameters::new(
config.try_deserialize::<HashMap<String, String>>()?,
));
// TODO: This should not be done this way.
// Now that mithril-client-cli use the mithril-client library, the genesis verification key is required for all commands
let fallback_genesis_verification_key =
fake_keys::genesis_verification_key()[0].to_string();
let client = ClientBuilder::aggregator(
&params.require("aggregator_endpoint")?,
&params.require("genesis_verification_key")?,
&params
.require("genesis_verification_key")
.unwrap_or(fallback_genesis_verification_key),
)
.with_logger(logger())
.build()?;
Expand Down
10 changes: 8 additions & 2 deletions mithril-client-cli/src/commands/snapshot/show.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::{collections::HashMap, sync::Arc};

use mithril_client::ClientBuilder;
use mithril_client_cli::{configuration::ConfigParameters, utils::ExpanderUtils};
use mithril_common::StdResult;
use mithril_common::{test_utils::fake_keys, StdResult};

/// Clap command to show a given snapshot
#[derive(Parser, Debug, Clone)]
Expand All @@ -29,9 +29,15 @@ impl SnapshotShowCommand {
let params = Arc::new(ConfigParameters::new(
config.try_deserialize::<HashMap<String, String>>()?,
));
// TODO: This should not be done this way.
// Now that mithril-client-cli use the mithril-client library, the genesis verification key is required for all commands
let fallback_genesis_verification_key =
fake_keys::genesis_verification_key()[0].to_string();
let client = ClientBuilder::aggregator(
&params.require("aggregator_endpoint")?,
&params.require("genesis_verification_key")?,
&params
.require("genesis_verification_key")
.unwrap_or(fallback_genesis_verification_key),
)
.with_logger(logger())
.build()?;
Expand Down

0 comments on commit 8d0796d

Please sign in to comment.