diff --git a/app/decorators/inflation_disable_minting.go b/app/decorators/inflation_disable_minting.go index 44c1f2f..4a3e1f7 100644 --- a/app/decorators/inflation_disable_minting.go +++ b/app/decorators/inflation_disable_minting.go @@ -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 diff --git a/app/decorators/inflation_disable_test.go b/app/decorators/inflation_disable_test.go index 52b5501..9646a1b 100644 --- a/app/decorators/inflation_disable_test.go +++ b/app/decorators/inflation_disable_test.go @@ -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(), }, } diff --git a/x/manifest/keeper/errors.go b/x/manifest/keeper/errors.go deleted file mode 100644 index a0d6c69..0000000 --- a/x/manifest/keeper/errors.go +++ /dev/null @@ -1,12 +0,0 @@ -package keeper - -import ( - "github.com/liftedinit/manifest-ledger/x/manifest/types" - - "cosmossdk.io/errors" -) - -var ( - ErrGettingMinter = errors.Register(types.ModuleName, 1, "getting minter in ante handler") - ErrManualMintingDisabled = errors.Register(types.ModuleName, 2, "manual minting is disabled due to inflation being >0") -) diff --git a/x/manifest/keeper/keeper.go b/x/manifest/keeper/keeper.go index cc128c8..c84dafc 100644 --- a/x/manifest/keeper/keeper.go +++ b/x/manifest/keeper/keeper.go @@ -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 diff --git a/x/manifest/types/errors.go b/x/manifest/types/errors.go new file mode 100644 index 0000000..cfd4f98 --- /dev/null +++ b/x/manifest/types/errors.go @@ -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") +)