forked from OpenZeppelin/openzeppelin-contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2e1a695
commit b81b4e1
Showing
16 changed files
with
518 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
pragma solidity ^0.4.18; | ||
|
||
library AddressUtils { | ||
|
||
function isContract(address addr) internal view returns (bool) { | ||
uint size; | ||
assembly { size := extcodesize(addr) } | ||
return size > 0; | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
pragma solidity ^0.4.18; | ||
|
||
import "../token/ERC721/ERC721BasicToken.sol"; | ||
|
||
/** | ||
* @title ERC721BasicTokenMock | ||
* This mock just provides a public mint and burn functions for testing purposes. | ||
*/ | ||
contract ERC721BasicTokenMock is ERC721BasicToken { | ||
function ERC721BasicTokenMock() ERC721BasicToken() public { } | ||
|
||
function mint(address _to, uint256 _tokenId) public { | ||
super.doMint(_to, _tokenId); | ||
} | ||
|
||
function burn(uint256 _tokenId) public { | ||
super.doBurn(_tokenId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,35 @@ | ||
pragma solidity ^0.4.18; | ||
|
||
import "./BaseERC721TokenMock.sol"; | ||
import "./ERC721BasicTokenMock.sol"; | ||
import "../token/ERC721/ERC721Token.sol"; | ||
|
||
/** | ||
* @title ERC721TokenMock | ||
* This mock just provides a public mint and burn functions for testing purposes. | ||
* This mock just provides a public mint and burn functions for testing purposes, | ||
* and a mock metadata URI implementation | ||
*/ | ||
contract ERC721TokenMock is ERC721Token, BaseERC721TokenMock { | ||
contract ERC721TokenMock is ERC721Token, ERC721BasicTokenMock { | ||
function ERC721TokenMock(string name, string symbol) | ||
BaseERC721TokenMock() | ||
ERC721BasicTokenMock() | ||
ERC721Token(name, symbol) | ||
public | ||
{ } | ||
|
||
// Mock implementation for testing. | ||
// Do not use this code in production! | ||
function tokenURI(uint256 _tokenId) public view returns (string) { | ||
require(exists(_tokenId)); | ||
|
||
bytes memory uri = new bytes(78); | ||
|
||
uint256 i; | ||
uint256 value = _tokenId; | ||
|
||
for (i = 0; i < 78; i++) { | ||
uri[7 + 78 - i] = byte(value % 10 + 48); | ||
value = value / 10; | ||
} | ||
|
||
return string(uri); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
pragma solidity ^0.4.18; | ||
|
||
import "./ERC721.sol"; | ||
|
||
contract DeprecatedERC721 is ERC721 { | ||
function takeOwnership(uint256 _tokenId) public; | ||
function transfer(address _to, uint256 _tokenId) public; | ||
function tokensOf(address _owner) public view returns (uint256[]); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
pragma solidity ^0.4.18; | ||
|
||
import "./DeprecatedERC721.sol"; | ||
import "./ERC721Token.sol"; | ||
|
||
contract DeprecatedERC721Token is DeprecatedERC721, ERC721Token { | ||
/** | ||
* @dev Claims the ownership of a given token ID | ||
* @param _tokenId uint256 ID of the token being claimed by the msg.sender | ||
*/ | ||
function takeOwnership(uint256 _tokenId) canTransfer(_tokenId) public { | ||
require(msg.sender != ownerOf(_tokenId)); | ||
clearApprovalAndTransfer(ownerOf(_tokenId), msg.sender, _tokenId, "", false); | ||
} | ||
|
||
/** | ||
* @dev Transfers the ownership of a given token ID to another address | ||
* @param _to address to receive the ownership of the given token ID | ||
* @param _tokenId uint256 ID of the token to be transferred | ||
*/ | ||
function transfer(address _to, uint256 _tokenId) public { | ||
address owner = ownerOf(_tokenId); | ||
require(owner == msg.sender); | ||
clearApprovalAndTransfer(owner, _to, _tokenId, "", false); | ||
} | ||
|
||
/** | ||
* @dev Gets the list of tokens owned by a given address | ||
* @param _owner address to query the tokens of | ||
* @return uint256[] representing the list of tokens owned by the passed address | ||
*/ | ||
function tokensOf(address _owner) public view returns (uint256[]) { | ||
return ownedTokens[_owner]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,18 @@ | ||
pragma solidity ^0.4.18; | ||
|
||
import "./BaseERC721.sol"; | ||
import "./ERC721Basic.sol"; | ||
|
||
contract ERC721Enumerable is ERC721Basic { | ||
function totalSupply() public view returns (uint256); | ||
function tokenOfOwnerByIndex(address _owner, uint256 _index) public view returns (uint256 _tokenId); | ||
//function tokenByIndex(uint256 _index) public view returns (uint256); | ||
} | ||
|
||
/** | ||
* @title Full ERC721 interface | ||
* @dev see https://github.com/ethereum/eips/issues/721 and https://github.com/ethereum/EIPs/pull/841 | ||
*/ | ||
contract ERC721 is BaseERC721 { | ||
event OperatorApproval(address indexed _owner, address indexed _operator, bool _approved); | ||
|
||
contract ERC721Metadata is ERC721Basic { | ||
function name() public view returns (string _name); | ||
function symbol() public view returns (string _symbol); | ||
function takeOwnershipFor(address _to, uint256 _tokenId) public; | ||
function setOperatorApproval(address _to, bool _approved) public; | ||
function isOperatorApprovedFor(address _owner, address _operator) public view returns (bool); | ||
function tokenOfOwnerByIndex(address _owner, uint256 _index) public view returns (uint256 _tokenId); | ||
function tokenURI(uint256 _tokenId) public view returns (string); | ||
} | ||
|
||
contract ERC721 is ERC721Basic, ERC721Enumerable, ERC721Metadata { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
pragma solidity ^0.4.18; | ||
|
||
/** | ||
* @title Base ERC721 interface | ||
* @dev see https://github.com/ethereum/eips/issues/721 and https://github.com/ethereum/EIPs/pull/841 | ||
*/ | ||
contract ERC721Basic { | ||
event Transfer(address indexed _from, address indexed _to, uint256 _tokenId); | ||
event Approval(address indexed _owner, address indexed _approved, uint256 _tokenId); | ||
event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved); | ||
|
||
function balanceOf(address _owner) public view returns (uint256 _balance); | ||
function ownerOf(uint256 _tokenId) public view returns (address _owner); | ||
function exists(uint256 _tokenId) public view returns (bool _exists); | ||
|
||
function approve(address _to, uint256 _tokenId) public; | ||
function getApproved(uint256 _tokenId) public view returns (address _operator); | ||
|
||
function setApprovalForAll(address _operator, bool _approved) public; | ||
function isApprovedForAll(address _owner, address _operator) public view returns (bool); | ||
|
||
function transferFrom(address _from, address _to, uint256 _tokenId) public; | ||
function safeTransferFrom(address _from, address _to, uint256 _tokenId) public; | ||
function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes _data) public; | ||
} |
Oops, something went wrong.