Skip to content

Commit

Permalink
Wiring things up
Browse files Browse the repository at this point in the history
  • Loading branch information
seanchen1991 committed Jan 9, 2025
1 parent fb6dc8c commit ba18f0d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::impls::commands::queries::client_state::QueryClientStateArgs;
use crate::impls::commands::queries::client_status::QueryClientStatusArgs;
use crate::impls::commands::queries::clients::QueryClientsArgs;
use crate::impls::commands::queries::consensus_state::QueryConsensusStateArgs;
use crate::traits::command::{CanRunCommand, CommandRunner};

Expand All @@ -16,17 +15,13 @@ pub enum QueryClientSubCommand {

/// Query the consensus state of a client
Consensus(QueryConsensusStateArgs),

/// Query all clients for a chain
Clients(QueryClientsArgs),
}

impl<App> CommandRunner<App, QueryClientSubCommand> for RunQueryClientSubCommand
where
App: CanRunCommand<QueryClientStateArgs>
+ CanRunCommand<QueryClientStatusArgs>
+ CanRunCommand<QueryConsensusStateArgs>
+ CanRunCommand<QueryClientsArgs>,
+ CanRunCommand<QueryConsensusStateArgs>,
{
async fn run_command(
app: &App,
Expand All @@ -36,7 +31,6 @@ where
QueryClientSubCommand::State(args) => app.run_command(args).await,
QueryClientSubCommand::Status(args) => app.run_command(args).await,
QueryClientSubCommand::Consensus(args) => app.run_command(args).await,
QueryClientSubCommand::Clients(args) => app.run_command(args).await,
}
}
}
8 changes: 3 additions & 5 deletions crates/cli/cli/src/commands/query/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
mod clients;
pub use clients::QueryClients;

mod connections;
pub use connections::QueryConnections;

Expand All @@ -13,6 +10,7 @@ pub use channels::QueryChannels;
mod packet;
use hermes_cli_components::impls::commands::queries::chain::QueryChainSubCommand;
use hermes_cli_components::impls::commands::queries::client::QueryClientSubCommand;
use hermes_cli_components::impls::commands::queries::clients::QueryClientsArgs;
use hermes_cli_components::impls::commands::queries::connection::QueryConnectionSubCommand;
use hermes_cli_components::impls::commands::queries::wallet::QueryWalletSubCommand;
use hermes_cli_components::traits::command::CanRunCommand;
Expand All @@ -27,7 +25,7 @@ use crate::Result;
#[derive(Debug, clap::Subcommand)]
pub enum QueryCommands {
/// Query all clients
Clients(QueryClients),
Clients(QueryClientsArgs),

/// Query all connections
Connections(QueryConnections),
Expand Down Expand Up @@ -66,7 +64,7 @@ impl CommandRunner<HermesApp> for QueryCommands {
Self::Wallet(cmd) => app.run_command(cmd).await,
Self::Chain(cmd) => app.run_command(cmd).await,
Self::Client(cmd) => app.run_command(cmd).await,
Self::Clients(cmd) => cmd.run(app).await,
Self::Clients(cmd) => app.run_command(cmd).await,
Self::Connection(cmd) => app.run_command(cmd).await,
Self::Connections(cmd) => cmd.run(app).await,
Self::Channels(cmd) => cmd.run(app).await,
Expand Down
8 changes: 8 additions & 0 deletions crates/cli/cli/src/contexts/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ use hermes_cli_components::impls::commands::queries::client_state::{
use hermes_cli_components::impls::commands::queries::client_status::{
QueryClientStatusArgs, RunQueryClientStatusCommand,
};
use hermes_cli_components::impls::commands::queries::clients::{
QueryClientsArgs, RunQueryClientsCommand,
};
use hermes_cli_components::impls::commands::queries::connection::{
QueryConnectionSubCommand, RunQueryConnectionSubCommand,
};
Expand Down Expand Up @@ -164,6 +167,9 @@ delegate_components! {
(QueryChannelEndArgs, symbol!("channel_id")): ParseFromString<ChannelId>,
(QueryChannelEndArgs, symbol!("height")): ParseFromOptionalString<Height>,

(QueryClientsArgs, symbol!("host_chain_id")): ParseFromString<ChainId>,
(QueryClientsArgs, symbol!("reference_chain_id")): ParseFromOptionalString<ChainId>,

(QueryClientStateArgs, symbol!("chain_id")): ParseFromString<ChainId>,
(QueryClientStateArgs, symbol!("client_id")): ParseFromString<ClientId>,
(QueryClientStateArgs, symbol!("height")): ParseFromOptionalString<Height>,
Expand Down Expand Up @@ -204,6 +210,7 @@ delegate_components! {
QueryChainSubCommand: RunQueryChainSubCommand,
QueryChainStatusArgs: RunQueryChainStatusCommand,

QueryClientsArgs: RunQueryClientsCommand,
QueryClientSubCommand: RunQueryClientSubCommand,
QueryClientStateArgs: RunQueryClientStateCommand,
QueryClientStatusArgs: RunQueryClientStatusCommand,
Expand Down Expand Up @@ -280,6 +287,7 @@ pub trait CanUseHermesApp:
+ CanLoadBuilder
+ CanRunCommand<StartRelayerArgs>
+ CanRunCommand<QueryClientSubCommand>
+ CanRunCommand<QueryClientsArgs>
+ CanRunCommand<QueryClientStateArgs>
+ CanRunCommand<QueryConsensusStateArgs>
+ CanRunCommand<QueryClientStatusArgs>
Expand Down

0 comments on commit ba18f0d

Please sign in to comment.