Skip to content

Commit

Permalink
fix contract
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-nguy committed Aug 9, 2022
1 parent cc23c5c commit a9e4c85
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions integration_tests/contracts/contracts/Gravity.sol
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ struct TransferReverted {
address tokenContract;
address destination;
uint256 amount;
bool activate;
}


Expand Down Expand Up @@ -481,7 +480,7 @@ contract Gravity is ReentrancyGuard, AccessControl, Pausable, Ownable {
function transferNoRevert(address token, address to, uint value) internal {
try this.safeTransferSelf(token,to, value) {
} catch {
state_RevertedVouchers[state_lastRevertedNonce] = TransferReverted(token, to, value, true);
state_RevertedVouchers[state_lastRevertedNonce] = TransferReverted(token, to, value);
state_lastRevertedNonce = state_lastRevertedNonce + 1;
}
}
Expand All @@ -494,13 +493,12 @@ contract Gravity is ReentrancyGuard, AccessControl, Pausable, Ownable {
uint256 _nonce,
address _newDestination
) public nonReentrant {
if(state_RevertedVouchers[_nonce].activate){
TransferReverted memory voucher = state_RevertedVouchers[_nonce];
require(voucher.destination == msg.sender, "Can only be redeemed by intended recipient");
state_RevertedVouchers[_nonce].activate = false;
state_RevertedVouchers[_nonce].amount = 0;
IERC20(voucher.tokenContract).safeTransfer(_newDestination, voucher.amount);
}
TransferReverted memory voucher = state_RevertedVouchers[_nonce];
require(voucher.destination == msg.sender, "Can only be redeemed by intended recipient");
require(state_RevertedVouchers[_nonce].amount > 0, "Voucher has been redeemed already");
// redeemVoucher
state_RevertedVouchers[_nonce].amount = 0;
IERC20(voucher.tokenContract).safeTransfer(_newDestination, voucher.amount);
}

// This makes calls to contracts that execute arbitrary logic
Expand Down

0 comments on commit a9e4c85

Please sign in to comment.