From ab4b919b78fdf40d172f1a7536873685e686b863 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Thu, 20 Jun 2024 12:23:09 +0200 Subject: [PATCH] refactor: bump client/v2 to v2.0.0-beta.2 (#4194) * chore: bump client/v2 to v2.0.0-beta.2 * pr number * updates --- changelog.md | 1 + .../{{binaryNamePrefix}}d/cmd/root.go.plush | 38 ++++-------------- .../{{binaryNamePrefix}}d/cmd/root.go.plush | 40 +++++-------------- ignite/templates/app/files/go.mod.plush | 4 +- 4 files changed, 20 insertions(+), 63 deletions(-) diff --git a/changelog.md b/changelog.md index 9d5838e6b5..59383c868a 100644 --- a/changelog.md +++ b/changelog.md @@ -43,6 +43,7 @@ - [#4159](https://github.com/ignite/cli/pull/4159) Enable gci linter - [#4160](https://github.com/ignite/cli/pull/4160) Enable copyloopvar linter - [#4162](https://github.com/ignite/cli/pull/4162) Enable errcheck linter +- [#4194](https://github.com/ignite/cli/pull/4194) Bump client/v2 to `v2.0.0-beta.2` ### Fixes diff --git a/ignite/templates/app/files-consumer/cmd/{{binaryNamePrefix}}d/cmd/root.go.plush b/ignite/templates/app/files-consumer/cmd/{{binaryNamePrefix}}d/cmd/root.go.plush index c32d8a41a9..72ade797d1 100644 --- a/ignite/templates/app/files-consumer/cmd/{{binaryNamePrefix}}d/cmd/root.go.plush +++ b/ignite/templates/app/files-consumer/cmd/{{binaryNamePrefix}}d/cmd/root.go.plush @@ -5,8 +5,6 @@ import ( "strings" "cosmossdk.io/client/v2/autocli" - clientv2keyring "cosmossdk.io/client/v2/autocli/keyring" - "cosmossdk.io/core/address" "cosmossdk.io/depinject" "cosmossdk.io/log" "github.com/cosmos/cosmos-sdk/client" @@ -14,12 +12,10 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/types/module" - "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" + authtxconfig "github.com/cosmos/cosmos-sdk/x/auth/tx/config" "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/spf13/cobra" "github.com/spf13/pflag" @@ -33,7 +29,6 @@ func NewRootCmd() *cobra.Command { initSDKConfig() var ( - txConfigOpts tx.ConfigOptions autoCliOpts autocli.AppOptions moduleBasicManager module.BasicManager clientCtx client.Context @@ -46,11 +41,9 @@ func NewRootCmd() *cobra.Command { ), depinject.Provide( ProvideClientContext, - ProvideKeyring, ProvideStakingKeeper, ), ), - &txConfigOpts, &autoCliOpts, &moduleBasicManager, &clientCtx, @@ -78,19 +71,6 @@ func NewRootCmd() *cobra.Command { return err } - // This needs to go after ReadFromClientConfig, as that function - // sets the RPC client needed for SIGN_MODE_TEXTUAL. - txConfigOpts.EnabledSignModes = append(txConfigOpts.EnabledSignModes, signing.SignMode_SIGN_MODE_TEXTUAL) - txConfigOpts.TextualCoinMetadataQueryFn = txmodule.NewGRPCCoinMetadataQueryFn(clientCtx) - txConfigWithTextual, err := tx.NewTxConfigWithOptions( - codec.NewProtoCodec(clientCtx.InterfaceRegistry), - txConfigOpts, - ) - if err != nil { - return err - } - - clientCtx = clientCtx.WithTxConfig(txConfigWithTextual) if err := client.SetCmdClientContextHandler(clientCtx, cmd); err != nil { return err } @@ -145,13 +125,12 @@ func overwriteFlagDefaults(c *cobra.Command, defaults map[string]string) { func ProvideClientContext( appCodec codec.Codec, interfaceRegistry codectypes.InterfaceRegistry, - txConfig client.TxConfig, + txConfigOpts tx.ConfigOptions, legacyAmino *codec.LegacyAmino, ) client.Context { clientCtx := client.Context{}. WithCodec(appCodec). WithInterfaceRegistry(interfaceRegistry). - WithTxConfig(txConfig). WithLegacyAmino(legacyAmino). WithInput(os.Stdin). WithAccountRetriever(types.AccountRetriever{}). @@ -161,16 +140,15 @@ func ProvideClientContext( // Read the config again to overwrite the default values with the values from the config file clientCtx, _ = config.ReadFromClientConfig(clientCtx) - return clientCtx -} - -func ProvideKeyring(clientCtx client.Context, addressCodec address.Codec) (clientv2keyring.Keyring, error) { - kb, err := client.NewKeyringFromBackend(clientCtx, clientCtx.Keyring.Backend()) + // textual is enabled by default, we need to re-create the tx config grpc instead of bank keeper. + txConfigOpts.TextualCoinMetadataQueryFn = authtxconfig.NewGRPCCoinMetadataQueryFn(clientCtx) + txConfig, err := tx.NewTxConfigWithOptions(clientCtx.Codec, txConfigOpts) if err != nil { - return nil, err + panic(err) } + clientCtx = clientCtx.WithTxConfig(txConfig) - return keyring.NewAutoCLIKeyring(kb) + return clientCtx } // This is a hack for root.go, needs to be reverted eventually. diff --git a/ignite/templates/app/files/cmd/{{binaryNamePrefix}}d/cmd/root.go.plush b/ignite/templates/app/files/cmd/{{binaryNamePrefix}}d/cmd/root.go.plush index 74c3218ae1..d169668b63 100644 --- a/ignite/templates/app/files/cmd/{{binaryNamePrefix}}d/cmd/root.go.plush +++ b/ignite/templates/app/files/cmd/{{binaryNamePrefix}}d/cmd/root.go.plush @@ -5,8 +5,6 @@ import ( "strings" "cosmossdk.io/client/v2/autocli" - clientv2keyring "cosmossdk.io/client/v2/autocli/keyring" - "cosmossdk.io/core/address" "cosmossdk.io/depinject" "cosmossdk.io/log" "github.com/cosmos/cosmos-sdk/client" @@ -14,12 +12,10 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/types/module" - "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" + authtxconfig "github.com/cosmos/cosmos-sdk/x/auth/tx/config" "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/spf13/cobra" "github.com/spf13/pflag" @@ -32,7 +28,6 @@ func NewRootCmd() *cobra.Command { initSDKConfig() var ( - txConfigOpts tx.ConfigOptions autoCliOpts autocli.AppOptions moduleBasicManager module.BasicManager clientCtx client.Context @@ -45,10 +40,8 @@ func NewRootCmd() *cobra.Command { ), depinject.Provide( ProvideClientContext, - ProvideKeyring, ), ), - &txConfigOpts, &autoCliOpts, &moduleBasicManager, &clientCtx, @@ -76,19 +69,6 @@ func NewRootCmd() *cobra.Command { return err } - // This needs to go after ReadFromClientConfig, as that function - // sets the RPC client needed for SIGN_MODE_TEXTUAL. - txConfigOpts.EnabledSignModes = append(txConfigOpts.EnabledSignModes, signing.SignMode_SIGN_MODE_TEXTUAL) - txConfigOpts.TextualCoinMetadataQueryFn = txmodule.NewGRPCCoinMetadataQueryFn(clientCtx) - txConfigWithTextual, err := tx.NewTxConfigWithOptions( - codec.NewProtoCodec(clientCtx.InterfaceRegistry), - txConfigOpts, - ) - if err != nil { - return err - } - - clientCtx = clientCtx.WithTxConfig(txConfigWithTextual) if err := client.SetCmdClientContextHandler(clientCtx, cmd); err != nil { return err } @@ -143,13 +123,12 @@ func overwriteFlagDefaults(c *cobra.Command, defaults map[string]string) { func ProvideClientContext( appCodec codec.Codec, interfaceRegistry codectypes.InterfaceRegistry, - txConfig client.TxConfig, + txConfigOpts tx.ConfigOptions, legacyAmino *codec.LegacyAmino, ) client.Context { clientCtx := client.Context{}. WithCodec(appCodec). WithInterfaceRegistry(interfaceRegistry). - WithTxConfig(txConfig). WithLegacyAmino(legacyAmino). WithInput(os.Stdin). WithAccountRetriever(types.AccountRetriever{}). @@ -159,14 +138,13 @@ func ProvideClientContext( // Read the config again to overwrite the default values with the values from the config file clientCtx, _ = config.ReadFromClientConfig(clientCtx) - return clientCtx -} - -func ProvideKeyring(clientCtx client.Context, addressCodec address.Codec) (clientv2keyring.Keyring, error) { - kb, err := client.NewKeyringFromBackend(clientCtx, clientCtx.Keyring.Backend()) + // textual is enabled by default, we need to re-create the tx config grpc instead of bank keeper. + txConfigOpts.TextualCoinMetadataQueryFn = authtxconfig.NewGRPCCoinMetadataQueryFn(clientCtx) + txConfig, err := tx.NewTxConfigWithOptions(clientCtx.Codec, txConfigOpts) if err != nil { - return nil, err + panic(err) } + clientCtx = clientCtx.WithTxConfig(txConfig) - return keyring.NewAutoCLIKeyring(kb) -} + return clientCtx +} \ No newline at end of file diff --git a/ignite/templates/app/files/go.mod.plush b/ignite/templates/app/files/go.mod.plush index e049bb04d3..2553998207 100644 --- a/ignite/templates/app/files/go.mod.plush +++ b/ignite/templates/app/files/go.mod.plush @@ -11,7 +11,7 @@ replace ( require ( cosmossdk.io/api v0.7.5 - cosmossdk.io/client/v2 v2.0.0-beta.1 + cosmossdk.io/client/v2 v2.0.0-beta.2 cosmossdk.io/collections v0.4.0 cosmossdk.io/core v0.11.0 cosmossdk.io/depinject v1.0.0-alpha.4 @@ -32,7 +32,7 @@ require ( github.com/cosmos/cosmos-db v1.0.2 github.com/cosmos/cosmos-proto v1.0.0-beta.5 github.com/cosmos/cosmos-sdk v0.50.7 - github.com/cosmos/gogoproto v1.4.12 + github.com/cosmos/gogoproto v1.5.0 github.com/cosmos/ibc-go/modules/capability v1.0.0 github.com/cosmos/ibc-go/v8 v8.3.1 github.com/golang/protobuf v1.5.4