From 51852ae51b91471e24f7b4b57116749b2d24d39c Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Tue, 7 Jun 2022 11:31:37 +0200 Subject: [PATCH 01/27] Updated CLI commands to take flags everywhere and updated e2e tests accordingly --- ci/e2e.sh | 10 +- e2e/e2e/channel.py | 58 ++--- e2e/e2e/client.py | 4 +- e2e/e2e/cmd.py | 2 +- e2e/e2e/connection.py | 28 +-- e2e/e2e/packet.py | 26 +- e2e/e2e/relayer.py | 2 +- relayer-cli/src/commands/clear.rs | 11 +- relayer-cli/src/commands/create/channel.rs | 18 +- relayer-cli/src/commands/create/connection.rs | 12 +- relayer-cli/src/commands/keys/add.rs | 12 +- relayer-cli/src/commands/keys/balance.rs | 6 +- relayer-cli/src/commands/keys/delete.rs | 22 +- relayer-cli/src/commands/keys/list.rs | 2 +- relayer-cli/src/commands/misbehaviour.rs | 2 + relayer-cli/src/commands/query/channel.rs | 21 +- .../src/commands/query/channel_client.rs | 19 +- .../src/commands/query/channel_ends.rs | 22 +- relayer-cli/src/commands/query/channels.rs | 18 +- relayer-cli/src/commands/query/client.rs | 79 ++++-- relayer-cli/src/commands/query/clients.rs | 16 +- relayer-cli/src/commands/query/connection.rs | 26 +- relayer-cli/src/commands/query/connections.rs | 6 +- relayer-cli/src/commands/query/packet/ack.rs | 23 +- relayer-cli/src/commands/query/packet/acks.rs | 19 +- .../src/commands/query/packet/commitment.rs | 23 +- .../src/commands/query/packet/commitments.rs | 19 +- .../src/commands/query/packet/pending.rs | 4 + .../commands/query/packet/unreceived_acks.rs | 5 +- .../query/packet/unreceived_packets.rs | 5 +- relayer-cli/src/commands/query/tx/events.rs | 8 +- relayer-cli/src/commands/tx/channel.rs | 226 ++++++++++++++---- relayer-cli/src/commands/tx/client.rs | 49 +++- relayer-cli/src/commands/tx/connection.rs | 121 +++++++--- relayer-cli/src/commands/tx/packet.rs | 52 +++- relayer-cli/src/commands/tx/transfer.rs | 47 ++-- relayer-cli/src/commands/tx/upgrade.rs | 34 ++- relayer-cli/src/entry.rs | 4 +- 38 files changed, 772 insertions(+), 289 deletions(-) diff --git a/ci/e2e.sh b/ci/e2e.sh index cd8b26a387..5047e2745c 100755 --- a/ci/e2e.sh +++ b/ci/e2e.sh @@ -16,7 +16,7 @@ echo "-------------------------------------------------------------------------- echo "Show relayer version" echo "-----------------------------------------------------------------------------------------------------------------" echo Config: "$CONFIG_PATH" -$RELAYER_CMD -c "$CONFIG_PATH" version +$RELAYER_CMD --config "$CONFIG_PATH" version echo "-----------------------------------------------------------------------------------------------------------------" echo "Setting up chains" echo "-----------------------------------------------------------------------------------------------------------------" @@ -34,10 +34,10 @@ echo "========================================================================== echo "-----------------------------------------------------------------------------------------------------------------" echo "Add keys for chains" echo "-----------------------------------------------------------------------------------------------------------------" -hermes -c "$CONFIG_PATH" keys add "$CHAIN_A" -f user_seed_"$CHAIN_A".json -hermes -c "$CONFIG_PATH" keys add "$CHAIN_B" -f user_seed_"$CHAIN_B".json -hermes -c "$CONFIG_PATH" keys add "$CHAIN_A" -f user2_seed_"$CHAIN_A".json -k user2 -hermes -c "$CONFIG_PATH" keys add "$CHAIN_B" -f user2_seed_"$CHAIN_B".json -k user2 +hermes --config "$CONFIG_PATH" keys add --chain "$CHAIN_A" --key-file user_seed_"$CHAIN_A".json +hermes --config "$CONFIG_PATH" keys add --chain "$CHAIN_B" --key-file user_seed_"$CHAIN_B".json +hermes --config "$CONFIG_PATH" keys add --chain "$CHAIN_A" --key-file user2_seed_"$CHAIN_A".json --key-name user2 +hermes --config "$CONFIG_PATH" keys add --chain "$CHAIN_B" --key-file user2_seed_"$CHAIN_B".json --key-name user2 echo "=================================================================================================================" echo " END-TO-END TESTS " diff --git a/e2e/e2e/channel.py b/e2e/e2e/channel.py index 90921aff7b..fba0eb16ec 100644 --- a/e2e/e2e/channel.py +++ b/e2e/e2e/channel.py @@ -27,9 +27,9 @@ class TxChanOpenInit(Cmd[TxChanOpenInitRes]): ordering: Optional[Ordering] = None def args(self) -> List[str]: - args = [self.dst_chain_id, self.src_chain_id, - self.connection_id, - self.dst_port_id, self.src_port_id] + args = ["--dst-chain", self.dst_chain_id, "--src-chain", self.src_chain_id, + "--conn", self.connection_id, + "--dst-port", self.dst_port_id, "--src-port", self.src_port_id] if self.ordering is not None: args.extend(['--ordering', str(self.ordering)]) @@ -65,10 +65,10 @@ class TxChanOpenTry(Cmd[TxChanOpenTryRes]): ordering: Optional[Ordering] = None def args(self) -> List[str]: - args = [self.dst_chain_id, self.src_chain_id, - self.connection_id, - self.dst_port_id, self.src_port_id, - "-s", self.src_channel_id] + args = ["--dst-chain", self.dst_chain_id, "--src-chain", self.src_chain_id, + "--conn", self.connection_id, + "--dst-port", self.dst_port_id, "--src-port", self.src_port_id, + "--src-chan", self.src_channel_id] if self.ordering is not None: args.extend(['--ordering', str(self.ordering)]) @@ -104,11 +104,11 @@ class TxChanOpenAck(Cmd[TxChanOpenAckRes]): src_channel_id: ChannelId def args(self) -> List[str]: - args = [self.dst_chain_id, self.src_chain_id, - self.connection_id, - self.dst_port_id, self.src_port_id, - "-d", self.dst_channel_id, - "-s", self.src_channel_id] + args = ["--dst-chain", self.dst_chain_id, "--src-chain", self.src_chain_id, + "--conn", self.connection_id, + "--dst-port", self.dst_port_id, "--src-port", self.src_port_id, + "--dst-chan", self.dst_channel_id, + "--src-chan", self.src_channel_id] return args @@ -141,11 +141,11 @@ class TxChanOpenConfirm(Cmd[TxChanOpenConfirmRes]): src_channel_id: ChannelId def args(self) -> List[str]: - args = [self.dst_chain_id, self.src_chain_id, - self.connection_id, - self.dst_port_id, self.src_port_id, - "-d", self.dst_channel_id, - "-s", self.src_channel_id] + args = ["--dst-chain", self.dst_chain_id, "--src-chain", self.src_chain_id, + "--conn", self.connection_id, + "--dst-port", self.dst_port_id, "--src-port", self.src_port_id, + "--dst-chan", self.dst_channel_id, + "--src-chan", self.src_channel_id] return args @@ -177,11 +177,11 @@ class TxChanCloseInit(Cmd[TxChanCloseInitRes]): src_chan_id: ChannelId def args(self) -> List[str]: - args = [self.dst_chain_id, self.src_chain_id, - self.dst_conn_id, - self.dst_port_id, self.src_port_id, - "-d", self.dst_chan_id, - "-s", self.src_chan_id] + args = ["--dst-chain", self.dst_chain_id, "--src-chain", self.src_chain_id, + "--dst-conn", self.dst_conn_id, + "--dst-port", self.dst_port_id, "--src-port", self.src_port_id, + "--dst-chan", self.dst_chan_id, + "--src-chan", self.src_chan_id] return args @@ -214,11 +214,11 @@ class TxChanCloseConfirm(Cmd[TxChanCloseConfirmRes]): src_chan_id: ChannelId def args(self) -> List[str]: - args = [self.dst_chain_id, self.src_chain_id, - self.dst_conn_id, - self.dst_port_id, self.src_port_id, - "-d", self.dst_chan_id, - "-s", self.src_chan_id] + args = ["--dst-chain", self.dst_chain_id, "--src-chain", self.src_chain_id, + "--dst-conn", self.dst_conn_id, + "--dst-port", self.dst_port_id, "--src-port", self.src_port_id, + "--dst-chan", self.dst_chan_id, + "--src-chan", self.src_chan_id] return args @@ -267,7 +267,7 @@ class QueryChannelEnd(Cmd[ChannelEnd]): channel_id: ChannelId def args(self) -> List[str]: - return [self.chain_id, self.port_id, self.channel_id] + return ["--chain", self.chain_id, "--port", self.port_id, "--chan", self.channel_id] def process(self, result: Any) -> ChannelEnd: return from_dict(ChannelEnd, result) @@ -280,7 +280,7 @@ class QueryChannelEnds(Cmd[ChannelEnds]): channel_id: ChannelId def args(self) -> List[str]: - return [self.chain_id, self.port_id, self.channel_id] + return ["--chain", self.chain_id, "--port", self.port_id, "--chan", self.channel_id] def process(self, result: Any) -> ChannelEnds: return from_dict(ChannelEnds, result) diff --git a/e2e/e2e/client.py b/e2e/e2e/client.py index fd71a5ae18..5f6423dc11 100644 --- a/e2e/e2e/client.py +++ b/e2e/e2e/client.py @@ -19,7 +19,7 @@ class TxCreateClient(Cmd[ClientCreated]): src_chain_id: ChainId def args(self) -> List[str]: - return [self.dst_chain_id, self.src_chain_id] + return ["--dst-chain", self.dst_chain_id, "--src-chain", self.src_chain_id] def process(self, result: Any) -> ClientCreated: return from_dict(ClientCreated, result['CreateClient']) @@ -43,7 +43,7 @@ class TxUpdateClient(Cmd[ClientUpdated]): dst_client_id: ClientId def args(self) -> List[str]: - return [self.dst_chain_id, self.dst_client_id] + return ["--dst-chain", self.dst_chain_id, "--dst-client", self.dst_client_id] def process(self, result: Any) -> ClientUpdated: return from_dict(ClientUpdated, result[-1]['UpdateClient']['common']) diff --git a/e2e/e2e/cmd.py b/e2e/e2e/cmd.py index 6750aab58b..bc2ef64953 100644 --- a/e2e/e2e/cmd.py +++ b/e2e/e2e/cmd.py @@ -55,7 +55,7 @@ def to_cmd(self) -> str: return f"{self.name} {' '.join(self.args())}" def run(self, config: Config, retries: int = 0) -> CmdResult[T]: - full_cmd = f'{config.relayer_cmd} -c {config.config_file} --json'.split(' ') + full_cmd = f'{config.relayer_cmd} --config {config.config_file} --json'.split(' ') full_cmd.extend(self.name.split(' ')) full_cmd.extend(self.args()) l.debug(' '.join(full_cmd)) diff --git a/e2e/e2e/connection.py b/e2e/e2e/connection.py index 834cfb6440..9404fb81c9 100644 --- a/e2e/e2e/connection.py +++ b/e2e/e2e/connection.py @@ -22,8 +22,8 @@ class TxConnInit(Cmd[TxConnInitRes]): src_client_id: ClientId def args(self) -> List[str]: - return [self.dst_chain_id, self.src_chain_id, - self.dst_client_id, self.src_client_id] + return ["--dst-chain", self.dst_chain_id, "--src-chain", self.src_chain_id, + "--dst-client", self.dst_client_id, "--src-client", self.src_client_id] def process(self, result: Any) -> TxConnInitRes: return from_dict(TxConnInitRes, result['OpenInitConnection']) @@ -46,9 +46,9 @@ class TxConnTry(Cmd[TxConnTryRes]): src_conn_id: ConnectionId def args(self) -> List[str]: - return [self.dst_chain_id, self.src_chain_id, - self.dst_client_id, self.src_client_id, - "-s", self.src_conn_id] + return ["dst-chain", self.dst_chain_id, "--src-chain", self.src_chain_id, + "--dst-client", self.dst_client_id, "--src-client", self.src_client_id, + "--src-conn", self.src_conn_id] def process(self, result: Any) -> TxConnTryRes: return from_dict(TxConnTryRes, result['OpenTryConnection']) @@ -72,10 +72,10 @@ class TxConnAck(Cmd[TxConnAckRes]): src_conn_id: ConnectionId def args(self) -> List[str]: - return [self.dst_chain_id, self.src_chain_id, - self.dst_client_id, self.src_client_id, - "-d", self.dst_conn_id, - "-s", self.src_conn_id] + return ["--dst-chain", self.dst_chain_id, "--src-chain", self.src_chain_id, + "--dst-client", self.dst_client_id, "--src-client", self.src_client_id, + "--dst-conn", self.dst_conn_id, + "--src-conn", self.src_conn_id] def process(self, result: Any) -> TxConnAckRes: return from_dict(TxConnAckRes, result['OpenAckConnection']) @@ -99,10 +99,10 @@ class TxConnConfirm(Cmd[TxConnConfirmRes]): src_conn_id: ConnectionId def args(self) -> List[str]: - return [self.dst_chain_id, self.src_chain_id, - self.dst_client_id, self.src_client_id, - "-d", self.dst_conn_id, - "-s", self.src_conn_id] + return ["--dst-chain", self.dst_chain_id, "--src-chain", self.src_chain_id, + "--dst-client", self.dst_client_id, "--src-client", self.src_client_id, + "--dst-conn", self.dst_conn_id, + "--src-conn", self.src_conn_id] def process(self, result: Any) -> TxConnConfirmRes: return from_dict(TxConnConfirmRes, result['OpenConfirmConnection']) @@ -139,7 +139,7 @@ class QueryConnectionEnd(Cmd[ConnectionEnd]): connection_id: ConnectionId def args(self) -> List[str]: - return [self.chain_id, self.connection_id] + return ["--chain", self.chain_id, "--conn", self.connection_id] def process(self, result: Any) -> ConnectionEnd: return from_dict(ConnectionEnd, result) diff --git a/e2e/e2e/packet.py b/e2e/e2e/packet.py index 278aaf1f04..84f0c705ea 100644 --- a/e2e/e2e/packet.py +++ b/e2e/e2e/packet.py @@ -36,19 +36,19 @@ class TxPacketSend(Cmd[TxPacketSendRes]): def args(self) -> List[str]: args = [ - self.dst_chain_id, - self.src_chain_id, - self.src_port, - self.src_channel, - str(self.amount), - "-o", str(self.height_offset), + "--dst-chain", self.dst_chain_id, + "--src-chain", self.src_chain_id, + "--src-port", self.src_port, + "--src-chan", self.src_channel, + "--amount", str(self.amount), + "--timeout-height-offset", str(self.height_offset), ] if self.number_msgs != None: - args.extend(['-n', str(self.number_msgs)]) + args.extend(['--number-msgs', str(self.number_msgs)]) if self.key != None: - args.extend(['-k', str(self.key)]) + args.extend(['--key-name', str(self.key)]) return args @@ -75,7 +75,7 @@ class TxPacketRecv(Cmd[TxPacketRecvRes]): src_channel: ChannelId def args(self) -> List[str]: - return [self.dst_chain_id, self.src_chain_id, self.src_port, self.src_channel] + return ["--dst-chain", self.dst_chain_id, "--src-chain", self.src_chain_id, "--src-port", self.src_port, "--src-chan", self.src_channel] def process(self, result: Any) -> TxPacketRecvRes: entry = find_entry(result, 'WriteAcknowledgement') @@ -99,7 +99,7 @@ class TxPacketTimeout(Cmd[TxPacketTimeoutRes]): src_channel: ChannelId def args(self) -> List[str]: - return [self.dst_chain_id, self.src_chain_id, self.src_port, self.src_channel] + return ["--dst-chain", self.dst_chain_id, "--src-chain", self.src_chain_id, "--src-port", self.src_port, "--src-chan", self.src_channel] def process(self, result: Any) -> TxPacketTimeoutRes: entry = find_entry(result, 'TimeoutPacket') @@ -124,7 +124,7 @@ class TxPacketAck(Cmd[TxPacketAckRes]): src_channel: ChannelId def args(self) -> List[str]: - return [self.dst_chain_id, self.src_chain_id, self.src_port, self.src_channel] + return ["--dst-chain", self.dst_chain_id, "--src-chain", self.src_chain_id, "--src-port", self.src_port, "--src-chan", self.src_channel] def process(self, result: Any) -> TxPacketAckRes: entry = find_entry(result, 'AcknowledgePacket') @@ -141,7 +141,7 @@ class QueryUnreceivedPackets(Cmd[List[int]]): channel: ChannelId def args(self) -> List[str]: - return [self.chain, self.port, self.channel] + return ["--chain", self.chain, "--port", self.port, "--chan", self.channel] def process(self, result: Any) -> List[int]: return from_dict(List[int], result) @@ -169,7 +169,7 @@ class QueryUnreceivedAcks(Cmd[List[int]]): channel: ChannelId def args(self) -> List[str]: - return [self.chain, self.port, self.channel] + return ["--chain", self.chain, "--port", self.port, "--chan", self.channel] def process(self, result: Any) -> List[int]: return from_dict(List[int], result) diff --git a/e2e/e2e/relayer.py b/e2e/e2e/relayer.py index 1f72d09c11..a475819775 100644 --- a/e2e/e2e/relayer.py +++ b/e2e/e2e/relayer.py @@ -6,6 +6,6 @@ def start(c: Config) -> Popen: - full_cmd = f'{c.relayer_cmd} -c {c.config_file} -j start'.split(' ') + full_cmd = f'{c.relayer_cmd} --config {c.config_file} --json start'.split(' ') l.debug(' '.join(full_cmd)) return Popen(full_cmd) diff --git a/relayer-cli/src/commands/clear.rs b/relayer-cli/src/commands/clear.rs index eff01641da..f7abd8f930 100644 --- a/relayer-cli/src/commands/clear.rs +++ b/relayer-cli/src/commands/clear.rs @@ -23,13 +23,18 @@ pub enum ClearCmds { #[derive(Debug, Parser)] pub struct ClearPacketsCmd { - #[clap(required = true, help = "identifier of the chain")] + #[clap(long = "chain", required = true, help = "identifier of the chain")] chain_id: ChainId, - #[clap(required = true, help = "identifier of the port")] + #[clap( + short = 'p', + long = "port", + required = true, + help = "identifier of the port" + )] port_id: PortId, - #[clap(required = true, help = "identifier of the channel")] + #[clap(long = "chan", required = true, help = "identifier of the channel")] channel_id: ChannelId, } diff --git a/relayer-cli/src/commands/create/channel.rs b/relayer-cli/src/commands/create/channel.rs index f26fa1fe2e..0288f61c04 100644 --- a/relayer-cli/src/commands/create/channel.rs +++ b/relayer-cli/src/commands/create/channel.rs @@ -45,14 +45,14 @@ static HINT: &str = "Consider using the default invocation\n\nhermes create chan #[clap(disable_version_flag = true)] pub struct CreateChannelCommand { #[clap( + long = "chain-a", required = true, help = "Identifier of the side `a` chain for the new channel" )] chain_a: ChainId, #[clap( - short, - long, + long = "chain-b", help = "Identifier of the side `b` chain for the new channel" )] chain_b: Option, @@ -61,37 +61,37 @@ pub struct CreateChannelCommand { connection_a: Option, #[clap( - long, + long = "port-a", required = true, help = "Identifier of the side `a` port for the new channel" )] port_a: PortId, #[clap( - long, + long = "port-b", required = true, help = "Identifier of the side `b` port for the new channel" )] port_b: PortId, #[clap( - short, - long, + short = 'o', + long = "order", help = "The channel ordering, valid options 'unordered' (default) and 'ordered'", default_value_t )] order: Order, #[clap( - short, - long = "channel-version", + short = 'v', + long = "chan-version", alias = "version", help = "The version for the new channel" )] version: Option, #[clap( - long, + long = "new-client-conn", help = "Indicates that a new client and connection will be created underlying the new channel" )] new_client_connection: bool, diff --git a/relayer-cli/src/commands/create/connection.rs b/relayer-cli/src/commands/create/connection.rs index d8377287ea..90c290373a 100644 --- a/relayer-cli/src/commands/create/connection.rs +++ b/relayer-cli/src/commands/create/connection.rs @@ -18,28 +18,32 @@ use crate::prelude::*; #[derive(Clone, Command, Debug, Parser)] pub struct CreateConnectionCommand { #[clap( + long = "chain-a", required = true, help = "identifier of the side `a` chain for the new connection" )] chain_a_id: ChainId, - #[clap(help = "identifier of the side `b` chain for the new connection")] + #[clap( + long = "chain-b", + help = "identifier of the side `b` chain for the new connection" + )] chain_b_id: Option, #[clap( - long, + long = "client-a", help = "identifier of client hosted on chain `a`; default: None (creates a new client)" )] client_a: Option, #[clap( - long, + long = "client-b", help = "identifier of client hosted on chain `b`; default: None (creates a new client)" )] client_b: Option, #[clap( - long, + long = "delay", help = "delay period parameter for the new connection (seconds)", default_value = "0" )] diff --git a/relayer-cli/src/commands/keys/add.rs b/relayer-cli/src/commands/keys/add.rs index 1e85269899..86e8293e02 100644 --- a/relayer-cli/src/commands/keys/add.rs +++ b/relayer-cli/src/commands/keys/add.rs @@ -37,7 +37,7 @@ pub struct KeysAddCmd { #[clap( short = 'f', - long, + long = "key-file", required = true, help = "path to the key file", group = "add-restore" @@ -45,8 +45,8 @@ pub struct KeysAddCmd { key_file: Option, #[clap( - short, - long, + short = 'm', + long = "mnemonic-file", required = true, help = "path to file containing mnemonic to restore the key from", group = "add-restore" @@ -54,15 +54,15 @@ pub struct KeysAddCmd { mnemonic_file: Option, #[clap( - short, - long, + short = 'k', + long = "key-name", help = "name of the key (defaults to the `key_name` defined in the config)" )] key_name: Option, #[clap( short = 'p', - long, + long = "hd-path", help = "derivation path for this key", default_value = "m/44'/118'/0'/0/0" )] diff --git a/relayer-cli/src/commands/keys/balance.rs b/relayer-cli/src/commands/keys/balance.rs index 2b0558f27e..137fa401c0 100644 --- a/relayer-cli/src/commands/keys/balance.rs +++ b/relayer-cli/src/commands/keys/balance.rs @@ -19,12 +19,12 @@ use crate::conclude::{exit_with_unrecoverable_error, json, Output}; /// on the given chain, will be displayed. #[derive(Clone, Command, Debug, Parser)] pub struct KeyBalanceCmd { - #[clap(required = true, help = "identifier of the chain")] + #[clap(long = "chain", required = true, help = "identifier of the chain")] chain_id: ChainId, #[clap( - long, - short, + short = 'k', + long = "key-name", help = "(optional) name of the key (defaults to the `key_name` defined in the config)" )] key_name: Option, diff --git a/relayer-cli/src/commands/keys/delete.rs b/relayer-cli/src/commands/keys/delete.rs index 717f620b53..efb6756c0e 100644 --- a/relayer-cli/src/commands/keys/delete.rs +++ b/relayer-cli/src/commands/keys/delete.rs @@ -12,13 +12,13 @@ use crate::conclude::Output; #[derive(Clone, Command, Debug, Parser)] pub struct KeysDeleteCmd { - #[clap(required = true, help = "identifier of the chain")] + #[clap(long = "chain", required = true, help = "identifier of the chain")] chain_id: ChainId, - #[clap(short = 'n', long, help = "name of the key")] - name: Option, + #[clap(short = 'k', long = "key-name", help = "name of the key")] + key_name: Option, - #[clap(short = 'a', long, help = "delete all keys")] + #[clap(short = 'a', long = "all", help = "delete all keys")] all: bool, } @@ -31,17 +31,19 @@ impl KeysDeleteCmd { .find_chain(&self.chain_id) .ok_or_else(|| format!("chain '{}' not found in configuration file", self.chain_id))?; - let id = match (self.all, &self.name) { + let id = match (self.all, &self.key_name) { (true, Some(_)) => { - return Err("cannot set both -n/--name and -a/--all".to_owned().into()); + return Err("cannot set both -k/--key-name and -a/--all" + .to_owned() + .into()); } (false, None) => { - return Err("must provide either -n/--name or -a/--all" + return Err("must provide either -k/--key-name or -a/--all" .to_owned() .into()); } (true, None) => KeysDeleteId::All, - (false, Some(ref name)) => KeysDeleteId::Named(name), + (false, Some(ref key_name)) => KeysDeleteId::Named(key_name), }; Ok(KeysDeleteOptions { @@ -80,10 +82,10 @@ impl Runnable for KeysDeleteCmd { } Err(e) => Output::error(format!("{}", e)).exit(), }, - KeysDeleteId::Named(name) => match delete_key(&opts.config, name) { + KeysDeleteId::Named(key_name) => match delete_key(&opts.config, key_name) { Ok(_) => Output::success_msg(format!( "Removed key ({}) on chain {}", - name, opts.config.id + key_name, opts.config.id )) .exit(), Err(e) => Output::error(format!("{}", e)).exit(), diff --git a/relayer-cli/src/commands/keys/list.rs b/relayer-cli/src/commands/keys/list.rs index b627fd77cb..bfc978206d 100644 --- a/relayer-cli/src/commands/keys/list.rs +++ b/relayer-cli/src/commands/keys/list.rs @@ -14,7 +14,7 @@ use crate::{application::app_config, conclude::json}; #[derive(Clone, Command, Debug, Parser)] pub struct KeysListCmd { - #[clap(required = true, help = "identifier of the chain")] + #[clap(long = "chain", required = true, help = "identifier of the chain")] chain_id: ChainId, } diff --git a/relayer-cli/src/commands/misbehaviour.rs b/relayer-cli/src/commands/misbehaviour.rs index 2b33c5171d..623f333552 100644 --- a/relayer-cli/src/commands/misbehaviour.rs +++ b/relayer-cli/src/commands/misbehaviour.rs @@ -18,12 +18,14 @@ use ibc::core::ics02_client::client_state::ClientState; #[derive(Clone, Command, Debug, Parser)] pub struct MisbehaviourCmd { #[clap( + long = "chain", required = true, help = "identifier of the chain where client updates are monitored for misbehaviour" )] chain_id: ChainId, #[clap( + long = "client", required = true, help = "identifier of the client to be monitored for misbehaviour" )] diff --git a/relayer-cli/src/commands/query/channel.rs b/relayer-cli/src/commands/query/channel.rs index 24cef1d005..107af9ee51 100644 --- a/relayer-cli/src/commands/query/channel.rs +++ b/relayer-cli/src/commands/query/channel.rs @@ -15,16 +15,29 @@ use ibc::core::ics04_channel::channel::State; #[derive(Clone, Command, Debug, Parser)] pub struct QueryChannelEndCmd { - #[clap(required = true, help = "identifier of the chain to query")] + #[clap( + long = "chain", + required = true, + help = "identifier of the chain to query" + )] chain_id: ChainId, - #[clap(required = true, help = "identifier of the port to query")] + #[clap( + short = 'p', + long = "port", + required = true, + help = "identifier of the port to query" + )] port_id: PortId, - #[clap(required = true, help = "identifier of the channel to query")] + #[clap( + long = "chan", + required = true, + help = "identifier of the channel to query" + )] channel_id: ChannelId, - #[clap(short = 'H', long, help = "height of the state to query")] + #[clap(short = 'H', long = "height", help = "height of the state to query")] height: Option, } diff --git a/relayer-cli/src/commands/query/channel_client.rs b/relayer-cli/src/commands/query/channel_client.rs index fef376e3a7..eafe56d825 100644 --- a/relayer-cli/src/commands/query/channel_client.rs +++ b/relayer-cli/src/commands/query/channel_client.rs @@ -16,13 +16,26 @@ use crate::conclude::{exit_with_unrecoverable_error, Output}; /// 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")] + #[clap( + long = "chain", + required = true, + help = "identifier of the chain to query" + )] chain_id: ChainId, - #[clap(required = true, long, help = "identifier of the port to query")] + #[clap( + short = 'p', + long = "port", + required = true, + help = "identifier of the port to query" + )] port_id: PortId, - #[clap(required = true, long, help = "identifier of the channel to query")] + #[clap( + long = "chan", + required = true, + help = "identifier of the channel to query" + )] channel_id: ChannelId, } diff --git a/relayer-cli/src/commands/query/channel_ends.rs b/relayer-cli/src/commands/query/channel_ends.rs index 774ae64f6c..7828948595 100644 --- a/relayer-cli/src/commands/query/channel_ends.rs +++ b/relayer-cli/src/commands/query/channel_ends.rs @@ -19,21 +19,33 @@ use crate::prelude::*; #[derive(Clone, Command, Debug, Parser)] pub struct QueryChannelEndsCmd { - #[clap(required = true, help = "identifier of the chain to query")] + #[clap( + long = "chain", + required = true, + help = "identifier of the chain to query" + )] chain_id: ChainId, - #[clap(required = true, help = "identifier of the port to query")] + #[clap( + long = "port", + required = true, + help = "identifier of the port to query" + )] port_id: PortId, - #[clap(required = true, help = "identifier of the channel to query")] + #[clap( + long = "chan", + required = true, + help = "identifier of the channel to query" + )] channel_id: ChannelId, - #[clap(short = 'H', long, help = "height of the state to query")] + #[clap(short = 'H', long = "height", help = "height of the state to query")] height: Option, #[clap( short = 'v', - long, + long = "verbose", help = "enable verbose output, displaying all details of channels, connections & clients" )] verbose: bool, diff --git a/relayer-cli/src/commands/query/channels.rs b/relayer-cli/src/commands/query/channels.rs index 7beb8fe618..80e50093d5 100644 --- a/relayer-cli/src/commands/query/channels.rs +++ b/relayer-cli/src/commands/query/channels.rs @@ -21,19 +21,23 @@ use crate::prelude::*; #[derive(Clone, Command, Debug, Parser)] pub struct QueryChannelsCmd { - #[clap(required = true, help = "identifier of the chain to query")] + #[clap( + long = "chain", + required = true, + help = "identifier of the chain to query" + )] chain_id: ChainId, #[clap( short = 'd', - long, + long = "dst-chain", help = "identifier of the channel's destination chain" )] - destination_chain: Option, + dst_chain_id: Option, #[clap( short = 'v', - long, + long = "verbose", help = "enable verbose output, displaying all client and connection ids" )] verbose: bool, @@ -90,7 +94,7 @@ fn run_query_channels( let channel_ends = query_channel_ends( &mut registry, &chain, - cmd.destination_chain.as_ref(), + cmd.dst_chain_id.as_ref(), channel_end, connection_id, chain_id, @@ -118,7 +122,7 @@ fn run_query_channels( fn query_channel_ends( registry: &mut Registry, chain: &Chain, - destination_chain: Option<&ChainId>, + dst_chain_id: Option<&ChainId>, channel_end: ChannelEnd, connection_id: ConnectionId, chain_id: ChainId, @@ -137,7 +141,7 @@ fn query_channel_ends( })?; let counterparty_chain_id = client_state.chain_id(); - if let Some(dst_chain_id) = destination_chain { + if let Some(dst_chain_id) = dst_chain_id { if dst_chain_id != &counterparty_chain_id { return Err(format!( "mismatch between supplied destination chain ({}) and counterparty chain ({})", diff --git a/relayer-cli/src/commands/query/client.rs b/relayer-cli/src/commands/query/client.rs index f23c0fc40b..e3d5e4eaf9 100644 --- a/relayer-cli/src/commands/query/client.rs +++ b/relayer-cli/src/commands/query/client.rs @@ -25,13 +25,25 @@ use crate::conclude::{exit_with_unrecoverable_error, Output}; /// Query client state command #[derive(Clone, Command, Debug, Parser)] pub struct QueryClientStateCmd { - #[clap(required = true, help = "identifier of the chain to query")] + #[clap( + long = "chain", + required = true, + help = "identifier of the chain to query" + )] chain_id: ChainId, - #[clap(required = true, help = "identifier of the client to query")] + #[clap( + long = "client", + required = true, + help = "identifier of the client to query" + )] client_id: ClientId, - #[clap(short = 'H', long, help = "the chain height context for the query")] + #[clap( + short = 'H', + long = "height", + help = "the chain height context for the query" + )] height: Option, } @@ -68,25 +80,36 @@ impl Runnable for QueryClientStateCmd { /// Query client consensus command #[derive(Clone, Command, Debug, Parser)] pub struct QueryClientConsensusCmd { - #[clap(required = true, help = "identifier of the chain to query")] + #[clap( + long = "chain", + required = true, + help = "identifier of the chain to query" + )] chain_id: ChainId, - #[clap(required = true, help = "identifier of the client to query")] + #[clap( + long = "client", + required = true, + help = "identifier of the client to query" + )] client_id: ClientId, #[clap( - short = 'c', - long, + long = "consensus-height", help = "height of the client's consensus state to query" )] consensus_height: Option, - #[clap(short = 's', long, help = "show only consensus heights")] + #[clap( + short = 's', + long = "heights-only", + help = "show only consensus heights" + )] heights_only: bool, #[clap( short = 'H', - long, + long = "height", help = "the chain height context to be used, applicable only to a specific height" )] height: Option, @@ -165,16 +188,32 @@ impl Runnable for QueryClientConsensusCmd { #[derive(Clone, Command, Debug, Parser)] pub struct QueryClientHeaderCmd { - #[clap(required = true, help = "identifier of the chain to query")] + #[clap( + long = "chain", + required = true, + help = "identifier of the chain to query" + )] chain_id: ChainId, - #[clap(required = true, help = "identifier of the client to query")] + #[clap( + long = "client", + required = true, + help = "identifier of the client to query" + )] client_id: ClientId, - #[clap(required = true, help = "height of header to query")] + #[clap( + long = "consensus-height", + required = true, + help = "height of header to query" + )] consensus_height: u64, - #[clap(short = 'H', long, help = "the chain height context for the query")] + #[clap( + short = 'H', + long = "height", + help = "the chain height context for the query" + )] height: Option, } @@ -232,15 +271,23 @@ impl Runnable for QueryClientHeaderCmd { /// Query client connections command #[derive(Clone, Command, Debug, Parser)] pub struct QueryClientConnectionsCmd { - #[clap(required = true, help = "identifier of the chain to query")] + #[clap( + long = "chain", + required = true, + help = "identifier of the chain to query" + )] chain_id: ChainId, - #[clap(required = true, help = "identifier of the client to query")] + #[clap( + long = "client", + required = true, + help = "identifier of the client to query" + )] client_id: ClientId, #[clap( short = 'H', - long, + long = "height", help = "the chain height which this query should reflect" )] height: Option, diff --git a/relayer-cli/src/commands/query/clients.rs b/relayer-cli/src/commands/query/clients.rs index e6ca161980..6bd2970d24 100644 --- a/relayer-cli/src/commands/query/clients.rs +++ b/relayer-cli/src/commands/query/clients.rs @@ -17,18 +17,26 @@ use crate::prelude::*; /// Query clients command #[derive(Clone, Command, Debug, Parser)] pub struct QueryAllClientsCmd { - #[clap(required = true, help = "identifier of the chain to query")] + #[clap( + long = "chain", + required = true, + help = "identifier of the chain to query" + )] chain_id: ChainId, #[clap( - short, - long, + short = 's', + long = "src-chain", help = "filter for clients which target a specific chain id (implies '-o')", value_name = "ID" )] src_chain_id: Option, - #[clap(short, long, help = "omit printing the source chain for each client")] + #[clap( + short = 'o', + long = "omit-chain-ids", + help = "omit printing the source chain for each client" + )] omit_chain_ids: bool, } diff --git a/relayer-cli/src/commands/query/connection.rs b/relayer-cli/src/commands/query/connection.rs index ea1288dddb..8a2f0e3325 100644 --- a/relayer-cli/src/commands/query/connection.rs +++ b/relayer-cli/src/commands/query/connection.rs @@ -20,13 +20,21 @@ use crate::prelude::*; #[derive(Clone, Command, Debug, Parser)] pub struct QueryConnectionEndCmd { - #[clap(required = true, help = "identifier of the chain to query")] + #[clap( + long = "chain", + required = true, + help = "identifier of the chain to query" + )] chain_id: ChainId, - #[clap(required = true, help = "identifier of the connection to query")] + #[clap( + long = "conn", + required = true, + help = "identifier of the connection to query" + )] connection_id: ConnectionId, - #[clap(short = 'H', long, help = "height of the state to query")] + #[clap(short = 'H', long = "height", help = "height of the state to query")] height: Option, } @@ -77,10 +85,18 @@ impl Runnable for QueryConnectionEndCmd { /// `cargo run --bin hermes -- query connection channels ibc-0 connection-0` #[derive(Clone, Command, Debug, Parser)] pub struct QueryConnectionChannelsCmd { - #[clap(required = true, help = "identifier of the chain to query")] + #[clap( + long = "chain", + required = true, + help = "identifier of the chain to query" + )] chain_id: ChainId, - #[clap(required = true, help = "identifier of the connection to query")] + #[clap( + long = "conn", + required = true, + help = "identifier of the connection to query" + )] connection_id: ConnectionId, } diff --git a/relayer-cli/src/commands/query/connections.rs b/relayer-cli/src/commands/query/connections.rs index 60aa94139e..f53d88a4ff 100644 --- a/relayer-cli/src/commands/query/connections.rs +++ b/relayer-cli/src/commands/query/connections.rs @@ -13,7 +13,11 @@ use crate::prelude::*; #[derive(Clone, Command, Debug, Parser)] pub struct QueryConnectionsCmd { - #[clap(required = true, help = "identifier of the chain to query")] + #[clap( + long = "chain", + required = true, + help = "identifier of the chain to query" + )] chain_id: ChainId, } diff --git a/relayer-cli/src/commands/query/packet/ack.rs b/relayer-cli/src/commands/query/packet/ack.rs index afbbd07c99..432c8254f5 100644 --- a/relayer-cli/src/commands/query/packet/ack.rs +++ b/relayer-cli/src/commands/query/packet/ack.rs @@ -14,19 +14,32 @@ use crate::prelude::*; #[derive(Clone, Command, Debug, Parser)] pub struct QueryPacketAcknowledgmentCmd { - #[clap(required = true, help = "identifier of the chain to query")] + #[clap( + long = "chain", + required = true, + help = "identifier of the chain to query" + )] chain_id: ChainId, - #[clap(required = true, help = "identifier of the port to query")] + #[clap( + short = 'p', + long = "port", + required = true, + help = "identifier of the port to query" + )] port_id: PortId, - #[clap(required = true, help = "identifier of the channel to query")] + #[clap( + long = "chan", + required = true, + help = "identifier of the channel to query" + )] channel_id: ChannelId, - #[clap(required = true, help = "sequence of packet to query")] + #[clap(long = "seq", required = true, help = "sequence of packet to query")] sequence: Sequence, - #[clap(short = 'H', long, help = "height of the state to query")] + #[clap(short = 'H', long = "height", help = "height of the state to query")] height: Option, } diff --git a/relayer-cli/src/commands/query/packet/acks.rs b/relayer-cli/src/commands/query/packet/acks.rs index d7179dc79d..8f4142c310 100644 --- a/relayer-cli/src/commands/query/packet/acks.rs +++ b/relayer-cli/src/commands/query/packet/acks.rs @@ -21,13 +21,26 @@ struct PacketSeqs { #[derive(Clone, Command, Debug, Parser)] pub struct QueryPacketAcknowledgementsCmd { - #[clap(required = true, help = "identifier of the chain to query")] + #[clap( + long = "chain", + required = true, + help = "identifier of the chain to query" + )] chain_id: ChainId, - #[clap(required = true, help = "identifier of the port to query")] + #[clap( + short = 'p', + long = "port", + required = true, + help = "identifier of the port to query" + )] port_id: PortId, - #[clap(required = true, help = "identifier of the channel to query")] + #[clap( + long = "chan", + required = true, + help = "identifier of the channel to query" + )] channel_id: ChannelId, } diff --git a/relayer-cli/src/commands/query/packet/commitment.rs b/relayer-cli/src/commands/query/packet/commitment.rs index 7910c53030..5a4c9e5cc3 100644 --- a/relayer-cli/src/commands/query/packet/commitment.rs +++ b/relayer-cli/src/commands/query/packet/commitment.rs @@ -21,19 +21,32 @@ struct PacketSeqs { #[derive(Clone, Command, Debug, Parser)] pub struct QueryPacketCommitmentCmd { - #[clap(required = true, help = "identifier of the chain to query")] + #[clap( + long = "chain", + required = true, + help = "identifier of the chain to query" + )] chain_id: ChainId, - #[clap(required = true, help = "identifier of the port to query")] + #[clap( + short = 'p', + long = "port", + required = true, + help = "identifier of the port to query" + )] port_id: PortId, - #[clap(required = true, help = "identifier of the channel to query")] + #[clap( + long = "chan", + required = true, + help = "identifier of the channel to query" + )] channel_id: ChannelId, - #[clap(required = true, help = "sequence of packet to query")] + #[clap(long = "seq", required = true, help = "sequence of packet to query")] sequence: Sequence, - #[clap(short = 'H', long, help = "height of the state to query")] + #[clap(short = 'H', long = "height", help = "height of the state to query")] height: Option, } diff --git a/relayer-cli/src/commands/query/packet/commitments.rs b/relayer-cli/src/commands/query/packet/commitments.rs index 15dfcac521..225b5fa245 100644 --- a/relayer-cli/src/commands/query/packet/commitments.rs +++ b/relayer-cli/src/commands/query/packet/commitments.rs @@ -20,13 +20,26 @@ struct PacketSeqs { #[derive(Clone, Command, Debug, Parser)] pub struct QueryPacketCommitmentsCmd { - #[clap(required = true, help = "identifier of the chain to query")] + #[clap( + long = "chain", + required = true, + help = "identifier of the chain to query" + )] chain_id: ChainId, - #[clap(required = true, help = "identifier of the port to query")] + #[clap( + short = 'p', + long = "port", + required = true, + help = "identifier of the port to query" + )] port_id: PortId, - #[clap(required = true, help = "identifier of the channel to query")] + #[clap( + long = "chan", + required = true, + help = "identifier of the channel to query" + )] channel_id: ChannelId, } diff --git a/relayer-cli/src/commands/query/packet/pending.rs b/relayer-cli/src/commands/query/packet/pending.rs index e59a7a1986..23d6e64a23 100644 --- a/relayer-cli/src/commands/query/packet/pending.rs +++ b/relayer-cli/src/commands/query/packet/pending.rs @@ -32,18 +32,22 @@ struct Summary { #[derive(Clone, Command, Debug, Parser)] pub struct QueryPendingPacketsCmd { #[clap( + long = "chain", required = true, help = "identifier of the chain at one end of the channel" )] chain_id: ChainId, #[clap( + short = 'p', + long = "port", required = true, help = "port identifier on the chain given by " )] port_id: PortId, #[clap( + long = "chan", required = true, help = "channel identifier on the chain given by " )] diff --git a/relayer-cli/src/commands/query/packet/unreceived_acks.rs b/relayer-cli/src/commands/query/packet/unreceived_acks.rs index a27ee607b3..0a88bc95b1 100644 --- a/relayer-cli/src/commands/query/packet/unreceived_acks.rs +++ b/relayer-cli/src/commands/query/packet/unreceived_acks.rs @@ -18,15 +18,16 @@ use crate::prelude::*; #[derive(Clone, Command, Debug, Parser)] pub struct QueryUnreceivedAcknowledgementCmd { #[clap( + long = "chain", required = true, help = "identifier of the chain to query the unreceived acknowledgments" )] chain_id: ChainId, - #[clap(required = true, help = "port identifier")] + #[clap(short = 'p', long = "port", required = true, help = "port identifier")] port_id: PortId, - #[clap(required = true, help = "channel identifier")] + #[clap(long = "chan", required = true, help = "channel identifier")] channel_id: ChannelId, } diff --git a/relayer-cli/src/commands/query/packet/unreceived_packets.rs b/relayer-cli/src/commands/query/packet/unreceived_packets.rs index fe027c50d7..e766e6ace6 100644 --- a/relayer-cli/src/commands/query/packet/unreceived_packets.rs +++ b/relayer-cli/src/commands/query/packet/unreceived_packets.rs @@ -18,15 +18,16 @@ use crate::prelude::*; #[derive(Clone, Command, Debug, Parser)] pub struct QueryUnreceivedPacketsCmd { #[clap( + long = "chain", required = true, help = "identifier of the chain for the unreceived sequences" )] chain_id: ChainId, - #[clap(required = true, help = "port identifier")] + #[clap(short = 'p', long = "port", required = true, help = "port identifier")] port_id: PortId, - #[clap(required = true, help = "channel identifier")] + #[clap(long = "chan", required = true, help = "channel identifier")] channel_id: ChannelId, } diff --git a/relayer-cli/src/commands/query/tx/events.rs b/relayer-cli/src/commands/query/tx/events.rs index 2004a3cef1..28aaa07b65 100644 --- a/relayer-cli/src/commands/query/tx/events.rs +++ b/relayer-cli/src/commands/query/tx/events.rs @@ -22,10 +22,14 @@ use crate::prelude::app_config; /// Query the events emitted by transaction #[derive(Clone, Command, Debug, Parser)] pub struct QueryTxEventsCmd { - #[clap(required = true, help = "identifier of the chain to query")] + #[clap( + long = "chain", + required = true, + help = "identifier of the chain to query" + )] chain_id: ChainId, - #[clap(required = true, help = "transaction hash to query")] + #[clap(long = "hash", required = true, help = "transaction hash to query")] hash: String, } diff --git a/relayer-cli/src/commands/tx/channel.rs b/relayer-cli/src/commands/tx/channel.rs index 3aa61c2fe7..5bce096f68 100644 --- a/relayer-cli/src/commands/tx/channel.rs +++ b/relayer-cli/src/commands/tx/channel.rs @@ -49,24 +49,46 @@ macro_rules! tx_chan_cmd { #[derive(Clone, Command, Debug, Parser)] pub struct TxRawChanOpenInitCmd { - #[clap(required = true, help = "identifier of the destination chain")] + #[clap( + short = 'd', + long = "dst-chain", + required = true, + help = "identifier of the destination chain" + )] dst_chain_id: ChainId, - #[clap(required = true, help = "identifier of the source chain")] + #[clap( + short = 's', + long = "src-chain", + required = true, + help = "identifier of the source chain" + )] src_chain_id: ChainId, - #[clap(required = true, help = "identifier of the destination connection")] + #[clap( + long = "dst-conn", + required = true, + help = "identifier of the destination connection" + )] dst_conn_id: ConnectionId, - #[clap(required = true, help = "identifier of the destination port")] + #[clap( + long = "dst-port", + required = true, + help = "identifier of the destination port" + )] dst_port_id: PortId, - #[clap(required = true, help = "identifier of the source port")] + #[clap( + long = "src-port", + required = true, + help = "identifier of the source port" + )] src_port_id: PortId, #[clap( - short, - long, + short = 'o', + long = "order", default_value_t, help = "the channel ordering, valid options 'unordered' (default) and 'ordered'" )] @@ -127,24 +149,45 @@ impl Runnable for TxRawChanOpenInitCmd { #[derive(Clone, Command, Debug, Parser)] pub struct TxRawChanOpenTryCmd { - #[clap(required = true, help = "identifier of the destination chain")] + #[clap( + short = 'd', + long = "dst-chain", + required = true, + help = "identifier of the destination chain" + )] dst_chain_id: ChainId, - #[clap(required = true, help = "identifier of the source chain")] + #[clap( + short = 's', + long = "src-chain", + required = true, + help = "identifier of the source chain" + )] src_chain_id: ChainId, - #[clap(required = true, help = "identifier of the destination connection")] + #[clap( + long = "dst-conn", + required = true, + help = "identifier of the destination connection" + )] dst_conn_id: ConnectionId, - #[clap(required = true, help = "identifier of the destination port")] + #[clap( + long = "dst-port", + required = true, + help = "identifier of the destination port" + )] dst_port_id: PortId, - #[clap(required = true, help = "identifier of the source port")] + #[clap( + long = "src-port", + required = true, + help = "identifier of the source port" + )] src_port_id: PortId, #[clap( - short = 's', - long, + long = "src-chan", required = true, help = "identifier of the source channel (required)", value_name = "ID" @@ -152,8 +195,7 @@ pub struct TxRawChanOpenTryCmd { src_chan_id: ChannelId, #[clap( - short = 'd', - long, + long = "dst-chan", help = "identifier of the destination channel (optional)", value_name = "ID" )] @@ -194,24 +236,45 @@ impl Runnable for TxRawChanOpenTryCmd { #[derive(Clone, Command, Debug, Parser)] pub struct TxRawChanOpenAckCmd { - #[clap(required = true, help = "identifier of the destination chain")] + #[clap( + short = 'd', + long = "dst-chain", + required = true, + help = "identifier of the destination chain" + )] dst_chain_id: ChainId, - #[clap(required = true, help = "identifier of the source chain")] + #[clap( + short = 's', + long = "src-chain", + required = true, + help = "identifier of the source chain" + )] src_chain_id: ChainId, - #[clap(required = true, help = "identifier of the destination connection")] + #[clap( + long = "dst-conn", + required = true, + help = "identifier of the destination connection" + )] dst_conn_id: ConnectionId, - #[clap(required = true, help = "identifier of the destination port")] + #[clap( + long = "dst-port", + required = true, + help = "identifier of the destination port" + )] dst_port_id: PortId, - #[clap(required = true, help = "identifier of the source port")] + #[clap( + long = "src-port", + required = true, + help = "identifier of the source port" + )] src_port_id: PortId, #[clap( - short = 'd', - long, + long = "dst-chan", required = true, help = "identifier of the destination channel (required)", value_name = "ID" @@ -219,8 +282,7 @@ pub struct TxRawChanOpenAckCmd { dst_chan_id: ChannelId, #[clap( - short = 's', - long, + long = "src-chan", required = true, help = "identifier of the source channel (required)", value_name = "ID" @@ -262,24 +324,45 @@ impl Runnable for TxRawChanOpenAckCmd { #[derive(Clone, Command, Debug, Parser)] pub struct TxRawChanOpenConfirmCmd { - #[clap(required = true, help = "identifier of the destination chain")] + #[clap( + short = 'd', + long = "dst-chain", + required = true, + help = "identifier of the destination chain" + )] dst_chain_id: ChainId, - #[clap(required = true, help = "identifier of the source chain")] + #[clap( + short = 's', + long = "src-chain", + required = true, + help = "identifier of the source chain" + )] src_chain_id: ChainId, - #[clap(required = true, help = "identifier of the destination connection")] + #[clap( + long = "dst-conn", + required = true, + help = "identifier of the destination connection" + )] dst_conn_id: ConnectionId, - #[clap(required = true, help = "identifier of the destination port")] + #[clap( + long = "dst-port", + required = true, + help = "identifier of the destination port" + )] dst_port_id: PortId, - #[clap(required = true, help = "identifier of the source port")] + #[clap( + long = "src-port", + required = true, + help = "identifier of the source port" + )] src_port_id: PortId, #[clap( - short = 'd', - long, + long = "dst-chan", required = true, help = "identifier of the destination channel (required)", value_name = "ID" @@ -287,8 +370,7 @@ pub struct TxRawChanOpenConfirmCmd { dst_chan_id: ChannelId, #[clap( - short = 's', - long, + long = "src-chan", required = true, help = "identifier of the source channel (required)", value_name = "ID" @@ -330,24 +412,45 @@ impl Runnable for TxRawChanOpenConfirmCmd { #[derive(Clone, Command, Debug, Parser)] pub struct TxRawChanCloseInitCmd { - #[clap(required = true, help = "identifier of the destination chain")] + #[clap( + short = 'd', + long = "dst-chain", + required = true, + help = "identifier of the destination chain" + )] dst_chain_id: ChainId, - #[clap(required = true, help = "identifier of the source chain")] + #[clap( + short = 's', + long = "src-chain", + required = true, + help = "identifier of the source chain" + )] src_chain_id: ChainId, - #[clap(required = true, help = "identifier of the destination connection")] + #[clap( + long = "dst-conn", + required = true, + help = "identifier of the destination connection" + )] dst_conn_id: ConnectionId, - #[clap(required = true, help = "identifier of the destination port")] + #[clap( + long = "dst-port", + required = true, + help = "identifier of the destination port" + )] dst_port_id: PortId, - #[clap(required = true, help = "identifier of the source port")] + #[clap( + long = "src-port", + required = true, + help = "identifier of the source port" + )] src_port_id: PortId, #[clap( - short = 'd', - long, + long = "dst-chan", required = true, help = "identifier of the destination channel (required)", value_name = "ID" @@ -355,8 +458,7 @@ pub struct TxRawChanCloseInitCmd { dst_chan_id: ChannelId, #[clap( - short = 's', - long, + long = "src-chan", required = true, help = "identifier of the source channel (required)", value_name = "ID" @@ -398,24 +500,45 @@ impl Runnable for TxRawChanCloseInitCmd { #[derive(Clone, Command, Debug, Parser)] pub struct TxRawChanCloseConfirmCmd { - #[clap(required = true, help = "identifier of the destination chain")] + #[clap( + short = 'd', + long = "dst-chain", + required = true, + help = "identifier of the destination chain" + )] dst_chain_id: ChainId, - #[clap(required = true, help = "identifier of the source chain")] + #[clap( + short = 's', + long = "src-chain", + required = true, + help = "identifier of the source chain" + )] src_chain_id: ChainId, - #[clap(required = true, help = "identifier of the destination connection")] + #[clap( + long = "dst-conn", + required = true, + help = "identifier of the destination connection" + )] dst_conn_id: ConnectionId, - #[clap(required = true, help = "identifier of the destination port")] + #[clap( + long = "dst-port", + required = true, + help = "identifier of the destination port" + )] dst_port_id: PortId, - #[clap(required = true, help = "identifier of the source port")] + #[clap( + long = "src-port", + required = true, + help = "identifier of the source port" + )] src_port_id: PortId, #[clap( - short = 'd', - long, + long = "dst-chan", required = true, help = "identifier of the destination channel (required)", value_name = "ID" @@ -423,8 +546,7 @@ pub struct TxRawChanCloseConfirmCmd { dst_chan_id: ChannelId, #[clap( - short = 's', - long, + long = "src-chan", required = true, help = "identifier of the source channel (required)", value_name = "ID" diff --git a/relayer-cli/src/commands/tx/client.rs b/relayer-cli/src/commands/tx/client.rs index 67b3030afe..6e1799efc2 100644 --- a/relayer-cli/src/commands/tx/client.rs +++ b/relayer-cli/src/commands/tx/client.rs @@ -21,10 +21,20 @@ use crate::error::Error; #[derive(Clone, Command, Debug, Parser)] pub struct TxCreateClientCmd { - #[clap(required = true, help = "identifier of the destination chain")] + #[clap( + short = 'd', + long = "dst-chain", + required = true, + help = "identifier of the destination chain" + )] dst_chain_id: ChainId, - #[clap(required = true, help = "identifier of the source chain")] + #[clap( + short = 's', + long = "src-chain", + required = true, + help = "identifier of the source chain" + )] src_chain_id: ChainId, /// The maximum allowed clock drift for this client. @@ -36,21 +46,21 @@ pub struct TxCreateClientCmd { /// to accept or reject a new header (originating from the source chain) for this client. /// If this option is not specified, a suitable clock drift value is derived from the chain /// configurations. - #[clap(short = 'd', long)] + #[clap(long = "clock-drift")] clock_drift: Option, /// Override the trusting period specified in the config. /// /// The trusting period specifies how long a validator set is trusted for /// (must be shorter than the chain's unbonding period). - #[clap(short = 'p', long)] + #[clap(short = 'p', long = "trusting-period")] trusting_period: Option, /// Override the trust threshold specified in the configuration. /// /// The trust threshold defines what fraction of the total voting power of a known /// and trusted validator set is sufficient for a commit to be accepted going forward. - #[clap(short = 't', long, parse(try_from_str = parse_trust_threshold))] + #[clap(short = 't', long = "trust-threshold", parse(try_from_str = parse_trust_threshold))] trust_threshold: Option, } @@ -91,19 +101,33 @@ impl Runnable for TxCreateClientCmd { #[derive(Clone, Command, Debug, Parser)] pub struct TxUpdateClientCmd { - #[clap(required = true, help = "identifier of the destination chain")] + #[clap( + short = 'd', + long = "dst-chain", + required = true, + help = "identifier of the destination chain" + )] dst_chain_id: ChainId, #[clap( + long = "dst-client", required = true, help = "identifier of the client to be updated on destination chain" )] dst_client_id: ClientId, - #[clap(short = 'H', long, help = "the target height of the client update")] + #[clap( + short = 'H', + long = "target-height", + help = "the target height of the client update" + )] target_height: Option, - #[clap(short = 't', long, help = "the trusted height of the client update")] + #[clap( + short = 't', + long = "trusted-height", + help = "the trusted height of the client update" + )] trusted_height: Option, } @@ -162,12 +186,17 @@ impl Runnable for TxUpdateClientCmd { #[derive(Clone, Command, Debug, Parser)] pub struct TxUpgradeClientCmd { #[clap( + long = "chain", required = true, help = "identifier of the chain that hosts the client" )] chain_id: ChainId, - #[clap(required = true, help = "identifier of the client to be upgraded")] + #[clap( + long = "client", + required = true, + help = "identifier of the client to be upgraded" + )] client_id: ClientId, } @@ -214,6 +243,8 @@ impl Runnable for TxUpgradeClientCmd { #[derive(Clone, Command, Debug, Parser)] pub struct TxUpgradeClientsCmd { #[clap( + short = 's', + long = "src-chain", required = true, help = "identifier of the chain that underwent an upgrade; all clients targeting this chain will be upgraded" )] diff --git a/relayer-cli/src/commands/tx/connection.rs b/relayer-cli/src/commands/tx/connection.rs index dc48202400..477ff1c3a0 100644 --- a/relayer-cli/src/commands/tx/connection.rs +++ b/relayer-cli/src/commands/tx/connection.rs @@ -36,16 +36,34 @@ macro_rules! conn_open_cmd { #[derive(Clone, Command, Debug, Parser)] pub struct TxRawConnInitCmd { - #[clap(required = true, help = "identifier of the destination chain")] + #[clap( + short = 'd', + long = "dst-chain", + required = true, + help = "identifier of the destination chain" + )] dst_chain_id: ChainId, - #[clap(required = true, help = "identifier of the source chain")] + #[clap( + short = 's', + long = "src-chain", + required = true, + help = "identifier of the source chain" + )] src_chain_id: ChainId, - #[clap(required = true, help = "identifier of the destination client")] + #[clap( + long = "dst-client", + required = true, + help = "identifier of the destination client" + )] dst_client_id: ClientId, - #[clap(required = true, help = "identifier of the source client")] + #[clap( + long = "src-client", + required = true, + help = "identifier of the source client" + )] src_client_id: ClientId, } @@ -68,21 +86,39 @@ impl Runnable for TxRawConnInitCmd { #[derive(Clone, Command, Debug, Parser)] pub struct TxRawConnTryCmd { - #[clap(required = true, help = "identifier of the destination chain")] + #[clap( + short = 'd', + long = "dst-chain", + required = true, + help = "identifier of the destination chain" + )] dst_chain_id: ChainId, - #[clap(required = true, help = "identifier of the source chain")] + #[clap( + short = 's', + long = "src-chain", + required = true, + help = "identifier of the source chain" + )] src_chain_id: ChainId, - #[clap(required = true, help = "identifier of the destination client")] + #[clap( + long = "dst-client", + required = true, + help = "identifier of the destination client" + )] dst_client_id: ClientId, - #[clap(required = true, help = "identifier of the source client")] + #[clap( + long = "src-client", + required = true, + help = "identifier of the source client" + )] src_client_id: ClientId, #[clap( short = 's', - long, + long = "src-conn", required = true, help = "identifier of the source connection (required)", value_name = "ID" @@ -90,8 +126,7 @@ pub struct TxRawConnTryCmd { src_conn_id: ConnectionId, #[clap( - short = 'd', - long, + long = "dst-conn", help = "identifier of the destination connection (optional)", value_name = "ID" )] @@ -125,21 +160,38 @@ impl Runnable for TxRawConnTryCmd { #[derive(Clone, Command, Debug, Parser)] pub struct TxRawConnAckCmd { - #[clap(required = true, help = "identifier of the destination chain")] + #[clap( + short = 'd', + long = "dst-chain", + required = true, + help = "identifier of the destination chain" + )] dst_chain_id: ChainId, - #[clap(required = true, help = "identifier of the source chain")] + #[clap( + short = 's', + long = "src-chain", + required = true, + help = "identifier of the source chain" + )] src_chain_id: ChainId, - #[clap(required = true, help = "identifier of the destination client")] + #[clap( + long = "dst-client", + required = true, + help = "identifier of the destination client" + )] dst_client_id: ClientId, - #[clap(required = true, help = "identifier of the source client")] + #[clap( + long = "src-client", + required = true, + help = "identifier of the source client" + )] src_client_id: ClientId, #[clap( - short = 'd', - long, + long = "dst-conn", required = true, help = "identifier of the destination connection (required)", value_name = "ID" @@ -147,8 +199,7 @@ pub struct TxRawConnAckCmd { dst_conn_id: ConnectionId, #[clap( - short = 's', - long, + long = "src-conn", required = true, help = "identifier of the source connection (required)", value_name = "ID" @@ -183,21 +234,38 @@ impl Runnable for TxRawConnAckCmd { #[derive(Clone, Command, Debug, Parser)] pub struct TxRawConnConfirmCmd { - #[clap(required = true, help = "identifier of the destination chain")] + #[clap( + short = 'd', + long = "dst-chain", + required = true, + help = "identifier of the destination chain" + )] dst_chain_id: ChainId, - #[clap(required = true, help = "identifier of the source chain")] + #[clap( + short = 's', + long = "src-chain", + required = true, + help = "identifier of the source chain" + )] src_chain_id: ChainId, - #[clap(required = true, help = "identifier of the destination client")] + #[clap( + long = "dst-client", + required = true, + help = "identifier of the destination client" + )] dst_client_id: ClientId, - #[clap(required = true, help = "identifier of the source client")] + #[clap( + long = "src-client", + required = true, + help = "identifier of the source client" + )] src_client_id: ClientId, #[clap( - short = 'd', - long, + long = "dst-conn", required = true, help = "identifier of the destination connection (required)", value_name = "ID" @@ -205,8 +273,7 @@ pub struct TxRawConnConfirmCmd { dst_conn_id: ConnectionId, #[clap( - short = 's', - long, + long = "src-conn", required = true, help = "identifier of the source connection (required)", value_name = "ID" diff --git a/relayer-cli/src/commands/tx/packet.rs b/relayer-cli/src/commands/tx/packet.rs index 607703b4f6..674ca0d6ac 100644 --- a/relayer-cli/src/commands/tx/packet.rs +++ b/relayer-cli/src/commands/tx/packet.rs @@ -12,16 +12,34 @@ use crate::prelude::*; #[derive(Clone, Command, Debug, Parser)] pub struct TxRawPacketRecvCmd { - #[clap(required = true, help = "identifier of the destination chain")] + #[clap( + short = 'd', + long = "dst-chain", + required = true, + help = "identifier of the destination chain" + )] dst_chain_id: ChainId, - #[clap(required = true, help = "identifier of the source chain")] + #[clap( + short = 's', + long = "src-chain", + required = true, + help = "identifier of the source chain" + )] src_chain_id: ChainId, - #[clap(required = true, help = "identifier of the source port")] + #[clap( + long = "src-port", + required = true, + help = "identifier of the source port" + )] src_port_id: PortId, - #[clap(required = true, help = "identifier of the source channel")] + #[clap( + long = "src-chan", + required = true, + help = "identifier of the source channel" + )] src_channel_id: ChannelId, } @@ -56,16 +74,34 @@ impl Runnable for TxRawPacketRecvCmd { #[derive(Clone, Command, Debug, Parser)] pub struct TxRawPacketAckCmd { - #[clap(required = true, help = "identifier of the destination chain")] + #[clap( + short = 'd', + long = "dst-chain", + required = true, + help = "identifier of the destination chain" + )] dst_chain_id: ChainId, - #[clap(required = true, help = "identifier of the source chain")] + #[clap( + short = 's', + long = "src-chain", + required = true, + help = "identifier of the source chain" + )] src_chain_id: ChainId, - #[clap(required = true, help = "identifier of the source port")] + #[clap( + long = "src-port", + required = true, + help = "identifier of the source port" + )] src_port_id: PortId, - #[clap(required = true, help = "identifier of the source channel")] + #[clap( + long = "src-chan", + required = true, + help = "identifier of the source channel" + )] src_channel_id: ChannelId, } diff --git a/relayer-cli/src/commands/tx/transfer.rs b/relayer-cli/src/commands/tx/transfer.rs index 860a7c51e2..8452127403 100644 --- a/relayer-cli/src/commands/tx/transfer.rs +++ b/relayer-cli/src/commands/tx/transfer.rs @@ -27,19 +27,39 @@ use crate::prelude::*; #[derive(Clone, Command, Debug, Parser)] pub struct TxIcs20MsgTransferCmd { - #[clap(required = true, help = "identifier of the destination chain")] + #[clap( + short = 'd', + long = "dst-chain", + required = true, + help = "identifier of the destination chain" + )] dst_chain_id: ChainId, - #[clap(required = true, help = "identifier of the source chain")] + #[clap( + short = 's', + long = "src-chain", + required = true, + help = "identifier of the source chain" + )] src_chain_id: ChainId, - #[clap(required = true, help = "identifier of the source port")] + #[clap( + long = "src-port", + required = true, + help = "identifier of the source port" + )] src_port_id: PortId, - #[clap(required = true, help = "identifier of the source channel")] + #[clap( + long = "src-chan", + required = true, + help = "identifier of the source channel" + )] src_channel_id: ChannelId, #[clap( + short = 'a', + long = "amount", required = true, help = "amount of coins (samoleans, by default) to send (e.g. `100000`)" )] @@ -47,7 +67,7 @@ pub struct TxIcs20MsgTransferCmd { #[clap( short = 'o', - long, + long = "timeout-height-offset", default_value = "0", help = "timeout in number of blocks since current" )] @@ -55,7 +75,7 @@ pub struct TxIcs20MsgTransferCmd { #[clap( short = 't', - long, + long = "timeout-seconds", default_value = "0", help = "timeout in seconds since current" )] @@ -63,28 +83,27 @@ pub struct TxIcs20MsgTransferCmd { #[clap( short = 'r', - long, + long = "receiver", help = "receiving account address on the destination chain" )] receiver: Option, #[clap( - short = 'd', - long, + long = "denom", help = "denomination of the coins to send", default_value = "samoleans" )] denom: String, - #[clap(short = 'n', long, help = "number of messages to send")] + #[clap(short = 'n', long = "number-msgs", help = "number of messages to send")] number_msgs: Option, #[clap( short = 'k', - long, - help = "use the given signing key (default: `key_name` config)" + long = "key-name", + help = "use the given signing key name (default: `key_name` config)" )] - key: Option, + key_name: Option, } impl Override for TxIcs20MsgTransferCmd { @@ -96,7 +115,7 @@ impl Override for TxIcs20MsgTransferCmd { )) })?; - if let Some(ref key_name) = self.key { + if let Some(ref key_name) = self.key_name { src_chain_config.key_name = key_name.to_string(); } diff --git a/relayer-cli/src/commands/tx/upgrade.rs b/relayer-cli/src/commands/tx/upgrade.rs index da2fa15139..18c163e6fa 100644 --- a/relayer-cli/src/commands/tx/upgrade.rs +++ b/relayer-cli/src/commands/tx/upgrade.rs @@ -18,30 +18,47 @@ use crate::prelude::*; #[derive(Clone, Command, Debug, Parser)] pub struct TxIbcUpgradeChainCmd { - #[clap(required = true, help = "identifier of the chain to upgrade")] + #[clap( + short = 'd', + long = "dst-chain", + required = true, + help = "identifier of the chain to upgrade" + )] dst_chain_id: ChainId, - #[clap(required = true, help = "identifier of the source chain")] + #[clap( + short = 's', + long = "src-chain", + required = true, + help = "identifier of the source chain" + )] src_chain_id: ChainId, #[clap( + long = "src-client", required = true, help = "identifier of the client on source chain from which the plan is created" )] src_client_id: ClientId, - #[clap(required = true, help = "amount of stake")] + #[clap( + short = 'a', + long = "amount", + required = true, + help = "amount of stake" + )] amount: u64, #[clap( + short = 'H', + long = "height-offset", required = true, help = "upgrade height offset in number of blocks since current" )] height_offset: u64, #[clap( - short = 'c', - long, + long = "new-chain", value_name = "CHAIN-ID", help = "new chain identifier to assign to the upgrading chain (optional)" )] @@ -49,7 +66,7 @@ pub struct TxIbcUpgradeChainCmd { #[clap( short = 'u', - long, + long = "new-unbonding", value_name = "PERIOD", help = "new unbonding period to assign to the upgrading chain, in seconds (optional)" )] @@ -57,15 +74,14 @@ pub struct TxIbcUpgradeChainCmd { #[clap( short = 'n', - long, + long = "upgrade-name", value_name = "NAME", help = "a string to name the upgrade proposal plan (default: 'plan')" )] upgrade_name: Option, #[clap( - short = 'd', - long, + long = "denom", help = "denomination for the deposit (default: 'stake')" )] denom: Option, diff --git a/relayer-cli/src/entry.rs b/relayer-cli/src/entry.rs index 312d43dfe2..c8198c9ed5 100644 --- a/relayer-cli/src/entry.rs +++ b/relayer-cli/src/entry.rs @@ -13,11 +13,11 @@ use crate::commands::CliCmd; #[clap(author, about, version)] pub struct EntryPoint { /// Path to the configuration file - #[clap(short = 'c', long, help = "path to configuration file")] + #[clap(short = 'c', long = "config", help = "path to configuration file")] pub config: Option, /// Toggle JSON output mode one verbosity setting - #[clap(short = 'j', long, help = "enable JSON output")] + #[clap(short = 'j', long = "json", help = "enable JSON output")] pub json: bool, /// Subcommand to execute. From 21580d309f6627e9bfcd4da797d9ec539f74a810 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Tue, 7 Jun 2022 11:55:45 +0200 Subject: [PATCH 02/27] Updated gm to use flags when calling Hermes --- relayer-cli/src/commands/keys/add.rs | 2 +- scripts/gm/bin/lib-gm | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/relayer-cli/src/commands/keys/add.rs b/relayer-cli/src/commands/keys/add.rs index 86e8293e02..279fd08edc 100644 --- a/relayer-cli/src/commands/keys/add.rs +++ b/relayer-cli/src/commands/keys/add.rs @@ -32,7 +32,7 @@ use crate::conclude::Output; /// If successful the key will be created or restored, depending on which flag was given. #[derive(Clone, Command, Debug, Parser)] pub struct KeysAddCmd { - #[clap(required = true, help = "identifier of the chain")] + #[clap(long = "chain", required = true, help = "identifier of the chain")] chain_id: ChainId, #[clap( diff --git a/scripts/gm/bin/lib-gm b/scripts/gm/bin/lib-gm index d1d637b77c..a2a2266a2c 100644 --- a/scripts/gm/bin/lib-gm +++ b/scripts/gm/bin/lib-gm @@ -1011,25 +1011,25 @@ hermes_keys() { HERMES_BINARY="$(get_hermes_binary)" HDPATH="$(get_hdpath "$1")" if [ -z "$GLOBAL_HERMES_CONFIG" ] && [ -z "$HDPATH" ]; then - "$HERMES_BINARY" keys add "$ID" -f "${NETWORK_HOME_DIR}/wallet_seed.json" + "$HERMES_BINARY" keys add --chain "$ID" --key-file "${NETWORK_HOME_DIR}/wallet_seed.json" elif [ -n "$GLOBAL_HERMES_CONFIG" ] && [ -z "$HDPATH" ]; then - "$HERMES_BINARY" -c "$GLOBAL_HERMES_CONFIG" keys add "$ID" -f "${NETWORK_HOME_DIR}/wallet_seed.json" + "$HERMES_BINARY" --config "$GLOBAL_HERMES_CONFIG" keys add --chain "$ID" --key-file "${NETWORK_HOME_DIR}/wallet_seed.json" elif [ -z "$GLOBAL_HERMES_CONFIG" ] && [ -n "$HDPATH" ]; then - "$HERMES_BINARY" keys add "$ID" --hd-path "$HDPATH" -f "${NETWORK_HOME_DIR}/wallet_seed.json" + "$HERMES_BINARY" keys add --chain "$ID" --hd-path "$HDPATH" --key-file "${NETWORK_HOME_DIR}/wallet_seed.json" elif [ -n "$GLOBAL_HERMES_CONFIG" ] && [ -n "$HDPATH" ]; then - "$HERMES_BINARY" -c "$GLOBAL_HERMES_CONFIG" keys add "$ID" --hd-path "$HDPATH" -f "${NETWORK_HOME_DIR}/wallet_seed.json" + "$HERMES_BINARY" --config "$GLOBAL_HERMES_CONFIG" keys add --chain "$ID" --hd-path "$HDPATH" --key-file "${NETWORK_HOME_DIR}/wallet_seed.json" fi EXTRA_WALLETS_COUNTER="$(get_extra_wallets "$1")" while [ "$EXTRA_WALLETS_COUNTER" -gt 0 ]; do if [ -z "$GLOBAL_HERMES_CONFIG" ] && [ -z "$HDPATH" ]; then - "$HERMES_BINARY" keys add "$ID" --key-name "wallet${EXTRA_WALLETS_COUNTER}" -f "${NETWORK_HOME_DIR}/wallet${EXTRA_WALLETS_COUNTER}_seed.json" + "$HERMES_BINARY" keys add --chain "$ID" --key-name "wallet${EXTRA_WALLETS_COUNTER}" --key-file "${NETWORK_HOME_DIR}/wallet${EXTRA_WALLETS_COUNTER}_seed.json" elif [ -n "$GLOBAL_HERMES_CONFIG" ] && [ -z "$HDPATH" ]; then - "$HERMES_BINARY" -c "$GLOBAL_HERMES_CONFIG" keys add "$ID" --key-name "wallet${EXTRA_WALLETS_COUNTER}" -f "${NETWORK_HOME_DIR}/wallet${EXTRA_WALLETS_COUNTER}_seed.json" + "$HERMES_BINARY" --config "$GLOBAL_HERMES_CONFIG" keys add --chain "$ID" --key-name "wallet${EXTRA_WALLETS_COUNTER}" --key-file "${NETWORK_HOME_DIR}/wallet${EXTRA_WALLETS_COUNTER}_seed.json" elif [ -z "$GLOBAL_HERMES_CONFIG" ] && [ -n "$HDPATH" ]; then - "$HERMES_BINARY" keys add "$ID" --hd-path "$HDPATH" --key-name "wallet${EXTRA_WALLETS_COUNTER}" -f "${NETWORK_HOME_DIR}/wallet${EXTRA_WALLETS_COUNTER}_seed.json" + "$HERMES_BINARY" keys add --chain "$ID" --hd-path "$HDPATH" --key-name "wallet${EXTRA_WALLETS_COUNTER}" --key-file "${NETWORK_HOME_DIR}/wallet${EXTRA_WALLETS_COUNTER}_seed.json" elif [ -n "$GLOBAL_HERMES_CONFIG" ] && [ -n "$HDPATH" ]; then - "$HERMES_BINARY" -c "$GLOBAL_HERMES_CONFIG" keys add "$ID" --hd-path "$HDPATH" --key-name "wallet${EXTRA_WALLETS_COUNTER}" -f "${NETWORK_HOME_DIR}/wallet${EXTRA_WALLETS_COUNTER}_seed.json" + "$HERMES_BINARY" --config "$GLOBAL_HERMES_CONFIG" keys add --chain "$ID" --hd-path "$HDPATH" --key-name "wallet${EXTRA_WALLETS_COUNTER}" --key-file "${NETWORK_HOME_DIR}/wallet${EXTRA_WALLETS_COUNTER}_seed.json" fi EXTRA_WALLETS_COUNTER="$((EXTRA_WALLETS_COUNTER - 1))" done @@ -1051,7 +1051,7 @@ hermes_cc() { do for j in $(seq $((i+1)) $N) do - echo "\"${HERMES_BINARY}\" create channel $(n_from_a "$i" "$CHAINS") $(n_from_a "$j" "$CHAINS") --port-a transfer --port-b transfer" + echo "\"${HERMES_BINARY}\" create channel --chain-a $(n_from_a "$i" "$CHAINS") --chain-b $(n_from_a "$j" "$CHAINS") --port-a transfer --port-b transfer" done done } From 09c157f4c36bfa1a0a22f9fe3075a1bce08ba73b Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Tue, 7 Jun 2022 12:41:10 +0200 Subject: [PATCH 03/27] Added missing flags to e2e test for 'query client state' command --- e2e/e2e/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/e2e/client.py b/e2e/e2e/client.py index 5f6423dc11..7e958226e5 100644 --- a/e2e/e2e/client.py +++ b/e2e/e2e/client.py @@ -86,7 +86,7 @@ def args(self) -> List[str]: if self.proof: args.append('--proof') - args.extend([self.chain_id, self.client_id]) + args.extend(["--chain", self.chain_id, "--client", self.client_id]) return args From 612a707c63909a19f92346726e680435452e2857 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Tue, 7 Jun 2022 13:14:25 +0200 Subject: [PATCH 04/27] Fixed flag errors in e2e tests and removed conflicting short flag. --- e2e/e2e/channel.py | 8 ++++---- e2e/e2e/connection.py | 2 +- relayer-cli/src/commands/tx/connection.rs | 1 - 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/e2e/e2e/channel.py b/e2e/e2e/channel.py index fba0eb16ec..5abd1df205 100644 --- a/e2e/e2e/channel.py +++ b/e2e/e2e/channel.py @@ -28,7 +28,7 @@ class TxChanOpenInit(Cmd[TxChanOpenInitRes]): def args(self) -> List[str]: args = ["--dst-chain", self.dst_chain_id, "--src-chain", self.src_chain_id, - "--conn", self.connection_id, + "--dst-conn", self.connection_id, "--dst-port", self.dst_port_id, "--src-port", self.src_port_id] if self.ordering is not None: @@ -66,7 +66,7 @@ class TxChanOpenTry(Cmd[TxChanOpenTryRes]): def args(self) -> List[str]: args = ["--dst-chain", self.dst_chain_id, "--src-chain", self.src_chain_id, - "--conn", self.connection_id, + "--dst-conn", self.connection_id, "--dst-port", self.dst_port_id, "--src-port", self.src_port_id, "--src-chan", self.src_channel_id] @@ -105,7 +105,7 @@ class TxChanOpenAck(Cmd[TxChanOpenAckRes]): def args(self) -> List[str]: args = ["--dst-chain", self.dst_chain_id, "--src-chain", self.src_chain_id, - "--conn", self.connection_id, + "--dst-conn", self.connection_id, "--dst-port", self.dst_port_id, "--src-port", self.src_port_id, "--dst-chan", self.dst_channel_id, "--src-chan", self.src_channel_id] @@ -142,7 +142,7 @@ class TxChanOpenConfirm(Cmd[TxChanOpenConfirmRes]): def args(self) -> List[str]: args = ["--dst-chain", self.dst_chain_id, "--src-chain", self.src_chain_id, - "--conn", self.connection_id, + "--dst-conn", self.connection_id, "--dst-port", self.dst_port_id, "--src-port", self.src_port_id, "--dst-chan", self.dst_channel_id, "--src-chan", self.src_channel_id] diff --git a/e2e/e2e/connection.py b/e2e/e2e/connection.py index 9404fb81c9..bfd15e1ef7 100644 --- a/e2e/e2e/connection.py +++ b/e2e/e2e/connection.py @@ -46,7 +46,7 @@ class TxConnTry(Cmd[TxConnTryRes]): src_conn_id: ConnectionId def args(self) -> List[str]: - return ["dst-chain", self.dst_chain_id, "--src-chain", self.src_chain_id, + return ["--dst-chain", self.dst_chain_id, "--src-chain", self.src_chain_id, "--dst-client", self.dst_client_id, "--src-client", self.src_client_id, "--src-conn", self.src_conn_id] diff --git a/relayer-cli/src/commands/tx/connection.rs b/relayer-cli/src/commands/tx/connection.rs index 477ff1c3a0..983d94124d 100644 --- a/relayer-cli/src/commands/tx/connection.rs +++ b/relayer-cli/src/commands/tx/connection.rs @@ -117,7 +117,6 @@ pub struct TxRawConnTryCmd { src_client_id: ClientId, #[clap( - short = 's', long = "src-conn", required = true, help = "identifier of the source connection (required)", From 88474db7e7a2957f9ab0f3b5273f82ec3b2ee544 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Wed, 8 Jun 2022 10:00:05 +0200 Subject: [PATCH 05/27] Removed all short flags and updated CLI commands comments --- relayer-cli/src/commands/clear.rs | 7 +---- relayer-cli/src/commands/create/channel.rs | 11 ++++---- relayer-cli/src/commands/create/connection.rs | 6 ++-- relayer-cli/src/commands/keys/add.rs | 10 ++----- relayer-cli/src/commands/keys/balance.rs | 3 +- relayer-cli/src/commands/keys/delete.rs | 4 +-- relayer-cli/src/commands/listen.rs | 3 +- relayer-cli/src/commands/query/channel.rs | 3 +- .../src/commands/query/channel_client.rs | 3 +- .../src/commands/query/channel_ends.rs | 3 +- relayer-cli/src/commands/query/channels.rs | 2 -- relayer-cli/src/commands/query/client.rs | 28 +++++-------------- relayer-cli/src/commands/query/clients.rs | 4 +-- relayer-cli/src/commands/query/connection.rs | 4 +-- relayer-cli/src/commands/query/packet/ack.rs | 3 +- relayer-cli/src/commands/query/packet/acks.rs | 3 +- .../src/commands/query/packet/commitment.rs | 3 +- .../src/commands/query/packet/commitments.rs | 3 +- .../src/commands/query/packet/pending.rs | 1 - .../commands/query/packet/unreceived_acks.rs | 2 +- .../query/packet/unreceived_packets.rs | 2 +- relayer-cli/src/commands/query/tx/events.rs | 2 +- relayer-cli/src/commands/start.rs | 1 - relayer-cli/src/commands/tx/channel.rs | 2 -- relayer-cli/src/commands/tx/client.rs | 4 +-- relayer-cli/src/commands/tx/transfer.rs | 9 +----- relayer-cli/src/commands/tx/upgrade.rs | 12 +------- relayer-cli/src/conclude.rs | 2 +- relayer-cli/src/entry.rs | 6 ++-- 29 files changed, 45 insertions(+), 101 deletions(-) diff --git a/relayer-cli/src/commands/clear.rs b/relayer-cli/src/commands/clear.rs index f7abd8f930..cbfd9fa805 100644 --- a/relayer-cli/src/commands/clear.rs +++ b/relayer-cli/src/commands/clear.rs @@ -26,12 +26,7 @@ pub struct ClearPacketsCmd { #[clap(long = "chain", required = true, help = "identifier of the chain")] chain_id: ChainId, - #[clap( - short = 'p', - long = "port", - required = true, - help = "identifier of the port" - )] + #[clap(long = "port", required = true, help = "identifier of the port")] port_id: PortId, #[clap(long = "chan", required = true, help = "identifier of the channel")] diff --git a/relayer-cli/src/commands/create/channel.rs b/relayer-cli/src/commands/create/channel.rs index 0288f61c04..8078acbf21 100644 --- a/relayer-cli/src/commands/create/channel.rs +++ b/relayer-cli/src/commands/create/channel.rs @@ -29,11 +29,11 @@ static HINT: &str = "Consider using the default invocation\n\nhermes create chan /// /// There are two possible ways to invoke this command: /// -/// `create channel --port-a --port-b ` is the default +/// `create channel --chain-a --conn-a --port-a --port-b ` is the default /// way in which this command should be used, specifying a `Connection-ID` for this new channel /// to re-use. The command expects that `Connection-ID` is associated with chain A. /// -/// `create channel --port-a --port-b --new-client-connection` +/// `create channel --chain-a --chain-b --port-a --port-b --new-client-conn` /// to indicate that a new connection/client pair is being created as part of this new channel. /// This brings up an interactive yes/no prompt to ensure that the operator at least /// considers the fact that they're initializing a new connection with the channel. @@ -57,7 +57,10 @@ pub struct CreateChannelCommand { )] chain_b: Option, - /// Identifier of the connection on chain `a` to use in creating the new channel. + #[clap( + long = "conn-a", + help = "Identifier of the connection on chain `a` to use in creating the new channel." + )] connection_a: Option, #[clap( @@ -75,7 +78,6 @@ pub struct CreateChannelCommand { port_b: PortId, #[clap( - short = 'o', long = "order", help = "The channel ordering, valid options 'unordered' (default) and 'ordered'", default_value_t @@ -83,7 +85,6 @@ pub struct CreateChannelCommand { order: Order, #[clap( - short = 'v', long = "chan-version", alias = "version", help = "The version for the new channel" diff --git a/relayer-cli/src/commands/create/connection.rs b/relayer-cli/src/commands/create/connection.rs index 90c290373a..5ae51fc90b 100644 --- a/relayer-cli/src/commands/create/connection.rs +++ b/relayer-cli/src/commands/create/connection.rs @@ -50,9 +50,9 @@ pub struct CreateConnectionCommand { delay: u64, } -// cargo run --bin hermes -- create connection ibc-0 ibc-1 -// cargo run --bin hermes -- create connection ibc-0 ibc-1 --delay 100 -// cargo run --bin hermes -- create connection ibc-0 --client-a-id 07-tendermint-0 --client-b-id 07-tendermint-0 +// cargo run --bin hermes -- create connection --chain-a ibc-0 --chain-b ibc-1 +// cargo run --bin hermes -- create connection --chain-a ibc-0 --chain-b ibc-1 --delay 100 +// cargo run --bin hermes -- create connection --chain-a ibc-0 --client-a 07-tendermint-0 --client-b 07-tendermint-0 impl Runnable for CreateConnectionCommand { fn run(&self) { match &self.chain_b_id { diff --git a/relayer-cli/src/commands/keys/add.rs b/relayer-cli/src/commands/keys/add.rs index 279fd08edc..f9139a618e 100644 --- a/relayer-cli/src/commands/keys/add.rs +++ b/relayer-cli/src/commands/keys/add.rs @@ -22,11 +22,11 @@ use crate::conclude::Output; /// /// The command to add a key from a file: /// -/// `keys add [OPTIONS] --key-file ` +/// `keys add [OPTIONS] --chain --key-file ` /// /// The command to restore a key from a file containing mnemonic: /// -/// `keys add [OPTIONS] --mnemonic-file ` +/// `keys add [OPTIONS] --chain --mnemonic-file ` /// /// The key-file and mnemonic-file flags can't be given at the same time, this will cause a terminating error. /// If successful the key will be created or restored, depending on which flag was given. @@ -36,7 +36,6 @@ pub struct KeysAddCmd { chain_id: ChainId, #[clap( - short = 'f', long = "key-file", required = true, help = "path to the key file", @@ -45,7 +44,6 @@ pub struct KeysAddCmd { key_file: Option, #[clap( - short = 'm', long = "mnemonic-file", required = true, help = "path to file containing mnemonic to restore the key from", @@ -54,14 +52,12 @@ pub struct KeysAddCmd { mnemonic_file: Option, #[clap( - short = 'k', long = "key-name", help = "name of the key (defaults to the `key_name` defined in the config)" )] key_name: Option, #[clap( - short = 'p', long = "hd-path", help = "derivation path for this key", default_value = "m/44'/118'/0'/0/0" @@ -107,7 +103,7 @@ impl Runnable for KeysAddCmd { Ok(result) => result, }; - // Check if --file or --mnemonic was given as input. + // Check if --key-file or --mnemonic-file was given as input. match (self.key_file.clone(), self.mnemonic_file.clone()) { (Some(key_file), _) => { let key = add_key(&opts.config, &opts.name, &key_file, &opts.hd_path); diff --git a/relayer-cli/src/commands/keys/balance.rs b/relayer-cli/src/commands/keys/balance.rs index 137fa401c0..9008536473 100644 --- a/relayer-cli/src/commands/keys/balance.rs +++ b/relayer-cli/src/commands/keys/balance.rs @@ -12,7 +12,7 @@ use crate::conclude::{exit_with_unrecoverable_error, json, Output}; /// /// The command has one argument and one optional flag: /// -/// `keys balance --key-name ` +/// `keys balance --chain --key-name ` /// /// If no key name is given, it will be taken from the configuration file. /// If successful the balance and denominator of the account, associated with the key name @@ -23,7 +23,6 @@ pub struct KeyBalanceCmd { chain_id: ChainId, #[clap( - short = 'k', long = "key-name", help = "(optional) name of the key (defaults to the `key_name` defined in the config)" )] diff --git a/relayer-cli/src/commands/keys/delete.rs b/relayer-cli/src/commands/keys/delete.rs index efb6756c0e..3873f7c1e1 100644 --- a/relayer-cli/src/commands/keys/delete.rs +++ b/relayer-cli/src/commands/keys/delete.rs @@ -15,10 +15,10 @@ pub struct KeysDeleteCmd { #[clap(long = "chain", required = true, help = "identifier of the chain")] chain_id: ChainId, - #[clap(short = 'k', long = "key-name", help = "name of the key")] + #[clap(long = "key-name", help = "name of the key")] key_name: Option, - #[clap(short = 'a', long = "all", help = "delete all keys")] + #[clap(long = "all", help = "delete all keys")] all: bool, } diff --git a/relayer-cli/src/commands/listen.rs b/relayer-cli/src/commands/listen.rs index 9a5c448116..a646b28e5f 100644 --- a/relayer-cli/src/commands/listen.rs +++ b/relayer-cli/src/commands/listen.rs @@ -61,11 +61,12 @@ impl FromStr for EventFilter { #[derive(Debug, Parser)] pub struct ListenCmd { /// Identifier of the chain to listen for events from + #[clap(long = "chain", required = true)] chain_id: ChainId, /// Add an event type to listen for, can be repeated. /// Listen for all events by default (available: Tx, NewBlock). - #[clap(short = 'e', long = "event", value_name = "EVENT")] + #[clap(long = "event", value_name = "EVENT")] events: Vec, } diff --git a/relayer-cli/src/commands/query/channel.rs b/relayer-cli/src/commands/query/channel.rs index 107af9ee51..1500b53746 100644 --- a/relayer-cli/src/commands/query/channel.rs +++ b/relayer-cli/src/commands/query/channel.rs @@ -23,7 +23,6 @@ pub struct QueryChannelEndCmd { chain_id: ChainId, #[clap( - short = 'p', long = "port", required = true, help = "identifier of the port to query" @@ -37,7 +36,7 @@ pub struct QueryChannelEndCmd { )] channel_id: ChannelId, - #[clap(short = 'H', long = "height", help = "height of the state to query")] + #[clap(long = "height", help = "height of the state to query")] height: Option, } diff --git a/relayer-cli/src/commands/query/channel_client.rs b/relayer-cli/src/commands/query/channel_client.rs index eafe56d825..88341cb383 100644 --- a/relayer-cli/src/commands/query/channel_client.rs +++ b/relayer-cli/src/commands/query/channel_client.rs @@ -11,7 +11,7 @@ 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 --channel-id ` +/// `query channel client --chain --port --chan ` /// /// If successful the channel's client state is displayed. #[derive(Clone, Command, Debug, Parser)] @@ -24,7 +24,6 @@ pub struct QueryChannelClientCmd { chain_id: ChainId, #[clap( - short = 'p', long = "port", required = true, help = "identifier of the port to query" diff --git a/relayer-cli/src/commands/query/channel_ends.rs b/relayer-cli/src/commands/query/channel_ends.rs index 7828948595..fa3f9c87d9 100644 --- a/relayer-cli/src/commands/query/channel_ends.rs +++ b/relayer-cli/src/commands/query/channel_ends.rs @@ -40,11 +40,10 @@ pub struct QueryChannelEndsCmd { )] channel_id: ChannelId, - #[clap(short = 'H', long = "height", help = "height of the state to query")] + #[clap(long = "height", help = "height of the state to query")] height: Option, #[clap( - short = 'v', long = "verbose", help = "enable verbose output, displaying all details of channels, connections & clients" )] diff --git a/relayer-cli/src/commands/query/channels.rs b/relayer-cli/src/commands/query/channels.rs index 80e50093d5..3603c490c6 100644 --- a/relayer-cli/src/commands/query/channels.rs +++ b/relayer-cli/src/commands/query/channels.rs @@ -29,14 +29,12 @@ pub struct QueryChannelsCmd { chain_id: ChainId, #[clap( - short = 'd', long = "dst-chain", help = "identifier of the channel's destination chain" )] dst_chain_id: Option, #[clap( - short = 'v', long = "verbose", help = "enable verbose output, displaying all client and connection ids" )] diff --git a/relayer-cli/src/commands/query/client.rs b/relayer-cli/src/commands/query/client.rs index e3d5e4eaf9..2f93ac0cd2 100644 --- a/relayer-cli/src/commands/query/client.rs +++ b/relayer-cli/src/commands/query/client.rs @@ -39,16 +39,12 @@ pub struct QueryClientStateCmd { )] client_id: ClientId, - #[clap( - short = 'H', - long = "height", - help = "the chain height context for the query" - )] + #[clap(long = "height", help = "the chain height context for the query")] height: Option, } /// Command for querying a client's state. -/// hermes query client state ibc-1 07-tendermint-0 --height 3 +/// hermes query client state --chain ibc-1 --client 07-tendermint-0 --height 3 impl Runnable for QueryClientStateCmd { fn run(&self) { let config = app_config(); @@ -100,15 +96,10 @@ pub struct QueryClientConsensusCmd { )] consensus_height: Option, - #[clap( - short = 's', - long = "heights-only", - help = "show only consensus heights" - )] + #[clap(long = "heights-only", help = "show only consensus heights")] heights_only: bool, #[clap( - short = 'H', long = "height", help = "the chain height context to be used, applicable only to a specific height" )] @@ -116,7 +107,7 @@ pub struct QueryClientConsensusCmd { } /// Implementation of the query for a client's consensus state at a certain height. -/// hermes query client consensus ibc-0 07-tendermint-0 -c 22 +/// hermes query client consensus --chain ibc-0 --client 07-tendermint-0 --consensus-height 22 impl Runnable for QueryClientConsensusCmd { fn run(&self) { let config = app_config(); @@ -209,16 +200,12 @@ pub struct QueryClientHeaderCmd { )] consensus_height: u64, - #[clap( - short = 'H', - long = "height", - help = "the chain height context for the query" - )] + #[clap(long = "height", help = "the chain height context for the query")] height: Option, } /// Implementation of the query for the header used in a client update at a certain height. -/// hermes query client header ibc-0 07-tendermint-0 22 +/// hermes query client header --chain ibc-0 --client 07-tendermint-0 --consensus-height 22 impl Runnable for QueryClientHeaderCmd { fn run(&self) { let config = app_config(); @@ -286,14 +273,13 @@ pub struct QueryClientConnectionsCmd { client_id: ClientId, #[clap( - short = 'H', long = "height", help = "the chain height which this query should reflect" )] height: Option, } -// hermes query connections ibc-0 +// hermes query connections --chain ibc-0 impl Runnable for QueryClientConnectionsCmd { fn run(&self) { let config = app_config(); diff --git a/relayer-cli/src/commands/query/clients.rs b/relayer-cli/src/commands/query/clients.rs index 6bd2970d24..67be80ccd2 100644 --- a/relayer-cli/src/commands/query/clients.rs +++ b/relayer-cli/src/commands/query/clients.rs @@ -25,7 +25,6 @@ pub struct QueryAllClientsCmd { chain_id: ChainId, #[clap( - short = 's', long = "src-chain", help = "filter for clients which target a specific chain id (implies '-o')", value_name = "ID" @@ -33,7 +32,6 @@ pub struct QueryAllClientsCmd { src_chain_id: Option, #[clap( - short = 'o', long = "omit-chain-ids", help = "omit printing the source chain for each client" )] @@ -47,7 +45,7 @@ struct ClientChain { } /// Command for querying all clients. -/// hermes -c cfg.toml query clients ibc-1 +/// hermes --config cfg.toml query clients --chain ibc-1 impl Runnable for QueryAllClientsCmd { fn run(&self) { let config = app_config(); diff --git a/relayer-cli/src/commands/query/connection.rs b/relayer-cli/src/commands/query/connection.rs index 8a2f0e3325..cb583a39c5 100644 --- a/relayer-cli/src/commands/query/connection.rs +++ b/relayer-cli/src/commands/query/connection.rs @@ -34,11 +34,11 @@ pub struct QueryConnectionEndCmd { )] connection_id: ConnectionId, - #[clap(short = 'H', long = "height", help = "height of the state to query")] + #[clap(long = "height", help = "height of the state to query")] height: Option, } -// cargo run --bin hermes -- query connection end ibc-test connectionidone --height 3 +// cargo run --bin hermes -- query connection end --chain ibc-test --conn connectionidone --height 3 impl Runnable for QueryConnectionEndCmd { fn run(&self) { let config = app_config(); diff --git a/relayer-cli/src/commands/query/packet/ack.rs b/relayer-cli/src/commands/query/packet/ack.rs index 432c8254f5..4227815a67 100644 --- a/relayer-cli/src/commands/query/packet/ack.rs +++ b/relayer-cli/src/commands/query/packet/ack.rs @@ -22,7 +22,6 @@ pub struct QueryPacketAcknowledgmentCmd { chain_id: ChainId, #[clap( - short = 'p', long = "port", required = true, help = "identifier of the port to query" @@ -39,7 +38,7 @@ pub struct QueryPacketAcknowledgmentCmd { #[clap(long = "seq", required = true, help = "sequence of packet to query")] sequence: Sequence, - #[clap(short = 'H', long = "height", help = "height of the state to query")] + #[clap(long = "height", help = "height of the state to query")] height: Option, } diff --git a/relayer-cli/src/commands/query/packet/acks.rs b/relayer-cli/src/commands/query/packet/acks.rs index 8f4142c310..c50d5f9670 100644 --- a/relayer-cli/src/commands/query/packet/acks.rs +++ b/relayer-cli/src/commands/query/packet/acks.rs @@ -29,7 +29,6 @@ pub struct QueryPacketAcknowledgementsCmd { chain_id: ChainId, #[clap( - short = 'p', long = "port", required = true, help = "identifier of the port to query" @@ -65,7 +64,7 @@ impl QueryPacketAcknowledgementsCmd { } } -// cargo run --bin hermes -- query packet acknowledgements ibc-0 transfer ibconexfer --height 3 +// cargo run --bin hermes -- query packet acknowledgements --chain ibc-0 --port transfer --conn ibconexfer --height 3 impl Runnable for QueryPacketAcknowledgementsCmd { fn run(&self) { match self.execute() { diff --git a/relayer-cli/src/commands/query/packet/commitment.rs b/relayer-cli/src/commands/query/packet/commitment.rs index 5a4c9e5cc3..1de2dcb531 100644 --- a/relayer-cli/src/commands/query/packet/commitment.rs +++ b/relayer-cli/src/commands/query/packet/commitment.rs @@ -29,7 +29,6 @@ pub struct QueryPacketCommitmentCmd { chain_id: ChainId, #[clap( - short = 'p', long = "port", required = true, help = "identifier of the port to query" @@ -46,7 +45,7 @@ pub struct QueryPacketCommitmentCmd { #[clap(long = "seq", required = true, help = "sequence of packet to query")] sequence: Sequence, - #[clap(short = 'H', long = "height", help = "height of the state to query")] + #[clap(long = "height", help = "height of the state to query")] height: Option, } diff --git a/relayer-cli/src/commands/query/packet/commitments.rs b/relayer-cli/src/commands/query/packet/commitments.rs index 225b5fa245..b4a156fa56 100644 --- a/relayer-cli/src/commands/query/packet/commitments.rs +++ b/relayer-cli/src/commands/query/packet/commitments.rs @@ -28,7 +28,6 @@ pub struct QueryPacketCommitmentsCmd { chain_id: ChainId, #[clap( - short = 'p', long = "port", required = true, help = "identifier of the port to query" @@ -60,7 +59,7 @@ impl QueryPacketCommitmentsCmd { } } -// cargo run --bin hermes -- query packet commitments ibc-0 transfer ibconexfer --height 3 +// cargo run --bin hermes -- query packet commitments --chain ibc-0 --port transfer --chan ibconexfer --height 3 impl Runnable for QueryPacketCommitmentsCmd { fn run(&self) { match self.execute() { diff --git a/relayer-cli/src/commands/query/packet/pending.rs b/relayer-cli/src/commands/query/packet/pending.rs index 23d6e64a23..9d4c765439 100644 --- a/relayer-cli/src/commands/query/packet/pending.rs +++ b/relayer-cli/src/commands/query/packet/pending.rs @@ -39,7 +39,6 @@ pub struct QueryPendingPacketsCmd { chain_id: ChainId, #[clap( - short = 'p', long = "port", required = true, help = "port identifier on the chain given by " diff --git a/relayer-cli/src/commands/query/packet/unreceived_acks.rs b/relayer-cli/src/commands/query/packet/unreceived_acks.rs index 0a88bc95b1..afad48463f 100644 --- a/relayer-cli/src/commands/query/packet/unreceived_acks.rs +++ b/relayer-cli/src/commands/query/packet/unreceived_acks.rs @@ -24,7 +24,7 @@ pub struct QueryUnreceivedAcknowledgementCmd { )] chain_id: ChainId, - #[clap(short = 'p', long = "port", required = true, help = "port identifier")] + #[clap(long = "port", required = true, help = "port identifier")] port_id: PortId, #[clap(long = "chan", required = true, help = "channel identifier")] diff --git a/relayer-cli/src/commands/query/packet/unreceived_packets.rs b/relayer-cli/src/commands/query/packet/unreceived_packets.rs index e766e6ace6..34cec32185 100644 --- a/relayer-cli/src/commands/query/packet/unreceived_packets.rs +++ b/relayer-cli/src/commands/query/packet/unreceived_packets.rs @@ -24,7 +24,7 @@ pub struct QueryUnreceivedPacketsCmd { )] chain_id: ChainId, - #[clap(short = 'p', long = "port", required = true, help = "port identifier")] + #[clap(long = "port", required = true, help = "port identifier")] port_id: PortId, #[clap(long = "chan", required = true, help = "channel identifier")] diff --git a/relayer-cli/src/commands/query/tx/events.rs b/relayer-cli/src/commands/query/tx/events.rs index 28aaa07b65..a05106c288 100644 --- a/relayer-cli/src/commands/query/tx/events.rs +++ b/relayer-cli/src/commands/query/tx/events.rs @@ -33,7 +33,7 @@ pub struct QueryTxEventsCmd { hash: String, } -// cargo run --bin hermes -- query tx events ibc-0 B8E78AD83810239E21863AC7B5FC4F99396ABB39EB534F721EEF43A4979C2821 +// cargo run --bin hermes -- query tx events --chain ibc-0 --hash B8E78AD83810239E21863AC7B5FC4F99396ABB39EB534F721EEF43A4979C2821 impl Runnable for QueryTxEventsCmd { fn run(&self) { let config = app_config(); diff --git a/relayer-cli/src/commands/start.rs b/relayer-cli/src/commands/start.rs index 0fff79eeaa..e79e48605b 100644 --- a/relayer-cli/src/commands/start.rs +++ b/relayer-cli/src/commands/start.rs @@ -19,7 +19,6 @@ use crate::prelude::*; #[derive(Clone, Command, Debug, Parser)] pub struct StartCmd { #[clap( - short = 'f', long = "full-scan", help = "Force a full scan of the chains for clients, connections and channels" )] diff --git a/relayer-cli/src/commands/tx/channel.rs b/relayer-cli/src/commands/tx/channel.rs index 5bce096f68..5627400044 100644 --- a/relayer-cli/src/commands/tx/channel.rs +++ b/relayer-cli/src/commands/tx/channel.rs @@ -50,7 +50,6 @@ macro_rules! tx_chan_cmd { #[derive(Clone, Command, Debug, Parser)] pub struct TxRawChanOpenInitCmd { #[clap( - short = 'd', long = "dst-chain", required = true, help = "identifier of the destination chain" @@ -58,7 +57,6 @@ pub struct TxRawChanOpenInitCmd { dst_chain_id: ChainId, #[clap( - short = 's', long = "src-chain", required = true, help = "identifier of the source chain" diff --git a/relayer-cli/src/commands/tx/client.rs b/relayer-cli/src/commands/tx/client.rs index 6e1799efc2..d76065552f 100644 --- a/relayer-cli/src/commands/tx/client.rs +++ b/relayer-cli/src/commands/tx/client.rs @@ -22,7 +22,6 @@ use crate::error::Error; #[derive(Clone, Command, Debug, Parser)] pub struct TxCreateClientCmd { #[clap( - short = 'd', long = "dst-chain", required = true, help = "identifier of the destination chain" @@ -30,7 +29,6 @@ pub struct TxCreateClientCmd { dst_chain_id: ChainId, #[clap( - short = 's', long = "src-chain", required = true, help = "identifier of the source chain" @@ -65,7 +63,7 @@ pub struct TxCreateClientCmd { } /// Sample to run this tx: -/// `hermes tx raw create-client ibc-0 ibc-1` +/// `hermes tx raw create-client --dst-chain ibc-0 --src-chain ibc-1` impl Runnable for TxCreateClientCmd { fn run(&self) { let config = app_config(); diff --git a/relayer-cli/src/commands/tx/transfer.rs b/relayer-cli/src/commands/tx/transfer.rs index 8452127403..c21f9b4f64 100644 --- a/relayer-cli/src/commands/tx/transfer.rs +++ b/relayer-cli/src/commands/tx/transfer.rs @@ -28,7 +28,6 @@ use crate::prelude::*; #[derive(Clone, Command, Debug, Parser)] pub struct TxIcs20MsgTransferCmd { #[clap( - short = 'd', long = "dst-chain", required = true, help = "identifier of the destination chain" @@ -36,7 +35,6 @@ pub struct TxIcs20MsgTransferCmd { dst_chain_id: ChainId, #[clap( - short = 's', long = "src-chain", required = true, help = "identifier of the source chain" @@ -58,7 +56,6 @@ pub struct TxIcs20MsgTransferCmd { src_channel_id: ChannelId, #[clap( - short = 'a', long = "amount", required = true, help = "amount of coins (samoleans, by default) to send (e.g. `100000`)" @@ -66,7 +63,6 @@ pub struct TxIcs20MsgTransferCmd { amount: Amount, #[clap( - short = 'o', long = "timeout-height-offset", default_value = "0", help = "timeout in number of blocks since current" @@ -74,7 +70,6 @@ pub struct TxIcs20MsgTransferCmd { timeout_height_offset: u64, #[clap( - short = 't', long = "timeout-seconds", default_value = "0", help = "timeout in seconds since current" @@ -82,7 +77,6 @@ pub struct TxIcs20MsgTransferCmd { timeout_seconds: u64, #[clap( - short = 'r', long = "receiver", help = "receiving account address on the destination chain" )] @@ -95,11 +89,10 @@ pub struct TxIcs20MsgTransferCmd { )] denom: String, - #[clap(short = 'n', long = "number-msgs", help = "number of messages to send")] + #[clap(long = "number-msgs", help = "number of messages to send")] number_msgs: Option, #[clap( - short = 'k', long = "key-name", help = "use the given signing key name (default: `key_name` config)" )] diff --git a/relayer-cli/src/commands/tx/upgrade.rs b/relayer-cli/src/commands/tx/upgrade.rs index 18c163e6fa..5fff3fab6a 100644 --- a/relayer-cli/src/commands/tx/upgrade.rs +++ b/relayer-cli/src/commands/tx/upgrade.rs @@ -19,7 +19,6 @@ use crate::prelude::*; #[derive(Clone, Command, Debug, Parser)] pub struct TxIbcUpgradeChainCmd { #[clap( - short = 'd', long = "dst-chain", required = true, help = "identifier of the chain to upgrade" @@ -27,7 +26,6 @@ pub struct TxIbcUpgradeChainCmd { dst_chain_id: ChainId, #[clap( - short = 's', long = "src-chain", required = true, help = "identifier of the source chain" @@ -41,16 +39,10 @@ pub struct TxIbcUpgradeChainCmd { )] src_client_id: ClientId, - #[clap( - short = 'a', - long = "amount", - required = true, - help = "amount of stake" - )] + #[clap(long = "amount", required = true, help = "amount of stake")] amount: u64, #[clap( - short = 'H', long = "height-offset", required = true, help = "upgrade height offset in number of blocks since current" @@ -65,7 +57,6 @@ pub struct TxIbcUpgradeChainCmd { new_chain_id: Option, #[clap( - short = 'u', long = "new-unbonding", value_name = "PERIOD", help = "new unbonding period to assign to the upgrading chain, in seconds (optional)" @@ -73,7 +64,6 @@ pub struct TxIbcUpgradeChainCmd { new_unbonding: Option, #[clap( - short = 'n', long = "upgrade-name", value_name = "NAME", help = "a string to name the upgrade proposal plan (default: 'plan')" diff --git a/relayer-cli/src/conclude.rs b/relayer-cli/src/conclude.rs index 294c20e764..44f7683edb 100644 --- a/relayer-cli/src/conclude.rs +++ b/relayer-cli/src/conclude.rs @@ -83,7 +83,7 @@ pub fn exit_with(out: Output) -> ! { } } -/// Returns true if the application global json flag `-j` or `--json` is enabled. +/// Returns true if the application global json flag `--json` is enabled. /// Returns false otherwise. pub fn json() -> bool { let a = app_reader(); diff --git a/relayer-cli/src/entry.rs b/relayer-cli/src/entry.rs index c8198c9ed5..eb55a7da14 100644 --- a/relayer-cli/src/entry.rs +++ b/relayer-cli/src/entry.rs @@ -13,11 +13,11 @@ use crate::commands::CliCmd; #[clap(author, about, version)] pub struct EntryPoint { /// Path to the configuration file - #[clap(short = 'c', long = "config", help = "path to configuration file")] + #[clap(long = "config", help = "path to configuration file")] pub config: Option, /// Toggle JSON output mode one verbosity setting - #[clap(short = 'j', long = "json", help = "enable JSON output")] + #[clap(long = "json", help = "enable JSON output")] pub json: bool, /// Subcommand to execute. @@ -53,7 +53,7 @@ impl Configurable for EntryPoint { } match &self.config { - // Use explicit `-c`/`--config` argument if passed + // Use explicit `--config` argument if passed Some(cfg) => Some(cfg.clone()), // Otherwise defer to the toplevel command's config path logic From a76599fa918e7fc6f55235f1b70a782ebc274b8c Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Wed, 8 Jun 2022 10:03:10 +0200 Subject: [PATCH 06/27] Removed forgotten short flags. --- relayer-cli/src/commands/tx/channel.rs | 11 ----------- relayer-cli/src/commands/tx/client.rs | 8 ++------ relayer-cli/src/commands/tx/connection.rs | 8 -------- relayer-cli/src/commands/tx/packet.rs | 4 ---- 4 files changed, 2 insertions(+), 29 deletions(-) diff --git a/relayer-cli/src/commands/tx/channel.rs b/relayer-cli/src/commands/tx/channel.rs index 5627400044..9328a34af8 100644 --- a/relayer-cli/src/commands/tx/channel.rs +++ b/relayer-cli/src/commands/tx/channel.rs @@ -85,7 +85,6 @@ pub struct TxRawChanOpenInitCmd { src_port_id: PortId, #[clap( - short = 'o', long = "order", default_value_t, help = "the channel ordering, valid options 'unordered' (default) and 'ordered'" @@ -148,7 +147,6 @@ impl Runnable for TxRawChanOpenInitCmd { #[derive(Clone, Command, Debug, Parser)] pub struct TxRawChanOpenTryCmd { #[clap( - short = 'd', long = "dst-chain", required = true, help = "identifier of the destination chain" @@ -156,7 +154,6 @@ pub struct TxRawChanOpenTryCmd { dst_chain_id: ChainId, #[clap( - short = 's', long = "src-chain", required = true, help = "identifier of the source chain" @@ -235,7 +232,6 @@ impl Runnable for TxRawChanOpenTryCmd { #[derive(Clone, Command, Debug, Parser)] pub struct TxRawChanOpenAckCmd { #[clap( - short = 'd', long = "dst-chain", required = true, help = "identifier of the destination chain" @@ -243,7 +239,6 @@ pub struct TxRawChanOpenAckCmd { dst_chain_id: ChainId, #[clap( - short = 's', long = "src-chain", required = true, help = "identifier of the source chain" @@ -323,7 +318,6 @@ impl Runnable for TxRawChanOpenAckCmd { #[derive(Clone, Command, Debug, Parser)] pub struct TxRawChanOpenConfirmCmd { #[clap( - short = 'd', long = "dst-chain", required = true, help = "identifier of the destination chain" @@ -331,7 +325,6 @@ pub struct TxRawChanOpenConfirmCmd { dst_chain_id: ChainId, #[clap( - short = 's', long = "src-chain", required = true, help = "identifier of the source chain" @@ -411,7 +404,6 @@ impl Runnable for TxRawChanOpenConfirmCmd { #[derive(Clone, Command, Debug, Parser)] pub struct TxRawChanCloseInitCmd { #[clap( - short = 'd', long = "dst-chain", required = true, help = "identifier of the destination chain" @@ -419,7 +411,6 @@ pub struct TxRawChanCloseInitCmd { dst_chain_id: ChainId, #[clap( - short = 's', long = "src-chain", required = true, help = "identifier of the source chain" @@ -499,7 +490,6 @@ impl Runnable for TxRawChanCloseInitCmd { #[derive(Clone, Command, Debug, Parser)] pub struct TxRawChanCloseConfirmCmd { #[clap( - short = 'd', long = "dst-chain", required = true, help = "identifier of the destination chain" @@ -507,7 +497,6 @@ pub struct TxRawChanCloseConfirmCmd { dst_chain_id: ChainId, #[clap( - short = 's', long = "src-chain", required = true, help = "identifier of the source chain" diff --git a/relayer-cli/src/commands/tx/client.rs b/relayer-cli/src/commands/tx/client.rs index d76065552f..cfd59c2428 100644 --- a/relayer-cli/src/commands/tx/client.rs +++ b/relayer-cli/src/commands/tx/client.rs @@ -51,14 +51,14 @@ pub struct TxCreateClientCmd { /// /// The trusting period specifies how long a validator set is trusted for /// (must be shorter than the chain's unbonding period). - #[clap(short = 'p', long = "trusting-period")] + #[clap(long = "trusting-period")] trusting_period: Option, /// Override the trust threshold specified in the configuration. /// /// The trust threshold defines what fraction of the total voting power of a known /// and trusted validator set is sufficient for a commit to be accepted going forward. - #[clap(short = 't', long = "trust-threshold", parse(try_from_str = parse_trust_threshold))] + #[clap(long = "trust-threshold", parse(try_from_str = parse_trust_threshold))] trust_threshold: Option, } @@ -100,7 +100,6 @@ impl Runnable for TxCreateClientCmd { #[derive(Clone, Command, Debug, Parser)] pub struct TxUpdateClientCmd { #[clap( - short = 'd', long = "dst-chain", required = true, help = "identifier of the destination chain" @@ -115,14 +114,12 @@ pub struct TxUpdateClientCmd { dst_client_id: ClientId, #[clap( - short = 'H', long = "target-height", help = "the target height of the client update" )] target_height: Option, #[clap( - short = 't', long = "trusted-height", help = "the trusted height of the client update" )] @@ -241,7 +238,6 @@ impl Runnable for TxUpgradeClientCmd { #[derive(Clone, Command, Debug, Parser)] pub struct TxUpgradeClientsCmd { #[clap( - short = 's', long = "src-chain", required = true, help = "identifier of the chain that underwent an upgrade; all clients targeting this chain will be upgraded" diff --git a/relayer-cli/src/commands/tx/connection.rs b/relayer-cli/src/commands/tx/connection.rs index 983d94124d..775dd8fb55 100644 --- a/relayer-cli/src/commands/tx/connection.rs +++ b/relayer-cli/src/commands/tx/connection.rs @@ -37,7 +37,6 @@ macro_rules! conn_open_cmd { #[derive(Clone, Command, Debug, Parser)] pub struct TxRawConnInitCmd { #[clap( - short = 'd', long = "dst-chain", required = true, help = "identifier of the destination chain" @@ -45,7 +44,6 @@ pub struct TxRawConnInitCmd { dst_chain_id: ChainId, #[clap( - short = 's', long = "src-chain", required = true, help = "identifier of the source chain" @@ -87,7 +85,6 @@ impl Runnable for TxRawConnInitCmd { #[derive(Clone, Command, Debug, Parser)] pub struct TxRawConnTryCmd { #[clap( - short = 'd', long = "dst-chain", required = true, help = "identifier of the destination chain" @@ -95,7 +92,6 @@ pub struct TxRawConnTryCmd { dst_chain_id: ChainId, #[clap( - short = 's', long = "src-chain", required = true, help = "identifier of the source chain" @@ -160,7 +156,6 @@ impl Runnable for TxRawConnTryCmd { #[derive(Clone, Command, Debug, Parser)] pub struct TxRawConnAckCmd { #[clap( - short = 'd', long = "dst-chain", required = true, help = "identifier of the destination chain" @@ -168,7 +163,6 @@ pub struct TxRawConnAckCmd { dst_chain_id: ChainId, #[clap( - short = 's', long = "src-chain", required = true, help = "identifier of the source chain" @@ -234,7 +228,6 @@ impl Runnable for TxRawConnAckCmd { #[derive(Clone, Command, Debug, Parser)] pub struct TxRawConnConfirmCmd { #[clap( - short = 'd', long = "dst-chain", required = true, help = "identifier of the destination chain" @@ -242,7 +235,6 @@ pub struct TxRawConnConfirmCmd { dst_chain_id: ChainId, #[clap( - short = 's', long = "src-chain", required = true, help = "identifier of the source chain" diff --git a/relayer-cli/src/commands/tx/packet.rs b/relayer-cli/src/commands/tx/packet.rs index 674ca0d6ac..b22f0b4ab3 100644 --- a/relayer-cli/src/commands/tx/packet.rs +++ b/relayer-cli/src/commands/tx/packet.rs @@ -13,7 +13,6 @@ use crate::prelude::*; #[derive(Clone, Command, Debug, Parser)] pub struct TxRawPacketRecvCmd { #[clap( - short = 'd', long = "dst-chain", required = true, help = "identifier of the destination chain" @@ -21,7 +20,6 @@ pub struct TxRawPacketRecvCmd { dst_chain_id: ChainId, #[clap( - short = 's', long = "src-chain", required = true, help = "identifier of the source chain" @@ -75,7 +73,6 @@ impl Runnable for TxRawPacketRecvCmd { #[derive(Clone, Command, Debug, Parser)] pub struct TxRawPacketAckCmd { #[clap( - short = 'd', long = "dst-chain", required = true, help = "identifier of the destination chain" @@ -83,7 +80,6 @@ pub struct TxRawPacketAckCmd { dst_chain_id: ChainId, #[clap( - short = 's', long = "src-chain", required = true, help = "identifier of the source chain" From bf60ca14f2f39689485dec6c52a28926d06d4579 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Wed, 8 Jun 2022 17:20:48 +0200 Subject: [PATCH 07/27] Updated Hermes guide with flags instead of positional arguments --- guide/src/SUMMARY.md | 1 + guide/src/commands/config.md | 4 +- guide/src/commands/global.md | 12 +-- guide/src/commands/keys/index.md | 97 +++++++++---------- guide/src/commands/listen/index.md | 18 ++-- guide/src/commands/misbehaviour/index.md | 13 +-- guide/src/commands/path-setup/channels.md | 25 ++--- guide/src/commands/path-setup/clients.md | 35 ++++--- guide/src/commands/path-setup/connections.md | 21 ++-- guide/src/commands/queries/channel.md | 67 +++++++------ guide/src/commands/queries/client.md | 95 ++++++++++-------- guide/src/commands/queries/connection.md | 36 +++---- guide/src/commands/queries/index.md | 1 + guide/src/commands/queries/packet.md | 96 +++++++++--------- guide/src/commands/queries/tx.md | 10 +- guide/src/commands/raw/channel-close.md | 41 ++++---- guide/src/commands/raw/channel-open.md | 82 ++++++++-------- guide/src/commands/raw/client.md | 46 ++++++--- guide/src/commands/raw/connection.md | 69 +++++++------ guide/src/commands/raw/index.md | 11 ++- guide/src/commands/raw/packet.md | 82 ++++++++++------ guide/src/commands/raw/upgrade.md | 91 +++++++++++++++++ guide/src/commands/relaying/clear.md | 25 ++--- guide/src/commands/relaying/index.md | 5 +- guide/src/commands/upgrade/index.md | 8 +- guide/src/commands/upgrade/test.md | 6 +- guide/src/config.md | 6 +- guide/src/help.md | 27 +++--- .../src/tutorials/local-chains/identifiers.md | 6 +- .../src/tutorials/local-chains/raw/channel.md | 12 +-- .../src/tutorials/local-chains/raw/client.md | 10 +- .../tutorials/local-chains/raw/connection.md | 12 +-- .../src/tutorials/local-chains/raw/packet.md | 26 ++--- .../relay-paths/create-new-path.md | 2 +- .../relay-paths/multiple-paths.md | 16 +-- guide/src/tutorials/local-chains/start.md | 4 +- 36 files changed, 633 insertions(+), 485 deletions(-) create mode 100644 guide/src/commands/raw/upgrade.md diff --git a/guide/src/SUMMARY.md b/guide/src/SUMMARY.md index d6acbed04a..0e5345c191 100644 --- a/guide/src/SUMMARY.md +++ b/guide/src/SUMMARY.md @@ -55,6 +55,7 @@ - [Channel Open](./commands/raw/channel-open.md) - [Channel Close](./commands/raw/channel-close.md) - [Packet](./commands/raw/packet.md) + - [Upgrade](./commands/raw/upgrade.md) - [Help](./help.md) - [Glossary](./glossary.md) --- diff --git a/guide/src/commands/config.md b/guide/src/commands/config.md index e00fa93f84..b80e8b6f42 100644 --- a/guide/src/commands/config.md +++ b/guide/src/commands/config.md @@ -30,13 +30,13 @@ Success: "validation passed successfully" Validate a config file at an arbitrary location: ```shell -hermes -c ./config.toml config validate +hermes --config ./config.toml config validate ``` This one fails validation because we mistakenly added two separate sections for the same chain `ibc-1`: ```text -hermes -c ./config.toml config validate +hermes --config ./config.toml config validate error: hermes fatal error: config error: config file has duplicate entry for the chain with id ibc-1 ``` diff --git a/guide/src/commands/global.md b/guide/src/commands/global.md index 6c302987f0..927bf50ca7 100644 --- a/guide/src/commands/global.md +++ b/guide/src/commands/global.md @@ -8,8 +8,8 @@ Informal Systems Implementation of `hermes`, an IBC Relayer developed in Rust. FLAGS: - -c, --config CONFIG path to configuration file - -j, --json enable JSON output + --config path to configuration file + --json enable JSON output ``` The flags must be specified right after the `hermes` command and before any subcommand. @@ -19,7 +19,7 @@ __Example__ To start the relayer using the configuration file at `/home/my_chain.toml` and enable JSON output: ```shell -hermes -c /home/my_chain.toml --json start +hermes --config /home/my_chain.toml --json start ``` ## JSON output @@ -34,7 +34,7 @@ To process all the output using `jq`, one can redirect `stderr` to `stdout` with __Example__ ```shell -hermes -c /home/my_chain.toml --json create client ibc-0 ibc-1 +hermes --config /home/my_chain.toml --json create client --dst-chain ibc-0 --src-chain ibc-1 ``` ```json @@ -51,7 +51,7 @@ __Example__ To improve the readability, pipe all of the output to `jq`: ``` -hermes -c /home/my_chain.toml --json create client ibc-0 ibc-1 2>&1 | jq +hermes --config /home/my_chain.toml --json create client --dst-chain ibc-0 --src-chain ibc-1 2>&1 | jq ``` ```json @@ -105,7 +105,7 @@ __Example__ To extract the identifer of the newly created client above: ``` -hermes -c /home/my_chain.toml --json create client ibc-0 ibc-1 | jq '.result.CreateClient.client_id' +hermes --config /home/my_chain.toml --json create client --dst-chain ibc-0 --src-chain ibc-1 | jq '.result.CreateClient.client_id' ``` ``` diff --git a/guide/src/commands/keys/index.md b/guide/src/commands/keys/index.md index e246d0ef4a..b6cbf970eb 100644 --- a/guide/src/commands/keys/index.md +++ b/guide/src/commands/keys/index.md @@ -62,63 +62,63 @@ The command outputs a JSON similar to the one below. } ``` -You can save this to a file (e.g. `key_seed.json`) and use it to add to the relayer with `hermes keys add -f key_seed.json`. See the `Adding Keys` section for more details. +You can save this to a file (e.g. `key_seed.json`) and use it to add to the relayer with `hermes keys add --chain --key-file key_seed.json`. See the `Adding Keys` section for more details. ### Adding and restoring Keys The command `keys add` has two exclusive flags, `--key-file` and `--mnemonic-file` which are respectively used to add and restore a key. ```shell - hermes keys add [OPTIONS] --key-file --mnemonic-file + hermes keys add [OPTIONS] --chain --key-file --mnemonic-file DESCRIPTION: Adds key to a configured chain or restores a key to a configured chain using a mnemonic -ARGS: - chain_id identifier of the chain - FLAGS: - -f, --key-file + --chain + identifier of the chain + + --key-file path to the key file - -m, --mnemonic-file + --mnemonic-file path to file containing mnemonic to restore the key from OPTIONS: - -k, --key-name + --key-name name of the key (defaults to the `key_name` defined in the config) - -p, --hd-path + --hd-path derivation path for this key [default: m/44'/118'/0'/0/0] ``` #### Add a private key to a chain from a key file ```shell - hermes keys add [OPTIONS] --key-file + hermes keys add [OPTIONS] --chain --key-file DESCRIPTION: Adds key to a configured chain or restores a key to a configured chain using a mnemonic -ARGS: - chain_id identifier of the chain - FLAGS: - -f, --key-file + --chain + identifier of the chain + + --key-file path to the key file OPTIONS: - -k, --key-name + --key-name name of the key (defaults to the `key_name` defined in the config) - -p, --hd-path + --hd-path derivation path for this key [default: m/44'/118'/0'/0/0] ``` To add a private key file to a chain: ```shell -hermes -c config.toml keys add [CHAIN_ID] -f [PRIVATE_KEY_FILE] +hermes --config config.toml keys add --chain [CHAIN_ID] --key-file [PRIVATE_KEY_FILE] ``` The content of the file key should have the same format as the output of the `gaiad keys add` command: @@ -144,36 +144,36 @@ Success: Added key testkey ([ADDRESS]) on [CHAIN ID] chain > To use a different key name, specify the `--key-name` option when invoking `keys add`. > > ``` -> hermes -c config.toml keys add [CHAINID] -f [PRIVATE_KEY_FILE] -k [KEY_NAME] +> hermes --config config.toml keys add --chain [CHAINID] --key-file [PRIVATE_KEY_FILE] --key-name [KEY_NAME] > ``` #### Restore a private key to a chain from a mnemonic ```shell - hermes keys add [OPTIONS] --mnemonic-file + hermes keys add [OPTIONS] --chain --mnemonic-file DESCRIPTION: Adds key to a configured chain or restores a key to a configured chain using a mnemonic -ARGS: - chain_id identifier of the chain - FLAGS: - -m, --mnemonic-file + --chain + identifier of the chain + + --mnemonic-file path to file containing mnemonic to restore the key from OPTIONS: - -k, --key-name + --key-name name of the key (defaults to the `key_name` defined in the config) - -p, --hd-path + --hd-path derivation path for this key [default: m/44'/118'/0'/0/0] ``` To restore a key from its mnemonic: ```shell -hermes -c config.toml keys add [CHAIN_ID] -m "[MNEMONIC_FILE]" +hermes --config config.toml keys add --chain [CHAIN_ID] --mnemonic-file "[MNEMONIC_FILE]" ``` or using an explicit [derivation path](https://github.com/satoshilabs/slips/blob/master/slip-0044.md), for example @@ -181,7 +181,7 @@ an Ethereum coin type (used for Evmos, Injective, Umee, Cronos, and possibly other networks): ```shell -hermes -c config.toml keys add --mnemonic-file --hd-path "m/44'/60'/0'/0/0" +hermes --config config.toml keys add --chain --mnemonic-file --hd-path "m/44'/60'/0'/0/0" ``` The mnemonic file needs to have the 24 mnemonic words on the same line, separated by a white space. So the content should have the following format: @@ -200,7 +200,7 @@ Success: Restore key testkey ([ADDRESS]) on [CHAIN ID] chain > To use a different key name, specify the `--key-name` option when invoking `keys add`. > > ``` -> hermes -c config.toml keys add [CHAINID] -m "[MNEMONIC_FILE]" -k [KEY_NAME] +> hermes --config config.toml keys add --chain [CHAINID] --mnemonic-file "[MNEMONIC_FILE]" --key-name [KEY_NAME] > ``` ### Delete keys @@ -209,17 +209,17 @@ In order to delete the private keys added to chains use the `keys delete` comman ```shell USAGE: - hermes keys delete + hermes keys delete [OPTIONS] --chain DESCRIPTION: Delete key(s) from a configured chain -POSITIONAL ARGUMENTS: - chain_id identifier of the chain - FLAGS: - -n, --name NAME name of the key - -a, --all delete all keys + --chain identifier of the chain + +OPTIONS: + --key-name NAME name of the key + --all delete all keys ``` #### Delete private keys that was previously added to a chain @@ -227,13 +227,13 @@ FLAGS: To delete a single private key by name: ```shell -hermes -c config.toml keys delete [CHAIN_ID] -n [KEY_NAME] +hermes --config config.toml keys delete --chain [CHAIN_ID] --key-name [KEY_NAME] ``` Alternatively, to delete all private keys added to a chain: ```shell -hermes -c config.toml keys delete [CHAIN_ID] -a +hermes --config config.toml keys delete --chain [CHAIN_ID] --all ``` ### List keys @@ -242,13 +242,13 @@ In order to list the private keys added to chains use the `keys list` command ```shell USAGE: - hermes keys list + hermes keys list --chain DESCRIPTION: List keys configured on a chain -POSITIONAL ARGUMENTS: - chain_id identifier of the chain +FLAGS: + --chain identifier of the chain ``` #### Listing the private key that was added to a chain @@ -256,7 +256,7 @@ POSITIONAL ARGUMENTS: To list the private key file that was added to a chain: ```shell -hermes -c config.toml keys list [CHAIN_ID] +hermes --config config.toml keys list --chain [CHAIN_ID] ``` If the command is successful a message similar to the one below will be displayed: @@ -270,7 +270,7 @@ Success: **JSON:** ```shell -hermes --json -c config.toml keys list [CHAIN_ID] | jq +hermes --json --config config.toml keys list --chain [CHAIN_ID] | jq ``` If the command is successful a message similar to the one below will be displayed: @@ -302,16 +302,16 @@ In order to retrieve the balance of an account associated with a key use the `ke ```shell USAGE: - hermes keys balance [OPTIONS] + hermes keys balance [OPTIONS] --chain DESCRIPTION: Query balance for a key from a configured chain. If no key is given, the key is retrieved from the configuration file -ARGS: - chain_id identifier of the chain +FLAGS: + --chain identifier of the chain OPTIONS: - -k, --key-name (optional) name of the key (defaults to the `key_name` defined in the config) + --key-name (optional) name of the key (defaults to the `key_name` defined in the config) ``` If the command is successful a message with the following format will be displayed: @@ -323,12 +323,7 @@ Success: balance for key `KEY_NAME`: 100000000000 stake **JSON:** ```shell - hermes --json keys balance [OPTIONS] -``` -or - -```shell - hermes -j keys balance [OPTIONS] +hermes --json keys balance [OPTIONS] --chain ``` If the command is successful a message with the following format will be displayed: diff --git a/guide/src/commands/listen/index.md b/guide/src/commands/listen/index.md index dd4fc8472d..89eb22f5b2 100644 --- a/guide/src/commands/listen/index.md +++ b/guide/src/commands/listen/index.md @@ -4,16 +4,16 @@ The relayer can be started in `listen` mode to display the events emitted by a g ```shell USAGE: - hermes listen + hermes listen [OPTIONS] --chain DESCRIPTION: Listen to and display IBC events emitted by a chain -POSITIONAL ARGUMENTS: - chain_id Identifier of the chain to listen for events from - FLAGS: - -e, --event EVENT Add an event type to listen for, can be repeated. Listen for all events by default (available: Tx, NewBlock) + --chain Identifier of the chain to listen for events from + +OPTIONS: + --event Add an event type to listen for, can be repeated. Listen for all events by default (available: Tx, NewBlock) ``` __Example__ @@ -21,7 +21,7 @@ __Example__ Start the relayer in listen mode for all `ibc-0` events and observe the output: ```shell -hermes listen ibc-0 +hermes listen --chain ibc-0 ``` ```json @@ -155,8 +155,8 @@ At the moment, two event types are available: The `--event` flag can be repeated to specify more than one event type. -- To listen for only `NewBlock` events on `ibc-0`, invoke `hermes listen ibc-0 --event NewBlock` -- To listen for only `Tx` events on `ibc-0`, invoke `hermes listen ibc-0 --event Tx` -- To listen for both `NewBlock` and `Tx` events on `ibc-0`, invoke `hermes listen ibc-0 --e NewBlock --event Tx` +- To listen for only `NewBlock` events on `ibc-0`, invoke `hermes listen --chain ibc-0 --event NewBlock` +- To listen for only `Tx` events on `ibc-0`, invoke `hermes listen --chain ibc-0 --event Tx` +- To listen for both `NewBlock` and `Tx` events on `ibc-0`, invoke `hermes listen --chain ibc-0 --event NewBlock --event Tx` If the `--event` flag is omitted, the relayer will subscribe to all event types. diff --git a/guide/src/commands/misbehaviour/index.md b/guide/src/commands/misbehaviour/index.md index 1d7f48cbad..57432b0b7c 100644 --- a/guide/src/commands/misbehaviour/index.md +++ b/guide/src/commands/misbehaviour/index.md @@ -10,14 +10,15 @@ cannot be relayed using the frozen client. ```shell USAGE: - hermes misbehaviour + hermes misbehaviour --chain --client DESCRIPTION: Listen to client update IBC events and handles misbehaviour -POSITIONAL ARGUMENTS: - chain_id identifier of the chain where client updates are monitored for misbehaviour - client_id identifier of the client to be monitored for misbehaviour +FLAGS: + --chain identifier of the chain where client updates are monitored for + misbehaviour + --client identifier of the client to be monitored for misbehaviour ``` The misbehaviour monitor starts by analyzing all headers used in prior client updates. @@ -53,7 +54,7 @@ __Example__ The `hermes misbehaviour` outputs an error message displaying `MISBEHAVIOUR DETECTED`: ```shell -hermes misbehaviour ibc-0 07-tendermint-0 +hermes misbehaviour --chain ibc-0 --client 07-tendermint-0 ``` ```json @@ -85,7 +86,7 @@ Success: Some( Querying client state from this point will show the client is in frozen state, with `frozen_height` indicating the height at which the client was frozen: ```shell -hermes query client state ibc-0 07-tendermint-0 | jq +hermes query client state --chain ibc-0 --client 07-tendermint-0 | jq ``` ```json { diff --git a/guide/src/commands/path-setup/channels.md b/guide/src/commands/path-setup/channels.md index ca47b1c116..87544df7e2 100644 --- a/guide/src/commands/path-setup/channels.md +++ b/guide/src/commands/path-setup/channels.md @@ -10,24 +10,25 @@ Use the `create channel` command to establish a new channel. ```shell USAGE: - hermes create channel [OPTIONS] --port-a --port-b [CONNECTION_A] + hermes create channel [OPTIONS] --chain-a --port-a --port-b DESCRIPTION: Create a new channel between two chains using a pre-existing connection. Alternatively, create a new client and a new connection underlying the new channel if a pre-existing connection is not provided. -POSITIONAL ARGUMENTS: - Identifier of the side `a` chain for the new channel - Identifier of the connection on chain `a` to use in creating the new channel - FLAGS: - -c, --chain-b Identifier of the side `b` chain for the new channel - -h, --help Print help information - --new-client-connection Indicates that a new client and connection will be created underlying the new channel - -o, --order The channel ordering, valid options 'unordered' (default) and 'ordered' [default: ORDER_UNORDERED] + --chain-a Identifier of the side `a` chain for the new channel --port-a Identifier of the side `a` port for the new channel --port-b Identifier of the side `b` port for the new channel - -v, --channel-version The version for the new channel + +FLAGS: + --chain-b Identifier of the side `b` chain for the new channel + --conn-a Identifier of the connection on chain `a` to use in creating the + new channel. + -h, --help Print help information + --new-client-conn Indicates that a new client and connection will be created underlying the new channel + --order The channel ordering, valid options 'unordered' (default) and 'ordered' [default: ORDER_UNORDERED] + --chan-version The version for the new channel ``` ## Examples @@ -42,7 +43,7 @@ specifically the one we just created in the example above, with port name `transfer` on both sides: ```shell -hermes create channel ibc-0 --connection-a connection-0 --port-a transfer --port-b transfer -o unordered +hermes create channel --chain-a ibc-0 --conn-a connection-0 --port-a transfer --port-b transfer --order unordered ``` Notice that one can omit the destination chain parameter, as Hermes will automatically @@ -205,7 +206,7 @@ interactive prompt that pops up notifying you that a new client and a new connection will be initialized as part of the process: ```shell -hermes create channel ibc-0 --chain-b ibc-1 --port-a transfer --port-b transfer -o unordered --new-client-connection +hermes create channel --chain-a ibc-0 --chain-b ibc-1 --port-a transfer --port-b transfer --order unordered --new-client-conn ``` ```json diff --git a/guide/src/commands/path-setup/clients.md b/guide/src/commands/path-setup/clients.md index bfecbc7913..44f2074d76 100644 --- a/guide/src/commands/path-setup/clients.md +++ b/guide/src/commands/path-setup/clients.md @@ -11,17 +11,17 @@ tracking the state of the source chain. ```shell USAGE: - hermes create client [OPTIONS] + hermes create client [OPTIONS] --dst-chain --src-chain -ARGS: - +FLAGS: + --dst-chain identifier of the destination chain - + --src-chain identifier of the source chain OPTIONS: - -d, --clock-drift + --clock-drift The maximum allowed clock drift for this client. The clock drift is a correction parameter. It helps deal with clocks that are only @@ -31,13 +31,13 @@ OPTIONS: option is not specified, a suitable clock drift value is derived from the chain configurations. - -p, --trusting-period + --trusting-period Override the trusting period specified in the config. The trusting period specifies how long a validator set is trusted for (must be shorter than the chain's unbonding period). - -t, --trust-threshold + --trust-threshold Override the trust threshold specified in the configuration. The trust threshold defines what fraction of the total voting power of a known and @@ -49,7 +49,7 @@ __Example__ Create a new client on `ibc-0` which tracks `ibc-1`: ```shell -hermes create client ibc-0 ibc-1 +hermes create client --dst-chain ibc-0 --src-chain ibc-1 ``` ```json @@ -81,16 +81,19 @@ Specific update and trusted heights can be specified. ```shell USAGE: - hermes update client [OPTIONS] + hermes update client [OPTIONS] --dst-chain --dst-client -ARGS: - identifier of the destination chain - identifier of the client to be updated on destination chain +FLAGS: + --dst-chain + identifier of the destination chain + + --dst-client + identifier of the client to be updated on destination chain OPTIONS: -h, --help Print help information - -H, --target-height the target height of the client update - -t, --trusted-height the trusted height of the client update + --target-height the target height of the client update + --trusted-height the trusted height of the client update ``` __Update client with latest header__ @@ -98,7 +101,7 @@ __Update client with latest header__ the client on `ibc-0` with latest header of `ibc-1`: ```shell -hermes update client ibc-0 07-tendermint-9 +hermes update client --dst-chain ibc-0 --dst-client 07-tendermint-9 ``` ```json @@ -126,7 +129,7 @@ The client with identifier `07-tendermint-1` has been updated with the consensus __Update a client to a specific target height__ ```shell -hermes update client ibc-0 07-tendermint-1 --target-height 320 --trusted-height 293 +hermes update client --dst-chain ibc-0 --dst-client 07-tendermint-1 --target-height 320 --trusted-height 293 ``` ```json diff --git a/guide/src/commands/path-setup/connections.md b/guide/src/commands/path-setup/connections.md index 2c8ec5a735..ce2d6fda4e 100644 --- a/guide/src/commands/path-setup/connections.md +++ b/guide/src/commands/path-setup/connections.md @@ -9,19 +9,19 @@ Use the `create connection` command to create a new connection. ```shell USAGE: - hermes create connection + hermes create connection [OPTIONS] --chain-a DESCRIPTION: Create a new connection between two chains -POSITIONAL ARGUMENTS: - chain_a_id identifier of the side `a` chain for the new connection - chain_b_id identifier of the side `b` chain for the new connection - FLAGS: - --client-a CLIENT-A identifier of client hosted on chain `a`; default: None (creates a new client) - --client-b CLIENT-B identifier of client hosted on chain `b`; default: None (creates a new client) - --delay DELAY delay period parameter for the new connection (seconds) (default: 0) + --chain-a identifier of the side `a` chain for the new connection + +OPTIONS: + --chain-b identifier of the side `b` chain for the new connection + --client-a identifier of client hosted on chain `a`; default: None (creates a new client) + --client-b identifier of client hosted on chain `b`; default: None (creates a new client) + --delay >DELAY> delay period parameter for the new connection (seconds) (default: 0) ``` ## Examples @@ -31,7 +31,7 @@ FLAGS: Create a new connection between `ibc-0` and `ibc-1` over new clients: ```shell -hermes create connection ibc-0 ibc-1 +hermes create connection --chain-a ibc-0 --chain-b ibc-1 ``` ```json @@ -202,8 +202,7 @@ Create a new connection between `ibc-0` and `ibc-1` over existing clients, both with client id `07-tendermint-0`: ```shell -hermes create connection ibc-0 --client-a 07-tendermint-0 --client-b -07-tendermint-0 +hermes create connection --chain-a ibc-0 --client-a 07-tendermint-0 --client-b 07-tendermint-0 ``` diff --git a/guide/src/commands/queries/channel.md b/guide/src/commands/queries/channel.md index fed5deb4ea..8614260158 100644 --- a/guide/src/commands/queries/channel.md +++ b/guide/src/commands/queries/channel.md @@ -8,13 +8,18 @@ Use the `query channels` command to query the identifiers of all channels on a g ```shell USAGE: - hermes query channels + hermes query channels [OPTIONS] --chain DESCRIPTION: Query the identifiers of all channels on a given chain -POSITIONAL ARGUMENTS: - chain_id identifier of the chain to query +FLAGS: + --chain identifier of the chain to query + +OPTIONS: + --dst-chain identifier of the channel's destination chain + --verbose enable verbose output, displaying all client and connection + ids ``` __Example__ @@ -22,7 +27,7 @@ __Example__ Query all channels on `ibc-1`: ```shell -hermes query channels ibc-1 +hermes query channels --chain ibc-1 ``` ```json @@ -69,18 +74,18 @@ Use the `query channel end` command to query the channel end: ```shell USAGE: - hermes query channel end + hermes query channel end [OPTIONS] --chain --port --chan DESCRIPTION: Query channel end -POSITIONAL ARGUMENTS: - chain_id identifier of the chain to query - port_id identifier of the port to query - channel_id identifier of the channel to query - FLAGS: - -H, --height HEIGHT height of the state to query + --chain identifier of the chain to query + --chan identifier of the channel to query + --port identifier of the port to query + +OPTIONS: + --height height of the state to query ``` __Example__ @@ -88,7 +93,7 @@ __Example__ Query the channel end of channel `channel-1` on port `transfer` on `ibc-1`: ```shell -hermes query channel end ibc-1 transfer channel-1 +hermes query channel end --chain ibc-1 --port transfer --chan channel-1 ``` ```json @@ -121,19 +126,20 @@ Use the `query channel ends` command to obtain both ends of a channel: ```shell USAGE: - hermes query channel ends + hermes query channel ends [OPTIONS] --chain --port --chan DESCRIPTION: Query channel ends and underlying connection and client objects -POSITIONAL ARGUMENTS: - chain_id identifier of the chain to query - port_id identifier of the port to query - channel_id identifier of the channel to query - FLAGS: - -H, --height HEIGHT height of the state to query - -v, --verbose enable verbose output, displaying all details of channels, connections & clients + --chain identifier of the chain to query + --chan identifier of the channel to query + --port identifier of the port to query + +OPTIONS: + --height height of the state to query + --verbose enable verbose output, displaying all details of channels, + connections & clients ``` __Example__ @@ -141,7 +147,7 @@ __Example__ Query the channel end of channel `channel-1` on port `transfer` on `ibc-0`: ```shell -hermes query channel ends ibc-0 transfer channel-1 +hermes query channel ends --chain ibc-0 --port transfer --chan channel-1 ``` ```json @@ -181,7 +187,7 @@ Success: ChannelEndsSummary { } ``` -Passing the `-v` flag will additionally print all the details of the +Passing the `--verbose` flag will additionally print all the details of the channel, connection, and client on both ends. ## Query the channel client state @@ -190,17 +196,15 @@ Use the `query channel client` command to obtain the channel's client state: ```shell USAGE: - hermes query channel client --port-id --channel-id + hermes query channel client --chain --port --chan DESCRIPTION: Query channel's client state -ARGS: - identifier of the chain to query - FLAGS: - --channel-id identifier of the channel to query - --port-id identifier of the port to query + --chain identifier of the chain to query + --chan identifier of the channel to query + --port identifier of the port to query ``` If the command is successful a message with the following format will be displayed: @@ -309,12 +313,7 @@ Success: Some( **JSON:** ```shell - hermes --json query channel client --port-id --channel-id -``` -or - -```shell - hermes -j query channel client --port-id --channel-id + hermes --json query channel client --chain --port --chan ``` If the command is successful a message with the following format will be displayed: diff --git a/guide/src/commands/queries/client.md b/guide/src/commands/queries/client.md index 1603f8332e..0c5567ef37 100644 --- a/guide/src/commands/queries/client.md +++ b/guide/src/commands/queries/client.md @@ -9,17 +9,17 @@ Use the `query clients` command to query the identifiers of all clients on a giv ```shell USAGE: - hermes query clients + hermes query clients [OPTIONS] --chain DESCRIPTION: Query the identifiers of all clients on a chain -POSITIONAL ARGUMENTS: - chain_id identifier of the chain to query - FLAGS: - -s, --src-chain-id ID filter for clients which target a specific chain id (implies '-o') - -o, --omit-chain-ids omit printing the source chain for each client (default: false) + --chain identifier of the chain to query + +OPTIONS: + --src-chain filter for clients which target a specific chain id (implies '--omit-chain-ids') + --omit-chain-ids omit printing the source chain for each client (default: false) ``` __Example__ @@ -27,7 +27,7 @@ __Example__ Query all clients on `ibc-1`: ```shell -hermes query clients ibc-1 +hermes query clients --chain ibc-1 ``` ```json @@ -56,7 +56,7 @@ Success: [ Query all clients on `ibc-1` having `ibc-2` as their source chain: ```shell -hermes query clients ibc-1 -s ibc-2 +hermes query clients --chain ibc-1 --src-chain ibc-2 ``` ```json @@ -79,9 +79,10 @@ DESCRIPTION: Query information about clients SUBCOMMANDS: - state query client full state - consensus query client consensus - connections query client connections + connections Query the client connections + consensus Query the client consensus state + header Query for the header used in a client update at a certain height + state Query the client full state ``` ## Query the client state @@ -90,17 +91,17 @@ Use the `query client state` command to query the client state of a client: ```shell USAGE: - hermes query client state + hermes query client state [OPTIONS] --chain --client DESCRIPTION: Query client full state -POSITIONAL ARGUMENTS: - chain_id identifier of the chain to query - client_id identifier of the client to query - FLAGS: - -H, --height HEIGHT the chain height which this query should reflect + --chain identifier of the chain to query + --client identifier of the client to query + +OPTIONS: + --height HEIGHT the chain height which this query should reflect ``` __Example__ @@ -108,7 +109,7 @@ __Example__ Query the state of client `07-tendermint-2` on `ibc-1`: ```shell -hermes query client state ibc-1 07-tendermint-1 +hermes query client state --chain ibc-1 --client 07-tendermint-1 ``` ```json @@ -147,19 +148,27 @@ Use the `query client consensus` command to query the consensus states of a give ```shell USAGE: - hermes query client consensus + hermes query client consensus [OPTIONS] --chain --client DESCRIPTION: Query client consensus state -POSITIONAL ARGUMENTS: - chain_id identifier of the chain to query - client_id identifier of the client to query - FLAGS: - -c, --consensus-height CONSENSUS-HEIGHT - -s, --heights-only show only consensus heights - -H, --height HEIGHT the chain height context to be used, applicable only to a specific height + --chain + identifier of the chain to query + + --client + identifier of the client to query + +OPTIONS: + --consensus-height + height of the client's consensus state to query + + --height + the chain height context to be used, applicable only to a specific height + + --heights-only + show only consensus heights ``` __Example__ @@ -167,7 +176,7 @@ __Example__ Query the states of client `07-tendermint-0` on `ibc-0`: ```shell -hermes query client consensus ibc-0 07-tendermint-0 --heights-only +hermes query client consensus --chain ibc-0 --client 07-tendermint-0 --heights-only ``` ```json @@ -202,7 +211,7 @@ Success: [ Query `ibc-0` at height `2800` for the consensus state for height `2724`: ```shell -hermes query client consensus ibc-0 07-tendermint-0 -c 2724 -h 2800 +hermes query client consensus --chain ibc-0 --client 07-tendermint-0 --consensus-height 2724 --height 2800 ``` ```json @@ -225,17 +234,17 @@ Use the `query client connections` command to query the connections associated w ```shell USAGE: - hermes query client connections + hermes query client connections [OPTIONS] --chain --client DESCRIPTION: Query client connections -POSITIONAL ARGUMENTS: - chain_id identifier of the chain to query - client_id identifier of the client to query - FLAGS: - -H, --height HEIGHT the chain height which this query should reflect + --chain identifier of the chain to query + --client identifier of the client to query + +OPTIONS: + --height the chain height which this query should reflect ``` __Example__ @@ -243,7 +252,7 @@ __Example__ Query the connections of client `07-tendermint-0` on `ibc-0`: ```shell -hermes query client connections ibc-0 07-tendermint-0 +hermes query client connections --chain ibc-0 --client 07-tendermint-0 ``` ```json @@ -257,18 +266,18 @@ Success: [ ``` USAGE: - hermes query client header + hermes query client header [OPTIONS] --chain --client --consensus-height DESCRIPTION: Query for the header used in a client update at a certain height -POSITIONAL ARGUMENTS: - chain_id identifier of the chain to query - client_id identifier of the client to query - consensus_height height of header to query - FLAGS: - -H, --height HEIGHT the chain height context for the query + --chain identifier of the chain to query + --client identifier of the client to query + --consensus-height height of header to query + +OPTIONS: + --height the chain height context for the query ``` __Example__ @@ -276,7 +285,7 @@ __Example__ Query for the header used in the `07-tendermint-0` client update at height 2724 on `ibc-0`: ```shell -hermes query client header ibc-0 07-tendermint-0 2724 +hermes query client header --chain ibc-0 --client 07-tendermint-0 --consensus-height 2724 ``` ```json diff --git a/guide/src/commands/queries/connection.md b/guide/src/commands/queries/connection.md index 2f2c4ad61f..379d6d3dd3 100644 --- a/guide/src/commands/queries/connection.md +++ b/guide/src/commands/queries/connection.md @@ -8,13 +8,13 @@ Use the `query connections` command to query the identifiers of all connections ```shell USAGE: - hermes query connections + hermes query connections --chain DESCRIPTION: Query the identifiers of all connections on a chain -POSITIONAL ARGUMENTS: - chain_id identifier of the chain to query +FLAGS: + --chain identifier of the chain to query ``` __Example__ @@ -22,7 +22,7 @@ __Example__ Query all connections on `ibc-1`: ```shell -hermes query connections ibc-1 +hermes query connections --chain ibc-1 ``` ```json @@ -58,17 +58,17 @@ Use the `query connection end` command to query the connection end: ```shell USAGE: - hermes query connection end + hermes query connection end [OPTIONS] --chain --conn DESCRIPTION: - query connection end - -POSITIONAL ARGUMENTS: - chain_id identifier of the chain to query - connection_id identifier of the connection to query + Query connection end FLAGS: - -H, --height HEIGHT height of the state to query + --chain identifier of the chain to query + --conn identifier of the connection to query + +OPTIONS: + --height height of the state to query ``` __Example__ @@ -76,7 +76,7 @@ __Example__ Query the connection end of connection `connection-1` on `ibc-1`: ```shell -hermes query connection end ibc-1 connection-1 +hermes query connection end --chain ibc-1 --conn connection-1 ``` ```json @@ -115,14 +115,14 @@ Use the `query connection channels` command to query the identifiers of the chan ```shell USAGE: - hermes query connection channels + hermes query connection channels --chain --conn DESCRIPTION: - query connection channels + Query connection channels -POSITIONAL ARGUMENTS: - chain_id identifier of the chain to query - connection_id identifier of the connection to query +FLAGS: + --chain identifier of the chain to query + --conn identifier of the connection to query ``` __Example__ @@ -130,7 +130,7 @@ __Example__ Query the channels associated with connection `connection-1` on `ibc-1`: ```shell -hermes query connection channels ibc-1 connection-1 +hermes query connection channels --chain ibc-1 --conn connection-1 ``` ```json diff --git a/guide/src/commands/queries/index.md b/guide/src/commands/queries/index.md index 67eeeba748..e40396b304 100644 --- a/guide/src/commands/queries/index.md +++ b/guide/src/commands/queries/index.md @@ -32,4 +32,5 @@ SUBCOMMANDS: channel Query information about channels channels Query the identifiers of all channels on a given chain packet Query information about packets + tx Query information about transactions ``` diff --git a/guide/src/commands/queries/packet.md b/guide/src/commands/queries/packet.md index fa7b8a9b5f..01f5e5278e 100644 --- a/guide/src/commands/queries/packet.md +++ b/guide/src/commands/queries/packet.md @@ -33,12 +33,12 @@ Use the `query packet pending` command to query the sequence numbers of all pack ```shell USAGE: - hermes query packet pending + hermes query packet pending --chain --port --chan -ARGS: - identifier of the chain at one end of the channel - port identifier on the chain given by - channel identifier on the chain given by +FLAGS: + --chain identifier of the chain at one end of the channel + --chan channel identifier on the chain given by + --port port identifier on the chain given by ``` __Example__ @@ -46,7 +46,7 @@ __Example__ Query the sequence numbers of all packets that either not yet been received or not yet been acknowledged, at both ends of the channel `channel-1`. ```shell -$ hermes query packet pending ibc-0 tranfer channel-1 +$ hermes query packet pending --chain ibc-0 --port transfer --chan channel-1 ``` ```json @@ -85,15 +85,15 @@ Use the `query packet commitments` command to query the sequence numbers of all ```shell USAGE: - hermes query packet commitments + hermes query packet commitments --chain --port --chan DESCRIPTION: Query packet commitments -POSITIONAL ARGUMENTS: - chain_id identifier of the chain to query - port_id identifier of the port to query - channel_id identifier of the channel to query +FLAGS: + --chain identifier of the chain to query + --chan identifier of the channel to query + --port identifier of the port to query ``` __Example__ @@ -101,7 +101,7 @@ __Example__ Query `ibc-0` for the sequence numbers of packets that still have commitments on `ibc-0` and that were sent on `transfer` port and `channel-0`: ```shell -hermes query packet commitments ibc-0 transfer channel-0 +hermes query packet commitments --chain ibc-0 --port transfer --chan channel-0 ``` ```json @@ -124,19 +124,19 @@ Use the `query packet commitment` command to query the commitment value of a pac ```shell USAGE: - hermes query packet commitment + hermes query packet commitment [OPTIONS] --chain --port --chan --seq DESCRIPTION: Query packet commitment -POSITIONAL ARGUMENTS: - chain_id identifier of the chain to query - port_id identifier of the port to query - channel_id identifier of the channel to query - sequence sequence of packet to query - FLAGS: - -H, --height HEIGHT height of the state to query + --chain identifier of the chain to query + --chan identifier of the channel to query + --port identifier of the port to query + --seq sequence of packet to query + +OPTIONS: + --height height of the state to query ``` __Example__ @@ -144,7 +144,7 @@ __Example__ Query `ibc-0` for the commitment of packet with sequence `3` sent on `transfer` port and `channel-0`: ```shell -hermes query packet commitment ibc-0 transfer channel-0 3 +hermes query packet commitment --chain ibc-0 --port transfer --chan channel-0 --seq 3 ``` ```json @@ -157,15 +157,15 @@ Use the `query packet acknowledgments` command to query the sequence numbers of ```shell USAGE: - hermes query packet acks + hermes query packet acks --chain --port --chan DESCRIPTION: Query packet acknowledgments -POSITIONAL ARGUMENTS: - chain_id identifier of the chain to query - port_id identifier of the port to query - channel_id identifier of the channel to query +FLAGS: + --chain identifier of the chain to query + --chan identifier of the channel to query + --port identifier of the port to query ``` __Example__ @@ -173,7 +173,7 @@ __Example__ Query `ibc-1` for the sequence numbers of packets acknowledged that were received on `transfer` port and `channel-1`: ```shell -hermes query packet acks ibc-1 transfer channel-1 +hermes query packet acks --chain ibc-1 --port transfer --chan channel-1 ``` ```json @@ -196,19 +196,19 @@ Use the `query packet acknowledgment` command to query the acknowledgment value ```shell USAGE: - hermes query packet ack + hermes query packet ack [OPTIONS] --chain --port --chan --seq DESCRIPTION: Query packet acknowledgment -POSITIONAL ARGUMENTS: - chain_id identifier of the chain to query - port_id identifier of the port to query - channel_id identifier of the channel to query - sequence sequence of packet to query - FLAGS: - -H, --height HEIGHT height of the state to query + --chain identifier of the chain to query + --chan identifier of the channel to query + --port identifier of the port to query + --seq sequence of packet to query + +OPTIONS: + --height height of the state to query ``` __Example__ @@ -216,7 +216,7 @@ __Example__ Query `ibc-1` for the acknowledgment of packet with sequence `2` received on `transfer` port and `channel-1`: ```shell -hermes query packet ack ibc-1 transfer channel-1 2 +hermes query packet ack --chain ibc-1 --port transfer --chan channel-1 --seq 2 ``` ```json @@ -229,15 +229,15 @@ Use the `query packet unreceived-packets` command to query the sequence numbers ```shell USAGE: - hermes query packet unreceived-packets + hermes query packet unreceived-packets --chain --port --chan DESCRIPTION: Query unreceived packets -POSITIONAL ARGUMENTS: - chain_id identifier of the chain for the unreceived sequences - port_id port identifier - channel_id channel identifier +FLAGS: + --chain identifier of the chain for the unreceived sequences + --chan channel identifier + --port port identifier ``` __Example__ @@ -245,7 +245,7 @@ __Example__ Query `transfer` port and `channel-1` on `ibc-1` for the sequence numbers of packets sent on `ibc-0` but not yet received: ```shell -hermes query packet unreceived-packets ibc-1 transfer channel-1 +hermes query packet unreceived-packets --chain ibc-1 --port transfer --chan channel-1 ``` ```json @@ -262,15 +262,15 @@ Use the `query packet unreceived-acks` command to query the sequence numbers of ```shell USAGE: - hermes query packet unreceived-acks + hermes query packet unreceived-acks --chain --port --chan DESCRIPTION: Query unreceived acknowledgments -POSITIONAL ARGUMENTS: - chain_id identifier of the chain to query the unreceived acknowledgments - port_id port identifier - channel_id channel identifier +FLAGS: + --chain identifier of the chain to query the unreceived acknowledgments + --chan channel identifier + --port port identifier ``` __Example__ @@ -278,7 +278,7 @@ __Example__ Query `transfer` port and `channel-0` on `ibc-0` for the sequence numbers of packets received by `ibc-1` but not yet acknowledged on `ibc-0`: ```shell -hermes query packet unreceived-acks ibc-0 transfer channel-0 +hermes query packet unreceived-acks --chain ibc-0 --port transfer --chan channel-0 ``` ```json diff --git a/guide/src/commands/queries/tx.md b/guide/src/commands/queries/tx.md index 7af7c4c2a4..536b66ca0b 100644 --- a/guide/src/commands/queries/tx.md +++ b/guide/src/commands/queries/tx.md @@ -26,14 +26,14 @@ delivering a transaction. ```shell USAGE: - hermes query tx events + hermes query tx events --chain --hash DESCRIPTION: Query the events emitted by transaction -POSITIONAL ARGUMENTS: - chain_id identifier of the chain to query - hash transaction hash to query +FLAGS: + --chain identifier of the chain to query + --hash transaction hash to query ``` __Example__ @@ -42,7 +42,7 @@ Query chain `ibc-0` for the events emitted due to transaction with hash `6EDBBCBCB779F9FC9D6884ACDC4350E69720C4B362E4ACE6C576DE792F837490`: ```shell -hermes query tx events ibc-0 6EDBBCBCB779F9FC9D6884ACDC4350E69720C4B362E4ACE6C576DE792F837490 +hermes query tx events --chain ibc-0 --hash 6EDBBCBCB779F9FC9D6884ACDC4350E69720C4B362E4ACE6C576DE792F837490 ``` ```json diff --git a/guide/src/commands/raw/channel-close.md b/guide/src/commands/raw/channel-close.md index b04befeeb0..abe6c4e086 100644 --- a/guide/src/commands/raw/channel-close.md +++ b/guide/src/commands/raw/channel-close.md @@ -12,27 +12,25 @@ Use the `chan-close-init` command to initialize the closure of a channel. ```shell USAGE: - hermes tx raw chan-close-init + hermes tx raw chan-close-init --dst-chain --src-chain --dst-conn --dst-port --src-port --dst-chan --src-chan DESCRIPTION: Initiate the closing of a channel (ChannelCloseInit) -POSITIONAL ARGUMENTS: - dst_chain_id identifier of the destination chain - src_chain_id identifier of the source chain - dst_conn_id identifier of the destination connection - dst_port_id identifier of the destination port - src_port_id identifier of the source port - FLAGS: - -d, --dst-chan-id ID identifier of the destination channel (required) - -s, --src-chan-id ID identifier of the source channel (required) + --dst-chain identifier of the destination chain + --dst-chan identifier of the destination channel (required) + --dst-conn identifier of the destination connection + --dst-port identifier of the destination port + --src-chain identifier of the source chain + --src-chan identifier of the source channel (required) + --src-port identifier of the source port ``` __Example__ ```shell -hermes tx raw chan-close-init ibc-0 ibc-1 connection-0 transfer transfer -d channel-0 -s channel-1 +hermes tx raw chan-close-init --dst-chain ibc-0 --src-chain ibc-1 --dst-conn connection-0 --dst-port transfer --src-port transfer --dst-chan channel-0 --src-chan channel-1 ``` ```json @@ -73,27 +71,26 @@ Use the `chan-close-confirm` command to confirm the closure of a channel. ```shell USAGE: - hermes tx raw chan-close-confirm + hermes tx raw chan-close-confirm --dst-chain --src-chain --dst-conn --dst-port --src-port --dst-chan --src-chan DESCRIPTION: Confirm the closing of a channel (ChannelCloseConfirm) -POSITIONAL ARGUMENTS: - dst_chain_id identifier of the destination chain - src_chain_id identifier of the source chain - dst_conn_id identifier of the destination connection - dst_port_id identifier of the destination port - src_port_id identifier of the source port - FLAGS: - -d, --dst-chan-id ID identifier of the destination channel (required) - -s, --src-chan-id ID identifier of the source channel (required) + --dst-chain identifier of the destination chain + --dst-chan identifier of the destination channel (required) + --dst-conn identifier of the destination connection + --dst-port identifier of the destination port + --src-chain identifier of the source chain + --src-chan identifier of the source channel (required) + --src-port identifier of the source port + ``` __Example__ ```shell -hermes tx raw chan-close-confirm ibc-1 ibc-0 connection-1 transfer transfer -d channel-1 -s channel-0 +hermes tx raw chan-close-confirm --dst-chain ibc-1 --src-chain ibc-0 --dst-conn connection-1 --src-port transfer --dst-port transfer --dst-chan channel-1 --src-chan channel-0 ``` ```json diff --git a/guide/src/commands/raw/channel-open.md b/guide/src/commands/raw/channel-open.md index 86bfb569d1..5dabafb714 100644 --- a/guide/src/commands/raw/channel-open.md +++ b/guide/src/commands/raw/channel-open.md @@ -35,20 +35,21 @@ Use the `chan-open-init` command to initialize a new channel. ```shell USAGE: - hermes tx raw chan-open-init + hermes tx raw chan-open-init [OPTIONS] --dst-chain --src-chain --dst-conn --dst-port --src-port DESCRIPTION: Initialize a channel (ChannelOpenInit) -POSITIONAL ARGUMENTS: - dst_chain_id identifier of the destination chain - src_chain_id identifier of the source chain - dst_conn_id identifier of the destination connection - dst_port_id identifier of the destination port - src_port_id identifier of the source port - FLAGS: - -o, --order ORDER the channel ordering, valid options 'unordered' (default) and 'ordered' + --dst-chain identifier of the destination chain + --dst-conn identifier of the destination connection + --dst-port identifier of the destination port + --src-chain identifier of the source chain + --src-port identifier of the source port + +OPTIONS: + --order the channel ordering, valid options 'unordered' (default) and + 'ordered' [default: ORDER_UNORDERED] ``` __Example__ @@ -56,7 +57,7 @@ __Example__ First, let's initialize the channel on `ibc-0` using an existing connection identified by `connection-0`: ```shell -hermes tx raw chan-open-init ibc-0 ibc-1 connection-0 transfer transfer +hermes tx raw chan-open-init --dst-chain ibc-0 --src-chain ibc-1 --dst-conn connection-0 --dst-port transfer --src-port transfer ``` ```json @@ -98,20 +99,21 @@ Use the `chan-open-try` command to establish a counterparty to the channel on th ```shell USAGE: - hermes tx raw chan-open-try + hermes tx raw chan-open-try [OPTIONS] --dst-chain --src-chain --dst-conn --dst-port --src-port --src-chan DESCRIPTION: Relay the channel attempt (ChannelOpenTry) -POSITIONAL ARGUMENTS: - dst_chain_id identifier of the destination chain - src_chain_id identifier of the source chain - dst_conn_id identifier of the destination connection - dst_port_id identifier of the destination port - src_port_id identifier of the source port - FLAGS: - -s, --src-chan-id ID identifier of the source channel (required) + --dst-chain identifier of the destination chain + --dst-conn identifier of the destination connection + --dst-port identifier of the destination port + --src-chain identifier of the source chain + --src-chan identifier of the source channel (required) + --src-port identifier of the source port + +OPTIONS: + --dst-chan identifier of the destination channel (optional) ``` __Example__ @@ -119,7 +121,7 @@ __Example__ Let's now create the counterparty to `channel-0` on chain `ibc-1`: ```shell -hermes tx raw chan-open-try ibc-1 ibc-0 connection-1 transfer transfer -s channel-0 +hermes tx raw chan-open-try --dst-chain ibc-1 --src-chain ibc-0 --dst-conn connection-1 --dst-port transfer --src-port transfer --src-chan channel-0 ``` ```json @@ -165,21 +167,19 @@ Use the `chan-open-ack` command to acknowledge the channel on the initial chain. ```shell USAGE: - hermes tx raw chan-open-ack + hermes tx raw chan-open-ack --dst-chain --src-chain --dst-conn --dst-port --src-port --dst-chan --src-chan DESCRIPTION: Relay acknowledgment of a channel attempt (ChannelOpenAck) -POSITIONAL ARGUMENTS: - dst_chain_id identifier of the destination chain - src_chain_id identifier of the source chain - dst_conn_id identifier of the destination connection - dst_port_id identifier of the destination port - src_port_id identifier of the source port - FLAGS: - -d, --dst-chan-id ID identifier of the destination channel (required) - -s, --src-chan-id ID identifier of the source channel (required) + --dst-chain identifier of the destination chain + --dst-chan identifier of the destination channel (required) + --dst-conn identifier of the destination connection + --dst-port identifier of the destination port + --src-chain identifier of the source chain + --src-chan identifier of the source channel (required) + --src-port identifier of the source port ``` __Example__ @@ -187,7 +187,7 @@ __Example__ We can now acknowledge on `ibc-0` that `ibc-1` has accepted the opening of the channel: ```shell -hermes tx raw chan-open-ack ibc-0 ibc-1 connection-0 transfer transfer -d channel-0 -s channel-1 +hermes tx raw chan-open-ack --dst-chain ibc-0 --src-chain ibc-1 --dst-conn connection-0 --dst-port transfer --src-port transfer --dst-chan channel-0 --src-chan channel-1 ``` ```json @@ -232,21 +232,19 @@ and finish the handshake, after which the channel is open on both chains. ```shell USAGE: - hermes tx raw chan-open-confirm + hermes tx raw chan-open-confirm --dst-chain --src-chain --dst-conn --dst-port --src-port --dst-chan --src-chan DESCRIPTION: Confirm opening of a channel (ChannelOpenConfirm) -POSITIONAL ARGUMENTS: - dst_chain_id identifier of the destination chain - src_chain_id identifier of the source chain - dst_conn_id identifier of the destination connection - dst_port_id identifier of the destination port - src_port_id identifier of the source port - FLAGS: - -d, --dst-chan-id ID identifier of the destination channel (required) - -s, --src-chan-id ID identifier of the source channel (required) + --dst-chain identifier of the destination chain + --dst-chan identifier of the destination channel (required) + --dst-conn identifier of the destination connection + --dst-port identifier of the destination port + --src-chain identifier of the source chain + --src-chan identifier of the source channel (required) + --src-port identifier of the source port ``` __Example__ @@ -255,7 +253,7 @@ Confirm on `ibc-1` that `ibc-0` has accepted the opening of the channel, after which the channel is open on both chains. ```shell -hermes tx raw chan-open-confirm ibc-1 ibc-0 connection-1 transfer transfer -d channel-1 -s channel-0 +hermes tx raw chan-open-confirm --dst-chain ibc-1 --src-chain ibc-0 --dst-conn connection-1 --dst-port transfer --src-port transfer --dst-chan channel-1 --src-chan channel-0 ``` ```json diff --git a/guide/src/commands/raw/client.md b/guide/src/commands/raw/client.md index b0041246ef..39db753216 100644 --- a/guide/src/commands/raw/client.md +++ b/guide/src/commands/raw/client.md @@ -9,14 +9,27 @@ Use the `create-client` command to create a new client. ```shell USAGE: - hermes tx raw create-client + hermes tx raw create-client [OPTIONS] --dst-chain --src-chain DESCRIPTION: Create a client for source chain on destination chain -POSITIONAL ARGUMENTS: - dst_chain_id identifier of the destination chain - src_chain_id identifier of the source chain +FLAGS: + --dst-chain + identifier of the destination chain + + --src-chain + identifier of the source chain + +OPTIONS: + --clock-drift + The maximum allowed clock drift for this client + + --trust-threshold + Override the trust threshold specified in the configuration + + --trusting-period + Override the trusting period specified in the config ``` @@ -25,7 +38,7 @@ __Example__ Create a new client of `ibc-1` on `ibc-0`: ```shell -hermes tx raw create-client ibc-0 ibc-1 +hermes tx raw create-client --dst-chain ibc-0 --src-chain ibc-1 ``` ```json @@ -53,18 +66,25 @@ Specific update and trusted heights can be specified. ```shell USAGE: - hermes tx raw update-client + hermes tx raw update-client [OPTIONS] --dst-chain --dst-client DESCRIPTION: Update the specified client on destination chain -POSITIONAL ARGUMENTS: - dst_chain_id identifier of the destination chain - dst_client_id identifier of the client to be updated on destination chain - FLAGS: - -H, --target-height TARGET-HEIGHT - -t, --trusted-height TRUSTED-HEIGHT + --dst-chain + identifier of the destination chain + + --dst-client + identifier of the client to be updated on destination chain + +OPTIONS: + + --target-height + the target height of the client update + + --trusted-height + the trusted height of the client update ``` __Example__ @@ -72,7 +92,7 @@ __Example__ Update the client on `ibc-0` with latest header of `ibc-1` ```shell -hermes tx raw update-client ibc-0 07-tendermint-0 +hermes tx raw update-client --dst-chain ibc-0 --dst-client 07-tendermint-0 ``` ```json diff --git a/guide/src/commands/raw/connection.md b/guide/src/commands/raw/connection.md index ce20d223fd..b6e061c808 100644 --- a/guide/src/commands/raw/connection.md +++ b/guide/src/commands/raw/connection.md @@ -35,16 +35,16 @@ Use the `conn-init` command to initialize a new connection on a chain. ```shell USAGE: - hermes tx raw conn-init + hermes tx raw conn-init --dst-chain --src-chain --dst-client --src-client DESCRIPTION: Initialize a connection (ConnectionOpenInit) -POSITIONAL ARGUMENTS: - dst_chain_id identifier of the destination chain - src_chain_id identifier of the source chain - dst_client_id identifier of the destination client - src_client_id identifier of the source client +FLAGS: + --dst-chain identifier of the destination chain + --dst-client identifier of the destination client + --src-chain identifier of the source chain + --src-client identifier of the source client ``` __Example__ @@ -55,7 +55,7 @@ identifier `07-tendermint-1` on chain `ibc-1`, we can initialize a connection be First, let's initialize the connection on `ibc-0`: ```shell -hermes tx raw conn-init ibc-0 ibc-1 07-tendermint-0 07-tendermint-1 +hermes tx raw conn-init --dst-chain ibc-0 --src-chain ibc-1 --dst-client 07-tendermint-0 --src-client 07-tendermint-1 ``` ```json @@ -94,19 +94,20 @@ Use the `conn-try` command to establish a counterparty to the connection on the ```shell USAGE: - hermes tx raw conn-try + hermes tx raw conn-try [OPTIONS] --dst-chain --src-chain --dst-client --src-client --src-conn DESCRIPTION: Relay the connection attempt (ConnectionOpenTry) -POSITIONAL ARGUMENTS: - dst_chain_id identifier of the destination chain - src_chain_id identifier of the source chain - dst_client_id identifier of the destination client - src_client_id identifier of the source client - FLAGS: - -s, --src-conn-id ID identifier of the source connection (required) + --dst-chain identifier of the destination chain + --dst-client identifier of the destination client + --src-chain identifier of the source chain + --src-client identifier of the source client + --src-conn identifier of the source connection (required) + +OPTIONS: + --dst-conn identifier of the destination connection (optional) ``` __Example__ @@ -114,7 +115,7 @@ __Example__ Let's now create the counterparty to `connection-0` on chain `ibc-1`: ```shell -hermes tx raw conn-try ibc-1 ibc-0 07-tendermint-1 07-tendermint-0 -s connection-0 +hermes tx raw conn-try --dst-chain ibc-1 --src-chain ibc-0 --dst-client 07-tendermint-1 --src-client 07-tendermint-0 --src-conn connection-0 ``` ```json @@ -157,20 +158,18 @@ Use the `conn-ack` command to acknowledge the connection on the initial chain. ```shell USAGE: - hermes tx raw conn-ack + hermes tx raw conn-ack --dst-chain --src-chain --dst-client --src-client --dst-conn --src-conn DESCRIPTION: Relay acknowledgment of a connection attempt (ConnectionOpenAck) -POSITIONAL ARGUMENTS: - dst_chain_id identifier of the destination chain - src_chain_id identifier of the source chain - dst_client_id identifier of the destination client - src_client_id identifier of the source client - FLAGS: - -d, --dst-conn-id ID identifier of the destination connection (required) - -s, --src-conn-id ID identifier of the source connection (required) + --dst-chain identifier of the destination chain + --dst-client identifier of the destination client + --dst-conn identifier of the destination connection (required) + --src-chain identifier of the source chain + --src-client identifier of the source client + --src-conn identifier of the source connection (required) ``` __Example__ @@ -178,7 +177,7 @@ __Example__ We can now acknowledge on `ibc-0` that `ibc-1` has accepted the connection attempt: ```shell -hermes tx raw conn-ack ibc-0 ibc-1 07-tendermint-0 07-tendermint-1 -d connection-0 -s connection-1 +hermes tx raw conn-ack --dst-chain ibc-0 --src-chain ibc-1 --dst-client 07-tendermint-0 --src-client 07-tendermint-1 --dst-conn connection-0 --src-conn connection-1 ``` ```json @@ -220,20 +219,18 @@ and finish the handshake, after which the connection is open on both chains. ```shell USAGE: - hermes tx raw conn-confirm + hermes tx raw conn-confirm --dst-chain --src-chain --dst-client --src-client --dst-conn --src-conn DESCRIPTION: Confirm opening of a connection (ConnectionOpenConfirm) -POSITIONAL ARGUMENTS: - dst_chain_id identifier of the destination chain - src_chain_id identifier of the source chain - dst_client_id identifier of the destination client - src_client_id identifier of the source client - FLAGS: - -d, --dst-conn-id ID identifier of the destination connection (required) - -s, --src-conn-id ID identifier of the source connection (required) + --dst-chain identifier of the destination chain + --dst-client identifier of the destination client + --dst-conn identifier of the destination connection (required) + --src-chain identifier of the source chain + --src-client identifier of the source client + --src-conn identifier of the source connection (required) ``` __Example__ @@ -241,7 +238,7 @@ __Example__ Confirm on `ibc-1` that `ibc-0` has accepted the connection attempt. ```shell -hermes tx raw conn-confirm ibc-1 ibc-0 07-tendermint-1 07-tendermint-0 -d connection-1 -s connection-0 +hermes tx raw conn-confirm --dst-chain ibc-1 --src-chain ibc-0 --dst-client 07-tendermint-1 --src-client 07-tendermint-0 --dst-conn connection-1 --src-conn connection-0 ``` ```json diff --git a/guide/src/commands/raw/index.md b/guide/src/commands/raw/index.md index c4c4093015..5da87a9130 100644 --- a/guide/src/commands/raw/index.md +++ b/guide/src/commands/raw/index.md @@ -15,12 +15,15 @@ The `tx raw` command provides the following sub-commands: | `chan-open-init` | [Initialize a channel (ChannelOpenInit)](./channel-open.md#channel-open-init) | | `chan-open-try` | [Relay the channel attempt (ChannelOpenTry)](./channel-open.md#channel-open-try) | | `chan-open-ack` | [Relay acknowledgment of a channel attempt (ChannelOpenAck)](./channel-open.md#channel-open-ack) | -| `chan-open-close` | [Confirm opening of a channel (ChannelOpenConfirm)](./channel-open.md#channel-open-close) | +| `chan-open-confirm` | [Confirm opening of a channel (ChannelOpenConfirm)](./channel-open.md#channel-open-close) | | `chan-close-init` | [Initiate the closing of a channel (ChannelCloseInit)](./channel-close.md#channel-close-init) | | `chan-close-confirm` | [Confirm the closing of a channel (ChannelCloseConfirm)](./channel-close.md#channel-close-confirm) | -| `ft-transfer` | [Send a fungible token transfer test transaction (ICS20 MsgTransfer](./packet.md#fungible-token-transfer) | +| `ft-transfer` | [Send a fungible token transfer test transaction (ICS20 MsgTransfer](./packet.md#fungible-token-transfer) | | `packet-recv` | [Relay receive or timeout packets](./packet.md#relay-receive-and-timeout-packets) | | `packet-ack` | [Relay acknowledgment packets](./packet.md#relay-acknowledgment-packets) | +| `upgrade-chain` | [Send an IBC upgrade plan](./upgrade.md) +| `upgrade-client` | [Upgrade the specified client on destination chain](./upgrade.md) +| `upgrade-clients` | [Upgrade all IBC clients that target a specific chain](./upgrade.md) The main purpose of these commands is to support development and testing, and continuous integration. These CLIs take quite a few parameters and they are explained in the individual sub-sections. @@ -55,6 +58,7 @@ In the command template above: - [Channel Open](./channel-open.md) - [Channel Close](./channel-close.md) - [Packet](./packet.md) + - [Upgrade](./upgrade.md) ## Usage @@ -82,4 +86,7 @@ SUBCOMMANDS: ft-transfer Send a fungible token transfer test transaction (ICS20 MsgTransfer) packet-recv Relay receive or timeout packets packet-ack Relay acknowledgment packets + upgrade-chain Send an IBC upgrade plan + upgrade-client Upgrade the specified client on destination chain + upgrade-clients Upgrade all IBC clients that target a specific chain ``` diff --git a/guide/src/commands/raw/packet.md b/guide/src/commands/raw/packet.md index e87bbacf29..0bd37fd374 100644 --- a/guide/src/commands/raw/packet.md +++ b/guide/src/commands/raw/packet.md @@ -11,25 +11,45 @@ __NOTE:__ This command is mainly used for testing the packet features of the rel ```shell USAGE: - hermes tx raw ft-transfer + hermes tx raw ft-transfer [OPTIONS] --dst-chain --src-chain --src-port --src-chan --amount DESCRIPTION: Send a fungible token transfer test transaction (ICS20 MsgTransfer) -POSITIONAL ARGUMENTS: - dst_chain_id identifier of the destination chain - src_chain_id identifier of the source chain - src_port_id identifier of the source port - src_channel_id identifier of the source channel - amount amount of coins (samoleans, by default) to send (e.g. `100000`) - FLAGS: - -o, --timeout-height-offset TIMEOUT-HEIGHT-OFFSET timeout in number of blocks since current - -t, --timeout-seconds TIMEOUT-SECONDS timeout in seconds since current - -r, --receiver RECEIVER receiving account address on the destination chain - -d, --denom DENOM denomination of the coins to send (default: samoleans) - -n, --number-msgs NUMBER-MSGS number of messages to send - -k, --key KEY use the given signing key (default: `key_name` config) + --amount + amount of coins (samoleans, by default) to send (e.g. `100000`) + + --dst-chain + identifier of the destination chain + + --src-chain + identifier of the source chain + + --src-chan + identifier of the source channel + + --src-port + identifier of the source port + +OPTIONS: + --denom + denomination of the coins to send [default: samoleans] + + --key-name + use the given signing key name (default: `key_name` config) + + --number-msgs + number of messages to send + + --receiver + receiving account address on the destination chain + + --timeout-height-offset + timeout in number of blocks since current [default: 0] + + --timeout-seconds + timeout in seconds since current [default: 0] ``` __Example__ @@ -37,7 +57,7 @@ __Example__ Send two transfer packets from the `transfer` module and `channel-0` of `ibc-0` to `ibc-1`. Each transfer if for `9999` samoleans (default denomination) and a timeout offset of `10` blocks. The transfer fee is paid by the relayer account on `ibc-1`. ```shell -hermes tx raw ft-transfer ibc-1 ibc-0 transfer channel-0 9999 -o 1000 -n 2 +hermes tx raw ft-transfer --dst-chain ibc-1 --src-chain ibc-0 --src-port transfer --src-chan channel-0 --amount 9999 --timeout-height-offset 1000 --number-msgs 2 ``` ```json @@ -65,10 +85,10 @@ Success: [ The transfer packets are stored on `ibc-0` and can be relayed. -> To send transfer packets with a custom receiver address use the `--receiver | -r` flag. +> To send transfer packets with a custom receiver address use the `--receiver` flag. ```shell -hermes tx raw ft-transfer ibc-1 ibc-0 transfer channel-0 9999 -o 1000 -n 1 -r board:1938586739 +hermes tx raw ft-transfer --dst-chain ibc-1 --src-chain ibc-0 --src-port transfer --src-chan channel-0 --amount 9999 --timeout-height-offset 1000 --number-msgs 1 --receiver board:1938586739 ``` ```json @@ -91,16 +111,16 @@ Use the `tx raw packet-recv` command to relay the packets sent but not yet recei ```shell USAGE: - hermes tx raw packet-recv + hermes tx raw packet-recv --dst-chain --src-chain --src-port --src-chan DESCRIPTION: Relay receive or timeout packets -POSITIONAL ARGUMENTS: - dst_chain_id identifier of the destination chain - src_chain_id identifier of the source chain - src_port_id identifier of the source port - src_channel_id identifier of the source channel +FLAGS: + --dst-chain identifier of the destination chain + --src-chain identifier of the source chain + --src-chan identifier of the source channel + --src-port identifier of the source port ``` __Example__ @@ -110,7 +130,7 @@ Send the two transfer packets to the `ibc-1` module bound to the `transfer` port __NOTE__: The relayer prepends a client update message before the receive messages. ```shell -hermes tx raw packet-recv ibc-1 ibc-0 transfer channel-0 +hermes tx raw packet-recv --dst-chain ibc-1 --src-chain ibc-0 --src-port transfer --src-chan channel-0 ``` ```json @@ -203,16 +223,16 @@ Use the `tx raw packet-ack` command to relay acknowledgments to the original sou ```shell USAGE: - hermes tx raw packet-ack + hermes tx raw packet-ack --dst-chain --src-chain --src-port --src-chan DESCRIPTION: Relay acknowledgment packets -POSITIONAL ARGUMENTS: - dst_chain_id identifier of the destination chain - src_chain_id identifier of the source chain - src_port_id identifier of the source port - src_channel_id identifier of the source channel +FLAGS: + --dst-chain identifier of the destination chain + --src-chain identifier of the source chain + --src-chan identifier of the source channel + --src-port identifier of the source port ``` __Example__ @@ -222,7 +242,7 @@ Send the acknowledgments to the `ibc-0` module bound to the `transfer` port and __NOTE__: The relayer prepends a client update message before the acknowledgments. ```shell -hermes tx raw packet-ack ibc-0 ibc-1 transfer channel-1 +hermes tx raw packet-ack --dst-chain ibc-0 --src-chain ibc-1 --src-port transfer --src-chan channel-1 ``` ```json diff --git a/guide/src/commands/raw/upgrade.md b/guide/src/commands/raw/upgrade.md new file mode 100644 index 0000000000..317ba51285 --- /dev/null +++ b/guide/src/commands/raw/upgrade.md @@ -0,0 +1,91 @@ +# Upgrade Tx Commands + +## Table of Contents + + + +## Upgrade Client + +Use this to perform the upgrade for the given client. + +```shell +USAGE: + hermes tx raw upgrade-client --chain --client + +DESCRIPTION: + Upgrade the specified client on destination chain + +FLAGS: + --chain identifier of the chain that hosts the client + --client identifier of the client to be upgraded +``` + +## Upgrade Clients + +Use this to perform the upgrade on all the clients. + +```shell +USAGE: + hermes tx raw upgrade-clients --src-chain + +DESCRIPTION: + Upgrade all IBC clients that target a specific chain + +FLAGS: + --src-chain identifier of the chain that underwent an upgrade; all clients + targeting this chain will be upgraded +``` + +## Upgrade Chain + +Use this to make an upgrade proposal. + +```shell +USAGE: + hermes tx raw upgrade-chain [OPTIONS] --dst-chain --src-chain --src-client --amount --height-offset + +DESCRIPTION: + Send an IBC upgrade plan + +FLAGS: + --amount + amount of stake + + --dst-chain + identifier of the chain to upgrade + + --height-offset + upgrade height offset in number of blocks since current + + --src-chain + identifier of the source chain + + --src-client + identifier of the client on source chain from which the plan is created + +OPTIONS: + --denom + denomination for the deposit (default: 'stake') + + --new-chain + new chain identifier to assign to the upgrading chain (optional) + + --new-unbonding + new unbonding period to assign to the upgrading chain, in seconds (optional) + + --upgrade-name + a string to name the upgrade proposal plan (default: 'plan') + +``` + +__Example__ + +An upgrade proposal is made for `ibc-0`, for height `300` blocks from latest height, with `10000000stake` deposited. The proposal will include the upgraded client state constructed from the state of `07-tendermint-0` client on `ibc-1`. + +```shell +hermes tx raw upgrade-chain --dst-chain ibc-0 --src-chain ibc-1 --src-client 07-tendermint-0 --amount 10000000 --height-offset 300 +``` + +```json +Success: transaction::Hash(CE98D8D98091BA8016BD852D18056E54C4CB3C4525E7F40DD3C40B4FD0F2482B) +``` \ No newline at end of file diff --git a/guide/src/commands/relaying/clear.md b/guide/src/commands/relaying/clear.md index a9f2c581cf..e0d25a6631 100644 --- a/guide/src/commands/relaying/clear.md +++ b/guide/src/commands/relaying/clear.md @@ -9,17 +9,18 @@ and [packet-acks](../raw/packet.md#relay-acknowledgment-packets). ### Usage ``` -Clear outstanding packets (i.e. packet-recv and packet-ack) on a given channel in both directions. +USAGE: + hermes clear packets --chain --port --chan -The channel is identified by the chain, port, and channel IDs at one of its ends +DESCRIPTION: + Clear outstanding packets (i.e. packet-recv and packet-ack) on a given channel in both directions. -USAGE: - hermes clear packets + The channel is identified by the chain, port, and channel IDs at one of its ends -ARGS: - identifier of the chain - identifier of the port - identifier of the channel +FLAGS: + --chain identifier of the chain + --chan identifier of the channel + --port identifier of the port OPTIONS: -h, --help Print help information @@ -30,7 +31,7 @@ OPTIONS: 1. Without Hermes running, send 3 packets over a channel, here `channel-13`: ``` -❯ hermes tx raw ft-transfer ibc1 ibc0 transfer channel-13 9999 -o 1000 -n 3 +❯ hermes tx raw ft-transfer --dst-chain ibc1 --src-chain ibc0 --src-port transfer --src-chan channel-13 --amount 9999 --timeout-height-offset 1000 --number-msgs 3 2022-02-24T14:16:28.295526Z INFO ThreadId(01) using default configuration from '/Users/coromac/.hermes/config.toml' 2022-02-24T14:16:28.330860Z INFO ThreadId(15) send_tx{id=ibc0}: refresh: retrieved account sequence=61 number=1 2022-02-24T14:16:28.350022Z INFO ThreadId(15) wait_for_block_commits: waiting for commit of tx hashes(s) AE4C3186778488E45670EB7303FA77E69B39F4E7C7494B05EC51E55136A373D6 id=ibc0 @@ -141,7 +142,7 @@ Success: [ as can be seen with the `query packet unreceived-packets` command: ``` -❯ hermes query packet unreceived-packets ibc1 transfer channel-13 +❯ hermes query packet unreceived-packets --chain ibc1 --port transfer --chan channel-13 2022-02-24T14:21:28.874190Z INFO ThreadId(01) using default configuration from '/Users/coromac/.hermes/config.toml' Success: [ 14, @@ -153,7 +154,7 @@ Success: [ 3. We can clear them manually using the `clear packets` command: ``` -❯ hermes clear packets ibc0 transfer channel-13 +❯ hermes clear packets --chain ibc0 --port transfer --chan channel-13 2022-02-24T14:17:25.748422Z INFO ThreadId(01) using default configuration from '/Users/coromac/.hermes/config.toml' 2022-02-24T14:17:25.799704Z INFO ThreadId(01) PacketRecvCmd{src_chain=ibc0 src_port=transfer src_channel=channel-13 dst_chain=ibc1}: found unprocessed SendPacket events for [Sequence(14), Sequence(15), Sequence(16)] (first 10 shown here; total=3) 2022-02-24T14:17:25.827177Z INFO ThreadId(01) PacketRecvCmd{src_chain=ibc0 src_port=transfer src_channel=channel-13 dst_chain=ibc1}: ready to fetch a scheduled op. data with batch of size 3 targeting Destination @@ -435,7 +436,7 @@ Success: [ 4. The packets have now been successfully relayed: ``` -❯ hermes query packet unreceived-packets ibc1 transfer channel-13 +❯ hermes query packet unreceived-packets --chain ibc1 --port transfer --chan channel-13 2022-02-24T14:21:28.874190Z INFO ThreadId(01) using default configuration from '/Users/coromac/.hermes/config.toml' Success: [] ``` diff --git a/guide/src/commands/relaying/index.md b/guide/src/commands/relaying/index.md index c9d4d06b06..db7fe96326 100644 --- a/guide/src/commands/relaying/index.md +++ b/guide/src/commands/relaying/index.md @@ -11,10 +11,13 @@ The `start` command can be used to start hermes in IBC event listen mode. ```shell USAGE: - hermes start + hermes start [OPTIONS] DESCRIPTION: Start the relayer in multi-chain mode. Relays packets and channel handshake messages between all chains in the config. + +OPTIONS: + --full-scan Force a full scan of the chains for clients, connections and channels ``` As described in next sub-sections, the type of relaying can be configured in the `global` section of the configuration file, by specifying different values in `strategy` field. diff --git a/guide/src/commands/upgrade/index.md b/guide/src/commands/upgrade/index.md index 135d9c137e..d4d4538680 100644 --- a/guide/src/commands/upgrade/index.md +++ b/guide/src/commands/upgrade/index.md @@ -6,14 +6,14 @@ Use the `upgrade client` command to upgrade a client after a chain upgrade. ```shell USAGE: - hermes upgrade client + hermes upgrade client --chain --client DESCRIPTION: Upgrade an IBC client -POSITIONAL ARGUMENTS: - dst_chain_id identifier of the destination chain - dst_client_id identifier of the client to be upgraded on destination chain +FLAGS: + --chain identifier of the chain that hosts the client + --client identifier of the client to be upgraded ``` __Example__ diff --git a/guide/src/commands/upgrade/test.md b/guide/src/commands/upgrade/test.md index 56a2f3ccb3..b62aae96e1 100644 --- a/guide/src/commands/upgrade/test.md +++ b/guide/src/commands/upgrade/test.md @@ -27,7 +27,7 @@ commit: 535be14a8bdbfeb0d950914b5baa2dc72c6b081c 2. Create one client on `ibc-1` for `ibc-0`: ```shell - hermes create client ibc-1 ibc-0 + hermes create client --dst-chain ibc-1 --src-chain ibc-0 ``` ```json @@ -51,7 +51,7 @@ commit: 535be14a8bdbfeb0d950914b5baa2dc72c6b081c The proposal includes the upgraded client state constructed from the state of `07-tendermint-0` client on `ibc-1` that was created in the previous step. In addition, the `unbonding_period` of the client is set to some new value (`400h`) ```shell - hermes tx raw upgrade-chain ibc-0 ibc-1 07-tendermint-0 10000000 300 + hermes tx raw upgrade-chain --dst-chain ibc-0 --src-chain ibc-1 --src-client 07-tendermint-0 --amount 10000000 --height-offset 300 ``` ```text @@ -197,7 +197,7 @@ commit: 535be14a8bdbfeb0d950914b5baa2dc72c6b081c and another for the upgraded state. ```shell - hermes upgrade client ibc-1 07-tendermint-0 + hermes upgrade client --chain ibc-1 --client 07-tendermint-0 ``` ```json Success: [ diff --git a/guide/src/config.md b/guide/src/config.md index cdde0904bd..31801b6431 100644 --- a/guide/src/config.md +++ b/guide/src/config.md @@ -6,14 +6,14 @@ The format supported for the configuration file is [TOML](https://toml.io/en/). By default, Hermes expects the configuration file to be located at `$HOME/.hermes/config.toml`. -This can be overridden by supplying the `-c` flag when invoking `hermes`, before the -name of the command to run, eg. `hermes -c my_config.toml query connection channels ibc-1 connection-1`. +This can be overridden by supplying the `--config` flag when invoking `hermes`, before the +name of the command to run, eg. `hermes --config my_config.toml query connection channels --chain ibc-1 --conn connection-1`. > The current version of Hermes does not support managing the configuration file programmatically. > You will need to use a text editor to create the file and add content to it. ```bash -hermes [-c CONFIG_FILE] COMMAND +hermes [--config CONFIG_FILE] COMMAND ``` ## Table of contents diff --git a/guide/src/help.md b/guide/src/help.md index e2e7bfcf45..aa61bbcea2 100644 --- a/guide/src/help.md +++ b/guide/src/help.md @@ -60,21 +60,26 @@ hermes help create channel ``` USAGE: - hermes create channel + hermes create channel [OPTIONS] --chain-a --port-a --port-b DESCRIPTION: - Create a new channel between two chains - -POSITIONAL ARGUMENTS: - chain_a_id identifier of the side `a` chain for the new channel - chain_b_id identifier of the side `b` chain for the new channel (optional) + Create a new channel between two chains using a pre-existing connection. Alternatively, create a new + client and a new connection underlying the new channel if a pre-existing connection is not provided FLAGS: - -c, --connection-a CONNECTION-A - --port-a PORT-A identifier of the side `a` port for the new channel - --port-b PORT-B identifier of the side `b` port for the new channel - -o, --order ORDER the channel ordering, valid options 'unordered' (default) and 'ordered' - -v, --channel-version VERSION the version for the new channel + --chain-a Identifier of the side `a` chain for the new channel + --port-a Identifier of the side `a` port for the new channel + --port-b Identifier of the side `b` port for the new channel + +OPTIONS: + --chain-b Identifier of the side `b` chain for the new channel + --chan-version The version for the new channel + --conn-a Identifier of the connection on chain `a` to use in creating the + new channel. + --new-client-conn Indicates that a new client and connection will be created + underlying the new channel + --order The channel ordering, valid options 'unordered' (default) and + 'ordered' [default: ORDER_UNORDERED] ``` Additionally, the `-h`/`--help` flags typical for CLI applications work on diff --git a/guide/src/tutorials/local-chains/identifiers.md b/guide/src/tutorials/local-chains/identifiers.md index b72682d7b1..47d6913288 100644 --- a/guide/src/tutorials/local-chains/identifiers.md +++ b/guide/src/tutorials/local-chains/identifiers.md @@ -14,7 +14,7 @@ __`07-tendermint-`__ for tendermint clients For example `07-tendermint-0` is assigned to the first client created on `ibc-1`: ```shell -hermes tx raw create-client ibc-1 ibc-0 +hermes tx raw create-client --dst-chain ibc-1 --src-chain ibc-0 ``` ```json @@ -47,7 +47,7 @@ __`connection-`__ for connections For example `connection-0` is assigned to the first connection created on `ibc-1`: ```shell -hermes tx raw conn-init ibc-1 ibc-0 07-tendermint-0 07-tendermint-0 +hermes tx raw conn-init --dst-chain ibc-1 --src-chain ibc-0 --dst-client 07-tendermint-0 --src-client 07-tendermint-0 ``` ```json @@ -83,7 +83,7 @@ We will create a second connection on `ibc-1` with identifier `connection-1` in For example `channel-0` is assigned to the first channel created on `ibc-1`: ```shell -hermes tx raw chan-open-init ibc-1 ibc-0 connection-0 transfer transfer +hermes tx raw chan-open-init --dst-chain ibc-1 --src-chain ibc-0 --dst-conn connection-0 --dst-port transfer --src-port transfer ``` ```json diff --git a/guide/src/tutorials/local-chains/raw/channel.md b/guide/src/tutorials/local-chains/raw/channel.md index 6902d98ae4..35f600f833 100644 --- a/guide/src/tutorials/local-chains/raw/channel.md +++ b/guide/src/tutorials/local-chains/raw/channel.md @@ -4,14 +4,14 @@ Initialize a new unordered channel on `ibc-0`: ```shell -hermes tx raw chan-open-init ibc-0 ibc-1 connection-0 transfer transfer -o UNORDERED +hermes tx raw chan-open-init --dst-chain ibc-0 --src-chain ibc-1 --dst-conn connection-0 --dst-port transfer --src-port transfer --order UNORDERED ``` ## 3.2 `chan-open-try` Send a channel open try to `ibc-1`: ```shell -hermes tx raw chan-open-try ibc-1 ibc-0 connection-1 transfer transfer -s channel-0 +hermes tx raw chan-open-try --dst-chain ibc-1 --src-chain ibc-0 --dst-conn connection-1 --dst-port transfer --src-port transfer --src-chan channel-0 ``` Take note of the ID allocated by the chain, e.g. `channel-1` on `ibc-1`. Use in the `chan-open-ack` CLI @@ -20,25 +20,25 @@ Take note of the ID allocated by the chain, e.g. `channel-1` on `ibc-1`. Use in Send a channel open acknowledgment to `ibc-0`: ```shell -hermes tx raw chan-open-ack ibc-0 ibc-1 connection-0 transfer transfer -d channel-0 -s channel-1 +hermes tx raw chan-open-ack --dst-chain ibc-0 --src-chain ibc-1 --dst-conn connection-0 --dst-port transfer --src-port transfer --dst-chan channel-0 --src-chan channel-1 ``` ## 3.4 `chan-open-confirm` Send the open confirmation to `ibc-1`: ```shell -hermes tx raw chan-open-confirm ibc-1 ibc-0 connection-1 transfer transfer -d channel-1 -s channel-0 +hermes tx raw chan-open-confirm --dst-chain ibc-1 --src-chain ibc-0 --dst-conn connection-1 --dst-port transfer --src-port transfer --dst-chan channel-1 --src-chan channel-0 ``` ## 3.5 `query channel` To verify that the two ends are in `Open` state: ```shell -hermes query channel end ibc-0 transfer channel-0 +hermes query channel end --chain ibc-0 --port transfer --chan channel-0 ``` ```shell -hermes query channel end ibc-1 transfer channel-1 +hermes query channel end --chain ibc-1 --port transfer --chan channel-1 ``` ## Next Steps diff --git a/guide/src/tutorials/local-chains/raw/client.md b/guide/src/tutorials/local-chains/raw/client.md index b29ebe1e08..c84f389a65 100644 --- a/guide/src/tutorials/local-chains/raw/client.md +++ b/guide/src/tutorials/local-chains/raw/client.md @@ -7,7 +7,7 @@ First you will need to create a client for each chain: This command submits a transaction to a destination chain (`ibc-0`) with a request to create a client for a source chain (`ibc-1`): ```shell -hermes tx raw create-client ibc-0 ibc-1 +hermes tx raw create-client --dst-chain ibc-0 --src-chain ibc-1 ``` if the command is successful a message similar to the one below will be displayed `status:success`: @@ -34,7 +34,7 @@ if the command is successful a message similar to the one below will be displaye You can also execute a __query__ to view the client state on destination chain `ibc-0` by specifying the `client_id` value `07-tendermint-0`: ```shell -hermes query client state ibc-0 07-tendermint-0 +hermes query client state --chain ibc-0 --client 07-tendermint-0 ``` which show a message similar to the one below: @@ -72,7 +72,7 @@ Success: ClientState { Now let's do the same for `ibc-1` as the destination chain: ```shell -hermes tx raw create-client ibc-1 ibc-0 +hermes tx raw create-client --dst-chain ibc-1 --src-chain ibc-0 ``` Take note of the `client_id` allocated for this client. In the examples we assume is `07-tendermint-1` (this client identity is obtained by creating two clients on ibc-1 for ibc-0). @@ -105,11 +105,11 @@ Success: CreateClient( Client states can be updated by sending an `update-client` transaction: ```shell -hermes tx raw update-client ibc-0 07-tendermint-0 +hermes tx raw update-client --dst-chain ibc-0 --dst-client 07-tendermint-0 ``` ```shell -hermes tx raw update-client ibc-1 07-tendermint-1 +hermes tx raw update-client --dst-chain ibc-1 --dst-client 07-tendermint-1 ``` ## Next Steps diff --git a/guide/src/tutorials/local-chains/raw/connection.md b/guide/src/tutorials/local-chains/raw/connection.md index f93c35e074..4985e364c5 100644 --- a/guide/src/tutorials/local-chains/raw/connection.md +++ b/guide/src/tutorials/local-chains/raw/connection.md @@ -4,7 +4,7 @@ Initialize a new connection on `ibc-0`: ```shell -hermes tx raw conn-init ibc-0 ibc-1 07-tendermint-0 07-tendermint-1 +hermes tx raw conn-init --dst-chain ibc-0 --src-chain ibc-1 --dst-client 07-tendermint-0 --src-client 07-tendermint-1 ``` Take note of the ID allocated by the chain, e.g. `connection-0` on `ibc-0` in order to use it in the `conn-try` command below. @@ -13,7 +13,7 @@ Take note of the ID allocated by the chain, e.g. `connection-0` on `ibc-0` in or Send a connection try to `ibc-1`: ```shell -hermes tx raw conn-try ibc-1 ibc-0 07-tendermint-1 07-tendermint-0 -s connection-0 +hermes tx raw conn-try --dst-chain ibc-1 --src-chain ibc-0 --dst-client 07-tendermint-1 --src-client 07-tendermint-0 --src-conn connection-0 ``` Take note of the ID allocated by the chain, e.g. `connection-1` on `ibc-1`. Use in the `conn-ack` CLI @@ -22,14 +22,14 @@ Take note of the ID allocated by the chain, e.g. `connection-1` on `ibc-1`. Use Send a connection open acknowledgment to `ibc-0`: ```shell -hermes tx raw conn-ack ibc-0 ibc-1 07-tendermint-0 07-tendermint-1 -d connection-0 -s connection-1 +hermes tx raw conn-ack --dst-chain ibc-0 --src-chain ibc-1 --dst-client 07-tendermint-0 --src-client 07-tendermint-1 --dst-conn connection-0 --src-conn connection-1 ``` ## 2.4 `conn-confirm` Send the open confirmation to `ibc-1`: ```shell -hermes tx raw conn-confirm ibc-1 ibc-0 07-tendermint-1 07-tendermint-0 -d connection-1 -s connection-0 +hermes tx raw conn-confirm --dst-chain ibc-1 --src-chain ibc-0 --dst-client 07-tendermint-1 --src-client 07-tendermint-0 --dst-conn connection-1 --src-conn connection-0 ``` ## 2.5 `query connection` @@ -37,11 +37,11 @@ hermes tx raw conn-confirm ibc-1 ibc-0 07-tendermint-1 07-tendermint-0 -d connec To verify that the two ends are in `Open` state: ```shell -hermes query connection end ibc-0 connection-0 +hermes query connection end --chain ibc-0 --conn connection-0 ``` ```shell -hermes query connection end ibc-1 connection-1 +hermes query connection end --chain ibc-1 --conn connection-1 ``` diff --git a/guide/src/tutorials/local-chains/raw/packet.md b/guide/src/tutorials/local-chains/raw/packet.md index 426b374d50..aaae0ed89a 100644 --- a/guide/src/tutorials/local-chains/raw/packet.md +++ b/guide/src/tutorials/local-chains/raw/packet.md @@ -23,45 +23,45 @@ First, we'll send `9999` `samoleans` from `ibc-0` to `ibc-1`. - start the transfer of 9999 samoleans from `ibc-0` to `ibc-1`. This sends a `MsgTransfer` in a transaction to `ibc-0` ```shell - hermes tx raw ft-transfer ibc-1 ibc-0 transfer channel-0 9999 -o 1000 -n 1 -d samoleans + hermes tx raw ft-transfer --dst-chain ibc-1 --src-chain ibc-0 --src-port transfer --src-chan channel-0 --amout 9999 --timeout-height-offset 1000 --number-msgs 1 --denom samoleans ``` - query packet commitments on `ibc-0` ```shell - hermes query packet commitments ibc-0 transfer channel-0 + hermes query packet commitments --chain ibc-0 --port transfer --chan channel-0 ``` - query unreceived packets on `ibc-1` ```shell - hermes query packet unreceived-packets ibc-1 transfer channel-1 + hermes query packet unreceived-packets --chain ibc-1 --port transfer --chan channel-1 ``` - send `recv_packet` to `ibc-1` ```shell - hermes tx raw packet-recv ibc-1 ibc-0 transfer channel-0 + hermes tx raw packet-recv --dst-chain ibc-1 --src-chain ibc-0 --src-port transfer --src-chan channel-0 ``` - query unreceived acks on `ibc-0` ```shell - hermes query packet unreceived-acks ibc-0 transfer channel-0 + hermes query packet unreceived-acks --chain ibc-0 --port transfer --chan channel-0 ``` - send acknowledgement to `ibc-0` ```shell - hermes tx raw packet-ack ibc-0 ibc-1 transfer channel-1 + hermes tx raw packet-ack --dst-chain ibc-0 --src-chain ibc-1 --src-port transfer --src-chan channel-1 ``` Send those samoleans back, from `ibc-1` to `ibc-0`. ```shell -hermes tx raw ft-transfer ibc-0 ibc-1 transfer channel-1 9999 -o 1000 -n 1 -d ibc/49D321B40FCF56B0370E5673CF090389C8E9CD185209FBE1BEE5D94E58E69BDC -hermes tx raw packet-recv ibc-0 ibc-1 transfer channel-1 -hermes tx raw packet-ack ibc-1 ibc-0 transfer channel-0 +hermes tx raw ft-transfer --dst-chain ibc-0 --src-chain ibc-1 --src-port transfer --src-chan channel-1 --amount 9999 --timeout-height-offset 1000 --number-msgs 1 --denom ibc/49D321B40FCF56B0370E5673CF090389C8E9CD185209FBE1BEE5D94E58E69BDC +hermes tx raw packet-recv --dst-chain ibc-0 --src-chain ibc-1 --src-port transfer --src-chan channel-1 +hermes tx raw packet-ack --dst-chain ibc-1 --src-chain ibc-0 --src-port transfer --src-chan channel-0 ``` The `ibc/49D321B40FCF56B0370E5673CF090389C8E9CD185209FBE1BEE5D94E58E69BDC` denominator above can be obtained by querying the balance at `ibc-1` after the transfer from `ibc-0` to `ibc-1` is concluded. @@ -70,23 +70,23 @@ Next we will test the packet timeouts. - send 1 packet with low timeout height offset to ibc-0 ```shell - hermes tx raw ft-transfer ibc-1 ibc-0 transfer channel-0 9999 -o 2 -n 1 + hermes tx raw ft-transfer --dst-chain ibc-1 --src-chain ibc-0 --src-port transfer --src-chan channel-0 --amount 9999 --timeout-height-offset 2 --number-msgs 1 ``` - send timeout to `ibc-0` ```shell - hermes tx raw packet-recv ibc-1 ibc-0 transfer channel-0 + hermes tx raw packet-recv --dst-chain ibc-1 --src-chain ibc-0 --src-port transfer --src-chan channel-0 ``` - send 1 packet with 2 second timeout to ibc-0 ```shell - hermes tx raw ft-transfer ibc-1 ibc-0 transfer channel-0 9999 -t 2 -n 1 + hermes tx raw ft-transfer --dst-chain ibc-1 --src-chain ibc-0 --src-port transfer --src-chan channel-0 --amount 9999 --timeout-seconds 2 --number-msgs 1 ``` - send timeout to `ibc-0` ```shell - hermes tx raw packet-recv ibc-1 ibc-0 transfer channel-0 + hermes tx raw packet-recv --dst-chain ibc-1 --src-chain ibc-0 --src-port transfer --src-chan channel-0 ``` \ No newline at end of file diff --git a/guide/src/tutorials/local-chains/relay-paths/create-new-path.md b/guide/src/tutorials/local-chains/relay-paths/create-new-path.md index 1ddc70699e..dc95686d2e 100644 --- a/guide/src/tutorials/local-chains/relay-paths/create-new-path.md +++ b/guide/src/tutorials/local-chains/relay-paths/create-new-path.md @@ -3,7 +3,7 @@ Perform client creation, connection and channel handshake to establish a new path between the `transfer` ports on `ibc-0` and `ibc-1` chains. ```shell -hermes create channel ibc-0 -c ibc-1 --port-a transfer --port-b transfer --new-client-connection +hermes create channel --chain-a ibc-0 --chain-b ibc-1 --port-a transfer --port-b transfer --new-client-conn ``` If all the handshakes are performed successfully you should see a message similar to the one below: diff --git a/guide/src/tutorials/local-chains/relay-paths/multiple-paths.md b/guide/src/tutorials/local-chains/relay-paths/multiple-paths.md index e314197603..7f3cac5db4 100644 --- a/guide/src/tutorials/local-chains/relay-paths/multiple-paths.md +++ b/guide/src/tutorials/local-chains/relay-paths/multiple-paths.md @@ -100,7 +100,7 @@ Follow the steps below to connect three chains together and relay packets betwee making an exception. Execute the following command: ```shell - hermes create channel ibc-0 --chain-b ibc-1 --port-a transfer --port-b transfer --new-client-connection + hermes create channel --chain-a ibc-0 --chain-b ibc-1 --port-a transfer --port-b transfer --new-client-conn ``` Then respond 'yes' to the prompt that pops up. Once the command has run to @@ -166,7 +166,7 @@ Follow the steps below to connect three chains together and relay packets betwee previous invocation we used to create a channel between `ibc-0` and `ibc-1`: ```shell - hermes create channel ibc-1 --chain-b ibc-2 --port-a transfer --port-b transfer --new-client-connection + hermes create channel --chain-a ibc-1 --chain-b ibc-2 --port-a transfer --port-b transfer --new-client-conn ``` ```json @@ -239,7 +239,7 @@ Follow the steps below to connect three chains together and relay packets betwee - Two packets from `ibc-0` to `ibc-1` from source channel `channel-0` ```shell - hermes tx raw ft-transfer ibc-1 ibc-0 transfer channel-0 9999 -o 1000 -n 2 + hermes tx raw ft-transfer --dst-chain ibc-1 --src-chain ibc-0 --src-port transfer --src-chan channel-0 --amount 9999 --timeout-height-offset 1000 --number-msgs 2 ``` ```json @@ -262,7 +262,7 @@ Follow the steps below to connect three chains together and relay packets betwee - Two packets from `ibc-1` to `ibc-2` from source channel `channel-1` ```shell - hermes tx raw ft-transfer ibc-2 ibc-1 transfer channel-1 9999 -o 1000 -n 2 + hermes tx raw ft-transfer --dst-chain ibc-2 --src-chain ibc-1 --src-port transfer --src-chan channel-1 --amount 9999 --timeout-height-offset 1000 --number-msgs 2 ``` ```json @@ -315,10 +315,10 @@ Follow the steps below to connect three chains together and relay packets betwee 8. Query the unreceived packets and acknowledgments on `ibc-1` and `ibc-2` from a different terminal: ```shell - hermes query packet unreceived-packets ibc-1 transfer channel-0 - hermes query packet unreceived-acks ibc-0 transfer channel-0 - hermes query packet unreceived-packets ibc-2 transfer channel-0 - hermes query packet unreceived-acks ibc-1 transfer channel-1 + hermes query packet unreceived-packets --chain ibc-1 --port transfer --chan channel-0 + hermes query packet unreceived-acks --chain ibc-0 --port transfer --chan channel-0 + hermes query packet unreceived-packets --chain ibc-2 --port transfer --chan channel-0 + hermes query packet unreceived-acks --chain ibc-1 --port transfer --chan channel-1 ``` If everything went well, each of these commands should result in: diff --git a/guide/src/tutorials/local-chains/start.md b/guide/src/tutorials/local-chains/start.md index 791d977fb3..d45c151e69 100644 --- a/guide/src/tutorials/local-chains/start.md +++ b/guide/src/tutorials/local-chains/start.md @@ -84,8 +84,8 @@ Our config file specifies two chains: `ibc-0` and `ibc-1`. We will need to speci previously mentioned, in this tutorial we will use the same private key for both chains. ```shell -hermes keys add ibc-0 -f key_seed.json -hermes keys add ibc-1 -f key_seed.json +hermes keys add --chain ibc-0 --key-file key_seed.json +hermes keys add --chain ibc-1 --key-file key_seed.json ``` If successful, both commands should show an output similar to: From b9983eff6550f4c9b56a72b7d32bfe87e2a8f095 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Wed, 8 Jun 2022 17:21:17 +0200 Subject: [PATCH 08/27] Updated script and comment with new long flags for Hermes --- relayer-cli/src/commands/query/clients.rs | 2 +- scripts/init-hermes | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/relayer-cli/src/commands/query/clients.rs b/relayer-cli/src/commands/query/clients.rs index 67be80ccd2..384eac5cd6 100644 --- a/relayer-cli/src/commands/query/clients.rs +++ b/relayer-cli/src/commands/query/clients.rs @@ -26,7 +26,7 @@ pub struct QueryAllClientsCmd { #[clap( long = "src-chain", - help = "filter for clients which target a specific chain id (implies '-o')", + help = "filter for clients which target a specific chain id (implies '--omit-chain-ids')", value_name = "ID" )] src_chain_id: Option, diff --git a/scripts/init-hermes b/scripts/init-hermes index ebf006e514..9f91ca009e 100755 --- a/scripts/init-hermes +++ b/scripts/init-hermes @@ -63,14 +63,14 @@ cargo build -q --locked # add the key seeds to the keyring of each chain echo "Importing keys..." -cargo run -q --bin hermes -- -c "$CONFIG_FILE" keys add "$CHAIN_0_ID" -f "$GAIA_DATA/$CHAIN_0_ID/user_seed.json" -cargo run -q --bin hermes -- -c "$CONFIG_FILE" keys add "$CHAIN_0_ID" -f "$GAIA_DATA/$CHAIN_0_ID/user2_seed.json" -k user2 -cargo run -q --bin hermes -- -c "$CONFIG_FILE" keys add "$CHAIN_1_ID" -f "$GAIA_DATA/$CHAIN_1_ID/user_seed.json" -cargo run -q --bin hermes -- -c "$CONFIG_FILE" keys add "$CHAIN_1_ID" -f "$GAIA_DATA/$CHAIN_1_ID/user2_seed.json" -k user2 +cargo run -q --bin hermes -- --config "$CONFIG_FILE" keys add --chain "$CHAIN_0_ID" --key-file "$GAIA_DATA/$CHAIN_0_ID/user_seed.json" +cargo run -q --bin hermes -- --config "$CONFIG_FILE" keys add --chain "$CHAIN_0_ID" --key-file "$GAIA_DATA/$CHAIN_0_ID/user2_seed.json" --key-name user2 +cargo run -q --bin hermes -- --config "$CONFIG_FILE" keys add --chain "$CHAIN_1_ID" --key-file "$GAIA_DATA/$CHAIN_1_ID/user2_seed.json" --key-name user2 +cargo run -q --bin hermes -- --config "$CONFIG_FILE" keys add --chain "$CHAIN_1_ID" --key-file "$GAIA_DATA/$CHAIN_1_ID/user_seed.json" if [ -n "$CHAIN_2_ID" ]; then - cargo run -q --bin hermes -- -c "$CONFIG_FILE" keys add "$CHAIN_2_ID" -f "$GAIA_DATA/$CHAIN_2_ID/user_seed.json" - cargo run -q --bin hermes -- -c "$CONFIG_FILE" keys add "$CHAIN_2_ID" -f "$GAIA_DATA/$CHAIN_2_ID/user2_seed.json" -k user2 + cargo run -q --bin hermes -- --config "$CONFIG_FILE" keys add --chain "$CHAIN_2_ID" --key-file "$GAIA_DATA/$CHAIN_2_ID/user_seed.json" + cargo run -q --bin hermes -- --config "$CONFIG_FILE" keys add --chain "$CHAIN_2_ID" --key-file "$GAIA_DATA/$CHAIN_2_ID/user2_seed.json" --key-name user2 fi echo "Done!" From eb13cd02cf05336d91ac67b1f5432f540cb61930 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Fri, 10 Jun 2022 15:14:07 +0200 Subject: [PATCH 09/27] Completed 'tx raw upgrade-' commands guide page. Updated Testing client upgrade guide page --- guide/src/commands/raw/upgrade.md | 74 +++++++++++++++++++++++++++++- guide/src/commands/upgrade/test.md | 66 ++++++++++++++++++++++---- 2 files changed, 128 insertions(+), 12 deletions(-) diff --git a/guide/src/commands/raw/upgrade.md b/guide/src/commands/raw/upgrade.md index 317ba51285..4244e71ab3 100644 --- a/guide/src/commands/raw/upgrade.md +++ b/guide/src/commands/raw/upgrade.md @@ -20,6 +20,40 @@ FLAGS: --client identifier of the client to be upgraded ``` +__Example__ + +A given client is upgraded: + +```shell +hermes tx raw upgrade-client --chain ibc-1 --client 07-tendermint-0 +```` + +``` +Success: [ + UpdateClient( + h: 1-101, cs_h: 07-tendermint-0(0-84), + ), + UpgradeClient( + UpgradeClient( + Attributes { + height: Height { + revision: 1, + height: 101, + }, + client_id: ClientId( + "07-tendermint-0", + ), + client_type: Tendermint, + consensus_height: Height { + revision: 0, + height: 85, + }, + }, + ), + ), +] +``` + ## Upgrade Clients Use this to perform the upgrade on all the clients. @@ -36,6 +70,42 @@ FLAGS: targeting this chain will be upgraded ``` +__Example__ + +All the clients are upgraded: + +```shell +hermes tx raw upgrade-clients --chain ibc-1 +```` + +``` +Success: [ + [ + UpdateClient( + h: 1-111, cs_h: 07-tendermint-0(0-108), + ), + UpgradeClient( + UpgradeClient( + Attributes { + height: Height { + revision: 1, + height: 111, + }, + client_id: ClientId( + "07-tendermint-0", + ), + client_type: Tendermint, + consensus_height: Height { + revision: 0, + height: 109, + }, + }, + ), + ), + ], +] +``` + ## Upgrade Chain Use this to make an upgrade proposal. @@ -86,6 +156,6 @@ An upgrade proposal is made for `ibc-0`, for height `300` blocks from latest hei hermes tx raw upgrade-chain --dst-chain ibc-0 --src-chain ibc-1 --src-client 07-tendermint-0 --amount 10000000 --height-offset 300 ``` -```json -Success: transaction::Hash(CE98D8D98091BA8016BD852D18056E54C4CB3C4525E7F40DD3C40B4FD0F2482B) +``` +Success: transaction::Hash(779713508B6103E37FADE60483BEE964A90BD67E5F20037B2CC4AE0E90B707C3) ``` \ No newline at end of file diff --git a/guide/src/commands/upgrade/test.md b/guide/src/commands/upgrade/test.md index b62aae96e1..803f323fcf 100644 --- a/guide/src/commands/upgrade/test.md +++ b/guide/src/commands/upgrade/test.md @@ -17,14 +17,24 @@ commit: 535be14a8bdbfeb0d950914b5baa2dc72c6b081c ## Testing procedure -1. Start two gaia instances and initialize hermes: +### Setup - ```shell - ./scripts/dev-env ~/.hermes/config.toml ibc-0 ibc-1 - ``` - The `one-chain` script is invoked for each chain and modifies the `genesis.json` file to use a short window for governance proposals (`200s` for `max_deposit_period` and `voting_period`). Therefore, an upgrade proposal can be submitted, voted on and accepted within a short time. +__With dev-env__ + +```shell +./scripts/dev-env ~/.hermes/config.toml ibc-0 ibc-1 +``` +The `one-chain` script is invoked for each chain and modifies the `genesis.json` file to use a short window for governance proposals (`200s` for `max_deposit_period` and `voting_period`). Therefore, an upgrade proposal can be submitted, voted on and accepted within a short time. + + +__With gm__ +* Run the command `gm start` +* Go to the file `$HOME/.gm/ibc-0/config/genesis.json` and change `max_deposit_period` and `voting_period` to a lower value, such as 200s +* Run the commands: `gm reset`, `gm hermes config` and `gm keys` -2. Create one client on `ibc-1` for `ibc-0`: +### Test upgrading chain and client + +1. Create one client on `ibc-1` for `ibc-0`: ```shell hermes create client --dst-chain ibc-1 --src-chain ibc-0 @@ -45,7 +55,7 @@ commit: 535be14a8bdbfeb0d950914b5baa2dc72c6b081c ) ``` -3. Create and submit an upgrade plan for chain `ibc-0`: +2. Create and submit an upgrade plan for chain `ibc-0`: Use the hermes test command to make an upgrade proposal. In the example below a software upgrade proposal is made for `ibc-0`, for the height `300` blocks from latest height. `10000000stake` is deposited. The proposal includes the upgraded client state constructed from the state of `07-tendermint-0` client on `ibc-1` that was created in the previous step. In addition, the `unbonding_period` of the client is set to some new value (`400h`) @@ -60,14 +70,22 @@ commit: 535be14a8bdbfeb0d950914b5baa2dc72c6b081c Note that the height offset should be picked such that the proposal plan height is reached after the `200s` voting period. - 4. Verify that the proposal was accepted: + 3. Verify that the proposal was accepted: Query the upgrade plan to check that it was submitted correctly. Note the `height` at which the proposal will take effect (chain halts). Also `status: PROPOSAL_STATUS_VOTING_PERIOD`. + Setup done with dev-env: + ```shell gaiad query gov proposal 1 --home data/ibc-0/ ``` + Setup done with gm: + + ```shell + gaiad --node tcp://localhost: query gov proposal 1 --home $HOME/.gm/ibc-0/ + ``` + ```text content: '@type': /cosmos.upgrade.v1beta1.SoftwareUpgradeProposal @@ -149,14 +167,21 @@ commit: 535be14a8bdbfeb0d950914b5baa2dc72c6b081c voting_start_time: "2021-04-12T16:30:17.187389Z" ``` - 5. Vote on the proposal + 4. Vote on the proposal The parameter `1` should match the `proposal_id:` from the upgrade proposal submitted at step 3. This command must be issued while the proposal status is `PROPOSAL_STATUS_VOTING_PERIOD`. Confirm transaction when prompted. + Setup done with dev-env: + ```shell gaiad tx gov vote 1 yes --home data/ibc-0/data/ --keyring-backend test --keyring-dir data/ibc-0/ --chain-id ibc-0 --from validator ``` + Setup done with gm: + + ```shell + gaiad --node tcp://localhost: tx gov vote 1 yes --home $HOME/.gm/ibc-0/data/ --keyring-backend test --keyring-dir $HOME/.gm/ibc-0/ --chain-id ibc-0 --from validator + ``` ```text confirm transaction before signing and broadcasting [y/N]: y @@ -164,12 +189,19 @@ commit: 535be14a8bdbfeb0d950914b5baa2dc72c6b081c {"height":"85","txhash":"AC24D80B1BFE0832769DECFDD3B3DF999A363D5E4390B0B673344FFDED9150B2","codespace":"","code":0,"data":"0A060A04766F7465","raw_log":"[{\"events\":[{\"type\":\"message\",\"attributes\":[{\"key\":\"action\",\"value\":\"vote\"},{\"key\":\"module\",\"value\":\"governance\"},{\"key\":\"sender\",\"value\":\"cosmos1srfzw0jkyyn7wf0ps4zy0tuvdaclfj2ufgp6w3\"}]},{\"type\":\"proposal_vote\",\"attributes\":[{\"key\":\"option\",\"value\":\"VOTE_OPTION_YES\"},{\"key\":\"proposal_id\",\"value\":\"1\"}]}]}]","logs":[{"msg_index":0,"log":"","events":[{"type":"message","attributes":[{"key":"action","value":"vote"},{"key":"module","value":"governance"},{"key":"sender","value":"cosmos1srfzw0jkyyn7wf0ps4zy0tuvdaclfj2ufgp6w3"}]},{"type":"proposal_vote","attributes":[{"key":"option","value":"VOTE_OPTION_YES"},{"key":"proposal_id","value":"1"}]}]}],"info":"","gas_wanted":"200000","gas_used":"43716","tx":null,"timestamp":""} ``` - 6. Wait approximately 200 seconds until the proposal changes status to `PROPOSAL_STATUS_PASSED`. + 5. Wait approximately 200 seconds until the proposal changes status to `PROPOSAL_STATUS_PASSED`. Note the `final tally_result` that includes the vote submitted in the previous step. + Setup done with dev-env + ```shell gaiad query gov proposal 1 --home data/ibc-0/ ``` + Setup done with gm: + + ```shell + gaiad --node tcp://localhost: query gov proposal 1 --home $HOME/.gm/ibc-0/ + ``` ```text content: @@ -230,3 +262,17 @@ commit: 535be14a8bdbfeb0d950914b5baa2dc72c6b081c ), ] ``` + +If the command fails with the error: + +```shell +Error: failed while trying to upgrade client id 07-tendermint-0 for chain ibc-0: failed while fetching from chain the upgraded client state: conversion from a protobuf `Any` into a domain type failed: conversion from a protobuf `Any` into a domain type failed: error converting message type into domain type: the client state was not found +``` + +It might be due to the chain not being at the height defined for the upgrade. This can be check with the INFO output of the command: + +```shell +INFO ThreadId(01) [ibc-0 -> ibc-1:07-tendermint-0] upgrade Height: 0-82 +``` + +Where in this case the chain is at height 82. \ No newline at end of file From 7a25573a3c199bf326fe7b8d0619a9a5d5e4cdec Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Fri, 10 Jun 2022 15:23:55 +0200 Subject: [PATCH 10/27] Added changelog entry --- .../ibc-relayer-cli/2239-changed-args-to-flags.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .changelog/unreleased/breaking-changes/ibc-relayer-cli/2239-changed-args-to-flags.md diff --git a/.changelog/unreleased/breaking-changes/ibc-relayer-cli/2239-changed-args-to-flags.md b/.changelog/unreleased/breaking-changes/ibc-relayer-cli/2239-changed-args-to-flags.md new file mode 100644 index 0000000000..e024f5c75f --- /dev/null +++ b/.changelog/unreleased/breaking-changes/ibc-relayer-cli/2239-changed-args-to-flags.md @@ -0,0 +1,2 @@ +- Updated all CLI commands to take flags instead of positional arguments. + ([#2239](https://github.com/informalsystems/ibc-rs/issues/2239)) \ No newline at end of file From 2e3fff32c9651c72883cbce5d7c6d21ee937c822 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Wed, 15 Jun 2022 16:58:27 +0200 Subject: [PATCH 11/27] Added example unit-tests to the 'keys add' command --- relayer-cli/src/commands/keys/add.rs | 38 +++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/relayer-cli/src/commands/keys/add.rs b/relayer-cli/src/commands/keys/add.rs index f9139a618e..67ffcdedd2 100644 --- a/relayer-cli/src/commands/keys/add.rs +++ b/relayer-cli/src/commands/keys/add.rs @@ -30,7 +30,7 @@ use crate::conclude::Output; /// /// The key-file and mnemonic-file flags can't be given at the same time, this will cause a terminating error. /// If successful the key will be created or restored, depending on which flag was given. -#[derive(Clone, Command, Debug, Parser)] +#[derive(Clone, Command, Debug, Parser, PartialEq)] pub struct KeysAddCmd { #[clap(long = "chain", required = true, help = "identifier of the chain")] chain_id: ChainId, @@ -175,3 +175,39 @@ pub fn restore_key( keyring.add_key(key_name, key_entry.clone())?; Ok(key_entry) } + +#[cfg(test)] +mod tests { + + use super::KeysAddCmd; + use std::path::PathBuf; + + use abscissa_core::clap::Parser; + use ibc::core::ics24_host::identifier::ChainId; + + #[test] + fn test_keys_add_key_file() { + assert_eq!( + KeysAddCmd{ chain_id: ChainId::from_string("chain_id"), key_file: Some(PathBuf::from("key_file")), mnemonic_file: None, key_name: None, hd_path: "m/44'/118'/0'/0/0".to_string() }, + KeysAddCmd::try_parse_from(&["test", "--chain", "chain_id", "--key-file", "key_file"]).unwrap() + ) + } + + #[test] + fn test_keys_add_mnemonic_file() { + assert_eq!( + KeysAddCmd{ chain_id: ChainId::from_string("chain_id"), key_file: None, mnemonic_file: Some(PathBuf::from("mnemonic_file")), key_name: None, hd_path: "m/44'/118'/0'/0/0".to_string() }, + KeysAddCmd::try_parse_from(&["test", "--chain", "chain_id", "--mnemonic-file", "mnemonic_file"]).unwrap() + ) + } + + #[test] + fn test_keys_add_no_file() { + assert!(KeysAddCmd::try_parse_from(&["test", "--chain", "chain_id"]).is_err()); + } + + #[test] + fn test_keys_add_key_and_mnemonic() { + assert!(KeysAddCmd::try_parse_from(&["test", "--chain", "chain_id", "--key-file", "key_file", "--mnemonic-file", "mnemonic_file"]).is_err()); + } +} \ No newline at end of file From ff8411936208470c0daa4703156b79005218d172 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Fri, 17 Jun 2022 09:48:03 +0200 Subject: [PATCH 12/27] Added value names to parameters and removed cli parsing unit-tests --- relayer-cli/src/commands/completions.rs | 2 +- relayer-cli/src/commands/create/channel.rs | 5 +++ relayer-cli/src/commands/create/connection.rs | 2 ++ relayer-cli/src/commands/keys/add.rs | 36 ------------------- relayer-cli/src/commands/query/channels.rs | 3 +- relayer-cli/src/commands/query/clients.rs | 7 ++-- relayer-cli/src/commands/tx/client.rs | 29 +++++++++------ 7 files changed, 32 insertions(+), 52 deletions(-) diff --git a/relayer-cli/src/commands/completions.rs b/relayer-cli/src/commands/completions.rs index 392cd9bb13..9bcb31becc 100644 --- a/relayer-cli/src/commands/completions.rs +++ b/relayer-cli/src/commands/completions.rs @@ -7,7 +7,7 @@ use std::io; #[derive(Debug, Parser)] pub struct CompletionsCmd { - #[clap(arg_enum)] + #[clap(long = "shell", arg_enum)] shell: Shell, } diff --git a/relayer-cli/src/commands/create/channel.rs b/relayer-cli/src/commands/create/channel.rs index 8078acbf21..3f8999e43b 100644 --- a/relayer-cli/src/commands/create/channel.rs +++ b/relayer-cli/src/commands/create/channel.rs @@ -47,18 +47,21 @@ pub struct CreateChannelCommand { #[clap( long = "chain-a", required = true, + value_name = "CHAIN_A_ID", help = "Identifier of the side `a` chain for the new channel" )] chain_a: ChainId, #[clap( long = "chain-b", + value_name = "CHAIN_B_ID", help = "Identifier of the side `b` chain for the new channel" )] chain_b: Option, #[clap( long = "conn-a", + value_name = "CONNECTION_A_ID", help = "Identifier of the connection on chain `a` to use in creating the new channel." )] connection_a: Option, @@ -66,6 +69,7 @@ pub struct CreateChannelCommand { #[clap( long = "port-a", required = true, + value_name = "PORT_A_ID", help = "Identifier of the side `a` port for the new channel" )] port_a: PortId, @@ -73,6 +77,7 @@ pub struct CreateChannelCommand { #[clap( long = "port-b", required = true, + value_name = "PORT_B_ID", help = "Identifier of the side `b` port for the new channel" )] port_b: PortId, diff --git a/relayer-cli/src/commands/create/connection.rs b/relayer-cli/src/commands/create/connection.rs index 5ae51fc90b..2949364840 100644 --- a/relayer-cli/src/commands/create/connection.rs +++ b/relayer-cli/src/commands/create/connection.rs @@ -32,12 +32,14 @@ pub struct CreateConnectionCommand { #[clap( long = "client-a", + value_name = "CLIENT_A_ID", help = "identifier of client hosted on chain `a`; default: None (creates a new client)" )] client_a: Option, #[clap( long = "client-b", + value_name = "CLIENT_B_ID", help = "identifier of client hosted on chain `b`; default: None (creates a new client)" )] client_b: Option, diff --git a/relayer-cli/src/commands/keys/add.rs b/relayer-cli/src/commands/keys/add.rs index 67ffcdedd2..c923ad5bd5 100644 --- a/relayer-cli/src/commands/keys/add.rs +++ b/relayer-cli/src/commands/keys/add.rs @@ -174,40 +174,4 @@ pub fn restore_key( keyring.add_key(key_name, key_entry.clone())?; Ok(key_entry) -} - -#[cfg(test)] -mod tests { - - use super::KeysAddCmd; - use std::path::PathBuf; - - use abscissa_core::clap::Parser; - use ibc::core::ics24_host::identifier::ChainId; - - #[test] - fn test_keys_add_key_file() { - assert_eq!( - KeysAddCmd{ chain_id: ChainId::from_string("chain_id"), key_file: Some(PathBuf::from("key_file")), mnemonic_file: None, key_name: None, hd_path: "m/44'/118'/0'/0/0".to_string() }, - KeysAddCmd::try_parse_from(&["test", "--chain", "chain_id", "--key-file", "key_file"]).unwrap() - ) - } - - #[test] - fn test_keys_add_mnemonic_file() { - assert_eq!( - KeysAddCmd{ chain_id: ChainId::from_string("chain_id"), key_file: None, mnemonic_file: Some(PathBuf::from("mnemonic_file")), key_name: None, hd_path: "m/44'/118'/0'/0/0".to_string() }, - KeysAddCmd::try_parse_from(&["test", "--chain", "chain_id", "--mnemonic-file", "mnemonic_file"]).unwrap() - ) - } - - #[test] - fn test_keys_add_no_file() { - assert!(KeysAddCmd::try_parse_from(&["test", "--chain", "chain_id"]).is_err()); - } - - #[test] - fn test_keys_add_key_and_mnemonic() { - assert!(KeysAddCmd::try_parse_from(&["test", "--chain", "chain_id", "--key-file", "key_file", "--mnemonic-file", "mnemonic_file"]).is_err()); - } } \ No newline at end of file diff --git a/relayer-cli/src/commands/query/channels.rs b/relayer-cli/src/commands/query/channels.rs index 3603c490c6..c3c8014847 100644 --- a/relayer-cli/src/commands/query/channels.rs +++ b/relayer-cli/src/commands/query/channels.rs @@ -29,7 +29,8 @@ pub struct QueryChannelsCmd { chain_id: ChainId, #[clap( - long = "dst-chain", + long = "chain-counterparty", + value_name = "CHAIN_COUNTERPARTY_ID", help = "identifier of the channel's destination chain" )] dst_chain_id: Option, diff --git a/relayer-cli/src/commands/query/clients.rs b/relayer-cli/src/commands/query/clients.rs index 384eac5cd6..eb82806a22 100644 --- a/relayer-cli/src/commands/query/clients.rs +++ b/relayer-cli/src/commands/query/clients.rs @@ -18,16 +18,17 @@ use crate::prelude::*; #[derive(Clone, Command, Debug, Parser)] pub struct QueryAllClientsCmd { #[clap( - long = "chain", + long = "chain-host", required = true, + value_name = "CHAIN_HOST_ID", help = "identifier of the chain to query" )] chain_id: ChainId, #[clap( - long = "src-chain", + long = "chain-reference", help = "filter for clients which target a specific chain id (implies '--omit-chain-ids')", - value_name = "ID" + value_name = "CHAIN_REFERENCE_ID" )] src_chain_id: Option, diff --git a/relayer-cli/src/commands/tx/client.rs b/relayer-cli/src/commands/tx/client.rs index cfd59c2428..c2ff6de1c5 100644 --- a/relayer-cli/src/commands/tx/client.rs +++ b/relayer-cli/src/commands/tx/client.rs @@ -22,16 +22,18 @@ use crate::error::Error; #[derive(Clone, Command, Debug, Parser)] pub struct TxCreateClientCmd { #[clap( - long = "dst-chain", + long = "chain-host", required = true, - help = "identifier of the destination chain" + value_name = "CHAIN_HOST_ID", + help = "identifier of the chain that hosts the client" )] dst_chain_id: ChainId, #[clap( - long = "src-chain", + long = "chain-reference", required = true, - help = "identifier of the source chain" + value_name = "CHAIN_REFERENCE_ID", + help = "identifier of the chain targeted by the client" )] src_chain_id: ChainId, @@ -100,27 +102,31 @@ impl Runnable for TxCreateClientCmd { #[derive(Clone, Command, Debug, Parser)] pub struct TxUpdateClientCmd { #[clap( - long = "dst-chain", + long = "chain-host", required = true, - help = "identifier of the destination chain" + value_name = "CHAIN_HOST_ID", + help = "identifier of the chain that hosts the client" )] dst_chain_id: ChainId, #[clap( - long = "dst-client", + long = "client-reference", required = true, - help = "identifier of the client to be updated on destination chain" + value_name = "CHAIN_REFERENCE_ID", + help = "identifier of the chain targeted by the client" )] dst_client_id: ClientId, #[clap( - long = "target-height", + long = "height", + value_name = "REFERENCE_HEIGHT", help = "the target height of the client update" )] target_height: Option, #[clap( long = "trusted-height", + value_name = "REFERENCE_TRUSTED_HEIGHT", help = "the trusted height of the client update" )] trusted_height: Option, @@ -181,7 +187,7 @@ impl Runnable for TxUpdateClientCmd { #[derive(Clone, Command, Debug, Parser)] pub struct TxUpgradeClientCmd { #[clap( - long = "chain", + long = "chain-host", required = true, help = "identifier of the chain that hosts the client" )] @@ -238,8 +244,9 @@ impl Runnable for TxUpgradeClientCmd { #[derive(Clone, Command, Debug, Parser)] pub struct TxUpgradeClientsCmd { #[clap( - long = "src-chain", + long = "chain-reference", required = true, + value_name = "CHAIN_REFERENCE_ID", help = "identifier of the chain that underwent an upgrade; all clients targeting this chain will be upgraded" )] src_chain_id: ChainId, From 4d3580070c2bfd1168ae9bd4d97ac37032919e18 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Fri, 17 Jun 2022 09:49:43 +0200 Subject: [PATCH 13/27] Cargo fmt changes --- relayer-cli/src/commands/keys/add.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/relayer-cli/src/commands/keys/add.rs b/relayer-cli/src/commands/keys/add.rs index c923ad5bd5..1847ac67ea 100644 --- a/relayer-cli/src/commands/keys/add.rs +++ b/relayer-cli/src/commands/keys/add.rs @@ -174,4 +174,4 @@ pub fn restore_key( keyring.add_key(key_name, key_entry.clone())?; Ok(key_entry) -} \ No newline at end of file +} From c7e1b9a7cd2de05e62e5f6b62d4d751eb7f8e21f Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Fri, 17 Jun 2022 16:09:38 +0200 Subject: [PATCH 14/27] Updated flags in order to reflect ADR 010 --- relayer-cli/src/commands/clear.rs | 21 +++++++++++-- relayer-cli/src/commands/completions.rs | 2 +- relayer-cli/src/commands/create/channel.rs | 22 +++++++------- relayer-cli/src/commands/create/connection.rs | 15 ++++++---- relayer-cli/src/commands/keys/add.rs | 4 +++ relayer-cli/src/commands/keys/balance.rs | 8 ++++- relayer-cli/src/commands/keys/delete.rs | 9 ++++-- relayer-cli/src/commands/keys/list.rs | 7 ++++- relayer-cli/src/commands/listen.rs | 2 +- relayer-cli/src/commands/misbehaviour.rs | 2 ++ relayer-cli/src/commands/query/channel.rs | 9 +++++- .../src/commands/query/channel_client.rs | 3 ++ .../src/commands/query/channel_ends.rs | 9 +++++- relayer-cli/src/commands/query/channels.rs | 5 ++-- relayer-cli/src/commands/query/client.rs | 24 +++++++++++++-- relayer-cli/src/commands/query/clients.rs | 8 ++--- relayer-cli/src/commands/query/connection.rs | 10 ++++++- relayer-cli/src/commands/query/connections.rs | 1 + relayer-cli/src/commands/query/packet/ack.rs | 16 ++++++++-- relayer-cli/src/commands/query/packet/acks.rs | 3 ++ .../src/commands/query/packet/commitment.rs | 16 ++++++++-- .../src/commands/query/packet/commitments.rs | 3 ++ .../src/commands/query/packet/pending.rs | 3 ++ .../commands/query/packet/unreceived_acks.rs | 15 ++++++++-- .../query/packet/unreceived_packets.rs | 15 ++++++++-- relayer-cli/src/commands/query/tx/events.rs | 8 ++++- relayer-cli/src/commands/tx/client.rs | 30 ++++++++++--------- 27 files changed, 211 insertions(+), 59 deletions(-) diff --git a/relayer-cli/src/commands/clear.rs b/relayer-cli/src/commands/clear.rs index cbfd9fa805..054ac05374 100644 --- a/relayer-cli/src/commands/clear.rs +++ b/relayer-cli/src/commands/clear.rs @@ -23,13 +23,28 @@ pub enum ClearCmds { #[derive(Debug, Parser)] pub struct ClearPacketsCmd { - #[clap(long = "chain", required = true, help = "identifier of the chain")] + #[clap( + long = "chain", + required = true, + value_name = "CHAIN_ID", + help = "identifier of the chain" + )] chain_id: ChainId, - #[clap(long = "port", required = true, help = "identifier of the port")] + #[clap( + long = "port", + required = true, + value_name = "PORT_ID", + help = "identifier of the port" + )] port_id: PortId, - #[clap(long = "chan", required = true, help = "identifier of the channel")] + #[clap( + long = "chan", + required = true, + value_name = "CHANNEL_ID", + help = "identifier of the channel" + )] channel_id: ChannelId, } diff --git a/relayer-cli/src/commands/completions.rs b/relayer-cli/src/commands/completions.rs index 9bcb31becc..bc7ca6c235 100644 --- a/relayer-cli/src/commands/completions.rs +++ b/relayer-cli/src/commands/completions.rs @@ -7,7 +7,7 @@ use std::io; #[derive(Debug, Parser)] pub struct CompletionsCmd { - #[clap(long = "shell", arg_enum)] + #[clap(long = "shell", value_name = "SHELL", arg_enum)] shell: Shell, } diff --git a/relayer-cli/src/commands/create/channel.rs b/relayer-cli/src/commands/create/channel.rs index 3f8999e43b..b4ae11d76a 100644 --- a/relayer-cli/src/commands/create/channel.rs +++ b/relayer-cli/src/commands/create/channel.rs @@ -45,45 +45,46 @@ static HINT: &str = "Consider using the default invocation\n\nhermes create chan #[clap(disable_version_flag = true)] pub struct CreateChannelCommand { #[clap( - long = "chain-a", + long = "a-chain", required = true, - value_name = "CHAIN_A_ID", + value_name = "A_CHAIN_ID", help = "Identifier of the side `a` chain for the new channel" )] chain_a: ChainId, #[clap( - long = "chain-b", - value_name = "CHAIN_B_ID", + long = "b-chain", + value_name = "B_CHAIN_ID", help = "Identifier of the side `b` chain for the new channel" )] chain_b: Option, #[clap( - long = "conn-a", - value_name = "CONNECTION_A_ID", + long = "a-conn", + value_name = "A_CONNECTION_ID", help = "Identifier of the connection on chain `a` to use in creating the new channel." )] connection_a: Option, #[clap( - long = "port-a", + long = "a-port", required = true, - value_name = "PORT_A_ID", + value_name = "A_PORT_ID", help = "Identifier of the side `a` port for the new channel" )] port_a: PortId, #[clap( - long = "port-b", + long = "b-port", required = true, - value_name = "PORT_B_ID", + value_name = "B_PORT_ID", help = "Identifier of the side `b` port for the new channel" )] port_b: PortId, #[clap( long = "order", + value_name = "ORDER", help = "The channel ordering, valid options 'unordered' (default) and 'ordered'", default_value_t )] @@ -92,6 +93,7 @@ pub struct CreateChannelCommand { #[clap( long = "chan-version", alias = "version", + value_name = "VERSION", help = "The version for the new channel" )] version: Option, diff --git a/relayer-cli/src/commands/create/connection.rs b/relayer-cli/src/commands/create/connection.rs index 2949364840..b4d862a917 100644 --- a/relayer-cli/src/commands/create/connection.rs +++ b/relayer-cli/src/commands/create/connection.rs @@ -18,34 +18,37 @@ use crate::prelude::*; #[derive(Clone, Command, Debug, Parser)] pub struct CreateConnectionCommand { #[clap( - long = "chain-a", + long = "a-chain", required = true, + value_name = "A_CHAIN_ID", help = "identifier of the side `a` chain for the new connection" )] chain_a_id: ChainId, #[clap( - long = "chain-b", + long = "b-chain", + value_name = "B_CHAIN_ID", help = "identifier of the side `b` chain for the new connection" )] chain_b_id: Option, #[clap( - long = "client-a", - value_name = "CLIENT_A_ID", + long = "a-client", + value_name = "A_CLIENT_ID", help = "identifier of client hosted on chain `a`; default: None (creates a new client)" )] client_a: Option, #[clap( - long = "client-b", - value_name = "CLIENT_B_ID", + long = "b-client", + value_name = "B_CLIENT_ID", help = "identifier of client hosted on chain `b`; default: None (creates a new client)" )] client_b: Option, #[clap( long = "delay", + value_name = "DELAY", help = "delay period parameter for the new connection (seconds)", default_value = "0" )] diff --git a/relayer-cli/src/commands/keys/add.rs b/relayer-cli/src/commands/keys/add.rs index 1847ac67ea..41a594a05b 100644 --- a/relayer-cli/src/commands/keys/add.rs +++ b/relayer-cli/src/commands/keys/add.rs @@ -38,6 +38,7 @@ pub struct KeysAddCmd { #[clap( long = "key-file", required = true, + value_name = "KEY_FILE", help = "path to the key file", group = "add-restore" )] @@ -46,6 +47,7 @@ pub struct KeysAddCmd { #[clap( long = "mnemonic-file", required = true, + value_name = "MNEMONIC_FILE", help = "path to file containing mnemonic to restore the key from", group = "add-restore" )] @@ -53,12 +55,14 @@ pub struct KeysAddCmd { #[clap( long = "key-name", + value_name = "KEY_NAME", help = "name of the key (defaults to the `key_name` defined in the config)" )] key_name: Option, #[clap( long = "hd-path", + value_name = "HD_PATH", help = "derivation path for this key", default_value = "m/44'/118'/0'/0/0" )] diff --git a/relayer-cli/src/commands/keys/balance.rs b/relayer-cli/src/commands/keys/balance.rs index 9008536473..6d911469d5 100644 --- a/relayer-cli/src/commands/keys/balance.rs +++ b/relayer-cli/src/commands/keys/balance.rs @@ -19,11 +19,17 @@ use crate::conclude::{exit_with_unrecoverable_error, json, Output}; /// on the given chain, will be displayed. #[derive(Clone, Command, Debug, Parser)] pub struct KeyBalanceCmd { - #[clap(long = "chain", required = true, help = "identifier of the chain")] + #[clap( + long = "chain", + required = true, + value_name = "CHAIN_ID", + help = "identifier of the chain" + )] chain_id: ChainId, #[clap( long = "key-name", + value_name = "KEY_NAME", help = "(optional) name of the key (defaults to the `key_name` defined in the config)" )] key_name: Option, diff --git a/relayer-cli/src/commands/keys/delete.rs b/relayer-cli/src/commands/keys/delete.rs index 3873f7c1e1..f5af54c604 100644 --- a/relayer-cli/src/commands/keys/delete.rs +++ b/relayer-cli/src/commands/keys/delete.rs @@ -12,10 +12,15 @@ use crate::conclude::Output; #[derive(Clone, Command, Debug, Parser)] pub struct KeysDeleteCmd { - #[clap(long = "chain", required = true, help = "identifier of the chain")] + #[clap( + long = "chain", + required = true, + value_name = "CHAIN_ID", + help = "identifier of the chain" + )] chain_id: ChainId, - #[clap(long = "key-name", help = "name of the key")] + #[clap(long = "key-name", value_name = "KEY_NAME", help = "name of the key")] key_name: Option, #[clap(long = "all", help = "delete all keys")] diff --git a/relayer-cli/src/commands/keys/list.rs b/relayer-cli/src/commands/keys/list.rs index bfc978206d..428b1c3c42 100644 --- a/relayer-cli/src/commands/keys/list.rs +++ b/relayer-cli/src/commands/keys/list.rs @@ -14,7 +14,12 @@ use crate::{application::app_config, conclude::json}; #[derive(Clone, Command, Debug, Parser)] pub struct KeysListCmd { - #[clap(long = "chain", required = true, help = "identifier of the chain")] + #[clap( + long = "chain", + required = true, + value_name = "CHAIN_ID", + help = "identifier of the chain" + )] chain_id: ChainId, } diff --git a/relayer-cli/src/commands/listen.rs b/relayer-cli/src/commands/listen.rs index a646b28e5f..83775f9059 100644 --- a/relayer-cli/src/commands/listen.rs +++ b/relayer-cli/src/commands/listen.rs @@ -61,7 +61,7 @@ impl FromStr for EventFilter { #[derive(Debug, Parser)] pub struct ListenCmd { /// Identifier of the chain to listen for events from - #[clap(long = "chain", required = true)] + #[clap(long = "chain", required = true, value_name = "CHAIN_ID")] chain_id: ChainId, /// Add an event type to listen for, can be repeated. diff --git a/relayer-cli/src/commands/misbehaviour.rs b/relayer-cli/src/commands/misbehaviour.rs index 623f333552..36fb4e3f15 100644 --- a/relayer-cli/src/commands/misbehaviour.rs +++ b/relayer-cli/src/commands/misbehaviour.rs @@ -20,6 +20,7 @@ pub struct MisbehaviourCmd { #[clap( long = "chain", required = true, + value_name = "CHAIN_ID", help = "identifier of the chain where client updates are monitored for misbehaviour" )] chain_id: ChainId, @@ -27,6 +28,7 @@ pub struct MisbehaviourCmd { #[clap( long = "client", required = true, + value_name = "CLIENT_ID", help = "identifier of the client to be monitored for misbehaviour" )] client_id: ClientId, diff --git a/relayer-cli/src/commands/query/channel.rs b/relayer-cli/src/commands/query/channel.rs index 1500b53746..af4b52f1b1 100644 --- a/relayer-cli/src/commands/query/channel.rs +++ b/relayer-cli/src/commands/query/channel.rs @@ -18,6 +18,7 @@ pub struct QueryChannelEndCmd { #[clap( long = "chain", required = true, + value_name = "CHAIN_ID", help = "identifier of the chain to query" )] chain_id: ChainId, @@ -25,6 +26,7 @@ pub struct QueryChannelEndCmd { #[clap( long = "port", required = true, + value_name = "PORT_ID", help = "identifier of the port to query" )] port_id: PortId, @@ -32,11 +34,16 @@ pub struct QueryChannelEndCmd { #[clap( long = "chan", required = true, + value_name = "CHANNEL_ID", help = "identifier of the channel to query" )] channel_id: ChannelId, - #[clap(long = "height", help = "height of the state to query")] + #[clap( + long = "height", + value_name = "HEIGHT", + help = "height of the state to query" + )] height: Option, } diff --git a/relayer-cli/src/commands/query/channel_client.rs b/relayer-cli/src/commands/query/channel_client.rs index 88341cb383..1d84fbd6c5 100644 --- a/relayer-cli/src/commands/query/channel_client.rs +++ b/relayer-cli/src/commands/query/channel_client.rs @@ -19,6 +19,7 @@ pub struct QueryChannelClientCmd { #[clap( long = "chain", required = true, + value_name = "CHAIN_ID", help = "identifier of the chain to query" )] chain_id: ChainId, @@ -26,6 +27,7 @@ pub struct QueryChannelClientCmd { #[clap( long = "port", required = true, + value_name = "PORT_ID", help = "identifier of the port to query" )] port_id: PortId, @@ -33,6 +35,7 @@ pub struct QueryChannelClientCmd { #[clap( long = "chan", required = true, + value_name = "CHANNEL_ID", help = "identifier of the channel to query" )] channel_id: ChannelId, diff --git a/relayer-cli/src/commands/query/channel_ends.rs b/relayer-cli/src/commands/query/channel_ends.rs index fa3f9c87d9..f731ec40d6 100644 --- a/relayer-cli/src/commands/query/channel_ends.rs +++ b/relayer-cli/src/commands/query/channel_ends.rs @@ -22,6 +22,7 @@ pub struct QueryChannelEndsCmd { #[clap( long = "chain", required = true, + value_name = "CHAIN_ID", help = "identifier of the chain to query" )] chain_id: ChainId, @@ -29,6 +30,7 @@ pub struct QueryChannelEndsCmd { #[clap( long = "port", required = true, + value_name = "PORT_ID", help = "identifier of the port to query" )] port_id: PortId, @@ -36,11 +38,16 @@ pub struct QueryChannelEndsCmd { #[clap( long = "chan", required = true, + value_name = "CHANNEL_ID", help = "identifier of the channel to query" )] channel_id: ChannelId, - #[clap(long = "height", help = "height of the state to query")] + #[clap( + long = "height", + value_name = "HEIGHT", + help = "height of the state to query" + )] height: Option, #[clap( diff --git a/relayer-cli/src/commands/query/channels.rs b/relayer-cli/src/commands/query/channels.rs index c3c8014847..39761f0e70 100644 --- a/relayer-cli/src/commands/query/channels.rs +++ b/relayer-cli/src/commands/query/channels.rs @@ -24,13 +24,14 @@ pub struct QueryChannelsCmd { #[clap( long = "chain", required = true, + value_name = "CHAIN_ID", help = "identifier of the chain to query" )] chain_id: ChainId, #[clap( - long = "chain-counterparty", - value_name = "CHAIN_COUNTERPARTY_ID", + long = "counterparty-chain", + value_name = "COUNTERPARTY_CHAIN_ID", help = "identifier of the channel's destination chain" )] dst_chain_id: Option, diff --git a/relayer-cli/src/commands/query/client.rs b/relayer-cli/src/commands/query/client.rs index 2f93ac0cd2..8d4695ed65 100644 --- a/relayer-cli/src/commands/query/client.rs +++ b/relayer-cli/src/commands/query/client.rs @@ -28,6 +28,7 @@ pub struct QueryClientStateCmd { #[clap( long = "chain", required = true, + value_name = "CHAIN_ID", help = "identifier of the chain to query" )] chain_id: ChainId, @@ -35,11 +36,16 @@ pub struct QueryClientStateCmd { #[clap( long = "client", required = true, + value_name = "CLIENT_ID", help = "identifier of the client to query" )] client_id: ClientId, - #[clap(long = "height", help = "the chain height context for the query")] + #[clap( + long = "height", + value_name = "HEIGHT", + help = "the chain height context for the query" + )] height: Option, } @@ -79,6 +85,7 @@ pub struct QueryClientConsensusCmd { #[clap( long = "chain", required = true, + value_name = "CHAIN_ID", help = "identifier of the chain to query" )] chain_id: ChainId, @@ -86,12 +93,14 @@ pub struct QueryClientConsensusCmd { #[clap( long = "client", required = true, + value_name = "CLIENT_ID", help = "identifier of the client to query" )] client_id: ClientId, #[clap( long = "consensus-height", + value_name = "CONSENSUS_HEIGHT", help = "height of the client's consensus state to query" )] consensus_height: Option, @@ -101,6 +110,7 @@ pub struct QueryClientConsensusCmd { #[clap( long = "height", + value_name = "HEIGHT", help = "the chain height context to be used, applicable only to a specific height" )] height: Option, @@ -182,6 +192,7 @@ pub struct QueryClientHeaderCmd { #[clap( long = "chain", required = true, + value_name = "CHAIN_ID", help = "identifier of the chain to query" )] chain_id: ChainId, @@ -189,6 +200,7 @@ pub struct QueryClientHeaderCmd { #[clap( long = "client", required = true, + value_name = "CLIENT_ID", help = "identifier of the client to query" )] client_id: ClientId, @@ -196,11 +208,16 @@ pub struct QueryClientHeaderCmd { #[clap( long = "consensus-height", required = true, + value_name = "CONSENSUS_HEIGHT", help = "height of header to query" )] consensus_height: u64, - #[clap(long = "height", help = "the chain height context for the query")] + #[clap( + long = "height", + value_name = "HEIGHT", + help = "the chain height context for the query" + )] height: Option, } @@ -261,6 +278,7 @@ pub struct QueryClientConnectionsCmd { #[clap( long = "chain", required = true, + value_name = "CHAIN_ID", help = "identifier of the chain to query" )] chain_id: ChainId, @@ -268,12 +286,14 @@ pub struct QueryClientConnectionsCmd { #[clap( long = "client", required = true, + value_name = "CLIENT_ID", help = "identifier of the client to query" )] client_id: ClientId, #[clap( long = "height", + value_name = "HEIGHT", help = "the chain height which this query should reflect" )] height: Option, diff --git a/relayer-cli/src/commands/query/clients.rs b/relayer-cli/src/commands/query/clients.rs index eb82806a22..7acf2fc8d7 100644 --- a/relayer-cli/src/commands/query/clients.rs +++ b/relayer-cli/src/commands/query/clients.rs @@ -18,17 +18,17 @@ use crate::prelude::*; #[derive(Clone, Command, Debug, Parser)] pub struct QueryAllClientsCmd { #[clap( - long = "chain-host", + long = "host-chain", required = true, - value_name = "CHAIN_HOST_ID", + value_name = "HOST_CHAIN_ID", help = "identifier of the chain to query" )] chain_id: ChainId, #[clap( - long = "chain-reference", + long = "reference-chain", help = "filter for clients which target a specific chain id (implies '--omit-chain-ids')", - value_name = "CHAIN_REFERENCE_ID" + value_name = "REFERENCE_CHAIN_ID" )] src_chain_id: Option, diff --git a/relayer-cli/src/commands/query/connection.rs b/relayer-cli/src/commands/query/connection.rs index cb583a39c5..0eb4805605 100644 --- a/relayer-cli/src/commands/query/connection.rs +++ b/relayer-cli/src/commands/query/connection.rs @@ -23,6 +23,7 @@ pub struct QueryConnectionEndCmd { #[clap( long = "chain", required = true, + value_name = "CHAIN_ID", help = "identifier of the chain to query" )] chain_id: ChainId, @@ -30,11 +31,16 @@ pub struct QueryConnectionEndCmd { #[clap( long = "conn", required = true, + value_name = "CONNECTION_ID", help = "identifier of the connection to query" )] connection_id: ConnectionId, - #[clap(long = "height", help = "height of the state to query")] + #[clap( + long = "height", + value_name = "HEIGHT", + help = "height of the state to query" + )] height: Option, } @@ -88,6 +94,7 @@ pub struct QueryConnectionChannelsCmd { #[clap( long = "chain", required = true, + value_name = "CHAIN_ID", help = "identifier of the chain to query" )] chain_id: ChainId, @@ -95,6 +102,7 @@ pub struct QueryConnectionChannelsCmd { #[clap( long = "conn", required = true, + value_name = "CONNECTION_ID", help = "identifier of the connection to query" )] connection_id: ConnectionId, diff --git a/relayer-cli/src/commands/query/connections.rs b/relayer-cli/src/commands/query/connections.rs index f53d88a4ff..51f9964598 100644 --- a/relayer-cli/src/commands/query/connections.rs +++ b/relayer-cli/src/commands/query/connections.rs @@ -16,6 +16,7 @@ pub struct QueryConnectionsCmd { #[clap( long = "chain", required = true, + value_name = "CHAIN_ID", help = "identifier of the chain to query" )] chain_id: ChainId, diff --git a/relayer-cli/src/commands/query/packet/ack.rs b/relayer-cli/src/commands/query/packet/ack.rs index 4227815a67..70ef2dfd2c 100644 --- a/relayer-cli/src/commands/query/packet/ack.rs +++ b/relayer-cli/src/commands/query/packet/ack.rs @@ -17,6 +17,7 @@ pub struct QueryPacketAcknowledgmentCmd { #[clap( long = "chain", required = true, + value_name = "CHAIN_ID", help = "identifier of the chain to query" )] chain_id: ChainId, @@ -24,6 +25,7 @@ pub struct QueryPacketAcknowledgmentCmd { #[clap( long = "port", required = true, + value_name = "PORT_ID", help = "identifier of the port to query" )] port_id: PortId, @@ -31,14 +33,24 @@ pub struct QueryPacketAcknowledgmentCmd { #[clap( long = "chan", required = true, + value_name = "CHANNEL_ID", help = "identifier of the channel to query" )] channel_id: ChannelId, - #[clap(long = "seq", required = true, help = "sequence of packet to query")] + #[clap( + long = "seq", + required = true, + value_name = "SEQUENCE", + help = "sequence of packet to query" + )] sequence: Sequence, - #[clap(long = "height", help = "height of the state to query")] + #[clap( + long = "height", + value_name = "HEIGHT", + help = "height of the state to query" + )] height: Option, } diff --git a/relayer-cli/src/commands/query/packet/acks.rs b/relayer-cli/src/commands/query/packet/acks.rs index c50d5f9670..1ba0df863b 100644 --- a/relayer-cli/src/commands/query/packet/acks.rs +++ b/relayer-cli/src/commands/query/packet/acks.rs @@ -24,6 +24,7 @@ pub struct QueryPacketAcknowledgementsCmd { #[clap( long = "chain", required = true, + value_name = "CHAIN_ID", help = "identifier of the chain to query" )] chain_id: ChainId, @@ -31,6 +32,7 @@ pub struct QueryPacketAcknowledgementsCmd { #[clap( long = "port", required = true, + value_name = "PORT_ID", help = "identifier of the port to query" )] port_id: PortId, @@ -38,6 +40,7 @@ pub struct QueryPacketAcknowledgementsCmd { #[clap( long = "chan", required = true, + value_name = "CHANNEL_ID", help = "identifier of the channel to query" )] channel_id: ChannelId, diff --git a/relayer-cli/src/commands/query/packet/commitment.rs b/relayer-cli/src/commands/query/packet/commitment.rs index 1de2dcb531..e272f5001f 100644 --- a/relayer-cli/src/commands/query/packet/commitment.rs +++ b/relayer-cli/src/commands/query/packet/commitment.rs @@ -24,6 +24,7 @@ pub struct QueryPacketCommitmentCmd { #[clap( long = "chain", required = true, + value_name = "CHAIN_ID", help = "identifier of the chain to query" )] chain_id: ChainId, @@ -31,6 +32,7 @@ pub struct QueryPacketCommitmentCmd { #[clap( long = "port", required = true, + value_name = "PORT_ID", help = "identifier of the port to query" )] port_id: PortId, @@ -38,14 +40,24 @@ pub struct QueryPacketCommitmentCmd { #[clap( long = "chan", required = true, + value_name = "CHANNEL_ID", help = "identifier of the channel to query" )] channel_id: ChannelId, - #[clap(long = "seq", required = true, help = "sequence of packet to query")] + #[clap( + long = "seq", + required = true, + value_name = "SEQUENCE", + help = "sequence of packet to query" + )] sequence: Sequence, - #[clap(long = "height", help = "height of the state to query")] + #[clap( + long = "height", + value_name = "HEIGHT", + help = "height of the state to query" + )] height: Option, } diff --git a/relayer-cli/src/commands/query/packet/commitments.rs b/relayer-cli/src/commands/query/packet/commitments.rs index b4a156fa56..9e06b7c10b 100644 --- a/relayer-cli/src/commands/query/packet/commitments.rs +++ b/relayer-cli/src/commands/query/packet/commitments.rs @@ -23,6 +23,7 @@ pub struct QueryPacketCommitmentsCmd { #[clap( long = "chain", required = true, + value_name = "CHAIN_ID", help = "identifier of the chain to query" )] chain_id: ChainId, @@ -30,6 +31,7 @@ pub struct QueryPacketCommitmentsCmd { #[clap( long = "port", required = true, + value_name = "PORT_ID", help = "identifier of the port to query" )] port_id: PortId, @@ -37,6 +39,7 @@ pub struct QueryPacketCommitmentsCmd { #[clap( long = "chan", required = true, + value_name = "CHANNEL_ID", help = "identifier of the channel to query" )] channel_id: ChannelId, diff --git a/relayer-cli/src/commands/query/packet/pending.rs b/relayer-cli/src/commands/query/packet/pending.rs index 9d4c765439..b4834358ef 100644 --- a/relayer-cli/src/commands/query/packet/pending.rs +++ b/relayer-cli/src/commands/query/packet/pending.rs @@ -34,6 +34,7 @@ pub struct QueryPendingPacketsCmd { #[clap( long = "chain", required = true, + value_name = "CHAIN_ID", help = "identifier of the chain at one end of the channel" )] chain_id: ChainId, @@ -41,6 +42,7 @@ pub struct QueryPendingPacketsCmd { #[clap( long = "port", required = true, + value_name = "PORT_ID", help = "port identifier on the chain given by " )] port_id: PortId, @@ -48,6 +50,7 @@ pub struct QueryPendingPacketsCmd { #[clap( long = "chan", required = true, + value_name = "CHANNEL_ID", help = "channel identifier on the chain given by " )] channel_id: ChannelId, diff --git a/relayer-cli/src/commands/query/packet/unreceived_acks.rs b/relayer-cli/src/commands/query/packet/unreceived_acks.rs index afad48463f..831712e7df 100644 --- a/relayer-cli/src/commands/query/packet/unreceived_acks.rs +++ b/relayer-cli/src/commands/query/packet/unreceived_acks.rs @@ -20,14 +20,25 @@ pub struct QueryUnreceivedAcknowledgementCmd { #[clap( long = "chain", required = true, + value_name = "CHAIN_ID", help = "identifier of the chain to query the unreceived acknowledgments" )] chain_id: ChainId, - #[clap(long = "port", required = true, help = "port identifier")] + #[clap( + long = "port", + required = true, + value_name = "PORT_ID", + help = "port identifier" + )] port_id: PortId, - #[clap(long = "chan", required = true, help = "channel identifier")] + #[clap( + long = "chan", + required = true, + value_name = "CHANNEL_ID", + help = "channel identifier" + )] channel_id: ChannelId, } diff --git a/relayer-cli/src/commands/query/packet/unreceived_packets.rs b/relayer-cli/src/commands/query/packet/unreceived_packets.rs index 34cec32185..485c185316 100644 --- a/relayer-cli/src/commands/query/packet/unreceived_packets.rs +++ b/relayer-cli/src/commands/query/packet/unreceived_packets.rs @@ -20,14 +20,25 @@ pub struct QueryUnreceivedPacketsCmd { #[clap( long = "chain", required = true, + value_name = "CHAIN_ID", help = "identifier of the chain for the unreceived sequences" )] chain_id: ChainId, - #[clap(long = "port", required = true, help = "port identifier")] + #[clap( + long = "port", + required = true, + value_name = "PORT_ID", + help = "port identifier" + )] port_id: PortId, - #[clap(long = "chan", required = true, help = "channel identifier")] + #[clap( + long = "chan", + required = true, + value_name = "CHANNEL_ID", + help = "channel identifier" + )] channel_id: ChannelId, } diff --git a/relayer-cli/src/commands/query/tx/events.rs b/relayer-cli/src/commands/query/tx/events.rs index a05106c288..2279ae3d93 100644 --- a/relayer-cli/src/commands/query/tx/events.rs +++ b/relayer-cli/src/commands/query/tx/events.rs @@ -25,11 +25,17 @@ pub struct QueryTxEventsCmd { #[clap( long = "chain", required = true, + value_name = "CHAIN_ID", help = "identifier of the chain to query" )] chain_id: ChainId, - #[clap(long = "hash", required = true, help = "transaction hash to query")] + #[clap( + long = "hash", + required = true, + value_name = "HASH", + help = "transaction hash to query" + )] hash: String, } diff --git a/relayer-cli/src/commands/tx/client.rs b/relayer-cli/src/commands/tx/client.rs index c2ff6de1c5..a0d9cb8bd9 100644 --- a/relayer-cli/src/commands/tx/client.rs +++ b/relayer-cli/src/commands/tx/client.rs @@ -22,17 +22,17 @@ use crate::error::Error; #[derive(Clone, Command, Debug, Parser)] pub struct TxCreateClientCmd { #[clap( - long = "chain-host", + long = "host-chain", required = true, - value_name = "CHAIN_HOST_ID", + value_name = "HOST_CHAIN_ID", help = "identifier of the chain that hosts the client" )] dst_chain_id: ChainId, #[clap( - long = "chain-reference", + long = "reference-chain", required = true, - value_name = "CHAIN_REFERENCE_ID", + value_name = "REFERENCE_CHAIN_ID", help = "identifier of the chain targeted by the client" )] src_chain_id: ChainId, @@ -46,21 +46,21 @@ pub struct TxCreateClientCmd { /// to accept or reject a new header (originating from the source chain) for this client. /// If this option is not specified, a suitable clock drift value is derived from the chain /// configurations. - #[clap(long = "clock-drift")] + #[clap(long = "clock-drift", value_name = "CLOCK_DRIFT")] clock_drift: Option, /// Override the trusting period specified in the config. /// /// The trusting period specifies how long a validator set is trusted for /// (must be shorter than the chain's unbonding period). - #[clap(long = "trusting-period")] + #[clap(long = "trusting-period", value_name = "TRUSTING_PERIOD")] trusting_period: Option, /// Override the trust threshold specified in the configuration. /// /// The trust threshold defines what fraction of the total voting power of a known /// and trusted validator set is sufficient for a commit to be accepted going forward. - #[clap(long = "trust-threshold", parse(try_from_str = parse_trust_threshold))] + #[clap(long = "trust-threshold", value_name = "TRUST_THRESHOLD", parse(try_from_str = parse_trust_threshold))] trust_threshold: Option, } @@ -102,17 +102,17 @@ impl Runnable for TxCreateClientCmd { #[derive(Clone, Command, Debug, Parser)] pub struct TxUpdateClientCmd { #[clap( - long = "chain-host", + long = "host-chain", required = true, - value_name = "CHAIN_HOST_ID", + value_name = "HOST_CHAIN_ID", help = "identifier of the chain that hosts the client" )] dst_chain_id: ChainId, #[clap( - long = "client-reference", + long = "client", required = true, - value_name = "CHAIN_REFERENCE_ID", + value_name = "CLIENT_ID", help = "identifier of the chain targeted by the client" )] dst_client_id: ClientId, @@ -187,8 +187,9 @@ impl Runnable for TxUpdateClientCmd { #[derive(Clone, Command, Debug, Parser)] pub struct TxUpgradeClientCmd { #[clap( - long = "chain-host", + long = "host-chain", required = true, + value_name = "HOST_CHAIN_ID", help = "identifier of the chain that hosts the client" )] chain_id: ChainId, @@ -196,6 +197,7 @@ pub struct TxUpgradeClientCmd { #[clap( long = "client", required = true, + value_name = "CLIENT_ID", help = "identifier of the client to be upgraded" )] client_id: ClientId, @@ -244,9 +246,9 @@ impl Runnable for TxUpgradeClientCmd { #[derive(Clone, Command, Debug, Parser)] pub struct TxUpgradeClientsCmd { #[clap( - long = "chain-reference", + long = "reference-chain", required = true, - value_name = "CHAIN_REFERENCE_ID", + value_name = "REFERENCE_CHAIN_ID", help = "identifier of the chain that underwent an upgrade; all clients targeting this chain will be upgraded" )] src_chain_id: ChainId, From c363e047323208afcdd8962a9246ff6b5d82a7a2 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Fri, 17 Jun 2022 17:13:32 +0200 Subject: [PATCH 15/27] Updated guide to reflect flag changes from ADR 010 --- guide/src/commands/config.md | 2 +- guide/src/commands/global.md | 6 +-- guide/src/commands/keys/index.md | 4 +- guide/src/commands/path-setup/channels.md | 30 ++++++------ guide/src/commands/path-setup/clients.md | 34 ++++++------- guide/src/commands/path-setup/connections.md | 20 ++++---- guide/src/commands/path-setup/index.md | 10 ++-- guide/src/commands/queries/channel.md | 10 ++-- guide/src/commands/queries/client.md | 16 ++++--- guide/src/commands/queries/packet.md | 1 - guide/src/commands/raw/client.md | 28 +++++------ guide/src/commands/raw/upgrade.md | 17 +++---- guide/src/commands/relaying/clear.md | 3 -- guide/src/commands/upgrade/index.md | 6 +-- guide/src/commands/upgrade/test.md | 4 +- guide/src/help.md | 48 ++++++++++--------- guide/src/installation.md | 34 ++++++++----- .../src/tutorials/local-chains/identifiers.md | 2 +- .../src/tutorials/local-chains/raw/client.md | 8 ++-- .../relay-paths/create-new-path.md | 2 +- .../relay-paths/multiple-paths.md | 4 +- 21 files changed, 155 insertions(+), 134 deletions(-) diff --git a/guide/src/commands/config.md b/guide/src/commands/config.md index b80e8b6f42..6a25b37682 100644 --- a/guide/src/commands/config.md +++ b/guide/src/commands/config.md @@ -6,7 +6,7 @@ your configuration file. ```shell USAGE: - hermes config validate + hermes config validate DESCRIPTION: validate the relayer configuration diff --git a/guide/src/commands/global.md b/guide/src/commands/global.md index 927bf50ca7..ef9c9596cd 100644 --- a/guide/src/commands/global.md +++ b/guide/src/commands/global.md @@ -34,7 +34,7 @@ To process all the output using `jq`, one can redirect `stderr` to `stdout` with __Example__ ```shell -hermes --config /home/my_chain.toml --json create client --dst-chain ibc-0 --src-chain ibc-1 +hermes --config /home/my_chain.toml --json create client --host-chain ibc-0 --reference-chain ibc-1 ``` ```json @@ -51,7 +51,7 @@ __Example__ To improve the readability, pipe all of the output to `jq`: ``` -hermes --config /home/my_chain.toml --json create client --dst-chain ibc-0 --src-chain ibc-1 2>&1 | jq +hermes --config /home/my_chain.toml --json create client --host-chain ibc-0 --reference-chain ibc-1 2>&1 | jq ``` ```json @@ -105,7 +105,7 @@ __Example__ To extract the identifer of the newly created client above: ``` -hermes --config /home/my_chain.toml --json create client --dst-chain ibc-0 --src-chain ibc-1 | jq '.result.CreateClient.client_id' +hermes --config /home/my_chain.toml --json create client --host-chain ibc-0 --reference-chain ibc-1 | jq '.result.CreateClient.client_id' ``` ``` diff --git a/guide/src/commands/keys/index.md b/guide/src/commands/keys/index.md index b6cbf970eb..08539a220e 100644 --- a/guide/src/commands/keys/index.md +++ b/guide/src/commands/keys/index.md @@ -218,8 +218,8 @@ FLAGS: --chain identifier of the chain OPTIONS: - --key-name NAME name of the key - --all delete all keys + --key-name name of the key + --all delete all keys ``` #### Delete private keys that was previously added to a chain diff --git a/guide/src/commands/path-setup/channels.md b/guide/src/commands/path-setup/channels.md index 87544df7e2..a6fbbe5d9e 100644 --- a/guide/src/commands/path-setup/channels.md +++ b/guide/src/commands/path-setup/channels.md @@ -10,25 +10,27 @@ Use the `create channel` command to establish a new channel. ```shell USAGE: - hermes create channel [OPTIONS] --chain-a --port-a --port-b + hermes create channel [OPTIONS] --a-chain --a-port --b-port DESCRIPTION: Create a new channel between two chains using a pre-existing connection. Alternatively, create a new client and a new connection underlying the new channel if a pre-existing connection is not provided. FLAGS: - --chain-a Identifier of the side `a` chain for the new channel - --port-a Identifier of the side `a` port for the new channel - --port-b Identifier of the side `b` port for the new channel + --a-chain Identifier of the side `a` chain for the new channel + --a-port Identifier of the side `a` port for the new channel + --b-port Identifier of the side `b` port for the new channel -FLAGS: - --chain-b Identifier of the side `b` chain for the new channel - --conn-a Identifier of the connection on chain `a` to use in creating the - new channel. - -h, --help Print help information - --new-client-conn Indicates that a new client and connection will be created underlying the new channel - --order The channel ordering, valid options 'unordered' (default) and 'ordered' [default: ORDER_UNORDERED] - --chan-version The version for the new channel +OPTIONS: + + --a-conn Identifier of the connection on chain `a` to use in creating + the new channel. + --b-chain Identifier of the side `b` chain for the new channel + --chan-version The version for the new channel + --new-client-conn Indicates that a new client and connection will be created + underlying the new channel + --order The channel ordering, valid options 'unordered' (default) and + 'ordered' [default: ORDER_UNORDERED] ``` ## Examples @@ -43,7 +45,7 @@ specifically the one we just created in the example above, with port name `transfer` on both sides: ```shell -hermes create channel --chain-a ibc-0 --conn-a connection-0 --port-a transfer --port-b transfer --order unordered +hermes create channel --a-chain ibc-0 --a-conn connection-0 --a-port transfer --b-port transfer --order unordered ``` Notice that one can omit the destination chain parameter, as Hermes will automatically @@ -206,7 +208,7 @@ interactive prompt that pops up notifying you that a new client and a new connection will be initialized as part of the process: ```shell -hermes create channel --chain-a ibc-0 --chain-b ibc-1 --port-a transfer --port-b transfer --order unordered --new-client-conn +hermes create channel --a-chain ibc-0 --b-chain ibc-1 --a-port transfer --b-port transfer --order unordered --new-client-conn ``` ```json diff --git a/guide/src/commands/path-setup/clients.md b/guide/src/commands/path-setup/clients.md index 44f2074d76..025ae08d80 100644 --- a/guide/src/commands/path-setup/clients.md +++ b/guide/src/commands/path-setup/clients.md @@ -11,14 +11,14 @@ tracking the state of the source chain. ```shell USAGE: - hermes create client [OPTIONS] --dst-chain --src-chain + hermes create client [OPTIONS] --host-chain --reference-chain FLAGS: - --dst-chain - identifier of the destination chain + --host-chain + identifier of the chain that hosts the client - --src-chain - identifier of the source chain + --reference-chain + identifier of the chain targeted by the client OPTIONS: --clock-drift @@ -49,7 +49,7 @@ __Example__ Create a new client on `ibc-0` which tracks `ibc-1`: ```shell -hermes create client --dst-chain ibc-0 --src-chain ibc-1 +hermes create client --host-chain ibc-0 --reference-chain ibc-1 ``` ```json @@ -81,19 +81,21 @@ Specific update and trusted heights can be specified. ```shell USAGE: - hermes update client [OPTIONS] --dst-chain --dst-client + hermes update client [OPTIONS] --host-chain --client FLAGS: - --dst-chain - identifier of the destination chain + --host-chain + identifier of the chain that hosts the client - --dst-client - identifier of the client to be updated on destination chain + --client + identifier of the chain targeted by the client OPTIONS: - -h, --help Print help information - --target-height the target height of the client update - --trusted-height the trusted height of the client update + --height + the target height of the client update + + --trusted-height + the trusted height of the client update ``` __Update client with latest header__ @@ -101,7 +103,7 @@ __Update client with latest header__ the client on `ibc-0` with latest header of `ibc-1`: ```shell -hermes update client --dst-chain ibc-0 --dst-client 07-tendermint-9 +hermes update client --host-chain ibc-0 --client 07-tendermint-9 ``` ```json @@ -129,7 +131,7 @@ The client with identifier `07-tendermint-1` has been updated with the consensus __Update a client to a specific target height__ ```shell -hermes update client --dst-chain ibc-0 --dst-client 07-tendermint-1 --target-height 320 --trusted-height 293 +hermes update client --host-chain ibc-0 --client 07-tendermint-1 --height 320 --trusted-height 293 ``` ```json diff --git a/guide/src/commands/path-setup/connections.md b/guide/src/commands/path-setup/connections.md index ce2d6fda4e..5bea038052 100644 --- a/guide/src/commands/path-setup/connections.md +++ b/guide/src/commands/path-setup/connections.md @@ -9,19 +9,22 @@ Use the `create connection` command to create a new connection. ```shell USAGE: - hermes create connection [OPTIONS] --chain-a + hermes create connection [OPTIONS] --a-chain DESCRIPTION: Create a new connection between two chains FLAGS: - --chain-a identifier of the side `a` chain for the new connection + --a-chain identifier of the side `a` chain for the new connection OPTIONS: - --chain-b identifier of the side `b` chain for the new connection - --client-a identifier of client hosted on chain `a`; default: None (creates a new client) - --client-b identifier of client hosted on chain `b`; default: None (creates a new client) - --delay >DELAY> delay period parameter for the new connection (seconds) (default: 0) + --a-client identifier of client hosted on chain `a`; default: None (creates + a new client) + --b-chain identifier of the side `b` chain for the new connection + --b-client identifier of client hosted on chain `b`; default: None (creates + a new client) + --delay delay period parameter for the new connection (seconds) + [default: 0] ``` ## Examples @@ -31,7 +34,7 @@ OPTIONS: Create a new connection between `ibc-0` and `ibc-1` over new clients: ```shell -hermes create connection --chain-a ibc-0 --chain-b ibc-1 +hermes create connection --a-chain ibc-0 --b-chain ibc-1 ``` ```json @@ -202,10 +205,9 @@ Create a new connection between `ibc-0` and `ibc-1` over existing clients, both with client id `07-tendermint-0`: ```shell -hermes create connection --chain-a ibc-0 --client-a 07-tendermint-0 --client-b 07-tendermint-0 +hermes create connection --a-chain ibc-0 --a-client 07-tendermint-0 --b-client 07-tendermint-0 ``` - Notice that one can omit the destination chain parameter, as Hermes will automatically figure it out by looking up the given client on `ibc-0`. diff --git a/guide/src/commands/path-setup/index.md b/guide/src/commands/path-setup/index.md index ae654ca77a..f632ad8907 100644 --- a/guide/src/commands/path-setup/index.md +++ b/guide/src/commands/path-setup/index.md @@ -21,10 +21,12 @@ DESCRIPTION: Create objects (client, connection, or channel) on chains SUBCOMMANDS: - help Get usage information - client Create a new IBC client - connection Create a new connection between two chains - channel Create a new channel between two chains + channel Create a new channel between two chains using a pre-existing connection. + Alternatively, create a new client and a new connection underlying the new + channel if a pre-existing connection is not provided + client Create a new IBC client + connection Create a new connection between two chains + help Print this message or the help of the given subcommand(s) ``` ## Update diff --git a/guide/src/commands/queries/channel.md b/guide/src/commands/queries/channel.md index 8614260158..033b64f938 100644 --- a/guide/src/commands/queries/channel.md +++ b/guide/src/commands/queries/channel.md @@ -14,12 +14,14 @@ DESCRIPTION: Query the identifiers of all channels on a given chain FLAGS: - --chain identifier of the chain to query + --chain + identifier of the chain to query OPTIONS: - --dst-chain identifier of the channel's destination chain - --verbose enable verbose output, displaying all client and connection - ids + --counterparty-chain + identifier of the channel's destination chain + --verbose + enable verbose output, displaying all client and connection ids ``` __Example__ diff --git a/guide/src/commands/queries/client.md b/guide/src/commands/queries/client.md index 0c5567ef37..37cbf1435e 100644 --- a/guide/src/commands/queries/client.md +++ b/guide/src/commands/queries/client.md @@ -9,17 +9,21 @@ Use the `query clients` command to query the identifiers of all clients on a giv ```shell USAGE: - hermes query clients [OPTIONS] --chain + hermes query clients [OPTIONS] --host-chain DESCRIPTION: Query the identifiers of all clients on a chain FLAGS: - --chain identifier of the chain to query + --host-chain + identifier of the chain to query OPTIONS: - --src-chain filter for clients which target a specific chain id (implies '--omit-chain-ids') - --omit-chain-ids omit printing the source chain for each client (default: false) + --omit-chain-ids + omit printing the source chain for each client + + --reference-chain + filter for clients which target a specific chain id (implies '--omit-chain-ids') ``` __Example__ @@ -27,7 +31,7 @@ __Example__ Query all clients on `ibc-1`: ```shell -hermes query clients --chain ibc-1 +hermes query clients --host-chain ibc-1 ``` ```json @@ -56,7 +60,7 @@ Success: [ Query all clients on `ibc-1` having `ibc-2` as their source chain: ```shell -hermes query clients --chain ibc-1 --src-chain ibc-2 +hermes query clients --host-chain ibc-1 --reference-chain ibc-2 ``` ```json diff --git a/guide/src/commands/queries/packet.md b/guide/src/commands/queries/packet.md index 01f5e5278e..647a280df6 100644 --- a/guide/src/commands/queries/packet.md +++ b/guide/src/commands/queries/packet.md @@ -19,7 +19,6 @@ SUBCOMMANDS: pending Output a summary of pending packets in both directions unreceived-acks Query unreceived acknowledgments unreceived-packets Query unreceived packets - help Print this message or the help of the given subcommand(s) ``` ## Table of Contents diff --git a/guide/src/commands/raw/client.md b/guide/src/commands/raw/client.md index 39db753216..6d35f638ef 100644 --- a/guide/src/commands/raw/client.md +++ b/guide/src/commands/raw/client.md @@ -9,17 +9,17 @@ Use the `create-client` command to create a new client. ```shell USAGE: - hermes tx raw create-client [OPTIONS] --dst-chain --src-chain + hermes tx raw create-client [OPTIONS] --host-chain --reference-chain DESCRIPTION: Create a client for source chain on destination chain FLAGS: - --dst-chain - identifier of the destination chain + --host-chain + identifier of the chain that hosts the client - --src-chain - identifier of the source chain + --reference-chain + identifier of the chain targeted by the client OPTIONS: --clock-drift @@ -38,7 +38,7 @@ __Example__ Create a new client of `ibc-1` on `ibc-0`: ```shell -hermes tx raw create-client --dst-chain ibc-0 --src-chain ibc-1 +hermes tx raw create-client --host-chain ibc-0 --reference-chain ibc-1 ``` ```json @@ -66,24 +66,24 @@ Specific update and trusted heights can be specified. ```shell USAGE: - hermes tx raw update-client [OPTIONS] --dst-chain --dst-client + hermes tx raw update-client [OPTIONS] --host-chain --client DESCRIPTION: Update the specified client on destination chain FLAGS: - --dst-chain - identifier of the destination chain + --host-chain + identifier of the chain that hosts the client - --dst-client - identifier of the client to be updated on destination chain + --client + identifier of the chain targeted by the client OPTIONS: - --target-height + --height the target height of the client update - --trusted-height + --trusted-height the trusted height of the client update ``` @@ -92,7 +92,7 @@ __Example__ Update the client on `ibc-0` with latest header of `ibc-1` ```shell -hermes tx raw update-client --dst-chain ibc-0 --dst-client 07-tendermint-0 +hermes tx raw update-client --host-chain ibc-0 --client 07-tendermint-0 ``` ```json diff --git a/guide/src/commands/raw/upgrade.md b/guide/src/commands/raw/upgrade.md index 4244e71ab3..b04268ba5f 100644 --- a/guide/src/commands/raw/upgrade.md +++ b/guide/src/commands/raw/upgrade.md @@ -10,14 +10,14 @@ Use this to perform the upgrade for the given client. ```shell USAGE: - hermes tx raw upgrade-client --chain --client + hermes tx raw upgrade-client --host-chain --client DESCRIPTION: Upgrade the specified client on destination chain FLAGS: - --chain identifier of the chain that hosts the client - --client identifier of the client to be upgraded + --client identifier of the client to be upgraded + --host-chain identifier of the chain that hosts the client ``` __Example__ @@ -25,7 +25,7 @@ __Example__ A given client is upgraded: ```shell -hermes tx raw upgrade-client --chain ibc-1 --client 07-tendermint-0 +hermes tx raw upgrade-client --host-chain ibc-1 --client 07-tendermint-0 ```` ``` @@ -60,14 +60,15 @@ Use this to perform the upgrade on all the clients. ```shell USAGE: - hermes tx raw upgrade-clients --src-chain + hermes tx raw upgrade-clients --reference-chain DESCRIPTION: Upgrade all IBC clients that target a specific chain FLAGS: - --src-chain identifier of the chain that underwent an upgrade; all clients - targeting this chain will be upgraded + --reference-chain + identifier of the chain that underwent an upgrade; all clients targeting this chain will + be upgraded ``` __Example__ @@ -75,7 +76,7 @@ __Example__ All the clients are upgraded: ```shell -hermes tx raw upgrade-clients --chain ibc-1 +hermes tx raw upgrade-clients --reference-chain ibc-1 ```` ``` diff --git a/guide/src/commands/relaying/clear.md b/guide/src/commands/relaying/clear.md index e0d25a6631..46588aefd3 100644 --- a/guide/src/commands/relaying/clear.md +++ b/guide/src/commands/relaying/clear.md @@ -21,9 +21,6 @@ FLAGS: --chain identifier of the chain --chan identifier of the channel --port identifier of the port - -OPTIONS: - -h, --help Print help information ``` ### Example diff --git a/guide/src/commands/upgrade/index.md b/guide/src/commands/upgrade/index.md index d4d4538680..2251baa45f 100644 --- a/guide/src/commands/upgrade/index.md +++ b/guide/src/commands/upgrade/index.md @@ -6,14 +6,14 @@ Use the `upgrade client` command to upgrade a client after a chain upgrade. ```shell USAGE: - hermes upgrade client --chain --client + hermes upgrade client --host-chain --client DESCRIPTION: Upgrade an IBC client FLAGS: - --chain identifier of the chain that hosts the client - --client identifier of the client to be upgraded + --host-chain identifier of the chain that hosts the client + --client identifier of the client to be upgraded ``` __Example__ diff --git a/guide/src/commands/upgrade/test.md b/guide/src/commands/upgrade/test.md index 803f323fcf..5e4f330bbe 100644 --- a/guide/src/commands/upgrade/test.md +++ b/guide/src/commands/upgrade/test.md @@ -37,7 +37,7 @@ __With gm__ 1. Create one client on `ibc-1` for `ibc-0`: ```shell - hermes create client --dst-chain ibc-1 --src-chain ibc-0 + hermes create client --host-chain ibc-1 --reference-chain ibc-0 ``` ```json @@ -229,7 +229,7 @@ __With gm__ and another for the upgraded state. ```shell - hermes upgrade client --chain ibc-1 --client 07-tendermint-0 + hermes upgrade client --host-chain ibc-1 --client 07-tendermint-0 ``` ```json Success: [ diff --git a/guide/src/help.md b/guide/src/help.md index aa61bbcea2..055324fea6 100644 --- a/guide/src/help.md +++ b/guide/src/help.md @@ -46,10 +46,12 @@ DESCRIPTION: Create objects (client, connection, or channel) on chains SUBCOMMANDS: - help Get usage information - client Create a new IBC client - connection Create a new connection between two chains - channel Create a new channel between two chains + channel Create a new channel between two chains using a pre-existing connection. + Alternatively, create a new client and a new connection underlying the new + channel if a pre-existing connection is not provided + client Create a new IBC client + connection Create a new connection between two chains + help Print this message or the help of the given subcommand(s) ``` This can provide further specific guidance if we add additional parameters, e.g., @@ -60,26 +62,26 @@ hermes help create channel ``` USAGE: - hermes create channel [OPTIONS] --chain-a --port-a --port-b + hermes create channel [OPTIONS] --a-chain --a-port --b-port DESCRIPTION: Create a new channel between two chains using a pre-existing connection. Alternatively, create a new client and a new connection underlying the new channel if a pre-existing connection is not provided FLAGS: - --chain-a Identifier of the side `a` chain for the new channel - --port-a Identifier of the side `a` port for the new channel - --port-b Identifier of the side `b` port for the new channel + --a-chain Identifier of the side `a` chain for the new channel + --a-port Identifier of the side `a` port for the new channel + --b-port Identifier of the side `b` port for the new channel OPTIONS: - --chain-b Identifier of the side `b` chain for the new channel - --chan-version The version for the new channel - --conn-a Identifier of the connection on chain `a` to use in creating the - new channel. - --new-client-conn Indicates that a new client and connection will be created - underlying the new channel - --order The channel ordering, valid options 'unordered' (default) and - 'ordered' [default: ORDER_UNORDERED] + --a-conn Identifier of the connection on chain `a` to use in creating + the new channel. + --b-chain Identifier of the side `b` chain for the new channel + --chan-version The version for the new channel + --new-client-conn Indicates that a new client and connection will be created + underlying the new channel + --order The channel ordering, valid options 'unordered' (default) and + 'ordered' [default: ORDER_UNORDERED] ``` Additionally, the `-h`/`--help` flags typical for CLI applications work on @@ -410,33 +412,33 @@ In order to test the correct operation during the channel close, perform the ste this path). ```shell - hermes tx raw ft-transfer ibc-0 ibc-1 transfer channel-1 5555 -o 1000 -n 1 -d samoleans + hermes tx raw ft-transfer --dst-chain ibc-0 --src-chain ibc-1 --src-port transfer --src-chan channel-1 --amount 5555 --timeout-height-offset 1000 --number-msgs 1 --denom samoleans ``` - now do the first step of channel closing: the channel will transition to close-open: ```shell - hermes -c config.toml tx raw chan-close-init ibc-0 ibc-1 connection-0 transfer transfer channel-0 channel-1 + hermes -c config.toml tx raw chan-close-init --dst-chain ibc-0 --src-chain ibc-1 --dst-conn connection-0 --dst-port transfer --src-port transfer --dst-chan channel-0 --src-chan channel-1 ``` - trigger timeout on close to ibc-1 ```shell - hermes -c config.toml tx raw packet-recv ibc-0 ibc-1 transfer channel-1 + hermes -c config.toml tx raw packet-recv --dst-chain ibc-0 --src-chain ibc-1 --src-port transfer --src-chan channel-1 ``` - close-close ```shell - hermes -c config.toml tx raw chan-close-confirm ibc-1 ibc-0 connection-1 transfer transfer channel-1 channel-0 + hermes -c config.toml tx raw chan-close-confirm --dst-chain ibc-1 --src-chain ibc-0 --dst-conn connection-1 --dst-port transfer --src-port transfer --dst-chan channel-1 --src-chan channel-0 ``` - verify that the two ends are in Close state: ```shell - hermes -c config.toml query channel end ibc-0 transfer channel-0 - hermes -c config.toml query channel end ibc-1 transfer channel-1 + hermes -c config.toml query channel end --chain ibc-0 --port transfer --chan channel-0 + hermes -c config.toml query channel end --chain ibc-1 --port transfer --chan channel-1 ``` @@ -517,7 +519,7 @@ the `profiling` feature and the [log level][log-level] should be `info` level or #### Example output for `tx raw conn-init` command ``` -hermes -c config.toml tx raw conn-init ibc-0 ibc-1 07-tendermint-0 07-tendermint-0 +hermes --config config.toml tx raw conn-init --dst-chain ibc-0 --src-chain ibc-1 --dst-client 07-tendermint-0 --src-client 07-tendermint-0 ``` ``` diff --git a/guide/src/installation.md b/guide/src/installation.md index 5a9bfe166f..fbd3f69150 100644 --- a/guide/src/installation.md +++ b/guide/src/installation.md @@ -155,21 +155,29 @@ hermes 0.15.0 Informal Systems USAGE: - hermes + hermes [OPTIONS] + +OPTIONS: + --config path to configuration file + -h, --help Print help information + --json enable JSON output + -V, --version Print version information SUBCOMMANDS: - help Get usage information - config Validate Hermes configuration file - keys Manage keys in the relayer for each chain - create Create objects (client, connection, or channel) on chains - update Update objects (clients) on chains - upgrade Upgrade objects (clients) after chain upgrade - start Start the relayer - query Query objects from the chain - tx Create and send IBC transactions - listen Listen to and display IBC events emitted by a chain - misbehaviour Listen to client update IBC events and handles misbehaviour - version Display version information + clear Clear objects, such as outstanding packets on a channel + config Validate Hermes configuration file + create Create objects (client, connection, or channel) on chains + health-check Performs a health check of all chains in the the config + help Print this message or the help of the given subcommand(s) + keys Manage keys in the relayer for each chain + listen Listen to and display IBC events emitted by a chain + misbehaviour Listen to client update IBC events and handles misbehaviour + query Query objects from the chain + start Start the relayer in multi-chain mode + tx Create and send IBC transactions + update Update objects (clients) on chains + upgrade Upgrade objects (clients) after chain upgrade + completions Generate auto-complete scripts for different shells ``` ### Creating an alias for the executable diff --git a/guide/src/tutorials/local-chains/identifiers.md b/guide/src/tutorials/local-chains/identifiers.md index 47d6913288..e2dad5873f 100644 --- a/guide/src/tutorials/local-chains/identifiers.md +++ b/guide/src/tutorials/local-chains/identifiers.md @@ -14,7 +14,7 @@ __`07-tendermint-`__ for tendermint clients For example `07-tendermint-0` is assigned to the first client created on `ibc-1`: ```shell -hermes tx raw create-client --dst-chain ibc-1 --src-chain ibc-0 +hermes tx raw create-client --host-chain ibc-1 --reference-chain ibc-0 ``` ```json diff --git a/guide/src/tutorials/local-chains/raw/client.md b/guide/src/tutorials/local-chains/raw/client.md index c84f389a65..ac8186889d 100644 --- a/guide/src/tutorials/local-chains/raw/client.md +++ b/guide/src/tutorials/local-chains/raw/client.md @@ -7,7 +7,7 @@ First you will need to create a client for each chain: This command submits a transaction to a destination chain (`ibc-0`) with a request to create a client for a source chain (`ibc-1`): ```shell -hermes tx raw create-client --dst-chain ibc-0 --src-chain ibc-1 +hermes tx raw create-client --host-chain ibc-0 --reference-chain ibc-1 ``` if the command is successful a message similar to the one below will be displayed `status:success`: @@ -72,7 +72,7 @@ Success: ClientState { Now let's do the same for `ibc-1` as the destination chain: ```shell -hermes tx raw create-client --dst-chain ibc-1 --src-chain ibc-0 +hermes tx raw create-client --host-chain ibc-1 --reference-chain ibc-0 ``` Take note of the `client_id` allocated for this client. In the examples we assume is `07-tendermint-1` (this client identity is obtained by creating two clients on ibc-1 for ibc-0). @@ -105,11 +105,11 @@ Success: CreateClient( Client states can be updated by sending an `update-client` transaction: ```shell -hermes tx raw update-client --dst-chain ibc-0 --dst-client 07-tendermint-0 +hermes tx raw update-client --host-chain ibc-0 --client 07-tendermint-0 ``` ```shell -hermes tx raw update-client --dst-chain ibc-1 --dst-client 07-tendermint-1 +hermes tx raw update-client --host-chain ibc-1 --client 07-tendermint-1 ``` ## Next Steps diff --git a/guide/src/tutorials/local-chains/relay-paths/create-new-path.md b/guide/src/tutorials/local-chains/relay-paths/create-new-path.md index dc95686d2e..b6c2d3b456 100644 --- a/guide/src/tutorials/local-chains/relay-paths/create-new-path.md +++ b/guide/src/tutorials/local-chains/relay-paths/create-new-path.md @@ -3,7 +3,7 @@ Perform client creation, connection and channel handshake to establish a new path between the `transfer` ports on `ibc-0` and `ibc-1` chains. ```shell -hermes create channel --chain-a ibc-0 --chain-b ibc-1 --port-a transfer --port-b transfer --new-client-conn +hermes create channel --a-chain ibc-0 --b-chain ibc-1 --a-port transfer --b-port transfer --new-client-conn ``` If all the handshakes are performed successfully you should see a message similar to the one below: diff --git a/guide/src/tutorials/local-chains/relay-paths/multiple-paths.md b/guide/src/tutorials/local-chains/relay-paths/multiple-paths.md index 7f3cac5db4..1161aa12f2 100644 --- a/guide/src/tutorials/local-chains/relay-paths/multiple-paths.md +++ b/guide/src/tutorials/local-chains/relay-paths/multiple-paths.md @@ -100,7 +100,7 @@ Follow the steps below to connect three chains together and relay packets betwee making an exception. Execute the following command: ```shell - hermes create channel --chain-a ibc-0 --chain-b ibc-1 --port-a transfer --port-b transfer --new-client-conn + hermes create channel --a-chain ibc-0 --b-chain ibc-1 --a-port transfer --b-port transfer --new-client-conn ``` Then respond 'yes' to the prompt that pops up. Once the command has run to @@ -166,7 +166,7 @@ Follow the steps below to connect three chains together and relay packets betwee previous invocation we used to create a channel between `ibc-0` and `ibc-1`: ```shell - hermes create channel --chain-a ibc-1 --chain-b ibc-2 --port-a transfer --port-b transfer --new-client-conn + hermes create channel --a-chain ibc-1 --b-chain ibc-2 --a-port transfer --b-port transfer --new-client-conn ``` ```json From 9e6d309eb4dca44ef5d35bd31f85194ff3690e5a Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Fri, 17 Jun 2022 17:28:52 +0200 Subject: [PATCH 16/27] Updated gm script and e2e tests to match flag changes from ADR 010 --- e2e/e2e/client.py | 4 ++-- scripts/gm/bin/lib-gm | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e/e2e/client.py b/e2e/e2e/client.py index 7e958226e5..c1b853c494 100644 --- a/e2e/e2e/client.py +++ b/e2e/e2e/client.py @@ -19,7 +19,7 @@ class TxCreateClient(Cmd[ClientCreated]): src_chain_id: ChainId def args(self) -> List[str]: - return ["--dst-chain", self.dst_chain_id, "--src-chain", self.src_chain_id] + return ["--host-chain", self.dst_chain_id, "--reference-chain", self.src_chain_id] def process(self, result: Any) -> ClientCreated: return from_dict(ClientCreated, result['CreateClient']) @@ -43,7 +43,7 @@ class TxUpdateClient(Cmd[ClientUpdated]): dst_client_id: ClientId def args(self) -> List[str]: - return ["--dst-chain", self.dst_chain_id, "--dst-client", self.dst_client_id] + return ["--host-chain", self.dst_chain_id, "--client", self.dst_client_id] def process(self, result: Any) -> ClientUpdated: return from_dict(ClientUpdated, result[-1]['UpdateClient']['common']) diff --git a/scripts/gm/bin/lib-gm b/scripts/gm/bin/lib-gm index a2a2266a2c..4176894b4f 100644 --- a/scripts/gm/bin/lib-gm +++ b/scripts/gm/bin/lib-gm @@ -1051,7 +1051,7 @@ hermes_cc() { do for j in $(seq $((i+1)) $N) do - echo "\"${HERMES_BINARY}\" create channel --chain-a $(n_from_a "$i" "$CHAINS") --chain-b $(n_from_a "$j" "$CHAINS") --port-a transfer --port-b transfer" + echo "\"${HERMES_BINARY}\" create channel --a-chain $(n_from_a "$i" "$CHAINS") --b-chain $(n_from_a "$j" "$CHAINS") --a-port transfer --b-port transfer" done done } From 89bfbf6961fc54ae899ff58514d65d612628ae3d Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Mon, 20 Jun 2022 10:26:54 +0200 Subject: [PATCH 17/27] Fixed ADR 010 typo --- docs/architecture/adr-010-unified-cli-arguments-hermes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/architecture/adr-010-unified-cli-arguments-hermes.md b/docs/architecture/adr-010-unified-cli-arguments-hermes.md index f39aea60b5..b392287021 100644 --- a/docs/architecture/adr-010-unified-cli-arguments-hermes.md +++ b/docs/architecture/adr-010-unified-cli-arguments-hermes.md @@ -115,7 +115,7 @@ __Connection__ * Optional: `[--height ]` * `query connections --chain ` - * Optional: `[--chain-counterparty ] [--verbose]` + * Optional: `[--counterparty-chain ] [--verbose]` __Channel__ From 433621d3e2a13acbe20aa254843f043e4c2aa903 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Tue, 21 Jun 2022 10:57:38 +0200 Subject: [PATCH 18/27] Added unit-testing CLI argument parsing --- relayer-cli/src/commands/clear.rs | 35 +++- relayer-cli/src/commands/completions.rs | 28 ++- relayer-cli/src/commands/create/channel.rs | 124 +++++++++---- relayer-cli/src/commands/create/connection.rs | 95 ++++++++-- relayer-cli/src/commands/keys/add.rs | 42 +++++ relayer-cli/src/commands/keys/balance.rs | 32 +++- relayer-cli/src/commands/keys/delete.rs | 59 +++++-- relayer-cli/src/commands/keys/list.rs | 23 ++- relayer-cli/src/commands/listen.rs | 46 ++++- relayer-cli/src/commands/misbehaviour.rs | 30 +++- relayer-cli/src/commands/query/channel.rs | 43 ++++- .../src/commands/query/channel_client.rs | 35 +++- .../src/commands/query/channel_ends.rs | 51 +++++- relayer-cli/src/commands/query/channels.rs | 39 ++++- relayer-cli/src/commands/query/client.rs | 143 ++++++++++++++- relayer-cli/src/commands/query/clients.rs | 39 ++++- relayer-cli/src/commands/query/connection.rs | 58 ++++++- relayer-cli/src/commands/query/connections.rs | 23 ++- relayer-cli/src/commands/query/packet/ack.rs | 49 +++++- relayer-cli/src/commands/query/packet/acks.rs | 35 +++- .../src/commands/query/packet/commitment.rs | 48 +++++- .../src/commands/query/packet/commitments.rs | 35 +++- .../src/commands/query/packet/pending.rs | 35 +++- .../commands/query/packet/unreceived_acks.rs | 35 +++- .../query/packet/unreceived_packets.rs | 35 +++- .../commands/query/transfer/denom_trace.rs | 28 ++- relayer-cli/src/commands/query/tx/events.rs | 28 ++- relayer-cli/src/commands/start.rs | 25 ++- relayer-cli/src/commands/tx/client.rs | 163 +++++++++++++++++- 29 files changed, 1370 insertions(+), 91 deletions(-) diff --git a/relayer-cli/src/commands/clear.rs b/relayer-cli/src/commands/clear.rs index 054ac05374..796f0c3f9a 100644 --- a/relayer-cli/src/commands/clear.rs +++ b/relayer-cli/src/commands/clear.rs @@ -21,7 +21,7 @@ pub enum ClearCmds { Packets(ClearPacketsCmd), } -#[derive(Debug, Parser)] +#[derive(Debug, Parser, PartialEq)] pub struct ClearPacketsCmd { #[clap( long = "chain", @@ -104,3 +104,36 @@ where Err(e) => Output::error(Error::link(e)).exit(), }; } + +#[cfg(test)] +mod tests { + use super::ClearPacketsCmd; + + use std::str::FromStr; + + use abscissa_core::clap::Parser; + use ibc::core::ics24_host::identifier::{ChainId, PortId, ChannelId}; + + #[test] + fn test_clear_packets() { + assert_eq!( + ClearPacketsCmd{ chain_id: ChainId::from_string("chain_id"), port_id: PortId::from_str("port_id").unwrap(), channel_id: ChannelId::from_str("channel-07").unwrap() }, + ClearPacketsCmd::parse_from(&["test", "--chain", "chain_id", "--port", "port_id", "--chan", "channel-07"]) + ) + } + + #[test] + fn test_clear_packets_no_chan() { + assert!(ClearPacketsCmd::try_parse_from(&["test", "--chain", "chain_id", "--port", "port_id"]).is_err()) + } + + #[test] + fn test_clear_packets_no_port() { + assert!(ClearPacketsCmd::try_parse_from(&["test", "--chain", "chain_id", "--chan", "channel-07"]).is_err()) + } + + #[test] + fn test_clear_packets_no_chain() { + assert!(ClearPacketsCmd::try_parse_from(&["test", "--port", "port_id", "--chan", "channel-07"]).is_err()) + } +} \ No newline at end of file diff --git a/relayer-cli/src/commands/completions.rs b/relayer-cli/src/commands/completions.rs index bc7ca6c235..6c0b1e97dd 100644 --- a/relayer-cli/src/commands/completions.rs +++ b/relayer-cli/src/commands/completions.rs @@ -5,7 +5,7 @@ use clap::IntoApp; use clap_complete::Shell; use std::io; -#[derive(Debug, Parser)] +#[derive(Debug, Parser, PartialEq)] pub struct CompletionsCmd { #[clap(long = "shell", value_name = "SHELL", arg_enum)] shell: Shell, @@ -18,3 +18,29 @@ impl Runnable for CompletionsCmd { clap_complete::generate(self.shell, &mut app, app_name, &mut io::stdout()); } } + +#[cfg(test)] +mod tests { + use super::CompletionsCmd; + + use abscissa_core::clap::Parser; + use clap_complete::Shell; + + #[test] + fn test_completions() { + assert_eq!( + CompletionsCmd{ shell: Shell::Zsh}, + CompletionsCmd::parse_from(&["test", "--shell", "zsh"]) + ) + } + + #[test] + fn test_completions_no_shell() { + assert!(CompletionsCmd::try_parse_from(&["test", "--shell"]).is_err()) + } + + #[test] + fn test_completions_unknown_shell() { + assert!(CompletionsCmd::try_parse_from(&["test", "--shell", "my_shell"]).is_err()) + } +} \ No newline at end of file diff --git a/relayer-cli/src/commands/create/channel.rs b/relayer-cli/src/commands/create/channel.rs index 90c376bb31..4ce2766f11 100644 --- a/relayer-cli/src/commands/create/channel.rs +++ b/relayer-cli/src/commands/create/channel.rs @@ -42,7 +42,7 @@ static HINT: &str = "Consider using the default invocation\n\nhermes create chan /// Note that `Connection-ID`s have to be considered based off of the chain's perspective. Although /// chain A and chain B might refer to the connection with different names, they are actually referring /// to the same connection. -#[derive(Clone, Command, Debug, Parser)] +#[derive(Clone, Command, Debug, Parser, PartialEq)] #[clap(disable_version_flag = true)] pub struct CreateChannelCommand { #[clap( @@ -55,6 +55,8 @@ pub struct CreateChannelCommand { #[clap( long = "b-chain", + group = "chain_b", + requires = "new_client", value_name = "B_CHAIN_ID", help = "Identifier of the side `b` chain for the new channel" )] @@ -62,6 +64,8 @@ pub struct CreateChannelCommand { #[clap( long = "a-conn", + required = true, + groups = &["chain_b", "new_client"], value_name = "A_CONNECTION_ID", help = "Identifier of the connection on chain `a` to use in creating the new channel." )] @@ -101,6 +105,7 @@ pub struct CreateChannelCommand { #[clap( long = "new-client-conn", + group = "new_client", help = "Indicates that a new client and connection will be created underlying the new channel" )] new_client_connection: bool, @@ -112,36 +117,29 @@ impl Runnable for CreateChannelCommand { Some(conn) => self.run_reusing_connection(conn), None => match &self.chain_b { Some(chain_b) => { - if self.new_client_connection { - match Confirm::new() - .with_prompt(format!( - "{}: {}\n{}: {}", - style("WARN").yellow(), - PROMPT, - style("Hint").cyan(), - HINT - )) - .interact() - { - Ok(confirm) => { - if confirm { - self.run_using_new_connection(chain_b); - } else { - Output::error("You elected not to create new clients and connections. Please re-invoke `create channel` with a pre-existing connection ID".to_string()).exit(); - } - } - Err(e) => { - Output::error(format!( - "An error occurred while waiting for user input: {}", - e - )); + match Confirm::new() + .with_prompt(format!( + "{}: {}\n{}: {}", + style("WARN").yellow(), + PROMPT, + style("Hint").cyan(), + HINT + )) + .interact() + { + Ok(confirm) => { + if confirm { + self.run_using_new_connection(chain_b); + } else { + Output::error("You elected not to create new clients and connections. Please re-invoke `create channel` with a pre-existing connection ID".to_string()).exit(); } } - } else { - Output::error( - "The `--new-client-connection` flag is required if invoking with `--chain-b`".to_string() - ) - .exit(); + Err(e) => { + Output::error(format!( + "An error occurred while waiting for user input: {}", + e + )); + } } } None => Output::error("Missing one of `` or ``".to_string()) @@ -244,3 +242,71 @@ impl CreateChannelCommand { Output::success(channel).exit(); } } + +#[cfg(test)] +mod tests { + use std::str::FromStr; + + use super::CreateChannelCommand; + use abscissa_core::clap::Parser; + + use ibc::core::ics04_channel::Version; + use ibc::core::ics04_channel::channel::Order; + use ibc::core::ics24_host::identifier::{ChainId, ConnectionId, PortId}; + + #[test] + fn test_create_channel_reuse_client() { + assert_eq!( + CreateChannelCommand{ chain_a: ChainId::from_string("chain_a"), chain_b: None, connection_a: Some(ConnectionId::from_str("connection_a").unwrap()), port_a: PortId::from_str("port_id_a").unwrap(), port_b: PortId::from_str("port_id_b").unwrap(), order: Order::Unordered, version: None, new_client_connection: false }, + CreateChannelCommand::parse_from(&["test", "--a-chain", "chain_a", "--a-conn", "connection_a", "--a-port", "port_id_a", "--b-port", "port_id_b"]) + ) + } + + #[test] + fn test_create_channel_version() { + assert_eq!( + CreateChannelCommand{ chain_a: ChainId::from_string("chain_a"), chain_b: None, connection_a: Some(ConnectionId::from_str("connection_a").unwrap()), port_a: PortId::from_str("port_id_a").unwrap(), port_b: PortId::from_str("port_id_b").unwrap(), order: Order::Unordered, version: Some(Version::new("v1".to_owned())), new_client_connection: false }, + CreateChannelCommand::parse_from(&["test", "--a-chain", "chain_a", "--a-conn", "connection_a", "--a-port", "port_id_a", "--b-port", "port_id_b", "--chan-version", "v1"]) + ) + } + + #[test] + fn test_create_channel_order() { + assert_eq!( + CreateChannelCommand{ chain_a: ChainId::from_string("chain_a"), chain_b: None, connection_a: Some(ConnectionId::from_str("connection_a").unwrap()), port_a: PortId::from_str("port_id_a").unwrap(), port_b: PortId::from_str("port_id_b").unwrap(), order: Order::Ordered, version: None, new_client_connection: false }, + CreateChannelCommand::parse_from(&["test", "--a-chain", "chain_a", "--a-conn", "connection_a", "--a-port", "port_id_a", "--b-port", "port_id_b", "--order", "ordered"]) + ) + } + + #[test] + fn test_create_channel_reuse_client_with_new_client() { + assert!( + CreateChannelCommand::try_parse_from(&["test", "--a-chain", "chain_a", "--a-conn", "connection_a", "--a-port", "port_id_a", "--b-port", "port_id_b", "--new-client-conn"]).is_err() + ) + } + + #[test] + fn test_create_channel_new_client() { + assert_eq!( + CreateChannelCommand{ chain_a: ChainId::from_string("chain_a"), chain_b: Some(ChainId::from_string("chain_b")), connection_a: None, port_a: PortId::from_str("port_id_a").unwrap(), port_b: PortId::from_str("port_id_b").unwrap(), order: Order::Unordered, version: None, new_client_connection: true }, + CreateChannelCommand::parse_from(&["test", "--a-chain", "chain_a", "--b-chain", "chain_b", "--a-port", "port_id_a", "--b-port", "port_id_b", "--new-client-conn"]) + ) + } + + #[test] + fn test_create_channel_reuse_client_with_b_chain() { + assert!( + CreateChannelCommand::try_parse_from(&["test", "--a-chain", "chain_a", "--b-chain", "chain_b", "--a-conn", "connection_a", "--a-port", "port_id_a", "--b-port", "port_id_b", "--order", "ordered"]).is_err() + ) + } + + #[test] + fn test_create_channel_b_chain_without_new_client() { + assert!(CreateChannelCommand::try_parse_from(&["test", "--a-chain", "chain_a", "--b-chain", "chain_b", "--a-port", "port_id_a", "--b-port", "port_id_b"]).is_err()) + } + + #[test] + fn test_create_channel_no_b_chain_nor_a_conn() { + assert!(CreateChannelCommand::try_parse_from(&["test", "--a-chain", "chain_a", "--a-port", "port_id_a", "--b-port", "port_id_b"]).is_err()) + } +} \ No newline at end of file diff --git a/relayer-cli/src/commands/create/connection.rs b/relayer-cli/src/commands/create/connection.rs index c346bfa0fc..a7d757b69d 100644 --- a/relayer-cli/src/commands/create/connection.rs +++ b/relayer-cli/src/commands/create/connection.rs @@ -14,7 +14,7 @@ use crate::cli_utils::{spawn_chain_runtime, ChainHandlePair}; use crate::conclude::{exit_with_unrecoverable_error, Output}; use crate::prelude::*; -#[derive(Clone, Command, Debug, Parser)] +#[derive(Clone, Command, Debug, Parser, PartialEq)] pub struct CreateConnectionCommand { #[clap( long = "a-chain", @@ -26,6 +26,8 @@ pub struct CreateConnectionCommand { #[clap( long = "b-chain", + required = true, + groups = &["client_a", "client_b"], value_name = "B_CHAIN_ID", help = "identifier of the side `b` chain for the new connection" )] @@ -33,6 +35,8 @@ pub struct CreateConnectionCommand { #[clap( long = "a-client", + required = true, + group = "client_a", value_name = "A_CLIENT_ID", help = "identifier of client hosted on chain `a`; default: None (creates a new client)" )] @@ -40,6 +44,8 @@ pub struct CreateConnectionCommand { #[clap( long = "b-client", + required = true, + group = "client_b", value_name = "B_CLIENT_ID", help = "identifier of client hosted on chain `b`; default: None (creates a new client)" )] @@ -54,9 +60,9 @@ pub struct CreateConnectionCommand { delay: u64, } -// cargo run --bin hermes -- create connection --chain-a ibc-0 --chain-b ibc-1 -// cargo run --bin hermes -- create connection --chain-a ibc-0 --chain-b ibc-1 --delay 100 -// cargo run --bin hermes -- create connection --chain-a ibc-0 --client-a 07-tendermint-0 --client-b 07-tendermint-0 +// cargo run --bin hermes -- create connection --a-chain ibc-0 --b-chain ibc-1 +// cargo run --bin hermes -- create connection --a-chain ibc-0 --b-chain ibc-1 --delay 100 +// cargo run --bin hermes -- create connection --a-chain ibc-0 --a-client 07-tendermint-0 --b-client 07-tendermint-0 impl Runnable for CreateConnectionCommand { fn run(&self) { match &self.chain_b_id { @@ -74,16 +80,6 @@ impl CreateConnectionCommand { let chains = ChainHandlePair::spawn(&config, &self.chain_a_id, chain_b_id) .unwrap_or_else(exit_with_unrecoverable_error); - // Validate the other options. Bail if the CLI was invoked with incompatible options. - if self.client_a.is_some() { - Output::error("Option `` is incompatible with `--client-a`".to_string()) - .exit(); - } - if self.client_b.is_some() { - Output::error("Option `` is incompatible with `--client-b`".to_string()) - .exit(); - } - info!( "Creating new clients hosted on chains {} and {}", self.chain_a_id, chain_b_id @@ -116,7 +112,7 @@ impl CreateConnectionCommand { let client_a_id = match &self.client_a { Some(c) => c, None => Output::error( - "Option `--client-a` is necessary when is missing".to_string(), + "Option `--a-client` is necessary when is missing".to_string(), ) .exit(), }; @@ -147,7 +143,7 @@ impl CreateConnectionCommand { let client_b_id = match &self.client_b { Some(c) => c, None => Output::error( - "Option `--client-b` is necessary when is missing".to_string(), + "Option `--b-client` is necessary when is missing".to_string(), ) .exit(), }; @@ -171,3 +167,70 @@ impl CreateConnectionCommand { } } } + +#[cfg(test)] +mod tests { + use super::CreateConnectionCommand; + + use abscissa_core::clap::Parser; + use ibc::core::ics24_host::identifier::{ChainId, ClientId}; + + use std::str::FromStr; + + #[test] + fn test_create_connection_chain_a_and_chain_b() { + assert_eq!( + CreateConnectionCommand{ chain_a_id: ChainId::from_string("chain_a"), chain_b_id: Some(ChainId::from_string("chain_b")), client_a: None, client_b: None, delay: 0 }, + CreateConnectionCommand::parse_from(&["test", "--a-chain", "chain_a", "--b-chain", "chain_b"]) + ) + } + + #[test] + fn test_create_connection_chain_a_and_chain_b_with_delay() { + assert_eq!( + CreateConnectionCommand{ chain_a_id: ChainId::from_string("chain_a"), chain_b_id: Some(ChainId::from_string("chain_b")), client_a: None, client_b: None, delay: 42 }, + CreateConnectionCommand::parse_from(&["test", "--a-chain", "chain_a", "--b-chain", "chain_b", "--delay", "42"]) + ) + } + + #[test] + fn create_connection_chain_a_and_clients() { + assert_eq!( + CreateConnectionCommand{ chain_a_id: ChainId::from_string("chain_a"), chain_b_id: None, client_a: Some(ClientId::from_str("07-client_a").unwrap()), client_b: Some(ClientId::from_str("07-client_b").unwrap()), delay: 0 }, + CreateConnectionCommand::parse_from(&["test", "--a-chain", "chain_a", "--a-client", "07-client_a", "--b-client", "07-client_b"]) + ) + } + + #[test] + fn create_connection_chain_a_and_clients_with_delay() { + assert_eq!( + CreateConnectionCommand{ chain_a_id: ChainId::from_string("chain_a"), chain_b_id: None, client_a: Some(ClientId::from_str("07-client_a").unwrap()), client_b: Some(ClientId::from_str("07-client_b").unwrap()), delay: 42 }, + CreateConnectionCommand::parse_from(&["test", "--a-chain", "chain_a", "--a-client", "07-client_a", "--b-client", "07-client_b", "--delay", "42"]) + ) + } + + #[test] + fn test_create_connection_chain_a_only() { + assert!(CreateConnectionCommand::try_parse_from(&["test", "--a-chain", "chain_a"]).is_err()) + } + + #[test] + fn test_create_connection_client_a_required_without_chain_b() { + assert!(CreateConnectionCommand::try_parse_from(&["test", "--a-chain", "chain_a", "--b-client", "client_b"]).is_err()) + } + + #[test] + fn test_create_connection_client_b_required_without_chain_b() { + assert!(CreateConnectionCommand::try_parse_from(&["test", "--a-chain", "chain_a", "--a-client", "client_a"]).is_err()) + } + + #[test] + fn test_create_connection_only_chain_b_or_client_a() { + assert!(CreateConnectionCommand::try_parse_from(&["test", "--a-chain", "chain_a", "--b-chain", "chain_b", "--a-client", "07-client_a"]).is_err()) + } + + #[test] + fn test_create_connection_only_chain_b_or_client_b() { + assert!(CreateConnectionCommand::try_parse_from(&["test", "--a-chain", "chain_a", "--b-chain", "chain_b", "--b-client", "07-client_b"]).is_err()) + } +} \ No newline at end of file diff --git a/relayer-cli/src/commands/keys/add.rs b/relayer-cli/src/commands/keys/add.rs index 41a594a05b..268ce6882a 100644 --- a/relayer-cli/src/commands/keys/add.rs +++ b/relayer-cli/src/commands/keys/add.rs @@ -179,3 +179,45 @@ pub fn restore_key( keyring.add_key(key_name, key_entry.clone())?; Ok(key_entry) } + +#[cfg(test)] +mod tests { + + use super::KeysAddCmd; + use std::path::PathBuf; + + use abscissa_core::clap::Parser; + use ibc::core::ics24_host::identifier::ChainId; + + #[test] + fn test_keys_add_key_file() { + assert_eq!( + KeysAddCmd{ chain_id: ChainId::from_string("chain_id"), key_file: Some(PathBuf::from("key_file")), mnemonic_file: None, key_name: None, hd_path: "m/44'/118'/0'/0/0".to_string() }, + KeysAddCmd::parse_from(&["test", "--chain", "chain_id", "--key-file", "key_file"]) + ) + } + + #[test] + fn test_keys_add_mnemonic_file() { + assert_eq!( + KeysAddCmd{ chain_id: ChainId::from_string("chain_id"), key_file: None, mnemonic_file: Some(PathBuf::from("mnemonic_file")), key_name: None, hd_path: "m/44'/118'/0'/0/0".to_string() }, + KeysAddCmd::parse_from(&["test", "--chain", "chain_id", "--mnemonic-file", "mnemonic_file"]) + ) + } + + #[test] + fn test_keys_add_no_file_nor_mnemonic() { + assert!(KeysAddCmd::try_parse_from(&["test", "--chain", "chain_id"]).is_err()); + } + + #[test] + fn test_keys_add_key_and_mnemonic() { + assert!(KeysAddCmd::try_parse_from(&["test", "--chain", "chain_id", "--key-file", "key_file", "--mnemonic-file", "mnemonic_file"]).is_err()); + } + + + #[test] + fn test_keys_add_no_chain() { + assert!(KeysAddCmd::try_parse_from(&["test", "--key-file", "key_file"]).is_err()); + } +} \ No newline at end of file diff --git a/relayer-cli/src/commands/keys/balance.rs b/relayer-cli/src/commands/keys/balance.rs index 6d911469d5..750dd84b90 100644 --- a/relayer-cli/src/commands/keys/balance.rs +++ b/relayer-cli/src/commands/keys/balance.rs @@ -17,7 +17,7 @@ use crate::conclude::{exit_with_unrecoverable_error, json, Output}; /// If no key name is given, it will be taken from the configuration file. /// If successful the balance and denominator of the account, associated with the key name /// on the given chain, will be displayed. -#[derive(Clone, Command, Debug, Parser)] +#[derive(Clone, Command, Debug, Parser, PartialEq)] pub struct KeyBalanceCmd { #[clap( long = "chain", @@ -69,3 +69,33 @@ impl Runnable for KeyBalanceCmd { } } } + +#[cfg(test)] +mod tests { + + use super::KeyBalanceCmd; + + use abscissa_core::clap::Parser; + use ibc::core::ics24_host::identifier::ChainId; + + #[test] + fn test_keys_balance_required_only() { + assert_eq!( + KeyBalanceCmd{ chain_id: ChainId::from_string("chain_id"), key_name: None }, + KeyBalanceCmd::parse_from(&["test", "--chain", "chain_id"]) + ) + } + + #[test] + fn test_keys_balance_name() { + assert_eq!( + KeyBalanceCmd{ chain_id: ChainId::from_string("chain_id"), key_name: Some("kname".to_owned()) }, + KeyBalanceCmd::parse_from(&["test", "--chain", "chain_id", "--key-name", "kname"]) + ) + } + + #[test] + fn test_keys_balance_no_chain() { + assert!(KeyBalanceCmd::try_parse_from(&["test", "--key-name", "kname"]).is_err()) + } +} \ No newline at end of file diff --git a/relayer-cli/src/commands/keys/delete.rs b/relayer-cli/src/commands/keys/delete.rs index f5af54c604..5fc765d7d0 100644 --- a/relayer-cli/src/commands/keys/delete.rs +++ b/relayer-cli/src/commands/keys/delete.rs @@ -10,7 +10,7 @@ use ibc_relayer::{ use crate::application::app_config; use crate::conclude::Output; -#[derive(Clone, Command, Debug, Parser)] +#[derive(Clone, Command, Debug, Parser, PartialEq)] pub struct KeysDeleteCmd { #[clap( long = "chain", @@ -20,10 +20,10 @@ pub struct KeysDeleteCmd { )] chain_id: ChainId, - #[clap(long = "key-name", value_name = "KEY_NAME", help = "name of the key")] + #[clap(long = "key-name", required = true, value_name = "KEY_NAME", group = "delete_key", help = "name of the key")] key_name: Option, - #[clap(long = "all", help = "delete all keys")] + #[clap(long = "all", required = true, group = "delete_key", help = "delete all keys")] all: bool, } @@ -37,18 +37,12 @@ impl KeysDeleteCmd { .ok_or_else(|| format!("chain '{}' not found in configuration file", self.chain_id))?; let id = match (self.all, &self.key_name) { - (true, Some(_)) => { - return Err("cannot set both -k/--key-name and -a/--all" - .to_owned() - .into()); - } - (false, None) => { - return Err("must provide either -k/--key-name or -a/--all" - .to_owned() - .into()); - } (true, None) => KeysDeleteId::All, (false, Some(ref key_name)) => KeysDeleteId::Named(key_name), + // This case should never be attained as --all and --key-name have the same group and are required. + _ => { + return Err("Error with clap parser. A parsing error should have been triggered.".to_owned().into()); + } }; Ok(KeysDeleteOptions { @@ -113,3 +107,42 @@ pub fn delete_all_keys(config: &ChainConfig) -> Result<(), Box( Ok(()) } + +#[cfg(test)] +mod tests { + use super::MisbehaviourCmd; + + use std::str::FromStr; + + use abscissa_core::clap::Parser; + use ibc::core::ics24_host::identifier::{ChainId, ClientId}; + + #[test] + fn test_misbehaviour() { + assert_eq!( + MisbehaviourCmd{ chain_id: ChainId::from_string("chain_id"), client_id: ClientId::from_str("client_id").unwrap() }, + MisbehaviourCmd::parse_from(&["test", "--chain", "chain_id", "--client", "client_id"]) + ) + } + + #[test] + fn test_misbehaviour_no_client() { + assert!(MisbehaviourCmd::try_parse_from(&["test", "--chain", "chain_id"]).is_err()) + } + + #[test] + fn test_misbehaviour_no_chain() { + assert!(MisbehaviourCmd::try_parse_from(&["test", "--client", "client_id"]).is_err()) + } +} \ No newline at end of file diff --git a/relayer-cli/src/commands/query/channel.rs b/relayer-cli/src/commands/query/channel.rs index 8022980c99..c605fe9684 100644 --- a/relayer-cli/src/commands/query/channel.rs +++ b/relayer-cli/src/commands/query/channel.rs @@ -11,7 +11,7 @@ use crate::conclude::{exit_with_unrecoverable_error, Output}; use crate::prelude::*; use ibc::core::ics04_channel::channel::State; -#[derive(Clone, Command, Debug, Parser)] +#[derive(Clone, Command, Debug, Parser, PartialEq)] pub struct QueryChannelEndCmd { #[clap( long = "chain", @@ -80,3 +80,44 @@ impl Runnable for QueryChannelEndCmd { } } } + +#[cfg(test)] +mod tests { + use super::QueryChannelEndCmd; + + use std::str::FromStr; + + use abscissa_core::clap::Parser; + use ibc::core::ics24_host::identifier::{ChainId, PortId, ChannelId}; + + #[test] + fn test_query_channel_end_required_only() { + assert_eq!( + QueryChannelEndCmd{ chain_id: ChainId::from_string("chain_id"), port_id: PortId::from_str("port_id").unwrap(), channel_id: ChannelId::from_str("channel-07").unwrap(), height: None }, + QueryChannelEndCmd::parse_from(&["test", "--chain", "chain_id", "--port", "port_id", "--chan", "channel-07"]) + ) + } + + #[test] + fn test_query_channel_end_height() { + assert_eq!( + QueryChannelEndCmd{ chain_id: ChainId::from_string("chain_id"), port_id: PortId::from_str("port_id").unwrap(), channel_id: ChannelId::from_str("channel-07").unwrap(), height: Some(42) }, + QueryChannelEndCmd::parse_from(&["test", "--chain", "chain_id", "--port", "port_id", "--chan", "channel-07", "--height", "42"]) + ) + } + + #[test] + fn test_query_channel_end_no_chan() { + assert!(QueryChannelEndCmd::try_parse_from(&["test", "--chain", "chain_id", "--port", "port_id"]).is_err()) + } + + #[test] + fn test_query_channel_end_no_port() { + assert!(QueryChannelEndCmd::try_parse_from(&["test", "--chain", "chain_id", "--chan", "channel-07"]).is_err()) + } + + #[test] + fn test_query_channel_end_no_chain() { + assert!(QueryChannelEndCmd::try_parse_from(&["test", "--port", "port_id", "--chan", "channel-07"]).is_err()) + } +} \ No newline at end of file diff --git a/relayer-cli/src/commands/query/channel_client.rs b/relayer-cli/src/commands/query/channel_client.rs index 1d84fbd6c5..8a2a7ee008 100644 --- a/relayer-cli/src/commands/query/channel_client.rs +++ b/relayer-cli/src/commands/query/channel_client.rs @@ -14,7 +14,7 @@ use crate::conclude::{exit_with_unrecoverable_error, Output}; /// `query channel client --chain --port --chan ` /// /// If successful the channel's client state is displayed. -#[derive(Clone, Command, Debug, Parser)] +#[derive(Clone, Command, Debug, Parser, PartialEq)] pub struct QueryChannelClientCmd { #[clap( long = "chain", @@ -57,3 +57,36 @@ impl Runnable for QueryChannelClientCmd { } } } + +#[cfg(test)] +mod tests { + use super::QueryChannelClientCmd; + + use std::str::FromStr; + + use abscissa_core::clap::Parser; + use ibc::core::ics24_host::identifier::{ChainId, PortId, ChannelId}; + + #[test] + fn test_query_channel_client() { + assert_eq!( + QueryChannelClientCmd{ chain_id: ChainId::from_string("chain_id"), port_id: PortId::from_str("port_id").unwrap(), channel_id: ChannelId::from_str("channel-07").unwrap() }, + QueryChannelClientCmd::parse_from(&["test", "--chain", "chain_id", "--port", "port_id", "--chan", "channel-07"]) + ) + } + + #[test] + fn test_query_channel_client_no_chan() { + assert!(QueryChannelClientCmd::try_parse_from(&["test", "--chain", "chain_id", "--port", "port_id"]).is_err()) + } + + #[test] + fn test_query_channel_client_no_port() { + assert!(QueryChannelClientCmd::try_parse_from(&["test", "--chain", "chain_id", "--chan", "channel-07"]).is_err()) + } + + #[test] + fn test_query_channel_client_no_chain() { + assert!(QueryChannelClientCmd::try_parse_from(&["test", "--port", "port_id", "--chan", "channel-07"]).is_err()) + } +} \ No newline at end of file diff --git a/relayer-cli/src/commands/query/channel_ends.rs b/relayer-cli/src/commands/query/channel_ends.rs index e0bbfb2d74..9e2cd8a96d 100644 --- a/relayer-cli/src/commands/query/channel_ends.rs +++ b/relayer-cli/src/commands/query/channel_ends.rs @@ -17,7 +17,7 @@ use ibc_relayer::registry::Registry; use crate::conclude::Output; use crate::prelude::*; -#[derive(Clone, Command, Debug, Parser)] +#[derive(Clone, Command, Debug, Parser, PartialEq)] pub struct QueryChannelEndsCmd { #[clap( long = "chain", @@ -237,3 +237,52 @@ impl Runnable for QueryChannelEndsCmd { } } } + +#[cfg(test)] +mod tests { + use super::QueryChannelEndsCmd; + + use std::str::FromStr; + + use abscissa_core::clap::Parser; + use ibc::core::ics24_host::identifier::{ChainId, PortId, ChannelId}; + + #[test] + fn test_query_channel_ends_required_only() { + assert_eq!( + QueryChannelEndsCmd{ chain_id: ChainId::from_string("chain_id"), port_id: PortId::from_str("port_id").unwrap(), channel_id: ChannelId::from_str("channel-07").unwrap(), height: None, verbose: false }, + QueryChannelEndsCmd::parse_from(&["test", "--chain", "chain_id", "--port", "port_id", "--chan", "channel-07"]) + ) + } + + #[test] + fn test_query_channel_ends_height() { + assert_eq!( + QueryChannelEndsCmd{ chain_id: ChainId::from_string("chain_id"), port_id: PortId::from_str("port_id").unwrap(), channel_id: ChannelId::from_str("channel-07").unwrap(), height: Some(42), verbose: false }, + QueryChannelEndsCmd::parse_from(&["test", "--chain", "chain_id", "--port", "port_id", "--chan", "channel-07", "--height", "42"]) + ) + } + + #[test] + fn test_query_channel_ends_verbose() { + assert_eq!( + QueryChannelEndsCmd{ chain_id: ChainId::from_string("chain_id"), port_id: PortId::from_str("port_id").unwrap(), channel_id: ChannelId::from_str("channel-07").unwrap(), height: None, verbose: true }, + QueryChannelEndsCmd::parse_from(&["test", "--chain", "chain_id", "--port", "port_id", "--chan", "channel-07", "--verbose"]) + ) + } + + #[test] + fn test_query_channel_client_no_chan() { + assert!(QueryChannelEndsCmd::try_parse_from(&["test", "--chain", "chain_id", "--port", "port_id"]).is_err()) + } + + #[test] + fn test_query_channel_client_no_port() { + assert!(QueryChannelEndsCmd::try_parse_from(&["test", "--chain", "chain_id", "--chan", "channel-07"]).is_err()) + } + + #[test] + fn test_query_channel_client_no_chain() { + assert!(QueryChannelEndsCmd::try_parse_from(&["test", "--port", "port_id", "--chan", "channel-07"]).is_err()) + } +} \ No newline at end of file diff --git a/relayer-cli/src/commands/query/channels.rs b/relayer-cli/src/commands/query/channels.rs index 1b6b9fb9bc..1f91e6cc10 100644 --- a/relayer-cli/src/commands/query/channels.rs +++ b/relayer-cli/src/commands/query/channels.rs @@ -18,7 +18,7 @@ use crate::commands::query::channel_ends::ChannelEnds; use crate::conclude::Output; use crate::prelude::*; -#[derive(Clone, Command, Debug, Parser)] +#[derive(Clone, Command, Debug, Parser, PartialEq)] pub struct QueryChannelsCmd { #[clap( long = "chain", @@ -272,3 +272,40 @@ impl Debug for QueryChannelsOutput { } } } + +#[cfg(test)] +mod tests { + use super::QueryChannelsCmd; + + use abscissa_core::clap::Parser; + use ibc::core::ics24_host::identifier::ChainId; + + #[test] + fn test_query_channels_required_only() { + assert_eq!( + QueryChannelsCmd{ chain_id: ChainId::from_string("chain_id"), dst_chain_id: None, verbose: false }, + QueryChannelsCmd::parse_from(&["test", "--chain", "chain_id"]) + ) + } + + #[test] + fn test_query_channels_counterparty_chain() { + assert_eq!( + QueryChannelsCmd{ chain_id: ChainId::from_string("chain_id"), dst_chain_id: Some(ChainId::from_string("counterparty_chain_id")), verbose: false }, + QueryChannelsCmd::parse_from(&["test", "--chain", "chain_id", "--counterparty-chain", "counterparty_chain_id"]) + ) + } + + #[test] + fn test_query_channels_verbose() { + assert_eq!( + QueryChannelsCmd{ chain_id: ChainId::from_string("chain_id"), dst_chain_id: None, verbose: true }, + QueryChannelsCmd::parse_from(&["test", "--chain", "chain_id", "--verbose"]) + ) + } + + #[test] + fn test_query_channels_no_chain() { + assert!(QueryChannelsCmd::try_parse_from(&["test"]).is_err()) + } +} \ No newline at end of file diff --git a/relayer-cli/src/commands/query/client.rs b/relayer-cli/src/commands/query/client.rs index 3a2e1d5524..7cc8d5a786 100644 --- a/relayer-cli/src/commands/query/client.rs +++ b/relayer-cli/src/commands/query/client.rs @@ -21,7 +21,7 @@ use crate::cli_utils::spawn_chain_runtime; use crate::conclude::{exit_with_unrecoverable_error, Output}; /// Query client state command -#[derive(Clone, Command, Debug, Parser)] +#[derive(Clone, Command, Debug, Parser, PartialEq)] pub struct QueryClientStateCmd { #[clap( long = "chain", @@ -72,7 +72,7 @@ impl Runnable for QueryClientStateCmd { } /// Query client consensus command -#[derive(Clone, Command, Debug, Parser)] +#[derive(Clone, Command, Debug, Parser, PartialEq)] pub struct QueryClientConsensusCmd { #[clap( long = "chain", @@ -184,7 +184,7 @@ impl Runnable for QueryClientConsensusCmd { } } -#[derive(Clone, Command, Debug, Parser)] +#[derive(Clone, Command, Debug, Parser, PartialEq)] pub struct QueryClientHeaderCmd { #[clap( long = "chain", @@ -264,7 +264,7 @@ impl Runnable for QueryClientHeaderCmd { } /// Query client connections command -#[derive(Clone, Command, Debug, Parser)] +#[derive(Clone, Command, Debug, Parser, PartialEq)] pub struct QueryClientConnectionsCmd { #[clap( long = "chain", @@ -310,3 +310,138 @@ impl Runnable for QueryClientConnectionsCmd { } } } + +#[cfg(test)] +mod tests { + use super::{QueryClientStateCmd, QueryClientConnectionsCmd, QueryClientConsensusCmd, QueryClientHeaderCmd}; + + use std::str::FromStr; + + use abscissa_core::clap::Parser; + use ibc::core::ics24_host::identifier::{ChainId, ClientId}; + + #[test] + fn test_query_client_connections_required_only() { + assert_eq!( + QueryClientConnectionsCmd{ chain_id: ChainId::from_string("chain_id"), client_id: ClientId::from_str("client_id").unwrap(), height: None }, + QueryClientConnectionsCmd::parse_from(&["test", "--chain", "chain_id", "--client", "client_id"]) + ) + } + + #[test] + fn test_query_client_connections_height() { + assert_eq!( + QueryClientConnectionsCmd{ chain_id: ChainId::from_string("chain_id"), client_id: ClientId::from_str("client_id").unwrap(), height: Some(42) }, + QueryClientConnectionsCmd::parse_from(&["test", "--chain", "chain_id", "--client", "client_id", "--height", "42"]) + ) + } + + #[test] + fn test_query_client_connections_no_client() { + assert!(QueryClientConnectionsCmd::try_parse_from(&["test", "--chain", "chain_id"]).is_err()) + } + + #[test] + fn test_query_client_connections_no_chain() { + assert!(QueryClientConnectionsCmd::try_parse_from(&["test", "--client", "client_id"]).is_err()) + } + + #[test] + fn test_query_client_consensus_required_only() { + assert_eq!( + QueryClientConsensusCmd{ chain_id: ChainId::from_string("chain_id"), client_id: ClientId::from_str("client_id").unwrap(), consensus_height: None, heights_only: false, height: None }, + QueryClientConsensusCmd::parse_from(&["test", "--chain", "chain_id", "--client", "client_id"]) + ) + } + + #[test] + fn test_query_client_consensus_consensus_height() { + assert_eq!( + QueryClientConsensusCmd{ chain_id: ChainId::from_string("chain_id"), client_id: ClientId::from_str("client_id").unwrap(), consensus_height: Some(42), heights_only: false, height: None }, + QueryClientConsensusCmd::parse_from(&["test", "--chain", "chain_id", "--client", "client_id", "--consensus-height", "42"]) + ) + } + + #[test] + fn test_query_client_consensus_height() { + assert_eq!( + QueryClientConsensusCmd{ chain_id: ChainId::from_string("chain_id"), client_id: ClientId::from_str("client_id").unwrap(), consensus_height: None, heights_only: false, height: Some(42) }, + QueryClientConsensusCmd::parse_from(&["test", "--chain", "chain_id", "--client", "client_id", "--height", "42"]) + ) + } + + #[test] + fn test_query_client_consensus_heights_only() { + assert_eq!( + QueryClientConsensusCmd{ chain_id: ChainId::from_string("chain_id"), client_id: ClientId::from_str("client_id").unwrap(), consensus_height: None, heights_only: true, height: None }, + QueryClientConsensusCmd::parse_from(&["test", "--chain", "chain_id", "--client", "client_id", "--heights-only"]) + ) + } + + #[test] + fn test_query_client_consensus_no_client() { + assert!(QueryClientConsensusCmd::try_parse_from(&["test", "--chain", "chain_id"]).is_err()) + } + + #[test] + fn test_query_client_consensus_no_chain() { + assert!(QueryClientConsensusCmd::try_parse_from(&["test", "--client", "client_id"]).is_err()) + } + + #[test] + fn test_query_client_header_required_only() { + assert_eq!( + QueryClientHeaderCmd{ chain_id: ChainId::from_string("chain_id"), client_id: ClientId::from_str("client_id").unwrap(), consensus_height: 42, height: None }, + QueryClientHeaderCmd::parse_from(&["test", "--chain", "chain_id", "--client", "client_id", "--consensus-height", "42"]) + ) + } + + #[test] + fn test_query_client_header_height() { + assert_eq!( + QueryClientHeaderCmd{ chain_id: ChainId::from_string("chain_id"), client_id: ClientId::from_str("client_id").unwrap(), consensus_height: 42, height: Some(21) }, + QueryClientHeaderCmd::parse_from(&["test", "--chain", "chain_id", "--client", "client_id", "--consensus-height", "42", "--height", "21"]) + ) + } + + #[test] + fn test_query_client_header_no_consensus_height() { + assert!(QueryClientHeaderCmd::try_parse_from(&["test", "--chain", "chain_id", "--client", "client_id"]).is_err()) + } + + #[test] + fn test_query_client_header_no_client() { + assert!(QueryClientHeaderCmd::try_parse_from(&["test", "--chain", "chain_id", "--consensus-height", "42"]).is_err()) + } + + #[test] + fn test_query_client_header_no_chain() { + assert!(QueryClientHeaderCmd::try_parse_from(&["test", "--client", "client_id", "--consensus-height", "42"]).is_err()) + } + + #[test] + fn test_query_client_state_required_only() { + assert_eq!( + QueryClientStateCmd{ chain_id: ChainId::from_string("chain_id"), client_id: ClientId::from_str("client_id").unwrap(), height: None }, + QueryClientStateCmd::parse_from(&["test", "--chain", "chain_id", "--client", "client_id"]) + ) + } + + #[test] + fn test_query_client_state_height() { + assert_eq!( + QueryClientStateCmd{ chain_id: ChainId::from_string("chain_id"), client_id: ClientId::from_str("client_id").unwrap(), height: Some(42) }, + QueryClientStateCmd::parse_from(&["test", "--chain", "chain_id", "--client", "client_id", "--height", "42"]) + ) + } + + #[test] + fn test_query_client_state_no_client() { + assert!(QueryClientStateCmd::try_parse_from(&["test", "--chain", "chain_id"]).is_err()) + } + + #[test] + fn test_query_client_state_no_chain() { + assert!(QueryClientStateCmd::try_parse_from(&["test", "--client", "client_id"]).is_err()) + } +} \ No newline at end of file diff --git a/relayer-cli/src/commands/query/clients.rs b/relayer-cli/src/commands/query/clients.rs index 61d30520cd..d34096a652 100644 --- a/relayer-cli/src/commands/query/clients.rs +++ b/relayer-cli/src/commands/query/clients.rs @@ -13,7 +13,7 @@ use crate::error::Error; use crate::prelude::*; /// Query clients command -#[derive(Clone, Command, Debug, Parser)] +#[derive(Clone, Command, Debug, Parser, PartialEq)] pub struct QueryAllClientsCmd { #[clap( long = "host-chain", @@ -108,3 +108,40 @@ impl Runnable for QueryAllClientsCmd { } } } + +#[cfg(test)] +mod tests { + use super::QueryAllClientsCmd; + + use abscissa_core::clap::Parser; + use ibc::core::ics24_host::identifier::ChainId; + + #[test] + fn test_query_clients_required_only() { + assert_eq!( + QueryAllClientsCmd{ chain_id: ChainId::from_string("chain_host_id"), src_chain_id: None, omit_chain_ids: false }, + QueryAllClientsCmd::parse_from(&["test", "--host-chain", "chain_host_id"]) + ) + } + + #[test] + fn test_query_clients_omit_chain_ids() { + assert_eq!( + QueryAllClientsCmd{ chain_id: ChainId::from_string("chain_host_id"), src_chain_id: None, omit_chain_ids: true }, + QueryAllClientsCmd::parse_from(&["test", "--host-chain", "chain_host_id", "--omit-chain-ids"]) + ) + } + + #[test] + fn test_query_clients_reference_chain() { + assert_eq!( + QueryAllClientsCmd{ chain_id: ChainId::from_string("chain_host_id"), src_chain_id: Some(ChainId::from_string("reference_chain_id")), omit_chain_ids: false }, + QueryAllClientsCmd::parse_from(&["test", "--host-chain", "chain_host_id", "--reference-chain", "reference_chain_id"]) + ) + } + + #[test] + fn test_query_clients_no_chain() { + assert!(QueryAllClientsCmd::try_parse_from(&["test"]).is_err()) + } +} \ No newline at end of file diff --git a/relayer-cli/src/commands/query/connection.rs b/relayer-cli/src/commands/query/connection.rs index fbc2569ce7..248ca07ee9 100644 --- a/relayer-cli/src/commands/query/connection.rs +++ b/relayer-cli/src/commands/query/connection.rs @@ -16,7 +16,7 @@ use crate::conclude::{exit_with_unrecoverable_error, Output}; use crate::error::Error; use crate::prelude::*; -#[derive(Clone, Command, Debug, Parser)] +#[derive(Clone, Command, Debug, Parser, PartialEq)] pub struct QueryConnectionEndCmd { #[clap( long = "chain", @@ -81,7 +81,7 @@ impl Runnable for QueryConnectionEndCmd { /// Command for querying the channel identifiers associated with a connection. /// Sample invocation: /// `cargo run --bin hermes -- query connection channels ibc-0 connection-0` -#[derive(Clone, Command, Debug, Parser)] +#[derive(Clone, Command, Debug, Parser, PartialEq)] pub struct QueryConnectionChannelsCmd { #[clap( long = "chain", @@ -131,3 +131,57 @@ impl Runnable for QueryConnectionChannelsCmd { } } } + +#[cfg(test)] +mod tests { + use super::{QueryConnectionChannelsCmd, QueryConnectionEndCmd}; + + use std::str::FromStr; + + use abscissa_core::clap::Parser; + use ibc::core::ics24_host::identifier::{ChainId, ConnectionId}; + + #[test] + fn test_query_connection_channels() { + assert_eq!( + QueryConnectionChannelsCmd{ chain_id: ChainId::from_string("chain_id"), connection_id: ConnectionId::from_str("connection_id").unwrap() }, + QueryConnectionChannelsCmd::parse_from(&["test", "--chain", "chain_id", "--conn", "connection_id"]) + ) + } + + #[test] + fn test_query_connection_channels_no_conn() { + assert!(QueryConnectionChannelsCmd::try_parse_from(&["test", "--chain", "chain_id"]).is_err()) + } + + #[test] + fn test_query_connection_channels_no_chain() { + assert!(QueryConnectionChannelsCmd::try_parse_from(&["test", "--conn", "connection_id"]).is_err()) + } + + #[test] + fn test_query_connection_end_required_only() { + assert_eq!( + QueryConnectionEndCmd{ chain_id: ChainId::from_string("chain_id"), connection_id: ConnectionId::from_str("connection_id").unwrap(), height: None }, + QueryConnectionEndCmd::parse_from(&["test", "--chain", "chain_id", "--conn", "connection_id"]) + ) + } + + #[test] + fn test_query_connection_end_height() { + assert_eq!( + QueryConnectionEndCmd{ chain_id: ChainId::from_string("chain_id"), connection_id: ConnectionId::from_str("connection_id").unwrap(), height: Some(42) }, + QueryConnectionEndCmd::parse_from(&["test", "--chain", "chain_id", "--conn", "connection_id", "--height", "42"]) + ) + } + + #[test] + fn test_query_connection_end_no_conn() { + assert!(QueryConnectionEndCmd::try_parse_from(&["test", "--chain", "chain_id"]).is_err()) + } + + #[test] + fn test_query_connection_end_no_chain() { + assert!(QueryConnectionEndCmd::try_parse_from(&["test", "--conn", "connection_id"]).is_err()) + } +} \ No newline at end of file diff --git a/relayer-cli/src/commands/query/connections.rs b/relayer-cli/src/commands/query/connections.rs index e5e88ddd9a..d1b115870a 100644 --- a/relayer-cli/src/commands/query/connections.rs +++ b/relayer-cli/src/commands/query/connections.rs @@ -9,7 +9,7 @@ use crate::cli_utils::spawn_chain_runtime; use crate::conclude::{exit_with_unrecoverable_error, Output}; use crate::prelude::*; -#[derive(Clone, Command, Debug, Parser)] +#[derive(Clone, Command, Debug, Parser, PartialEq)] pub struct QueryConnectionsCmd { #[clap( long = "chain", @@ -47,3 +47,24 @@ impl Runnable for QueryConnectionsCmd { } } } + +#[cfg(test)] +mod tests { + use super::QueryConnectionsCmd; + + use abscissa_core::clap::Parser; + use ibc::core::ics24_host::identifier::ChainId; + + #[test] + fn test_query_connections() { + assert_eq!( + QueryConnectionsCmd{ chain_id: ChainId::from_string("chain_id") }, + QueryConnectionsCmd::parse_from(&["test", "--chain", "chain_id"]) + ) + } + + #[test] + fn test_query_connections_no_chain() { + assert!(QueryConnectionsCmd::try_parse_from(&["test"]).is_err()) + } +} \ No newline at end of file diff --git a/relayer-cli/src/commands/query/packet/ack.rs b/relayer-cli/src/commands/query/packet/ack.rs index a177762fc6..3abf928039 100644 --- a/relayer-cli/src/commands/query/packet/ack.rs +++ b/relayer-cli/src/commands/query/packet/ack.rs @@ -12,7 +12,7 @@ use crate::conclude::Output; use crate::error::Error; use crate::prelude::*; -#[derive(Clone, Command, Debug, Parser)] +#[derive(Clone, Command, Debug, Parser, PartialEq)] pub struct QueryPacketAcknowledgmentCmd { #[clap( long = "chain", @@ -94,3 +94,50 @@ impl Runnable for QueryPacketAcknowledgmentCmd { } } } + +#[cfg(test)] +mod tests { + use super::QueryPacketAcknowledgmentCmd; + + use std::str::FromStr; + + use abscissa_core::clap::Parser; + use ibc::core::ics24_host::identifier::{ChainId, ChannelId, PortId}; + use ibc::core::ics04_channel::packet::Sequence; + + #[test] + fn test_query_packet_ack_required_only() { + assert_eq!( + QueryPacketAcknowledgmentCmd{ chain_id: ChainId::from_string("chain_id"), port_id: PortId::from_str("port_id").unwrap(), channel_id: ChannelId::from_str("channel-07").unwrap(), sequence: Sequence::from(42), height: None }, + QueryPacketAcknowledgmentCmd::parse_from(&["test", "--chain", "chain_id", "--port", "port_id", "--chan", "channel-07", "--seq", "42"]) + ) + } + + #[test] + fn test_query_packet_ack_height() { + assert_eq!( + QueryPacketAcknowledgmentCmd{ chain_id: ChainId::from_string("chain_id"), port_id: PortId::from_str("port_id").unwrap(), channel_id: ChannelId::from_str("channel-07").unwrap(), sequence: Sequence::from(42), height: Some(21) }, + QueryPacketAcknowledgmentCmd::parse_from(&["test", "--chain", "chain_id", "--port", "port_id", "--chan", "channel-07", "--seq", "42", "--height", "21"]) + ) + } + + #[test] + fn test_query_packet_ack_no_seq() { + assert!(QueryPacketAcknowledgmentCmd::try_parse_from(&["test", "--chain", "chain_id", "--port", "port_id", "--chan", "channel-07"]).is_err()) + } + + #[test] + fn test_query_packet_ack_no_chan() { + assert!(QueryPacketAcknowledgmentCmd::try_parse_from(&["test", "--chain", "chain_id", "--port", "port_id", "--seq", "42"]).is_err()) + } + + #[test] + fn test_query_packet_ack_no_port() { + assert!(QueryPacketAcknowledgmentCmd::try_parse_from(&["test", "--chain", "chain_id", "--chan", "channel-07", "--seq", "42"]).is_err()) + } + + #[test] + fn test_query_packet_ack_no_chain() { + assert!(QueryPacketAcknowledgmentCmd::try_parse_from(&["test", "--port", "port_id", "--chan", "channel-07", "--seq", "42"]).is_err()) + } +} \ No newline at end of file diff --git a/relayer-cli/src/commands/query/packet/acks.rs b/relayer-cli/src/commands/query/packet/acks.rs index 1ba0df863b..29fae7aae1 100644 --- a/relayer-cli/src/commands/query/packet/acks.rs +++ b/relayer-cli/src/commands/query/packet/acks.rs @@ -19,7 +19,7 @@ struct PacketSeqs { seqs: Vec, } -#[derive(Clone, Command, Debug, Parser)] +#[derive(Clone, Command, Debug, Parser, PartialEq)] pub struct QueryPacketAcknowledgementsCmd { #[clap( long = "chain", @@ -76,3 +76,36 @@ impl Runnable for QueryPacketAcknowledgementsCmd { } } } + +#[cfg(test)] +mod tests { + use super::QueryPacketAcknowledgementsCmd; + + use std::str::FromStr; + + use abscissa_core::clap::Parser; + use ibc::core::ics24_host::identifier::{ChainId, PortId, ChannelId}; + + #[test] + fn test_query_packet_acks() { + assert_eq!( + QueryPacketAcknowledgementsCmd{chain_id: ChainId::from_string("chain_id"), port_id: PortId::from_str("port_id").unwrap(), channel_id: ChannelId::from_str("channel-07").unwrap()}, + QueryPacketAcknowledgementsCmd::parse_from(&["test", "--chain", "chain_id", "--port", "port_id", "--chan", "channel-07"]) + ) + } + + #[test] + fn test_query_packet_acks_no_chan() { + assert!(QueryPacketAcknowledgementsCmd::try_parse_from(&["test", "--chain", "chain_id", "--port", "port_id"]).is_err()) + } + + #[test] + fn test_query_packet_acks_no_port() { + assert!(QueryPacketAcknowledgementsCmd::try_parse_from(&["test", "--chain", "chain_id", "--chan", "channel-07"]).is_err()) + } + + #[test] + fn test_query_packet_acks_no_chain() { + assert!(QueryPacketAcknowledgementsCmd::try_parse_from(&["test", "--port", "port_id", "--chan", "channel-07"]).is_err()) + } +} \ No newline at end of file diff --git a/relayer-cli/src/commands/query/packet/commitment.rs b/relayer-cli/src/commands/query/packet/commitment.rs index 02e2202362..d1ef4eef3c 100644 --- a/relayer-cli/src/commands/query/packet/commitment.rs +++ b/relayer-cli/src/commands/query/packet/commitment.rs @@ -20,7 +20,7 @@ struct PacketSeqs { seqs: Vec, } -#[derive(Clone, Command, Debug, Parser)] +#[derive(Clone, Command, Debug, Parser, PartialEq)] pub struct QueryPacketCommitmentCmd { #[clap( long = "chain", @@ -105,3 +105,49 @@ impl Runnable for QueryPacketCommitmentCmd { } } } + +#[cfg(test)] +mod tests { + use super::QueryPacketCommitmentCmd; + + use std::str::FromStr; + + use abscissa_core::clap::Parser; + use ibc::core::{ics24_host::identifier::{ChainId, PortId, ChannelId}, ics04_channel::packet::Sequence}; + + #[test] + fn test_query_packet_commitment_required_only() { + assert_eq!( + QueryPacketCommitmentCmd{ chain_id: ChainId::from_string("chain_id"), port_id: PortId::from_str("port_id").unwrap(), channel_id: ChannelId::from_str("channel-07").unwrap(), sequence: Sequence::from(42), height: None }, + QueryPacketCommitmentCmd::parse_from(&["test", "--chain", "chain_id", "--port", "port_id", "--chan", "channel-07", "--seq", "42"]) + ) + } + + #[test] + fn test_query_packet_commitment_height() { + assert_eq!( + QueryPacketCommitmentCmd{ chain_id: ChainId::from_string("chain_id"), port_id: PortId::from_str("port_id").unwrap(), channel_id: ChannelId::from_str("channel-07").unwrap(), sequence: Sequence::from(42), height: Some(21) }, + QueryPacketCommitmentCmd::parse_from(&["test", "--chain", "chain_id", "--port", "port_id", "--chan", "channel-07", "--seq", "42", "--height", "21"]) + ) + } + + #[test] + fn test_query_packet_commitment_no_seq() { + assert!(QueryPacketCommitmentCmd::try_parse_from(&["test", "--chain", "chain_id", "--port", "port_id", "--chan", "channel-07"]).is_err()) + } + + #[test] + fn test_query_packet_commitment_no_chan() { + assert!(QueryPacketCommitmentCmd::try_parse_from(&["test", "--chain", "chain_id", "--port", "port_id", "--seq", "42"]).is_err()) + } + + #[test] + fn test_query_packet_commitment_no_port() { + assert!(QueryPacketCommitmentCmd::try_parse_from(&["test", "--chain", "chain_id", "--chan", "channel-07", "--seq", "42"]).is_err()) + } + + #[test] + fn test_query_packet_commitment_no_chain() { + assert!(QueryPacketCommitmentCmd::try_parse_from(&["test", "--port", "port_id", "--chan", "channel-07", "--seq", "42"]).is_err()) + } +} \ No newline at end of file diff --git a/relayer-cli/src/commands/query/packet/commitments.rs b/relayer-cli/src/commands/query/packet/commitments.rs index 9e06b7c10b..79e1697488 100644 --- a/relayer-cli/src/commands/query/packet/commitments.rs +++ b/relayer-cli/src/commands/query/packet/commitments.rs @@ -18,7 +18,7 @@ struct PacketSeqs { seqs: Vec, } -#[derive(Clone, Command, Debug, Parser)] +#[derive(Clone, Command, Debug, Parser, PartialEq)] pub struct QueryPacketCommitmentsCmd { #[clap( long = "chain", @@ -71,3 +71,36 @@ impl Runnable for QueryPacketCommitmentsCmd { } } } + +#[cfg(test)] +mod tests { + use super::QueryPacketCommitmentsCmd; + + use std::str::FromStr; + + use abscissa_core::clap::Parser; + use ibc::core::ics24_host::identifier::{ChainId, PortId, ChannelId}; + + #[test] + fn test_query_packet_commitments() { + assert_eq!( + QueryPacketCommitmentsCmd{ chain_id: ChainId::from_string("chain_id"), port_id: PortId::from_str("port_id").unwrap(), channel_id: ChannelId::from_str("channel-07").unwrap() }, + QueryPacketCommitmentsCmd::parse_from(&["test", "--chain", "chain_id", "--port", "port_id", "--chan", "channel-07"]) + ) + } + + #[test] + fn test_query_packet_commitments_no_chan() { + assert!(QueryPacketCommitmentsCmd::try_parse_from(&["test", "--chain", "chain_id", "--port", "port_id"]).is_err()) + } + + #[test] + fn test_query_packet_commitments_no_port() { + assert!(QueryPacketCommitmentsCmd::try_parse_from(&["test", "--chain", "chain_id", "--chan", "channel-07"]).is_err()) + } + + #[test] + fn test_query_packet_commitments_no_chain() { + assert!(QueryPacketCommitmentsCmd::try_parse_from(&["test", "--port", "port_id", "--chan", "channel-07"]).is_err()) + } +} \ No newline at end of file diff --git a/relayer-cli/src/commands/query/packet/pending.rs b/relayer-cli/src/commands/query/packet/pending.rs index b4834358ef..d3d6c515b1 100644 --- a/relayer-cli/src/commands/query/packet/pending.rs +++ b/relayer-cli/src/commands/query/packet/pending.rs @@ -29,7 +29,7 @@ struct Summary { /// 2. queries both chains for all packet commitments/ sequences for the given port and channel /// and its counterparty. /// 3. queries both chains for the unreceived sequences and acks out of the lists obtained in 2. -#[derive(Clone, Command, Debug, Parser)] +#[derive(Clone, Command, Debug, Parser, PartialEq)] pub struct QueryPendingPacketsCmd { #[clap( long = "chain", @@ -99,3 +99,36 @@ impl Runnable for QueryPendingPacketsCmd { } } } + +#[cfg(test)] +mod tests { + use super::QueryPendingPacketsCmd; + + use std::str::FromStr; + + use abscissa_core::clap::Parser; + use ibc::core::ics24_host::identifier::{ChainId, PortId, ChannelId}; + + #[test] + fn test_query_packet_pending() { + assert_eq!( + QueryPendingPacketsCmd{ chain_id: ChainId::from_string("chain_id"), port_id: PortId::from_str("port_id").unwrap(), channel_id: ChannelId::from_str("channel-07").unwrap() }, + QueryPendingPacketsCmd::parse_from(&["test", "--chain", "chain_id", "--port", "port_id", "--chan", "channel-07"]) + ) + } + + #[test] + fn test_query_packet_pending_no_chan() { + assert!(QueryPendingPacketsCmd::try_parse_from(&["test", "--chain", "chain_id", "--port", "port_id"]).is_err()) + } + + #[test] + fn test_query_packet_pending_no_port() { + assert!(QueryPendingPacketsCmd::try_parse_from(&["test", "--chain", "chain_id", "--chan", "channel-07"]).is_err()) + } + + #[test] + fn test_query_packet_pending_no_chain() { + assert!(QueryPendingPacketsCmd::try_parse_from(&["test", "--port", "port_id", "--chan", "channel-07"]).is_err()) + } +} \ No newline at end of file diff --git a/relayer-cli/src/commands/query/packet/unreceived_acks.rs b/relayer-cli/src/commands/query/packet/unreceived_acks.rs index 831712e7df..72d40615b4 100644 --- a/relayer-cli/src/commands/query/packet/unreceived_acks.rs +++ b/relayer-cli/src/commands/query/packet/unreceived_acks.rs @@ -15,7 +15,7 @@ use crate::prelude::*; /// 1. queries the chain to get its counterparty, channel and port identifiers (needed in 2) /// 2. queries the chain for all packet commitments/ sequences for a given port and channel /// 3. queries the counterparty chain for the unacknowledged sequences out of the list obtained in 2. -#[derive(Clone, Command, Debug, Parser)] +#[derive(Clone, Command, Debug, Parser, PartialEq)] pub struct QueryUnreceivedAcknowledgementCmd { #[clap( long = "chain", @@ -73,3 +73,36 @@ impl Runnable for QueryUnreceivedAcknowledgementCmd { } } } + +#[cfg(test)] +mod tests { + use super::QueryUnreceivedAcknowledgementCmd; + + use std::str::FromStr; + + use abscissa_core::clap::Parser; + use ibc::core::ics24_host::identifier::{ChainId, PortId, ChannelId}; + + #[test] + fn test_query_packet_unreceived_acks() { + assert_eq!( + QueryUnreceivedAcknowledgementCmd{ chain_id: ChainId::from_string("chain_id"), port_id: PortId::from_str("port_id").unwrap(), channel_id: ChannelId::from_str("channel-07").unwrap() }, + QueryUnreceivedAcknowledgementCmd::parse_from(&["test", "--chain", "chain_id", "--port", "port_id", "--chan", "channel-07"]) + ) + } + + #[test] + fn test_query_packet_unreceived_acks_no_chan() { + assert!(QueryUnreceivedAcknowledgementCmd::try_parse_from(&["test", "--chain", "chain_id", "--port", "port_id"]).is_err()) + } + + #[test] + fn test_query_packet_unreceived_acks_no_port() { + assert!(QueryUnreceivedAcknowledgementCmd::try_parse_from(&["test", "--chain", "chain_id", "--chan", "channel-07"]).is_err()) + } + + #[test] + fn test_query_packet_unreceived_acks_no_chain() { + assert!(QueryUnreceivedAcknowledgementCmd::try_parse_from(&["test", "--port", "port_id", "--chan", "channel-07"]).is_err()) + } +} \ No newline at end of file diff --git a/relayer-cli/src/commands/query/packet/unreceived_packets.rs b/relayer-cli/src/commands/query/packet/unreceived_packets.rs index 485c185316..33b7186e64 100644 --- a/relayer-cli/src/commands/query/packet/unreceived_packets.rs +++ b/relayer-cli/src/commands/query/packet/unreceived_packets.rs @@ -15,7 +15,7 @@ use crate::prelude::*; /// 1. queries the chain to get its counterparty chain, channel and port identifiers (needed in 2) /// 2. queries the counterparty chain for all packet commitments/ sequences for a given port and channel /// 3. queries the chain for the unreceived sequences out of the list obtained in 2. -#[derive(Clone, Command, Debug, Parser)] +#[derive(Clone, Command, Debug, Parser, PartialEq)] pub struct QueryUnreceivedPacketsCmd { #[clap( long = "chain", @@ -73,3 +73,36 @@ impl Runnable for QueryUnreceivedPacketsCmd { } } } + +#[cfg(test)] +mod tests { + use super::QueryUnreceivedPacketsCmd; + + use std::str::FromStr; + + use abscissa_core::clap::Parser; + use ibc::core::ics24_host::identifier::{ChainId, PortId, ChannelId}; + + #[test] + fn test_query_packet_unreceived_packets() { + assert_eq!( + QueryUnreceivedPacketsCmd{ chain_id: ChainId::from_string("chain_id"), port_id: PortId::from_str("port_id").unwrap(), channel_id: ChannelId::from_str("channel-07").unwrap() }, + QueryUnreceivedPacketsCmd::parse_from(&["test", "--chain", "chain_id", "--port", "port_id", "--chan", "channel-07"]) + ) + } + + #[test] + fn test_query_packet_unreceived_packets_no_chan() { + assert!(QueryUnreceivedPacketsCmd::try_parse_from(&["test", "--chain", "chain_id", "--port", "port_id"]).is_err()) + } + + #[test] + fn test_query_packet_unreceived_packets_no_port() { + assert!(QueryUnreceivedPacketsCmd::try_parse_from(&["test", "--chain", "chain_id", "--chan", "channel-07"]).is_err()) + } + + #[test] + fn test_query_packet_unreceived_packets_no_chain() { + assert!(QueryUnreceivedPacketsCmd::try_parse_from(&["test", "--port", "port_id", "--chan", "channel-07"]).is_err()) + } +} \ No newline at end of file diff --git a/relayer-cli/src/commands/query/transfer/denom_trace.rs b/relayer-cli/src/commands/query/transfer/denom_trace.rs index f0c13a5c8b..a9c0b36402 100644 --- a/relayer-cli/src/commands/query/transfer/denom_trace.rs +++ b/relayer-cli/src/commands/query/transfer/denom_trace.rs @@ -15,7 +15,7 @@ use crate::conclude::{exit_with_unrecoverable_error, json, Output}; /// `query transfer denom-trace --chain --hash ` /// /// If successful the the base denomination and the path will be displayed. -#[derive(Clone, Command, Debug, Parser)] +#[derive(Clone, Command, Debug, Parser, PartialEq)] pub struct DenomTraceCmd { #[clap(long = "chain", required = true, help = "identifier of the chain")] chain_id: ChainId, @@ -46,3 +46,29 @@ impl Runnable for DenomTraceCmd { } } } + +#[cfg(test)] +mod tests { + use super::DenomTraceCmd; + + use abscissa_core::clap::Parser; + use ibc::core::ics24_host::identifier::ChainId; + + #[test] + fn test_transfer_denom_trace() { + assert_eq!( + DenomTraceCmd{ chain_id: ChainId::from_string("chain_id"), hash: "abcdefg".to_owned() }, + DenomTraceCmd::parse_from(&["test", "--chain", "chain_id", "--hash", "abcdefg"]) + ) + } + + #[test] + fn test_transfer_denom_trace_no_hash() { + assert!(DenomTraceCmd::try_parse_from(&["test", "--chain", "chain_id"]).is_err()) + } + + #[test] + fn test_transfer_denom_trace_no_chain() { + assert!(DenomTraceCmd::try_parse_from(&["test", "--hash", "abcdefg"]).is_err()) + } +} \ No newline at end of file diff --git a/relayer-cli/src/commands/query/tx/events.rs b/relayer-cli/src/commands/query/tx/events.rs index c572447bfd..5a2cd627f6 100644 --- a/relayer-cli/src/commands/query/tx/events.rs +++ b/relayer-cli/src/commands/query/tx/events.rs @@ -17,7 +17,7 @@ use crate::error::Error; use crate::prelude::app_config; /// Query the events emitted by transaction -#[derive(Clone, Command, Debug, Parser)] +#[derive(Clone, Command, Debug, Parser, PartialEq)] pub struct QueryTxEventsCmd { #[clap( long = "chain", @@ -60,3 +60,29 @@ impl Runnable for QueryTxEventsCmd { } } } + +#[cfg(test)] +mod tests { + use super::QueryTxEventsCmd; + + use abscissa_core::clap::Parser; + use ibc::core::ics24_host::identifier::ChainId; + + #[test] + fn test_query_tx_events() { + assert_eq!( + QueryTxEventsCmd{ chain_id: ChainId::from_string("chain_id"), hash: "abcdefg".to_owned() }, + QueryTxEventsCmd::parse_from(&["test", "--chain", "chain_id", "--hash", "abcdefg"]) + ) + } + + #[test] + fn test_query_tx_events_no_hash() { + assert!(QueryTxEventsCmd::try_parse_from(&["test", "--chain", "chain_id"]).is_err()) + } + + #[test] + fn test_query_tx_events_no_chain() { + assert!(QueryTxEventsCmd::try_parse_from(&["test", "--hash", "abcdefg"]).is_err()) + } +} \ No newline at end of file diff --git a/relayer-cli/src/commands/start.rs b/relayer-cli/src/commands/start.rs index a5f9c02ef9..cf2a1d69c1 100644 --- a/relayer-cli/src/commands/start.rs +++ b/relayer-cli/src/commands/start.rs @@ -16,7 +16,7 @@ use crate::conclude::json; use crate::conclude::Output; use crate::prelude::*; -#[derive(Clone, Command, Debug, Parser)] +#[derive(Clone, Command, Debug, Parser, PartialEq)] pub struct StartCmd { #[clap( long = "full-scan", @@ -187,3 +187,26 @@ fn make_supervisor( }, )?) } + +#[cfg(test)] +mod tests { + use super::StartCmd; + + use abscissa_core::clap::Parser; + + #[test] + fn test_start_required_only() { + assert_eq!( + StartCmd{ full_scan: false }, + StartCmd::parse_from(&["test"]) + ) + } + + #[test] + fn test_start_full_scan() { + assert_eq!( + StartCmd{ full_scan: true }, + StartCmd::parse_from(&["test", "--full-scan"]) + ) + } +} \ No newline at end of file diff --git a/relayer-cli/src/commands/tx/client.rs b/relayer-cli/src/commands/tx/client.rs index ce92cfce50..7158199ad4 100644 --- a/relayer-cli/src/commands/tx/client.rs +++ b/relayer-cli/src/commands/tx/client.rs @@ -21,7 +21,7 @@ use crate::cli_utils::{spawn_chain_runtime, spawn_chain_runtime_generic, ChainHa use crate::conclude::{exit_with_unrecoverable_error, Output}; use crate::error::Error; -#[derive(Clone, Command, Debug, Parser)] +#[derive(Clone, Command, Debug, Parser, PartialEq)] pub struct TxCreateClientCmd { #[clap( long = "host-chain", @@ -101,7 +101,7 @@ impl Runnable for TxCreateClientCmd { } } -#[derive(Clone, Command, Debug, Parser)] +#[derive(Clone, Command, Debug, Parser, PartialEq)] pub struct TxUpdateClientCmd { #[clap( long = "host-chain", @@ -189,7 +189,7 @@ impl Runnable for TxUpdateClientCmd { } } -#[derive(Clone, Command, Debug, Parser)] +#[derive(Clone, Command, Debug, Parser, PartialEq)] pub struct TxUpgradeClientCmd { #[clap( long = "host-chain", @@ -268,7 +268,7 @@ impl Runnable for TxUpgradeClientCmd { } } -#[derive(Clone, Command, Debug, Parser)] +#[derive(Clone, Command, Debug, Parser, PartialEq)] pub struct TxUpgradeClientsCmd { #[clap( long = "reference-chain", @@ -457,7 +457,14 @@ impl OutputBuffer { #[cfg(test)] mod tests { - use super::parse_trust_threshold; + use super::{parse_trust_threshold, TxCreateClientCmd, TxUpdateClientCmd, TxUpgradeClientCmd, TxUpgradeClientsCmd}; + + use std::str::FromStr; + + use abscissa_core::clap::Parser; + use humantime::Duration; + use ibc::core::ics24_host::identifier::{ChainId, ClientId}; + use tendermint_light_client_verifier::types::TrustThreshold; #[test] fn test_parse_trust_threshold() { @@ -473,4 +480,150 @@ mod tests { assert_eq!(threshold.numerator(), 3); assert_eq!(threshold.denominator(), 5); } + + #[test] + fn test_create_client_required_only() { + assert_eq!( + TxCreateClientCmd{ dst_chain_id: ChainId::from_string("host_chain"), src_chain_id: ChainId::from_string("reference_chain"), clock_drift: None, trusting_period: None, trust_threshold: None }, + TxCreateClientCmd::parse_from(&["test", "--host-chain", "host_chain", "--reference-chain", "reference_chain"]) + ) + } + + #[test] + fn test_create_client_clock_drift() { + assert_eq!( + TxCreateClientCmd{ dst_chain_id: ChainId::from_string("host_chain"), src_chain_id: ChainId::from_string("reference_chain"), clock_drift: Some("5s".parse::().unwrap()), trusting_period: None, trust_threshold: None }, + TxCreateClientCmd::parse_from(&["test", "--host-chain", "host_chain", "--reference-chain", "reference_chain", "--clock-drift", "5sec"]) + ); + assert_eq!( + TxCreateClientCmd{ dst_chain_id: ChainId::from_string("host_chain"), src_chain_id: ChainId::from_string("reference_chain"), clock_drift: Some("3s".parse::().unwrap()), trusting_period: None, trust_threshold: None }, + TxCreateClientCmd::parse_from(&["test", "--host-chain", "host_chain", "--reference-chain", "reference_chain", "--clock-drift", "3s"]) + ); + } + + #[test] + fn test_create_client_trusting_period() { + assert_eq!( + TxCreateClientCmd{ dst_chain_id: ChainId::from_string("host_chain"), src_chain_id: ChainId::from_string("reference_chain"), clock_drift: None, trusting_period: Some("5s".parse::().unwrap()), trust_threshold: None }, + TxCreateClientCmd::parse_from(&["test", "--host-chain", "host_chain", "--reference-chain", "reference_chain", "--trusting-period", "5sec"]) + ); + assert_eq!( + TxCreateClientCmd{ dst_chain_id: ChainId::from_string("host_chain"), src_chain_id: ChainId::from_string("reference_chain"), clock_drift: None, trusting_period: Some("3s".parse::().unwrap()), trust_threshold: None }, + TxCreateClientCmd::parse_from(&["test", "--host-chain", "host_chain", "--reference-chain", "reference_chain", "--trusting-period", "3s"]) + ); + } + + #[test] + fn test_create_client_trust_threshold() { + assert_eq!( + TxCreateClientCmd{ dst_chain_id: ChainId::from_string("host_chain"), src_chain_id: ChainId::from_string("reference_chain"), clock_drift: None, trusting_period: None, trust_threshold: Some(TrustThreshold::new(1, 2).unwrap()) }, + TxCreateClientCmd::parse_from(&["test", "--host-chain", "host_chain", "--reference-chain", "reference_chain", "--trust-threshold", "1/2"]) + ) + } + + #[test] + fn test_create_client_all_options() { + assert_eq!( + TxCreateClientCmd{ dst_chain_id: ChainId::from_string("host_chain"), src_chain_id: ChainId::from_string("reference_chain"), clock_drift: Some("5s".parse::().unwrap()), trusting_period: Some("3s".parse::().unwrap()), trust_threshold: Some(TrustThreshold::new(1, 2).unwrap()) }, + TxCreateClientCmd::parse_from(&["test", "--host-chain", "host_chain", "--reference-chain", "reference_chain", "--clock-drift", "5sec", "--trusting-period", "3s", "--trust-threshold", "1/2"]) + ) + } + + #[test] + fn test_create_client_no_host_chain() { + assert!(TxCreateClientCmd::try_parse_from(&["test", "--reference-chain", "reference_chain", "--clock-drift", "5sec", "--trusting-period", "3s", "--trust-threshold", "1/2"]).is_err()) + } + + #[test] + fn test_create_client_no_reference_chain() { + assert!(TxCreateClientCmd::try_parse_from(&["test", "--host-chain", "host_chain", "--clock-drift", "5sec", "--trusting-period", "3s", "--trust-threshold", "1/2"]).is_err()) + } + + #[test] + fn test_create_client_no_chain() { + assert!(TxCreateClientCmd::try_parse_from(&["test", "--clock-drift", "5sec", "--trusting-period", "3s", "--trust-threshold", "1/2"]).is_err()) + } + + #[test] + fn test_update_client_required_only() { + assert_eq!( + TxUpdateClientCmd{ dst_chain_id: ChainId::from_string("host_chain"), dst_client_id: ClientId::from_str("client_to_update").unwrap(), target_height: None, trusted_height: None }, + TxUpdateClientCmd::parse_from(&["test", "--host-chain", "host_chain", "--client", "client_to_update"]) + ) + } + + #[test] + fn test_update_client_height() { + assert_eq!( + TxUpdateClientCmd{ dst_chain_id: ChainId::from_string("host_chain"), dst_client_id: ClientId::from_str("client_to_update").unwrap(), target_height: Some(42), trusted_height: None }, + TxUpdateClientCmd::parse_from(&["test", "--host-chain", "host_chain", "--client", "client_to_update", "--height", "42"]) + ) + } + + #[test] + fn test_update_client_trusted_height() { + assert_eq!( + TxUpdateClientCmd{ dst_chain_id: ChainId::from_string("host_chain"), dst_client_id: ClientId::from_str("client_to_update").unwrap(), target_height: None, trusted_height: Some(42) }, + TxUpdateClientCmd::parse_from(&["test", "--host-chain", "host_chain", "--client", "client_to_update", "--trusted-height", "42"]) + ) + } + + #[test] + fn test_update_client_all_options() { + assert_eq!( + TxUpdateClientCmd{ dst_chain_id: ChainId::from_string("host_chain"), dst_client_id: ClientId::from_str("client_to_update").unwrap(), target_height: Some(21), trusted_height: Some(42) }, + TxUpdateClientCmd::parse_from(&["test", "--host-chain", "host_chain", "--client", "client_to_update", "--height", "21", "--trusted-height", "42"]) + ) + } + + #[test] + fn test_update_client_no_chain() { + assert!( + TxUpdateClientCmd::try_parse_from(&["test", "--client", "client_to_update", "--height", "21", "--trusted-height", "42"]).is_err() + ) + } + + #[test] + fn test_update_client_no_client() { + assert!( + TxUpdateClientCmd::try_parse_from(&["test", "--host-chain", "host_chain", "--height", "21", "--trusted-height", "42"]).is_err() + ) + } + + #[test] + fn test_upgrade_client_required_only() { + assert_eq!( + TxUpgradeClientCmd{ chain_id: ChainId::from_string("chain_id"), client_id: ClientId::from_str("client_to_upgrade").unwrap() }, + TxUpgradeClientCmd::parse_from(&["test", "--host-chain", "chain_id", "--client", "client_to_upgrade"]) + ) + } + + #[test] + fn test_upgrade_client_no_chain() { + assert!( + TxUpgradeClientCmd::try_parse_from(&["test", "--client", "client_to_upgrade"]).is_err() + ) + } + + #[test] + fn test_upgrade_client_no_client() { + assert!( + TxUpgradeClientCmd::try_parse_from(&["test", "--host-chain", "chain_id"]).is_err() + ) + } + + #[test] + fn test_upgrade_clients_required_only() { + assert_eq!( + TxUpgradeClientsCmd{ src_chain_id: ChainId::from_string("chain_id") }, + TxUpgradeClientsCmd::parse_from(&["test", "--reference-chain", "chain_id"]) + ) + } + + #[test] + fn test_upgrade_clients_no_chain() { + assert!( + TxUpgradeClientsCmd::try_parse_from(&["test"]).is_err() + ) + } } From 26a46c9d724727e677d0dbce3cdf596e744eb2f1 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Wed, 29 Jun 2022 11:40:08 +0200 Subject: [PATCH 19/27] Updated unit tests for CLI and improved help output --- guide/src/commands/queries/channel.md | 4 +- guide/src/commands/queries/client.md | 6 +- relayer-cli/src/commands/clear.rs | 66 +++- relayer-cli/src/commands/completions.rs | 6 +- relayer-cli/src/commands/create.rs | 5 +- relayer-cli/src/commands/create/channel.rs | 367 ++++++++++++++++-- relayer-cli/src/commands/create/connection.rs | 156 ++++++-- relayer-cli/src/commands/keys/add.rs | 48 ++- relayer-cli/src/commands/keys/balance.rs | 11 +- relayer-cli/src/commands/keys/delete.rs | 43 +- relayer-cli/src/commands/keys/list.rs | 5 +- relayer-cli/src/commands/listen.rs | 56 ++- relayer-cli/src/commands/misbehaviour.rs | 7 +- relayer-cli/src/commands/query/channel.rs | 87 ++++- .../src/commands/query/channel_client.rs | 66 +++- .../src/commands/query/channel_ends.rs | 109 +++++- relayer-cli/src/commands/query/channels.rs | 22 +- relayer-cli/src/commands/query/client.rs | 222 +++++++++-- relayer-cli/src/commands/query/clients.rs | 34 +- relayer-cli/src/commands/query/connection.rs | 104 ++++- relayer-cli/src/commands/query/connections.rs | 5 +- relayer-cli/src/commands/query/packet/ack.rs | 120 +++++- relayer-cli/src/commands/query/packet/acks.rs | 66 +++- .../src/commands/query/packet/commitment.rs | 123 +++++- .../src/commands/query/packet/commitments.rs | 66 +++- .../src/commands/query/packet/pending.rs | 66 +++- .../commands/query/packet/unreceived_acks.rs | 66 +++- .../query/packet/unreceived_packets.rs | 66 +++- .../commands/query/transfer/denom_trace.rs | 21 +- relayer-cli/src/commands/query/tx/events.rs | 7 +- relayer-cli/src/commands/start.rs | 6 +- relayer-cli/src/commands/tx/client.rs | 302 +++++++++++--- 32 files changed, 2035 insertions(+), 303 deletions(-) diff --git a/guide/src/commands/queries/channel.md b/guide/src/commands/queries/channel.md index b9188697c6..3d71f18acb 100644 --- a/guide/src/commands/queries/channel.md +++ b/guide/src/commands/queries/channel.md @@ -15,11 +15,11 @@ DESCRIPTION: FLAGS: --chain - identifier of the chain to query + Identifier of the chain to query OPTIONS: --verbose - enable verbose output, displaying the client and connection ids for each channel in the + Enable verbose output, displaying the client and connection ids for each channel in the response ``` diff --git a/guide/src/commands/queries/client.md b/guide/src/commands/queries/client.md index 84b6459cee..85994fb00a 100644 --- a/guide/src/commands/queries/client.md +++ b/guide/src/commands/queries/client.md @@ -17,14 +17,14 @@ DESCRIPTION: FLAGS: --host-chain - identifier of the chain to query + Identifier of the chain to query OPTIONS: --omit-chain-ids - omit printing the reference (or target) chain for each client + Omit printing the reference (or target) chain for each client --reference-chain - filter for clients which target a specific chain id (implies '--omit-chain-ids') + Filter for clients which target a specific chain id (implies '--omit-chain-ids') ``` __Example__ diff --git a/relayer-cli/src/commands/clear.rs b/relayer-cli/src/commands/clear.rs index aed1948a7a..62864ed066 100644 --- a/relayer-cli/src/commands/clear.rs +++ b/relayer-cli/src/commands/clear.rs @@ -27,6 +27,7 @@ pub struct ClearPacketsCmd { long = "chain", required = true, value_name = "CHAIN_ID", + help_heading = "FLAGS", help = "Identifier of the chain" )] chain_id: ChainId, @@ -35,15 +36,17 @@ pub struct ClearPacketsCmd { long = "port", required = true, value_name = "PORT_ID", + help_heading = "FLAGS", help = "Identifier of the port" )] port_id: PortId, #[clap( long = "channel", - alias = "chan", + visible_alias = "chan", required = true, value_name = "CHANNEL_ID", + help_heading = "FLAGS", help = "Identifier of the channel" )] channel_id: ChannelId, @@ -113,28 +116,77 @@ mod tests { use std::str::FromStr; use abscissa_core::clap::Parser; - use ibc::core::ics24_host::identifier::{ChainId, PortId, ChannelId}; + use ibc::core::ics24_host::identifier::{ChainId, ChannelId, PortId}; #[test] fn test_clear_packets() { assert_eq!( - ClearPacketsCmd{ chain_id: ChainId::from_string("chain_id"), port_id: PortId::from_str("port_id").unwrap(), channel_id: ChannelId::from_str("channel-07").unwrap() }, - ClearPacketsCmd::parse_from(&["test", "--chain", "chain_id", "--port", "port_id", "--chan", "channel-07"]) + ClearPacketsCmd { + chain_id: ChainId::from_string("chain_id"), + port_id: PortId::from_str("port_id").unwrap(), + channel_id: ChannelId::from_str("channel-07").unwrap() + }, + ClearPacketsCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--port", + "port_id", + "--channel", + "channel-07" + ]) + ) + } + + #[test] + fn test_clear_packets_chan_alias() { + assert_eq!( + ClearPacketsCmd { + chain_id: ChainId::from_string("chain_id"), + port_id: PortId::from_str("port_id").unwrap(), + channel_id: ChannelId::from_str("channel-07").unwrap() + }, + ClearPacketsCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--port", + "port_id", + "--chan", + "channel-07" + ]) ) } #[test] fn test_clear_packets_no_chan() { - assert!(ClearPacketsCmd::try_parse_from(&["test", "--chain", "chain_id", "--port", "port_id"]).is_err()) + assert!(ClearPacketsCmd::try_parse_from(&[ + "test", "--chain", "chain_id", "--port", "port_id" + ]) + .is_err()) } #[test] fn test_clear_packets_no_port() { - assert!(ClearPacketsCmd::try_parse_from(&["test", "--chain", "chain_id", "--chan", "channel-07"]).is_err()) + assert!(ClearPacketsCmd::try_parse_from(&[ + "test", + "--chain", + "chain_id", + "--channel", + "channel-07" + ]) + .is_err()) } #[test] fn test_clear_packets_no_chain() { - assert!(ClearPacketsCmd::try_parse_from(&["test", "--port", "port_id", "--chan", "channel-07"]).is_err()) + assert!(ClearPacketsCmd::try_parse_from(&[ + "test", + "--port", + "port_id", + "--channel", + "channel-07" + ]) + .is_err()) } } diff --git a/relayer-cli/src/commands/completions.rs b/relayer-cli/src/commands/completions.rs index 6c0b1e97dd..41d0a79fd6 100644 --- a/relayer-cli/src/commands/completions.rs +++ b/relayer-cli/src/commands/completions.rs @@ -7,7 +7,7 @@ use std::io; #[derive(Debug, Parser, PartialEq)] pub struct CompletionsCmd { - #[clap(long = "shell", value_name = "SHELL", arg_enum)] + #[clap(long = "shell", value_name = "SHELL", arg_enum, help_heading = "FLAGS")] shell: Shell, } @@ -29,7 +29,7 @@ mod tests { #[test] fn test_completions() { assert_eq!( - CompletionsCmd{ shell: Shell::Zsh}, + CompletionsCmd { shell: Shell::Zsh }, CompletionsCmd::parse_from(&["test", "--shell", "zsh"]) ) } @@ -43,4 +43,4 @@ mod tests { fn test_completions_unknown_shell() { assert!(CompletionsCmd::try_parse_from(&["test", "--shell", "my_shell"]).is_err()) } -} \ No newline at end of file +} diff --git a/relayer-cli/src/commands/create.rs b/relayer-cli/src/commands/create.rs index d736d877ae..0bb2dd9e19 100644 --- a/relayer-cli/src/commands/create.rs +++ b/relayer-cli/src/commands/create.rs @@ -18,9 +18,10 @@ pub enum CreateCmds { /// Create a new connection between two chains Connection(CreateConnectionCommand), - /// Create a new channel between two chains using a pre-existing connection. + /// Create a new channel between two chains. /// - /// Alternatively, create a new client and a new connection underlying + /// Can create a new channel using a pre-existing connection or + /// alternatively, create a new client and a new connection underlying /// the new channel if a pre-existing connection is not provided. Channel(CreateChannelCommand), } diff --git a/relayer-cli/src/commands/create/channel.rs b/relayer-cli/src/commands/create/channel.rs index 24a733e1bb..f754eb057e 100644 --- a/relayer-cli/src/commands/create/channel.rs +++ b/relayer-cli/src/commands/create/channel.rs @@ -30,11 +30,11 @@ static HINT: &str = "Consider using the default invocation\n\nhermes create chan /// /// There are two possible ways to invoke this command: /// -/// `create channel --a-port --b-port --a-chain --a-conn ` +/// `create channel --a-port --b-port --a-chain --a-connection ` /// is the default way in which this command should be used, specifying a `Connection-ID` /// associated with chain A for this new channel to re-use. /// -/// `create channel --a-port --b-port --a-chain --b-chain --new-client-conn` +/// `create channel --a-port --b-port --a-chain --b-chain --new-client-connection` /// can alternatively be used to indicate that a new connection/client pair is being /// created as part of this new channel. This brings up an interactive yes/no prompt /// to ensure that the operator at least considers the fact that they're initializing a @@ -45,11 +45,15 @@ static HINT: &str = "Consider using the default invocation\n\nhermes create chan /// chain A and chain B might refer to the connection with different names, they are actually referring /// to the same connection. #[derive(Clone, Command, Debug, Parser, PartialEq)] +#[clap( + override_usage = "hermes create channel [OPTIONS] --a-chain --a-connection --a-port --b-port \n\n hermes create channel [OPTIONS] --a-chain --b-chain --a-port --b-port --new-client-connection" +)] pub struct CreateChannelCommand { #[clap( long = "a-chain", required = true, value_name = "A_CHAIN_ID", + help_heading = "FLAGS", help = "Identifier of the side `a` chain for the new channel" )] chain_a: ChainId, @@ -57,14 +61,21 @@ pub struct CreateChannelCommand { #[clap( long = "b-chain", value_name = "B_CHAIN_ID", + required = true, + requires = "new-client-connection", + group = "b_chain_group", + help_heading = "FLAGS", help = "Identifier of the side `b` chain for the new channel" )] chain_b: Option, #[clap( long = "a-connection", - alias = "a-conn", + visible_alias = "a-conn", value_name = "A_CONNECTION_ID", + required = true, + groups = &["b_chain_group", "new_client_group"], + help_heading = "FLAGS", help = "Identifier of the connection on chain `a` to use in creating the new channel." )] connection_a: Option, @@ -73,6 +84,7 @@ pub struct CreateChannelCommand { long = "a-port", required = true, value_name = "A_PORT_ID", + help_heading = "FLAGS", help = "Identifier of the side `a` port for the new channel" )] port_a: PortId, @@ -81,6 +93,7 @@ pub struct CreateChannelCommand { long = "b-port", required = true, value_name = "B_PORT_ID", + help_heading = "FLAGS", help = "Identifier of the side `b` port for the new channel" )] port_b: PortId, @@ -95,7 +108,7 @@ pub struct CreateChannelCommand { #[clap( long = "channel-version", - alias = "chan-version", + visible_alias = "chan-version", value_name = "VERSION", help = "The version for the new channel" )] @@ -103,12 +116,18 @@ pub struct CreateChannelCommand { #[clap( long = "new-client-connection", - alias = "new-client-conn", + visible_alias = "new-client-conn", + group = "new_client_group", + help_heading = "FLAGS", help = "Indicates that a new client and connection will be created underlying the new channel" )] - new_client_conn: bool, + new_client_connection: bool, - #[clap(long, help = "Skip new_client_conn confirmation")] + #[clap( + long, + requires = "new-client-connection", + help = "Skip new_client_connection confirmation" + )] yes: bool, } @@ -118,7 +137,7 @@ impl Runnable for CreateChannelCommand { Some(conn) => self.run_reusing_connection(conn), None => match &self.chain_b { Some(chain_b) => { - if self.new_client_conn { + if self.new_client_connection { if self.yes { self.run_using_new_connection(chain_b); } else { @@ -147,17 +166,9 @@ impl Runnable for CreateChannelCommand { } } } - } else { - Output::error( - "The `--new-client-conn` flag is required if invoking with `--b-chain`" - .to_string(), - ) - .exit(); } } - None => { - Output::error("Missing one of `--b-chain` or `--a-conn`".to_string()).exit() - } + None => {} }, } } @@ -264,63 +275,347 @@ mod tests { use super::CreateChannelCommand; use abscissa_core::clap::Parser; - use ibc::core::ics04_channel::Version; use ibc::core::ics04_channel::channel::Order; + use ibc::core::ics04_channel::Version; use ibc::core::ics24_host::identifier::{ChainId, ConnectionId, PortId}; #[test] - fn test_create_channel_reuse_client() { + fn test_create_channel_a_conn_required() { assert_eq!( - CreateChannelCommand{ chain_a: ChainId::from_string("chain_a"), chain_b: None, connection_a: Some(ConnectionId::from_str("connection_a").unwrap()), port_a: PortId::from_str("port_id_a").unwrap(), port_b: PortId::from_str("port_id_b").unwrap(), order: Order::Unordered, version: None, new_client_connection: false }, - CreateChannelCommand::parse_from(&["test", "--a-chain", "chain_a", "--a-conn", "connection_a", "--a-port", "port_id_a", "--b-port", "port_id_b"]) + CreateChannelCommand { + chain_a: ChainId::from_string("chain_a"), + chain_b: None, + connection_a: Some(ConnectionId::from_str("connection_a").unwrap()), + port_a: PortId::from_str("port_id_a").unwrap(), + port_b: PortId::from_str("port_id_b").unwrap(), + order: Order::Unordered, + version: None, + new_client_connection: false, + yes: false + }, + CreateChannelCommand::parse_from(&[ + "test", + "--a-chain", + "chain_a", + "--a-connection", + "connection_a", + "--a-port", + "port_id_a", + "--b-port", + "port_id_b" + ]) ) } #[test] fn test_create_channel_version() { assert_eq!( - CreateChannelCommand{ chain_a: ChainId::from_string("chain_a"), chain_b: None, connection_a: Some(ConnectionId::from_str("connection_a").unwrap()), port_a: PortId::from_str("port_id_a").unwrap(), port_b: PortId::from_str("port_id_b").unwrap(), order: Order::Unordered, version: Some(Version::new("v1".to_owned())), new_client_connection: false }, - CreateChannelCommand::parse_from(&["test", "--a-chain", "chain_a", "--a-conn", "connection_a", "--a-port", "port_id_a", "--b-port", "port_id_b", "--chan-version", "v1"]) + CreateChannelCommand { + chain_a: ChainId::from_string("chain_a"), + chain_b: None, + connection_a: Some(ConnectionId::from_str("connection_a").unwrap()), + port_a: PortId::from_str("port_id_a").unwrap(), + port_b: PortId::from_str("port_id_b").unwrap(), + order: Order::Unordered, + version: Some(Version::new("v1".to_owned())), + new_client_connection: false, + yes: false + }, + CreateChannelCommand::parse_from(&[ + "test", + "--a-chain", + "chain_a", + "--a-connection", + "connection_a", + "--a-port", + "port_id_a", + "--b-port", + "port_id_b", + "--channel-version", + "v1" + ]) ) } #[test] fn test_create_channel_order() { assert_eq!( - CreateChannelCommand{ chain_a: ChainId::from_string("chain_a"), chain_b: None, connection_a: Some(ConnectionId::from_str("connection_a").unwrap()), port_a: PortId::from_str("port_id_a").unwrap(), port_b: PortId::from_str("port_id_b").unwrap(), order: Order::Ordered, version: None, new_client_connection: false }, - CreateChannelCommand::parse_from(&["test", "--a-chain", "chain_a", "--a-conn", "connection_a", "--a-port", "port_id_a", "--b-port", "port_id_b", "--order", "ordered"]) + CreateChannelCommand { + chain_a: ChainId::from_string("chain_a"), + chain_b: None, + connection_a: Some(ConnectionId::from_str("connection_a").unwrap()), + port_a: PortId::from_str("port_id_a").unwrap(), + port_b: PortId::from_str("port_id_b").unwrap(), + order: Order::Ordered, + version: None, + new_client_connection: false, + yes: false + }, + CreateChannelCommand::parse_from(&[ + "test", + "--a-chain", + "chain_a", + "--a-connection", + "connection_a", + "--a-port", + "port_id_a", + "--b-port", + "port_id_b", + "--order", + "ordered" + ]) ) } #[test] - fn test_create_channel_reuse_client_with_new_client() { - assert!( - CreateChannelCommand::try_parse_from(&["test", "--a-chain", "chain_a", "--a-conn", "connection_a", "--a-port", "port_id_a", "--b-port", "port_id_b", "--new-client-conn"]).is_err() + fn test_create_channel_a_conn_alias() { + assert_eq!( + CreateChannelCommand { + chain_a: ChainId::from_string("chain_a"), + chain_b: None, + connection_a: Some(ConnectionId::from_str("connection_a").unwrap()), + port_a: PortId::from_str("port_id_a").unwrap(), + port_b: PortId::from_str("port_id_b").unwrap(), + order: Order::Unordered, + version: None, + new_client_connection: false, + yes: false + }, + CreateChannelCommand::parse_from(&[ + "test", + "--a-chain", + "chain_a", + "--a-conn", + "connection_a", + "--a-port", + "port_id_a", + "--b-port", + "port_id_b" + ]) ) } #[test] - fn test_create_channel_new_client() { + fn test_create_channel_a_conn_with_new_client_conn() { + assert!(CreateChannelCommand::try_parse_from(&[ + "test", + "--a-chain", + "chain_a", + "--a-connection", + "connection_a", + "--a-port", + "port_id_a", + "--b-port", + "port_id_b", + "--new-client-connection" + ]) + .is_err()) + } + + #[test] + fn test_create_channel_a_conn_with_yes() { + assert!(CreateChannelCommand::try_parse_from(&[ + "test", + "--a-chain", + "chain_a", + "--b-chain", + "chain_b", + "--a-connection", + "connection_a", + "--a-port", + "port_id_a", + "--b-port", + "port_id_b", + "--order", + "ordered", + "--yes" + ]) + .is_err()) + } + + #[test] + fn test_create_channel_a_conn_with_b_chain() { + assert!(CreateChannelCommand::try_parse_from(&[ + "test", + "--a-chain", + "chain_a", + "--b-chain", + "chain_b", + "--a-connection", + "connection_a", + "--a-port", + "port_id_a", + "--b-port", + "port_id_b", + "--order", + "ordered" + ]) + .is_err()) + } + + #[test] + fn test_create_channel_b_chain() { + assert_eq!( + CreateChannelCommand { + chain_a: ChainId::from_string("chain_a"), + chain_b: Some(ChainId::from_string("chain_b")), + connection_a: None, + port_a: PortId::from_str("port_id_a").unwrap(), + port_b: PortId::from_str("port_id_b").unwrap(), + order: Order::Unordered, + version: None, + new_client_connection: true, + yes: false + }, + CreateChannelCommand::parse_from(&[ + "test", + "--a-chain", + "chain_a", + "--b-chain", + "chain_b", + "--a-port", + "port_id_a", + "--b-port", + "port_id_b", + "--new-client-connection" + ]) + ) + } + + #[test] + fn test_create_channel_b_chain_yes() { assert_eq!( - CreateChannelCommand{ chain_a: ChainId::from_string("chain_a"), chain_b: Some(ChainId::from_string("chain_b")), connection_a: None, port_a: PortId::from_str("port_id_a").unwrap(), port_b: PortId::from_str("port_id_b").unwrap(), order: Order::Unordered, version: None, new_client_connection: true }, - CreateChannelCommand::parse_from(&["test", "--a-chain", "chain_a", "--b-chain", "chain_b", "--a-port", "port_id_a", "--b-port", "port_id_b", "--new-client-conn"]) + CreateChannelCommand { + chain_a: ChainId::from_string("chain_a"), + chain_b: Some(ChainId::from_string("chain_b")), + connection_a: None, + port_a: PortId::from_str("port_id_a").unwrap(), + port_b: PortId::from_str("port_id_b").unwrap(), + order: Order::Unordered, + version: None, + new_client_connection: true, + yes: true + }, + CreateChannelCommand::parse_from(&[ + "test", + "--a-chain", + "chain_a", + "--b-chain", + "chain_b", + "--a-port", + "port_id_a", + "--b-port", + "port_id_b", + "--new-client-connection", + "--yes" + ]) ) } #[test] - fn test_create_channel_reuse_client_with_b_chain() { - assert!( - CreateChannelCommand::try_parse_from(&["test", "--a-chain", "chain_a", "--b-chain", "chain_b", "--a-conn", "connection_a", "--a-port", "port_id_a", "--b-port", "port_id_b", "--order", "ordered"]).is_err() + fn test_create_channel_b_new_client_conn_alias() { + assert_eq!( + CreateChannelCommand { + chain_a: ChainId::from_string("chain_a"), + chain_b: Some(ChainId::from_string("chain_b")), + connection_a: None, + port_a: PortId::from_str("port_id_a").unwrap(), + port_b: PortId::from_str("port_id_b").unwrap(), + order: Order::Unordered, + version: None, + new_client_connection: true, + yes: false + }, + CreateChannelCommand::parse_from(&[ + "test", + "--a-chain", + "chain_a", + "--b-chain", + "chain_b", + "--a-port", + "port_id_a", + "--b-port", + "port_id_b", + "--new-client-conn" + ]) ) } #[test] fn test_create_channel_b_chain_without_new_client() { - assert!(CreateChannelCommand::try_parse_from(&["test", "--a-chain", "chain_a", "--b-chain", "chain_b", "--a-port", "port_id_a", "--b-port", "port_id_b"]).is_err()) + assert!(CreateChannelCommand::try_parse_from(&[ + "test", + "--a-chain", + "chain_a", + "--b-chain", + "chain_b", + "--a-port", + "port_id_a", + "--b-port", + "port_id_b" + ]) + .is_err()) + } + + #[test] + fn test_create_channel_no_b_port() { + assert!(CreateChannelCommand::try_parse_from(&[ + "test", + "--a-chain", + "chain_a", + "--b-chain", + "chain_b", + "--a-connection", + "connection_a", + "--a-port", + "port_id_a" + ]) + .is_err()) + } + + #[test] + fn test_create_channel_no_a_port() { + assert!(CreateChannelCommand::try_parse_from(&[ + "test", + "--a-chain", + "chain_a", + "--b-chain", + "chain_b", + "--a-connection", + "connection_a", + "--b-port", + "port_id_b" + ]) + .is_err()) } #[test] fn test_create_channel_no_b_chain_nor_a_conn() { - assert!(CreateChannelCommand::try_parse_from(&["test", "--a-chain", "chain_a", "--a-port", "port_id_a", "--b-port", "port_id_b"]).is_err()) + assert!(CreateChannelCommand::try_parse_from(&[ + "test", + "--a-chain", + "chain_a", + "--a-port", + "port_id_a", + "--b-port", + "port_id_b" + ]) + .is_err()) + } + + #[test] + fn test_create_channel_no_a_chain() { + assert!(CreateChannelCommand::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-connection", + "connection_a", + "--a-port", + "port_id_a", + "--b-port", + "port_id_b" + ]) + .is_err()) } } diff --git a/relayer-cli/src/commands/create/connection.rs b/relayer-cli/src/commands/create/connection.rs index 59ad12905f..7329a57539 100644 --- a/relayer-cli/src/commands/create/connection.rs +++ b/relayer-cli/src/commands/create/connection.rs @@ -15,32 +15,43 @@ use crate::conclude::{exit_with_unrecoverable_error, Output}; use crate::prelude::*; #[derive(Clone, Command, Debug, Parser, PartialEq)] +#[clap(override_usage("hermes create connection [OPTIONS] --a-chain --b-chain \n\n hermes create connection [OPTIONS] --a-chain --a-client --b-client "))] pub struct CreateConnectionCommand { #[clap( long = "a-chain", required = true, value_name = "A_CHAIN_ID", + help_heading = "FLAGS", help = "Identifier of the side `a` chain for the new connection" )] chain_a_id: ChainId, #[clap( long = "b-chain", + required = true, value_name = "B_CHAIN_ID", + groups = &["a_client", "b_client"], + help_heading = "FLAGS", help = "Identifier of the side `b` chain for the new connection" )] chain_b_id: Option, #[clap( long = "a-client", + required = true, value_name = "A_CLIENT_ID", + group = "a_client", + help_heading = "FLAGS", help = "Identifier of client hosted on chain `a`; default: None (creates a new client)" )] client_a: Option, #[clap( long = "b-client", + required = true, value_name = "B_CLIENT_ID", + group = "b_client", + help_heading = "FLAGS", help = "Identifier of client hosted on chain `b`; default: None (creates a new client)" )] client_b: Option, @@ -74,16 +85,6 @@ impl CreateConnectionCommand { let chains = ChainHandlePair::spawn(&config, &self.chain_a_id, chain_b_id) .unwrap_or_else(exit_with_unrecoverable_error); - // Validate the other options. Bail if the CLI was invoked with incompatible options. - if self.client_a.is_some() { - Output::error("Option `` is incompatible with `--a-client`".to_string()) - .exit(); - } - if self.client_b.is_some() { - Output::error("Option `` is incompatible with `--b-client`".to_string()) - .exit(); - } - info!( "Creating new clients hosted on chains {} and {}", self.chain_a_id, chain_b_id @@ -182,59 +183,152 @@ mod tests { use std::str::FromStr; #[test] - fn test_create_connection_chain_a_and_chain_b() { + fn test_create_connection_b_chain() { assert_eq!( - CreateConnectionCommand{ chain_a_id: ChainId::from_string("chain_a"), chain_b_id: Some(ChainId::from_string("chain_b")), client_a: None, client_b: None, delay: 0 }, - CreateConnectionCommand::parse_from(&["test", "--a-chain", "chain_a", "--b-chain", "chain_b"]) + CreateConnectionCommand { + chain_a_id: ChainId::from_string("chain_a"), + chain_b_id: Some(ChainId::from_string("chain_b")), + client_a: None, + client_b: None, + delay: 0 + }, + CreateConnectionCommand::parse_from(&[ + "test", + "--a-chain", + "chain_a", + "--b-chain", + "chain_b" + ]) ) } #[test] - fn test_create_connection_chain_a_and_chain_b_with_delay() { + fn test_create_connection_b_chain_with_delay() { assert_eq!( - CreateConnectionCommand{ chain_a_id: ChainId::from_string("chain_a"), chain_b_id: Some(ChainId::from_string("chain_b")), client_a: None, client_b: None, delay: 42 }, - CreateConnectionCommand::parse_from(&["test", "--a-chain", "chain_a", "--b-chain", "chain_b", "--delay", "42"]) + CreateConnectionCommand { + chain_a_id: ChainId::from_string("chain_a"), + chain_b_id: Some(ChainId::from_string("chain_b")), + client_a: None, + client_b: None, + delay: 42 + }, + CreateConnectionCommand::parse_from(&[ + "test", + "--a-chain", + "chain_a", + "--b-chain", + "chain_b", + "--delay", + "42" + ]) ) } #[test] - fn create_connection_chain_a_and_clients() { + fn create_connection_a_chain_and_clients() { assert_eq!( - CreateConnectionCommand{ chain_a_id: ChainId::from_string("chain_a"), chain_b_id: None, client_a: Some(ClientId::from_str("07-client_a").unwrap()), client_b: Some(ClientId::from_str("07-client_b").unwrap()), delay: 0 }, - CreateConnectionCommand::parse_from(&["test", "--a-chain", "chain_a", "--a-client", "07-client_a", "--b-client", "07-client_b"]) + CreateConnectionCommand { + chain_a_id: ChainId::from_string("chain_a"), + chain_b_id: None, + client_a: Some(ClientId::from_str("07-client_a").unwrap()), + client_b: Some(ClientId::from_str("07-client_b").unwrap()), + delay: 0 + }, + CreateConnectionCommand::parse_from(&[ + "test", + "--a-chain", + "chain_a", + "--a-client", + "07-client_a", + "--b-client", + "07-client_b" + ]) ) } #[test] - fn create_connection_chain_a_and_clients_with_delay() { + fn create_connection_a_chain_and_clients_with_delay() { assert_eq!( - CreateConnectionCommand{ chain_a_id: ChainId::from_string("chain_a"), chain_b_id: None, client_a: Some(ClientId::from_str("07-client_a").unwrap()), client_b: Some(ClientId::from_str("07-client_b").unwrap()), delay: 42 }, - CreateConnectionCommand::parse_from(&["test", "--a-chain", "chain_a", "--a-client", "07-client_a", "--b-client", "07-client_b", "--delay", "42"]) + CreateConnectionCommand { + chain_a_id: ChainId::from_string("chain_a"), + chain_b_id: None, + client_a: Some(ClientId::from_str("07-client_a").unwrap()), + client_b: Some(ClientId::from_str("07-client_b").unwrap()), + delay: 42 + }, + CreateConnectionCommand::parse_from(&[ + "test", + "--a-chain", + "chain_a", + "--a-client", + "07-client_a", + "--b-client", + "07-client_b", + "--delay", + "42" + ]) ) } #[test] - fn test_create_connection_chain_a_only() { + fn test_create_connection_a_chain_only() { assert!(CreateConnectionCommand::try_parse_from(&["test", "--a-chain", "chain_a"]).is_err()) } #[test] - fn test_create_connection_client_a_required_without_chain_b() { - assert!(CreateConnectionCommand::try_parse_from(&["test", "--a-chain", "chain_a", "--b-client", "client_b"]).is_err()) + fn test_create_connection_no_a_chain() { + assert!(CreateConnectionCommand::try_parse_from(&["test", "--b-chain", "chain_b"]).is_err()) + } + + #[test] + fn test_create_connection_b_client_without_a_client() { + assert!(CreateConnectionCommand::try_parse_from(&[ + "test", + "--a-chain", + "chain_a", + "--b-client", + "client_b" + ]) + .is_err()) } #[test] - fn test_create_connection_client_b_required_without_chain_b() { - assert!(CreateConnectionCommand::try_parse_from(&["test", "--a-chain", "chain_a", "--a-client", "client_a"]).is_err()) + fn test_create_connection_a_client_required_without_b_client() { + assert!(CreateConnectionCommand::try_parse_from(&[ + "test", + "--a-chain", + "chain_a", + "--a-client", + "client_a" + ]) + .is_err()) } #[test] - fn test_create_connection_only_chain_b_or_client_a() { - assert!(CreateConnectionCommand::try_parse_from(&["test", "--a-chain", "chain_a", "--b-chain", "chain_b", "--a-client", "07-client_a"]).is_err()) + fn test_create_connection_b_chain_with_a_client() { + assert!(CreateConnectionCommand::try_parse_from(&[ + "test", + "--a-chain", + "chain_a", + "--b-chain", + "chain_b", + "--a-client", + "07-client_a" + ]) + .is_err()) } #[test] - fn test_create_connection_only_chain_b_or_client_b() { - assert!(CreateConnectionCommand::try_parse_from(&["test", "--a-chain", "chain_a", "--b-chain", "chain_b", "--b-client", "07-client_b"]).is_err()) + fn test_create_connection_b_chain_with_b_client() { + assert!(CreateConnectionCommand::try_parse_from(&[ + "test", + "--a-chain", + "chain_a", + "--b-chain", + "chain_b", + "--b-client", + "07-client_b" + ]) + .is_err()) } } diff --git a/relayer-cli/src/commands/keys/add.rs b/relayer-cli/src/commands/keys/add.rs index 8181b8c9f1..24221a5419 100644 --- a/relayer-cli/src/commands/keys/add.rs +++ b/relayer-cli/src/commands/keys/add.rs @@ -31,14 +31,23 @@ use crate::conclude::Output; /// The key-file and mnemonic-file flags can't be given at the same time, this will cause a terminating error. /// If successful the key will be created or restored, depending on which flag was given. #[derive(Clone, Command, Debug, Parser, PartialEq)] +#[clap( + override_usage = "hermes keys add [OPTIONS] --chain --key-file \n\n hermes keys add [OPTIONS] --chain --mnemonic-file " +)] pub struct KeysAddCmd { - #[clap(long = "chain", required = true, help = "Identifier of the chain")] + #[clap( + long = "chain", + required = true, + help_heading = "FLAGS", + help = "Identifier of the chain" + )] chain_id: ChainId, #[clap( long = "key-file", required = true, value_name = "KEY_FILE", + help_heading = "FLAGS", help = "Path to the key file", group = "add-restore" )] @@ -48,6 +57,7 @@ pub struct KeysAddCmd { long = "mnemonic-file", required = true, value_name = "MNEMONIC_FILE", + help_heading = "FLAGS", help = "Path to file containing mnemonic to restore the key from", group = "add-restore" )] @@ -192,7 +202,13 @@ mod tests { #[test] fn test_keys_add_key_file() { assert_eq!( - KeysAddCmd{ chain_id: ChainId::from_string("chain_id"), key_file: Some(PathBuf::from("key_file")), mnemonic_file: None, key_name: None, hd_path: "m/44'/118'/0'/0/0".to_string() }, + KeysAddCmd { + chain_id: ChainId::from_string("chain_id"), + key_file: Some(PathBuf::from("key_file")), + mnemonic_file: None, + key_name: None, + hd_path: "m/44'/118'/0'/0/0".to_string() + }, KeysAddCmd::parse_from(&["test", "--chain", "chain_id", "--key-file", "key_file"]) ) } @@ -200,8 +216,20 @@ mod tests { #[test] fn test_keys_add_mnemonic_file() { assert_eq!( - KeysAddCmd{ chain_id: ChainId::from_string("chain_id"), key_file: None, mnemonic_file: Some(PathBuf::from("mnemonic_file")), key_name: None, hd_path: "m/44'/118'/0'/0/0".to_string() }, - KeysAddCmd::parse_from(&["test", "--chain", "chain_id", "--mnemonic-file", "mnemonic_file"]) + KeysAddCmd { + chain_id: ChainId::from_string("chain_id"), + key_file: None, + mnemonic_file: Some(PathBuf::from("mnemonic_file")), + key_name: None, + hd_path: "m/44'/118'/0'/0/0".to_string() + }, + KeysAddCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--mnemonic-file", + "mnemonic_file" + ]) ) } @@ -212,10 +240,18 @@ mod tests { #[test] fn test_keys_add_key_and_mnemonic() { - assert!(KeysAddCmd::try_parse_from(&["test", "--chain", "chain_id", "--key-file", "key_file", "--mnemonic-file", "mnemonic_file"]).is_err()); + assert!(KeysAddCmd::try_parse_from(&[ + "test", + "--chain", + "chain_id", + "--key-file", + "key_file", + "--mnemonic-file", + "mnemonic_file" + ]) + .is_err()); } - #[test] fn test_keys_add_no_chain() { assert!(KeysAddCmd::try_parse_from(&["test", "--key-file", "key_file"]).is_err()); diff --git a/relayer-cli/src/commands/keys/balance.rs b/relayer-cli/src/commands/keys/balance.rs index 2292b34b82..fea8a9ffc6 100644 --- a/relayer-cli/src/commands/keys/balance.rs +++ b/relayer-cli/src/commands/keys/balance.rs @@ -23,6 +23,7 @@ pub struct KeyBalanceCmd { long = "chain", required = true, value_name = "CHAIN_ID", + help_heading = "FLAGS", help = "Identifier of the chain" )] chain_id: ChainId, @@ -81,7 +82,10 @@ mod tests { #[test] fn test_keys_balance_required_only() { assert_eq!( - KeyBalanceCmd{ chain_id: ChainId::from_string("chain_id"), key_name: None }, + KeyBalanceCmd { + chain_id: ChainId::from_string("chain_id"), + key_name: None + }, KeyBalanceCmd::parse_from(&["test", "--chain", "chain_id"]) ) } @@ -89,7 +93,10 @@ mod tests { #[test] fn test_keys_balance_name() { assert_eq!( - KeyBalanceCmd{ chain_id: ChainId::from_string("chain_id"), key_name: Some("kname".to_owned()) }, + KeyBalanceCmd { + chain_id: ChainId::from_string("chain_id"), + key_name: Some("kname".to_owned()) + }, KeyBalanceCmd::parse_from(&["test", "--chain", "chain_id", "--key-name", "kname"]) ) } diff --git a/relayer-cli/src/commands/keys/delete.rs b/relayer-cli/src/commands/keys/delete.rs index 8a87a73617..243410c248 100644 --- a/relayer-cli/src/commands/keys/delete.rs +++ b/relayer-cli/src/commands/keys/delete.rs @@ -11,19 +11,36 @@ use crate::application::app_config; use crate::conclude::Output; #[derive(Clone, Command, Debug, Parser, PartialEq)] +#[clap( + override_usage = "hermes keys delete --chain --key-name \n\n hermes keys delete --chain --all" +)] pub struct KeysDeleteCmd { #[clap( long = "chain", required = true, value_name = "CHAIN_ID", + help_heading = "FLAGS", help = "Identifier of the chain" )] chain_id: ChainId, - #[clap(long = "key-name", value_name = "KEY_NAME", help = "Name of the key")] + #[clap( + long = "key-name", + required = true, + value_name = "KEY_NAME", + group = "delete_mode", + help_heading = "FLAGS", + help = "Name of the key" + )] key_name: Option, - #[clap(long = "all", help = "Delete all keys")] + #[clap( + long = "all", + required = true, + group = "delete_mode", + help_heading = "FLAGS", + help = "Delete all keys" + )] all: bool, } @@ -120,7 +137,11 @@ mod tests { #[test] fn test_keys_delete_key_name() { assert_eq!( - KeysDeleteCmd{ chain_id: ChainId::from_string("chain_id"), key_name: Some("to_delete".to_owned()), all: false }, + KeysDeleteCmd { + chain_id: ChainId::from_string("chain_id"), + key_name: Some("to_delete".to_owned()), + all: false + }, KeysDeleteCmd::parse_from(&["test", "--chain", "chain_id", "--key-name", "to_delete"]) ) } @@ -128,7 +149,11 @@ mod tests { #[test] fn test_keys_delete_all() { assert_eq!( - KeysDeleteCmd{ chain_id: ChainId::from_string("chain_id"), key_name: None, all: true }, + KeysDeleteCmd { + chain_id: ChainId::from_string("chain_id"), + key_name: None, + all: true + }, KeysDeleteCmd::parse_from(&["test", "--chain", "chain_id", "--all"]) ) } @@ -140,7 +165,15 @@ mod tests { #[test] fn test_keys_delete_key_name_or_all() { - assert!(KeysDeleteCmd::try_parse_from(&["test", "--chain", "chain_id", "--key-name", "to_delete", "--all"]).is_err()) + assert!(KeysDeleteCmd::try_parse_from(&[ + "test", + "--chain", + "chain_id", + "--key-name", + "to_delete", + "--all" + ]) + .is_err()) } #[test] diff --git a/relayer-cli/src/commands/keys/list.rs b/relayer-cli/src/commands/keys/list.rs index 7bb42e2070..6f00ebe21f 100644 --- a/relayer-cli/src/commands/keys/list.rs +++ b/relayer-cli/src/commands/keys/list.rs @@ -18,6 +18,7 @@ pub struct KeysListCmd { long = "chain", required = true, value_name = "CHAIN_ID", + help_heading = "FLAGS", help = "Identifier of the chain" )] chain_id: ChainId, @@ -84,7 +85,9 @@ mod tests { #[test] fn test_keys_list() { assert_eq!( - KeysListCmd{ chain_id: ChainId::from_string("chain_id") }, + KeysListCmd { + chain_id: ChainId::from_string("chain_id") + }, KeysListCmd::parse_from(&["test", "--chain", "chain_id"]) ) } diff --git a/relayer-cli/src/commands/listen.rs b/relayer-cli/src/commands/listen.rs index 0216857958..dd4334b18e 100644 --- a/relayer-cli/src/commands/listen.rs +++ b/relayer-cli/src/commands/listen.rs @@ -61,7 +61,12 @@ impl FromStr for EventFilter { #[derive(Debug, Parser, PartialEq)] pub struct ListenCmd { /// Identifier of the chain to listen for events from - #[clap(long = "chain", required = true, value_name = "CHAIN_ID")] + #[clap( + long = "chain", + required = true, + value_name = "CHAIN_ID", + help_heading = "FLAGS" + )] chain_id: ChainId, /// Add an event type to listen for, can be repeated. @@ -163,7 +168,7 @@ fn subscribe( #[cfg(test)] mod tests { - use super::{ListenCmd, EventFilter}; + use super::{EventFilter, ListenCmd}; use std::str::FromStr; @@ -173,7 +178,10 @@ mod tests { #[test] fn test_listen_required_only() { assert_eq!( - ListenCmd{ chain_id: ChainId::from_string("chain_id"), events: vec!() }, + ListenCmd { + chain_id: ChainId::from_string("chain_id"), + events: vec!() + }, ListenCmd::parse_from(&["test", "--chain", "chain_id"]) ) } @@ -181,22 +189,54 @@ mod tests { #[test] fn test_listen_single_event() { assert_eq!( - ListenCmd{ chain_id: ChainId::from_string("chain_id"), events: vec!(EventFilter::from_str("Tx").unwrap()) }, - ListenCmd::parse_from(&["test", "--chain", "chain_id", "--event", "Tx"]) + ListenCmd { + chain_id: ChainId::from_string("chain_id"), + events: vec!(EventFilter::from_str("Tx").unwrap()) + }, + ListenCmd::parse_from(&["test", "--chain", "chain_id", "--events", "Tx"]) ) } #[test] fn test_listen_multiple_events() { assert_eq!( - ListenCmd{ chain_id: ChainId::from_string("chain_id"), events: vec!(EventFilter::from_str("Tx").unwrap(), EventFilter::from_str("NewBlock").unwrap()) }, - ListenCmd::parse_from(&["test", "--chain", "chain_id", "--event", "Tx", "--event", "NewBlock"]) + ListenCmd { + chain_id: ChainId::from_string("chain_id"), + events: vec!( + EventFilter::from_str("Tx").unwrap(), + EventFilter::from_str("NewBlock").unwrap() + ) + }, + ListenCmd::parse_from(&[ + "test", "--chain", "chain_id", "--events", "Tx", "--events", "NewBlock" + ]) + ) + } + + #[test] + fn test_listen_multiple_events_single_flag() { + assert_eq!( + ListenCmd { + chain_id: ChainId::from_string("chain_id"), + events: vec!( + EventFilter::from_str("Tx").unwrap(), + EventFilter::from_str("NewBlock").unwrap() + ) + }, + ListenCmd::parse_from(&["test", "--chain", "chain_id", "--events", "Tx", "NewBlock"]) ) } #[test] fn test_listen_unknown_event_filter() { - assert!(ListenCmd::try_parse_from(&["test", "--chain", "chain_id", "--event", "TestFilter"]).is_err()) + assert!(ListenCmd::try_parse_from(&[ + "test", + "--chain", + "chain_id", + "--events", + "TestFilter" + ]) + .is_err()) } #[test] diff --git a/relayer-cli/src/commands/misbehaviour.rs b/relayer-cli/src/commands/misbehaviour.rs index fc257e4b55..aab02eace1 100644 --- a/relayer-cli/src/commands/misbehaviour.rs +++ b/relayer-cli/src/commands/misbehaviour.rs @@ -20,6 +20,7 @@ pub struct MisbehaviourCmd { long = "chain", required = true, value_name = "CHAIN_ID", + help_heading = "FLAGS", help = "Identifier of the chain where client updates are monitored for misbehaviour" )] chain_id: ChainId, @@ -28,6 +29,7 @@ pub struct MisbehaviourCmd { long = "client", required = true, value_name = "CLIENT_ID", + help_heading = "FLAGS", help = "Identifier of the client to be monitored for misbehaviour" )] client_id: ClientId, @@ -146,7 +148,10 @@ mod tests { #[test] fn test_misbehaviour() { assert_eq!( - MisbehaviourCmd{ chain_id: ChainId::from_string("chain_id"), client_id: ClientId::from_str("client_id").unwrap() }, + MisbehaviourCmd { + chain_id: ChainId::from_string("chain_id"), + client_id: ClientId::from_str("client_id").unwrap() + }, MisbehaviourCmd::parse_from(&["test", "--chain", "chain_id", "--client", "client_id"]) ) } diff --git a/relayer-cli/src/commands/query/channel.rs b/relayer-cli/src/commands/query/channel.rs index 483135cb68..dfe0741069 100644 --- a/relayer-cli/src/commands/query/channel.rs +++ b/relayer-cli/src/commands/query/channel.rs @@ -17,6 +17,7 @@ pub struct QueryChannelEndCmd { long = "chain", required = true, value_name = "CHAIN_ID", + help_heading = "FLAGS", help = "Identifier of the chain to query" )] chain_id: ChainId, @@ -25,15 +26,17 @@ pub struct QueryChannelEndCmd { long = "port", required = true, value_name = "PORT_ID", + help_heading = "FLAGS", help = "Identifier of the port to query" )] port_id: PortId, #[clap( long = "channel", - alias = "chan", + visible_alias = "chan", required = true, value_name = "CHANNEL_ID", + help_heading = "FLAGS", help = "Identifier of the channel to query" )] channel_id: ChannelId, @@ -89,36 +92,102 @@ mod tests { use std::str::FromStr; use abscissa_core::clap::Parser; - use ibc::core::ics24_host::identifier::{ChainId, PortId, ChannelId}; + use ibc::core::ics24_host::identifier::{ChainId, ChannelId, PortId}; #[test] fn test_query_channel_end_required_only() { assert_eq!( - QueryChannelEndCmd{ chain_id: ChainId::from_string("chain_id"), port_id: PortId::from_str("port_id").unwrap(), channel_id: ChannelId::from_str("channel-07").unwrap(), height: None }, - QueryChannelEndCmd::parse_from(&["test", "--chain", "chain_id", "--port", "port_id", "--chan", "channel-07"]) + QueryChannelEndCmd { + chain_id: ChainId::from_string("chain_id"), + port_id: PortId::from_str("port_id").unwrap(), + channel_id: ChannelId::from_str("channel-07").unwrap(), + height: None + }, + QueryChannelEndCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--port", + "port_id", + "--channel", + "channel-07" + ]) + ) + } + + #[test] + fn test_query_channel_end_chan_alias() { + assert_eq!( + QueryChannelEndCmd { + chain_id: ChainId::from_string("chain_id"), + port_id: PortId::from_str("port_id").unwrap(), + channel_id: ChannelId::from_str("channel-07").unwrap(), + height: None + }, + QueryChannelEndCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--port", + "port_id", + "--chan", + "channel-07" + ]) ) } #[test] fn test_query_channel_end_height() { assert_eq!( - QueryChannelEndCmd{ chain_id: ChainId::from_string("chain_id"), port_id: PortId::from_str("port_id").unwrap(), channel_id: ChannelId::from_str("channel-07").unwrap(), height: Some(42) }, - QueryChannelEndCmd::parse_from(&["test", "--chain", "chain_id", "--port", "port_id", "--chan", "channel-07", "--height", "42"]) + QueryChannelEndCmd { + chain_id: ChainId::from_string("chain_id"), + port_id: PortId::from_str("port_id").unwrap(), + channel_id: ChannelId::from_str("channel-07").unwrap(), + height: Some(42) + }, + QueryChannelEndCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--port", + "port_id", + "--channel", + "channel-07", + "--height", + "42" + ]) ) } #[test] fn test_query_channel_end_no_chan() { - assert!(QueryChannelEndCmd::try_parse_from(&["test", "--chain", "chain_id", "--port", "port_id"]).is_err()) + assert!(QueryChannelEndCmd::try_parse_from(&[ + "test", "--chain", "chain_id", "--port", "port_id" + ]) + .is_err()) } #[test] fn test_query_channel_end_no_port() { - assert!(QueryChannelEndCmd::try_parse_from(&["test", "--chain", "chain_id", "--chan", "channel-07"]).is_err()) + assert!(QueryChannelEndCmd::try_parse_from(&[ + "test", + "--chain", + "chain_id", + "--channel", + "channel-07" + ]) + .is_err()) } #[test] fn test_query_channel_end_no_chain() { - assert!(QueryChannelEndCmd::try_parse_from(&["test", "--port", "port_id", "--chan", "channel-07"]).is_err()) + assert!(QueryChannelEndCmd::try_parse_from(&[ + "test", + "--port", + "port_id", + "--channel", + "channel-07" + ]) + .is_err()) } } diff --git a/relayer-cli/src/commands/query/channel_client.rs b/relayer-cli/src/commands/query/channel_client.rs index 38553998ee..f52888bcbd 100644 --- a/relayer-cli/src/commands/query/channel_client.rs +++ b/relayer-cli/src/commands/query/channel_client.rs @@ -20,6 +20,7 @@ pub struct QueryChannelClientCmd { long = "chain", required = true, value_name = "CHAIN_ID", + help_heading = "FLAGS", help = "Identifier of the chain to query" )] chain_id: ChainId, @@ -28,15 +29,17 @@ pub struct QueryChannelClientCmd { long = "port", required = true, value_name = "PORT_ID", + help_heading = "FLAGS", help = "Identifier of the port to query" )] port_id: PortId, #[clap( long = "channel", - alias = "chan", + visible_alias = "chan", required = true, value_name = "CHANNEL_ID", + help_heading = "FLAGS", help = "Identifier of the channel to query" )] channel_id: ChannelId, @@ -66,28 +69,77 @@ mod tests { use std::str::FromStr; use abscissa_core::clap::Parser; - use ibc::core::ics24_host::identifier::{ChainId, PortId, ChannelId}; + use ibc::core::ics24_host::identifier::{ChainId, ChannelId, PortId}; #[test] fn test_query_channel_client() { assert_eq!( - QueryChannelClientCmd{ chain_id: ChainId::from_string("chain_id"), port_id: PortId::from_str("port_id").unwrap(), channel_id: ChannelId::from_str("channel-07").unwrap() }, - QueryChannelClientCmd::parse_from(&["test", "--chain", "chain_id", "--port", "port_id", "--chan", "channel-07"]) + QueryChannelClientCmd { + chain_id: ChainId::from_string("chain_id"), + port_id: PortId::from_str("port_id").unwrap(), + channel_id: ChannelId::from_str("channel-07").unwrap() + }, + QueryChannelClientCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--port", + "port_id", + "--channel", + "channel-07" + ]) + ) + } + + #[test] + fn test_query_channel_client_chan_alias() { + assert_eq!( + QueryChannelClientCmd { + chain_id: ChainId::from_string("chain_id"), + port_id: PortId::from_str("port_id").unwrap(), + channel_id: ChannelId::from_str("channel-07").unwrap() + }, + QueryChannelClientCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--port", + "port_id", + "--chan", + "channel-07" + ]) ) } #[test] fn test_query_channel_client_no_chan() { - assert!(QueryChannelClientCmd::try_parse_from(&["test", "--chain", "chain_id", "--port", "port_id"]).is_err()) + assert!(QueryChannelClientCmd::try_parse_from(&[ + "test", "--chain", "chain_id", "--port", "port_id" + ]) + .is_err()) } #[test] fn test_query_channel_client_no_port() { - assert!(QueryChannelClientCmd::try_parse_from(&["test", "--chain", "chain_id", "--chan", "channel-07"]).is_err()) + assert!(QueryChannelClientCmd::try_parse_from(&[ + "test", + "--chain", + "chain_id", + "--channel", + "channel-07" + ]) + .is_err()) } #[test] fn test_query_channel_client_no_chain() { - assert!(QueryChannelClientCmd::try_parse_from(&["test", "--port", "port_id", "--chan", "channel-07"]).is_err()) + assert!(QueryChannelClientCmd::try_parse_from(&[ + "test", + "--port", + "port_id", + "--channel", + "channel-07" + ]) + .is_err()) } } diff --git a/relayer-cli/src/commands/query/channel_ends.rs b/relayer-cli/src/commands/query/channel_ends.rs index 6b867c6bcc..8c62fca955 100644 --- a/relayer-cli/src/commands/query/channel_ends.rs +++ b/relayer-cli/src/commands/query/channel_ends.rs @@ -23,6 +23,7 @@ pub struct QueryChannelEndsCmd { long = "chain", required = true, value_name = "CHAIN_ID", + help_heading = "FLAGS", help = "Identifier of the chain to query" )] chain_id: ChainId, @@ -31,15 +32,17 @@ pub struct QueryChannelEndsCmd { long = "port", required = true, value_name = "PORT_ID", + help_heading = "FLAGS", help = "Identifier of the port to query" )] port_id: PortId, #[clap( long = "channel", - alias = "chan", + visible_alias = "chan", required = true, value_name = "CHANNEL_ID", + help_heading = "FLAGS", help = "Identifier of the channel to query" )] channel_id: ChannelId, @@ -246,44 +249,128 @@ mod tests { use std::str::FromStr; use abscissa_core::clap::Parser; - use ibc::core::ics24_host::identifier::{ChainId, PortId, ChannelId}; + use ibc::core::ics24_host::identifier::{ChainId, ChannelId, PortId}; #[test] fn test_query_channel_ends_required_only() { assert_eq!( - QueryChannelEndsCmd{ chain_id: ChainId::from_string("chain_id"), port_id: PortId::from_str("port_id").unwrap(), channel_id: ChannelId::from_str("channel-07").unwrap(), height: None, verbose: false }, - QueryChannelEndsCmd::parse_from(&["test", "--chain", "chain_id", "--port", "port_id", "--chan", "channel-07"]) + QueryChannelEndsCmd { + chain_id: ChainId::from_string("chain_id"), + port_id: PortId::from_str("port_id").unwrap(), + channel_id: ChannelId::from_str("channel-07").unwrap(), + height: None, + verbose: false + }, + QueryChannelEndsCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--port", + "port_id", + "--channel", + "channel-07" + ]) + ) + } + + #[test] + fn test_query_channel_ends_chan_alias() { + assert_eq!( + QueryChannelEndsCmd { + chain_id: ChainId::from_string("chain_id"), + port_id: PortId::from_str("port_id").unwrap(), + channel_id: ChannelId::from_str("channel-07").unwrap(), + height: None, + verbose: false + }, + QueryChannelEndsCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--port", + "port_id", + "--chan", + "channel-07" + ]) ) } #[test] fn test_query_channel_ends_height() { assert_eq!( - QueryChannelEndsCmd{ chain_id: ChainId::from_string("chain_id"), port_id: PortId::from_str("port_id").unwrap(), channel_id: ChannelId::from_str("channel-07").unwrap(), height: Some(42), verbose: false }, - QueryChannelEndsCmd::parse_from(&["test", "--chain", "chain_id", "--port", "port_id", "--chan", "channel-07", "--height", "42"]) + QueryChannelEndsCmd { + chain_id: ChainId::from_string("chain_id"), + port_id: PortId::from_str("port_id").unwrap(), + channel_id: ChannelId::from_str("channel-07").unwrap(), + height: Some(42), + verbose: false + }, + QueryChannelEndsCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--port", + "port_id", + "--channel", + "channel-07", + "--height", + "42" + ]) ) } #[test] fn test_query_channel_ends_verbose() { assert_eq!( - QueryChannelEndsCmd{ chain_id: ChainId::from_string("chain_id"), port_id: PortId::from_str("port_id").unwrap(), channel_id: ChannelId::from_str("channel-07").unwrap(), height: None, verbose: true }, - QueryChannelEndsCmd::parse_from(&["test", "--chain", "chain_id", "--port", "port_id", "--chan", "channel-07", "--verbose"]) + QueryChannelEndsCmd { + chain_id: ChainId::from_string("chain_id"), + port_id: PortId::from_str("port_id").unwrap(), + channel_id: ChannelId::from_str("channel-07").unwrap(), + height: None, + verbose: true + }, + QueryChannelEndsCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--port", + "port_id", + "--channel", + "channel-07", + "--verbose" + ]) ) } #[test] fn test_query_channel_client_no_chan() { - assert!(QueryChannelEndsCmd::try_parse_from(&["test", "--chain", "chain_id", "--port", "port_id"]).is_err()) + assert!(QueryChannelEndsCmd::try_parse_from(&[ + "test", "--chain", "chain_id", "--port", "port_id" + ]) + .is_err()) } #[test] fn test_query_channel_client_no_port() { - assert!(QueryChannelEndsCmd::try_parse_from(&["test", "--chain", "chain_id", "--chan", "channel-07"]).is_err()) + assert!(QueryChannelEndsCmd::try_parse_from(&[ + "test", + "--chain", + "chain_id", + "--channel", + "channel-07" + ]) + .is_err()) } #[test] fn test_query_channel_client_no_chain() { - assert!(QueryChannelEndsCmd::try_parse_from(&["test", "--port", "port_id", "--chan", "channel-07"]).is_err()) + assert!(QueryChannelEndsCmd::try_parse_from(&[ + "test", + "--port", + "port_id", + "--channel", + "channel-07" + ]) + .is_err()) } } diff --git a/relayer-cli/src/commands/query/channels.rs b/relayer-cli/src/commands/query/channels.rs index eac4edf7bc..3e5970125c 100644 --- a/relayer-cli/src/commands/query/channels.rs +++ b/relayer-cli/src/commands/query/channels.rs @@ -20,13 +20,11 @@ use crate::prelude::*; #[derive(Clone, Command, Debug, Parser, PartialEq)] pub struct QueryChannelsCmd { - #[clap(required = true, help = "identifier of the chain to query")] - chain_id: ChainId, - #[clap( long = "chain", required = true, value_name = "CHAIN_ID", + help_heading = "FLAGS", help = "Identifier of the chain to query" )] chain_id: ChainId, @@ -287,23 +285,21 @@ mod tests { #[test] fn test_query_channels_required_only() { assert_eq!( - QueryChannelsCmd{ chain_id: ChainId::from_string("chain_id"), dst_chain_id: None, verbose: false }, + QueryChannelsCmd { + chain_id: ChainId::from_string("chain_id"), + verbose: false + }, QueryChannelsCmd::parse_from(&["test", "--chain", "chain_id"]) ) } - #[test] - fn test_query_channels_counterparty_chain() { - assert_eq!( - QueryChannelsCmd{ chain_id: ChainId::from_string("chain_id"), dst_chain_id: Some(ChainId::from_string("counterparty_chain_id")), verbose: false }, - QueryChannelsCmd::parse_from(&["test", "--chain", "chain_id", "--counterparty-chain", "counterparty_chain_id"]) - ) - } - #[test] fn test_query_channels_verbose() { assert_eq!( - QueryChannelsCmd{ chain_id: ChainId::from_string("chain_id"), dst_chain_id: None, verbose: true }, + QueryChannelsCmd { + chain_id: ChainId::from_string("chain_id"), + verbose: true + }, QueryChannelsCmd::parse_from(&["test", "--chain", "chain_id", "--verbose"]) ) } diff --git a/relayer-cli/src/commands/query/client.rs b/relayer-cli/src/commands/query/client.rs index feb09f541c..c548a03f1f 100644 --- a/relayer-cli/src/commands/query/client.rs +++ b/relayer-cli/src/commands/query/client.rs @@ -26,6 +26,7 @@ pub struct QueryClientStateCmd { long = "chain", required = true, value_name = "CHAIN_ID", + help_heading = "FLAGS", help = "Identifier of the chain to query" )] chain_id: ChainId, @@ -34,6 +35,7 @@ pub struct QueryClientStateCmd { long = "client", required = true, value_name = "CLIENT_ID", + help_heading = "FLAGS", help = "Identifier of the client to query" )] client_id: ClientId, @@ -77,6 +79,7 @@ pub struct QueryClientConsensusCmd { long = "chain", required = true, value_name = "CHAIN_ID", + help_heading = "FLAGS", help = "Identifier of the chain to query" )] chain_id: ChainId, @@ -85,6 +88,7 @@ pub struct QueryClientConsensusCmd { long = "client", required = true, value_name = "CLIENT_ID", + help_heading = "FLAGS", help = "Identifier of the client to query" )] client_id: ClientId, @@ -189,6 +193,7 @@ pub struct QueryClientHeaderCmd { long = "chain", required = true, value_name = "CHAIN_ID", + help_heading = "FLAGS", help = "Identifier of the chain to query" )] chain_id: ChainId, @@ -197,6 +202,7 @@ pub struct QueryClientHeaderCmd { long = "client", required = true, value_name = "CLIENT_ID", + help_heading = "FLAGS", help = "Identifier of the client to query" )] client_id: ClientId, @@ -205,6 +211,7 @@ pub struct QueryClientHeaderCmd { long = "consensus-height", required = true, value_name = "CONSENSUS_HEIGHT", + help_heading = "FLAGS", help = "Height of header to query" )] consensus_height: u64, @@ -274,6 +281,7 @@ pub struct QueryClientConnectionsCmd { long = "chain", required = true, value_name = "CHAIN_ID", + help_heading = "FLAGS", help = "Identifier of the chain to query" )] chain_id: ChainId, @@ -282,6 +290,7 @@ pub struct QueryClientConnectionsCmd { long = "client", required = true, value_name = "CLIENT_ID", + help_heading = "FLAGS", help = "Identifier of the client to query" )] client_id: ClientId, @@ -317,7 +326,10 @@ impl Runnable for QueryClientConnectionsCmd { #[cfg(test)] mod tests { - use super::{QueryClientStateCmd, QueryClientConnectionsCmd, QueryClientConsensusCmd, QueryClientHeaderCmd}; + use super::{ + QueryClientConnectionsCmd, QueryClientConsensusCmd, QueryClientHeaderCmd, + QueryClientStateCmd, + }; use std::str::FromStr; @@ -327,58 +339,137 @@ mod tests { #[test] fn test_query_client_connections_required_only() { assert_eq!( - QueryClientConnectionsCmd{ chain_id: ChainId::from_string("chain_id"), client_id: ClientId::from_str("client_id").unwrap(), height: None }, - QueryClientConnectionsCmd::parse_from(&["test", "--chain", "chain_id", "--client", "client_id"]) + QueryClientConnectionsCmd { + chain_id: ChainId::from_string("chain_id"), + client_id: ClientId::from_str("client_id").unwrap(), + height: None + }, + QueryClientConnectionsCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--client", + "client_id" + ]) ) } #[test] fn test_query_client_connections_height() { assert_eq!( - QueryClientConnectionsCmd{ chain_id: ChainId::from_string("chain_id"), client_id: ClientId::from_str("client_id").unwrap(), height: Some(42) }, - QueryClientConnectionsCmd::parse_from(&["test", "--chain", "chain_id", "--client", "client_id", "--height", "42"]) + QueryClientConnectionsCmd { + chain_id: ChainId::from_string("chain_id"), + client_id: ClientId::from_str("client_id").unwrap(), + height: Some(42) + }, + QueryClientConnectionsCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--client", + "client_id", + "--height", + "42" + ]) ) } #[test] fn test_query_client_connections_no_client() { - assert!(QueryClientConnectionsCmd::try_parse_from(&["test", "--chain", "chain_id"]).is_err()) + assert!( + QueryClientConnectionsCmd::try_parse_from(&["test", "--chain", "chain_id"]).is_err() + ) } #[test] fn test_query_client_connections_no_chain() { - assert!(QueryClientConnectionsCmd::try_parse_from(&["test", "--client", "client_id"]).is_err()) + assert!( + QueryClientConnectionsCmd::try_parse_from(&["test", "--client", "client_id"]).is_err() + ) } #[test] fn test_query_client_consensus_required_only() { assert_eq!( - QueryClientConsensusCmd{ chain_id: ChainId::from_string("chain_id"), client_id: ClientId::from_str("client_id").unwrap(), consensus_height: None, heights_only: false, height: None }, - QueryClientConsensusCmd::parse_from(&["test", "--chain", "chain_id", "--client", "client_id"]) + QueryClientConsensusCmd { + chain_id: ChainId::from_string("chain_id"), + client_id: ClientId::from_str("client_id").unwrap(), + consensus_height: None, + heights_only: false, + height: None + }, + QueryClientConsensusCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--client", + "client_id" + ]) ) } #[test] fn test_query_client_consensus_consensus_height() { assert_eq!( - QueryClientConsensusCmd{ chain_id: ChainId::from_string("chain_id"), client_id: ClientId::from_str("client_id").unwrap(), consensus_height: Some(42), heights_only: false, height: None }, - QueryClientConsensusCmd::parse_from(&["test", "--chain", "chain_id", "--client", "client_id", "--consensus-height", "42"]) + QueryClientConsensusCmd { + chain_id: ChainId::from_string("chain_id"), + client_id: ClientId::from_str("client_id").unwrap(), + consensus_height: Some(42), + heights_only: false, + height: None + }, + QueryClientConsensusCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--client", + "client_id", + "--consensus-height", + "42" + ]) ) } #[test] fn test_query_client_consensus_height() { assert_eq!( - QueryClientConsensusCmd{ chain_id: ChainId::from_string("chain_id"), client_id: ClientId::from_str("client_id").unwrap(), consensus_height: None, heights_only: false, height: Some(42) }, - QueryClientConsensusCmd::parse_from(&["test", "--chain", "chain_id", "--client", "client_id", "--height", "42"]) + QueryClientConsensusCmd { + chain_id: ChainId::from_string("chain_id"), + client_id: ClientId::from_str("client_id").unwrap(), + consensus_height: None, + heights_only: false, + height: Some(42) + }, + QueryClientConsensusCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--client", + "client_id", + "--height", + "42" + ]) ) } #[test] fn test_query_client_consensus_heights_only() { assert_eq!( - QueryClientConsensusCmd{ chain_id: ChainId::from_string("chain_id"), client_id: ClientId::from_str("client_id").unwrap(), consensus_height: None, heights_only: true, height: None }, - QueryClientConsensusCmd::parse_from(&["test", "--chain", "chain_id", "--client", "client_id", "--heights-only"]) + QueryClientConsensusCmd { + chain_id: ChainId::from_string("chain_id"), + client_id: ClientId::from_str("client_id").unwrap(), + consensus_height: None, + heights_only: true, + height: None + }, + QueryClientConsensusCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--client", + "client_id", + "--heights-only" + ]) ) } @@ -389,53 +480,126 @@ mod tests { #[test] fn test_query_client_consensus_no_chain() { - assert!(QueryClientConsensusCmd::try_parse_from(&["test", "--client", "client_id"]).is_err()) + assert!( + QueryClientConsensusCmd::try_parse_from(&["test", "--client", "client_id"]).is_err() + ) } - + #[test] fn test_query_client_header_required_only() { assert_eq!( - QueryClientHeaderCmd{ chain_id: ChainId::from_string("chain_id"), client_id: ClientId::from_str("client_id").unwrap(), consensus_height: 42, height: None }, - QueryClientHeaderCmd::parse_from(&["test", "--chain", "chain_id", "--client", "client_id", "--consensus-height", "42"]) + QueryClientHeaderCmd { + chain_id: ChainId::from_string("chain_id"), + client_id: ClientId::from_str("client_id").unwrap(), + consensus_height: 42, + height: None + }, + QueryClientHeaderCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--client", + "client_id", + "--consensus-height", + "42" + ]) ) } - + #[test] fn test_query_client_header_height() { assert_eq!( - QueryClientHeaderCmd{ chain_id: ChainId::from_string("chain_id"), client_id: ClientId::from_str("client_id").unwrap(), consensus_height: 42, height: Some(21) }, - QueryClientHeaderCmd::parse_from(&["test", "--chain", "chain_id", "--client", "client_id", "--consensus-height", "42", "--height", "21"]) + QueryClientHeaderCmd { + chain_id: ChainId::from_string("chain_id"), + client_id: ClientId::from_str("client_id").unwrap(), + consensus_height: 42, + height: Some(21) + }, + QueryClientHeaderCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--client", + "client_id", + "--consensus-height", + "42", + "--height", + "21" + ]) ) } #[test] fn test_query_client_header_no_consensus_height() { - assert!(QueryClientHeaderCmd::try_parse_from(&["test", "--chain", "chain_id", "--client", "client_id"]).is_err()) + assert!(QueryClientHeaderCmd::try_parse_from(&[ + "test", + "--chain", + "chain_id", + "--client", + "client_id" + ]) + .is_err()) } #[test] fn test_query_client_header_no_client() { - assert!(QueryClientHeaderCmd::try_parse_from(&["test", "--chain", "chain_id", "--consensus-height", "42"]).is_err()) + assert!(QueryClientHeaderCmd::try_parse_from(&[ + "test", + "--chain", + "chain_id", + "--consensus-height", + "42" + ]) + .is_err()) } #[test] fn test_query_client_header_no_chain() { - assert!(QueryClientHeaderCmd::try_parse_from(&["test", "--client", "client_id", "--consensus-height", "42"]).is_err()) + assert!(QueryClientHeaderCmd::try_parse_from(&[ + "test", + "--client", + "client_id", + "--consensus-height", + "42" + ]) + .is_err()) } #[test] fn test_query_client_state_required_only() { assert_eq!( - QueryClientStateCmd{ chain_id: ChainId::from_string("chain_id"), client_id: ClientId::from_str("client_id").unwrap(), height: None }, - QueryClientStateCmd::parse_from(&["test", "--chain", "chain_id", "--client", "client_id"]) + QueryClientStateCmd { + chain_id: ChainId::from_string("chain_id"), + client_id: ClientId::from_str("client_id").unwrap(), + height: None + }, + QueryClientStateCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--client", + "client_id" + ]) ) } #[test] fn test_query_client_state_height() { assert_eq!( - QueryClientStateCmd{ chain_id: ChainId::from_string("chain_id"), client_id: ClientId::from_str("client_id").unwrap(), height: Some(42) }, - QueryClientStateCmd::parse_from(&["test", "--chain", "chain_id", "--client", "client_id", "--height", "42"]) + QueryClientStateCmd { + chain_id: ChainId::from_string("chain_id"), + client_id: ClientId::from_str("client_id").unwrap(), + height: Some(42) + }, + QueryClientStateCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--client", + "client_id", + "--height", + "42" + ]) ) } diff --git a/relayer-cli/src/commands/query/clients.rs b/relayer-cli/src/commands/query/clients.rs index 7596b01f94..48ac732960 100644 --- a/relayer-cli/src/commands/query/clients.rs +++ b/relayer-cli/src/commands/query/clients.rs @@ -19,6 +19,7 @@ pub struct QueryAllClientsCmd { long = "host-chain", required = true, value_name = "HOST_CHAIN_ID", + help_heading = "FLAGS", help = "Identifier of the chain to query" )] chain_id: ChainId, @@ -119,7 +120,11 @@ mod tests { #[test] fn test_query_clients_required_only() { assert_eq!( - QueryAllClientsCmd{ chain_id: ChainId::from_string("chain_host_id"), src_chain_id: None, omit_chain_ids: false }, + QueryAllClientsCmd { + chain_id: ChainId::from_string("chain_host_id"), + src_chain_id: None, + omit_chain_ids: false + }, QueryAllClientsCmd::parse_from(&["test", "--host-chain", "chain_host_id"]) ) } @@ -127,16 +132,35 @@ mod tests { #[test] fn test_query_clients_omit_chain_ids() { assert_eq!( - QueryAllClientsCmd{ chain_id: ChainId::from_string("chain_host_id"), src_chain_id: None, omit_chain_ids: true }, - QueryAllClientsCmd::parse_from(&["test", "--host-chain", "chain_host_id", "--omit-chain-ids"]) + QueryAllClientsCmd { + chain_id: ChainId::from_string("chain_host_id"), + src_chain_id: None, + omit_chain_ids: true + }, + QueryAllClientsCmd::parse_from(&[ + "test", + "--host-chain", + "chain_host_id", + "--omit-chain-ids" + ]) ) } #[test] fn test_query_clients_reference_chain() { assert_eq!( - QueryAllClientsCmd{ chain_id: ChainId::from_string("chain_host_id"), src_chain_id: Some(ChainId::from_string("reference_chain_id")), omit_chain_ids: false }, - QueryAllClientsCmd::parse_from(&["test", "--host-chain", "chain_host_id", "--reference-chain", "reference_chain_id"]) + QueryAllClientsCmd { + chain_id: ChainId::from_string("chain_host_id"), + src_chain_id: Some(ChainId::from_string("reference_chain_id")), + omit_chain_ids: false + }, + QueryAllClientsCmd::parse_from(&[ + "test", + "--host-chain", + "chain_host_id", + "--reference-chain", + "reference_chain_id" + ]) ) } diff --git a/relayer-cli/src/commands/query/connection.rs b/relayer-cli/src/commands/query/connection.rs index cf07d993ba..16d8b729d4 100644 --- a/relayer-cli/src/commands/query/connection.rs +++ b/relayer-cli/src/commands/query/connection.rs @@ -22,15 +22,17 @@ pub struct QueryConnectionEndCmd { long = "chain", required = true, value_name = "CHAIN_ID", + help_heading = "FLAGS", help = "Identifier of the chain to query" )] chain_id: ChainId, #[clap( long = "connection", - alias = "conn", + visible_alias = "conn", required = true, value_name = "CONNECTION_ID", + help_heading = "FLAGS", help = "Identifier of the connection to query" )] connection_id: ConnectionId, @@ -82,21 +84,23 @@ impl Runnable for QueryConnectionEndCmd { /// Command for querying the channel identifiers associated with a connection. /// Sample invocation: /// `cargo run --bin hermes -- query connection channels ibc-0 connection-0` -#[derive(Clone, Command, Debug, Parser)] +#[derive(Clone, Command, Debug, Parser, PartialEq)] pub struct QueryConnectionChannelsCmd { #[clap( long = "chain", required = true, value_name = "CHAIN_ID", + help_heading = "FLAGS", help = "Identifier of the chain to query" )] chain_id: ChainId, #[clap( long = "connection", - alias = "conn", + visible_alias = "conn", required = true, value_name = "CONNECTION_ID", + help_heading = "FLAGS", help = "Identifier of the connection to query" )] connection_id: ConnectionId, @@ -146,34 +150,107 @@ mod tests { #[test] fn test_query_connection_channels() { assert_eq!( - QueryConnectionChannelsCmd{ chain_id: ChainId::from_string("chain_id"), connection_id: ConnectionId::from_str("connection_id").unwrap() }, - QueryConnectionChannelsCmd::parse_from(&["test", "--chain", "chain_id", "--conn", "connection_id"]) + QueryConnectionChannelsCmd { + chain_id: ChainId::from_string("chain_id"), + connection_id: ConnectionId::from_str("connection_id").unwrap() + }, + QueryConnectionChannelsCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--connection", + "connection_id" + ]) + ) + } + + #[test] + fn test_query_connection_channels_conn_alias() { + assert_eq!( + QueryConnectionChannelsCmd { + chain_id: ChainId::from_string("chain_id"), + connection_id: ConnectionId::from_str("connection_id").unwrap() + }, + QueryConnectionChannelsCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--conn", + "connection_id" + ]) ) } #[test] fn test_query_connection_channels_no_conn() { - assert!(QueryConnectionChannelsCmd::try_parse_from(&["test", "--chain", "chain_id"]).is_err()) + assert!( + QueryConnectionChannelsCmd::try_parse_from(&["test", "--chain", "chain_id"]).is_err() + ) } #[test] fn test_query_connection_channels_no_chain() { - assert!(QueryConnectionChannelsCmd::try_parse_from(&["test", "--conn", "connection_id"]).is_err()) + assert!(QueryConnectionChannelsCmd::try_parse_from(&[ + "test", + "--connection", + "connection_id" + ]) + .is_err()) } #[test] fn test_query_connection_end_required_only() { assert_eq!( - QueryConnectionEndCmd{ chain_id: ChainId::from_string("chain_id"), connection_id: ConnectionId::from_str("connection_id").unwrap(), height: None }, - QueryConnectionEndCmd::parse_from(&["test", "--chain", "chain_id", "--conn", "connection_id"]) + QueryConnectionEndCmd { + chain_id: ChainId::from_string("chain_id"), + connection_id: ConnectionId::from_str("connection_id").unwrap(), + height: None + }, + QueryConnectionEndCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--connection", + "connection_id" + ]) + ) + } + + #[test] + fn test_query_connection_end_conn_alias() { + assert_eq!( + QueryConnectionEndCmd { + chain_id: ChainId::from_string("chain_id"), + connection_id: ConnectionId::from_str("connection_id").unwrap(), + height: None + }, + QueryConnectionEndCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--conn", + "connection_id" + ]) ) } #[test] fn test_query_connection_end_height() { assert_eq!( - QueryConnectionEndCmd{ chain_id: ChainId::from_string("chain_id"), connection_id: ConnectionId::from_str("connection_id").unwrap(), height: Some(42) }, - QueryConnectionEndCmd::parse_from(&["test", "--chain", "chain_id", "--conn", "connection_id", "--height", "42"]) + QueryConnectionEndCmd { + chain_id: ChainId::from_string("chain_id"), + connection_id: ConnectionId::from_str("connection_id").unwrap(), + height: Some(42) + }, + QueryConnectionEndCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--connection", + "connection_id", + "--height", + "42" + ]) ) } @@ -184,6 +261,9 @@ mod tests { #[test] fn test_query_connection_end_no_chain() { - assert!(QueryConnectionEndCmd::try_parse_from(&["test", "--conn", "connection_id"]).is_err()) + assert!( + QueryConnectionEndCmd::try_parse_from(&["test", "--connection", "connection_id"]) + .is_err() + ) } } diff --git a/relayer-cli/src/commands/query/connections.rs b/relayer-cli/src/commands/query/connections.rs index 80db413d39..45fb2f5617 100644 --- a/relayer-cli/src/commands/query/connections.rs +++ b/relayer-cli/src/commands/query/connections.rs @@ -15,6 +15,7 @@ pub struct QueryConnectionsCmd { long = "chain", required = true, value_name = "CHAIN_ID", + help_heading = "FLAGS", help = "Identifier of the chain to query" )] chain_id: ChainId, @@ -58,7 +59,9 @@ mod tests { #[test] fn test_query_connections() { assert_eq!( - QueryConnectionsCmd{ chain_id: ChainId::from_string("chain_id") }, + QueryConnectionsCmd { + chain_id: ChainId::from_string("chain_id") + }, QueryConnectionsCmd::parse_from(&["test", "--chain", "chain_id"]) ) } diff --git a/relayer-cli/src/commands/query/packet/ack.rs b/relayer-cli/src/commands/query/packet/ack.rs index ad8962a7d6..05b92a8860 100644 --- a/relayer-cli/src/commands/query/packet/ack.rs +++ b/relayer-cli/src/commands/query/packet/ack.rs @@ -18,6 +18,7 @@ pub struct QueryPacketAcknowledgmentCmd { long = "chain", required = true, value_name = "CHAIN_ID", + help_heading = "FLAGS", help = "Identifier of the chain to query" )] chain_id: ChainId, @@ -26,24 +27,27 @@ pub struct QueryPacketAcknowledgmentCmd { long = "port", required = true, value_name = "PORT_ID", + help_heading = "FLAGS", help = "Identifier of the port to query" )] port_id: PortId, #[clap( long = "channel", - alias = "chan", + visible_alias = "chan", required = true, value_name = "CHANNEL_ID", + help_heading = "FLAGS", help = "Identifier of the channel to query" )] channel_id: ChannelId, #[clap( long = "sequence", - alias = "seq", + visible_alias = "seq", required = true, value_name = "SEQUENCE", + help_heading = "FLAGS", help = "Sequence of packet to query" )] sequence: Sequence, @@ -104,42 +108,136 @@ mod tests { use std::str::FromStr; use abscissa_core::clap::Parser; - use ibc::core::ics24_host::identifier::{ChainId, ChannelId, PortId}; use ibc::core::ics04_channel::packet::Sequence; + use ibc::core::ics24_host::identifier::{ChainId, ChannelId, PortId}; #[test] fn test_query_packet_ack_required_only() { assert_eq!( - QueryPacketAcknowledgmentCmd{ chain_id: ChainId::from_string("chain_id"), port_id: PortId::from_str("port_id").unwrap(), channel_id: ChannelId::from_str("channel-07").unwrap(), sequence: Sequence::from(42), height: None }, - QueryPacketAcknowledgmentCmd::parse_from(&["test", "--chain", "chain_id", "--port", "port_id", "--chan", "channel-07", "--seq", "42"]) + QueryPacketAcknowledgmentCmd { + chain_id: ChainId::from_string("chain_id"), + port_id: PortId::from_str("port_id").unwrap(), + channel_id: ChannelId::from_str("channel-07").unwrap(), + sequence: Sequence::from(42), + height: None + }, + QueryPacketAcknowledgmentCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--port", + "port_id", + "--channel", + "channel-07", + "--sequence", + "42" + ]) + ) + } + + #[test] + fn test_query_packet_ack_aliases() { + assert_eq!( + QueryPacketAcknowledgmentCmd { + chain_id: ChainId::from_string("chain_id"), + port_id: PortId::from_str("port_id").unwrap(), + channel_id: ChannelId::from_str("channel-07").unwrap(), + sequence: Sequence::from(42), + height: None + }, + QueryPacketAcknowledgmentCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--port", + "port_id", + "--chan", + "channel-07", + "--seq", + "42" + ]) ) } #[test] fn test_query_packet_ack_height() { assert_eq!( - QueryPacketAcknowledgmentCmd{ chain_id: ChainId::from_string("chain_id"), port_id: PortId::from_str("port_id").unwrap(), channel_id: ChannelId::from_str("channel-07").unwrap(), sequence: Sequence::from(42), height: Some(21) }, - QueryPacketAcknowledgmentCmd::parse_from(&["test", "--chain", "chain_id", "--port", "port_id", "--chan", "channel-07", "--seq", "42", "--height", "21"]) + QueryPacketAcknowledgmentCmd { + chain_id: ChainId::from_string("chain_id"), + port_id: PortId::from_str("port_id").unwrap(), + channel_id: ChannelId::from_str("channel-07").unwrap(), + sequence: Sequence::from(42), + height: Some(21) + }, + QueryPacketAcknowledgmentCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--port", + "port_id", + "--channel", + "channel-07", + "--sequence", + "42", + "--height", + "21" + ]) ) } #[test] fn test_query_packet_ack_no_seq() { - assert!(QueryPacketAcknowledgmentCmd::try_parse_from(&["test", "--chain", "chain_id", "--port", "port_id", "--chan", "channel-07"]).is_err()) + assert!(QueryPacketAcknowledgmentCmd::try_parse_from(&[ + "test", + "--chain", + "chain_id", + "--port", + "port_id", + "--channel", + "channel-07" + ]) + .is_err()) } #[test] fn test_query_packet_ack_no_chan() { - assert!(QueryPacketAcknowledgmentCmd::try_parse_from(&["test", "--chain", "chain_id", "--port", "port_id", "--seq", "42"]).is_err()) + assert!(QueryPacketAcknowledgmentCmd::try_parse_from(&[ + "test", + "--chain", + "chain_id", + "--port", + "port_id", + "--sequence", + "42" + ]) + .is_err()) } #[test] fn test_query_packet_ack_no_port() { - assert!(QueryPacketAcknowledgmentCmd::try_parse_from(&["test", "--chain", "chain_id", "--chan", "channel-07", "--seq", "42"]).is_err()) + assert!(QueryPacketAcknowledgmentCmd::try_parse_from(&[ + "test", + "--chain", + "chain_id", + "--channel", + "channel-07", + "--sequence", + "42" + ]) + .is_err()) } #[test] fn test_query_packet_ack_no_chain() { - assert!(QueryPacketAcknowledgmentCmd::try_parse_from(&["test", "--port", "port_id", "--chan", "channel-07", "--seq", "42"]).is_err()) + assert!(QueryPacketAcknowledgmentCmd::try_parse_from(&[ + "test", + "--port", + "port_id", + "--channel", + "channel-07", + "--sequence", + "42" + ]) + .is_err()) } } diff --git a/relayer-cli/src/commands/query/packet/acks.rs b/relayer-cli/src/commands/query/packet/acks.rs index 41807ece63..7f36303750 100644 --- a/relayer-cli/src/commands/query/packet/acks.rs +++ b/relayer-cli/src/commands/query/packet/acks.rs @@ -25,6 +25,7 @@ pub struct QueryPacketAcknowledgementsCmd { long = "chain", required = true, value_name = "CHAIN_ID", + help_heading = "FLAGS", help = "Identifier of the chain to query" )] chain_id: ChainId, @@ -33,15 +34,17 @@ pub struct QueryPacketAcknowledgementsCmd { long = "port", required = true, value_name = "PORT_ID", + help_heading = "FLAGS", help = "Identifier of the port to query" )] port_id: PortId, #[clap( long = "channel", - alias = "chan", + visible_alias = "chan", required = true, value_name = "CHANNEL_ID", + help_heading = "FLAGS", help = "Identifier of the channel to query" )] channel_id: ChannelId, @@ -85,28 +88,77 @@ mod tests { use std::str::FromStr; use abscissa_core::clap::Parser; - use ibc::core::ics24_host::identifier::{ChainId, PortId, ChannelId}; + use ibc::core::ics24_host::identifier::{ChainId, ChannelId, PortId}; #[test] fn test_query_packet_acks() { assert_eq!( - QueryPacketAcknowledgementsCmd{chain_id: ChainId::from_string("chain_id"), port_id: PortId::from_str("port_id").unwrap(), channel_id: ChannelId::from_str("channel-07").unwrap()}, - QueryPacketAcknowledgementsCmd::parse_from(&["test", "--chain", "chain_id", "--port", "port_id", "--chan", "channel-07"]) + QueryPacketAcknowledgementsCmd { + chain_id: ChainId::from_string("chain_id"), + port_id: PortId::from_str("port_id").unwrap(), + channel_id: ChannelId::from_str("channel-07").unwrap() + }, + QueryPacketAcknowledgementsCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--port", + "port_id", + "--channel", + "channel-07" + ]) + ) + } + + #[test] + fn test_query_packet_acks_chan_alias() { + assert_eq!( + QueryPacketAcknowledgementsCmd { + chain_id: ChainId::from_string("chain_id"), + port_id: PortId::from_str("port_id").unwrap(), + channel_id: ChannelId::from_str("channel-07").unwrap() + }, + QueryPacketAcknowledgementsCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--port", + "port_id", + "--chan", + "channel-07" + ]) ) } #[test] fn test_query_packet_acks_no_chan() { - assert!(QueryPacketAcknowledgementsCmd::try_parse_from(&["test", "--chain", "chain_id", "--port", "port_id"]).is_err()) + assert!(QueryPacketAcknowledgementsCmd::try_parse_from(&[ + "test", "--chain", "chain_id", "--port", "port_id" + ]) + .is_err()) } #[test] fn test_query_packet_acks_no_port() { - assert!(QueryPacketAcknowledgementsCmd::try_parse_from(&["test", "--chain", "chain_id", "--chan", "channel-07"]).is_err()) + assert!(QueryPacketAcknowledgementsCmd::try_parse_from(&[ + "test", + "--chain", + "chain_id", + "--channel", + "channel-07" + ]) + .is_err()) } #[test] fn test_query_packet_acks_no_chain() { - assert!(QueryPacketAcknowledgementsCmd::try_parse_from(&["test", "--port", "port_id", "--chan", "channel-07"]).is_err()) + assert!(QueryPacketAcknowledgementsCmd::try_parse_from(&[ + "test", + "--port", + "port_id", + "--channel", + "channel-07" + ]) + .is_err()) } } diff --git a/relayer-cli/src/commands/query/packet/commitment.rs b/relayer-cli/src/commands/query/packet/commitment.rs index ddf4c0eb47..66fab1119c 100644 --- a/relayer-cli/src/commands/query/packet/commitment.rs +++ b/relayer-cli/src/commands/query/packet/commitment.rs @@ -26,6 +26,7 @@ pub struct QueryPacketCommitmentCmd { long = "chain", required = true, value_name = "CHAIN_ID", + help_heading = "FLAGS", help = "Identifier of the chain to query" )] chain_id: ChainId, @@ -34,24 +35,27 @@ pub struct QueryPacketCommitmentCmd { long = "port", required = true, value_name = "PORT_ID", + help_heading = "FLAGS", help = "Identifier of the port to query" )] port_id: PortId, #[clap( long = "channel", - alias = "chan", + visible_alias = "chan", required = true, value_name = "CHANNEL_ID", + help_heading = "FLAGS", help = "Identifier of the channel to query" )] channel_id: ChannelId, #[clap( long = "sequence", - alias = "seq", + visible_alias = "seq", required = true, value_name = "SEQUENCE", + help_heading = "FLAGS", help = "Sequence of packet to query" )] sequence: Sequence, @@ -115,41 +119,138 @@ mod tests { use std::str::FromStr; use abscissa_core::clap::Parser; - use ibc::core::{ics24_host::identifier::{ChainId, PortId, ChannelId}, ics04_channel::packet::Sequence}; + use ibc::core::{ + ics04_channel::packet::Sequence, + ics24_host::identifier::{ChainId, ChannelId, PortId}, + }; #[test] fn test_query_packet_commitment_required_only() { assert_eq!( - QueryPacketCommitmentCmd{ chain_id: ChainId::from_string("chain_id"), port_id: PortId::from_str("port_id").unwrap(), channel_id: ChannelId::from_str("channel-07").unwrap(), sequence: Sequence::from(42), height: None }, - QueryPacketCommitmentCmd::parse_from(&["test", "--chain", "chain_id", "--port", "port_id", "--chan", "channel-07", "--seq", "42"]) + QueryPacketCommitmentCmd { + chain_id: ChainId::from_string("chain_id"), + port_id: PortId::from_str("port_id").unwrap(), + channel_id: ChannelId::from_str("channel-07").unwrap(), + sequence: Sequence::from(42), + height: None + }, + QueryPacketCommitmentCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--port", + "port_id", + "--channel", + "channel-07", + "--sequence", + "42" + ]) + ) + } + + #[test] + fn test_query_packet_commitment_aliases() { + assert_eq!( + QueryPacketCommitmentCmd { + chain_id: ChainId::from_string("chain_id"), + port_id: PortId::from_str("port_id").unwrap(), + channel_id: ChannelId::from_str("channel-07").unwrap(), + sequence: Sequence::from(42), + height: None + }, + QueryPacketCommitmentCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--port", + "port_id", + "--chan", + "channel-07", + "--seq", + "42" + ]) ) } #[test] fn test_query_packet_commitment_height() { assert_eq!( - QueryPacketCommitmentCmd{ chain_id: ChainId::from_string("chain_id"), port_id: PortId::from_str("port_id").unwrap(), channel_id: ChannelId::from_str("channel-07").unwrap(), sequence: Sequence::from(42), height: Some(21) }, - QueryPacketCommitmentCmd::parse_from(&["test", "--chain", "chain_id", "--port", "port_id", "--chan", "channel-07", "--seq", "42", "--height", "21"]) + QueryPacketCommitmentCmd { + chain_id: ChainId::from_string("chain_id"), + port_id: PortId::from_str("port_id").unwrap(), + channel_id: ChannelId::from_str("channel-07").unwrap(), + sequence: Sequence::from(42), + height: Some(21) + }, + QueryPacketCommitmentCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--port", + "port_id", + "--channel", + "channel-07", + "--sequence", + "42", + "--height", + "21" + ]) ) } #[test] fn test_query_packet_commitment_no_seq() { - assert!(QueryPacketCommitmentCmd::try_parse_from(&["test", "--chain", "chain_id", "--port", "port_id", "--chan", "channel-07"]).is_err()) + assert!(QueryPacketCommitmentCmd::try_parse_from(&[ + "test", + "--chain", + "chain_id", + "--port", + "port_id", + "--channel", + "channel-07" + ]) + .is_err()) } #[test] fn test_query_packet_commitment_no_chan() { - assert!(QueryPacketCommitmentCmd::try_parse_from(&["test", "--chain", "chain_id", "--port", "port_id", "--seq", "42"]).is_err()) + assert!(QueryPacketCommitmentCmd::try_parse_from(&[ + "test", + "--chain", + "chain_id", + "--port", + "port_id", + "--sequence", + "42" + ]) + .is_err()) } #[test] fn test_query_packet_commitment_no_port() { - assert!(QueryPacketCommitmentCmd::try_parse_from(&["test", "--chain", "chain_id", "--chan", "channel-07", "--seq", "42"]).is_err()) + assert!(QueryPacketCommitmentCmd::try_parse_from(&[ + "test", + "--chain", + "chain_id", + "--channel", + "channel-07", + "--sequence", + "42" + ]) + .is_err()) } #[test] fn test_query_packet_commitment_no_chain() { - assert!(QueryPacketCommitmentCmd::try_parse_from(&["test", "--port", "port_id", "--chan", "channel-07", "--seq", "42"]).is_err()) + assert!(QueryPacketCommitmentCmd::try_parse_from(&[ + "test", + "--port", + "port_id", + "--channel", + "channel-07", + "--sequence", + "42" + ]) + .is_err()) } } diff --git a/relayer-cli/src/commands/query/packet/commitments.rs b/relayer-cli/src/commands/query/packet/commitments.rs index 897aa34441..f730245f25 100644 --- a/relayer-cli/src/commands/query/packet/commitments.rs +++ b/relayer-cli/src/commands/query/packet/commitments.rs @@ -24,6 +24,7 @@ pub struct QueryPacketCommitmentsCmd { long = "chain", required = true, value_name = "CHAIN_ID", + help_heading = "FLAGS", help = "Identifier of the chain to query" )] chain_id: ChainId, @@ -32,15 +33,17 @@ pub struct QueryPacketCommitmentsCmd { long = "port", required = true, value_name = "PORT_ID", + help_heading = "FLAGS", help = "Identifier of the port to query" )] port_id: PortId, #[clap( long = "channel", - alias = "chan", + visible_alias = "chan", required = true, value_name = "CHANNEL_ID", + help_heading = "FLAGS", help = "Identifier of the channel to query" )] channel_id: ChannelId, @@ -80,28 +83,77 @@ mod tests { use std::str::FromStr; use abscissa_core::clap::Parser; - use ibc::core::ics24_host::identifier::{ChainId, PortId, ChannelId}; + use ibc::core::ics24_host::identifier::{ChainId, ChannelId, PortId}; #[test] fn test_query_packet_commitments() { assert_eq!( - QueryPacketCommitmentsCmd{ chain_id: ChainId::from_string("chain_id"), port_id: PortId::from_str("port_id").unwrap(), channel_id: ChannelId::from_str("channel-07").unwrap() }, - QueryPacketCommitmentsCmd::parse_from(&["test", "--chain", "chain_id", "--port", "port_id", "--chan", "channel-07"]) + QueryPacketCommitmentsCmd { + chain_id: ChainId::from_string("chain_id"), + port_id: PortId::from_str("port_id").unwrap(), + channel_id: ChannelId::from_str("channel-07").unwrap() + }, + QueryPacketCommitmentsCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--port", + "port_id", + "--channel", + "channel-07" + ]) + ) + } + + #[test] + fn test_query_packet_commitments_chan_alias() { + assert_eq!( + QueryPacketCommitmentsCmd { + chain_id: ChainId::from_string("chain_id"), + port_id: PortId::from_str("port_id").unwrap(), + channel_id: ChannelId::from_str("channel-07").unwrap() + }, + QueryPacketCommitmentsCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--port", + "port_id", + "--chan", + "channel-07" + ]) ) } #[test] fn test_query_packet_commitments_no_chan() { - assert!(QueryPacketCommitmentsCmd::try_parse_from(&["test", "--chain", "chain_id", "--port", "port_id"]).is_err()) + assert!(QueryPacketCommitmentsCmd::try_parse_from(&[ + "test", "--chain", "chain_id", "--port", "port_id" + ]) + .is_err()) } #[test] fn test_query_packet_commitments_no_port() { - assert!(QueryPacketCommitmentsCmd::try_parse_from(&["test", "--chain", "chain_id", "--chan", "channel-07"]).is_err()) + assert!(QueryPacketCommitmentsCmd::try_parse_from(&[ + "test", + "--chain", + "chain_id", + "--channel", + "channel-07" + ]) + .is_err()) } #[test] fn test_query_packet_commitments_no_chain() { - assert!(QueryPacketCommitmentsCmd::try_parse_from(&["test", "--port", "port_id", "--chan", "channel-07"]).is_err()) + assert!(QueryPacketCommitmentsCmd::try_parse_from(&[ + "test", + "--port", + "port_id", + "--channel", + "channel-07" + ]) + .is_err()) } } diff --git a/relayer-cli/src/commands/query/packet/pending.rs b/relayer-cli/src/commands/query/packet/pending.rs index bc78ffdede..0868b9c899 100644 --- a/relayer-cli/src/commands/query/packet/pending.rs +++ b/relayer-cli/src/commands/query/packet/pending.rs @@ -35,6 +35,7 @@ pub struct QueryPendingPacketsCmd { long = "chain", required = true, value_name = "CHAIN_ID", + help_heading = "FLAGS", help = "Identifier of the chain at one end of the channel" )] chain_id: ChainId, @@ -43,15 +44,17 @@ pub struct QueryPendingPacketsCmd { long = "port", required = true, value_name = "PORT_ID", + help_heading = "FLAGS", help = "Port identifier on the chain given by " )] port_id: PortId, #[clap( long = "channel", - alias = "chan", + visible_alias = "chan", required = true, value_name = "CHANNEL_ID", + help_heading = "FLAGS", help = "Channel identifier on the chain given by " )] channel_id: ChannelId, @@ -108,28 +111,77 @@ mod tests { use std::str::FromStr; use abscissa_core::clap::Parser; - use ibc::core::ics24_host::identifier::{ChainId, PortId, ChannelId}; + use ibc::core::ics24_host::identifier::{ChainId, ChannelId, PortId}; #[test] fn test_query_packet_pending() { assert_eq!( - QueryPendingPacketsCmd{ chain_id: ChainId::from_string("chain_id"), port_id: PortId::from_str("port_id").unwrap(), channel_id: ChannelId::from_str("channel-07").unwrap() }, - QueryPendingPacketsCmd::parse_from(&["test", "--chain", "chain_id", "--port", "port_id", "--chan", "channel-07"]) + QueryPendingPacketsCmd { + chain_id: ChainId::from_string("chain_id"), + port_id: PortId::from_str("port_id").unwrap(), + channel_id: ChannelId::from_str("channel-07").unwrap() + }, + QueryPendingPacketsCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--port", + "port_id", + "--channel", + "channel-07" + ]) + ) + } + + #[test] + fn test_query_packet_pending_chan_alias() { + assert_eq!( + QueryPendingPacketsCmd { + chain_id: ChainId::from_string("chain_id"), + port_id: PortId::from_str("port_id").unwrap(), + channel_id: ChannelId::from_str("channel-07").unwrap() + }, + QueryPendingPacketsCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--port", + "port_id", + "--chan", + "channel-07" + ]) ) } #[test] fn test_query_packet_pending_no_chan() { - assert!(QueryPendingPacketsCmd::try_parse_from(&["test", "--chain", "chain_id", "--port", "port_id"]).is_err()) + assert!(QueryPendingPacketsCmd::try_parse_from(&[ + "test", "--chain", "chain_id", "--port", "port_id" + ]) + .is_err()) } #[test] fn test_query_packet_pending_no_port() { - assert!(QueryPendingPacketsCmd::try_parse_from(&["test", "--chain", "chain_id", "--chan", "channel-07"]).is_err()) + assert!(QueryPendingPacketsCmd::try_parse_from(&[ + "test", + "--chain", + "chain_id", + "--channel", + "channel-07" + ]) + .is_err()) } #[test] fn test_query_packet_pending_no_chain() { - assert!(QueryPendingPacketsCmd::try_parse_from(&["test", "--port", "port_id", "--chan", "channel-07"]).is_err()) + assert!(QueryPendingPacketsCmd::try_parse_from(&[ + "test", + "--port", + "port_id", + "--channel", + "channel-07" + ]) + .is_err()) } } diff --git a/relayer-cli/src/commands/query/packet/unreceived_acks.rs b/relayer-cli/src/commands/query/packet/unreceived_acks.rs index 6cc535c390..e1119fa35c 100644 --- a/relayer-cli/src/commands/query/packet/unreceived_acks.rs +++ b/relayer-cli/src/commands/query/packet/unreceived_acks.rs @@ -21,6 +21,7 @@ pub struct QueryUnreceivedAcknowledgementCmd { long = "chain", required = true, value_name = "CHAIN_ID", + help_heading = "FLAGS", help = "Identifier of the chain to query the unreceived acknowledgments" )] chain_id: ChainId, @@ -29,15 +30,17 @@ pub struct QueryUnreceivedAcknowledgementCmd { long = "port", required = true, value_name = "PORT_ID", + help_heading = "FLAGS", help = "Port identifier" )] port_id: PortId, #[clap( long = "channel", - alias = "chan", + visible_alias = "chan", required = true, value_name = "CHANNEL_ID", + help_heading = "FLAGS", help = "Channel identifier" )] channel_id: ChannelId, @@ -82,28 +85,77 @@ mod tests { use std::str::FromStr; use abscissa_core::clap::Parser; - use ibc::core::ics24_host::identifier::{ChainId, PortId, ChannelId}; + use ibc::core::ics24_host::identifier::{ChainId, ChannelId, PortId}; #[test] fn test_query_packet_unreceived_acks() { assert_eq!( - QueryUnreceivedAcknowledgementCmd{ chain_id: ChainId::from_string("chain_id"), port_id: PortId::from_str("port_id").unwrap(), channel_id: ChannelId::from_str("channel-07").unwrap() }, - QueryUnreceivedAcknowledgementCmd::parse_from(&["test", "--chain", "chain_id", "--port", "port_id", "--chan", "channel-07"]) + QueryUnreceivedAcknowledgementCmd { + chain_id: ChainId::from_string("chain_id"), + port_id: PortId::from_str("port_id").unwrap(), + channel_id: ChannelId::from_str("channel-07").unwrap() + }, + QueryUnreceivedAcknowledgementCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--port", + "port_id", + "--channel", + "channel-07" + ]) + ) + } + + #[test] + fn test_query_packet_unreceived_acks_chan_alias() { + assert_eq!( + QueryUnreceivedAcknowledgementCmd { + chain_id: ChainId::from_string("chain_id"), + port_id: PortId::from_str("port_id").unwrap(), + channel_id: ChannelId::from_str("channel-07").unwrap() + }, + QueryUnreceivedAcknowledgementCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--port", + "port_id", + "--chan", + "channel-07" + ]) ) } #[test] fn test_query_packet_unreceived_acks_no_chan() { - assert!(QueryUnreceivedAcknowledgementCmd::try_parse_from(&["test", "--chain", "chain_id", "--port", "port_id"]).is_err()) + assert!(QueryUnreceivedAcknowledgementCmd::try_parse_from(&[ + "test", "--chain", "chain_id", "--port", "port_id" + ]) + .is_err()) } #[test] fn test_query_packet_unreceived_acks_no_port() { - assert!(QueryUnreceivedAcknowledgementCmd::try_parse_from(&["test", "--chain", "chain_id", "--chan", "channel-07"]).is_err()) + assert!(QueryUnreceivedAcknowledgementCmd::try_parse_from(&[ + "test", + "--chain", + "chain_id", + "--channel", + "channel-07" + ]) + .is_err()) } #[test] fn test_query_packet_unreceived_acks_no_chain() { - assert!(QueryUnreceivedAcknowledgementCmd::try_parse_from(&["test", "--port", "port_id", "--chan", "channel-07"]).is_err()) + assert!(QueryUnreceivedAcknowledgementCmd::try_parse_from(&[ + "test", + "--port", + "port_id", + "--channel", + "channel-07" + ]) + .is_err()) } } diff --git a/relayer-cli/src/commands/query/packet/unreceived_packets.rs b/relayer-cli/src/commands/query/packet/unreceived_packets.rs index b6dd551e94..fea8bb266c 100644 --- a/relayer-cli/src/commands/query/packet/unreceived_packets.rs +++ b/relayer-cli/src/commands/query/packet/unreceived_packets.rs @@ -21,6 +21,7 @@ pub struct QueryUnreceivedPacketsCmd { long = "chain", required = true, value_name = "CHAIN_ID", + help_heading = "FLAGS", help = "Identifier of the chain for the unreceived sequences" )] chain_id: ChainId, @@ -29,15 +30,17 @@ pub struct QueryUnreceivedPacketsCmd { long = "port", required = true, value_name = "PORT_ID", + help_heading = "FLAGS", help = "Port identifier" )] port_id: PortId, #[clap( long = "channel", - alias = "chan", + visible_alias = "chan", required = true, value_name = "CHANNEL_ID", + help_heading = "FLAGS", help = "Channel identifier" )] channel_id: ChannelId, @@ -82,28 +85,77 @@ mod tests { use std::str::FromStr; use abscissa_core::clap::Parser; - use ibc::core::ics24_host::identifier::{ChainId, PortId, ChannelId}; + use ibc::core::ics24_host::identifier::{ChainId, ChannelId, PortId}; #[test] fn test_query_packet_unreceived_packets() { assert_eq!( - QueryUnreceivedPacketsCmd{ chain_id: ChainId::from_string("chain_id"), port_id: PortId::from_str("port_id").unwrap(), channel_id: ChannelId::from_str("channel-07").unwrap() }, - QueryUnreceivedPacketsCmd::parse_from(&["test", "--chain", "chain_id", "--port", "port_id", "--chan", "channel-07"]) + QueryUnreceivedPacketsCmd { + chain_id: ChainId::from_string("chain_id"), + port_id: PortId::from_str("port_id").unwrap(), + channel_id: ChannelId::from_str("channel-07").unwrap() + }, + QueryUnreceivedPacketsCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--port", + "port_id", + "--channel", + "channel-07" + ]) + ) + } + + #[test] + fn test_query_packet_unreceived_packets_chan_alias() { + assert_eq!( + QueryUnreceivedPacketsCmd { + chain_id: ChainId::from_string("chain_id"), + port_id: PortId::from_str("port_id").unwrap(), + channel_id: ChannelId::from_str("channel-07").unwrap() + }, + QueryUnreceivedPacketsCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--port", + "port_id", + "--chan", + "channel-07" + ]) ) } #[test] fn test_query_packet_unreceived_packets_no_chan() { - assert!(QueryUnreceivedPacketsCmd::try_parse_from(&["test", "--chain", "chain_id", "--port", "port_id"]).is_err()) + assert!(QueryUnreceivedPacketsCmd::try_parse_from(&[ + "test", "--chain", "chain_id", "--port", "port_id" + ]) + .is_err()) } #[test] fn test_query_packet_unreceived_packets_no_port() { - assert!(QueryUnreceivedPacketsCmd::try_parse_from(&["test", "--chain", "chain_id", "--chan", "channel-07"]).is_err()) + assert!(QueryUnreceivedPacketsCmd::try_parse_from(&[ + "test", + "--chain", + "chain_id", + "--channel", + "channel-07" + ]) + .is_err()) } #[test] fn test_query_packet_unreceived_packets_no_chain() { - assert!(QueryUnreceivedPacketsCmd::try_parse_from(&["test", "--port", "port_id", "--chan", "channel-07"]).is_err()) + assert!(QueryUnreceivedPacketsCmd::try_parse_from(&[ + "test", + "--port", + "port_id", + "--channel", + "channel-07" + ]) + .is_err()) } } diff --git a/relayer-cli/src/commands/query/transfer/denom_trace.rs b/relayer-cli/src/commands/query/transfer/denom_trace.rs index 60ab538bc2..61dc123ff3 100644 --- a/relayer-cli/src/commands/query/transfer/denom_trace.rs +++ b/relayer-cli/src/commands/query/transfer/denom_trace.rs @@ -17,10 +17,20 @@ use crate::conclude::{exit_with_unrecoverable_error, json, Output}; /// If successful the the base denomination and the path will be displayed. #[derive(Clone, Command, Debug, Parser, PartialEq)] pub struct DenomTraceCmd { - #[clap(long = "chain", required = true, help = "Identifier of the chain")] + #[clap( + long = "chain", + required = true, + help_heading = "FLAGS", + help = "Identifier of the chain" + )] chain_id: ChainId, - #[clap(long = "hash", required = true, help = "Trace hash to query")] + #[clap( + long = "hash", + required = true, + help_heading = "FLAGS", + help = "Trace hash to query" + )] hash: String, } @@ -57,7 +67,10 @@ mod tests { #[test] fn test_transfer_denom_trace() { assert_eq!( - DenomTraceCmd{ chain_id: ChainId::from_string("chain_id"), hash: "abcdefg".to_owned() }, + DenomTraceCmd { + chain_id: ChainId::from_string("chain_id"), + hash: "abcdefg".to_owned() + }, DenomTraceCmd::parse_from(&["test", "--chain", "chain_id", "--hash", "abcdefg"]) ) } @@ -71,4 +84,4 @@ mod tests { fn test_transfer_denom_trace_no_chain() { assert!(DenomTraceCmd::try_parse_from(&["test", "--hash", "abcdefg"]).is_err()) } -} \ No newline at end of file +} diff --git a/relayer-cli/src/commands/query/tx/events.rs b/relayer-cli/src/commands/query/tx/events.rs index 60da2306ea..786c4e0baf 100644 --- a/relayer-cli/src/commands/query/tx/events.rs +++ b/relayer-cli/src/commands/query/tx/events.rs @@ -23,6 +23,7 @@ pub struct QueryTxEventsCmd { long = "chain", required = true, value_name = "CHAIN_ID", + help_heading = "FLAGS", help = "Identifier of the chain to query" )] chain_id: ChainId, @@ -31,6 +32,7 @@ pub struct QueryTxEventsCmd { long = "hash", required = true, value_name = "HASH", + help_heading = "FLAGS", help = "Transaction hash to query" )] hash: String, @@ -71,7 +73,10 @@ mod tests { #[test] fn test_query_tx_events() { assert_eq!( - QueryTxEventsCmd{ chain_id: ChainId::from_string("chain_id"), hash: "abcdefg".to_owned() }, + QueryTxEventsCmd { + chain_id: ChainId::from_string("chain_id"), + hash: "abcdefg".to_owned() + }, QueryTxEventsCmd::parse_from(&["test", "--chain", "chain_id", "--hash", "abcdefg"]) ) } diff --git a/relayer-cli/src/commands/start.rs b/relayer-cli/src/commands/start.rs index cf2a1d69c1..cf440761c3 100644 --- a/relayer-cli/src/commands/start.rs +++ b/relayer-cli/src/commands/start.rs @@ -197,7 +197,7 @@ mod tests { #[test] fn test_start_required_only() { assert_eq!( - StartCmd{ full_scan: false }, + StartCmd { full_scan: false }, StartCmd::parse_from(&["test"]) ) } @@ -205,8 +205,8 @@ mod tests { #[test] fn test_start_full_scan() { assert_eq!( - StartCmd{ full_scan: true }, + StartCmd { full_scan: true }, StartCmd::parse_from(&["test", "--full-scan"]) ) } -} \ No newline at end of file +} diff --git a/relayer-cli/src/commands/tx/client.rs b/relayer-cli/src/commands/tx/client.rs index 82d94dadb2..b580ff1042 100644 --- a/relayer-cli/src/commands/tx/client.rs +++ b/relayer-cli/src/commands/tx/client.rs @@ -21,12 +21,13 @@ use crate::cli_utils::{spawn_chain_runtime, spawn_chain_runtime_generic, ChainHa use crate::conclude::{exit_with_unrecoverable_error, Output}; use crate::error::Error; -#[derive(Clone, Command, Debug, Parser)] +#[derive(Clone, Command, Debug, Parser, PartialEq)] pub struct TxCreateClientCmd { #[clap( long = "host-chain", required = true, value_name = "HOST_CHAIN_ID", + help_heading = "FLAGS", help = "Identifier of the chain that hosts the client" )] dst_chain_id: ChainId, @@ -35,6 +36,7 @@ pub struct TxCreateClientCmd { long = "reference-chain", required = true, value_name = "REFERENCE_CHAIN_ID", + help_heading = "FLAGS", help = "Identifier of the chain targeted by the client" )] src_chain_id: ChainId, @@ -107,6 +109,7 @@ pub struct TxUpdateClientCmd { long = "host-chain", required = true, value_name = "HOST_CHAIN_ID", + help_heading = "FLAGS", help = "Identifier of the chain that hosts the client" )] dst_chain_id: ChainId, @@ -115,6 +118,7 @@ pub struct TxUpdateClientCmd { long = "client", required = true, value_name = "CLIENT_ID", + help_heading = "FLAGS", help = "Identifier of the chain targeted by the client" )] dst_client_id: ClientId, @@ -187,12 +191,13 @@ impl Runnable for TxUpdateClientCmd { } } -#[derive(Clone, Command, Debug, Parser)] +#[derive(Clone, Command, Debug, Parser, PartialEq)] pub struct TxUpgradeClientCmd { #[clap( long = "host-chain", required = true, value_name = "HOST_CHAIN_ID", + help_heading = "FLAGS", help = "Identifier of the chain that hosts the client" )] chain_id: ChainId, @@ -201,6 +206,7 @@ pub struct TxUpgradeClientCmd { long = "client", required = true, value_name = "CLIENT_ID", + help_heading = "FLAGS", help = "Identifier of the client to be upgraded" )] client_id: ClientId, @@ -266,12 +272,13 @@ impl Runnable for TxUpgradeClientCmd { } } -#[derive(Clone, Command, Debug, Parser)] +#[derive(Clone, Command, Debug, Parser, PartialEq)] pub struct TxUpgradeClientsCmd { #[clap( long = "reference-chain", required = true, value_name = "REFERENCE_CHAIN_ID", + help_heading = "FLAGS", help = "Identifier of the chain that underwent an upgrade; all clients targeting this chain will be upgraded" )] src_chain_id: ChainId, @@ -455,7 +462,10 @@ impl OutputBuffer { #[cfg(test)] mod tests { - use super::{parse_trust_threshold, TxCreateClientCmd, TxUpdateClientCmd, TxUpgradeClientCmd, TxUpgradeClientsCmd}; + use super::{ + parse_trust_threshold, TxCreateClientCmd, TxUpdateClientCmd, TxUpgradeClientCmd, + TxUpgradeClientsCmd, + }; use std::str::FromStr; @@ -482,117 +492,323 @@ mod tests { #[test] fn test_create_client_required_only() { assert_eq!( - TxCreateClientCmd{ dst_chain_id: ChainId::from_string("host_chain"), src_chain_id: ChainId::from_string("reference_chain"), clock_drift: None, trusting_period: None, trust_threshold: None }, - TxCreateClientCmd::parse_from(&["test", "--host-chain", "host_chain", "--reference-chain", "reference_chain"]) + TxCreateClientCmd { + dst_chain_id: ChainId::from_string("host_chain"), + src_chain_id: ChainId::from_string("reference_chain"), + clock_drift: None, + trusting_period: None, + trust_threshold: None + }, + TxCreateClientCmd::parse_from(&[ + "test", + "--host-chain", + "host_chain", + "--reference-chain", + "reference_chain" + ]) ) } #[test] fn test_create_client_clock_drift() { assert_eq!( - TxCreateClientCmd{ dst_chain_id: ChainId::from_string("host_chain"), src_chain_id: ChainId::from_string("reference_chain"), clock_drift: Some("5s".parse::().unwrap()), trusting_period: None, trust_threshold: None }, - TxCreateClientCmd::parse_from(&["test", "--host-chain", "host_chain", "--reference-chain", "reference_chain", "--clock-drift", "5sec"]) + TxCreateClientCmd { + dst_chain_id: ChainId::from_string("host_chain"), + src_chain_id: ChainId::from_string("reference_chain"), + clock_drift: Some("5s".parse::().unwrap()), + trusting_period: None, + trust_threshold: None + }, + TxCreateClientCmd::parse_from(&[ + "test", + "--host-chain", + "host_chain", + "--reference-chain", + "reference_chain", + "--clock-drift", + "5sec" + ]) ); assert_eq!( - TxCreateClientCmd{ dst_chain_id: ChainId::from_string("host_chain"), src_chain_id: ChainId::from_string("reference_chain"), clock_drift: Some("3s".parse::().unwrap()), trusting_period: None, trust_threshold: None }, - TxCreateClientCmd::parse_from(&["test", "--host-chain", "host_chain", "--reference-chain", "reference_chain", "--clock-drift", "3s"]) + TxCreateClientCmd { + dst_chain_id: ChainId::from_string("host_chain"), + src_chain_id: ChainId::from_string("reference_chain"), + clock_drift: Some("3s".parse::().unwrap()), + trusting_period: None, + trust_threshold: None + }, + TxCreateClientCmd::parse_from(&[ + "test", + "--host-chain", + "host_chain", + "--reference-chain", + "reference_chain", + "--clock-drift", + "3s" + ]) ); } #[test] fn test_create_client_trusting_period() { assert_eq!( - TxCreateClientCmd{ dst_chain_id: ChainId::from_string("host_chain"), src_chain_id: ChainId::from_string("reference_chain"), clock_drift: None, trusting_period: Some("5s".parse::().unwrap()), trust_threshold: None }, - TxCreateClientCmd::parse_from(&["test", "--host-chain", "host_chain", "--reference-chain", "reference_chain", "--trusting-period", "5sec"]) + TxCreateClientCmd { + dst_chain_id: ChainId::from_string("host_chain"), + src_chain_id: ChainId::from_string("reference_chain"), + clock_drift: None, + trusting_period: Some("5s".parse::().unwrap()), + trust_threshold: None + }, + TxCreateClientCmd::parse_from(&[ + "test", + "--host-chain", + "host_chain", + "--reference-chain", + "reference_chain", + "--trusting-period", + "5sec" + ]) ); assert_eq!( - TxCreateClientCmd{ dst_chain_id: ChainId::from_string("host_chain"), src_chain_id: ChainId::from_string("reference_chain"), clock_drift: None, trusting_period: Some("3s".parse::().unwrap()), trust_threshold: None }, - TxCreateClientCmd::parse_from(&["test", "--host-chain", "host_chain", "--reference-chain", "reference_chain", "--trusting-period", "3s"]) + TxCreateClientCmd { + dst_chain_id: ChainId::from_string("host_chain"), + src_chain_id: ChainId::from_string("reference_chain"), + clock_drift: None, + trusting_period: Some("3s".parse::().unwrap()), + trust_threshold: None + }, + TxCreateClientCmd::parse_from(&[ + "test", + "--host-chain", + "host_chain", + "--reference-chain", + "reference_chain", + "--trusting-period", + "3s" + ]) ); } #[test] fn test_create_client_trust_threshold() { assert_eq!( - TxCreateClientCmd{ dst_chain_id: ChainId::from_string("host_chain"), src_chain_id: ChainId::from_string("reference_chain"), clock_drift: None, trusting_period: None, trust_threshold: Some(TrustThreshold::new(1, 2).unwrap()) }, - TxCreateClientCmd::parse_from(&["test", "--host-chain", "host_chain", "--reference-chain", "reference_chain", "--trust-threshold", "1/2"]) + TxCreateClientCmd { + dst_chain_id: ChainId::from_string("host_chain"), + src_chain_id: ChainId::from_string("reference_chain"), + clock_drift: None, + trusting_period: None, + trust_threshold: Some(TrustThreshold::new(1, 2).unwrap()) + }, + TxCreateClientCmd::parse_from(&[ + "test", + "--host-chain", + "host_chain", + "--reference-chain", + "reference_chain", + "--trust-threshold", + "1/2" + ]) ) } #[test] fn test_create_client_all_options() { assert_eq!( - TxCreateClientCmd{ dst_chain_id: ChainId::from_string("host_chain"), src_chain_id: ChainId::from_string("reference_chain"), clock_drift: Some("5s".parse::().unwrap()), trusting_period: Some("3s".parse::().unwrap()), trust_threshold: Some(TrustThreshold::new(1, 2).unwrap()) }, - TxCreateClientCmd::parse_from(&["test", "--host-chain", "host_chain", "--reference-chain", "reference_chain", "--clock-drift", "5sec", "--trusting-period", "3s", "--trust-threshold", "1/2"]) + TxCreateClientCmd { + dst_chain_id: ChainId::from_string("host_chain"), + src_chain_id: ChainId::from_string("reference_chain"), + clock_drift: Some("5s".parse::().unwrap()), + trusting_period: Some("3s".parse::().unwrap()), + trust_threshold: Some(TrustThreshold::new(1, 2).unwrap()) + }, + TxCreateClientCmd::parse_from(&[ + "test", + "--host-chain", + "host_chain", + "--reference-chain", + "reference_chain", + "--clock-drift", + "5sec", + "--trusting-period", + "3s", + "--trust-threshold", + "1/2" + ]) ) } #[test] fn test_create_client_no_host_chain() { - assert!(TxCreateClientCmd::try_parse_from(&["test", "--reference-chain", "reference_chain", "--clock-drift", "5sec", "--trusting-period", "3s", "--trust-threshold", "1/2"]).is_err()) + assert!(TxCreateClientCmd::try_parse_from(&[ + "test", + "--reference-chain", + "reference_chain", + "--clock-drift", + "5sec", + "--trusting-period", + "3s", + "--trust-threshold", + "1/2" + ]) + .is_err()) } #[test] fn test_create_client_no_reference_chain() { - assert!(TxCreateClientCmd::try_parse_from(&["test", "--host-chain", "host_chain", "--clock-drift", "5sec", "--trusting-period", "3s", "--trust-threshold", "1/2"]).is_err()) + assert!(TxCreateClientCmd::try_parse_from(&[ + "test", + "--host-chain", + "host_chain", + "--clock-drift", + "5sec", + "--trusting-period", + "3s", + "--trust-threshold", + "1/2" + ]) + .is_err()) } #[test] fn test_create_client_no_chain() { - assert!(TxCreateClientCmd::try_parse_from(&["test", "--clock-drift", "5sec", "--trusting-period", "3s", "--trust-threshold", "1/2"]).is_err()) + assert!(TxCreateClientCmd::try_parse_from(&[ + "test", + "--clock-drift", + "5sec", + "--trusting-period", + "3s", + "--trust-threshold", + "1/2" + ]) + .is_err()) } #[test] fn test_update_client_required_only() { assert_eq!( - TxUpdateClientCmd{ dst_chain_id: ChainId::from_string("host_chain"), dst_client_id: ClientId::from_str("client_to_update").unwrap(), target_height: None, trusted_height: None }, - TxUpdateClientCmd::parse_from(&["test", "--host-chain", "host_chain", "--client", "client_to_update"]) + TxUpdateClientCmd { + dst_chain_id: ChainId::from_string("host_chain"), + dst_client_id: ClientId::from_str("client_to_update").unwrap(), + target_height: None, + trusted_height: None + }, + TxUpdateClientCmd::parse_from(&[ + "test", + "--host-chain", + "host_chain", + "--client", + "client_to_update" + ]) ) } #[test] fn test_update_client_height() { assert_eq!( - TxUpdateClientCmd{ dst_chain_id: ChainId::from_string("host_chain"), dst_client_id: ClientId::from_str("client_to_update").unwrap(), target_height: Some(42), trusted_height: None }, - TxUpdateClientCmd::parse_from(&["test", "--host-chain", "host_chain", "--client", "client_to_update", "--height", "42"]) + TxUpdateClientCmd { + dst_chain_id: ChainId::from_string("host_chain"), + dst_client_id: ClientId::from_str("client_to_update").unwrap(), + target_height: Some(42), + trusted_height: None + }, + TxUpdateClientCmd::parse_from(&[ + "test", + "--host-chain", + "host_chain", + "--client", + "client_to_update", + "--height", + "42" + ]) ) } #[test] fn test_update_client_trusted_height() { assert_eq!( - TxUpdateClientCmd{ dst_chain_id: ChainId::from_string("host_chain"), dst_client_id: ClientId::from_str("client_to_update").unwrap(), target_height: None, trusted_height: Some(42) }, - TxUpdateClientCmd::parse_from(&["test", "--host-chain", "host_chain", "--client", "client_to_update", "--trusted-height", "42"]) + TxUpdateClientCmd { + dst_chain_id: ChainId::from_string("host_chain"), + dst_client_id: ClientId::from_str("client_to_update").unwrap(), + target_height: None, + trusted_height: Some(42) + }, + TxUpdateClientCmd::parse_from(&[ + "test", + "--host-chain", + "host_chain", + "--client", + "client_to_update", + "--trusted-height", + "42" + ]) ) } #[test] fn test_update_client_all_options() { assert_eq!( - TxUpdateClientCmd{ dst_chain_id: ChainId::from_string("host_chain"), dst_client_id: ClientId::from_str("client_to_update").unwrap(), target_height: Some(21), trusted_height: Some(42) }, - TxUpdateClientCmd::parse_from(&["test", "--host-chain", "host_chain", "--client", "client_to_update", "--height", "21", "--trusted-height", "42"]) + TxUpdateClientCmd { + dst_chain_id: ChainId::from_string("host_chain"), + dst_client_id: ClientId::from_str("client_to_update").unwrap(), + target_height: Some(21), + trusted_height: Some(42) + }, + TxUpdateClientCmd::parse_from(&[ + "test", + "--host-chain", + "host_chain", + "--client", + "client_to_update", + "--height", + "21", + "--trusted-height", + "42" + ]) ) } #[test] fn test_update_client_no_chain() { - assert!( - TxUpdateClientCmd::try_parse_from(&["test", "--client", "client_to_update", "--height", "21", "--trusted-height", "42"]).is_err() - ) + assert!(TxUpdateClientCmd::try_parse_from(&[ + "test", + "--client", + "client_to_update", + "--height", + "21", + "--trusted-height", + "42" + ]) + .is_err()) } #[test] fn test_update_client_no_client() { - assert!( - TxUpdateClientCmd::try_parse_from(&["test", "--host-chain", "host_chain", "--height", "21", "--trusted-height", "42"]).is_err() - ) + assert!(TxUpdateClientCmd::try_parse_from(&[ + "test", + "--host-chain", + "host_chain", + "--height", + "21", + "--trusted-height", + "42" + ]) + .is_err()) } #[test] fn test_upgrade_client_required_only() { assert_eq!( - TxUpgradeClientCmd{ chain_id: ChainId::from_string("chain_id"), client_id: ClientId::from_str("client_to_upgrade").unwrap() }, - TxUpgradeClientCmd::parse_from(&["test", "--host-chain", "chain_id", "--client", "client_to_upgrade"]) + TxUpgradeClientCmd { + chain_id: ChainId::from_string("chain_id"), + client_id: ClientId::from_str("client_to_upgrade").unwrap() + }, + TxUpgradeClientCmd::parse_from(&[ + "test", + "--host-chain", + "chain_id", + "--client", + "client_to_upgrade" + ]) ) } @@ -605,23 +821,21 @@ mod tests { #[test] fn test_upgrade_client_no_client() { - assert!( - TxUpgradeClientCmd::try_parse_from(&["test", "--host-chain", "chain_id"]).is_err() - ) + assert!(TxUpgradeClientCmd::try_parse_from(&["test", "--host-chain", "chain_id"]).is_err()) } #[test] fn test_upgrade_clients_required_only() { assert_eq!( - TxUpgradeClientsCmd{ src_chain_id: ChainId::from_string("chain_id") }, + TxUpgradeClientsCmd { + src_chain_id: ChainId::from_string("chain_id") + }, TxUpgradeClientsCmd::parse_from(&["test", "--reference-chain", "chain_id"]) ) } #[test] fn test_upgrade_clients_no_chain() { - assert!( - TxUpgradeClientsCmd::try_parse_from(&["test"]).is_err() - ) + assert!(TxUpgradeClientsCmd::try_parse_from(&["test"]).is_err()) } } From ddd9913011f75ebb343ed5e5d54bb53217f617d8 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Wed, 29 Jun 2022 13:11:03 +0200 Subject: [PATCH 20/27] Improved 'override_usage' for commands with multiple usages --- relayer-cli/src/commands/create/channel.rs | 4 +++- relayer-cli/src/commands/create/connection.rs | 4 +++- relayer-cli/src/commands/keys/add.rs | 4 +++- relayer-cli/src/commands/keys/delete.rs | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/relayer-cli/src/commands/create/channel.rs b/relayer-cli/src/commands/create/channel.rs index f754eb057e..551db18a67 100644 --- a/relayer-cli/src/commands/create/channel.rs +++ b/relayer-cli/src/commands/create/channel.rs @@ -46,7 +46,9 @@ static HINT: &str = "Consider using the default invocation\n\nhermes create chan /// to the same connection. #[derive(Clone, Command, Debug, Parser, PartialEq)] #[clap( - override_usage = "hermes create channel [OPTIONS] --a-chain --a-connection --a-port --b-port \n\n hermes create channel [OPTIONS] --a-chain --b-chain --a-port --b-port --new-client-connection" + override_usage = "hermes create channel [OPTIONS] --a-chain --a-connection --a-port --b-port + + hermes create channel [OPTIONS] --a-chain --b-chain --a-port --b-port --new-client-connection" )] pub struct CreateChannelCommand { #[clap( diff --git a/relayer-cli/src/commands/create/connection.rs b/relayer-cli/src/commands/create/connection.rs index 7329a57539..dac7d034ac 100644 --- a/relayer-cli/src/commands/create/connection.rs +++ b/relayer-cli/src/commands/create/connection.rs @@ -15,7 +15,9 @@ use crate::conclude::{exit_with_unrecoverable_error, Output}; use crate::prelude::*; #[derive(Clone, Command, Debug, Parser, PartialEq)] -#[clap(override_usage("hermes create connection [OPTIONS] --a-chain --b-chain \n\n hermes create connection [OPTIONS] --a-chain --a-client --b-client "))] +#[clap(override_usage("hermes create connection [OPTIONS] --a-chain --b-chain + + hermes create connection [OPTIONS] --a-chain --a-client --b-client "))] pub struct CreateConnectionCommand { #[clap( long = "a-chain", diff --git a/relayer-cli/src/commands/keys/add.rs b/relayer-cli/src/commands/keys/add.rs index 24221a5419..7515d65441 100644 --- a/relayer-cli/src/commands/keys/add.rs +++ b/relayer-cli/src/commands/keys/add.rs @@ -32,7 +32,9 @@ use crate::conclude::Output; /// If successful the key will be created or restored, depending on which flag was given. #[derive(Clone, Command, Debug, Parser, PartialEq)] #[clap( - override_usage = "hermes keys add [OPTIONS] --chain --key-file \n\n hermes keys add [OPTIONS] --chain --mnemonic-file " + override_usage = "hermes keys add [OPTIONS] --chain --key-file + + hermes keys add [OPTIONS] --chain --mnemonic-file " )] pub struct KeysAddCmd { #[clap( diff --git a/relayer-cli/src/commands/keys/delete.rs b/relayer-cli/src/commands/keys/delete.rs index 243410c248..989ac037db 100644 --- a/relayer-cli/src/commands/keys/delete.rs +++ b/relayer-cli/src/commands/keys/delete.rs @@ -12,7 +12,9 @@ use crate::conclude::Output; #[derive(Clone, Command, Debug, Parser, PartialEq)] #[clap( - override_usage = "hermes keys delete --chain --key-name \n\n hermes keys delete --chain --all" + override_usage = "hermes keys delete --chain --key-name + + hermes keys delete --chain --all" )] pub struct KeysDeleteCmd { #[clap( From ea134e1e117a061fbde9b233a1e548c05a986dad Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Thu, 30 Jun 2022 11:47:12 +0200 Subject: [PATCH 21/27] Updated Hermes guide. Removed changes for issue #2349, they will be added in a separate PR. --- .../adr-010-unified-cli-arguments-hermes.md | 4 ++-- guide/src/commands/path-setup/channels.md | 11 ++++++----- guide/src/help.md | 12 ++++++++---- guide/src/installation.md | 6 +++--- .../local-chains/relay-paths/create-new-path.md | 2 +- .../local-chains/relay-paths/multiple-paths.md | 4 ++-- relayer-cli/src/commands/clear.rs | 3 --- relayer-cli/src/commands/completions.rs | 2 +- relayer-cli/src/commands/create/channel.rs | 15 ++------------- relayer-cli/src/commands/create/connection.rs | 7 ------- relayer-cli/src/commands/keys/add.rs | 8 -------- relayer-cli/src/commands/keys/balance.rs | 1 - relayer-cli/src/commands/keys/delete.rs | 8 -------- relayer-cli/src/commands/keys/list.rs | 1 - relayer-cli/src/commands/listen.rs | 3 +-- relayer-cli/src/commands/misbehaviour.rs | 2 -- relayer-cli/src/commands/query/channel.rs | 3 --- relayer-cli/src/commands/query/channel_client.rs | 3 --- relayer-cli/src/commands/query/channel_ends.rs | 3 --- relayer-cli/src/commands/query/channels.rs | 1 - relayer-cli/src/commands/query/client.rs | 9 --------- relayer-cli/src/commands/query/clients.rs | 1 - relayer-cli/src/commands/query/connection.rs | 4 ---- relayer-cli/src/commands/query/connections.rs | 1 - relayer-cli/src/commands/query/packet/ack.rs | 4 ---- relayer-cli/src/commands/query/packet/acks.rs | 3 --- .../src/commands/query/packet/commitment.rs | 4 ---- .../src/commands/query/packet/commitments.rs | 3 --- relayer-cli/src/commands/query/packet/pending.rs | 3 --- .../src/commands/query/packet/unreceived_acks.rs | 3 --- .../commands/query/packet/unreceived_packets.rs | 3 --- .../src/commands/query/transfer/denom_trace.rs | 2 -- relayer-cli/src/commands/query/tx/events.rs | 2 -- relayer-cli/src/commands/tx/client.rs | 7 ------- 34 files changed, 26 insertions(+), 122 deletions(-) diff --git a/docs/architecture/adr-010-unified-cli-arguments-hermes.md b/docs/architecture/adr-010-unified-cli-arguments-hermes.md index 8d98fe2053..639e0a21b3 100644 --- a/docs/architecture/adr-010-unified-cli-arguments-hermes.md +++ b/docs/architecture/adr-010-unified-cli-arguments-hermes.md @@ -53,8 +53,8 @@ The following commands are implemented, with the binary name `hermes` often omit * `create channel --a-chain --a-connection --a-port --b-port ` * Optional: `[--chan-version ] [--order ]` -* `create channel --a-chain --b-chain --a-port --b-port --new-client-conn` - * Optional: `[--chan-version ] [--order ]` +* `create channel --a-chain --b-chain --a-port --b-port --new-client-connection` + * Optional: `[--chan-version ] [--order ] [--yes]` ### Commands for keys diff --git a/guide/src/commands/path-setup/channels.md b/guide/src/commands/path-setup/channels.md index 975f5107fc..634e8fd89e 100644 --- a/guide/src/commands/path-setup/channels.md +++ b/guide/src/commands/path-setup/channels.md @@ -13,10 +13,10 @@ USAGE: hermes create channel [OPTIONS] --a-chain --a-port --b-port DESCRIPTION: - Create a new channel between two chains using a pre-existing connection. + Create a new channel between two chains. - Alternatively, create a new client and a new connection underlying the new channel if a pre-existing - connection is not provided. + Can create a new channel using a pre-existing connection or alternatively, create a new client and a + new connection underlying the new channel if a pre-existing connection is not provided. FLAGS: --a-chain Identifier of the side `a` chain for the new channel @@ -26,13 +26,14 @@ FLAGS: OPTIONS: --a-connection Identifier of the connection on chain `a` to use in creating - the new channel. + the new channel --b-chain Identifier of the side `b` chain for the new channel --chan-version The version for the new channel --new-client-connection Indicates that a new client and connection will be created underlying the new channel --order The channel ordering, valid options 'unordered' (default) and 'ordered' [default: ORDER_UNORDERED] + --yes Skip new_client_connection confirmation ``` ## Examples @@ -210,7 +211,7 @@ interactive prompt that pops up notifying you that a new client and a new connection will be initialized as part of the process: ```shell -hermes create channel --a-chain ibc-0 --b-chain ibc-1 --a-port transfer --b-port transfer --order unordered --new-client-conn +hermes create channel --a-chain ibc-0 --b-chain ibc-1 --a-port transfer --b-port transfer --order unordered --new-client-connection ``` ```json diff --git a/guide/src/help.md b/guide/src/help.md index a076612b70..8c09ea13c2 100644 --- a/guide/src/help.md +++ b/guide/src/help.md @@ -60,13 +60,15 @@ This can provide further specific guidance if we add additional parameters, e.g. hermes help create channel ``` -``` +```shell USAGE: hermes create channel [OPTIONS] --a-chain --a-port --b-port DESCRIPTION: - Create a new channel between two chains using a pre-existing connection. Alternatively, create a new - client and a new connection underlying the new channel if a pre-existing connection is not provided + Create a new channel between two chains. + + Can create a new channel using a pre-existing connection or alternatively, create a new client and a + new connection underlying the new channel if a pre-existing connection is not provided. FLAGS: --a-chain Identifier of the side `a` chain for the new channel @@ -74,14 +76,16 @@ FLAGS: --b-port Identifier of the side `b` port for the new channel OPTIONS: + --a-connection Identifier of the connection on chain `a` to use in creating - the new channel. + the new channel --b-chain Identifier of the side `b` chain for the new channel --chan-version The version for the new channel --new-client-connection Indicates that a new client and connection will be created underlying the new channel --order The channel ordering, valid options 'unordered' (default) and 'ordered' [default: ORDER_UNORDERED] + --yes Skip new_client_connection confirmation ``` Additionally, the `-h`/`--help` flags typical for CLI applications work on diff --git a/guide/src/installation.md b/guide/src/installation.md index 75f1fcac24..ee19666b4d 100644 --- a/guide/src/installation.md +++ b/guide/src/installation.md @@ -200,19 +200,19 @@ and any further necessary modifications to the shell's startup files. ### Bash ```sh -hermes completions bash > ~/.local/share/bash-completion/completions/hermes +hermes completions --shell bash > ~/.local/share/bash-completion/completions/hermes ``` On a MacOS installation with Homebrew `bash-completion` formula installed, use ```sh -hermes completions bash > $(brew --prefix)/etc/bash_completion.d/hermes.bash-completion +hermes completions --shell bash > $(brew --prefix)/etc/bash_completion.d/hermes.bash-completion ``` ### Zsh ```sh -hermes completions zsh > ~/.zfunc/_hermes +hermes completions --shell zsh > ~/.zfunc/_hermes ``` To make the shell load the script on initialization, add the directory to `fpath` diff --git a/guide/src/tutorials/local-chains/relay-paths/create-new-path.md b/guide/src/tutorials/local-chains/relay-paths/create-new-path.md index b6c2d3b456..c93b74671b 100644 --- a/guide/src/tutorials/local-chains/relay-paths/create-new-path.md +++ b/guide/src/tutorials/local-chains/relay-paths/create-new-path.md @@ -3,7 +3,7 @@ Perform client creation, connection and channel handshake to establish a new path between the `transfer` ports on `ibc-0` and `ibc-1` chains. ```shell -hermes create channel --a-chain ibc-0 --b-chain ibc-1 --a-port transfer --b-port transfer --new-client-conn +hermes create channel --a-chain ibc-0 --b-chain ibc-1 --a-port transfer --b-port transfer --new-client-connection ``` If all the handshakes are performed successfully you should see a message similar to the one below: diff --git a/guide/src/tutorials/local-chains/relay-paths/multiple-paths.md b/guide/src/tutorials/local-chains/relay-paths/multiple-paths.md index 69d8aa2c9b..20b747edb3 100644 --- a/guide/src/tutorials/local-chains/relay-paths/multiple-paths.md +++ b/guide/src/tutorials/local-chains/relay-paths/multiple-paths.md @@ -100,7 +100,7 @@ Follow the steps below to connect three chains together and relay packets betwee making an exception. Execute the following command: ```shell - hermes create channel --a-chain ibc-0 --b-chain ibc-1 --a-port transfer --b-port transfer --new-client-conn + hermes create channel --a-chain ibc-0 --b-chain ibc-1 --a-port transfer --b-port transfer --new-client-connection ``` Then respond 'yes' to the prompt that pops up. Once the command has run to @@ -166,7 +166,7 @@ Follow the steps below to connect three chains together and relay packets betwee previous invocation we used to create a channel between `ibc-0` and `ibc-1`: ```shell - hermes create channel --a-chain ibc-1 --b-chain ibc-2 --a-port transfer --b-port transfer --new-client-conn + hermes create channel --a-chain ibc-1 --b-chain ibc-2 --a-port transfer --b-port transfer --new-client-connection ``` ```json diff --git a/relayer-cli/src/commands/clear.rs b/relayer-cli/src/commands/clear.rs index 62864ed066..a185f0f351 100644 --- a/relayer-cli/src/commands/clear.rs +++ b/relayer-cli/src/commands/clear.rs @@ -27,7 +27,6 @@ pub struct ClearPacketsCmd { long = "chain", required = true, value_name = "CHAIN_ID", - help_heading = "FLAGS", help = "Identifier of the chain" )] chain_id: ChainId, @@ -36,7 +35,6 @@ pub struct ClearPacketsCmd { long = "port", required = true, value_name = "PORT_ID", - help_heading = "FLAGS", help = "Identifier of the port" )] port_id: PortId, @@ -46,7 +44,6 @@ pub struct ClearPacketsCmd { visible_alias = "chan", required = true, value_name = "CHANNEL_ID", - help_heading = "FLAGS", help = "Identifier of the channel" )] channel_id: ChannelId, diff --git a/relayer-cli/src/commands/completions.rs b/relayer-cli/src/commands/completions.rs index 41d0a79fd6..3130001fa4 100644 --- a/relayer-cli/src/commands/completions.rs +++ b/relayer-cli/src/commands/completions.rs @@ -7,7 +7,7 @@ use std::io; #[derive(Debug, Parser, PartialEq)] pub struct CompletionsCmd { - #[clap(long = "shell", value_name = "SHELL", arg_enum, help_heading = "FLAGS")] + #[clap(long = "shell", value_name = "SHELL", arg_enum)] shell: Shell, } diff --git a/relayer-cli/src/commands/create/channel.rs b/relayer-cli/src/commands/create/channel.rs index 551db18a67..96964ec951 100644 --- a/relayer-cli/src/commands/create/channel.rs +++ b/relayer-cli/src/commands/create/channel.rs @@ -45,17 +45,11 @@ static HINT: &str = "Consider using the default invocation\n\nhermes create chan /// chain A and chain B might refer to the connection with different names, they are actually referring /// to the same connection. #[derive(Clone, Command, Debug, Parser, PartialEq)] -#[clap( - override_usage = "hermes create channel [OPTIONS] --a-chain --a-connection --a-port --b-port - - hermes create channel [OPTIONS] --a-chain --b-chain --a-port --b-port --new-client-connection" -)] pub struct CreateChannelCommand { #[clap( long = "a-chain", required = true, value_name = "A_CHAIN_ID", - help_heading = "FLAGS", help = "Identifier of the side `a` chain for the new channel" )] chain_a: ChainId, @@ -66,7 +60,6 @@ pub struct CreateChannelCommand { required = true, requires = "new-client-connection", group = "b_chain_group", - help_heading = "FLAGS", help = "Identifier of the side `b` chain for the new channel" )] chain_b: Option, @@ -77,8 +70,7 @@ pub struct CreateChannelCommand { value_name = "A_CONNECTION_ID", required = true, groups = &["b_chain_group", "new_client_group"], - help_heading = "FLAGS", - help = "Identifier of the connection on chain `a` to use in creating the new channel." + help = "Identifier of the connection on chain `a` to use in creating the new channel" )] connection_a: Option, @@ -86,7 +78,6 @@ pub struct CreateChannelCommand { long = "a-port", required = true, value_name = "A_PORT_ID", - help_heading = "FLAGS", help = "Identifier of the side `a` port for the new channel" )] port_a: PortId, @@ -95,7 +86,6 @@ pub struct CreateChannelCommand { long = "b-port", required = true, value_name = "B_PORT_ID", - help_heading = "FLAGS", help = "Identifier of the side `b` port for the new channel" )] port_b: PortId, @@ -120,13 +110,12 @@ pub struct CreateChannelCommand { long = "new-client-connection", visible_alias = "new-client-conn", group = "new_client_group", - help_heading = "FLAGS", help = "Indicates that a new client and connection will be created underlying the new channel" )] new_client_connection: bool, #[clap( - long, + long = "yes", requires = "new-client-connection", help = "Skip new_client_connection confirmation" )] diff --git a/relayer-cli/src/commands/create/connection.rs b/relayer-cli/src/commands/create/connection.rs index dac7d034ac..f4d6fdbc2b 100644 --- a/relayer-cli/src/commands/create/connection.rs +++ b/relayer-cli/src/commands/create/connection.rs @@ -15,15 +15,11 @@ use crate::conclude::{exit_with_unrecoverable_error, Output}; use crate::prelude::*; #[derive(Clone, Command, Debug, Parser, PartialEq)] -#[clap(override_usage("hermes create connection [OPTIONS] --a-chain --b-chain - - hermes create connection [OPTIONS] --a-chain --a-client --b-client "))] pub struct CreateConnectionCommand { #[clap( long = "a-chain", required = true, value_name = "A_CHAIN_ID", - help_heading = "FLAGS", help = "Identifier of the side `a` chain for the new connection" )] chain_a_id: ChainId, @@ -33,7 +29,6 @@ pub struct CreateConnectionCommand { required = true, value_name = "B_CHAIN_ID", groups = &["a_client", "b_client"], - help_heading = "FLAGS", help = "Identifier of the side `b` chain for the new connection" )] chain_b_id: Option, @@ -43,7 +38,6 @@ pub struct CreateConnectionCommand { required = true, value_name = "A_CLIENT_ID", group = "a_client", - help_heading = "FLAGS", help = "Identifier of client hosted on chain `a`; default: None (creates a new client)" )] client_a: Option, @@ -53,7 +47,6 @@ pub struct CreateConnectionCommand { required = true, value_name = "B_CLIENT_ID", group = "b_client", - help_heading = "FLAGS", help = "Identifier of client hosted on chain `b`; default: None (creates a new client)" )] client_b: Option, diff --git a/relayer-cli/src/commands/keys/add.rs b/relayer-cli/src/commands/keys/add.rs index 7515d65441..2704271330 100644 --- a/relayer-cli/src/commands/keys/add.rs +++ b/relayer-cli/src/commands/keys/add.rs @@ -31,16 +31,10 @@ use crate::conclude::Output; /// The key-file and mnemonic-file flags can't be given at the same time, this will cause a terminating error. /// If successful the key will be created or restored, depending on which flag was given. #[derive(Clone, Command, Debug, Parser, PartialEq)] -#[clap( - override_usage = "hermes keys add [OPTIONS] --chain --key-file - - hermes keys add [OPTIONS] --chain --mnemonic-file " -)] pub struct KeysAddCmd { #[clap( long = "chain", required = true, - help_heading = "FLAGS", help = "Identifier of the chain" )] chain_id: ChainId, @@ -49,7 +43,6 @@ pub struct KeysAddCmd { long = "key-file", required = true, value_name = "KEY_FILE", - help_heading = "FLAGS", help = "Path to the key file", group = "add-restore" )] @@ -59,7 +52,6 @@ pub struct KeysAddCmd { long = "mnemonic-file", required = true, value_name = "MNEMONIC_FILE", - help_heading = "FLAGS", help = "Path to file containing mnemonic to restore the key from", group = "add-restore" )] diff --git a/relayer-cli/src/commands/keys/balance.rs b/relayer-cli/src/commands/keys/balance.rs index fea8a9ffc6..cd32bce391 100644 --- a/relayer-cli/src/commands/keys/balance.rs +++ b/relayer-cli/src/commands/keys/balance.rs @@ -23,7 +23,6 @@ pub struct KeyBalanceCmd { long = "chain", required = true, value_name = "CHAIN_ID", - help_heading = "FLAGS", help = "Identifier of the chain" )] chain_id: ChainId, diff --git a/relayer-cli/src/commands/keys/delete.rs b/relayer-cli/src/commands/keys/delete.rs index 989ac037db..a05f8b371e 100644 --- a/relayer-cli/src/commands/keys/delete.rs +++ b/relayer-cli/src/commands/keys/delete.rs @@ -11,17 +11,11 @@ use crate::application::app_config; use crate::conclude::Output; #[derive(Clone, Command, Debug, Parser, PartialEq)] -#[clap( - override_usage = "hermes keys delete --chain --key-name - - hermes keys delete --chain --all" -)] pub struct KeysDeleteCmd { #[clap( long = "chain", required = true, value_name = "CHAIN_ID", - help_heading = "FLAGS", help = "Identifier of the chain" )] chain_id: ChainId, @@ -31,7 +25,6 @@ pub struct KeysDeleteCmd { required = true, value_name = "KEY_NAME", group = "delete_mode", - help_heading = "FLAGS", help = "Name of the key" )] key_name: Option, @@ -40,7 +33,6 @@ pub struct KeysDeleteCmd { long = "all", required = true, group = "delete_mode", - help_heading = "FLAGS", help = "Delete all keys" )] all: bool, diff --git a/relayer-cli/src/commands/keys/list.rs b/relayer-cli/src/commands/keys/list.rs index 6f00ebe21f..8b06408772 100644 --- a/relayer-cli/src/commands/keys/list.rs +++ b/relayer-cli/src/commands/keys/list.rs @@ -18,7 +18,6 @@ pub struct KeysListCmd { long = "chain", required = true, value_name = "CHAIN_ID", - help_heading = "FLAGS", help = "Identifier of the chain" )] chain_id: ChainId, diff --git a/relayer-cli/src/commands/listen.rs b/relayer-cli/src/commands/listen.rs index dd4334b18e..f251a90542 100644 --- a/relayer-cli/src/commands/listen.rs +++ b/relayer-cli/src/commands/listen.rs @@ -64,8 +64,7 @@ pub struct ListenCmd { #[clap( long = "chain", required = true, - value_name = "CHAIN_ID", - help_heading = "FLAGS" + value_name = "CHAIN_ID" )] chain_id: ChainId, diff --git a/relayer-cli/src/commands/misbehaviour.rs b/relayer-cli/src/commands/misbehaviour.rs index aab02eace1..f2dab15cc5 100644 --- a/relayer-cli/src/commands/misbehaviour.rs +++ b/relayer-cli/src/commands/misbehaviour.rs @@ -20,7 +20,6 @@ pub struct MisbehaviourCmd { long = "chain", required = true, value_name = "CHAIN_ID", - help_heading = "FLAGS", help = "Identifier of the chain where client updates are monitored for misbehaviour" )] chain_id: ChainId, @@ -29,7 +28,6 @@ pub struct MisbehaviourCmd { long = "client", required = true, value_name = "CLIENT_ID", - help_heading = "FLAGS", help = "Identifier of the client to be monitored for misbehaviour" )] client_id: ClientId, diff --git a/relayer-cli/src/commands/query/channel.rs b/relayer-cli/src/commands/query/channel.rs index dfe0741069..c136c335eb 100644 --- a/relayer-cli/src/commands/query/channel.rs +++ b/relayer-cli/src/commands/query/channel.rs @@ -17,7 +17,6 @@ pub struct QueryChannelEndCmd { long = "chain", required = true, value_name = "CHAIN_ID", - help_heading = "FLAGS", help = "Identifier of the chain to query" )] chain_id: ChainId, @@ -26,7 +25,6 @@ pub struct QueryChannelEndCmd { long = "port", required = true, value_name = "PORT_ID", - help_heading = "FLAGS", help = "Identifier of the port to query" )] port_id: PortId, @@ -36,7 +34,6 @@ pub struct QueryChannelEndCmd { visible_alias = "chan", required = true, value_name = "CHANNEL_ID", - help_heading = "FLAGS", help = "Identifier of the channel to query" )] channel_id: ChannelId, diff --git a/relayer-cli/src/commands/query/channel_client.rs b/relayer-cli/src/commands/query/channel_client.rs index f52888bcbd..02212a35e3 100644 --- a/relayer-cli/src/commands/query/channel_client.rs +++ b/relayer-cli/src/commands/query/channel_client.rs @@ -20,7 +20,6 @@ pub struct QueryChannelClientCmd { long = "chain", required = true, value_name = "CHAIN_ID", - help_heading = "FLAGS", help = "Identifier of the chain to query" )] chain_id: ChainId, @@ -29,7 +28,6 @@ pub struct QueryChannelClientCmd { long = "port", required = true, value_name = "PORT_ID", - help_heading = "FLAGS", help = "Identifier of the port to query" )] port_id: PortId, @@ -39,7 +37,6 @@ pub struct QueryChannelClientCmd { visible_alias = "chan", required = true, value_name = "CHANNEL_ID", - help_heading = "FLAGS", help = "Identifier of the channel to query" )] channel_id: ChannelId, diff --git a/relayer-cli/src/commands/query/channel_ends.rs b/relayer-cli/src/commands/query/channel_ends.rs index 8c62fca955..4d38d90246 100644 --- a/relayer-cli/src/commands/query/channel_ends.rs +++ b/relayer-cli/src/commands/query/channel_ends.rs @@ -23,7 +23,6 @@ pub struct QueryChannelEndsCmd { long = "chain", required = true, value_name = "CHAIN_ID", - help_heading = "FLAGS", help = "Identifier of the chain to query" )] chain_id: ChainId, @@ -32,7 +31,6 @@ pub struct QueryChannelEndsCmd { long = "port", required = true, value_name = "PORT_ID", - help_heading = "FLAGS", help = "Identifier of the port to query" )] port_id: PortId, @@ -42,7 +40,6 @@ pub struct QueryChannelEndsCmd { visible_alias = "chan", required = true, value_name = "CHANNEL_ID", - help_heading = "FLAGS", help = "Identifier of the channel to query" )] channel_id: ChannelId, diff --git a/relayer-cli/src/commands/query/channels.rs b/relayer-cli/src/commands/query/channels.rs index 3e5970125c..1ab5335ba2 100644 --- a/relayer-cli/src/commands/query/channels.rs +++ b/relayer-cli/src/commands/query/channels.rs @@ -24,7 +24,6 @@ pub struct QueryChannelsCmd { long = "chain", required = true, value_name = "CHAIN_ID", - help_heading = "FLAGS", help = "Identifier of the chain to query" )] chain_id: ChainId, diff --git a/relayer-cli/src/commands/query/client.rs b/relayer-cli/src/commands/query/client.rs index c548a03f1f..211dedf141 100644 --- a/relayer-cli/src/commands/query/client.rs +++ b/relayer-cli/src/commands/query/client.rs @@ -26,7 +26,6 @@ pub struct QueryClientStateCmd { long = "chain", required = true, value_name = "CHAIN_ID", - help_heading = "FLAGS", help = "Identifier of the chain to query" )] chain_id: ChainId, @@ -35,7 +34,6 @@ pub struct QueryClientStateCmd { long = "client", required = true, value_name = "CLIENT_ID", - help_heading = "FLAGS", help = "Identifier of the client to query" )] client_id: ClientId, @@ -79,7 +77,6 @@ pub struct QueryClientConsensusCmd { long = "chain", required = true, value_name = "CHAIN_ID", - help_heading = "FLAGS", help = "Identifier of the chain to query" )] chain_id: ChainId, @@ -88,7 +85,6 @@ pub struct QueryClientConsensusCmd { long = "client", required = true, value_name = "CLIENT_ID", - help_heading = "FLAGS", help = "Identifier of the client to query" )] client_id: ClientId, @@ -193,7 +189,6 @@ pub struct QueryClientHeaderCmd { long = "chain", required = true, value_name = "CHAIN_ID", - help_heading = "FLAGS", help = "Identifier of the chain to query" )] chain_id: ChainId, @@ -202,7 +197,6 @@ pub struct QueryClientHeaderCmd { long = "client", required = true, value_name = "CLIENT_ID", - help_heading = "FLAGS", help = "Identifier of the client to query" )] client_id: ClientId, @@ -211,7 +205,6 @@ pub struct QueryClientHeaderCmd { long = "consensus-height", required = true, value_name = "CONSENSUS_HEIGHT", - help_heading = "FLAGS", help = "Height of header to query" )] consensus_height: u64, @@ -281,7 +274,6 @@ pub struct QueryClientConnectionsCmd { long = "chain", required = true, value_name = "CHAIN_ID", - help_heading = "FLAGS", help = "Identifier of the chain to query" )] chain_id: ChainId, @@ -290,7 +282,6 @@ pub struct QueryClientConnectionsCmd { long = "client", required = true, value_name = "CLIENT_ID", - help_heading = "FLAGS", help = "Identifier of the client to query" )] client_id: ClientId, diff --git a/relayer-cli/src/commands/query/clients.rs b/relayer-cli/src/commands/query/clients.rs index 48ac732960..6cb6bd1e63 100644 --- a/relayer-cli/src/commands/query/clients.rs +++ b/relayer-cli/src/commands/query/clients.rs @@ -19,7 +19,6 @@ pub struct QueryAllClientsCmd { long = "host-chain", required = true, value_name = "HOST_CHAIN_ID", - help_heading = "FLAGS", help = "Identifier of the chain to query" )] chain_id: ChainId, diff --git a/relayer-cli/src/commands/query/connection.rs b/relayer-cli/src/commands/query/connection.rs index 16d8b729d4..06cbce4c86 100644 --- a/relayer-cli/src/commands/query/connection.rs +++ b/relayer-cli/src/commands/query/connection.rs @@ -22,7 +22,6 @@ pub struct QueryConnectionEndCmd { long = "chain", required = true, value_name = "CHAIN_ID", - help_heading = "FLAGS", help = "Identifier of the chain to query" )] chain_id: ChainId, @@ -32,7 +31,6 @@ pub struct QueryConnectionEndCmd { visible_alias = "conn", required = true, value_name = "CONNECTION_ID", - help_heading = "FLAGS", help = "Identifier of the connection to query" )] connection_id: ConnectionId, @@ -90,7 +88,6 @@ pub struct QueryConnectionChannelsCmd { long = "chain", required = true, value_name = "CHAIN_ID", - help_heading = "FLAGS", help = "Identifier of the chain to query" )] chain_id: ChainId, @@ -100,7 +97,6 @@ pub struct QueryConnectionChannelsCmd { visible_alias = "conn", required = true, value_name = "CONNECTION_ID", - help_heading = "FLAGS", help = "Identifier of the connection to query" )] connection_id: ConnectionId, diff --git a/relayer-cli/src/commands/query/connections.rs b/relayer-cli/src/commands/query/connections.rs index 45fb2f5617..abc502d403 100644 --- a/relayer-cli/src/commands/query/connections.rs +++ b/relayer-cli/src/commands/query/connections.rs @@ -15,7 +15,6 @@ pub struct QueryConnectionsCmd { long = "chain", required = true, value_name = "CHAIN_ID", - help_heading = "FLAGS", help = "Identifier of the chain to query" )] chain_id: ChainId, diff --git a/relayer-cli/src/commands/query/packet/ack.rs b/relayer-cli/src/commands/query/packet/ack.rs index 05b92a8860..cfb10bcfa4 100644 --- a/relayer-cli/src/commands/query/packet/ack.rs +++ b/relayer-cli/src/commands/query/packet/ack.rs @@ -18,7 +18,6 @@ pub struct QueryPacketAcknowledgmentCmd { long = "chain", required = true, value_name = "CHAIN_ID", - help_heading = "FLAGS", help = "Identifier of the chain to query" )] chain_id: ChainId, @@ -27,7 +26,6 @@ pub struct QueryPacketAcknowledgmentCmd { long = "port", required = true, value_name = "PORT_ID", - help_heading = "FLAGS", help = "Identifier of the port to query" )] port_id: PortId, @@ -37,7 +35,6 @@ pub struct QueryPacketAcknowledgmentCmd { visible_alias = "chan", required = true, value_name = "CHANNEL_ID", - help_heading = "FLAGS", help = "Identifier of the channel to query" )] channel_id: ChannelId, @@ -47,7 +44,6 @@ pub struct QueryPacketAcknowledgmentCmd { visible_alias = "seq", required = true, value_name = "SEQUENCE", - help_heading = "FLAGS", help = "Sequence of packet to query" )] sequence: Sequence, diff --git a/relayer-cli/src/commands/query/packet/acks.rs b/relayer-cli/src/commands/query/packet/acks.rs index 7f36303750..d8c09cecfe 100644 --- a/relayer-cli/src/commands/query/packet/acks.rs +++ b/relayer-cli/src/commands/query/packet/acks.rs @@ -25,7 +25,6 @@ pub struct QueryPacketAcknowledgementsCmd { long = "chain", required = true, value_name = "CHAIN_ID", - help_heading = "FLAGS", help = "Identifier of the chain to query" )] chain_id: ChainId, @@ -34,7 +33,6 @@ pub struct QueryPacketAcknowledgementsCmd { long = "port", required = true, value_name = "PORT_ID", - help_heading = "FLAGS", help = "Identifier of the port to query" )] port_id: PortId, @@ -44,7 +42,6 @@ pub struct QueryPacketAcknowledgementsCmd { visible_alias = "chan", required = true, value_name = "CHANNEL_ID", - help_heading = "FLAGS", help = "Identifier of the channel to query" )] channel_id: ChannelId, diff --git a/relayer-cli/src/commands/query/packet/commitment.rs b/relayer-cli/src/commands/query/packet/commitment.rs index 66fab1119c..99e9321236 100644 --- a/relayer-cli/src/commands/query/packet/commitment.rs +++ b/relayer-cli/src/commands/query/packet/commitment.rs @@ -26,7 +26,6 @@ pub struct QueryPacketCommitmentCmd { long = "chain", required = true, value_name = "CHAIN_ID", - help_heading = "FLAGS", help = "Identifier of the chain to query" )] chain_id: ChainId, @@ -35,7 +34,6 @@ pub struct QueryPacketCommitmentCmd { long = "port", required = true, value_name = "PORT_ID", - help_heading = "FLAGS", help = "Identifier of the port to query" )] port_id: PortId, @@ -45,7 +43,6 @@ pub struct QueryPacketCommitmentCmd { visible_alias = "chan", required = true, value_name = "CHANNEL_ID", - help_heading = "FLAGS", help = "Identifier of the channel to query" )] channel_id: ChannelId, @@ -55,7 +52,6 @@ pub struct QueryPacketCommitmentCmd { visible_alias = "seq", required = true, value_name = "SEQUENCE", - help_heading = "FLAGS", help = "Sequence of packet to query" )] sequence: Sequence, diff --git a/relayer-cli/src/commands/query/packet/commitments.rs b/relayer-cli/src/commands/query/packet/commitments.rs index f730245f25..c3a20bd5a0 100644 --- a/relayer-cli/src/commands/query/packet/commitments.rs +++ b/relayer-cli/src/commands/query/packet/commitments.rs @@ -24,7 +24,6 @@ pub struct QueryPacketCommitmentsCmd { long = "chain", required = true, value_name = "CHAIN_ID", - help_heading = "FLAGS", help = "Identifier of the chain to query" )] chain_id: ChainId, @@ -33,7 +32,6 @@ pub struct QueryPacketCommitmentsCmd { long = "port", required = true, value_name = "PORT_ID", - help_heading = "FLAGS", help = "Identifier of the port to query" )] port_id: PortId, @@ -43,7 +41,6 @@ pub struct QueryPacketCommitmentsCmd { visible_alias = "chan", required = true, value_name = "CHANNEL_ID", - help_heading = "FLAGS", help = "Identifier of the channel to query" )] channel_id: ChannelId, diff --git a/relayer-cli/src/commands/query/packet/pending.rs b/relayer-cli/src/commands/query/packet/pending.rs index 0868b9c899..777b04b124 100644 --- a/relayer-cli/src/commands/query/packet/pending.rs +++ b/relayer-cli/src/commands/query/packet/pending.rs @@ -35,7 +35,6 @@ pub struct QueryPendingPacketsCmd { long = "chain", required = true, value_name = "CHAIN_ID", - help_heading = "FLAGS", help = "Identifier of the chain at one end of the channel" )] chain_id: ChainId, @@ -44,7 +43,6 @@ pub struct QueryPendingPacketsCmd { long = "port", required = true, value_name = "PORT_ID", - help_heading = "FLAGS", help = "Port identifier on the chain given by " )] port_id: PortId, @@ -54,7 +52,6 @@ pub struct QueryPendingPacketsCmd { visible_alias = "chan", required = true, value_name = "CHANNEL_ID", - help_heading = "FLAGS", help = "Channel identifier on the chain given by " )] channel_id: ChannelId, diff --git a/relayer-cli/src/commands/query/packet/unreceived_acks.rs b/relayer-cli/src/commands/query/packet/unreceived_acks.rs index e1119fa35c..0ca55b2edb 100644 --- a/relayer-cli/src/commands/query/packet/unreceived_acks.rs +++ b/relayer-cli/src/commands/query/packet/unreceived_acks.rs @@ -21,7 +21,6 @@ pub struct QueryUnreceivedAcknowledgementCmd { long = "chain", required = true, value_name = "CHAIN_ID", - help_heading = "FLAGS", help = "Identifier of the chain to query the unreceived acknowledgments" )] chain_id: ChainId, @@ -30,7 +29,6 @@ pub struct QueryUnreceivedAcknowledgementCmd { long = "port", required = true, value_name = "PORT_ID", - help_heading = "FLAGS", help = "Port identifier" )] port_id: PortId, @@ -40,7 +38,6 @@ pub struct QueryUnreceivedAcknowledgementCmd { visible_alias = "chan", required = true, value_name = "CHANNEL_ID", - help_heading = "FLAGS", help = "Channel identifier" )] channel_id: ChannelId, diff --git a/relayer-cli/src/commands/query/packet/unreceived_packets.rs b/relayer-cli/src/commands/query/packet/unreceived_packets.rs index fea8bb266c..8ef6355241 100644 --- a/relayer-cli/src/commands/query/packet/unreceived_packets.rs +++ b/relayer-cli/src/commands/query/packet/unreceived_packets.rs @@ -21,7 +21,6 @@ pub struct QueryUnreceivedPacketsCmd { long = "chain", required = true, value_name = "CHAIN_ID", - help_heading = "FLAGS", help = "Identifier of the chain for the unreceived sequences" )] chain_id: ChainId, @@ -30,7 +29,6 @@ pub struct QueryUnreceivedPacketsCmd { long = "port", required = true, value_name = "PORT_ID", - help_heading = "FLAGS", help = "Port identifier" )] port_id: PortId, @@ -40,7 +38,6 @@ pub struct QueryUnreceivedPacketsCmd { visible_alias = "chan", required = true, value_name = "CHANNEL_ID", - help_heading = "FLAGS", help = "Channel identifier" )] channel_id: ChannelId, diff --git a/relayer-cli/src/commands/query/transfer/denom_trace.rs b/relayer-cli/src/commands/query/transfer/denom_trace.rs index 61dc123ff3..3c80130f27 100644 --- a/relayer-cli/src/commands/query/transfer/denom_trace.rs +++ b/relayer-cli/src/commands/query/transfer/denom_trace.rs @@ -20,7 +20,6 @@ pub struct DenomTraceCmd { #[clap( long = "chain", required = true, - help_heading = "FLAGS", help = "Identifier of the chain" )] chain_id: ChainId, @@ -28,7 +27,6 @@ pub struct DenomTraceCmd { #[clap( long = "hash", required = true, - help_heading = "FLAGS", help = "Trace hash to query" )] hash: String, diff --git a/relayer-cli/src/commands/query/tx/events.rs b/relayer-cli/src/commands/query/tx/events.rs index 786c4e0baf..619d761a3e 100644 --- a/relayer-cli/src/commands/query/tx/events.rs +++ b/relayer-cli/src/commands/query/tx/events.rs @@ -23,7 +23,6 @@ pub struct QueryTxEventsCmd { long = "chain", required = true, value_name = "CHAIN_ID", - help_heading = "FLAGS", help = "Identifier of the chain to query" )] chain_id: ChainId, @@ -32,7 +31,6 @@ pub struct QueryTxEventsCmd { long = "hash", required = true, value_name = "HASH", - help_heading = "FLAGS", help = "Transaction hash to query" )] hash: String, diff --git a/relayer-cli/src/commands/tx/client.rs b/relayer-cli/src/commands/tx/client.rs index b580ff1042..58f004f0c1 100644 --- a/relayer-cli/src/commands/tx/client.rs +++ b/relayer-cli/src/commands/tx/client.rs @@ -27,7 +27,6 @@ pub struct TxCreateClientCmd { long = "host-chain", required = true, value_name = "HOST_CHAIN_ID", - help_heading = "FLAGS", help = "Identifier of the chain that hosts the client" )] dst_chain_id: ChainId, @@ -36,7 +35,6 @@ pub struct TxCreateClientCmd { long = "reference-chain", required = true, value_name = "REFERENCE_CHAIN_ID", - help_heading = "FLAGS", help = "Identifier of the chain targeted by the client" )] src_chain_id: ChainId, @@ -109,7 +107,6 @@ pub struct TxUpdateClientCmd { long = "host-chain", required = true, value_name = "HOST_CHAIN_ID", - help_heading = "FLAGS", help = "Identifier of the chain that hosts the client" )] dst_chain_id: ChainId, @@ -118,7 +115,6 @@ pub struct TxUpdateClientCmd { long = "client", required = true, value_name = "CLIENT_ID", - help_heading = "FLAGS", help = "Identifier of the chain targeted by the client" )] dst_client_id: ClientId, @@ -197,7 +193,6 @@ pub struct TxUpgradeClientCmd { long = "host-chain", required = true, value_name = "HOST_CHAIN_ID", - help_heading = "FLAGS", help = "Identifier of the chain that hosts the client" )] chain_id: ChainId, @@ -206,7 +201,6 @@ pub struct TxUpgradeClientCmd { long = "client", required = true, value_name = "CLIENT_ID", - help_heading = "FLAGS", help = "Identifier of the client to be upgraded" )] client_id: ClientId, @@ -278,7 +272,6 @@ pub struct TxUpgradeClientsCmd { long = "reference-chain", required = true, value_name = "REFERENCE_CHAIN_ID", - help_heading = "FLAGS", help = "Identifier of the chain that underwent an upgrade; all clients targeting this chain will be upgraded" )] src_chain_id: ChainId, From 2f38712c9d9b3dfca3c50671d3c3509de8894e71 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Thu, 30 Jun 2022 12:07:47 +0200 Subject: [PATCH 22/27] Removed manual validation for 'keys add' and 'keys delete' flags. --- relayer-cli/src/commands/keys/add.rs | 2 +- relayer-cli/src/commands/keys/delete.rs | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/relayer-cli/src/commands/keys/add.rs b/relayer-cli/src/commands/keys/add.rs index 2704271330..72b9fc00e1 100644 --- a/relayer-cli/src/commands/keys/add.rs +++ b/relayer-cli/src/commands/keys/add.rs @@ -147,7 +147,7 @@ impl Runnable for KeysAddCmd { // This case should never trigger. // The 'required' parameter for the flags will trigger an error if both flags have not been given. // And the 'group' parameter for the flags will trigger an error if both flags are given. - _ => Output::error("--mnemonic-file and --key-file can't both be None".to_string()) + _ => Output::error("--mnemonic-file and --key-file can't both be set or both None".to_string()) .exit(), } } diff --git a/relayer-cli/src/commands/keys/delete.rs b/relayer-cli/src/commands/keys/delete.rs index a05f8b371e..e424e5f911 100644 --- a/relayer-cli/src/commands/keys/delete.rs +++ b/relayer-cli/src/commands/keys/delete.rs @@ -48,14 +48,13 @@ impl KeysDeleteCmd { .ok_or_else(|| format!("chain '{}' not found in configuration file", self.chain_id))?; let id = match (self.all, &self.key_name) { - (true, Some(_)) => { - return Err("cannot set both --key-name and --all".to_owned().into()); - } - (false, None) => { - return Err("must provide either --key-name or --all".to_owned().into()); - } (true, None) => KeysDeleteId::All, (false, Some(ref key_name)) => KeysDeleteId::Named(key_name), + // This case should never trigger. + // The 'required' parameter for the flags will trigger an error if both flags have not been given. + // And the 'group' parameter for the flags will trigger an error if both flags are given. + _ => Output::error("--key-name and --all can't both be set or both None".to_string()) + .exit(), }; Ok(KeysDeleteOptions { From 3eb9484810bd46eafcdbeccc3b99407c6d735970 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Thu, 30 Jun 2022 12:09:44 +0200 Subject: [PATCH 23/27] Added changelog entry --- .../features/ibc-relayer-cli/2358-add-unit-testing-commands.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .changelog/unreleased/features/ibc-relayer-cli/2358-add-unit-testing-commands.md diff --git a/.changelog/unreleased/features/ibc-relayer-cli/2358-add-unit-testing-commands.md b/.changelog/unreleased/features/ibc-relayer-cli/2358-add-unit-testing-commands.md new file mode 100644 index 0000000000..101c190ded --- /dev/null +++ b/.changelog/unreleased/features/ibc-relayer-cli/2358-add-unit-testing-commands.md @@ -0,0 +1,2 @@ +- Add unit tests for all Hermes commands with at least one argument + ([#2358](https://github.com/informalsystems/ibc-rs/issues/2358)) \ No newline at end of file From af2f9f0df16b9ff45fd00b890eba0e271354e1f3 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Thu, 30 Jun 2022 12:21:19 +0200 Subject: [PATCH 24/27] Updated unit tests for command 'clear packets' to include new optional flags --- .../adr-010-unified-cli-arguments-hermes.md | 4 +- relayer-cli/src/commands/clear.rs | 64 +++++++++++++++++-- 2 files changed, 60 insertions(+), 8 deletions(-) diff --git a/docs/architecture/adr-010-unified-cli-arguments-hermes.md b/docs/architecture/adr-010-unified-cli-arguments-hermes.md index 424718ee89..74acbc571c 100644 --- a/docs/architecture/adr-010-unified-cli-arguments-hermes.md +++ b/docs/architecture/adr-010-unified-cli-arguments-hermes.md @@ -86,8 +86,8 @@ The following commands are implemented, with the binary name `hermes` often omit ### Clear packets -* `clear packets --chain --port --channel - --key-name --counterparty-key-name ` +* `clear packets [OPTIONS] --chain --port --channel ` + * Optional: `[--key-name ] [--counterparty-key-name ]` ### Queries diff --git a/relayer-cli/src/commands/clear.rs b/relayer-cli/src/commands/clear.rs index 22c2ddcb4e..7f91636253 100644 --- a/relayer-cli/src/commands/clear.rs +++ b/relayer-cli/src/commands/clear.rs @@ -23,7 +23,7 @@ pub enum ClearCmds { Packets(ClearPacketsCmd), } -#[derive(Debug, Parser, Command)] +#[derive(Debug, Parser, Command, PartialEq)] pub struct ClearPacketsCmd { #[clap( long = "chain", @@ -51,13 +51,13 @@ pub struct ClearPacketsCmd { channel_id: ChannelId, #[clap( - long, + long = "key-name", help = "use the given signing key for the specified chain (default: `key_name` config)" )] key_name: Option, #[clap( - long, + long = "counterparty-key-name", help = "use the given signing key for the counterparty chain (default: `counterparty_key_name` config)" )] counterparty_key_name: Option, @@ -158,12 +158,14 @@ mod tests { use ibc::core::ics24_host::identifier::{ChainId, ChannelId, PortId}; #[test] - fn test_clear_packets() { + fn test_clear_packets_required_only() { assert_eq!( ClearPacketsCmd { chain_id: ChainId::from_string("chain_id"), port_id: PortId::from_str("port_id").unwrap(), - channel_id: ChannelId::from_str("channel-07").unwrap() + channel_id: ChannelId::from_str("channel-07").unwrap(), + key_name: None, + counterparty_key_name: None, }, ClearPacketsCmd::parse_from(&[ "test", @@ -183,7 +185,9 @@ mod tests { ClearPacketsCmd { chain_id: ChainId::from_string("chain_id"), port_id: PortId::from_str("port_id").unwrap(), - channel_id: ChannelId::from_str("channel-07").unwrap() + channel_id: ChannelId::from_str("channel-07").unwrap(), + key_name: None, + counterparty_key_name: None }, ClearPacketsCmd::parse_from(&[ "test", @@ -197,6 +201,54 @@ mod tests { ) } + #[test] + fn test_clear_packets_key_name() { + assert_eq!( + ClearPacketsCmd { + chain_id: ChainId::from_string("chain_id"), + port_id: PortId::from_str("port_id").unwrap(), + channel_id: ChannelId::from_str("channel-07").unwrap(), + key_name: Some("key_name".to_owned()), + counterparty_key_name: None, + }, + ClearPacketsCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--port", + "port_id", + "--channel", + "channel-07", + "--key-name", + "key_name" + ]) + ) + } + + #[test] + fn test_clear_packets_counterparty_key_name() { + assert_eq!( + ClearPacketsCmd { + chain_id: ChainId::from_string("chain_id"), + port_id: PortId::from_str("port_id").unwrap(), + channel_id: ChannelId::from_str("channel-07").unwrap(), + key_name: None, + counterparty_key_name: Some("counterparty_key_name".to_owned()), + }, + ClearPacketsCmd::parse_from(&[ + "test", + "--chain", + "chain_id", + "--port", + "port_id", + "--channel", + "channel-07", + "--counterparty-key-name", + "counterparty_key_name" + ]) + ) + } + #[test] fn test_clear_packets_no_chan() { assert!(ClearPacketsCmd::try_parse_from(&[ From 0e5d73d595d6252aff6453db71b0ce2b12efda47 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Thu, 30 Jun 2022 13:35:17 +0200 Subject: [PATCH 25/27] Cargo fmt --- relayer-cli/src/commands/keys/add.rs | 12 +++++------- relayer-cli/src/commands/listen.rs | 6 +----- .../src/commands/query/transfer/denom_trace.rs | 12 ++---------- 3 files changed, 8 insertions(+), 22 deletions(-) diff --git a/relayer-cli/src/commands/keys/add.rs b/relayer-cli/src/commands/keys/add.rs index 72b9fc00e1..13dd710a86 100644 --- a/relayer-cli/src/commands/keys/add.rs +++ b/relayer-cli/src/commands/keys/add.rs @@ -32,11 +32,7 @@ use crate::conclude::Output; /// If successful the key will be created or restored, depending on which flag was given. #[derive(Clone, Command, Debug, Parser, PartialEq)] pub struct KeysAddCmd { - #[clap( - long = "chain", - required = true, - help = "Identifier of the chain" - )] + #[clap(long = "chain", required = true, help = "Identifier of the chain")] chain_id: ChainId, #[clap( @@ -147,8 +143,10 @@ impl Runnable for KeysAddCmd { // This case should never trigger. // The 'required' parameter for the flags will trigger an error if both flags have not been given. // And the 'group' parameter for the flags will trigger an error if both flags are given. - _ => Output::error("--mnemonic-file and --key-file can't both be set or both None".to_string()) - .exit(), + _ => Output::error( + "--mnemonic-file and --key-file can't both be set or both None".to_string(), + ) + .exit(), } } } diff --git a/relayer-cli/src/commands/listen.rs b/relayer-cli/src/commands/listen.rs index f251a90542..b4dbb17e7c 100644 --- a/relayer-cli/src/commands/listen.rs +++ b/relayer-cli/src/commands/listen.rs @@ -61,11 +61,7 @@ impl FromStr for EventFilter { #[derive(Debug, Parser, PartialEq)] pub struct ListenCmd { /// Identifier of the chain to listen for events from - #[clap( - long = "chain", - required = true, - value_name = "CHAIN_ID" - )] + #[clap(long = "chain", required = true, value_name = "CHAIN_ID")] chain_id: ChainId, /// Add an event type to listen for, can be repeated. diff --git a/relayer-cli/src/commands/query/transfer/denom_trace.rs b/relayer-cli/src/commands/query/transfer/denom_trace.rs index 3c80130f27..85e59de073 100644 --- a/relayer-cli/src/commands/query/transfer/denom_trace.rs +++ b/relayer-cli/src/commands/query/transfer/denom_trace.rs @@ -17,18 +17,10 @@ use crate::conclude::{exit_with_unrecoverable_error, json, Output}; /// If successful the the base denomination and the path will be displayed. #[derive(Clone, Command, Debug, Parser, PartialEq)] pub struct DenomTraceCmd { - #[clap( - long = "chain", - required = true, - help = "Identifier of the chain" - )] + #[clap(long = "chain", required = true, help = "Identifier of the chain")] chain_id: ChainId, - #[clap( - long = "hash", - required = true, - help = "Trace hash to query" - )] + #[clap(long = "hash", required = true, help = "Trace hash to query")] hash: String, } From 1f29fbf62847e4f26ac946ac77424abeedee7832 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Fri, 1 Jul 2022 10:57:12 +0200 Subject: [PATCH 26/27] Fixed 'keys add' in ADR 010 and added shell completion unit test for case with no flag --- .../architecture/adr-010-unified-cli-arguments-hermes.md | 9 ++++++--- relayer-cli/src/commands/completions.rs | 5 +++++ relayer-cli/src/commands/create/channel.rs | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/docs/architecture/adr-010-unified-cli-arguments-hermes.md b/docs/architecture/adr-010-unified-cli-arguments-hermes.md index 74acbc571c..29f77d14b6 100644 --- a/docs/architecture/adr-010-unified-cli-arguments-hermes.md +++ b/docs/architecture/adr-010-unified-cli-arguments-hermes.md @@ -51,14 +51,17 @@ The following commands are implemented, with the binary name `hermes` often omit ### Create a channel * `create channel --a-chain --a-connection --a-port --b-port ` - * Optional: `[--chan-version ] [--order ]` + * Optional: `[--channel-version ] [--order ]` * `create channel --a-chain --b-chain --a-port --b-port --new-client-connection` - * Optional: `[--chan-version ] [--order ] [--yes]` + * Optional: `[--channel-version ] [--order ] [--yes]` ### Commands for keys -* `keys add --chain --key-file --mnemonic-file ` +* `keys add --chain --key-file ` + * Optional: `[--hd-path ] [--key-name ]` + +* `keys add --chain --mnemonic-file ` * Optional: `[--hd-path ] [--key-name ]` * `keys balance --chain ` diff --git a/relayer-cli/src/commands/completions.rs b/relayer-cli/src/commands/completions.rs index 3130001fa4..7a79ea33a2 100644 --- a/relayer-cli/src/commands/completions.rs +++ b/relayer-cli/src/commands/completions.rs @@ -39,6 +39,11 @@ mod tests { assert!(CompletionsCmd::try_parse_from(&["test", "--shell"]).is_err()) } + #[test] + fn test_completions_no_shell_flag() { + assert!(CompletionsCmd::try_parse_from(&["test"]).is_err()) + } + #[test] fn test_completions_unknown_shell() { assert!(CompletionsCmd::try_parse_from(&["test", "--shell", "my_shell"]).is_err()) diff --git a/relayer-cli/src/commands/create/channel.rs b/relayer-cli/src/commands/create/channel.rs index 96964ec951..ef10baa24a 100644 --- a/relayer-cli/src/commands/create/channel.rs +++ b/relayer-cli/src/commands/create/channel.rs @@ -109,6 +109,7 @@ pub struct CreateChannelCommand { #[clap( long = "new-client-connection", visible_alias = "new-client-conn", + required = true, group = "new_client_group", help = "Indicates that a new client and connection will be created underlying the new channel" )] From 99b57bffbc0179f31c198f9161ed99a4da33fe7a Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Fri, 1 Jul 2022 11:59:38 +0200 Subject: [PATCH 27/27] Fix clippy warnings introduced in Rust 1.62 --- relayer-cli/src/commands/keys/list.rs | 3 ++- relayer/src/worker/map.rs | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/relayer-cli/src/commands/keys/list.rs b/relayer-cli/src/commands/keys/list.rs index 8b06408772..0812b24d17 100644 --- a/relayer-cli/src/commands/keys/list.rs +++ b/relayer-cli/src/commands/keys/list.rs @@ -1,4 +1,5 @@ use alloc::collections::btree_map::BTreeMap as HashMap; +use core::fmt::Write; use abscissa_core::clap::Parser; use abscissa_core::{Command, Runnable}; @@ -52,7 +53,7 @@ impl Runnable for KeysListCmd { Ok(keys) => { let mut msg = String::new(); for (name, key) in keys { - msg.push_str(&format!("\n- {} ({})", name, key.account)); + let _ = write!(msg, "\n- {} ({})", name, key.account); } Output::success_msg(msg).exit() } diff --git a/relayer/src/worker/map.rs b/relayer/src/worker/map.rs index ad426f5b80..0347d1806a 100644 --- a/relayer/src/worker/map.rs +++ b/relayer/src/worker/map.rs @@ -58,7 +58,7 @@ impl WorkerMap { "waiting for worker loop to end" ); - let _ = handle.join(); + handle.join(); trace!( worker.id = %id, worker.object = %object.short_name(), @@ -109,7 +109,7 @@ impl WorkerMap { for worker in self.to_notify(src_chain_id) { // Ignore send error if the worker task handling // NewBlock cmd has been terminated. - let _ = worker.send_new_block(height, new_block); + worker.send_new_block(height, new_block); } }