Skip to content

Commit

Permalink
Check if balance of the refund addess is positive
Browse files Browse the repository at this point in the history
  • Loading branch information
stana-miric committed Jan 6, 2023
1 parent 1f07652 commit 3d5df32
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/upgrades/v8/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,12 @@ func QuicksilverFix(ctx sdk.Context, keepers *keepers.AppKeepers) error {

// Get balance from stuck address and subtract 1 uatom sent by bad actor
sourceBalance := keepers.BankKeeper.GetBalance(ctx, sourceAddress, "uatom")
refundBalance := sourceBalance.SubAmount(sdk.NewInt(1))
err = keepers.BankKeeper.SendCoins(ctx, sourceAddress, destinationAddress, sdk.NewCoins(refundBalance))
if err != nil {
return errors.New("unable to refund coins")
if sourceBalance.IsGTE(sdk.NewCoin("uatom", sdk.NewInt(1))) {
refundBalance := sourceBalance.SubAmount(sdk.NewInt(1))
err = keepers.BankKeeper.SendCoins(ctx, sourceAddress, destinationAddress, sdk.NewCoins(refundBalance))
if err != nil {
return errors.New("unable to refund coins")
}
}

// Close channels
Expand Down

0 comments on commit 3d5df32

Please # to comment.