From 0f0ef466d4137d34767ba25e9443b2af9614ef13 Mon Sep 17 00:00:00 2001 From: Ralph Pichler Date: Fri, 26 Mar 2021 19:59:37 +0100 Subject: [PATCH] upgrade to solidity 0.7.6 (#123) --- contracts/ERC20SimpleSwap.sol | 6 +++--- contracts/SimpleSwapFactory.sol | 4 ++-- contracts/TestToken.sol | 4 ++-- hardhat.config.js | 2 +- package.json | 2 +- yarn.lock | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/contracts/ERC20SimpleSwap.sol b/contracts/ERC20SimpleSwap.sol index 34aca99..73331b0 100644 --- a/contracts/ERC20SimpleSwap.sol +++ b/contracts/ERC20SimpleSwap.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity =0.6.12; +pragma solidity =0.7.6; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/math/Math.sol"; import "@openzeppelin/contracts/cryptography/ECDSA.sol"; @@ -241,7 +241,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); } @@ -252,7 +252,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); diff --git a/contracts/SimpleSwapFactory.sol b/contracts/SimpleSwapFactory.sol index 5db51a0..c8ebfbc 100644 --- a/contracts/SimpleSwapFactory.sol +++ b/contracts/SimpleSwapFactory.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity =0.6.12; +pragma solidity =0.7.6; import "./ERC20SimpleSwap.sol"; import "@openzeppelin/contracts/proxy/Clones.sol"; @@ -21,7 +21,7 @@ contract SimpleSwapFactory { /* address of the code contract from which all chequebooks are cloned */ address public master; - constructor(address _ERC20Address) public { + constructor(address _ERC20Address) { ERC20Address = _ERC20Address; ERC20SimpleSwap _master = new ERC20SimpleSwap(); // set the issuer of the master contract to prevent misuse diff --git a/contracts/TestToken.sol b/contracts/TestToken.sol index 89066e8..6310f99 100644 --- a/contracts/TestToken.sol +++ b/contracts/TestToken.sol @@ -1,11 +1,11 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity ^0.6.12; +pragma solidity =0.7.6; import "@openzeppelin/contracts/presets/ERC20PresetMinterPauser.sol"; contract TestToken is ERC20PresetMinterPauser { - constructor() ERC20PresetMinterPauser("Test", "TST") public { + constructor() ERC20PresetMinterPauser("Test", "TST") { } } diff --git a/hardhat.config.js b/hardhat.config.js index 7599e2e..5d43ed2 100644 --- a/hardhat.config.js +++ b/hardhat.config.js @@ -15,7 +15,7 @@ const accounts = { mnemonic }; // Config for hardhat. module.exports = { - solidity: { version: '0.6.12' }, + solidity: { version: '0.7.6' }, networks: { hardhat: { accounts, diff --git a/package.json b/package.json index a11624c..c0bf2ce 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "url": "https://github.com/ethersphere/swap-swear-and-swindle.git" }, "dependencies": { - "@openzeppelin/contracts": "^3.4.1" + "@openzeppelin/contracts": "^3.4.1-solc-0.7-2" }, "devDependencies": { "@nomiclabs/hardhat-truffle5": "^2.0.0", diff --git a/yarn.lock b/yarn.lock index 16fab77..0f176c7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -295,7 +295,7 @@ find-up "^4.1.0" fs-extra "^8.1.0" -"@openzeppelin/contracts@^3.4.1": +"@openzeppelin/contracts@^3.4.1-solc-0.7-2": version "3.4.1" resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-3.4.1.tgz#03c891fec7f93be0ae44ed74e57a122a38732ce7" integrity sha512-cUriqMauq1ylzP2TxePNdPqkwI7Le3Annh4K9rrpvKfSBB/bdW+Iu1ihBaTIABTAAJ85LmKL5SSPPL9ry8d1gQ==