Skip to content

Commit

Permalink
fix: skip validation flag in subUnockedCoins()
Browse files Browse the repository at this point in the history
  • Loading branch information
kakysha committed Jun 10, 2024
1 parent bc84b8c commit fc7ff68
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions x/bank/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func (k BaseKeeper) UndelegateCoins(ctx context.Context, moduleAccAddr, delegato
return errorsmod.Wrap(sdkerrors.ErrInvalidCoins, amt.String())
}

err := k.subUnlockedCoins(ctx, moduleAccAddr, amt)
err := k.subUnlockedCoins(ctx, moduleAccAddr, amt, false)
if err != nil {
return err
}
Expand Down Expand Up @@ -393,7 +393,7 @@ func (k BaseKeeper) BurnCoins(ctx context.Context, moduleName string, amounts sd
panic(errorsmod.Wrapf(sdkerrors.ErrUnauthorized, "module account %s does not have permissions to burn tokens", moduleName))
}

err := k.subUnlockedCoins(ctx, acc.GetAddress(), amounts)
err := k.subUnlockedCoins(ctx, acc.GetAddress(), amounts, false)
if err != nil {
return err
}
Expand Down
13 changes: 8 additions & 5 deletions x/bank/keeper/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func (k BaseSendKeeper) InputOutputCoins(ctx context.Context, input types.Input,
}
}

err = k.subUnlockedCoins(ctx, inAddress, input.Coins)
err = k.subUnlockedCoins(ctx, inAddress, input.Coins, true)
if err != nil {
return err
}
Expand Down Expand Up @@ -222,7 +222,7 @@ func (k BaseSendKeeper) SendCoins(ctx context.Context, fromAddr, toAddr sdk.AccA
return err
}

err = k.subUnlockedCoins(ctx, fromAddr, amt)
err = k.subUnlockedCoins(ctx, fromAddr, amt, true)
if err != nil {
return err
}
Expand Down Expand Up @@ -297,9 +297,12 @@ func (k BaseSendKeeper) validateCoinsBeforeSend(ctx context.Context, addr sdk.Ac
// subUnlockedCoins removes the unlocked amt coins of the given account. An error is
// returned if the resulting balance is negative or the initial amount is invalid.
// A coin_spent event is emitted after.
func (k BaseSendKeeper) subUnlockedCoins(ctx context.Context, addr sdk.AccAddress, amt sdk.Coins) error {
if err := k.validateCoinsBeforeSend(ctx, addr, amt); err != nil {
return err
func (k BaseSendKeeper) subUnlockedCoins(ctx context.Context, addr sdk.AccAddress, amt sdk.Coins, skipValidation bool) error {
if !skipValidation {
err := k.validateCoinsBeforeSend(ctx, addr, amt)
if err != nil {
return err
}
}

for _, coin := range amt {
Expand Down

0 comments on commit fc7ff68

Please sign in to comment.