diff --git a/CHANGELOG.md b/CHANGELOG.md index 32c4811db4ec..25e964526885 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i ### Features +* (client) [#21074](https://github.com/cosmos/cosmos-sdk/pull/21074) Add auto cli for node service * (baseapp) [#20291](https://github.com/cosmos/cosmos-sdk/pull/20291) Simulate nested messages. * (tests) [#20013](https://github.com/cosmos/cosmos-sdk/pull/20013) Introduce system tests to run multi node local testnet in CI * (runtime) [#19953](https://github.com/cosmos/cosmos-sdk/pull/19953) Implement `core/transaction.Service` in runtime. diff --git a/client/grpc/node/autocli.go b/client/grpc/node/autocli.go new file mode 100644 index 000000000000..87819e0f0371 --- /dev/null +++ b/client/grpc/node/autocli.go @@ -0,0 +1,43 @@ +package node + +import ( + autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" + nodev1beta1 "cosmossdk.io/api/cosmos/base/node/v1beta1" +) + +var ServiceAutoCLIDescriptor = &autocliv1.ServiceCommandDescriptor{ + Service: nodev1beta1.Service_ServiceDesc.ServiceName, + RpcCommandOptions: []*autocliv1.RpcCommandOptions{ + { + RpcMethod: "Config", + Use: "config", + Short: "Query the current node config", + }, + { + RpcMethod: "Status", + Use: "status", + Short: "Query the current node status", + }, + }, +} + +// NewNodeCommands is a fake `appmodule.Module` to be considered as a module +// and be added in AutoCLI. +func NewNodeCommands() *nodeModule { + return &nodeModule{} +} + +type nodeModule struct{} + +func (m nodeModule) IsOnePerModuleType() {} +func (m nodeModule) IsAppModule() {} + +func (m nodeModule) Name() string { + return "node" +} + +func (m nodeModule) AutoCLIOptions() *autocliv1.ModuleOptions { + return &autocliv1.ModuleOptions{ + Query: ServiceAutoCLIDescriptor, + } +} diff --git a/simapp/simd/cmd/root.go b/simapp/simd/cmd/root.go index 5734452f0bd0..3743b1d1d9bb 100644 --- a/simapp/simd/cmd/root.go +++ b/simapp/simd/cmd/root.go @@ -18,6 +18,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/config" + nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" "github.com/cosmos/cosmos-sdk/server" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" @@ -122,6 +123,9 @@ func NewRootCmd() *cobra.Command { autoCliOpts := tempApp.AutoCliOpts() autoCliOpts.ClientCtx = initClientCtx + nodeCmds := nodeservice.NewNodeCommands() + autoCliOpts.ModuleOptions[nodeCmds.Name()] = nodeCmds.AutoCLIOptions() + if err := autoCliOpts.EnhanceRootCommand(rootCmd); err != nil { panic(err) } diff --git a/simapp/simd/cmd/root_di.go b/simapp/simd/cmd/root_di.go index 08fc997af43d..640ebdf1c5fd 100644 --- a/simapp/simd/cmd/root_di.go +++ b/simapp/simd/cmd/root_di.go @@ -8,6 +8,7 @@ import ( "github.com/spf13/cobra" authv1 "cosmossdk.io/api/cosmos/auth/module/v1" + autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" stakingv1 "cosmossdk.io/api/cosmos/staking/module/v1" "cosmossdk.io/client/v2/autocli" "cosmossdk.io/core/address" @@ -18,6 +19,7 @@ import ( "cosmossdk.io/x/auth/tx" authtxconfig "cosmossdk.io/x/auth/tx/config" "cosmossdk.io/x/auth/types" + nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/config" @@ -83,6 +85,10 @@ func NewRootCmd() *cobra.Command { initRootCmd(rootCmd, moduleManager) + nodeCmds := nodeservice.NewNodeCommands() + autoCliOpts.ModuleOptions = make(map[string]*autocliv1.ModuleOptions) + autoCliOpts.ModuleOptions[nodeCmds.Name()] = nodeCmds.AutoCLIOptions() + if err := autoCliOpts.EnhanceRootCommand(rootCmd); err != nil { panic(err) } diff --git a/simapp/v2/simdv2/cmd/root_di.go b/simapp/v2/simdv2/cmd/root_di.go index 6051bede8e9c..539b50baf4f7 100644 --- a/simapp/v2/simdv2/cmd/root_di.go +++ b/simapp/v2/simdv2/cmd/root_di.go @@ -5,6 +5,7 @@ import ( "github.com/spf13/cobra" + autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" "cosmossdk.io/client/v2/autocli" "cosmossdk.io/core/address" "cosmossdk.io/core/legacy" @@ -19,6 +20,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/config" + nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/std" @@ -81,6 +83,11 @@ func NewRootCmd[T transaction.Tx]() *cobra.Command { } initRootCmd[T](rootCmd, clientCtx.TxConfig, moduleManager) + + nodeCmds := nodeservice.NewNodeCommands() + autoCliOpts.ModuleOptions = make(map[string]*autocliv1.ModuleOptions) + autoCliOpts.ModuleOptions[nodeCmds.Name()] = nodeCmds.AutoCLIOptions() + if err := autoCliOpts.EnhanceRootCommand(rootCmd); err != nil { panic(err) }