Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
1192e68
Rename current ERC721 implementation to BaseERC721
facuspagnuolo Feb 26, 2018
ca163a8
Implement ERC721 optional & approveAll functionality
facuspagnuolo Feb 26, 2018
71cbc51
Support for new ERC721 interface
spalladino Mar 7, 2018
3745025
Add more tests for ERC721
spalladino Mar 8, 2018
559df81
Implement suggestions by @dekz
spalladino Mar 8, 2018
d726c79
Update comments in ERC721 contracts
spalladino Mar 8, 2018
54a1d2e
Implement tokensByIndex extension
spalladino Mar 9, 2018
851685c
Add default implementation for metadata URI
spalladino Mar 9, 2018
3cef880
Allow operators to call approve on a token
spalladino Mar 9, 2018
6f180a6
Remove gas stipend restriction in call to 721 receiver
spalladino Mar 9, 2018
6fbe771
Remove deprecated implementation
spalladino Mar 9, 2018
626742e
Add notice to isContract helper on constract constructors
spalladino Mar 20, 2018
95a1f9a
Change natspec delimiters for consistency
spalladino Mar 21, 2018
15f9556
Minor linting fixes
spalladino Mar 21, 2018
b332995
Add constant modifier to ERC721_RECEIVED magic value
spalladino Mar 21, 2018
f4748da
Use 4-params safeTransferFrom for implementing the 3-params overload
spalladino Mar 21, 2018
fb4f728
Minor text changes in natspec comments
spalladino Mar 21, 2018
6b98e4e
Use address(0) instead of 0 or 0x0
spalladino Mar 21, 2018
3f2ea8a
Use if-statements instead of boolean one-liners for clarity
spalladino Mar 21, 2018
74db03b
Keep ownedTokensCount state var in sync in full ERC721 implementation
spalladino Mar 21, 2018
981c6f7
Fix incorrect comparison when burning ERC721 tokens with metadata
spalladino Mar 21, 2018
73b77ae
Use address(0) instead of 0 in one more place in ERC721
spalladino Mar 21, 2018
eee5b0e
Throw when querying balance for the zero address
spalladino Mar 21, 2018
9deb637
Update links to approved version of EIP721
spalladino Mar 21, 2018
fe6e4ff
Use explicit size for uint
spalladino Mar 22, 2018
4836279
Remove unneeded internal function in ERC721
spalladino Mar 22, 2018
619ae84
Use underscore instead of 'do' prefix for internal methods in ERC721
spalladino Mar 22, 2018
2e593f2
Fix failing test due to events reordering in ERC721 safe transfer
spalladino Mar 22, 2018
6c09d20
Fix bug introduced in 74db03ba06
spalladino Mar 22, 2018
37929c8
Remove do prefix for internal setTokenUri method
spalladino Mar 22, 2018
3676b55
Allow transfers to self in ERC721
spalladino Mar 23, 2018
7815cc5
Merge branch 'master' into feature/full_erc721
frangio Mar 23, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Implement ERC721 optional & approveAll functionality
  • Loading branch information
facuspagnuolo authored and spalladino committed Mar 9, 2018
commit ca163a849b0b3bbdb18965d54ccf140d07063b69
16 changes: 16 additions & 0 deletions contracts/mocks/ERC721TokenMock.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
pragma solidity ^0.4.18;

import "./BaseERC721TokenMock.sol";
import "../token/ERC721/ERC721Token.sol";

/**
* @title ERC721TokenMock
* This mock just provides a public mint and burn functions for testing purposes.
*/
contract ERC721TokenMock is ERC721Token, BaseERC721TokenMock {
function ERC721TokenMock(string name, string symbol)
BaseERC721TokenMock()
ERC721Token(name, symbol)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we have a convention for this, but I think modifiers should be indented.

public
{ }
}
19 changes: 19 additions & 0 deletions contracts/token/ERC721/ERC721.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
pragma solidity ^0.4.18;

import "./BaseERC721.sol";


/**
* @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);

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);
}
99 changes: 99 additions & 0 deletions contracts/token/ERC721/ERC721Token.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
pragma solidity ^0.4.18;

import "./ERC721.sol";
import "./BaseERC721Token.sol";


/**
* @title Full ERC721 Token
* This implementation includes all the required and some optional functionality of the ERC721 standard
* Moreover, it includes approve all functionality using operatable terminology
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

operable or operator

* @dev see https://github.com/ethereum/eips/issues/721 and https://github.com/ethereum/EIPs/pull/841
*/
contract ERC721Token is ERC721, BaseERC721Token {
// Token name
string private _name;

// Token symbol
string private _symbol;

// Mapping from owner to operator approvals
mapping (address => mapping (address => bool)) private operatorApprovals;

/**
* @dev Constructor function
*/
function ERC721Token(string name, string symbol) public {
_name = name;
_symbol = symbol;
}

/**
* @dev Gets the token name
* @return string representing the token name
*/
function name() public view returns (string) {
return _name;
}

/**
* @dev Gets the token symbol
* @return string representing the token symbol
*/
function symbol() public view returns (string) {
return _symbol;
}

/**
* @dev Gets the token ID at a given index of the tokens list of the requested owner
* @param _owner address owning the tokens list to be accessed
* @param _index uint256 representing the index to be accessed of the requested tokens list
* @return uint256 token ID at the given index of the tokens list owned by the requested address
*/
function tokenOfOwnerByIndex(address _owner, uint256 _index) public view returns (uint256) {
require(_index < balanceOf(_owner));
return tokensOf(_owner)[_index];
}

/**
* @dev Claims the ownership of a given token ID for a given recipient
* @param _to address which you want to transfer the token to
* @param _tokenId uint256 ID of the token being claimed by the msg.sender
*/
function takeOwnershipFor(address _to, uint256 _tokenId) public {
require(isApprovedFor(msg.sender, _tokenId));
clearApprovalAndTransfer(ownerOf(_tokenId), _to, _tokenId);
}

/**
* @dev Sets the approval of a given operator
* @param _to operator address to set the approval
* @param _approved representing the status of the approval to be set
*/
function setOperatorApproval(address _to, bool _approved) public {
require(_to != msg.sender);
operatorApprovals[msg.sender][_to] = _approved;
OperatorApproval(msg.sender, _to, _approved);
}

/**
* @dev Tells whether an operator is approved by a given owner
* @param _owner owner address which you want to query the approval of
* @param _operator operator address which you want to query the approval of
* @return bool whether the given operator is approved by the given owner
*/
function isOperatorApprovedFor(address _owner, address _operator) public view returns (bool) {
return operatorApprovals[_owner][_operator];
}

/**
* @dev Tells whether the given spender is approved for the given token ID or
* if the given owner is an operator approved by the owner of the token
* @param _spender address of the spender to query the approval of
* @param _tokenId uint256 ID of the token to query the approval of
* @return bool whether the msg.sender is approved for the given token ID or not
*/
function isApprovedFor(address _spender, uint256 _tokenId) internal view returns (bool) {
return super.isApprovedFor(_spender, _tokenId) || isOperatorApprovedFor(ownerOf(_tokenId), _spender);
}
}
Loading