diff --git a/simapp/simd/cmd/commands.go b/simapp/simd/cmd/commands.go index 86f91f571d5..abfa351961d 100644 --- a/simapp/simd/cmd/commands.go +++ b/simapp/simd/cmd/commands.go @@ -1,7 +1,6 @@ package cmd import ( - "context" "errors" "io" "os" @@ -27,7 +26,6 @@ import ( servertypes "github.com/cosmos/cosmos-sdk/server/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" - "github.com/cosmos/cosmos-sdk/version" authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/crisis" @@ -40,14 +38,10 @@ func initRootCmd( interfaceRegistry codectypes.InterfaceRegistry, appCodec codec.Codec, basicManager module.BasicManager, - extraInfo version.ExtraInfo, ) { cfg := sdk.GetConfig() cfg.Seal() - cmdContext := context.WithValue(context.Background(), version.ContextKey{}, extraInfo) - rootCmd.SetContext(cmdContext) - rootCmd.AddCommand( genutilcli.InitCmd(basicManager), NewTestnetCmd(basicManager, banktypes.GenesisBalancesIterator{}), diff --git a/simapp/simd/cmd/root.go b/simapp/simd/cmd/root.go index 98f5ba46b49..1b829136790 100644 --- a/simapp/simd/cmd/root.go +++ b/simapp/simd/cmd/root.go @@ -99,7 +99,7 @@ func NewRootCmd() *cobra.Command { }, } - initRootCmd(rootCmd, encodingConfig.TxConfig, encodingConfig.InterfaceRegistry, encodingConfig.Codec, tempApp.BasicModuleManager, nil) + initRootCmd(rootCmd, encodingConfig.TxConfig, encodingConfig.InterfaceRegistry, encodingConfig.Codec, tempApp.BasicModuleManager) // autocli opts customClientTemplate, customClientConfig := initClientConfig() diff --git a/simapp/simd/cmd/root_v2.go b/simapp/simd/cmd/root_v2.go index f26449880ce..170aa94b0fb 100644 --- a/simapp/simd/cmd/root_v2.go +++ b/simapp/simd/cmd/root_v2.go @@ -100,7 +100,7 @@ func NewRootCmd() *cobra.Command { }, } - initRootCmd(rootCmd, clientCtx.TxConfig, clientCtx.InterfaceRegistry, clientCtx.Codec, moduleBasicManager, nil) + initRootCmd(rootCmd, clientCtx.TxConfig, clientCtx.InterfaceRegistry, clientCtx.Codec, moduleBasicManager) if err := autoCliOpts.EnhanceRootCommand(rootCmd); err != nil { panic(err) diff --git a/version/command.go b/version/command.go index 689fcd4a0da..163e6e5c7d2 100644 --- a/version/command.go +++ b/version/command.go @@ -15,6 +15,11 @@ const ( ) // NewVersionCommand returns a CLI command to interactively print the application binary version information. +// Note: When seeking to add the extra info to the context +// The below can be added to the initRootCmd to include the extraInfo field +// +// cmdContext := context.WithValue(context.Background(), version.ContextKey{}, extraInfo) +// rootCmd.SetContext(cmdContext) func NewVersionCommand() *cobra.Command { cmd := &cobra.Command{ Use: "version", @@ -28,6 +33,7 @@ func NewVersionCommand() *cobra.Command { return nil } + // Extract and set extra information from the context extraInfo := extraInfoFromContext(cmd) verInfo.ExtraInfo = &extraInfo