From 526f925da236059ad6dc494ed23ce5787093bbae Mon Sep 17 00:00:00 2001 From: Facu Spagnuolo Date: Mon, 2 Sep 2019 23:11:09 +0200 Subject: [PATCH] contracts: support solc 0.5 for some lib utils --- contracts/common/Initializable.sol | 2 +- contracts/common/IsContract.sol | 2 +- contracts/common/SafeERC20.sol | 12 ++++++------ contracts/common/TimeHelpers.sol | 2 +- contracts/common/Uint256Helpers.sol | 2 +- contracts/common/UnstructuredStorage.sol | 2 +- contracts/lib/math/SafeMath.sol | 2 +- contracts/lib/math/SafeMath64.sol | 2 +- contracts/lib/misc/Migrations.sol | 11 ++++++----- contracts/lib/token/ERC20.sol | 2 +- 10 files changed, 20 insertions(+), 19 deletions(-) diff --git a/contracts/common/Initializable.sol b/contracts/common/Initializable.sol index d267ab2f1..6431f35aa 100644 --- a/contracts/common/Initializable.sol +++ b/contracts/common/Initializable.sol @@ -2,7 +2,7 @@ * SPDX-License-Identitifer: MIT */ -pragma solidity ^0.4.24; +pragma solidity >=0.4.24 <0.6.0; import "./TimeHelpers.sol"; import "./UnstructuredStorage.sol"; diff --git a/contracts/common/IsContract.sol b/contracts/common/IsContract.sol index 9c5d412b6..212d6cb16 100644 --- a/contracts/common/IsContract.sol +++ b/contracts/common/IsContract.sol @@ -2,7 +2,7 @@ * SPDX-License-Identitifer: MIT */ -pragma solidity ^0.4.24; +pragma solidity >=0.4.24 <0.6.0; contract IsContract { diff --git a/contracts/common/SafeERC20.sol b/contracts/common/SafeERC20.sol index fa11c0921..36ad60a6e 100644 --- a/contracts/common/SafeERC20.sol +++ b/contracts/common/SafeERC20.sol @@ -1,7 +1,7 @@ // Inspired by AdEx (https://github.com/AdExNetwork/adex-protocol-eth/blob/b9df617829661a7518ee10f4cb6c4108659dd6d5/contracts/libs/SafeERC20.sol) // and 0x (https://github.com/0xProject/0x-monorepo/blob/737d1dc54d72872e24abce5a1dbe1b66d35fa21a/contracts/protocol/contracts/protocol/AssetProxy/ERC20Proxy.sol#L143) -pragma solidity ^0.4.24; +pragma solidity >=0.4.24 <0.6.0; import "../lib/token/ERC20.sol"; @@ -91,7 +91,7 @@ library SafeERC20 { _to, _amount ); - return invokeAndCheckSuccess(_token, transferCallData); + return invokeAndCheckSuccess(address(_token), transferCallData); } /** @@ -105,7 +105,7 @@ library SafeERC20 { _to, _amount ); - return invokeAndCheckSuccess(_token, transferFromCallData); + return invokeAndCheckSuccess(address(_token), transferFromCallData); } /** @@ -118,7 +118,7 @@ library SafeERC20 { _spender, _amount ); - return invokeAndCheckSuccess(_token, approveCallData); + return invokeAndCheckSuccess(address(_token), approveCallData); } /** @@ -131,7 +131,7 @@ library SafeERC20 { _owner ); - (bool success, uint256 tokenBalance) = staticInvoke(_token, balanceOfCallData); + (bool success, uint256 tokenBalance) = staticInvoke(address(_token), balanceOfCallData); require(success, ERROR_TOKEN_BALANCE_REVERTED); return tokenBalance; @@ -148,7 +148,7 @@ library SafeERC20 { _spender ); - (bool success, uint256 allowance) = staticInvoke(_token, allowanceCallData); + (bool success, uint256 allowance) = staticInvoke(address(_token), allowanceCallData); require(success, ERROR_TOKEN_ALLOWANCE_REVERTED); return allowance; diff --git a/contracts/common/TimeHelpers.sol b/contracts/common/TimeHelpers.sol index cb9993331..f74858171 100644 --- a/contracts/common/TimeHelpers.sol +++ b/contracts/common/TimeHelpers.sol @@ -2,7 +2,7 @@ * SPDX-License-Identitifer: MIT */ -pragma solidity ^0.4.24; +pragma solidity >=0.4.24 <0.6.0; import "./Uint256Helpers.sol"; diff --git a/contracts/common/Uint256Helpers.sol b/contracts/common/Uint256Helpers.sol index 919b2e955..a0d09ab34 100644 --- a/contracts/common/Uint256Helpers.sol +++ b/contracts/common/Uint256Helpers.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.24; +pragma solidity >=0.4.24 <0.6.0; library Uint256Helpers { diff --git a/contracts/common/UnstructuredStorage.sol b/contracts/common/UnstructuredStorage.sol index db0a56d98..abdd61382 100644 --- a/contracts/common/UnstructuredStorage.sol +++ b/contracts/common/UnstructuredStorage.sol @@ -2,7 +2,7 @@ * SPDX-License-Identitifer: MIT */ -pragma solidity ^0.4.24; +pragma solidity >=0.4.24 <0.6.0; library UnstructuredStorage { diff --git a/contracts/lib/math/SafeMath.sol b/contracts/lib/math/SafeMath.sol index 90fb9e5bb..4cef8a8c6 100644 --- a/contracts/lib/math/SafeMath.sol +++ b/contracts/lib/math/SafeMath.sol @@ -1,7 +1,7 @@ // See https://github.com/OpenZeppelin/openzeppelin-solidity/blob/d51e38758e1d985661534534d5c61e27bece5042/contracts/math/SafeMath.sol // Adapted to use pragma ^0.4.24 and satisfy our linter rules -pragma solidity ^0.4.24; +pragma solidity >=0.4.24 <0.6.0; /** diff --git a/contracts/lib/math/SafeMath64.sol b/contracts/lib/math/SafeMath64.sol index 6243aaa54..bc4e4cdd3 100644 --- a/contracts/lib/math/SafeMath64.sol +++ b/contracts/lib/math/SafeMath64.sol @@ -2,7 +2,7 @@ // Adapted for uint64, pragma ^0.4.24, and satisfying our linter rules // Also optimized the mul() implementation, see https://github.com/aragon/aragonOS/pull/417 -pragma solidity ^0.4.24; +pragma solidity >=0.4.24 <0.6.0; /** diff --git a/contracts/lib/misc/Migrations.sol b/contracts/lib/misc/Migrations.sol index 189ef8031..222dfd7a2 100644 --- a/contracts/lib/misc/Migrations.sol +++ b/contracts/lib/misc/Migrations.sol @@ -1,20 +1,21 @@ -pragma solidity ^0.4.2; +pragma solidity >=0.4.2 <0.6.0; contract Migrations { address public owner; - uint public lastCompletedMigration; + uint256 public lastCompletedMigration; modifier restricted() { - if (msg.sender == owner) + if (msg.sender == owner) { _; + } } - function Migrations() public { + constructor() public { owner = msg.sender; } - function setCompleted(uint completed) restricted public { + function setCompleted(uint256 completed) restricted public { lastCompletedMigration = completed; } diff --git a/contracts/lib/token/ERC20.sol b/contracts/lib/token/ERC20.sol index de963bd12..6be791ed4 100644 --- a/contracts/lib/token/ERC20.sol +++ b/contracts/lib/token/ERC20.sol @@ -1,6 +1,6 @@ // See https://github.com/OpenZeppelin/openzeppelin-solidity/blob/a9f910d34f0ab33a1ae5e714f69f9596a02b4d91/contracts/token/ERC20/ERC20.sol -pragma solidity ^0.4.24; +pragma solidity >=0.4.24 <0.6.0; /**