-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
query channel client
command to query a channel's client state (#…
…2248) * Added new CLI command 'query channel client' * Updated Hermes guide to include new query channel client command and updated changelog * Added missing subcommand in Hermes guide, section 7.9.3 Co-authored-by: Luca Joss <[email protected]>
- Loading branch information
Showing
4 changed files
with
280 additions
and
0 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
...ngelog/unreleased/features/ibc-relayer-cli/999-channel-client-subcommand-cli.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- Added CLI command `query channel client` which outputs the channel's client state. | ||
([#999](https://github.com/informalsystems/ibc-rs/issues/999)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use abscissa_core::clap::Parser; | ||
use abscissa_core::{Command, Runnable}; | ||
|
||
use ibc::core::ics24_host::identifier::{ChainId, ChannelId, PortId}; | ||
use ibc_relayer::chain::handle::ChainHandle; | ||
use ibc_relayer::chain::requests::QueryChannelClientStateRequest; | ||
|
||
use crate::application::app_config; | ||
use crate::cli_utils::spawn_chain_runtime; | ||
use crate::conclude::{exit_with_unrecoverable_error, Output}; | ||
|
||
/// The data structure that represents the arguments when invoking the `query channel client` CLI command. | ||
/// | ||
/// `query channel client --port-id <port_id> --channel-id <channel_id> <chain_id>` | ||
/// | ||
/// If successful the channel's client state is displayed. | ||
#[derive(Clone, Command, Debug, Parser)] | ||
pub struct QueryChannelClientCmd { | ||
#[clap(required = true, help = "identifier of the chain to query")] | ||
chain_id: ChainId, | ||
|
||
#[clap(required = true, long, help = "identifier of the port to query")] | ||
port_id: PortId, | ||
|
||
#[clap(required = true, long, help = "identifier of the channel to query")] | ||
channel_id: ChannelId, | ||
} | ||
|
||
impl Runnable for QueryChannelClientCmd { | ||
fn run(&self) { | ||
let config = app_config(); | ||
|
||
let chain = spawn_chain_runtime(&config, &self.chain_id) | ||
.unwrap_or_else(exit_with_unrecoverable_error); | ||
|
||
match chain.query_channel_client_state(QueryChannelClientStateRequest { | ||
port_id: self.port_id.clone(), | ||
channel_id: self.channel_id.clone(), | ||
}) { | ||
Ok(cs) => Output::success(cs).exit(), | ||
Err(e) => Output::error(format!("{}", e)).exit(), | ||
} | ||
} | ||
} |