Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
openzeppelin-contracts-upgradeable
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
俞永鹏
openzeppelin-contracts-upgradeable
Commits
41e6b2e9
Unverified
Commit
41e6b2e9
authored
Aug 13, 2018
by
Nicolás Venturo
Committed by
GitHub
Aug 13, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make ERC721.exists internal (#1193)
* Made ERC721.exists internal. * Removed exists ERC165 identifiers
parent
f00fce53
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
16 additions
and
42 deletions
+16
-42
ERC721TokenMock.sol
contracts/mocks/ERC721TokenMock.sol
+4
-0
ERC721Basic.sol
contracts/token/ERC721/ERC721Basic.sol
+0
-7
ERC721BasicToken.sol
contracts/token/ERC721/ERC721BasicToken.sol
+10
-11
ERC721Token.sol
contracts/token/ERC721/ERC721Token.sol
+2
-2
ERC721BasicToken.behavior.js
test/token/ERC721/ERC721BasicToken.behavior.js
+0
-21
ERC721Token.test.js
test/token/ERC721/ERC721Token.test.js
+0
-1
No files found.
contracts/mocks/ERC721TokenMock.sol
View file @
41e6b2e9
...
@@ -21,6 +21,10 @@ contract ERC721TokenMock is ERC721Token {
...
@@ -21,6 +21,10 @@ contract ERC721TokenMock is ERC721Token {
super._burn(ownerOf(_tokenId), _tokenId);
super._burn(ownerOf(_tokenId), _tokenId);
}
}
function exists(uint256 _tokenId) public view returns (bool) {
return super._exists(_tokenId);
}
function setTokenURI(uint256 _tokenId, string _uri) public {
function setTokenURI(uint256 _tokenId, string _uri) public {
super._setTokenURI(_tokenId, _uri);
super._setTokenURI(_tokenId, _uri);
}
}
...
...
contracts/token/ERC721/ERC721Basic.sol
View file @
41e6b2e9
...
@@ -23,12 +23,6 @@ contract ERC721Basic is ERC165 {
...
@@ -23,12 +23,6 @@ contract ERC721Basic is ERC165 {
* bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)'))
* bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)'))
*/
*/
bytes4 internal constant InterfaceId_ERC721Exists = 0x4f558e79;
/*
* 0x4f558e79 ===
* bytes4(keccak256('exists(uint256)'))
*/
bytes4 internal constant InterfaceId_ERC721Enumerable = 0x780e9d63;
bytes4 internal constant InterfaceId_ERC721Enumerable = 0x780e9d63;
/**
/**
* 0x780e9d63 ===
* 0x780e9d63 ===
...
@@ -63,7 +57,6 @@ contract ERC721Basic is ERC165 {
...
@@ -63,7 +57,6 @@ contract ERC721Basic is ERC165 {
function balanceOf(address _owner) public view returns (uint256 _balance);
function balanceOf(address _owner) public view returns (uint256 _balance);
function ownerOf(uint256 _tokenId) public view returns (address _owner);
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 approve(address _to, uint256 _tokenId) public;
function getApproved(uint256 _tokenId)
function getApproved(uint256 _tokenId)
...
...
contracts/token/ERC721/ERC721BasicToken.sol
View file @
41e6b2e9
...
@@ -37,7 +37,6 @@ contract ERC721BasicToken is SupportsInterfaceWithLookup, ERC721Basic {
...
@@ -37,7 +37,6 @@ contract ERC721BasicToken is SupportsInterfaceWithLookup, ERC721Basic {
{
{
// register the supported interfaces to conform to ERC721 via ERC165
// register the supported interfaces to conform to ERC721 via ERC165
_registerInterface(InterfaceId_ERC721);
_registerInterface(InterfaceId_ERC721);
_registerInterface(InterfaceId_ERC721Exists);
}
}
/**
/**
...
@@ -62,16 +61,6 @@ contract ERC721BasicToken is SupportsInterfaceWithLookup, ERC721Basic {
...
@@ -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
* @dev Approves another address to transfer the given token ID
* The zero address indicates there is no approved address.
* The zero address indicates there is no approved address.
* There can only be one approved address per token at a given time.
* There can only be one approved address per token at a given time.
...
@@ -201,6 +190,16 @@ contract ERC721BasicToken is SupportsInterfaceWithLookup, ERC721Basic {
...
@@ -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
* @dev Returns whether the given spender can transfer a given token ID
* @param _spender address of the spender to query
* @param _spender address of the spender to query
* @param _tokenId uint256 ID of the token to be transferred
* @param _tokenId uint256 ID of the token to be transferred
...
...
contracts/token/ERC721/ERC721Token.sol
View file @
41e6b2e9
...
@@ -68,7 +68,7 @@ contract ERC721Token is SupportsInterfaceWithLookup, ERC721BasicToken, ERC721 {
...
@@ -68,7 +68,7 @@ contract ERC721Token is SupportsInterfaceWithLookup, ERC721BasicToken, ERC721 {
* @param _tokenId uint256 ID of the token to query
* @param _tokenId uint256 ID of the token to query
*/
*/
function tokenURI(uint256 _tokenId) public view returns (string) {
function tokenURI(uint256 _tokenId) public view returns (string) {
require(exists(_tokenId));
require(
_
exists(_tokenId));
return tokenURIs[_tokenId];
return tokenURIs[_tokenId];
}
}
...
@@ -116,7 +116,7 @@ contract ERC721Token is SupportsInterfaceWithLookup, ERC721BasicToken, ERC721 {
...
@@ -116,7 +116,7 @@ contract ERC721Token is SupportsInterfaceWithLookup, ERC721BasicToken, ERC721 {
* @param _uri string URI to assign
* @param _uri string URI to assign
*/
*/
function _setTokenURI(uint256 _tokenId, string _uri) internal {
function _setTokenURI(uint256 _tokenId, string _uri) internal {
require(exists(_tokenId));
require(
_
exists(_tokenId));
tokenURIs[_tokenId] = _uri;
tokenURIs[_tokenId] = _uri;
}
}
...
...
test/token/ERC721/ERC721BasicToken.behavior.js
View file @
41e6b2e9
...
@@ -47,26 +47,6 @@ function shouldBehaveLikeERC721BasicToken (accounts) {
...
@@ -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
()
{
describe
(
'ownerOf'
,
function
()
{
context
(
'when the given token ID was tracked by this token'
,
function
()
{
context
(
'when the given token ID was tracked by this token'
,
function
()
{
const
tokenId
=
firstTokenId
;
const
tokenId
=
firstTokenId
;
...
@@ -554,7 +534,6 @@ function shouldBehaveLikeERC721BasicToken (accounts) {
...
@@ -554,7 +534,6 @@ function shouldBehaveLikeERC721BasicToken (accounts) {
shouldSupportInterfaces
([
shouldSupportInterfaces
([
'ERC165'
,
'ERC165'
,
'ERC721'
,
'ERC721'
,
'ERC721Exists'
,
]);
]);
});
});
}
}
...
...
test/token/ERC721/ERC721Token.test.js
View file @
41e6b2e9
...
@@ -225,7 +225,6 @@ contract('ERC721Token', function (accounts) {
...
@@ -225,7 +225,6 @@ contract('ERC721Token', function (accounts) {
shouldSupportInterfaces
([
shouldSupportInterfaces
([
'ERC165'
,
'ERC165'
,
'ERC721'
,
'ERC721'
,
'ERC721Exists'
,
'ERC721Enumerable'
,
'ERC721Enumerable'
,
'ERC721Metadata'
,
'ERC721Metadata'
,
]);
]);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment