This repository has been archived by the owner on Jul 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
query.go
62 lines (52 loc) · 1.58 KB
/
query.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
57
58
59
60
61
62
package cli
import (
"fmt"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/spf13/cobra"
"github.com/coinexchain/cet-sdk/modules/authx/internal/types"
"github.com/coinexchain/cosmos-utils/client/cliutil"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth"
)
// get the root query command of this module
func GetQueryCmd(cdc *codec.Codec) *cobra.Command {
// Group asset queries under a subcommand
assQueryCmd := &cobra.Command{
Use: auth.ModuleName,
Short: "Querying commands for the auth module",
}
assQueryCmd.AddCommand(client.GetCommands(
GetQueryParamsCmd(cdc),
)...)
return assQueryCmd
}
func GetQueryParamsCmd(cdc *codec.Codec) *cobra.Command {
return &cobra.Command{
Use: "params",
Args: cobra.NoArgs,
Short: "Query auth params",
RunE: func(cmd *cobra.Command, args []string) error {
route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryParameters)
return cliutil.CliQuery(cdc, route, nil)
},
}
}
func GetAccountXCmd(cdc *codec.Codec) *cobra.Command {
cmd := &cobra.Command{
Use: "account [address]",
Short: "Query account balance",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryAccountMix)
acc, err := sdk.AccAddressFromBech32(args[0])
if err != nil {
return err
}
param := auth.NewQueryAccountParams(acc)
return cliutil.CliQuery(cdc, route, ¶m)
},
}
return flags.GetCommands(cmd)[0]
}