From 38ec3e87d8c8aee66a9c3e1ca7402eba02abe0f9 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Tue, 2 Jan 2024 10:45:39 -0500 Subject: [PATCH] Add missing gov commands that are generated from autocli. --- modules/async-icq/testing/simapp/app.go | 23 +++++++++++++++++++ .../async-icq/testing/simapp/cmd/icqd/root.go | 9 ++++++++ 2 files changed, 32 insertions(+) diff --git a/modules/async-icq/testing/simapp/app.go b/modules/async-icq/testing/simapp/app.go index 47562cb7..e733151d 100644 --- a/modules/async-icq/testing/simapp/app.go +++ b/modules/async-icq/testing/simapp/app.go @@ -15,6 +15,8 @@ import ( autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1" + "cosmossdk.io/client/v2/autocli" + "cosmossdk.io/core/appmodule" storetypes "cosmossdk.io/store/types" "cosmossdk.io/x/evidence" evidencekeeper "cosmossdk.io/x/evidence/keeper" @@ -744,6 +746,27 @@ func (app *SimApp) GetTxConfig() client.TxConfig { return moduletestutil.MakeTestEncodingConfig().TxConfig } +// AutoCliOpts returns the autocli options for the app. +func (app *SimApp) AutoCliOpts() autocli.AppOptions { + modules := make(map[string]appmodule.AppModule, 0) + for _, m := range app.mm.Modules { + if moduleWithName, ok := m.(module.HasName); ok { + moduleName := moduleWithName.Name() + if appModule, ok := moduleWithName.(appmodule.AppModule); ok { + modules[moduleName] = appModule + } + } + } + + return autocli.AppOptions{ + Modules: modules, + ModuleOptions: runtimeservices.ExtractAutoCLIOptions(app.mm.Modules), + AddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()), + ValidatorAddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()), + ConsensusAddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()), + } +} + // SimulationManager implements the SimulationApp interface func (app *SimApp) SimulationManager() *module.SimulationManager { return app.sm diff --git a/modules/async-icq/testing/simapp/cmd/icqd/root.go b/modules/async-icq/testing/simapp/cmd/icqd/root.go index d80c6033..aea34725 100644 --- a/modules/async-icq/testing/simapp/cmd/icqd/root.go +++ b/modules/async-icq/testing/simapp/cmd/icqd/root.go @@ -16,6 +16,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/keys" "github.com/cosmos/cosmos-sdk/client/pruning" "github.com/cosmos/cosmos-sdk/client/rpc" + "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/server" serverconfig "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" @@ -85,6 +86,14 @@ func NewRootCmd() (*cobra.Command, app.EncodingConfig) { initRootCmd(rootCmd, encodingConfig, tempApp) + autoCliOpts := tempApp.AutoCliOpts() + autoCliOpts.Keyring, _ = keyring.NewAutoCLIKeyring(initClientCtx.Keyring) + autoCliOpts.ClientCtx = initClientCtx + + if err := autoCliOpts.EnhanceRootCommand(rootCmd); err != nil { + panic(err) + } + return rootCmd, encodingConfig }