Skip to content

Commit 68a6615

Browse files
committed
feat: adding query for getting incentivized packet by packet-id
1 parent 7447b60 commit 68a6615

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

modules/apps/29-fee/client/cli/cli.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ func GetQueryCmd() *cobra.Command {
1818
GetCmdTotalRecvFees(),
1919
GetCmdTotalAckFees(),
2020
GetCmdTotalTimeoutFees(),
21+
GetIncentivizedPacketByPacketId(),
2122
)
2223

2324
return queryCmd

modules/apps/29-fee/client/cli/query.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,50 @@ func GetCmdTotalTimeoutFees() *cobra.Command {
149149

150150
return cmd
151151
}
152+
153+
// GetIncentivizedPacketByPacketId returns the unrelayed incentivized packets for a given packetID
154+
func GetIncentivizedPacketByPacketId() *cobra.Command {
155+
cmd := &cobra.Command{
156+
Use: "packet-by-id [port-id] [channel-id] [sequence]",
157+
Short: "Query for an incentivized packet by packet-id.",
158+
Long: "Query for an incentivized packet packet-id. A packet-id is made up of port-id, channel-id and packet sequence.",
159+
Args: cobra.ExactArgs(3),
160+
Example: fmt.Sprintf("%s query ibc-fee packet-by-id", version.AppName),
161+
RunE: func(cmd *cobra.Command, args []string) error {
162+
clientCtx, err := client.GetClientQueryContext(cmd)
163+
if err != nil {
164+
return err
165+
}
166+
167+
seq, err := strconv.ParseUint(args[2], 10, 64)
168+
if err != nil {
169+
return err
170+
}
171+
172+
packetId := channeltypes.PacketId{
173+
PortId: args[0],
174+
ChannelId: args[1],
175+
Sequence: seq,
176+
}
177+
178+
req := &types.QueryIncentivizedPacketRequest{
179+
PacketId: packetId,
180+
QueryHeight: uint64(clientCtx.Height),
181+
}
182+
183+
queryClient := types.NewQueryClient(clientCtx)
184+
185+
res, err := queryClient.IncentivizedPacket(cmd.Context(), req)
186+
if err != nil {
187+
return err
188+
}
189+
190+
return clientCtx.PrintProto(res)
191+
},
192+
}
193+
194+
flags.AddQueryFlagsToCmd(cmd)
195+
flags.AddPaginationFlagsToCmd(cmd, "packet-by-id")
196+
197+
return cmd
198+
}

0 commit comments

Comments
 (0)