Skip to content

Commit 8595e33

Browse files
committed
cmd: add pagination and sorting to tapcli addr receives
1 parent 8145efc commit 8595e33

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

cmd/commands/addrs.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ const (
158158
limitName = "limit"
159159

160160
offsetName = "offset"
161+
162+
directionName = "direction"
161163
)
162164

163165
var queryAddrsCommand = cli.Command{
@@ -283,6 +285,20 @@ var receivesAddrCommand = cli.Command{
283285
Name: addrName,
284286
Usage: "show transfers of a single address only",
285287
},
288+
cli.Int64Flag{
289+
Name: limitName,
290+
Usage: "the max number of events returned",
291+
},
292+
cli.Int64Flag{
293+
Name: offsetName,
294+
Usage: "the number of events to skip",
295+
},
296+
cli.StringFlag{
297+
Name: directionName,
298+
Usage: "the sort direction for events (asc or desc). " +
299+
"Defaults to desc.",
300+
Value: "desc",
301+
},
286302
},
287303
Action: addrReceives,
288304
}
@@ -301,8 +317,16 @@ func addrReceives(ctx *cli.Context) error {
301317
addr = ctx.Args().First()
302318
}
303319

320+
direction := taprpc.SortDirection_SORT_DIRECTION_DESC
321+
if ctx.String(directionName) == "asc" {
322+
direction = taprpc.SortDirection_SORT_DIRECTION_ASC
323+
}
324+
304325
resp, err := client.AddrReceives(ctxc, &taprpc.AddrReceivesRequest{
305326
FilterAddr: addr,
327+
Limit: int32(ctx.Int64(limitName)),
328+
Offset: int32(ctx.Int64(offsetName)),
329+
Direction: direction,
306330
})
307331
if err != nil {
308332
return fmt.Errorf("unable to query addr receives: %w", err)

0 commit comments

Comments
 (0)