diff --git a/x/mint/CHANGELOG.md b/x/mint/CHANGELOG.md index 749a0680d1e2..670ba976013b 100644 --- a/x/mint/CHANGELOG.md +++ b/x/mint/CHANGELOG.md @@ -39,6 +39,5 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [#20363](https://github.com/cosmos/cosmos-sdk/pull/20363) Deprecated InflationCalculationFn in favor of MintFn, `keeper.DefaultMintFn` wrapper must be used in order to continue using it in `NewAppModule`. This is not breaking for depinject users, as both `MintFn` and `InflationCalculationFn` are accepted. * [#19367](https://github.com/cosmos/cosmos-sdk/pull/19398) `appmodule.Environment` is received on the Keeper to get access to different application services. * [#21858](https://github.com/cosmos/cosmos-sdk/pull/21858) `NewKeeper` now returns a pointer to `Keeper`. -* [#21858](https://github.com/cosmos/cosmos-sdk/pull/21858) `DefaultMintFn` now takes `StakingKeeper` and `MintKeeper` as arguments to avoid staking keeper being required by mint. +* [#21858](https://github.com/cosmos/cosmos-sdk/pull/21858), [#22979](https://github.com/cosmos/cosmos-sdk/pull/22979) `DefaultMintFn` now takes `StakingKeeper` and `MintKeeper` as arguments to avoid staking keeper being required by mint. * `SetMintFn` is used to replace the default minting function. - * `InflationCalculationFn` is not passed through depinject any longer, a MintFn is required instead. diff --git a/x/mint/depinject.go b/x/mint/depinject.go index db36920101d5..5119403b7b4f 100644 --- a/x/mint/depinject.go +++ b/x/mint/depinject.go @@ -77,11 +77,22 @@ func ProvideModule(in ModuleInputs) ModuleOutputs { return ModuleOutputs{MintKeeper: k, Module: m, EpochHooks: epochstypes.EpochHooksWrapper{EpochHooks: m}} } -func InvokeSetMintFn(mintKeeper *keeper.Keeper, mintFn types.MintFn, stakingKeeper types.StakingKeeper) error { - if mintFn == nil && stakingKeeper == nil { - return fmt.Errorf("custom minting function or staking keeper must be supplied or available") +func InvokeSetMintFn( + mintKeeper *keeper.Keeper, + stakingKeeper types.StakingKeeper, + mintFn types.MintFn, + inflationCalculationFn types.InflationCalculationFn, +) error { + if mintFn == nil && stakingKeeper == nil && inflationCalculationFn == nil { + return fmt.Errorf("custom minting function, inflation calculation function or staking keeper must be supplied or available") + } else if mintFn != nil && inflationCalculationFn != nil { + return fmt.Errorf("cannot set both custom minting function and inflation calculation function") } else if mintFn == nil { - mintFn = keeper.DefaultMintFn(types.DefaultInflationCalculationFn, stakingKeeper, mintKeeper) + if inflationCalculationFn != nil && stakingKeeper != nil { + mintFn = keeper.DefaultMintFn(inflationCalculationFn, stakingKeeper, mintKeeper) + } else { + mintFn = keeper.DefaultMintFn(types.DefaultInflationCalculationFn, stakingKeeper, mintKeeper) + } } return mintKeeper.SetMintFn(mintFn)