Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cli query for host and controller params #578

Merged
merged 6 commits into from
Dec 1, 2021
Merged
26 changes: 26 additions & 0 deletions modules/apps/27-interchain-accounts/client/cli/cli.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package cli

import (
"github.com/spf13/cobra"

controllercli "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/controller/client/cli"
hostcli "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/host/client/cli"
)

// GetQueryCmd returns the query commands for the interchain-accounts submodule
func GetQueryCmd() *cobra.Command {
icaQueryCmd := &cobra.Command{
Use: "interchain-accounts",
Aliases: []string{"ica"},
Short: "interchain-accounts subcommands",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
}

icaQueryCmd.AddCommand(
controllercli.GetQueryCmd(),
hostcli.GetQueryCmd(),
)

return icaQueryCmd
}
21 changes: 21 additions & 0 deletions modules/apps/27-interchain-accounts/controller/client/cli/cli.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package cli

import (
"github.com/spf13/cobra"
)

// GetQueryCmd returns the query commands for the ICA controller submodule
func GetQueryCmd() *cobra.Command {
queryCmd := &cobra.Command{
Use: "controller",
Short: "interchain-accounts controller subcommands",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
}

queryCmd.AddCommand(
GetCmdParams(),
)

return queryCmd
}
37 changes: 37 additions & 0 deletions modules/apps/27-interchain-accounts/controller/client/cli/query.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package cli

import (
"fmt"

"github.com/spf13/cobra"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/controller/types"
)

// 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, _ := queryClient.Params(cmd.Context(), &types.QueryParamsRequest{})
return clientCtx.PrintProto(res.Params)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}
21 changes: 21 additions & 0 deletions modules/apps/27-interchain-accounts/host/client/cli/cli.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package cli

import (
"github.com/spf13/cobra"
)

// GetQueryCmd returns the query commands for the ICA host submodule
func GetQueryCmd() *cobra.Command {
queryCmd := &cobra.Command{
Use: "host",
Short: "interchain-accounts host subcommands",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
}

queryCmd.AddCommand(
GetCmdParams(),
)

return queryCmd
}
37 changes: 37 additions & 0 deletions modules/apps/27-interchain-accounts/host/client/cli/query.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package cli

import (
"fmt"

"github.com/spf13/cobra"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/host/types"
)

// GetCmdParams returns the command handler for the host submodule parameter querying.
func GetCmdParams() *cobra.Command {
cmd := &cobra.Command{
Use: "params",
Short: "Query the current interchain-accounts host submodule parameters",
Long: "Query the current interchain-accounts host submodule parameters",
Args: cobra.NoArgs,
Example: fmt.Sprintf("%s query interchain-accounts host 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, _ := queryClient.Params(cmd.Context(), &types.QueryParamsRequest{})
return clientCtx.PrintProto(res.Params)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}
3 changes: 2 additions & 1 deletion modules/apps/27-interchain-accounts/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/grpc-ecosystem/grpc-gateway/runtime"
abci "github.com/tendermint/tendermint/abci/types"

"github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/client/cli"
"github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/controller"
controllerkeeper "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/controller/keeper"
controllertypes "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/controller/types"
Expand Down Expand Up @@ -85,7 +86,7 @@ func (AppModuleBasic) GetTxCmd() *cobra.Command {

// GetQueryCmd implements AppModuleBasic interface
func (AppModuleBasic) GetQueryCmd() *cobra.Command {
return nil
return cli.GetQueryCmd()
}

// AppModule is the application module for the IBC interchain accounts module
Expand Down