diff --git a/contracts/FxChild.sol b/contracts/FxChild.sol index 595b250..08641a6 100644 --- a/contracts/FxChild.sol +++ b/contracts/FxChild.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; // IStateReceiver represents interface to receive state interface IStateReceiver { diff --git a/contracts/FxRoot.sol b/contracts/FxRoot.sol index 4e418e0..9212986 100644 --- a/contracts/FxRoot.sol +++ b/contracts/FxRoot.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; interface IStateSender { @@ -17,7 +17,7 @@ contract FxRoot is IFxStateSender { IStateSender public stateSender; address public fxChild; - constructor(address _stateSender) { + constructor(address _stateSender) public { stateSender = IStateSender(_stateSender); } @@ -26,7 +26,7 @@ contract FxRoot is IFxStateSender { fxChild = _fxChild; } - function sendMessageToChild(address _receiver, bytes calldata _data) public override { + function sendMessageToChild(address _receiver, bytes memory _data) public override { bytes memory data = abi.encode(msg.sender, _receiver, _data); stateSender.syncState(fxChild, data); } diff --git a/contracts/examples/erc1155-transfer/FxERC1155ChildTunnel.sol b/contracts/examples/erc1155-transfer/FxERC1155ChildTunnel.sol index fe9924d..55367ea 100644 --- a/contracts/examples/erc1155-transfer/FxERC1155ChildTunnel.sol +++ b/contracts/examples/erc1155-transfer/FxERC1155ChildTunnel.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; import {IFxERC1155} from "../../tokens/IFxERC1155.sol"; import {ERC1155Holder} from "../../lib/ERC1155Holder.sol" ; @@ -19,7 +19,7 @@ contract FxERC1155ChildTunnel is FxBaseChildTunnel, Create2, ERC1155Holder { mapping(address => address) public rootToChildToken; address public tokenTemplate; - constructor(address _fxChild, address _tokenTemplate) FxBaseChildTunnel(_fxChild) { + constructor(address _fxChild, address _tokenTemplate) FxBaseChildTunnel(_fxChild) public { tokenTemplate = _tokenTemplate; require(_isContract(_tokenTemplate), "Token template is not contract"); } diff --git a/contracts/examples/erc1155-transfer/FxERC1155RootTunnel.sol b/contracts/examples/erc1155-transfer/FxERC1155RootTunnel.sol index 07c27a9..843d4e1 100644 --- a/contracts/examples/erc1155-transfer/FxERC1155RootTunnel.sol +++ b/contracts/examples/erc1155-transfer/FxERC1155RootTunnel.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; import {ERC1155} from "../../lib/ERC1155.sol"; import {ERC1155Holder} from "../../lib/ERC1155Holder.sol" ; @@ -18,7 +18,7 @@ contract FxERC1155RootTunnel is FxBaseRootTunnel, Create2, ERC1155Holder { mapping(address => address) public rootToChildTokens; bytes32 public childTokenTemplateCodeHash; - constructor(address _checkpointManager, address _fxRoot, address _fxERC1155Token) FxBaseRootTunnel(_checkpointManager, _fxRoot) { + constructor(address _checkpointManager, address _fxRoot, address _fxERC1155Token) FxBaseRootTunnel(_checkpointManager, _fxRoot) public { childTokenTemplateCodeHash = keccak256(minimalProxyCreationCode(_fxERC1155Token)); } diff --git a/contracts/examples/erc20-transfer/FxERC20ChildTunnel.sol b/contracts/examples/erc20-transfer/FxERC20ChildTunnel.sol index a61db9b..7db7b74 100644 --- a/contracts/examples/erc20-transfer/FxERC20ChildTunnel.sol +++ b/contracts/examples/erc20-transfer/FxERC20ChildTunnel.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; import { FxBaseChildTunnel } from '../../tunnel/FxBaseChildTunnel.sol'; import { Create2 } from '../../lib/Create2.sol'; @@ -21,7 +21,7 @@ contract FxERC20ChildTunnel is FxBaseChildTunnel, Create2 { // token template address public tokenTemplate; - constructor(address _fxChild, address _tokenTemplate) FxBaseChildTunnel(_fxChild) { + constructor(address _fxChild, address _tokenTemplate) FxBaseChildTunnel(_fxChild) public { tokenTemplate = _tokenTemplate; require(_isContract(_tokenTemplate), "Token template is not contract"); } diff --git a/contracts/examples/erc20-transfer/FxERC20RootTunnel.sol b/contracts/examples/erc20-transfer/FxERC20RootTunnel.sol index 55cb4e7..7d3da54 100755 --- a/contracts/examples/erc20-transfer/FxERC20RootTunnel.sol +++ b/contracts/examples/erc20-transfer/FxERC20RootTunnel.sol @@ -1,10 +1,10 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; import { ERC20 } from "../../lib/ERC20.sol"; import { Create2 } from "../../lib/Create2.sol"; import { FxBaseRootTunnel } from "../../tunnel/FxBaseRootTunnel.sol"; -import {SafeERC20,IERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; +import {SafeERC20,IERC20} from "../../lib/SafeERC20.sol"; /** * @title FxERC20RootTunnel @@ -20,7 +20,7 @@ contract FxERC20RootTunnel is FxBaseRootTunnel, Create2 { mapping(address => address) public rootToChildTokens; bytes32 public childTokenTemplateCodeHash; - constructor(address _checkpointManager, address _fxRoot, address _fxERC20Token) FxBaseRootTunnel(_checkpointManager, _fxRoot) { + constructor(address _checkpointManager, address _fxRoot, address _fxERC20Token) FxBaseRootTunnel(_checkpointManager, _fxRoot) public { // compute child token template code hash childTokenTemplateCodeHash = keccak256(minimalProxyCreationCode(_fxERC20Token)); } diff --git a/contracts/examples/erc721-transfer/FxERC721ChildTunnel.sol b/contracts/examples/erc721-transfer/FxERC721ChildTunnel.sol index ac30b06..2b925fd 100755 --- a/contracts/examples/erc721-transfer/FxERC721ChildTunnel.sol +++ b/contracts/examples/erc721-transfer/FxERC721ChildTunnel.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; import { FxBaseChildTunnel } from '../../tunnel/FxBaseChildTunnel.sol'; import { Create2 } from '../../lib/Create2.sol'; @@ -22,18 +22,18 @@ contract FxERC721ChildTunnel is FxBaseChildTunnel, Create2, IERC721Receiver { // token template address public tokenTemplate; - constructor(address _fxChild, address _tokenTemplate) FxBaseChildTunnel(_fxChild) { + constructor(address _fxChild, address _tokenTemplate) FxBaseChildTunnel(_fxChild) public { tokenTemplate = _tokenTemplate; require(_isContract(_tokenTemplate), "Token template is not contract"); } function onERC721Received( address /* operator */, address /* from */, uint256 /* tokenId */, bytes calldata /* data */ - ) external pure override returns (bytes4) { + ) external override returns (bytes4) { return this.onERC721Received.selector; } - function withdraw(address childToken, uint256 tokenId, bytes memory data) external { + function withdraw(address childToken, uint256 tokenId, bytes calldata data) external { IFxERC721 childTokenContract = IFxERC721(childToken); // child token contract will have root token address rootToken = childTokenContract.connectedToken(); diff --git a/contracts/examples/erc721-transfer/FxERC721RootTunnel.sol b/contracts/examples/erc721-transfer/FxERC721RootTunnel.sol index 6205586..fa9077c 100755 --- a/contracts/examples/erc721-transfer/FxERC721RootTunnel.sol +++ b/contracts/examples/erc721-transfer/FxERC721RootTunnel.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; import { ERC721 } from "../../lib/ERC721.sol"; import { Create2 } from "../../lib/Create2.sol"; @@ -20,14 +20,14 @@ contract FxERC721RootTunnel is FxBaseRootTunnel, Create2, IERC721Receiver { bytes32 public childTokenTemplateCodeHash; constructor(address _checkpointManager, address _fxRoot, address _fxERC721Token) - FxBaseRootTunnel(_checkpointManager, _fxRoot) { + FxBaseRootTunnel(_checkpointManager, _fxRoot) public { // compute child token template code hash childTokenTemplateCodeHash = keccak256(minimalProxyCreationCode(_fxERC721Token)); } function onERC721Received( address /* operator */, address /* from */, uint256 /* tokenId */, bytes calldata /* data */ - ) external pure override returns (bytes4) { + ) external override returns (bytes4) { return this.onERC721Received.selector; } diff --git a/contracts/examples/mintable-erc20-transfer/FxMintableERC20ChildTunnel.sol b/contracts/examples/mintable-erc20-transfer/FxMintableERC20ChildTunnel.sol index 53f5ba4..8572030 100755 --- a/contracts/examples/mintable-erc20-transfer/FxMintableERC20ChildTunnel.sol +++ b/contracts/examples/mintable-erc20-transfer/FxMintableERC20ChildTunnel.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; import { FxBaseChildTunnel } from '../../tunnel/FxBaseChildTunnel.sol'; import { Create2 } from '../../lib/Create2.sol'; @@ -24,7 +24,7 @@ contract FxMintableERC20ChildTunnel is Ownable, FxBaseChildTunnel, Create2 { // root token tempalte code hash bytes32 public rootTokenTemplateCodeHash; - constructor(address _fxChild, address _childTokenTemplate, address _rootTokenTemplate) FxBaseChildTunnel(_fxChild) { + constructor(address _fxChild, address _childTokenTemplate, address _rootTokenTemplate) FxBaseChildTunnel(_fxChild) public { childTokenTemplate = _childTokenTemplate; require(_isContract(_childTokenTemplate), "Token template is not contract"); // compute root token template code hash diff --git a/contracts/examples/mintable-erc20-transfer/FxMintableERC20RootTunnel.sol b/contracts/examples/mintable-erc20-transfer/FxMintableERC20RootTunnel.sol index a3a0444..044a311 100644 --- a/contracts/examples/mintable-erc20-transfer/FxMintableERC20RootTunnel.sol +++ b/contracts/examples/mintable-erc20-transfer/FxMintableERC20RootTunnel.sol @@ -1,11 +1,11 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; import { Create2 } from "../../lib/Create2.sol"; import { SafeMath } from "../../lib/SafeMath.sol"; import { FxERC20 } from "../../tokens/FxERC20.sol"; import { FxBaseRootTunnel } from "../../tunnel/FxBaseRootTunnel.sol"; -import {SafeERC20,IERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; +import {SafeERC20,IERC20} from "../../lib/SafeERC20.sol"; /** @@ -23,7 +23,7 @@ contract FxMintableERC20RootTunnel is FxBaseRootTunnel, Create2 { address public rootTokenTemplate; bytes32 public childTokenTemplateCodeHash; - constructor(address _checkpointManager, address _fxRoot, address _rootTokenTemplate) FxBaseRootTunnel(_checkpointManager, _fxRoot) { + constructor(address _checkpointManager, address _fxRoot, address _rootTokenTemplate) FxBaseRootTunnel(_checkpointManager, _fxRoot) public { rootTokenTemplate = _rootTokenTemplate; } diff --git a/contracts/examples/state-transfer/FxStateChildTunnel.sol b/contracts/examples/state-transfer/FxStateChildTunnel.sol index a99c32f..c807856 100644 --- a/contracts/examples/state-transfer/FxStateChildTunnel.sol +++ b/contracts/examples/state-transfer/FxStateChildTunnel.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; import { FxBaseChildTunnel } from '../../tunnel/FxBaseChildTunnel.sol'; @@ -11,7 +11,7 @@ contract FxStateChildTunnel is FxBaseChildTunnel { address public latestRootMessageSender; bytes public latestData; - constructor(address _fxChild) FxBaseChildTunnel(_fxChild) { + constructor(address _fxChild) FxBaseChildTunnel(_fxChild) public { } diff --git a/contracts/examples/state-transfer/FxStateRootTunnel.sol b/contracts/examples/state-transfer/FxStateRootTunnel.sol index a41d8e6..2fe4ccc 100644 --- a/contracts/examples/state-transfer/FxStateRootTunnel.sol +++ b/contracts/examples/state-transfer/FxStateRootTunnel.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; import { FxBaseRootTunnel } from '../../tunnel/FxBaseRootTunnel.sol'; @@ -9,7 +9,7 @@ import { FxBaseRootTunnel } from '../../tunnel/FxBaseRootTunnel.sol'; contract FxStateRootTunnel is FxBaseRootTunnel { bytes public latestData; - constructor(address _checkpointManager, address _fxRoot) FxBaseRootTunnel(_checkpointManager, _fxRoot) {} + constructor(address _checkpointManager, address _fxRoot) FxBaseRootTunnel(_checkpointManager, _fxRoot) public {} function _processMessageFromChild(bytes memory data) internal override { latestData = data; diff --git a/contracts/lib/Address.sol b/contracts/lib/Address.sol index bd9a5e0..1fb567c 100755 --- a/contracts/lib/Address.sol +++ b/contracts/lib/Address.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; /** * @dev Collection of functions related to the address type diff --git a/contracts/lib/Context.sol b/contracts/lib/Context.sol index adb36f4..14c15de 100755 --- a/contracts/lib/Context.sol +++ b/contracts/lib/Context.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; /* * @dev Provides information about the current execution context, including the @@ -17,7 +17,7 @@ abstract contract Context { return msg.sender; } - function _msgData() internal view virtual returns (bytes calldata) { + function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } diff --git a/contracts/lib/Create2.sol b/contracts/lib/Create2.sol index bc4c0ef..06dfded 100644 --- a/contracts/lib/Create2.sol +++ b/contracts/lib/Create2.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; // Create2 adds common methods for minimal proxy with create2 diff --git a/contracts/lib/ERC1155.sol b/contracts/lib/ERC1155.sol index 750a870..16e524f 100644 --- a/contracts/lib/ERC1155.sol +++ b/contracts/lib/ERC1155.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; import "./IERC1155.sol"; import "./IERC1155Receiver.sol"; @@ -33,10 +33,9 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { /** * @dev See {IERC165-supportsInterface}. */ + bytes4 INTERFACE_ID = 0x01ffc9a7; function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { - return interfaceId == type(IERC1155).interfaceId - || interfaceId == type(IERC1155MetadataURI).interfaceId - || super.supportsInterface(interfaceId); + return interfaceId == INTERFACE_ID; } /** diff --git a/contracts/lib/ERC1155Holder.sol b/contracts/lib/ERC1155Holder.sol index 4468f65..877d5d7 100644 --- a/contracts/lib/ERC1155Holder.sol +++ b/contracts/lib/ERC1155Holder.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; import "./ERC1155Receiver.sol"; diff --git a/contracts/lib/ERC1155Receiver.sol b/contracts/lib/ERC1155Receiver.sol index e30efcf..6a2db9d 100644 --- a/contracts/lib/ERC1155Receiver.sol +++ b/contracts/lib/ERC1155Receiver.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; import "./IERC1155Receiver.sol"; import "./ERC165.sol"; @@ -12,8 +12,8 @@ abstract contract ERC1155Receiver is ERC165, IERC1155Receiver { /** * @dev See {IERC165-supportsInterface}. */ + bytes4 INTERFACE_ID = 0x01ffc9a7; function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { - return interfaceId == type(IERC1155Receiver).interfaceId - || super.supportsInterface(interfaceId); + return interfaceId == INTERFACE_ID; } } diff --git a/contracts/lib/ERC165.sol b/contracts/lib/ERC165.sol index fc9b52f..cc724fa 100755 --- a/contracts/lib/ERC165.sol +++ b/contracts/lib/ERC165.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; import "./IERC165.sol"; @@ -22,7 +22,8 @@ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ + bytes4 INTERFACE = 0x01ffc9a7; function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { - return interfaceId == type(IERC165).interfaceId; + return interfaceId == INTERFACE; } } diff --git a/contracts/lib/ERC20.sol b/contracts/lib/ERC20.sol index b02f8dd..3e8e442 100644 --- a/contracts/lib/ERC20.sol +++ b/contracts/lib/ERC20.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; import { IERC20 } from './IERC20.sol'; import { SafeMath } from './SafeMath.sol'; diff --git a/contracts/lib/ERC721.sol b/contracts/lib/ERC721.sol index be467c9..d3897f1 100755 --- a/contracts/lib/ERC721.sol +++ b/contracts/lib/ERC721.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; @@ -40,10 +40,9 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { /** * @dev See {IERC165-supportsInterface}. */ + bytes4 INTERFACE_ID = 0x01ffc9a7; function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { - return interfaceId == type(IERC721).interfaceId - || interfaceId == type(IERC721Metadata).interfaceId - || super.supportsInterface(interfaceId); + return interfaceId == INTERFACE_ID; } /** diff --git a/contracts/lib/IERC1155.sol b/contracts/lib/IERC1155.sol index f37b6ff..bdc8e17 100644 --- a/contracts/lib/IERC1155.sol +++ b/contracts/lib/IERC1155.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; import "./IERC165.sol"; diff --git a/contracts/lib/IERC1155MetadataURI.sol b/contracts/lib/IERC1155MetadataURI.sol index f636cc2..7ae70ef 100644 --- a/contracts/lib/IERC1155MetadataURI.sol +++ b/contracts/lib/IERC1155MetadataURI.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; import "./IERC1155.sol"; diff --git a/contracts/lib/IERC1155Receiver.sol b/contracts/lib/IERC1155Receiver.sol index e8653f6..e035550 100644 --- a/contracts/lib/IERC1155Receiver.sol +++ b/contracts/lib/IERC1155Receiver.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; import "./IERC165.sol"; diff --git a/contracts/lib/IERC165.sol b/contracts/lib/IERC165.sol index 01c9c08..a61d9d2 100755 --- a/contracts/lib/IERC165.sol +++ b/contracts/lib/IERC165.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; /** * @dev Interface of the ERC165 standard, as defined in the diff --git a/contracts/lib/IERC20.sol b/contracts/lib/IERC20.sol index cdc179a..95596f3 100644 --- a/contracts/lib/IERC20.sol +++ b/contracts/lib/IERC20.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. diff --git a/contracts/lib/IERC721.sol b/contracts/lib/IERC721.sol index cb2c519..05779c0 100755 --- a/contracts/lib/IERC721.sol +++ b/contracts/lib/IERC721.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; import "./IERC165.sol"; diff --git a/contracts/lib/IERC721Metadata.sol b/contracts/lib/IERC721Metadata.sol index 24f02f8..003d0ff 100755 --- a/contracts/lib/IERC721Metadata.sol +++ b/contracts/lib/IERC721Metadata.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; import "./IERC721.sol"; diff --git a/contracts/lib/IERC721Receiver.sol b/contracts/lib/IERC721Receiver.sol index 081f4ab..079dc81 100755 --- a/contracts/lib/IERC721Receiver.sol +++ b/contracts/lib/IERC721Receiver.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; /** * @title ERC721 token receiver interface diff --git a/contracts/lib/Merkle.sol b/contracts/lib/Merkle.sol index a3bd280..4d72c18 100755 --- a/contracts/lib/Merkle.sol +++ b/contracts/lib/Merkle.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; library Merkle { function checkMembership( diff --git a/contracts/lib/MerklePatriciaProof.sol b/contracts/lib/MerklePatriciaProof.sol index bbe74e5..801bfc2 100644 --- a/contracts/lib/MerklePatriciaProof.sol +++ b/contracts/lib/MerklePatriciaProof.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; import {RLPReader} from "./RLPReader.sol"; diff --git a/contracts/lib/Ownable.sol b/contracts/lib/Ownable.sol index 29b7bff..77004b9 100644 --- a/contracts/lib/Ownable.sol +++ b/contracts/lib/Ownable.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; /** * @dev Contract module which provides a basic access control mechanism, where @@ -21,7 +21,7 @@ abstract contract Ownable { /** * @dev Initializes the contract setting the deployer as the initial owner. */ - constructor() { + constructor() public { address msgSender = msg.sender; _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); diff --git a/contracts/lib/RLPReader.sol b/contracts/lib/RLPReader.sol index 7e635dc..a702ee3 100644 --- a/contracts/lib/RLPReader.sol +++ b/contracts/lib/RLPReader.sol @@ -2,7 +2,7 @@ * @author Hamdi Allam hamdi.allam97@gmail.com * Please reach out with any questions or concerns */ -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; library RLPReader { uint8 constant STRING_SHORT_START = 0x80; diff --git a/contracts/lib/SafeERC20.sol b/contracts/lib/SafeERC20.sol new file mode 100644 index 0000000..aa0adf7 --- /dev/null +++ b/contracts/lib/SafeERC20.sol @@ -0,0 +1,75 @@ +pragma solidity >=0.6.0<0.7.0; + +import "./IERC20.sol"; +import "./SafeMath.sol"; +import "./Address.sol"; + +/** + * @title SafeERC20 + * @dev Wrappers around ERC20 operations that throw on failure (when the token + * contract returns false). Tokens that return no value (and instead revert or + * throw on failure) are also supported, non-reverting calls are assumed to be + * successful. + * To use this library you can add a `using SafeERC20 for ERC20;` statement to your contract, + * 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 { + callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); + } + + function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { + callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); + } + + function safeApprove(IERC20 token, address spender, uint256 value) internal { + // safeApprove should only be called when setting an initial allowance, + // or when resetting it to zero. To increase and decrease it, use + // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' + // solhint-disable-next-line max-line-length + require((value == 0) || (token.allowance(address(this), spender) == 0), + "SafeERC20: approve from non-zero to non-zero allowance" + ); + callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); + } + + function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { + uint256 newAllowance = token.allowance(address(this), spender).add(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); + callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); + } + + /** + * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement + * on the return value: the return value is optional (but if data is returned, it must not be false). + * @param token The token targeted by the call. + * @param data The call data (encoded using abi.encode or one of its variants). + */ + function callOptionalReturn(IERC20 token, bytes memory data) private { + // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since + // we're implementing it ourselves. + + // A Solidity high level call has three parts: + // 1. The target address is checked to verify it contains contract code + // 2. The call itself is made, and success asserted + // 3. The return value is decoded, which in turn checks the size of the returned data. + // solhint-disable-next-line max-line-length + require(address(token).isContract(), "SafeERC20: call to non-contract"); + + // solhint-disable-next-line avoid-low-level-calls + (bool success, bytes memory returndata) = address(token).call(data); + require(success, "SafeERC20: low-level call failed"); + + if (returndata.length > 0) { // Return data is optional + // solhint-disable-next-line max-line-length + require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); + } + } +} \ No newline at end of file diff --git a/contracts/lib/SafeMath.sol b/contracts/lib/SafeMath.sol index 6f19bed..007447d 100644 --- a/contracts/lib/SafeMath.sol +++ b/contracts/lib/SafeMath.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow diff --git a/contracts/lib/Strings.sol b/contracts/lib/Strings.sol index dac2f35..9e32941 100755 --- a/contracts/lib/Strings.sol +++ b/contracts/lib/Strings.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; /** * @dev String operations. diff --git a/contracts/tokens/FxERC1155.sol b/contracts/tokens/FxERC1155.sol index c436da8..329bf67 100644 --- a/contracts/tokens/FxERC1155.sol +++ b/contracts/tokens/FxERC1155.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; import {ERC1155} from "../lib/ERC1155.sol"; import {IFxERC1155} from "./IFxERC1155.sol"; @@ -17,11 +17,11 @@ contract FxERC1155 is ERC1155, IFxERC1155 { setupMetaData(uri_); } - function fxManager() public override view returns (address) { + function fxManager() public override returns (address) { return _fxManager; } - function connectedToken() public override view returns (address) { + function connectedToken() public override returns (address) { return _connectedToken; } diff --git a/contracts/tokens/FxERC20.sol b/contracts/tokens/FxERC20.sol index 6e03846..ae6cf37 100644 --- a/contracts/tokens/FxERC20.sol +++ b/contracts/tokens/FxERC20.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; import { ERC20 } from "../lib/ERC20.sol"; import { IFxERC20 } from "./IFxERC20.sol"; @@ -22,12 +22,12 @@ contract FxERC20 is IFxERC20, ERC20 { } // fxManager rturns fx manager - function fxManager() public override view returns (address) { + function fxManager() public override returns (address) { return _fxManager; } // connectedToken returns root token - function connectedToken() public override view returns (address) { + function connectedToken() public override returns (address) { return _connectedToken; } diff --git a/contracts/tokens/FxERC721.sol b/contracts/tokens/FxERC721.sol index 8ddf05e..2971196 100755 --- a/contracts/tokens/FxERC721.sol +++ b/contracts/tokens/FxERC721.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; import { ERC721 } from "../lib/ERC721.sol"; import { IFxERC721 } from "./IFxERC721.sol"; @@ -22,12 +22,12 @@ contract FxERC721 is IFxERC721, ERC721 { } // fxManager returns fx manager - function fxManager() public override view returns (address) { + function fxManager() public override returns (address) { return _fxManager; } // connectedToken returns root token - function connectedToken() public override view returns (address) { + function connectedToken() public override returns (address) { return _connectedToken; } diff --git a/contracts/tokens/IFxERC1155.sol b/contracts/tokens/IFxERC1155.sol index a4a90ed..a30c502 100755 --- a/contracts/tokens/IFxERC1155.sol +++ b/contracts/tokens/IFxERC1155.sol @@ -1,12 +1,12 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; interface IFxERC1155 { function fxManager() external returns(address); - function initialize(address fxManager_, address connectedToken_, string memory uri_) external; + function initialize(address fxManager_, address connectedToken_, string calldata uri_) external; function connectedToken() external returns(address); - function mint(address user, uint256 id, uint256 amount, bytes memory data) external; - function mintBatch(address user, uint256[] memory ids, uint256[] memory amounts, bytes memory data) external; + function mint(address user, uint256 id, uint256 amount, bytes calldata data) external; + function mintBatch(address user, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data) external; function burn(address user, uint256 id, uint256 amount) external; - function burnBatch(address user, uint256[] memory ids, uint256[] memory amounts) external; + function burnBatch(address user, uint256[] calldata ids, uint256[] calldata amounts) external; } diff --git a/contracts/tokens/IFxERC20.sol b/contracts/tokens/IFxERC20.sol index f707e79..e8cb689 100644 --- a/contracts/tokens/IFxERC20.sol +++ b/contracts/tokens/IFxERC20.sol @@ -1,10 +1,10 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; interface IFxERC20 { function fxManager() external returns(address); function connectedToken() external returns(address); - function initialize(address _fxManager,address _connectedToken, string memory _name, string memory _symbol, uint8 _decimals) external; + function initialize(address _fxManager,address _connectedToken, string calldata _name, string calldata _symbol, uint8 _decimals) external; function mint(address user, uint256 amount) external; function burn(address user, uint256 amount) external; } \ No newline at end of file diff --git a/contracts/tokens/IFxERC721.sol b/contracts/tokens/IFxERC721.sol index bcf1205..2990ece 100755 --- a/contracts/tokens/IFxERC721.sol +++ b/contracts/tokens/IFxERC721.sol @@ -1,10 +1,10 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; interface IFxERC721 { function fxManager() external returns(address); function connectedToken() external returns(address); - function initialize(address _fxManager, address _connectedToken, string memory _name, string memory _symbol) external; - function mint(address user, uint256 tokenId, bytes memory _data) external; + function initialize(address _fxManager, address _connectedToken, string calldata _name, string calldata _symbol) external; + function mint(address user, uint256 tokenId, bytes calldata _data) external; function burn(uint256 tokenId) external; } diff --git a/contracts/tunnel/FxBaseChildTunnel.sol b/contracts/tunnel/FxBaseChildTunnel.sol index c711080..debefe1 100644 --- a/contracts/tunnel/FxBaseChildTunnel.sol +++ b/contracts/tunnel/FxBaseChildTunnel.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; // IFxMessageProcessor represents interface to process message interface IFxMessageProcessor { @@ -19,7 +19,7 @@ abstract contract FxBaseChildTunnel is IFxMessageProcessor{ // fx root tunnel address public fxRootTunnel; - constructor(address _fxChild) { + constructor(address _fxChild) public { fxChild = _fxChild; } diff --git a/contracts/tunnel/FxBaseRootTunnel.sol b/contracts/tunnel/FxBaseRootTunnel.sol index 2a0903d..2b063f7 100644 --- a/contracts/tunnel/FxBaseRootTunnel.sol +++ b/contracts/tunnel/FxBaseRootTunnel.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity >=0.6.2<0.7.0; import {RLPReader} from "../lib/RLPReader.sol"; @@ -45,7 +45,7 @@ abstract contract FxBaseRootTunnel { // storage to avoid duplicate exits mapping(bytes32 => bool) public processedExits; - constructor(address _checkpointManager, address _fxRoot) { + constructor(address _checkpointManager, address _fxRoot) public { checkpointManager = ICheckpointManager(_checkpointManager); fxRoot = IFxStateSender(_fxRoot); } diff --git a/hardhat.config.js b/hardhat.config.js index 9416e3c..56d3581 100755 --- a/hardhat.config.js +++ b/hardhat.config.js @@ -22,7 +22,7 @@ module.exports = { solidity: { compilers: [ { - version: "0.8.0" + version: "0.6.2" } ] }