Skip to content

Commit

Permalink
Hook up generic create connection cli command
Browse files Browse the repository at this point in the history
  • Loading branch information
seanchen1991 committed Jan 15, 2025
1 parent 758712e commit fac6a57
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ use crate::traits::command::CommandRunner;
use crate::traits::output::CanProduceOutput;
use crate::traits::parse::CanParseArg;

pub struct RunCreateConnectionCommand;

#[derive(Debug, clap::Parser, HasField)]
pub struct ConnectionCreateArgs {
pub struct CreateConnectionArgs {
#[clap(
long = "target-chain-id",
required = true,
Expand Down Expand Up @@ -54,8 +56,6 @@ pub struct ConnectionCreateArgs {
counterparty_client_id: String,
}

pub struct RunCreateConnectionCommand;

impl<App, Args, Builder, Chain, Counterparty, Relay> CommandRunner<App, Args>
for RunCreateConnectionCommand
where
Expand Down
11 changes: 7 additions & 4 deletions crates/cli/cli/src/commands/connection/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
mod create;
pub use create::ConnectionCreate;
// mod create;
// pub use create::ConnectionCreate;

use hermes_cli_components::impls::commands::connection::create::CreateConnectionArgs;
use hermes_cli_components::traits::command::CanRunCommand;
use hermes_cli_framework::command::CommandRunner;
use hermes_cli_framework::output::Output;

Expand All @@ -9,13 +12,13 @@ use crate::Result;
#[derive(Debug, clap::Subcommand)]
pub enum ConnectionCommands {
/// Create a new connection
Create(ConnectionCreate),
Create(CreateConnectionArgs),
}

impl CommandRunner<HermesApp> for ConnectionCommands {
async fn run(&self, app: &HermesApp) -> Result<Output> {
match self {
Self::Create(cmd) => cmd.run(app).await,
Self::Create(cmd) => app.run_command(cmd).await,
}
}
}
10 changes: 10 additions & 0 deletions crates/cli/cli/src/contexts/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ use hermes_cli_components::impls::commands::client::create::{
use hermes_cli_components::impls::commands::client::update::{
RunUpdateClientCommand, UpdateClientArgs,
};
use hermes_cli_components::impls::commands::connection::create::{
CreateConnectionArgs, RunCreateConnectionCommand,
};
use hermes_cli_components::impls::commands::queries::balance::{
QueryBalanceArgs, RunQueryBalanceCommand,
};
Expand Down Expand Up @@ -198,6 +201,11 @@ delegate_components! {
(CreateClientArgs, symbol!("target_chain_id")): ParseFromString<ChainId>,
(CreateClientArgs, symbol!("counterparty_chain_id")): ParseFromString<ChainId>,

(CreateConnectionArgs, symbol!("target_chain_id")): ParseFromString<ChainId>,
(CreateConnectionArgs, symbol!("target_client_id")): ParseFromString<ClientId>,
(CreateConnectionArgs, symbol!("counterparty_chain_id")): ParseFromString<ChainId>,
(CreateConnectionArgs, symbol!("counterparty_client_id")): ParseFromString<ClientId>,

(UpdateClientArgs, symbol!("host_chain_id")): ParseFromString<ChainId>,
(UpdateClientArgs, symbol!("client_id")): ParseFromString<ClientId>,
(UpdateClientArgs, symbol!("counterparty_client_id")): ParseFromString<ClientId>,
Expand All @@ -218,6 +226,7 @@ delegate_components! {
QueryConsensusStateArgs: RunQueryConsensusStateCommand,

CreateClientArgs: RunCreateClientCommand,
CreateConnectionArgs: RunCreateConnectionCommand,
UpdateClientArgs: RunUpdateClientCommand,

BootstrapSubCommand: RunBootstrapSubCommand,
Expand Down Expand Up @@ -297,6 +306,7 @@ pub trait CanUseHermesApp:
+ CanRunCommand<QueryChainStatusArgs>
+ CanRunCommand<QueryBalanceArgs>
+ CanRunCommand<CreateClientArgs>
+ CanRunCommand<CreateConnectionArgs>
+ CanRunCommand<UpdateClientArgs>
+ CanRunCommand<BootstrapChainArgs>
+ CanRunCommand<QueryChannelSubCommand>
Expand Down

0 comments on commit fac6a57

Please sign in to comment.