Skip to content

Commit

Permalink
Migrate contracts to Solidity 0.7 (OpenZeppelin#2319)
Browse files Browse the repository at this point in the history
* Update contract pragmas to solidity 0.7

* Remove internal declaration on constructors

* Reference SafeMath explicitely

* Remove public constructor declaration from abstract contracts

* Remove public constructor declaration from non-abstract contracts
  • Loading branch information
elenadimitrova authored Jul 29, 2020
1 parent 09014f9 commit 04fc357
Show file tree
Hide file tree
Showing 125 changed files with 194 additions and 193 deletions.
2 changes: 1 addition & 1 deletion .solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"func-order": "off",
"mark-callable-contracts": "off",
"no-empty-blocks": "off",
"compiler-version": ["error", "^0.6.0"],
"compiler-version": ["error", "^0.7.0"],
"private-vars-leading-underscore": "error"
}
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ 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.7.0;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
contract MyCollectible is ERC721 {
constructor() ERC721("MyCollectible", "MCO") public {
constructor() ERC721("MyCollectible", "MCO") {
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion contracts/GSN/Context.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;
pragma solidity ^0.7.0;

/*
* @dev Provides information about the current execution context, including the
Expand Down
2 changes: 1 addition & 1 deletion contracts/GSN/GSNRecipient.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;
pragma solidity ^0.7.0;

import "./IRelayRecipient.sol";
import "./IRelayHub.sol";
Expand Down
6 changes: 3 additions & 3 deletions contracts/GSN/GSNRecipientERC20Fee.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;
pragma solidity ^0.7.0;

import "./GSNRecipient.sol";
import "../math/SafeMath.sol";
Expand Down Expand Up @@ -30,7 +30,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);
}

Expand Down Expand Up @@ -116,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 {
Expand Down
4 changes: 2 additions & 2 deletions contracts/GSN/GSNRecipientSignature.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;
pragma solidity ^0.7.0;

import "./GSNRecipient.sol";
import "../cryptography/ECDSA.sol";
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/GSN/IRelayHub.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;
pragma solidity ^0.7.0;

/**
* @dev Interface for `RelayHub`, the core contract of the GSN. Users should not need to interact with this contract
Expand Down
2 changes: 1 addition & 1 deletion contracts/GSN/IRelayRecipient.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;
pragma solidity ^0.7.0;

/**
* @dev Base interface for a contract that will be called via the GSN from {IRelayHub}.
Expand Down
2 changes: 1 addition & 1 deletion contracts/access/AccessControl.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;
pragma solidity ^0.7.0;

import "../utils/EnumerableSet.sol";
import "../utils/Address.sol";
Expand Down
4 changes: 2 additions & 2 deletions contracts/access/Ownable.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;
pragma solidity ^0.7.0;

import "../GSN/Context.sol";
/**
Expand All @@ -23,7 +23,7 @@ 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);
Expand Down
2 changes: 1 addition & 1 deletion contracts/cryptography/ECDSA.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;
pragma solidity ^0.7.0;

/**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
Expand Down
2 changes: 1 addition & 1 deletion contracts/cryptography/MerkleProof.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;
pragma solidity ^0.7.0;

/**
* @dev These functions deal with verification of Merkle trees (hash trees),
Expand Down
4 changes: 2 additions & 2 deletions contracts/introspection/ERC165.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;
pragma solidity ^0.7.0;

import "./IERC165.sol";

Expand All @@ -21,7 +21,7 @@ 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);
Expand Down
2 changes: 1 addition & 1 deletion contracts/introspection/ERC165Checker.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.2;
pragma solidity ^0.7.0;

/**
* @dev Library used to query support of an interface declared via {IERC165}.
Expand Down
2 changes: 1 addition & 1 deletion contracts/introspection/ERC1820Implementer.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;
pragma solidity ^0.7.0;

import "./IERC1820Implementer.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/introspection/IERC165.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;
pragma solidity ^0.7.0;

/**
* @dev Interface of the ERC165 standard, as defined in the
Expand Down
2 changes: 1 addition & 1 deletion contracts/introspection/IERC1820Implementer.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;
pragma solidity ^0.7.0;

/**
* @dev Interface for an ERC1820 implementer, as defined in the
Expand Down
2 changes: 1 addition & 1 deletion contracts/introspection/IERC1820Registry.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;
pragma solidity ^0.7.0;

/**
* @dev Interface of the global ERC1820 Registry, as defined in the
Expand Down
2 changes: 1 addition & 1 deletion contracts/math/Math.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;
pragma solidity ^0.7.0;

/**
* @dev Standard math utilities missing in the Solidity language.
Expand Down
2 changes: 1 addition & 1 deletion contracts/math/SafeMath.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;
pragma solidity ^0.7.0;

/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
Expand Down
2 changes: 1 addition & 1 deletion contracts/math/SignedSafeMath.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;
pragma solidity ^0.7.0;

/**
* @title SignedSafeMath
Expand Down
4 changes: 2 additions & 2 deletions contracts/mocks/AccessControlMock.sol
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;
pragma solidity ^0.7.0;

import "../access/AccessControl.sol";

contract AccessControlMock is AccessControl {
constructor() public {
constructor() {
_setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/AddressImpl.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;
pragma solidity ^0.7.0;

import "../utils/Address.sol";

Expand Down
4 changes: 2 additions & 2 deletions contracts/mocks/ArraysImpl.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;
pragma solidity ^0.7.0;

import "../utils/Arrays.sol";

Expand All @@ -9,7 +9,7 @@ contract ArraysImpl {

uint256[] private _array;

constructor (uint256[] memory array) public {
constructor (uint256[] memory array) {
_array = array;
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/CallReceiverMock.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;
pragma solidity ^0.7.0;

contract CallReceiverMock {

Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/ConditionalEscrowMock.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;
pragma solidity ^0.7.0;

import "../payment/escrow/ConditionalEscrow.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/ContextMock.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;
pragma solidity ^0.7.0;

import "../GSN/Context.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/CountersImpl.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;
pragma solidity ^0.7.0;

import "../utils/Counters.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/Create2Impl.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;
pragma solidity ^0.7.0;

import "../utils/Create2.sol";
import "../introspection/ERC1820Implementer.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/ECDSAMock.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;
pragma solidity ^0.7.0;

import "../cryptography/ECDSA.sol";

Expand Down
4 changes: 2 additions & 2 deletions contracts/mocks/ERC1155BurnableMock.sol
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;
pragma solidity ^0.7.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);
Expand Down
4 changes: 2 additions & 2 deletions contracts/mocks/ERC1155Mock.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;
pragma solidity ^0.7.0;

import "../token/ERC1155/ERC1155.sol";

Expand All @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions contracts/mocks/ERC1155PausableMock.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;
pragma solidity ^0.7.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();
Expand Down
3 changes: 1 addition & 2 deletions contracts/mocks/ERC1155ReceiverMock.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;
pragma solidity ^0.7.0;

import "../token/ERC1155/IERC1155Receiver.sol";
import "./ERC165Mock.sol";
Expand All @@ -20,7 +20,6 @@ contract ERC1155ReceiverMock is IERC1155Receiver, ERC165Mock {
bytes4 batRetval,
bool batReverts
)
public
{
_recRetval = recRetval;
_recReverts = recReverts;
Expand Down
6 changes: 3 additions & 3 deletions contracts/mocks/ERC165/ERC165InterfacesSupported.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;
pragma solidity ^0.7.0;

import "../../introspection/IERC165.sol";

Expand Down Expand Up @@ -29,7 +29,7 @@ contract SupportsInterfaceWithLookupMock is IERC165 {
* @dev A contract implementing SupportsInterfaceWithLookup
* implement ERC165 itself.
*/
constructor () public {
constructor () {
_registerInterface(INTERFACE_ID_ERC165);
}

Expand All @@ -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]);
}
Expand Down
Loading

0 comments on commit 04fc357

Please sign in to comment.