diff --git a/cmd/gaiad/cmd/root.go b/cmd/gaiad/cmd/root.go index 05d5d32a6b1..cbaddca2d79 100644 --- a/cmd/gaiad/cmd/root.go +++ b/cmd/gaiad/cmd/root.go @@ -7,6 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" + config "github.com/cosmos/cosmos-sdk/client/config" "github.com/cosmos/cosmos-sdk/client/debug" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/keys" @@ -22,14 +23,13 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/crisis" genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli" + gaia "github.com/cosmos/gaia/v4/app" + "github.com/cosmos/gaia/v4/app/params" "github.com/spf13/cast" "github.com/spf13/cobra" tmcli "github.com/tendermint/tendermint/libs/cli" "github.com/tendermint/tendermint/libs/log" dbm "github.com/tendermint/tm-db" - - gaia "github.com/cosmos/gaia/v4/app" - "github.com/cosmos/gaia/v4/app/params" ) // NewRootCmd creates a new root command for simd. It is called once in the @@ -44,12 +44,24 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) { WithInput(os.Stdin). WithAccountRetriever(types.AccountRetriever{}). WithBroadcastMode(flags.BroadcastBlock). - WithHomeDir(gaia.DefaultNodeHome) + WithHomeDir(gaia.DefaultNodeHome). + WithViper("GAIA") rootCmd := &cobra.Command{ Use: "gaiad", Short: "Stargate Cosmos Hub App", PersistentPreRunE: func(cmd *cobra.Command, _ []string) error { + // set the default command outputs + cmd.SetOut(cmd.OutOrStdout()) + cmd.SetErr(cmd.ErrOrStderr()) + + initClientCtx = client.ReadHomeFlag(initClientCtx, cmd) + + initClientCtx, err := config.ReadFromClientConfig(initClientCtx) + if err != nil { + return err + } + if err := client.SetCmdClientContextHandler(initClientCtx, cmd); err != nil { return err }