forked from informalsystems/hermes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added CLI to query for all connections (informalsystems#565)
* Added query for informalsystems#553 and upd changelog. * Moved the 'raw' ConnectionIds file from ICS02 to ICS03 * Optimized imports à la intellij * Cargo fmt Co-authored-by: Anca Zamfir <zamfiranca@gmail.com>
- Loading branch information
1 parent
2c88f52
commit 349750d
Showing
8 changed files
with
118 additions
and
14 deletions.
There are no files selected for viewing
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
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,55 @@ | ||
use std::sync::Arc; | ||
|
||
use abscissa_core::{Options, Runnable}; | ||
use tokio::runtime::Runtime as TokioRuntime; | ||
|
||
use ibc::ics24_host::identifier::ChainId; | ||
use ibc_proto::ibc::core::connection::v1::QueryConnectionsRequest; | ||
use relayer::chain::{Chain, CosmosSDKChain}; | ||
use relayer::config::{ChainConfig, Config}; | ||
|
||
use crate::conclude::Output; | ||
use crate::prelude::*; | ||
|
||
#[derive(Clone, Command, Debug, Options)] | ||
pub struct QueryConnectionsCmd { | ||
#[options(free, required, help = "identifier of the chain to query")] | ||
chain_id: ChainId, | ||
} | ||
|
||
impl QueryConnectionsCmd { | ||
fn validate_options(&self, config: &Config) -> Result<ChainConfig, String> { | ||
let chain_config = config | ||
.find_chain(&self.chain_id) | ||
.ok_or_else(|| format!("chain '{}' not found in configuration file", self.chain_id))?; | ||
|
||
Ok(chain_config.clone()) | ||
} | ||
} | ||
|
||
// rrly -c config.toml query connections ibc-0 | ||
impl Runnable for QueryConnectionsCmd { | ||
fn run(&self) { | ||
let config = app_config(); | ||
|
||
let chain_config = match self.validate_options(&config) { | ||
Err(err) => { | ||
return Output::error(err).exit(); | ||
} | ||
Ok(result) => result, | ||
}; | ||
info!("Options {:?}", chain_config); | ||
|
||
let rt = Arc::new(TokioRuntime::new().unwrap()); | ||
let chain = CosmosSDKChain::bootstrap(chain_config, rt).unwrap(); | ||
|
||
let req = QueryConnectionsRequest { pagination: None }; | ||
|
||
let res = chain.query_connections(req); | ||
|
||
match res { | ||
Ok(ce) => Output::success(ce).exit(), | ||
Err(e) => Output::error(format!("{}", e)).exit(), | ||
} | ||
} | ||
} |
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
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