Skip to content

Commit

Permalink
codec.JSONCodec -> codec.Codec
Browse files Browse the repository at this point in the history
  • Loading branch information
faddat committed Feb 21, 2022
1 parent 290f7ea commit 3da4a2f
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion docs/migrations/sdk-to-v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,6 @@ The `consensus_height` attribute has been removed in the Misbehaviour event emit
* (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`
* `codec.JSONMarshaler``codec.Codec`
* Removed `BinaryBare` suffix from `BinaryCodec` methods (`MarshalBinaryBare`, `UnmarshalBinaryBare`, ...)
* Removed `Binary` infix from `BinaryCodec` methods (`MarshalBinaryLengthPrefixed`, `UnmarshalBinaryLengthPrefixed`, ...)
8 changes: 4 additions & 4 deletions modules/apps/27-interchain-accounts/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry)

// DefaultGenesis returns default genesis state as raw bytes for the IBC
// interchain accounts module
func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
func (AppModuleBasic) DefaultGenesis(cdc codec.Codec) json.RawMessage {
return cdc.MustMarshalJSON(types.DefaultGenesis())
}

// ValidateGenesis performs genesis state validation for the IBC interchain acounts module
func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error {
func (AppModuleBasic) ValidateGenesis(cdc codec.Codec, config client.TxEncodingConfig, bz json.RawMessage) error {
var gs types.GenesisState
if err := cdc.UnmarshalJSON(bz, &gs); err != nil {
return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err)
Expand Down Expand Up @@ -133,7 +133,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {

// InitGenesis performs genesis initialization for the interchain accounts module.
// It returns no validator updates.
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate {
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.Codec, data json.RawMessage) []abci.ValidatorUpdate {
var genesisState types.GenesisState
cdc.MustUnmarshalJSON(data, &genesisState)

Expand All @@ -149,7 +149,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.
}

// ExportGenesis returns the exported genesis state as raw bytes for the interchain accounts module
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.Codec) json.RawMessage {
var (
controllerGenesisState = types.DefaultControllerGenesis()
hostGenesisState = types.DefaultHostGenesis()
Expand Down
8 changes: 4 additions & 4 deletions modules/apps/transfer/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry)

// DefaultGenesis returns default genesis state as raw bytes for the ibc
// transfer module.
func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
func (AppModuleBasic) DefaultGenesis(cdc codec.Codec) json.RawMessage {
return cdc.MustMarshalJSON(types.DefaultGenesisState())
}

// ValidateGenesis performs genesis state validation for the ibc transfer module.
func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error {
func (AppModuleBasic) ValidateGenesis(cdc codec.Codec, config client.TxEncodingConfig, bz json.RawMessage) error {
var gs types.GenesisState
if err := cdc.UnmarshalJSON(bz, &gs); err != nil {
return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err)
Expand Down Expand Up @@ -124,7 +124,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {

// InitGenesis performs genesis initialization for the ibc-transfer module. It returns
// no validator updates.
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate {
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.Codec, data json.RawMessage) []abci.ValidatorUpdate {
var genesisState types.GenesisState
cdc.MustUnmarshalJSON(data, &genesisState)
am.keeper.InitGenesis(ctx, genesisState)
Expand All @@ -133,7 +133,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.

// ExportGenesis returns the exported genesis state as raw bytes for the ibc-transfer
// module.
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.Codec) json.RawMessage {
gs := am.keeper.ExportGenesis(ctx)
return cdc.MustMarshalJSON(gs)
}
Expand Down
8 changes: 4 additions & 4 deletions modules/core/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ func (AppModuleBasic) RegisterLegacyAminoCodec(*codec.LegacyAmino) {}

// DefaultGenesis returns default genesis state as raw bytes for the ibc
// module.
func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
func (AppModuleBasic) DefaultGenesis(cdc codec.Codec) json.RawMessage {
return cdc.MustMarshalJSON(types.DefaultGenesisState())
}

// ValidateGenesis performs genesis state validation for the ibc module.
func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error {
func (AppModuleBasic) ValidateGenesis(cdc codec.Codec, config client.TxEncodingConfig, bz json.RawMessage) error {
var gs types.GenesisState
if err := cdc.UnmarshalJSON(bz, &gs); err != nil {
return fmt.Errorf("failed to unmarshal %s genesis state: %w", host.ModuleName, err)
Expand Down Expand Up @@ -143,7 +143,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {

// InitGenesis performs genesis initialization for the ibc module. It returns
// no validator updates.
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, bz json.RawMessage) []abci.ValidatorUpdate {
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.Codec, bz json.RawMessage) []abci.ValidatorUpdate {
var gs types.GenesisState
err := cdc.UnmarshalJSON(bz, &gs)
if err != nil {
Expand All @@ -155,7 +155,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, bz json.Ra

// ExportGenesis returns the exported genesis state as raw bytes for the ibc
// module.
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.Codec) json.RawMessage {
return cdc.MustMarshalJSON(ExportGenesis(ctx, *am.keeper))
}

Expand Down
8 changes: 4 additions & 4 deletions testing/mock/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ func (AppModuleBasic) RegisterLegacyAminoCodec(*codec.LegacyAmino) {}
func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) {}

// DefaultGenesis implements AppModuleBasic interface.
func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
func (AppModuleBasic) DefaultGenesis(cdc codec.Codec) json.RawMessage {
return nil
}

// ValidateGenesis implements the AppModuleBasic interface.
func (AppModuleBasic) ValidateGenesis(codec.JSONCodec, client.TxEncodingConfig, json.RawMessage) error {
func (AppModuleBasic) ValidateGenesis(codec.Codec, client.TxEncodingConfig, json.RawMessage) error {
return nil
}

Expand Down Expand Up @@ -122,7 +122,7 @@ func (am AppModule) LegacyQuerierHandler(*codec.LegacyAmino) sdk.Querier {
func (am AppModule) RegisterServices(module.Configurator) {}

// InitGenesis implements the AppModule interface.
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate {
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.Codec, data json.RawMessage) []abci.ValidatorUpdate {
for _, ibcApp := range am.ibcApps {
if ibcApp.PortID != "" && !am.portKeeper.IsBound(ctx, ibcApp.PortID) {
// bind mock portID
Expand All @@ -135,7 +135,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.
}

// ExportGenesis implements the AppModule interface.
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.Codec) json.RawMessage {
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion testing/simapp/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ import (
type GenesisState map[string]json.RawMessage

// NewDefaultGenesisState generates the default state for the application.
func NewDefaultGenesisState(cdc codec.JSONCodec) GenesisState {
func NewDefaultGenesisState(cdc codec.Codec) GenesisState {
return ModuleBasics.DefaultGenesis(cdc)
}
6 changes: 3 additions & 3 deletions testing/simapp/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
// AppStateFn returns the initial application state using a genesis or the simulation parameters.
// It panics if the user provides files for both of them.
// If a file is not given for the genesis or the sim params, it creates a randomized one.
func AppStateFn(cdc codec.JSONCodec, simManager *module.SimulationManager) simtypes.AppStateFn {
func AppStateFn(cdc codec.Codec, simManager *module.SimulationManager) simtypes.AppStateFn {
return func(r *rand.Rand, accs []simtypes.Account, config simtypes.Config,
) (appState json.RawMessage, simAccs []simtypes.Account, chainID string, genesisTimestamp time.Time) {

Expand Down Expand Up @@ -129,7 +129,7 @@ func AppStateFn(cdc codec.JSONCodec, simManager *module.SimulationManager) simty
// AppStateRandomizedFn creates calls each module's GenesisState generator function
// and creates the simulation params
func AppStateRandomizedFn(
simManager *module.SimulationManager, r *rand.Rand, cdc codec.JSONCodec,
simManager *module.SimulationManager, r *rand.Rand, cdc codec.Codec,
accs []simtypes.Account, genesisTimestamp time.Time, appParams simtypes.AppParams,
) (json.RawMessage, []simtypes.Account) {
numAccs := int64(len(accs))
Expand Down Expand Up @@ -183,7 +183,7 @@ func AppStateRandomizedFn(

// AppStateFromGenesisFileFn util function to generate the genesis AppState
// from a genesis.json file.
func AppStateFromGenesisFileFn(r io.Reader, cdc codec.JSONCodec, genesisFile string) (tmtypes.GenesisDoc, []simtypes.Account) {
func AppStateFromGenesisFileFn(r io.Reader, cdc codec.Codec, genesisFile string) (tmtypes.GenesisDoc, []simtypes.Account) {
bytes, err := ioutil.ReadFile(genesisFile)
if err != nil {
panic(err)
Expand Down
2 changes: 1 addition & 1 deletion testing/simapp/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func SetupSimulation(dirPrefix, dbName string) (simtypes.Config, dbm.DB, string,

// SimulationOperations retrieves the simulation params from the provided file path
// and returns all the modules weighted operations
func SimulationOperations(app App, cdc codec.JSONCodec, config simtypes.Config) []simtypes.WeightedOperation {
func SimulationOperations(app App, cdc codec.Codec, config simtypes.Config) []simtypes.WeightedOperation {
simState := module.SimulationState{
AppParams: make(simtypes.AppParams),
Cdc: cdc,
Expand Down

0 comments on commit 3da4a2f

Please sign in to comment.