Skip to content

Commit d1c874b

Browse files
committed
address review comments
1 parent 2256bf8 commit d1c874b

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

x/mint/abci.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@ func BeginBlocker(ctx sdk.Context, k keeper.Keeper, ic types.InflationCalculatio
2020
// recalculate inflation rate
2121
totalStakingSupply := k.StakingTokenSupply(ctx)
2222
bondedRatio := k.BondedRatio(ctx)
23-
if ic == nil {
24-
minter.Inflation = minter.NextInflationRate(params, bondedRatio)
25-
} else {
26-
minter.Inflation = ic(ctx, minter, params, bondedRatio)
27-
}
23+
minter.Inflation = ic(ctx, minter, params, bondedRatio)
2824
minter.AnnualProvisions = minter.NextAnnualProvisions(params, totalStakingSupply)
2925
k.SetMinter(ctx, minter)
3026

x/mint/module.go

+3
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ type AppModule struct {
9797

9898
// NewAppModule creates a new AppModule object
9999
func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak types.AccountKeeper, ic types.InflationCalculationFn) AppModule {
100+
if ic == nil {
101+
ic = types.DefaultInflationCalculationFn
102+
}
100103
return AppModule{
101104
AppModuleBasic: AppModuleBasic{cdc: cdc},
102105
keeper: keeper,

x/mint/types/genesis.go

+5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ import (
1111
// default logic provided by the sdk.
1212
type InflationCalculationFn func(ctx sdk.Context, minter Minter, params Params, bondedRatio sdk.Dec) sdk.Dec
1313

14+
// DefaultInflationCalculationFn is the default function used to calculate inflation.
15+
func DefaultInflationCalculationFn(ctx sdk.Context, minter Minter, params Params, bondedRatio sdk.Dec) sdk.Dec {
16+
return minter.NextInflationRate(params, bondedRatio)
17+
}
18+
1419
// NewGenesisState creates a new GenesisState object
1520
func NewGenesisState(minter Minter, params Params) *GenesisState {
1621
return &GenesisState{

0 commit comments

Comments
 (0)