Skip to content

Commit

Permalink
reorder
Browse files Browse the repository at this point in the history
  • Loading branch information
yihuang committed Mar 29, 2024
1 parent f3146d3 commit 5b42837
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions x/bank/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,26 +424,34 @@ func (k BaseKeeper) BurnCoins(ctx context.Context, moduleName string, amounts sd
// it's for evm integration, call at your own risk.
// it emits mint event.
func (k BaseKeeper) AddBalance(ctx context.Context, addr sdk.AccAddress, coin sdk.Coin) error {
sdkCtx := sdk.UnwrapSDKContext(ctx)
if err := k.addCoin(ctx, addr, coin); err != nil {
return err
}

// emit mint event
sdkCtx := sdk.UnwrapSDKContext(ctx)
sdkCtx.EventManager().EmitEvent(
types.NewCoinMintEvent(addr, sdk.NewCoins(coin)),
)
return k.addCoin(ctx, addr, coin)
return nil
}

// SubBalance is low level api to update balance directly, mainly used by evm integration,
// caller should make sure the total supply of the denom not changed.
// it's for evm integration, call at your own risk.
// it emits burn event.
func (k BaseKeeper) SubBalance(ctx context.Context, addr sdk.AccAddress, coin sdk.Coin) error {
lockedCoins := k.LockedCoins(ctx, addr)
if err := k.subCoin(ctx, addr, coin, lockedCoins); err != nil {
return err
}

sdkCtx := sdk.UnwrapSDKContext(ctx)
// emit burn event
sdkCtx.EventManager().EmitEvent(
types.NewCoinBurnEvent(addr, sdk.NewCoins(coin)),
)
lockedCoins := k.LockedCoins(ctx, addr)
return k.subCoin(ctx, addr, coin, lockedCoins)
return nil
}

// setSupply sets the supply for the given coin
Expand Down

0 comments on commit 5b42837

Please sign in to comment.