-
Notifications
You must be signed in to change notification settings - Fork 12.4k
ERC721 full implementation #803
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
1192e68
ca163a8
71cbc51
3745025
559df81
d726c79
54a1d2e
851685c
3cef880
6f180a6
6fbe771
626742e
95a1f9a
15f9556
b332995
f4748da
fb4f728
6b98e4e
3f2ea8a
74db03b
981c6f7
73b77ae
eee5b0e
9deb637
fe6e4ff
4836279
619ae84
2e593f2
6c09d20
37929c8
3676b55
7815cc5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| pragma solidity ^0.4.18; | ||
|
|
||
| import "../token/ERC721/ERC721Receiver.sol"; | ||
|
|
||
| contract ERC721ReceiverMock is ERC721Receiver { | ||
| bytes4 retval; | ||
| bool reverts; | ||
|
|
||
| event Received(address _address, uint256 _tokenId, bytes _data, uint256 _gas); | ||
|
|
||
| function ERC721ReceiverMock(bytes4 _retval, bool _reverts) public { | ||
| retval = _retval; | ||
| reverts = _reverts; | ||
| } | ||
|
|
||
| function onERC721Received(address _address, uint256 _tokenId, bytes _data) public returns(bytes4) { | ||
| require(!reverts); | ||
| Received(_address, _tokenId, _data, msg.gas); | ||
| return retval; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -177,9 +177,7 @@ contract ERC721BasicToken is ERC721Basic { | |
| * @param _tokenId uint256 ID of the token being burned by the msg.sender | ||
| */ | ||
| function doBurn(uint256 _tokenId) onlyOwnerOf(_tokenId) internal { | ||
| if (getApproved(_tokenId) != 0) { | ||
| clearApproval(msg.sender, _tokenId); | ||
| } | ||
| clearApproval(msg.sender, _tokenId); | ||
| removeToken(msg.sender, _tokenId); | ||
| totalTokens = totalTokens.sub(1); | ||
| Transfer(msg.sender, 0x0, _tokenId); | ||
|
|
@@ -214,8 +212,10 @@ contract ERC721BasicToken is ERC721Basic { | |
| */ | ||
| function clearApproval(address _owner, uint256 _tokenId) internal { | ||
| require(ownerOf(_tokenId) == _owner); | ||
| tokenApprovals[_tokenId] = 0; | ||
| Approval(_owner, 0, _tokenId); | ||
| if (tokenApprovals[_tokenId] != 0) { | ||
| tokenApprovals[_tokenId] = 0; | ||
| Approval(_owner, 0, _tokenId); | ||
|
||
| } | ||
| } | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| const _ = require('lodash'); | ||
| const ethjsABI = require('ethjs-abi'); | ||
|
|
||
| export function findMethod (abi, name, args) { | ||
| for (var i = 0; i < abi.length; i++) { | ||
| const methodArgs = _.map(abi[i].inputs, 'type').join(','); | ||
| if ((abi[i].name === name) && (methodArgs === args)) { | ||
| return abi[i]; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| export default function sendTransaction (target, name, argsTypes, argsValues, opts) { | ||
| const abiMethod = findMethod(target.abi, name, argsTypes); | ||
| const encodedData = ethjsABI.encodeMethod(abiMethod, argsValues); | ||
| return target.sendTransaction(Object.assign({ data: encodedData }, opts)); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the linter will cry if you don't make visibility explicit here