Upgrade Swap contracts to Solidity 0.7

now -> block.timestamp
This commit is contained in:
Oskar Thoren 2021-01-28 19:23:11 +08:00
parent 364f67971c
commit de4589c0b6
No known key found for this signature in database
GPG Key ID: BDB55C8C0EF29911
2 changed files with 4 additions and 4 deletions

View File

@ -1,4 +1,4 @@
pragma solidity =0.6.12;
pragma solidity ^0.7.0;
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/math/Math.sol";
import "@openzeppelin/contracts/cryptography/ECDSA.sol";
@ -235,7 +235,7 @@ contract ERC20SimpleSwap {
require(decreaseAmount <= hardDeposit.amount, "SimpleSwap: hard deposit not sufficient");
// if hardDeposit.timeout was never set, apply defaultHardDepositTimeout
uint timeout = hardDeposit.timeout == 0 ? defaultHardDepositTimeout : hardDeposit.timeout;
hardDeposit.canBeDecreasedAt = now + timeout;
hardDeposit.canBeDecreasedAt = block.timestamp + timeout;
hardDeposit.decreaseAmount = decreaseAmount;
emit HardDepositDecreasePrepared(beneficiary, decreaseAmount);
}
@ -246,7 +246,7 @@ contract ERC20SimpleSwap {
*/
function decreaseHardDeposit(address beneficiary) public {
HardDeposit storage hardDeposit = hardDeposits[beneficiary];
require(now >= hardDeposit.canBeDecreasedAt && hardDeposit.canBeDecreasedAt != 0, "SimpleSwap: deposit not yet timed out");
require(block.timestamp >= hardDeposit.canBeDecreasedAt && hardDeposit.canBeDecreasedAt != 0, "SimpleSwap: deposit not yet timed out");
/* this throws if decreaseAmount > amount */
//TODO: if there is a cash-out in between prepareDecreaseHardDeposit and decreaseHardDeposit, decreaseHardDeposit will throw and reducing hard-deposits is impossible.
hardDeposit.amount = hardDeposit.amount.sub(hardDeposit.decreaseAmount);

View File

@ -1,4 +1,4 @@
pragma solidity =0.6.12;
pragma solidity ^0.7.0;
import "./ERC20SimpleSwap.sol";
/**