mirror of
https://github.com/status-im/keycard-redeem.git
synced 2025-01-12 05:04:34 +00:00
Revert "downgrade solidity version to 0.5.16 in contracts"
This reverts commit 9f4a48e2827765d4de3c6c1af08a301f04fdea8b.
This commit is contained in:
parent
d2ea7607eb
commit
3151b19e3e
0
contracts/.gitkeep
Normal file
0
contracts/.gitkeep
Normal file
@ -1,7 +1,7 @@
|
|||||||
pragma solidity ^0.5.16;
|
pragma solidity ^0.6.1;
|
||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
contract Bucket {
|
abstract contract Bucket {
|
||||||
bool initialized;
|
bool initialized;
|
||||||
address payable public owner;
|
address payable public owner;
|
||||||
address public tokenAddress;
|
address public tokenAddress;
|
||||||
@ -50,7 +50,7 @@ contract Bucket {
|
|||||||
startTime = _startTime;
|
startTime = _startTime;
|
||||||
expirationTime = _expirationTime;
|
expirationTime = _expirationTime;
|
||||||
maxTxDelayInBlocks = _maxTxDelayInBlocks;
|
maxTxDelayInBlocks = _maxTxDelayInBlocks;
|
||||||
owner = address(uint160(_owner));
|
owner = payable(_owner);
|
||||||
|
|
||||||
DOMAIN_SEPARATOR = keccak256(abi.encode(
|
DOMAIN_SEPARATOR = keccak256(abi.encode(
|
||||||
EIP712DOMAIN_TYPEHASH,
|
EIP712DOMAIN_TYPEHASH,
|
||||||
@ -63,11 +63,11 @@ contract Bucket {
|
|||||||
initialized = true;
|
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 {
|
function redeem(Redeem calldata _redeem, bytes calldata _sig) external {
|
||||||
// validate Redeem
|
// validate Redeem
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
pragma solidity ^0.5.16;
|
pragma solidity ^0.6.1;
|
||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
import "./Bucket.sol";
|
import "./Bucket.sol";
|
||||||
@ -41,18 +41,18 @@ contract ERC20Bucket is Bucket {
|
|||||||
redeemableSupply += amount;
|
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");
|
require(redeemableSupply >= data, "not enough redeemable supply");
|
||||||
redeemableSupply -= data;
|
redeemableSupply -= data;
|
||||||
IERC20(tokenAddress).transfer(redeem.receiver, data);
|
IERC20(tokenAddress).transfer(redeem.receiver, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
function transferRedeemablesToOwner() internal {
|
function transferRedeemablesToOwner() internal override {
|
||||||
bool success = IERC20(tokenAddress).transfer(owner, this.totalSupply());
|
bool success = IERC20(tokenAddress).transfer(owner, this.totalSupply());
|
||||||
assert(success);
|
assert(success);
|
||||||
}
|
}
|
||||||
|
|
||||||
function bucketType() external returns (uint256) {
|
function bucketType() external override returns (uint256) {
|
||||||
return 20;
|
return 20;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
pragma solidity ^0.5.16;
|
pragma solidity ^0.6.1;
|
||||||
|
|
||||||
import "./ERC20Bucket.sol";
|
import "./ERC20Bucket.sol";
|
||||||
import "./Proxy.sol";
|
import "./Proxy.sol";
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
pragma solidity ^0.5.16;
|
pragma solidity ^0.6.1;
|
||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
import "./Bucket.sol";
|
import "./Bucket.sol";
|
||||||
@ -15,24 +15,24 @@ contract NFTBucket is Bucket, IERC165, IERC721Receiver {
|
|||||||
uint256 _expirationTime,
|
uint256 _expirationTime,
|
||||||
uint256 _maxTxDelayInBlocks) Bucket("KeycardNFTBucket", _tokenAddress, _startTime, _expirationTime, _maxTxDelayInBlocks) public {}
|
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);
|
IERC721(tokenAddress).safeTransferFrom(address(this), redeem.receiver, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
function transferRedeemablesToOwner() internal {
|
function transferRedeemablesToOwner() internal override {
|
||||||
IERC721(tokenAddress).setApprovalForAll(owner, true);
|
IERC721(tokenAddress).setApprovalForAll(owner, true);
|
||||||
assert(IERC721(tokenAddress).isApprovedForAll(address(this), owner));
|
assert(IERC721(tokenAddress).isApprovedForAll(address(this), owner));
|
||||||
}
|
}
|
||||||
|
|
||||||
function bucketType() external returns (uint256) {
|
function bucketType() external override returns (uint256) {
|
||||||
return 721;
|
return 721;
|
||||||
}
|
}
|
||||||
|
|
||||||
function supportsInterface(bytes4 interfaceID) external view returns (bool) {
|
function supportsInterface(bytes4 interfaceID) external override(IERC165) view returns (bool) {
|
||||||
return interfaceID == _ERC721_RECEIVED;
|
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(msg.sender == tokenAddress, "only the NFT contract can call this");
|
||||||
require((_operator == owner) || (_from == owner), "only the owner can create redeemables");
|
require((_operator == owner) || (_from == owner), "only the owner can create redeemables");
|
||||||
require(_data.length == 52, "invalid data field");
|
require(_data.length == 52, "invalid data field");
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
pragma solidity ^0.5.16;
|
pragma solidity ^0.6.1;
|
||||||
|
|
||||||
import "./NFTBucket.sol";
|
import "./NFTBucket.sol";
|
||||||
import "./Proxy.sol";
|
import "./Proxy.sol";
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
pragma solidity ^0.5.16;
|
pragma solidity ^0.6.1;
|
||||||
|
|
||||||
contract Proxy {
|
contract Proxy {
|
||||||
/**
|
/**
|
||||||
@ -23,7 +23,7 @@ contract Proxy {
|
|||||||
* @dev Fallback function allowing to perform a delegatecall to the given implementation.
|
* @dev Fallback function allowing to perform a delegatecall to the given implementation.
|
||||||
* This function will return whatever the implementation call returns
|
* This function will return whatever the implementation call returns
|
||||||
*/
|
*/
|
||||||
function() external payable {
|
fallback() external payable {
|
||||||
assembly { // solium-disable-line
|
assembly { // solium-disable-line
|
||||||
let contractLogic := sload(0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7)
|
let contractLogic := sload(0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7)
|
||||||
calldatacopy(0x0, 0x0, calldatasize())
|
calldatacopy(0x0, 0x0, calldatasize())
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
pragma solidity ^0.5.16;
|
pragma solidity ^0.6.1;
|
||||||
|
|
||||||
// https://github.com/ethereum/EIPs/issues/20
|
// https://github.com/ethereum/EIPs/issues/20
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
pragma solidity ^0.5.16;
|
pragma solidity >=0.5.0 <0.7.0;
|
||||||
|
|
||||||
import "./IERC20.sol";
|
import "./IERC20.sol";
|
||||||
|
|
||||||
contract IERC20Detailed is IERC20 {
|
abstract contract IERC20Detailed is IERC20 {
|
||||||
function symbol() public view returns (string memory);
|
function symbol() virtual public view returns (string memory);
|
||||||
function decimals() public view returns (uint8);
|
function decimals() virtual public view returns (uint8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
pragma solidity ^0.5.16;
|
pragma solidity ^0.6.1;
|
||||||
|
|
||||||
import "./IERC20.sol";
|
import "./IERC20.sol";
|
||||||
|
|
||||||
@ -15,6 +15,7 @@ contract StandardToken is IERC20 {
|
|||||||
uint256 _value
|
uint256 _value
|
||||||
)
|
)
|
||||||
external
|
external
|
||||||
|
override(IERC20)
|
||||||
returns (bool success)
|
returns (bool success)
|
||||||
{
|
{
|
||||||
return transfer(msg.sender, _to, _value);
|
return transfer(msg.sender, _to, _value);
|
||||||
@ -22,6 +23,7 @@ contract StandardToken is IERC20 {
|
|||||||
|
|
||||||
function approve(address _spender, uint256 _value)
|
function approve(address _spender, uint256 _value)
|
||||||
external
|
external
|
||||||
|
override(IERC20)
|
||||||
returns (bool success)
|
returns (bool success)
|
||||||
{
|
{
|
||||||
allowed[msg.sender][_spender] = _value;
|
allowed[msg.sender][_spender] = _value;
|
||||||
@ -35,6 +37,7 @@ contract StandardToken is IERC20 {
|
|||||||
uint256 _value
|
uint256 _value
|
||||||
)
|
)
|
||||||
external
|
external
|
||||||
|
override(IERC20)
|
||||||
returns (bool success)
|
returns (bool success)
|
||||||
{
|
{
|
||||||
if (balances[_from] >= _value &&
|
if (balances[_from] >= _value &&
|
||||||
@ -50,6 +53,7 @@ contract StandardToken is IERC20 {
|
|||||||
function allowance(address _owner, address _spender)
|
function allowance(address _owner, address _spender)
|
||||||
external
|
external
|
||||||
view
|
view
|
||||||
|
override(IERC20)
|
||||||
returns (uint256 remaining)
|
returns (uint256 remaining)
|
||||||
{
|
{
|
||||||
return allowed[_owner][_spender];
|
return allowed[_owner][_spender];
|
||||||
@ -58,6 +62,7 @@ contract StandardToken is IERC20 {
|
|||||||
function balanceOf(address _owner)
|
function balanceOf(address _owner)
|
||||||
external
|
external
|
||||||
view
|
view
|
||||||
|
override(IERC20)
|
||||||
returns (uint256 balance)
|
returns (uint256 balance)
|
||||||
{
|
{
|
||||||
return balances[_owner];
|
return balances[_owner];
|
||||||
@ -66,6 +71,7 @@ contract StandardToken is IERC20 {
|
|||||||
function totalSupply()
|
function totalSupply()
|
||||||
external
|
external
|
||||||
view
|
view
|
||||||
|
override(IERC20)
|
||||||
returns(uint256 currentTotalSupply)
|
returns(uint256 currentTotalSupply)
|
||||||
{
|
{
|
||||||
return supply;
|
return supply;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
pragma solidity ^0.5.16;
|
pragma solidity ^0.6.1;
|
||||||
|
|
||||||
import "./StandardToken.sol";
|
import "./StandardToken.sol";
|
||||||
|
|
||||||
@ -16,8 +16,7 @@ contract TestToken is StandardToken {
|
|||||||
_decimals = decimals;
|
_decimals = decimals;
|
||||||
}
|
}
|
||||||
|
|
||||||
// fallback
|
fallback() external {
|
||||||
function() external {
|
|
||||||
uint256 amount = 5000;
|
uint256 amount = 5000;
|
||||||
mint(amount * uint256(10)**_decimals);
|
mint(amount * uint256(10)**_decimals);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
pragma solidity ^0.5.16;
|
pragma solidity ^0.6.1;
|
||||||
|
|
||||||
interface IERC165 {
|
interface IERC165 {
|
||||||
function supportsInterface(bytes4 interfaceId) external view returns (bool);
|
function supportsInterface(bytes4 interfaceId) external view returns (bool);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
pragma solidity ^0.5.16;
|
pragma solidity ^0.6.1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Required interface of an ERC721 compliant contract.
|
* @dev Required interface of an ERC721 compliant contract.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
pragma solidity ^0.5.16;
|
pragma solidity ^0.6.1;
|
||||||
|
|
||||||
/// @title ERC-721 Non-Fungible Token Standard, optional metadata extension
|
/// @title ERC-721 Non-Fungible Token Standard, optional metadata extension
|
||||||
/// @dev See https://eips.ethereum.org/EIPS/eip-721
|
/// @dev See https://eips.ethereum.org/EIPS/eip-721
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
pragma solidity ^0.5.16;
|
pragma solidity ^0.6.1;
|
||||||
|
|
||||||
interface IERC721Receiver {
|
interface IERC721Receiver {
|
||||||
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 returns (bytes4);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
pragma solidity ^0.5.16;
|
pragma solidity ^0.6.1;
|
||||||
|
|
||||||
import "./IERC721.sol";
|
import "./IERC721.sol";
|
||||||
import "./IERC721Receiver.sol";
|
import "./IERC721Receiver.sol";
|
||||||
@ -14,19 +14,19 @@ contract TestNFT is IERC165, IERC721 {
|
|||||||
|
|
||||||
bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd;
|
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");
|
require(owner != address(0), "ERC721: balance query for the zero address");
|
||||||
return _ownedTokensCount[owner];
|
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];
|
address owner = _tokenOwner[tokenId];
|
||||||
require(owner != address(0), "ERC721: owner query for nonexistent token");
|
require(owner != address(0), "ERC721: owner query for nonexistent token");
|
||||||
|
|
||||||
return owner;
|
return owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
function approve(address to, uint256 tokenId) public {
|
function approve(address to, uint256 tokenId) public override(IERC721) {
|
||||||
address owner = ownerOf(tokenId);
|
address owner = ownerOf(tokenId);
|
||||||
require(to != owner, "ERC721: approval to current owner");
|
require(to != owner, "ERC721: approval to current owner");
|
||||||
|
|
||||||
@ -38,34 +38,34 @@ contract TestNFT is IERC165, IERC721 {
|
|||||||
emit Approval(owner, to, tokenId);
|
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");
|
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
|
||||||
|
|
||||||
return _tokenApprovals[tokenId];
|
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");
|
require(to != msg.sender, "ERC721: approve to caller");
|
||||||
|
|
||||||
_operatorApprovals[msg.sender][to] = approved;
|
_operatorApprovals[msg.sender][to] = approved;
|
||||||
emit ApprovalForAll(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];
|
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");
|
require(_isApprovedOrOwner(msg.sender, tokenId), "ERC721: transfer caller is not owner nor approved");
|
||||||
|
|
||||||
_transferFrom(from, to, tokenId);
|
_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, "");
|
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);
|
transferFrom(from, to, tokenId);
|
||||||
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
|
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
|
||||||
}
|
}
|
||||||
@ -131,7 +131,7 @@ contract TestNFT is IERC165, IERC721 {
|
|||||||
return size > 0;
|
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;
|
return interfaceID == _INTERFACE_ID_ERC721;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user