Skip to content

Commit

Permalink
fix client signing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
harish551 committed Sep 23, 2024
1 parent 6630980 commit 46d2a4b
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions cmd/omniflixhubd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ import (
"github.com/cosmos/cosmos-sdk/server"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec"
"github.com/cosmos/cosmos-sdk/x/auth/tx"
authtxconfig "github.com/cosmos/cosmos-sdk/x/auth/tx/config"
"github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/crisis"
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
Expand Down Expand Up @@ -104,9 +107,29 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) {
if err != nil {
return err
}
if err := client.SetCmdClientContextHandler(initClientCtx, cmd); err != nil {

// 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 {
txConfigOpts := tx.ConfigOptions{
EnabledSignModes: append(tx.DefaultSignModes, signing.SignMode_SIGN_MODE_TEXTUAL),
TextualCoinMetadataQueryFn: authtxconfig.NewGRPCCoinMetadataQueryFn(initClientCtx),
}
txConfigWithTextual, err := tx.NewTxConfigWithOptions(
initClientCtx.Codec,
txConfigOpts,
)
if err != nil {
return err
}
initClientCtx = initClientCtx.WithTxConfig(txConfigWithTextual)
}

if err = client.SetCmdClientContextHandler(initClientCtx, cmd); err != nil {
return err
}

appTemplate, appConfig := initAppConfig()
customTMConfig := initCometBftConfig()
return server.InterceptConfigsPreRunHandler(cmd, appTemplate, appConfig, customTMConfig)
Expand All @@ -116,7 +139,8 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) {
initRootCmd(rootCmd, encodingConfig, tempApp)

// must need as part of cosmos-sdk 0.50.x migration
if err := autoCliOpts(initClientCtx, tempApp).EnhanceRootCommand(rootCmd); err != nil {
autocliOptions := autoCliOpts(initClientCtx, tempApp)
if err := autocliOptions.EnhanceRootCommand(rootCmd); err != nil {
panic(err)
}

Expand Down Expand Up @@ -345,5 +369,9 @@ func autoCliOpts(initClientCtx client.Context, tempApp *app.OmniFlixApp) autocli
ValidatorAddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()),
ConsensusAddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()),
ClientCtx: initClientCtx,
TxConfigOpts: tx.ConfigOptions{
EnabledSignModes: tx.DefaultSignModes,
TextualCoinMetadataQueryFn: authtxconfig.NewGRPCCoinMetadataQueryFn(initClientCtx),
},
}
}

0 comments on commit 46d2a4b

Please sign in to comment.