-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Tests for new features are pending - ERC721 is abstract, since it requires metadata implementation - Move some methods into DeprecatedERC721 contract - Reorganise base vs full implementation - Pending tokenByIndex
- Loading branch information
1 parent
2e1a695
commit c03b84a
Showing
17 changed files
with
964 additions
and
1,215 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,17 @@ | ||
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 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 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]; | ||
} | ||
} |
Oops, something went wrong.