Skip to content

Commit

Permalink
feat: adding CLI for getting incentivized packets on a specific chann…
Browse files Browse the repository at this point in the history
…el (#1230)

* feat: adding CLI for getting incentivized packets on a specific channel

* chore: changelog

* refactor: usage
  • Loading branch information
seantking authored Apr 8, 2022
1 parent c5897ae commit b71bbf2
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ 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) [\#1230](https://github.com/cosmos/ibc-go/pull/1230) Adding CLI command for getting incentivized packets for a specific channel-id.


* [\#276](https://github.com/cosmos/ibc-go/pull/276) Adding the Fee Middleware module v1
* (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.
Expand Down
1 change: 1 addition & 0 deletions modules/apps/29-fee/client/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func GetQueryCmd() *cobra.Command {
GetCmdTotalRecvFees(),
GetCmdTotalAckFees(),
GetCmdTotalTimeoutFees(),
GetCmdIncentivizedPacketsForChannel(),
GetCmdCounterpartyAddress(),
GetCmdFeeEnabledChannel(),
GetCmdFeeEnabledChannels(),
Expand Down
43 changes: 43 additions & 0 deletions modules/apps/29-fee/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,3 +350,46 @@ func GetCmdFeeEnabledChannel() *cobra.Command {

return cmd
}

// GetCmdIncentivizedPacketsForChannel returns all of the unrelayed incentivized packets on a given channel
func GetCmdIncentivizedPacketsForChannel() *cobra.Command {
cmd := &cobra.Command{
Use: "packets-for-channel [port-id] [channel-id]",
Short: "Query for all of the unrelayed incentivized packets on a given channel",
Long: "Query for all of the unrelayed incentivized packets on a given channel. These are packets that have not yet been relayed.",
Args: cobra.ExactArgs(2),
Example: fmt.Sprintf("%s query ibc-fee packets-for-channel", 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.QueryIncentivizedPacketsForChannelRequest{
Pagination: pageReq,
PortId: args[0],
ChannelId: args[1],
QueryHeight: uint64(clientCtx.Height),
}

queryClient := types.NewQueryClient(clientCtx)

res, err := queryClient.IncentivizedPacketsForChannel(cmd.Context(), req)
if err != nil {
return err
}

return clientCtx.PrintProto(res)
},
}

flags.AddQueryFlagsToCmd(cmd)
flags.AddPaginationFlagsToCmd(cmd, "packets-for-channel")

return cmd
}

0 comments on commit b71bbf2

Please sign in to comment.