From 97926918bc389ae59539eeaea1d9bcfaa4dc25b3 Mon Sep 17 00:00:00 2001 From: MSalopek Date: Mon, 22 Jul 2024 10:51:32 +0200 Subject: [PATCH] fix: use client/v2 v2.0.0-beta3; fix broken client.toml usage (#3210) * fix: use client/v2 v2.0.0-beta3; fix broken client.toml usage * Update root.go (cherry picked from commit 27da5e89823aac293df67163eaa26c30fb659479) --- cmd/gaiad/cmd/root.go | 28 ++++++---------------------- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 9 insertions(+), 25 deletions(-) diff --git a/cmd/gaiad/cmd/root.go b/cmd/gaiad/cmd/root.go index 109eb34c963..0d39e5a6166 100644 --- a/cmd/gaiad/cmd/root.go +++ b/cmd/gaiad/cmd/root.go @@ -37,7 +37,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" codectypes "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/server" serverconfig "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" @@ -46,7 +45,7 @@ import ( "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" + authtxconfig "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" @@ -86,7 +85,6 @@ func NewRootCmd() *cobra.Command { initClientCtx := client.Context{}. WithCodec(tempApplication.AppCodec()). WithInterfaceRegistry(tempApplication.InterfaceRegistry()). - WithTxConfig(tempApplication.GetTxConfig()). WithLegacyAmino(tempApplication.LegacyAmino()). WithInput(os.Stdin). WithAccountRetriever(types.AccountRetriever{}). @@ -117,10 +115,10 @@ func NewRootCmd() *cobra.Command { if !initClientCtx.Offline { txConfigOpts := tx.ConfigOptions{ EnabledSignModes: append(tx.DefaultSignModes, signing.SignMode_SIGN_MODE_TEXTUAL), - TextualCoinMetadataQueryFn: txmodule.NewGRPCCoinMetadataQueryFn(initClientCtx), + TextualCoinMetadataQueryFn: authtxconfig.NewGRPCCoinMetadataQueryFn(initClientCtx), } txConfigWithTextual, err := tx.NewTxConfigWithOptions( - codec.NewProtoCodec(tempApplication.InterfaceRegistry()), + initClientCtx.Codec, txConfigOpts, ) if err != nil { @@ -142,11 +140,7 @@ func NewRootCmd() *cobra.Command { initRootCmd(rootCmd, tempApplication.ModuleBasics, tempApplication.AppCodec(), tempApplication.InterfaceRegistry(), tempApplication.GetTxConfig()) - autoCliOpts, err := enrichAutoCliOpts(tempApplication.AutoCliOpts(), initClientCtx) - if err != nil { - panic(err) - } - + autoCliOpts := enrichAutoCliOpts(tempApplication.AutoCliOpts(), initClientCtx) if err := autoCliOpts.EnhanceRootCommand(rootCmd); err != nil { panic(err) } @@ -154,24 +148,14 @@ func NewRootCmd() *cobra.Command { return rootCmd } -func enrichAutoCliOpts(autoCliOpts autocli.AppOptions, clientCtx client.Context) (autocli.AppOptions, error) { +func enrichAutoCliOpts(autoCliOpts autocli.AppOptions, clientCtx client.Context) autocli.AppOptions { autoCliOpts.AddressCodec = addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()) autoCliOpts.ValidatorAddressCodec = addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()) autoCliOpts.ConsensusAddressCodec = addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()) - var err error - clientCtx, err = config.ReadFromClientConfig(clientCtx) - if err != nil { - return autocli.AppOptions{}, err - } - autoCliOpts.ClientCtx = clientCtx - autoCliOpts.Keyring, err = keyring.NewAutoCLIKeyring(clientCtx.Keyring) - if err != nil { - return autocli.AppOptions{}, err - } - return autoCliOpts, nil + return autoCliOpts } // initCometConfig helps to override default CometBFT Config values. diff --git a/go.mod b/go.mod index 04830a52c9f..ff4b9feee20 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.22.3 require ( cosmossdk.io/api v0.7.5 - cosmossdk.io/client/v2 v2.0.0-beta.1.0.20240124105859-5ad1805d0e79 + cosmossdk.io/client/v2 v2.0.0-beta.3 cosmossdk.io/core v0.11.0 cosmossdk.io/errors v1.0.1 cosmossdk.io/log v1.3.1 diff --git a/go.sum b/go.sum index 80955c818e9..2fc96318e8d 100644 --- a/go.sum +++ b/go.sum @@ -190,8 +190,8 @@ cloud.google.com/go/webrisk v1.5.0/go.mod h1:iPG6fr52Tv7sGk0H6qUFzmL3HHZev1htXuW cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1Vwf+KmJENM0= cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M= collectd.org v0.3.0/go.mod h1:A/8DzQBkF6abtvrT2j/AU/4tiBgJWYyh0y/oB/4MlWE= -cosmossdk.io/client/v2 v2.0.0-beta.1.0.20240124105859-5ad1805d0e79 h1:Hr1t0fCq1nbFC7hLs0Xvy9WAiH7Iti5iVLXMM5C37F0= -cosmossdk.io/client/v2 v2.0.0-beta.1.0.20240124105859-5ad1805d0e79/go.mod h1:8pN6LSVReNnIxrC2QGcvuIJ/m1pJN6FNYn2kAYtYftI= +cosmossdk.io/client/v2 v2.0.0-beta.3 h1:+TTuH0DwQYsUq2JFAl3fDZzKq5gQG7nt3dAattkjFDU= +cosmossdk.io/client/v2 v2.0.0-beta.3/go.mod h1:CZcL41HpJPOOayTCO28j8weNBQprG+SRiKX39votypo= cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= cosmossdk.io/core v0.11.0 h1:vtIafqUi+1ZNAE/oxLOQQ7Oek2n4S48SWLG8h/+wdbo=