From f3ad22d41ecfdcafa7f4c71899b0347feaf57672 Mon Sep 17 00:00:00 2001 From: Srinivas Baride Date: Sun, 13 Mar 2022 01:47:58 +0530 Subject: [PATCH] Updated mint module --- x/mint/keeper/inflation.go | 8 ++++---- x/mint/keeper/keeper.go | 4 ++-- x/mint/module.go | 14 ++++++++------ 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/x/mint/keeper/inflation.go b/x/mint/keeper/inflation.go index b0651108..f4bdd8c5 100644 --- a/x/mint/keeper/inflation.go +++ b/x/mint/keeper/inflation.go @@ -13,7 +13,7 @@ func (k *Keeper) SetInflation(ctx sdk.Context, inflation types.Inflation) { var ( store = k.Store(ctx) key = types.InflationKey(inflation.Timestamp) - value = k.cdc.MustMarshalBinaryBare(&inflation) + value = k.cdc.MustMarshal(&inflation) ) store.Set(key, value) @@ -30,7 +30,7 @@ func (k *Keeper) GetInflation(ctx sdk.Context, timestamp time.Time) (inflation t return inflation, false } - k.cdc.MustUnmarshalBinaryBare(value, &inflation) + k.cdc.MustUnmarshal(value, &inflation) return inflation, true } @@ -56,7 +56,7 @@ func (k *Keeper) GetInflations(ctx sdk.Context, skip, limit int64) (items []type iter.Skip(skip) iter.Limit(limit, func(iter sdk.Iterator) { var item types.Inflation - k.cdc.MustUnmarshalBinaryBare(iter.Value(), &item) + k.cdc.MustUnmarshal(iter.Value(), &item) items = append(items, item) }) @@ -73,7 +73,7 @@ func (k *Keeper) IterateInflations(ctx sdk.Context, fn func(index int, item type for i := 0; iter.Valid(); iter.Next() { var item types.Inflation - k.cdc.MustUnmarshalBinaryBare(iter.Value(), &item) + k.cdc.MustUnmarshal(iter.Value(), &item) if stop := fn(i, item); stop { break diff --git a/x/mint/keeper/keeper.go b/x/mint/keeper/keeper.go index a7e84aee..15c0c722 100644 --- a/x/mint/keeper/keeper.go +++ b/x/mint/keeper/keeper.go @@ -10,12 +10,12 @@ import ( ) type Keeper struct { - cdc codec.BinaryMarshaler + cdc codec.BinaryCodec key sdk.StoreKey mint expected.MintKeeper } -func NewKeeper(cdc codec.BinaryMarshaler, key sdk.StoreKey, mint expected.MintKeeper) Keeper { +func NewKeeper(cdc codec.BinaryCodec, key sdk.StoreKey, mint expected.MintKeeper) Keeper { return Keeper{ cdc: cdc, key: key, diff --git a/x/mint/module.go b/x/mint/module.go index 6fdbb5ca..69822b8b 100644 --- a/x/mint/module.go +++ b/x/mint/module.go @@ -35,11 +35,11 @@ func (a AppModuleBasic) RegisterLegacyAminoCodec(_ *codec.LegacyAmino) {} func (a AppModuleBasic) RegisterInterfaces(_ codectypes.InterfaceRegistry) {} -func (a AppModuleBasic) DefaultGenesis(cdc codec.JSONMarshaler) json.RawMessage { +func (a AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { return cdc.MustMarshalJSON(types.DefaultGenesisState()) } -func (a AppModuleBasic) ValidateGenesis(cdc codec.JSONMarshaler, _ client.TxEncodingConfig, message json.RawMessage) error { +func (a AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, message json.RawMessage) error { var state types.GenesisState if err := cdc.UnmarshalJSON(message, &state); err != nil { return err @@ -58,18 +58,18 @@ func (a AppModuleBasic) GetQueryCmd() *cobra.Command { return nil } type AppModule struct { AppModuleBasic - cdc codec.Marshaler + cdc codec.Codec k keeper.Keeper } -func NewAppModule(cdc codec.Marshaler, k keeper.Keeper) AppModule { +func NewAppModule(cdc codec.Codec, k keeper.Keeper) AppModule { return AppModule{ cdc: cdc, k: k, } } -func (a AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONMarshaler, message json.RawMessage) []abcitypes.ValidatorUpdate { +func (a AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, message json.RawMessage) []abcitypes.ValidatorUpdate { var state types.GenesisState cdc.MustUnmarshalJSON(message, &state) InitGenesis(ctx, a.k, &state) @@ -77,7 +77,7 @@ func (a AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONMarshaler, message return nil } -func (a AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONMarshaler) json.RawMessage { +func (a AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { return cdc.MustMarshalJSON(ExportGenesis(ctx, a.k)) } @@ -95,6 +95,8 @@ func (a AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier { retu func (a AppModule) RegisterServices(_ module.Configurator) {} +func (a AppModule) ConsensusVersion() uint64 { return 1 } + func (a AppModule) BeginBlock(ctx sdk.Context, _ abcitypes.RequestBeginBlock) { BeginBlock(ctx, a.k) }