Skip to content
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

ERC827-like methods for ERC721Holdings #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion contracts/ERC721Holdings.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pragma solidity ^0.4.23;

import "./ERC721HoldingsBasic.sol";
import "./ERC721HoldingsExecuteCalls.sol";


/**
Expand Down Expand Up @@ -29,4 +30,4 @@ contract ERC721HoldingsMetadata is ERC721HoldingsBasic {
* @title Holdings of ERC-721 Non-Fungible Token Standard, full implementation interface
* @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
*/
contract ERC721Holdings is ERC721HoldingsBasic, ERC721HoldingsEnumerable, ERC721HoldingsMetadata {}
contract ERC721Holdings is ERC721HoldingsBasic, ERC721HoldingsEnumerable, ERC721HoldingsMetadata, ERC721HoldingsExecuteCalls {}
12 changes: 12 additions & 0 deletions contracts/ERC721HoldingsExecuteCalls.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
pragma solidity ^0.4.23;

import "./ERC721HoldingsBasic.sol";


contract ERC721HoldingsExecuteCalls is ERC721HoldingsBasic {
function approveAndCall(address _spender, uint256 _tokenId, bytes _data)
public payable returns (bool);

function transferFromAndCall(address _from, uint256 _to, address _toOrigin, uint256 _tokenId, bytes _data)
public payable returns (bool);
}
36 changes: 36 additions & 0 deletions contracts/ERC721HoldingsExecuteCallsToken.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
pragma solidity ^0.4.23;

import "./ERC721HoldingsBasicToken.sol";


contract ERC721HoldingsExecuteCallsToken is ERC721HoldingsBasicToken {

function approveAndCall(address _spender, uint256 _tokenId, bytes _data)
public payable returns (bool)
{
super.approve(_spender, _tokenId);

// solium-disable-next-line security/no-call-value
require(_spender.call.value(msg.value)(_data));

return true;
}

function transferFromAndCall(
address _from,
uint256 _to,
address _toOrigin,
uint256 _tokenId,
bytes _data)
public payable returns (bool)
{
address _holderOwner = _ownerOf(_to, _toOrigin);
require(_holderOwner != address(this));

super.transferFrom(_from, _to, _toOrigin, _tokenId);

// solium-disable-next-line security/no-call-value
require(_holderOwner.call.value(msg.value)(_data));
return true;
}
}
3 changes: 2 additions & 1 deletion contracts/ERC721HoldingsToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ pragma solidity ^0.4.23;

import "./ERC721Holdings.sol";
import "./ERC721HoldingsBasicToken.sol";
import "./ERC721HoldingsExecuteCallsToken.sol";


/**
* @title Full ERC721Holdings Token
* This implementation includes all the required and some optional functionality of the ERC721Holdings standard
* @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
*/
contract ERC721HoldingsToken is ERC721Holdings, ERC721HoldingsBasicToken {
contract ERC721HoldingsToken is ERC721Holdings, ERC721HoldingsBasicToken, ERC721HoldingsExecuteCallsToken {
// Token name
string internal name_;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
pragma solidity ^0.4.23;

import "../ERC721HoldingsBasicToken.sol";
import "../ERC721HoldingsToken.sol";


/**
* @title ERC721HoldingsBasicTokenMock
* @title ERC721HoldingsTokenMock
* This mock just provides a public mint and burn functions for testing purposes
*/
contract ERC721HoldingsBasicTokenMock is ERC721HoldingsBasicToken {
contract ERC721HoldingsTokenMock is ERC721HoldingsToken {

constructor (address _nftAddress) ERC721HoldingsBasicToken(_nftAddress) public {
constructor (address _nftAddress) ERC721HoldingsToken("Test", "TST", _nftAddress) public {
require(_nftAddress != address(0));
tokens = ERC721(_nftAddress);
}
Expand Down
30 changes: 30 additions & 0 deletions contracts/test/MessageHelper.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
pragma solidity ^0.4.23;


contract MessageHelper {

event Show(bytes32 b32, uint256 number, string text);
event Buy(bytes32 b32, uint256 number, string text, uint256 value);

function showMessage( bytes32 message, uint256 number, string text ) public returns (bool) {
emit Show(message, number, text);
return true;
}

function buyMessage( bytes32 message, uint256 number, string text ) public payable returns (bool) {
emit Buy(message, number, text, msg.value);
return true;
}

function fail() public pure {
require(false);
}

function call(address to, bytes data) public returns (bool) {
// solium-disable-next-line security/no-low-level-calls
if (to.call(data))
return true;
else
return false;
}
}
71 changes: 71 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"chai": "^4.1.2",
"chai-as-promised": "^7.1.1",
"chai-bignumber": "^2.0.2",
"ethereumjs-abi": "^0.6.5",
"ethjs-abi": "^0.2.1",
"solium": "^1.1.7",
"truffle": "^4.1.7",
Expand Down
21 changes: 0 additions & 21 deletions test/ERC721HoldingsBasicToken.test.js

This file was deleted.

Loading