Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions modules/apps/29-fee/client/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ func GetQueryCmd() *cobra.Command {
GetCmdTotalRecvFees(),
GetCmdTotalAckFees(),
GetCmdTotalTimeoutFees(),
GetIncentivizedPacketByPacketId(),
GetAllIncentivizedPackets(),
)

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

// 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
}