/
query_can_propose.go
56 lines (45 loc) · 1.15 KB
/
query_can_propose.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
49
50
51
52
53
54
55
56
package cli
import (
"strconv"
"github.com/KYVENetwork/chain/x/query/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/spf13/cast"
"github.com/spf13/cobra"
)
var _ = strconv.Itoa(0)
func CmdCanPropose() *cobra.Command {
cmd := &cobra.Command{
Use: "can-propose [pool-id] [proposer] [from-height]",
Short: "Query if node can propose next bundle",
Args: cobra.ExactArgs(3),
RunE: func(cmd *cobra.Command, args []string) (err error) {
reqId, err := cast.ToUint64E(args[0])
if err != nil {
return err
}
reqProposer := args[1]
reqFromIndex, err := cast.ToUint64E(args[2])
if err != nil {
return err
}
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryBundlesClient(clientCtx)
params := &types.QueryCanProposeRequest{
PoolId: reqId,
Proposer: reqProposer,
FromIndex: reqFromIndex,
}
res, err := queryClient.CanPropose(cmd.Context(), params)
if err != nil {
return err
}
return clientCtx.PrintProto(res)
},
}
flags.AddQueryFlagsToCmd(cmd)
return cmd
}