Revert "downgrade solidity version to 0.5.16 in contracts"

This reverts commit 9f4a48e282.
This commit is contained in:
Andrea Franz 2020-09-30 12:17:50 +02:00
parent d2ea7607eb
commit 3151b19e3e
No known key found for this signature in database
GPG Key ID: 4F0D2F2D9DE7F29D
18 changed files with 51 additions and 46 deletions

0
contracts/.gitkeep Normal file
View File

View File

@ -1,7 +1,7 @@
pragma solidity ^0.5.16;
pragma solidity ^0.6.1;
pragma experimental ABIEncoderV2;
contract Bucket {
abstract contract Bucket {
bool initialized;
address payable public owner;
address public tokenAddress;
@ -50,7 +50,7 @@ contract Bucket {
startTime = _startTime;
expirationTime = _expirationTime;
maxTxDelayInBlocks = _maxTxDelayInBlocks;
owner = address(uint160(_owner));
owner = payable(_owner);
DOMAIN_SEPARATOR = keccak256(abi.encode(
EIP712DOMAIN_TYPEHASH,
@ -63,11 +63,11 @@ contract Bucket {
initialized = true;
}
function transferRedeemable(uint256 data, Redeem memory redeem) internal;
function transferRedeemable(uint256 data, Redeem memory redeem) virtual internal;
function transferRedeemablesToOwner() internal;
function transferRedeemablesToOwner() virtual internal;
function bucketType() external returns (uint256);
function bucketType() virtual external returns (uint256);
function redeem(Redeem calldata _redeem, bytes calldata _sig) external {
// validate Redeem

View File

@ -1,4 +1,4 @@
pragma solidity ^0.5.16;
pragma solidity ^0.6.1;
pragma experimental ABIEncoderV2;
import "./Bucket.sol";
@ -41,18 +41,18 @@ contract ERC20Bucket is Bucket {
redeemableSupply += amount;
}
function transferRedeemable(uint256 data, Redeem memory redeem) internal {
function transferRedeemable(uint256 data, Redeem memory redeem) internal override {
require(redeemableSupply >= data, "not enough redeemable supply");
redeemableSupply -= data;
IERC20(tokenAddress).transfer(redeem.receiver, data);
}
function transferRedeemablesToOwner() internal {
function transferRedeemablesToOwner() internal override {
bool success = IERC20(tokenAddress).transfer(owner, this.totalSupply());
assert(success);
}
function bucketType() external returns (uint256) {
function bucketType() external override returns (uint256) {
return 20;
}
}

View File

@ -1,4 +1,4 @@
pragma solidity ^0.5.16;
pragma solidity ^0.6.1;
import "./ERC20Bucket.sol";
import "./Proxy.sol";

View File

@ -1,4 +1,4 @@
pragma solidity ^0.5.16;
pragma solidity ^0.6.1;
pragma experimental ABIEncoderV2;
import "./Bucket.sol";
@ -15,24 +15,24 @@ contract NFTBucket is Bucket, IERC165, IERC721Receiver {
uint256 _expirationTime,
uint256 _maxTxDelayInBlocks) Bucket("KeycardNFTBucket", _tokenAddress, _startTime, _expirationTime, _maxTxDelayInBlocks) public {}
function transferRedeemable(uint256 data, Redeem memory redeem) internal {
function transferRedeemable(uint256 data, Redeem memory redeem) internal override {
IERC721(tokenAddress).safeTransferFrom(address(this), redeem.receiver, data);
}
function transferRedeemablesToOwner() internal {
function transferRedeemablesToOwner() internal override {
IERC721(tokenAddress).setApprovalForAll(owner, true);
assert(IERC721(tokenAddress).isApprovedForAll(address(this), owner));
}
function bucketType() external returns (uint256) {
function bucketType() external override returns (uint256) {
return 721;
}
function supportsInterface(bytes4 interfaceID) external view returns (bool) {
function supportsInterface(bytes4 interfaceID) external override(IERC165) view returns (bool) {
return interfaceID == _ERC721_RECEIVED;
}
function onERC721Received(address _operator, address _from, uint256 _tokenID, bytes calldata _data) external returns(bytes4) {
function onERC721Received(address _operator, address _from, uint256 _tokenID, bytes calldata _data) external override(IERC721Receiver) returns(bytes4) {
require(msg.sender == tokenAddress, "only the NFT contract can call this");
require((_operator == owner) || (_from == owner), "only the owner can create redeemables");
require(_data.length == 52, "invalid data field");

View File

@ -1,4 +1,4 @@
pragma solidity ^0.5.16;
pragma solidity ^0.6.1;
import "./NFTBucket.sol";
import "./Proxy.sol";

View File

@ -1,4 +1,4 @@
pragma solidity ^0.5.16;
pragma solidity ^0.6.1;
contract Proxy {
/**
@ -23,7 +23,7 @@ contract Proxy {
* @dev Fallback function allowing to perform a delegatecall to the given implementation.
* This function will return whatever the implementation call returns
*/
function() external payable {
fallback() external payable {
assembly { // solium-disable-line
let contractLogic := sload(0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7)
calldatacopy(0x0, 0x0, calldatasize())

View File

@ -1,4 +1,4 @@
pragma solidity ^0.5.16;
pragma solidity ^0.6.1;
// https://github.com/ethereum/EIPs/issues/20

View File

@ -1,9 +1,9 @@
pragma solidity ^0.5.16;
pragma solidity >=0.5.0 <0.7.0;
import "./IERC20.sol";
contract IERC20Detailed is IERC20 {
function symbol() public view returns (string memory);
function decimals() public view returns (uint8);
abstract contract IERC20Detailed is IERC20 {
function symbol() virtual public view returns (string memory);
function decimals() virtual public view returns (uint8);
}

View File

@ -1,4 +1,4 @@
pragma solidity ^0.5.16;
pragma solidity ^0.6.1;
import "./IERC20.sol";
@ -15,6 +15,7 @@ contract StandardToken is IERC20 {
uint256 _value
)
external
override(IERC20)
returns (bool success)
{
return transfer(msg.sender, _to, _value);
@ -22,6 +23,7 @@ contract StandardToken is IERC20 {
function approve(address _spender, uint256 _value)
external
override(IERC20)
returns (bool success)
{
allowed[msg.sender][_spender] = _value;
@ -35,6 +37,7 @@ contract StandardToken is IERC20 {
uint256 _value
)
external
override(IERC20)
returns (bool success)
{
if (balances[_from] >= _value &&
@ -50,6 +53,7 @@ contract StandardToken is IERC20 {
function allowance(address _owner, address _spender)
external
view
override(IERC20)
returns (uint256 remaining)
{
return allowed[_owner][_spender];
@ -58,6 +62,7 @@ contract StandardToken is IERC20 {
function balanceOf(address _owner)
external
view
override(IERC20)
returns (uint256 balance)
{
return balances[_owner];
@ -66,6 +71,7 @@ contract StandardToken is IERC20 {
function totalSupply()
external
view
override(IERC20)
returns(uint256 currentTotalSupply)
{
return supply;

View File

@ -1,4 +1,4 @@
pragma solidity ^0.5.16;
pragma solidity ^0.6.1;
import "./StandardToken.sol";
@ -16,8 +16,7 @@ contract TestToken is StandardToken {
_decimals = decimals;
}
// fallback
function() external {
fallback() external {
uint256 amount = 5000;
mint(amount * uint256(10)**_decimals);
}

View File

@ -1,4 +1,4 @@
pragma solidity ^0.5.16;
pragma solidity ^0.6.1;
interface IERC165 {
function supportsInterface(bytes4 interfaceId) external view returns (bool);

View File

@ -1,4 +1,4 @@
pragma solidity ^0.5.16;
pragma solidity ^0.6.1;
/**
* @dev Required interface of an ERC721 compliant contract.

View File

@ -1,4 +1,4 @@
pragma solidity ^0.5.16;
pragma solidity ^0.6.1;
/// @title ERC-721 Non-Fungible Token Standard, optional metadata extension
/// @dev See https://eips.ethereum.org/EIPS/eip-721

View File

@ -1,4 +1,4 @@
pragma solidity ^0.5.16;
pragma solidity ^0.6.1;
interface IERC721Receiver {
function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4);

View File

@ -1,4 +1,4 @@
pragma solidity ^0.5.16;
pragma solidity ^0.6.1;
import "./IERC721.sol";
import "./IERC721Receiver.sol";
@ -14,19 +14,19 @@ contract TestNFT is IERC165, IERC721 {
bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd;
function balanceOf(address owner) public view returns (uint256) {
function balanceOf(address owner) public override(IERC721) view returns (uint256) {
require(owner != address(0), "ERC721: balance query for the zero address");
return _ownedTokensCount[owner];
}
function ownerOf(uint256 tokenId) public view returns (address) {
function ownerOf(uint256 tokenId) public override(IERC721) view returns (address) {
address owner = _tokenOwner[tokenId];
require(owner != address(0), "ERC721: owner query for nonexistent token");
return owner;
}
function approve(address to, uint256 tokenId) public {
function approve(address to, uint256 tokenId) public override(IERC721) {
address owner = ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
@ -38,34 +38,34 @@ contract TestNFT is IERC165, IERC721 {
emit Approval(owner, to, tokenId);
}
function getApproved(uint256 tokenId) public view returns (address) {
function getApproved(uint256 tokenId) public override(IERC721) view returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
function setApprovalForAll(address to, bool approved) public {
function setApprovalForAll(address to, bool approved) public override(IERC721) {
require(to != msg.sender, "ERC721: approve to caller");
_operatorApprovals[msg.sender][to] = approved;
emit ApprovalForAll(msg.sender, to, approved);
}
function isApprovedForAll(address owner, address operator) public view returns (bool) {
function isApprovedForAll(address owner, address operator) public override(IERC721) view returns (bool) {
return _operatorApprovals[owner][operator];
}
function transferFrom(address from, address to, uint256 tokenId) public {
function transferFrom(address from, address to, uint256 tokenId) public override(IERC721) {
require(_isApprovedOrOwner(msg.sender, tokenId), "ERC721: transfer caller is not owner nor approved");
_transferFrom(from, to, tokenId);
}
function safeTransferFrom(address from, address to, uint256 tokenId) public {
function safeTransferFrom(address from, address to, uint256 tokenId) public override(IERC721) {
safeTransferFrom(from, to, tokenId, "");
}
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public {
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public override(IERC721) {
transferFrom(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
@ -131,7 +131,7 @@ contract TestNFT is IERC165, IERC721 {
return size > 0;
}
function supportsInterface(bytes4 interfaceID) external view returns (bool) {
function supportsInterface(bytes4 interfaceID) external override(IERC165) view returns (bool) {
return interfaceID == _INTERFACE_ID_ERC721;
}
}