diff --git a/cmd/comdex/root.go b/cmd/comdex/root.go index 9d65499ab..40143f33d 100644 --- a/cmd/comdex/root.go +++ b/cmd/comdex/root.go @@ -12,6 +12,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" + "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" @@ -37,25 +38,33 @@ import ( ) func NewRootCmd() (*cobra.Command, comdex.EncodingConfig) { - var ( - config = comdex.MakeEncodingConfig() - context = client.Context{}. - WithCodec(config.Marshaler). - WithInterfaceRegistry(config.InterfaceRegistry). - WithTxConfig(config.TxConfig). - WithLegacyAmino(config.Amino). - WithInput(os.Stdin). - WithAccountRetriever(authtypes.AccountRetriever{}). - WithBroadcastMode(flags.BroadcastBlock). - WithHomeDir(comdex.DefaultNodeHome) - ) + encodingConfig := comdex.MakeEncodingConfig() + initClientCtx := client.Context{}. + WithCodec(encodingConfig.Marshaler). + WithInterfaceRegistry(encodingConfig.InterfaceRegistry). + WithTxConfig(encodingConfig.TxConfig). + WithLegacyAmino(encodingConfig.Amino). + WithInput(os.Stdin). + WithAccountRetriever(authtypes.AccountRetriever{}). + WithBroadcastMode(flags.BroadcastBlock). + WithHomeDir(comdex.DefaultNodeHome). + WithViper("") cobra.EnableCommandSorting = false root := &cobra.Command{ Use: "comdex", Short: "Comdex - Decentralised Synthetic Asset Exchange", PersistentPreRunE: func(cmd *cobra.Command, _ []string) error { - if err := client.SetCmdClientContextHandler(context, cmd); err != nil { + initClientCtx, err := client.ReadPersistentCommandFlags(initClientCtx, cmd.Flags()) + if err != nil { + return err + } + initClientCtx, err = config.ReadFromClientConfig(initClientCtx) + if err != nil { + return err + } + + if err := client.SetCmdClientContextHandler(initClientCtx, cmd); err != nil { return err } @@ -63,8 +72,8 @@ func NewRootCmd() (*cobra.Command, comdex.EncodingConfig) { }, } - initRootCmd(root, config) - return root, config + initRootCmd(root, encodingConfig) + return root, encodingConfig } func initRootCmd(rootCmd *cobra.Command, encoding comdex.EncodingConfig) {