diff --git a/CHANGELOG.md b/CHANGELOG.md index dd21171417e0..37daf483a1b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,7 +38,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] ### Client Breaking - +* (modules) [\#7243](https://github.com/cosmos/cosmos-sdk/pull/7243) Rename `RegisterCodec` to `RegisterLegacyAminoCodec` and `codec.New()` is now renamed to `codec.NewLegacyAmino()` * (cli) [\#6651](https://github.com/cosmos/cosmos-sdk/pull/6651) The `gentx` command has been improved. No longer are `--from` and `--name` flags required. Instead, a single argument, `name`, is required which refers to the key pair in the Keyring. In addition, an optional `--moniker` flag can be provided to override the moniker found in `config.toml`. * (api) [\#6426](https://github.com/cosmos/cosmos-sdk/pull/6426) The ability to start an out-of-process API REST server has now been removed. Instead, the API server is now started in-process along with the application and Tendermint. Configuration options have been added to `app.toml` to enable/disable the API server along with additional HTTP server options. diff --git a/baseapp/baseapp_test.go b/baseapp/baseapp_test.go index 4371be44f6e9..9e0e50e1031f 100644 --- a/baseapp/baseapp_test.go +++ b/baseapp/baseapp_test.go @@ -75,14 +75,14 @@ func defaultLogger() log.Logger { func newBaseApp(name string, options ...func(*BaseApp)) *BaseApp { logger := defaultLogger() db := dbm.NewMemDB() - codec := codec.New() + codec := codec.NewLegacyAmino() registerTestCodec(codec) return NewBaseApp(name, logger, db, testTxDecoder(codec), options...) } func registerTestCodec(cdc *codec.LegacyAmino) { // register Tx, Msg - sdk.RegisterCodec(cdc) + sdk.RegisterLegacyAminoCodec(cdc) // register test types cdc.RegisterConcrete(&txTest{}, "cosmos-sdk/baseapp/txTest", nil) @@ -384,7 +384,7 @@ func testChangeNameHelper(name string) func(*BaseApp) { // Test that txs can be unmarshalled and read and that // correct error codes are returned when not func TestTxDecoder(t *testing.T) { - codec := codec.New() + codec := codec.NewLegacyAmino() registerTestCodec(codec) app := newBaseApp(t.Name()) @@ -810,7 +810,7 @@ func TestCheckTx(t *testing.T) { app.InitChain(abci.RequestInitChain{}) // Create same codec used in txDecoder - codec := codec.New() + codec := codec.NewLegacyAmino() registerTestCodec(codec) for i := int64(0); i < nTxs; i++ { @@ -857,7 +857,7 @@ func TestDeliverTx(t *testing.T) { app.InitChain(abci.RequestInitChain{}) // Create same codec used in txDecoder - codec := codec.New() + codec := codec.NewLegacyAmino() registerTestCodec(codec) nBlocks := 3 @@ -912,7 +912,7 @@ func TestMultiMsgDeliverTx(t *testing.T) { app := setupBaseApp(t, anteOpt, routerOpt) // Create same codec used in txDecoder - codec := codec.New() + codec := codec.NewLegacyAmino() registerTestCodec(codec) // run a multi-msg tx @@ -993,7 +993,7 @@ func TestSimulateTx(t *testing.T) { app.InitChain(abci.RequestInitChain{}) // Create same codec used in txDecoder - cdc := codec.New() + cdc := codec.NewLegacyAmino() registerTestCodec(cdc) nBlocks := 3 @@ -1128,7 +1128,7 @@ func TestRunInvalidTransaction(t *testing.T) { tx.Msgs = append(tx.Msgs, msgNoDecode{}) // new codec so we can encode the tx, but we shouldn't be able to decode - newCdc := codec.New() + newCdc := codec.NewLegacyAmino() registerTestCodec(newCdc) newCdc.RegisterConcrete(&msgNoDecode{}, "cosmos-sdk/baseapp/msgNoDecode", nil) @@ -1385,7 +1385,7 @@ func TestBaseAppAnteHandler(t *testing.T) { bapp.Router().AddRoute(r) } - cdc := codec.New() + cdc := codec.NewLegacyAmino() app := setupBaseApp(t, anteOpt, routerOpt) app.InitChain(abci.RequestInitChain{}) @@ -1485,7 +1485,7 @@ func TestGasConsumptionBadTx(t *testing.T) { bapp.Router().AddRoute(r) } - cdc := codec.New() + cdc := codec.NewLegacyAmino() registerTestCodec(cdc) app := setupBaseApp(t, anteOpt, routerOpt) @@ -1698,7 +1698,7 @@ func TestWithRouter(t *testing.T) { app.InitChain(abci.RequestInitChain{}) // Create same codec used in txDecoder - codec := codec.New() + codec := codec.NewLegacyAmino() registerTestCodec(codec) nBlocks := 3 diff --git a/client/keys/codec.go b/client/keys/codec.go index 02d8389ada67..2fb7bd94397e 100644 --- a/client/keys/codec.go +++ b/client/keys/codec.go @@ -9,7 +9,7 @@ import ( var KeysCdc *codec.LegacyAmino func init() { - KeysCdc = codec.New() + KeysCdc = codec.NewLegacyAmino() cryptocodec.RegisterCrypto(KeysCdc) KeysCdc.Seal() } diff --git a/codec/amino.go b/codec/amino.go index 2c19667f682e..38e93429d745 100644 --- a/codec/amino.go +++ b/codec/amino.go @@ -23,7 +23,7 @@ func (cdc *LegacyAmino) Seal() { cdc.Amino.Seal() } -func New() *LegacyAmino { +func NewLegacyAmino() *LegacyAmino { return &LegacyAmino{amino.NewCodec()} } diff --git a/codec/amino_codec_test.go b/codec/amino_codec_test.go index 7c683d6f0012..c36e7a990b88 100644 --- a/codec/amino_codec_test.go +++ b/codec/amino_codec_test.go @@ -14,7 +14,7 @@ import ( ) func createTestCodec() *codec.LegacyAmino { - cdc := codec.New() + cdc := codec.NewLegacyAmino() cdc.RegisterInterface((*testdata.Animal)(nil), nil) cdc.RegisterConcrete(testdata.Dog{}, "testdata/Dog", nil) diff --git a/codec/legacy/codec.go b/codec/legacy/codec.go index 4298668e0b82..09225998e0be 100644 --- a/codec/legacy/codec.go +++ b/codec/legacy/codec.go @@ -12,7 +12,7 @@ import ( var Cdc *codec.LegacyAmino func init() { - Cdc = codec.New() + Cdc = codec.NewLegacyAmino() cryptocodec.RegisterCrypto(Cdc) codec.RegisterEvidences(Cdc) Cdc.Seal() diff --git a/crypto/codec/amino.go b/crypto/codec/amino.go index 027a831e499e..69f7dde35748 100644 --- a/crypto/codec/amino.go +++ b/crypto/codec/amino.go @@ -13,7 +13,7 @@ import ( var amino *codec.LegacyAmino func init() { - amino = codec.New() + amino = codec.NewLegacyAmino() RegisterCrypto(amino) } diff --git a/crypto/keyring/codec.go b/crypto/keyring/codec.go index a71006228f97..6e6a254c87e3 100644 --- a/crypto/keyring/codec.go +++ b/crypto/keyring/codec.go @@ -10,14 +10,14 @@ import ( var CryptoCdc *codec.LegacyAmino func init() { - CryptoCdc = codec.New() + CryptoCdc = codec.NewLegacyAmino() cryptocodec.RegisterCrypto(CryptoCdc) - RegisterCodec(CryptoCdc) + RegisterLegacyAminoCodec(CryptoCdc) CryptoCdc.Seal() } -// RegisterCodec registers concrete types and interfaces on the given codec. -func RegisterCodec(cdc *codec.LegacyAmino) { +// RegisterLegacyAminoCodec registers concrete types and interfaces on the given codec. +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterInterface((*Info)(nil), nil) cdc.RegisterConcrete(hd.BIP44Params{}, "crypto/keys/hd/BIP44Params", nil) cdc.RegisterConcrete(localInfo{}, "crypto/keys/localInfo", nil) diff --git a/crypto/ledger/amino.go b/crypto/ledger/amino.go index 24345226a81d..0e717a9604f0 100644 --- a/crypto/ledger/amino.go +++ b/crypto/ledger/amino.go @@ -5,7 +5,7 @@ import ( cryptoAmino "github.com/cosmos/cosmos-sdk/crypto/codec" ) -var cdc = codec.New() +var cdc = codec.NewLegacyAmino() func init() { RegisterAmino(cdc) diff --git a/crypto/types/multisig/threshold_pubkey_test.go b/crypto/types/multisig/threshold_pubkey_test.go index 2396e09ad54b..cd5a6033f0c6 100644 --- a/crypto/types/multisig/threshold_pubkey_test.go +++ b/crypto/types/multisig/threshold_pubkey_test.go @@ -187,7 +187,7 @@ func TestMultiSigMigration(t *testing.T) { multisigKey := multisig.NewPubKeyMultisigThreshold(2, pkSet) signBytesFn := func(mode signing.SignMode) ([]byte, error) { return msg, nil } - cdc := codec.New() + cdc := codec.NewLegacyAmino() err := multisig.AddSignatureFromPubKey(multisignature, sigs[0], pkSet[0], pkSet) diff --git a/docs/architecture/adr-011-generalize-genesis-accounts.md b/docs/architecture/adr-011-generalize-genesis-accounts.md index a8d528d1f081..db323966e1f0 100644 --- a/docs/architecture/adr-011-generalize-genesis-accounts.md +++ b/docs/architecture/adr-011-generalize-genesis-accounts.md @@ -80,7 +80,7 @@ The `auth` codec definition: var ModuleCdc *codec.LegacyAmino func init() { - ModuleCdc = codec.New() + ModuleCdc = codec.NewLegacyAmino() // register module msg's and Account interface ... // leave the codec unsealed diff --git a/docs/basics/app-anatomy.md b/docs/basics/app-anatomy.md index f27bfdce5ee1..fc64b772423f 100644 --- a/docs/basics/app-anatomy.md +++ b/docs/basics/app-anatomy.md @@ -106,9 +106,9 @@ See an example of `BeginBlocker` and `EndBlocker` functions from [`gaia`](https: ### Register Codec -The `MakeCodec` function is the last important function of the `app.go` file. The goal of this function is to instantiate a [codec `cdc`](../core/encoding.md) (e.g. amino) initialize the codec of the SDK and each of the application's modules using the `RegisterCodec` function. +The `MakeCodec` function is the last important function of the `app.go` file. The goal of this function is to instantiate a [codec `cdc`](../core/encoding.md) (e.g. amino) initialize the codec of the SDK and each of the application's modules using the `RegisterLegacyAminoCodec` function. -To register the application's modules, the `MakeCodec` function calls `RegisterCodec` on `ModuleBasics`. `ModuleBasics` is a [basic manager](../building-modules/module-manager.md#basicmanager) which lists all of the application's modules. It is instanciated in the `init()` function, and only serves to easily register non-dependant elements of application's modules (such as codec). To learn more about the basic module manager, click [here](../building-modules/module-manager.md#basicmanager). +To register the application's modules, the `MakeCodec` function calls `RegisterLegacyAminoCodec` on `ModuleBasics`. `ModuleBasics` is a [basic manager](../building-modules/module-manager.md#basicmanager) which lists all of the application's modules. It is instanciated in the `init()` function, and only serves to easily register non-dependant elements of application's modules (such as codec). To learn more about the basic module manager, click [here](../building-modules/module-manager.md#basicmanager). See an example of a `MakeCodec` from [`gaia`](https://github.com/cosmos/gaia): diff --git a/docs/building-modules/module-manager.md b/docs/building-modules/module-manager.md index 17bf12a036e9..dad35a9da3aa 100644 --- a/docs/building-modules/module-manager.md +++ b/docs/building-modules/module-manager.md @@ -34,7 +34,7 @@ The `AppModuleBasic` interface defines the independent methods modules need to i Let us go through the methods: - `Name()`: Returns the name of the module as a `string`. -- `RegisterCodec(*codec.LegacyAmino)`: Registers the `amino` codec for the module, which is used to marhsal and unmarshal structs to/from `[]byte` in order to persist them in the moduel's `KVStore`. +- `RegisterLegacyAminoCodec(*codec.LegacyAmino)`: Registers the `amino` codec for the module, which is used to marhsal and unmarshal structs to/from `[]byte` in order to persist them in the moduel's `KVStore`. - `DefaultGenesis()`: Returns a default [`GenesisState`](./genesis.md#genesisstate) for the module, marshalled to `json.RawMessage`. The default `GenesisState` need to be defined by the module developer and is primarily used for testing. - `ValidateGenesis(json.RawMessage)`: Used to validate the `GenesisState` defined by a module, given in its `json.RawMessage` form. It will usually unmarshall the `json` before running a custom [`ValidateGenesis`](./genesis.md#validategenesis) function defined by the module developer. - `RegisterRESTRoutes(client.Context, *mux.Router)`: Registers the REST routes for the module. These routes will be used to map REST request to the module in order to process them. See [../interfaces/rest.md] for more. @@ -108,7 +108,7 @@ The `BasicManager` is a structure that lists all the `AppModuleBasic` of an appl It implements the following methods: - `NewBasicManager(modules ...AppModuleBasic)`: Constructor function. It takes a list of the application's `AppModuleBasic` and builds a new `BasicManager`. This function is generally called in the `init()` function of [`app.go`](../basics/app-anatomy.md#core-application-file) to quickly initialize the independent elements of the application's modules (click [here](https://github.com/cosmos/gaia/blob/master/app/app.go#L59-L74) to see an example). -- `RegisterCodec(cdc *codec.LegacyAmino)`: Registers the [`codec`s](../core/encoding.md) of each of the application's `AppModuleBasic`. This function is usually called early on in the [application's construction](../basics/app-anatomy.md#constructor). +- `RegisterLegacyAminoCodec(cdc *codec.LegacyAmino)`: Registers the [`codec`s](../core/encoding.md) of each of the application's `AppModuleBasic`. This function is usually called early on in the [application's construction](../basics/app-anatomy.md#constructor). - `DefaultGenesis()`: Provides default genesis information for modules in the application by calling the [`DefaultGenesis()`](./genesis.md#defaultgenesis) function of each module. It is used to construct a default genesis file for the application. - `ValidateGenesis(genesis map[string]json.RawMessage)`: Validates the genesis information modules by calling the [`ValidateGenesis()`](./genesis.md#validategenesis) function of each module. - `RegisterRESTRoutes(ctx client.Context, rtr *mux.Router)`: Registers REST routes for modules by calling the [`RegisterRESTRoutes`](./module-interfaces.md#register-routes) function of each module. This function is usually called function from the `main.go` function of the [application's command-line interface](../interfaces/cli.md). diff --git a/docs/cn/basics/app-anatomy.md b/docs/cn/basics/app-anatomy.md index 84ba5ff6e516..7909c40c8a71 100644 --- a/docs/cn/basics/app-anatomy.md +++ b/docs/cn/basics/app-anatomy.md @@ -104,9 +104,9 @@ See an example of an `InitChainer` from [`gaia`](https://github.com/cosmos/gaia) ### Register Codec -MakeCodec 函数是 app.go 文件的最后一个重要功能。 此函数的目的是使用 RegisterCodec 函数实例化 codec`cdc`,例如 amino 初始化 SDK 的编解码器以及每个应用程序的模块。 +MakeCodec 函数是 app.go 文件的最后一个重要功能。 此函数的目的是使用 RegisterLegacyAminoCodec 函数实例化 codec`cdc`,例如 amino 初始化 SDK 的编解码器以及每个应用程序的模块。 -为了注册应用程序的模块,`MakeCodec` 函数在 `ModuleBasics` 上调用 `RegisterCodec`。`ModuleBasics` 是一个基本管理器,其中列出了应用程序的所有模块。 它在`init()`函数中得到实例化,仅用于注册应用程序模块的非依赖元素(例如编解码器)。 要了解有关基本模块管理器的更多信息,请点击[这里](https://docs.cosmos.network/master/building-modules/module-manager.html#basicmanager)。 +为了注册应用程序的模块,`MakeCodec` 函数在 `ModuleBasics` 上调用 `RegisterLegacyAminoCodec`。`ModuleBasics` 是一个基本管理器,其中列出了应用程序的所有模块。 它在`init()`函数中得到实例化,仅用于注册应用程序模块的非依赖元素(例如编解码器)。 要了解有关基本模块管理器的更多信息,请点击[这里](https://docs.cosmos.network/master/building-modules/module-manager.html#basicmanager)。 请参阅 [gaia](https://github.com/cosmos/gaia) 中的 `MakeCodec` 示例: diff --git a/docs/core/encoding.md b/docs/core/encoding.md index 44b6d1348335..3af7c1cc5990 100644 --- a/docs/core/encoding.md +++ b/docs/core/encoding.md @@ -56,7 +56,7 @@ for their types, they may use an Amino codec directly. Every module uses an Amino codec to serialize types and interfaces. This codec typically has types and interfaces registered in that module's domain only (e.g. messages), -but there are exceptions like `x/gov`. Each module exposes a `RegisterCodec` function +but there are exceptions like `x/gov`. Each module exposes a `RegisterLegacyAminoCodec` function that allows a user to provide a codec and have all the types registered. An application will call this method for each necessary module. diff --git a/server/tm_cmds.go b/server/tm_cmds.go index 6bcba09aa83a..95b1c6fa4298 100644 --- a/server/tm_cmds.go +++ b/server/tm_cmds.go @@ -130,7 +130,7 @@ against which this app has been compiled. } func printlnJSON(v interface{}) error { - cdc := codec.New() + cdc := codec.NewLegacyAmino() cryptocodec.RegisterCrypto(cdc) marshalled, err := cdc.MarshalJSON(v) diff --git a/simapp/encoding.go b/simapp/encoding.go index 120d1e74380c..0ceb12274342 100644 --- a/simapp/encoding.go +++ b/simapp/encoding.go @@ -8,9 +8,9 @@ import ( // MakeEncodingConfig creates an EncodingConfig for testing func MakeEncodingConfig() params.EncodingConfig { encodingConfig := params.MakeEncodingConfig() - std.RegisterCodec(encodingConfig.Amino) + std.RegisterLegacyAminoCodec(encodingConfig.Amino) std.RegisterInterfaces(encodingConfig.InterfaceRegistry) - ModuleBasics.RegisterCodec(encodingConfig.Amino) + ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino) ModuleBasics.RegisterInterfaces(encodingConfig.InterfaceRegistry) return encodingConfig } diff --git a/simapp/params/amino.go b/simapp/params/amino.go index e5d540888769..67ee2d54da2c 100644 --- a/simapp/params/amino.go +++ b/simapp/params/amino.go @@ -10,7 +10,7 @@ import ( // MakeEncodingConfig creates an EncodingConfig for an amino based test configuration. func MakeEncodingConfig() EncodingConfig { - cdc := codec.New() + cdc := codec.NewLegacyAmino() interfaceRegistry := types.NewInterfaceRegistry() marshaler := codec.NewAminoCodec(cdc) diff --git a/simapp/params/proto.go b/simapp/params/proto.go index 919ef949b669..20d3a3af9046 100644 --- a/simapp/params/proto.go +++ b/simapp/params/proto.go @@ -11,7 +11,7 @@ import ( // MakeEncodingConfig creates an EncodingConfig for an amino based test configuration. func MakeEncodingConfig() EncodingConfig { - amino := codec.New() + amino := codec.NewLegacyAmino() interfaceRegistry := types.NewInterfaceRegistry() marshaler := codec.NewProtoCodec(interfaceRegistry) txCfg := tx.NewTxConfig(marshaler, std.DefaultPublicKeyCodec{}, tx.DefaultSignModes) diff --git a/simapp/utils_test.go b/simapp/utils_test.go index 22e362480500..6d8bb21f3f08 100644 --- a/simapp/utils_test.go +++ b/simapp/utils_test.go @@ -15,10 +15,10 @@ import ( ) func makeCodec(bm module.BasicManager) *codec.LegacyAmino { - cdc := codec.New() + cdc := codec.NewLegacyAmino() - bm.RegisterCodec(cdc) - std.RegisterCodec(cdc) + bm.RegisterLegacyAminoCodec(cdc) + std.RegisterLegacyAminoCodec(cdc) return cdc } diff --git a/std/codec.go b/std/codec.go index a7a09031bb2c..4563e955b09c 100644 --- a/std/codec.go +++ b/std/codec.go @@ -8,9 +8,9 @@ import ( vesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" ) -func RegisterCodec(cdc *codec.LegacyAmino) { - vesting.RegisterCodec(cdc) - sdk.RegisterCodec(cdc) +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + vesting.RegisterLegacyAminoCodec(cdc) + sdk.RegisterLegacyAminoCodec(cdc) cryptocodec.RegisterCrypto(cdc) } diff --git a/tests/mocks/types_module_module.go b/tests/mocks/types_module_module.go index 81221aef036f..816a486b2ec7 100644 --- a/tests/mocks/types_module_module.go +++ b/tests/mocks/types_module_module.go @@ -56,16 +56,16 @@ func (mr *MockAppModuleBasicMockRecorder) Name() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Name", reflect.TypeOf((*MockAppModuleBasic)(nil).Name)) } -// RegisterCodec mocks base method -func (m *MockAppModuleBasic) RegisterCodec(arg0 *codec.LegacyAmino) { +// RegisterLegacyAminoCodec mocks base method +func (m *MockAppModuleBasic) RegisterLegacyAminoCodec(arg0 *codec.LegacyAmino) { m.ctrl.T.Helper() - m.ctrl.Call(m, "RegisterCodec", arg0) + m.ctrl.Call(m, "RegisterLegacyAminoCodec", arg0) } -// RegisterCodec indicates an expected call of RegisterCodec -func (mr *MockAppModuleBasicMockRecorder) RegisterCodec(arg0 interface{}) *gomock.Call { +// RegisterLegacyAminoCodec indicates an expected call of RegisterLegacyAminoCodec +func (mr *MockAppModuleBasicMockRecorder) RegisterLegacyAminoCodec(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterCodec", reflect.TypeOf((*MockAppModuleBasic)(nil).RegisterCodec), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterLegacyAminoCodec", reflect.TypeOf((*MockAppModuleBasic)(nil).RegisterLegacyAminoCodec), arg0) } // RegisterInterfaces mocks base method @@ -197,16 +197,16 @@ func (mr *MockAppModuleGenesisMockRecorder) Name() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Name", reflect.TypeOf((*MockAppModuleGenesis)(nil).Name)) } -// RegisterCodec mocks base method -func (m *MockAppModuleGenesis) RegisterCodec(arg0 *codec.LegacyAmino) { +// RegisterLegacyAminoCodec mocks base method +func (m *MockAppModuleGenesis) RegisterLegacyAminoCodec(arg0 *codec.LegacyAmino) { m.ctrl.T.Helper() - m.ctrl.Call(m, "RegisterCodec", arg0) + m.ctrl.Call(m, "RegisterLegacyAminoCodec", arg0) } -// RegisterCodec indicates an expected call of RegisterCodec -func (mr *MockAppModuleGenesisMockRecorder) RegisterCodec(arg0 interface{}) *gomock.Call { +// RegisterLegacyAminoCodec indicates an expected call of RegisterLegacyAminoCodec +func (mr *MockAppModuleGenesisMockRecorder) RegisterLegacyAminoCodec(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterCodec", reflect.TypeOf((*MockAppModuleGenesis)(nil).RegisterCodec), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterLegacyAminoCodec", reflect.TypeOf((*MockAppModuleGenesis)(nil).RegisterLegacyAminoCodec), arg0) } // RegisterInterfaces mocks base method @@ -366,16 +366,16 @@ func (mr *MockAppModuleMockRecorder) Name() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Name", reflect.TypeOf((*MockAppModule)(nil).Name)) } -// RegisterCodec mocks base method -func (m *MockAppModule) RegisterCodec(arg0 *codec.LegacyAmino) { +// RegisterLegacyAminoCodec mocks base method +func (m *MockAppModule) RegisterLegacyAminoCodec(arg0 *codec.LegacyAmino) { m.ctrl.T.Helper() - m.ctrl.Call(m, "RegisterCodec", arg0) + m.ctrl.Call(m, "RegisterLegacyAminoCodec", arg0) } -// RegisterCodec indicates an expected call of RegisterCodec -func (mr *MockAppModuleMockRecorder) RegisterCodec(arg0 interface{}) *gomock.Call { +// RegisterLegacyAminoCodec indicates an expected call of RegisterLegacyAminoCodec +func (mr *MockAppModuleMockRecorder) RegisterLegacyAminoCodec(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterCodec", reflect.TypeOf((*MockAppModule)(nil).RegisterCodec), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterLegacyAminoCodec", reflect.TypeOf((*MockAppModule)(nil).RegisterLegacyAminoCodec), arg0) } // RegisterInterfaces mocks base method diff --git a/types/codec.go b/types/codec.go index bf3c4c4d049c..c654508b4c49 100644 --- a/types/codec.go +++ b/types/codec.go @@ -6,8 +6,8 @@ import ( "github.com/cosmos/cosmos-sdk/codec" ) -// RegisterCodec registers the sdk message type. -func RegisterCodec(cdc *codec.LegacyAmino) { +// RegisterLegacyAminoCodec registers the sdk message type. +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterInterface((*Msg)(nil), nil) cdc.RegisterInterface((*Tx)(nil), nil) } diff --git a/types/coin_test.go b/types/coin_test.go index f16bd682e5ef..1fc965bd0132 100644 --- a/types/coin_test.go +++ b/types/coin_test.go @@ -873,8 +873,8 @@ func TestCoinsIsAnyGT(t *testing.T) { } func TestMarshalJSONCoins(t *testing.T) { - cdc := codec.New() - RegisterCodec(cdc) + cdc := codec.NewLegacyAmino() + RegisterLegacyAminoCodec(cdc) testCases := []struct { name string diff --git a/types/module/module.go b/types/module/module.go index 34904f5d797f..6934ce89f18b 100644 --- a/types/module/module.go +++ b/types/module/module.go @@ -49,7 +49,7 @@ import ( // AppModuleBasic is the standard form for basic non-dependant elements of an application module. type AppModuleBasic interface { Name() string - RegisterCodec(*codec.LegacyAmino) + RegisterLegacyAminoCodec(*codec.LegacyAmino) RegisterInterfaces(codectypes.InterfaceRegistry) DefaultGenesis(codec.JSONMarshaler) json.RawMessage @@ -74,10 +74,10 @@ func NewBasicManager(modules ...AppModuleBasic) BasicManager { return moduleMap } -// RegisterCodec registers all module codecs -func (bm BasicManager) RegisterCodec(cdc *codec.LegacyAmino) { +// RegisterLegacyAminoCodec registers all module codecs +func (bm BasicManager) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { for _, b := range bm { - b.RegisterCodec(cdc) + b.RegisterLegacyAminoCodec(cdc) } } diff --git a/types/module/module_test.go b/types/module/module_test.go index 6472370b4c68..6dc3665043f2 100644 --- a/types/module/module_test.go +++ b/types/module/module_test.go @@ -25,7 +25,7 @@ var errFoo = errors.New("dummy") func TestBasicManager(t *testing.T) { mockCtrl := gomock.NewController(t) t.Cleanup(mockCtrl.Finish) - legacyAmino := codec.New() + legacyAmino := codec.NewLegacyAmino() interfaceRegistry := types.NewInterfaceRegistry() cdc := codec.NewProtoCodec(interfaceRegistry) @@ -39,7 +39,7 @@ func TestBasicManager(t *testing.T) { mockAppModuleBasic1.EXPECT().DefaultGenesis(gomock.Eq(cdc)).Times(1).Return(json.RawMessage(``)) mockAppModuleBasic1.EXPECT().ValidateGenesis(gomock.Eq(cdc), gomock.Eq(nil), gomock.Eq(wantDefaultGenesis["mockAppModuleBasic1"])).Times(1).Return(errFoo) mockAppModuleBasic1.EXPECT().RegisterRESTRoutes(gomock.Eq(client.Context{}), gomock.Eq(&mux.Router{})).Times(1) - mockAppModuleBasic1.EXPECT().RegisterCodec(gomock.Eq(legacyAmino)).Times(1) + mockAppModuleBasic1.EXPECT().RegisterLegacyAminoCodec(gomock.Eq(legacyAmino)).Times(1) mockAppModuleBasic1.EXPECT().RegisterInterfaces(gomock.Eq(interfaceRegistry)).Times(1) mockAppModuleBasic1.EXPECT().GetTxCmd().Times(1).Return(nil) mockAppModuleBasic1.EXPECT().GetQueryCmd().Times(1).Return(nil) @@ -47,7 +47,7 @@ func TestBasicManager(t *testing.T) { mm := module.NewBasicManager(mockAppModuleBasic1) require.Equal(t, mm["mockAppModuleBasic1"], mockAppModuleBasic1) - mm.RegisterCodec(legacyAmino) + mm.RegisterLegacyAminoCodec(legacyAmino) mm.RegisterInterfaces(interfaceRegistry) require.Equal(t, wantDefaultGenesis, mm.DefaultGenesis(cdc)) @@ -165,7 +165,7 @@ func TestManager_RegisterRoutes(t *testing.T) { mockAppModule1.EXPECT().NewQuerierHandler().Times(1).Return(handler3) queryRouter.EXPECT().AddRoute(gomock.Eq("querierRoute1"), gomock.Eq(handler3)).Times(1) - amino := codec.New() + amino := codec.NewLegacyAmino() mm.RegisterRoutes(router, queryRouter, amino) } diff --git a/types/rest/rest_test.go b/types/rest/rest_test.go index b6ff87be5cf9..9060bab09ad1 100644 --- a/types/rest/rest_test.go +++ b/types/rest/rest_test.go @@ -200,7 +200,7 @@ func TestProcessPostResponse(t *testing.T) { sequence := uint64(32) acc := mockAccount{addr, coins, pubKey, accNumber, sequence} - cdc := codec.New() + cdc := codec.NewLegacyAmino() cryptocodec.RegisterCrypto(cdc) cdc.RegisterConcrete(&mockAccount{}, "cosmos-sdk/mockAccount", nil) ctx = ctx.WithLegacyAmino(cdc) @@ -232,7 +232,7 @@ func TestReadRESTReq(t *testing.T) { var br rest.BaseReq // test OK - rest.ReadRESTReq(w, req, codec.New(), &br) + rest.ReadRESTReq(w, req, codec.NewLegacyAmino(), &br) res := w.Result() //nolint:bodyclose t.Cleanup(func() { res.Body.Close() }) require.Equal(t, rest.BaseReq{ChainID: "alessio", Memo: "text"}, br) @@ -243,7 +243,7 @@ func TestReadRESTReq(t *testing.T) { req = &http.Request{Body: reqBody} br = rest.BaseReq{} w = httptest.NewRecorder() - rest.ReadRESTReq(w, req, codec.New(), &br) + rest.ReadRESTReq(w, req, codec.NewLegacyAmino(), &br) require.Equal(t, br, br) res = w.Result() //nolint:bodyclose t.Cleanup(func() { res.Body.Close() }) @@ -253,7 +253,7 @@ func TestReadRESTReq(t *testing.T) { func TestWriteSimulationResponse(t *testing.T) { t.Parallel() w := httptest.NewRecorder() - rest.WriteSimulationResponse(w, codec.New(), 10) + rest.WriteSimulationResponse(w, codec.NewLegacyAmino(), 10) res := w.Result() //nolint:bodyclose t.Cleanup(func() { res.Body.Close() }) require.Equal(t, http.StatusOK, res.StatusCode) diff --git a/types/result.go b/types/result.go index a71cfc82fb3c..56d4482dcd9d 100644 --- a/types/result.go +++ b/types/result.go @@ -15,7 +15,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec/types" ) -var cdc = codec.New() +var cdc = codec.NewLegacyAmino() func (gi GasInfo) String() string { bz, _ := yaml.Marshal(gi) diff --git a/types/result_test.go b/types/result_test.go index 203d9415b9a8..3d0283a31f50 100644 --- a/types/result_test.go +++ b/types/result_test.go @@ -28,7 +28,7 @@ func TestParseABCILog(t *testing.T) { func TestABCIMessageLog(t *testing.T) { t.Parallel() - cdc := codec.New() + cdc := codec.NewLegacyAmino() events := sdk.Events{sdk.NewEvent("transfer", sdk.NewAttribute("sender", "foo"))} msgLog := sdk.NewABCIMessageLog(0, "", events) diff --git a/x/auth/ante/sigverify_test.go b/x/auth/ante/sigverify_test.go index 3b8b5e02b38b..54554f5b95ca 100644 --- a/x/auth/ante/sigverify_test.go +++ b/x/auth/ante/sigverify_test.go @@ -193,7 +193,7 @@ func (suite *AnteTestSuite) TestSigVerification_ExplicitAmino() { suite.ctx = suite.ctx.WithBlockHeight(1) // Set up TxConfig. - aminoCdc := codec.New() + aminoCdc := codec.NewLegacyAmino() // We're using TestMsg amino encoding in some tests, so register it here. txConfig := authtypes.StdTxConfig{Cdc: aminoCdc} diff --git a/x/auth/client/cli/cli_test.go b/x/auth/client/cli/cli_test.go index 8440aea5b002..6b0f29c917b7 100644 --- a/x/auth/client/cli/cli_test.go +++ b/x/auth/client/cli/cli_test.go @@ -334,9 +334,9 @@ func (s *IntegrationTestSuite) TestCLISendGenerateSignAndBroadcast() { func (s *IntegrationTestSuite) TestCLIMultisignInsufficientCosigners() { val1 := s.network.Validators[0] - codec := codec2.New() - sdk.RegisterCodec(codec) - banktypes.RegisterCodec(codec) + codec := codec2.NewLegacyAmino() + sdk.RegisterLegacyAminoCodec(codec) + banktypes.RegisterLegacyAminoCodec(codec) val1.ClientCtx.LegacyAmino = codec // Generate 2 accounts and a multisig. @@ -445,9 +445,9 @@ func (s *IntegrationTestSuite) TestCLIEncode() { func (s *IntegrationTestSuite) TestCLIMultisignSortSignatures() { val1 := s.network.Validators[0] - codec := codec2.New() - sdk.RegisterCodec(codec) - banktypes.RegisterCodec(codec) + codec := codec2.NewLegacyAmino() + sdk.RegisterLegacyAminoCodec(codec) + banktypes.RegisterLegacyAminoCodec(codec) val1.ClientCtx.LegacyAmino = codec // Generate 2 accounts and a multisig. @@ -546,9 +546,9 @@ func (s *IntegrationTestSuite) TestCLIMultisignSortSignatures() { func (s *IntegrationTestSuite) TestCLIMultisign() { val1 := s.network.Validators[0] - codec := codec2.New() - sdk.RegisterCodec(codec) - banktypes.RegisterCodec(codec) + codec := codec2.NewLegacyAmino() + sdk.RegisterLegacyAminoCodec(codec) + banktypes.RegisterLegacyAminoCodec(codec) val1.ClientCtx.LegacyAmino = codec // Generate 2 accounts and a multisig. diff --git a/x/auth/client/cli/encode_test.go b/x/auth/client/cli/encode_test.go index 8b245af985f3..61464bb951ab 100644 --- a/x/auth/client/cli/encode_test.go +++ b/x/auth/client/cli/encode_test.go @@ -20,8 +20,8 @@ func TestGetCommandEncode(t *testing.T) { cmd := GetEncodeCommand() _ = testutil.ApplyMockIODiscardOutErr(cmd) - authtypes.RegisterCodec(encodingConfig.Amino) - sdk.RegisterCodec(encodingConfig.Amino) + authtypes.RegisterLegacyAminoCodec(encodingConfig.Amino) + sdk.RegisterLegacyAminoCodec(encodingConfig.Amino) txCfg := encodingConfig.TxConfig @@ -58,7 +58,7 @@ func TestGetCommandDecode(t *testing.T) { cmd := GetDecodeCommand() _ = testutil.ApplyMockIODiscardOutErr(cmd) - sdk.RegisterCodec(encodingConfig.Amino) + sdk.RegisterLegacyAminoCodec(encodingConfig.Amino) txCfg := encodingConfig.TxConfig clientCtx = clientCtx.WithTxConfig(txCfg) diff --git a/x/auth/client/tx_test.go b/x/auth/client/tx_test.go index 3483f17f4a59..bf433f1e332b 100644 --- a/x/auth/client/tx_test.go +++ b/x/auth/client/tx_test.go @@ -152,10 +152,10 @@ func compareEncoders(t *testing.T, expected sdk.TxEncoder, actual sdk.TxEncoder) } func makeCodec() *codec.LegacyAmino { - var cdc = codec.New() - sdk.RegisterCodec(cdc) + var cdc = codec.NewLegacyAmino() + sdk.RegisterLegacyAminoCodec(cdc) cryptocodec.RegisterCrypto(cdc) - authtypes.RegisterCodec(cdc) + authtypes.RegisterLegacyAminoCodec(cdc) cdc.RegisterConcrete(testdata.TestMsg{}, "cosmos-sdk/Test", nil) return cdc } diff --git a/x/auth/legacy/v0_38/types.go b/x/auth/legacy/v0_38/types.go index 6d5708c114e3..f576648279bf 100644 --- a/x/auth/legacy/v0_38/types.go +++ b/x/auth/legacy/v0_38/types.go @@ -521,7 +521,7 @@ func ValidateGenAccounts(genAccounts GenesisAccounts) error { return nil } -func RegisterCodec(cdc *codec.LegacyAmino) { +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterInterface((*GenesisAccount)(nil), nil) cdc.RegisterInterface((*Account)(nil), nil) cdc.RegisterConcrete(&BaseAccount{}, "cosmos-sdk/Account", nil) diff --git a/x/auth/legacy/v0_39/types.go b/x/auth/legacy/v0_39/types.go index 32b527cce74c..ed5a790a5a31 100644 --- a/x/auth/legacy/v0_39/types.go +++ b/x/auth/legacy/v0_39/types.go @@ -419,7 +419,7 @@ func (ma *ModuleAccount) UnmarshalJSON(bz []byte) error { return nil } -func RegisterCodec(cdc *codec.LegacyAmino) { +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterInterface((*v038auth.GenesisAccount)(nil), nil) cdc.RegisterInterface((*v038auth.Account)(nil), nil) cdc.RegisterConcrete(&BaseAccount{}, "cosmos-sdk/Account", nil) diff --git a/x/auth/legacy/v0_40/migrate_test.go b/x/auth/legacy/v0_40/migrate_test.go index 108273b6e720..6aad03d340d4 100644 --- a/x/auth/legacy/v0_40/migrate_test.go +++ b/x/auth/legacy/v0_40/migrate_test.go @@ -15,9 +15,9 @@ import ( ) func TestMigrate(t *testing.T) { - v039Codec := codec.New() + v039Codec := codec.NewLegacyAmino() cryptocodec.RegisterCrypto(v039Codec) - v039auth.RegisterCodec(v039Codec) + v039auth.RegisterLegacyAminoCodec(v039Codec) coins := sdk.NewCoins(sdk.NewInt64Coin("stake", 50)) addr1, _ := sdk.AccAddressFromBech32("cosmos1xxkueklal9vejv9unqu80w9vptyepfa95pd53u") diff --git a/x/auth/module.go b/x/auth/module.go index 9567b4dd8ed4..80a738551bfd 100644 --- a/x/auth/module.go +++ b/x/auth/module.go @@ -40,9 +40,9 @@ func (AppModuleBasic) Name() string { return types.ModuleName } -// RegisterCodec registers the auth module's types for the given codec. -func (AppModuleBasic) RegisterCodec(cdc *codec.LegacyAmino) { - types.RegisterCodec(cdc) +// RegisterLegacyAminoCodec registers the auth module's types for the given codec. +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterLegacyAminoCodec(cdc) } // DefaultGenesis returns default genesis state as raw bytes for the auth diff --git a/x/auth/signing/verify_test.go b/x/auth/signing/verify_test.go index 3a8d82c23632..198536111a1e 100644 --- a/x/auth/signing/verify_test.go +++ b/x/auth/signing/verify_test.go @@ -29,9 +29,9 @@ func TestVerifySignature(t *testing.T) { app, ctx := createTestApp(false) ctx = ctx.WithBlockHeight(1) - cdc := codec.New() - sdk.RegisterCodec(cdc) - types.RegisterCodec(cdc) + cdc := codec.NewLegacyAmino() + sdk.RegisterLegacyAminoCodec(cdc) + types.RegisterLegacyAminoCodec(cdc) cdc.RegisterConcrete(testdata.TestMsg{}, "cosmos-sdk/Test", nil) acc1 := app.AccountKeeper.NewAccountWithAddress(ctx, addr) diff --git a/x/auth/types/client_tx_test.go b/x/auth/types/client_tx_test.go index 683487c70b6b..7d531bc243b5 100644 --- a/x/auth/types/client_tx_test.go +++ b/x/auth/types/client_tx_test.go @@ -17,8 +17,8 @@ import ( ) func testCodec() *codec.LegacyAmino { - cdc := codec.New() - sdk.RegisterCodec(cdc) + cdc := codec.NewLegacyAmino() + sdk.RegisterLegacyAminoCodec(cdc) cryptoAmino.RegisterCrypto(cdc) cdc.RegisterConcrete(&testdata.TestMsg{}, "cosmos-sdk/Test", nil) return cdc diff --git a/x/auth/types/codec.go b/x/auth/types/codec.go index f309c9c78909..24ed5f32a5e2 100644 --- a/x/auth/types/codec.go +++ b/x/auth/types/codec.go @@ -6,9 +6,9 @@ import ( cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" ) -// RegisterCodec registers the account interfaces and concrete types on the -// provided Amino codec. -func RegisterCodec(cdc *codec.LegacyAmino) { +// 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) { cdc.RegisterInterface((*ModuleAccountI)(nil), nil) cdc.RegisterInterface((*GenesisAccount)(nil), nil) cdc.RegisterInterface((*AccountI)(nil), nil) @@ -42,12 +42,12 @@ func RegisterKeyTypeCodec(o interface{}, name string) { } var ( - amino = codec.New() + amino = codec.NewLegacyAmino() ModuleCdc = codec.NewAminoCodec(amino) ) func init() { - RegisterCodec(amino) + RegisterLegacyAminoCodec(amino) cryptocodec.RegisterCrypto(amino) } diff --git a/x/auth/types/stdtx_test.go b/x/auth/types/stdtx_test.go index eb1f94c71a07..9f01c39fd342 100644 --- a/x/auth/types/stdtx_test.go +++ b/x/auth/types/stdtx_test.go @@ -154,9 +154,9 @@ func TestTxValidateBasic(t *testing.T) { } func TestDefaultTxEncoder(t *testing.T) { - cdc := codec.New() - sdk.RegisterCodec(cdc) - RegisterCodec(cdc) + cdc := codec.NewLegacyAmino() + sdk.RegisterLegacyAminoCodec(cdc) + RegisterLegacyAminoCodec(cdc) cdc.RegisterConcrete(testdata.TestMsg{}, "cosmos-sdk/Test", nil) encoder := DefaultTxEncoder(cdc) @@ -205,9 +205,9 @@ func TestStdSignatureMarshalYAML(t *testing.T) { func TestSignatureV2Conversions(t *testing.T) { _, pubKey, _ := testdata.KeyTestPubAddr() - cdc := codec.New() - sdk.RegisterCodec(cdc) - RegisterCodec(cdc) + cdc := codec.NewLegacyAmino() + sdk.RegisterLegacyAminoCodec(cdc) + RegisterLegacyAminoCodec(cdc) dummy := []byte("dummySig") sig := StdSignature{PubKey: pubKey, Signature: dummy} @@ -262,10 +262,10 @@ func TestGetSignaturesV2(t *testing.T) { _, pubKey, _ := testdata.KeyTestPubAddr() dummy := []byte("dummySig") - cdc := codec.New() - sdk.RegisterCodec(cdc) + cdc := codec.NewLegacyAmino() + sdk.RegisterLegacyAminoCodec(cdc) cryptocodec.RegisterCrypto(cdc) - RegisterCodec(cdc) + RegisterLegacyAminoCodec(cdc) fee := NewStdFee(50000, sdk.Coins{sdk.NewInt64Coin("atom", 150)}) sig := StdSignature{PubKey: pubKey, Signature: dummy} diff --git a/x/auth/vesting/types/codec.go b/x/auth/vesting/types/codec.go index 4edd9acdebd1..177942c83f4a 100644 --- a/x/auth/vesting/types/codec.go +++ b/x/auth/vesting/types/codec.go @@ -7,9 +7,9 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth/vesting/exported" ) -// RegisterCodec registers the vesting interfaces and concrete types on the -// provided Amino codec. -func RegisterCodec(cdc *codec.LegacyAmino) { +// 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) { cdc.RegisterInterface((*exported.VestingAccount)(nil), nil) cdc.RegisterConcrete(&BaseVestingAccount{}, "cosmos-sdk/BaseVestingAccount", nil) cdc.RegisterConcrete(&ContinuousVestingAccount{}, "cosmos-sdk/ContinuousVestingAccount", nil) @@ -43,9 +43,9 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { ) } -var amino = codec.New() +var amino = codec.NewLegacyAmino() func init() { - RegisterCodec(amino) + RegisterLegacyAminoCodec(amino) amino.Seal() } diff --git a/x/bank/legacy/v0_40/migrate_test.go b/x/bank/legacy/v0_40/migrate_test.go index 10b245c5ec7d..41b79c4042f9 100644 --- a/x/bank/legacy/v0_40/migrate_test.go +++ b/x/bank/legacy/v0_40/migrate_test.go @@ -15,9 +15,9 @@ import ( ) func TestMigrate(t *testing.T) { - v040Codec := codec.New() + v040Codec := codec.NewLegacyAmino() cryptocodec.RegisterCrypto(v040Codec) - v039auth.RegisterCodec(v040Codec) + v039auth.RegisterLegacyAminoCodec(v040Codec) coins := sdk.NewCoins(sdk.NewInt64Coin("stake", 50)) addr1, _ := sdk.AccAddressFromBech32("cosmos1xxkueklal9vejv9unqu80w9vptyepfa95pd53u") diff --git a/x/bank/module.go b/x/bank/module.go index 41677b8cd9d4..6bbf0e7dc382 100644 --- a/x/bank/module.go +++ b/x/bank/module.go @@ -39,8 +39,10 @@ type AppModuleBasic struct { // Name returns the bank module's name. func (AppModuleBasic) Name() string { return types.ModuleName } -// RegisterCodec registers the bank module's types for the given codec. -func (AppModuleBasic) RegisterCodec(cdc *codec.LegacyAmino) { types.RegisterCodec(cdc) } +// RegisterLegacyAminoCodec registers the bank module's types on the LegacyAmino codec. +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterLegacyAminoCodec(cdc) +} // DefaultGenesis returns default genesis state as raw bytes for the bank // module. diff --git a/x/bank/types/codec.go b/x/bank/types/codec.go index b0acd6b7c190..42c117e24a9d 100644 --- a/x/bank/types/codec.go +++ b/x/bank/types/codec.go @@ -8,9 +8,9 @@ import ( "github.com/cosmos/cosmos-sdk/x/bank/exported" ) -// RegisterCodec registers the necessary x/bank interfaces and concrete types -// on the provided Amino codec. These types are used for Amino JSON serialization. -func RegisterCodec(cdc *codec.LegacyAmino) { +// 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) { cdc.RegisterInterface((*exported.SupplyI)(nil), nil) cdc.RegisterConcrete(&Supply{}, "cosmos-sdk/Supply", nil) cdc.RegisterConcrete(&MsgSend{}, "cosmos-sdk/MsgSend", nil) @@ -31,7 +31,7 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { } var ( - amino = codec.New() + amino = codec.NewLegacyAmino() // ModuleCdc references the global x/bank module codec. Note, the codec should // ONLY be used in certain instances of tests and for JSON encoding as Amino is @@ -43,7 +43,7 @@ var ( ) func init() { - RegisterCodec(amino) + RegisterLegacyAminoCodec(amino) cryptocodec.RegisterCrypto(amino) amino.Seal() } diff --git a/x/bank/types/genesis_test.go b/x/bank/types/genesis_test.go index c0a7d61430be..5f612aed726b 100644 --- a/x/bank/types/genesis_test.go +++ b/x/bank/types/genesis_test.go @@ -10,7 +10,7 @@ import ( ) func TestMarshalJSONMetaData(t *testing.T) { - cdc := codec.New() + cdc := codec.NewLegacyAmino() testCases := []struct { name string diff --git a/x/capability/module.go b/x/capability/module.go index e1bd4c99c3c9..a946c137e4cf 100644 --- a/x/capability/module.go +++ b/x/capability/module.go @@ -47,9 +47,9 @@ func (AppModuleBasic) Name() string { return types.ModuleName } -// RegisterCodec registers the capability module's types to the provided codec. -func (AppModuleBasic) RegisterCodec(cdc *codec.LegacyAmino) { - types.RegisterCodec(cdc) +// RegisterLegacyAminoCodec registers the capability module's types to the LegacyAmino codec. +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterLegacyAminoCodec(cdc) } // RegisterInterfaces registers the module's interface types diff --git a/x/capability/types/codec.go b/x/capability/types/codec.go index 57f1312cc5e7..61203988a015 100644 --- a/x/capability/types/codec.go +++ b/x/capability/types/codec.go @@ -4,19 +4,19 @@ import ( "github.com/cosmos/cosmos-sdk/codec" ) -// RegisterCodec registers all the necessary types and interfaces for the +// RegisterLegacyAminoCodec registers all the necessary types and interfaces for the // capability module. -func RegisterCodec(cdc *codec.LegacyAmino) { +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&Capability{}, "cosmos-sdk/Capability", nil) cdc.RegisterConcrete(Owner{}, "cosmos-sdk/Owner", nil) cdc.RegisterConcrete(&CapabilityOwners{}, "cosmos-sdk/CapabilityOwners", nil) } var ( - amino = codec.New() + amino = codec.NewLegacyAmino() ) func init() { - RegisterCodec(amino) + RegisterLegacyAminoCodec(amino) amino.Seal() } diff --git a/x/crisis/module.go b/x/crisis/module.go index 76acb86e4f30..cc0beac0637a 100644 --- a/x/crisis/module.go +++ b/x/crisis/module.go @@ -33,9 +33,9 @@ func (AppModuleBasic) Name() string { return types.ModuleName } -// RegisterCodec registers the crisis module's types for the given codec. -func (AppModuleBasic) RegisterCodec(cdc *codec.LegacyAmino) { - types.RegisterCodec(cdc) +// RegisterLegacyAminoCodec registers the crisis module's types on the given LegacyAmino codec. +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterLegacyAminoCodec(cdc) } // DefaultGenesis returns default genesis state as raw bytes for the crisis diff --git a/x/crisis/types/codec.go b/x/crisis/types/codec.go index 57732fa0dadd..3b5dd5eb5a26 100644 --- a/x/crisis/types/codec.go +++ b/x/crisis/types/codec.go @@ -7,9 +7,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// RegisterCodec registers the necessary x/crisis interfaces and concrete types -// on the provided Amino codec. These types are used for Amino JSON serialization. -func RegisterCodec(cdc *codec.LegacyAmino) { +// 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) { cdc.RegisterConcrete(&MsgVerifyInvariant{}, "cosmos-sdk/MsgVerifyInvariant", nil) } @@ -20,7 +20,7 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { } var ( - amino = codec.New() + amino = codec.NewLegacyAmino() // ModuleCdc references the global x/crisis module codec. Note, the codec should // ONLY be used in certain instances of tests and for JSON encoding as Amino is @@ -32,7 +32,7 @@ var ( ) func init() { - RegisterCodec(amino) + RegisterLegacyAminoCodec(amino) cryptocodec.RegisterCrypto(amino) amino.Seal() } diff --git a/x/distribution/keeper/querier_test.go b/x/distribution/keeper/querier_test.go index 2a30c7bc9069..e801a4311d7f 100644 --- a/x/distribution/keeper/querier_test.go +++ b/x/distribution/keeper/querier_test.go @@ -111,9 +111,9 @@ func getQueriedCommunityPool(t *testing.T, ctx sdk.Context, cdc *codec.LegacyAmi } func TestQueries(t *testing.T) { - cdc := codec.New() - types.RegisterCodec(cdc) - banktypes.RegisterCodec(cdc) + cdc := codec.NewLegacyAmino() + types.RegisterLegacyAminoCodec(cdc) + banktypes.RegisterLegacyAminoCodec(cdc) app := simapp.Setup(false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) diff --git a/x/distribution/module.go b/x/distribution/module.go index 2b896fe8418e..efd6bcc739a2 100644 --- a/x/distribution/module.go +++ b/x/distribution/module.go @@ -43,9 +43,9 @@ func (AppModuleBasic) Name() string { return types.ModuleName } -// RegisterCodec registers the distribution module's types for the given codec. -func (AppModuleBasic) RegisterCodec(cdc *codec.LegacyAmino) { - types.RegisterCodec(cdc) +// RegisterLegacyAminoCodec registers the distribution module's types for the given codec. +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterLegacyAminoCodec(cdc) } // DefaultGenesis returns default genesis state as raw bytes for the distribution diff --git a/x/distribution/types/codec.go b/x/distribution/types/codec.go index 08d7ad9d0d6a..8d0e81f3701d 100644 --- a/x/distribution/types/codec.go +++ b/x/distribution/types/codec.go @@ -8,9 +8,9 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" ) -// RegisterCodec registers the necessary x/distribution interfaces and concrete types -// on the provided Amino codec. These types are used for Amino JSON serialization. -func RegisterCodec(cdc *codec.LegacyAmino) { +// 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) { cdc.RegisterConcrete(&MsgWithdrawDelegatorReward{}, "cosmos-sdk/MsgWithdrawDelegationReward", nil) cdc.RegisterConcrete(&MsgWithdrawValidatorCommission{}, "cosmos-sdk/MsgWithdrawValidatorCommission", nil) cdc.RegisterConcrete(&MsgSetWithdrawAddress{}, "cosmos-sdk/MsgModifyWithdrawAddress", nil) @@ -33,7 +33,7 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { } var ( - amino = codec.New() + amino = codec.NewLegacyAmino() // ModuleCdc references the global x/distribution module codec. Note, the codec // should ONLY be used in certain instances of tests and for JSON encoding as Amino @@ -45,7 +45,7 @@ var ( ) func init() { - RegisterCodec(amino) + RegisterLegacyAminoCodec(amino) cryptocodec.RegisterCrypto(amino) amino.Seal() } diff --git a/x/evidence/module.go b/x/evidence/module.go index 97d1e941ae3e..078cd6e2c925 100644 --- a/x/evidence/module.go +++ b/x/evidence/module.go @@ -55,9 +55,9 @@ func (AppModuleBasic) Name() string { return types.ModuleName } -// RegisterCodec registers the evidence module's types to the provided codec. -func (AppModuleBasic) RegisterCodec(cdc *codec.LegacyAmino) { - types.RegisterCodec(cdc) +// RegisterLegacyAminoCodec registers the evidence module's types to the LegacyAmino codec. +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterLegacyAminoCodec(cdc) } // DefaultGenesis returns the evidence module's default genesis state. diff --git a/x/evidence/types/codec.go b/x/evidence/types/codec.go index ce8f81ed0963..b75d9efb4fc5 100644 --- a/x/evidence/types/codec.go +++ b/x/evidence/types/codec.go @@ -8,9 +8,9 @@ import ( "github.com/cosmos/cosmos-sdk/x/evidence/exported" ) -// RegisterCodec registers all the necessary types and interfaces for the +// RegisterLegacyAminoCodec registers all the necessary types and interfaces for the // evidence module. -func RegisterCodec(cdc *codec.LegacyAmino) { +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterInterface((*exported.Evidence)(nil), nil) cdc.RegisterConcrete(&MsgSubmitEvidence{}, "cosmos-sdk/MsgSubmitEvidence", nil) cdc.RegisterConcrete(&Equivocation{}, "cosmos-sdk/Equivocation", nil) @@ -26,7 +26,7 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { } var ( - amino = codec.New() + amino = codec.NewLegacyAmino() // ModuleCdc references the global x/evidence module codec. Note, the codec should // ONLY be used in certain instances of tests and for JSON encoding as Amino is @@ -38,7 +38,7 @@ var ( ) func init() { - RegisterCodec(amino) + RegisterLegacyAminoCodec(amino) cryptocodec.RegisterCrypto(amino) amino.Seal() } diff --git a/x/evidence/types/genesis_test.go b/x/evidence/types/genesis_test.go index b8b8ee0e1a16..12b99603e5ec 100644 --- a/x/evidence/types/genesis_test.go +++ b/x/evidence/types/genesis_test.go @@ -142,7 +142,7 @@ func TestUnpackInterfaces(t *testing.T) { }, { "error", - codec.New(), + codec.NewLegacyAmino(), false, }, } diff --git a/x/genutil/client/cli/init_test.go b/x/genutil/client/cli/init_test.go index 2adaf4a62b46..74fbdf8afbe4 100644 --- a/x/genutil/client/cli/init_test.go +++ b/x/genutil/client/cli/init_test.go @@ -191,8 +191,8 @@ func TestInitNodeValidatorFiles(t *testing.T) { // custom tx codec func makeCodec() *codec.LegacyAmino { - var cdc = codec.New() - sdk.RegisterCodec(cdc) + var cdc = codec.NewLegacyAmino() + sdk.RegisterLegacyAminoCodec(cdc) cryptocodec.RegisterCrypto(cdc) return cdc } diff --git a/x/genutil/legacy/v0_36/migrate.go b/x/genutil/legacy/v0_36/migrate.go index cabfd285ef42..2be7806ef6e8 100644 --- a/x/genutil/legacy/v0_36/migrate.go +++ b/x/genutil/legacy/v0_36/migrate.go @@ -19,13 +19,13 @@ import ( // Migrate migrates exported state from v0.34 to a v0.36 genesis state. func Migrate(appState types.AppMap) types.AppMap { - v034Codec := codec.New() + v034Codec := codec.NewLegacyAmino() cryptocodec.RegisterCrypto(v034Codec) - v034gov.RegisterCodec(v034Codec) + v034gov.RegisterLegacyAminoCodec(v034Codec) - v036Codec := codec.New() + v036Codec := codec.NewLegacyAmino() cryptocodec.RegisterCrypto(v036Codec) - v036gov.RegisterCodec(v036Codec) + v036gov.RegisterLegacyAminoCodec(v036Codec) // migrate genesis accounts state if appState[v034genAccounts.ModuleName] != nil { diff --git a/x/genutil/legacy/v0_38/migrate.go b/x/genutil/legacy/v0_38/migrate.go index 6c9e8c003676..b0cf85229b39 100644 --- a/x/genutil/legacy/v0_38/migrate.go +++ b/x/genutil/legacy/v0_38/migrate.go @@ -15,12 +15,12 @@ import ( // Migrate migrates exported state from v0.36/v0.37 to a v0.38 genesis state. func Migrate(appState types.AppMap) types.AppMap { - v036Codec := codec.New() + v036Codec := codec.NewLegacyAmino() cryptocodec.RegisterCrypto(v036Codec) - v038Codec := codec.New() + v038Codec := codec.NewLegacyAmino() cryptocodec.RegisterCrypto(v038Codec) - v038auth.RegisterCodec(v038Codec) + v038auth.RegisterLegacyAminoCodec(v038Codec) if appState[v036genaccounts.ModuleName] != nil { // unmarshal relative source genesis application state diff --git a/x/genutil/legacy/v0_39/migrate.go b/x/genutil/legacy/v0_39/migrate.go index f1d1b45d5868..d7be5583d053 100644 --- a/x/genutil/legacy/v0_39/migrate.go +++ b/x/genutil/legacy/v0_39/migrate.go @@ -13,13 +13,13 @@ import ( // NOTE: No actual migration occurs since the types do not change, but JSON // serialization of accounts do change. func Migrate(appState types.AppMap) types.AppMap { - v038Codec := codec.New() + v038Codec := codec.NewLegacyAmino() cryptocodec.RegisterCrypto(v038Codec) - v038auth.RegisterCodec(v038Codec) + v038auth.RegisterLegacyAminoCodec(v038Codec) - v039Codec := codec.New() + v039Codec := codec.NewLegacyAmino() cryptocodec.RegisterCrypto(v039Codec) - v039auth.RegisterCodec(v039Codec) + v039auth.RegisterLegacyAminoCodec(v039Codec) // migrate x/auth state (JSON serialization only) if appState[v038auth.ModuleName] != nil { diff --git a/x/genutil/legacy/v0_40/migrate.go b/x/genutil/legacy/v0_40/migrate.go index 9b04a9222d06..3e4c06ac5fce 100644 --- a/x/genutil/legacy/v0_40/migrate.go +++ b/x/genutil/legacy/v0_40/migrate.go @@ -12,13 +12,13 @@ import ( // Migrate migrates exported state from v0.39 to a v0.40 genesis state. func Migrate(appState types.AppMap) types.AppMap { - v039Codec := codec.New() + v039Codec := codec.NewLegacyAmino() cryptocodec.RegisterCrypto(v039Codec) - v039auth.RegisterCodec(v039Codec) + v039auth.RegisterLegacyAminoCodec(v039Codec) - v040Codec := codec.New() + v040Codec := codec.NewLegacyAmino() cryptocodec.RegisterCrypto(v040Codec) - v039auth.RegisterCodec(v040Codec) + v039auth.RegisterLegacyAminoCodec(v040Codec) // remove balances from existing accounts if appState[v039auth.ModuleName] != nil { diff --git a/x/genutil/module.go b/x/genutil/module.go index b1dd164759c3..0280ffa3a3e7 100644 --- a/x/genutil/module.go +++ b/x/genutil/module.go @@ -31,8 +31,8 @@ func (AppModuleBasic) Name() string { return types.ModuleName } -// RegisterCodec registers the genutil module's types for the given codec. -func (AppModuleBasic) RegisterCodec(cdc *codec.LegacyAmino) {} +// RegisterLegacyAminoCodec registers the genutil module's types on the given LegacyAmino codec. +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} // RegisterInterfaces registers the module's interface types func (b AppModuleBasic) RegisterInterfaces(_ cdctypes.InterfaceRegistry) {} diff --git a/x/genutil/types/genesis_state_test.go b/x/genutil/types/genesis_state_test.go index 5d2b2d8627b2..8040da552a5f 100644 --- a/x/genutil/types/genesis_state_test.go +++ b/x/genutil/types/genesis_state_test.go @@ -73,7 +73,7 @@ func TestValidateGenesisBadMessage(t *testing.T) { } func TestGenesisStateFromGenFile(t *testing.T) { - cdc := codec.New() + cdc := codec.NewLegacyAmino() genFile := "../../../tests/fixtures/adr-024-coin-metadata_genesis.json" genesisState, _, err := types.GenesisStateFromGenFile(genFile) diff --git a/x/gov/client/utils/query_test.go b/x/gov/client/utils/query_test.go index 3a448c2f5f88..c576eacd493e 100644 --- a/x/gov/client/utils/query_test.go +++ b/x/gov/client/utils/query_test.go @@ -48,10 +48,10 @@ func (mock TxSearchMock) Block(height *int64) (*ctypes.ResultBlock, error) { } func newTestCodec() *codec.LegacyAmino { - cdc := codec.New() - sdk.RegisterCodec(cdc) - types.RegisterCodec(cdc) - authtypes.RegisterCodec(cdc) + cdc := codec.NewLegacyAmino() + sdk.RegisterLegacyAminoCodec(cdc) + types.RegisterLegacyAminoCodec(cdc) + authtypes.RegisterLegacyAminoCodec(cdc) return cdc } diff --git a/x/gov/legacy/v0_34/types.go b/x/gov/legacy/v0_34/types.go index 349206f232cc..4b78b6987f10 100644 --- a/x/gov/legacy/v0_34/types.go +++ b/x/gov/legacy/v0_34/types.go @@ -326,7 +326,7 @@ func (pt ProposalKind) String() string { } } -func RegisterCodec(cdc *codec.LegacyAmino) { +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterInterface((*ProposalContent)(nil), nil) cdc.RegisterConcrete(TextProposal{}, "gov/TextProposal", nil) } diff --git a/x/gov/legacy/v0_36/types.go b/x/gov/legacy/v0_36/types.go index 0c874a9205cf..54fd9d748032 100644 --- a/x/gov/legacy/v0_36/types.go +++ b/x/gov/legacy/v0_36/types.go @@ -127,7 +127,7 @@ func ValidateAbstract(c Content) error { return nil } -func RegisterCodec(cdc *codec.LegacyAmino) { +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterInterface((*Content)(nil), nil) cdc.RegisterConcrete(TextProposal{}, "cosmos-sdk/TextProposal", nil) } diff --git a/x/gov/module.go b/x/gov/module.go index b0f43fb6e923..82b6392340b1 100644 --- a/x/gov/module.go +++ b/x/gov/module.go @@ -53,9 +53,9 @@ func (AppModuleBasic) Name() string { return types.ModuleName } -// RegisterCodec registers the gov module's types for the given codec. -func (AppModuleBasic) RegisterCodec(cdc *codec.LegacyAmino) { - types.RegisterCodec(cdc) +// RegisterLegacyAminoCodec registers the gov module's types for the given codec. +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterLegacyAminoCodec(cdc) } // DefaultGenesis returns default genesis state as raw bytes for the gov diff --git a/x/gov/types/codec.go b/x/gov/types/codec.go index 6abb77d9feb0..85bac043abdd 100644 --- a/x/gov/types/codec.go +++ b/x/gov/types/codec.go @@ -7,9 +7,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// RegisterCodec registers all the necessary types and interfaces for the +// RegisterLegacyAminoCodec registers all the necessary types and interfaces for the // governance module. -func RegisterCodec(cdc *codec.LegacyAmino) { +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterInterface((*Content)(nil), nil) cdc.RegisterConcrete(&MsgSubmitProposal{}, "cosmos-sdk/MsgSubmitProposal", nil) cdc.RegisterConcrete(&MsgDeposit{}, "cosmos-sdk/MsgDeposit", nil) @@ -41,7 +41,7 @@ func RegisterProposalTypeCodec(o interface{}, name string) { } var ( - amino = codec.New() + amino = codec.NewLegacyAmino() // ModuleCdc references the global x/gov module codec. Note, the codec should // ONLY be used in certain instances of tests and for JSON encoding as Amino is @@ -53,6 +53,6 @@ var ( ) func init() { - RegisterCodec(amino) + RegisterLegacyAminoCodec(amino) cryptocodec.RegisterCrypto(amino) } diff --git a/x/ibc-transfer/module.go b/x/ibc-transfer/module.go index 085385eedad9..d98462cf150f 100644 --- a/x/ibc-transfer/module.go +++ b/x/ibc-transfer/module.go @@ -45,8 +45,8 @@ func (AppModuleBasic) Name() string { return types.ModuleName } -// RegisterCodec implements AppModuleBasic interface -func (AppModuleBasic) RegisterCodec(*codec.LegacyAmino) {} +// RegisterLegacyAminoCodec implements AppModuleBasic interface +func (AppModuleBasic) RegisterLegacyAminoCodec(*codec.LegacyAmino) {} // RegisterInterfaces registers module concrete types into protobuf Any. func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) { diff --git a/x/ibc/07-tendermint/client/cli/tx.go b/x/ibc/07-tendermint/client/cli/tx.go index 81d074c904f2..607afbe9a745 100644 --- a/x/ibc/07-tendermint/client/cli/tx.go +++ b/x/ibc/07-tendermint/client/cli/tx.go @@ -50,7 +50,7 @@ func NewCreateClientCmd() *cobra.Command { clientID := args[0] cdc := codec.NewProtoCodec(clientCtx.InterfaceRegistry) - legacyAmino := codec.New() + legacyAmino := codec.NewLegacyAmino() var header *types.Header if err := cdc.UnmarshalJSON([]byte(args[1]), header); err != nil { diff --git a/x/ibc/module.go b/x/ibc/module.go index f6489b9d1fd9..8b6f96e2a877 100644 --- a/x/ibc/module.go +++ b/x/ibc/module.go @@ -46,8 +46,8 @@ func (AppModuleBasic) Name() string { return host.ModuleName } -// RegisterCodec does nothing. IBC does not support amino. -func (AppModuleBasic) RegisterCodec(*codec.LegacyAmino) {} +// RegisterLegacyAminoCodec does nothing. IBC does not support amino. +func (AppModuleBasic) RegisterLegacyAminoCodec(*codec.LegacyAmino) {} // DefaultGenesis returns default genesis state as raw bytes for the ibc // module. diff --git a/x/ibc/testing/mock/mock.go b/x/ibc/testing/mock/mock.go index 639b68df4a00..e8a72ba10a58 100644 --- a/x/ibc/testing/mock/mock.go +++ b/x/ibc/testing/mock/mock.go @@ -38,8 +38,8 @@ func (AppModuleBasic) Name() string { return ModuleName } -// RegisterCodec implements AppModuleBasic interface. -func (AppModuleBasic) RegisterCodec(*codec.LegacyAmino) {} +// RegisterLegacyAminoCodec implements AppModuleBasic interface. +func (AppModuleBasic) RegisterLegacyAminoCodec(*codec.LegacyAmino) {} // RegisterInterfaces implements AppModuleBasic interface. func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) {} diff --git a/x/mint/module.go b/x/mint/module.go index 69aeaeffa7a9..b483696b9228 100644 --- a/x/mint/module.go +++ b/x/mint/module.go @@ -43,8 +43,8 @@ func (AppModuleBasic) Name() string { return types.ModuleName } -// RegisterCodec registers the mint module's types for the given codec. -func (AppModuleBasic) RegisterCodec(cdc *codec.LegacyAmino) {} +// RegisterLegacyAminoCodec registers the mint module's types on the given LegacyAmino codec. +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} // RegisterInterfaces registers the module's interface types func (b AppModuleBasic) RegisterInterfaces(_ cdctypes.InterfaceRegistry) {} diff --git a/x/mint/types/codec.go b/x/mint/types/codec.go index 5ee27a45bbe2..b436c10298d5 100644 --- a/x/mint/types/codec.go +++ b/x/mint/types/codec.go @@ -6,7 +6,7 @@ import ( ) var ( - amino = codec.New() + amino = codec.NewLegacyAmino() ) func init() { diff --git a/x/params/client/cli/tx_test.go b/x/params/client/cli/tx_test.go index 9eb662bb283a..a85e8b1d4811 100644 --- a/x/params/client/cli/tx_test.go +++ b/x/params/client/cli/tx_test.go @@ -11,7 +11,7 @@ import ( ) func TestParseProposal(t *testing.T) { - cdc := codec.New() + cdc := codec.NewLegacyAmino() okJSON, cleanup := testutil.WriteToNewTempFile(t, ` { "title": "Staking Param Change", diff --git a/x/params/keeper/common_test.go b/x/params/keeper/common_test.go index 139aaccc9aba..eb60d12b8b20 100644 --- a/x/params/keeper/common_test.go +++ b/x/params/keeper/common_test.go @@ -31,8 +31,8 @@ type s struct { } func createTestCodec() *codec.LegacyAmino { - cdc := codec.New() - sdk.RegisterCodec(cdc) + cdc := codec.NewLegacyAmino() + sdk.RegisterLegacyAminoCodec(cdc) cdc.RegisterConcrete(s{}, "test/s", nil) cdc.RegisterConcrete(invalid{}, "test/invalid", nil) return cdc diff --git a/x/params/module.go b/x/params/module.go index 89a76facd9d4..0c947938311d 100644 --- a/x/params/module.go +++ b/x/params/module.go @@ -39,9 +39,9 @@ func (AppModuleBasic) Name() string { return proposal.ModuleName } -// RegisterCodec registers the params module's types for the given codec. -func (AppModuleBasic) RegisterCodec(cdc *codec.LegacyAmino) { - proposal.RegisterCodec(cdc) +// RegisterLegacyAminoCodec registers the params module's types on the given LegacyAmino codec. +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + proposal.RegisterLegacyAminoCodec(cdc) } // DefaultGenesis returns default genesis state as raw bytes for the params diff --git a/x/params/proposal_handler_test.go b/x/params/proposal_handler_test.go index 163182d9c029..b810a490cf75 100644 --- a/x/params/proposal_handler_test.go +++ b/x/params/proposal_handler_test.go @@ -61,8 +61,8 @@ func testProposal(changes ...proposal.ParamChange) *proposal.ParameterChangeProp } func newTestInput(t *testing.T) testInput { - cdc := codec.New() - proposal.RegisterCodec(cdc) + cdc := codec.NewLegacyAmino() + proposal.RegisterLegacyAminoCodec(cdc) db := dbm.NewMemDB() cms := store.NewCommitMultiStore(db) diff --git a/x/params/types/proposal/codec.go b/x/params/types/proposal/codec.go index d274da798458..d638caccaf65 100644 --- a/x/params/types/proposal/codec.go +++ b/x/params/types/proposal/codec.go @@ -6,8 +6,8 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" ) -// RegisterCodec registers all necessary param module types with a given codec. -func RegisterCodec(cdc *codec.LegacyAmino) { +// RegisterLegacyAminoCodec registers all necessary param module types with a given LegacyAmino codec. +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&ParameterChangeProposal{}, "cosmos-sdk/ParameterChangeProposal", nil) } diff --git a/x/slashing/keeper/querier_test.go b/x/slashing/keeper/querier_test.go index d3305eb9f8ac..004ae1e8541c 100644 --- a/x/slashing/keeper/querier_test.go +++ b/x/slashing/keeper/querier_test.go @@ -31,7 +31,7 @@ func TestNewQuerier(t *testing.T) { } func TestQueryParams(t *testing.T) { - cdc := codec.New() + cdc := codec.NewLegacyAmino() legacyQuerierCdc := codec.NewAminoCodec(cdc) app := simapp.Setup(false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) diff --git a/x/slashing/module.go b/x/slashing/module.go index b653e38decb5..21fa5e336090 100644 --- a/x/slashing/module.go +++ b/x/slashing/module.go @@ -46,9 +46,9 @@ func (AppModuleBasic) Name() string { return types.ModuleName } -// RegisterCodec registers the slashing module's types for the given codec. -func (AppModuleBasic) RegisterCodec(cdc *codec.LegacyAmino) { - types.RegisterCodec(cdc) +// RegisterLegacyAminoCodec registers the slashing module's types for the given codec. +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterLegacyAminoCodec(cdc) } // RegisterInterfaces registers the module's interface types diff --git a/x/slashing/types/codec.go b/x/slashing/types/codec.go index 340f4317463f..a6edce9fb905 100644 --- a/x/slashing/types/codec.go +++ b/x/slashing/types/codec.go @@ -7,8 +7,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// RegisterCodec registers concrete types on codec -func RegisterCodec(cdc *codec.LegacyAmino) { +// RegisterLegacyAminoCodec registers concrete types on LegacyAmino codec +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgUnjail{}, "cosmos-sdk/MsgUnjail", nil) } @@ -19,7 +19,7 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { } var ( - amino = codec.New() + amino = codec.NewLegacyAmino() // ModuleCdc references the global x/slashing module codec. Note, the codec // should ONLY be used in certain instances of tests and for JSON encoding as Amino @@ -31,7 +31,7 @@ var ( ) func init() { - RegisterCodec(amino) + RegisterLegacyAminoCodec(amino) cryptocodec.RegisterCrypto(amino) amino.Seal() } diff --git a/x/staking/common_test.go b/x/staking/common_test.go index 52dd0ec6c812..948159d138e2 100644 --- a/x/staking/common_test.go +++ b/x/staking/common_test.go @@ -56,7 +56,7 @@ func getBaseSimappWithCustomKeeper() (*codec.LegacyAmino, *simapp.SimApp, sdk.Co ) app.StakingKeeper.SetParams(ctx, types.DefaultParams()) - return codec.New(), app, ctx + return codec.NewLegacyAmino(), app, ctx } // generateAddresses generates numAddrs of normal AccAddrs and ValAddrs diff --git a/x/staking/keeper/common_test.go b/x/staking/keeper/common_test.go index 4239d101f204..065a0f52e8c8 100644 --- a/x/staking/keeper/common_test.go +++ b/x/staking/keeper/common_test.go @@ -32,7 +32,7 @@ func createTestInput() (*codec.LegacyAmino, *simapp.SimApp, sdk.Context) { app.GetSubspace(types.ModuleName), ) - return codec.New(), app, ctx + return codec.NewLegacyAmino(), app, ctx } // intended to be used with require/assert: require.True(ValEq(...)) diff --git a/x/staking/module.go b/x/staking/module.go index 03480080a558..f91d0eee7617 100644 --- a/x/staking/module.go +++ b/x/staking/module.go @@ -44,9 +44,9 @@ func (AppModuleBasic) Name() string { return types.ModuleName } -// RegisterCodec registers the staking module's types for the given codec. -func (AppModuleBasic) RegisterCodec(cdc *codec.LegacyAmino) { - types.RegisterCodec(cdc) +// RegisterLegacyAminoCodec registers the staking module's types on the given LegacyAmino codec. +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterLegacyAminoCodec(cdc) } // RegisterInterfaces registers the module's interface types diff --git a/x/staking/simulation/decoder_test.go b/x/staking/simulation/decoder_test.go index f442f648dd6e..05ba5798cde7 100644 --- a/x/staking/simulation/decoder_test.go +++ b/x/staking/simulation/decoder_test.go @@ -24,10 +24,10 @@ var ( ) func makeTestCodec() (cdc *codec.LegacyAmino) { - cdc = codec.New() - sdk.RegisterCodec(cdc) + cdc = codec.NewLegacyAmino() + sdk.RegisterLegacyAminoCodec(cdc) cryptocodec.RegisterCrypto(cdc) - types.RegisterCodec(cdc) + types.RegisterLegacyAminoCodec(cdc) return } diff --git a/x/staking/types/codec.go b/x/staking/types/codec.go index 7a69e259edb0..b4b3c353dcb3 100644 --- a/x/staking/types/codec.go +++ b/x/staking/types/codec.go @@ -7,9 +7,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// RegisterCodec registers the necessary x/staking interfaces and concrete types -// on the provided Amino codec. These types are used for Amino JSON serialization. -func RegisterCodec(cdc *codec.LegacyAmino) { +// 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) { cdc.RegisterConcrete(&MsgCreateValidator{}, "cosmos-sdk/MsgCreateValidator", nil) cdc.RegisterConcrete(&MsgEditValidator{}, "cosmos-sdk/MsgEditValidator", nil) cdc.RegisterConcrete(&MsgDelegate{}, "cosmos-sdk/MsgDelegate", nil) @@ -29,7 +29,7 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { } var ( - amino = codec.New() + amino = codec.NewLegacyAmino() // ModuleCdc references the global x/staking module codec. Note, the codec should // ONLY be used in certain instances of tests and for JSON encoding as Amino is @@ -41,7 +41,7 @@ var ( ) func init() { - RegisterCodec(amino) + RegisterLegacyAminoCodec(amino) cryptocodec.RegisterCrypto(amino) amino.Seal() } diff --git a/x/staking/types/delegation_test.go b/x/staking/types/delegation_test.go index 07496e05601c..45ec655d5473 100644 --- a/x/staking/types/delegation_test.go +++ b/x/staking/types/delegation_test.go @@ -79,7 +79,7 @@ func TestRedelegationString(t *testing.T) { } func TestDelegationResponses(t *testing.T) { - cdc := codec.New() + cdc := codec.NewLegacyAmino() dr1 := NewDelegationResp(sdk.AccAddress(valAddr1), valAddr2, sdk.NewDec(5), sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(5))) dr2 := NewDelegationResp(sdk.AccAddress(valAddr1), valAddr3, sdk.NewDec(5), @@ -108,7 +108,7 @@ func TestDelegationResponses(t *testing.T) { } func TestRedelegationResponses(t *testing.T) { - cdc := codec.New() + cdc := codec.NewLegacyAmino() entries := []RedelegationEntryResponse{ NewRedelegationEntryResponse(0, time.Unix(0, 0), sdk.NewDec(5), sdk.NewInt(5), sdk.NewInt(5)), NewRedelegationEntryResponse(0, time.Unix(0, 0), sdk.NewDec(5), sdk.NewInt(5), sdk.NewInt(5)), diff --git a/x/upgrade/module.go b/x/upgrade/module.go index cb1e4932823a..940ee9460c5f 100644 --- a/x/upgrade/module.go +++ b/x/upgrade/module.go @@ -23,11 +23,8 @@ import ( "github.com/cosmos/cosmos-sdk/x/upgrade/types" ) -// module codec -var moduleCdc = codec.New() - func init() { - types.RegisterCodec(moduleCdc) + types.RegisterLegacyAminoCodec(codec.NewLegacyAmino()) } var ( @@ -43,9 +40,9 @@ func (AppModuleBasic) Name() string { return types.ModuleName } -// RegisterCodec registers the upgrade types on the amino codec -func (AppModuleBasic) RegisterCodec(cdc *codec.LegacyAmino) { - types.RegisterCodec(cdc) +// RegisterLegacyAminoCodec registers the upgrade types on the LegacyAmino codec +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterLegacyAminoCodec(cdc) } // RegisterRESTRoutes registers all REST query handlers diff --git a/x/upgrade/types/codec.go b/x/upgrade/types/codec.go index 6b274e467d6a..59703f57a8f9 100644 --- a/x/upgrade/types/codec.go +++ b/x/upgrade/types/codec.go @@ -6,8 +6,8 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" ) -// RegisterCodec registers concrete types on the Amino codec -func RegisterCodec(cdc *codec.LegacyAmino) { +// 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) diff --git a/x/upgrade/types/proposal_test.go b/x/upgrade/types/proposal_test.go index cf4fd6eee1a2..0756776ddfce 100644 --- a/x/upgrade/types/proposal_test.go +++ b/x/upgrade/types/proposal_test.go @@ -42,9 +42,9 @@ func TestContentAccessors(t *testing.T) { }, } - cdc := codec.New() - gov.RegisterCodec(cdc) - RegisterCodec(cdc) + cdc := codec.NewLegacyAmino() + gov.RegisterLegacyAminoCodec(cdc) + RegisterLegacyAminoCodec(cdc) for name, tc := range cases { tc := tc // copy to local variable for scopelint