-
Notifications
You must be signed in to change notification settings - Fork 684
/
Copy pathquery.go
52 lines (40 loc) · 1.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
package cli
import (
"context"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/spf13/cobra"
"github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types"
)
func GetQueryCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "interchain-accounts",
Aliases: []string{"ica"},
Short: "Querying commands for the interchain accounts module",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}
cmd.AddCommand(GetInterchainAccountCmd())
return cmd
}
func GetInterchainAccountCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "address [counterparty-port-id]",
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}
counterpartyPortID := args[0]
queryClient := types.NewQueryClient(clientCtx)
res, err := queryClient.InterchainAccountAddress(context.Background(), &types.QueryInterchainAccountAddressRequest{CounterpartyPortId: counterpartyPortID})
if err != nil {
return err
}
return clientCtx.PrintProto(res)
},
}
flags.AddQueryFlagsToCmd(cmd)
return cmd
}