diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f08ec06a9..61391afeaa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -71,6 +71,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * Use fields of the SimulationState for the encoders needed for simulations [#1931](https://github.com/provenance-io/provenance/pull/1931). * Removes sync-info code for sdk v0.50 [#1760](https://github.com/provenance-io/provenance/issues/1760). * Fix most of the failing unit tests [#1943](https://github.com/provenance-io/provenance/pull/1943) +* Clean up ReadFromClient [#1760](https://github.com/provenance-io/provenance/issues/1760). ### Dependencies diff --git a/cmd/provenanced/cmd/root.go b/cmd/provenanced/cmd/root.go index f59990f864..138cbbd941 100644 --- a/cmd/provenanced/cmd/root.go +++ b/cmd/provenanced/cmd/root.go @@ -26,7 +26,6 @@ import ( dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" - clientconfig "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" @@ -39,10 +38,7 @@ import ( simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" - "github.com/cosmos/cosmos-sdk/types/tx/signing" authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli" - "github.com/cosmos/cosmos-sdk/x/auth/tx" - txmodule "github.com/cosmos/cosmos-sdk/x/auth/tx/config" "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/crisis" @@ -109,33 +105,6 @@ func NewRootCmd(sealConfig bool) (*cobra.Command, params.EncodingConfig) { return err } - // TODO[1760]: client: Check impact that this has on our custom client config. - initClientCtx, err = clientconfig.ReadFromClientConfig(initClientCtx) - if err != nil { - return err - } - - // This needs to go after ReadFromClientConfig, as that function - // sets the RPC client needed for SIGN_MODE_TEXTUAL. This sign mode - // is only available if the client is online. - if !initClientCtx.Offline { - enabledSignModes := tx.DefaultSignModes - enabledSignModes = append(enabledSignModes, signing.SignMode_SIGN_MODE_TEXTUAL) - txConfigOpts := tx.ConfigOptions{ - EnabledSignModes: enabledSignModes, - TextualCoinMetadataQueryFn: txmodule.NewGRPCCoinMetadataQueryFn(initClientCtx), - } - txConfig, err := tx.NewTxConfigWithOptions( - initClientCtx.Codec, - txConfigOpts, - ) - if err != nil { - return err - } - - initClientCtx = initClientCtx.WithTxConfig(txConfig) - } - if err := client.SetCmdClientContext(cmd, initClientCtx); err != nil { return err } diff --git a/cmd/provenanced/config/client.go b/cmd/provenanced/config/client.go index 07e4da7b2f..244cab7e6f 100644 --- a/cmd/provenanced/config/client.go +++ b/cmd/provenanced/config/client.go @@ -5,6 +5,9 @@ import ( "fmt" "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/types/tx/signing" + "github.com/cosmos/cosmos-sdk/x/auth/tx" + txmodule "github.com/cosmos/cosmos-sdk/x/auth/tx/config" ) // Default constants @@ -92,5 +95,26 @@ func ApplyClientConfigToContext(ctx client.Context, config *ClientConfig) (clien WithClient(clnt). WithBroadcastMode(config.BroadcastMode) + // This needs to go after ReadFromClientConfig, as that function + // sets the RPC client needed for SIGN_MODE_TEXTUAL. This sign mode + // is only available if the client is online. + if !ctx.Offline { + enabledSignModes := tx.DefaultSignModes + enabledSignModes = append(enabledSignModes, signing.SignMode_SIGN_MODE_TEXTUAL) + txConfigOpts := tx.ConfigOptions{ + EnabledSignModes: enabledSignModes, + TextualCoinMetadataQueryFn: txmodule.NewGRPCCoinMetadataQueryFn(ctx), + } + txConfig, err := tx.NewTxConfigWithOptions( + ctx.Codec, + txConfigOpts, + ) + if err != nil { + return ctx, err + } + + ctx = ctx.WithTxConfig(txConfig) + } + return ctx, nil }