From 493d486bc6c0308c497b2c09f3a279cde0892e63 Mon Sep 17 00:00:00 2001 From: Matt Kocubinski Date: Tue, 14 May 2024 12:52:51 -0400 Subject: [PATCH] refactor: decouple from sdk/codec in amino codec usage (#20369) --- CHANGELOG.md | 1 + UPGRADING.md | 7 ++++ codec/amino.go | 25 ++++++++---- codec/amino_codec_test.go | 4 +- codec/depinject.go | 47 +++++++++++++++++++++++ codec/legacy/amino_msg.go | 7 ++-- core/legacy/amino.go | 14 +++++++ crypto/codec/amino.go | 19 ++++----- crypto/keyring/codec.go | 10 ++--- crypto/keys/multisig/codec.go | 8 ++-- crypto/ledger/amino.go | 2 +- runtime/app.go | 3 +- runtime/module.go | 53 +++++++------------------- simapp/app_di.go | 10 ++++- simapp/simd/cmd/root_di.go | 10 ++++- std/codec.go | 4 +- tests/sims/authz/operations_test.go | 2 - tests/sims/feegrant/operations_test.go | 2 - tests/sims/slashing/operations_test.go | 2 - testutil/network/network.go | 9 ++++- types/codec.go | 4 +- types/module/core_module.go | 6 +-- types/module/module.go | 6 +-- x/auth/ante/testutil_test.go | 2 +- x/auth/migrations/legacytx/codec.go | 6 +-- x/auth/module.go | 10 ++++- x/auth/types/codec.go | 12 +++--- x/auth/vesting/module.go | 6 +-- x/auth/vesting/types/codec.go | 14 +++---- x/authz/codec.go | 6 +-- x/authz/module/module.go | 11 +++++- x/bank/module.go | 3 +- x/bank/types/codec.go | 8 ++-- x/consensus/module.go | 3 +- x/consensus/types/codec.go | 4 +- x/crisis/module.go | 3 +- x/crisis/types/codec.go | 4 +- x/distribution/module.go | 3 +- x/distribution/types/codec.go | 6 +-- x/epochs/module.go | 4 +- x/evidence/module.go | 3 +- x/evidence/types/codec.go | 6 +-- x/feegrant/codec.go | 10 ++--- x/feegrant/module/module.go | 3 +- x/gov/module.go | 3 +- x/gov/types/v1/codec.go | 4 +- x/gov/types/v1beta1/codec.go | 6 +-- x/group/codec.go | 8 ++-- x/group/module/module.go | 3 +- x/mint/module.go | 3 +- x/mint/types/codec.go | 6 +-- x/params/keeper/common_test.go | 4 +- x/params/module.go | 4 +- x/params/types/proposal/codec.go | 7 ++-- x/protocolpool/module.go | 3 +- x/slashing/depinject.go | 3 +- x/slashing/keeper/keeper.go | 3 +- x/slashing/module.go | 3 +- x/slashing/types/codec.go | 6 +-- x/staking/module.go | 3 +- x/staking/types/codec.go | 12 +++--- x/upgrade/module.go | 8 +--- x/upgrade/types/codec.go | 10 ++--- 63 files changed, 286 insertions(+), 195 deletions(-) create mode 100644 codec/depinject.go create mode 100644 core/legacy/amino.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e8b308835fe..ce1fb5cc5c7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -118,6 +118,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i ### API Breaking Changes +* (types)[#20369](https://github.com/cosmos/cosmos-sdk/pull/20369) The signature of `HasAminoCodec` has changed to accept a `core/legacy.Amino` interface instead of `codec.LegacyAmino`. * (x/simulation)[#20056](https://github.com/cosmos/cosmos-sdk/pull/20056) `SimulateFromSeed` now takes an address codec as argument. * (x/crisis) [#20043](https://github.com/cosmos/cosmos-sdk/pull/20043) Changed `NewMsgVerifyInvariant` to accept a string as argument instead of an `AccAddress`. * (x/genutil) [#19926](https://github.com/cosmos/cosmos-sdk/pull/19926) Removal of the Address.String() method and related changes: diff --git a/UPGRADING.md b/UPGRADING.md index 84374275e84a..3ae40ff63338 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -186,6 +186,13 @@ The signature of the extension interface `HasRegisterInterfaces` has been change +func (AppModule) RegisterInterfaces(registry registry.InterfaceRegistrar) { ``` +The signature of the extension interface `HasAminoCodec` has been changed to accept a `cosmossdk.io/core/legacy.Amino` instead of a `codec.LegacyAmino`. Modules should update their `HasAminoCodec` implementation to accept a `cosmossdk.io/core/legacy.Amino` interface. + +```diff +-func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { ++func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) { +``` + ##### Simulation `MsgSimulatorFn` has been updated to return an error. Its context argument has been removed, and an address.Codec has diff --git a/codec/amino.go b/codec/amino.go index 6d4b70bb5736..7dcdb844d518 100644 --- a/codec/amino.go +++ b/codec/amino.go @@ -10,6 +10,8 @@ import ( cmttypes "github.com/cometbft/cometbft/types" "github.com/tendermint/go-amino" + "cosmossdk.io/core/legacy" + "github.com/cosmos/cosmos-sdk/codec/types" ) @@ -23,15 +25,17 @@ func (cdc *LegacyAmino) Seal() { cdc.Amino.Seal() } +var _ legacy.Amino = &LegacyAmino{} + func NewLegacyAmino() *LegacyAmino { return &LegacyAmino{amino.NewCodec()} } // RegisterEvidences registers CometBFT evidence types with the provided Amino // codec. -func RegisterEvidences(cdc *LegacyAmino) { - cdc.Amino.RegisterInterface((*cmttypes.Evidence)(nil), nil) - cdc.Amino.RegisterConcrete(&cmttypes.DuplicateVoteEvidence{}, "tendermint/DuplicateVoteEvidence", nil) +func RegisterEvidences(cdc legacy.Amino) { + cdc.RegisterInterface((*cmttypes.Evidence)(nil), nil) + cdc.RegisterConcrete(&cmttypes.DuplicateVoteEvidence{}, "tendermint/DuplicateVoteEvidence") } // MarshalJSONIndent provides a utility for indented JSON encoding of an object @@ -175,12 +179,19 @@ func (*LegacyAmino) UnpackAny(*types.Any, interface{}) error { return errors.New("AminoCodec can't handle unpack protobuf Any's") } -func (cdc *LegacyAmino) RegisterInterface(ptr interface{}, iopts *amino.InterfaceOptions) { - cdc.Amino.RegisterInterface(ptr, iopts) +func (cdc *LegacyAmino) RegisterInterface(ptr interface{}, iopts *legacy.InterfaceOptions) { + if iopts == nil { + cdc.Amino.RegisterInterface(ptr, nil) + } else { + cdc.Amino.RegisterInterface(ptr, &amino.InterfaceOptions{ + Priority: iopts.Priority, + AlwaysDisambiguate: iopts.AlwaysDisambiguate, + }) + } } -func (cdc *LegacyAmino) RegisterConcrete(o interface{}, name string, copts *amino.ConcreteOptions) { - cdc.Amino.RegisterConcrete(o, name, copts) +func (cdc *LegacyAmino) RegisterConcrete(o interface{}, name string) { + cdc.Amino.RegisterConcrete(o, name, nil) } func (cdc *LegacyAmino) MarshalJSONIndent(o interface{}, prefix, indent string) ([]byte, error) { diff --git a/codec/amino_codec_test.go b/codec/amino_codec_test.go index 24b612496572..63df85e83782 100644 --- a/codec/amino_codec_test.go +++ b/codec/amino_codec_test.go @@ -17,8 +17,8 @@ func createTestCodec() *codec.LegacyAmino { cdc.RegisterInterface((*testdata.Animal)(nil), nil) // NOTE: since we unmarshal interface using pointers, we need to register a pointer // types here. - cdc.RegisterConcrete(&testdata.Dog{}, "testdata/Dog", nil) - cdc.RegisterConcrete(&testdata.Cat{}, "testdata/Cat", nil) + cdc.RegisterConcrete(&testdata.Dog{}, "testdata/Dog") + cdc.RegisterConcrete(&testdata.Cat{}, "testdata/Cat") return cdc } diff --git a/codec/depinject.go b/codec/depinject.go new file mode 100644 index 000000000000..3414a7933a49 --- /dev/null +++ b/codec/depinject.go @@ -0,0 +1,47 @@ +package codec + +import ( + "github.com/cosmos/gogoproto/proto" + + "cosmossdk.io/core/address" + "cosmossdk.io/core/legacy" + "cosmossdk.io/x/tx/signing" + + "github.com/cosmos/cosmos-sdk/codec/types" +) + +func ProvideInterfaceRegistry( + addressCodec address.Codec, + validatorAddressCodec address.ValidatorAddressCodec, + customGetSigners []signing.CustomGetSigner, +) (types.InterfaceRegistry, error) { + signingOptions := signing.Options{ + AddressCodec: addressCodec, + ValidatorAddressCodec: validatorAddressCodec, + } + for _, signer := range customGetSigners { + signingOptions.DefineCustomGetSigners(signer.MsgType, signer.Fn) + } + + interfaceRegistry, err := types.NewInterfaceRegistryWithOptions(types.InterfaceRegistryOptions{ + ProtoFiles: proto.HybridResolver, + SigningOptions: signingOptions, + }) + if err != nil { + return nil, err + } + + if err := interfaceRegistry.SigningContext().Validate(); err != nil { + return nil, err + } + + return interfaceRegistry, nil +} + +func ProvideLegacyAmino() legacy.Amino { + return NewLegacyAmino() +} + +func ProvideProtoCodec(interfaceRegistry types.InterfaceRegistry) *ProtoCodec { + return NewProtoCodec(interfaceRegistry) +} diff --git a/codec/legacy/amino_msg.go b/codec/legacy/amino_msg.go index 58a02bed7b21..a3aca8e7a139 100644 --- a/codec/legacy/amino_msg.go +++ b/codec/legacy/amino_msg.go @@ -3,16 +3,17 @@ package legacy import ( "fmt" - "github.com/cosmos/cosmos-sdk/codec" + "cosmossdk.io/core/legacy" + sdk "github.com/cosmos/cosmos-sdk/types" ) // RegisterAminoMsg first checks that the msgName is <40 chars // (else this would break ledger nano signing: https://github.com/cosmos/cosmos-sdk/issues/10870), // then registers the concrete msg type with amino. -func RegisterAminoMsg(cdc *codec.LegacyAmino, msg sdk.Msg, msgName string) { +func RegisterAminoMsg(cdc legacy.Amino, msg sdk.Msg, msgName string) { if len(msgName) > 39 { panic(fmt.Errorf("msg name %s is too long to be registered with amino", msgName)) } - cdc.RegisterConcrete(msg, msgName, nil) + cdc.RegisterConcrete(msg, msgName) } diff --git a/core/legacy/amino.go b/core/legacy/amino.go new file mode 100644 index 000000000000..63ae965ee03e --- /dev/null +++ b/core/legacy/amino.go @@ -0,0 +1,14 @@ +package legacy + +type Amino interface { + // RegisterInterface registers an interface and its concrete type with the Amino codec. + RegisterInterface(interfacePtr any, iopts *InterfaceOptions) + + // RegisterConcrete registers a concrete type with the Amino codec. + RegisterConcrete(cdcType interface{}, name string) +} + +type InterfaceOptions struct { + Priority []string // Disamb priority. + AlwaysDisambiguate bool // If true, include disamb for all types. +} diff --git a/crypto/codec/amino.go b/crypto/codec/amino.go index 988c17ba1976..2c83723a6d48 100644 --- a/crypto/codec/amino.go +++ b/crypto/codec/amino.go @@ -3,7 +3,8 @@ package codec import ( "github.com/cometbft/cometbft/crypto/sr25519" - "github.com/cosmos/cosmos-sdk/codec" + "cosmossdk.io/core/legacy" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" @@ -12,22 +13,22 @@ import ( // RegisterCrypto registers all crypto dependency types with the provided Amino // codec. -func RegisterCrypto(cdc *codec.LegacyAmino) { +func RegisterCrypto(cdc legacy.Amino) { cdc.RegisterInterface((*cryptotypes.PubKey)(nil), nil) cdc.RegisterConcrete(sr25519.PubKey{}, - sr25519.PubKeyName, nil) + sr25519.PubKeyName) cdc.RegisterConcrete(&ed25519.PubKey{}, - ed25519.PubKeyName, nil) + ed25519.PubKeyName) cdc.RegisterConcrete(&secp256k1.PubKey{}, - secp256k1.PubKeyName, nil) + secp256k1.PubKeyName) cdc.RegisterConcrete(&kmultisig.LegacyAminoPubKey{}, - kmultisig.PubKeyAminoRoute, nil) + kmultisig.PubKeyAminoRoute) cdc.RegisterInterface((*cryptotypes.PrivKey)(nil), nil) cdc.RegisterConcrete(sr25519.PrivKey{}, - sr25519.PrivKeyName, nil) + sr25519.PrivKeyName) cdc.RegisterConcrete(&ed25519.PrivKey{}, - ed25519.PrivKeyName, nil) + ed25519.PrivKeyName) cdc.RegisterConcrete(&secp256k1.PrivKey{}, - secp256k1.PrivKeyName, nil) + secp256k1.PrivKeyName) } diff --git a/crypto/keyring/codec.go b/crypto/keyring/codec.go index 9b4c44039231..1393d2f35e1e 100644 --- a/crypto/keyring/codec.go +++ b/crypto/keyring/codec.go @@ -13,9 +13,9 @@ func init() { // RegisterLegacyAminoCodec registers concrete types and interfaces on the given codec. func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterInterface((*LegacyInfo)(nil), nil) - cdc.RegisterConcrete(hd.BIP44Params{}, "crypto/keys/hd/BIP44Params", nil) - cdc.RegisterConcrete(legacyLocalInfo{}, "crypto/keys/localInfo", nil) - cdc.RegisterConcrete(legacyLedgerInfo{}, "crypto/keys/ledgerInfo", nil) - cdc.RegisterConcrete(legacyOfflineInfo{}, "crypto/keys/offlineInfo", nil) - cdc.RegisterConcrete(LegacyMultiInfo{}, "crypto/keys/multiInfo", nil) + cdc.RegisterConcrete(hd.BIP44Params{}, "crypto/keys/hd/BIP44Params") + cdc.RegisterConcrete(legacyLocalInfo{}, "crypto/keys/localInfo") + cdc.RegisterConcrete(legacyLedgerInfo{}, "crypto/keys/ledgerInfo") + cdc.RegisterConcrete(legacyOfflineInfo{}, "crypto/keys/offlineInfo") + cdc.RegisterConcrete(LegacyMultiInfo{}, "crypto/keys/multiInfo") } diff --git a/crypto/keys/multisig/codec.go b/crypto/keys/multisig/codec.go index 7dc3ed262d0e..6572123af540 100644 --- a/crypto/keys/multisig/codec.go +++ b/crypto/keys/multisig/codec.go @@ -22,11 +22,11 @@ var AminoCdc = codec.NewLegacyAmino() func init() { AminoCdc.RegisterInterface((*cryptotypes.PubKey)(nil), nil) AminoCdc.RegisterConcrete(ed25519.PubKey{}, - ed25519.PubKeyName, nil) + ed25519.PubKeyName) AminoCdc.RegisterConcrete(sr25519.PubKey{}, - sr25519.PubKeyName, nil) + sr25519.PubKeyName) AminoCdc.RegisterConcrete(&secp256k1.PubKey{}, - secp256k1.PubKeyName, nil) + secp256k1.PubKeyName) AminoCdc.RegisterConcrete(&LegacyAminoPubKey{}, - PubKeyAminoRoute, nil) + PubKeyAminoRoute) } diff --git a/crypto/ledger/amino.go b/crypto/ledger/amino.go index 0e717a9604f0..8a5915f31abf 100644 --- a/crypto/ledger/amino.go +++ b/crypto/ledger/amino.go @@ -15,5 +15,5 @@ func init() { // RegisterAmino registers all go-crypto related types in the given (amino) codec. func RegisterAmino(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(PrivKeyLedgerSecp256k1{}, - "tendermint/PrivKeyLedgerSecp256k1", nil) + "tendermint/PrivKeyLedgerSecp256k1") } diff --git a/runtime/app.go b/runtime/app.go index 7c494e02ba00..2f208a635e09 100644 --- a/runtime/app.go +++ b/runtime/app.go @@ -10,6 +10,7 @@ import ( runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1" appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/legacy" "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" authtx "cosmossdk.io/x/auth/tx" @@ -46,7 +47,7 @@ type App struct { storeKeys []storetypes.StoreKey interfaceRegistry codectypes.InterfaceRegistry cdc codec.Codec - amino *codec.LegacyAmino + amino legacy.Amino baseAppOptions []BaseAppOption msgServiceRouter *baseapp.MsgServiceRouter grpcQueryRouter *baseapp.GRPCQueryRouter diff --git a/runtime/module.go b/runtime/module.go index ad8aed2b0935..9e82cf6c30e0 100644 --- a/runtime/module.go +++ b/runtime/module.go @@ -19,12 +19,12 @@ import ( "cosmossdk.io/core/appmodule" "cosmossdk.io/core/comet" "cosmossdk.io/core/genesis" + "cosmossdk.io/core/legacy" "cosmossdk.io/core/store" "cosmossdk.io/depinject" "cosmossdk.io/depinject/appconfig" "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" - "cosmossdk.io/x/tx/signing" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" @@ -93,7 +93,11 @@ func init() { appconfig.RegisterModule(&runtimev1alpha1.Module{}, appconfig.Provide( ProvideApp, - ProvideInterfaceRegistry, + // to decouple runtime from sdk/codec ProvideInterfaceReistry can be registered from the app + // i.e. in the call to depinject.Inject(...) + codec.ProvideInterfaceRegistry, + codec.ProvideLegacyAmino, + codec.ProvideProtoCodec, ProvideKVStoreKey, ProvideTransientStoreKey, ProvideMemoryStoreKey, @@ -109,9 +113,11 @@ func init() { ) } -func ProvideApp(interfaceRegistry codectypes.InterfaceRegistry) ( - codec.Codec, - *codec.LegacyAmino, +func ProvideApp( + interfaceRegistry codectypes.InterfaceRegistry, + amino legacy.Amino, + protoCodec *codec.ProtoCodec, +) ( *AppBuilder, *baseapp.MsgServiceRouter, *baseapp.GRPCQueryRouter, @@ -130,25 +136,22 @@ func ProvideApp(interfaceRegistry codectypes.InterfaceRegistry) ( _, _ = fmt.Fprintln(os.Stderr, err.Error()) } - amino := codec.NewLegacyAmino() - std.RegisterInterfaces(interfaceRegistry) std.RegisterLegacyAminoCodec(amino) - cdc := codec.NewProtoCodec(interfaceRegistry) msgServiceRouter := baseapp.NewMsgServiceRouter() grpcQueryRouter := baseapp.NewGRPCQueryRouter() app := &App{ storeKeys: nil, interfaceRegistry: interfaceRegistry, - cdc: cdc, + cdc: protoCodec, amino: amino, msgServiceRouter: msgServiceRouter, grpcQueryRouter: grpcQueryRouter, } appBuilder := &AppBuilder{app} - return cdc, amino, appBuilder, msgServiceRouter, grpcQueryRouter, appModule{app}, protoFiles, protoTypes, nil + return appBuilder, msgServiceRouter, grpcQueryRouter, appModule{app}, protoFiles, protoTypes, nil } type AppInputs struct { @@ -161,7 +164,7 @@ type AppInputs struct { ModuleManager *module.Manager BaseAppOptions []BaseAppOption InterfaceRegistry codectypes.InterfaceRegistry - LegacyAmino *codec.LegacyAmino + LegacyAmino legacy.Amino } func SetupAppBuilder(inputs AppInputs) { @@ -175,34 +178,6 @@ func SetupAppBuilder(inputs AppInputs) { app.ModuleManager.RegisterLegacyAminoCodec(inputs.LegacyAmino) } -func ProvideInterfaceRegistry( - addressCodec address.Codec, - validatorAddressCodec address.ValidatorAddressCodec, - customGetSigners []signing.CustomGetSigner, -) (codectypes.InterfaceRegistry, error) { - signingOptions := signing.Options{ - AddressCodec: addressCodec, - ValidatorAddressCodec: validatorAddressCodec, - } - for _, signer := range customGetSigners { - signingOptions.DefineCustomGetSigners(signer.MsgType, signer.Fn) - } - - interfaceRegistry, err := codectypes.NewInterfaceRegistryWithOptions(codectypes.InterfaceRegistryOptions{ - ProtoFiles: proto.HybridResolver, - SigningOptions: signingOptions, - }) - if err != nil { - return nil, err - } - - if err := interfaceRegistry.SigningContext().Validate(); err != nil { - return nil, err - } - - return interfaceRegistry, nil -} - func registerStoreKey(wrapper *AppBuilder, key storetypes.StoreKey) { wrapper.app.storeKeys = append(wrapper.app.storeKeys, key) } diff --git a/simapp/app_di.go b/simapp/app_di.go index eab4f0110f63..7a459a18507e 100644 --- a/simapp/app_di.go +++ b/simapp/app_di.go @@ -12,6 +12,7 @@ import ( dbm "github.com/cosmos/cosmos-db" "github.com/spf13/cast" + "cosmossdk.io/core/legacy" "cosmossdk.io/depinject" "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" @@ -67,7 +68,7 @@ var ( // capabilities aren't needed for testing. type SimApp struct { *runtime.App - legacyAmino *codec.LegacyAmino + legacyAmino legacy.Amino appCodec codec.Codec txConfig client.TxConfig interfaceRegistry codectypes.InterfaceRegistry @@ -342,7 +343,12 @@ func (app *SimApp) Close() error { // NOTE: This is solely to be used for testing purposes as it may be desirable // for modules to register their own custom testing types. func (app *SimApp) LegacyAmino() *codec.LegacyAmino { - return app.legacyAmino + switch cdc := app.legacyAmino.(type) { + case *codec.LegacyAmino: + return cdc + default: + panic("unexpected codec type") + } } // AppCodec returns SimApp's app codec. diff --git a/simapp/simd/cmd/root_di.go b/simapp/simd/cmd/root_di.go index cfc8407edc11..adf8b6cef37c 100644 --- a/simapp/simd/cmd/root_di.go +++ b/simapp/simd/cmd/root_di.go @@ -12,6 +12,7 @@ import ( "cosmossdk.io/client/v2/autocli" clientv2keyring "cosmossdk.io/client/v2/autocli/keyring" "cosmossdk.io/core/address" + "cosmossdk.io/core/legacy" "cosmossdk.io/depinject" "cosmossdk.io/log" "cosmossdk.io/simapp" @@ -100,7 +101,7 @@ func ProvideClientContext( appCodec codec.Codec, interfaceRegistry codectypes.InterfaceRegistry, txConfigOpts tx.ConfigOptions, - legacyAmino *codec.LegacyAmino, + legacyAmino legacy.Amino, addressCodec address.Codec, validatorAddressCodec address.ValidatorAddressCodec, consensusAddressCodec address.ConsensusAddressCodec, @@ -109,10 +110,15 @@ func ProvideClientContext( ) client.Context { var err error + amino, ok := legacyAmino.(*codec.LegacyAmino) + if !ok { + panic("ProvideClientContext requires a *codec.LegacyAmino instance") + } + clientCtx := client.Context{}. WithCodec(appCodec). WithInterfaceRegistry(interfaceRegistry). - WithLegacyAmino(legacyAmino). + WithLegacyAmino(amino). WithInput(os.Stdin). WithAccountRetriever(types.AccountRetriever{}). WithAddressCodec(addressCodec). diff --git a/std/codec.go b/std/codec.go index 9a5b6a7467a1..c6020c133029 100644 --- a/std/codec.go +++ b/std/codec.go @@ -1,6 +1,8 @@ package std import ( + "cosmossdk.io/core/legacy" + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" @@ -9,7 +11,7 @@ import ( ) // RegisterLegacyAminoCodec registers types with the Amino codec. -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func RegisterLegacyAminoCodec(cdc legacy.Amino) { sdk.RegisterLegacyAminoCodec(cdc) cryptocodec.RegisterCrypto(cdc) codec.RegisterEvidences(cdc) diff --git a/tests/sims/authz/operations_test.go b/tests/sims/authz/operations_test.go index fa1e422f68a1..6abed781569f 100644 --- a/tests/sims/authz/operations_test.go +++ b/tests/sims/authz/operations_test.go @@ -57,7 +57,6 @@ type SimTestSuite struct { ctx sdk.Context app *runtime.App - legacyAmino *codec.LegacyAmino codec codec.Codec interfaceRegistry codectypes.InterfaceRegistry txConfig client.TxConfig @@ -72,7 +71,6 @@ func (suite *SimTestSuite) SetupTest() { AppConfig, depinject.Supply(log.NewNopLogger()), ), - &suite.legacyAmino, &suite.codec, &suite.interfaceRegistry, &suite.txConfig, diff --git a/tests/sims/feegrant/operations_test.go b/tests/sims/feegrant/operations_test.go index dba7785cedf7..d280cd6c40ba 100644 --- a/tests/sims/feegrant/operations_test.go +++ b/tests/sims/feegrant/operations_test.go @@ -49,7 +49,6 @@ type SimTestSuite struct { accountKeeper authkeeper.AccountKeeper bankKeeper bankkeeper.Keeper cdc codec.Codec - legacyAmino *codec.LegacyAmino } func (suite *SimTestSuite) SetupTest() { @@ -74,7 +73,6 @@ func (suite *SimTestSuite) SetupTest() { &suite.interfaceRegistry, &suite.txConfig, &suite.cdc, - &suite.legacyAmino, ) suite.Require().NoError(err) diff --git a/tests/sims/slashing/operations_test.go b/tests/sims/slashing/operations_test.go index e19241c1c775..f3263f1ab6e1 100644 --- a/tests/sims/slashing/operations_test.go +++ b/tests/sims/slashing/operations_test.go @@ -47,7 +47,6 @@ type SimTestSuite struct { accounts []simtypes.Account app *runtime.App - legacyAmino *codec.LegacyAmino codec codec.Codec interfaceRegistry codectypes.InterfaceRegistry txConfig client.TxConfig @@ -86,7 +85,6 @@ func (suite *SimTestSuite) SetupTest() { depinject.Supply(log.NewNopLogger()), ), startupCfg, - &suite.legacyAmino, &suite.codec, &suite.interfaceRegistry, &suite.txConfig, diff --git a/testutil/network/network.go b/testutil/network/network.go index 1c867bd42521..17c9c19fc38b 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -21,6 +21,7 @@ import ( "github.com/spf13/cobra" "cosmossdk.io/core/address" + "cosmossdk.io/core/legacy" "cosmossdk.io/depinject" "cosmossdk.io/log" sdkmath "cosmossdk.io/math" @@ -184,7 +185,7 @@ func DefaultConfigWithAppConfig(appConfig depinject.Config) (Config, error) { var ( appBuilder *runtime.AppBuilder txConfig client.TxConfig - legacyAmino *codec.LegacyAmino + legacyAmino legacy.Amino cdc codec.Codec interfaceRegistry codectypes.InterfaceRegistry addressCodec address.Codec @@ -214,7 +215,11 @@ func DefaultConfigWithAppConfig(appConfig depinject.Config) (Config, error) { }) cfg.Codec = cdc cfg.TxConfig = txConfig - cfg.LegacyAmino = legacyAmino + amino, ok := legacyAmino.(*codec.LegacyAmino) + if !ok { + return Config{}, errors.New("legacyAmino must be a *codec.LegacyAmino") + } + cfg.LegacyAmino = amino cfg.InterfaceRegistry = interfaceRegistry cfg.GenesisState = appBuilder.DefaultGenesis() cfg.AppConstructor = func(val ValidatorI) servertypes.Application { diff --git a/types/codec.go b/types/codec.go index 7cad97227b38..b24eff214356 100644 --- a/types/codec.go +++ b/types/codec.go @@ -1,9 +1,9 @@ package types import ( + "cosmossdk.io/core/legacy" coretransaction "cosmossdk.io/core/transaction" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" ) @@ -13,7 +13,7 @@ const ( ) // RegisterLegacyAminoCodec registers the sdk message type. -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func RegisterLegacyAminoCodec(cdc legacy.Amino) { cdc.RegisterInterface((*coretransaction.Msg)(nil), nil) cdc.RegisterInterface((*Tx)(nil), nil) } diff --git a/types/module/core_module.go b/types/module/core_module.go index 26acf836bd68..97466ffeb165 100644 --- a/types/module/core_module.go +++ b/types/module/core_module.go @@ -9,11 +9,11 @@ import ( "cosmossdk.io/core/appmodule" "cosmossdk.io/core/genesis" + "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -198,9 +198,9 @@ func (c coreAppModuleAdaptor) RegisterInterfaces(reg registry.InterfaceRegistrar } // RegisterLegacyAminoCodec implements HasAminoCodec -func (c coreAppModuleAdaptor) RegisterLegacyAminoCodec(amino *codec.LegacyAmino) { +func (c coreAppModuleAdaptor) RegisterLegacyAminoCodec(amino legacy.Amino) { if mod, ok := c.module.(interface { - RegisterLegacyAminoCodec(amino *codec.LegacyAmino) + RegisterLegacyAminoCodec(amino legacy.Amino) }); ok { mod.RegisterLegacyAminoCodec(amino) } diff --git a/types/module/module.go b/types/module/module.go index 1d718b9d4aac..306db89d4fbf 100644 --- a/types/module/module.go +++ b/types/module/module.go @@ -34,12 +34,12 @@ import ( "cosmossdk.io/core/appmodule" appmodulev2 "cosmossdk.io/core/appmodule/v2" "cosmossdk.io/core/genesis" + "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" errorsmod "cosmossdk.io/errors" storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) @@ -78,7 +78,7 @@ type HasGenesisBasics interface { // HasAminoCodec is the interface for modules that have amino codec registration. // Deprecated: modules should not need to register their own amino codecs. type HasAminoCodec interface { - RegisterLegacyAminoCodec(*codec.LegacyAmino) + RegisterLegacyAminoCodec(legacy.Amino) } // HasGRPCGateway is the interface for modules to register their gRPC gateway routes. @@ -299,7 +299,7 @@ func (m *Manager) SetOrderMigrations(moduleNames ...string) { } // RegisterLegacyAminoCodec registers all module codecs -func (m *Manager) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func (m *Manager) RegisterLegacyAminoCodec(cdc legacy.Amino) { for _, b := range m.Modules { if mod, ok := b.(HasAminoCodec); ok { mod.RegisterLegacyAminoCodec(cdc) diff --git a/x/auth/ante/testutil_test.go b/x/auth/ante/testutil_test.go index b589b41a1504..65491692675c 100644 --- a/x/auth/ante/testutil_test.go +++ b/x/auth/ante/testutil_test.go @@ -108,7 +108,7 @@ func SetupTestSuite(t *testing.T, isCheckTx bool) *AnteTestSuite { require.NoError(t, err) // We're using TestMsg encoding in some tests, so register it here. - suite.encCfg.Amino.RegisterConcrete(&testdata.TestMsg{}, "testdata.TestMsg", nil) + suite.encCfg.Amino.RegisterConcrete(&testdata.TestMsg{}, "testdata.TestMsg") testdata.RegisterInterfaces(suite.encCfg.InterfaceRegistry) suite.clientCtx = client.Context{}. diff --git a/x/auth/migrations/legacytx/codec.go b/x/auth/migrations/legacytx/codec.go index 2bad4718e1e6..541a15470687 100644 --- a/x/auth/migrations/legacytx/codec.go +++ b/x/auth/migrations/legacytx/codec.go @@ -1,9 +1,9 @@ package legacytx import ( - "github.com/cosmos/cosmos-sdk/codec" + "cosmossdk.io/core/legacy" ) -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(StdTx{}, "cosmos-sdk/StdTx", nil) +func RegisterLegacyAminoCodec(cdc legacy.Amino) { + cdc.RegisterConcrete(StdTx{}, "cosmos-sdk/StdTx") } diff --git a/x/auth/module.go b/x/auth/module.go index 8459fd4aa610..a2ceba435aea 100644 --- a/x/auth/module.go +++ b/x/auth/module.go @@ -9,6 +9,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" "cosmossdk.io/x/auth/keeper" "cosmossdk.io/x/auth/simulation" @@ -48,7 +49,12 @@ type AppModule struct { func (am AppModule) IsAppModule() {} // NewAppModule creates a new AppModule object -func NewAppModule(cdc codec.Codec, accountKeeper keeper.AccountKeeper, ak types.AccountsModKeeper, randGenAccountsFn types.RandomGenesisAccountsFn) AppModule { +func NewAppModule( + cdc codec.Codec, + accountKeeper keeper.AccountKeeper, + ak types.AccountsModKeeper, + randGenAccountsFn types.RandomGenesisAccountsFn, +) AppModule { return AppModule{ accountKeeper: accountKeeper, randGenAccountsFn: randGenAccountsFn, @@ -63,7 +69,7 @@ func (AppModule) Name() string { } // RegisterLegacyAminoCodec registers the auth module's types for the given codec. -func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) { types.RegisterLegacyAminoCodec(cdc) } diff --git a/x/auth/types/codec.go b/x/auth/types/codec.go index d4d59a6a840e..473e3d94ab21 100644 --- a/x/auth/types/codec.go +++ b/x/auth/types/codec.go @@ -1,11 +1,11 @@ package types import ( + corelegacy "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" coretransaction "cosmossdk.io/core/transaction" "cosmossdk.io/x/auth/migrations/legacytx" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -13,14 +13,14 @@ import ( // RegisterLegacyAminoCodec registers the account interfaces and concrete types on the // provided LegacyAmino codec. These types are used for Amino JSON serialization -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func RegisterLegacyAminoCodec(cdc corelegacy.Amino) { cdc.RegisterInterface((*sdk.ModuleAccountI)(nil), nil) cdc.RegisterInterface((*GenesisAccount)(nil), nil) cdc.RegisterInterface((*sdk.AccountI)(nil), nil) - cdc.RegisterConcrete(&BaseAccount{}, "cosmos-sdk/BaseAccount", nil) - cdc.RegisterConcrete(&ModuleAccount{}, "cosmos-sdk/ModuleAccount", nil) - cdc.RegisterConcrete(Params{}, "cosmos-sdk/x/auth/Params", nil) - cdc.RegisterConcrete(&ModuleCredential{}, "cosmos-sdk/GroupAccountCredential", nil) + cdc.RegisterConcrete(&BaseAccount{}, "cosmos-sdk/BaseAccount") + cdc.RegisterConcrete(&ModuleAccount{}, "cosmos-sdk/ModuleAccount") + cdc.RegisterConcrete(Params{}, "cosmos-sdk/x/auth/Params") + cdc.RegisterConcrete(&ModuleCredential{}, "cosmos-sdk/GroupAccountCredential") legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, "cosmos-sdk/x/auth/MsgUpdateParams") diff --git a/x/auth/vesting/module.go b/x/auth/vesting/module.go index 8835309db9ed..0baec3da3b01 100644 --- a/x/auth/vesting/module.go +++ b/x/auth/vesting/module.go @@ -2,11 +2,11 @@ package vesting import ( "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" "cosmossdk.io/x/auth/keeper" "cosmossdk.io/x/auth/vesting/types" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types/module" ) @@ -38,8 +38,8 @@ func (AppModule) Name() string { return types.ModuleName } -// RegisterCodec registers the module's types with the given codec. -func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +// RegisterLegacyAminoCodec registers the module's types with the given codec. +func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) { types.RegisterLegacyAminoCodec(cdc) } diff --git a/x/auth/vesting/types/codec.go b/x/auth/vesting/types/codec.go index c415488afdbf..99246287c315 100644 --- a/x/auth/vesting/types/codec.go +++ b/x/auth/vesting/types/codec.go @@ -1,12 +1,12 @@ package types import ( + corelegacy "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" coretransaction "cosmossdk.io/core/transaction" authtypes "cosmossdk.io/x/auth/types" "cosmossdk.io/x/auth/vesting/exported" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" @@ -14,13 +14,13 @@ import ( // RegisterLegacyAminoCodec registers the vesting interfaces and concrete types on the // provided LegacyAmino codec. These types are used for Amino JSON serialization -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func RegisterLegacyAminoCodec(cdc corelegacy.Amino) { cdc.RegisterInterface((*exported.VestingAccount)(nil), nil) - cdc.RegisterConcrete(&BaseVestingAccount{}, "cosmos-sdk/BaseVestingAccount", nil) - cdc.RegisterConcrete(&ContinuousVestingAccount{}, "cosmos-sdk/ContinuousVestingAccount", nil) - cdc.RegisterConcrete(&DelayedVestingAccount{}, "cosmos-sdk/DelayedVestingAccount", nil) - cdc.RegisterConcrete(&PeriodicVestingAccount{}, "cosmos-sdk/PeriodicVestingAccount", nil) - cdc.RegisterConcrete(&PermanentLockedAccount{}, "cosmos-sdk/PermanentLockedAccount", nil) + cdc.RegisterConcrete(&BaseVestingAccount{}, "cosmos-sdk/BaseVestingAccount") + cdc.RegisterConcrete(&ContinuousVestingAccount{}, "cosmos-sdk/ContinuousVestingAccount") + cdc.RegisterConcrete(&DelayedVestingAccount{}, "cosmos-sdk/DelayedVestingAccount") + cdc.RegisterConcrete(&PeriodicVestingAccount{}, "cosmos-sdk/PeriodicVestingAccount") + cdc.RegisterConcrete(&PermanentLockedAccount{}, "cosmos-sdk/PermanentLockedAccount") legacy.RegisterAminoMsg(cdc, &MsgCreateVestingAccount{}, "cosmos-sdk/MsgCreateVestingAccount") legacy.RegisterAminoMsg(cdc, &MsgCreatePermanentLockedAccount{}, "cosmos-sdk/MsgCreatePermLockedAccount") legacy.RegisterAminoMsg(cdc, &MsgCreatePeriodicVestingAccount{}, "cosmos-sdk/MsgCreatePeriodVestAccount") diff --git a/x/authz/codec.go b/x/authz/codec.go index 18e65dbb4c0a..925fd90b639b 100644 --- a/x/authz/codec.go +++ b/x/authz/codec.go @@ -1,25 +1,25 @@ package authz import ( + corelegacy "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" coretransaction "cosmossdk.io/core/transaction" bank "cosmossdk.io/x/bank/types" staking "cosmossdk.io/x/staking/types" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/types/msgservice" ) // RegisterLegacyAminoCodec registers the necessary x/authz interfaces and concrete types // on the provided LegacyAmino codec. These types are used for Amino JSON serialization. -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func RegisterLegacyAminoCodec(cdc corelegacy.Amino) { legacy.RegisterAminoMsg(cdc, &MsgGrant{}, "cosmos-sdk/MsgGrant") legacy.RegisterAminoMsg(cdc, &MsgRevoke{}, "cosmos-sdk/MsgRevoke") legacy.RegisterAminoMsg(cdc, &MsgExec{}, "cosmos-sdk/MsgExec") cdc.RegisterInterface((*Authorization)(nil), nil) - cdc.RegisterConcrete(&GenericAuthorization{}, "cosmos-sdk/GenericAuthorization", nil) + cdc.RegisterConcrete(&GenericAuthorization{}, "cosmos-sdk/GenericAuthorization") } // RegisterInterfaces registers the interfaces types with the interface registry diff --git a/x/authz/module/module.go b/x/authz/module/module.go index bf39198c6412..3d14c8f2cccc 100644 --- a/x/authz/module/module.go +++ b/x/authz/module/module.go @@ -10,6 +10,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" "cosmossdk.io/errors" "cosmossdk.io/x/authz" @@ -50,7 +51,13 @@ type AppModule struct { } // NewAppModule creates a new AppModule object -func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak authz.AccountKeeper, bk authz.BankKeeper, registry cdctypes.InterfaceRegistry) AppModule { +func NewAppModule( + cdc codec.Codec, + keeper keeper.Keeper, + ak authz.AccountKeeper, + bk authz.BankKeeper, + registry cdctypes.InterfaceRegistry, +) AppModule { return AppModule{ cdc: cdc, keeper: keeper, @@ -87,7 +94,7 @@ func (am AppModule) RegisterMigrations(mr appmodule.MigrationRegistrar) error { } // RegisterLegacyAminoCodec registers the authz module's types for the given codec. -func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) { authz.RegisterLegacyAminoCodec(cdc) } diff --git a/x/bank/module.go b/x/bank/module.go index d9db2b6abe96..78295ca268e6 100644 --- a/x/bank/module.go +++ b/x/bank/module.go @@ -10,6 +10,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" "cosmossdk.io/x/bank/client/cli" "cosmossdk.io/x/bank/keeper" @@ -63,7 +64,7 @@ func (am AppModule) IsAppModule() {} func (AppModule) Name() string { return types.ModuleName } // RegisterLegacyAminoCodec registers the bank module's types on the LegacyAmino codec. -func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) { types.RegisterLegacyAminoCodec(cdc) } diff --git a/x/bank/types/codec.go b/x/bank/types/codec.go index 500fb979b494..643621fe90dd 100644 --- a/x/bank/types/codec.go +++ b/x/bank/types/codec.go @@ -1,24 +1,24 @@ package types import ( + corelegacy "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" coretransaction "cosmossdk.io/core/transaction" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/types/msgservice" ) // RegisterLegacyAminoCodec registers the necessary x/bank interfaces and concrete types // on the provided LegacyAmino codec. These types are used for Amino JSON serialization. -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func RegisterLegacyAminoCodec(cdc corelegacy.Amino) { legacy.RegisterAminoMsg(cdc, &MsgSend{}, "cosmos-sdk/MsgSend") legacy.RegisterAminoMsg(cdc, &MsgMultiSend{}, "cosmos-sdk/MsgMultiSend") legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, "cosmos-sdk/x/bank/MsgUpdateParams") legacy.RegisterAminoMsg(cdc, &MsgSetSendEnabled{}, "cosmos-sdk/MsgSetSendEnabled") - cdc.RegisterConcrete(&SendAuthorization{}, "cosmos-sdk/SendAuthorization", nil) - cdc.RegisterConcrete(&Params{}, "cosmos-sdk/x/bank/Params", nil) + cdc.RegisterConcrete(&SendAuthorization{}, "cosmos-sdk/SendAuthorization") + cdc.RegisterConcrete(&Params{}, "cosmos-sdk/x/bank/Params") } func RegisterInterfaces(registrar registry.InterfaceRegistrar) { diff --git a/x/consensus/module.go b/x/consensus/module.go index adeed0733025..4ef57fcb39e6 100644 --- a/x/consensus/module.go +++ b/x/consensus/module.go @@ -7,6 +7,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" "cosmossdk.io/x/consensus/keeper" "cosmossdk.io/x/consensus/types" @@ -49,7 +50,7 @@ func (AppModule) IsAppModule() {} func (AppModule) Name() string { return types.ModuleName } // RegisterLegacyAminoCodec registers the consensus module's types on the LegacyAmino codec. -func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) { types.RegisterLegacyAminoCodec(cdc) } diff --git a/x/consensus/types/codec.go b/x/consensus/types/codec.go index 069b198a5be4..2573b41d4beb 100644 --- a/x/consensus/types/codec.go +++ b/x/consensus/types/codec.go @@ -1,10 +1,10 @@ package types import ( + corelegacy "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" coretransaction "cosmossdk.io/core/transaction" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/types/msgservice" ) @@ -20,6 +20,6 @@ func RegisterInterfaces(registrar registry.InterfaceRegistrar) { // RegisterLegacyAminoCodec registers the necessary x/consensus interfaces and concrete types // on the provided LegacyAmino codec. These types are used for Amino JSON serialization. -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func RegisterLegacyAminoCodec(cdc corelegacy.Amino) { legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, "cosmos-sdk/x/consensus/MsgUpdateParams") } diff --git a/x/crisis/module.go b/x/crisis/module.go index 0a17ce54908b..245b6797c350 100644 --- a/x/crisis/module.go +++ b/x/crisis/module.go @@ -9,6 +9,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" "github.com/cosmos/cosmos-sdk/codec" @@ -66,7 +67,7 @@ func (AppModule) Name() string { } // RegisterLegacyAminoCodec registers the crisis module's types on the given LegacyAmino codec. -func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) { types.RegisterLegacyAminoCodec(cdc) } diff --git a/x/crisis/types/codec.go b/x/crisis/types/codec.go index 82a880305314..ca3f0e52afb8 100644 --- a/x/crisis/types/codec.go +++ b/x/crisis/types/codec.go @@ -1,17 +1,17 @@ package types import ( + corelegacy "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" coretransaction "cosmossdk.io/core/transaction" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/types/msgservice" ) // RegisterLegacyAminoCodec registers the necessary x/crisis interfaces and concrete types // on the provided LegacyAmino codec. These types are used for Amino JSON serialization. -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func RegisterLegacyAminoCodec(cdc corelegacy.Amino) { legacy.RegisterAminoMsg(cdc, &MsgVerifyInvariant{}, "cosmos-sdk/MsgVerifyInvariant") legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, "cosmos-sdk/x/crisis/MsgUpdateParams") } diff --git a/x/distribution/module.go b/x/distribution/module.go index eebf6ac2517d..e9bfb03a179f 100644 --- a/x/distribution/module.go +++ b/x/distribution/module.go @@ -10,6 +10,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" "cosmossdk.io/x/distribution/client/cli" "cosmossdk.io/x/distribution/keeper" @@ -75,7 +76,7 @@ func (AppModule) Name() string { } // RegisterLegacyAminoCodec registers the distribution module's types for the given codec. -func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) { types.RegisterLegacyAminoCodec(cdc) } diff --git a/x/distribution/types/codec.go b/x/distribution/types/codec.go index d40ee6db22da..79e5c78c0613 100644 --- a/x/distribution/types/codec.go +++ b/x/distribution/types/codec.go @@ -1,10 +1,10 @@ package types import ( + corelegacy "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" coretransaction "cosmossdk.io/core/transaction" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/types/msgservice" ) @@ -12,14 +12,14 @@ import ( // RegisterLegacyAminoCodec registers the necessary x/distribution interfaces // and concrete types on the provided LegacyAmino codec. These types are used // for Amino JSON serialization. -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func RegisterLegacyAminoCodec(cdc corelegacy.Amino) { legacy.RegisterAminoMsg(cdc, &MsgWithdrawDelegatorReward{}, "cosmos-sdk/MsgWithdrawDelegationReward") legacy.RegisterAminoMsg(cdc, &MsgWithdrawValidatorCommission{}, "cosmos-sdk/MsgWithdrawValCommission") legacy.RegisterAminoMsg(cdc, &MsgSetWithdrawAddress{}, "cosmos-sdk/MsgModifyWithdrawAddress") legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, "cosmos-sdk/distribution/MsgUpdateParams") legacy.RegisterAminoMsg(cdc, &MsgDepositValidatorRewardsPool{}, "cosmos-sdk/distr/MsgDepositValRewards") - cdc.RegisterConcrete(Params{}, "cosmos-sdk/x/distribution/Params", nil) + cdc.RegisterConcrete(Params{}, "cosmos-sdk/x/distribution/Params") } func RegisterInterfaces(registrar registry.InterfaceRegistrar) { diff --git a/x/epochs/module.go b/x/epochs/module.go index d520fe0e2436..23f39c362075 100644 --- a/x/epochs/module.go +++ b/x/epochs/module.go @@ -9,6 +9,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/legacy" "cosmossdk.io/x/epochs/keeper" "cosmossdk.io/x/epochs/simulation" "cosmossdk.io/x/epochs/types" @@ -55,8 +56,7 @@ func (AppModule) Name() string { } // RegisterLegacyAminoCodec registers the epochs module's types for the given codec. -func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { -} +func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) {} // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the epochs module. func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwruntime.ServeMux) { diff --git a/x/evidence/module.go b/x/evidence/module.go index 4482fbf36fd8..22756148485d 100644 --- a/x/evidence/module.go +++ b/x/evidence/module.go @@ -11,6 +11,7 @@ import ( "cosmossdk.io/core/appmodule" "cosmossdk.io/core/comet" + "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" eviclient "cosmossdk.io/x/evidence/client" "cosmossdk.io/x/evidence/client/cli" @@ -65,7 +66,7 @@ func (AppModule) Name() string { } // RegisterLegacyAminoCodec registers the evidence module's types to the LegacyAmino codec. -func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) { types.RegisterLegacyAminoCodec(cdc) } diff --git a/x/evidence/types/codec.go b/x/evidence/types/codec.go index fe592cba9bf7..d26766dad7d5 100644 --- a/x/evidence/types/codec.go +++ b/x/evidence/types/codec.go @@ -1,21 +1,21 @@ package types import ( + corelegacy "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" coretransaction "cosmossdk.io/core/transaction" "cosmossdk.io/x/evidence/exported" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/types/msgservice" ) // RegisterLegacyAminoCodec registers all the necessary types and interfaces for the // evidence module. -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func RegisterLegacyAminoCodec(cdc corelegacy.Amino) { cdc.RegisterInterface((*exported.Evidence)(nil), nil) legacy.RegisterAminoMsg(cdc, &MsgSubmitEvidence{}, "cosmos-sdk/MsgSubmitEvidence") - cdc.RegisterConcrete(&Equivocation{}, "cosmos-sdk/Equivocation", nil) + cdc.RegisterConcrete(&Equivocation{}, "cosmos-sdk/Equivocation") } // RegisterInterfaces registers the interfaces types with the interface registry. diff --git a/x/feegrant/codec.go b/x/feegrant/codec.go index d5da542a11fc..d27a3a22db90 100644 --- a/x/feegrant/codec.go +++ b/x/feegrant/codec.go @@ -1,24 +1,24 @@ package feegrant import ( + corelegacy "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" coretransaction "cosmossdk.io/core/transaction" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/types/msgservice" ) // RegisterLegacyAminoCodec registers the necessary x/feegrant interfaces and concrete types // on the provided LegacyAmino codec. These types are used for Amino JSON serialization. -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func RegisterLegacyAminoCodec(cdc corelegacy.Amino) { legacy.RegisterAminoMsg(cdc, &MsgGrantAllowance{}, "cosmos-sdk/MsgGrantAllowance") legacy.RegisterAminoMsg(cdc, &MsgRevokeAllowance{}, "cosmos-sdk/MsgRevokeAllowance") cdc.RegisterInterface((*FeeAllowanceI)(nil), nil) - cdc.RegisterConcrete(&BasicAllowance{}, "cosmos-sdk/BasicAllowance", nil) - cdc.RegisterConcrete(&PeriodicAllowance{}, "cosmos-sdk/PeriodicAllowance", nil) - cdc.RegisterConcrete(&AllowedMsgAllowance{}, "cosmos-sdk/AllowedMsgAllowance", nil) + cdc.RegisterConcrete(&BasicAllowance{}, "cosmos-sdk/BasicAllowance") + cdc.RegisterConcrete(&PeriodicAllowance{}, "cosmos-sdk/PeriodicAllowance") + cdc.RegisterConcrete(&AllowedMsgAllowance{}, "cosmos-sdk/AllowedMsgAllowance") } // RegisterInterfaces registers the interfaces types with the interface registry diff --git a/x/feegrant/module/module.go b/x/feegrant/module/module.go index b02978dbd906..237705f5b997 100644 --- a/x/feegrant/module/module.go +++ b/x/feegrant/module/module.go @@ -10,6 +10,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" "cosmossdk.io/errors" "cosmossdk.io/x/feegrant" @@ -66,7 +67,7 @@ func (AppModule) Name() string { } // RegisterLegacyAminoCodec registers the feegrant module's types for the given codec. -func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) { feegrant.RegisterLegacyAminoCodec(cdc) } diff --git a/x/gov/module.go b/x/gov/module.go index f88ed628a4fe..38ff794653ef 100644 --- a/x/gov/module.go +++ b/x/gov/module.go @@ -10,6 +10,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" govclient "cosmossdk.io/x/gov/client" "cosmossdk.io/x/gov/client/cli" @@ -79,7 +80,7 @@ func (AppModule) Name() string { } // RegisterLegacyAminoCodec registers the gov module's types for the given codec. -func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) { v1beta1.RegisterLegacyAminoCodec(cdc) v1.RegisterLegacyAminoCodec(cdc) } diff --git a/x/gov/types/v1/codec.go b/x/gov/types/v1/codec.go index 767b1276bb96..bb0beae33ea7 100644 --- a/x/gov/types/v1/codec.go +++ b/x/gov/types/v1/codec.go @@ -1,17 +1,17 @@ package v1 import ( + corelegacy "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" coretransaction "cosmossdk.io/core/transaction" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/types/msgservice" ) // RegisterLegacyAminoCodec registers all the necessary types and interfaces for the // governance module. -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func RegisterLegacyAminoCodec(cdc corelegacy.Amino) { legacy.RegisterAminoMsg(cdc, &MsgSubmitProposal{}, "cosmos-sdk/v1/MsgSubmitProposal") legacy.RegisterAminoMsg(cdc, &MsgSubmitMultipleChoiceProposal{}, "gov/MsgSubmitMultipleChoiceProposal") legacy.RegisterAminoMsg(cdc, &MsgDeposit{}, "cosmos-sdk/v1/MsgDeposit") diff --git a/x/gov/types/v1beta1/codec.go b/x/gov/types/v1beta1/codec.go index aebb575ce2aa..475a8dc451dd 100644 --- a/x/gov/types/v1beta1/codec.go +++ b/x/gov/types/v1beta1/codec.go @@ -1,23 +1,23 @@ package v1beta1 import ( + corelegacy "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" coretransaction "cosmossdk.io/core/transaction" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/types/msgservice" ) // RegisterLegacyAminoCodec registers all the necessary types and interfaces for the // governance module. -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func RegisterLegacyAminoCodec(cdc corelegacy.Amino) { cdc.RegisterInterface((*Content)(nil), nil) legacy.RegisterAminoMsg(cdc, &MsgSubmitProposal{}, "cosmos-sdk/MsgSubmitProposal") legacy.RegisterAminoMsg(cdc, &MsgDeposit{}, "cosmos-sdk/MsgDeposit") legacy.RegisterAminoMsg(cdc, &MsgVote{}, "cosmos-sdk/MsgVote") legacy.RegisterAminoMsg(cdc, &MsgVoteWeighted{}, "cosmos-sdk/MsgVoteWeighted") - cdc.RegisterConcrete(&TextProposal{}, "cosmos-sdk/TextProposal", nil) + cdc.RegisterConcrete(&TextProposal{}, "cosmos-sdk/TextProposal") } // RegisterInterfaces registers the interfaces types with the Interface Registry. diff --git a/x/group/codec.go b/x/group/codec.go index 19b2d7c02749..f4d80229fb79 100644 --- a/x/group/codec.go +++ b/x/group/codec.go @@ -1,10 +1,10 @@ package group import ( + corelegacy "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" coretransaction "cosmossdk.io/core/transaction" - codectypes "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/types/msgservice" ) @@ -12,10 +12,10 @@ import ( // RegisterLegacyAminoCodec registers all the necessary group module concrete // types and interfaces with the provided codec reference. // These types are used for Amino JSON serialization. -func RegisterLegacyAminoCodec(cdc *codectypes.LegacyAmino) { +func RegisterLegacyAminoCodec(cdc corelegacy.Amino) { cdc.RegisterInterface((*DecisionPolicy)(nil), nil) - cdc.RegisterConcrete(&ThresholdDecisionPolicy{}, "cosmos-sdk/ThresholdDecisionPolicy", nil) - cdc.RegisterConcrete(&PercentageDecisionPolicy{}, "cosmos-sdk/PercentageDecisionPolicy", nil) + cdc.RegisterConcrete(&ThresholdDecisionPolicy{}, "cosmos-sdk/ThresholdDecisionPolicy") + cdc.RegisterConcrete(&PercentageDecisionPolicy{}, "cosmos-sdk/PercentageDecisionPolicy") legacy.RegisterAminoMsg(cdc, &MsgCreateGroup{}, "cosmos-sdk/MsgCreateGroup") legacy.RegisterAminoMsg(cdc, &MsgUpdateGroupMembers{}, "cosmos-sdk/MsgUpdateGroupMembers") diff --git a/x/group/module/module.go b/x/group/module/module.go index 42c4ede0af51..c66756457517 100644 --- a/x/group/module/module.go +++ b/x/group/module/module.go @@ -10,6 +10,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" "cosmossdk.io/x/group" "cosmossdk.io/x/group/client/cli" @@ -88,7 +89,7 @@ func (AppModule) RegisterInterfaces(registrar registry.InterfaceRegistrar) { } // RegisterLegacyAminoCodec registers the group module's types for the given codec. -func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) { group.RegisterLegacyAminoCodec(cdc) } diff --git a/x/mint/module.go b/x/mint/module.go index 617868e39019..8c0d69bce55a 100644 --- a/x/mint/module.go +++ b/x/mint/module.go @@ -9,6 +9,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" "cosmossdk.io/x/mint/keeper" "cosmossdk.io/x/mint/simulation" @@ -77,7 +78,7 @@ func (AppModule) Name() string { } // RegisterLegacyAminoCodec registers the mint module's types on the given LegacyAmino codec. -func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) { types.RegisterLegacyAminoCodec(cdc) } diff --git a/x/mint/types/codec.go b/x/mint/types/codec.go index c492772d05f5..a90efe4abbe1 100644 --- a/x/mint/types/codec.go +++ b/x/mint/types/codec.go @@ -1,17 +1,17 @@ package types import ( + corelegacy "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" coretransaction "cosmossdk.io/core/transaction" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/types/msgservice" ) // RegisterLegacyAminoCodec registers concrete types on the LegacyAmino codec -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(Params{}, "cosmos-sdk/x/mint/Params", nil) +func RegisterLegacyAminoCodec(cdc corelegacy.Amino) { + cdc.RegisterConcrete(Params{}, "cosmos-sdk/x/mint/Params") legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, "cosmos-sdk/x/mint/MsgUpdateParams") } diff --git a/x/params/keeper/common_test.go b/x/params/keeper/common_test.go index 5a577e51b649..07a7ddd8a475 100644 --- a/x/params/keeper/common_test.go +++ b/x/params/keeper/common_test.go @@ -34,7 +34,7 @@ type s struct { func createTestCodec() *codec.LegacyAmino { cdc := codec.NewLegacyAmino() sdk.RegisterLegacyAminoCodec(cdc) - cdc.RegisterConcrete(s{}, "test/s", nil) - cdc.RegisterConcrete(invalid{}, "test/invalid", nil) + cdc.RegisterConcrete(s{}, "test/s") + cdc.RegisterConcrete(invalid{}, "test/invalid") return cdc } diff --git a/x/params/module.go b/x/params/module.go index 0ed3a514fb3c..bba2218ea3e0 100644 --- a/x/params/module.go +++ b/x/params/module.go @@ -7,12 +7,12 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" "cosmossdk.io/x/params/keeper" "cosmossdk.io/x/params/types/proposal" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" ) @@ -52,7 +52,7 @@ func (AppModule) Name() string { } // RegisterLegacyAminoCodec registers the params module's types on the given LegacyAmino codec. -func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) { proposal.RegisterLegacyAminoCodec(cdc) } diff --git a/x/params/types/proposal/codec.go b/x/params/types/proposal/codec.go index 78cbcb5c371d..a2a226e683e8 100644 --- a/x/params/types/proposal/codec.go +++ b/x/params/types/proposal/codec.go @@ -1,15 +1,14 @@ package proposal import ( + "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" govtypes "cosmossdk.io/x/gov/types/v1beta1" - - "github.com/cosmos/cosmos-sdk/codec" ) // RegisterLegacyAminoCodec registers all necessary param module types with a given LegacyAmino codec. -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(&ParameterChangeProposal{}, "cosmos-sdk/ParameterChangeProposal", nil) +func RegisterLegacyAminoCodec(cdc legacy.Amino) { + cdc.RegisterConcrete(&ParameterChangeProposal{}, "cosmos-sdk/ParameterChangeProposal") } func RegisterInterfaces(registrar registry.InterfaceRegistrar) { diff --git a/x/protocolpool/module.go b/x/protocolpool/module.go index 78b53339a215..a3a79decf8fb 100644 --- a/x/protocolpool/module.go +++ b/x/protocolpool/module.go @@ -9,6 +9,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" "cosmossdk.io/x/protocolpool/keeper" "cosmossdk.io/x/protocolpool/types" @@ -60,7 +61,7 @@ func (AppModule) IsAppModule() {} func (AppModule) Name() string { return types.ModuleName } // RegisterLegacyAminoCodec registers the pool module's types on the LegacyAmino codec. -func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} +func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) {} // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwruntime.ServeMux) { diff --git a/x/slashing/depinject.go b/x/slashing/depinject.go index d1af9fa19b94..ead44b6fd8f2 100644 --- a/x/slashing/depinject.go +++ b/x/slashing/depinject.go @@ -35,7 +35,6 @@ type ModuleInputs struct { Config *modulev1.Module Environment appmodule.Environment Cdc codec.Codec - LegacyAmino *codec.LegacyAmino Registry cdctypes.InterfaceRegistry CometService comet.Service @@ -64,7 +63,7 @@ func ProvideModule(in ModuleInputs) ModuleOutputs { panic(fmt.Errorf("unable to decode authority in slashing: %w", err)) } - k := keeper.NewKeeper(in.Environment, in.Cdc, in.LegacyAmino, in.StakingKeeper, authStr) + k := keeper.NewKeeper(in.Environment, in.Cdc, nil, in.StakingKeeper, authStr) m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper, in.StakingKeeper, in.Registry, in.CometService) return ModuleOutputs{ Keeper: k, diff --git a/x/slashing/keeper/keeper.go b/x/slashing/keeper/keeper.go index 1a511626e5ab..1aa8c1f8c59b 100644 --- a/x/slashing/keeper/keeper.go +++ b/x/slashing/keeper/keeper.go @@ -20,7 +20,8 @@ import ( type Keeper struct { appmodule.Environment - cdc codec.BinaryCodec + cdc codec.BinaryCodec + // deprecated! legacyAmino *codec.LegacyAmino sk types.StakingKeeper diff --git a/x/slashing/module.go b/x/slashing/module.go index c38157b2d8b6..f3a8a3f3e506 100644 --- a/x/slashing/module.go +++ b/x/slashing/module.go @@ -10,6 +10,7 @@ import ( "cosmossdk.io/core/appmodule" "cosmossdk.io/core/comet" + "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" "cosmossdk.io/x/slashing/keeper" "cosmossdk.io/x/slashing/simulation" @@ -81,7 +82,7 @@ func (AppModule) Name() string { } // RegisterLegacyAminoCodec registers the slashing module's types for the given codec. -func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) { types.RegisterLegacyAminoCodec(cdc) } diff --git a/x/slashing/types/codec.go b/x/slashing/types/codec.go index 18eb7aa2f419..7e58c25d9f5a 100644 --- a/x/slashing/types/codec.go +++ b/x/slashing/types/codec.go @@ -1,17 +1,17 @@ package types import ( + corelegacy "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" coretransaction "cosmossdk.io/core/transaction" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/types/msgservice" ) // RegisterLegacyAminoCodec registers concrete types on LegacyAmino codec -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(Params{}, "cosmos-sdk/x/slashing/Params", nil) +func RegisterLegacyAminoCodec(cdc corelegacy.Amino) { + cdc.RegisterConcrete(Params{}, "cosmos-sdk/x/slashing/Params") legacy.RegisterAminoMsg(cdc, &MsgUnjail{}, "cosmos-sdk/MsgUnjail") legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, "cosmos-sdk/x/slashing/MsgUpdateParams") } diff --git a/x/staking/module.go b/x/staking/module.go index a315ae1a1963..622b088ca1ed 100644 --- a/x/staking/module.go +++ b/x/staking/module.go @@ -10,6 +10,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" "cosmossdk.io/depinject" "cosmossdk.io/x/staking/client/cli" @@ -76,7 +77,7 @@ func (AppModule) Name() string { } // RegisterLegacyAminoCodec registers the staking module's types on the given LegacyAmino codec. -func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) { types.RegisterLegacyAminoCodec(cdc) } diff --git a/x/staking/types/codec.go b/x/staking/types/codec.go index 922a069e918e..0d4fb4a4d001 100644 --- a/x/staking/types/codec.go +++ b/x/staking/types/codec.go @@ -1,17 +1,17 @@ package types import ( + corelegacy "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" coretransaction "cosmossdk.io/core/transaction" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/types/msgservice" ) // RegisterLegacyAminoCodec registers the necessary x/staking interfaces and concrete types // on the provided LegacyAmino codec. These types are used for Amino JSON serialization. -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func RegisterLegacyAminoCodec(cdc corelegacy.Amino) { legacy.RegisterAminoMsg(cdc, &MsgCreateValidator{}, "cosmos-sdk/MsgCreateValidator") legacy.RegisterAminoMsg(cdc, &MsgEditValidator{}, "cosmos-sdk/MsgEditValidator") legacy.RegisterAminoMsg(cdc, &MsgDelegate{}, "cosmos-sdk/MsgDelegate") @@ -22,10 +22,10 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { legacy.RegisterAminoMsg(cdc, &MsgRotateConsPubKey{}, "cosmos-sdk/MsgRotateConsPubKey") cdc.RegisterInterface((*isStakeAuthorization_Validators)(nil), nil) - cdc.RegisterConcrete(&StakeAuthorization_AllowList{}, "cosmos-sdk/StakeAuthorization/AllowList", nil) - cdc.RegisterConcrete(&StakeAuthorization_DenyList{}, "cosmos-sdk/StakeAuthorization/DenyList", nil) - cdc.RegisterConcrete(&StakeAuthorization{}, "cosmos-sdk/StakeAuthorization", nil) - cdc.RegisterConcrete(Params{}, "cosmos-sdk/x/staking/Params", nil) + cdc.RegisterConcrete(&StakeAuthorization_AllowList{}, "cosmos-sdk/StakeAuthorization/AllowList") + cdc.RegisterConcrete(&StakeAuthorization_DenyList{}, "cosmos-sdk/StakeAuthorization/DenyList") + cdc.RegisterConcrete(&StakeAuthorization{}, "cosmos-sdk/StakeAuthorization") + cdc.RegisterConcrete(Params{}, "cosmos-sdk/x/staking/Params") } // RegisterInterfaces registers the x/staking interfaces types with the interface registry diff --git a/x/upgrade/module.go b/x/upgrade/module.go index 70e8bc0d3ee2..76c6e4e4ce38 100644 --- a/x/upgrade/module.go +++ b/x/upgrade/module.go @@ -10,20 +10,16 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" "cosmossdk.io/x/upgrade/client/cli" "cosmossdk.io/x/upgrade/keeper" "cosmossdk.io/x/upgrade/types" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types/module" ) -func init() { - types.RegisterLegacyAminoCodec(codec.NewLegacyAmino()) -} - // ConsensusVersion defines the current x/upgrade module consensus version. const ConsensusVersion uint64 = 3 @@ -61,7 +57,7 @@ func (AppModule) Name() string { } // RegisterLegacyAminoCodec registers the upgrade types on the LegacyAmino codec -func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) { types.RegisterLegacyAminoCodec(cdc) } diff --git a/x/upgrade/types/codec.go b/x/upgrade/types/codec.go index 98bec26aa4d9..64d3b919cb1c 100644 --- a/x/upgrade/types/codec.go +++ b/x/upgrade/types/codec.go @@ -1,19 +1,19 @@ package types import ( + corelegacy "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" coretransaction "cosmossdk.io/core/transaction" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/types/msgservice" ) // RegisterLegacyAminoCodec registers concrete types on the LegacyAmino codec -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(Plan{}, "cosmos-sdk/Plan", nil) - cdc.RegisterConcrete(&SoftwareUpgradeProposal{}, "cosmos-sdk/SoftwareUpgradeProposal", nil) - cdc.RegisterConcrete(&CancelSoftwareUpgradeProposal{}, "cosmos-sdk/CancelSoftwareUpgradeProposal", nil) +func RegisterLegacyAminoCodec(cdc corelegacy.Amino) { + cdc.RegisterConcrete(Plan{}, "cosmos-sdk/Plan") + cdc.RegisterConcrete(&SoftwareUpgradeProposal{}, "cosmos-sdk/SoftwareUpgradeProposal") + cdc.RegisterConcrete(&CancelSoftwareUpgradeProposal{}, "cosmos-sdk/CancelSoftwareUpgradeProposal") legacy.RegisterAminoMsg(cdc, &MsgSoftwareUpgrade{}, "cosmos-sdk/MsgSoftwareUpgrade") legacy.RegisterAminoMsg(cdc, &MsgCancelUpgrade{}, "cosmos-sdk/MsgCancelUpgrade") }