Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
sainoe committed Jan 23, 2024
1 parent 7f50252 commit 6a22eee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions app/upgrades/v15/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,13 @@ func ClawbackVestingFunds(ctx sdk.Context, address sdk.AccAddress, keepers *keep
return nil
}

// returns if no coins are vesting
_, vestingCoins := vestAccount.GetVestingCoins(ctx.BlockTime()).Find(sk.BondDenom(ctx))
if vestingCoins.IsNil() {
// returns if the account has no vesting coins of the bond denom
vestingCoinToClawback := sdk.Coin{}
if vc := vestAccount.GetVestingCoins(ctx.BlockTime()); !vc.Empty() {
_, vestingCoinToClawback = vc.Find(sk.BondDenom(ctx))
}

if vestingCoinToClawback.IsNil() {
ctx.Logger().Info(
"%s: %s",
"no vesting coins to migrate",
Expand All @@ -172,7 +176,7 @@ func ClawbackVestingFunds(ctx sdk.Context, address sdk.AccAddress, keepers *keep
dk,
bk,
ctx,
vestingCoins,
vestingCoinToClawback,
address,
keepers.GetKey(banktypes.StoreKey),
); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion app/upgrades/v15/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func TestClawbackVestingFunds(t *testing.T) {
require.Equal(t, vestingAccount.GetDelegatedVesting(), origCoins)
require.Empty(t, vestingAccount.GetDelegatedFree())

// check that migration succeeds when all coins are alreay vested
// check that migration succeeds when all coins are already vested
require.NoError(t, v15.ClawbackVestingFunds(ctx.WithBlockTime(endTime), addr, &gaiaApp.AppKeepers))

// vest half of the tokens
Expand Down

0 comments on commit 6a22eee

Please sign in to comment.