From bd34d55f51ee219d075a28ba01c15350c0d04958 Mon Sep 17 00:00:00 2001 From: valli0x Date: Tue, 15 Oct 2024 12:59:28 +0300 Subject: [PATCH] SIGN_MODE_TEXTUAL --- cmd/galacticad/cmd/root.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/cmd/galacticad/cmd/root.go b/cmd/galacticad/cmd/root.go index e3ae4f2..ee9b327 100644 --- a/cmd/galacticad/cmd/root.go +++ b/cmd/galacticad/cmd/root.go @@ -66,6 +66,10 @@ import ( // ethertypes "github.com/evmos/ethermint/types" "github.com/Galactica-corp/galactica/app" + authtxconfig "github.com/cosmos/cosmos-sdk/x/auth/tx/config" + txsign "github.com/cosmos/cosmos-sdk/types/tx/signing" + authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" + "slices" appparams "github.com/Galactica-corp/galactica/app/params" "github.com/Galactica-corp/galactica/cmd/galacticad/cmd/ethkeys" dbm "github.com/cosmos/cosmos-db" @@ -120,6 +124,27 @@ func NewRootCmd() (*cobra.Command, appparams.EncodingConfig) { 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 := slices.Clone(authtx.DefaultSignModes) + enabledSignModes = append(enabledSignModes, txsign.SignMode_SIGN_MODE_TEXTUAL) + txConfigOpts := authtx.ConfigOptions{ + EnabledSignModes: enabledSignModes, + TextualCoinMetadataQueryFn: authtxconfig.NewGRPCCoinMetadataQueryFn(initClientCtx), + } + txConfig, err := authtx.NewTxConfigWithOptions( + initClientCtx.Codec, + txConfigOpts, + ) + if err != nil { + return err + } + + initClientCtx = initClientCtx.WithTxConfig(txConfig) + } + if err := client.SetCmdClientContextHandler(initClientCtx, cmd); err != nil { return err }