Skip to content

Commit fad47a7

Browse files
committed
feat: add cli for getting all incentivized packets across all channels
1 parent 68a6615 commit fad47a7

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

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

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ func GetQueryCmd() *cobra.Command {
1919
GetCmdTotalAckFees(),
2020
GetCmdTotalTimeoutFees(),
2121
GetIncentivizedPacketByPacketId(),
22+
GetAllIncentivizedPackets(),
2223
)
2324

2425
return queryCmd

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

+41
Original file line numberDiff line numberDiff line change
@@ -196,3 +196,44 @@ func GetIncentivizedPacketByPacketId() *cobra.Command {
196196

197197
return cmd
198198
}
199+
200+
// GetAllIncentivizedPackets returns all of the unrelayed incentivized packets
201+
func GetAllIncentivizedPackets() *cobra.Command {
202+
cmd := &cobra.Command{
203+
Use: "packets",
204+
Short: "Query for all of the unrelayed incentivized packets across all channels.",
205+
Long: "Query for all of the unrelayed incentivized packets across all channels.",
206+
Args: cobra.NoArgs,
207+
Example: fmt.Sprintf("%s query ibc-fee packets", version.AppName),
208+
RunE: func(cmd *cobra.Command, args []string) error {
209+
clientCtx, err := client.GetClientQueryContext(cmd)
210+
if err != nil {
211+
return err
212+
}
213+
214+
pageReq, err := client.ReadPageRequest(cmd.Flags())
215+
if err != nil {
216+
return err
217+
}
218+
219+
req := &types.QueryIncentivizedPacketsRequest{
220+
Pagination: pageReq,
221+
QueryHeight: uint64(clientCtx.Height),
222+
}
223+
224+
queryClient := types.NewQueryClient(clientCtx)
225+
226+
res, err := queryClient.IncentivizedPackets(cmd.Context(), req)
227+
if err != nil {
228+
return err
229+
}
230+
231+
return clientCtx.PrintProto(res)
232+
},
233+
}
234+
235+
flags.AddQueryFlagsToCmd(cmd)
236+
flags.AddPaginationFlagsToCmd(cmd, "packets")
237+
238+
return cmd
239+
}

0 commit comments

Comments
 (0)