diff --git a/.changelog/unreleased/breaking-changes/ibc-relayer-cli/2376-refactor-tx-raw-commands.md b/.changelog/unreleased/breaking-changes/ibc-relayer-cli/2376-refactor-tx-raw-commands.md new file mode 100644 index 0000000000..65b64af466 --- /dev/null +++ b/.changelog/unreleased/breaking-changes/ibc-relayer-cli/2376-refactor-tx-raw-commands.md @@ -0,0 +1,5 @@ +- Refactored old `tx raw` commands to drop the `raw` subcommand. + Replaced `--src-` and `--dst-` flag prefixes in old `tx raw` commands with more meaningful prefixes. + Removed commands `tx raw update-client`, `tx raw upgrade-client`, `tx raw upgrade-client` and + `tx raw create-client`. + ([#2376](https://github.com/informalsystems/ibc-rs/issues/2376)) \ No newline at end of file diff --git a/ci/README.md b/ci/README.md index 087686ece8..5caa006184 100644 --- a/ci/README.md +++ b/ci/README.md @@ -68,7 +68,7 @@ __Note__: This assumes you are running this the first time, if not, please ensur __Note__: If this is the first time you're running this command, the `informaldev/ibc-0:[RELEASE TAG]` and `informaldev/ibc-1:[RELEASE TAG]` container images will be pulled from the Docker Hub. For instructions on how to update these images in Docker Hub please see the [upgrading the release](#upgrading-chains) section. -5. Run the command below to execute the relayer end to end (e2e) test. This command will execute the `e2e.sh` on the relayer container. The script will configure the light clients for both chains, add the private keys for both chains and run transactions on both chains (e.g. create-client transaction). +5. Run the command below to execute the relayer end to end (e2e) test. This command will execute the `e2e.sh` on the relayer container. The script will configure the light clients for both chains, add the private keys for both chains and run transactions on both chains (e.g. create client transaction). `docker exec relayer /bin/sh -c /relayer/e2e.sh` diff --git a/docs/architecture/adr-010-unified-cli-arguments-hermes.md b/docs/architecture/adr-010-unified-cli-arguments-hermes.md index 83e550020f..158cf095c5 100644 --- a/docs/architecture/adr-010-unified-cli-arguments-hermes.md +++ b/docs/architecture/adr-010-unified-cli-arguments-hermes.md @@ -173,7 +173,7 @@ __Tx__ * `health-check` -### Tx +### Tx __conn-init__ diff --git a/e2e/e2e/channel.py b/e2e/e2e/channel.py index 5abd1df205..384b03aa16 100644 --- a/e2e/e2e/channel.py +++ b/e2e/e2e/channel.py @@ -16,7 +16,7 @@ class TxChanOpenInitRes: port_id: PortId -@cmd("tx raw chan-open-init") +@cmd("tx chan-open-init") @dataclass class TxChanOpenInit(Cmd[TxChanOpenInitRes]): dst_chain_id: ChainId @@ -27,9 +27,9 @@ class TxChanOpenInit(Cmd[TxChanOpenInitRes]): ordering: Optional[Ordering] = None def args(self) -> List[str]: - args = ["--dst-chain", self.dst_chain_id, "--src-chain", self.src_chain_id, - "--dst-conn", self.connection_id, - "--dst-port", self.dst_port_id, "--src-port", self.src_port_id] + args = ["--b-chain", self.dst_chain_id, "--a-chain", self.src_chain_id, + "--b-connection", self.connection_id, + "--b-port", self.dst_port_id, "--a-port", self.src_port_id] if self.ordering is not None: args.extend(['--ordering', str(self.ordering)]) @@ -53,7 +53,7 @@ class TxChanOpenTryRes: port_id: PortId -@cmd("tx raw chan-open-try") +@cmd("tx chan-open-try") @dataclass class TxChanOpenTry(Cmd[TxChanOpenTryRes]): dst_chain_id: ChainId @@ -65,10 +65,10 @@ class TxChanOpenTry(Cmd[TxChanOpenTryRes]): ordering: Optional[Ordering] = None def args(self) -> List[str]: - args = ["--dst-chain", self.dst_chain_id, "--src-chain", self.src_chain_id, - "--dst-conn", self.connection_id, - "--dst-port", self.dst_port_id, "--src-port", self.src_port_id, - "--src-chan", self.src_channel_id] + args = ["--b-chain", self.dst_chain_id, "--a-chain", self.src_chain_id, + "--b-connection", self.connection_id, + "--b-port", self.dst_port_id, "--a-port", self.src_port_id, + "--a-channel", self.src_channel_id] if self.ordering is not None: args.extend(['--ordering', str(self.ordering)]) @@ -92,7 +92,7 @@ class TxChanOpenAckRes: port_id: PortId -@cmd("tx raw chan-open-ack") +@cmd("tx chan-open-ack") @dataclass class TxChanOpenAck(Cmd[TxChanOpenAckRes]): dst_chain_id: ChainId @@ -104,11 +104,11 @@ class TxChanOpenAck(Cmd[TxChanOpenAckRes]): src_channel_id: ChannelId def args(self) -> List[str]: - args = ["--dst-chain", self.dst_chain_id, "--src-chain", self.src_chain_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] + args = ["--b-chain", self.dst_chain_id, "--a-chain", self.src_chain_id, + "--b-connection", self.connection_id, + "--b-port", self.dst_port_id, "--a-port", self.src_port_id, + "--b-channel", self.dst_channel_id, + "--a-channel", self.src_channel_id] return args @@ -129,7 +129,7 @@ class TxChanOpenConfirmRes: port_id: PortId -@cmd("tx raw chan-open-confirm") +@cmd("tx chan-open-confirm") @dataclass class TxChanOpenConfirm(Cmd[TxChanOpenConfirmRes]): dst_chain_id: ChainId @@ -141,11 +141,11 @@ class TxChanOpenConfirm(Cmd[TxChanOpenConfirmRes]): src_channel_id: ChannelId def args(self) -> List[str]: - args = ["--dst-chain", self.dst_chain_id, "--src-chain", self.src_chain_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] + args = ["--b-chain", self.dst_chain_id, "--a-chain", self.src_chain_id, + "--b-connection", self.connection_id, + "--b-port", self.dst_port_id, "--a-port", self.src_port_id, + "--b-channel", self.dst_channel_id, + "--a-channel", self.src_channel_id] return args @@ -165,7 +165,7 @@ class TxChanCloseInitRes: port_id: PortId -@cmd("tx raw chan-close-init") +@cmd("tx chan-close-init") @dataclass class TxChanCloseInit(Cmd[TxChanCloseInitRes]): dst_chain_id: ChainId @@ -177,11 +177,11 @@ class TxChanCloseInit(Cmd[TxChanCloseInitRes]): src_chan_id: ChannelId def args(self) -> List[str]: - 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] + args = ["--b-chain", self.dst_chain_id, "--a-chain", self.src_chain_id, + "--b-connection", self.dst_conn_id, + "--b-port", self.dst_port_id, "--a-port", self.src_port_id, + "--b-channel", self.dst_chan_id, + "--a-channel", self.src_chan_id] return args @@ -202,7 +202,7 @@ class TxChanCloseConfirmRes: port_id: PortId -@cmd("tx raw chan-close-confirm") +@cmd("tx chan-close-confirm") @dataclass class TxChanCloseConfirm(Cmd[TxChanCloseConfirmRes]): dst_chain_id: ChainId @@ -214,11 +214,11 @@ class TxChanCloseConfirm(Cmd[TxChanCloseConfirmRes]): src_chan_id: ChannelId def args(self) -> List[str]: - 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] + args = ["--b-chain", self.dst_chain_id, "--a-chain", self.src_chain_id, + "--b-connection", self.dst_conn_id, + "--b-port", self.dst_port_id, "--a-port", self.src_port_id, + "--b-channel", self.dst_chan_id, + "--a-channel", self.src_chan_id] return args diff --git a/e2e/e2e/client.py b/e2e/e2e/client.py index c1b853c494..e828a06700 100644 --- a/e2e/e2e/client.py +++ b/e2e/e2e/client.py @@ -13,7 +13,7 @@ class ClientCreated: @dataclass -@cmd("tx raw create-client") +@cmd("create client") class TxCreateClient(Cmd[ClientCreated]): dst_chain_id: ChainId src_chain_id: ChainId @@ -37,7 +37,7 @@ class ClientUpdated: @dataclass -@cmd("tx raw update-client") +@cmd("update client") class TxUpdateClient(Cmd[ClientUpdated]): dst_chain_id: ChainId dst_client_id: ClientId diff --git a/e2e/e2e/connection.py b/e2e/e2e/connection.py index bfd15e1ef7..be23028306 100644 --- a/e2e/e2e/connection.py +++ b/e2e/e2e/connection.py @@ -13,7 +13,7 @@ class TxConnInitRes: connection_id: ConnectionId -@cmd("tx raw conn-init") +@cmd("tx conn-init") @dataclass class TxConnInit(Cmd[TxConnInitRes]): dst_chain_id: ChainId @@ -22,8 +22,8 @@ class TxConnInit(Cmd[TxConnInitRes]): src_client_id: ClientId def args(self) -> List[str]: - 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] + return ["--b-chain", self.dst_chain_id, "--a-chain", self.src_chain_id, + "--b-client", self.dst_client_id, "--a-client", self.src_client_id] def process(self, result: Any) -> TxConnInitRes: return from_dict(TxConnInitRes, result['OpenInitConnection']) @@ -36,7 +36,7 @@ class TxConnTryRes: connection_id: ConnectionId -@cmd("tx raw conn-try") +@cmd("tx conn-try") @dataclass class TxConnTry(Cmd[TxConnTryRes]): dst_chain_id: ChainId @@ -46,9 +46,9 @@ 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, - "--dst-client", self.dst_client_id, "--src-client", self.src_client_id, - "--src-conn", self.src_conn_id] + return ["--b-chain", self.dst_chain_id, "--a-chain", self.src_chain_id, + "--b-client", self.dst_client_id, "--a-client", self.src_client_id, + "--a-connection", self.src_conn_id] def process(self, result: Any) -> TxConnTryRes: return from_dict(TxConnTryRes, result['OpenTryConnection']) @@ -61,7 +61,7 @@ class TxConnAckRes: connection_id: ConnectionId -@cmd("tx raw conn-ack") +@cmd("tx conn-ack") @dataclass class TxConnAck(Cmd[TxConnAckRes]): dst_chain_id: ChainId @@ -72,10 +72,10 @@ class TxConnAck(Cmd[TxConnAckRes]): src_conn_id: ConnectionId def args(self) -> List[str]: - 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] + return ["--b-chain", self.dst_chain_id, "--a-chain", self.src_chain_id, + "--b-client", self.dst_client_id, "--a-client", self.src_client_id, + "--b-connection", self.dst_conn_id, + "--a-connection", self.src_conn_id] def process(self, result: Any) -> TxConnAckRes: return from_dict(TxConnAckRes, result['OpenAckConnection']) @@ -88,7 +88,7 @@ class TxConnConfirmRes: connection_id: ConnectionId -@cmd("tx raw conn-confirm") +@cmd("tx conn-confirm") @dataclass class TxConnConfirm(Cmd[TxConnConfirmRes]): dst_chain_id: ChainId @@ -99,10 +99,10 @@ class TxConnConfirm(Cmd[TxConnConfirmRes]): src_conn_id: ConnectionId def args(self) -> List[str]: - 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] + return ["--b-chain", self.dst_chain_id, "--a-chain", self.src_chain_id, + "--b-client", self.dst_client_id, "--a-client", self.src_client_id, + "--b-connection", self.dst_conn_id, + "--a-connection", self.src_conn_id] def process(self, result: Any) -> TxConnConfirmRes: return from_dict(TxConnConfirmRes, result['OpenConfirmConnection']) diff --git a/e2e/e2e/packet.py b/e2e/e2e/packet.py index db9aa97ddb..ea8b03a726 100644 --- a/e2e/e2e/packet.py +++ b/e2e/e2e/packet.py @@ -22,7 +22,7 @@ class TxPacketSendRes: packet: Packet -@cmd("tx raw ft-transfer") +@cmd("tx ft-transfer") @dataclass class TxPacketSend(Cmd[TxPacketSendRes]): dst_chain_id: ChainId @@ -36,10 +36,10 @@ class TxPacketSend(Cmd[TxPacketSendRes]): def args(self) -> List[str]: args = [ - "--dst-chain", self.dst_chain_id, - "--src-chain", self.src_chain_id, - "--src-port", self.src_port, - "--src-chan", self.src_channel, + "--receiver-chain", self.dst_chain_id, + "--sender-chain", self.src_chain_id, + "--sender-port", self.src_port, + "--sender-channel", self.src_channel, "--amount", str(self.amount), "--timeout-height-offset", str(self.height_offset), ] @@ -66,7 +66,7 @@ class TxPacketRecvRes: ack: Hex -@cmd("tx raw packet-recv") +@cmd("tx packet-recv") @dataclass class TxPacketRecv(Cmd[TxPacketRecvRes]): dst_chain_id: ChainId @@ -75,7 +75,7 @@ class TxPacketRecv(Cmd[TxPacketRecvRes]): src_channel: ChannelId def args(self) -> List[str]: - return ["--dst-chain", self.dst_chain_id, "--src-chain", self.src_chain_id, "--src-port", self.src_port, "--src-chan", self.src_channel] + return ["--receiver-chain", self.dst_chain_id, "--sender-chain", self.src_chain_id, "--sender-port", self.src_port, "--sender-channel", self.src_channel] def process(self, result: Any) -> TxPacketRecvRes: entry = find_entry(result, 'WriteAcknowledgement') @@ -90,7 +90,7 @@ class TxPacketTimeoutRes: packet: Packet -@cmd("tx raw packet-recv") +@cmd("tx packet-recv") @dataclass class TxPacketTimeout(Cmd[TxPacketTimeoutRes]): dst_chain_id: ChainId @@ -99,7 +99,7 @@ class TxPacketTimeout(Cmd[TxPacketTimeoutRes]): src_channel: ChannelId def args(self) -> List[str]: - return ["--dst-chain", self.dst_chain_id, "--src-chain", self.src_chain_id, "--src-port", self.src_port, "--src-chan", self.src_channel] + return ["--receiver-chain", self.dst_chain_id, "--sender-chain", self.src_chain_id, "--sender-port", self.src_port, "--sender-channel", self.src_channel] def process(self, result: Any) -> TxPacketTimeoutRes: entry = find_entry(result, 'TimeoutPacket') @@ -115,7 +115,7 @@ class TxPacketAckRes: packet: Packet -@cmd("tx raw packet-ack") +@cmd("tx packet-ack") @dataclass class TxPacketAck(Cmd[TxPacketAckRes]): dst_chain_id: ChainId @@ -124,7 +124,7 @@ class TxPacketAck(Cmd[TxPacketAckRes]): src_channel: ChannelId def args(self) -> List[str]: - return ["--dst-chain", self.dst_chain_id, "--src-chain", self.src_chain_id, "--src-port", self.src_port, "--src-chan", self.src_channel] + return ["--receiver-chain", self.dst_chain_id, "--sender-chain", self.src_chain_id, "--sender-port", self.src_port, "--sender-channel", self.src_channel] def process(self, result: Any) -> TxPacketAckRes: entry = find_entry(result, 'AcknowledgePacket') diff --git a/e2e/run.py b/e2e/run.py index 0b70a423d6..fc2926e14c 100755 --- a/e2e/run.py +++ b/e2e/run.py @@ -22,30 +22,30 @@ def passive_packets( # 1. create some unreceived acks - # hermes tx raw ft-transfer ibc-1 ibc-0 transfer channel-0 10000 -o 1000 -n 2 + # hermes tx ft-transfer --receiver-chain ibc-1 --sender-chain ibc-0 --sender-port transfer --sender-channel channel-0 --amount 10000 --timeout-height-offset 1000 --number-msgs 2 packet.packet_send(c, src=ibc0, dst=ibc1, src_port=port_id, src_channel=ibc0_channel_id, amount=10000, height_offset=1000, number_msgs=2) - # hermes tx raw ft-transfer ibc-0 ibc-1 transfer channel-1 10000 -o 1000 -n 2 + # hermes tx ft-transfer --receiver-chain ibc-0 --sender-chain ibc-1 --sender-port transfer --sender-channel channel-1 --amount 10000 --timeout-height-offset 1000 --number-msgs 2 packet.packet_send(c, src=ibc1, dst=ibc0, src_port=port_id, src_channel=ibc1_channel_id, amount=10000, height_offset=1000, number_msgs=2) sleep(5.0) - # hermes tx raw packet-recv ibc-1 ibc-0 transfer channel-0 + # hermes tx packet-recv --receiver-chain ibc-1 --sender-chain ibc-0 --sender-port transfer --sender-channel channel-0 packet.packet_recv(c, src=ibc0, dst=ibc1, src_port=port_id, src_channel=ibc0_channel_id) - # hermes tx raw packet-recv ibc-0 ibc-1 transfer channel-1 + # hermes tx packet-recv --receiver-chain ibc-0 --sender-chain ibc-1 --sender-port transfer --sender-channel channel-1 packet.packet_recv(c, src=ibc1, dst=ibc0, src_port=port_id, src_channel=ibc1_channel_id) # 2. create some unreceived packets - # hermes tx raw ft-transfer ibc-0 ibc-1 transfer channel-1 10000 -o 1000 -n 3 + # hermes tx ft-transfer --receiver-chain ibc-0 --sender-chain ibc-1 --sender-port transfer --sender-channel channel-1 --amount 10000 --timeout-height-offset 1000 --number-msgs 3 packet.packet_send(c, src=ibc1, dst=ibc0, src_port=port_id, src_channel=ibc1_channel_id, amount=10000, height_offset=1000, number_msgs=3) - # hermes tx raw ft-transfer ibc-1 ibc-0 transfer channel-0 10000 -o 1000 -n 4 + # hermes tx ft-transfer --receiver-chain ibc-1 --sender-chain ibc-0 --sender-port transfer --sender-channel channel-0 --amount 10000 --timeout-height-offset 1000 --number-msgs 4 packet.packet_send(c, src=ibc0, dst=ibc1, src_port=port_id, src_channel=ibc0_channel_id, amount=10000, height_offset=1000, number_msgs=4) @@ -53,25 +53,25 @@ def passive_packets( # 3. verify the expected number of unreceived packets and acks on each channel end - # hermes query packet pending-sends ibc-0 transfer channel-0 + # hermes query packet pending-sends --chain ibc-0 --port transfer --channel channel-0 unreceived = packet.query_unreceived_packets( c, chain=ibc0, port=port_id, channel=ibc0_channel_id) assert (len(unreceived) == 3), (unreceived, "unreceived packet mismatch") - # hermes query packet pending-acks ibc-1 transfer channel-1 + # hermes query packet pending-acks --chain ibc-1 --port transfer --channel channel-1 unreceived = packet.query_unreceived_acks( c, chain=ibc1, port=port_id, channel=ibc1_channel_id) assert (len(unreceived) == 2), (unreceived, "unreceived packet mismatch") - # hermes query packet pending-sends ibc-1 transfer channel-1 + # hermes query packet pending-sends --chain ibc-1 --port transfer --channel channel-1 unreceived = packet.query_unreceived_packets( c, chain=ibc1, port=port_id, channel=ibc1_channel_id) assert (len(unreceived) == 4), (unreceived, "unreceived packet mismatch") - # hermes query packet pending-acks ibc-0 transfer channel-0 + # hermes query packet pending-acks --chain ibc-0 --port transfer --channel channel-0 unreceived = packet.query_unreceived_acks( c, chain=ibc0, port=port_id, channel=ibc0_channel_id) @@ -84,28 +84,28 @@ def passive_packets( sleep(20.0) # 6. verify that there are no pending packets - # hermes query packet pending-sends ibc-1 transfer channel-1 + # hermes query packet pending-sends --chain ibc-1 --port transfer --channel channel-1 unreceived = packet.query_unreceived_packets( c, chain=ibc1, port=port_id, channel=ibc1_channel_id) assert (len(unreceived) == 0), (unreceived, "unreceived packets mismatch (expected 0)") - # hermes query packet pending-acks ibc-1 transfer channel-1 + # hermes query packet pending-acks --chain ibc-1 --port transfer --channel channel-1 unreceived = packet.query_unreceived_acks( c, chain=ibc1, port=port_id, channel=ibc1_channel_id) assert (len(unreceived) == 0), (unreceived, "unreceived acks mismatch (expected 0)") - # hermes query packet pending-sends ibc-0 transfer channel-0 + # hermes query packet pending-sends --chain ibc-0 --port transfer --channel channel-0 unreceived = packet.query_unreceived_packets( c, chain=ibc0, port=port_id, channel=ibc0_channel_id) assert (len(unreceived) == 0), (unreceived, "unreceived packets mismatch (expected 0)") - # hermes query packet pending-acks ibc-0 transfer channel-0 + # hermes query packet pending-acks --chain ibc-0 --port transfer --channel channel-0 unreceived = packet.query_unreceived_acks( c, chain=ibc0, port=port_id, channel=ibc0_channel_id) @@ -113,39 +113,39 @@ def passive_packets( "unreceived acks mismatch (expected 0)") # 7. send some packets - # hermes tx raw ft-transfer ibc-0 ibc-1 transfer channel-1 10000 1000 -n 3 + # hermes tx ft-transfer --receiver-chain ibc-0 --sender-chain ibc-1 --sender-port transfer --sender-channel channel-1 --amount 10000 --timeout-height-offset 1000 --number-msgs 3 packet.packet_send(c, src=ibc1, dst=ibc0, src_port=port_id, src_channel=ibc1_channel_id, amount=10000, height_offset=1000, number_msgs=3) - # hermes tx raw ft-transfer ibc-1 ibc-0 transfer channel-0 10000 1000 -n 4 + # hermes tx ft-transfer --receiver-chain ibc-1 --sender-chain ibc-0 --sender-port transfer --sender-channel channel-0 --amount 10000 --timeout-height-offset 1000 --number-msgs 4 packet.packet_send(c, src=ibc0, dst=ibc1, src_port=port_id, src_channel=ibc0_channel_id, amount=10000, height_offset=1000, number_msgs=4) sleep(20.0) # 8. verify that there are no pending packets - # hermes query packet pending-sends ibc-1 transfer channel-1 + # hermes query packet pending-sends --chain ibc-1 --port transfer --channel channel-1 unreceived = packet.query_unreceived_packets( c, chain=ibc1, port=port_id, channel=ibc1_channel_id) assert (len(unreceived) == 0), (unreceived, "unreceived packets mismatch (expected 0)") - # hermes query packet pending-acks ibc-1 transfer channel-1 + # hermes query packet pending-acks --chain ibc-1 --port transfer --channel channel-1 unreceived = packet.query_unreceived_acks( c, chain=ibc1, port=port_id, channel=ibc1_channel_id) assert (len(unreceived) == 0), (unreceived, "unreceived acks mismatch (expected 0)") - # hermes query packet pending-sends ibc-0 transfer channel-0 + # hermes query packet pending-sends --chain ibc-0 --port transfer --channel channel-0 unreceived = packet.query_unreceived_packets( c, chain=ibc0, port=port_id, channel=ibc0_channel_id) assert (len(unreceived) == 0), (unreceived, "unreceived packets mismatch (expected 0)") - # hermes query packet pending-acks ibc-0 transfer channel-0 + # hermes query packet pending-acks --chain ibc-0 --port transfer --channel channel-0 unreceived = packet.query_unreceived_acks( c, chain=ibc0, port=port_id, channel=ibc0_channel_id) diff --git a/guide/src/SUMMARY.md b/guide/src/SUMMARY.md index e4d38dda4b..9e09ade5a2 100644 --- a/guide/src/SUMMARY.md +++ b/guide/src/SUMMARY.md @@ -23,7 +23,7 @@ - [Connect the chains using relay paths](./tutorials/local-chains/relay-paths/index.md) - [Create a new path](./tutorials/local-chains/relay-paths/create-new-path.md) - [Relay packets on multiple paths](./tutorials/local-chains/relay-paths/multiple-paths.md) - - [Connect the chains using raw transactions](./tutorials/local-chains/raw/index.md) + - [Connect the chains using transactions](./tutorials/local-chains/raw/index.md) - [Configure clients](./tutorials/local-chains/raw/client.md) - [Connection handshake](./tutorials/local-chains/raw/connection.md) - [Channel handshake](./tutorials/local-chains/raw/channel.md) @@ -51,13 +51,12 @@ - [Packet](./commands/queries/packet.md) - [Tx](./commands/queries/tx.md) - [Transfer](./commands/queries/transfer.md) - - [Raw transactions](./commands/raw/index.md) - - [Client](./commands/raw/client.md) - - [Connection](./commands/raw/connection.md) - - [Channel Open](./commands/raw/channel-open.md) - - [Channel Close](./commands/raw/channel-close.md) - - [Packet](./commands/raw/packet.md) - - [Upgrade](./commands/raw/upgrade.md) + - [Transactions](./commands/tx/index.md) + - [Connection](./commands/tx/connection.md) + - [Channel Open](./commands/tx/channel-open.md) + - [Channel Close](./commands/tx/channel-close.md) + - [Packet](./commands/tx/packet.md) + - [Upgrade](./commands/tx/upgrade.md) - [Help](./help.md) - [Glossary](./glossary.md) --- diff --git a/guide/src/commands/index.md b/guide/src/commands/index.md index 9f7ede994e..00061e6988 100644 --- a/guide/src/commands/index.md +++ b/guide/src/commands/index.md @@ -36,6 +36,6 @@ Commands to monitor clients and submit evidence of misbehaviour Commands to execute queries on configured chains -**[Raw Transactions](./raw/index.md)** +**[Transactions](./raw/index.md)** Commands to submit individual transactions to configured chains diff --git a/guide/src/commands/raw/client.md b/guide/src/commands/raw/client.md deleted file mode 100644 index 6d35f638ef..0000000000 --- a/guide/src/commands/raw/client.md +++ /dev/null @@ -1,118 +0,0 @@ -# Client -The `tx raw` commands can be used to create and update the on-chain IBC clients. - -## Table of Contents - - -## Create Client -Use the `create-client` command to create a new client. - -```shell -USAGE: - hermes tx raw create-client [OPTIONS] --host-chain --reference-chain - -DESCRIPTION: - Create a client for source chain on destination chain - -FLAGS: - --host-chain - identifier of the chain that hosts the client - - --reference-chain - identifier of the chain targeted by the client - -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 - -``` - -__Example__ - -Create a new client of `ibc-1` on `ibc-0`: - -```shell -hermes tx raw create-client --host-chain ibc-0 --reference-chain ibc-1 -``` - -```json -{ - Success: CreateClient( - CreateClient( - Attributes { - height: Height { revision: 0, height: 43 }, - client_id: ClientId( - "07-tendermint-0", - ), - client_type: Tendermint, - consensus_height: Height { revision: 1, height: 32 }, - }, - ), - ) -} -``` - -A new client is created with identifier `07-tendermint-0` - -## Update Client -Use the `update-client` command to update an existing client with a new consensus state. -Specific update and trusted heights can be specified. - -```shell -USAGE: - hermes tx raw update-client [OPTIONS] --host-chain --client - -DESCRIPTION: - Update the specified client on destination chain - -FLAGS: - --host-chain - identifier of the chain that hosts the client - - --client - identifier of the chain targeted by the client - -OPTIONS: - - --height - the target height of the client update - - --trusted-height - the trusted height of the client update -``` - -__Example__ - -Update the client on `ibc-0` with latest header of `ibc-1` - -```shell -hermes tx raw update-client --host-chain ibc-0 --client 07-tendermint-0 -``` - -```json -Success: UpdateClient( - UpdateClient { - common: Attributes { - height: Height { revision: 0, height: 110 }, - client_id: ClientId( - "07-tendermint-0", - ), - client_type: Tendermint, - consensus_height: Height { revision: 1, height: 109 }, - }, - header: Some( - Tendermint( - Header {...}, - ), - ), - }, -) -``` - -The client with identifier `07-tendermint-0` has been updated with the consensus state at height `1-273`. diff --git a/guide/src/commands/raw/upgrade.md b/guide/src/commands/raw/upgrade.md deleted file mode 100644 index d8f35033c2..0000000000 --- a/guide/src/commands/raw/upgrade.md +++ /dev/null @@ -1,162 +0,0 @@ -# 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 --host-chain --client - -DESCRIPTION: - Upgrade the specified client on destination chain - -FLAGS: - --client Identifier of the client to be upgraded - --host-chain Identifier of the chain that hosts the client -``` - -__Example__ - -A given client is upgraded: - -```shell -hermes tx raw upgrade-client --host-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. - -```shell -USAGE: - hermes tx raw upgrade-clients --reference-chain - -DESCRIPTION: - Upgrade all IBC clients that target a specific chain - -FLAGS: - --reference-chain - identifier of the chain that underwent an upgrade; all clients targeting this chain will - be upgraded -``` - -__Example__ - -All the clients are upgraded: - -```shell -hermes tx raw upgrade-clients --reference-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. - -```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 -``` - -``` -Success: transaction::Hash(779713508B6103E37FADE60483BEE964A90BD67E5F20037B2CC4AE0E90B707C3) -``` diff --git a/guide/src/commands/relaying/clear.md b/guide/src/commands/relaying/clear.md index a396a7e28b..b1d1e0bb3e 100644 --- a/guide/src/commands/relaying/clear.md +++ b/guide/src/commands/relaying/clear.md @@ -35,7 +35,7 @@ REQUIRED: 1. Without Hermes running, send 3 packets over a channel, here `channel-13`: ``` -❯ 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 +❯ hermes tx ft-transfer --receiver-chain ibc1 --sender-chain ibc0 --sender-port transfer --sender-channel 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 diff --git a/guide/src/commands/raw/channel-close.md b/guide/src/commands/tx/channel-close.md similarity index 53% rename from guide/src/commands/raw/channel-close.md rename to guide/src/commands/tx/channel-close.md index 16bddfbf38..b7a22b7ba9 100644 --- a/guide/src/commands/raw/channel-close.md +++ b/guide/src/commands/tx/channel-close.md @@ -12,25 +12,38 @@ Use the `chan-close-init` command to initialize the closure of a channel. ```shell USAGE: - hermes tx raw chan-close-init --dst-chain --src-chain --dst-conn --dst-port --src-port --dst-chan --src-chan + hermes tx chan-close-init --b-chain --a-chain --b-connection --b-port --a-port --b-channel --a-channel DESCRIPTION: Initiate the closing of a channel (ChannelCloseInit) -FLAGS: - --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 +REQUIRED: + --a-chain + Identifier of the source chain + + --a-channel + Identifier of the source channel (required) [aliases: a-chan] + + --a-port + Identifier of the source port + + --b-chain + Identifier of the destination chain + + --b-channel + Identifier of the destination channel (required) [aliases: b-chan] + + --b-connection + Identifier of the destination connection [aliases: b-conn] + + --b-port + Identifier of the destination port ``` __Example__ ```shell -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 +hermes tx chan-close-init --b-chain ibc-0 --a-chain ibc-1 --b-connection connection-0 --b-port transfer --a-port transfer --b-channel channel-0 --a-channel channel-1 ``` ```json @@ -71,26 +84,39 @@ Use the `chan-close-confirm` command to confirm the closure of a channel. ```shell USAGE: - hermes tx raw chan-close-confirm --dst-chain --src-chain --dst-conn --dst-port --src-port --dst-chan --src-chan + hermes tx chan-close-confirm --b-chain --a-chain --b-connection --b-port --a-port --b-channel --a-channel DESCRIPTION: Confirm the closing of a channel (ChannelCloseConfirm) -FLAGS: - --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 +REQUIRED: + --a-chain + Identifier of the source chain + + --a-channel + Identifier of the source channel (required) [aliases: a-chan] + + --a-port + Identifier of the source port + + --b-chain + Identifier of the destination chain + + --b-channel + Identifier of the destination channel (required) [aliases: b-chan] + + --b-connection + Identifier of the destination connection [aliases: b-conn] + + --b-port + Identifier of the destination port ``` __Example__ ```shell -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 +hermes tx chan-close-confirm --b-chain ibc-1 --a-chain ibc-0 --b-connection connection-1 --a-port transfer --b-port transfer --b-channel channel-1 --a-channel channel-0 ``` ```json diff --git a/guide/src/commands/raw/channel-open.md b/guide/src/commands/tx/channel-open.md similarity index 55% rename from guide/src/commands/raw/channel-open.md rename to guide/src/commands/tx/channel-open.md index 6dc106cfe1..2e2e56aa55 100644 --- a/guide/src/commands/raw/channel-open.md +++ b/guide/src/commands/tx/channel-open.md @@ -1,6 +1,6 @@ # Channel Open Handshake -The `tx raw` commands can be used to establish a channel for a given connection. Only `unordered` channels are currently supported. +The `tx` commands can be used to establish a channel for a given connection. Only `unordered` channels are currently supported.
@@ -35,21 +35,30 @@ Use the `chan-open-init` command to initialize a new channel. ```shell USAGE: - hermes tx raw chan-open-init [OPTIONS] --dst-chain --src-chain --dst-conn --dst-port --src-port + hermes tx chan-open-init [OPTIONS] --b-chain --a-chain --b-connection --b-port --a-port DESCRIPTION: Initialize a channel (ChannelOpenInit) -FLAGS: - --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] + --order The channel ordering, valid options 'unordered' (default) and 'ordered' + [default: ORDER_UNORDERED] + +REQUIRED: + --a-chain + Identifier of the source chain + + --a-port + Identifier of the source port + + --b-chain + Identifier of the destination chain + + --b-connection + Identifier of the destination connection [aliases: b-conn] + + --b-port + Identifier of the destination port ``` __Example__ @@ -57,7 +66,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 --dst-chain ibc-0 --src-chain ibc-1 --dst-conn connection-0 --dst-port transfer --src-port transfer +hermes tx chan-open-init --b-chain ibc-0 --a-chain ibc-1 --b-connection connection-0 --b-port transfer --a-port transfer ``` ```json @@ -99,21 +108,33 @@ Use the `chan-open-try` command to establish a counterparty to the channel on th ```shell USAGE: - hermes tx raw chan-open-try [OPTIONS] --dst-chain --src-chain --dst-conn --dst-port --src-port --src-chan + hermes tx chan-open-try [OPTIONS] --b-chain --a-chain --b-connection --b-port --a-port --a-channel DESCRIPTION: Relay the channel attempt (ChannelOpenTry) -FLAGS: - --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) + --b-channel Identifier of the destination channel (optional) [aliases: + b-chan] + +REQUIRED: + --a-chain + Identifier of the source chain + + --a-channel + Identifier of the source channel (required) [aliases: a-chan] + + --a-port + Identifier of the source port + + --b-chain + Identifier of the destination chain + + --b-connection + Identifier of the destination connection [aliases: b-conn] + + --b-port + Identifier of the destination port ``` __Example__ @@ -121,7 +142,7 @@ __Example__ Let's now create the counterparty to `channel-0` on chain `ibc-1`: ```shell -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 +hermes tx chan-open-try --b-chain ibc-1 --a-chain ibc-0 --b-connection connection-1 --b-port transfer --a-port transfer --a-channel channel-0 ``` ```json @@ -167,19 +188,32 @@ Use the `chan-open-ack` command to acknowledge the channel on the initial chain. ```shell USAGE: - hermes tx raw chan-open-ack --dst-chain --src-chain --dst-conn --dst-port --src-port --dst-chan --src-chan + hermes tx chan-open-ack --b-chain --a-chain --b-connection --b-port --a-port --b-channel --a-channel DESCRIPTION: Relay acknowledgment of a channel attempt (ChannelOpenAck) -FLAGS: - --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 +REQUIRED: + --a-chain + Identifier of the source chain + + --a-channel + Identifier of the source channel (required) [aliases: a-chan] + + --a-port + Identifier of the source port + + --b-chain + Identifier of the destination chain + + --b-channel + Identifier of the destination channel (required) [aliases: b-chan] + + --b-connection + Identifier of the destination connection [aliases: b-conn] + + --b-port + Identifier of the destination port ``` __Example__ @@ -187,7 +221,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 --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 +hermes tx chan-open-ack --b-chain ibc-0 --a-chain ibc-1 --b-connection connection-0 --b-port transfer --a-port transfer --b-channel channel-0 --a-channel channel-1 ``` ```json @@ -232,19 +266,32 @@ and finish the handshake, after which the channel is open on both chains. ```shell USAGE: - hermes tx raw chan-open-confirm --dst-chain --src-chain --dst-conn --dst-port --src-port --dst-chan --src-chan + hermes tx chan-open-confirm --b-chain --a-chain --b-connection --b-port --a-port --b-channel --a-channel DESCRIPTION: Confirm opening of a channel (ChannelOpenConfirm) -FLAGS: - --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 +REQUIRED: + --a-chain + Identifier of the source chain + + --a-channel + Identifier of the source channel (required) [aliases: a-chan] + + --a-port + Identifier of the source port + + --b-chain + Identifier of the destination chain + + --b-channel + Identifier of the destination channel (required) [aliases: b-chan] + + --b-connection + Identifier of the destination connection [aliases: b-conn] + + --b-port + Identifier of the destination port ``` __Example__ @@ -253,7 +300,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 --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 +hermes tx chan-open-confirm --b-chain ibc-1 --a-chain ibc-0 --b-connection connection-1 --b-port transfer --a-port transfer --b-channel channel-1 --a-channel channel-0 ``` ```json diff --git a/guide/src/commands/raw/connection.md b/guide/src/commands/tx/connection.md similarity index 60% rename from guide/src/commands/raw/connection.md rename to guide/src/commands/tx/connection.md index 276fcc0cea..37e6c27511 100644 --- a/guide/src/commands/raw/connection.md +++ b/guide/src/commands/tx/connection.md @@ -1,6 +1,6 @@ # Connection Handshake -The `tx raw` commands can be used to establish a connection between two clients. +The `tx` commands can be used to establish a connection between two clients.
@@ -35,16 +35,16 @@ Use the `conn-init` command to initialize a new connection on a chain. ```shell USAGE: - hermes tx raw conn-init --dst-chain --src-chain --dst-client --src-client + hermes tx conn-init --b-chain --a-chain --b-client --a-client DESCRIPTION: Initialize a connection (ConnectionOpenInit) -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 +REQUIRED: + --a-chain Identifier of the source chain + --a-client Identifier of the source client + --b-chain Identifier of the destination chain + --b-client Identifier of the destination 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 --dst-chain ibc-0 --src-chain ibc-1 --dst-client 07-tendermint-0 --src-client 07-tendermint-1 +hermes tx conn-init --b-chain ibc-0 --a-chain ibc-1 --b-client 07-tendermint-0 --a-client 07-tendermint-1 ``` ```json @@ -94,20 +94,30 @@ Use the `conn-try` command to establish a counterparty to the connection on the ```shell USAGE: - hermes tx raw conn-try [OPTIONS] --dst-chain --src-chain --dst-client --src-client --src-conn + hermes tx conn-try [OPTIONS] --b-chain --a-chain --b-client --a-client --a-connection DESCRIPTION: Relay the connection attempt (ConnectionOpenTry) -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 - --src-conn Identifier of the source connection (required) - OPTIONS: - --dst-conn Identifier of the destination connection (optional) + --b-connection + Identifier of the destination connection (optional) [aliases: b-conn] + +REQUIRED: + --a-chain + Identifier of the source chain + + --a-client + Identifier of the source client + + --a-connection + Identifier of the source connection (required) [aliases: a-conn] + + --b-chain + Identifier of the destination chain + + --b-client + Identifier of the destination client ``` __Example__ @@ -115,7 +125,7 @@ __Example__ Let's now create the counterparty to `connection-0` on chain `ibc-1`: ```shell -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 +hermes tx conn-try --b-chain ibc-1 --a-chain ibc-0 --b-client 07-tendermint-1 --a-client 07-tendermint-0 --a-connection connection-0 ``` ```json @@ -158,18 +168,29 @@ Use the `conn-ack` command to acknowledge the connection on the initial chain. ```shell USAGE: - hermes tx raw conn-ack --dst-chain --src-chain --dst-client --src-client --dst-conn --src-conn + hermes tx conn-ack --b-chain --a-chain --b-client --a-client --b-connection --a-connection DESCRIPTION: Relay acknowledgment of a connection attempt (ConnectionOpenAck) -FLAGS: - --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) +REQUIRED: + --a-chain + Identifier of the source chain + + --a-client + Identifier of the source client + + --a-connection + Identifier of the source connection (required) [aliases: a-conn] + + --b-chain + Identifier of the destination chain + + --b-client + Identifier of the destination client + + --b-connection + Identifier of the destination connection (required) [aliases: b-conn] ``` __Example__ @@ -177,7 +198,7 @@ __Example__ We can now acknowledge on `ibc-0` that `ibc-1` has accepted the connection attempt: ```shell -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 +hermes tx conn-ack --b-chain ibc-0 --a-chain ibc-1 --b-client 07-tendermint-0 --a-client 07-tendermint-1 --b-connection connection-0 --a-connection connection-1 ``` ```json @@ -219,18 +240,29 @@ and finish the handshake, after which the connection is open on both chains. ```shell USAGE: - hermes tx raw conn-confirm --dst-chain --src-chain --dst-client --src-client --dst-conn --src-conn + hermes tx conn-confirm --b-chain --a-chain --b-client --a-client --b-connection --a-connection DESCRIPTION: Confirm opening of a connection (ConnectionOpenConfirm) -FLAGS: - --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) +REQUIRED: + --a-chain + Identifier of the source chain + + --a-client + Identifier of the source client + + --a-connection + Identifier of the source connection (required) [aliases: a-conn] + + --b-chain + Identifier of the destination chain + + --b-client + Identifier of the destination client + + --b-connection + Identifier of the destination connection (required) [aliases: b-conn] ``` __Example__ @@ -238,7 +270,7 @@ __Example__ Confirm on `ibc-1` that `ibc-0` has accepted the connection attempt. ```shell -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 +hermes tx conn-confirm --b-chain ibc-1 --a-chain ibc-0 --b-client 07-tendermint-1 --a-client 07-tendermint-0 --b-connection connection-1 --a-connection connection-0 ``` ```json diff --git a/guide/src/commands/raw/index.md b/guide/src/commands/tx/index.md similarity index 82% rename from guide/src/commands/raw/index.md rename to guide/src/commands/tx/index.md index 5da87a9130..e85d3f7a57 100644 --- a/guide/src/commands/raw/index.md +++ b/guide/src/commands/tx/index.md @@ -1,13 +1,11 @@ -# Raw Transactions +# Transactions There are a number of simple commands that perform minimal validation, build and send IBC transactions. -The `tx raw` command provides the following sub-commands: +The `tx` command provides the following sub-commands: | CLI name | Description | | ---------------------- | --------------------------------------------------------------------------------------------------------------- | -| `create-client` | [Create a client for source chain on destination chain](./client.md#create-client) | -| `update-client` | [Update the specified client on destination chain](./client.md#update-client) | | `conn-init` | [Initialize a connection (ConnectionOpenInit)](./connection.md#connection-init) | | `conn-try` | [Relay the connection attempt (ConnectionOpenTry)](./connection.md#connection-try) | | `conn-ack` | [Relay acknowledgment of a connection attempt (ConnectionOpenAck)](./connection.md#connection-ack) | @@ -22,15 +20,13 @@ The `tx raw` command provides the following sub-commands: | `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. At a high level, most commands follow this template: ```shell -hermes tx raw [-d -s ]* +hermes tx [-d -s ]* ``` In the command template above: @@ -38,7 +34,6 @@ In the command template above: - `ibc-datagram` - identifies the "main" IBC message that is being sent, e.g. `conn-init`, `conn-try`, `chan-open-init`, etc. To ensure successful processing on the receiving chain, the majority of these commands build and send two messages: one `UpdateClient` message followed by the actual IBC message. These two messages are included in a single transaction. This is done for all IBC datagrams that include proofs collected from the source chain. The messages that do not require proofs are: - - `MsgCreateClient` (`create-client` command), - `MsgConnectionOpenInit` (`conn-open-init` command), - `MsgChannelOpenInit` (`chan-open-init` command), - `MsgChannelCloseInit` (`chan-close-init` command) and @@ -52,8 +47,7 @@ In the command template above: - `src-obj-id` - the identifier of an object on the source chain, required by the datagram, e.d. the `client-id` of the connection on source chain. -- More details about the `tx raw` commands can be found in the following sections: - - [Client](./client.md) +- More details about the `tx` commands can be found in the following sections: - [Connection](./connection.md) - [Channel Open](./channel-open.md) - [Channel Close](./channel-close.md) @@ -64,15 +58,13 @@ In the command template above: ```shell USAGE: - hermes tx raw + hermes tx DESCRIPTION: Raw commands for sending transactions to a configured chain. SUBCOMMANDS: help Get usage information - create-client Create a client for source chain on destination chain - update-client Update the specified client on destination chain conn-init Initialize a connection (ConnectionOpenInit) conn-try Relay the connection attempt (ConnectionOpenTry) conn-ack Relay acknowledgment of a connection attempt (ConnectionOpenAck) @@ -87,6 +79,4 @@ SUBCOMMANDS: 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/tx/packet.md similarity index 70% rename from guide/src/commands/raw/packet.md rename to guide/src/commands/tx/packet.md index 5876290d17..46e5240666 100644 --- a/guide/src/commands/raw/packet.md +++ b/guide/src/commands/tx/packet.md @@ -6,32 +6,16 @@ ## Fungible token transfer -Use the `tx raw ft-transfer` command to send ICS-20 fungible token transfer packets. +Use the `tx ft-transfer` command to send ICS-20 fungible token transfer packets. __NOTE:__ This command is mainly used for testing the packet features of the relayer. ```shell USAGE: - hermes tx raw ft-transfer [OPTIONS] --dst-chain --src-chain --src-port --src-chan --amount + hermes tx ft-transfer [OPTIONS] --receiver-chain --sender-chain --sender-port --sender-channel --amount DESCRIPTION: Send a fungible token transfer test transaction (ICS20 MsgTransfer) -FLAGS: - --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] @@ -50,6 +34,22 @@ OPTIONS: --timeout-seconds Timeout in seconds since current [default: 0] + +REQUIRED: + --amount + Amount of coins (samoleans, by default) to send (e.g. `100000`) + + --receiver-chain + Identifier of the destination chain + + --sender-chain + Identifier of the source chain + + --sender-channel + Identifier of the source channel [aliases: sender-chan] + + --sender-port + Identifier of the source port ``` __Example__ @@ -57,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 --dst-chain ibc-1 --src-chain ibc-0 --src-port transfer --src-chan channel-0 --amount 9999 --timeout-height-offset 1000 --number-msgs 2 +hermes tx ft-transfer --receiver-chain ibc-1 --sender-chain ibc-0 --sender-port transfer --sender-channel channel-0 --amount 9999 --timeout-height-offset 1000 --number-msgs 2 ``` ```json @@ -88,7 +88,7 @@ The transfer packets are stored on `ibc-0` and can be relayed. > To send transfer packets with a custom receiver address use the `--receiver` flag. ```shell -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 +hermes tx ft-transfer --receiver-chain ibc-1 --sender-chain ibc-0 --sender-port transfer --sender-channel channel-0 --amount 9999 --timeout-height-offset 1000 --number-msgs 1 --receiver board:1938586739 ``` ```json @@ -107,20 +107,27 @@ Success: [ ## Relay receive and timeout packets -Use the `tx raw packet-recv` command to relay the packets sent but not yet received. If the sent packets have timed out then a timeout packet is sent to the source chain. +Use the `tx packet-recv` command to relay the packets sent but not yet received. If the sent packets have timed out then a timeout packet is sent to the source chain. ```shell USAGE: - hermes tx raw packet-recv --dst-chain --src-chain --src-port --src-chan + hermes tx packet-recv --receiver-chain --sender-chain --sender-port --sender-channel DESCRIPTION: Relay receive or timeout packets -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 +REQUIRED: + --receiver-chain + Identifier of the destination chain + + --sender-chain + Identifier of the source chain + + --sender-channel + Identifier of the source channel [aliases: sender-chan] + + --sender-port + Identifier of the source port ``` __Example__ @@ -130,7 +137,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 --dst-chain ibc-1 --src-chain ibc-0 --src-port transfer --src-chan channel-0 +hermes tx packet-recv --receiver-chain ibc-1 --sender-chain ibc-0 --sender-port transfer --sender-channel channel-0 ``` ```json @@ -219,20 +226,27 @@ Both packets have been relayed to `ibc-1` and acknowledged. ## Relay acknowledgment packets -Use the `tx raw packet-ack` command to relay acknowledgments to the original source of the packets. +Use the `tx packet-ack` command to relay acknowledgments to the original source of the packets. ```shell USAGE: - hermes tx raw packet-ack --dst-chain --src-chain --src-port --src-chan + hermes tx packet-ack --receiver-chain --sender-chain --sender-port --sender-channel DESCRIPTION: Relay acknowledgment packets -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 +REQUIRED: + --receiver-chain + Identifier of the destination chain + + --sender-chain + Identifier of the source chain + + --sender-channel + Identifier of the source channel [aliases: sender-chan] + + --sender-port + Identifier of the source port ``` __Example__ @@ -242,7 +256,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 --dst-chain ibc-0 --src-chain ibc-1 --src-port transfer --src-chan channel-1 +hermes tx packet-ack --receiver-chain ibc-0 --sender-chain ibc-1 --sender-port transfer --sender-channel channel-1 ``` ```json diff --git a/guide/src/commands/tx/upgrade.md b/guide/src/commands/tx/upgrade.md new file mode 100644 index 0000000000..7b9b93f91b --- /dev/null +++ b/guide/src/commands/tx/upgrade.md @@ -0,0 +1,58 @@ +# Upgrade Tx Commands + +## Table of Contents + + + +## Upgrade Chain + +Use this to make an upgrade proposal. + +```shell +USAGE: + hermes tx upgrade-chain [OPTIONS] --receiver-chain --sender-chain --sender-client --amount --height-offset + +DESCRIPTION: + Send an IBC upgrade plan + +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') + +REQUIRED: + --amount + Amount of stake + + --height-offset + Upgrade height offset in number of blocks since current + + --receiver-chain + Identifier of the chain to upgrade + + --sender-chain + Identifier of the source chain + + --sender-client + Identifier of the client on source chain from which the plan is created +``` + +__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 upgrade-chain --receiver-chain ibc-0 --sender-chain ibc-1 --sender-client 07-tendermint-0 --amount 10000000 --height-offset 300 +``` + +``` +Success: transaction::Hash(779713508B6103E37FADE60483BEE964A90BD67E5F20037B2CC4AE0E90B707C3) +``` diff --git a/guide/src/commands/upgrade/test.md b/guide/src/commands/upgrade/test.md index 1c19b571f4..0e1eb23d66 100644 --- a/guide/src/commands/upgrade/test.md +++ b/guide/src/commands/upgrade/test.md @@ -71,7 +71,7 @@ gaiad version --log_level error --long | head -n4 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. ```shell - hermes tx raw upgrade-chain --dst-chain ibc-0 --src-chain ibc-1 --src-client 07-tendermint-0 --amount 10000000 --height-offset 60 + hermes tx upgrade-chain --receiver-chain ibc-0 --sender-chain ibc-1 --sender-client 07-tendermint-0 --amount 10000000 --height-offset 60 ``` ```text diff --git a/guide/src/config.md b/guide/src/config.md index a28623bc4a..5dd34cdc68 100644 --- a/guide/src/config.md +++ b/guide/src/config.md @@ -40,7 +40,7 @@ To restrict relaying on specific channels, or uni-directionally, you can use [pa ## Adding private keys -For each chain configured you need to add a private key for that chain in order to submit [transactions](./commands/raw/index.md), +For each chain configured you need to add a private key for that chain in order to submit [transactions](./commands/tx/index.md), please refer to the [Keys](./commands/keys/index.md) sections in order to learn how to add the private keys that are used by the relayer. ## Connecting via TLS diff --git a/guide/src/help.md b/guide/src/help.md index 762668edd4..a6b6636377 100644 --- a/guide/src/help.md +++ b/guide/src/help.md @@ -439,26 +439,26 @@ In order to test the correct operation during the channel close, perform the ste this path). ```shell - 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 + hermes tx ft-transfer --receiver-chain ibc-0 --sender-chain ibc-1 --sender-port transfer --sender-channel 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 --config 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 + hermes --config config.toml tx chan-close-init --receiver-chain ibc-0 --sender-chain ibc-1 --receiver-connection connection-0 --receiver-port transfer --sender-port transfer --receiver-channel channel-0 --sender-channel channel-1 ``` - trigger timeout on close to ibc-1 ```shell - hermes --config config.toml tx raw packet-recv --dst-chain ibc-0 --src-chain ibc-1 --src-port transfer --src-chan channel-1 + hermes --config config.toml tx packet-recv --receiver-chain ibc-0 --sender-chain ibc-1 --sender-port transfer --sender-channel channel-1 ``` - close-close ```shell - hermes --config 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 + hermes --config config.toml tx chan-close-confirm --receiver-chain ibc-1 --sender-chain ibc-0 --receiver-connection connection-1 --receiver-port transfer --sender-port transfer --receiver-channel channel-1 --sender-channel channel-0 ``` - verify that the two ends are in Close state: @@ -543,10 +543,10 @@ methods involved in a command. __NOTE__: To be able to see the profiling output, the realyer needs to be compiled with the `profiling` feature and the [log level][log-level] should be `info` level or lower. -#### Example output for `tx raw conn-init` command +#### Example output for `tx conn-init` command ``` -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 +hermes --config config.toml tx conn-init --b-chain ibc-0 --a-chain ibc-1 --b-client 07-tendermint-0 --a-client 07-tendermint-0 ``` ``` @@ -617,4 +617,4 @@ Success: CreateClient( [profiling]: ./help.md#profiling [feature]: ./help.md#new-feature-request [patching]: ./help.md#patching-gaia -[chan-close]: ./commands/raw/channel-close.md#channel-close-init +[chan-close]: ./commands/tx/channel-close.md#channel-close-init diff --git a/guide/src/tutorials/local-chains/identifiers.md b/guide/src/tutorials/local-chains/identifiers.md index e2dad5873f..f38e29c1b2 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 --host-chain ibc-1 --reference-chain ibc-0 +hermes create client --host-chain ibc-1 --reference-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 --dst-chain ibc-1 --src-chain ibc-0 --dst-client 07-tendermint-0 --src-client 07-tendermint-0 +hermes tx conn-init --b-chain ibc-1 --a-chain ibc-0 --b-client 07-tendermint-0 --a-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 --dst-chain ibc-1 --src-chain ibc-0 --dst-conn connection-0 --dst-port transfer --src-port transfer +hermes tx chan-open-init --b-chain ibc-1 --a-chain ibc-0 --b-connection connection-0 --b-port transfer --a-port transfer ``` ```json diff --git a/guide/src/tutorials/local-chains/raw/channel.md b/guide/src/tutorials/local-chains/raw/channel.md index 38b4c9263d..5bafb11e27 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 --dst-chain ibc-0 --src-chain ibc-1 --dst-conn connection-0 --dst-port transfer --src-port transfer --order UNORDERED +hermes tx chan-open-init --b-chain ibc-0 --a-chain ibc-1 --b-connection connection-0 --b-port transfer --a-port transfer --order UNORDERED ``` ## 3.2 `chan-open-try` Send a channel open try to `ibc-1`: ```shell -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 +hermes tx chan-open-try --b-chain ibc-1 --a-chain ibc-0 --b-connection connection-1 --b-port transfer --a-port transfer --a-channel 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,14 +20,14 @@ 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 --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 +hermes tx chan-open-ack --b-chain ibc-0 --a-chain ibc-1 --b-connection connection-0 --b-port transfer --a-port transfer --b-channel channel-0 --a-channel channel-1 ``` ## 3.4 `chan-open-confirm` Send the open confirmation to `ibc-1`: ```shell -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 +hermes tx chan-open-confirm --b-chain ibc-1 --a-chain ibc-0 --b-connection connection-1 --b-port transfer --a-port transfer --b-channel channel-1 --a-channel channel-0 ``` ## 3.5 `query channel` diff --git a/guide/src/tutorials/local-chains/raw/client.md b/guide/src/tutorials/local-chains/raw/client.md index ac8186889d..c4464b2129 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 --host-chain ibc-0 --reference-chain ibc-1 +hermes 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 --host-chain ibc-1 --reference-chain ibc-0 +hermes 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). @@ -100,16 +100,16 @@ Success: CreateClient( ) ``` -### 1.2 `update-client` +### 1.2 `update client` Client states can be updated by sending an `update-client` transaction: ```shell -hermes tx raw update-client --host-chain ibc-0 --client 07-tendermint-0 +hermes update client --host-chain ibc-0 --client 07-tendermint-0 ``` ```shell -hermes tx raw update-client --host-chain ibc-1 --client 07-tendermint-1 +hermes update client --host-chain ibc-1 --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 04224b2d6e..e6b4113b83 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 --dst-chain ibc-0 --src-chain ibc-1 --dst-client 07-tendermint-0 --src-client 07-tendermint-1 +hermes conn-init --b-chain ibc-0 --a-chain ibc-1 --b-client 07-tendermint-0 --a-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 --dst-chain ibc-1 --src-chain ibc-0 --dst-client 07-tendermint-1 --src-client 07-tendermint-0 --src-conn connection-0 +hermes tx conn-try --b-chain ibc-1 --a-chain ibc-0 --b-client 07-tendermint-1 --a-client 07-tendermint-0 --a-connection 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 --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 +hermes tx conn-ack --b-chain ibc-0 --a-chain ibc-1 --b-client 07-tendermint-0 --a-client 07-tendermint-1 --b-connection connection-0 --a-connection connection-1 ``` ## 2.4 `conn-confirm` Send the open confirmation to `ibc-1`: ```shell -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 +hermes tx conn-confirm --b-chain ibc-1 --a-chain ibc-0 --b-client 07-tendermint-1 --a-client 07-tendermint-0 --b-connection connection-1 --a-connection connection-0 ``` ## 2.5 `query connection` diff --git a/guide/src/tutorials/local-chains/raw/packet.md b/guide/src/tutorials/local-chains/raw/packet.md index 7647296ec2..bfe4938673 100644 --- a/guide/src/tutorials/local-chains/raw/packet.md +++ b/guide/src/tutorials/local-chains/raw/packet.md @@ -23,7 +23,7 @@ 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 --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 + hermes tx ft-transfer --receiver-chain ibc-1 --sender-chain ibc-0 --sender-port transfer --sender-channel channel-0 --amout 9999 --timeout-height-offset 1000 --number-msgs 1 --denom samoleans ``` - query packet commitments on `ibc-0` @@ -41,7 +41,7 @@ First, we'll send `9999` `samoleans` from `ibc-0` to `ibc-1`. - send `recv_packet` to `ibc-1` ```shell - hermes tx raw packet-recv --dst-chain ibc-1 --src-chain ibc-0 --src-port transfer --src-chan channel-0 + hermes tx packet-recv --receiver-chain ibc-1 --sender-chain ibc-0 --sender-port transfer --sender-channel channel-0 ``` - query pending acks on `ibc-0` @@ -53,15 +53,15 @@ First, we'll send `9999` `samoleans` from `ibc-0` to `ibc-1`. - send acknowledgement to `ibc-0` ```shell - hermes tx raw packet-ack --dst-chain ibc-0 --src-chain ibc-1 --src-port transfer --src-chan channel-1 + hermes tx packet-ack --receiver-chain ibc-0 --sender-chain ibc-1 --sender-port transfer --sender-channel channel-1 ``` Send those samoleans back, from `ibc-1` to `ibc-0`. ```shell -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 +hermes tx ft-transfer --receiver-chain ibc-0 --sender-chain ibc-1 --sender-port transfer --sender-channel channel-1 --amount 9999 --timeout-height-offset 1000 --number-msgs 1 --denom ibc/49D321B40FCF56B0370E5673CF090389C8E9CD185209FBE1BEE5D94E58E69BDC +hermes tx packet-recv --receiver-chain ibc-0 --sender-chain ibc-1 --sender-port transfer --sender-channel channel-1 +hermes tx packet-ack --receiver-chain ibc-1 --sender-chain ibc-0 --sender-port transfer --sender-channel 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 --dst-chain ibc-1 --src-chain ibc-0 --src-port transfer --src-chan channel-0 --amount 9999 --timeout-height-offset 2 --number-msgs 1 + hermes tx ft-transfer --receiver-chain ibc-1 --sender-chain ibc-0 --sender-port transfer --sender-channel channel-0 --amount 9999 --timeout-height-offset 2 --number-msgs 1 ``` - send timeout to `ibc-0` ```shell - hermes tx raw packet-recv --dst-chain ibc-1 --src-chain ibc-0 --src-port transfer --src-chan channel-0 + hermes tx packet-recv --receiver-chain ibc-1 --sender-chain ibc-0 --sender-port transfer --sender-channel channel-0 ``` - send 1 packet with 2 second timeout to ibc-0 ```shell - 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 + hermes tx ft-transfer --receiver-chain ibc-1 --sender-chain ibc-0 --sender-port transfer --sender-channel channel-0 --amount 9999 --timeout-seconds 2 --number-msgs 1 ``` - send timeout to `ibc-0` ```shell - hermes tx raw packet-recv --dst-chain ibc-1 --src-chain ibc-0 --src-port transfer --src-chan channel-0 + hermes tx packet-recv --receiver-chain ibc-1 --sender-chain ibc-0 --sender-port transfer --sender-channel channel-0 ``` 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 9080447475..5c573124e4 100644 --- a/guide/src/tutorials/local-chains/relay-paths/multiple-paths.md +++ b/guide/src/tutorials/local-chains/relay-paths/multiple-paths.md @@ -219,7 +219,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 --dst-chain ibc-1 --src-chain ibc-0 --src-port transfer --src-chan channel-0 --amount 9999 --timeout-height-offset 1000 --number-msgs 2 + hermes tx ft-transfer --receiver-chain ibc-1 --sender-chain ibc-0 --sender-port transfer --sender-channel channel-0 --amount 9999 --timeout-height-offset 1000 --number-msgs 2 ``` ```json @@ -242,7 +242,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 --dst-chain ibc-2 --src-chain ibc-1 --src-port transfer --src-chan channel-1 --amount 9999 --timeout-height-offset 1000 --number-msgs 2 + hermes tx ft-transfer --receiver-chain ibc-2 --sender-chain ibc-1 --sender-port transfer --sender-channel channel-1 --amount 9999 --timeout-height-offset 1000 --number-msgs 2 ``` ```json diff --git a/relayer-cli/src/commands/tx.rs b/relayer-cli/src/commands/tx.rs index 64c3ee31b4..f8cadf766b 100644 --- a/relayer-cli/src/commands/tx.rs +++ b/relayer-cli/src/commands/tx.rs @@ -3,10 +3,6 @@ use abscissa_core::clap::Parser; use abscissa_core::{config::Override, Command, Runnable}; use ibc_relayer::config::Config; -use crate::commands::tx::client::{ - TxCreateClientCmd, TxUpdateClientCmd, TxUpgradeClientCmd, TxUpgradeClientsCmd, -}; - mod channel; pub(crate) mod client; mod connection; @@ -18,77 +14,50 @@ mod upgrade; #[allow(clippy::large_enum_variant)] #[derive(Command, Debug, Parser, Runnable)] pub enum TxCmd { - /// Raw commands for sending transactions to a configured chain. - #[clap(subcommand)] - Raw(TxRawCommands), -} - -#[derive(Command, Debug, Parser, Runnable)] -pub enum TxRawCommands { - /// Create a client for source chain on destination chain - CreateClient(TxCreateClientCmd), - - /// Update the specified client on destination chain - UpdateClient(TxUpdateClientCmd), - - /// Upgrade the specified client on destination chain - UpgradeClient(TxUpgradeClientCmd), - - /// Upgrade all IBC clients that target a specific chain - UpgradeClients(TxUpgradeClientsCmd), - /// Initialize a connection (ConnectionOpenInit) - ConnInit(connection::TxRawConnInitCmd), + ConnInit(connection::TxConnInitCmd), /// Relay the connection attempt (ConnectionOpenTry) - ConnTry(connection::TxRawConnTryCmd), + ConnTry(connection::TxConnTryCmd), /// Relay acknowledgment of a connection attempt (ConnectionOpenAck) - ConnAck(connection::TxRawConnAckCmd), + ConnAck(connection::TxConnAckCmd), /// Confirm opening of a connection (ConnectionOpenConfirm) - ConnConfirm(connection::TxRawConnConfirmCmd), + ConnConfirm(connection::TxConnConfirmCmd), /// Initialize a channel (ChannelOpenInit) - ChanOpenInit(channel::TxRawChanOpenInitCmd), + ChanOpenInit(channel::TxChanOpenInitCmd), /// Relay the channel attempt (ChannelOpenTry) - ChanOpenTry(channel::TxRawChanOpenTryCmd), + ChanOpenTry(channel::TxChanOpenTryCmd), /// Relay acknowledgment of a channel attempt (ChannelOpenAck) - ChanOpenAck(channel::TxRawChanOpenAckCmd), + ChanOpenAck(channel::TxChanOpenAckCmd), /// Confirm opening of a channel (ChannelOpenConfirm) - ChanOpenConfirm(channel::TxRawChanOpenConfirmCmd), + ChanOpenConfirm(channel::TxChanOpenConfirmCmd), /// Initiate the closing of a channel (ChannelCloseInit) - ChanCloseInit(channel::TxRawChanCloseInitCmd), + ChanCloseInit(channel::TxChanCloseInitCmd), /// Confirm the closing of a channel (ChannelCloseConfirm) - ChanCloseConfirm(channel::TxRawChanCloseConfirmCmd), + ChanCloseConfirm(channel::TxChanCloseConfirmCmd), /// Send a fungible token transfer test transaction (ICS20 MsgTransfer) FtTransfer(transfer::TxIcs20MsgTransferCmd), /// Relay receive or timeout packets - PacketRecv(packet::TxRawPacketRecvCmd), + PacketRecv(packet::TxPacketRecvCmd), /// Relay acknowledgment packets - PacketAck(packet::TxRawPacketAckCmd), + PacketAck(packet::TxPacketAckCmd), /// Send an IBC upgrade plan UpgradeChain(upgrade::TxIbcUpgradeChainCmd), } impl Override for TxCmd { - fn override_config(&self, config: Config) -> Result { - match self { - Self::Raw(cmd) => cmd.override_config(config), - } - } -} - -impl Override for TxRawCommands { fn override_config(&self, config: Config) -> Result { match self { Self::FtTransfer(cmd) => cmd.override_config(config), diff --git a/relayer-cli/src/commands/tx/channel.rs b/relayer-cli/src/commands/tx/channel.rs index 3f934bbd40..7d1da1de8f 100644 --- a/relayer-cli/src/commands/tx/channel.rs +++ b/relayer-cli/src/commands/tx/channel.rs @@ -49,40 +49,50 @@ macro_rules! tx_chan_cmd { }; } -#[derive(Clone, Command, Debug, Parser)] -pub struct TxRawChanOpenInitCmd { +#[derive(Clone, Command, Debug, Parser, PartialEq)] +pub struct TxChanOpenInitCmd { #[clap( - long = "dst-chain", + long = "b-chain", required = true, + value_name = "B_CHAIN_ID", + help_heading = "REQUIRED", help = "Identifier of the destination chain" )] dst_chain_id: ChainId, #[clap( - long = "src-chain", + long = "a-chain", required = true, + value_name = "A_CHAIN_ID", + help_heading = "REQUIRED", help = "Identifier of the source chain" )] src_chain_id: ChainId, #[clap( - long = "dst-connection", - alias = "dst-conn", + long = "b-connection", + visible_alias = "b-conn", required = true, + value_name = "B_CONNECTION_ID", + help_heading = "REQUIRED", help = "Identifier of the destination connection" )] dst_conn_id: ConnectionId, #[clap( - long = "dst-port", + long = "b-port", required = true, + value_name = "B_PORT_ID", + help_heading = "REQUIRED", help = "Identifier of the destination port" )] dst_port_id: PortId, #[clap( - long = "src-port", + long = "a-port", required = true, + value_name = "A_PORT_ID", + help_heading = "REQUIRED", help = "Identifier of the source port" )] src_port_id: PortId, @@ -90,12 +100,13 @@ pub struct TxRawChanOpenInitCmd { #[clap( long = "order", default_value_t, + value_name = "ORDER", help = "The channel ordering, valid options 'unordered' (default) and 'ordered'" )] order: Order, } -impl Runnable for TxRawChanOpenInitCmd { +impl Runnable for TxChanOpenInitCmd { fn run(&self) { let config = app_config(); @@ -150,63 +161,74 @@ impl Runnable for TxRawChanOpenInitCmd { } } -#[derive(Clone, Command, Debug, Parser)] -pub struct TxRawChanOpenTryCmd { +#[derive(Clone, Command, Debug, Parser, PartialEq)] +pub struct TxChanOpenTryCmd { #[clap( - long = "dst-chain", + long = "b-chain", required = true, + value_name = "B_CHAIN_ID", + help_heading = "REQUIRED", help = "Identifier of the destination chain" )] dst_chain_id: ChainId, #[clap( - long = "src-chain", + long = "a-chain", required = true, + value_name = "A_CHAIN_ID", + help_heading = "REQUIRED", help = "Identifier of the source chain" )] src_chain_id: ChainId, #[clap( - long = "dst-connection", - alias = "dst-conn", + long = "b-connection", + visible_alias = "b-conn", required = true, + value_name = "B_CONNECTION_ID", + help_heading = "REQUIRED", help = "Identifier of the destination connection" )] dst_conn_id: ConnectionId, #[clap( - long = "dst-port", + long = "b-port", required = true, + value_name = "B_PORT_ID", + help_heading = "REQUIRED", help = "Identifier of the destination port" )] dst_port_id: PortId, #[clap( - long = "src-port", + long = "a-port", required = true, + value_name = "A_PORT_ID", + help_heading = "REQUIRED", help = "Identifier of the source port" )] src_port_id: PortId, #[clap( - long = "src-channel", - alias = "src-chan", + long = "a-channel", + visible_alias = "a-chan", required = true, - help = "Identifier of the source channel (required)", - value_name = "ID" + value_name = "A_CHANNEL_ID", + help_heading = "REQUIRED", + help = "Identifier of the source channel (required)" )] src_chan_id: ChannelId, #[clap( - long = "dst-channel", - alias = "dst-chan", - help = "Identifier of the destination channel (optional)", - value_name = "ID" + long = "b-channel", + visible_alias = "b-chan", + value_name = "B_CHANNEL_ID", + help = "Identifier of the destination channel (optional)" )] dst_chan_id: Option, } -impl Runnable for TxRawChanOpenTryCmd { +impl Runnable for TxChanOpenTryCmd { fn run(&self) { tx_chan_cmd!( "ChanOpenTry", @@ -238,64 +260,76 @@ impl Runnable for TxRawChanOpenTryCmd { } } -#[derive(Clone, Command, Debug, Parser)] -pub struct TxRawChanOpenAckCmd { +#[derive(Clone, Command, Debug, Parser, PartialEq)] +pub struct TxChanOpenAckCmd { #[clap( - long = "dst-chain", + long = "b-chain", required = true, + value_name = "B_CHAIN_ID", + help_heading = "REQUIRED", help = "Identifier of the destination chain" )] dst_chain_id: ChainId, #[clap( - long = "src-chain", + long = "a-chain", required = true, + value_name = "A_CHAIN_ID", + help_heading = "REQUIRED", help = "Identifier of the source chain" )] src_chain_id: ChainId, #[clap( - long = "dst-connection", - alias = "dst-conn", + long = "b-connection", + visible_alias = "b-conn", required = true, + value_name = "B_CONNECTION_ID", + help_heading = "REQUIRED", help = "Identifier of the destination connection" )] dst_conn_id: ConnectionId, #[clap( - long = "dst-port", + long = "b-port", required = true, + value_name = "B_PORT_ID", + help_heading = "REQUIRED", help = "Identifier of the destination port" )] dst_port_id: PortId, #[clap( - long = "src-port", + long = "a-port", required = true, + value_name = "A_PORT_ID", + help_heading = "REQUIRED", help = "Identifier of the source port" )] src_port_id: PortId, #[clap( - long = "dst-channel", - alias = "dst-chan", + long = "b-channel", + visible_alias = "b-chan", required = true, - help = "Identifier of the destination channel (required)", - value_name = "ID" + value_name = "B_CHANNEL_ID", + help_heading = "REQUIRED", + help = "Identifier of the destination channel (required)" )] dst_chan_id: ChannelId, #[clap( - long = "src-channel", - alias = "src-chan", + long = "a-channel", + visible_alias = "a-chan", required = true, - help = "Identifier of the source channel (required)", - value_name = "ID" + value_name = "A_CHANNEL_ID", + help_heading = "REQUIRED", + help = "Identifier of the source channel (required)" )] src_chan_id: ChannelId, } -impl Runnable for TxRawChanOpenAckCmd { +impl Runnable for TxChanOpenAckCmd { fn run(&self) { tx_chan_cmd!( "ChanOpenAck", @@ -327,64 +361,76 @@ impl Runnable for TxRawChanOpenAckCmd { } } -#[derive(Clone, Command, Debug, Parser)] -pub struct TxRawChanOpenConfirmCmd { +#[derive(Clone, Command, Debug, Parser, PartialEq)] +pub struct TxChanOpenConfirmCmd { #[clap( - long = "dst-chain", + long = "b-chain", required = true, + value_name = "B_CHAIN_ID", + help_heading = "REQUIRED", help = "Identifier of the destination chain" )] dst_chain_id: ChainId, #[clap( - long = "src-chain", + long = "a-chain", required = true, + value_name = "A_CHAIN_ID", + help_heading = "REQUIRED", help = "Identifier of the source chain" )] src_chain_id: ChainId, #[clap( - long = "dst-connection", - alias = "dst-conn", + long = "b-connection", + visible_alias = "b-conn", required = true, + value_name = "B_CONNECTION_ID", + help_heading = "REQUIRED", help = "Identifier of the destination connection" )] dst_conn_id: ConnectionId, #[clap( - long = "dst-port", + long = "b-port", required = true, + value_name = "B_PORT_ID", + help_heading = "REQUIRED", help = "Identifier of the destination port" )] dst_port_id: PortId, #[clap( - long = "src-port", + long = "a-port", required = true, + value_name = "A_PORT_ID", + help_heading = "REQUIRED", help = "Identifier of the source port" )] src_port_id: PortId, #[clap( - long = "dst-channel", - alias = "dst-chan", + long = "b-channel", + visible_alias = "b-chan", required = true, - help = "Identifier of the destination channel (required)", - value_name = "ID" + value_name = "B_CHANNEL_ID", + help_heading = "REQUIRED", + help = "Identifier of the destination channel (required)" )] dst_chan_id: ChannelId, #[clap( - long = "src-channel", - alias = "src-chan", + long = "a-channel", + visible_alias = "a-chan", required = true, - help = "Identifier of the source channel (required)", - value_name = "ID" + value_name = "A_CHANNEL_ID", + help_heading = "REQUIRED", + help = "Identifier of the source channel (required)" )] src_chan_id: ChannelId, } -impl Runnable for TxRawChanOpenConfirmCmd { +impl Runnable for TxChanOpenConfirmCmd { fn run(&self) { tx_chan_cmd!( "ChanOpenConfirm", @@ -416,64 +462,76 @@ impl Runnable for TxRawChanOpenConfirmCmd { } } -#[derive(Clone, Command, Debug, Parser)] -pub struct TxRawChanCloseInitCmd { +#[derive(Clone, Command, Debug, Parser, PartialEq)] +pub struct TxChanCloseInitCmd { #[clap( - long = "dst-chain", + long = "b-chain", required = true, + value_name = "B_CHAIN_ID", + help_heading = "REQUIRED", help = "Identifier of the destination chain" )] dst_chain_id: ChainId, #[clap( - long = "src-chain", + long = "a-chain", required = true, + value_name = "A_CHAIN_ID", + help_heading = "REQUIRED", help = "Identifier of the source chain" )] src_chain_id: ChainId, #[clap( - long = "dst-connection", - alias = "dst-conn", + long = "b-connection", + visible_alias = "b-conn", required = true, + value_name = "B_CONNECTION_ID", + help_heading = "REQUIRED", help = "Identifier of the destination connection" )] dst_conn_id: ConnectionId, #[clap( - long = "dst-port", + long = "b-port", required = true, + value_name = "B_PORT_ID", + help_heading = "REQUIRED", help = "Identifier of the destination port" )] dst_port_id: PortId, #[clap( - long = "src-port", + long = "a-port", required = true, + value_name = "A_PORT_ID", + help_heading = "REQUIRED", help = "Identifier of the source port" )] src_port_id: PortId, #[clap( - long = "dst-channel", - alias = "dst-chan", + long = "b-channel", + visible_alias = "b-chan", required = true, - help = "Identifier of the destination channel (required)", - value_name = "ID" + value_name = "B_CHANNEL_ID", + help_heading = "REQUIRED", + help = "Identifier of the destination channel (required)" )] dst_chan_id: ChannelId, #[clap( - long = "src-channel", - alias = "src-chan", + long = "a-channel", + visible_alias = "a-chan", required = true, - help = "Identifier of the source channel (required)", - value_name = "ID" + value_name = "A_CHANNEL_ID", + help_heading = "REQUIRED", + help = "Identifier of the source channel (required)" )] src_chan_id: ChannelId, } -impl Runnable for TxRawChanCloseInitCmd { +impl Runnable for TxChanCloseInitCmd { fn run(&self) { tx_chan_cmd!( "ChanCloseInit", @@ -505,64 +563,76 @@ impl Runnable for TxRawChanCloseInitCmd { } } -#[derive(Clone, Command, Debug, Parser)] -pub struct TxRawChanCloseConfirmCmd { +#[derive(Clone, Command, Debug, Parser, PartialEq)] +pub struct TxChanCloseConfirmCmd { #[clap( - long = "dst-chain", + long = "b-chain", required = true, + value_name = "B_CHAIN_ID", + help_heading = "REQUIRED", help = "Identifier of the destination chain" )] dst_chain_id: ChainId, #[clap( - long = "src-chain", + long = "a-chain", required = true, + value_name = "A_CHAIN_ID", + help_heading = "REQUIRED", help = "Identifier of the source chain" )] src_chain_id: ChainId, #[clap( - long = "dst-connection", - alias = "dst-conn", + long = "b-connection", + visible_alias = "b-conn", required = true, + value_name = "B_CONNECTION_ID", + help_heading = "REQUIRED", help = "Identifier of the destination connection" )] dst_conn_id: ConnectionId, #[clap( - long = "dst-port", + long = "b-port", required = true, + value_name = "B_PORT_ID", + help_heading = "REQUIRED", help = "Identifier of the destination port" )] dst_port_id: PortId, #[clap( - long = "src-port", + long = "a-port", required = true, + value_name = "A_PORT_ID", + help_heading = "REQUIRED", help = "Identifier of the source port" )] src_port_id: PortId, #[clap( - long = "dst-channel", - alias = "dst-chan", + long = "b-channel", + visible_alias = "b-chan", required = true, - help = "Identifier of the destination channel (required)", - value_name = "ID" + value_name = "B_CHANNEL_ID", + help_heading = "REQUIRED", + help = "Identifier of the destination channel (required)" )] dst_chan_id: ChannelId, #[clap( - long = "src-channel", - alias = "src-chan", + long = "a-channel", + visible_alias = "a-chan", required = true, - help = "Identifier of the source channel (required)", - value_name = "ID" + value_name = "A_CHANNEL_ID", + help_heading = "REQUIRED", + help = "Identifier of the source channel (required)" )] src_chan_id: ChannelId, } -impl Runnable for TxRawChanCloseConfirmCmd { +impl Runnable for TxChanCloseConfirmCmd { fn run(&self) { tx_chan_cmd!( "ChanCloseConfirm", @@ -593,3 +663,1200 @@ impl Runnable for TxRawChanCloseConfirmCmd { ); } } + +#[cfg(test)] +mod tests { + use super::{ + TxChanCloseConfirmCmd, TxChanCloseInitCmd, TxChanOpenAckCmd, TxChanOpenConfirmCmd, + TxChanOpenInitCmd, TxChanOpenTryCmd, + }; + + use std::str::FromStr; + + use abscissa_core::clap::Parser; + use ibc::core::{ + ics04_channel::channel::Order, + ics24_host::identifier::{ChainId, ChannelId, ConnectionId, PortId}, + }; + + #[test] + fn test_chan_open_init_required_only() { + assert_eq!( + TxChanOpenInitCmd { + dst_chain_id: ChainId::from_string("chain_b"), + src_chain_id: ChainId::from_string("chain_a"), + dst_conn_id: ConnectionId::from_str("connection_b").unwrap(), + dst_port_id: PortId::from_str("port_b").unwrap(), + src_port_id: PortId::from_str("port_a").unwrap(), + order: Order::Unordered + }, + TxChanOpenInitCmd::parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-connection", + "connection_b", + "--b-port", + "port_b", + "--a-port", + "port_a" + ]) + ) + } + + #[test] + fn test_chan_open_init_order() { + assert_eq!( + TxChanOpenInitCmd { + dst_chain_id: ChainId::from_string("chain_b"), + src_chain_id: ChainId::from_string("chain_a"), + dst_conn_id: ConnectionId::from_str("connection_b").unwrap(), + dst_port_id: PortId::from_str("port_b").unwrap(), + src_port_id: PortId::from_str("port_a").unwrap(), + order: Order::Ordered + }, + TxChanOpenInitCmd::parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-connection", + "connection_b", + "--b-port", + "port_b", + "--a-port", + "port_a", + "--order", + "ordered" + ]) + ) + } + + #[test] + fn test_chan_open_init_aliases() { + assert_eq!( + TxChanOpenInitCmd { + dst_chain_id: ChainId::from_string("chain_b"), + src_chain_id: ChainId::from_string("chain_a"), + dst_conn_id: ConnectionId::from_str("connection_b").unwrap(), + dst_port_id: PortId::from_str("port_b").unwrap(), + src_port_id: PortId::from_str("port_a").unwrap(), + order: Order::Unordered + }, + TxChanOpenInitCmd::parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-conn", + "connection_b", + "--b-port", + "port_b", + "--a-port", + "port_a" + ]) + ) + } + + #[test] + fn test_chan_open_init_no_a_port() { + assert!(TxChanOpenInitCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-connection", + "connection_b", + "--b-port", + "port_b" + ]) + .is_err()) + } + + #[test] + fn test_chan_open_init_no_b_port() { + assert!(TxChanOpenInitCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-connection", + "connection_b", + "--a-port", + "port_a" + ]) + .is_err()) + } + + #[test] + fn test_chan_open_init_no_b_connection() { + assert!(TxChanOpenInitCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-port", + "port_b", + "--a-port", + "port_a" + ]) + .is_err()) + } + + #[test] + fn test_chan_open_init_no_a_chain() { + assert!(TxChanOpenInitCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--b-connection", + "connection_b", + "--b-port", + "port_b", + "--a-port", + "port_a" + ]) + .is_err()) + } + + #[test] + fn test_chan_open_init_no_b_chain() { + assert!(TxChanOpenInitCmd::try_parse_from(&[ + "test", + "--a-chain", + "chain_a", + "--b-connection", + "connection_b", + "--b-port", + "port_b", + "--a-port", + "port_a" + ]) + .is_err()) + } + + #[test] + fn test_chan_open_try_required_only() { + assert_eq!( + TxChanOpenTryCmd { + dst_chain_id: ChainId::from_string("chain_b"), + src_chain_id: ChainId::from_string("chain_a"), + dst_conn_id: ConnectionId::from_str("connection_b").unwrap(), + dst_port_id: PortId::from_str("port_b").unwrap(), + src_port_id: PortId::from_str("port_a").unwrap(), + src_chan_id: ChannelId::from_str("channel_a").unwrap(), + dst_chan_id: None + }, + TxChanOpenTryCmd::parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-connection", + "connection_b", + "--b-port", + "port_b", + "--a-port", + "port_a", + "--a-channel", + "channel_a" + ]) + ) + } + + #[test] + fn test_chan_open_try_b_channel() { + assert_eq!( + TxChanOpenTryCmd { + dst_chain_id: ChainId::from_string("chain_b"), + src_chain_id: ChainId::from_string("chain_a"), + dst_conn_id: ConnectionId::from_str("connection_b").unwrap(), + dst_port_id: PortId::from_str("port_b").unwrap(), + src_port_id: PortId::from_str("port_a").unwrap(), + src_chan_id: ChannelId::from_str("channel_a").unwrap(), + dst_chan_id: Some(ChannelId::from_str("channel_b").unwrap()) + }, + TxChanOpenTryCmd::parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-connection", + "connection_b", + "--b-port", + "port_b", + "--a-port", + "port_a", + "--a-channel", + "channel_a", + "--b-channel", + "channel_b" + ]) + ) + } + + #[test] + fn test_chan_open_try_aliases() { + assert_eq!( + TxChanOpenTryCmd { + dst_chain_id: ChainId::from_string("chain_b"), + src_chain_id: ChainId::from_string("chain_a"), + dst_conn_id: ConnectionId::from_str("connection_b").unwrap(), + dst_port_id: PortId::from_str("port_b").unwrap(), + src_port_id: PortId::from_str("port_a").unwrap(), + src_chan_id: ChannelId::from_str("channel_a").unwrap(), + dst_chan_id: Some(ChannelId::from_str("channel_b").unwrap()) + }, + TxChanOpenTryCmd::parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-conn", + "connection_b", + "--b-port", + "port_b", + "--a-port", + "port_a", + "--a-chan", + "channel_a", + "--b-chan", + "channel_b" + ]) + ) + } + + #[test] + fn test_chan_open_try_no_a_channel() { + assert!(TxChanOpenTryCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-connection", + "connection_b", + "--b-port", + "port_b", + "--a-port", + "port_a" + ]) + .is_err()) + } + + #[test] + fn test_chan_open_try_no_a_port() { + assert!(TxChanOpenTryCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-connection", + "connection_b", + "--b-port", + "port_b", + "--a-channel", + "channel_a" + ]) + .is_err()) + } + + #[test] + fn test_chan_open_try_no_b_port() { + assert!(TxChanOpenTryCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-connection", + "connection_b", + "--a-port", + "port_a", + "--a-channel", + "channel_a" + ]) + .is_err()) + } + + #[test] + fn test_chan_open_try_no_b_connection() { + assert!(TxChanOpenTryCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-port", + "port_b", + "--a-port", + "port_a", + "--a-channel", + "channel_a" + ]) + .is_err()) + } + + #[test] + fn test_chan_open_try_no_a_chain() { + assert!(TxChanOpenTryCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--b-connection", + "connection_b", + "--b-port", + "port_b", + "--a-port", + "port_a", + "--a-channel", + "channel_a" + ]) + .is_err()) + } + + #[test] + fn test_chan_open_try_no_b_chain() { + assert!(TxChanOpenTryCmd::try_parse_from(&[ + "test", + "--a-chain", + "chain_a", + "--b-connection", + "connection_b", + "--b-port", + "port_b", + "--a-port", + "port_a", + "--a-channel", + "channel_a" + ]) + .is_err()) + } + + #[test] + fn test_chan_open_ack() { + assert_eq!( + TxChanOpenAckCmd { + dst_chain_id: ChainId::from_string("chain_b"), + src_chain_id: ChainId::from_string("chain_a"), + dst_conn_id: ConnectionId::from_str("connection_b").unwrap(), + dst_port_id: PortId::from_str("port_b").unwrap(), + src_port_id: PortId::from_str("port_a").unwrap(), + dst_chan_id: ChannelId::from_str("channel_b").unwrap(), + src_chan_id: ChannelId::from_str("channel_a").unwrap() + }, + TxChanOpenAckCmd::parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-connection", + "connection_b", + "--b-port", + "port_b", + "--a-port", + "port_a", + "--b-channel", + "channel_b", + "--a-channel", + "channel_a" + ]) + ) + } + + #[test] + fn test_chan_open_ack_aliases() { + assert_eq!( + TxChanOpenAckCmd { + dst_chain_id: ChainId::from_string("chain_b"), + src_chain_id: ChainId::from_string("chain_a"), + dst_conn_id: ConnectionId::from_str("connection_b").unwrap(), + dst_port_id: PortId::from_str("port_b").unwrap(), + src_port_id: PortId::from_str("port_a").unwrap(), + dst_chan_id: ChannelId::from_str("channel_b").unwrap(), + src_chan_id: ChannelId::from_str("channel_a").unwrap() + }, + TxChanOpenAckCmd::parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-conn", + "connection_b", + "--b-port", + "port_b", + "--a-port", + "port_a", + "--b-chan", + "channel_b", + "--a-chan", + "channel_a" + ]) + ) + } + + #[test] + fn test_chan_open_ack_no_a_channel() { + assert!(TxChanOpenAckCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-connection", + "connection_b", + "--b-port", + "port_b", + "--a-port", + "port_a", + "--b-channel", + "channel_b" + ]) + .is_err()) + } + + #[test] + fn test_chan_open_ack_no_b_channel() { + assert!(TxChanOpenAckCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-connection", + "connection_b", + "--b-port", + "port_b", + "--a-port", + "port_a", + "--a-channel", + "channel_a" + ]) + .is_err()) + } + + #[test] + fn test_chan_open_ack_no_a_port() { + assert!(TxChanOpenAckCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-connection", + "connection_b", + "--b-port", + "port_b", + "--b-channel", + "channel_b", + "--a-channel", + "channel_a" + ]) + .is_err()) + } + + #[test] + fn test_chan_open_ack_no_b_port() { + assert!(TxChanOpenAckCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-connection", + "connection_b", + "--a-port", + "port_a", + "--b-channel", + "channel_b", + "--a-channel", + "channel_a" + ]) + .is_err()) + } + + #[test] + fn test_chan_open_ack_no_b_connection() { + assert!(TxChanOpenAckCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-port", + "port_b", + "--a-port", + "port_a", + "--b-channel", + "channel_b", + "--a-channel", + "channel_a" + ]) + .is_err()) + } + + #[test] + fn test_chan_open_ack_no_a_chain() { + assert!(TxChanOpenAckCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--b-connection", + "connection_b", + "--b-port", + "port_b", + "--a-port", + "port_a", + "--b-channel", + "channel_b", + "--a-channel", + "channel_a" + ]) + .is_err()) + } + + #[test] + fn test_chan_open_ack_no_b_chain() { + assert!(TxChanOpenAckCmd::try_parse_from(&[ + "test", + "--a-chain", + "chain_a", + "--b-connection", + "connection_b", + "--b-port", + "port_b", + "--a-port", + "port_a", + "--b-channel", + "channel_b", + "--a-channel", + "channel_a" + ]) + .is_err()) + } + + #[test] + fn test_chan_open_confirm() { + assert_eq!( + TxChanOpenConfirmCmd { + dst_chain_id: ChainId::from_string("chain_b"), + src_chain_id: ChainId::from_string("chain_a"), + dst_conn_id: ConnectionId::from_str("connection_b").unwrap(), + dst_port_id: PortId::from_str("port_b").unwrap(), + src_port_id: PortId::from_str("port_a").unwrap(), + dst_chan_id: ChannelId::from_str("channel_b").unwrap(), + src_chan_id: ChannelId::from_str("channel_a").unwrap() + }, + TxChanOpenConfirmCmd::parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-connection", + "connection_b", + "--b-port", + "port_b", + "--a-port", + "port_a", + "--b-channel", + "channel_b", + "--a-channel", + "channel_a" + ]) + ) + } + + #[test] + fn test_chan_open_confirm_aliases() { + assert_eq!( + TxChanOpenConfirmCmd { + dst_chain_id: ChainId::from_string("chain_b"), + src_chain_id: ChainId::from_string("chain_a"), + dst_conn_id: ConnectionId::from_str("connection_b").unwrap(), + dst_port_id: PortId::from_str("port_b").unwrap(), + src_port_id: PortId::from_str("port_a").unwrap(), + dst_chan_id: ChannelId::from_str("channel_b").unwrap(), + src_chan_id: ChannelId::from_str("channel_a").unwrap() + }, + TxChanOpenConfirmCmd::parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-conn", + "connection_b", + "--b-port", + "port_b", + "--a-port", + "port_a", + "--b-chan", + "channel_b", + "--a-chan", + "channel_a" + ]) + ) + } + + #[test] + fn test_chan_open_confirm_no_a_channel() { + assert!(TxChanOpenConfirmCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-connection", + "connection_b", + "--b-port", + "port_b", + "--a-port", + "port_a", + "--b-channel", + "channel_b" + ]) + .is_err()) + } + + #[test] + fn test_chan_open_confirm_no_b_channel() { + assert!(TxChanOpenConfirmCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-connection", + "connection_b", + "--b-port", + "port_b", + "--a-port", + "port_a", + "--a-channel", + "channel_a" + ]) + .is_err()) + } + + #[test] + fn test_chan_open_confirm_no_a_port() { + assert!(TxChanOpenConfirmCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-connection", + "connection_b", + "--b-port", + "port_b", + "--b-channel", + "channel_b", + "--a-channel", + "channel_a" + ]) + .is_err()) + } + + #[test] + fn test_chan_open_confirm_no_b_port() { + assert!(TxChanOpenConfirmCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-connection", + "connection_b", + "--a-port", + "port_a", + "--b-channel", + "channel_b", + "--a-channel", + "channel_a" + ]) + .is_err()) + } + + #[test] + fn test_chan_open_confirm_no_b_connection() { + assert!(TxChanOpenConfirmCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-port", + "port_b", + "--a-port", + "port_a", + "--b-channel", + "channel_b", + "--a-channel", + "channel_a" + ]) + .is_err()) + } + + #[test] + fn test_chan_open_confirm_no_a_chain() { + assert!(TxChanOpenConfirmCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--b-connection", + "connection_b", + "--b-port", + "port_b", + "--a-port", + "port_a", + "--b-channel", + "channel_b", + "--a-channel", + "channel_a" + ]) + .is_err()) + } + + #[test] + fn test_chan_open_confirm_no_b_chain() { + assert!(TxChanOpenConfirmCmd::try_parse_from(&[ + "test", + "--a-chain", + "chain_a", + "--b-connection", + "connection_b", + "--b-port", + "port_b", + "--a-port", + "port_a", + "--b-channel", + "channel_b", + "--a-channel", + "channel_a" + ]) + .is_err()) + } + + #[test] + fn test_chan_close_init() { + assert_eq!( + TxChanCloseInitCmd { + dst_chain_id: ChainId::from_string("chain_b"), + src_chain_id: ChainId::from_string("chain_a"), + dst_conn_id: ConnectionId::from_str("connection_b").unwrap(), + dst_port_id: PortId::from_str("port_b").unwrap(), + src_port_id: PortId::from_str("port_a").unwrap(), + dst_chan_id: ChannelId::from_str("channel_b").unwrap(), + src_chan_id: ChannelId::from_str("channel_a").unwrap() + }, + TxChanCloseInitCmd::parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-connection", + "connection_b", + "--b-port", + "port_b", + "--a-port", + "port_a", + "--b-channel", + "channel_b", + "--a-channel", + "channel_a" + ]) + ) + } + + #[test] + fn test_chan_close_init_aliases() { + assert_eq!( + TxChanCloseInitCmd { + dst_chain_id: ChainId::from_string("chain_b"), + src_chain_id: ChainId::from_string("chain_a"), + dst_conn_id: ConnectionId::from_str("connection_b").unwrap(), + dst_port_id: PortId::from_str("port_b").unwrap(), + src_port_id: PortId::from_str("port_a").unwrap(), + dst_chan_id: ChannelId::from_str("channel_b").unwrap(), + src_chan_id: ChannelId::from_str("channel_a").unwrap() + }, + TxChanCloseInitCmd::parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-conn", + "connection_b", + "--b-port", + "port_b", + "--a-port", + "port_a", + "--b-chan", + "channel_b", + "--a-chan", + "channel_a" + ]) + ) + } + + #[test] + fn test_chan_close_init_no_a_channel() { + assert!(TxChanCloseInitCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-connection", + "connection_b", + "--b-port", + "port_b", + "--a-port", + "port_a", + "--b-channel", + "channel_b" + ]) + .is_err()) + } + + #[test] + fn test_chan_close_init_no_b_channel() { + assert!(TxChanCloseInitCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-connection", + "connection_b", + "--b-port", + "port_b", + "--a-port", + "port_a", + "--a-channel", + "channel_a" + ]) + .is_err()) + } + + #[test] + fn test_chan_close_init_no_a_port() { + assert!(TxChanCloseInitCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-connection", + "connection_b", + "--b-port", + "port_b", + "--b-channel", + "channel_b", + "--a-channel", + "channel_a" + ]) + .is_err()) + } + + #[test] + fn test_chan_close_init_no_b_port() { + assert!(TxChanCloseInitCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-connection", + "connection_b", + "--a-port", + "port_a", + "--b-channel", + "channel_b", + "--a-channel", + "channel_a" + ]) + .is_err()) + } + + #[test] + fn test_chan_close_init_no_b_connection() { + assert!(TxChanCloseInitCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-port", + "port_b", + "--a-port", + "port_a", + "--b-channel", + "channel_b", + "--a-channel", + "channel_a" + ]) + .is_err()) + } + + #[test] + fn test_chan_close_init_no_a_chain() { + assert!(TxChanCloseInitCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--b-connection", + "connection_b", + "--b-port", + "port_b", + "--a-port", + "port_a", + "--b-channel", + "channel_b", + "--a-channel", + "channel_a" + ]) + .is_err()) + } + + #[test] + fn test_chan_close_init_no_b_chain() { + assert!(TxChanCloseInitCmd::try_parse_from(&[ + "test", + "--a-chain", + "chain_a", + "--b-connection", + "connection_b", + "--b-port", + "port_b", + "--a-port", + "port_a", + "--b-channel", + "channel_b", + "--a-channel", + "channel_a" + ]) + .is_err()) + } + + #[test] + fn test_chan_close_confirm() { + assert_eq!( + TxChanCloseConfirmCmd { + dst_chain_id: ChainId::from_string("chain_b"), + src_chain_id: ChainId::from_string("chain_a"), + dst_conn_id: ConnectionId::from_str("connection_b").unwrap(), + dst_port_id: PortId::from_str("port_b").unwrap(), + src_port_id: PortId::from_str("port_a").unwrap(), + dst_chan_id: ChannelId::from_str("channel_b").unwrap(), + src_chan_id: ChannelId::from_str("channel_a").unwrap() + }, + TxChanCloseConfirmCmd::parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-connection", + "connection_b", + "--b-port", + "port_b", + "--a-port", + "port_a", + "--b-channel", + "channel_b", + "--a-channel", + "channel_a" + ]) + ) + } + + #[test] + fn test_chan_close_confirm_aliases() { + assert_eq!( + TxChanCloseConfirmCmd { + dst_chain_id: ChainId::from_string("chain_b"), + src_chain_id: ChainId::from_string("chain_a"), + dst_conn_id: ConnectionId::from_str("connection_b").unwrap(), + dst_port_id: PortId::from_str("port_b").unwrap(), + src_port_id: PortId::from_str("port_a").unwrap(), + dst_chan_id: ChannelId::from_str("channel_b").unwrap(), + src_chan_id: ChannelId::from_str("channel_a").unwrap() + }, + TxChanCloseConfirmCmd::parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-conn", + "connection_b", + "--b-port", + "port_b", + "--a-port", + "port_a", + "--b-chan", + "channel_b", + "--a-chan", + "channel_a" + ]) + ) + } + + #[test] + fn test_chan_close_confirm_no_a_channel() { + assert!(TxChanCloseConfirmCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-connection", + "connection_b", + "--b-port", + "port_b", + "--a-port", + "port_a", + "--b-channel", + "channel_b" + ]) + .is_err()) + } + + #[test] + fn test_chan_close_confirm_no_b_channel() { + assert!(TxChanCloseConfirmCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-connection", + "connection_b", + "--b-port", + "port_b", + "--a-port", + "port_a", + "--a-channel", + "channel_a" + ]) + .is_err()) + } + + #[test] + fn test_chan_close_confirm_no_a_port() { + assert!(TxChanCloseConfirmCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-connection", + "connection_b", + "--b-port", + "port_b", + "--b-channel", + "channel_b", + "--a-channel", + "channel_a" + ]) + .is_err()) + } + + #[test] + fn test_chan_close_confirm_no_b_port() { + assert!(TxChanCloseConfirmCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-connection", + "connection_b", + "--a-port", + "port_a", + "--b-channel", + "channel_b", + "--a-channel", + "channel_a" + ]) + .is_err()) + } + + #[test] + fn test_chan_close_confirm_no_b_connection() { + assert!(TxChanCloseConfirmCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-port", + "port_b", + "--a-port", + "port_a", + "--b-channel", + "channel_b", + "--a-channel", + "channel_a" + ]) + .is_err()) + } + + #[test] + fn test_chan_close_confirm_no_a_chain() { + assert!(TxChanCloseConfirmCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--b-connection", + "connection_b", + "--b-port", + "port_b", + "--a-port", + "port_a", + "--b-channel", + "channel_b", + "--a-channel", + "channel_a" + ]) + .is_err()) + } + + #[test] + fn test_chan_close_confirm_no_b_chain() { + assert!(TxChanCloseConfirmCmd::try_parse_from(&[ + "test", + "--a-chain", + "chain_a", + "--b-connection", + "connection_b", + "--b-port", + "port_b", + "--a-port", + "port_a", + "--b-channel", + "channel_b", + "--a-channel", + "channel_a" + ]) + .is_err()) + } +} diff --git a/relayer-cli/src/commands/tx/client.rs b/relayer-cli/src/commands/tx/client.rs index 225dbccc49..04c61bdf82 100644 --- a/relayer-cli/src/commands/tx/client.rs +++ b/relayer-cli/src/commands/tx/client.rs @@ -70,7 +70,7 @@ pub struct TxCreateClientCmd { } /// Sample to run this tx: -/// `hermes tx raw create-client --dst-chain ibc-0 --src-chain ibc-1` +/// `hermes create client --host-chain ibc-0 --reference-chain ibc-1` impl Runnable for TxCreateClientCmd { fn run(&self) { let config = app_config(); diff --git a/relayer-cli/src/commands/tx/connection.rs b/relayer-cli/src/commands/tx/connection.rs index a483a67e7f..561c5c9fee 100644 --- a/relayer-cli/src/commands/tx/connection.rs +++ b/relayer-cli/src/commands/tx/connection.rs @@ -34,38 +34,46 @@ macro_rules! conn_open_cmd { }; } -#[derive(Clone, Command, Debug, Parser)] -pub struct TxRawConnInitCmd { +#[derive(Clone, Command, Debug, Parser, PartialEq)] +pub struct TxConnInitCmd { #[clap( - long = "dst-chain", + long = "b-chain", required = true, + value_name = "B_CHAIN_ID", + help_heading = "REQUIRED", help = "Identifier of the destination chain" )] dst_chain_id: ChainId, #[clap( - long = "src-chain", + long = "a-chain", required = true, + value_name = "A_CHAIN_ID", + help_heading = "REQUIRED", help = "Identifier of the source chain" )] src_chain_id: ChainId, #[clap( - long = "dst-client", + long = "b-client", required = true, + value_name = "B_CLIENT_ID", + help_heading = "REQUIRED", help = "Identifier of the destination client" )] dst_client_id: ClientId, #[clap( - long = "src-client", + long = "a-client", required = true, + value_name = "A_CLIENT_ID", + help_heading = "REQUIRED", help = "Identifier of the source client" )] src_client_id: ClientId, } -impl Runnable for TxRawConnInitCmd { +impl Runnable for TxConnInitCmd { fn run(&self) { conn_open_cmd!( "ConnOpenInit", @@ -82,55 +90,64 @@ impl Runnable for TxRawConnInitCmd { } } -#[derive(Clone, Command, Debug, Parser)] -pub struct TxRawConnTryCmd { +#[derive(Clone, Command, Debug, Parser, PartialEq)] +pub struct TxConnTryCmd { #[clap( - long = "dst-chain", + long = "b-chain", required = true, + value_name = "B_CHAIN_ID", + help_heading = "REQUIRED", help = "Identifier of the destination chain" )] dst_chain_id: ChainId, #[clap( - long = "src-chain", + long = "a-chain", required = true, + value_name = "A_CHAIN_ID", + help_heading = "REQUIRED", help = "Identifier of the source chain" )] src_chain_id: ChainId, #[clap( - long = "dst-client", + long = "b-client", required = true, + value_name = "B_CLIENT_ID", + help_heading = "REQUIRED", help = "Identifier of the destination client" )] dst_client_id: ClientId, #[clap( - long = "src-client", + long = "a-client", required = true, + value_name = "A_CLIENT_ID", + help_heading = "REQUIRED", help = "Identifier of the source client" )] src_client_id: ClientId, #[clap( - long = "src-connection", - alias = "src-conn", + long = "a-connection", + visible_alias = "a-conn", required = true, - help = "Identifier of the source connection (required)", - value_name = "ID" + value_name = "A_CONNECTION_ID", + help_heading = "REQUIRED", + help = "Identifier of the source connection (required)" )] src_conn_id: ConnectionId, #[clap( - long = "dst-connection", - alias = "dst-conn", - help = "Identifier of the destination connection (optional)", - value_name = "ID" + long = "b-connection", + visible_alias = "b-conn", + value_name = "B_CONNECTION_ID", + help = "Identifier of the destination connection (optional)" )] dst_conn_id: Option, } -impl Runnable for TxRawConnTryCmd { +impl Runnable for TxConnTryCmd { fn run(&self) { conn_open_cmd!( "ConnOpenTry", @@ -155,56 +172,66 @@ impl Runnable for TxRawConnTryCmd { } } -#[derive(Clone, Command, Debug, Parser)] -pub struct TxRawConnAckCmd { +#[derive(Clone, Command, Debug, Parser, PartialEq)] +pub struct TxConnAckCmd { #[clap( - long = "dst-chain", + long = "b-chain", required = true, + value_name = "B_CHAIN_ID", + help_heading = "REQUIRED", help = "Identifier of the destination chain" )] dst_chain_id: ChainId, #[clap( - long = "src-chain", + long = "a-chain", required = true, + value_name = "A_CHAIN_ID", + help_heading = "REQUIRED", help = "Identifier of the source chain" )] src_chain_id: ChainId, #[clap( - long = "dst-client", + long = "b-client", required = true, + value_name = "B_CLIENT_ID", + help_heading = "REQUIRED", help = "Identifier of the destination client" )] dst_client_id: ClientId, #[clap( - long = "src-client", + long = "a-client", required = true, + value_name = "A_CLIENT_ID", + help_heading = "REQUIRED", help = "Identifier of the source client" )] src_client_id: ClientId, #[clap( - long = "dst-connection", - alias = "dst-conn", + long = "b-connection", + visible_alias = "b-conn", required = true, - help = "Identifier of the destination connection (required)", - value_name = "ID" + value_name = "B_CONNECTION_ID", + help_heading = "REQUIRED", + help = "Identifier of the destination connection (required)" )] dst_conn_id: ConnectionId, #[clap( - long = "src-connection", - alias = "src-conn", + long = "a-connection", + visible_alias = "a-conn", required = true, - help = "Identifier of the source connection (required)", - value_name = "ID" + value_name = "A_CONNECTION_ID", + help_heading = "REQUIRED", + help = "Identifier of the source connection (required)" )] src_conn_id: ConnectionId, } -impl Runnable for TxRawConnAckCmd { +impl Runnable for TxConnAckCmd { fn run(&self) { conn_open_cmd!( "ConnOpenAck", @@ -229,56 +256,66 @@ impl Runnable for TxRawConnAckCmd { } } -#[derive(Clone, Command, Debug, Parser)] -pub struct TxRawConnConfirmCmd { +#[derive(Clone, Command, Debug, Parser, PartialEq)] +pub struct TxConnConfirmCmd { #[clap( - long = "dst-chain", + long = "b-chain", required = true, + value_name = "B_CHAIN_ID", + help_heading = "REQUIRED", help = "Identifier of the destination chain" )] dst_chain_id: ChainId, #[clap( - long = "src-chain", + long = "a-chain", required = true, + value_name = "A_CHAIN_ID", + help_heading = "REQUIRED", help = "Identifier of the source chain" )] src_chain_id: ChainId, #[clap( - long = "dst-client", + long = "b-client", required = true, + value_name = "B_CLIENT_ID", + help_heading = "REQUIRED", help = "Identifier of the destination client" )] dst_client_id: ClientId, #[clap( - long = "src-client", + long = "a-client", required = true, + value_name = "A_CLIENT_ID", + help_heading = "REQUIRED", help = "Identifier of the source client" )] src_client_id: ClientId, #[clap( - long = "dst-connection", - alias = "dst-conn", + long = "b-connection", + visible_alias = "b-conn", required = true, - help = "Identifier of the destination connection (required)", - value_name = "ID" + value_name = "B_CONNECTION_ID", + help_heading = "REQUIRED", + help = "Identifier of the destination connection (required)" )] dst_conn_id: ConnectionId, #[clap( - long = "src-connection", - alias = "src-conn", + long = "a-connection", + visible_alias = "a-conn", required = true, - help = "Identifier of the source connection (required)", - value_name = "ID" + value_name = "A_CONNECTION_ID", + help_heading = "REQUIRED", + help = "Identifier of the source connection (required)" )] src_conn_id: ConnectionId, } -impl Runnable for TxRawConnConfirmCmd { +impl Runnable for TxConnConfirmCmd { fn run(&self) { conn_open_cmd!( "ConnOpenConfirm", @@ -302,3 +339,589 @@ impl Runnable for TxRawConnConfirmCmd { ); } } + +#[cfg(test)] +mod tests { + use super::{TxConnAckCmd, TxConnConfirmCmd, TxConnInitCmd, TxConnTryCmd}; + + use std::str::FromStr; + + use abscissa_core::clap::Parser; + use ibc::core::ics24_host::identifier::{ChainId, ClientId, ConnectionId}; + + #[test] + fn test_conn_init() { + assert_eq!( + TxConnInitCmd { + dst_chain_id: ChainId::from_string("chain_b"), + src_chain_id: ChainId::from_string("chain_a"), + dst_client_id: ClientId::from_str("client_b-01").unwrap(), + src_client_id: ClientId::from_str("client_a-01").unwrap() + }, + TxConnInitCmd::parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-client", + "client_b-01", + "--a-client", + "client_a-01" + ]) + ) + } + + #[test] + fn test_conn_init_no_a_client() { + assert!(TxConnInitCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-client", + "client_b-01" + ]) + .is_err()) + } + + #[test] + fn test_conn_init_no_b_client() { + assert!(TxConnInitCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--a-client", + "client_a-01" + ]) + .is_err()) + } + + #[test] + fn test_conn_init_no_a_chain() { + assert!(TxConnInitCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--b-client", + "client_b-01", + "--a-client", + "client_a-01" + ]) + .is_err()) + } + + #[test] + fn test_conn_init_no_b_chain() { + assert!(TxConnInitCmd::try_parse_from(&[ + "test", + "--a-chain", + "chain_a", + "--b-client", + "client_b-01", + "--a-client", + "client_a-01" + ]) + .is_err()) + } + + #[test] + fn test_conn_try_required_only() { + assert_eq!( + TxConnTryCmd { + dst_chain_id: ChainId::from_string("chain_b"), + src_chain_id: ChainId::from_string("chain_a"), + dst_client_id: ClientId::from_str("client_b-01").unwrap(), + src_client_id: ClientId::from_str("client_a-01").unwrap(), + src_conn_id: ConnectionId::from_str("connection_a").unwrap(), + dst_conn_id: None + }, + TxConnTryCmd::parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-client", + "client_b-01", + "--a-client", + "client_a-01", + "--a-connection", + "connection_a" + ]) + ) + } + + #[test] + fn test_conn_try_b_connection() { + assert_eq!( + TxConnTryCmd { + dst_chain_id: ChainId::from_string("chain_b"), + src_chain_id: ChainId::from_string("chain_a"), + dst_client_id: ClientId::from_str("client_b-01").unwrap(), + src_client_id: ClientId::from_str("client_a-01").unwrap(), + src_conn_id: ConnectionId::from_str("connection_a").unwrap(), + dst_conn_id: Some(ConnectionId::from_str("connection_b").unwrap()) + }, + TxConnTryCmd::parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-client", + "client_b-01", + "--a-client", + "client_a-01", + "--a-connection", + "connection_a", + "--b-connection", + "connection_b" + ]) + ) + } + + #[test] + fn test_conn_try_b_connection_aliases() { + assert_eq!( + TxConnTryCmd { + dst_chain_id: ChainId::from_string("chain_b"), + src_chain_id: ChainId::from_string("chain_a"), + dst_client_id: ClientId::from_str("client_b-01").unwrap(), + src_client_id: ClientId::from_str("client_a-01").unwrap(), + src_conn_id: ConnectionId::from_str("connection_a").unwrap(), + dst_conn_id: Some(ConnectionId::from_str("connection_b").unwrap()) + }, + TxConnTryCmd::parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-client", + "client_b-01", + "--a-client", + "client_a-01", + "--a-conn", + "connection_a", + "--b-conn", + "connection_b" + ]) + ) + } + + #[test] + fn test_conn_try_no_a_connection() { + assert!(TxConnTryCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-client", + "client_b-01", + "--a-client", + "client_a-01" + ]) + .is_err()) + } + + #[test] + fn test_conn_try_no_a_client() { + assert!(TxConnTryCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-client", + "client_b-01", + "--a-connection", + "connection_a" + ]) + .is_err()) + } + + #[test] + fn test_conn_try_no_b_client() { + assert!(TxConnTryCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--a-client", + "client_a-01", + "--a-connection", + "connection_a" + ]) + .is_err()) + } + + #[test] + fn test_conn_try_no_a_chain() { + assert!(TxConnTryCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--b-client", + "client_b-01", + "--a-client", + "client_a-01", + "--a-connection", + "connection_a" + ]) + .is_err()) + } + + #[test] + fn test_conn_try_no_b_chain() { + assert!(TxConnTryCmd::try_parse_from(&[ + "test", + "--a-chain", + "chain_a", + "--b-client", + "client_b-01", + "--a-client", + "client_a-01", + "--a-connection", + "connection_a" + ]) + .is_err()) + } + + #[test] + fn test_conn_ack() { + assert_eq!( + TxConnAckCmd { + dst_chain_id: ChainId::from_string("chain_b"), + src_chain_id: ChainId::from_string("chain_a"), + dst_client_id: ClientId::from_str("client_b-01").unwrap(), + src_client_id: ClientId::from_str("client_a-01").unwrap(), + dst_conn_id: ConnectionId::from_str("connection_b").unwrap(), + src_conn_id: ConnectionId::from_str("connection_a").unwrap() + }, + TxConnAckCmd::parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-client", + "client_b-01", + "--a-client", + "client_a-01", + "--b-connection", + "connection_b", + "--a-connection", + "connection_a" + ]) + ) + } + + #[test] + fn test_conn_ack_aliases() { + assert_eq!( + TxConnAckCmd { + dst_chain_id: ChainId::from_string("chain_b"), + src_chain_id: ChainId::from_string("chain_a"), + dst_client_id: ClientId::from_str("client_b-01").unwrap(), + src_client_id: ClientId::from_str("client_a-01").unwrap(), + dst_conn_id: ConnectionId::from_str("connection_b").unwrap(), + src_conn_id: ConnectionId::from_str("connection_a").unwrap() + }, + TxConnAckCmd::parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-client", + "client_b-01", + "--a-client", + "client_a-01", + "--b-conn", + "connection_b", + "--a-conn", + "connection_a" + ]) + ) + } + + #[test] + fn test_conn_ack_no_a_connection() { + assert!(TxConnAckCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-client", + "client_b-01", + "--a-client", + "client_a-01", + "--b-connection", + "connection_b" + ]) + .is_err()) + } + + #[test] + fn test_conn_ack_no_b_connection() { + assert!(TxConnAckCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-client", + "client_b-01", + "--a-client", + "client_a-01", + "--a-connection", + "connection_a" + ]) + .is_err()) + } + + #[test] + fn test_conn_ack_no_a_client() { + assert!(TxConnAckCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-client", + "client_b-01", + "--b-connection", + "connection_b", + "--a-connection", + "connection_a" + ]) + .is_err()) + } + + #[test] + fn test_conn_ack_no_b_client() { + assert!(TxConnAckCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--a-client", + "client_a-01", + "--b-connection", + "connection_b", + "--a-connection", + "connection_a" + ]) + .is_err()) + } + + #[test] + fn test_conn_ack_no_a_chain() { + assert!(TxConnAckCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--b-client", + "client_b-01", + "--a-client", + "client_a-01", + "--b-connection", + "connection_b", + "--a-connection", + "connection_a" + ]) + .is_err()) + } + + #[test] + fn test_conn_ack_no_b_chain() { + assert!(TxConnAckCmd::try_parse_from(&[ + "test", + "--a-chain", + "chain_a", + "--b-client", + "client_b-01", + "--a-client", + "client_a-01", + "--b-connection", + "connection_b", + "--a-connection", + "connection_a" + ]) + .is_err()) + } + + #[test] + fn test_conn_confirm() { + assert_eq!( + TxConnConfirmCmd { + dst_chain_id: ChainId::from_string("chain_b"), + src_chain_id: ChainId::from_string("chain_a"), + dst_client_id: ClientId::from_str("client_b-01").unwrap(), + src_client_id: ClientId::from_str("client_a-01").unwrap(), + dst_conn_id: ConnectionId::from_str("connection_b").unwrap(), + src_conn_id: ConnectionId::from_str("connection_a").unwrap() + }, + TxConnConfirmCmd::parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-client", + "client_b-01", + "--a-client", + "client_a-01", + "--b-connection", + "connection_b", + "--a-connection", + "connection_a" + ]) + ) + } + + #[test] + fn test_conn_confirm_aliases() { + assert_eq!( + TxConnConfirmCmd { + dst_chain_id: ChainId::from_string("chain_b"), + src_chain_id: ChainId::from_string("chain_a"), + dst_client_id: ClientId::from_str("client_b-01").unwrap(), + src_client_id: ClientId::from_str("client_a-01").unwrap(), + dst_conn_id: ConnectionId::from_str("connection_b").unwrap(), + src_conn_id: ConnectionId::from_str("connection_a").unwrap() + }, + TxConnConfirmCmd::parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-client", + "client_b-01", + "--a-client", + "client_a-01", + "--b-conn", + "connection_b", + "--a-conn", + "connection_a" + ]) + ) + } + + #[test] + fn test_conn_confirm_no_a_connection() { + assert!(TxConnConfirmCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-client", + "client_b-01", + "--a-client", + "client_a-01", + "--b-connection", + "connection_b" + ]) + .is_err()) + } + + #[test] + fn test_conn_confirm_no_b_connection() { + assert!(TxConnConfirmCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-client", + "client_b-01", + "--a-client", + "client_a-01", + "--a-connection", + "connection_a" + ]) + .is_err()) + } + + #[test] + fn test_conn_confirm_no_a_client() { + assert!(TxConnConfirmCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--b-client", + "client_b-01", + "--b-connection", + "connection_b", + "--a-connection", + "connection_a" + ]) + .is_err()) + } + + #[test] + fn test_conn_confirm_no_b_client() { + assert!(TxConnConfirmCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--a-chain", + "chain_a", + "--a-client", + "client_a-01", + "--b-connection", + "connection_b", + "--a-connection", + "connection_a" + ]) + .is_err()) + } + + #[test] + fn test_conn_confirm_no_a_chain() { + assert!(TxConnConfirmCmd::try_parse_from(&[ + "test", + "--b-chain", + "chain_b", + "--b-client", + "client_b-01", + "--a-client", + "client_a-01", + "--b-connection", + "connection_b", + "--a-connection", + "connection_a" + ]) + .is_err()) + } + + #[test] + fn test_conn_confirm_no_b_chain() { + assert!(TxConnConfirmCmd::try_parse_from(&[ + "test", + "--a-chain", + "chain_a", + "--b-client", + "client_b-01", + "--a-client", + "client_a-01", + "--b-connection", + "connection_b", + "--a-connection", + "connection_a" + ]) + .is_err()) + } +} diff --git a/relayer-cli/src/commands/tx/packet.rs b/relayer-cli/src/commands/tx/packet.rs index 5bc3370986..faeba1e89d 100644 --- a/relayer-cli/src/commands/tx/packet.rs +++ b/relayer-cli/src/commands/tx/packet.rs @@ -10,39 +10,47 @@ use crate::conclude::Output; use crate::error::Error; use crate::prelude::*; -#[derive(Clone, Command, Debug, Parser)] -pub struct TxRawPacketRecvCmd { +#[derive(Clone, Command, Debug, Parser, PartialEq)] +pub struct TxPacketRecvCmd { #[clap( - long = "dst-chain", + long = "receiver-chain", required = true, + value_name = "RECEIVER_CHAIN_ID", + help_heading = "REQUIRED", help = "Identifier of the destination chain" )] dst_chain_id: ChainId, #[clap( - long = "src-chain", + long = "sender-chain", required = true, + value_name = "SENDER_CHAIN_ID", + help_heading = "REQUIRED", help = "Identifier of the source chain" )] src_chain_id: ChainId, #[clap( - long = "src-port", + long = "sender-port", required = true, + value_name = "SENDER_PORT_ID", + help_heading = "REQUIRED", help = "Identifier of the source port" )] src_port_id: PortId, #[clap( - long = "src-channel", - alias = "src-chan", + long = "sender-channel", + visible_alias = "sender-chan", required = true, + value_name = "SENDER_CHANNEL_ID", + help_heading = "REQUIRED", help = "Identifier of the source channel" )] src_channel_id: ChannelId, } -impl Runnable for TxRawPacketRecvCmd { +impl Runnable for TxPacketRecvCmd { fn run(&self) { let config = app_config(); @@ -71,39 +79,47 @@ impl Runnable for TxRawPacketRecvCmd { } } -#[derive(Clone, Command, Debug, Parser)] -pub struct TxRawPacketAckCmd { +#[derive(Clone, Command, Debug, Parser, PartialEq)] +pub struct TxPacketAckCmd { #[clap( - long = "dst-chain", + long = "receiver-chain", required = true, + value_name = "RECEIVER_CHAIN_ID", + help_heading = "REQUIRED", help = "Identifier of the destination chain" )] dst_chain_id: ChainId, #[clap( - long = "src-chain", + long = "sender-chain", required = true, + value_name = "SENDER_CHAIN_ID", + help_heading = "REQUIRED", help = "Identifier of the source chain" )] src_chain_id: ChainId, #[clap( - long = "src-port", + long = "sender-port", required = true, + value_name = "SENDER_PORT_ID", + help_heading = "REQUIRED", help = "Identifier of the source port" )] src_port_id: PortId, #[clap( - long = "src-channel", - alias = "src-chan", + long = "sender-channel", + visible_alias = "sender-chan", required = true, + value_name = "SENDER_CHANNEL_ID", + help_heading = "REQUIRED", help = "Identifier of the source channel" )] src_channel_id: ChannelId, } -impl Runnable for TxRawPacketAckCmd { +impl Runnable for TxPacketAckCmd { fn run(&self) { let config = app_config(); @@ -130,3 +146,217 @@ impl Runnable for TxRawPacketAckCmd { } } } + +#[cfg(test)] +mod tests { + use super::{TxPacketAckCmd, TxPacketRecvCmd}; + + use std::str::FromStr; + + use abscissa_core::clap::Parser; + use ibc::core::ics24_host::identifier::{ChainId, ChannelId, PortId}; + + #[test] + fn test_packet_recv() { + assert_eq!( + TxPacketRecvCmd { + dst_chain_id: ChainId::from_string("chain_receiver"), + src_chain_id: ChainId::from_string("chain_sender"), + src_port_id: PortId::from_str("port_sender").unwrap(), + src_channel_id: ChannelId::from_str("channel_sender").unwrap() + }, + TxPacketRecvCmd::parse_from(&[ + "test", + "--receiver-chain", + "chain_receiver", + "--sender-chain", + "chain_sender", + "--sender-port", + "port_sender", + "--sender-channel", + "channel_sender" + ]) + ) + } + + #[test] + fn test_packet_recv_aliases() { + assert_eq!( + TxPacketRecvCmd { + dst_chain_id: ChainId::from_string("chain_receiver"), + src_chain_id: ChainId::from_string("chain_sender"), + src_port_id: PortId::from_str("port_sender").unwrap(), + src_channel_id: ChannelId::from_str("channel_sender").unwrap() + }, + TxPacketRecvCmd::parse_from(&[ + "test", + "--receiver-chain", + "chain_receiver", + "--sender-chain", + "chain_sender", + "--sender-port", + "port_sender", + "--sender-chan", + "channel_sender" + ]) + ) + } + + #[test] + fn test_packet_recv_no_sender_channel() { + assert!(TxPacketRecvCmd::try_parse_from(&[ + "test", + "--receiver-chain", + "chain_receiver", + "--sender-chain", + "chain_sender", + "--sender-port", + "port_sender" + ]) + .is_err()) + } + + #[test] + fn test_packet_recv_no_sender_port() { + assert!(TxPacketRecvCmd::try_parse_from(&[ + "test", + "--receiver-chain", + "chain_receiver", + "--sender-chain", + "chain_sender", + "--sender-channel", + "channel_sender" + ]) + .is_err()) + } + + #[test] + fn test_packet_recv_no_sender_chain() { + assert!(TxPacketRecvCmd::try_parse_from(&[ + "test", + "--receiver-chain", + "chain_receiver", + "--sender-port", + "port_sender", + "--sender-channel", + "channel_sender" + ]) + .is_err()) + } + + #[test] + fn test_packet_recv_no_receiver_chain() { + assert!(TxPacketRecvCmd::try_parse_from(&[ + "test", + "--sender-chain", + "chain_sender", + "--sender-port", + "port_sender", + "--sender-channel", + "channel_sender" + ]) + .is_err()) + } + + #[test] + fn test_packet_ack() { + assert_eq!( + TxPacketAckCmd { + dst_chain_id: ChainId::from_string("chain_receiver"), + src_chain_id: ChainId::from_string("chain_sender"), + src_port_id: PortId::from_str("port_sender").unwrap(), + src_channel_id: ChannelId::from_str("channel_sender").unwrap() + }, + TxPacketAckCmd::parse_from(&[ + "test", + "--receiver-chain", + "chain_receiver", + "--sender-chain", + "chain_sender", + "--sender-port", + "port_sender", + "--sender-channel", + "channel_sender" + ]) + ) + } + + #[test] + fn test_packet_ack_aliases() { + assert_eq!( + TxPacketAckCmd { + dst_chain_id: ChainId::from_string("chain_receiver"), + src_chain_id: ChainId::from_string("chain_sender"), + src_port_id: PortId::from_str("port_sender").unwrap(), + src_channel_id: ChannelId::from_str("channel_sender").unwrap() + }, + TxPacketAckCmd::parse_from(&[ + "test", + "--receiver-chain", + "chain_receiver", + "--sender-chain", + "chain_sender", + "--sender-port", + "port_sender", + "--sender-chan", + "channel_sender" + ]) + ) + } + + #[test] + fn test_packet_ack_no_sender_channel() { + assert!(TxPacketAckCmd::try_parse_from(&[ + "test", + "--receiver-chain", + "chain_receiver", + "--sender-chain", + "chain_sender", + "--sender-port", + "port_sender" + ]) + .is_err()) + } + + #[test] + fn test_packet_ack_no_sender_port() { + assert!(TxPacketAckCmd::try_parse_from(&[ + "test", + "--receiver-chain", + "chain_receiver", + "--sender-chain", + "chain_sender", + "--sender-channel", + "channel_sender" + ]) + .is_err()) + } + + #[test] + fn test_packet_ack_no_sender_chain() { + assert!(TxPacketAckCmd::try_parse_from(&[ + "test", + "--receiver-chain", + "chain_receiver", + "--sender-port", + "port_sender", + "--sender-channel", + "channel_sender" + ]) + .is_err()) + } + + #[test] + fn test_packet_ack_no_receiver_chain() { + assert!(TxPacketAckCmd::try_parse_from(&[ + "test", + "--sender-chain", + "chain_sender", + "--sender-port", + "port_sender", + "--sender-channel", + "channel_sender" + ]) + .is_err()) + } +} diff --git a/relayer-cli/src/commands/tx/transfer.rs b/relayer-cli/src/commands/tx/transfer.rs index c43a105adb..3555f69850 100644 --- a/relayer-cli/src/commands/tx/transfer.rs +++ b/relayer-cli/src/commands/tx/transfer.rs @@ -24,33 +24,41 @@ 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 TxIcs20MsgTransferCmd { #[clap( - long = "dst-chain", + long = "receiver-chain", required = true, + value_name = "RECEIVER_CHAIN_ID", + help_heading = "REQUIRED", help = "Identifier of the destination chain" )] dst_chain_id: ChainId, #[clap( - long = "src-chain", + long = "sender-chain", required = true, + value_name = "SENDER_CHAIN_ID", + help_heading = "REQUIRED", help = "Identifier of the source chain" )] src_chain_id: ChainId, #[clap( - long = "src-port", + long = "sender-port", required = true, + value_name = "SENDER_PORT_ID", + help_heading = "REQUIRED", help = "Identifier of the source port" )] src_port_id: PortId, #[clap( - long = "src-channel", - alias = "src-chan", + long = "sender-channel", + visible_alias = "sender-chan", required = true, + value_name = "SENDER_CHANNEL_ID", + help_heading = "REQUIRED", help = "Identifier of the source channel" )] src_channel_id: ChannelId, @@ -58,6 +66,8 @@ pub struct TxIcs20MsgTransferCmd { #[clap( long = "amount", required = true, + value_name = "AMOUNT", + help_heading = "REQUIRED", help = "Amount of coins (samoleans, by default) to send (e.g. `100000`)" )] amount: Amount, @@ -65,6 +75,7 @@ pub struct TxIcs20MsgTransferCmd { #[clap( long = "timeout-height-offset", default_value = "0", + value_name = "TIMEOUT_HEIGHT_OFFSET", help = "Timeout in number of blocks since current" )] timeout_height_offset: u64, @@ -72,28 +83,36 @@ pub struct TxIcs20MsgTransferCmd { #[clap( long = "timeout-seconds", default_value = "0", + value_name = "TIMEOUT_SECONDS", help = "Timeout in seconds since current" )] timeout_seconds: u64, #[clap( long = "receiver", + value_name = "RECEIVER", help = "Receiving account address on the destination chain" )] receiver: Option, #[clap( long = "denom", + value_name = "DENOM", help = "Denomination of the coins to send", default_value = "samoleans" )] denom: String, - #[clap(long = "number-msgs", help = "Number of messages to send")] + #[clap( + long = "number-msgs", + value_name = "NUMBER_MSGS", + help = "Number of messages to send" + )] number_msgs: Option, #[clap( long = "key-name", + value_name = "KEY_NAME", help = "Use the given signing key name (default: `key_name` config)" )] key_name: Option, @@ -257,3 +276,364 @@ impl Runnable for TxIcs20MsgTransferCmd { } } } + +#[cfg(test)] +mod tests { + use ibc::{ + applications::transfer::Amount, + core::ics24_host::identifier::{ChainId, ChannelId, PortId}, + }; + + use super::TxIcs20MsgTransferCmd; + + use abscissa_core::clap::Parser; + use std::str::FromStr; + + #[test] + fn test_ft_transfer_required_only() { + assert_eq!( + TxIcs20MsgTransferCmd { + dst_chain_id: ChainId::from_string("chain_receiver"), + src_chain_id: ChainId::from_string("chain_sender"), + src_port_id: PortId::from_str("port_sender").unwrap(), + src_channel_id: ChannelId::from_str("channel_sender").unwrap(), + amount: Amount::from(42), + timeout_height_offset: 0, + timeout_seconds: 0, + receiver: None, + denom: "samoleans".to_owned(), + number_msgs: None, + key_name: None + }, + TxIcs20MsgTransferCmd::parse_from(&[ + "test", + "--receiver-chain", + "chain_receiver", + "--sender-chain", + "chain_sender", + "--sender-port", + "port_sender", + "--sender-channel", + "channel_sender", + "--amount", + "42" + ]) + ) + } + + #[test] + fn test_ft_transfer_aliases() { + assert_eq!( + TxIcs20MsgTransferCmd { + dst_chain_id: ChainId::from_string("chain_receiver"), + src_chain_id: ChainId::from_string("chain_sender"), + src_port_id: PortId::from_str("port_sender").unwrap(), + src_channel_id: ChannelId::from_str("channel_sender").unwrap(), + amount: Amount::from(42), + timeout_height_offset: 0, + timeout_seconds: 0, + receiver: None, + denom: "samoleans".to_owned(), + number_msgs: None, + key_name: None + }, + TxIcs20MsgTransferCmd::parse_from(&[ + "test", + "--receiver-chain", + "chain_receiver", + "--sender-chain", + "chain_sender", + "--sender-port", + "port_sender", + "--sender-chan", + "channel_sender", + "--amount", + "42" + ]) + ) + } + + #[test] + fn test_ft_transfer_denom() { + assert_eq!( + TxIcs20MsgTransferCmd { + dst_chain_id: ChainId::from_string("chain_receiver"), + src_chain_id: ChainId::from_string("chain_sender"), + src_port_id: PortId::from_str("port_sender").unwrap(), + src_channel_id: ChannelId::from_str("channel_sender").unwrap(), + amount: Amount::from(42), + timeout_height_offset: 0, + timeout_seconds: 0, + receiver: None, + denom: "my_denom".to_owned(), + number_msgs: None, + key_name: None + }, + TxIcs20MsgTransferCmd::parse_from(&[ + "test", + "--receiver-chain", + "chain_receiver", + "--sender-chain", + "chain_sender", + "--sender-port", + "port_sender", + "--sender-channel", + "channel_sender", + "--amount", + "42", + "--denom", + "my_denom" + ]) + ) + } + + #[test] + fn test_ft_transfer_key_name() { + assert_eq!( + TxIcs20MsgTransferCmd { + dst_chain_id: ChainId::from_string("chain_receiver"), + src_chain_id: ChainId::from_string("chain_sender"), + src_port_id: PortId::from_str("port_sender").unwrap(), + src_channel_id: ChannelId::from_str("channel_sender").unwrap(), + amount: Amount::from(42), + timeout_height_offset: 0, + timeout_seconds: 0, + receiver: None, + denom: "samoleans".to_owned(), + number_msgs: None, + key_name: Some("key_name".to_owned()) + }, + TxIcs20MsgTransferCmd::parse_from(&[ + "test", + "--receiver-chain", + "chain_receiver", + "--sender-chain", + "chain_sender", + "--sender-port", + "port_sender", + "--sender-channel", + "channel_sender", + "--amount", + "42", + "--key-name", + "key_name" + ]) + ) + } + + #[test] + fn test_ft_transfer_number_msgs() { + assert_eq!( + TxIcs20MsgTransferCmd { + dst_chain_id: ChainId::from_string("chain_receiver"), + src_chain_id: ChainId::from_string("chain_sender"), + src_port_id: PortId::from_str("port_sender").unwrap(), + src_channel_id: ChannelId::from_str("channel_sender").unwrap(), + amount: Amount::from(42), + timeout_height_offset: 0, + timeout_seconds: 0, + receiver: None, + denom: "samoleans".to_owned(), + number_msgs: Some(21), + key_name: None + }, + TxIcs20MsgTransferCmd::parse_from(&[ + "test", + "--receiver-chain", + "chain_receiver", + "--sender-chain", + "chain_sender", + "--sender-port", + "port_sender", + "--sender-channel", + "channel_sender", + "--amount", + "42", + "--number-msgs", + "21" + ]) + ) + } + + #[test] + fn test_ft_transfer_receiver() { + assert_eq!( + TxIcs20MsgTransferCmd { + dst_chain_id: ChainId::from_string("chain_receiver"), + src_chain_id: ChainId::from_string("chain_sender"), + src_port_id: PortId::from_str("port_sender").unwrap(), + src_channel_id: ChannelId::from_str("channel_sender").unwrap(), + amount: Amount::from(42), + timeout_height_offset: 0, + timeout_seconds: 0, + receiver: Some("receiver_addr".to_owned()), + denom: "samoleans".to_owned(), + number_msgs: None, + key_name: None + }, + TxIcs20MsgTransferCmd::parse_from(&[ + "test", + "--receiver-chain", + "chain_receiver", + "--sender-chain", + "chain_sender", + "--sender-port", + "port_sender", + "--sender-channel", + "channel_sender", + "--amount", + "42", + "--receiver", + "receiver_addr" + ]) + ) + } + + #[test] + fn test_ft_transfer_timeout_height_offset() { + assert_eq!( + TxIcs20MsgTransferCmd { + dst_chain_id: ChainId::from_string("chain_receiver"), + src_chain_id: ChainId::from_string("chain_sender"), + src_port_id: PortId::from_str("port_sender").unwrap(), + src_channel_id: ChannelId::from_str("channel_sender").unwrap(), + amount: Amount::from(42), + timeout_height_offset: 21, + timeout_seconds: 0, + receiver: None, + denom: "samoleans".to_owned(), + number_msgs: None, + key_name: None + }, + TxIcs20MsgTransferCmd::parse_from(&[ + "test", + "--receiver-chain", + "chain_receiver", + "--sender-chain", + "chain_sender", + "--sender-port", + "port_sender", + "--sender-channel", + "channel_sender", + "--amount", + "42", + "--timeout-height-offset", + "21" + ]) + ) + } + + #[test] + fn test_ft_transfer_timeout_seconds() { + assert_eq!( + TxIcs20MsgTransferCmd { + dst_chain_id: ChainId::from_string("chain_receiver"), + src_chain_id: ChainId::from_string("chain_sender"), + src_port_id: PortId::from_str("port_sender").unwrap(), + src_channel_id: ChannelId::from_str("channel_sender").unwrap(), + amount: Amount::from(42), + timeout_height_offset: 0, + timeout_seconds: 21, + receiver: None, + denom: "samoleans".to_owned(), + number_msgs: None, + key_name: None + }, + TxIcs20MsgTransferCmd::parse_from(&[ + "test", + "--receiver-chain", + "chain_receiver", + "--sender-chain", + "chain_sender", + "--sender-port", + "port_sender", + "--sender-channel", + "channel_sender", + "--amount", + "42", + "--timeout-seconds", + "21" + ]) + ) + } + + #[test] + fn test_ft_transfer_no_amount() { + assert!(TxIcs20MsgTransferCmd::try_parse_from(&[ + "test", + "--receiver-chain", + "chain_receiver", + "--sender-chain", + "chain_sender", + "--sender-port", + "port_sender", + "--sender-channel", + "channel_sender" + ]) + .is_err()) + } + + #[test] + fn test_ft_transfer_no_sender_channel() { + assert!(TxIcs20MsgTransferCmd::try_parse_from(&[ + "test", + "--receiver-chain", + "chain_receiver", + "--sender-chain", + "chain_sender", + "--sender-port", + "port_sender", + "--amount", + "42" + ]) + .is_err()) + } + + #[test] + fn test_ft_transfer_no_sender_port() { + assert!(TxIcs20MsgTransferCmd::try_parse_from(&[ + "test", + "--receiver-chain", + "chain_receiver", + "--sender-chain", + "chain_sender", + "--sender-channel", + "channel_sender", + "--amount", + "42" + ]) + .is_err()) + } + + #[test] + fn test_ft_transfer_no_sender_chain() { + assert!(TxIcs20MsgTransferCmd::try_parse_from(&[ + "test", + "--receiver-chain", + "chain_receiver", + "--sender-port", + "port_sender", + "--sender-channel", + "channel_sender", + "--amount", + "42" + ]) + .is_err()) + } + + #[test] + fn test_ft_transfer_no_receiver_chain() { + assert!(TxIcs20MsgTransferCmd::try_parse_from(&[ + "test", + "--sender-chain", + "chain_sender", + "--sender-port", + "port_sender", + "--sender-channel", + "channel_sender", + "--amount", + "42" + ]) + .is_err()) + } +} diff --git a/relayer-cli/src/commands/tx/upgrade.rs b/relayer-cli/src/commands/tx/upgrade.rs index 541af9ff2f..f48d41af81 100644 --- a/relayer-cli/src/commands/tx/upgrade.rs +++ b/relayer-cli/src/commands/tx/upgrade.rs @@ -12,62 +12,77 @@ 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 TxIbcUpgradeChainCmd { #[clap( - long = "dst-chain", + long = "receiver-chain", required = true, + value_name = "RECEIVER_CHAIN_ID", + help_heading = "REQUIRED", help = "Identifier of the chain to upgrade" )] dst_chain_id: ChainId, #[clap( - long = "src-chain", + long = "sender-chain", required = true, + value_name = "SENDER_CHAIN_ID", + help_heading = "REQUIRED", help = "Identifier of the source chain" )] src_chain_id: ChainId, #[clap( - long = "src-client", + long = "sender-client", required = true, + value_name = "SENDER_CLIENT_ID", + help_heading = "REQUIRED", help = "Identifier of the client on source chain from which the plan is created" )] src_client_id: ClientId, - #[clap(long = "amount", required = true, help = "Amount of stake")] + #[clap( + long = "amount", + required = true, + value_name = "AMOUNT", + help_heading = "REQUIRED", + help = "Amount of stake" + )] amount: u64, #[clap( long = "height-offset", required = true, + value_name = "HEIGHT_OFFSET", + help_heading = "REQUIRED", help = "Upgrade height offset in number of blocks since current" )] height_offset: u64, #[clap( long = "new-chain", - value_name = "CHAIN-ID", + value_name = "CHAIN_ID", help = "New chain identifier to assign to the upgrading chain (optional)" )] new_chain_id: Option, #[clap( long = "new-unbonding", - value_name = "PERIOD", + value_name = "UNBONDING_PERIOD", help = "New unbonding period to assign to the upgrading chain, in seconds (optional)" )] new_unbonding: Option, #[clap( long = "upgrade-name", - value_name = "NAME", + value_name = "UPGRADE_NAME", help = "A string to name the upgrade proposal plan (default: 'plan')" )] upgrade_name: Option, #[clap( long = "denom", + value_name = "DENOM", help = "Denomination for the deposit (default: 'stake')" )] denom: Option, @@ -137,3 +152,250 @@ impl Runnable for TxIbcUpgradeChainCmd { } } } + +#[cfg(test)] +mod tests { + use super::TxIbcUpgradeChainCmd; + + use abscissa_core::clap::Parser; + use ibc::core::ics24_host::identifier::{ChainId, ClientId}; + use std::str::FromStr; + + #[test] + fn test_upgrade_chain_required_only() { + assert_eq!( + TxIbcUpgradeChainCmd { + dst_chain_id: ChainId::from_string("chain_receiver"), + src_chain_id: ChainId::from_string("chain_sender"), + src_client_id: ClientId::from_str("client_sender").unwrap(), + amount: 42, + height_offset: 21, + new_chain_id: None, + new_unbonding: None, + upgrade_name: None, + denom: None + }, + TxIbcUpgradeChainCmd::parse_from(&[ + "test", + "--receiver-chain", + "chain_receiver", + "--sender-chain", + "chain_sender", + "--sender-client", + "client_sender", + "--amount", + "42", + "--height-offset", + "21" + ]) + ) + } + + #[test] + fn test_upgrade_chain_denom() { + assert_eq!( + TxIbcUpgradeChainCmd { + dst_chain_id: ChainId::from_string("chain_receiver"), + src_chain_id: ChainId::from_string("chain_sender"), + src_client_id: ClientId::from_str("client_sender").unwrap(), + amount: 42, + height_offset: 21, + new_chain_id: None, + new_unbonding: None, + upgrade_name: None, + denom: Some("my_denom".to_owned()) + }, + TxIbcUpgradeChainCmd::parse_from(&[ + "test", + "--receiver-chain", + "chain_receiver", + "--sender-chain", + "chain_sender", + "--sender-client", + "client_sender", + "--amount", + "42", + "--height-offset", + "21", + "--denom", + "my_denom" + ]) + ) + } + + #[test] + fn test_upgrade_chain_new_chain() { + assert_eq!( + TxIbcUpgradeChainCmd { + dst_chain_id: ChainId::from_string("chain_receiver"), + src_chain_id: ChainId::from_string("chain_sender"), + src_client_id: ClientId::from_str("client_sender").unwrap(), + amount: 42, + height_offset: 21, + new_chain_id: Some(ChainId::from_string("new_chain")), + new_unbonding: None, + upgrade_name: None, + denom: None + }, + TxIbcUpgradeChainCmd::parse_from(&[ + "test", + "--receiver-chain", + "chain_receiver", + "--sender-chain", + "chain_sender", + "--sender-client", + "client_sender", + "--amount", + "42", + "--height-offset", + "21", + "--new-chain", + "new_chain" + ]) + ) + } + + #[test] + fn test_upgrade_chain_new_unbonding() { + assert_eq!( + TxIbcUpgradeChainCmd { + dst_chain_id: ChainId::from_string("chain_receiver"), + src_chain_id: ChainId::from_string("chain_sender"), + src_client_id: ClientId::from_str("client_sender").unwrap(), + amount: 42, + height_offset: 21, + new_chain_id: None, + new_unbonding: Some(17), + upgrade_name: None, + denom: None + }, + TxIbcUpgradeChainCmd::parse_from(&[ + "test", + "--receiver-chain", + "chain_receiver", + "--sender-chain", + "chain_sender", + "--sender-client", + "client_sender", + "--amount", + "42", + "--height-offset", + "21", + "--new-unbonding", + "17" + ]) + ) + } + + #[test] + fn test_upgrade_chain_upgrade_name() { + assert_eq!( + TxIbcUpgradeChainCmd { + dst_chain_id: ChainId::from_string("chain_receiver"), + src_chain_id: ChainId::from_string("chain_sender"), + src_client_id: ClientId::from_str("client_sender").unwrap(), + amount: 42, + height_offset: 21, + new_chain_id: None, + new_unbonding: None, + upgrade_name: Some("upgrade_name".to_owned()), + denom: None + }, + TxIbcUpgradeChainCmd::parse_from(&[ + "test", + "--receiver-chain", + "chain_receiver", + "--sender-chain", + "chain_sender", + "--sender-client", + "client_sender", + "--amount", + "42", + "--height-offset", + "21", + "--upgrade-name", + "upgrade_name" + ]) + ) + } + + #[test] + fn test_upgrade_chain_no_height_offset() { + assert!(TxIbcUpgradeChainCmd::try_parse_from(&[ + "test", + "--receiver-chain", + "chain_receiver", + "--sender-chain", + "chain_sender", + "--sender-client", + "client_sender", + "--amount", + "42" + ]) + .is_err()) + } + + #[test] + fn test_upgrade_chain_no_amount() { + assert!(TxIbcUpgradeChainCmd::try_parse_from(&[ + "test", + "--receiver-chain", + "chain_receiver", + "--sender-chain", + "chain_sender", + "--sender-client", + "client_sender", + "--height-offset", + "21" + ]) + .is_err()) + } + + #[test] + fn test_upgrade_chain_no_sender_client() { + assert!(TxIbcUpgradeChainCmd::try_parse_from(&[ + "test", + "--receiver-chain", + "chain_receiver", + "--sender-chain", + "chain_sender", + "--amount", + "42", + "--height-offset", + "21" + ]) + .is_err()) + } + + #[test] + fn test_upgrade_chain_no_sender_chain() { + assert!(TxIbcUpgradeChainCmd::try_parse_from(&[ + "test", + "--receiver-chain", + "chain_receiver", + "--sender-client", + "client_sender", + "--amount", + "42", + "--height-offset", + "21" + ]) + .is_err()) + } + + #[test] + fn test_upgrade_chain_no_receiver_chain() { + assert!(TxIbcUpgradeChainCmd::try_parse_from(&[ + "test", + "--sender-chain", + "chain_sender", + "--sender-client", + "client_sender", + "--amount", + "42", + "--height-offset", + "21" + ]) + .is_err()) + } +} diff --git a/relayer/src/chain/handle/base.rs b/relayer/src/chain/handle/base.rs index ce1e998e32..01178638c4 100644 --- a/relayer/src/chain/handle/base.rs +++ b/relayer/src/chain/handle/base.rs @@ -53,7 +53,7 @@ use crate::{ use super::{reply_channel, ChainHandle, ChainRequest, HealthCheck, ReplyTo, Subscription}; /// A basic chain handle implementation. -/// For use in interactive CLIs, e.g., `query`, `tx raw`, etc. +/// For use in interactive CLIs, e.g., `query`, `tx`, etc. #[derive(Debug, Clone)] pub struct BaseChainHandle { /// Chain identifier diff --git a/tools/integration-test/src/bin/test_setup_with_binary_channel.rs b/tools/integration-test/src/bin/test_setup_with_binary_channel.rs index be1c374f54..ad1eca8775 100644 --- a/tools/integration-test/src/bin/test_setup_with_binary_channel.rs +++ b/tools/integration-test/src/bin/test_setup_with_binary_channel.rs @@ -19,7 +19,7 @@ ```bash $ source /path/to/ibc-rs/data/test-1790156739/binary-channels.env - $ cargo run --bin hermes -- -c $RELAYER_CONFIG tx raw ft-transfer \ + $ cargo run --bin hermes -- -c $RELAYER_CONFIG tx ft-transfer \ $CHAIN_ID_B $CHAIN_ID_A $PORT_A $CHANNEL_ID_A 9999 -o 1000 \ -k $NODE_A_WALLETS_USER1_KEY_ID -d $NODE_A_DENOM ``` diff --git a/tools/integration-test/src/bin/test_setup_with_ternary_channel.rs b/tools/integration-test/src/bin/test_setup_with_ternary_channel.rs index 8d153a7c06..c5ea6765a3 100644 --- a/tools/integration-test/src/bin/test_setup_with_ternary_channel.rs +++ b/tools/integration-test/src/bin/test_setup_with_ternary_channel.rs @@ -19,7 +19,7 @@ ```bash $ source /path/to/ibc-rs/data/test-1790156739/binary-channels.env - $ cargo run --bin hermes -- -c $RELAYER_CONFIG tx raw ft-transfer \ + $ cargo run --bin hermes -- -c $RELAYER_CONFIG tx ft-transfer \ $CHAIN_ID_B $CHAIN_ID_A $PORT_A $CHANNEL_ID_A 9999 -o 1000 \ -k $NODE_A_WALLETS_USER1_KEY_ID -d $NODE_A_DENOM ``` diff --git a/tools/integration-test/src/tests/manual/simulation.rs b/tools/integration-test/src/tests/manual/simulation.rs index df62833202..20296194bf 100644 --- a/tools/integration-test/src/tests/manual/simulation.rs +++ b/tools/integration-test/src/tests/manual/simulation.rs @@ -59,7 +59,7 @@ impl BinaryChannelTest for SimulationTest { } /** - Perform the same operation as `hermes tx raw ft-transfer`. + Perform the same operation as `hermes tx ft-transfer`. The function call skips the checks done in the CLI, as we already have the necessary information given to us by the test framework. diff --git a/tools/test-framework/src/relayer/transfer.rs b/tools/test-framework/src/relayer/transfer.rs index 3a9f2c0bca..61ad23b650 100644 --- a/tools/test-framework/src/relayer/transfer.rs +++ b/tools/test-framework/src/relayer/transfer.rs @@ -1,6 +1,6 @@ /*! Functions for performing IBC transfer that works similar to - `hermes tx raw ft-transfer`. + `hermes tx ft-transfer`. */ use core::ops::Add;