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
82ce197e
Commit
82ce197e
authored
Mar 28, 2018
by
Leo Arias
Committed by
Francisco Giordano
Mar 28, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: fix most of the static warnings (#844)
parent
42787e2a
Hide whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
173 additions
and
71 deletions
+173
-71
AddressUtils.sol
contracts/AddressUtils.sol
+11
-4
DayLimit.sol
contracts/DayLimit.sol
+1
-1
ECRecovery.sol
contracts/ECRecovery.sol
+7
-0
MerkleProof.sol
contracts/MerkleProof.sol
+1
-0
Crowdsale.sol
contracts/crowdsale/Crowdsale.sol
+2
-2
FinalizableCrowdsale.sol
contracts/crowdsale/distribution/FinalizableCrowdsale.sol
+2
-0
PostDeliveryCrowdsale.sol
contracts/crowdsale/distribution/PostDeliveryCrowdsale.sol
+11
-9
IncreasingPriceCrowdsale.sol
contracts/crowdsale/price/IncreasingPriceCrowdsale.sol
+5
-4
TimedCrowdsale.sol
contracts/crowdsale/validation/TimedCrowdsale.sol
+5
-5
SampleCrowdsale.sol
contracts/examples/SampleCrowdsale.sol
+10
-1
ERC223TokenMock.sol
contracts/mocks/ERC223TokenMock.sol
+5
-3
ERC721BasicTokenMock.sol
contracts/mocks/ERC721BasicTokenMock.sol
+1
-0
ERC721ReceiverMock.sol
contracts/mocks/ERC721ReceiverMock.sol
+2
-1
ERC721TokenMock.sol
contracts/mocks/ERC721TokenMock.sol
+2
-2
MessageHelper.sol
contracts/mocks/MessageHelper.sol
+1
-0
RefundableCrowdsaleImpl.sol
contracts/mocks/RefundableCrowdsaleImpl.sol
+2
-1
StandardTokenMock.sol
contracts/mocks/StandardTokenMock.sol
+1
-0
TimedCrowdsaleImpl.sol
contracts/mocks/TimedCrowdsaleImpl.sol
+2
-1
SafeERC20.sol
contracts/token/ERC20/SafeERC20.sol
+8
-1
TokenTimelock.sol
contracts/token/ERC20/TokenTimelock.sol
+2
-2
TokenVesting.sol
contracts/token/ERC20/TokenVesting.sol
+12
-4
DeprecatedERC721.sol
contracts/token/ERC721/DeprecatedERC721.sol
+1
-1
ERC721.sol
contracts/token/ERC721/ERC721.sol
+3
-0
ERC721Basic.sol
contracts/token/ERC721/ERC721Basic.sol
+12
-5
ERC721BasicToken.sol
contracts/token/ERC721/ERC721BasicToken.sol
+30
-7
ERC721Holder.sol
contracts/token/ERC721/ERC721Holder.sol
+1
-0
ERC721Receiver.sol
contracts/token/ERC721/ERC721Receiver.sol
+3
-2
ERC721Token.sol
contracts/token/ERC721/ERC721Token.sol
+13
-13
ERC827.sol
contracts/token/ERC827/ERC827.sol
+8
-1
ERC827Token.sol
contracts/token/ERC827/ERC827Token.sol
+9
-1
No files found.
contracts/AddressUtils.sol
View file @
82ce197e
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 the
re 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 the
re 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;
}
}
...
...
contracts/DayLimit.sol
View file @
82ce197e
...
@@ -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;
}
}
/**
/**
...
...
contracts/ECRecovery.sol
View file @
82ce197e
...
@@ -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))
...
...
contracts/MerkleProof.sol
View file @
82ce197e
...
@@ -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))
...
...
contracts/crowdsale/Crowdsale.sol
View file @
82ce197e
...
@@ -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,
...
@@ -11,11 +12,10 @@ import "../math/SafeMath.sol";
...
@@ -11,11 +12,10 @@ import "../math/SafeMath.sol";
* functionality and/or custom behavior.
* functionality and/or custom behavior.
* The external interface represents the basic interface for purchasing tokens, and conform
* The external interface represents the basic interface for purchasing tokens, and conform
* the base architecture for crowdsales. They are *not* intended to be modified / overriden.
* the base architecture for crowdsales. They are *not* intended to be modified / overriden.
* The internal interface conforms the extensible and modifiable surface of crowdsales. Override
* The internal interface conforms the extensible and modifiable surface of crowdsales. Override
* 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;
...
...
contracts/crowdsale/distribution/FinalizableCrowdsale.sol
View file @
82ce197e
...
@@ -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 {
}
}
}
}
contracts/crowdsale/distribution/PostDeliveryCrowdsale.sol
View file @
82ce197e
...
@@ -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);
}
}
}
contracts/crowdsale/price/IncreasingPriceCrowdsale.sol
View file @
82ce197e
...
@@ -3,9 +3,10 @@ pragma solidity ^0.4.18;
...
@@ -3,9 +3,10 @@ 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.
* Note that what should be provided to the constructor is the initial and final _rates_, that is,
* Note that what should be provided to the constructor is the initial and final _rates_, that is,
* the amount of tokens per wei contributed. Thus, the initial rate must be greater than the final rate.
* the amount of tokens per wei contributed. Thus, the initial rate must be greater than the final rate.
*/
*/
...
@@ -28,12 +29,12 @@ contract IncreasingPriceCrowdsale is TimedCrowdsale {
...
@@ -28,12 +29,12 @@ contract IncreasingPriceCrowdsale is TimedCrowdsale {
}
}
/**
/**
* @dev Returns the rate of tokens per wei at the present time.
* @dev Returns the rate of tokens per wei at the present time.
* Note that, as price _increases_ with time, the rate _decreases_.
* Note that, as price _increases_ with time, the rate _decreases_.
* @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));
...
...
contracts/crowdsale/validation/TimedCrowdsale.sol
View file @
82ce197e
...
@@ -15,10 +15,10 @@ contract TimedCrowdsale is Crowdsale {
...
@@ -15,10 +15,10 @@ contract TimedCrowdsale is Crowdsale {
uint256 public closingTime;
uint256 public closingTime;
/**
/**
* @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,9 +40,9 @@ contract TimedCrowdsale is Crowdsale {
...
@@ -40,9 +40,9 @@ 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;
}
}
/**
/**
* @dev Extend parent behavior requiring to be within contributing period
* @dev Extend parent behavior requiring to be within contributing period
* @param _beneficiary Token purchaser
* @param _beneficiary Token purchaser
...
...
contracts/examples/SampleCrowdsale.sol
View file @
82ce197e
...
@@ -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)
...
...
contracts/mocks/ERC223TokenMock.sol
View file @
82ce197e
...
@@ -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
_c
ontract = false;
bool is
C
ontract = false;
assembly {
assembly {
is
_c
ontract := not(iszero(extcodesize(_to)))
is
C
ontract := not(iszero(extcodesize(_to)))
}
}
if (is
_c
ontract) {
if (is
C
ontract) {
ERC223ContractInterface receiver = ERC223ContractInterface(_to);
ERC223ContractInterface receiver = ERC223ContractInterface(_to);
receiver.tokenFallback(msg.sender, _value, _data);
receiver.tokenFallback(msg.sender, _value, _data);
}
}
...
...
contracts/mocks/ERC721BasicTokenMock.sol
View file @
82ce197e
...
@@ -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
...
...
contracts/mocks/ERC721ReceiverMock.sol
View file @
82ce197e
...
@@ -2,10 +2,11 @@ pragma solidity ^0.4.18;
...
@@ -2,10 +2,11 @@ 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;
event Received(address _address, uint256 _tokenId, bytes _data, uint256 _gas);
event Received(address _address, uint256 _tokenId, bytes _data, uint256 _gas);
function ERC721ReceiverMock(bytes4 _retval, bool _reverts) public {
function ERC721ReceiverMock(bytes4 _retval, bool _reverts) public {
...
...
contracts/mocks/ERC721TokenMock.sol
View file @
82ce197e
...
@@ -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,
...
@@ -23,4 +24,4 @@ contract ERC721TokenMock is ERC721Token {
...
@@ -23,4 +24,4 @@ contract ERC721TokenMock is ERC721Token {
function setTokenURI(uint256 _tokenId, string _uri) public {
function setTokenURI(uint256 _tokenId, string _uri) public {
super._setTokenURI(_tokenId, _uri);
super._setTokenURI(_tokenId, _uri);
}
}
}
}
\ No newline at end of file
contracts/mocks/MessageHelper.sol
View file @
82ce197e
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);
...
...
contracts/mocks/RefundableCrowdsaleImpl.sol
View file @
82ce197e
...
@@ -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 (
...
@@ -12,7 +13,7 @@ contract RefundableCrowdsaleImpl is RefundableCrowdsale {
...
@@ -12,7 +13,7 @@ contract RefundableCrowdsaleImpl is RefundableCrowdsale {
address _wallet,
address _wallet,
MintableToken _token,
MintableToken _token,
uint256 _goal
uint256 _goal
)
)
public
public
Crowdsale(_rate, _wallet, _token)
Crowdsale(_rate, _wallet, _token)
TimedCrowdsale(_openingTime, _closingTime)
TimedCrowdsale(_openingTime, _closingTime)
...
...
contracts/mocks/StandardTokenMock.sol
View file @
82ce197e
...
@@ -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 {
...
...
contracts/mocks/TimedCrowdsaleImpl.sol
View file @
82ce197e
...
@@ -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 (
...
@@ -11,7 +12,7 @@ contract TimedCrowdsaleImpl is TimedCrowdsale {
...
@@ -11,7 +12,7 @@ contract TimedCrowdsaleImpl is TimedCrowdsale {
uint256 _rate,
uint256 _rate,
address _wallet,
address _wallet,
ERC20 _token
ERC20 _token
)
)
public
public
Crowdsale(_rate, _wallet, _token)
Crowdsale(_rate, _wallet, _token)
TimedCrowdsale(_openingTime, _closingTime)
TimedCrowdsale(_openingTime, _closingTime)
...
...
contracts/token/ERC20/SafeERC20.sol
View file @
82ce197e
...
@@ -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));
}
}
...
...
contracts/token/ERC20/TokenTimelock.sol
View file @
82ce197e
...
@@ -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);
...
...
contracts/token/ERC20/TokenVesting.sol
View file @
82ce197e
...
@@ -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);
}
}
}
}
}
}
contracts/token/ERC721/DeprecatedERC721.sol
View file @
82ce197e
...
@@ -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[]);
}
}
contracts/token/ERC721/ERC721.sol
View file @
82ce197e
...
@@ -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
...
...
contracts/token/ERC721/ERC721Basic.sol
View file @
82ce197e
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
...
@@ -7,19 +8,25 @@ pragma solidity ^0.4.18;
...
@@ -7,19 +8,25 @@ pragma solidity ^0.4.18;
contract ERC721Basic {
contract ERC721Basic {
event Transfer(address indexed _from, address indexed _to, uint256 _tokenId);
event Transfer(address indexed _from, address indexed _to, uint256 _tokenId);
event Approval(address indexed _owner, address indexed _approved, uint256 _tokenId);
event Approval(address indexed _owner, address indexed _approved, uint256 _tokenId);
event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);
event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);
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 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) public view returns (address _operator);
function getApproved(uint256 _tokenId) public view returns (address _operator);
function setApprovalForAll(address _operator, bool _approved) public;
function setApprovalForAll(address _operator, bool _approved) public;
function isApprovedForAll(address _owner, address _operator) public view returns (bool);
function isApprovedForAll(address _owner, address _operator) public view returns (bool);
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;
}
}
contracts/token/ERC721/ERC721BasicToken.sol
View file @
82ce197e
...
@@ -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
...
@@ -12,10 +13,10 @@ import "../../AddressUtils.sol";
...
@@ -12,10 +13,10 @@ import "../../AddressUtils.sol";
contract ERC721BasicToken is ERC721Basic {
contract ERC721BasicToken is ERC721Basic {
using SafeMath for uint256;
using SafeMath for uint256;
using AddressUtils for address;
using AddressUtils for address;
// Equals to `bytes4(keccak256("onERC721Received(address,uint256,bytes)"))`
// Equals to `bytes4(keccak256("onERC721Received(address,uint256,bytes)"))`
// which can be also obtained as `ERC721Receiver(0).onERC721Received.selector`
// which can be also obtained as `ERC721Receiver(0).onERC721Received.selector`
bytes4 constant ERC721_RECEIVED = 0xf0b9e5ba;
bytes4 constant ERC721_RECEIVED = 0xf0b9e5ba;
// Mapping from token ID to owner
// Mapping from token ID to owner
mapping (uint256 => address) internal tokenOwner;
mapping (uint256 => address) internal tokenOwner;
...
@@ -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
...
@@ -144,7 +144,7 @@ contract ERC721BasicToken is ERC721Basic {
...
@@ -144,7 +144,7 @@ contract ERC721BasicToken is ERC721Basic {
clearApproval(_from, _tokenId);
clearApproval(_from, _tokenId);
removeTokenFrom(_from, _tokenId);
removeTokenFrom(_from, _tokenId);
addTokenTo(_to, _tokenId);
addTokenTo(_to, _tokenId);
Transfer(_from, _to, _tokenId);
Transfer(_from, _to, _tokenId);
}
}
...
@@ -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;
}
}
...
...
contracts/token/ERC721/ERC721Holder.sol
View file @
82ce197e
...
@@ -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;
...
...
contracts/token/ERC721/ERC721Receiver.sol
View file @
82ce197e
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
...
@@ -11,7 +12,7 @@ contract ERC721Receiver {
...
@@ -11,7 +12,7 @@ contract ERC721Receiver {
* Equals to `bytes4(keccak256("onERC721Received(address,uint256,bytes)"))`,
* Equals to `bytes4(keccak256("onERC721Received(address,uint256,bytes)"))`,
* which can be also obtained as `ERC721Receiver(0).onERC721Received.selector`
* which can be also obtained as `ERC721Receiver(0).onERC721Received.selector`
*/
*/
bytes4 constant ERC721_RECEIVED = 0xf0b9e5ba;
bytes4 constant ERC721_RECEIVED = 0xf0b9e5ba;
/**
/**
* @notice Handle the receipt of an NFT
* @notice Handle the receipt of an NFT
...
@@ -20,7 +21,7 @@ contract ERC721Receiver {
...
@@ -20,7 +21,7 @@ contract ERC721Receiver {
* transfer. This function MUST use 50,000 gas or less. Return of other
* transfer. This function MUST use 50,000 gas or less. Return of other
* than the magic value MUST result in the transaction being reverted.
* than the magic value MUST result in the transaction being reverted.
* Note: the contract address is always the message sender.
* Note: the contract address is always the message sender.
* @param _from The sending address
* @param _from The sending address
* @param _tokenId The NFT identifier which is being transfered
* @param _tokenId The NFT identifier which is being transfered
* @param _data Additional data with no specified format
* @param _data Additional data with no specified format
* @return `bytes4(keccak256("onERC721Received(address,uint256,bytes)"))`
* @return `bytes4(keccak256("onERC721Received(address,uint256,bytes)"))`
...
...
contracts/token/ERC721/ERC721Token.sol
View file @
82ce197e
...
@@ -30,7 +30,7 @@ contract ERC721Token is ERC721, ERC721BasicToken {
...
@@ -30,7 +30,7 @@ contract ERC721Token is ERC721, ERC721BasicToken {
// Mapping from token id to position in the allTokens array
// Mapping from token id to position in the allTokens array
mapping(uint256 => uint256) internal allTokensIndex;
mapping(uint256 => uint256) internal allTokensIndex;
// Optional mapping for token URIs
// Optional mapping for token URIs
mapping(uint256 => string) internal tokenURIs;
mapping(uint256 => string) internal tokenURIs;
/**
/**
...
@@ -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
...
@@ -151,7 +151,7 @@ contract ERC721Token is ERC721, ERC721BasicToken {
...
@@ -151,7 +151,7 @@ contract ERC721Token is ERC721, ERC721BasicToken {
*/
*/
function _mint(address _to, uint256 _tokenId) internal {
function _mint(address _to, uint256 _tokenId) internal {
super._mint(_to, _tokenId);
super._mint(_to, _tokenId);
allTokensIndex[_tokenId] = allTokens.length;
allTokensIndex[_tokenId] = allTokens.length;
allTokens.push(_tokenId);
allTokens.push(_tokenId);
}
}
...
...
contracts/token/ERC827/ERC827.sol
View file @
82ce197e
...
@@ -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);
}
}
contracts/token/ERC827/ERC827Token.sol
View file @
82ce197e
...
@@ -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);
...
...
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