From 974c534210ab3347bdaa45f0f07cfe298a8a6866 Mon Sep 17 00:00:00 2001 From: Andre Korol Date: Thu, 14 Jan 2021 22:38:53 +0000 Subject: [PATCH] Update contracts to support Solidity 0.8.x (#2442) Co-authored-by: Francisco Giordano --- .github/workflows/test.yml | 2 + README.md | 2 +- buidler.config.js | 2 +- contracts/GSN/Context.sol | 4 +- contracts/GSN/GSNRecipient.sol | 6 +- contracts/GSN/GSNRecipientERC20Fee.sol | 14 ++- contracts/GSN/GSNRecipientSignature.sol | 4 +- contracts/GSN/IRelayHub.sol | 2 +- contracts/GSN/IRelayRecipient.sol | 2 +- contracts/access/AccessControl.sol | 2 +- contracts/access/Ownable.sol | 4 +- contracts/access/TimelockController.sol | 8 +- contracts/cryptography/ECDSA.sol | 2 +- contracts/cryptography/MerkleProof.sol | 2 +- contracts/drafts/EIP712.sol | 17 +--- contracts/drafts/ERC20Permit.sol | 4 +- contracts/drafts/IERC20Permit.sol | 2 +- contracts/introspection/ERC165.sol | 4 +- contracts/introspection/ERC165Checker.sol | 2 +- .../introspection/ERC1820Implementer.sol | 2 +- contracts/introspection/IERC165.sol | 2 +- .../introspection/IERC1820Implementer.sol | 2 +- contracts/introspection/IERC1820Registry.sol | 2 +- contracts/math/Math.sol | 2 +- contracts/math/SafeMath.sol | 97 ++----------------- contracts/math/SignedSafeMath.sol | 41 ++------ contracts/mocks/AccessControlMock.sol | 4 +- contracts/mocks/AddressImpl.sol | 2 +- contracts/mocks/ArraysImpl.sol | 4 +- contracts/mocks/BadBeacon.sol | 2 +- contracts/mocks/CallReceiverMock.sol | 2 +- contracts/mocks/ClashingImplementation.sol | 2 +- contracts/mocks/ConditionalEscrowMock.sol | 2 +- contracts/mocks/ContextMock.sol | 2 +- contracts/mocks/CountersImpl.sol | 2 +- contracts/mocks/Create2Impl.sol | 2 +- contracts/mocks/DummyImplementation.sol | 2 +- contracts/mocks/ECDSAMock.sol | 2 +- contracts/mocks/EIP712External.sol | 11 +-- contracts/mocks/ERC1155BurnableMock.sol | 4 +- contracts/mocks/ERC1155Mock.sol | 4 +- contracts/mocks/ERC1155PausableMock.sol | 4 +- contracts/mocks/ERC1155ReceiverMock.sol | 3 +- .../ERC165/ERC165InterfacesSupported.sol | 6 +- contracts/mocks/ERC165/ERC165NotSupported.sol | 2 +- contracts/mocks/ERC165CheckerMock.sol | 2 +- contracts/mocks/ERC165Mock.sol | 2 +- contracts/mocks/ERC1820ImplementerMock.sol | 2 +- contracts/mocks/ERC20BurnableMock.sol | 4 +- contracts/mocks/ERC20CappedMock.sol | 4 +- contracts/mocks/ERC20DecimalsMock.sol | 4 +- contracts/mocks/ERC20Mock.sol | 4 +- contracts/mocks/ERC20PausableMock.sol | 4 +- contracts/mocks/ERC20PermitMock.sol | 11 +-- contracts/mocks/ERC20SnapshotMock.sol | 4 +- contracts/mocks/ERC721BurnableMock.sol | 4 +- contracts/mocks/ERC721GSNRecipientMock.sol | 5 +- contracts/mocks/ERC721Mock.sol | 4 +- contracts/mocks/ERC721PausableMock.sol | 4 +- contracts/mocks/ERC721ReceiverMock.sol | 4 +- contracts/mocks/ERC777Mock.sol | 4 +- contracts/mocks/ERC777SenderRecipientMock.sol | 2 +- contracts/mocks/EnumerableMapMock.sol | 2 +- contracts/mocks/EnumerableSetMock.sol | 2 +- contracts/mocks/EtherReceiverMock.sol | 2 +- contracts/mocks/GSNRecipientERC20FeeMock.sol | 4 +- contracts/mocks/GSNRecipientMock.sol | 4 +- contracts/mocks/GSNRecipientSignatureMock.sol | 4 +- contracts/mocks/InitializableMock.sol | 2 +- contracts/mocks/MathMock.sol | 2 +- contracts/mocks/MerkleProofWrapper.sol | 2 +- .../MultipleInheritanceInitializableMocks.sol | 2 +- contracts/mocks/OwnableMock.sol | 2 +- contracts/mocks/PausableMock.sol | 4 +- contracts/mocks/PullPaymentMock.sol | 4 +- contracts/mocks/ReentrancyAttack.sol | 2 +- contracts/mocks/ReentrancyMock.sol | 4 +- contracts/mocks/RegressionImplementation.sol | 2 +- contracts/mocks/SafeCastMock.sol | 2 +- contracts/mocks/SafeERC20Helper.sol | 4 +- contracts/mocks/SafeMathMock.sol | 2 +- contracts/mocks/SignedSafeMathMock.sol | 2 +- .../SingleInheritanceInitializableMocks.sol | 2 +- contracts/mocks/StringsMock.sol | 2 +- contracts/payment/PaymentSplitter.sol | 17 ++-- contracts/payment/PullPayment.sol | 4 +- .../payment/escrow/ConditionalEscrow.sol | 2 +- contracts/payment/escrow/Escrow.sol | 6 +- contracts/payment/escrow/RefundEscrow.sol | 4 +- .../presets/ERC1155PresetMinterPauser.sol | 4 +- contracts/presets/ERC20PresetFixedSupply.sol | 4 +- contracts/presets/ERC20PresetMinterPauser.sol | 4 +- .../ERC721PresetMinterPauserAutoId.sol | 4 +- contracts/presets/ERC777PresetFixedSupply.sol | 4 +- contracts/proxy/BeaconProxy.sol | 4 +- contracts/proxy/IBeacon.sol | 2 +- contracts/proxy/Initializable.sol | 2 +- contracts/proxy/Proxy.sol | 2 +- contracts/proxy/ProxyAdmin.sol | 2 +- .../proxy/TransparentUpgradeableProxy.sol | 4 +- contracts/proxy/UpgradeableBeacon.sol | 4 +- contracts/proxy/UpgradeableProxy.sol | 4 +- contracts/token/ERC1155/ERC1155.sol | 31 ++---- contracts/token/ERC1155/ERC1155Burnable.sol | 2 +- contracts/token/ERC1155/ERC1155Holder.sol | 2 +- contracts/token/ERC1155/ERC1155Pausable.sol | 2 +- contracts/token/ERC1155/ERC1155Receiver.sol | 4 +- contracts/token/ERC1155/IERC1155.sol | 2 +- .../token/ERC1155/IERC1155MetadataURI.sol | 2 +- contracts/token/ERC1155/IERC1155Receiver.sol | 2 +- contracts/token/ERC20/ERC20.sol | 25 +++-- contracts/token/ERC20/ERC20Burnable.sol | 6 +- contracts/token/ERC20/ERC20Capped.sol | 8 +- contracts/token/ERC20/ERC20Pausable.sol | 2 +- contracts/token/ERC20/ERC20Snapshot.sol | 4 +- contracts/token/ERC20/IERC20.sol | 2 +- contracts/token/ERC20/SafeERC20.sol | 8 +- contracts/token/ERC20/TokenTimelock.sol | 4 +- contracts/token/ERC721/ERC721.sol | 6 +- contracts/token/ERC721/ERC721Burnable.sol | 2 +- contracts/token/ERC721/ERC721Holder.sol | 2 +- contracts/token/ERC721/ERC721Pausable.sol | 2 +- contracts/token/ERC721/IERC721.sol | 2 +- contracts/token/ERC721/IERC721Enumerable.sol | 2 +- contracts/token/ERC721/IERC721Metadata.sol | 2 +- contracts/token/ERC721/IERC721Receiver.sol | 2 +- contracts/token/ERC777/ERC777.sol | 20 ++-- contracts/token/ERC777/IERC777.sol | 2 +- contracts/token/ERC777/IERC777Recipient.sol | 2 +- contracts/token/ERC777/IERC777Sender.sol | 2 +- contracts/utils/Address.sol | 2 +- contracts/utils/Arrays.sol | 2 +- contracts/utils/Counters.sol | 12 +-- contracts/utils/Create2.sol | 2 +- contracts/utils/EnumerableMap.sol | 2 +- contracts/utils/EnumerableSet.sol | 2 +- contracts/utils/Pausable.sol | 4 +- contracts/utils/ReentrancyGuard.sol | 4 +- contracts/utils/SafeCast.sol | 2 +- contracts/utils/Strings.sol | 6 +- docs/modules/ROOT/pages/access-control.adoc | 10 +- docs/modules/ROOT/pages/erc1155.adoc | 6 +- docs/modules/ROOT/pages/erc20-supply.adoc | 8 +- docs/modules/ROOT/pages/erc20.adoc | 2 +- docs/modules/ROOT/pages/erc721.adoc | 4 +- docs/modules/ROOT/pages/erc777.adoc | 2 +- .../ROOT/pages/extending-contracts.adoc | 6 +- docs/modules/ROOT/pages/gsn-strategies.adoc | 8 +- docs/modules/ROOT/pages/index.adoc | 2 +- test/math/SafeMath.test.js | 16 +-- test/math/SignedSafeMath.test.js | 22 ++--- test/token/ERC1155/ERC1155.behavior.js | 6 +- test/token/ERC1155/ERC1155.test.js | 9 +- test/token/ERC20/ERC20.behavior.js | 16 +-- test/token/ERC20/ERC20.test.js | 16 +-- test/token/ERC20/SafeERC20.test.js | 7 +- .../ERC20/behaviors/ERC20Burnable.behavior.js | 12 +-- test/utils/Address.test.js | 5 +- test/utils/Counters.test.js | 2 +- 159 files changed, 338 insertions(+), 509 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 558ae0c58..0f80782ba 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -42,4 +42,6 @@ jobs: - run: npm ci if: steps.cache.outputs.cache-hit != 'true' - run: npm run coverage + env: + NODE_OPTIONS: --max_old_space_size=4096 - uses: codecov/codecov-action@v1 diff --git a/README.md b/README.md index 80aa66830..013e5eb76 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ OpenZeppelin Contracts features a [stable API](https://docs.openzeppelin.com/con Once installed, you can use the contracts in the library by importing them: ```solidity -pragma solidity ^0.6.0; +pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; diff --git a/buidler.config.js b/buidler.config.js index bf28eeedb..0738bdd74 100644 --- a/buidler.config.js +++ b/buidler.config.js @@ -15,6 +15,6 @@ module.exports = { }, }, solc: { - version: '0.6.12', + version: '0.8.0', }, }; diff --git a/contracts/GSN/Context.sol b/contracts/GSN/Context.sol index 3d07c4aad..b8fca57b0 100644 --- a/contracts/GSN/Context.sol +++ b/contracts/GSN/Context.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the @@ -13,7 +13,7 @@ pragma solidity >=0.6.0 <0.8.0; * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { - function _msgSender() internal view virtual returns (address payable) { + function _msgSender() internal view virtual returns (address) { return msg.sender; } diff --git a/contracts/GSN/GSNRecipient.sol b/contracts/GSN/GSNRecipient.sol index ae0c795b3..6504b5308 100644 --- a/contracts/GSN/GSNRecipient.sol +++ b/contracts/GSN/GSNRecipient.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "./IRelayRecipient.sol"; import "./IRelayHub.sol"; @@ -87,7 +87,7 @@ abstract contract GSNRecipient is IRelayRecipient, Context { * * IMPORTANT: Contracts derived from {GSNRecipient} should never use `msg.sender`, and use {_msgSender} instead. */ - function _msgSender() internal view virtual override returns (address payable) { + function _msgSender() internal view virtual override returns (address) { if (msg.sender != _relayHub) { return msg.sender; } else { @@ -192,7 +192,7 @@ abstract contract GSNRecipient is IRelayRecipient, Context { return (gas * gasPrice * (100 + serviceFee)) / 100; } - function _getRelayedCallSender() private pure returns (address payable result) { + function _getRelayedCallSender() private pure returns (address result) { // We need to read 20 bytes (an address) located at array index msg.data.length - 20. In memory, the array // is prefixed with a 32-byte length value, so we first add 32 to get the memory read index. However, doing // so would leave the address in the upper 20 bytes of the 32-byte word, which is inconvenient and would diff --git a/contracts/GSN/GSNRecipientERC20Fee.sol b/contracts/GSN/GSNRecipientERC20Fee.sol index 1abe9f3b1..6ea35b106 100644 --- a/contracts/GSN/GSNRecipientERC20Fee.sol +++ b/contracts/GSN/GSNRecipientERC20Fee.sol @@ -1,9 +1,8 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "./GSNRecipient.sol"; -import "../math/SafeMath.sol"; import "../access/Ownable.sol"; import "../token/ERC20/SafeERC20.sol"; import "../token/ERC20/ERC20.sol"; @@ -19,7 +18,6 @@ import "../token/ERC20/ERC20.sol"; */ contract GSNRecipientERC20Fee is GSNRecipient { using SafeERC20 for __unstable__ERC20Owned; - using SafeMath for uint256; enum GSNRecipientERC20FeeErrorCodes { INSUFFICIENT_BALANCE @@ -30,7 +28,7 @@ contract GSNRecipientERC20Fee is GSNRecipient { /** * @dev The arguments to the constructor are the details that the gas payment token will have: `name` and `symbol`. `decimals` is hard-coded to 18. */ - constructor(string memory name, string memory symbol) public { + constructor(string memory name, string memory symbol) { _token = new __unstable__ERC20Owned(name, symbol); } @@ -100,11 +98,11 @@ contract GSNRecipientERC20Fee is GSNRecipient { // actualCharge is an _estimated_ charge, which assumes postRelayedCall will use all available gas. // This implementation's gas cost can be roughly estimated as 10k gas, for the two SSTORE operations in an // ERC20 transfer. - uint256 overestimation = _computeCharge(_POST_RELAYED_CALL_MAX_GAS.sub(10000), gasPrice, transactionFee); - actualCharge = actualCharge.sub(overestimation); + uint256 overestimation = _computeCharge(_POST_RELAYED_CALL_MAX_GAS - 10000, gasPrice, transactionFee); + actualCharge = actualCharge - overestimation; // After the relayed call has been executed and the actual charge estimated, the excess pre-charge is returned - _token.safeTransfer(from, maxPossibleCharge.sub(actualCharge)); + _token.safeTransfer(from, maxPossibleCharge - actualCharge); } } @@ -118,7 +116,7 @@ contract GSNRecipientERC20Fee is GSNRecipient { contract __unstable__ERC20Owned is ERC20, Ownable { uint256 private constant _UINT256_MAX = 2**256 - 1; - constructor(string memory name, string memory symbol) public ERC20(name, symbol) { } + constructor(string memory name, string memory symbol) ERC20(name, symbol) { } // The owner (GSNRecipientERC20Fee) can mint tokens function mint(address account, uint256 amount) public onlyOwner { diff --git a/contracts/GSN/GSNRecipientSignature.sol b/contracts/GSN/GSNRecipientSignature.sol index e61939494..6813cc631 100644 --- a/contracts/GSN/GSNRecipientSignature.sol +++ b/contracts/GSN/GSNRecipientSignature.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "./GSNRecipient.sol"; import "../cryptography/ECDSA.sol"; @@ -23,7 +23,7 @@ contract GSNRecipientSignature is GSNRecipient { /** * @dev Sets the trusted signer that is going to be producing signatures to approve relayed calls. */ - constructor(address trustedSigner) public { + constructor(address trustedSigner) { require(trustedSigner != address(0), "GSNRecipientSignature: trusted signer is the zero address"); _trustedSigner = trustedSigner; } diff --git a/contracts/GSN/IRelayHub.sol b/contracts/GSN/IRelayHub.sol index 34930334a..7fb421681 100644 --- a/contracts/GSN/IRelayHub.sol +++ b/contracts/GSN/IRelayHub.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; /** * @dev Interface for `RelayHub`, the core contract of the GSN. Users should not need to interact with this contract diff --git a/contracts/GSN/IRelayRecipient.sol b/contracts/GSN/IRelayRecipient.sol index 0257e6551..39d690e15 100644 --- a/contracts/GSN/IRelayRecipient.sol +++ b/contracts/GSN/IRelayRecipient.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; /** * @dev Base interface for a contract that will be called via the GSN from {IRelayHub}. diff --git a/contracts/access/AccessControl.sol b/contracts/access/AccessControl.sol index 395e9a413..e02605bce 100644 --- a/contracts/access/AccessControl.sol +++ b/contracts/access/AccessControl.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../utils/EnumerableSet.sol"; import "../utils/Address.sol"; diff --git a/contracts/access/Ownable.sol b/contracts/access/Ownable.sol index 0223a15fe..a9419294f 100644 --- a/contracts/access/Ownable.sol +++ b/contracts/access/Ownable.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../GSN/Context.sol"; /** @@ -23,7 +23,7 @@ abstract contract Ownable is Context { /** * @dev Initializes the contract setting the deployer as the initial owner. */ - constructor () internal { + constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); diff --git a/contracts/access/TimelockController.sol b/contracts/access/TimelockController.sol index f96f37152..2a43b92ea 100644 --- a/contracts/access/TimelockController.sol +++ b/contracts/access/TimelockController.sol @@ -1,9 +1,7 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.9 <0.8.0; -pragma experimental ABIEncoderV2; +pragma solidity ^0.8.0; -import "./../math/SafeMath.sol"; import "./AccessControl.sol"; /** @@ -52,7 +50,7 @@ contract TimelockController is AccessControl { /** * @dev Initializes the contract with a given `minDelay`. */ - constructor(uint256 minDelay, address[] memory proposers, address[] memory executors) public { + constructor(uint256 minDelay, address[] memory proposers, address[] memory executors) { _setRoleAdmin(TIMELOCK_ADMIN_ROLE, TIMELOCK_ADMIN_ROLE); _setRoleAdmin(PROPOSER_ROLE, TIMELOCK_ADMIN_ROLE); _setRoleAdmin(EXECUTOR_ROLE, TIMELOCK_ADMIN_ROLE); @@ -188,7 +186,7 @@ contract TimelockController is AccessControl { require(_timestamps[id] == 0, "TimelockController: operation already scheduled"); require(delay >= _minDelay, "TimelockController: insufficient delay"); // solhint-disable-next-line not-rely-on-time - _timestamps[id] = SafeMath.add(block.timestamp, delay); + _timestamps[id] = block.timestamp + delay; } /** diff --git a/contracts/cryptography/ECDSA.sol b/contracts/cryptography/ECDSA.sol index 74326eab8..e70815df1 100644 --- a/contracts/cryptography/ECDSA.sol +++ b/contracts/cryptography/ECDSA.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. diff --git a/contracts/cryptography/MerkleProof.sol b/contracts/cryptography/MerkleProof.sol index 665a93a3d..65463889c 100644 --- a/contracts/cryptography/MerkleProof.sol +++ b/contracts/cryptography/MerkleProof.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; /** * @dev These functions deal with verification of Merkle trees (hash trees), diff --git a/contracts/drafts/EIP712.sol b/contracts/drafts/EIP712.sol index 8e528767c..34fa345a3 100644 --- a/contracts/drafts/EIP712.sol +++ b/contracts/drafts/EIP712.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. @@ -43,13 +43,13 @@ abstract contract EIP712 { * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ - constructor(string memory name, string memory version) internal { + constructor(string memory name, string memory version) { bytes32 hashedName = keccak256(bytes(name)); bytes32 hashedVersion = keccak256(bytes(version)); bytes32 typeHash = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"); _HASHED_NAME = hashedName; _HASHED_VERSION = hashedVersion; - _CACHED_CHAIN_ID = _getChainId(); + _CACHED_CHAIN_ID = block.chainid; _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion); _TYPE_HASH = typeHash; } @@ -58,7 +58,7 @@ abstract contract EIP712 { * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view returns (bytes32) { - if (_getChainId() == _CACHED_CHAIN_ID) { + if (block.chainid == _CACHED_CHAIN_ID) { return _CACHED_DOMAIN_SEPARATOR; } else { return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION); @@ -71,7 +71,7 @@ abstract contract EIP712 { typeHash, name, version, - _getChainId(), + block.chainid, address(this) ) ); @@ -95,11 +95,4 @@ abstract contract EIP712 { function _hashTypedDataV4(bytes32 structHash) internal view returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", _domainSeparatorV4(), structHash)); } - - function _getChainId() private pure returns (uint256 chainId) { - // solhint-disable-next-line no-inline-assembly - assembly { - chainId := chainid() - } - } } diff --git a/contracts/drafts/ERC20Permit.sol b/contracts/drafts/ERC20Permit.sol index 7edee3fd1..f05a9aedd 100644 --- a/contracts/drafts/ERC20Permit.sol +++ b/contracts/drafts/ERC20Permit.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.5 <0.8.0; +pragma solidity ^0.8.0; import "../token/ERC20/ERC20.sol"; import "./IERC20Permit.sol"; @@ -29,7 +29,7 @@ abstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 { * * It's a good idea to use the same `name` that is defined as the ERC20 token name. */ - constructor(string memory name) internal EIP712(name, "1") { + constructor(string memory name) EIP712(name, "1") { } /** diff --git a/contracts/drafts/IERC20Permit.sol b/contracts/drafts/IERC20Permit.sol index ccdf81d95..0da72211d 100644 --- a/contracts/drafts/IERC20Permit.sol +++ b/contracts/drafts/IERC20Permit.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in diff --git a/contracts/introspection/ERC165.sol b/contracts/introspection/ERC165.sol index 79e5f6460..fa16eaa3a 100644 --- a/contracts/introspection/ERC165.sol +++ b/contracts/introspection/ERC165.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "./IERC165.sol"; @@ -21,7 +21,7 @@ abstract contract ERC165 is IERC165 { */ mapping(bytes4 => bool) private _supportedInterfaces; - constructor () internal { + constructor () { // Derived contracts need only register support for their own interfaces, // we register support for ERC165 itself here _registerInterface(_INTERFACE_ID_ERC165); diff --git a/contracts/introspection/ERC165Checker.sol b/contracts/introspection/ERC165Checker.sol index 75eb50ee4..4a7ae88dc 100644 --- a/contracts/introspection/ERC165Checker.sol +++ b/contracts/introspection/ERC165Checker.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.2 <0.8.0; +pragma solidity ^0.8.0; /** * @dev Library used to query support of an interface declared via {IERC165}. diff --git a/contracts/introspection/ERC1820Implementer.sol b/contracts/introspection/ERC1820Implementer.sol index 69b644e9d..c73fdda32 100644 --- a/contracts/introspection/ERC1820Implementer.sol +++ b/contracts/introspection/ERC1820Implementer.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "./IERC1820Implementer.sol"; diff --git a/contracts/introspection/IERC165.sol b/contracts/introspection/IERC165.sol index d47435525..01c9c0864 100644 --- a/contracts/introspection/IERC165.sol +++ b/contracts/introspection/IERC165.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the diff --git a/contracts/introspection/IERC1820Implementer.sol b/contracts/introspection/IERC1820Implementer.sol index c507da0cc..a7c1ce0e5 100644 --- a/contracts/introspection/IERC1820Implementer.sol +++ b/contracts/introspection/IERC1820Implementer.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; /** * @dev Interface for an ERC1820 implementer, as defined in the diff --git a/contracts/introspection/IERC1820Registry.sol b/contracts/introspection/IERC1820Registry.sol index e63bf0417..75da55687 100644 --- a/contracts/introspection/IERC1820Registry.sol +++ b/contracts/introspection/IERC1820Registry.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; /** * @dev Interface of the global ERC1820 Registry, as defined in the diff --git a/contracts/math/Math.sol b/contracts/math/Math.sol index a0c35b5a2..414da4b00 100644 --- a/contracts/math/Math.sol +++ b/contracts/math/Math.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. diff --git a/contracts/math/SafeMath.sol b/contracts/math/SafeMath.sol index 7975c634c..c1e476e57 100644 --- a/contracts/math/SafeMath.sol +++ b/contracts/math/SafeMath.sol @@ -1,19 +1,9 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; /** - * @dev Wrappers over Solidity's arithmetic operations with added overflow - * checks. - * - * Arithmetic operations in Solidity wrap on overflow. This can easily result - * in bugs, because programmers usually assume that an overflow raises an - * error, which is the standard behavior in high level programming languages. - * `SafeMath` restores this intuition by reverting the transaction when an - * operation overflows. - * - * Using this library instead of the unchecked operations eliminates an entire - * class of bugs, so it's recommended to use it always. + * @dev Wrappers over Solidity's arithmetic operations. */ library SafeMath { /** @@ -27,10 +17,7 @@ library SafeMath { * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { - uint256 c = a + b; - require(c >= a, "SafeMath: addition overflow"); - - return c; + return a + b; } /** @@ -44,24 +31,7 @@ library SafeMath { * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { - return sub(a, b, "SafeMath: subtraction overflow"); - } - - /** - * @dev Returns the subtraction of two unsigned integers, reverting with custom message on - * overflow (when the result is negative). - * - * Counterpart to Solidity's `-` operator. - * - * Requirements: - * - * - Subtraction cannot overflow. - */ - function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { - require(b <= a, errorMessage); - uint256 c = a - b; - - return c; + return a - b; } /** @@ -75,85 +45,34 @@ library SafeMath { * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { - // Gas optimization: this is cheaper than requiring 'a' not being zero, but the - // benefit is lost if 'b' is also tested. - // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 - if (a == 0) { - return 0; - } - - uint256 c = a * b; - require(c / a == b, "SafeMath: multiplication overflow"); - - return c; + return a * b; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * - * Counterpart to Solidity's `/` operator. Note: this function uses a - * `revert` opcode (which leaves remaining gas untouched) while Solidity - * uses an invalid opcode to revert (consuming all remaining gas). + * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { - return div(a, b, "SafeMath: division by zero"); - } - - /** - * @dev Returns the integer division of two unsigned integers. Reverts with custom message on - * division by zero. The result is rounded towards zero. - * - * Counterpart to Solidity's `/` operator. Note: this function uses a - * `revert` opcode (which leaves remaining gas untouched) while Solidity - * uses an invalid opcode to revert (consuming all remaining gas). - * - * Requirements: - * - * - The divisor cannot be zero. - */ - function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { - require(b > 0, errorMessage); - uint256 c = a / b; - // assert(a == b * c + a % b); // There is no case in which this doesn't hold - - return c; + return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * - * Counterpart to Solidity's `%` operator. This function uses a `revert` - * opcode (which leaves remaining gas untouched) while Solidity uses an - * invalid opcode to revert (consuming all remaining gas). + * Counterpart to Solidity's `%` operator. * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { - return mod(a, b, "SafeMath: modulo by zero"); - } - - /** - * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), - * Reverts with custom message when dividing by zero. - * - * Counterpart to Solidity's `%` operator. This function uses a `revert` - * opcode (which leaves remaining gas untouched) while Solidity uses an - * invalid opcode to revert (consuming all remaining gas). - * - * Requirements: - * - * - The divisor cannot be zero. - */ - function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { - require(b != 0, errorMessage); return a % b; } } diff --git a/contracts/math/SignedSafeMath.sol b/contracts/math/SignedSafeMath.sol index c8b1bc53f..15530c27b 100644 --- a/contracts/math/SignedSafeMath.sol +++ b/contracts/math/SignedSafeMath.sol @@ -1,14 +1,12 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; /** * @title SignedSafeMath - * @dev Signed math operations with safety checks that revert on error. + * @dev Signed math operations that revert on error. */ library SignedSafeMath { - int256 constant private _INT256_MIN = -2**255; - /** * @dev Returns the multiplication of two signed integers, reverting on * overflow. @@ -20,40 +18,21 @@ library SignedSafeMath { * - Multiplication cannot overflow. */ function mul(int256 a, int256 b) internal pure returns (int256) { - // Gas optimization: this is cheaper than requiring 'a' not being zero, but the - // benefit is lost if 'b' is also tested. - // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 - if (a == 0) { - return 0; - } - - require(!(a == -1 && b == _INT256_MIN), "SignedSafeMath: multiplication overflow"); - - int256 c = a * b; - require(c / a == b, "SignedSafeMath: multiplication overflow"); - - return c; + return a * b; } /** * @dev Returns the integer division of two signed integers. Reverts on * division by zero. The result is rounded towards zero. * - * Counterpart to Solidity's `/` operator. Note: this function uses a - * `revert` opcode (which leaves remaining gas untouched) while Solidity - * uses an invalid opcode to revert (consuming all remaining gas). + * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(int256 a, int256 b) internal pure returns (int256) { - require(b != 0, "SignedSafeMath: division by zero"); - require(!(b == -1 && a == _INT256_MIN), "SignedSafeMath: division overflow"); - - int256 c = a / b; - - return c; + return a / b; } /** @@ -67,10 +46,7 @@ library SignedSafeMath { * - Subtraction cannot overflow. */ function sub(int256 a, int256 b) internal pure returns (int256) { - int256 c = a - b; - require((b >= 0 && c <= a) || (b < 0 && c > a), "SignedSafeMath: subtraction overflow"); - - return c; + return a - b; } /** @@ -84,9 +60,6 @@ library SignedSafeMath { * - Addition cannot overflow. */ function add(int256 a, int256 b) internal pure returns (int256) { - int256 c = a + b; - require((b >= 0 && c >= a) || (b < 0 && c < a), "SignedSafeMath: addition overflow"); - - return c; + return a + b; } } diff --git a/contracts/mocks/AccessControlMock.sol b/contracts/mocks/AccessControlMock.sol index 968d3893b..340e2080b 100644 --- a/contracts/mocks/AccessControlMock.sol +++ b/contracts/mocks/AccessControlMock.sol @@ -1,11 +1,11 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../access/AccessControl.sol"; contract AccessControlMock is AccessControl { - constructor() public { + constructor() { _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); } diff --git a/contracts/mocks/AddressImpl.sol b/contracts/mocks/AddressImpl.sol index 1d84dbec4..eabd31543 100644 --- a/contracts/mocks/AddressImpl.sol +++ b/contracts/mocks/AddressImpl.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../utils/Address.sol"; diff --git a/contracts/mocks/ArraysImpl.sol b/contracts/mocks/ArraysImpl.sol index d3c4a13d2..e70ced6c5 100644 --- a/contracts/mocks/ArraysImpl.sol +++ b/contracts/mocks/ArraysImpl.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../utils/Arrays.sol"; @@ -9,7 +9,7 @@ contract ArraysImpl { uint256[] private _array; - constructor (uint256[] memory array) public { + constructor (uint256[] memory array) { _array = array; } diff --git a/contracts/mocks/BadBeacon.sol b/contracts/mocks/BadBeacon.sol index 8883e041f..7fe486dd8 100644 --- a/contracts/mocks/BadBeacon.sol +++ b/contracts/mocks/BadBeacon.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; contract BadBeaconNoImpl { } diff --git a/contracts/mocks/CallReceiverMock.sol b/contracts/mocks/CallReceiverMock.sol index 0ab2d84d2..11d21b405 100644 --- a/contracts/mocks/CallReceiverMock.sol +++ b/contracts/mocks/CallReceiverMock.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; contract CallReceiverMock { string public sharedAnswer; diff --git a/contracts/mocks/ClashingImplementation.sol b/contracts/mocks/ClashingImplementation.sol index 1780781a5..d954d0a22 100644 --- a/contracts/mocks/ClashingImplementation.sol +++ b/contracts/mocks/ClashingImplementation.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; /** diff --git a/contracts/mocks/ConditionalEscrowMock.sol b/contracts/mocks/ConditionalEscrowMock.sol index 4d5f1f054..5ceea1761 100644 --- a/contracts/mocks/ConditionalEscrowMock.sol +++ b/contracts/mocks/ConditionalEscrowMock.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../payment/escrow/ConditionalEscrow.sol"; diff --git a/contracts/mocks/ContextMock.sol b/contracts/mocks/ContextMock.sol index daae264fc..cbb8e15b8 100644 --- a/contracts/mocks/ContextMock.sol +++ b/contracts/mocks/ContextMock.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../GSN/Context.sol"; diff --git a/contracts/mocks/CountersImpl.sol b/contracts/mocks/CountersImpl.sol index ee7c83042..108142e39 100644 --- a/contracts/mocks/CountersImpl.sol +++ b/contracts/mocks/CountersImpl.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../utils/Counters.sol"; diff --git a/contracts/mocks/Create2Impl.sol b/contracts/mocks/Create2Impl.sol index 0bcd8cbbf..7e5cd1a1c 100644 --- a/contracts/mocks/Create2Impl.sol +++ b/contracts/mocks/Create2Impl.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../utils/Create2.sol"; import "../introspection/ERC1820Implementer.sol"; diff --git a/contracts/mocks/DummyImplementation.sol b/contracts/mocks/DummyImplementation.sol index df6a7d890..d4c1d7d84 100644 --- a/contracts/mocks/DummyImplementation.sol +++ b/contracts/mocks/DummyImplementation.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; abstract contract Impl { function version() public pure virtual returns (string memory); diff --git a/contracts/mocks/ECDSAMock.sol b/contracts/mocks/ECDSAMock.sol index d8ef1062d..beec44d26 100644 --- a/contracts/mocks/ECDSAMock.sol +++ b/contracts/mocks/ECDSAMock.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../cryptography/ECDSA.sol"; diff --git a/contracts/mocks/EIP712External.sol b/contracts/mocks/EIP712External.sol index 81e1f5952..7c37fb3c9 100644 --- a/contracts/mocks/EIP712External.sol +++ b/contracts/mocks/EIP712External.sol @@ -1,12 +1,12 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../drafts/EIP712.sol"; import "../cryptography/ECDSA.sol"; contract EIP712External is EIP712 { - constructor(string memory name, string memory version) public EIP712(name, version) {} + constructor(string memory name, string memory version) EIP712(name, version) {} function domainSeparator() external view returns (bytes32) { return _domainSeparatorV4(); @@ -22,10 +22,7 @@ contract EIP712External is EIP712 { require(recoveredSigner == signer); } - function getChainId() external pure returns (uint256 chainId) { - // solhint-disable-next-line no-inline-assembly - assembly { - chainId := chainid() - } + function getChainId() external view returns (uint256) { + return block.chainid; } } diff --git a/contracts/mocks/ERC1155BurnableMock.sol b/contracts/mocks/ERC1155BurnableMock.sol index 38f117e67..24ea6121c 100644 --- a/contracts/mocks/ERC1155BurnableMock.sol +++ b/contracts/mocks/ERC1155BurnableMock.sol @@ -1,11 +1,11 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../token/ERC1155/ERC1155Burnable.sol"; contract ERC1155BurnableMock is ERC1155Burnable { - constructor(string memory uri) public ERC1155(uri) { } + constructor(string memory uri) ERC1155(uri) { } function mint(address to, uint256 id, uint256 value, bytes memory data) public { _mint(to, id, value, data); diff --git a/contracts/mocks/ERC1155Mock.sol b/contracts/mocks/ERC1155Mock.sol index e1127086c..b99f6d37c 100644 --- a/contracts/mocks/ERC1155Mock.sol +++ b/contracts/mocks/ERC1155Mock.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../token/ERC1155/ERC1155.sol"; @@ -9,7 +9,7 @@ import "../token/ERC1155/ERC1155.sol"; * This mock just publicizes internal functions for testing purposes */ contract ERC1155Mock is ERC1155 { - constructor (string memory uri) public ERC1155(uri) { + constructor (string memory uri) ERC1155(uri) { // solhint-disable-previous-line no-empty-blocks } diff --git a/contracts/mocks/ERC1155PausableMock.sol b/contracts/mocks/ERC1155PausableMock.sol index 2502b8f39..4f7edcccb 100644 --- a/contracts/mocks/ERC1155PausableMock.sol +++ b/contracts/mocks/ERC1155PausableMock.sol @@ -1,12 +1,12 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "./ERC1155Mock.sol"; import "../token/ERC1155/ERC1155Pausable.sol"; contract ERC1155PausableMock is ERC1155Mock, ERC1155Pausable { - constructor(string memory uri) public ERC1155Mock(uri) { } + constructor(string memory uri) ERC1155Mock(uri) { } function pause() external { _pause(); diff --git a/contracts/mocks/ERC1155ReceiverMock.sol b/contracts/mocks/ERC1155ReceiverMock.sol index 9e665c821..6faaaa336 100644 --- a/contracts/mocks/ERC1155ReceiverMock.sol +++ b/contracts/mocks/ERC1155ReceiverMock.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../token/ERC1155/IERC1155Receiver.sol"; import "./ERC165Mock.sol"; @@ -20,7 +20,6 @@ contract ERC1155ReceiverMock is IERC1155Receiver, ERC165Mock { bytes4 batRetval, bool batReverts ) - public { _recRetval = recRetval; _recReverts = recReverts; diff --git a/contracts/mocks/ERC165/ERC165InterfacesSupported.sol b/contracts/mocks/ERC165/ERC165InterfacesSupported.sol index b44f23520..ffe8965bb 100644 --- a/contracts/mocks/ERC165/ERC165InterfacesSupported.sol +++ b/contracts/mocks/ERC165/ERC165InterfacesSupported.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../../introspection/IERC165.sol"; @@ -29,7 +29,7 @@ contract SupportsInterfaceWithLookupMock is IERC165 { * @dev A contract implementing SupportsInterfaceWithLookup * implement ERC165 itself. */ - constructor () public { + constructor () { _registerInterface(INTERFACE_ID_ERC165); } @@ -50,7 +50,7 @@ contract SupportsInterfaceWithLookupMock is IERC165 { } contract ERC165InterfacesSupported is SupportsInterfaceWithLookupMock { - constructor (bytes4[] memory interfaceIds) public { + constructor (bytes4[] memory interfaceIds) { for (uint256 i = 0; i < interfaceIds.length; i++) { _registerInterface(interfaceIds[i]); } diff --git a/contracts/mocks/ERC165/ERC165NotSupported.sol b/contracts/mocks/ERC165/ERC165NotSupported.sol index 0a8a26464..8fa2c1bf6 100644 --- a/contracts/mocks/ERC165/ERC165NotSupported.sol +++ b/contracts/mocks/ERC165/ERC165NotSupported.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; contract ERC165NotSupported { } diff --git a/contracts/mocks/ERC165CheckerMock.sol b/contracts/mocks/ERC165CheckerMock.sol index 5c18e66bf..de940022f 100644 --- a/contracts/mocks/ERC165CheckerMock.sol +++ b/contracts/mocks/ERC165CheckerMock.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../introspection/ERC165Checker.sol"; diff --git a/contracts/mocks/ERC165Mock.sol b/contracts/mocks/ERC165Mock.sol index 6a3ffb6a7..54677d3d4 100644 --- a/contracts/mocks/ERC165Mock.sol +++ b/contracts/mocks/ERC165Mock.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../introspection/ERC165.sol"; diff --git a/contracts/mocks/ERC1820ImplementerMock.sol b/contracts/mocks/ERC1820ImplementerMock.sol index 958387705..126d8671d 100644 --- a/contracts/mocks/ERC1820ImplementerMock.sol +++ b/contracts/mocks/ERC1820ImplementerMock.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../introspection/ERC1820Implementer.sol"; diff --git a/contracts/mocks/ERC20BurnableMock.sol b/contracts/mocks/ERC20BurnableMock.sol index ffcaf440c..e4bd44cfa 100644 --- a/contracts/mocks/ERC20BurnableMock.sol +++ b/contracts/mocks/ERC20BurnableMock.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../token/ERC20/ERC20Burnable.sol"; @@ -10,7 +10,7 @@ contract ERC20BurnableMock is ERC20Burnable { string memory symbol, address initialAccount, uint256 initialBalance - ) public ERC20(name, symbol) { + ) ERC20(name, symbol) { _mint(initialAccount, initialBalance); } } diff --git a/contracts/mocks/ERC20CappedMock.sol b/contracts/mocks/ERC20CappedMock.sol index a59bec9ea..6cf74e9a3 100644 --- a/contracts/mocks/ERC20CappedMock.sol +++ b/contracts/mocks/ERC20CappedMock.sol @@ -1,12 +1,12 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../token/ERC20/ERC20Capped.sol"; contract ERC20CappedMock is ERC20Capped { constructor (string memory name, string memory symbol, uint256 cap) - public ERC20(name, symbol) ERC20Capped(cap) + ERC20(name, symbol) ERC20Capped(cap) { } function mint(address to, uint256 tokenId) public { diff --git a/contracts/mocks/ERC20DecimalsMock.sol b/contracts/mocks/ERC20DecimalsMock.sol index 5fcad4c43..141daf758 100644 --- a/contracts/mocks/ERC20DecimalsMock.sol +++ b/contracts/mocks/ERC20DecimalsMock.sol @@ -1,11 +1,11 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../token/ERC20/ERC20.sol"; contract ERC20DecimalsMock is ERC20 { - constructor (string memory name, string memory symbol, uint8 decimals) public ERC20(name, symbol) { + constructor (string memory name, string memory symbol, uint8 decimals) ERC20(name, symbol) { _setupDecimals(decimals); } } diff --git a/contracts/mocks/ERC20Mock.sol b/contracts/mocks/ERC20Mock.sol index 4e441d9c8..b78d101af 100644 --- a/contracts/mocks/ERC20Mock.sol +++ b/contracts/mocks/ERC20Mock.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../token/ERC20/ERC20.sol"; @@ -11,7 +11,7 @@ contract ERC20Mock is ERC20 { string memory symbol, address initialAccount, uint256 initialBalance - ) public payable ERC20(name, symbol) { + ) payable ERC20(name, symbol) { _mint(initialAccount, initialBalance); } diff --git a/contracts/mocks/ERC20PausableMock.sol b/contracts/mocks/ERC20PausableMock.sol index 541b62cc1..0433e49a8 100644 --- a/contracts/mocks/ERC20PausableMock.sol +++ b/contracts/mocks/ERC20PausableMock.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../token/ERC20/ERC20Pausable.sol"; @@ -11,7 +11,7 @@ contract ERC20PausableMock is ERC20Pausable { string memory symbol, address initialAccount, uint256 initialBalance - ) public ERC20(name, symbol) { + ) ERC20(name, symbol) { _mint(initialAccount, initialBalance); } diff --git a/contracts/mocks/ERC20PermitMock.sol b/contracts/mocks/ERC20PermitMock.sol index 1477338b3..6699cfe7c 100644 --- a/contracts/mocks/ERC20PermitMock.sol +++ b/contracts/mocks/ERC20PermitMock.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../drafts/ERC20Permit.sol"; @@ -10,14 +10,11 @@ contract ERC20PermitMock is ERC20Permit { string memory symbol, address initialAccount, uint256 initialBalance - ) public payable ERC20(name, symbol) ERC20Permit(name) { + ) payable ERC20(name, symbol) ERC20Permit(name) { _mint(initialAccount, initialBalance); } - function getChainId() external pure returns (uint256 chainId) { - // solhint-disable-next-line no-inline-assembly - assembly { - chainId := chainid() - } + function getChainId() external view returns (uint256) { + return block.chainid; } } diff --git a/contracts/mocks/ERC20SnapshotMock.sol b/contracts/mocks/ERC20SnapshotMock.sol index 66a90c269..d8db876a0 100644 --- a/contracts/mocks/ERC20SnapshotMock.sol +++ b/contracts/mocks/ERC20SnapshotMock.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../token/ERC20/ERC20Snapshot.sol"; @@ -11,7 +11,7 @@ contract ERC20SnapshotMock is ERC20Snapshot { string memory symbol, address initialAccount, uint256 initialBalance - ) public ERC20(name, symbol) { + ) ERC20(name, symbol) { _mint(initialAccount, initialBalance); } diff --git a/contracts/mocks/ERC721BurnableMock.sol b/contracts/mocks/ERC721BurnableMock.sol index ff0b843b0..d2531b93c 100644 --- a/contracts/mocks/ERC721BurnableMock.sol +++ b/contracts/mocks/ERC721BurnableMock.sol @@ -1,11 +1,11 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../token/ERC721/ERC721Burnable.sol"; contract ERC721BurnableMock is ERC721Burnable { - constructor(string memory name, string memory symbol) public ERC721(name, symbol) { } + constructor(string memory name, string memory symbol) ERC721(name, symbol) { } function mint(address to, uint256 tokenId) public { _mint(to, tokenId); diff --git a/contracts/mocks/ERC721GSNRecipientMock.sol b/contracts/mocks/ERC721GSNRecipientMock.sol index 5709b3c86..96efd5a75 100644 --- a/contracts/mocks/ERC721GSNRecipientMock.sol +++ b/contracts/mocks/ERC721GSNRecipientMock.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../token/ERC721/ERC721.sol"; import "../GSN/GSNRecipient.sol"; @@ -12,7 +12,6 @@ import "../GSN/GSNRecipientSignature.sol"; */ contract ERC721GSNRecipientMock is ERC721, GSNRecipient, GSNRecipientSignature { constructor(string memory name, string memory symbol, address trustedSigner) - public ERC721(name, symbol) GSNRecipientSignature(trustedSigner) { } @@ -21,7 +20,7 @@ contract ERC721GSNRecipientMock is ERC721, GSNRecipient, GSNRecipientSignature { _mint(_msgSender(), tokenId); } - function _msgSender() internal view override(Context, GSNRecipient) returns (address payable) { + function _msgSender() internal view override(Context, GSNRecipient) returns (address) { return GSNRecipient._msgSender(); } diff --git a/contracts/mocks/ERC721Mock.sol b/contracts/mocks/ERC721Mock.sol index 70e8285c3..34a76ab35 100644 --- a/contracts/mocks/ERC721Mock.sol +++ b/contracts/mocks/ERC721Mock.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../token/ERC721/ERC721.sol"; @@ -9,7 +9,7 @@ import "../token/ERC721/ERC721.sol"; * This mock just provides a public safeMint, mint, and burn functions for testing purposes */ contract ERC721Mock is ERC721 { - constructor (string memory name, string memory symbol) public ERC721(name, symbol) { } + constructor (string memory name, string memory symbol) ERC721(name, symbol) { } function exists(uint256 tokenId) public view returns (bool) { return _exists(tokenId); diff --git a/contracts/mocks/ERC721PausableMock.sol b/contracts/mocks/ERC721PausableMock.sol index 35be858ec..6bebea4a4 100644 --- a/contracts/mocks/ERC721PausableMock.sol +++ b/contracts/mocks/ERC721PausableMock.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../token/ERC721/ERC721Pausable.sol"; @@ -9,7 +9,7 @@ import "../token/ERC721/ERC721Pausable.sol"; * This mock just provides a public mint, burn and exists functions for testing purposes */ contract ERC721PausableMock is ERC721Pausable { - constructor (string memory name, string memory symbol) public ERC721(name, symbol) { } + constructor (string memory name, string memory symbol) ERC721(name, symbol) { } function mint(address to, uint256 tokenId) public { super._mint(to, tokenId); diff --git a/contracts/mocks/ERC721ReceiverMock.sol b/contracts/mocks/ERC721ReceiverMock.sol index 836c3c010..eafacd804 100644 --- a/contracts/mocks/ERC721ReceiverMock.sol +++ b/contracts/mocks/ERC721ReceiverMock.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../token/ERC721/IERC721Receiver.sol"; @@ -10,7 +10,7 @@ contract ERC721ReceiverMock is IERC721Receiver { event Received(address operator, address from, uint256 tokenId, bytes data, uint256 gas); - constructor (bytes4 retval, bool reverts) public { + constructor (bytes4 retval, bool reverts) { _retval = retval; _reverts = reverts; } diff --git a/contracts/mocks/ERC777Mock.sol b/contracts/mocks/ERC777Mock.sol index db624cc06..ab8475bdd 100644 --- a/contracts/mocks/ERC777Mock.sol +++ b/contracts/mocks/ERC777Mock.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../GSN/Context.sol"; import "../token/ERC777/ERC777.sol"; @@ -12,7 +12,7 @@ contract ERC777Mock is Context, ERC777 { string memory name, string memory symbol, address[] memory defaultOperators - ) public ERC777(name, symbol, defaultOperators) { + ) ERC777(name, symbol, defaultOperators) { _mint(initialHolder, initialBalance, "", ""); } diff --git a/contracts/mocks/ERC777SenderRecipientMock.sol b/contracts/mocks/ERC777SenderRecipientMock.sol index e4ce53f89..a234bc99f 100644 --- a/contracts/mocks/ERC777SenderRecipientMock.sol +++ b/contracts/mocks/ERC777SenderRecipientMock.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../GSN/Context.sol"; import "../token/ERC777/IERC777.sol"; diff --git a/contracts/mocks/EnumerableMapMock.sol b/contracts/mocks/EnumerableMapMock.sol index 79226d739..08c86a02d 100644 --- a/contracts/mocks/EnumerableMapMock.sol +++ b/contracts/mocks/EnumerableMapMock.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../utils/EnumerableMap.sol"; diff --git a/contracts/mocks/EnumerableSetMock.sol b/contracts/mocks/EnumerableSetMock.sol index 80454381e..eb5aa4f6f 100644 --- a/contracts/mocks/EnumerableSetMock.sol +++ b/contracts/mocks/EnumerableSetMock.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../utils/EnumerableSet.sol"; diff --git a/contracts/mocks/EtherReceiverMock.sol b/contracts/mocks/EtherReceiverMock.sol index 3e45bf133..41cb88139 100644 --- a/contracts/mocks/EtherReceiverMock.sol +++ b/contracts/mocks/EtherReceiverMock.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; contract EtherReceiverMock { bool private _acceptEther; diff --git a/contracts/mocks/GSNRecipientERC20FeeMock.sol b/contracts/mocks/GSNRecipientERC20FeeMock.sol index 624c7307c..b87b0caad 100644 --- a/contracts/mocks/GSNRecipientERC20FeeMock.sol +++ b/contracts/mocks/GSNRecipientERC20FeeMock.sol @@ -1,12 +1,12 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../GSN/GSNRecipient.sol"; import "../GSN/GSNRecipientERC20Fee.sol"; contract GSNRecipientERC20FeeMock is GSNRecipient, GSNRecipientERC20Fee { - constructor(string memory name, string memory symbol) public GSNRecipientERC20Fee(name, symbol) { } + constructor(string memory name, string memory symbol) GSNRecipientERC20Fee(name, symbol) { } function mint(address account, uint256 amount) public { _mint(account, amount); diff --git a/contracts/mocks/GSNRecipientMock.sol b/contracts/mocks/GSNRecipientMock.sol index 966bff321..5e8aab1e7 100644 --- a/contracts/mocks/GSNRecipientMock.sol +++ b/contracts/mocks/GSNRecipientMock.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "./ContextMock.sol"; import "../GSN/GSNRecipient.sol"; @@ -28,7 +28,7 @@ contract GSNRecipientMock is ContextMock, GSNRecipient { return _upgradeRelayHub(newRelayHub); } - function _msgSender() internal override(Context, GSNRecipient) view virtual returns (address payable) { + function _msgSender() internal override(Context, GSNRecipient) view virtual returns (address) { return GSNRecipient._msgSender(); } diff --git a/contracts/mocks/GSNRecipientSignatureMock.sol b/contracts/mocks/GSNRecipientSignatureMock.sol index a0f7a26de..4ae01b1bf 100644 --- a/contracts/mocks/GSNRecipientSignatureMock.sol +++ b/contracts/mocks/GSNRecipientSignatureMock.sol @@ -1,12 +1,12 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../GSN/GSNRecipient.sol"; import "../GSN/GSNRecipientSignature.sol"; contract GSNRecipientSignatureMock is GSNRecipient, GSNRecipientSignature { - constructor(address trustedSigner) public GSNRecipientSignature(trustedSigner) { } + constructor(address trustedSigner) GSNRecipientSignature(trustedSigner) { } event MockFunctionCalled(); diff --git a/contracts/mocks/InitializableMock.sol b/contracts/mocks/InitializableMock.sol index 424b0706e..aacb30b20 100644 --- a/contracts/mocks/InitializableMock.sol +++ b/contracts/mocks/InitializableMock.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../proxy/Initializable.sol"; diff --git a/contracts/mocks/MathMock.sol b/contracts/mocks/MathMock.sol index cfafcf280..3f20efa01 100644 --- a/contracts/mocks/MathMock.sol +++ b/contracts/mocks/MathMock.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../math/Math.sol"; diff --git a/contracts/mocks/MerkleProofWrapper.sol b/contracts/mocks/MerkleProofWrapper.sol index f18cf8dbb..004287e10 100644 --- a/contracts/mocks/MerkleProofWrapper.sol +++ b/contracts/mocks/MerkleProofWrapper.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import { MerkleProof } from "../cryptography/MerkleProof.sol"; diff --git a/contracts/mocks/MultipleInheritanceInitializableMocks.sol b/contracts/mocks/MultipleInheritanceInitializableMocks.sol index 8db5f9c23..f0095ce96 100644 --- a/contracts/mocks/MultipleInheritanceInitializableMocks.sol +++ b/contracts/mocks/MultipleInheritanceInitializableMocks.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../proxy/Initializable.sol"; diff --git a/contracts/mocks/OwnableMock.sol b/contracts/mocks/OwnableMock.sol index 3ef3c7a46..4751ed4b7 100644 --- a/contracts/mocks/OwnableMock.sol +++ b/contracts/mocks/OwnableMock.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../access/Ownable.sol"; diff --git a/contracts/mocks/PausableMock.sol b/contracts/mocks/PausableMock.sol index 144028503..fb8a1b81f 100644 --- a/contracts/mocks/PausableMock.sol +++ b/contracts/mocks/PausableMock.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../utils/Pausable.sol"; @@ -8,7 +8,7 @@ contract PausableMock is Pausable { bool public drasticMeasureTaken; uint256 public count; - constructor () public { + constructor () { drasticMeasureTaken = false; count = 0; } diff --git a/contracts/mocks/PullPaymentMock.sol b/contracts/mocks/PullPaymentMock.sol index d4b2d6567..b9c6ea37f 100644 --- a/contracts/mocks/PullPaymentMock.sol +++ b/contracts/mocks/PullPaymentMock.sol @@ -1,12 +1,12 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../payment/PullPayment.sol"; // mock class using PullPayment contract PullPaymentMock is PullPayment { - constructor () public payable { } + constructor () payable { } // test helper function to call asyncTransfer function callTransfer(address dest, uint256 amount) public { diff --git a/contracts/mocks/ReentrancyAttack.sol b/contracts/mocks/ReentrancyAttack.sol index ce528e482..c67cf5626 100644 --- a/contracts/mocks/ReentrancyAttack.sol +++ b/contracts/mocks/ReentrancyAttack.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../GSN/Context.sol"; contract ReentrancyAttack is Context { diff --git a/contracts/mocks/ReentrancyMock.sol b/contracts/mocks/ReentrancyMock.sol index 65444eb90..0333e9059 100644 --- a/contracts/mocks/ReentrancyMock.sol +++ b/contracts/mocks/ReentrancyMock.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../utils/ReentrancyGuard.sol"; import "./ReentrancyAttack.sol"; @@ -8,7 +8,7 @@ import "./ReentrancyAttack.sol"; contract ReentrancyMock is ReentrancyGuard { uint256 public counter; - constructor () public { + constructor () { counter = 0; } diff --git a/contracts/mocks/RegressionImplementation.sol b/contracts/mocks/RegressionImplementation.sol index 7a62638a7..e11826f21 100644 --- a/contracts/mocks/RegressionImplementation.sol +++ b/contracts/mocks/RegressionImplementation.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../proxy/Initializable.sol"; diff --git a/contracts/mocks/SafeCastMock.sol b/contracts/mocks/SafeCastMock.sol index b51192fb0..5d8e6b0fb 100644 --- a/contracts/mocks/SafeCastMock.sol +++ b/contracts/mocks/SafeCastMock.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../utils/SafeCast.sol"; diff --git a/contracts/mocks/SafeERC20Helper.sol b/contracts/mocks/SafeERC20Helper.sol index fbd05d3e0..0eec45d14 100644 --- a/contracts/mocks/SafeERC20Helper.sol +++ b/contracts/mocks/SafeERC20Helper.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../GSN/Context.sol"; import "../token/ERC20/IERC20.sol"; @@ -98,7 +98,7 @@ contract SafeERC20Wrapper is Context { IERC20 private _token; - constructor (IERC20 token) public { + constructor (IERC20 token) { _token = token; } diff --git a/contracts/mocks/SafeMathMock.sol b/contracts/mocks/SafeMathMock.sol index 5d2b8d8b2..b6c281118 100644 --- a/contracts/mocks/SafeMathMock.sol +++ b/contracts/mocks/SafeMathMock.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../math/SafeMath.sol"; diff --git a/contracts/mocks/SignedSafeMathMock.sol b/contracts/mocks/SignedSafeMathMock.sol index e5dcf32cc..08afdc66b 100644 --- a/contracts/mocks/SignedSafeMathMock.sol +++ b/contracts/mocks/SignedSafeMathMock.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../math/SignedSafeMath.sol"; diff --git a/contracts/mocks/SingleInheritanceInitializableMocks.sol b/contracts/mocks/SingleInheritanceInitializableMocks.sol index 617eeb4f7..f5f81a7b0 100644 --- a/contracts/mocks/SingleInheritanceInitializableMocks.sol +++ b/contracts/mocks/SingleInheritanceInitializableMocks.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../proxy/Initializable.sol"; diff --git a/contracts/mocks/StringsMock.sol b/contracts/mocks/StringsMock.sol index 203491b32..f395831e3 100644 --- a/contracts/mocks/StringsMock.sol +++ b/contracts/mocks/StringsMock.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../utils/Strings.sol"; diff --git a/contracts/payment/PaymentSplitter.sol b/contracts/payment/PaymentSplitter.sol index f2697797d..8e2e156ad 100644 --- a/contracts/payment/PaymentSplitter.sol +++ b/contracts/payment/PaymentSplitter.sol @@ -1,9 +1,8 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../GSN/Context.sol"; -import "../math/SafeMath.sol"; /** * @title PaymentSplitter @@ -19,8 +18,6 @@ import "../math/SafeMath.sol"; * function. */ contract PaymentSplitter is Context { - using SafeMath for uint256; - event PayeeAdded(address account, uint256 shares); event PaymentReleased(address to, uint256 amount); event PaymentReceived(address from, uint256 amount); @@ -39,7 +36,7 @@ contract PaymentSplitter is Context { * All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no * duplicates in `payees`. */ - constructor (address[] memory payees, uint256[] memory shares_) public payable { + constructor (address[] memory payees, uint256[] memory shares_) payable { // solhint-disable-next-line max-line-length require(payees.length == shares_.length, "PaymentSplitter: payees and shares length mismatch"); require(payees.length > 0, "PaymentSplitter: no payees"); @@ -104,13 +101,13 @@ contract PaymentSplitter is Context { function release(address payable account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); - uint256 totalReceived = address(this).balance.add(_totalReleased); - uint256 payment = totalReceived.mul(_shares[account]).div(_totalShares).sub(_released[account]); + uint256 totalReceived = address(this).balance + _totalReleased; + uint256 payment = totalReceived * _shares[account] / _totalShares - _released[account]; require(payment != 0, "PaymentSplitter: account is not due payment"); - _released[account] = _released[account].add(payment); - _totalReleased = _totalReleased.add(payment); + _released[account] = _released[account] + payment; + _totalReleased = _totalReleased + payment; account.transfer(payment); emit PaymentReleased(account, payment); @@ -128,7 +125,7 @@ contract PaymentSplitter is Context { _payees.push(account); _shares[account] = shares_; - _totalShares = _totalShares.add(shares_); + _totalShares = _totalShares + shares_; emit PayeeAdded(account, shares_); } } diff --git a/contracts/payment/PullPayment.sol b/contracts/payment/PullPayment.sol index c8ade2bcc..05617f66d 100644 --- a/contracts/payment/PullPayment.sol +++ b/contracts/payment/PullPayment.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.2 <0.8.0; +pragma solidity ^0.8.0; import "./escrow/Escrow.sol"; @@ -25,7 +25,7 @@ import "./escrow/Escrow.sol"; abstract contract PullPayment { Escrow private _escrow; - constructor () internal { + constructor () { _escrow = new Escrow(); } diff --git a/contracts/payment/escrow/ConditionalEscrow.sol b/contracts/payment/escrow/ConditionalEscrow.sol index 8e3b36f06..d1e558748 100644 --- a/contracts/payment/escrow/ConditionalEscrow.sol +++ b/contracts/payment/escrow/ConditionalEscrow.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "./Escrow.sol"; diff --git a/contracts/payment/escrow/Escrow.sol b/contracts/payment/escrow/Escrow.sol index 4e2ea5cb8..e8ab0106a 100644 --- a/contracts/payment/escrow/Escrow.sol +++ b/contracts/payment/escrow/Escrow.sol @@ -1,8 +1,7 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; -import "../../math/SafeMath.sol"; import "../../access/Ownable.sol"; import "../../utils/Address.sol"; @@ -20,7 +19,6 @@ import "../../utils/Address.sol"; * to the escrow's deposit and withdraw. */ contract Escrow is Ownable { - using SafeMath for uint256; using Address for address payable; event Deposited(address indexed payee, uint256 weiAmount); @@ -38,7 +36,7 @@ contract Escrow is Ownable { */ function deposit(address payee) public virtual payable onlyOwner { uint256 amount = msg.value; - _deposits[payee] = _deposits[payee].add(amount); + _deposits[payee] = _deposits[payee] + amount; emit Deposited(payee, amount); } diff --git a/contracts/payment/escrow/RefundEscrow.sol b/contracts/payment/escrow/RefundEscrow.sol index 03cffc8d3..137b84716 100644 --- a/contracts/payment/escrow/RefundEscrow.sol +++ b/contracts/payment/escrow/RefundEscrow.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "./ConditionalEscrow.sol"; @@ -27,7 +27,7 @@ contract RefundEscrow is ConditionalEscrow { * @dev Constructor. * @param beneficiary_ The beneficiary of the deposits. */ - constructor (address payable beneficiary_) public { + constructor (address payable beneficiary_) { require(beneficiary_ != address(0), "RefundEscrow: beneficiary is the zero address"); _beneficiary = beneficiary_; _state = State.Active; diff --git a/contracts/presets/ERC1155PresetMinterPauser.sol b/contracts/presets/ERC1155PresetMinterPauser.sol index 45d59f239..22194cc00 100644 --- a/contracts/presets/ERC1155PresetMinterPauser.sol +++ b/contracts/presets/ERC1155PresetMinterPauser.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../access/AccessControl.sol"; import "../GSN/Context.sol"; @@ -30,7 +30,7 @@ contract ERC1155PresetMinterPauser is Context, AccessControl, ERC1155Burnable, E * @dev Grants `DEFAULT_ADMIN_ROLE`, `MINTER_ROLE`, and `PAUSER_ROLE` to the account that * deploys the contract. */ - constructor(string memory uri) public ERC1155(uri) { + constructor(string memory uri) ERC1155(uri) { _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); _setupRole(MINTER_ROLE, _msgSender()); diff --git a/contracts/presets/ERC20PresetFixedSupply.sol b/contracts/presets/ERC20PresetFixedSupply.sol index 839110952..2c64e5b7d 100644 --- a/contracts/presets/ERC20PresetFixedSupply.sol +++ b/contracts/presets/ERC20PresetFixedSupply.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.6.2; +pragma solidity ^0.8.0; import "../token/ERC20/ERC20Burnable.sol"; @@ -24,7 +24,7 @@ contract ERC20PresetFixedSupply is ERC20Burnable { string memory symbol, uint256 initialSupply, address owner - ) public ERC20(name, symbol) { + ) ERC20(name, symbol) { _mint(owner, initialSupply); } } diff --git a/contracts/presets/ERC20PresetMinterPauser.sol b/contracts/presets/ERC20PresetMinterPauser.sol index a3c332d78..ac641f892 100644 --- a/contracts/presets/ERC20PresetMinterPauser.sol +++ b/contracts/presets/ERC20PresetMinterPauser.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../access/AccessControl.sol"; import "../GSN/Context.sol"; @@ -32,7 +32,7 @@ contract ERC20PresetMinterPauser is Context, AccessControl, ERC20Burnable, ERC20 * * See {ERC20-constructor}. */ - constructor(string memory name, string memory symbol) public ERC20(name, symbol) { + constructor(string memory name, string memory symbol) ERC20(name, symbol) { _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); _setupRole(MINTER_ROLE, _msgSender()); diff --git a/contracts/presets/ERC721PresetMinterPauserAutoId.sol b/contracts/presets/ERC721PresetMinterPauserAutoId.sol index 461e014a1..5f10e7270 100644 --- a/contracts/presets/ERC721PresetMinterPauserAutoId.sol +++ b/contracts/presets/ERC721PresetMinterPauserAutoId.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../access/AccessControl.sol"; import "../GSN/Context.sol"; @@ -39,7 +39,7 @@ contract ERC721PresetMinterPauserAutoId is Context, AccessControl, ERC721Burnabl * Token URIs will be autogenerated based on `baseURI` and their token IDs. * See {ERC721-tokenURI}. */ - constructor(string memory name, string memory symbol, string memory baseURI) public ERC721(name, symbol) { + constructor(string memory name, string memory symbol, string memory baseURI) ERC721(name, symbol) { _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); _setupRole(MINTER_ROLE, _msgSender()); diff --git a/contracts/presets/ERC777PresetFixedSupply.sol b/contracts/presets/ERC777PresetFixedSupply.sol index 5756b6498..3c29be4b7 100644 --- a/contracts/presets/ERC777PresetFixedSupply.sol +++ b/contracts/presets/ERC777PresetFixedSupply.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.6.2; +pragma solidity ^0.8.0; import "../token/ERC777/ERC777.sol"; @@ -21,7 +21,7 @@ contract ERC777PresetFixedSupply is ERC777 { address[] memory defaultOperators, uint256 initialSupply, address owner - ) public ERC777(name, symbol, defaultOperators) { + ) ERC777(name, symbol, defaultOperators) { _mint(owner, initialSupply, "", ""); } } diff --git a/contracts/proxy/BeaconProxy.sol b/contracts/proxy/BeaconProxy.sol index 8054c4847..6bed67b13 100644 --- a/contracts/proxy/BeaconProxy.sol +++ b/contracts/proxy/BeaconProxy.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "./Proxy.sol"; import "../utils/Address.sol"; @@ -30,7 +30,7 @@ contract BeaconProxy is Proxy { * * - `beacon` must be a contract with the interface {IBeacon}. */ - constructor(address beacon, bytes memory data) public payable { + constructor(address beacon, bytes memory data) payable { assert(_BEACON_SLOT == bytes32(uint256(keccak256("eip1967.proxy.beacon")) - 1)); _setBeacon(beacon, data); } diff --git a/contracts/proxy/IBeacon.sol b/contracts/proxy/IBeacon.sol index 7d08b7b17..ebba392b1 100644 --- a/contracts/proxy/IBeacon.sol +++ b/contracts/proxy/IBeacon.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. diff --git a/contracts/proxy/Initializable.sol b/contracts/proxy/Initializable.sol index 514fbbb19..5fa83a825 100644 --- a/contracts/proxy/Initializable.sol +++ b/contracts/proxy/Initializable.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT // solhint-disable-next-line compiler-version -pragma solidity >=0.4.24 <0.8.0; +pragma solidity ^0.8.0; /** diff --git a/contracts/proxy/Proxy.sol b/contracts/proxy/Proxy.sol index a444637ed..daae63f5d 100644 --- a/contracts/proxy/Proxy.sol +++ b/contracts/proxy/Proxy.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM diff --git a/contracts/proxy/ProxyAdmin.sol b/contracts/proxy/ProxyAdmin.sol index f93c204ce..067ccad83 100644 --- a/contracts/proxy/ProxyAdmin.sol +++ b/contracts/proxy/ProxyAdmin.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../access/Ownable.sol"; import "./TransparentUpgradeableProxy.sol"; diff --git a/contracts/proxy/TransparentUpgradeableProxy.sol b/contracts/proxy/TransparentUpgradeableProxy.sol index 7908a6497..97d8bf299 100644 --- a/contracts/proxy/TransparentUpgradeableProxy.sol +++ b/contracts/proxy/TransparentUpgradeableProxy.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "./UpgradeableProxy.sol"; @@ -30,7 +30,7 @@ contract TransparentUpgradeableProxy is UpgradeableProxy { * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and * optionally initialized with `_data` as explained in {UpgradeableProxy-constructor}. */ - constructor(address _logic, address admin_, bytes memory _data) public payable UpgradeableProxy(_logic, _data) { + constructor(address _logic, address admin_, bytes memory _data) payable UpgradeableProxy(_logic, _data) { assert(_ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1)); _setAdmin(admin_); } diff --git a/contracts/proxy/UpgradeableBeacon.sol b/contracts/proxy/UpgradeableBeacon.sol index e1350ce36..719260266 100644 --- a/contracts/proxy/UpgradeableBeacon.sol +++ b/contracts/proxy/UpgradeableBeacon.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "./IBeacon.sol"; import "../access/Ownable.sol"; @@ -24,7 +24,7 @@ contract UpgradeableBeacon is IBeacon, Ownable { * @dev Sets the address of the initial implementation, and the deployer account as the owner who can upgrade the * beacon. */ - constructor(address implementation_) public { + constructor(address implementation_) { _setImplementation(implementation_); } diff --git a/contracts/proxy/UpgradeableProxy.sol b/contracts/proxy/UpgradeableProxy.sol index 1889351a3..78ef280c0 100644 --- a/contracts/proxy/UpgradeableProxy.sol +++ b/contracts/proxy/UpgradeableProxy.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "./Proxy.sol"; import "../utils/Address.sol"; @@ -21,7 +21,7 @@ contract UpgradeableProxy is Proxy { * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded * function call, and allows initializating the storage of the proxy like a Solidity constructor. */ - constructor(address _logic, bytes memory _data) public payable { + constructor(address _logic, bytes memory _data) payable { assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); _setImplementation(_logic); if(_data.length > 0) { diff --git a/contracts/token/ERC1155/ERC1155.sol b/contracts/token/ERC1155/ERC1155.sol index fa849009b..7251a5b08 100644 --- a/contracts/token/ERC1155/ERC1155.sol +++ b/contracts/token/ERC1155/ERC1155.sol @@ -1,13 +1,12 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "./IERC1155.sol"; import "./IERC1155MetadataURI.sol"; import "./IERC1155Receiver.sol"; import "../../GSN/Context.sol"; import "../../introspection/ERC165.sol"; -import "../../math/SafeMath.sol"; import "../../utils/Address.sol"; /** @@ -19,7 +18,6 @@ import "../../utils/Address.sol"; * _Available since v3.1._ */ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { - using SafeMath for uint256; using Address for address; // Mapping from token ID to account balances @@ -52,7 +50,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { /** * @dev See {_setURI}. */ - constructor (string memory uri_) public { + constructor (string memory uri_) { _setURI(uri_); // register the supported interfaces to conform to ERC1155 via ERC165 @@ -157,8 +155,8 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { _beforeTokenTransfer(operator, from, to, _asSingletonArray(id), _asSingletonArray(amount), data); - _balances[id][from] = _balances[id][from].sub(amount, "ERC1155: insufficient balance for transfer"); - _balances[id][to] = _balances[id][to].add(amount); + _balances[id][from] = _balances[id][from] - amount; + _balances[id][to] = _balances[id][to] + amount; emit TransferSingle(operator, from, to, id, amount); @@ -194,11 +192,8 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { uint256 id = ids[i]; uint256 amount = amounts[i]; - _balances[id][from] = _balances[id][from].sub( - amount, - "ERC1155: insufficient balance for transfer" - ); - _balances[id][to] = _balances[id][to].add(amount); + _balances[id][from] = _balances[id][from] - amount; + _balances[id][to] = _balances[id][to] + amount; } emit TransferBatch(operator, from, to, ids, amounts); @@ -247,7 +242,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { _beforeTokenTransfer(operator, address(0), account, _asSingletonArray(id), _asSingletonArray(amount), data); - _balances[id][account] = _balances[id][account].add(amount); + _balances[id][account] = _balances[id][account] + amount; emit TransferSingle(operator, address(0), account, id, amount); _doSafeTransferAcceptanceCheck(operator, address(0), account, id, amount, data); @@ -271,7 +266,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { _beforeTokenTransfer(operator, address(0), to, ids, amounts, data); for (uint i = 0; i < ids.length; i++) { - _balances[ids[i]][to] = amounts[i].add(_balances[ids[i]][to]); + _balances[ids[i]][to] = amounts[i] + _balances[ids[i]][to]; } emit TransferBatch(operator, address(0), to, ids, amounts); @@ -294,10 +289,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { _beforeTokenTransfer(operator, account, address(0), _asSingletonArray(id), _asSingletonArray(amount), ""); - _balances[id][account] = _balances[id][account].sub( - amount, - "ERC1155: burn amount exceeds balance" - ); + _balances[id][account] = _balances[id][account] - amount; emit TransferSingle(operator, account, address(0), id, amount); } @@ -318,10 +310,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { _beforeTokenTransfer(operator, account, address(0), ids, amounts, ""); for (uint i = 0; i < ids.length; i++) { - _balances[ids[i]][account] = _balances[ids[i]][account].sub( - amounts[i], - "ERC1155: burn amount exceeds balance" - ); + _balances[ids[i]][account] = _balances[ids[i]][account] - amounts[i]; } emit TransferBatch(operator, account, address(0), ids, amounts); diff --git a/contracts/token/ERC1155/ERC1155Burnable.sol b/contracts/token/ERC1155/ERC1155Burnable.sol index 9218e7ad2..d95b43853 100644 --- a/contracts/token/ERC1155/ERC1155Burnable.sol +++ b/contracts/token/ERC1155/ERC1155Burnable.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "./ERC1155.sol"; diff --git a/contracts/token/ERC1155/ERC1155Holder.sol b/contracts/token/ERC1155/ERC1155Holder.sol index 7f7ea9b9b..4468f65cc 100644 --- a/contracts/token/ERC1155/ERC1155Holder.sol +++ b/contracts/token/ERC1155/ERC1155Holder.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "./ERC1155Receiver.sol"; diff --git a/contracts/token/ERC1155/ERC1155Pausable.sol b/contracts/token/ERC1155/ERC1155Pausable.sol index 82d99161a..3704f9ae5 100644 --- a/contracts/token/ERC1155/ERC1155Pausable.sol +++ b/contracts/token/ERC1155/ERC1155Pausable.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "./ERC1155.sol"; import "../../utils/Pausable.sol"; diff --git a/contracts/token/ERC1155/ERC1155Receiver.sol b/contracts/token/ERC1155/ERC1155Receiver.sol index c546c3283..f3e870270 100644 --- a/contracts/token/ERC1155/ERC1155Receiver.sol +++ b/contracts/token/ERC1155/ERC1155Receiver.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "./IERC1155Receiver.sol"; import "../../introspection/ERC165.sol"; @@ -9,7 +9,7 @@ import "../../introspection/ERC165.sol"; * @dev _Available since v3.1._ */ abstract contract ERC1155Receiver is ERC165, IERC1155Receiver { - constructor() internal { + constructor() { _registerInterface( ERC1155Receiver(address(0)).onERC1155Received.selector ^ ERC1155Receiver(address(0)).onERC1155BatchReceived.selector diff --git a/contracts/token/ERC1155/IERC1155.sol b/contracts/token/ERC1155/IERC1155.sol index 1f5014162..673196332 100644 --- a/contracts/token/ERC1155/IERC1155.sol +++ b/contracts/token/ERC1155/IERC1155.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.2 <0.8.0; +pragma solidity ^0.8.0; import "../../introspection/IERC165.sol"; diff --git a/contracts/token/ERC1155/IERC1155MetadataURI.sol b/contracts/token/ERC1155/IERC1155MetadataURI.sol index ce784a5a2..f636cc2d8 100644 --- a/contracts/token/ERC1155/IERC1155MetadataURI.sol +++ b/contracts/token/ERC1155/IERC1155MetadataURI.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.2 <0.8.0; +pragma solidity ^0.8.0; import "./IERC1155.sol"; diff --git a/contracts/token/ERC1155/IERC1155Receiver.sol b/contracts/token/ERC1155/IERC1155Receiver.sol index 4b7627e1e..07c441e22 100644 --- a/contracts/token/ERC1155/IERC1155Receiver.sol +++ b/contracts/token/ERC1155/IERC1155Receiver.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../../introspection/IERC165.sol"; diff --git a/contracts/token/ERC20/ERC20.sol b/contracts/token/ERC20/ERC20.sol index f688ed6d7..6d5d190fe 100644 --- a/contracts/token/ERC20/ERC20.sol +++ b/contracts/token/ERC20/ERC20.sol @@ -1,10 +1,9 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../../GSN/Context.sol"; import "./IERC20.sol"; -import "../../math/SafeMath.sol"; /** * @dev Implementation of the {IERC20} interface. @@ -31,8 +30,6 @@ import "../../math/SafeMath.sol"; * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { - using SafeMath for uint256; - mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; @@ -52,7 +49,7 @@ contract ERC20 is Context, IERC20 { * All three of these values are immutable: they can only be set once during * construction. */ - constructor (string memory name_, string memory symbol_) public { + constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; _decimals = 18; @@ -151,7 +148,7 @@ contract ERC20 is Context, IERC20 { */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); - _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); + _approve(sender, _msgSender(), _allowances[sender][_msgSender()] - amount); return true; } @@ -168,7 +165,7 @@ contract ERC20 is Context, IERC20 { * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { - _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); + _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } @@ -187,7 +184,7 @@ contract ERC20 is Context, IERC20 { * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { - _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); + _approve(_msgSender(), spender, _allowances[_msgSender()][spender] - subtractedValue); return true; } @@ -211,8 +208,8 @@ contract ERC20 is Context, IERC20 { _beforeTokenTransfer(sender, recipient, amount); - _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); - _balances[recipient] = _balances[recipient].add(amount); + _balances[sender] = _balances[sender] - amount; + _balances[recipient] = _balances[recipient] + amount; emit Transfer(sender, recipient, amount); } @@ -230,8 +227,8 @@ contract ERC20 is Context, IERC20 { _beforeTokenTransfer(address(0), account, amount); - _totalSupply = _totalSupply.add(amount); - _balances[account] = _balances[account].add(amount); + _totalSupply = _totalSupply + amount; + _balances[account] = _balances[account] + amount; emit Transfer(address(0), account, amount); } @@ -251,8 +248,8 @@ contract ERC20 is Context, IERC20 { _beforeTokenTransfer(account, address(0), amount); - _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); - _totalSupply = _totalSupply.sub(amount); + _balances[account] = _balances[account] - amount; + _totalSupply = _totalSupply - amount; emit Transfer(account, address(0), amount); } diff --git a/contracts/token/ERC20/ERC20Burnable.sol b/contracts/token/ERC20/ERC20Burnable.sol index 4383f2168..a88bf341b 100644 --- a/contracts/token/ERC20/ERC20Burnable.sol +++ b/contracts/token/ERC20/ERC20Burnable.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../../GSN/Context.sol"; import "./ERC20.sol"; @@ -11,8 +11,6 @@ import "./ERC20.sol"; * recognized off-chain (via event analysis). */ abstract contract ERC20Burnable is Context, ERC20 { - using SafeMath for uint256; - /** * @dev Destroys `amount` tokens from the caller. * @@ -34,7 +32,7 @@ abstract contract ERC20Burnable is Context, ERC20 { * `amount`. */ function burnFrom(address account, uint256 amount) public virtual { - uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, "ERC20: burn amount exceeds allowance"); + uint256 decreasedAllowance = allowance(account, _msgSender()) - amount; _approve(account, _msgSender(), decreasedAllowance); _burn(account, amount); diff --git a/contracts/token/ERC20/ERC20Capped.sol b/contracts/token/ERC20/ERC20Capped.sol index c42bfd99c..b250e704d 100644 --- a/contracts/token/ERC20/ERC20Capped.sol +++ b/contracts/token/ERC20/ERC20Capped.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "./ERC20.sol"; @@ -8,15 +8,13 @@ import "./ERC20.sol"; * @dev Extension of {ERC20} that adds a cap to the supply of tokens. */ abstract contract ERC20Capped is ERC20 { - using SafeMath for uint256; - uint256 private _cap; /** * @dev Sets the value of the `cap`. This value is immutable, it can only be * set once during construction. */ - constructor (uint256 cap_) internal { + constructor (uint256 cap_) { require(cap_ > 0, "ERC20Capped: cap is 0"); _cap = cap_; } @@ -39,7 +37,7 @@ abstract contract ERC20Capped is ERC20 { super._beforeTokenTransfer(from, to, amount); if (from == address(0)) { // When minting tokens - require(totalSupply().add(amount) <= _cap, "ERC20Capped: cap exceeded"); + require(totalSupply() + amount <= _cap, "ERC20Capped: cap exceeded"); } } } diff --git a/contracts/token/ERC20/ERC20Pausable.sol b/contracts/token/ERC20/ERC20Pausable.sol index a2568f643..a484fef81 100644 --- a/contracts/token/ERC20/ERC20Pausable.sol +++ b/contracts/token/ERC20/ERC20Pausable.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "./ERC20.sol"; import "../../utils/Pausable.sol"; diff --git a/contracts/token/ERC20/ERC20Snapshot.sol b/contracts/token/ERC20/ERC20Snapshot.sol index 996ba731e..9958bfb6a 100644 --- a/contracts/token/ERC20/ERC20Snapshot.sol +++ b/contracts/token/ERC20/ERC20Snapshot.sol @@ -1,8 +1,7 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; -import "../../math/SafeMath.sol"; import "../../utils/Arrays.sol"; import "../../utils/Counters.sol"; import "./ERC20.sol"; @@ -35,7 +34,6 @@ abstract contract ERC20Snapshot is ERC20 { // Inspired by Jordi Baylina's MiniMeToken to record historical balances: // https://github.com/Giveth/minimd/blob/ea04d950eea153a04c51fa510b068b9dded390cb/contracts/MiniMeToken.sol - using SafeMath for uint256; using Arrays for uint256[]; using Counters for Counters.Counter; diff --git a/contracts/token/ERC20/IERC20.sol b/contracts/token/ERC20/IERC20.sol index 9b877d119..1d0863fff 100644 --- a/contracts/token/ERC20/IERC20.sol +++ b/contracts/token/ERC20/IERC20.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. diff --git a/contracts/token/ERC20/SafeERC20.sol b/contracts/token/ERC20/SafeERC20.sol index b05110913..024719c0d 100644 --- a/contracts/token/ERC20/SafeERC20.sol +++ b/contracts/token/ERC20/SafeERC20.sol @@ -1,9 +1,8 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "./IERC20.sol"; -import "../../math/SafeMath.sol"; import "../../utils/Address.sol"; /** @@ -16,7 +15,6 @@ import "../../utils/Address.sol"; * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { - using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { @@ -46,12 +44,12 @@ library SafeERC20 { } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { - uint256 newAllowance = token.allowance(address(this), spender).add(value); + uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { - uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); + uint256 newAllowance = token.allowance(address(this), spender) - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } diff --git a/contracts/token/ERC20/TokenTimelock.sol b/contracts/token/ERC20/TokenTimelock.sol index 130a4faaf..efda2d06f 100644 --- a/contracts/token/ERC20/TokenTimelock.sol +++ b/contracts/token/ERC20/TokenTimelock.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "./SafeERC20.sol"; @@ -23,7 +23,7 @@ contract TokenTimelock { // timestamp when token release is enabled uint256 private _releaseTime; - constructor (IERC20 token_, address beneficiary_, uint256 releaseTime_) public { + constructor (IERC20 token_, address beneficiary_, uint256 releaseTime_) { // solhint-disable-next-line not-rely-on-time require(releaseTime_ > block.timestamp, "TokenTimelock: release time is before current time"); _token = token_; diff --git a/contracts/token/ERC721/ERC721.sol b/contracts/token/ERC721/ERC721.sol index 15a0619c5..673059b19 100644 --- a/contracts/token/ERC721/ERC721.sol +++ b/contracts/token/ERC721/ERC721.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../../GSN/Context.sol"; import "./IERC721.sol"; @@ -8,7 +8,6 @@ import "./IERC721Metadata.sol"; import "./IERC721Enumerable.sol"; import "./IERC721Receiver.sol"; import "../../introspection/ERC165.sol"; -import "../../math/SafeMath.sol"; import "../../utils/Address.sol"; import "../../utils/EnumerableSet.sol"; import "../../utils/EnumerableMap.sol"; @@ -19,7 +18,6 @@ import "../../utils/Strings.sol"; * @dev see https://eips.ethereum.org/EIPS/eip-721 */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable { - using SafeMath for uint256; using Address for address; using EnumerableSet for EnumerableSet.UintSet; using EnumerableMap for EnumerableMap.UintToAddressMap; @@ -90,7 +88,7 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ - constructor (string memory name_, string memory symbol_) public { + constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; diff --git a/contracts/token/ERC721/ERC721Burnable.sol b/contracts/token/ERC721/ERC721Burnable.sol index 69bec7107..c9fa8c872 100644 --- a/contracts/token/ERC721/ERC721Burnable.sol +++ b/contracts/token/ERC721/ERC721Burnable.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../../GSN/Context.sol"; import "./ERC721.sol"; diff --git a/contracts/token/ERC721/ERC721Holder.sol b/contracts/token/ERC721/ERC721Holder.sol index c0910e249..6e4858a6b 100644 --- a/contracts/token/ERC721/ERC721Holder.sol +++ b/contracts/token/ERC721/ERC721Holder.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "./IERC721Receiver.sol"; diff --git a/contracts/token/ERC721/ERC721Pausable.sol b/contracts/token/ERC721/ERC721Pausable.sol index 9301e19dc..456db1d52 100644 --- a/contracts/token/ERC721/ERC721Pausable.sol +++ b/contracts/token/ERC721/ERC721Pausable.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "./ERC721.sol"; import "../../utils/Pausable.sol"; diff --git a/contracts/token/ERC721/IERC721.sol b/contracts/token/ERC721/IERC721.sol index 72a81c6d6..58de7fdd3 100644 --- a/contracts/token/ERC721/IERC721.sol +++ b/contracts/token/ERC721/IERC721.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.2 <0.8.0; +pragma solidity ^0.8.0; import "../../introspection/IERC165.sol"; diff --git a/contracts/token/ERC721/IERC721Enumerable.sol b/contracts/token/ERC721/IERC721Enumerable.sol index cd08125fb..2cb478965 100644 --- a/contracts/token/ERC721/IERC721Enumerable.sol +++ b/contracts/token/ERC721/IERC721Enumerable.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.2 <0.8.0; +pragma solidity ^0.8.0; import "./IERC721.sol"; diff --git a/contracts/token/ERC721/IERC721Metadata.sol b/contracts/token/ERC721/IERC721Metadata.sol index 9a64c87c2..24f02f838 100644 --- a/contracts/token/ERC721/IERC721Metadata.sol +++ b/contracts/token/ERC721/IERC721Metadata.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.2 <0.8.0; +pragma solidity ^0.8.0; import "./IERC721.sol"; diff --git a/contracts/token/ERC721/IERC721Receiver.sol b/contracts/token/ERC721/IERC721Receiver.sol index 85fd1e482..081f4ab8d 100644 --- a/contracts/token/ERC721/IERC721Receiver.sol +++ b/contracts/token/ERC721/IERC721Receiver.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface diff --git a/contracts/token/ERC777/ERC777.sol b/contracts/token/ERC777/ERC777.sol index 91f6f1ec2..99989337d 100644 --- a/contracts/token/ERC777/ERC777.sol +++ b/contracts/token/ERC777/ERC777.sol @@ -1,13 +1,12 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../../GSN/Context.sol"; import "./IERC777.sol"; import "./IERC777Recipient.sol"; import "./IERC777Sender.sol"; import "../../token/ERC20/IERC20.sol"; -import "../../math/SafeMath.sol"; import "../../utils/Address.sol"; import "../../introspection/IERC1820Registry.sol"; @@ -27,7 +26,6 @@ import "../../introspection/IERC1820Registry.sol"; * destroyed. This makes integration with ERC20 applications seamless. */ contract ERC777 is Context, IERC777, IERC20 { - using SafeMath for uint256; using Address for address; IERC1820Registry constant internal _ERC1820_REGISTRY = IERC1820Registry(0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24); @@ -70,7 +68,7 @@ contract ERC777 is Context, IERC777, IERC20 { string memory name_, string memory symbol_, address[] memory defaultOperators_ - ) public { + ) { _name = name_; _symbol = symbol_; @@ -288,7 +286,7 @@ contract ERC777 is Context, IERC777, IERC20 { _callTokensToSend(spender, holder, recipient, amount, "", ""); _move(spender, holder, recipient, amount, "", ""); - _approve(holder, spender, _allowances[holder][spender].sub(amount, "ERC777: transfer amount exceeds allowance")); + _approve(holder, spender, _allowances[holder][spender] - amount); _callTokensReceived(spender, holder, recipient, amount, "", "", false); @@ -327,8 +325,8 @@ contract ERC777 is Context, IERC777, IERC20 { _beforeTokenTransfer(operator, address(0), account, amount); // Update state variables - _totalSupply = _totalSupply.add(amount); - _balances[account] = _balances[account].add(amount); + _totalSupply = _totalSupply + amount; + _balances[account] = _balances[account] + amount; _callTokensReceived(operator, address(0), account, amount, userData, operatorData, true); @@ -391,8 +389,8 @@ contract ERC777 is Context, IERC777, IERC20 { _callTokensToSend(operator, from, address(0), amount, data, operatorData); // Update state variables - _balances[from] = _balances[from].sub(amount, "ERC777: burn amount exceeds balance"); - _totalSupply = _totalSupply.sub(amount); + _balances[from] = _balances[from] - amount; + _totalSupply = _totalSupply - amount; emit Burned(operator, from, amount, data, operatorData); emit Transfer(from, address(0), amount); @@ -410,8 +408,8 @@ contract ERC777 is Context, IERC777, IERC20 { { _beforeTokenTransfer(operator, from, to, amount); - _balances[from] = _balances[from].sub(amount, "ERC777: transfer amount exceeds balance"); - _balances[to] = _balances[to].add(amount); + _balances[from] = _balances[from] - amount; + _balances[to] = _balances[to] + amount; emit Sent(operator, from, to, amount, userData, operatorData); emit Transfer(from, to, amount); diff --git a/contracts/token/ERC777/IERC777.sol b/contracts/token/ERC777/IERC777.sol index b68e6dc51..ad2beeb4c 100644 --- a/contracts/token/ERC777/IERC777.sol +++ b/contracts/token/ERC777/IERC777.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; /** * @dev Interface of the ERC777Token standard as defined in the EIP. diff --git a/contracts/token/ERC777/IERC777Recipient.sol b/contracts/token/ERC777/IERC777Recipient.sol index 71c8738a7..a89769159 100644 --- a/contracts/token/ERC777/IERC777Recipient.sol +++ b/contracts/token/ERC777/IERC777Recipient.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; /** * @dev Interface of the ERC777TokensRecipient standard as defined in the EIP. diff --git a/contracts/token/ERC777/IERC777Sender.sol b/contracts/token/ERC777/IERC777Sender.sol index 74b8a9528..137181183 100644 --- a/contracts/token/ERC777/IERC777Sender.sol +++ b/contracts/token/ERC777/IERC777Sender.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; /** * @dev Interface of the ERC777TokensSender standard as defined in the EIP. diff --git a/contracts/utils/Address.sol b/contracts/utils/Address.sol index 5d09d5edd..b75217ad0 100644 --- a/contracts/utils/Address.sol +++ b/contracts/utils/Address.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.2 <0.8.0; +pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type diff --git a/contracts/utils/Arrays.sol b/contracts/utils/Arrays.sol index acd3b0ef8..4bbaa138c 100644 --- a/contracts/utils/Arrays.sol +++ b/contracts/utils/Arrays.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../math/Math.sol"; diff --git a/contracts/utils/Counters.sol b/contracts/utils/Counters.sol index a65f71794..c4ee7b718 100644 --- a/contracts/utils/Counters.sol +++ b/contracts/utils/Counters.sol @@ -1,8 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; - -import "../math/SafeMath.sol"; +pragma solidity ^0.8.0; /** * @title Counters @@ -11,13 +9,8 @@ import "../math/SafeMath.sol"; * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` - * Since it is not possible to overflow a 256 bit integer with increments of one, `increment` can skip the {SafeMath} - * overflow check, thereby saving gas. This does assume however correct usage, in that the underlying `_value` is never - * directly accessed. */ library Counters { - using SafeMath for uint256; - struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add @@ -30,11 +23,10 @@ library Counters { } function increment(Counter storage counter) internal { - // The {SafeMath} overflow check can be skipped here, see the comment at the top counter._value += 1; } function decrement(Counter storage counter) internal { - counter._value = counter._value.sub(1); + counter._value = counter._value - 1; } } diff --git a/contracts/utils/Create2.sol b/contracts/utils/Create2.sol index ec1a6f41a..e4bfcb16d 100644 --- a/contracts/utils/Create2.sol +++ b/contracts/utils/Create2.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; /** * @dev Helper to make usage of the `CREATE2` EVM opcode easier and safer. diff --git a/contracts/utils/EnumerableMap.sol b/contracts/utils/EnumerableMap.sol index 2daa13190..7ebfa9717 100644 --- a/contracts/utils/EnumerableMap.sol +++ b/contracts/utils/EnumerableMap.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; /** * @dev Library for managing an enumerable variant of Solidity's diff --git a/contracts/utils/EnumerableSet.sol b/contracts/utils/EnumerableSet.sol index 858312dd9..637f1901d 100644 --- a/contracts/utils/EnumerableSet.sol +++ b/contracts/utils/EnumerableSet.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; /** * @dev Library for managing diff --git a/contracts/utils/Pausable.sol b/contracts/utils/Pausable.sol index c16e22e45..a84659978 100644 --- a/contracts/utils/Pausable.sol +++ b/contracts/utils/Pausable.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; import "../GSN/Context.sol"; @@ -29,7 +29,7 @@ abstract contract Pausable is Context { /** * @dev Initializes the contract in unpaused state. */ - constructor () internal { + constructor () { _paused = false; } diff --git a/contracts/utils/ReentrancyGuard.sol b/contracts/utils/ReentrancyGuard.sol index 24c90c32f..baa779c24 100644 --- a/contracts/utils/ReentrancyGuard.sol +++ b/contracts/utils/ReentrancyGuard.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. @@ -35,7 +35,7 @@ abstract contract ReentrancyGuard { uint256 private _status; - constructor () internal { + constructor () { _status = _NOT_ENTERED; } diff --git a/contracts/utils/SafeCast.sol b/contracts/utils/SafeCast.sol index 151bd73a4..860ef0b7a 100644 --- a/contracts/utils/SafeCast.sol +++ b/contracts/utils/SafeCast.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; /** diff --git a/contracts/utils/Strings.sol b/contracts/utils/Strings.sol index 5842448b3..56c276111 100644 --- a/contracts/utils/Strings.sol +++ b/contracts/utils/Strings.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.8.0; +pragma solidity ^0.8.0; /** * @dev String operations. @@ -23,10 +23,10 @@ library Strings { temp /= 10; } bytes memory buffer = new bytes(digits); - uint256 index = digits - 1; + uint256 index = digits; temp = value; while (temp != 0) { - buffer[index--] = bytes1(uint8(48 + temp % 10)); + buffer[--index] = bytes1(uint8(48 + uint256(temp % 10))); temp /= 10; } return string(buffer); diff --git a/docs/modules/ROOT/pages/access-control.adoc b/docs/modules/ROOT/pages/access-control.adoc index d9b090199..b298b0adc 100644 --- a/docs/modules/ROOT/pages/access-control.adoc +++ b/docs/modules/ROOT/pages/access-control.adoc @@ -13,7 +13,7 @@ OpenZeppelin provides xref:api:access.adoc#Ownable[`Ownable`] for implementing o ---- // contracts/MyContract.sol // SPDX-License-Identifier: MIT -pragma solidity ^0.6.0; +pragma solidity ^0.8.0; import "@openzeppelin/contracts/access/Ownable.sol"; @@ -62,7 +62,7 @@ Here's a simple example of using `AccessControl` in an xref:tokens.adoc#ERC20[`E ---- // contracts/MyToken.sol // SPDX-License-Identifier: MIT -pragma solidity ^0.6.0; +pragma solidity ^0.8.0; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; @@ -94,7 +94,7 @@ Let's augment our ERC20 token example by also defining a 'burner' role, which le ---- // contracts/MyToken.sol // SPDX-License-Identifier: MIT -pragma solidity ^0.6.0; +pragma solidity ^0.8.0; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; @@ -139,7 +139,7 @@ Let's take a look at the ERC20 token example, this time taking advantage of the ---- // contracts/MyToken.sol // SPDX-License-Identifier: MIT -pragma solidity ^0.6.0; +pragma solidity ^0.8.0; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; @@ -148,7 +148,7 @@ contract MyToken is ERC20, AccessControl { bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE"); - constructor() public ERC20("MyToken", "TKN") { + constructor() ERC20("MyToken", "TKN") { // Grant the contract deployer the default admin role: it will be able // to grant and revoke any roles _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); diff --git a/docs/modules/ROOT/pages/erc1155.adoc b/docs/modules/ROOT/pages/erc1155.adoc index 9180a4b52..2444abe40 100644 --- a/docs/modules/ROOT/pages/erc1155.adoc +++ b/docs/modules/ROOT/pages/erc1155.adoc @@ -34,7 +34,7 @@ Here's what a contract for tokenized items might look like: ---- // contracts/GameItems.sol // SPDX-License-Identifier: MIT -pragma solidity ^0.6.0; +pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; @@ -45,7 +45,7 @@ contract GameItems is ERC1155 { uint256 public constant SWORD = 3; uint256 public constant SHIELD = 4; - constructor() public ERC1155("https://game.example/api/item/{id}.json") { + constructor() ERC1155("https://game.example/api/item/{id}.json") { _mint(msg.sender, GOLD, 10**18, ""); _mint(msg.sender, SILVER, 10**27, ""); _mint(msg.sender, THORS_HAMMER, 1, ""); @@ -132,7 +132,7 @@ In order for our contract to receive ERC1155 tokens we can inherit from the conv ---- // contracts/MyContract.sol // SPDX-License-Identifier: MIT -pragma solidity ^0.6.0; +pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC1155/ERC1155Holder.sol"; diff --git a/docs/modules/ROOT/pages/erc20-supply.adoc b/docs/modules/ROOT/pages/erc20-supply.adoc index 3db0828d8..f77546dab 100644 --- a/docs/modules/ROOT/pages/erc20-supply.adoc +++ b/docs/modules/ROOT/pages/erc20-supply.adoc @@ -14,7 +14,7 @@ Let's say we want a token with a fixed supply of 1000, initially allocated to th [source,solidity] ---- contract ERC20FixedSupply is ERC20 { - constructor() public { + constructor() { totalSupply += 1000; balances[msg.sender] += 1000; } @@ -26,7 +26,7 @@ Starting with Contracts v2 this pattern is not only discouraged, but disallowed. [source,solidity] ---- contract ERC20FixedSupply is ERC20 { - constructor() public ERC20("Fixed", "FIX") { + constructor() ERC20("Fixed", "FIX") { _mint(msg.sender, 1000); } } @@ -44,7 +44,7 @@ The mechanism we will implement is a token reward for the miners that produce Et [source,solidity] ---- contract ERC20WithMinerReward is ERC20 { - constructor() public ERC20("Reward", "RWD") {} + constructor() ERC20("Reward", "RWD") {} function mintMinerReward() public { _mint(block.coinbase, 1000); @@ -92,7 +92,7 @@ Adding to the supply mechanism from previous sections, we can use this hook to m [source,solidity] ---- contract ERC20WithAutoMinerReward is ERC20 { - constructor() public ERC20("Reward", "RWD") {} + constructor() ERC20("Reward", "RWD") {} function _mintMinerReward() internal { _mint(block.coinbase, 1000); diff --git a/docs/modules/ROOT/pages/erc20.adoc b/docs/modules/ROOT/pages/erc20.adoc index 7a132019a..ebf05832b 100644 --- a/docs/modules/ROOT/pages/erc20.adoc +++ b/docs/modules/ROOT/pages/erc20.adoc @@ -15,7 +15,7 @@ Here's what our GLD token might look like. ---- // contracts/GLDToken.sol // SPDX-License-Identifier: MIT -pragma solidity ^0.6.0; +pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; diff --git a/docs/modules/ROOT/pages/erc721.adoc b/docs/modules/ROOT/pages/erc721.adoc index 005ed3f76..9962c2c0e 100644 --- a/docs/modules/ROOT/pages/erc721.adoc +++ b/docs/modules/ROOT/pages/erc721.adoc @@ -14,7 +14,7 @@ Here's what a contract for tokenized items might look like: ---- // contracts/GameItem.sol // SPDX-License-Identifier: MIT -pragma solidity ^0.6.0; +pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; @@ -23,7 +23,7 @@ contract GameItem is ERC721 { using Counters for Counters.Counter; Counters.Counter private _tokenIds; - constructor() public ERC721("GameItem", "ITM") {} + constructor() ERC721("GameItem", "ITM") {} function awardItem(address player, string memory tokenURI) public diff --git a/docs/modules/ROOT/pages/erc777.adoc b/docs/modules/ROOT/pages/erc777.adoc index 7d69ca011..8225e6be7 100644 --- a/docs/modules/ROOT/pages/erc777.adoc +++ b/docs/modules/ROOT/pages/erc777.adoc @@ -20,7 +20,7 @@ We will replicate the `GLD` example of the xref:erc20.adoc#constructing-an-erc20 ---- // contracts/GLDToken.sol // SPDX-License-Identifier: MIT -pragma solidity ^0.6.0; +pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC777/ERC777.sol"; diff --git a/docs/modules/ROOT/pages/extending-contracts.adoc b/docs/modules/ROOT/pages/extending-contracts.adoc index a97e2e45b..7d25ae9e4 100644 --- a/docs/modules/ROOT/pages/extending-contracts.adoc +++ b/docs/modules/ROOT/pages/extending-contracts.adoc @@ -20,7 +20,7 @@ For example, imagine you want to change xref:api:access.adoc#AccessControl[`Acce ```solidity // contracts/ModifiedAccessControl.sol // SPDX-License-Identifier: MIT -pragma solidity ^0.6.0; +pragma solidity ^0.8.0; import "@openzeppelin/contracts/access/AccessControl.sol"; @@ -48,7 +48,7 @@ Here is a modified version of xref:api:access.adoc#AccessControl[`AccessControl` ```solidity // contracts/ModifiedAccessControl.sol // SPDX-License-Identifier: MIT -pragma solidity ^0.6.0; +pragma solidity ^0.8.0; import "@openzeppelin/contracts/access/AccessControl.sol"; @@ -80,7 +80,7 @@ Hooks are simply functions that are called before or after some action takes pla Here's how you would implement the `IERC721Receiver` pattern in `ERC20`, using the xref:api:token/ERC20.adoc#ERC20-_beforeTokenTransfer-address-address-uint256-[`_beforeTokenTransfer`] hook: ```solidity -pragma solidity ^0.6.0; +pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; diff --git a/docs/modules/ROOT/pages/gsn-strategies.adoc b/docs/modules/ROOT/pages/gsn-strategies.adoc index 1a7543d62..ca2923e9f 100644 --- a/docs/modules/ROOT/pages/gsn-strategies.adoc +++ b/docs/modules/ROOT/pages/gsn-strategies.adoc @@ -108,7 +108,7 @@ Your GSN recipient contract needs to inherit from `GSNRecipientERC20Fee` along w ---- // contracts/MyContract.sol // SPDX-License-Identifier: MIT -pragma solidity ^0.6.0; +pragma solidity ^0.8.0; import "@openzeppelin/contracts/GSN/GSNRecipientERC20Fee.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; @@ -116,11 +116,11 @@ import "@openzeppelin/contracts/access/AccessControl.sol"; contract MyContract is GSNRecipientERC20Fee, AccessControl { bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); - constructor() public GSNRecipientERC20Fee("FeeToken", "FEE") { + constructor() GSNRecipientERC20Fee("FeeToken", "FEE") { _setupRole(MINTER_ROLE, _msgSender()); } - function _msgSender() internal view override(Context, GSNRecipient) returns (address payable) { + function _msgSender() internal view override(Context, GSNRecipient) returns (address) { return GSNRecipient._msgSender(); } @@ -154,7 +154,7 @@ Once your strategy is ready, all your GSN recipient needs to do is inherit from [source,solidity] ---- contract MyContract is MyCustomGSNStrategy { - constructor() public MyCustomGSNStrategy() { + constructor() MyCustomGSNStrategy() { } } ---- diff --git a/docs/modules/ROOT/pages/index.adoc b/docs/modules/ROOT/pages/index.adoc index 96041fe6e..eaa693ad9 100644 --- a/docs/modules/ROOT/pages/index.adoc +++ b/docs/modules/ROOT/pages/index.adoc @@ -28,7 +28,7 @@ Once installed, you can use the contracts in the library by importing them: ---- // contracts/MyNFT.sol // SPDX-License-Identifier: MIT -pragma solidity ^0.6.0; +pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; diff --git a/test/math/SafeMath.test.js b/test/math/SafeMath.test.js index 44cc1ba8e..b03600aae 100644 --- a/test/math/SafeMath.test.js +++ b/test/math/SafeMath.test.js @@ -15,9 +15,9 @@ contract('SafeMath', function (accounts) { expect(await fn(rhs, lhs)).to.be.bignumber.equal(expected); } - async function testFailsCommutative (fn, lhs, rhs, reason) { - await expectRevert(fn(lhs, rhs), reason); - await expectRevert(fn(rhs, lhs), reason); + async function testFailsCommutative (fn, lhs, rhs) { + await expectRevert.unspecified(fn(lhs, rhs)); + await expectRevert.unspecified(fn(rhs, lhs)); } describe('add', function () { @@ -32,7 +32,7 @@ contract('SafeMath', function (accounts) { const a = MAX_UINT256; const b = new BN('1'); - await testFailsCommutative(this.safeMath.add, a, b, 'SafeMath: addition overflow'); + await testFailsCommutative(this.safeMath.add, a, b); }); }); @@ -48,7 +48,7 @@ contract('SafeMath', function (accounts) { const a = new BN('1234'); const b = new BN('5678'); - await expectRevert(this.safeMath.sub(a, b), 'SafeMath: subtraction overflow'); + await expectRevert.unspecified(this.safeMath.sub(a, b)); }); }); @@ -71,7 +71,7 @@ contract('SafeMath', function (accounts) { const a = MAX_UINT256; const b = new BN('2'); - await testFailsCommutative(this.safeMath.mul, a, b, 'SafeMath: multiplication overflow'); + await testFailsCommutative(this.safeMath.mul, a, b); }); }); @@ -101,7 +101,7 @@ contract('SafeMath', function (accounts) { const a = new BN('5678'); const b = new BN('0'); - await expectRevert(this.safeMath.div(a, b), 'SafeMath: division by zero'); + await expectRevert.unspecified(this.safeMath.div(a, b)); }); }); @@ -140,7 +140,7 @@ contract('SafeMath', function (accounts) { const a = new BN('5678'); const b = new BN('0'); - await expectRevert(this.safeMath.mod(a, b), 'SafeMath: modulo by zero'); + await expectRevert.unspecified(this.safeMath.mod(a, b)); }); }); }); diff --git a/test/math/SignedSafeMath.test.js b/test/math/SignedSafeMath.test.js index be7c55eea..c6aa15ed9 100644 --- a/test/math/SignedSafeMath.test.js +++ b/test/math/SignedSafeMath.test.js @@ -15,9 +15,9 @@ contract('SignedSafeMath', function (accounts) { expect(await fn(rhs, lhs)).to.be.bignumber.equal(expected); } - async function testFailsCommutative (fn, lhs, rhs, reason) { - await expectRevert(fn(lhs, rhs), reason); - await expectRevert(fn(rhs, lhs), reason); + async function testFailsCommutative (fn, lhs, rhs) { + await expectRevert.unspecified(fn(lhs, rhs)); + await expectRevert.unspecified(fn(rhs, lhs)); } describe('add', function () { @@ -39,14 +39,14 @@ contract('SignedSafeMath', function (accounts) { const a = MAX_INT256; const b = new BN('1'); - await testFailsCommutative(this.safeMath.add, a, b, 'SignedSafeMath: addition overflow'); + await testFailsCommutative(this.safeMath.add, a, b); }); it('reverts on negative addition overflow', async function () { const a = MIN_INT256; const b = new BN('-1'); - await testFailsCommutative(this.safeMath.add, a, b, 'SignedSafeMath: addition overflow'); + await testFailsCommutative(this.safeMath.add, a, b); }); }); @@ -71,14 +71,14 @@ contract('SignedSafeMath', function (accounts) { const a = MAX_INT256; const b = new BN('-1'); - await expectRevert(this.safeMath.sub(a, b), 'SignedSafeMath: subtraction overflow'); + await expectRevert.unspecified(this.safeMath.sub(a, b)); }); it('reverts on negative subtraction overflow', async function () { const a = MIN_INT256; const b = new BN('1'); - await expectRevert(this.safeMath.sub(a, b), 'SignedSafeMath: subtraction overflow'); + await expectRevert.unspecified(this.safeMath.sub(a, b)); }); }); @@ -101,14 +101,14 @@ contract('SignedSafeMath', function (accounts) { const a = MAX_INT256; const b = new BN('2'); - await testFailsCommutative(this.safeMath.mul, a, b, 'SignedSafeMath: multiplication overflow'); + await testFailsCommutative(this.safeMath.mul, a, b); }); it('reverts when minimum integer is multiplied by -1', async function () { const a = MIN_INT256; const b = new BN('-1'); - await testFailsCommutative(this.safeMath.mul, a, b, 'SignedSafeMath: multiplication overflow'); + await testFailsCommutative(this.safeMath.mul, a, b); }); }); @@ -139,14 +139,14 @@ contract('SignedSafeMath', function (accounts) { const a = new BN('-5678'); const b = new BN('0'); - await expectRevert(this.safeMath.div(a, b), 'SignedSafeMath: division by zero'); + await expectRevert.unspecified(this.safeMath.div(a, b)); }); it('reverts on overflow, negative second', async function () { const a = new BN(MIN_INT256); const b = new BN('-1'); - await expectRevert(this.safeMath.div(a, b), 'SignedSafeMath: division overflow'); + await expectRevert.unspecified(this.safeMath.div(a, b)); }); }); }); diff --git a/test/token/ERC1155/ERC1155.behavior.js b/test/token/ERC1155/ERC1155.behavior.js index 0a8ea9776..1a6cf1554 100644 --- a/test/token/ERC1155/ERC1155.behavior.js +++ b/test/token/ERC1155/ERC1155.behavior.js @@ -208,7 +208,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder, }); it('reverts when transferring more than balance', async function () { - await expectRevert( + await expectRevert.unspecified( this.token.safeTransferFrom( multiTokenHolder, recipient, @@ -217,7 +217,6 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder, '0x', { from: multiTokenHolder }, ), - 'ERC1155: insufficient balance for transfer', ); }); @@ -464,14 +463,13 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder, }); it('reverts when transferring amount more than any of balances', async function () { - await expectRevert( + await expectRevert.unspecified( this.token.safeBatchTransferFrom( multiTokenHolder, recipient, [firstTokenId, secondTokenId], [firstAmount, secondAmount.addn(1)], '0x', { from: multiTokenHolder }, ), - 'ERC1155: insufficient balance for transfer', ); }); diff --git a/test/token/ERC1155/ERC1155.test.js b/test/token/ERC1155/ERC1155.test.js index dffe054b6..cbe141a41 100644 --- a/test/token/ERC1155/ERC1155.test.js +++ b/test/token/ERC1155/ERC1155.test.js @@ -118,9 +118,8 @@ contract('ERC1155', function (accounts) { }); it('reverts when burning a non-existent token id', async function () { - await expectRevert( + await expectRevert.unspecified( this.token.burn(tokenHolder, tokenId, mintAmount), - 'ERC1155: burn amount exceeds balance', ); }); @@ -133,9 +132,8 @@ contract('ERC1155', function (accounts) { { from: operator }, ); - await expectRevert( + await expectRevert.unspecified( this.token.burn(tokenHolder, tokenId, mintAmount.addn(1)), - 'ERC1155: burn amount exceeds balance', ); }); @@ -190,9 +188,8 @@ contract('ERC1155', function (accounts) { }); it('reverts when burning a non-existent token id', async function () { - await expectRevert( + await expectRevert.unspecified( this.token.burnBatch(tokenBatchHolder, tokenBatchIds, burnAmounts), - 'ERC1155: burn amount exceeds balance', ); }); diff --git a/test/token/ERC20/ERC20.behavior.js b/test/token/ERC20/ERC20.behavior.js index 5d23fa9ee..ee1a5759f 100644 --- a/test/token/ERC20/ERC20.behavior.js +++ b/test/token/ERC20/ERC20.behavior.js @@ -87,8 +87,8 @@ function shouldBehaveLikeERC20 (errorPrefix, initialSupply, initialHolder, recip const amount = initialSupply.addn(1); it('reverts', async function () { - await expectRevert(this.token.transferFrom( - tokenOwner, to, amount, { from: spender }), `${errorPrefix}: transfer amount exceeds balance`, + await expectRevert.unspecified(this.token.transferFrom( + tokenOwner, to, amount, { from: spender }), ); }); }); @@ -103,8 +103,8 @@ function shouldBehaveLikeERC20 (errorPrefix, initialSupply, initialHolder, recip const amount = initialSupply; it('reverts', async function () { - await expectRevert(this.token.transferFrom( - tokenOwner, to, amount, { from: spender }), `${errorPrefix}: transfer amount exceeds allowance`, + await expectRevert.unspecified(this.token.transferFrom( + tokenOwner, to, amount, { from: spender }), ); }); }); @@ -113,8 +113,8 @@ function shouldBehaveLikeERC20 (errorPrefix, initialSupply, initialHolder, recip const amount = initialSupply.addn(1); it('reverts', async function () { - await expectRevert(this.token.transferFrom( - tokenOwner, to, amount, { from: spender }), `${errorPrefix}: transfer amount exceeds balance`, + await expectRevert.unspecified(this.token.transferFrom( + tokenOwner, to, amount, { from: spender }), ); }); }); @@ -165,8 +165,8 @@ function shouldBehaveLikeERC20Transfer (errorPrefix, from, to, balance, transfer const amount = balance.addn(1); it('reverts', async function () { - await expectRevert(transfer.call(this, from, to, amount), - `${errorPrefix}: transfer amount exceeds balance`, + await expectRevert.unspecified(transfer.call(this, from, to, amount), + ); }); }); diff --git a/test/token/ERC20/ERC20.test.js b/test/token/ERC20/ERC20.test.js index 883c388d7..ab2570fce 100644 --- a/test/token/ERC20/ERC20.test.js +++ b/test/token/ERC20/ERC20.test.js @@ -53,8 +53,8 @@ contract('ERC20', function (accounts) { function shouldDecreaseApproval (amount) { describe('when there was no approved amount before', function () { it('reverts', async function () { - await expectRevert(this.token.decreaseAllowance( - spender, amount, { from: initialHolder }), 'ERC20: decreased allowance below zero', + await expectRevert.unspecified(this.token.decreaseAllowance( + spender, amount, { from: initialHolder }), ); }); }); @@ -88,9 +88,9 @@ contract('ERC20', function (accounts) { }); it('reverts when more than the full allowance is removed', async function () { - await expectRevert( + await expectRevert.unspecified( this.token.decreaseAllowance(spender, approvedAmount.addn(1), { from: initialHolder }), - 'ERC20: decreased allowance below zero', + ); }); }); @@ -114,8 +114,8 @@ contract('ERC20', function (accounts) { const spender = ZERO_ADDRESS; it('reverts', async function () { - await expectRevert(this.token.decreaseAllowance( - spender, amount, { from: initialHolder }), 'ERC20: decreased allowance below zero', + await expectRevert.unspecified(this.token.decreaseAllowance( + spender, amount, { from: initialHolder }), ); }); }); @@ -247,8 +247,8 @@ contract('ERC20', function (accounts) { describe('for a non zero account', function () { it('rejects burning more than balance', async function () { - await expectRevert(this.token.burn( - initialHolder, initialSupply.addn(1)), 'ERC20: burn amount exceeds balance', + await expectRevert.unspecified(this.token.burn( + initialHolder, initialSupply.addn(1)), ); }); diff --git a/test/token/ERC20/SafeERC20.test.js b/test/token/ERC20/SafeERC20.test.js index 0bed70521..50c782141 100644 --- a/test/token/ERC20/SafeERC20.test.js +++ b/test/token/ERC20/SafeERC20.test.js @@ -93,9 +93,9 @@ function shouldOnlyRevertOnErrors () { }); it('reverts when decreasing the allowance', async function () { - await expectRevert( + await expectRevert.unspecified( this.wrapper.decreaseAllowance(10), - 'SafeERC20: decreased allowance below zero', + ); }); }); @@ -125,9 +125,8 @@ function shouldOnlyRevertOnErrors () { }); it('reverts when decreasing the allowance to a negative value', async function () { - await expectRevert( + await expectRevert.unspecified( this.wrapper.decreaseAllowance(200), - 'SafeERC20: decreased allowance below zero', ); }); }); diff --git a/test/token/ERC20/behaviors/ERC20Burnable.behavior.js b/test/token/ERC20/behaviors/ERC20Burnable.behavior.js index 0fa2f11cd..9ef8bdde8 100644 --- a/test/token/ERC20/behaviors/ERC20Burnable.behavior.js +++ b/test/token/ERC20/behaviors/ERC20Burnable.behavior.js @@ -37,8 +37,8 @@ function shouldBehaveLikeERC20Burnable (owner, initialBalance, [burner]) { const amount = initialBalance.addn(1); it('reverts', async function () { - await expectRevert(this.token.burn(amount, { from: owner }), - 'ERC20: burn amount exceeds balance', + await expectRevert.unspecified(this.token.burn(amount, { from: owner }), + ); }); }); @@ -86,8 +86,8 @@ function shouldBehaveLikeERC20Burnable (owner, initialBalance, [burner]) { it('reverts', async function () { await this.token.approve(burner, amount, { from: owner }); - await expectRevert(this.token.burnFrom(owner, amount, { from: burner }), - 'ERC20: burn amount exceeds balance', + await expectRevert.unspecified(this.token.burnFrom(owner, amount, { from: burner }), + ); }); }); @@ -97,8 +97,8 @@ function shouldBehaveLikeERC20Burnable (owner, initialBalance, [burner]) { it('reverts', async function () { await this.token.approve(burner, allowance, { from: owner }); - await expectRevert(this.token.burnFrom(owner, allowance.addn(1), { from: burner }), - 'ERC20: burn amount exceeds allowance', + await expectRevert.unspecified(this.token.burnFrom(owner, allowance.addn(1), { from: burner }), + ); }); }); diff --git a/test/utils/Address.test.js b/test/utils/Address.test.js index b19d62982..6cd202c54 100644 --- a/test/utils/Address.test.js +++ b/test/utils/Address.test.js @@ -143,7 +143,7 @@ contract('Address', function (accounts) { }, []); await expectRevert( - this.mock.functionCall(this.contractRecipient.address, abiEncodedCall, { gas: '90000' }), + this.mock.functionCall(this.contractRecipient.address, abiEncodedCall, { gas: '100000' }), 'Address: low-level call failed', ); }); @@ -155,9 +155,8 @@ contract('Address', function (accounts) { inputs: [], }, []); - await expectRevert( + await expectRevert.unspecified( this.mock.functionCall(this.contractRecipient.address, abiEncodedCall), - 'Address: low-level call failed', ); }); diff --git a/test/utils/Counters.test.js b/test/utils/Counters.test.js index 35eafa79c..5e6424e0e 100644 --- a/test/utils/Counters.test.js +++ b/test/utils/Counters.test.js @@ -43,7 +43,7 @@ contract('Counters', function (accounts) { it('reverts if the current value is 0', async function () { await this.counter.decrement(); - await expectRevert(this.counter.decrement(), 'SafeMath: subtraction overflow'); + await expectRevert.unspecified(this.counter.decrement()); }); }); context('after incremented to 3', function () {