diff --git a/voyager/src/cli.rs b/voyager/src/cli.rs index e7f1c3c9e9..7ee65f1e91 100644 --- a/voyager/src/cli.rs +++ b/voyager/src/cli.rs @@ -36,37 +36,27 @@ pub struct AppArgs { #[allow(clippy::large_enum_variant)] pub enum Command { PrintConfig, - Relay(RelayCmd), - #[command(subcommand)] - SubmitPacket(SubmitPacketCmd), - #[command(subcommand)] - Query(QueryCmd), + Relay, #[command(subcommand)] Setup(SetupCmd), - #[command(subcommand)] - Ibc(IbcCmd), -} - -#[derive(Debug, Subcommand)] -pub enum IbcCmd { Query { #[arg(long)] on: String, #[arg(long, default_value_t = QueryHeight::::Latest)] at: QueryHeight, #[command(subcommand)] - cmd: IbcQueryCmd, + cmd: QueryCmd, }, } #[derive(Debug, Subcommand)] -pub enum IbcQueryCmd { +pub enum QueryCmd { #[command(subcommand)] - Path(IbcQueryPathCmd), + IbcPath(QueryIbcPathCmd), } #[derive(Debug, clap::Subcommand)] -pub enum IbcQueryPathCmd { +pub enum QueryIbcPathCmd { ClientState(proof::ClientStatePath), ClientConsensusState(proof::ClientConsensusStatePath), Connection(proof::ConnectionPath), @@ -75,7 +65,7 @@ pub enum IbcQueryPathCmd { Acknowledgement(proof::AcknowledgementPath), } -impl IbcQueryPathCmd { +impl QueryIbcPathCmd { pub async fn any_state_proof_to_json< Counterparty: Chain, This: IbcStateReadPaths, @@ -166,26 +156,6 @@ pub enum SubmitPacketCmd { }, } -#[derive(Debug, Subcommand)] -pub enum QueryCmd { - Client { - #[arg(long)] - on: String, - #[arg(long)] - client_id: String, - }, - Connection {}, - Channel {}, - Balances { - #[arg(long)] - on: String, - #[arg(long)] - who: Address, - #[arg(long)] - denom: String, - }, -} - #[derive(Debug, Parser)] pub struct RelayCmd { #[arg(long)] diff --git a/voyager/src/main.rs b/voyager/src/main.rs index c9204e1aae..b0136cb9cc 100644 --- a/voyager/src/main.rs +++ b/voyager/src/main.rs @@ -16,9 +16,9 @@ use unionlabs::ethereum_consts_traits::Mainnet; use crate::{ chain::AnyChain, - cli::{AppArgs, Command, IbcCmd, IbcQueryCmd}, + cli::{AppArgs, Command, QueryCmd}, config::Config, - queue::{AnyQueue, InMemoryQueue, PgQueue, Voyager}, + queue::{AnyQueue, Voyager}, }; pub const DELAY_PERIOD: u64 = 0; @@ -51,7 +51,8 @@ async fn do_main(args: cli::AppArgs) -> Result<(), anyhow::Error> { match args.command { Command::PrintConfig => { println!("{}", serde_json::to_string_pretty(&voyager_config).unwrap()); - + } + Command::Relay => { let queue = Voyager::new(voyager_config.clone()).await; queue.run().await; @@ -100,39 +101,30 @@ async fn do_main(args: cli::AppArgs) -> Result<(), anyhow::Error> { } _ => panic!("not supported"), }, - Command::Ibc(IbcCmd::Query { - on, - at, - cmd: IbcQueryCmd::Path(path), - }) => { + Command::Query { on, at, cmd } => { let on = voyager_config.get_chain(&on).await.unwrap(); - let json = match on { - // AnyChain::Union(_) => todo!(), - AnyChain::EvmMainnet(evm) => { - path.any_state_proof_to_json::(evm, at).await - } - AnyChain::EvmMinimal(evm) => { - path.any_state_proof_to_json::(evm, at).await - } - AnyChain::Union(union) => { - // NOTE: ChainSpec is arbitrary - path.any_state_proof_to_json::, _>(union, at) - .await + match cmd { + QueryCmd::IbcPath(path) => { + let json = match on { + AnyChain::EvmMainnet(evm) => { + path.any_state_proof_to_json::(evm, at).await + } + AnyChain::EvmMinimal(evm) => { + path.any_state_proof_to_json::(evm, at).await + } + AnyChain::Union(union) => { + // NOTE: ChainSpec is arbitrary + path.any_state_proof_to_json::, _>(union, at) + .await + } + }; + + println!("{json}"); } - _ => panic!(), - }; - - println!("{json}"); + } } - _ => panic!(), } - std::fs::write( - args.config_file_path, - serde_json::to_string_pretty(&voyager_config).unwrap(), - ) - .unwrap(); - Ok(()) }