-
Notifications
You must be signed in to change notification settings - Fork 6
/
query_states.go
54 lines (42 loc) · 1.13 KB
/
query_states.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
package cli
import (
"fmt"
"strconv"
"strings"
"github.com/chain4energy/c4e-chain/x/cfedistributor/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/version"
"github.com/spf13/cobra"
)
var _ = strconv.Itoa(0)
func CmdStates() *cobra.Command {
cmd := &cobra.Command{
Use: "states",
Short: fmt.Sprintf("Query current %s states", types.ModuleName),
Long: strings.TrimSpace(
fmt.Sprintf(`Query the current %s states. States contains data for each destination participating in distribution process.
Example:
$ %s query %s states
`,
types.ModuleName, version.AppName, types.ModuleName,
),
),
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) (err error) {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)
params := &types.QueryStatesRequest{}
res, err := queryClient.States(cmd.Context(), params)
if err != nil {
return err
}
return clientCtx.PrintProto(res)
},
}
flags.AddQueryFlagsToCmd(cmd)
return cmd
}