diff --git a/app/app.go b/app/app.go index 566dff20f9..1a9c2adb3c 100644 --- a/app/app.go +++ b/app/app.go @@ -33,6 +33,8 @@ import ( abci "github.com/cometbft/cometbft/abci/types" tmos "github.com/cometbft/cometbft/libs/os" + "cosmossdk.io/client/v2/autocli" + "cosmossdk.io/core/appmodule" "cosmossdk.io/log" "cosmossdk.io/simapp" dbm "github.com/cosmos/cosmos-db" @@ -874,6 +876,27 @@ func (app *EthermintApp) InterfaceRegistry() types.InterfaceRegistry { return app.interfaceRegistry } +// AutoCliOpts returns the autocli options for the app. +func (app *EthermintApp) 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()), + } +} + // GetKey returns the KVStoreKey for the provided store key. // // NOTE: This is solely to be used for testing purposes. diff --git a/cmd/ethermintd/root.go b/cmd/ethermintd/root.go index ccaf69630c..affd8d36d4 100644 --- a/cmd/ethermintd/root.go +++ b/cmd/ethermintd/root.go @@ -53,6 +53,8 @@ import ( genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli" // rosettaCmd "github.com/cosmos/rosetta/cmd" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" "github.com/evmos/ethermint/app" ethermintclient "github.com/evmos/ethermint/client" @@ -71,6 +73,17 @@ const EnvPrefix = "ETHERMINT" // NewRootCmd creates a new root command for simd. It is called once in the // main function. func NewRootCmd() (*cobra.Command, params.EncodingConfig) { + tempApp := app.NewEthermintApp( + log.NewNopLogger(), + dbm.NewMemDB(), + nil, + true, + map[int64]bool{}, + app.DefaultNodeHome, + 0, + encoding.MakeConfig(app.ModuleBasics), + simtestutil.NewAppOptionsWithFlagHome(app.DefaultNodeHome), + ) encodingConfig := encoding.MakeConfig(app.ModuleBasics) initClientCtx := client.Context{}. WithCodec(encodingConfig.Codec). @@ -177,6 +190,15 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) { ethermintclient.KeyCommands(app.DefaultNodeHome), ) + autoCliOpts := tempApp.AutoCliOpts() + initClientCtx, _ = config.ReadFromClientConfig(initClientCtx) + autoCliOpts.Keyring, _ = keyring.NewAutoCLIKeyring(initClientCtx.Keyring) + autoCliOpts.ClientCtx = initClientCtx + + if err := autoCliOpts.EnhanceRootCommand(rootCmd); err != nil { + panic(err) + } + rootCmd, err := srvflags.AddTxFlags(rootCmd) if err != nil { panic(err) @@ -210,7 +232,6 @@ func queryCommand() *cobra.Command { sdkserver.QueryBlockResultsCmd(), ) - app.ModuleBasics.AddQueryCommands(cmd) cmd.PersistentFlags().String(flags.FlagChainID, "", "The network chain ID") return cmd @@ -237,7 +258,6 @@ func txCommand() *cobra.Command { authcmd.GetSimulateCmd(), ) - // app.ModuleBasics.AddTxCommands(cmd) // <- cmd.PersistentFlags().String(flags.FlagChainID, "", "The network chain ID") return cmd diff --git a/tests/importer/importer_test.go b/tests/importer/importer_test.go index 4ec5cac26d..285300b265 100644 --- a/tests/importer/importer_test.go +++ b/tests/importer/importer_test.go @@ -161,7 +161,9 @@ func (suite *ImporterTestSuite) TestImportBlocks() { accumulateRewards(chainConfig, vmdb, header, block.Uncles()) // simulate BaseApp EndBlocker commitment - suite.app.EndBlocker(ctx.WithBlockHeight(tmheader.Height)) + suite.app.FinalizeBlock(&types.RequestFinalizeBlock{ + Height: tmheader.Height, + }) suite.app.Commit() // block debugging output