-
Notifications
You must be signed in to change notification settings - Fork 655
/
Copy pathquery.go
75 lines (61 loc) · 2.25 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
63
64
65
66
67
68
69
70
71
72
73
74
75
package cli
import (
"fmt"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/version"
"github.com/spf13/cobra"
"github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/controller/types"
)
// GetCmdQueryInterchainAccount returns the command handler for the controller submodule parameter querying.
func GetCmdQueryInterchainAccount() *cobra.Command {
cmd := &cobra.Command{
Use: "interchain-account [owner] [connection-id]",
Short: "Query the interchain account address for a given owner on a particular connection",
Long: "Query the controller submodule for the interchain account address for a given owner on a particular connection",
Args: cobra.ExactArgs(2),
Example: fmt.Sprintf("%s query interchain-accounts controller interchain-account cosmos1layxcsmyye0dc0har9sdfzwckaz8sjwlfsj8zs connection-0", version.AppName),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)
req := &types.QueryInterchainAccountRequest{
Owner: args[0],
ConnectionId: args[1],
}
res, err := queryClient.InterchainAccount(cmd.Context(), req)
if err != nil {
return err
}
return clientCtx.PrintProto(res)
},
}
flags.AddQueryFlagsToCmd(cmd)
return cmd
}
// GetCmdParams returns the command handler for the controller submodule parameter querying.
func GetCmdParams() *cobra.Command {
cmd := &cobra.Command{
Use: "params",
Short: "Query the current interchain-accounts controller submodule parameters",
Long: "Query the current interchain-accounts controller submodule parameters",
Args: cobra.NoArgs,
Example: fmt.Sprintf("%s query interchain-accounts controller params", version.AppName),
RunE: func(cmd *cobra.Command, _ []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)
res, err := queryClient.Params(cmd.Context(), &types.QueryParamsRequest{})
if err != nil {
return err
}
return clientCtx.PrintProto(res.Params)
},
}
flags.AddQueryFlagsToCmd(cmd)
return cmd
}