Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement create connection CLI #223

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions relayer/crates/starknet-cli/src/commands/connection/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod subcommand;
23 changes: 23 additions & 0 deletions relayer/crates/starknet-cli/src/commands/connection/subcommand.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use hermes_cli_components::impls::commands::connection::create::CreateConnectionArgs;
use hermes_cli_components::traits::command::{CanRunCommand, CommandRunner};

#[derive(Debug, clap::Subcommand)]
pub enum CreateSubCommand {
Connection(CreateConnectionArgs),
}

pub struct RunCreateSubCommand;

impl<App> CommandRunner<App, CreateSubCommand> for RunCreateSubCommand
where
App: CanRunCommand<CreateConnectionArgs>,
{
async fn run_command(
app: &App,
subcommand: &CreateSubCommand,
) -> Result<App::Output, App::Error> {
match subcommand {
CreateSubCommand::Connection(args) => app.run_command(args).await,
}
}
}
1 change: 1 addition & 0 deletions relayer/crates/starknet-cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pub mod client;
pub mod connection;
pub mod query;
11 changes: 11 additions & 0 deletions relayer/crates/starknet-cli/src/contexts/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ use hermes_cli_components::impls::commands::bootstrap::chain::RunBootstrapChainC
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 @@ -156,6 +159,11 @@ delegate_components! {
(UpdateClientArgs, symbol!("client_id")): ParseFromString<ClientId>,
(UpdateClientArgs, symbol!("counterparty_client_id")): ParseFromString<CosmosClientId>,
(UpdateClientArgs, symbol!("target_height")): ParseFromOptionalString<Height>,

(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<CosmosClientId>,
}
}

Expand All @@ -173,6 +181,8 @@ delegate_components! {
ClientSubCommand: RunClientSubCommand,
UpdateClientArgs: RunUpdateClientCommand,

CreateConnectionArgs: RunCreateConnectionCommand,

BootstrapStarknetChainArgs: RunBootstrapChainCommand<UpdateStarknetConfig>,
}
}
Expand Down Expand Up @@ -237,6 +247,7 @@ pub trait CanUseStarknetApp:
+ CanRunCommand<QueryBalanceArgs>
+ CanRunCommand<ClientSubCommand>
+ CanRunCommand<UpdateClientArgs>
+ CanRunCommand<CreateConnectionArgs>
{
}

Expand Down
8 changes: 7 additions & 1 deletion relayer/crates/starknet-cli/src/impls/subcommand.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use hermes_cli_components::traits::command::{CanRunCommand, CommandRunner};

use crate::commands::connection::subcommand::CreateSubCommand;
use crate::commands::query::subcommand::QuerySubCommand;
use crate::impls::bootstrap::subcommand::BootstrapSubCommand;

Expand All @@ -9,13 +10,17 @@ pub enum AllSubCommands {
Bootstrap(BootstrapSubCommand),
#[clap(subcommand)]
Query(QuerySubCommand),
#[clap(subcommand)]
Create(CreateSubCommand),
}

pub struct RunAllSubCommand;

impl<App> CommandRunner<App, AllSubCommands> for RunAllSubCommand
where
App: CanRunCommand<BootstrapSubCommand> + CanRunCommand<QuerySubCommand>,
App: CanRunCommand<BootstrapSubCommand>
+ CanRunCommand<QuerySubCommand>
+ CanRunCommand<CreateSubCommand>,
{
async fn run_command(
app: &App,
Expand All @@ -24,6 +29,7 @@ where
match subcommand {
AllSubCommands::Bootstrap(args) => app.run_command(args).await,
AllSubCommands::Query(args) => app.run_command(args).await,
AllSubCommands::Create(args) => app.run_command(args).await,
}
}
}
Loading