mithril_client_cli/commands/
mod.rs

1//! Command module
2//! This module holds the subcommands that can be used from the CLI.
3//!
4//!
5
6pub mod cardano_db;
7pub mod cardano_db_v2;
8pub mod cardano_stake_distribution;
9pub mod cardano_transaction;
10mod deprecation;
11pub mod mithril_stake_distribution;
12
13pub use deprecation::{DeprecatedCommand, Deprecation};
14
15use clap::Args;
16use mithril_client::{ClientBuilder, MithrilResult};
17
18use crate::configuration::ConfigParameters;
19
20/// Shared arguments for all commands
21#[derive(Debug, Clone, Args)]
22pub struct SharedArgs {
23    /// Enable JSON output for command results
24    #[clap(long)]
25    json: bool,
26}
27
28pub(crate) fn client_builder(params: &ConfigParameters) -> MithrilResult<ClientBuilder> {
29    let builder = ClientBuilder::aggregator(
30        &params.require("aggregator_endpoint")?,
31        &params.require("genesis_verification_key")?,
32    )
33    .with_origin_tag(params.get("origin_tag"));
34
35    Ok(builder)
36}
37
38pub(crate) fn client_builder_with_fallback_genesis_key(
39    params: &ConfigParameters,
40) -> MithrilResult<ClientBuilder> {
41    // TODO: This should not be done this way.
42    // Now that mithril-client-cli uses the mithril-client library, the genesis verification key is required for all commands
43    let fallback_genesis_verification_key = "5b33322c3235332c3138362c3230312c3137372c31312c3131372c3133352c3138372c3136372c3138312c3138\
44        382c32322c35392c3230362c3130352c3233312c3135302c3231352c33302c37382c3231322c37362c31362c323\
45        5322c3138302c37322c3133342c3133372c3234372c3136312c36385d";
46
47    let builder = ClientBuilder::aggregator(
48        &params.require("aggregator_endpoint")?,
49        &params.get_or(
50            "genesis_verification_key",
51            fallback_genesis_verification_key,
52        ),
53    )
54    .with_origin_tag(params.get("origin_tag"));
55
56    Ok(builder)
57}