Skip to content

Commit

Permalink
simplify IsManualMintingEnabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Reecepbcups committed Feb 24, 2024
1 parent 41ab858 commit 887a788
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 22 deletions.
4 changes: 3 additions & 1 deletion app/decorators/inflation_disable_minting.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ func (mfd MsgManualMintFilterDecorator) hasInvalidMsgFromPoAAdmin(ctx sdk.Contex

func (mfd MsgManualMintFilterDecorator) senderAdminOnMintWithInflation(ctx context.Context, sender string) error {
if mfd.isSudoAdminFunc(ctx, sender) {
return mfd.mk.IsManualMintingEnabled(ctx)
if !mfd.mk.IsManualMintingEnabled(ctx) {
return manifesttypes.ErrManualMintingDisabled
}
}

return nil
Expand Down
4 changes: 2 additions & 2 deletions app/decorators/inflation_disable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ func (s *AnteTestSuite) TestAnteInflationAndMinting() {
name: "fail; inflation enabled, no manual mint from admin",
inflation: true,
msg: tokenfactorytypes.NewMsgMint(poaAdmin.String(), coin),
err: manifestkeeper.ErrManualMintingDisabled.Error(),
err: manifesttypes.ErrManualMintingDisabled.Error(),
},
{
name: "fail; inflation enabled, no manual payout from admin",
inflation: true,
msg: manifesttypes.NewMsgPayoutStakeholders(poaAdmin, coin),
err: manifestkeeper.ErrManualMintingDisabled.Error(),
err: manifesttypes.ErrManualMintingDisabled.Error(),
},
}

Expand Down
12 changes: 0 additions & 12 deletions x/manifest/keeper/errors.go

This file was deleted.

10 changes: 3 additions & 7 deletions x/manifest/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,13 @@ func (k *Keeper) GetShareHolders(ctx context.Context) []*types.StakeHolders {
}

// IsManualMintingEnabled returns nil if inflation mint is 0% (disabled)
func (k Keeper) IsManualMintingEnabled(ctx context.Context) error {
func (k Keeper) IsManualMintingEnabled(ctx context.Context) bool {
params, err := k.Params.Get(ctx)
if err != nil {
return err
}

if !params.Inflation.AutomaticEnabled {
return nil
panic(err)
}

return ErrManualMintingDisabled.Wrapf("token inflation: %d", params.Inflation.YearlyAmount)
return !params.Inflation.AutomaticEnabled
}

// Returns the amount of coins to be distributed to the holders
Expand Down
10 changes: 10 additions & 0 deletions x/manifest/types/errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package types

import (
"cosmossdk.io/errors"
)

var (
ErrGettingMinter = errors.Register(ModuleName, 1, "getting minter in ante handler")
ErrManualMintingDisabled = errors.Register(ModuleName, 2, "manual minting is disabled due to automatic inflation being on")
)

0 comments on commit 887a788

Please sign in to comment.