-
Notifications
You must be signed in to change notification settings - Fork 206
/
query_next.go
48 lines (37 loc) · 992 Bytes
/
query_next.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package cli
import (
"strconv"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/lavanet/lava/x/timerstore/types"
"github.com/spf13/cobra"
)
var _ = strconv.Itoa(0)
func CmdNext() *cobra.Command {
cmd := &cobra.Command{
Use: "next [store-key] [prefix]",
Short: "Query next timeout of a specific timer store",
Example: "lavad q timerstore next [store_key] [prefix]",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) (err error) {
storeKey := args[0]
prefix := args[1]
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)
params := &types.QueryNextRequest{
StoreKey: storeKey,
Prefix: prefix,
}
res, err := queryClient.Next(cmd.Context(), params)
if err != nil {
return err
}
return clientCtx.PrintProto(res)
},
}
flags.AddQueryFlagsToCmd(cmd)
return cmd
}