Skip to content

Commit

Permalink
Fix issue with vesting logic
Browse files Browse the repository at this point in the history
  • Loading branch information
0a1c committed Mar 28, 2023
1 parent 4d5d3fe commit d1b70eb
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions x/bank/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,17 @@ func (k BaseKeeper) DelegateCoins(ctx sdk.Context, delegatorAddr, moduleAccAddr
return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, amt.String())
}

spendableBalances := k.SpendableCoins(ctx, delegatorAddr)
balances := sdk.NewCoins()

for _, coin := range amt {
ok, spendableBalance := spendableBalances.Find(coin.GetDenom())
if !ok || spendableBalance.IsLT(coin) {
return sdkerrors.Wrapf(
sdkerrors.ErrInsufficientFunds, "failed to delegate; %s is smaller than %s", spendableBalance, amt,
)
}

balance := k.GetBalance(ctx, delegatorAddr, coin.GetDenom())
if balance.IsLT(coin) {
return sdkerrors.Wrapf(
Expand Down

0 comments on commit d1b70eb

Please sign in to comment.