From 68a6615c03e2bbf698a6de7959071a54764693b9 Mon Sep 17 00:00:00 2001 From: Sean King Date: Thu, 7 Apr 2022 15:16:45 +0200 Subject: [PATCH 1/6] feat: adding query for getting incentivized packet by packet-id --- modules/apps/29-fee/client/cli/cli.go | 1 + modules/apps/29-fee/client/cli/query.go | 47 +++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/modules/apps/29-fee/client/cli/cli.go b/modules/apps/29-fee/client/cli/cli.go index 292f1d7b3d8..80a1a6ee1c4 100644 --- a/modules/apps/29-fee/client/cli/cli.go +++ b/modules/apps/29-fee/client/cli/cli.go @@ -18,6 +18,7 @@ func GetQueryCmd() *cobra.Command { GetCmdTotalRecvFees(), GetCmdTotalAckFees(), GetCmdTotalTimeoutFees(), + GetIncentivizedPacketByPacketId(), ) return queryCmd diff --git a/modules/apps/29-fee/client/cli/query.go b/modules/apps/29-fee/client/cli/query.go index 95bb0959ba7..6ee52bf1f28 100644 --- a/modules/apps/29-fee/client/cli/query.go +++ b/modules/apps/29-fee/client/cli/query.go @@ -149,3 +149,50 @@ func GetCmdTotalTimeoutFees() *cobra.Command { return cmd } + +// GetIncentivizedPacketByPacketId returns the unrelayed incentivized packets for a given packetID +func GetIncentivizedPacketByPacketId() *cobra.Command { + cmd := &cobra.Command{ + Use: "packet-by-id [port-id] [channel-id] [sequence]", + Short: "Query for an incentivized packet by packet-id.", + Long: "Query for an incentivized packet packet-id. A packet-id is made up of port-id, channel-id and packet sequence.", + Args: cobra.ExactArgs(3), + Example: fmt.Sprintf("%s query ibc-fee packet-by-id", version.AppName), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + seq, err := strconv.ParseUint(args[2], 10, 64) + if err != nil { + return err + } + + packetId := channeltypes.PacketId{ + PortId: args[0], + ChannelId: args[1], + Sequence: seq, + } + + req := &types.QueryIncentivizedPacketRequest{ + PacketId: packetId, + QueryHeight: uint64(clientCtx.Height), + } + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.IncentivizedPacket(cmd.Context(), req) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + flags.AddPaginationFlagsToCmd(cmd, "packet-by-id") + + return cmd +} From fad47a706e629cb0dab3a46b1b60ba85c382ae9d Mon Sep 17 00:00:00 2001 From: Sean King Date: Thu, 7 Apr 2022 15:27:53 +0200 Subject: [PATCH 2/6] feat: add cli for getting all incentivized packets across all channels --- modules/apps/29-fee/client/cli/cli.go | 1 + modules/apps/29-fee/client/cli/query.go | 41 +++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/modules/apps/29-fee/client/cli/cli.go b/modules/apps/29-fee/client/cli/cli.go index 80a1a6ee1c4..d2ebc0a9920 100644 --- a/modules/apps/29-fee/client/cli/cli.go +++ b/modules/apps/29-fee/client/cli/cli.go @@ -19,6 +19,7 @@ func GetQueryCmd() *cobra.Command { GetCmdTotalAckFees(), GetCmdTotalTimeoutFees(), GetIncentivizedPacketByPacketId(), + GetAllIncentivizedPackets(), ) return queryCmd diff --git a/modules/apps/29-fee/client/cli/query.go b/modules/apps/29-fee/client/cli/query.go index 6ee52bf1f28..78ec3d9d231 100644 --- a/modules/apps/29-fee/client/cli/query.go +++ b/modules/apps/29-fee/client/cli/query.go @@ -196,3 +196,44 @@ func GetIncentivizedPacketByPacketId() *cobra.Command { return cmd } + +// GetAllIncentivizedPackets returns all of the unrelayed incentivized packets +func GetAllIncentivizedPackets() *cobra.Command { + cmd := &cobra.Command{ + Use: "packets", + Short: "Query for all of the unrelayed incentivized packets across all channels.", + Long: "Query for all of the unrelayed incentivized packets across all channels.", + Args: cobra.NoArgs, + Example: fmt.Sprintf("%s query ibc-fee packets", version.AppName), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + req := &types.QueryIncentivizedPacketsRequest{ + Pagination: pageReq, + QueryHeight: uint64(clientCtx.Height), + } + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.IncentivizedPackets(cmd.Context(), req) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + flags.AddPaginationFlagsToCmd(cmd, "packets") + + return cmd +} From 6c7e54798108f3dc05480ac204061f34951ca003 Mon Sep 17 00:00:00 2001 From: Sean King Date: Thu, 7 Apr 2022 16:04:47 +0200 Subject: [PATCH 3/6] nits: suggestions --- modules/apps/29-fee/client/cli/cli.go | 4 ++-- modules/apps/29-fee/client/cli/query.go | 15 +++++++-------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/modules/apps/29-fee/client/cli/cli.go b/modules/apps/29-fee/client/cli/cli.go index d2ebc0a9920..5a53914bc58 100644 --- a/modules/apps/29-fee/client/cli/cli.go +++ b/modules/apps/29-fee/client/cli/cli.go @@ -18,8 +18,8 @@ func GetQueryCmd() *cobra.Command { GetCmdTotalRecvFees(), GetCmdTotalAckFees(), GetCmdTotalTimeoutFees(), - GetIncentivizedPacketByPacketId(), - GetAllIncentivizedPackets(), + GetCmdIncentivizedPacket(), + GetCmdIncentivizedPackets(), ) return queryCmd diff --git a/modules/apps/29-fee/client/cli/query.go b/modules/apps/29-fee/client/cli/query.go index 78ec3d9d231..e23ab3ea5a1 100644 --- a/modules/apps/29-fee/client/cli/query.go +++ b/modules/apps/29-fee/client/cli/query.go @@ -150,10 +150,10 @@ func GetCmdTotalTimeoutFees() *cobra.Command { return cmd } -// GetIncentivizedPacketByPacketId returns the unrelayed incentivized packets for a given packetID -func GetIncentivizedPacketByPacketId() *cobra.Command { +// GetCmdIncentivizedPacket returns the unrelayed incentivized packets for a given packetID +func GetCmdIncentivizedPacket() *cobra.Command { cmd := &cobra.Command{ - Use: "packet-by-id [port-id] [channel-id] [sequence]", + Use: "packet [port-id] [channel-id] [sequence]", Short: "Query for an incentivized packet by packet-id.", Long: "Query for an incentivized packet packet-id. A packet-id is made up of port-id, channel-id and packet sequence.", Args: cobra.ExactArgs(3), @@ -169,14 +169,14 @@ func GetIncentivizedPacketByPacketId() *cobra.Command { return err } - packetId := channeltypes.PacketId{ + packetID := channeltypes.PacketId{ PortId: args[0], ChannelId: args[1], Sequence: seq, } req := &types.QueryIncentivizedPacketRequest{ - PacketId: packetId, + PacketId: packetID, QueryHeight: uint64(clientCtx.Height), } @@ -192,13 +192,12 @@ func GetIncentivizedPacketByPacketId() *cobra.Command { } flags.AddQueryFlagsToCmd(cmd) - flags.AddPaginationFlagsToCmd(cmd, "packet-by-id") return cmd } -// GetAllIncentivizedPackets returns all of the unrelayed incentivized packets -func GetAllIncentivizedPackets() *cobra.Command { +// GetCmdIncentivizedPackets returns all of the unrelayed incentivized packets +func GetCmdIncentivizedPackets() *cobra.Command { cmd := &cobra.Command{ Use: "packets", Short: "Query for all of the unrelayed incentivized packets across all channels.", From a6fd76230877a2a33305ae60511ec196a9322639 Mon Sep 17 00:00:00 2001 From: Sean King Date: Thu, 7 Apr 2022 16:05:39 +0200 Subject: [PATCH 4/6] Update modules/apps/29-fee/client/cli/query.go Co-authored-by: Damian Nolan --- modules/apps/29-fee/client/cli/query.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/apps/29-fee/client/cli/query.go b/modules/apps/29-fee/client/cli/query.go index e23ab3ea5a1..b89869cbc31 100644 --- a/modules/apps/29-fee/client/cli/query.go +++ b/modules/apps/29-fee/client/cli/query.go @@ -200,7 +200,7 @@ func GetCmdIncentivizedPacket() *cobra.Command { func GetCmdIncentivizedPackets() *cobra.Command { cmd := &cobra.Command{ Use: "packets", - Short: "Query for all of the unrelayed incentivized packets across all channels.", + Short: "Query for all of the unrelayed incentivized packets and associated fees across all channels.", Long: "Query for all of the unrelayed incentivized packets across all channels.", Args: cobra.NoArgs, Example: fmt.Sprintf("%s query ibc-fee packets", version.AppName), From c13487b67639f8527af9f45bc92a9ca7ed8f1f3a Mon Sep 17 00:00:00 2001 From: Sean King Date: Thu, 7 Apr 2022 16:41:02 +0200 Subject: [PATCH 5/6] chore: changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a393565403b..80905a6931e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (modules/core/04-channel) [\#1160](https://github.com/cosmos/ibc-go/pull/1160) Improve `uint64 -> string` performance in `Logger`. ### Features +* (modules/apps/29-fee) [\#1229](https://github.com/cosmos/ibc-go/pull/1229) Adding CLI commands for getting all unrelayed incentivized packets and packet by packet-id. ### Bug Fixes From ce1a671d6c85acdfd32fb67bf9baf9dfadb54502 Mon Sep 17 00:00:00 2001 From: Sean King Date: Thu, 7 Apr 2022 17:02:18 +0200 Subject: [PATCH 6/6] nits: comments --- modules/apps/29-fee/client/cli/query.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/apps/29-fee/client/cli/query.go b/modules/apps/29-fee/client/cli/query.go index b89869cbc31..e16cc842360 100644 --- a/modules/apps/29-fee/client/cli/query.go +++ b/modules/apps/29-fee/client/cli/query.go @@ -150,12 +150,12 @@ func GetCmdTotalTimeoutFees() *cobra.Command { return cmd } -// GetCmdIncentivizedPacket returns the unrelayed incentivized packets for a given packetID +// GetCmdIncentivizedPacket returns the unrelayed incentivized packet for a given packetID func GetCmdIncentivizedPacket() *cobra.Command { cmd := &cobra.Command{ Use: "packet [port-id] [channel-id] [sequence]", - Short: "Query for an incentivized packet by packet-id.", - Long: "Query for an incentivized packet packet-id. A packet-id is made up of port-id, channel-id and packet sequence.", + Short: "Query for an unrelayed incentivized packet by port-id, channel-id and packet sequence.", + Long: "Query for an unrelayed incentivized packet by port-id, channel-id and packet sequence.", Args: cobra.ExactArgs(3), Example: fmt.Sprintf("%s query ibc-fee packet-by-id", version.AppName), RunE: func(cmd *cobra.Command, args []string) error { @@ -201,7 +201,7 @@ func GetCmdIncentivizedPackets() *cobra.Command { cmd := &cobra.Command{ Use: "packets", Short: "Query for all of the unrelayed incentivized packets and associated fees across all channels.", - Long: "Query for all of the unrelayed incentivized packets across all channels.", + Long: "Query for all of the unrelayed incentivized packets and associated fees across all channels.", Args: cobra.NoArgs, Example: fmt.Sprintf("%s query ibc-fee packets", version.AppName), RunE: func(cmd *cobra.Command, args []string) error {