diff --git a/CHANGELOG.md b/CHANGELOG.md index e85e50e71066..ff23cb0311be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -94,7 +94,7 @@ if input key is empty, or input data contains empty key. * (auth/tx) [\#8926](https://github.com/cosmos/cosmos-sdk/pull/8926) The `ProtoTxProvider` interface used as a workaround for transaction simulation has been removed. * (x/bank) [\#8798](https://github.com/cosmos/cosmos-sdk/pull/8798) `GetTotalSupply` is removed in favour of `GetPaginatedTotalSupply` * (x/bank/types) [\#9061](https://github.com/cosmos/cosmos-sdk/pull/9061) `AddressFromBalancesStore` now returns an error for invalid key instead of panic. -* (codec) [\#9061](https://github.com/cosmos/cosmos-sdk/pull/9226) Rename codec interfaces and methods, to follow a general Go interfaces: +* (codec) [\#9226](https://github.com/cosmos/cosmos-sdk/pull/9226) Rename codec interfaces and methods, to follow a general Go interfaces: * `codec.Marshaler` → `codec.Codec` (this defines objects which serialize other objects) * `codec.BinaryMarshaler` → `codec.BinaryCodec` * `codec.JSONMarshaler` → `codec.JSONCodec` @@ -104,7 +104,7 @@ if input key is empty, or input data contains empty key. * The `sdk.ServiceMsg` struct has been removed. * `sdk.Msg` now only contains `ValidateBasic` and `GetSigners` methods. The remaining methods `GetSignBytes`, `Route` and `Type` are moved to `legacytx.LegacyMsg`. * The `RegisterCustomTypeURL` function and the `cosmos.base.v1beta1.ServiceMsg` interface have been removed from the interface registry. - +* (codec) [\#9251](https://github.com/cosmos/cosmos-sdk/pull/9251) Rename `clientCtx.JSONMarshaler` to `clientCtx.JSONCodec` as per #9226. ### State Machine Breaking diff --git a/client/context.go b/client/context.go index a9a3dba86393..ee6fe8b86081 100644 --- a/client/context.go +++ b/client/context.go @@ -25,7 +25,7 @@ type Context struct { FromAddress sdk.AccAddress Client rpcclient.Client ChainID string - JSONMarshaler codec.JSONCodec + JSONCodec codec.JSONCodec InterfaceRegistry codectypes.InterfaceRegistry Input io.Reader Keyring keyring.Keyring @@ -72,9 +72,9 @@ func (ctx Context) WithInput(r io.Reader) Context { return ctx } -// WithJSONMarshaler returns a copy of the Context with an updated JSONMarshaler. -func (ctx Context) WithJSONMarshaler(m codec.JSONCodec) Context { - ctx.JSONMarshaler = m +// WithJSONCodec returns a copy of the Context with an updated JSONCodec. +func (ctx Context) WithJSONCodec(m codec.JSONCodec) Context { + ctx.JSONCodec = m return ctx } @@ -254,10 +254,10 @@ func (ctx Context) PrintBytes(o []byte) error { // PrintProto outputs toPrint to the ctx.Output based on ctx.OutputFormat which is // either text or json. If text, toPrint will be YAML encoded. Otherwise, toPrint -// will be JSON encoded using ctx.JSONMarshaler. An error is returned upon failure. +// will be JSON encoded using ctx.JSONCodec. An error is returned upon failure. func (ctx Context) PrintProto(toPrint proto.Message) error { // always serialize JSON initially because proto json can't be directly YAML encoded - out, err := ctx.JSONMarshaler.MarshalJSON(toPrint) + out, err := ctx.JSONCodec.MarshalJSON(toPrint) if err != nil { return err } diff --git a/client/context_test.go b/client/context_test.go index f1c01e765810..53214b7c23d8 100644 --- a/client/context_test.go +++ b/client/context_test.go @@ -41,7 +41,7 @@ func TestContext_PrintObject(t *testing.T) { // proto // registry := testdata.NewTestInterfaceRegistry() - ctx = ctx.WithJSONMarshaler(codec.NewProtoCodec(registry)) + ctx = ctx.WithJSONCodec(codec.NewProtoCodec(registry)) // json buf := &bytes.Buffer{} diff --git a/client/debug/main.go b/client/debug/main.go index 8a3fbe910bee..377fa5f54903 100644 --- a/client/debug/main.go +++ b/client/debug/main.go @@ -32,7 +32,7 @@ func Cmd() *cobra.Command { // getPubKeyFromString decodes SDK PubKey using JSON marshaler. func getPubKeyFromString(ctx client.Context, pkstr string) (cryptotypes.PubKey, error) { var pk cryptotypes.PubKey - err := ctx.JSONMarshaler.UnmarshalInterfaceJSON([]byte(pkstr), &pk) + err := ctx.JSONCodec.UnmarshalInterfaceJSON([]byte(pkstr), &pk) return pk, err } diff --git a/client/grpc/tmservice/service_test.go b/client/grpc/tmservice/service_test.go index fb83ab9c2046..0256ec8197d4 100644 --- a/client/grpc/tmservice/service_test.go +++ b/client/grpc/tmservice/service_test.go @@ -57,7 +57,7 @@ func (s IntegrationTestSuite) TestQueryNodeInfo() { restRes, err := rest.GetRequest(fmt.Sprintf("%s/cosmos/base/tendermint/v1beta1/node_info", val.APIAddress)) s.Require().NoError(err) var getInfoRes tmservice.GetNodeInfoResponse - s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(restRes, &getInfoRes)) + s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(restRes, &getInfoRes)) s.Require().Equal(getInfoRes.ApplicationVersion.AppName, version.NewInfo().AppName) } @@ -70,7 +70,7 @@ func (s IntegrationTestSuite) TestQuerySyncing() { restRes, err := rest.GetRequest(fmt.Sprintf("%s/cosmos/base/tendermint/v1beta1/syncing", val.APIAddress)) s.Require().NoError(err) var syncingRes tmservice.GetSyncingResponse - s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(restRes, &syncingRes)) + s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(restRes, &syncingRes)) } func (s IntegrationTestSuite) TestQueryLatestBlock() { @@ -82,7 +82,7 @@ func (s IntegrationTestSuite) TestQueryLatestBlock() { restRes, err := rest.GetRequest(fmt.Sprintf("%s/cosmos/base/tendermint/v1beta1/blocks/latest", val.APIAddress)) s.Require().NoError(err) var blockInfoRes tmservice.GetLatestBlockResponse - s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(restRes, &blockInfoRes)) + s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(restRes, &blockInfoRes)) } func (s IntegrationTestSuite) TestQueryBlockByHeight() { @@ -93,7 +93,7 @@ func (s IntegrationTestSuite) TestQueryBlockByHeight() { restRes, err := rest.GetRequest(fmt.Sprintf("%s/cosmos/base/tendermint/v1beta1/blocks/%d", val.APIAddress, 1)) s.Require().NoError(err) var blockInfoRes tmservice.GetBlockByHeightResponse - s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(restRes, &blockInfoRes)) + s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(restRes, &blockInfoRes)) } func (s IntegrationTestSuite) TestQueryLatestValidatorSet() { @@ -124,7 +124,7 @@ func (s IntegrationTestSuite) TestQueryLatestValidatorSet() { restRes, err := rest.GetRequest(fmt.Sprintf("%s/cosmos/base/tendermint/v1beta1/validatorsets/latest?pagination.offset=%d&pagination.limit=%d", val.APIAddress, 0, 1)) s.Require().NoError(err) var validatorSetRes tmservice.GetLatestValidatorSetResponse - s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(restRes, &validatorSetRes)) + s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(restRes, &validatorSetRes)) s.Require().Equal(1, len(validatorSetRes.Validators)) anyPub, err := codectypes.NewAnyWithValue(val.PubKey) s.Require().NoError(err) @@ -183,7 +183,7 @@ func (s IntegrationTestSuite) TestLatestValidatorSet_GRPCGateway() { s.Require().Contains(string(res), tc.expErrMsg) } else { var result tmservice.GetLatestValidatorSetResponse - err = vals[0].ClientCtx.JSONMarshaler.UnmarshalJSON(res, &result) + err = vals[0].ClientCtx.JSONCodec.UnmarshalJSON(res, &result) s.Require().NoError(err) s.Require().Equal(uint64(len(vals)), result.Pagination.Total) anyPub, err := codectypes.NewAnyWithValue(vals[0].PubKey) @@ -245,7 +245,7 @@ func (s IntegrationTestSuite) TestValidatorSetByHeight_GRPCGateway() { s.Require().Contains(string(res), tc.expErrMsg) } else { var result tmservice.GetValidatorSetByHeightResponse - err = vals[0].ClientCtx.JSONMarshaler.UnmarshalJSON(res, &result) + err = vals[0].ClientCtx.JSONCodec.UnmarshalJSON(res, &result) s.Require().NoError(err) s.Require().Equal(uint64(len(vals)), result.Pagination.Total) } diff --git a/client/keys/add.go b/client/keys/add.go index 7c337bab40d5..e119388d012a 100644 --- a/client/keys/add.go +++ b/client/keys/add.go @@ -173,7 +173,7 @@ func RunAddCmd(ctx client.Context, cmd *cobra.Command, args []string, inBuf *buf pubKey, _ := cmd.Flags().GetString(FlagPublicKey) if pubKey != "" { var pk cryptotypes.PubKey - err = ctx.JSONMarshaler.UnmarshalInterfaceJSON([]byte(pubKey), &pk) + err = ctx.JSONCodec.UnmarshalInterfaceJSON([]byte(pubKey), &pk) if err != nil { return err } diff --git a/codec/amino_codec.go b/codec/amino_codec.go index 668efb70b1b8..69f4dc133d29 100644 --- a/codec/amino_codec.go +++ b/codec/amino_codec.go @@ -57,25 +57,25 @@ func (ac *AminoCodec) MustUnmarshalLengthPrefixed(bz []byte, ptr ProtoMarshaler) ac.LegacyAmino.MustUnmarshalLengthPrefixed(bz, ptr) } -// MarshalJSON implements JSONMarshaler.MarshalJSON method, +// MarshalJSON implements JSONCodec.MarshalJSON method, // it marshals to JSON using legacy amino codec. func (ac *AminoCodec) MarshalJSON(o proto.Message) ([]byte, error) { return ac.LegacyAmino.MarshalJSON(o) } -// MustMarshalJSON implements JSONMarshaler.MustMarshalJSON method, +// MustMarshalJSON implements JSONCodec.MustMarshalJSON method, // it executes MarshalJSON except it panics upon failure. func (ac *AminoCodec) MustMarshalJSON(o proto.Message) []byte { return ac.LegacyAmino.MustMarshalJSON(o) } -// UnmarshalJSON implements JSONMarshaler.UnmarshalJSON method, +// UnmarshalJSON implements JSONCodec.UnmarshalJSON method, // it unmarshals from JSON using legacy amino codec. func (ac *AminoCodec) UnmarshalJSON(bz []byte, ptr proto.Message) error { return ac.LegacyAmino.UnmarshalJSON(bz, ptr) } -// MustUnmarshalJSON implements JSONMarshaler.MustUnmarshalJSON method, +// MustUnmarshalJSON implements JSONCodec.MustUnmarshalJSON method, // it executes UnmarshalJSON except it panics upon failure. func (ac *AminoCodec) MustUnmarshalJSON(bz []byte, ptr proto.Message) { ac.LegacyAmino.MustUnmarshalJSON(bz, ptr) diff --git a/codec/any_test.go b/codec/any_test.go index a9c30c0def4a..8b5ecaca3c07 100644 --- a/codec/any_test.go +++ b/codec/any_test.go @@ -114,7 +114,7 @@ func TestMarshalProtoInterfacePubKey(t *testing.T) { require.NoError(err) require.True(pk3.Equals(pk)) - // ** Check unmarshal using JSONMarshaler ** + // ** Check unmarshal using JSONCodec ** // Unpacking won't work straightforward s Any type // Any can't implement UnpackInterfacesMessage interface. So Any is not // automatically unpacked and we won't get a value. diff --git a/codec/proto_codec.go b/codec/proto_codec.go index 19c867f55830..b75f1d8355c0 100644 --- a/codec/proto_codec.go +++ b/codec/proto_codec.go @@ -122,7 +122,7 @@ func (pc *ProtoCodec) MustUnmarshalLengthPrefixed(bz []byte, ptr ProtoMarshaler) } } -// MarshalJSON implements JSONMarshaler.MarshalJSON method, +// MarshalJSON implements JSONCodec.MarshalJSON method, // it marshals to JSON using proto codec. // NOTE: this function must be used with a concrete type which // implements proto.Message. For interface please use the codec.MarshalInterfaceJSON @@ -135,7 +135,7 @@ func (pc *ProtoCodec) MarshalJSON(o proto.Message) ([]byte, error) { return ProtoMarshalJSON(m, pc.interfaceRegistry) } -// MustMarshalJSON implements JSONMarshaler.MustMarshalJSON method, +// MustMarshalJSON implements JSONCodec.MustMarshalJSON method, // it executes MarshalJSON except it panics upon failure. // NOTE: this function must be used with a concrete type which // implements proto.Message. For interface please use the codec.MarshalInterfaceJSON @@ -148,7 +148,7 @@ func (pc *ProtoCodec) MustMarshalJSON(o proto.Message) []byte { return bz } -// UnmarshalJSON implements JSONMarshaler.UnmarshalJSON method, +// UnmarshalJSON implements JSONCodec.UnmarshalJSON method, // it unmarshals from JSON using proto codec. // NOTE: this function must be used with a concrete type which // implements proto.Message. For interface please use the codec.UnmarshalInterfaceJSON @@ -167,7 +167,7 @@ func (pc *ProtoCodec) UnmarshalJSON(bz []byte, ptr proto.Message) error { return types.UnpackInterfaces(ptr, pc.interfaceRegistry) } -// MustUnmarshalJSON implements JSONMarshaler.MustUnmarshalJSON method, +// MustUnmarshalJSON implements JSONCodec.MustUnmarshalJSON method, // it executes UnmarshalJSON except it panics upon failure. // NOTE: this function must be used with a concrete type which // implements proto.Message. For interface please use the codec.UnmarshalInterfaceJSON diff --git a/codec/yaml.go b/codec/yaml.go index d641e52f2018..fc8b7d3f601e 100644 --- a/codec/yaml.go +++ b/codec/yaml.go @@ -7,13 +7,13 @@ import ( "gopkg.in/yaml.v2" ) -// MarshalYAML marshals toPrint using jsonMarshaler to leverage specialized MarshalJSON methods +// MarshalYAML marshals toPrint using JSONCodec to leverage specialized MarshalJSON methods // (usually related to serialize data with protobuf or amin depending on a configuration). // This involves additional roundtrip through JSON. -func MarshalYAML(jsonMarshaler JSONCodec, toPrint proto.Message) ([]byte, error) { +func MarshalYAML(cdc JSONCodec, toPrint proto.Message) ([]byte, error) { // We are OK with the performance hit of the additional JSON roundtip. MarshalYAML is not // used in any critical parts of the system. - bz, err := jsonMarshaler.MarshalJSON(toPrint) + bz, err := cdc.MarshalJSON(toPrint) if err != nil { return nil, err } diff --git a/docs/architecture/adr-020-protobuf-transaction-encoding.md b/docs/architecture/adr-020-protobuf-transaction-encoding.md index dde981f7e9ec..d2e288db3841 100644 --- a/docs/architecture/adr-020-protobuf-transaction-encoding.md +++ b/docs/architecture/adr-020-protobuf-transaction-encoding.md @@ -13,6 +13,7 @@ - 2020 September 25: Remove `PublicKey` type in favor of `secp256k1.PubKey`, `ed25519.PubKey` and `multisig.LegacyAminoPubKey`. - 2020 October 15: Add `GetAccount` and `GetAccountWithHeight` methods to the `AccountRetriever` interface. - 2021 Feb 24: The SDK does not use Tendermint's `PubKey` interface anymore, but its own `cryptotypes.PubKey`. Updates to reflect this. +- 2021 May 3: Rename `clientCtx.JSONMarshaler` to `clientCtx.JSONCodec` ## Status @@ -343,7 +344,7 @@ type TxBuilder interface { } ``` -We then update `Context` to have new fields: `JSONMarshaler`, `TxGenerator`, +We then update `Context` to have new fields: `JSONCodec`, `TxGenerator`, and `AccountRetriever`, and we update `AppModuleBasic.GetTxCmd` to take a `Context` which should have all of these fields pre-populated. diff --git a/docs/basics/app-anatomy.md b/docs/basics/app-anatomy.md index 70b725865aba..4efa5503aba6 100644 --- a/docs/basics/app-anatomy.md +++ b/docs/basics/app-anatomy.md @@ -116,7 +116,7 @@ Here are descriptions of what each of the four fields means: - `InterfaceRegistry`: The `InterfaceRegistry` is used by the Protobuf codec to handle interfaces that are encoded and decoded (we also say "unpacked") using [`google.protobuf.Any`](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto). `Any` could be thought as a struct that contains a `type_url` (name of a concrete type implementing the interface) and a `value` (its encoded bytes). `InterfaceRegistry` provides a mechanism for registering interfaces and implementations that can be safely unpacked from `Any`. Each of the application's modules implements the `RegisterInterfaces` method that can be used to register the module's own interfaces and implementations. - You can read more about Any in [ADR-19](../architecture/adr-019-protobuf-state-encoding.md#usage-of-any-to-encode-interfaces). - To go more into details, the SDK uses an implementation of the Protobuf specification called [`gogoprotobuf`](https://github.com/gogo/protobuf). By default, the [gogo protobuf implementation of `Any`](https://godoc.org/github.com/gogo/protobuf/types) uses [global type registration](https://github.com/gogo/protobuf/blob/master/proto/properties.go#L540) to decode values packed in `Any` into concrete Go types. This introduces a vulnerability where any malicious module in the dependency tree could registry a type with the global protobuf registry and cause it to be loaded and unmarshaled by a transaction that referenced it in the `type_url` field. For more information, please refer to [ADR-019](../architecture/adr-019-protobuf-state-encoding.md). -- `Marshaler`: the default codec used throughout the SDK. It is composed of a `BinaryMarshaler` used to encode and decode state, and a `JSONMarshaler` used to output data to the users (for example in the [CLI](#cli)). By default, the SDK uses Protobuf as `Marshaler`. +- `Marshaler`: the default codec used throughout the SDK. It is composed of a `BinaryCodec` used to encode and decode state, and a `JSONCodec` used to output data to the users (for example in the [CLI](#cli)). By default, the SDK uses Protobuf as `Marshaler`. - `TxConfig`: `TxConfig` defines an interface a client can utilize to generate an application-defined concrete transaction type. Currently, the SDK handles two transaction types: `SIGN_MODE_DIRECT` (which uses Protobuf binary as over-the-wire encoding) and `SIGN_MODE_LEGACY_AMINO_JSON` (which depends on Amino). Read more about transactions [here](../core/transactions.md). - `Amino`: Some legacy parts of the SDK still use Amino for backwards-compatibility. Each module exposes a `RegisterLegacyAmino` method to register the module's specific types within Amino. This `Amino` codec should not be used by app developers anymore, and will be removed in future releases. diff --git a/docs/migrations/app_and_modules.md b/docs/migrations/app_and_modules.md index 5249a0131359..1e1e0a07a4d9 100644 --- a/docs/migrations/app_and_modules.md +++ b/docs/migrations/app_and_modules.md @@ -146,7 +146,7 @@ clientCtx, err := client.GetClientTxContext(cmd) Some other flags helper functions are transformed: `flags.PostCommands(cmds ...*cobra.Command) []*cobra.Command` and `flags.GetCommands(...)` usage is now replaced by `flags.AddTxFlagsToCmd(cmd *cobra.Command)` and `flags.AddQueryFlagsToCmd(cmd *cobra.Command)` respectively. -Moreover, new CLI commands don't take any codec as input anymore. Instead, the `clientCtx` can be retrieved from the `cmd` itself using the `GetClient{Query,Tx}Context` function above, and the codec as `clientCtx.JSONMarshaler`. +Moreover, new CLI commands don't take any codec as input anymore. Instead, the `clientCtx` can be retrieved from the `cmd` itself using the `GetClient{Query,Tx}Context` function above, and the codec as `clientCtx.JSONCodec`. ```diff // v0.39 @@ -157,7 +157,7 @@ Moreover, new CLI commands don't take any codec as input anymore. Instead, the ` // v0.40 + func NewSendTxCmd() *cobra.Command { + clientCtx, err := client.GetClientTxContext(cmd) -+ clientCtx.JSONMarshaler.MarshalJSON(...) ++ clientCtx.JSONCodec.MarshalJSON(...) +} ``` diff --git a/server/export_test.go b/server/export_test.go index 7280bbc718f4..e7d62ebfcfc9 100644 --- a/server/export_test.go +++ b/server/export_test.go @@ -135,7 +135,7 @@ func setupApp(t *testing.T, tempDir string) (*simapp.SimApp, context.Context, *t serverCtx := server.NewDefaultContext() serverCtx.Config.RootDir = tempDir - clientCtx := client.Context{}.WithJSONMarshaler(app.AppCodec()) + clientCtx := client.Context{}.WithJSONCodec(app.AppCodec()) genDoc := newDefaultGenesisDoc(encCfg.Marshaler) require.NoError(t, saveGenesisFile(genDoc, serverCtx.Config.GenesisFile())) diff --git a/server/start.go b/server/start.go index eef353fa7ef8..3d09e2a96da9 100644 --- a/server/start.go +++ b/server/start.go @@ -347,7 +347,7 @@ func startInProcess(ctx *Context, clientCtx client.Context, appCreator types.App Retries: config.Rosetta.Retries, Offline: offlineMode, } - conf.WithCodec(clientCtx.InterfaceRegistry, clientCtx.JSONMarshaler.(*codec.ProtoCodec)) + conf.WithCodec(clientCtx.InterfaceRegistry, clientCtx.JSONCodec.(*codec.ProtoCodec)) rosettaSrv, err = rosetta.ServerFromConfig(conf) if err != nil { diff --git a/server/tm_cmds.go b/server/tm_cmds.go index 969d5ae8dd28..4d94422f795a 100644 --- a/server/tm_cmds.go +++ b/server/tm_cmds.go @@ -55,7 +55,7 @@ func ShowValidatorCmd() *cobra.Command { return err } clientCtx := client.GetClientContextFromCmd(cmd) - bz, err := clientCtx.JSONMarshaler.MarshalInterfaceJSON(sdkPK) + bz, err := clientCtx.JSONCodec.MarshalInterfaceJSON(sdkPK) if err != nil { return err } diff --git a/simapp/simd/cmd/genaccounts.go b/simapp/simd/cmd/genaccounts.go index 9c34f3388dca..5c04059b7d2d 100644 --- a/simapp/simd/cmd/genaccounts.go +++ b/simapp/simd/cmd/genaccounts.go @@ -40,7 +40,7 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { clientCtx := client.GetClientContextFromCmd(cmd) - depCdc := clientCtx.JSONMarshaler + depCdc := clientCtx.JSONCodec cdc := depCdc.(codec.Codec) serverCtx := server.GetServerContextFromCmd(cmd) diff --git a/simapp/simd/cmd/genaccounts_test.go b/simapp/simd/cmd/genaccounts_test.go index 34fda7b54aac..a1b0137a1261 100644 --- a/simapp/simd/cmd/genaccounts_test.go +++ b/simapp/simd/cmd/genaccounts_test.go @@ -63,7 +63,7 @@ func TestAddGenesisAccountCmd(t *testing.T) { require.NoError(t, err) serverCtx := server.NewContext(viper.New(), cfg, logger) - clientCtx := client.Context{}.WithJSONMarshaler(appCodec).WithHomeDir(home) + clientCtx := client.Context{}.WithJSONCodec(appCodec).WithHomeDir(home) ctx := context.Background() ctx = context.WithValue(ctx, client.ClientContextKey, &clientCtx) diff --git a/simapp/simd/cmd/root.go b/simapp/simd/cmd/root.go index 2e615eb87f08..2b18ddc7a1a4 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{}. - WithJSONMarshaler(encodingConfig.Marshaler). + WithJSONCodec(encodingConfig.Marshaler). WithInterfaceRegistry(encodingConfig.InterfaceRegistry). WithTxConfig(encodingConfig.TxConfig). WithLegacyAmino(encodingConfig.Amino). diff --git a/simapp/simd/cmd/testnet.go b/simapp/simd/cmd/testnet.go index 99cf09958791..d188253a6324 100644 --- a/simapp/simd/cmd/testnet.go +++ b/simapp/simd/cmd/testnet.go @@ -271,11 +271,11 @@ func initGenFiles( genFiles []string, numValidators int, ) error { - appGenState := mbm.DefaultGenesis(clientCtx.JSONMarshaler) + appGenState := mbm.DefaultGenesis(clientCtx.JSONCodec) // set the accounts in the genesis state var authGenState authtypes.GenesisState - clientCtx.JSONMarshaler.MustUnmarshalJSON(appGenState[authtypes.ModuleName], &authGenState) + clientCtx.JSONCodec.MustUnmarshalJSON(appGenState[authtypes.ModuleName], &authGenState) accounts, err := authtypes.PackAccounts(genAccounts) if err != nil { @@ -283,14 +283,14 @@ func initGenFiles( } authGenState.Accounts = accounts - appGenState[authtypes.ModuleName] = clientCtx.JSONMarshaler.MustMarshalJSON(&authGenState) + appGenState[authtypes.ModuleName] = clientCtx.JSONCodec.MustMarshalJSON(&authGenState) // set the balances in the genesis state var bankGenState banktypes.GenesisState - clientCtx.JSONMarshaler.MustUnmarshalJSON(appGenState[banktypes.ModuleName], &bankGenState) + clientCtx.JSONCodec.MustUnmarshalJSON(appGenState[banktypes.ModuleName], &bankGenState) bankGenState.Balances = genBalances - appGenState[banktypes.ModuleName] = clientCtx.JSONMarshaler.MustMarshalJSON(&bankGenState) + appGenState[banktypes.ModuleName] = clientCtx.JSONCodec.MustMarshalJSON(&bankGenState) appGenStateJSON, err := json.MarshalIndent(appGenState, "", " ") if err != nil { @@ -337,7 +337,7 @@ func collectGenFiles( return err } - nodeAppState, err := genutil.GenAppStateFromConfig(clientCtx.JSONMarshaler, clientCtx.TxConfig, nodeConfig, initCfg, *genDoc, genBalIterator) + nodeAppState, err := genutil.GenAppStateFromConfig(clientCtx.JSONCodec, clientCtx.TxConfig, nodeConfig, initCfg, *genDoc, genBalIterator) if err != nil { return err } diff --git a/testutil/network/network.go b/testutil/network/network.go index edb3d0879dc7..58f08316a407 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -346,7 +346,7 @@ func New(t *testing.T, cfg Config) *Network { WithHomeDir(tmCfg.RootDir). WithChainID(cfg.ChainID). WithInterfaceRegistry(cfg.InterfaceRegistry). - WithJSONMarshaler(cfg.Codec). + WithJSONCodec(cfg.Codec). WithLegacyAmino(cfg.LegacyAmino). WithTxConfig(cfg.TxConfig). WithAccountRetriever(cfg.AccountRetriever) diff --git a/x/auth/client/cli/encode_test.go b/x/auth/client/cli/encode_test.go index 44648758abba..2b0a7ab2e5e4 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). - WithJSONMarshaler(encodingConfig.Marshaler) + WithJSONCodec(encodingConfig.Marshaler) 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). - WithJSONMarshaler(encodingConfig.Marshaler) + WithJSONCodec(encodingConfig.Marshaler) cmd := GetDecodeCommand() _ = testutil.ApplyMockIODiscardOutErr(cmd) diff --git a/x/auth/client/rest/rest_test.go b/x/auth/client/rest/rest_test.go index 4cd99475d6b1..96ff41461af6 100644 --- a/x/auth/client/rest/rest_test.go +++ b/x/auth/client/rest/rest_test.go @@ -258,7 +258,7 @@ func (s *IntegrationTestSuite) TestQueryTxWithServiceMsg() { s.Require().NoError(err) var txRes sdk.TxResponse - s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &txRes)) + s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &txRes)) s.Require().Equal(uint32(0), txRes.Code) s.Require().NoError(s.network.WaitForNextBlock()) @@ -411,7 +411,7 @@ func (s *IntegrationTestSuite) testQueryIBCTx(txRes sdk.TxResponse, cmd *cobra.C s.Require().NoError(err) var getTxRes txtypes.GetTxResponse - s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(grpcJSON, &getTxRes)) + s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(grpcJSON, &getTxRes)) s.Require().Equal(getTxRes.Tx.Body.Memo, "foobar") // generate broadcast only txn. @@ -522,7 +522,7 @@ func (s *IntegrationTestSuite) TestLegacyMultisig() { s.Require().NoError(s.network.WaitForNextBlock()) var txRes sdk.TxResponse - err = val1.ClientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &txRes) + err = val1.ClientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &txRes) s.Require().NoError(err) s.Require().Equal(uint32(0), txRes.Code) diff --git a/x/auth/client/testutil/suite.go b/x/auth/client/testutil/suite.go index 5e449e1f6aee..dfda9f44258e 100644 --- a/x/auth/client/testutil/suite.go +++ b/x/auth/client/testutil/suite.go @@ -169,7 +169,7 @@ func (s *IntegrationTestSuite) TestCLISignAminoJSON() { queryResJSON, err := QueryAccountExec(val1.ClientCtx, val1.Address) require.NoError(err) var account authtypes.AccountI - require.NoError(val1.ClientCtx.JSONMarshaler.UnmarshalInterfaceJSON(queryResJSON.Bytes(), &account)) + require.NoError(val1.ClientCtx.JSONCodec.UnmarshalInterfaceJSON(queryResJSON.Bytes(), &account)) /**** test signature-only ****/ res, err := TxSignExec(val1.ClientCtx, val1.Address, fileUnsigned.Name(), chainFlag, @@ -258,7 +258,7 @@ func (s *IntegrationTestSuite) TestCLIQueryTxCmd() { ) s.Require().NoError(err) var txRes sdk.TxResponse - s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &txRes)) + s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &txRes)) s.Require().NoError(s.network.WaitForNextBlock()) testCases := []struct { @@ -300,7 +300,7 @@ func (s *IntegrationTestSuite) TestCLIQueryTxCmd() { s.Require().NotEqual("internal", err.Error()) } else { var result sdk.TxResponse - s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &result)) + s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &result)) s.Require().NotNil(result.Height) s.Require().Contains(result.RawLog, tc.rawLogContains) } @@ -353,7 +353,7 @@ func (s *IntegrationTestSuite) TestCLISendGenerateSignAndBroadcast() { s.Require().NoError(err) var balRes banktypes.QueryAllBalancesResponse - err = val1.ClientCtx.JSONMarshaler.UnmarshalJSON(resp.Bytes(), &balRes) + err = val1.ClientCtx.JSONCodec.UnmarshalJSON(resp.Bytes(), &balRes) s.Require().NoError(err) startTokens := balRes.Balances.AmountOf(s.cfg.BondDenom) @@ -414,7 +414,7 @@ func (s *IntegrationTestSuite) TestCLISendGenerateSignAndBroadcast() { resp, err = bankcli.QueryBalancesExec(val1.ClientCtx, val1.Address) s.Require().NoError(err) - err = val1.ClientCtx.JSONMarshaler.UnmarshalJSON(resp.Bytes(), &balRes) + err = val1.ClientCtx.JSONCodec.UnmarshalJSON(resp.Bytes(), &balRes) s.Require().NoError(err) s.Require().Equal(startTokens, balRes.Balances.AmountOf(s.cfg.BondDenom)) @@ -437,7 +437,7 @@ func (s *IntegrationTestSuite) TestCLISendGenerateSignAndBroadcast() { resp, err = bankcli.QueryBalancesExec(val1.ClientCtx, account.GetAddress()) s.Require().NoError(err) - err = val1.ClientCtx.JSONMarshaler.UnmarshalJSON(resp.Bytes(), &balRes) + err = val1.ClientCtx.JSONCodec.UnmarshalJSON(resp.Bytes(), &balRes) s.Require().NoError(err) s.Require().Equal(sendTokens.Amount, balRes.Balances.AmountOf(s.cfg.BondDenom)) @@ -445,7 +445,7 @@ func (s *IntegrationTestSuite) TestCLISendGenerateSignAndBroadcast() { resp, err = bankcli.QueryBalancesExec(val1.ClientCtx, val1.Address) s.Require().NoError(err) - err = val1.ClientCtx.JSONMarshaler.UnmarshalJSON(resp.Bytes(), &balRes) + err = val1.ClientCtx.JSONCodec.UnmarshalJSON(resp.Bytes(), &balRes) s.Require().NoError(err) } @@ -554,7 +554,7 @@ func (s *IntegrationTestSuite) TestCLIMultisignSortSignatures() { s.Require().NoError(err) var balRes banktypes.QueryAllBalancesResponse - err = val1.ClientCtx.JSONMarshaler.UnmarshalJSON(resp.Bytes(), &balRes) + err = val1.ClientCtx.JSONCodec.UnmarshalJSON(resp.Bytes(), &balRes) s.Require().NoError(err) intialCoins := balRes.Balances @@ -572,7 +572,7 @@ func (s *IntegrationTestSuite) TestCLIMultisignSortSignatures() { resp, err = bankcli.QueryBalancesExec(val1.ClientCtx, multisigInfo.GetAddress()) s.Require().NoError(err) - err = val1.ClientCtx.JSONMarshaler.UnmarshalJSON(resp.Bytes(), &balRes) + err = val1.ClientCtx.JSONCodec.UnmarshalJSON(resp.Bytes(), &balRes) s.Require().NoError(err) diff, _ := balRes.Balances.SafeSub(intialCoins) s.Require().Equal(sendTokens.Amount, diff.AmountOf(s.cfg.BondDenom)) @@ -650,7 +650,7 @@ func (s *IntegrationTestSuite) TestCLIMultisign() { s.Require().NoError(err) var balRes banktypes.QueryAllBalancesResponse - err = val1.ClientCtx.JSONMarshaler.UnmarshalJSON(resp.Bytes(), &balRes) + err = val1.ClientCtx.JSONCodec.UnmarshalJSON(resp.Bytes(), &balRes) s.Require().NoError(err) s.Require().Equal(sendTokens.Amount, balRes.Balances.AmountOf(s.cfg.BondDenom)) @@ -805,7 +805,7 @@ func (s *IntegrationTestSuite) TestMultisignBatch() { queryResJSON, err := QueryAccountExec(val.ClientCtx, multisigInfo.GetAddress()) s.Require().NoError(err) var account authtypes.AccountI - s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalInterfaceJSON(queryResJSON.Bytes(), &account)) + s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalInterfaceJSON(queryResJSON.Bytes(), &account)) // sign-batch file res, err := TxSignBatchExec(val.ClientCtx, account1.GetAddress(), filename.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--multisig", multisigInfo.GetAddress().String(), fmt.Sprintf("--%s", flags.FlagOffline), fmt.Sprintf("--%s=%s", flags.FlagAccountNumber, fmt.Sprint(account.GetAccountNumber())), fmt.Sprintf("--%s=%s", flags.FlagSequence, fmt.Sprint(account.GetSequence()))) @@ -867,7 +867,7 @@ func (s *IntegrationTestSuite) TestGetAccountCmd() { s.Require().NotEqual("internal", err.Error()) } else { var acc authtypes.AccountI - s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalInterfaceJSON(out.Bytes(), &acc)) + s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalInterfaceJSON(out.Bytes(), &acc)) s.Require().Equal(val.Address, acc.GetAddress()) } }) @@ -884,7 +884,7 @@ func (s *IntegrationTestSuite) TestGetAccountsCmd() { s.Require().NoError(err) var res authtypes.QueryAccountsResponse - s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &res)) + s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &res)) s.Require().NotEmpty(res.Accounts) } @@ -962,7 +962,7 @@ func (s *IntegrationTestSuite) TestQueryParamsCmd() { s.Require().NotEqual("internal", err.Error()) } else { var authParams authtypes.Params - s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &authParams)) + s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &authParams)) s.Require().NotNil(authParams.MaxMemoCharacters) } }) @@ -1009,11 +1009,11 @@ func (s *IntegrationTestSuite) TestTxWithoutPublicKey() { // Note: this method is only used for test purposes! In general, one should // use txBuilder and TxEncoder/TxDecoder to manipulate txs. var tx tx.Tx - err = val1.ClientCtx.JSONMarshaler.UnmarshalJSON(signedTx.Bytes(), &tx) + err = val1.ClientCtx.JSONCodec.UnmarshalJSON(signedTx.Bytes(), &tx) s.Require().NoError(err) tx.AuthInfo.SignerInfos[0].PublicKey = nil // Re-encode the tx again, to another file. - txJSON, err = val1.ClientCtx.JSONMarshaler.MarshalJSON(&tx) + txJSON, err = val1.ClientCtx.JSONCodec.MarshalJSON(&tx) s.Require().NoError(err) signedTxFile := testutil.WriteToNewTempFile(s.T(), string(txJSON)) s.Require().True(strings.Contains(string(txJSON), "\"public_key\":null")) @@ -1023,7 +1023,7 @@ func (s *IntegrationTestSuite) TestTxWithoutPublicKey() { out, err := TxBroadcastExec(val1.ClientCtx, signedTxFile.Name()) s.Require().NoError(err) var res sdk.TxResponse - s.Require().NoError(val1.ClientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &res)) + s.Require().NoError(val1.ClientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &res)) s.Require().NotEqual(0, res.Code) } @@ -1081,14 +1081,14 @@ func (s *IntegrationTestSuite) TestSignWithMultiSignersAminoJSON() { require.NoError(err) var txRes sdk.TxResponse - require.NoError(val0.ClientCtx.JSONMarshaler.UnmarshalJSON(res.Bytes(), &txRes)) + require.NoError(val0.ClientCtx.JSONCodec.UnmarshalJSON(res.Bytes(), &txRes)) require.Equal(uint32(0), txRes.Code) // Make sure the addr1's balance got funded. queryResJSON, err := bankcli.QueryBalancesExec(val0.ClientCtx, addr1) require.NoError(err) var queryRes banktypes.QueryAllBalancesResponse - err = val0.ClientCtx.JSONMarshaler.UnmarshalJSON(queryResJSON.Bytes(), &queryRes) + err = val0.ClientCtx.JSONCodec.UnmarshalJSON(queryResJSON.Bytes(), &queryRes) require.NoError(err) require.Equal(sdk.NewCoins(val0Coin, val1Coin), queryRes.Balances) } diff --git a/x/auth/legacy/v040/migrate_test.go b/x/auth/legacy/v040/migrate_test.go index e24104609547..b6892702db10 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). - WithJSONMarshaler(encodingConfig.Marshaler) + WithJSONCodec(encodingConfig.Marshaler) coins := sdk.NewCoins(sdk.NewInt64Coin("stake", 50)) @@ -241,7 +241,7 @@ func TestMigrate(t *testing.T) { } }` - bz, err := clientCtx.JSONMarshaler.MarshalJSON(migrated) + bz, err := clientCtx.JSONCodec.MarshalJSON(migrated) require.NoError(t, err) // Indent the JSON bz correctly. diff --git a/x/auth/tx/service_test.go b/x/auth/tx/service_test.go index 98b2fbcbe677..6519eed5a341 100644 --- a/x/auth/tx/service_test.go +++ b/x/auth/tx/service_test.go @@ -76,7 +76,7 @@ func (s *IntegrationTestSuite) SetupSuite() { fmt.Sprintf("--%s=foobar", flags.FlagMemo), ) s.Require().NoError(err) - s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &s.txRes)) + s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &s.txRes)) s.Require().Equal(uint32(0), s.txRes.Code) s.Require().NoError(s.network.WaitForNextBlock()) @@ -151,7 +151,7 @@ func (s IntegrationTestSuite) TestSimulateTx_GRPCGateway() { for _, tc := range testCases { s.Run(tc.name, func() { - req, err := val.ClientCtx.JSONMarshaler.MarshalJSON(tc.req) + req, err := val.ClientCtx.JSONCodec.MarshalJSON(tc.req) s.Require().NoError(err) res, err := rest.PostRequest(fmt.Sprintf("%s/cosmos/tx/v1beta1/simulate", val.APIAddress), "application/json", req) s.Require().NoError(err) @@ -159,7 +159,7 @@ func (s IntegrationTestSuite) TestSimulateTx_GRPCGateway() { s.Require().Contains(string(res), tc.expErrMsg) } else { var result tx.SimulateResponse - err = val.ClientCtx.JSONMarshaler.UnmarshalJSON(res, &result) + err = val.ClientCtx.JSONCodec.UnmarshalJSON(res, &result) s.Require().NoError(err) // Check the result and gas used are correct. s.Require().Equal(len(result.GetResult().GetEvents()), 6) // 1 coin recv, 1 coin spent,1 transfer, 3 messages. @@ -313,7 +313,7 @@ func (s IntegrationTestSuite) TestGetTxEvents_GRPCGateway() { s.Require().Contains(string(res), tc.expErrMsg) } else { var result tx.GetTxsEventResponse - err = val.ClientCtx.JSONMarshaler.UnmarshalJSON(res, &result) + err = val.ClientCtx.JSONCodec.UnmarshalJSON(res, &result) s.Require().NoError(err) s.Require().GreaterOrEqual(len(result.Txs), 1) s.Require().Equal("foobar", result.Txs[0].Body.Memo) @@ -382,7 +382,7 @@ func (s IntegrationTestSuite) TestGetTx_GRPCGateway() { s.Require().Contains(string(res), tc.expErrMsg) } else { var result tx.GetTxResponse - err = val.ClientCtx.JSONMarshaler.UnmarshalJSON(res, &result) + err = val.ClientCtx.JSONCodec.UnmarshalJSON(res, &result) s.Require().NoError(err) s.Require().Equal("foobar", result.Tx.Body.Memo) s.Require().NotZero(result.TxResponse.Height) @@ -459,7 +459,7 @@ func (s IntegrationTestSuite) TestBroadcastTx_GRPCGateway() { for _, tc := range testCases { s.Run(tc.name, func() { - req, err := val.ClientCtx.JSONMarshaler.MarshalJSON(tc.req) + req, err := val.ClientCtx.JSONCodec.MarshalJSON(tc.req) s.Require().NoError(err) res, err := rest.PostRequest(fmt.Sprintf("%s/cosmos/tx/v1beta1/txs", val.APIAddress), "application/json", req) s.Require().NoError(err) @@ -467,7 +467,7 @@ func (s IntegrationTestSuite) TestBroadcastTx_GRPCGateway() { s.Require().Contains(string(res), tc.expErrMsg) } else { var result tx.BroadcastTxResponse - err = val.ClientCtx.JSONMarshaler.UnmarshalJSON(res, &result) + err = val.ClientCtx.JSONCodec.UnmarshalJSON(res, &result) s.Require().NoError(err) s.Require().Equal(uint32(0), result.TxResponse.Code, "rawlog", result.TxResponse.RawLog) } diff --git a/x/auth/vesting/client/testutil/suite.go b/x/auth/vesting/client/testutil/suite.go index e538f73a62d9..1d41e136d076 100644 --- a/x/auth/vesting/client/testutil/suite.go +++ b/x/auth/vesting/client/testutil/suite.go @@ -122,7 +122,7 @@ func (s *IntegrationTestSuite) TestNewMsgCreateVestingAccountCmd() { s.Require().Error(err) } else { s.Require().NoError(err) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(bw.Bytes(), tc.respType), bw.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(bw.Bytes(), tc.respType), bw.String()) txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code) diff --git a/x/authz/client/rest/grpc_query_test.go b/x/authz/client/rest/grpc_query_test.go index a94c65d6366f..698bd359bea1 100644 --- a/x/authz/client/rest/grpc_query_test.go +++ b/x/authz/client/rest/grpc_query_test.go @@ -138,7 +138,7 @@ func (s *IntegrationTestSuite) TestQueryAuthorizationGRPC() { s.Require().Contains(string(resp), tc.errorMsg) } else { var authorization types.QueryAuthorizationResponse - err := val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, &authorization) + err := val.ClientCtx.JSONCodec.UnmarshalJSON(resp, &authorization) s.Require().NoError(err) authorization.Authorization.UnpackInterfaces(val.ClientCtx.InterfaceRegistry) auth := authorization.Authorization.GetAuthorizationGrant() @@ -245,7 +245,7 @@ func (s *IntegrationTestSuite) TestQueryAuthorizationsGRPC() { s.Require().Contains(string(resp), tc.errMsg) } else { var authorizations types.QueryAuthorizationsResponse - err := val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, &authorizations) + err := val.ClientCtx.JSONCodec.UnmarshalJSON(resp, &authorizations) s.Require().NoError(err) tc.postRun(&authorizations) } diff --git a/x/authz/client/testutil/query.go b/x/authz/client/testutil/query.go index 6079bcacb0b8..a193760c27ef 100644 --- a/x/authz/client/testutil/query.go +++ b/x/authz/client/testutil/query.go @@ -86,7 +86,7 @@ func (s *IntegrationTestSuite) TestQueryAuthorizations() { } else { s.Require().NoError(err) var grants types.QueryAuthorizationsResponse - err = val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp.Bytes(), &grants) + err = val.ClientCtx.JSONCodec.UnmarshalJSON(resp.Bytes(), &grants) s.Require().NoError(err) } }) diff --git a/x/authz/client/testutil/tx.go b/x/authz/client/testutil/tx.go index 3b50074219b5..494def184b02 100644 --- a/x/authz/client/testutil/tx.go +++ b/x/authz/client/testutil/tx.go @@ -273,7 +273,7 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() { } else { var txResp sdk.TxResponse s.Require().NoError(err) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &txResp), out.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &txResp), out.String()) s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) } }) @@ -393,7 +393,7 @@ func (s *IntegrationTestSuite) TestCmdRevokeAuthorizations() { s.Require().Error(err) } else { s.Require().NoError(err) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) @@ -523,7 +523,7 @@ func (s *IntegrationTestSuite) TestNewExecGenericAuthorized() { s.Require().Error(err) } else { s.Require().NoError(err) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) } @@ -609,7 +609,7 @@ func (s *IntegrationTestSuite) TestNewExecGrantAuthorized() { } else { var response sdk.TxResponse s.Require().NoError(err) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &response), out.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &response), out.String()) s.Require().Equal(tc.expectedCode, response.Code, out.String()) } }) @@ -706,7 +706,7 @@ func (s *IntegrationTestSuite) TestExecDelegateAuthorization() { } else { var response sdk.TxResponse s.Require().NoError(err) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &response), out.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &response), out.String()) s.Require().Equal(tc.expectedCode, response.Code, out.String()) } }) @@ -783,7 +783,7 @@ func (s *IntegrationTestSuite) TestExecDelegateAuthorization() { } else { var response sdk.TxResponse s.Require().NoError(err) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &response), out.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &response), out.String()) s.Require().Equal(tc.expectedCode, response.Code, out.String()) } }) @@ -924,7 +924,7 @@ func (s *IntegrationTestSuite) TestExecUndelegateAuthorization() { } else { var response sdk.TxResponse s.Require().NoError(err) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &response), out.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &response), out.String()) s.Require().Equal(tc.expectedCode, response.Code, out.String()) } }) @@ -1001,7 +1001,7 @@ func (s *IntegrationTestSuite) TestExecUndelegateAuthorization() { } else { var response sdk.TxResponse s.Require().NoError(err) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &response), out.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &response), out.String()) s.Require().Equal(tc.expectedCode, response.Code, out.String()) } }) diff --git a/x/bank/client/rest/grpc_query_test.go b/x/bank/client/rest/grpc_query_test.go index b32b9386d514..a770919b17ea 100644 --- a/x/bank/client/rest/grpc_query_test.go +++ b/x/bank/client/rest/grpc_query_test.go @@ -95,7 +95,7 @@ func (s *IntegrationTestSuite) TestTotalSupplyGRPCHandler() { resp, err := testutil.GetRequestWithHeaders(tc.url, tc.headers) s.Require().NoError(err) - s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, tc.respType)) + s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(resp, tc.respType)) s.Require().Equal(tc.expected.String(), tc.respType.String()) }) } @@ -199,9 +199,9 @@ func (s *IntegrationTestSuite) TestDenomMetadataGRPCHandler() { s.Require().NoError(err) if tc.expErr { - s.Require().Error(val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, tc.respType)) + s.Require().Error(val.ClientCtx.JSONCodec.UnmarshalJSON(resp, tc.respType)) } else { - s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, tc.respType)) + s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(resp, tc.respType)) s.Require().Equal(tc.expected.String(), tc.respType.String()) } }) @@ -262,7 +262,7 @@ func (s *IntegrationTestSuite) TestBalancesGRPCHandler() { resp, err := rest.GetRequest(tc.url) s.Require().NoError(err) - s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, tc.respType)) + s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(resp, tc.respType)) s.Require().Equal(tc.expected.String(), tc.respType.String()) }) } diff --git a/x/bank/client/testutil/suite.go b/x/bank/client/testutil/suite.go index 342c780253e0..69892674fe8c 100644 --- a/x/bank/client/testutil/suite.go +++ b/x/bank/client/testutil/suite.go @@ -155,7 +155,7 @@ func (s *IntegrationTestSuite) TestGetBalancesCmd() { s.Require().Error(err) } else { s.Require().NoError(err) - s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType)) + s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType)) s.Require().Equal(tc.expected.String(), tc.respType.String()) } }) @@ -227,7 +227,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryTotalSupply() { s.Require().Error(err) } else { s.Require().NoError(err) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType)) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType)) s.Require().Equal(tc.expected, tc.respType) } }) @@ -354,7 +354,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryDenomsMetadata() { s.Require().Error(err) } else { s.Require().NoError(err) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType)) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType)) s.Require().Equal(tc.expected, tc.respType) } }) @@ -462,7 +462,7 @@ func (s *IntegrationTestSuite) TestNewSendTxCmd() { } else { s.Require().NoError(err) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(bz.Bytes(), tc.respType), bz.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(bz.Bytes(), tc.respType), bz.String()) txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code) } diff --git a/x/bank/legacy/v040/migrate_test.go b/x/bank/legacy/v040/migrate_test.go index 9b458e120992..9f1874f8c957 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). - WithJSONMarshaler(encodingConfig.Marshaler) + WithJSONCodec(encodingConfig.Marshaler) coins := sdk.NewCoins(sdk.NewInt64Coin("stake", 50)) addr1, _ := sdk.AccAddressFromBech32("cosmos1xxkueklal9vejv9unqu80w9vptyepfa95pd53u") @@ -50,7 +50,7 @@ func TestMigrate(t *testing.T) { migrated := v040bank.Migrate(bankGenState, authGenState, supplyGenState) expected := `{"params":{"send_enabled":[],"default_send_enabled":true},"balances":[{"address":"cosmos1xxkueklal9vejv9unqu80w9vptyepfa95pd53u","coins":[{"denom":"stake","amount":"50"}]},{"address":"cosmos15v50ymp6n5dn73erkqtmq0u8adpl8d3ujv2e74","coins":[{"denom":"stake","amount":"50"}]}],"supply":[{"denom":"stake","amount":"1000"}],"denom_metadata":[]}` - bz, err := clientCtx.JSONMarshaler.MarshalJSON(migrated) + bz, err := clientCtx.JSONCodec.MarshalJSON(migrated) require.NoError(t, err) require.Equal(t, expected, string(bz)) } diff --git a/x/crisis/client/testsuite/suite.go b/x/crisis/client/testsuite/suite.go index 1b6907e834cf..c38ff8fe170e 100644 --- a/x/crisis/client/testsuite/suite.go +++ b/x/crisis/client/testsuite/suite.go @@ -94,7 +94,7 @@ func (s *IntegrationTestSuite) TestNewMsgVerifyInvariantTxCmd() { s.Require().Error(err) } else { s.Require().NoError(err) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code) diff --git a/x/distribution/client/cli/tx.go b/x/distribution/client/cli/tx.go index 6237bf92ef5e..e18b8d29e33e 100644 --- a/x/distribution/client/cli/tx.go +++ b/x/distribution/client/cli/tx.go @@ -306,7 +306,7 @@ Where proposal.json contains: if err != nil { return err } - proposal, err := ParseCommunityPoolSpendProposalWithDeposit(clientCtx.JSONMarshaler, args[0]) + proposal, err := ParseCommunityPoolSpendProposalWithDeposit(clientCtx.JSONCodec, args[0]) if err != nil { return err } diff --git a/x/distribution/client/rest/grpc_query_test.go b/x/distribution/client/rest/grpc_query_test.go index 639c7cb7d850..393b5da76e0b 100644 --- a/x/distribution/client/rest/grpc_query_test.go +++ b/x/distribution/client/rest/grpc_query_test.go @@ -61,7 +61,7 @@ func (s *IntegrationTestSuite) TestQueryParamsGRPC() { resp, err := rest.GetRequest(tc.url) s.Run(tc.name, func() { s.Require().NoError(err) - s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, tc.respType)) + s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(resp, tc.respType)) s.Require().Equal(tc.expected, tc.respType) }) } @@ -111,10 +111,10 @@ func (s *IntegrationTestSuite) TestQueryOutstandingRewardsGRPC() { resp, err := testutil.GetRequestWithHeaders(tc.url, tc.headers) s.Run(tc.name, func() { if tc.expErr { - s.Require().Error(val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, tc.respType)) + s.Require().Error(val.ClientCtx.JSONCodec.UnmarshalJSON(resp, tc.respType)) } else { s.Require().NoError(err) - s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, tc.respType)) + s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(resp, tc.respType)) s.Require().Equal(tc.expected.String(), tc.respType.String()) } }) @@ -165,10 +165,10 @@ func (s *IntegrationTestSuite) TestQueryValidatorCommissionGRPC() { resp, err := testutil.GetRequestWithHeaders(tc.url, tc.headers) s.Run(tc.name, func() { if tc.expErr { - s.Require().Error(val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, tc.respType)) + s.Require().Error(val.ClientCtx.JSONCodec.UnmarshalJSON(resp, tc.respType)) } else { s.Require().NoError(err) - s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, tc.respType)) + s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(resp, tc.respType)) s.Require().Equal(tc.expected.String(), tc.respType.String()) } }) @@ -224,10 +224,10 @@ func (s *IntegrationTestSuite) TestQuerySlashesGRPC() { s.Run(tc.name, func() { if tc.expErr { - s.Require().Error(val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, tc.respType)) + s.Require().Error(val.ClientCtx.JSONCodec.UnmarshalJSON(resp, tc.respType)) } else { s.Require().NoError(err) - s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, tc.respType)) + s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(resp, tc.respType)) s.Require().Equal(tc.expected.String(), tc.respType.String()) } }) @@ -300,10 +300,10 @@ func (s *IntegrationTestSuite) TestQueryDelegatorRewardsGRPC() { s.Run(tc.name, func() { if tc.expErr { - s.Require().Error(val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, tc.respType)) + s.Require().Error(val.ClientCtx.JSONCodec.UnmarshalJSON(resp, tc.respType)) } else { s.Require().NoError(err) - s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, tc.respType)) + s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(resp, tc.respType)) s.Require().Equal(tc.expected.String(), tc.respType.String()) } }) @@ -352,10 +352,10 @@ func (s *IntegrationTestSuite) TestQueryDelegatorValidatorsGRPC() { s.Run(tc.name, func() { if tc.expErr { - s.Require().Error(val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, tc.respType)) + s.Require().Error(val.ClientCtx.JSONCodec.UnmarshalJSON(resp, tc.respType)) } else { s.Require().NoError(err) - s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, tc.respType)) + s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(resp, tc.respType)) s.Require().Equal(tc.expected.String(), tc.respType.String()) } }) @@ -404,10 +404,10 @@ func (s *IntegrationTestSuite) TestQueryWithdrawAddressGRPC() { s.Run(tc.name, func() { if tc.expErr { - s.Require().Error(val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, tc.respType)) + s.Require().Error(val.ClientCtx.JSONCodec.UnmarshalJSON(resp, tc.respType)) } else { s.Require().NoError(err) - s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, tc.respType)) + s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(resp, tc.respType)) s.Require().Equal(tc.expected.String(), tc.respType.String()) } }) @@ -452,7 +452,7 @@ func (s *IntegrationTestSuite) TestQueryValidatorCommunityPoolGRPC() { s.Require().Error(err) } else { s.Require().NoError(err) - s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, tc.respType)) + s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(resp, tc.respType)) s.Require().Equal(tc.expected.String(), tc.respType.String()) } }) diff --git a/x/distribution/client/testutil/suite.go b/x/distribution/client/testutil/suite.go index 603b8b6a2344..91c24a43029a 100644 --- a/x/distribution/client/testutil/suite.go +++ b/x/distribution/client/testutil/suite.go @@ -502,7 +502,7 @@ func (s *IntegrationTestSuite) TestNewWithdrawRewardsCmd() { s.Require().Error(err) } else { s.Require().NoError(err) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(bz, tc.respType), string(bz)) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(bz, tc.respType), string(bz)) txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code) @@ -555,7 +555,7 @@ func (s *IntegrationTestSuite) TestNewWithdrawAllRewardsCmd() { s.Require().Error(err) } else { s.Require().NoError(err) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code) @@ -610,7 +610,7 @@ func (s *IntegrationTestSuite) TestNewSetWithdrawAddrCmd() { s.Require().Error(err) } else { s.Require().NoError(err) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code) @@ -665,7 +665,7 @@ func (s *IntegrationTestSuite) TestNewFundCommunityPoolCmd() { s.Require().Error(err) } else { s.Require().NoError(err) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code) @@ -739,7 +739,7 @@ func (s *IntegrationTestSuite) TestGetCmdSubmitProposal() { s.Require().Error(err) } else { s.Require().NoError(err) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) diff --git a/x/evidence/client/rest/query.go b/x/evidence/client/rest/query.go index 21ae8b7bb306..4ce8e22e08ed 100644 --- a/x/evidence/client/rest/query.go +++ b/x/evidence/client/rest/query.go @@ -47,7 +47,7 @@ func queryEvidenceHandler(clientCtx client.Context) http.HandlerFunc { } params := types.NewQueryEvidenceRequest(decodedHash) - bz, err := clientCtx.JSONMarshaler.MarshalJSON(params) + bz, err := clientCtx.JSONCodec.MarshalJSON(params) if err != nil { rest.WriteErrorResponse(w, http.StatusBadRequest, fmt.Sprintf("failed to marshal query params: %s", err)) return diff --git a/x/evidence/legacy/v040/migrate_test.go b/x/evidence/legacy/v040/migrate_test.go index 99260f026851..0ad7fe3e5680 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). - WithJSONMarshaler(encodingConfig.Marshaler) + WithJSONCodec(encodingConfig.Marshaler) addr1, _ := sdk.AccAddressFromBech32("cosmos1xxkueklal9vejv9unqu80w9vptyepfa95pd53u") @@ -34,7 +34,7 @@ func TestMigrate(t *testing.T) { migrated := v040evidence.Migrate(evidenceGenState) expected := `{"evidence":[{"@type":"/cosmos.evidence.v1beta1.Equivocation","height":"20","time":"0001-01-01T00:00:00Z","power":"100","consensus_address":"cosmosvalcons1xxkueklal9vejv9unqu80w9vptyepfa99x2a3w"}]}` - bz, err := clientCtx.JSONMarshaler.MarshalJSON(migrated) + bz, err := clientCtx.JSONCodec.MarshalJSON(migrated) require.NoError(t, err) require.Equal(t, expected, string(bz)) } diff --git a/x/feegrant/client/testutil/suite.go b/x/feegrant/client/testutil/suite.go index 44fb76761ca4..fa7682b49c66 100644 --- a/x/feegrant/client/testutil/suite.go +++ b/x/feegrant/client/testutil/suite.go @@ -172,7 +172,7 @@ func (s *IntegrationTestSuite) TestCmdGetFeeGrant() { s.Require().Contains(err.Error(), tc.expectErrMsg) } else { s.Require().NoError(err) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) s.Require().Equal(tc.respType.Grantee, tc.respType.Grantee) s.Require().Equal(tc.respType.Granter, tc.respType.Granter) grant, err := tc.respType.GetGrant() @@ -237,7 +237,7 @@ func (s *IntegrationTestSuite) TestCmdGetFeeGrants() { s.Require().Error(err) } else { s.Require().NoError(err) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.resp), out.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.resp), out.String()) s.Require().Len(tc.resp.Allowances, tc.expectLength) } }) @@ -486,7 +486,7 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { s.Require().Error(err) } else { s.Require().NoError(err) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) @@ -575,7 +575,7 @@ func (s *IntegrationTestSuite) TestNewCmdRevokeFeegrant() { s.Require().Error(err) } else { s.Require().NoError(err) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) @@ -629,7 +629,7 @@ func (s *IntegrationTestSuite) TestTxWithFeeGrant() { s.Require().NoError(err) var resp sdk.TxResponse - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &resp), out.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &resp), out.String()) s.Require().Equal(uint32(0), resp.Code) } @@ -714,7 +714,7 @@ func (s *IntegrationTestSuite) TestFilteredFeeAllowance() { s.Require().Error(err) } else { s.Require().NoError(err) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) @@ -735,7 +735,7 @@ func (s *IntegrationTestSuite) TestFilteredFeeAllowance() { resp := &types.Grant{} - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), resp), out.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), resp), out.String()) s.Require().Equal(resp.Grantee, resp.Grantee) s.Require().Equal(resp.Granter, resp.Granter) @@ -804,7 +804,7 @@ func (s *IntegrationTestSuite) TestFilteredFeeAllowance() { s.Run(tc.name, func() { out, err := tc.malleate() s.Require().NoError(err) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) }) diff --git a/x/genutil/client/cli/collect.go b/x/genutil/client/cli/collect.go index cc862583680c..4e3cc1e6a9db 100644 --- a/x/genutil/client/cli/collect.go +++ b/x/genutil/client/cli/collect.go @@ -27,7 +27,7 @@ func CollectGenTxsCmd(genBalIterator types.GenesisBalancesIterator, defaultNodeH config := serverCtx.Config clientCtx := client.GetClientContextFromCmd(cmd) - cdc := clientCtx.JSONMarshaler + cdc := clientCtx.JSONCodec config.SetRoot(clientCtx.HomeDir) diff --git a/x/genutil/client/cli/gentx.go b/x/genutil/client/cli/gentx.go index c7f05a30a6a0..107990ed1182 100644 --- a/x/genutil/client/cli/gentx.go +++ b/x/genutil/client/cli/gentx.go @@ -61,7 +61,7 @@ $ %s gentx my-key-name 1000000stake --home=/path/to/home/dir --keyring-backend=o if err != nil { return err } - cdc := clientCtx.JSONMarshaler + cdc := clientCtx.JSONCodec config := serverCtx.Config config.SetRoot(clientCtx.HomeDir) @@ -78,7 +78,7 @@ $ %s gentx my-key-name 1000000stake --home=/path/to/home/dir --keyring-backend=o // read --pubkey, if empty take it from priv_validator.json if val, _ := cmd.Flags().GetString(cli.FlagPubKey); val != "" { - err = clientCtx.JSONMarshaler.UnmarshalJSON([]byte(val), valPubKey) + err = clientCtx.JSONCodec.UnmarshalJSON([]byte(val), valPubKey) if err != nil { return errors.Wrap(err, "failed to unmarshal consensus node public key") } diff --git a/x/genutil/client/cli/init.go b/x/genutil/client/cli/init.go index f5fda79c69f0..84a03c877dab 100644 --- a/x/genutil/client/cli/init.go +++ b/x/genutil/client/cli/init.go @@ -72,7 +72,7 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command { Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx := client.GetClientContextFromCmd(cmd) - cdc := clientCtx.JSONMarshaler + cdc := clientCtx.JSONCodec serverCtx := server.GetServerContextFromCmd(cmd) config := serverCtx.Config diff --git a/x/genutil/client/cli/init_test.go b/x/genutil/client/cli/init_test.go index 80820052dfa1..37bbd7597a7c 100644 --- a/x/genutil/client/cli/init_test.go +++ b/x/genutil/client/cli/init_test.go @@ -63,7 +63,7 @@ func TestInitCmd(t *testing.T) { interfaceRegistry := types.NewInterfaceRegistry() marshaler := codec.NewProtoCodec(interfaceRegistry) clientCtx := client.Context{}. - WithJSONMarshaler(marshaler). + WithJSONCodec(marshaler). WithLegacyAmino(makeCodec()). WithHomeDir(home) @@ -97,7 +97,7 @@ func TestInitRecover(t *testing.T) { interfaceRegistry := types.NewInterfaceRegistry() marshaler := codec.NewProtoCodec(interfaceRegistry) clientCtx := client.Context{}. - WithJSONMarshaler(marshaler). + WithJSONCodec(marshaler). WithLegacyAmino(makeCodec()). WithHomeDir(home) @@ -128,7 +128,7 @@ func TestEmptyState(t *testing.T) { interfaceRegistry := types.NewInterfaceRegistry() marshaler := codec.NewProtoCodec(interfaceRegistry) clientCtx := client.Context{}. - WithJSONMarshaler(marshaler). + WithJSONCodec(marshaler). WithLegacyAmino(makeCodec()). WithHomeDir(home) diff --git a/x/genutil/client/cli/validate_genesis.go b/x/genutil/client/cli/validate_genesis.go index 0514cc66fd2f..30102277d670 100644 --- a/x/genutil/client/cli/validate_genesis.go +++ b/x/genutil/client/cli/validate_genesis.go @@ -24,7 +24,7 @@ func ValidateGenesisCmd(mbm module.BasicManager) *cobra.Command { serverCtx := server.GetServerContextFromCmd(cmd) clientCtx := client.GetClientContextFromCmd(cmd) - cdc := clientCtx.JSONMarshaler + cdc := clientCtx.JSONCodec // Load default if passed no args, otherwise load passed file var genesis string diff --git a/x/genutil/client/rest/query.go b/x/genutil/client/rest/query.go index dddd2b75a558..025f3a21d8d3 100644 --- a/x/genutil/client/rest/query.go +++ b/x/genutil/client/rest/query.go @@ -32,7 +32,7 @@ func QueryGenesisTxs(clientCtx client.Context, w http.ResponseWriter) { return } - genState := types.GetGenesisStateFromAppState(clientCtx.JSONMarshaler, appState) + genState := types.GetGenesisStateFromAppState(clientCtx.JSONCodec, appState) genTxs := make([]sdk.Tx, len(genState.GenTxs)) for i, tx := range genState.GenTxs { err := clientCtx.LegacyAmino.UnmarshalJSON(tx, &genTxs[i]) diff --git a/x/genutil/client/testutil/helpers.go b/x/genutil/client/testutil/helpers.go index ec9331e9b1a6..1a5229f3733d 100644 --- a/x/genutil/client/testutil/helpers.go +++ b/x/genutil/client/testutil/helpers.go @@ -26,7 +26,7 @@ func ExecInitCmd(testMbm module.BasicManager, home string, cdc codec.JSONCodec) cmd := genutilcli.InitCmd(testMbm, home) serverCtx := server.NewContext(viper.New(), cfg, logger) - clientCtx := client.Context{}.WithJSONMarshaler(cdc).WithHomeDir(home) + clientCtx := client.Context{}.WithJSONCodec(cdc).WithHomeDir(home) _, out := testutil.ApplyMockIO(cmd) clientCtx = clientCtx.WithOutput(out) diff --git a/x/genutil/legacy/v040/migrate.go b/x/genutil/legacy/v040/migrate.go index eb5d10690a26..3f1896cd1d49 100644 --- a/x/genutil/legacy/v040/migrate.go +++ b/x/genutil/legacy/v040/migrate.go @@ -44,7 +44,7 @@ func Migrate(appState types.AppMap, clientCtx client.Context) types.AppMap { v036params.RegisterLegacyAminoCodec(v039Codec) v038upgrade.RegisterLegacyAminoCodec(v039Codec) - v040Codec := clientCtx.JSONMarshaler + v040Codec := clientCtx.JSONCodec if appState[v038bank.ModuleName] != nil { // unmarshal relative source genesis application state diff --git a/x/genutil/legacy/v043/migrate.go b/x/genutil/legacy/v043/migrate.go index 8b6a00529252..c5fd884863c4 100644 --- a/x/genutil/legacy/v043/migrate.go +++ b/x/genutil/legacy/v043/migrate.go @@ -13,14 +13,14 @@ func Migrate(appState types.AppMap, clientCtx client.Context) types.AppMap { if appState[v040gov.ModuleName] != nil { // unmarshal relative source genesis application state var oldGovState v040gov.GenesisState - clientCtx.JSONMarshaler.MustUnmarshalJSON(appState[v040gov.ModuleName], &oldGovState) + clientCtx.JSONCodec.MustUnmarshalJSON(appState[v040gov.ModuleName], &oldGovState) // delete deprecated x/gov genesis state delete(appState, v040gov.ModuleName) // Migrate relative source genesis application state and marshal it into // the respective key. - appState[v043gov.ModuleName] = clientCtx.JSONMarshaler.MustMarshalJSON(v043gov.MigrateJSON(&oldGovState)) + appState[v043gov.ModuleName] = clientCtx.JSONCodec.MustMarshalJSON(v043gov.MigrateJSON(&oldGovState)) } return appState diff --git a/x/gov/client/cli/query.go b/x/gov/client/cli/query.go index b382f540e26b..68e1347c0b02 100644 --- a/x/gov/client/cli/query.go +++ b/x/gov/client/cli/query.go @@ -238,7 +238,7 @@ $ %s query gov vote 1 cosmos1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39lk return err } - if err := clientCtx.JSONMarshaler.UnmarshalJSON(resByTxQuery, &vote); err != nil { + if err := clientCtx.JSONCodec.UnmarshalJSON(resByTxQuery, &vote); err != nil { return err } } @@ -303,7 +303,7 @@ $ %[1]s query gov votes 1 --page=2 --limit=100 } var votes types.Votes - // TODO migrate to use JSONMarshaler (implement MarshalJSONArray + // TODO migrate to use JSONCodec (implement MarshalJSONArray // or wrap lists of proto.Message in some other message) clientCtx.LegacyAmino.MustUnmarshalJSON(resByTxQuery, &votes) return clientCtx.PrintObjectLegacy(votes) @@ -394,7 +394,7 @@ $ %s query gov deposit 1 cosmos1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39lk if err != nil { return err } - clientCtx.JSONMarshaler.MustUnmarshalJSON(resByTxQuery, &deposit) + clientCtx.JSONCodec.MustUnmarshalJSON(resByTxQuery, &deposit) } return clientCtx.PrintProto(&deposit) @@ -454,7 +454,7 @@ $ %s query gov deposits 1 } var dep types.Deposits - // TODO migrate to use JSONMarshaler (implement MarshalJSONArray + // TODO migrate to use JSONCodec (implement MarshalJSONArray // or wrap lists of proto.Message in some other message) clientCtx.LegacyAmino.MustUnmarshalJSON(resByTxQuery, &dep) diff --git a/x/gov/client/rest/grpc_query_test.go b/x/gov/client/rest/grpc_query_test.go index 57e0d8f2b782..ecbf0c5915a1 100644 --- a/x/gov/client/rest/grpc_query_test.go +++ b/x/gov/client/rest/grpc_query_test.go @@ -103,7 +103,7 @@ func (s *IntegrationTestSuite) TestGetProposalGRPC() { s.Require().NoError(err) var proposal types.QueryProposalResponse - err = val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, &proposal) + err = val.ClientCtx.JSONCodec.UnmarshalJSON(resp, &proposal) if tc.expErr { s.Require().Error(err) @@ -157,7 +157,7 @@ func (s *IntegrationTestSuite) TestGetProposalsGRPC() { s.Require().NoError(err) var proposals types.QueryProposalsResponse - err = val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, &proposals) + err = val.ClientCtx.JSONCodec.UnmarshalJSON(resp, &proposals) if tc.expErr { s.Require().Empty(proposals.Proposals) @@ -224,7 +224,7 @@ func (s *IntegrationTestSuite) TestGetProposalVoteGRPC() { s.Require().NoError(err) var vote types.QueryVoteResponse - err = val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, &vote) + err = val.ClientCtx.JSONCodec.UnmarshalJSON(resp, &vote) if tc.expErr { s.Require().Error(err) @@ -268,7 +268,7 @@ func (s *IntegrationTestSuite) TestGetProposalVotesGRPC() { s.Require().NoError(err) var votes types.QueryVotesResponse - err = val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, &votes) + err = val.ClientCtx.JSONCodec.UnmarshalJSON(resp, &votes) if tc.expErr { s.Require().Error(err) @@ -317,7 +317,7 @@ func (s *IntegrationTestSuite) TestGetProposalDepositGRPC() { s.Require().NoError(err) var deposit types.QueryDepositResponse - err = val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, &deposit) + err = val.ClientCtx.JSONCodec.UnmarshalJSON(resp, &deposit) if tc.expErr { s.Require().Error(err) @@ -356,7 +356,7 @@ func (s *IntegrationTestSuite) TestGetProposalDepositsGRPC() { s.Require().NoError(err) var deposits types.QueryDepositsResponse - err = val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, &deposits) + err = val.ClientCtx.JSONCodec.UnmarshalJSON(resp, &deposits) if tc.expErr { s.Require().Error(err) @@ -401,7 +401,7 @@ func (s *IntegrationTestSuite) TestGetTallyGRPC() { s.Require().NoError(err) var tally types.QueryTallyResultResponse - err = val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, &tally) + err = val.ClientCtx.JSONCodec.UnmarshalJSON(resp, &tally) if tc.expErr { s.Require().Error(err) @@ -463,7 +463,7 @@ func (s *IntegrationTestSuite) TestGetParamsGRPC() { resp, err := rest.GetRequest(tc.url) s.Require().NoError(err) - err = val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, tc.respType) + err = val.ClientCtx.JSONCodec.UnmarshalJSON(resp, tc.respType) if tc.expErr { s.Require().Error(err) diff --git a/x/gov/client/testutil/suite.go b/x/gov/client/testutil/suite.go index 2bc14f0f427b..bcb0f823a2ee 100644 --- a/x/gov/client/testutil/suite.go +++ b/x/gov/client/testutil/suite.go @@ -266,7 +266,7 @@ func (s *IntegrationTestSuite) TestCmdTally() { s.Require().Error(err) } else { var tally types.TallyResult - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &tally), out.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &tally), out.String()) s.Require().Equal(tally, tc.expectedOutput) } }) @@ -357,7 +357,7 @@ func (s *IntegrationTestSuite) TestNewCmdSubmitProposal() { s.Require().Error(err) } else { s.Require().NoError(err) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) } @@ -406,7 +406,7 @@ func (s *IntegrationTestSuite) TestCmdGetProposal() { } else { s.Require().NoError(err) var proposal types.Proposal - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &proposal), out.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &proposal), out.String()) s.Require().Equal(title, proposal.GetTitle()) } }) @@ -452,7 +452,7 @@ func (s *IntegrationTestSuite) TestCmdGetProposals() { s.Require().NoError(err) var proposals types.QueryProposalsResponse - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &proposals), out.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &proposals), out.String()) s.Require().Len(proposals.Proposals, 3) } }) @@ -498,7 +498,7 @@ func (s *IntegrationTestSuite) TestCmdQueryDeposits() { s.Require().NoError(err) var deposits types.QueryDepositsResponse - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &deposits), out.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &deposits), out.String()) s.Require().Len(deposits.Deposits, 1) } }) @@ -554,7 +554,7 @@ func (s *IntegrationTestSuite) TestCmdQueryDeposit() { s.Require().NoError(err) var deposit types.Deposit - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &deposit), out.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &deposit), out.String()) s.Require().Equal(depositAmount.String(), deposit.Amount.String()) } }) @@ -632,7 +632,7 @@ func (s *IntegrationTestSuite) TestNewCmdDeposit() { } else { s.Require().NoError(err) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &resp), out.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &resp), out.String()) s.Require().Equal(tc.expectedCode, resp.Code, out.String()) } }) @@ -683,7 +683,7 @@ func (s *IntegrationTestSuite) TestCmdQueryVotes() { s.Require().NoError(err) var votes types.QueryVotesResponse - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &votes), out.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &votes), out.String()) s.Require().Len(votes.Votes, 1) } }) @@ -758,7 +758,7 @@ func (s *IntegrationTestSuite) TestCmdQueryVote() { s.Require().NoError(err) var vote types.Vote - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &vote), out.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &vote), out.String()) s.Require().Equal(len(vote.Options), len(tc.expVoteOptions)) for i, option := range tc.expVoteOptions { s.Require().Equal(option.Option, vote.Options[i].Option) @@ -822,7 +822,7 @@ func (s *IntegrationTestSuite) TestNewCmdVote() { s.Require().Error(err) } else { s.Require().NoError(err) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &txResp), out.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &txResp), out.String()) s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) } }) @@ -906,7 +906,7 @@ func (s *IntegrationTestSuite) TestNewCmdWeightedVote() { s.Require().Error(err) } else { s.Require().NoError(err) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &txResp), out.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &txResp), out.String()) s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) } }) diff --git a/x/gov/client/utils/query.go b/x/gov/client/utils/query.go index c0734c0ff1dd..0538cfc72d65 100644 --- a/x/gov/client/utils/query.go +++ b/x/gov/client/utils/query.go @@ -210,7 +210,7 @@ func QueryVoteByTxQuery(clientCtx client.Context, params types.QueryVoteParams) } if vote != nil { - bz, err := clientCtx.JSONMarshaler.MarshalJSON(vote) + bz, err := clientCtx.JSONCodec.MarshalJSON(vote) if err != nil { return nil, err } @@ -255,7 +255,7 @@ func QueryDepositByTxQuery(clientCtx client.Context, params types.QueryDepositPa Amount: depMsg.Amount, } - bz, err := clientCtx.JSONMarshaler.MarshalJSON(&deposit) + bz, err := clientCtx.JSONCodec.MarshalJSON(&deposit) if err != nil { return nil, err } diff --git a/x/gov/legacy/v040/migrate_test.go b/x/gov/legacy/v040/migrate_test.go index 51604809abb7..ab66a1b14254 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). - WithJSONMarshaler(encodingConfig.Marshaler) + WithJSONCodec(encodingConfig.Marshaler) recipient, err := sdk.AccAddressFromBech32("cosmos1fl48vsnmsdzcv85q5d2q4z5ajdha8yu34mf0eh") require.NoError(t, err) @@ -78,7 +78,7 @@ func TestMigrate(t *testing.T) { migrated := v040gov.Migrate(govGenState) - bz, err := clientCtx.JSONMarshaler.MarshalJSON(migrated) + bz, err := clientCtx.JSONCodec.MarshalJSON(migrated) require.NoError(t, err) // Indent the JSON bz correctly. diff --git a/x/gov/legacy/v043/json_test.go b/x/gov/legacy/v043/json_test.go index 66082e5daf6b..47910d01324f 100644 --- a/x/gov/legacy/v043/json_test.go +++ b/x/gov/legacy/v043/json_test.go @@ -20,7 +20,7 @@ func TestMigrateJSON(t *testing.T) { clientCtx := client.Context{}. WithInterfaceRegistry(encodingConfig.InterfaceRegistry). WithTxConfig(encodingConfig.TxConfig). - WithJSONMarshaler(encodingConfig.Marshaler) + WithJSONCodec(encodingConfig.Marshaler) voter, err := sdk.AccAddressFromBech32("cosmos1fl48vsnmsdzcv85q5d2q4z5ajdha8yu34mf0eh") require.NoError(t, err) @@ -36,7 +36,7 @@ func TestMigrateJSON(t *testing.T) { migrated := v043gov.MigrateJSON(govGenState) - bz, err := clientCtx.JSONMarshaler.MarshalJSON(migrated) + bz, err := clientCtx.JSONCodec.MarshalJSON(migrated) require.NoError(t, err) // Indent the JSON bz correctly. diff --git a/x/mint/client/rest/grpc_query_test.go b/x/mint/client/rest/grpc_query_test.go index b2024e7d57ae..6d8fa90a2fcc 100644 --- a/x/mint/client/rest/grpc_query_test.go +++ b/x/mint/client/rest/grpc_query_test.go @@ -101,7 +101,7 @@ func (s *IntegrationTestSuite) TestQueryGRPC() { resp, err := testutil.GetRequestWithHeaders(tc.url, tc.headers) s.Run(tc.name, func() { s.Require().NoError(err) - s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, tc.respType)) + s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(resp, tc.respType)) s.Require().Equal(tc.expected.String(), tc.respType.String()) }) } diff --git a/x/params/client/rest/grpc_query_test.go b/x/params/client/rest/grpc_query_test.go index af00834183b9..eb3c0ac13d31 100644 --- a/x/params/client/rest/grpc_query_test.go +++ b/x/params/client/rest/grpc_query_test.go @@ -113,7 +113,7 @@ func (s *IntegrationTestSuite) TestQueryParamsGRPC() { resp, err := testutil.GetRequestWithHeaders(tc.url, tc.headers) s.Require().NoError(err) - err = val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, tc.respType) + err = val.ClientCtx.JSONCodec.UnmarshalJSON(resp, tc.respType) if tc.expErr { s.Require().Error(err) diff --git a/x/slashing/client/cli/query.go b/x/slashing/client/cli/query.go index 361d6b08188c..50c3fe683819 100644 --- a/x/slashing/client/cli/query.go +++ b/x/slashing/client/cli/query.go @@ -50,7 +50,7 @@ $ query slashing signing-info '{"@type":"/cosmos.crypto.ed25519.PubKey"," } var pk cryptotypes.PubKey - if err := clientCtx.JSONMarshaler.UnmarshalInterfaceJSON([]byte(args[0]), &pk); err != nil { + if err := clientCtx.JSONCodec.UnmarshalInterfaceJSON([]byte(args[0]), &pk); err != nil { return err } diff --git a/x/slashing/client/rest/grpc_query_test.go b/x/slashing/client/rest/grpc_query_test.go index 8d4efd364c85..bfc6f20a5825 100644 --- a/x/slashing/client/rest/grpc_query_test.go +++ b/x/slashing/client/rest/grpc_query_test.go @@ -117,7 +117,7 @@ func (s *IntegrationTestSuite) TestGRPCQueries() { resp, err := testutil.GetRequestWithHeaders(tc.url, tc.headers) s.Require().NoError(err) - err = val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, tc.respType) + err = val.ClientCtx.JSONCodec.UnmarshalJSON(resp, tc.respType) if tc.expErr { s.Require().Error(err) diff --git a/x/slashing/client/testutil/suite.go b/x/slashing/client/testutil/suite.go index 2ab4a965eb74..815c02160416 100644 --- a/x/slashing/client/testutil/suite.go +++ b/x/slashing/client/testutil/suite.go @@ -173,7 +173,7 @@ func (s *IntegrationTestSuite) TestNewUnjailTxCmd() { s.Require().Error(err) } else { s.Require().NoError(err) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) diff --git a/x/slashing/legacy/v040/migrate_test.go b/x/slashing/legacy/v040/migrate_test.go index 016f3f4d44f3..b5c2fa3bc809 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). - WithJSONMarshaler(encodingConfig.Marshaler) + WithJSONCodec(encodingConfig.Marshaler) addr1, err := sdk.ConsAddressFromBech32("cosmosvalcons104cjmxkrg8y8lmrp25de02e4zf00zle4mzs685") require.NoError(t, err) @@ -126,7 +126,7 @@ func TestMigrate(t *testing.T) { ] }` - bz, err := clientCtx.JSONMarshaler.MarshalJSON(migrated) + bz, err := clientCtx.JSONCodec.MarshalJSON(migrated) require.NoError(t, err) // Indent the JSON bz correctly. diff --git a/x/staking/client/cli/tx.go b/x/staking/client/cli/tx.go index 84487f342626..f129979dd04d 100644 --- a/x/staking/client/cli/tx.go +++ b/x/staking/client/cli/tx.go @@ -322,7 +322,7 @@ func newBuildCreateValidatorMsg(clientCtx client.Context, txf tx.Factory, fs *fl } var pk cryptotypes.PubKey - if err := clientCtx.JSONMarshaler.UnmarshalInterfaceJSON([]byte(pkStr), &pk); err != nil { + if err := clientCtx.JSONCodec.UnmarshalInterfaceJSON([]byte(pkStr), &pk); err != nil { return txf, nil, err } diff --git a/x/staking/client/rest/grpc_query_test.go b/x/staking/client/rest/grpc_query_test.go index f0cc39996299..651931d8d559 100644 --- a/x/staking/client/rest/grpc_query_test.go +++ b/x/staking/client/rest/grpc_query_test.go @@ -109,7 +109,7 @@ func (s *IntegrationTestSuite) TestQueryValidatorsGRPCHandler() { s.Require().NoError(err) var valRes types.QueryValidatorsResponse - err = val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, &valRes) + err = val.ClientCtx.JSONCodec.UnmarshalJSON(resp, &valRes) if tc.error { s.Require().Error(err) @@ -157,7 +157,7 @@ func (s *IntegrationTestSuite) TestQueryValidatorGRPC() { s.Require().NoError(err) var validator types.QueryValidatorResponse - err = val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, &validator) + err = val.ClientCtx.JSONCodec.UnmarshalJSON(resp, &validator) if tc.error { s.Require().Error(err) @@ -221,7 +221,7 @@ func (s *IntegrationTestSuite) TestQueryValidatorDelegationsGRPC() { resp, err := testutil.GetRequestWithHeaders(tc.url, tc.headers) s.Require().NoError(err) - err = val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, tc.respType) + err = val.ClientCtx.JSONCodec.UnmarshalJSON(resp, tc.respType) if tc.error { s.Require().Error(err) @@ -267,7 +267,7 @@ func (s *IntegrationTestSuite) TestQueryValidatorUnbondingDelegationsGRPC() { var ubds types.QueryValidatorUnbondingDelegationsResponse - err = val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, &ubds) + err = val.ClientCtx.JSONCodec.UnmarshalJSON(resp, &ubds) if tc.error { s.Require().Error(err) @@ -344,7 +344,7 @@ func (s *IntegrationTestSuite) TestQueryDelegationGRPC() { resp, err := rest.GetRequest(tc.url) s.Require().NoError(err) s.T().Logf("%s", resp) - err = val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, tc.respType) + err = val.ClientCtx.JSONCodec.UnmarshalJSON(resp, tc.respType) if tc.error { s.Require().Error(err) @@ -400,7 +400,7 @@ func (s *IntegrationTestSuite) TestQueryUnbondingDelegationGRPC() { var ubd types.QueryUnbondingDelegationResponse - err = val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, &ubd) + err = val.ClientCtx.JSONCodec.UnmarshalJSON(resp, &ubd) if tc.error { s.Require().Error(err) @@ -494,7 +494,7 @@ func (s *IntegrationTestSuite) TestQueryDelegatorDelegationsGRPC() { resp, err := testutil.GetRequestWithHeaders(tc.url, tc.headers) s.Require().NoError(err) - err = val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, tc.respType) + err = val.ClientCtx.JSONCodec.UnmarshalJSON(resp, tc.respType) if tc.error { s.Require().Error(err) @@ -544,7 +544,7 @@ func (s *IntegrationTestSuite) TestQueryDelegatorUnbondingDelegationsGRPC() { var ubds types.QueryDelegatorUnbondingDelegationsResponse - err = val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, &ubds) + err = val.ClientCtx.JSONCodec.UnmarshalJSON(resp, &ubds) if tc.error { s.Require().Error(err) @@ -605,7 +605,7 @@ func (s *IntegrationTestSuite) TestQueryRedelegationsGRPC() { s.Require().NoError(err) var redelegations types.QueryRedelegationsResponse - err = val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, &redelegations) + err = val.ClientCtx.JSONCodec.UnmarshalJSON(resp, &redelegations) if tc.error { s.Require().Error(err) @@ -655,7 +655,7 @@ func (s *IntegrationTestSuite) TestQueryDelegatorValidatorsGRPC() { var validators types.QueryDelegatorValidatorsResponse - err = val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, &validators) + err = val.ClientCtx.JSONCodec.UnmarshalJSON(resp, &validators) if tc.error { s.Require().Error(err) @@ -711,7 +711,7 @@ func (s *IntegrationTestSuite) TestQueryDelegatorValidatorGRPC() { s.Require().NoError(err) var validator types.QueryDelegatorValidatorResponse - err = val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, &validator) + err = val.ClientCtx.JSONCodec.UnmarshalJSON(resp, &validator) if tc.error { s.Require().Error(err) @@ -758,7 +758,7 @@ func (s *IntegrationTestSuite) TestQueryHistoricalInfoGRPC() { var historicalInfo types.QueryHistoricalInfoResponse - err = val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, &historicalInfo) + err = val.ClientCtx.JSONCodec.UnmarshalJSON(resp, &historicalInfo) if tc.error { s.Require().Error(err) @@ -795,7 +795,7 @@ func (s *IntegrationTestSuite) TestQueryParamsGRPC() { resp, err := rest.GetRequest(tc.url) s.Run(tc.name, func() { s.Require().NoError(err) - s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, tc.respType)) + s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(resp, tc.respType)) s.Require().Equal(tc.expected, tc.respType) }) } @@ -829,7 +829,7 @@ func (s *IntegrationTestSuite) TestQueryPoolGRPC() { resp, err := rest.GetRequest(tc.url) s.Run(tc.name, func() { s.Require().NoError(err) - s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, tc.respType)) + s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(resp, tc.respType)) s.Require().Equal(tc.expected, tc.respType) }) } diff --git a/x/staking/client/testutil/suite.go b/x/staking/client/testutil/suite.go index d05f45b4ce30..a6e385b405aa 100644 --- a/x/staking/client/testutil/suite.go +++ b/x/staking/client/testutil/suite.go @@ -200,7 +200,7 @@ func (s *IntegrationTestSuite) TestNewCreateValidatorCmd() { require.Error(err) } else { require.NoError(err, "test: %s\noutput: %s", tc.name, out.String()) - err = clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType) + err = clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType) require.NoError(err, out.String(), "test: %s, output\n:", tc.name, out.String()) txResp := tc.respType.(*sdk.TxResponse) @@ -245,7 +245,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryValidator() { s.Require().NotEqual("internal", err.Error()) } else { var result types.Validator - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &result)) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &result)) s.Require().Equal(val.ValAddress.String(), result.OperatorAddress) } }) @@ -286,7 +286,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryValidators() { s.Require().NoError(err) var result types.QueryValidatorsResponse - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &result)) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &result)) s.Require().Equal(tc.minValidatorCount, len(result.Validators)) }) } @@ -352,7 +352,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryDelegation() { s.Require().Error(err) } else { s.Require().NoError(err) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) s.Require().Equal(tc.expected.String(), tc.respType.String()) } }) @@ -408,7 +408,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryDelegations() { s.Require().Error(err) } else { s.Require().NoError(err) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) s.Require().Equal(tc.expected.String(), tc.respType.String()) } }) @@ -464,7 +464,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryDelegationsTo() { s.Require().Error(err) } else { s.Require().NoError(err) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) s.Require().Equal(tc.expected.String(), tc.respType.String()) } }) @@ -509,7 +509,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryUnbondingDelegations() { s.Require().Error(err) } else { var ubds types.QueryDelegatorUnbondingDelegationsResponse - err = val.ClientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &ubds) + err = val.ClientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &ubds) s.Require().NoError(err) s.Require().Len(ubds.UnbondingResponses, 1) @@ -569,7 +569,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryUnbondingDelegation() { } else { var ubd types.UnbondingDelegation - err = val.ClientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &ubd) + err = val.ClientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &ubd) s.Require().NoError(err) s.Require().Equal(ubd.DelegatorAddress, val.Address.String()) s.Require().Equal(ubd.ValidatorAddress, val.ValAddress.String()) @@ -617,7 +617,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryValidatorUnbondingDelegations() { s.Require().Error(err) } else { var ubds types.QueryValidatorUnbondingDelegationsResponse - err = val.ClientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &ubds) + err = val.ClientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &ubds) s.Require().NoError(err) s.Require().Len(ubds.UnbondingResponses, 1) @@ -666,7 +666,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryRedelegations() { s.Require().Error(err) } else { var redelegations types.QueryRedelegationsResponse - err = val.ClientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &redelegations) + err = val.ClientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &redelegations) s.Require().NoError(err) @@ -743,7 +743,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryRedelegation() { } else { var redelegations types.QueryRedelegationsResponse - err = val.ClientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &redelegations) + err = val.ClientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &redelegations) s.Require().NoError(err) s.Require().Len(redelegations.RedelegationResponses, 1) @@ -794,7 +794,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryRedelegationsFrom() { s.Require().Error(err) } else { var redelegations types.QueryRedelegationsResponse - err = val.ClientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &redelegations) + err = val.ClientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &redelegations) s.Require().NoError(err) @@ -845,7 +845,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryHistoricalInfo() { } else { var historicalInfo types.HistoricalInfo - err = val.ClientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &historicalInfo) + err = val.ClientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &historicalInfo) s.Require().NoError(err) s.Require().NotNil(historicalInfo) } @@ -1032,7 +1032,7 @@ func (s *IntegrationTestSuite) TestNewCmdEditValidator() { s.Require().Error(err) } else { s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) @@ -1114,7 +1114,7 @@ func (s *IntegrationTestSuite) TestNewCmdDelegate() { s.Require().Error(err) } else { s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) @@ -1200,7 +1200,7 @@ func (s *IntegrationTestSuite) TestNewCmdRedelegate() { s.Require().Error(err) } else { s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) @@ -1267,7 +1267,7 @@ func (s *IntegrationTestSuite) TestNewCmdUnbond() { s.Require().Error(err) } else { s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) diff --git a/x/staking/legacy/v040/migrate_test.go b/x/staking/legacy/v040/migrate_test.go index 2be5e80dbc31..97321a47b9f5 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). - WithJSONMarshaler(encodingConfig.Marshaler) + WithJSONCodec(encodingConfig.Marshaler) consPubKey := ed25519.GenPrivKeyFromSecret([]byte("val0")).PubKey() stakingGenState := v038staking.GenesisState{ @@ -32,7 +32,7 @@ func TestMigrate(t *testing.T) { migrated := v040staking.Migrate(stakingGenState) - bz, err := clientCtx.JSONMarshaler.MarshalJSON(migrated) + bz, err := clientCtx.JSONCodec.MarshalJSON(migrated) require.NoError(t, err) // Indent the JSON bz correctly. diff --git a/x/staking/legacy/v043/json_test.go b/x/staking/legacy/v043/json_test.go index 82d2422417a1..8dc2bf82a440 100644 --- a/x/staking/legacy/v043/json_test.go +++ b/x/staking/legacy/v043/json_test.go @@ -19,7 +19,7 @@ func TestMigrateJSON(t *testing.T) { clientCtx := client.Context{}. WithInterfaceRegistry(encodingConfig.InterfaceRegistry). WithTxConfig(encodingConfig.TxConfig). - WithJSONMarshaler(encodingConfig.Marshaler) + WithJSONCodec(encodingConfig.Marshaler) // voter, err := sdk.AccAddressFromBech32("cosmos1fl48vsnmsdzcv85q5d2q4z5ajdha8yu34mf0eh") // require.NoError(t, err) @@ -31,7 +31,7 @@ func TestMigrateJSON(t *testing.T) { require.True(t, migrated.Params.PowerReduction.Equal(sdk.DefaultPowerReduction)) - bz, err := clientCtx.JSONMarshaler.MarshalJSON(migrated) + bz, err := clientCtx.JSONCodec.MarshalJSON(migrated) require.NoError(t, err) // Indent the JSON bz correctly.