Skip to content

Commit

Permalink
Updated mint module
Browse files Browse the repository at this point in the history
  • Loading branch information
bsrinivas8687 committed Mar 12, 2022
1 parent 0e08890 commit f3ad22d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
8 changes: 4 additions & 4 deletions x/mint/keeper/inflation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}

Expand All @@ -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)
})

Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions x/mint/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
14 changes: 8 additions & 6 deletions x/mint/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -58,26 +58,26 @@ 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)

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))
}

Expand All @@ -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)
}
Expand Down

0 comments on commit f3ad22d

Please sign in to comment.