Skip to content

Commit 887a788

Browse files
committed
simplify IsManualMintingEnabled
1 parent 41ab858 commit 887a788

File tree

5 files changed

+18
-22
lines changed

5 files changed

+18
-22
lines changed

app/decorators/inflation_disable_minting.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ func (mfd MsgManualMintFilterDecorator) hasInvalidMsgFromPoAAdmin(ctx sdk.Contex
5151

5252
func (mfd MsgManualMintFilterDecorator) senderAdminOnMintWithInflation(ctx context.Context, sender string) error {
5353
if mfd.isSudoAdminFunc(ctx, sender) {
54-
return mfd.mk.IsManualMintingEnabled(ctx)
54+
if !mfd.mk.IsManualMintingEnabled(ctx) {
55+
return manifesttypes.ErrManualMintingDisabled
56+
}
5557
}
5658

5759
return nil

app/decorators/inflation_disable_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,13 @@ func (s *AnteTestSuite) TestAnteInflationAndMinting() {
104104
name: "fail; inflation enabled, no manual mint from admin",
105105
inflation: true,
106106
msg: tokenfactorytypes.NewMsgMint(poaAdmin.String(), coin),
107-
err: manifestkeeper.ErrManualMintingDisabled.Error(),
107+
err: manifesttypes.ErrManualMintingDisabled.Error(),
108108
},
109109
{
110110
name: "fail; inflation enabled, no manual payout from admin",
111111
inflation: true,
112112
msg: manifesttypes.NewMsgPayoutStakeholders(poaAdmin, coin),
113-
err: manifestkeeper.ErrManualMintingDisabled.Error(),
113+
err: manifesttypes.ErrManualMintingDisabled.Error(),
114114
},
115115
}
116116

x/manifest/keeper/errors.go

-12
This file was deleted.

x/manifest/keeper/keeper.go

+3-7
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,13 @@ func (k *Keeper) GetShareHolders(ctx context.Context) []*types.StakeHolders {
9696
}
9797

9898
// IsManualMintingEnabled returns nil if inflation mint is 0% (disabled)
99-
func (k Keeper) IsManualMintingEnabled(ctx context.Context) error {
99+
func (k Keeper) IsManualMintingEnabled(ctx context.Context) bool {
100100
params, err := k.Params.Get(ctx)
101101
if err != nil {
102-
return err
103-
}
104-
105-
if !params.Inflation.AutomaticEnabled {
106-
return nil
102+
panic(err)
107103
}
108104

109-
return ErrManualMintingDisabled.Wrapf("token inflation: %d", params.Inflation.YearlyAmount)
105+
return !params.Inflation.AutomaticEnabled
110106
}
111107

112108
// Returns the amount of coins to be distributed to the holders

x/manifest/types/errors.go

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package types
2+
3+
import (
4+
"cosmossdk.io/errors"
5+
)
6+
7+
var (
8+
ErrGettingMinter = errors.Register(ModuleName, 1, "getting minter in ante handler")
9+
ErrManualMintingDisabled = errors.Register(ModuleName, 2, "manual minting is disabled due to automatic inflation being on")
10+
)

0 commit comments

Comments
 (0)