Commit 82ce197e by Leo Arias Committed by Francisco Giordano

tests: fix most of the static warnings (#844)

parent 42787e2a
pragma solidity ^0.4.18; pragma solidity ^0.4.18;
/** /**
* Utility library of inline functions on addresses * Utility library of inline functions on addresses
*/ */
library AddressUtils { library AddressUtils {
/** /**
* Returns whether there is code in the target address * Returns whether the target address is a contract
* @dev This function will return false if invoked during the constructor of a contract, * @dev This function will return false if invoked during the constructor of a contract,
* as the code is not actually created until after the constructor finishes. * as the code is not actually created until after the constructor finishes.
* @param addr address address to check * @param addr address to check
* @return whether there is code in the target address * @return whether the target address is a contract
*/ */
function isContract(address addr) internal view returns (bool) { function isContract(address addr) internal view returns (bool) {
uint256 size; uint256 size;
assembly { size := extcodesize(addr) } // XXX Currently there is no better way to check if there is a contract in an address
// than to check the size of the code at that address.
// See https://ethereum.stackexchange.com/a/14016/36603
// for more details about how this works.
// TODO Check this again before the Serenity release, because all addresses will be
// contracts then.
assembly { size := extcodesize(addr) } // solium-disable-line security/no-inline-assembly
return size > 0; return size > 0;
} }
......
...@@ -61,7 +61,7 @@ contract DayLimit { ...@@ -61,7 +61,7 @@ contract DayLimit {
* @return uint256 of today's index. * @return uint256 of today's index.
*/ */
function today() private view returns (uint256) { function today() private view returns (uint256) {
return now / 1 days; return block.timestamp / 1 days;
} }
/** /**
......
...@@ -5,6 +5,10 @@ pragma solidity ^0.4.18; ...@@ -5,6 +5,10 @@ pragma solidity ^0.4.18;
* @title Eliptic curve signature operations * @title Eliptic curve signature operations
* *
* @dev Based on https://gist.github.com/axic/5b33912c6f61ae6fd96d6c4a47afde6d * @dev Based on https://gist.github.com/axic/5b33912c6f61ae6fd96d6c4a47afde6d
*
* TODO Remove this library once solidity supports passing a signature to ecrecover.
* See https://github.com/ethereum/solidity/issues/864
*
*/ */
library ECRecovery { library ECRecovery {
...@@ -25,6 +29,9 @@ library ECRecovery { ...@@ -25,6 +29,9 @@ library ECRecovery {
} }
// Divide the signature in r, s and v variables // Divide the signature in r, s and v variables
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
// solium-disable-next-line security/no-inline-assembly
assembly { assembly {
r := mload(add(sig, 32)) r := mload(add(sig, 32))
s := mload(add(sig, 64)) s := mload(add(sig, 64))
......
...@@ -24,6 +24,7 @@ library MerkleProof { ...@@ -24,6 +24,7 @@ library MerkleProof {
bytes32 computedHash = _leaf; bytes32 computedHash = _leaf;
for (uint256 i = 32; i <= _proof.length; i += 32) { for (uint256 i = 32; i <= _proof.length; i += 32) {
// solium-disable-next-line security/no-inline-assembly
assembly { assembly {
// Load the current element of the proof // Load the current element of the proof
proofElement := mload(add(_proof, i)) proofElement := mload(add(_proof, i))
......
...@@ -3,6 +3,7 @@ pragma solidity ^0.4.18; ...@@ -3,6 +3,7 @@ pragma solidity ^0.4.18;
import "../token/ERC20/ERC20.sol"; import "../token/ERC20/ERC20.sol";
import "../math/SafeMath.sol"; import "../math/SafeMath.sol";
/** /**
* @title Crowdsale * @title Crowdsale
* @dev Crowdsale is a base contract for managing a token crowdsale, * @dev Crowdsale is a base contract for managing a token crowdsale,
...@@ -15,7 +16,6 @@ import "../math/SafeMath.sol"; ...@@ -15,7 +16,6 @@ import "../math/SafeMath.sol";
* the methods to add functionality. Consider using 'super' where appropiate to concatenate * the methods to add functionality. Consider using 'super' where appropiate to concatenate
* behavior. * behavior.
*/ */
contract Crowdsale { contract Crowdsale {
using SafeMath for uint256; using SafeMath for uint256;
......
...@@ -4,6 +4,7 @@ import "../../math/SafeMath.sol"; ...@@ -4,6 +4,7 @@ import "../../math/SafeMath.sol";
import "../../ownership/Ownable.sol"; import "../../ownership/Ownable.sol";
import "../validation/TimedCrowdsale.sol"; import "../validation/TimedCrowdsale.sol";
/** /**
* @title FinalizableCrowdsale * @title FinalizableCrowdsale
* @dev Extension of Crowdsale where an owner can do extra work * @dev Extension of Crowdsale where an owner can do extra work
...@@ -37,4 +38,5 @@ contract FinalizableCrowdsale is TimedCrowdsale, Ownable { ...@@ -37,4 +38,5 @@ contract FinalizableCrowdsale is TimedCrowdsale, Ownable {
*/ */
function finalization() internal { function finalization() internal {
} }
} }
...@@ -4,6 +4,7 @@ import "../validation/TimedCrowdsale.sol"; ...@@ -4,6 +4,7 @@ import "../validation/TimedCrowdsale.sol";
import "../../token/ERC20/ERC20.sol"; import "../../token/ERC20/ERC20.sol";
import "../../math/SafeMath.sol"; import "../../math/SafeMath.sol";
/** /**
* @title PostDeliveryCrowdsale * @title PostDeliveryCrowdsale
* @dev Crowdsale that locks tokens from withdrawal until it ends. * @dev Crowdsale that locks tokens from withdrawal until it ends.
...@@ -14,15 +15,6 @@ contract PostDeliveryCrowdsale is TimedCrowdsale { ...@@ -14,15 +15,6 @@ contract PostDeliveryCrowdsale is TimedCrowdsale {
mapping(address => uint256) public balances; mapping(address => uint256) public balances;
/** /**
* @dev Overrides parent by storing balances instead of issuing tokens right away.
* @param _beneficiary Token purchaser
* @param _tokenAmount Amount of tokens purchased
*/
function _processPurchase(address _beneficiary, uint256 _tokenAmount) internal {
balances[_beneficiary] = balances[_beneficiary].add(_tokenAmount);
}
/**
* @dev Withdraw tokens only after crowdsale ends. * @dev Withdraw tokens only after crowdsale ends.
*/ */
function withdrawTokens() public { function withdrawTokens() public {
...@@ -32,4 +24,14 @@ contract PostDeliveryCrowdsale is TimedCrowdsale { ...@@ -32,4 +24,14 @@ contract PostDeliveryCrowdsale is TimedCrowdsale {
balances[msg.sender] = 0; balances[msg.sender] = 0;
_deliverTokens(msg.sender, amount); _deliverTokens(msg.sender, amount);
} }
/**
* @dev Overrides parent by storing balances instead of issuing tokens right away.
* @param _beneficiary Token purchaser
* @param _tokenAmount Amount of tokens purchased
*/
function _processPurchase(address _beneficiary, uint256 _tokenAmount) internal {
balances[_beneficiary] = balances[_beneficiary].add(_tokenAmount);
}
} }
...@@ -3,6 +3,7 @@ pragma solidity ^0.4.18; ...@@ -3,6 +3,7 @@ pragma solidity ^0.4.18;
import "../validation/TimedCrowdsale.sol"; import "../validation/TimedCrowdsale.sol";
import "../../math/SafeMath.sol"; import "../../math/SafeMath.sol";
/** /**
* @title IncreasingPriceCrowdsale * @title IncreasingPriceCrowdsale
* @dev Extension of Crowdsale contract that increases the price of tokens linearly in time. * @dev Extension of Crowdsale contract that increases the price of tokens linearly in time.
...@@ -33,7 +34,7 @@ contract IncreasingPriceCrowdsale is TimedCrowdsale { ...@@ -33,7 +34,7 @@ contract IncreasingPriceCrowdsale is TimedCrowdsale {
* @return The number of tokens a buyer gets per wei at a given time * @return The number of tokens a buyer gets per wei at a given time
*/ */
function getCurrentRate() public view returns (uint256) { function getCurrentRate() public view returns (uint256) {
uint256 elapsedTime = now.sub(openingTime); uint256 elapsedTime = block.timestamp.sub(openingTime);
uint256 timeRange = closingTime.sub(openingTime); uint256 timeRange = closingTime.sub(openingTime);
uint256 rateRange = initialRate.sub(finalRate); uint256 rateRange = initialRate.sub(finalRate);
return initialRate.sub(elapsedTime.mul(rateRange).div(timeRange)); return initialRate.sub(elapsedTime.mul(rateRange).div(timeRange));
......
...@@ -18,7 +18,7 @@ contract TimedCrowdsale is Crowdsale { ...@@ -18,7 +18,7 @@ contract TimedCrowdsale is Crowdsale {
* @dev Reverts if not in crowdsale time range. * @dev Reverts if not in crowdsale time range.
*/ */
modifier onlyWhileOpen { modifier onlyWhileOpen {
require(now >= openingTime && now <= closingTime); require(block.timestamp >= openingTime && block.timestamp <= closingTime);
_; _;
} }
...@@ -28,7 +28,7 @@ contract TimedCrowdsale is Crowdsale { ...@@ -28,7 +28,7 @@ contract TimedCrowdsale is Crowdsale {
* @param _closingTime Crowdsale closing time * @param _closingTime Crowdsale closing time
*/ */
function TimedCrowdsale(uint256 _openingTime, uint256 _closingTime) public { function TimedCrowdsale(uint256 _openingTime, uint256 _closingTime) public {
require(_openingTime >= now); require(_openingTime >= block.timestamp);
require(_closingTime >= _openingTime); require(_closingTime >= _openingTime);
openingTime = _openingTime; openingTime = _openingTime;
...@@ -40,7 +40,7 @@ contract TimedCrowdsale is Crowdsale { ...@@ -40,7 +40,7 @@ contract TimedCrowdsale is Crowdsale {
* @return Whether crowdsale period has elapsed * @return Whether crowdsale period has elapsed
*/ */
function hasClosed() public view returns (bool) { function hasClosed() public view returns (bool) {
return now > closingTime; return block.timestamp > closingTime;
} }
/** /**
......
...@@ -33,7 +33,16 @@ contract SampleCrowdsaleToken is MintableToken { ...@@ -33,7 +33,16 @@ contract SampleCrowdsaleToken is MintableToken {
*/ */
contract SampleCrowdsale is CappedCrowdsale, RefundableCrowdsale, MintedCrowdsale { contract SampleCrowdsale is CappedCrowdsale, RefundableCrowdsale, MintedCrowdsale {
function SampleCrowdsale(uint256 _openingTime, uint256 _closingTime, uint256 _rate, address _wallet, uint256 _cap, MintableToken _token, uint256 _goal) public function SampleCrowdsale(
uint256 _openingTime,
uint256 _closingTime,
uint256 _rate,
address _wallet,
uint256 _cap,
MintableToken _token,
uint256 _goal
)
public
Crowdsale(_rate, _wallet, _token) Crowdsale(_rate, _wallet, _token)
CappedCrowdsale(_cap) CappedCrowdsale(_cap)
TimedCrowdsale(_openingTime, _closingTime) TimedCrowdsale(_openingTime, _closingTime)
......
...@@ -2,10 +2,12 @@ pragma solidity ^0.4.18; ...@@ -2,10 +2,12 @@ pragma solidity ^0.4.18;
import "../token/ERC20/BasicToken.sol"; import "../token/ERC20/BasicToken.sol";
contract ERC223ContractInterface { contract ERC223ContractInterface {
function tokenFallback(address _from, uint256 _value, bytes _data) external; function tokenFallback(address _from, uint256 _value, bytes _data) external;
} }
contract ERC223TokenMock is BasicToken { contract ERC223TokenMock is BasicToken {
function ERC223TokenMock(address initialAccount, uint256 initialBalance) public { function ERC223TokenMock(address initialAccount, uint256 initialBalance) public {
...@@ -18,11 +20,11 @@ contract ERC223TokenMock is BasicToken { ...@@ -18,11 +20,11 @@ contract ERC223TokenMock is BasicToken {
returns (bool success) returns (bool success)
{ {
transfer(_to, _value); transfer(_to, _value);
bool is_contract = false; bool isContract = false;
assembly { assembly {
is_contract := not(iszero(extcodesize(_to))) isContract := not(iszero(extcodesize(_to)))
} }
if (is_contract) { if (isContract) {
ERC223ContractInterface receiver = ERC223ContractInterface(_to); ERC223ContractInterface receiver = ERC223ContractInterface(_to);
receiver.tokenFallback(msg.sender, _value, _data); receiver.tokenFallback(msg.sender, _value, _data);
} }
......
...@@ -2,6 +2,7 @@ pragma solidity ^0.4.18; ...@@ -2,6 +2,7 @@ pragma solidity ^0.4.18;
import "../token/ERC721/ERC721BasicToken.sol"; import "../token/ERC721/ERC721BasicToken.sol";
/** /**
* @title ERC721BasicTokenMock * @title ERC721BasicTokenMock
* This mock just provides a public mint and burn functions for testing purposes * This mock just provides a public mint and burn functions for testing purposes
......
...@@ -2,6 +2,7 @@ pragma solidity ^0.4.18; ...@@ -2,6 +2,7 @@ pragma solidity ^0.4.18;
import "../token/ERC721/ERC721Receiver.sol"; import "../token/ERC721/ERC721Receiver.sol";
contract ERC721ReceiverMock is ERC721Receiver { contract ERC721ReceiverMock is ERC721Receiver {
bytes4 retval; bytes4 retval;
bool reverts; bool reverts;
......
...@@ -2,6 +2,7 @@ pragma solidity ^0.4.18; ...@@ -2,6 +2,7 @@ pragma solidity ^0.4.18;
import "../token/ERC721/ERC721Token.sol"; import "../token/ERC721/ERC721Token.sol";
/** /**
* @title ERC721TokenMock * @title ERC721TokenMock
* This mock just provides a public mint and burn functions for testing purposes, * This mock just provides a public mint and burn functions for testing purposes,
......
pragma solidity ^0.4.11; pragma solidity ^0.4.11;
contract MessageHelper { contract MessageHelper {
event Show(bytes32 b32, uint256 number, string text); event Show(bytes32 b32, uint256 number, string text);
......
...@@ -3,6 +3,7 @@ pragma solidity ^0.4.18; ...@@ -3,6 +3,7 @@ pragma solidity ^0.4.18;
import "../token/ERC20/MintableToken.sol"; import "../token/ERC20/MintableToken.sol";
import "../crowdsale/distribution/RefundableCrowdsale.sol"; import "../crowdsale/distribution/RefundableCrowdsale.sol";
contract RefundableCrowdsaleImpl is RefundableCrowdsale { contract RefundableCrowdsaleImpl is RefundableCrowdsale {
function RefundableCrowdsaleImpl ( function RefundableCrowdsaleImpl (
......
...@@ -2,6 +2,7 @@ pragma solidity ^0.4.18; ...@@ -2,6 +2,7 @@ pragma solidity ^0.4.18;
import "../token/ERC20/StandardToken.sol"; import "../token/ERC20/StandardToken.sol";
// mock class using StandardToken // mock class using StandardToken
contract StandardTokenMock is StandardToken { contract StandardTokenMock is StandardToken {
......
...@@ -3,6 +3,7 @@ pragma solidity ^0.4.18; ...@@ -3,6 +3,7 @@ pragma solidity ^0.4.18;
import "../token/ERC20/ERC20.sol"; import "../token/ERC20/ERC20.sol";
import "../crowdsale/validation/TimedCrowdsale.sol"; import "../crowdsale/validation/TimedCrowdsale.sol";
contract TimedCrowdsaleImpl is TimedCrowdsale { contract TimedCrowdsaleImpl is TimedCrowdsale {
function TimedCrowdsaleImpl ( function TimedCrowdsaleImpl (
......
...@@ -15,7 +15,14 @@ library SafeERC20 { ...@@ -15,7 +15,14 @@ library SafeERC20 {
assert(token.transfer(to, value)); assert(token.transfer(to, value));
} }
function safeTransferFrom(ERC20 token, address from, address to, uint256 value) internal { function safeTransferFrom(
ERC20 token,
address from,
address to,
uint256 value
)
internal
{
assert(token.transferFrom(from, to, value)); assert(token.transferFrom(from, to, value));
} }
......
...@@ -21,7 +21,7 @@ contract TokenTimelock { ...@@ -21,7 +21,7 @@ contract TokenTimelock {
uint256 public releaseTime; uint256 public releaseTime;
function TokenTimelock(ERC20Basic _token, address _beneficiary, uint256 _releaseTime) public { function TokenTimelock(ERC20Basic _token, address _beneficiary, uint256 _releaseTime) public {
require(_releaseTime > now); require(_releaseTime > block.timestamp);
token = _token; token = _token;
beneficiary = _beneficiary; beneficiary = _beneficiary;
releaseTime = _releaseTime; releaseTime = _releaseTime;
...@@ -31,7 +31,7 @@ contract TokenTimelock { ...@@ -31,7 +31,7 @@ contract TokenTimelock {
* @notice Transfers tokens held by timelock to beneficiary. * @notice Transfers tokens held by timelock to beneficiary.
*/ */
function release() public { function release() public {
require(now >= releaseTime); require(block.timestamp >= releaseTime);
uint256 amount = token.balanceOf(this); uint256 amount = token.balanceOf(this);
require(amount > 0); require(amount > 0);
......
...@@ -40,7 +40,15 @@ contract TokenVesting is Ownable { ...@@ -40,7 +40,15 @@ contract TokenVesting is Ownable {
* @param _duration duration in seconds of the period in which the tokens will vest * @param _duration duration in seconds of the period in which the tokens will vest
* @param _revocable whether the vesting is revocable or not * @param _revocable whether the vesting is revocable or not
*/ */
function TokenVesting(address _beneficiary, uint256 _start, uint256 _cliff, uint256 _duration, bool _revocable) public { function TokenVesting(
address _beneficiary,
uint256 _start,
uint256 _cliff,
uint256 _duration,
bool _revocable
)
public
{
require(_beneficiary != address(0)); require(_beneficiary != address(0));
require(_cliff <= _duration); require(_cliff <= _duration);
...@@ -104,12 +112,12 @@ contract TokenVesting is Ownable { ...@@ -104,12 +112,12 @@ contract TokenVesting is Ownable {
uint256 currentBalance = token.balanceOf(this); uint256 currentBalance = token.balanceOf(this);
uint256 totalBalance = currentBalance.add(released[token]); uint256 totalBalance = currentBalance.add(released[token]);
if (now < cliff) { if (block.timestamp < cliff) {
return 0; return 0;
} else if (now >= start.add(duration) || revoked[token]) { } else if (block.timestamp >= start.add(duration) || revoked[token]) {
return totalBalance; return totalBalance;
} else { } else {
return totalBalance.mul(now.sub(start)).div(duration); return totalBalance.mul(block.timestamp.sub(start)).div(duration);
} }
} }
} }
...@@ -2,6 +2,7 @@ pragma solidity ^0.4.18; ...@@ -2,6 +2,7 @@ pragma solidity ^0.4.18;
import "./ERC721.sol"; import "./ERC721.sol";
/** /**
* @title ERC-721 methods shipped in OpenZeppelin v1.7.0, removed in the latest version of the standard * @title ERC-721 methods shipped in OpenZeppelin v1.7.0, removed in the latest version of the standard
* @dev Only use this interface for compatibility with previously deployed contracts * @dev Only use this interface for compatibility with previously deployed contracts
...@@ -12,4 +13,3 @@ contract DeprecatedERC721 is ERC721 { ...@@ -12,4 +13,3 @@ contract DeprecatedERC721 is ERC721 {
function transfer(address _to, uint256 _tokenId) public; function transfer(address _to, uint256 _tokenId) public;
function tokensOf(address _owner) public view returns (uint256[]); function tokensOf(address _owner) public view returns (uint256[]);
} }
...@@ -2,6 +2,7 @@ pragma solidity ^0.4.18; ...@@ -2,6 +2,7 @@ pragma solidity ^0.4.18;
import "./ERC721Basic.sol"; import "./ERC721Basic.sol";
/** /**
* @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
* @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
...@@ -12,6 +13,7 @@ contract ERC721Enumerable is ERC721Basic { ...@@ -12,6 +13,7 @@ contract ERC721Enumerable is ERC721Basic {
function tokenByIndex(uint256 _index) public view returns (uint256); function tokenByIndex(uint256 _index) public view returns (uint256);
} }
/** /**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
...@@ -22,6 +24,7 @@ contract ERC721Metadata is ERC721Basic { ...@@ -22,6 +24,7 @@ contract ERC721Metadata is ERC721Basic {
function tokenURI(uint256 _tokenId) public view returns (string); function tokenURI(uint256 _tokenId) public view returns (string);
} }
/** /**
* @title ERC-721 Non-Fungible Token Standard, full implementation interface * @title ERC-721 Non-Fungible Token Standard, full implementation interface
* @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
......
pragma solidity ^0.4.18; pragma solidity ^0.4.18;
/** /**
* @title ERC721 Non-Fungible Token Standard basic interface * @title ERC721 Non-Fungible Token Standard basic interface
* @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
...@@ -21,5 +22,11 @@ contract ERC721Basic { ...@@ -21,5 +22,11 @@ contract ERC721Basic {
function transferFrom(address _from, address _to, uint256 _tokenId) public; function transferFrom(address _from, address _to, uint256 _tokenId) public;
function safeTransferFrom(address _from, address _to, uint256 _tokenId) public; function safeTransferFrom(address _from, address _to, uint256 _tokenId) public;
function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes _data) public; function safeTransferFrom(
address _from,
address _to,
uint256 _tokenId,
bytes _data
)
public;
} }
...@@ -5,6 +5,7 @@ import "./ERC721Receiver.sol"; ...@@ -5,6 +5,7 @@ import "./ERC721Receiver.sol";
import "../../math/SafeMath.sol"; import "../../math/SafeMath.sol";
import "../../AddressUtils.sol"; import "../../AddressUtils.sol";
/** /**
* @title ERC721 Non-Fungible Token Standard basic implementation * @title ERC721 Non-Fungible Token Standard basic implementation
* @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
...@@ -106,7 +107,6 @@ contract ERC721BasicToken is ERC721Basic { ...@@ -106,7 +107,6 @@ contract ERC721BasicToken is ERC721Basic {
return tokenApprovals[_tokenId]; return tokenApprovals[_tokenId];
} }
/** /**
* @dev Sets or unsets the approval of a given operator * @dev Sets or unsets the approval of a given operator
* @dev An operator is allowed to transfer all tokens of the sender on their behalf * @dev An operator is allowed to transfer all tokens of the sender on their behalf
...@@ -159,7 +159,14 @@ contract ERC721BasicToken is ERC721Basic { ...@@ -159,7 +159,14 @@ contract ERC721BasicToken is ERC721Basic {
* @param _to address to receive the ownership of the given token ID * @param _to address to receive the ownership of the given token ID
* @param _tokenId uint256 ID of the token to be transferred * @param _tokenId uint256 ID of the token to be transferred
*/ */
function safeTransferFrom(address _from, address _to, uint256 _tokenId) public canTransfer(_tokenId) { function safeTransferFrom(
address _from,
address _to,
uint256 _tokenId
)
public
canTransfer(_tokenId)
{
safeTransferFrom(_from, _to, _tokenId, ""); safeTransferFrom(_from, _to, _tokenId, "");
} }
...@@ -175,7 +182,15 @@ contract ERC721BasicToken is ERC721Basic { ...@@ -175,7 +182,15 @@ contract ERC721BasicToken is ERC721Basic {
* @param _tokenId uint256 ID of the token to be transferred * @param _tokenId uint256 ID of the token to be transferred
* @param _data bytes data to send along with a safe transfer check * @param _data bytes data to send along with a safe transfer check
*/ */
function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes _data) public canTransfer(_tokenId) { function safeTransferFrom(
address _from,
address _to,
uint256 _tokenId,
bytes _data
)
public
canTransfer(_tokenId)
{
transferFrom(_from, _to, _tokenId); transferFrom(_from, _to, _tokenId);
require(checkAndCallSafeTransfer(_from, _to, _tokenId, _data)); require(checkAndCallSafeTransfer(_from, _to, _tokenId, _data));
} }
...@@ -260,7 +275,15 @@ contract ERC721BasicToken is ERC721Basic { ...@@ -260,7 +275,15 @@ contract ERC721BasicToken is ERC721Basic {
* @param _data bytes optional data to send along with the call * @param _data bytes optional data to send along with the call
* @return whether the call correctly returned the expected magic value * @return whether the call correctly returned the expected magic value
*/ */
function checkAndCallSafeTransfer(address _from, address _to, uint256 _tokenId, bytes _data) internal returns (bool) { function checkAndCallSafeTransfer(
address _from,
address _to,
uint256 _tokenId,
bytes _data
)
internal
returns (bool)
{
if (!_to.isContract()) { if (!_to.isContract()) {
return true; return true;
} }
......
...@@ -2,6 +2,7 @@ pragma solidity ^0.4.18; ...@@ -2,6 +2,7 @@ pragma solidity ^0.4.18;
import "./ERC721Receiver.sol"; import "./ERC721Receiver.sol";
contract ERC721Holder is ERC721Receiver { contract ERC721Holder is ERC721Receiver {
function onERC721Received(address, uint256, bytes) public returns(bytes4) { function onERC721Received(address, uint256, bytes) public returns(bytes4) {
return ERC721_RECEIVED; return ERC721_RECEIVED;
......
pragma solidity ^0.4.18; pragma solidity ^0.4.18;
/** /**
* @title ERC721 token receiver interface * @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers * @dev Interface for any contract that wants to support safeTransfers
......
...@@ -68,17 +68,6 @@ contract ERC721Token is ERC721, ERC721BasicToken { ...@@ -68,17 +68,6 @@ contract ERC721Token is ERC721, ERC721BasicToken {
} }
/** /**
* @dev Internal function to set the token URI for a given token
* @dev Reverts if the token ID does not exist
* @param _tokenId uint256 ID of the token to set its URI
* @param _uri string URI to assign
*/
function _setTokenURI(uint256 _tokenId, string _uri) internal {
require(exists(_tokenId));
tokenURIs[_tokenId] = _uri;
}
/**
* @dev Gets the token ID at a given index of the tokens list of the requested owner * @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 _owner address owning the tokens list to be accessed
* @param _index uint256 representing the index to be accessed of the requested tokens list * @param _index uint256 representing the index to be accessed of the requested tokens list
...@@ -109,6 +98,17 @@ contract ERC721Token is ERC721, ERC721BasicToken { ...@@ -109,6 +98,17 @@ contract ERC721Token is ERC721, ERC721BasicToken {
} }
/** /**
* @dev Internal function to set the token URI for a given token
* @dev Reverts if the token ID does not exist
* @param _tokenId uint256 ID of the token to set its URI
* @param _uri string URI to assign
*/
function _setTokenURI(uint256 _tokenId, string _uri) internal {
require(exists(_tokenId));
tokenURIs[_tokenId] = _uri;
}
/**
* @dev Internal function to add a token ID to the list of a given address * @dev Internal function to add a token ID to the list of a given address
* @param _to address representing the new owner of the given token ID * @param _to address representing the new owner of the given token ID
* @param _tokenId uint256 ID of the token to be added to the tokens list of the given address * @param _tokenId uint256 ID of the token to be added to the tokens list of the given address
......
...@@ -15,6 +15,13 @@ contract ERC827 is ERC20 { ...@@ -15,6 +15,13 @@ contract ERC827 is ERC20 {
function approve( address _spender, uint256 _value, bytes _data ) public returns (bool); function approve( address _spender, uint256 _value, bytes _data ) public returns (bool);
function transfer( address _to, uint256 _value, bytes _data ) public returns (bool); function transfer( address _to, uint256 _value, bytes _data ) public returns (bool);
function transferFrom( address _from, address _to, uint256 _value, bytes _data ) public returns (bool); function transferFrom(
address _from,
address _to,
uint256 _value,
bytes _data
)
public
returns (bool);
} }
...@@ -3,6 +3,7 @@ pragma solidity ^0.4.13; ...@@ -3,6 +3,7 @@ pragma solidity ^0.4.13;
import "./ERC827.sol"; import "./ERC827.sol";
import "../ERC20/StandardToken.sol"; import "../ERC20/StandardToken.sol";
/** /**
@title ERC827, an extension of ERC20 token standard @title ERC827, an extension of ERC20 token standard
...@@ -70,7 +71,14 @@ contract ERC827Token is ERC827, StandardToken { ...@@ -70,7 +71,14 @@ contract ERC827Token is ERC827, StandardToken {
@return true if the call function was executed successfully @return true if the call function was executed successfully
*/ */
function transferFrom(address _from, address _to, uint256 _value, bytes _data) public returns (bool) { function transferFrom(
address _from,
address _to,
uint256 _value,
bytes _data
)
public returns (bool)
{
require(_to != address(this)); require(_to != address(this));
super.transferFrom(_from, _to, _value); super.transferFrom(_from, _to, _value);
......
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