Skip to content

Commit

Permalink
feat: add cli for getting all incentivized packets across all channels
Browse files Browse the repository at this point in the history
  • Loading branch information
seantking committed Apr 7, 2022
1 parent 68a6615 commit fad47a7
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
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 @@ -19,6 +19,7 @@ func GetQueryCmd() *cobra.Command {
GetCmdTotalAckFees(),
GetCmdTotalTimeoutFees(),
GetIncentivizedPacketByPacketId(),
GetAllIncentivizedPackets(),
)

return queryCmd
Expand Down
41 changes: 41 additions & 0 deletions modules/apps/29-fee/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit fad47a7

Please sign in to comment.