Skip to content

Commit

Permalink
fix: require and satisfy hasbeginblocker interface correclty in x/mint
Browse files Browse the repository at this point in the history
  • Loading branch information
Lockwarr committed Jul 16, 2024
1 parent b4715ae commit 36e9d93
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
6 changes: 4 additions & 2 deletions x/mint/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,11 @@ func predictTotalMinted(totalMinted sdkmath.Uint, normTimePassed, timeAhead sdkm
}

// BeginBlocker mints new tokens for the previous block.
func BeginBlocker(ctx context.Context, k keeper.Keeper) {
func BeginBlocker(ctx context.Context, k keeper.Keeper) error {
c := sdk.UnwrapSDKContext(ctx)
minter := k.GetMinter(ctx)
if minter.TotalMinted.GTE(types.MintingCap) {
return
return errors.New("minting cap has been reached")
}

defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker)
Expand Down Expand Up @@ -206,4 +206,6 @@ func BeginBlocker(ctx context.Context, k keeper.Keeper) {
sdk.NewAttribute(sdk.AttributeKeyAmount, coinAmount.String()),
),
)

return nil
}
9 changes: 5 additions & 4 deletions x/mint/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ var (
_ module.AppModuleSimulation = (*AppModule)(nil)
_ module.HasABCIGenesis = (*AppModule)(nil)

_ appmodule.AppModule = (*AppModule)(nil)
_ module.HasABCIEndBlock = (*AppModule)(nil)
_ appmodule.AppModule = (*AppModule)(nil)
_ module.HasABCIEndBlock = (*AppModule)(nil)
_ appmodule.HasBeginBlocker = (*AppModule)(nil)
)

// AppModuleBasic defines the basic application module used by the mint module.
Expand Down Expand Up @@ -166,8 +167,8 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion }

// BeginBlock returns the begin blocker for the mint module.
func (am AppModule) BeginBlock(ctx context.Context) {
BeginBlocker(ctx, am.keeper)
func (am AppModule) BeginBlock(ctx context.Context) error {
return BeginBlocker(ctx, am.keeper)
}

// EndBlock returns the end blocker for the mint module. It returns no validator
Expand Down

0 comments on commit 36e9d93

Please sign in to comment.