Unverified Commit 41e6b2e9 by Nicolás Venturo Committed by GitHub

Make ERC721.exists internal (#1193)

* Made ERC721.exists internal.

* Removed exists ERC165 identifiers
parent f00fce53
......@@ -21,6 +21,10 @@ contract ERC721TokenMock is ERC721Token {
super._burn(ownerOf(_tokenId), _tokenId);
}
function exists(uint256 _tokenId) public view returns (bool) {
return super._exists(_tokenId);
}
function setTokenURI(uint256 _tokenId, string _uri) public {
super._setTokenURI(_tokenId, _uri);
}
......
......@@ -23,12 +23,6 @@ contract ERC721Basic is ERC165 {
* bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)'))
*/
bytes4 internal constant InterfaceId_ERC721Exists = 0x4f558e79;
/*
* 0x4f558e79 ===
* bytes4(keccak256('exists(uint256)'))
*/
bytes4 internal constant InterfaceId_ERC721Enumerable = 0x780e9d63;
/**
* 0x780e9d63 ===
......@@ -63,7 +57,6 @@ contract ERC721Basic is ERC165 {
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)
......
......@@ -37,7 +37,6 @@ contract ERC721BasicToken is SupportsInterfaceWithLookup, ERC721Basic {
{
// register the supported interfaces to conform to ERC721 via ERC165
_registerInterface(InterfaceId_ERC721);
_registerInterface(InterfaceId_ERC721Exists);
}
/**
......@@ -62,16 +61,6 @@ contract ERC721BasicToken is SupportsInterfaceWithLookup, ERC721Basic {
}
/**
* @dev Returns whether the specified token exists
* @param _tokenId uint256 ID of the token to query the existence of
* @return whether the token exists
*/
function exists(uint256 _tokenId) public view returns (bool) {
address owner = tokenOwner[_tokenId];
return owner != address(0);
}
/**
* @dev Approves another address to transfer the given token ID
* The zero address indicates there is no approved address.
* There can only be one approved address per token at a given time.
......@@ -201,6 +190,16 @@ contract ERC721BasicToken is SupportsInterfaceWithLookup, ERC721Basic {
}
/**
* @dev Returns whether the specified token exists
* @param _tokenId uint256 ID of the token to query the existence of
* @return whether the token exists
*/
function _exists(uint256 _tokenId) internal view returns (bool) {
address owner = tokenOwner[_tokenId];
return owner != address(0);
}
/**
* @dev Returns whether the given spender can transfer a given token ID
* @param _spender address of the spender to query
* @param _tokenId uint256 ID of the token to be transferred
......
......@@ -68,7 +68,7 @@ contract ERC721Token is SupportsInterfaceWithLookup, ERC721BasicToken, ERC721 {
* @param _tokenId uint256 ID of the token to query
*/
function tokenURI(uint256 _tokenId) public view returns (string) {
require(exists(_tokenId));
require(_exists(_tokenId));
return tokenURIs[_tokenId];
}
......@@ -116,7 +116,7 @@ contract ERC721Token is SupportsInterfaceWithLookup, ERC721BasicToken, ERC721 {
* @param _uri string URI to assign
*/
function _setTokenURI(uint256 _tokenId, string _uri) internal {
require(exists(_tokenId));
require(_exists(_tokenId));
tokenURIs[_tokenId] = _uri;
}
......
......@@ -47,26 +47,6 @@ function shouldBehaveLikeERC721BasicToken (accounts) {
});
});
describe('exists', function () {
context('when the token exists', function () {
const tokenId = firstTokenId;
it('should return true', async function () {
const result = await this.token.exists(tokenId);
result.should.be.true;
});
});
context('when the token does not exist', function () {
const tokenId = unknownTokenId;
it('should return false', async function () {
const result = await this.token.exists(tokenId);
result.should.be.false;
});
});
});
describe('ownerOf', function () {
context('when the given token ID was tracked by this token', function () {
const tokenId = firstTokenId;
......@@ -554,7 +534,6 @@ function shouldBehaveLikeERC721BasicToken (accounts) {
shouldSupportInterfaces([
'ERC165',
'ERC721',
'ERC721Exists',
]);
});
}
......
......@@ -225,7 +225,6 @@ contract('ERC721Token', function (accounts) {
shouldSupportInterfaces([
'ERC165',
'ERC721',
'ERC721Exists',
'ERC721Enumerable',
'ERC721Metadata',
]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment