From d9fb4cf34d4ca65d2eca078dbd7edde084c884db Mon Sep 17 00:00:00 2001 From: MD Aleem <72057206+aleem1314@users.noreply.github.com> Date: Thu, 1 Jul 2021 14:22:38 +0530 Subject: [PATCH] refactor!: Remove `clientCtx.JSONCodec` and rename `EncodingConfig.Marshaler` to `Codec` (#9521) ## Description Closes: #9499 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [x] added `!` to the type prefix if API or client breaking change - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [x] provided a link to the relevant issue or specification - [x] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [x] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [x] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable) --- CHANGELOG.md | 2 ++ client/context.go | 20 +++----------------- client/keys/add_test.go | 4 ++-- codec/any_test.go | 18 +++++++++--------- crypto/keys/multisig/multisig_test.go | 2 +- server/export_test.go | 2 +- server/util_test.go | 4 ++-- simapp/app.go | 2 +- simapp/app_test.go | 4 ++-- simapp/params/encoding.go | 7 +++---- simapp/params/proto.go | 6 +++--- simapp/simd/cmd/genaccounts_test.go | 2 +- simapp/simd/cmd/root.go | 4 ++-- simapp/simd/cmd/testnet_test.go | 6 +++--- simapp/test_helpers.go | 2 +- testutil/network/network.go | 4 ++-- x/auth/client/cli/encode_test.go | 4 ++-- x/auth/keeper/keeper_test.go | 2 +- x/auth/legacy/v040/migrate_test.go | 2 +- x/auth/legacy/v043/store_test.go | 2 +- x/auth/simulation/decoder_test.go | 2 +- x/auth/types/common_test.go | 2 +- x/authz/simulation/decoder_test.go | 2 +- x/bank/keeper/keeper_test.go | 2 +- x/bank/legacy/v040/migrate_test.go | 2 +- x/bank/legacy/v043/store_test.go | 6 +++--- x/capability/simulation/decoder_test.go | 2 +- x/distribution/client/cli/tx_test.go | 2 +- x/distribution/simulation/decoder_test.go | 2 +- x/evidence/keeper/querier_test.go | 2 +- x/evidence/legacy/v040/migrate_test.go | 2 +- x/feegrant/simulation/decoder_test.go | 2 +- x/genutil/gentx_test.go | 4 ++-- x/gov/keeper/common_test.go | 2 +- x/gov/legacy/v040/migrate_test.go | 2 +- x/gov/legacy/v043/json_test.go | 2 +- x/gov/legacy/v043/store_test.go | 2 +- x/gov/simulation/decoder_test.go | 2 +- x/mint/simulation/decoder_test.go | 2 +- x/params/keeper/common_test.go | 2 +- x/params/types/subspace_test.go | 4 ++-- x/slashing/legacy/v040/migrate_test.go | 2 +- x/slashing/simulation/decoder_test.go | 2 +- x/staking/keeper/grpc_query_test.go | 2 +- x/staking/legacy/v040/migrate_test.go | 2 +- x/staking/simulation/decoder_test.go | 2 +- 46 files changed, 73 insertions(+), 86 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bccf1210b79..9611cd353110 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (client/tx) [\#9421](https://github.com/cosmos/cosmos-sdk/pull/9421/) `BuildUnsignedTx`, `BuildSimTx`, `PrintUnsignedStdTx` functions are moved to the Tx Factory as methods. * [\#9246](https://github.com/cosmos/cosmos-sdk/pull/9246) The `New` method for the network package now returns an error. +* (codec) [\#9521](https://github.com/cosmos/cosmos-sdk/pull/9521) Removed deprecated `clientCtx.JSONCodec` from `client.Context`. +* (codec) [\#9521](https://github.com/cosmos/cosmos-sdk/pull/9521) Rename `EncodingConfig.Marshaler` to `Codec`. ### CLI Breaking Changes diff --git a/client/context.go b/client/context.go index 246ea5b40d67..1308823c8409 100644 --- a/client/context.go +++ b/client/context.go @@ -22,11 +22,9 @@ import ( // Context implements a typical context created in SDK modules for transaction // handling and queries. type Context struct { - FromAddress sdk.AccAddress - Client rpcclient.Client - ChainID string - // Deprecated: Codec codec will be changed to Codec: codec.Codec - JSONCodec codec.JSONCodec + FromAddress sdk.AccAddress + Client rpcclient.Client + ChainID string Codec codec.Codec InterfaceRegistry codectypes.InterfaceRegistry Input io.Reader @@ -74,20 +72,8 @@ func (ctx Context) WithInput(r io.Reader) Context { return ctx } -// Deprecated: WithJSONCodec returns a copy of the Context with an updated JSONCodec. -func (ctx Context) WithJSONCodec(m codec.JSONCodec) Context { - ctx.JSONCodec = m - // since we are using ctx.Codec everywhere in the SDK, for backward compatibility - // we need to try to set it here as well. - if c, ok := m.(codec.Codec); ok { - ctx.Codec = c - } - return ctx -} - // WithCodec returns a copy of the Context with an updated Codec. func (ctx Context) WithCodec(m codec.Codec) Context { - ctx.JSONCodec = m ctx.Codec = m return ctx } diff --git a/client/keys/add_test.go b/client/keys/add_test.go index 06375257a445..8e6bf7e5cce5 100644 --- a/client/keys/add_test.go +++ b/client/keys/add_test.go @@ -191,9 +191,9 @@ func Test_runAddCmdDryRun(t *testing.T) { kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome, mockIn) require.NoError(t, err) - appCodec := simapp.MakeTestEncodingConfig().Marshaler + appCodec := simapp.MakeTestEncodingConfig().Codec clientCtx := client.Context{}. - WithJSONCodec(appCodec). + WithCodec(appCodec). WithKeyringDir(kbHome). WithKeyring(kb) ctx := context.WithValue(context.Background(), client.ClientContextKey, &clientCtx) diff --git a/codec/any_test.go b/codec/any_test.go index 8b5ecaca3c07..92bb9d0d5004 100644 --- a/codec/any_test.go +++ b/codec/any_test.go @@ -68,11 +68,11 @@ func TestMarshalProtoPubKey(t *testing.T) { pkAny, err := codectypes.NewAnyWithValue(pk) require.NoError(err) - bz, err := ccfg.Marshaler.MarshalJSON(pkAny) + bz, err := ccfg.Codec.MarshalJSON(pkAny) require.NoError(err) var pkAny2 codectypes.Any - err = ccfg.Marshaler.UnmarshalJSON(bz, &pkAny2) + err = ccfg.Codec.UnmarshalJSON(bz, &pkAny2) require.NoError(err) // Before getting a cached value we need to unpack it. // Normally this happens in types which implement UnpackInterfaces @@ -84,11 +84,11 @@ func TestMarshalProtoPubKey(t *testing.T) { // **** test binary serialization **** - bz, err = ccfg.Marshaler.Marshal(pkAny) + bz, err = ccfg.Codec.Marshal(pkAny) require.NoError(err) var pkAny3 codectypes.Any - err = ccfg.Marshaler.Unmarshal(bz, &pkAny3) + err = ccfg.Codec.Unmarshal(bz, &pkAny3) require.NoError(err) err = ccfg.InterfaceRegistry.UnpackAny(&pkAny3, &pkI) require.NoError(err) @@ -106,11 +106,11 @@ func TestMarshalProtoInterfacePubKey(t *testing.T) { // **** test JSON serialization **** - bz, err := ccfg.Marshaler.MarshalInterfaceJSON(pk) + bz, err := ccfg.Codec.MarshalInterfaceJSON(pk) require.NoError(err) var pk3 cryptotypes.PubKey - err = ccfg.Marshaler.UnmarshalInterfaceJSON(bz, &pk3) + err = ccfg.Codec.UnmarshalInterfaceJSON(bz, &pk3) require.NoError(err) require.True(pk3.Equals(pk)) @@ -119,18 +119,18 @@ func TestMarshalProtoInterfacePubKey(t *testing.T) { // Any can't implement UnpackInterfacesMessage interface. So Any is not // automatically unpacked and we won't get a value. var pkAny codectypes.Any - err = ccfg.Marshaler.UnmarshalJSON(bz, &pkAny) + err = ccfg.Codec.UnmarshalJSON(bz, &pkAny) require.NoError(err) ifc := pkAny.GetCachedValue() require.Nil(ifc) // **** test binary serialization **** - bz, err = ccfg.Marshaler.MarshalInterface(pk) + bz, err = ccfg.Codec.MarshalInterface(pk) require.NoError(err) var pk2 cryptotypes.PubKey - err = ccfg.Marshaler.UnmarshalInterface(bz, &pk2) + err = ccfg.Codec.UnmarshalInterface(bz, &pk2) require.NoError(err) require.True(pk2.Equals(pk)) } diff --git a/crypto/keys/multisig/multisig_test.go b/crypto/keys/multisig/multisig_test.go index 8fb93d3524c4..93ef120fabd5 100644 --- a/crypto/keys/multisig/multisig_test.go +++ b/crypto/keys/multisig/multisig_test.go @@ -352,7 +352,7 @@ func TestDisplay(t *testing.T) { func() { require.Empty(msig.String()) }, ) ccfg := simapp.MakeTestEncodingConfig() - bz, err := ccfg.Marshaler.MarshalInterfaceJSON(msig) + bz, err := ccfg.Codec.MarshalInterfaceJSON(msig) require.NoError(err) expectedPrefix := `{"@type":"/cosmos.crypto.multisig.LegacyAminoPubKey","threshold":2,"public_keys":[{"@type":"/cosmos.crypto.secp256k1.PubKey"` require.True(strings.HasPrefix(string(bz), expectedPrefix)) diff --git a/server/export_test.go b/server/export_test.go index 364a8475dd33..c41d60f027e8 100644 --- a/server/export_test.go +++ b/server/export_test.go @@ -136,7 +136,7 @@ func setupApp(t *testing.T, tempDir string) (*simapp.SimApp, context.Context, *t serverCtx.Config.RootDir = tempDir clientCtx := client.Context{}.WithCodec(app.AppCodec()) - genDoc := newDefaultGenesisDoc(encCfg.Marshaler) + genDoc := newDefaultGenesisDoc(encCfg.Codec) require.NoError(t, saveGenesisFile(genDoc, serverCtx.Config.GenesisFile())) app.InitChain( diff --git a/server/util_test.go b/server/util_test.go index b83531f562e5..c027925c94c1 100644 --- a/server/util_test.go +++ b/server/util_test.go @@ -18,8 +18,8 @@ import ( "github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/server/config" "github.com/cosmos/cosmos-sdk/simapp" - genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli" ) var cancelledInPreRun = errors.New("Cancelled in prerun") @@ -414,7 +414,7 @@ func TestEmptyMinGasPrices(t *testing.T) { encCfg := simapp.MakeTestEncodingConfig() // Run InitCmd to create necessary config files. - clientCtx := client.Context{}.WithHomeDir(tempDir).WithJSONCodec(encCfg.Marshaler) + clientCtx := client.Context{}.WithHomeDir(tempDir).WithCodec(encCfg.Codec) serverCtx := server.NewDefaultContext() ctx := context.WithValue(context.Background(), server.ServerContextKey, serverCtx) ctx = context.WithValue(ctx, client.ClientContextKey, &clientCtx) diff --git a/simapp/app.go b/simapp/app.go index 88b23865c0b2..d36bf9de2cbc 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -193,7 +193,7 @@ func NewSimApp( appOpts servertypes.AppOptions, baseAppOptions ...func(*baseapp.BaseApp), ) *SimApp { - appCodec := encodingConfig.Marshaler + appCodec := encodingConfig.Codec legacyAmino := encodingConfig.Amino interfaceRegistry := encodingConfig.InterfaceRegistry diff --git a/simapp/app_test.go b/simapp/app_test.go index 56c6dc1485ad..c84c99003053 100644 --- a/simapp/app_test.go +++ b/simapp/app_test.go @@ -48,7 +48,7 @@ func TestSimAppExportAndBlockedAddrs(t *testing.T) { ) } - genesisState := NewDefaultGenesisState(encCfg.Marshaler) + genesisState := NewDefaultGenesisState(encCfg.Codec) stateBytes, err := json.MarshalIndent(genesisState, "", " ") require.NoError(t, err) @@ -243,7 +243,7 @@ func TestUpgradeStateOnGenesis(t *testing.T) { encCfg := MakeTestEncodingConfig() db := dbm.NewMemDB() app := NewSimApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, map[int64]bool{}, DefaultNodeHome, 0, encCfg, EmptyAppOptions{}) - genesisState := NewDefaultGenesisState(encCfg.Marshaler) + genesisState := NewDefaultGenesisState(encCfg.Codec) stateBytes, err := json.MarshalIndent(genesisState, "", " ") require.NoError(t, err) diff --git a/simapp/params/encoding.go b/simapp/params/encoding.go index 2cd16263a899..8ff9ea04b39b 100644 --- a/simapp/params/encoding.go +++ b/simapp/params/encoding.go @@ -10,8 +10,7 @@ import ( // This is provided for compatibility between protobuf and amino implementations. type EncodingConfig struct { InterfaceRegistry types.InterfaceRegistry - // NOTE: this field will be renamed to Codec - Marshaler codec.Codec - TxConfig client.TxConfig - Amino *codec.LegacyAmino + Codec codec.Codec + TxConfig client.TxConfig + Amino *codec.LegacyAmino } diff --git a/simapp/params/proto.go b/simapp/params/proto.go index 04aa524b9004..c3975c669fa8 100644 --- a/simapp/params/proto.go +++ b/simapp/params/proto.go @@ -15,12 +15,12 @@ import ( func MakeTestEncodingConfig() EncodingConfig { cdc := codec.NewLegacyAmino() interfaceRegistry := types.NewInterfaceRegistry() - marshaler := codec.NewProtoCodec(interfaceRegistry) + codec := codec.NewProtoCodec(interfaceRegistry) return EncodingConfig{ InterfaceRegistry: interfaceRegistry, - Marshaler: marshaler, - TxConfig: tx.NewTxConfig(marshaler, tx.DefaultSignModes), + Codec: codec, + TxConfig: tx.NewTxConfig(codec, tx.DefaultSignModes), Amino: cdc, } } diff --git a/simapp/simd/cmd/genaccounts_test.go b/simapp/simd/cmd/genaccounts_test.go index 2802cd4af8ae..b4ce4b76715e 100644 --- a/simapp/simd/cmd/genaccounts_test.go +++ b/simapp/simd/cmd/genaccounts_test.go @@ -58,7 +58,7 @@ func TestAddGenesisAccountCmd(t *testing.T) { cfg, err := genutiltest.CreateDefaultTendermintConfig(home) require.NoError(t, err) - appCodec := simapp.MakeTestEncodingConfig().Marshaler + appCodec := simapp.MakeTestEncodingConfig().Codec err = genutiltest.ExecInitCmd(testMbm, home, appCodec) require.NoError(t, err) diff --git a/simapp/simd/cmd/root.go b/simapp/simd/cmd/root.go index 62215c865beb..a5bdbced5956 100644 --- a/simapp/simd/cmd/root.go +++ b/simapp/simd/cmd/root.go @@ -39,7 +39,7 @@ import ( func NewRootCmd() (*cobra.Command, params.EncodingConfig) { encodingConfig := simapp.MakeTestEncodingConfig() initClientCtx := client.Context{}. - WithCodec(encodingConfig.Marshaler). + WithCodec(encodingConfig.Codec). WithInterfaceRegistry(encodingConfig.InterfaceRegistry). WithTxConfig(encodingConfig.TxConfig). WithLegacyAmino(encodingConfig.Amino). @@ -163,7 +163,7 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) { ) // add rosetta - rootCmd.AddCommand(server.RosettaCommand(encodingConfig.InterfaceRegistry, encodingConfig.Marshaler)) + rootCmd.AddCommand(server.RosettaCommand(encodingConfig.InterfaceRegistry, encodingConfig.Codec)) } func addModuleInitFlags(startCmd *cobra.Command) { diff --git a/simapp/simd/cmd/testnet_test.go b/simapp/simd/cmd/testnet_test.go index fae132340745..eafc3d4cdd5c 100644 --- a/simapp/simd/cmd/testnet_test.go +++ b/simapp/simd/cmd/testnet_test.go @@ -24,12 +24,12 @@ func Test_TestnetCmd(t *testing.T) { cfg, err := genutiltest.CreateDefaultTendermintConfig(home) require.NoError(t, err) - err = genutiltest.ExecInitCmd(simapp.ModuleBasics, home, encodingConfig.Marshaler) + err = genutiltest.ExecInitCmd(simapp.ModuleBasics, home, encodingConfig.Codec) require.NoError(t, err) serverCtx := server.NewContext(viper.New(), cfg, logger) clientCtx := client.Context{}. - WithCodec(encodingConfig.Marshaler). + WithCodec(encodingConfig.Codec). WithHomeDir(home). WithTxConfig(encodingConfig.TxConfig) @@ -45,6 +45,6 @@ func Test_TestnetCmd(t *testing.T) { appState, _, err := genutiltypes.GenesisStateFromGenFile(genFile) require.NoError(t, err) - bankGenState := banktypes.GetGenesisStateFromAppState(encodingConfig.Marshaler, appState) + bankGenState := banktypes.GetGenesisStateFromAppState(encodingConfig.Codec, appState) require.NotEmpty(t, bankGenState.Supply.String()) } diff --git a/simapp/test_helpers.go b/simapp/test_helpers.go index 9b50236e9d17..8d7548e1026a 100644 --- a/simapp/test_helpers.go +++ b/simapp/test_helpers.go @@ -55,7 +55,7 @@ func setup(withGenesis bool, invCheckPeriod uint) (*SimApp, GenesisState) { encCdc := MakeTestEncodingConfig() app := NewSimApp(log.NewNopLogger(), db, nil, true, map[int64]bool{}, DefaultNodeHome, invCheckPeriod, encCdc, EmptyAppOptions{}) if withGenesis { - return app, NewDefaultGenesisState(encCdc.Marshaler) + return app, NewDefaultGenesisState(encCdc.Codec) } return app, GenesisState{} } diff --git a/testutil/network/network.go b/testutil/network/network.go index 7087e4bd9f46..738f0afd9682 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -103,13 +103,13 @@ func DefaultConfig() Config { encCfg := simapp.MakeTestEncodingConfig() return Config{ - Codec: encCfg.Marshaler, + Codec: encCfg.Codec, TxConfig: encCfg.TxConfig, LegacyAmino: encCfg.Amino, InterfaceRegistry: encCfg.InterfaceRegistry, AccountRetriever: authtypes.AccountRetriever{}, AppConstructor: NewAppConstructor(encCfg), - GenesisState: simapp.ModuleBasics.DefaultGenesis(encCfg.Marshaler), + GenesisState: simapp.ModuleBasics.DefaultGenesis(encCfg.Codec), TimeoutCommit: 2 * time.Second, ChainID: "chain-" + tmrand.NewRand().Str(6), NumValidators: 4, diff --git a/x/auth/client/cli/encode_test.go b/x/auth/client/cli/encode_test.go index ed3566aaf2c6..a0b5a7427ee8 100644 --- a/x/auth/client/cli/encode_test.go +++ b/x/auth/client/cli/encode_test.go @@ -39,7 +39,7 @@ func TestGetCommandEncode(t *testing.T) { ctx := context.Background() clientCtx := client.Context{}. WithTxConfig(encodingConfig.TxConfig). - WithCodec(encodingConfig.Marshaler) + WithCodec(encodingConfig.Codec) ctx = context.WithValue(ctx, client.ClientContextKey, &clientCtx) cmd.SetArgs([]string{txFileName}) @@ -52,7 +52,7 @@ func TestGetCommandDecode(t *testing.T) { clientCtx := client.Context{}. WithTxConfig(encodingConfig.TxConfig). - WithCodec(encodingConfig.Marshaler) + WithCodec(encodingConfig.Codec) cmd := GetDecodeCommand() _ = testutil.ApplyMockIODiscardOutErr(cmd) diff --git a/x/auth/keeper/keeper_test.go b/x/auth/keeper/keeper_test.go index 16cf53a253cf..7b9cd99c3cca 100644 --- a/x/auth/keeper/keeper_test.go +++ b/x/auth/keeper/keeper_test.go @@ -129,7 +129,7 @@ func TestSupply_ValidatePermissions(t *testing.T) { maccPerms[multiPerm] = []string{types.Burner, types.Minter, types.Staking} maccPerms[randomPerm] = []string{"random"} - cdc := simapp.MakeTestEncodingConfig().Marshaler + cdc := simapp.MakeTestEncodingConfig().Codec keeper := keeper.NewAccountKeeper( cdc, app.GetKey(types.StoreKey), app.GetSubspace(types.ModuleName), types.ProtoBaseAccount, maccPerms, diff --git a/x/auth/legacy/v040/migrate_test.go b/x/auth/legacy/v040/migrate_test.go index 9b09d6e18a02..d666337b18dd 100644 --- a/x/auth/legacy/v040/migrate_test.go +++ b/x/auth/legacy/v040/migrate_test.go @@ -22,7 +22,7 @@ func TestMigrate(t *testing.T) { WithInterfaceRegistry(encodingConfig.InterfaceRegistry). WithTxConfig(encodingConfig.TxConfig). WithLegacyAmino(encodingConfig.Amino). - WithJSONCodec(encodingConfig.Marshaler) + WithCodec(encodingConfig.Codec) coins := sdk.NewCoins(sdk.NewInt64Coin("stake", 50)) diff --git a/x/auth/legacy/v043/store_test.go b/x/auth/legacy/v043/store_test.go index 3daa2d52fc53..bb2cdfdee448 100644 --- a/x/auth/legacy/v043/store_test.go +++ b/x/auth/legacy/v043/store_test.go @@ -661,7 +661,7 @@ func createValidator(t *testing.T, ctx sdk.Context, app *simapp.SimApp, powers i addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, valTokens) valAddrs := simapp.ConvertAddrsToValAddrs(addrs) pks := simapp.CreateTestPubKeys(1) - cdc := simapp.MakeTestEncodingConfig().Marshaler + cdc := simapp.MakeTestEncodingConfig().Codec app.StakingKeeper = stakingkeeper.NewKeeper( cdc, diff --git a/x/auth/simulation/decoder_test.go b/x/auth/simulation/decoder_test.go index 9e21df6e5791..ee78c511dd10 100644 --- a/x/auth/simulation/decoder_test.go +++ b/x/auth/simulation/decoder_test.go @@ -22,7 +22,7 @@ var ( func TestDecodeStore(t *testing.T) { app := simapp.Setup(false) - cdc := simapp.MakeTestEncodingConfig().Marshaler + cdc := simapp.MakeTestEncodingConfig().Codec acc := types.NewBaseAccountWithAddress(delAddr1) dec := simulation.NewDecodeStore(app.AccountKeeper) diff --git a/x/auth/types/common_test.go b/x/auth/types/common_test.go index 8588778994ec..6c045029fd5b 100644 --- a/x/auth/types/common_test.go +++ b/x/auth/types/common_test.go @@ -7,5 +7,5 @@ import ( var ( app = simapp.Setup(false) ecdc = simapp.MakeTestEncodingConfig() - appCodec, legacyAmino = ecdc.Marshaler, ecdc.Amino + appCodec, legacyAmino = ecdc.Codec, ecdc.Amino ) diff --git a/x/authz/simulation/decoder_test.go b/x/authz/simulation/decoder_test.go index cfda286a8377..4851b6ec2ca2 100644 --- a/x/authz/simulation/decoder_test.go +++ b/x/authz/simulation/decoder_test.go @@ -17,7 +17,7 @@ import ( ) func TestDecodeStore(t *testing.T) { - cdc := simapp.MakeTestEncodingConfig().Marshaler + cdc := simapp.MakeTestEncodingConfig().Codec dec := simulation.NewDecodeStore(cdc) grant, _ := authz.NewGrant(banktypes.NewSendAuthorization(sdk.NewCoins(sdk.NewInt64Coin("foo", 123))), time.Now().UTC()) diff --git a/x/bank/keeper/keeper_test.go b/x/bank/keeper/keeper_test.go index 5e67204d34f2..d7f840f9e1f8 100644 --- a/x/bank/keeper/keeper_test.go +++ b/x/bank/keeper/keeper_test.go @@ -74,7 +74,7 @@ type IntegrationTestSuite struct { func (suite *IntegrationTestSuite) initKeepersWithmAccPerms(blockedAddrs map[string]bool) (authkeeper.AccountKeeper, keeper.BaseKeeper) { app := suite.app maccPerms := simapp.GetMaccPerms() - appCodec := simapp.MakeTestEncodingConfig().Marshaler + appCodec := simapp.MakeTestEncodingConfig().Codec maccPerms[holder] = nil maccPerms[authtypes.Burner] = []string{authtypes.Burner} diff --git a/x/bank/legacy/v040/migrate_test.go b/x/bank/legacy/v040/migrate_test.go index e30299ff9251..b00af1af2c3e 100644 --- a/x/bank/legacy/v040/migrate_test.go +++ b/x/bank/legacy/v040/migrate_test.go @@ -21,7 +21,7 @@ func TestMigrate(t *testing.T) { WithInterfaceRegistry(encodingConfig.InterfaceRegistry). WithTxConfig(encodingConfig.TxConfig). WithLegacyAmino(encodingConfig.Amino). - WithJSONCodec(encodingConfig.Marshaler) + WithCodec(encodingConfig.Codec) coins := sdk.NewCoins(sdk.NewInt64Coin("stake", 50)) addr1, _ := sdk.AccAddressFromBech32("cosmos1xxkueklal9vejv9unqu80w9vptyepfa95pd53u") diff --git a/x/bank/legacy/v043/store_test.go b/x/bank/legacy/v043/store_test.go index 5f61e33dffde..3473039a8d46 100644 --- a/x/bank/legacy/v043/store_test.go +++ b/x/bank/legacy/v043/store_test.go @@ -27,12 +27,12 @@ func TestSupplyMigration(t *testing.T) { // Old supply was stored as a single blob under the `SupplyKey`. var oldSupply v040bank.SupplyI oldSupply = &types.Supply{Total: sdk.NewCoins(oldFooCoin, oldBarCoin)} - oldSupplyBz, err := encCfg.Marshaler.MarshalInterface(oldSupply) + oldSupplyBz, err := encCfg.Codec.MarshalInterface(oldSupply) require.NoError(t, err) store.Set(v040bank.SupplyKey, oldSupplyBz) // Run migration. - err = v043bank.MigrateStore(ctx, bankKey, encCfg.Marshaler) + err = v043bank.MigrateStore(ctx, bankKey, encCfg.Codec) require.NoError(t, err) // New supply is indexed by denom. @@ -72,7 +72,7 @@ func TestBalanceKeysMigration(t *testing.T) { oldKey := append(append(v040bank.BalancesPrefix, addr...), denom...) store.Set(oldKey, value) - err := v043bank.MigrateStore(ctx, bankKey, encCfg.Marshaler) + err := v043bank.MigrateStore(ctx, bankKey, encCfg.Codec) require.NoError(t, err) newKey := append(types.CreateAccountBalancesPrefix(addr), denom...) diff --git a/x/capability/simulation/decoder_test.go b/x/capability/simulation/decoder_test.go index a18bcd56115d..093cf5f2daad 100644 --- a/x/capability/simulation/decoder_test.go +++ b/x/capability/simulation/decoder_test.go @@ -14,7 +14,7 @@ import ( ) func TestDecodeStore(t *testing.T) { - cdc := simapp.MakeTestEncodingConfig().Marshaler + cdc := simapp.MakeTestEncodingConfig().Codec dec := simulation.NewDecodeStore(cdc) capOwners := types.CapabilityOwners{ diff --git a/x/distribution/client/cli/tx_test.go b/x/distribution/client/cli/tx_test.go index 36a946e7cca7..7176c6bf9578 100644 --- a/x/distribution/client/cli/tx_test.go +++ b/x/distribution/client/cli/tx_test.go @@ -77,7 +77,7 @@ func TestParseProposal(t *testing.T) { } `) - proposal, err := ParseCommunityPoolSpendProposalWithDeposit(encodingConfig.Marshaler, okJSON.Name()) + proposal, err := ParseCommunityPoolSpendProposalWithDeposit(encodingConfig.Codec, okJSON.Name()) require.NoError(t, err) require.Equal(t, "Community Pool Spend", proposal.Title) diff --git a/x/distribution/simulation/decoder_test.go b/x/distribution/simulation/decoder_test.go index 69bb6b3b77a0..01e986fe53eb 100644 --- a/x/distribution/simulation/decoder_test.go +++ b/x/distribution/simulation/decoder_test.go @@ -22,7 +22,7 @@ var ( ) func TestDecodeDistributionStore(t *testing.T) { - cdc := simapp.MakeTestEncodingConfig().Marshaler + cdc := simapp.MakeTestEncodingConfig().Codec dec := simulation.NewDecodeStore(cdc) decCoins := sdk.DecCoins{sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, sdk.OneDec())} diff --git a/x/evidence/keeper/querier_test.go b/x/evidence/keeper/querier_test.go index 40a9f94e5fb0..709340d24168 100644 --- a/x/evidence/keeper/querier_test.go +++ b/x/evidence/keeper/querier_test.go @@ -37,7 +37,7 @@ func (suite *KeeperTestSuite) TestQuerier_QueryEvidence_Existing() { func (suite *KeeperTestSuite) TestQuerier_QueryEvidence_NonExisting() { ctx := suite.ctx.WithIsCheckTx(false) - cdc := simapp.MakeTestEncodingConfig().Marshaler + cdc := simapp.MakeTestEncodingConfig().Codec numEvidence := 100 suite.populateEvidence(ctx, numEvidence) diff --git a/x/evidence/legacy/v040/migrate_test.go b/x/evidence/legacy/v040/migrate_test.go index 43d3d9db7e2e..02446439221a 100644 --- a/x/evidence/legacy/v040/migrate_test.go +++ b/x/evidence/legacy/v040/migrate_test.go @@ -18,7 +18,7 @@ func TestMigrate(t *testing.T) { WithInterfaceRegistry(encodingConfig.InterfaceRegistry). WithTxConfig(encodingConfig.TxConfig). WithLegacyAmino(encodingConfig.Amino). - WithJSONCodec(encodingConfig.Marshaler) + WithCodec(encodingConfig.Codec) addr1, _ := sdk.AccAddressFromBech32("cosmos1xxkueklal9vejv9unqu80w9vptyepfa95pd53u") diff --git a/x/feegrant/simulation/decoder_test.go b/x/feegrant/simulation/decoder_test.go index 57ed0dfa1a17..bb6fc789d76b 100644 --- a/x/feegrant/simulation/decoder_test.go +++ b/x/feegrant/simulation/decoder_test.go @@ -22,7 +22,7 @@ var ( ) func TestDecodeStore(t *testing.T) { - cdc := simapp.MakeTestEncodingConfig().Marshaler + cdc := simapp.MakeTestEncodingConfig().Codec dec := simulation.NewDecodeStore(cdc) grant, err := feegrant.NewGrant(granterAddr, granteeAddr, &feegrant.BasicAllowance{ diff --git a/x/genutil/gentx_test.go b/x/genutil/gentx_test.go index ac9ef6de3fdd..65fd5194d96e 100644 --- a/x/genutil/gentx_test.go +++ b/x/genutil/gentx_test.go @@ -111,7 +111,7 @@ func (suite *GenTxTestSuite) TestSetGenTxsInAppGenesisState() { for _, tc := range testCases { suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() - cdc := suite.encodingConfig.Marshaler + cdc := suite.encodingConfig.Codec txJSONEncoder := suite.encodingConfig.TxConfig.TxJSONEncoder() tc.malleate() @@ -178,7 +178,7 @@ func (suite *GenTxTestSuite) TestValidateAccountInGenesis() { for _, tc := range testCases { suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() - cdc := suite.encodingConfig.Marshaler + cdc := suite.encodingConfig.Codec suite.app.StakingKeeper.SetParams(suite.ctx, stakingtypes.DefaultParams()) stakingGenesisState := staking.ExportGenesis(suite.ctx, suite.app.StakingKeeper) diff --git a/x/gov/keeper/common_test.go b/x/gov/keeper/common_test.go index e39ca9c70380..89da4e06074d 100644 --- a/x/gov/keeper/common_test.go +++ b/x/gov/keeper/common_test.go @@ -21,7 +21,7 @@ func createValidators(t *testing.T, ctx sdk.Context, app *simapp.SimApp, powers addrs := simapp.AddTestAddrsIncremental(app, ctx, 5, sdk.NewInt(30000000)) valAddrs := simapp.ConvertAddrsToValAddrs(addrs) pks := simapp.CreateTestPubKeys(5) - cdc := simapp.MakeTestEncodingConfig().Marshaler + cdc := simapp.MakeTestEncodingConfig().Codec app.StakingKeeper = stakingkeeper.NewKeeper( cdc, diff --git a/x/gov/legacy/v040/migrate_test.go b/x/gov/legacy/v040/migrate_test.go index 664696bf296e..2d399f38beb3 100644 --- a/x/gov/legacy/v040/migrate_test.go +++ b/x/gov/legacy/v040/migrate_test.go @@ -22,7 +22,7 @@ func TestMigrate(t *testing.T) { WithInterfaceRegistry(encodingConfig.InterfaceRegistry). WithTxConfig(encodingConfig.TxConfig). WithLegacyAmino(encodingConfig.Amino). - WithJSONCodec(encodingConfig.Marshaler) + WithCodec(encodingConfig.Codec) recipient, err := sdk.AccAddressFromBech32("cosmos1fl48vsnmsdzcv85q5d2q4z5ajdha8yu34mf0eh") require.NoError(t, err) diff --git a/x/gov/legacy/v043/json_test.go b/x/gov/legacy/v043/json_test.go index d9f045774661..4fa05b941398 100644 --- a/x/gov/legacy/v043/json_test.go +++ b/x/gov/legacy/v043/json_test.go @@ -19,7 +19,7 @@ func TestMigrateJSON(t *testing.T) { clientCtx := client.Context{}. WithInterfaceRegistry(encodingConfig.InterfaceRegistry). WithTxConfig(encodingConfig.TxConfig). - WithCodec(encodingConfig.Marshaler) + WithCodec(encodingConfig.Codec) voter, err := sdk.AccAddressFromBech32("cosmos1fl48vsnmsdzcv85q5d2q4z5ajdha8yu34mf0eh") require.NoError(t, err) diff --git a/x/gov/legacy/v043/store_test.go b/x/gov/legacy/v043/store_test.go index b65b126b03ec..3501395010e6 100644 --- a/x/gov/legacy/v043/store_test.go +++ b/x/gov/legacy/v043/store_test.go @@ -17,7 +17,7 @@ import ( ) func TestMigrateStore(t *testing.T) { - cdc := simapp.MakeTestEncodingConfig().Marshaler + cdc := simapp.MakeTestEncodingConfig().Codec govKey := sdk.NewKVStoreKey("gov") ctx := testutil.DefaultContext(govKey, sdk.NewTransientStoreKey("transient_test")) store := ctx.KVStore(govKey) diff --git a/x/gov/simulation/decoder_test.go b/x/gov/simulation/decoder_test.go index 188fe9e540f0..44752440f041 100644 --- a/x/gov/simulation/decoder_test.go +++ b/x/gov/simulation/decoder_test.go @@ -22,7 +22,7 @@ var ( ) func TestDecodeStore(t *testing.T) { - cdc := simapp.MakeTestEncodingConfig().Marshaler + cdc := simapp.MakeTestEncodingConfig().Codec dec := simulation.NewDecodeStore(cdc) endTime := time.Now().UTC() diff --git a/x/mint/simulation/decoder_test.go b/x/mint/simulation/decoder_test.go index 43a8cfbd42c4..9ee8315f000d 100644 --- a/x/mint/simulation/decoder_test.go +++ b/x/mint/simulation/decoder_test.go @@ -14,7 +14,7 @@ import ( ) func TestDecodeStore(t *testing.T) { - cdc := simapp.MakeTestEncodingConfig().Marshaler + cdc := simapp.MakeTestEncodingConfig().Codec dec := simulation.NewDecodeStore(cdc) minter := types.NewMinter(sdk.OneDec(), sdk.NewDec(15)) diff --git a/x/params/keeper/common_test.go b/x/params/keeper/common_test.go index 3ba444173588..e5bebaf09b06 100644 --- a/x/params/keeper/common_test.go +++ b/x/params/keeper/common_test.go @@ -9,7 +9,7 @@ import ( ) func testComponents() (*codec.LegacyAmino, sdk.Context, sdk.StoreKey, sdk.StoreKey, paramskeeper.Keeper) { - marshaler := simapp.MakeTestEncodingConfig().Marshaler + marshaler := simapp.MakeTestEncodingConfig().Codec legacyAmino := createTestCodec() mkey := sdk.NewKVStoreKey("test") tkey := sdk.NewTransientStoreKey("transient_test") diff --git a/x/params/types/subspace_test.go b/x/params/types/subspace_test.go index a347a5f5427e..664c70df1801 100644 --- a/x/params/types/subspace_test.go +++ b/x/params/types/subspace_test.go @@ -35,9 +35,9 @@ func (suite *SubspaceTestSuite) SetupTest() { suite.NoError(ms.LoadLatestVersion()) encCfg := simapp.MakeTestEncodingConfig() - ss := types.NewSubspace(encCfg.Marshaler, encCfg.Amino, key, tkey, "testsubspace") + ss := types.NewSubspace(encCfg.Codec, encCfg.Amino, key, tkey, "testsubspace") - suite.cdc = encCfg.Marshaler + suite.cdc = encCfg.Codec suite.amino = encCfg.Amino suite.ctx = sdk.NewContext(ms, tmproto.Header{}, false, log.NewNopLogger()) suite.ss = ss.WithKeyTable(paramKeyTable()) diff --git a/x/slashing/legacy/v040/migrate_test.go b/x/slashing/legacy/v040/migrate_test.go index f11d2e9d26ee..03186634c038 100644 --- a/x/slashing/legacy/v040/migrate_test.go +++ b/x/slashing/legacy/v040/migrate_test.go @@ -19,7 +19,7 @@ func TestMigrate(t *testing.T) { WithInterfaceRegistry(encodingConfig.InterfaceRegistry). WithTxConfig(encodingConfig.TxConfig). WithLegacyAmino(encodingConfig.Amino). - WithJSONCodec(encodingConfig.Marshaler) + WithCodec(encodingConfig.Codec) addr1, err := sdk.ConsAddressFromBech32("cosmosvalcons104cjmxkrg8y8lmrp25de02e4zf00zle4mzs685") require.NoError(t, err) diff --git a/x/slashing/simulation/decoder_test.go b/x/slashing/simulation/decoder_test.go index 94b9f5a1c88c..883b3874d2f7 100644 --- a/x/slashing/simulation/decoder_test.go +++ b/x/slashing/simulation/decoder_test.go @@ -25,7 +25,7 @@ var ( ) func TestDecodeStore(t *testing.T) { - cdc := simapp.MakeTestEncodingConfig().Marshaler + cdc := simapp.MakeTestEncodingConfig().Codec dec := simulation.NewDecodeStore(cdc) info := types.NewValidatorSigningInfo(consAddr1, 0, 1, time.Now().UTC(), false, 0) diff --git a/x/staking/keeper/grpc_query_test.go b/x/staking/keeper/grpc_query_test.go index ba43269e2e32..1b06f8588641 100644 --- a/x/staking/keeper/grpc_query_test.go +++ b/x/staking/keeper/grpc_query_test.go @@ -773,7 +773,7 @@ func createValidators(t *testing.T, ctx sdk.Context, app *simapp.SimApp, powers addrs := simapp.AddTestAddrsIncremental(app, ctx, 5, app.StakingKeeper.TokensFromConsensusPower(ctx, 300)) valAddrs := simapp.ConvertAddrsToValAddrs(addrs) pks := simapp.CreateTestPubKeys(5) - cdc := simapp.MakeTestEncodingConfig().Marshaler + cdc := simapp.MakeTestEncodingConfig().Codec app.StakingKeeper = keeper.NewKeeper( cdc, app.GetKey(types.StoreKey), diff --git a/x/staking/legacy/v040/migrate_test.go b/x/staking/legacy/v040/migrate_test.go index af409dde26b8..d336d4dd3915 100644 --- a/x/staking/legacy/v040/migrate_test.go +++ b/x/staking/legacy/v040/migrate_test.go @@ -20,7 +20,7 @@ func TestMigrate(t *testing.T) { WithInterfaceRegistry(encodingConfig.InterfaceRegistry). WithTxConfig(encodingConfig.TxConfig). WithLegacyAmino(encodingConfig.Amino). - WithJSONCodec(encodingConfig.Marshaler) + WithCodec(encodingConfig.Codec) consPubKey := ed25519.GenPrivKeyFromSecret([]byte("val0")).PubKey() stakingGenState := v038staking.GenesisState{ diff --git a/x/staking/simulation/decoder_test.go b/x/staking/simulation/decoder_test.go index 6584df24f508..3d7546369d6b 100644 --- a/x/staking/simulation/decoder_test.go +++ b/x/staking/simulation/decoder_test.go @@ -32,7 +32,7 @@ func makeTestCodec() (cdc *codec.LegacyAmino) { } func TestDecodeStore(t *testing.T) { - cdc := simapp.MakeTestEncodingConfig().Marshaler + cdc := simapp.MakeTestEncodingConfig().Codec dec := simulation.NewDecodeStore(cdc) bondTime := time.Now().UTC()