From 2cfdf81707f391c5087d938d4e43a994f910ce2f Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Wed, 26 May 2021 12:46:31 -0400 Subject: [PATCH 1/3] New cmd: query ibc-transfer escrow-address --- modules/apps/transfer/client/cli/cli.go | 1 + modules/apps/transfer/client/cli/query.go | 25 +++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/modules/apps/transfer/client/cli/cli.go b/modules/apps/transfer/client/cli/cli.go index d3ca8341e95..643af504178 100644 --- a/modules/apps/transfer/client/cli/cli.go +++ b/modules/apps/transfer/client/cli/cli.go @@ -19,6 +19,7 @@ func GetQueryCmd() *cobra.Command { GetCmdQueryDenomTrace(), GetCmdQueryDenomTraces(), GetCmdParams(), + GetCmdQueryEscrowAddress(), ) return queryCmd diff --git a/modules/apps/transfer/client/cli/query.go b/modules/apps/transfer/client/cli/query.go index 6dd2e6cf8dc..fdb62044126 100644 --- a/modules/apps/transfer/client/cli/query.go +++ b/modules/apps/transfer/client/cli/query.go @@ -106,3 +106,28 @@ func GetCmdParams() *cobra.Command { return cmd } + +// GetCmdParams returns the command handler for ibc-transfer parameter querying. +func GetCmdQueryEscrowAddress() *cobra.Command { + cmd := &cobra.Command{ + Use: "escrow-address", + Short: "Get the escrow address for a channel", + Long: "Get the escrow address for a channel", + Args: cobra.ExactArgs(2), + Example: fmt.Sprintf("%s query ibc-transfer escrow-address [port] [channel-id]", version.AppName), + RunE: func(cmd *cobra.Command, _ []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + port := args[0] + channel := args[1] + addr := GetEscrowAddress(port, channel) + return clientCtx.PrintProto(addr.String()) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} From 860ec6ce3681a90908a67cf52299af9c8159dcc4 Mon Sep 17 00:00:00 2001 From: Aditya Date: Wed, 26 May 2021 15:50:24 -0400 Subject: [PATCH 2/3] Update modules/apps/transfer/client/cli/query.go --- modules/apps/transfer/client/cli/query.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/apps/transfer/client/cli/query.go b/modules/apps/transfer/client/cli/query.go index fdb62044126..43ff3e73064 100644 --- a/modules/apps/transfer/client/cli/query.go +++ b/modules/apps/transfer/client/cli/query.go @@ -122,7 +122,7 @@ func GetCmdQueryEscrowAddress() *cobra.Command { } port := args[0] channel := args[1] - addr := GetEscrowAddress(port, channel) + addr := types.GetEscrowAddress(port, channel) return clientCtx.PrintProto(addr.String()) }, } From 94f184d73b76f954c1c27d312f8b951ecd34fe90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Colin=20Axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Thu, 27 May 2021 12:26:57 +0200 Subject: [PATCH 3/3] fix build, add changelog --- CHANGELOG.md | 4 ++++ modules/apps/transfer/client/cli/query.go | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e7c5fa7795..1a0bf9e12de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -73,6 +73,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (modules/light-clients/07-tendermint) [\#125](https://github.com/cosmos/ibc-go/pull/125) Implement efficient iteration of consensus states and pruning of earliest expired consensus state on UpdateClient. * (modules/light-clients/07-tendermint) [\#141](https://github.com/cosmos/ibc-go/pull/141) Return early in case there's a duplicate update call to save Gas. +### Features + +* [\#198](https://github.com/cosmos/ibc-go/pull/198) New CLI command `query ibc-transfer escrow-address ` to get the escrow address for a channel; can be used to then query balance of escrowed tokens + ## IBC in the Cosmos SDK Repository diff --git a/modules/apps/transfer/client/cli/query.go b/modules/apps/transfer/client/cli/query.go index 43ff3e73064..3bf09c56b52 100644 --- a/modules/apps/transfer/client/cli/query.go +++ b/modules/apps/transfer/client/cli/query.go @@ -115,7 +115,7 @@ func GetCmdQueryEscrowAddress() *cobra.Command { Long: "Get the escrow address for a channel", Args: cobra.ExactArgs(2), Example: fmt.Sprintf("%s query ibc-transfer escrow-address [port] [channel-id]", version.AppName), - RunE: func(cmd *cobra.Command, _ []string) error { + RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { return err @@ -123,7 +123,7 @@ func GetCmdQueryEscrowAddress() *cobra.Command { port := args[0] channel := args[1] addr := types.GetEscrowAddress(port, channel) - return clientCtx.PrintProto(addr.String()) + return clientCtx.PrintString(fmt.Sprintf("%s\n", addr.String())) }, }