Skip to content

Commit

Permalink
set mint modules to be a minter
Browse files Browse the repository at this point in the history
  • Loading branch information
kkast committed Mar 20, 2024
1 parent ff68541 commit a76ebd3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
appCodec, appKeepers.keys[distrtypes.StoreKey], appKeepers.AccountKeeper, appKeepers.BankKeeper,
appKeepers.StakingKeeper, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
appKeepers.StakingKeeper.RegisterKeepers(appKeepers.DistrKeeper, appKeepers.BankKeeper)
appKeepers.StakingKeeper.RegisterKeepers(appKeepers.DistrKeeper, appKeepers.MintKeeper)
appKeepers.SlashingKeeper = slashingkeeper.NewKeeper(
appCodec, cdc, appKeepers.keys[slashingtypes.StoreKey], appKeepers.StakingKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
Expand Down
11 changes: 6 additions & 5 deletions custom/staking/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
distkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
"github.com/cosmos/cosmos-sdk/x/staking/types"
mintkeeper "github.com/notional-labs/composable/v6/x/mint/keeper"
minttypes "github.com/notional-labs/composable/v6/x/mint/types"
stakingmiddleware "github.com/notional-labs/composable/v6/x/stakingmiddleware/keeper"
)
Expand All @@ -21,7 +22,7 @@ type Keeper struct {
cdc codec.BinaryCodec
Stakingmiddleware *stakingmiddleware.Keeper
authority string
mintKeeper minttypes.BankKeeper
mintKeeper mintkeeper.Keeper
distrKeeper distkeeper.Keeper
authKeeper minttypes.AccountKeeper
}
Expand Down Expand Up @@ -125,14 +126,14 @@ func NewKeeper(
authority: authority,
Stakingmiddleware: stakingmiddleware,
cdc: cdc,
mintKeeper: nil,
mintKeeper: mintkeeper.Keeper{},
distrKeeper: distkeeper.Keeper{},
authKeeper: ak,
}
return &keeper
}

func (k *Keeper) RegisterKeepers(dk distkeeper.Keeper, mk minttypes.BankKeeper) {
func (k *Keeper) RegisterKeepers(dk distkeeper.Keeper, mk mintkeeper.Keeper) {
k.distrKeeper = dk
k.mintKeeper = mk
}
Expand All @@ -143,11 +144,11 @@ func (k Keeper) SlashWithInfractionReason(ctx sdk.Context, consAddr sdk.ConsAddr
amountBurned := k.Slash(ctx, consAddr, infractionHeight, power, slashFactor)
// after usual slashing and burning is done, mint burned coinds into community pool
coins := sdk.NewCoins(sdk.NewCoin(k.BondDenom(ctx), amountBurned))
err := k.mintKeeper.MintCoins(ctx, types.ModuleName, coins)
err := k.mintKeeper.MintCoins(ctx, coins)
if err != nil {
k.Logger(ctx).Error("Failed to mint slashed coins: ", amountBurned)
} else {
err = k.distrKeeper.FundCommunityPool(ctx, coins, k.authKeeper.GetModuleAddress(types.ModuleName))
err = k.distrKeeper.FundCommunityPool(ctx, coins, k.authKeeper.GetModuleAddress(minttypes.ModuleName))
if err != nil {
k.Logger(ctx).Error(fmt.Sprintf("Failed to fund community pool. Tokens minted to the staking module account: %d. ", amountBurned))
} else {
Expand Down

0 comments on commit a76ebd3

Please sign in to comment.