hermes_cli/commands/bootstrap/
chain.rs

1use alloc::sync::Arc;
2
3use cgp::prelude::*;
4use hermes_cli_components::traits::bootstrap::{BootstrapLoader, HasBootstrapType};
5use hermes_cosmos_integration_tests::contexts::bootstrap::CosmosBootstrap;
6use hermes_cosmos_relayer::contexts::build::CosmosBuilder;
7use hermes_error::types::HermesError;
8use hermes_runtime::types::runtime::HermesRuntime;
9use hermes_runtime_components::traits::runtime::HasRuntime;
10
11#[derive(Debug, clap::Parser, HasField)]
12pub struct BootstrapChainArgs {
13    #[clap(long = "chain-id", required = true)]
14    pub chain_id: String,
15
16    #[clap(long = "chain-store-dir", required = true)]
17    pub chain_store_dir: String,
18
19    #[clap(long = "chain-command-path", default_value = "gaiad")]
20    pub chain_command_path: String,
21
22    #[clap(long = "account-prefix", default_value = "cosmos")]
23    pub account_prefix: String,
24
25    #[clap(long = "staking-denom", default_value = "stake")]
26    pub staking_denom: String,
27
28    #[clap(long = "transfer-denom", default_value = "samoleon")]
29    pub transfer_denom: String,
30}
31
32pub struct LoadCosmosBootstrap;
33
34impl<App> BootstrapLoader<App, BootstrapChainArgs> for LoadCosmosBootstrap
35where
36    App: HasBootstrapType<Bootstrap = CosmosBootstrap>
37        + HasRuntime<Runtime = HermesRuntime>
38        + CanRaiseError<HermesError>,
39{
40    async fn load_bootstrap(
41        app: &App,
42        args: &BootstrapChainArgs,
43    ) -> Result<App::Bootstrap, App::Error> {
44        let runtime = app.runtime();
45
46        let builder = CosmosBuilder::new_with_default(runtime.clone());
47
48        let bootstrap = CosmosBootstrap {
49            runtime: runtime.clone(),
50            builder: Arc::new(builder),
51            should_randomize_identifiers: false,
52            chain_store_dir: args.chain_store_dir.clone().into(),
53            chain_command_path: args.chain_command_path.clone().into(),
54            account_prefix: args.account_prefix.clone(),
55            staking_denom: args.staking_denom.clone(),
56            transfer_denom: args.transfer_denom.clone(),
57            genesis_config_modifier: Box::new(|_| Ok(())),
58            comet_config_modifier: Box::new(|_| Ok(())),
59        };
60
61        Ok(bootstrap)
62    }
63}