Commit bce2d68e by Francisco Giordano

convert 2 spaces to 4 spaces

parent b047d284
...@@ -6,36 +6,36 @@ pragma solidity ^0.4.24; ...@@ -6,36 +6,36 @@ pragma solidity ^0.4.24;
* @dev Library for managing addresses assigned to a Role. * @dev Library for managing addresses assigned to a Role.
*/ */
library Roles { library Roles {
struct Role { struct Role {
mapping (address => bool) bearer; mapping (address => bool) bearer;
} }
/** /**
* @dev give an account access to this role * @dev give an account access to this role
*/ */
function add(Role storage role, address account) internal { function add(Role storage role, address account) internal {
require(account != address(0)); require(account != address(0));
role.bearer[account] = true; role.bearer[account] = true;
} }
/** /**
* @dev remove an account's access to this role * @dev remove an account's access to this role
*/ */
function remove(Role storage role, address account) internal { function remove(Role storage role, address account) internal {
require(account != address(0)); require(account != address(0));
role.bearer[account] = false; role.bearer[account] = false;
} }
/** /**
* @dev check if an account has this role * @dev check if an account has this role
* @return bool * @return bool
*/ */
function has(Role storage role, address account) function has(Role storage role, address account)
internal internal
view view
returns (bool) returns (bool)
{ {
require(account != address(0)); require(account != address(0));
return role.bearer[account]; return role.bearer[account];
} }
} }
...@@ -5,45 +5,45 @@ import "../Roles.sol"; ...@@ -5,45 +5,45 @@ import "../Roles.sol";
contract CapperRole is Initializable { contract CapperRole is Initializable {
using Roles for Roles.Role; using Roles for Roles.Role;
event CapperAdded(address indexed account); event CapperAdded(address indexed account);
event CapperRemoved(address indexed account); event CapperRemoved(address indexed account);
Roles.Role private cappers; Roles.Role private cappers;
function initialize(address sender) public initializer { function initialize(address sender) public initializer {
if (!isCapper(sender)) { if (!isCapper(sender)) {
_addCapper(sender); _addCapper(sender);
}
} }
}
modifier onlyCapper() { modifier onlyCapper() {
require(isCapper(msg.sender)); require(isCapper(msg.sender));
_; _;
} }
function isCapper(address account) public view returns (bool) { function isCapper(address account) public view returns (bool) {
return cappers.has(account); return cappers.has(account);
} }
function addCapper(address account) public onlyCapper { function addCapper(address account) public onlyCapper {
_addCapper(account); _addCapper(account);
} }
function renounceCapper() public { function renounceCapper() public {
_removeCapper(msg.sender); _removeCapper(msg.sender);
} }
function _addCapper(address account) internal { function _addCapper(address account) internal {
cappers.add(account); cappers.add(account);
emit CapperAdded(account); emit CapperAdded(account);
} }
function _removeCapper(address account) internal { function _removeCapper(address account) internal {
cappers.remove(account); cappers.remove(account);
emit CapperRemoved(account); emit CapperRemoved(account);
} }
uint256[50] private ______gap; uint256[50] private ______gap;
} }
...@@ -5,45 +5,45 @@ import "../Roles.sol"; ...@@ -5,45 +5,45 @@ import "../Roles.sol";
contract MinterRole is Initializable { contract MinterRole is Initializable {
using Roles for Roles.Role; using Roles for Roles.Role;
event MinterAdded(address indexed account); event MinterAdded(address indexed account);
event MinterRemoved(address indexed account); event MinterRemoved(address indexed account);
Roles.Role private minters; Roles.Role private minters;
function initialize(address sender) public initializer { function initialize(address sender) public initializer {
if (!isMinter(sender)) { if (!isMinter(sender)) {
_addMinter(sender); _addMinter(sender);
}
} }
}
modifier onlyMinter() { modifier onlyMinter() {
require(isMinter(msg.sender)); require(isMinter(msg.sender));
_; _;
} }
function isMinter(address account) public view returns (bool) { function isMinter(address account) public view returns (bool) {
return minters.has(account); return minters.has(account);
} }
function addMinter(address account) public onlyMinter { function addMinter(address account) public onlyMinter {
_addMinter(account); _addMinter(account);
} }
function renounceMinter() public { function renounceMinter() public {
_removeMinter(msg.sender); _removeMinter(msg.sender);
} }
function _addMinter(address account) internal { function _addMinter(address account) internal {
minters.add(account); minters.add(account);
emit MinterAdded(account); emit MinterAdded(account);
} }
function _removeMinter(address account) internal { function _removeMinter(address account) internal {
minters.remove(account); minters.remove(account);
emit MinterRemoved(account); emit MinterRemoved(account);
} }
uint256[50] private ______gap; uint256[50] private ______gap;
} }
...@@ -5,45 +5,45 @@ import "../Roles.sol"; ...@@ -5,45 +5,45 @@ import "../Roles.sol";
contract PauserRole is Initializable { contract PauserRole is Initializable {
using Roles for Roles.Role; using Roles for Roles.Role;
event PauserAdded(address indexed account); event PauserAdded(address indexed account);
event PauserRemoved(address indexed account); event PauserRemoved(address indexed account);
Roles.Role private pausers; Roles.Role private pausers;
function initialize(address sender) public initializer { function initialize(address sender) public initializer {
if (!isPauser(sender)) { if (!isPauser(sender)) {
_addPauser(sender); _addPauser(sender);
}
} }
}
modifier onlyPauser() { modifier onlyPauser() {
require(isPauser(msg.sender)); require(isPauser(msg.sender));
_; _;
} }
function isPauser(address account) public view returns (bool) { function isPauser(address account) public view returns (bool) {
return pausers.has(account); return pausers.has(account);
} }
function addPauser(address account) public onlyPauser { function addPauser(address account) public onlyPauser {
_addPauser(account); _addPauser(account);
} }
function renouncePauser() public { function renouncePauser() public {
_removePauser(msg.sender); _removePauser(msg.sender);
} }
function _addPauser(address account) internal { function _addPauser(address account) internal {
pausers.add(account); pausers.add(account);
emit PauserAdded(account); emit PauserAdded(account);
} }
function _removePauser(address account) internal { function _removePauser(address account) internal {
pausers.remove(account); pausers.remove(account);
emit PauserRemoved(account); emit PauserRemoved(account);
} }
uint256[50] private ______gap; uint256[50] private ______gap;
} }
...@@ -5,45 +5,45 @@ import "../Roles.sol"; ...@@ -5,45 +5,45 @@ import "../Roles.sol";
contract SignerRole is Initializable { contract SignerRole is Initializable {
using Roles for Roles.Role; using Roles for Roles.Role;
event SignerAdded(address indexed account); event SignerAdded(address indexed account);
event SignerRemoved(address indexed account); event SignerRemoved(address indexed account);
Roles.Role private signers; Roles.Role private signers;
function initialize(address sender) public initializer { function initialize(address sender) public initializer {
if (!isSigner(sender)) { if (!isSigner(sender)) {
_addSigner(sender); _addSigner(sender);
}
} }
}
modifier onlySigner() { modifier onlySigner() {
require(isSigner(msg.sender)); require(isSigner(msg.sender));
_; _;
} }
function isSigner(address account) public view returns (bool) { function isSigner(address account) public view returns (bool) {
return signers.has(account); return signers.has(account);
} }
function addSigner(address account) public onlySigner { function addSigner(address account) public onlySigner {
_addSigner(account); _addSigner(account);
} }
function renounceSigner() public { function renounceSigner() public {
_removeSigner(msg.sender); _removeSigner(msg.sender);
} }
function _addSigner(address account) internal { function _addSigner(address account) internal {
signers.add(account); signers.add(account);
emit SignerAdded(account); emit SignerAdded(account);
} }
function _removeSigner(address account) internal { function _removeSigner(address account) internal {
signers.remove(account); signers.remove(account);
emit SignerRemoved(account); emit SignerRemoved(account);
} }
uint256[50] private ______gap; uint256[50] private ______gap;
} }
...@@ -11,41 +11,41 @@ import "../validation/TimedCrowdsale.sol"; ...@@ -11,41 +11,41 @@ import "../validation/TimedCrowdsale.sol";
* can do extra work after finishing. * can do extra work after finishing.
*/ */
contract FinalizableCrowdsale is Initializable, TimedCrowdsale { contract FinalizableCrowdsale is Initializable, TimedCrowdsale {
using SafeMath for uint256; using SafeMath for uint256;
bool private _finalized = false; bool private _finalized = false;
event CrowdsaleFinalized(); event CrowdsaleFinalized();
/** /**
* @return true if the crowdsale is finalized, false otherwise. * @return true if the crowdsale is finalized, false otherwise.
*/ */
function finalized() public view returns (bool) { function finalized() public view returns (bool) {
return _finalized; return _finalized;
} }
/** /**
* @dev Must be called after crowdsale ends, to do some extra finalization * @dev Must be called after crowdsale ends, to do some extra finalization
* work. Calls the contract's finalization function. * work. Calls the contract's finalization function.
*/ */
function finalize() public { function finalize() public {
require(!_finalized); require(!_finalized);
require(hasClosed()); require(hasClosed());
_finalization(); _finalization();
emit CrowdsaleFinalized(); emit CrowdsaleFinalized();
_finalized = true; _finalized = true;
} }
/** /**
* @dev Can be overridden to add finalization logic. The overriding function * @dev Can be overridden to add finalization logic. The overriding function
* should call super._finalization() to ensure the chain of finalization is * should call super._finalization() to ensure the chain of finalization is
* executed entirely. * executed entirely.
*/ */
function _finalization() internal { function _finalization() internal {
} }
uint256[50] private ______gap; uint256[50] private ______gap;
} }
...@@ -11,43 +11,43 @@ import "../../math/SafeMath.sol"; ...@@ -11,43 +11,43 @@ import "../../math/SafeMath.sol";
* @dev Crowdsale that locks tokens from withdrawal until it ends. * @dev Crowdsale that locks tokens from withdrawal until it ends.
*/ */
contract PostDeliveryCrowdsale is Initializable, TimedCrowdsale { contract PostDeliveryCrowdsale is Initializable, TimedCrowdsale {
using SafeMath for uint256; using SafeMath for uint256;
mapping(address => uint256) private _balances; mapping(address => uint256) private _balances;
/** /**
* @dev Withdraw tokens only after crowdsale ends. * @dev Withdraw tokens only after crowdsale ends.
* @param beneficiary Whose tokens will be withdrawn. * @param beneficiary Whose tokens will be withdrawn.
*/ */
function withdrawTokens(address beneficiary) public { function withdrawTokens(address beneficiary) public {
require(hasClosed()); require(hasClosed());
uint256 amount = _balances[beneficiary]; uint256 amount = _balances[beneficiary];
require(amount > 0); require(amount > 0);
_balances[beneficiary] = 0; _balances[beneficiary] = 0;
_deliverTokens(beneficiary, amount); _deliverTokens(beneficiary, amount);
} }
/** /**
* @return the balance of an account. * @return the balance of an account.
*/ */
function balanceOf(address account) public view returns(uint256) { function balanceOf(address account) public view returns(uint256) {
return _balances[account]; return _balances[account];
} }
/** /**
* @dev Overrides parent by storing balances instead of issuing tokens right away. * @dev Overrides parent by storing balances instead of issuing tokens right away.
* @param beneficiary Token purchaser * @param beneficiary Token purchaser
* @param tokenAmount Amount of tokens purchased * @param tokenAmount Amount of tokens purchased
*/ */
function _processPurchase( function _processPurchase(
address beneficiary, address beneficiary,
uint256 tokenAmount uint256 tokenAmount
) )
internal internal
{ {
_balances[beneficiary] = _balances[beneficiary].add(tokenAmount); _balances[beneficiary] = _balances[beneficiary].add(tokenAmount);
} }
uint256[50] private ______gap; uint256[50] private ______gap;
} }
...@@ -13,80 +13,80 @@ import "../../payment/RefundEscrow.sol"; ...@@ -13,80 +13,80 @@ import "../../payment/RefundEscrow.sol";
* the possibility of users getting a refund if goal is not met. * the possibility of users getting a refund if goal is not met.
*/ */
contract RefundableCrowdsale is Initializable, FinalizableCrowdsale { contract RefundableCrowdsale is Initializable, FinalizableCrowdsale {
using SafeMath for uint256; using SafeMath for uint256;
// minimum amount of funds to be raised in weis // minimum amount of funds to be raised in weis
uint256 private _goal; uint256 private _goal;
// refund escrow used to hold funds while crowdsale is running // refund escrow used to hold funds while crowdsale is running
RefundEscrow private _escrow; RefundEscrow private _escrow;
/** /**
* @dev Constructor, creates RefundEscrow. * @dev Constructor, creates RefundEscrow.
* @param goal Funding goal * @param goal Funding goal
*/ */
function initialize(uint256 goal) public initializer { function initialize(uint256 goal) public initializer {
// FinalizableCrowdsale depends on TimedCrowdsale // FinalizableCrowdsale depends on TimedCrowdsale
assert(TimedCrowdsale._hasBeenInitialized()); assert(TimedCrowdsale._hasBeenInitialized());
require(goal > 0); require(goal > 0);
// conditional added to make initializer idempotent in case of diamond inheritance // conditional added to make initializer idempotent in case of diamond inheritance
if (address(_escrow) == address(0)) { if (address(_escrow) == address(0)) {
_escrow = new RefundEscrow(); _escrow = new RefundEscrow();
_escrow.initialize(wallet(), address(this)); _escrow.initialize(wallet(), address(this));
}
_goal = goal;
}
/**
* @return minimum amount of funds to be raised in wei.
*/
function goal() public view returns(uint256) {
return _goal;
}
/**
* @dev Investors can claim refunds here if crowdsale is unsuccessful
* @param beneficiary Whose refund will be claimed.
*/
function claimRefund(address beneficiary) public {
require(finalized());
require(!goalReached());
_escrow.withdraw(beneficiary);
} }
_goal = goal; /**
} * @dev Checks whether funding goal was reached.
* @return Whether funding goal was reached
/** */
* @return minimum amount of funds to be raised in wei. function goalReached() public view returns (bool) {
*/ return weiRaised() >= _goal;
function goal() public view returns(uint256) {
return _goal;
}
/**
* @dev Investors can claim refunds here if crowdsale is unsuccessful
* @param beneficiary Whose refund will be claimed.
*/
function claimRefund(address beneficiary) public {
require(finalized());
require(!goalReached());
_escrow.withdraw(beneficiary);
}
/**
* @dev Checks whether funding goal was reached.
* @return Whether funding goal was reached
*/
function goalReached() public view returns (bool) {
return weiRaised() >= _goal;
}
/**
* @dev escrow finalization task, called when finalize() is called
*/
function _finalization() internal {
if (goalReached()) {
_escrow.close();
_escrow.beneficiaryWithdraw();
} else {
_escrow.enableRefunds();
} }
super._finalization(); /**
} * @dev escrow finalization task, called when finalize() is called
*/
function _finalization() internal {
if (goalReached()) {
_escrow.close();
_escrow.beneficiaryWithdraw();
} else {
_escrow.enableRefunds();
}
super._finalization();
}
/** /**
* @dev Overrides Crowdsale fund forwarding, sending funds to escrow. * @dev Overrides Crowdsale fund forwarding, sending funds to escrow.
*/ */
function _forwardFunds() internal { function _forwardFunds() internal {
_escrow.deposit.value(msg.value)(msg.sender); _escrow.deposit.value(msg.value)(msg.sender);
} }
uint256[50] private ______gap; uint256[50] private ______gap;
} }
...@@ -12,50 +12,50 @@ import "../../math/SafeMath.sol"; ...@@ -12,50 +12,50 @@ import "../../math/SafeMath.sol";
* @dev Extension of Crowdsale where tokens are held by a wallet, which approves an allowance to the crowdsale. * @dev Extension of Crowdsale where tokens are held by a wallet, which approves an allowance to the crowdsale.
*/ */
contract AllowanceCrowdsale is Initializable, Crowdsale { contract AllowanceCrowdsale is Initializable, Crowdsale {
using SafeMath for uint256; using SafeMath for uint256;
using SafeERC20 for IERC20; using SafeERC20 for IERC20;
address private _tokenWallet; address private _tokenWallet;
/** /**
* @dev Constructor, takes token wallet address. * @dev Constructor, takes token wallet address.
* @param tokenWallet Address holding the tokens, which has approved allowance to the crowdsale * @param tokenWallet Address holding the tokens, which has approved allowance to the crowdsale
*/ */
function initialize(address tokenWallet) public initializer { function initialize(address tokenWallet) public initializer {
assert(Crowdsale._hasBeenInitialized()); assert(Crowdsale._hasBeenInitialized());
require(tokenWallet != address(0)); require(tokenWallet != address(0));
_tokenWallet = tokenWallet; _tokenWallet = tokenWallet;
} }
/** /**
* @return the address of the wallet that will hold the tokens. * @return the address of the wallet that will hold the tokens.
*/ */
function tokenWallet() public view returns(address) { function tokenWallet() public view returns(address) {
return _tokenWallet; return _tokenWallet;
} }
/** /**
* @dev Checks the amount of tokens left in the allowance. * @dev Checks the amount of tokens left in the allowance.
* @return Amount of tokens left in the allowance * @return Amount of tokens left in the allowance
*/ */
function remainingTokens() public view returns (uint256) { function remainingTokens() public view returns (uint256) {
return token().allowance(_tokenWallet, this); return token().allowance(_tokenWallet, this);
} }
/** /**
* @dev Overrides parent behavior by transferring tokens from wallet. * @dev Overrides parent behavior by transferring tokens from wallet.
* @param beneficiary Token purchaser * @param beneficiary Token purchaser
* @param tokenAmount Amount of tokens purchased * @param tokenAmount Amount of tokens purchased
*/ */
function _deliverTokens( function _deliverTokens(
address beneficiary, address beneficiary,
uint256 tokenAmount uint256 tokenAmount
) )
internal internal
{ {
token().safeTransferFrom(_tokenWallet, beneficiary, tokenAmount); token().safeTransferFrom(_tokenWallet, beneficiary, tokenAmount);
} }
uint256[50] private ______gap; uint256[50] private ______gap;
} }
...@@ -12,21 +12,21 @@ import "../../token/ERC20/ERC20Mintable.sol"; ...@@ -12,21 +12,21 @@ import "../../token/ERC20/ERC20Mintable.sol";
*/ */
contract MintedCrowdsale is Initializable, Crowdsale { contract MintedCrowdsale is Initializable, Crowdsale {
/** /**
* @dev Overrides delivery by minting tokens upon purchase. * @dev Overrides delivery by minting tokens upon purchase.
* @param beneficiary Token purchaser * @param beneficiary Token purchaser
* @param tokenAmount Number of tokens to be minted * @param tokenAmount Number of tokens to be minted
*/ */
function _deliverTokens( function _deliverTokens(
address beneficiary, address beneficiary,
uint256 tokenAmount uint256 tokenAmount
) )
internal internal
{ {
// Potentially dangerous assumption about the type of the token. // Potentially dangerous assumption about the type of the token.
require( require(
ERC20Mintable(address(token())).mint(beneficiary, tokenAmount)); ERC20Mintable(address(token())).mint(beneficiary, tokenAmount));
} }
uint256[50] private ______gap; uint256[50] private ______gap;
} }
...@@ -12,64 +12,64 @@ import "../../math/SafeMath.sol"; ...@@ -12,64 +12,64 @@ import "../../math/SafeMath.sol";
* 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.
*/ */
contract IncreasingPriceCrowdsale is Initializable, TimedCrowdsale { contract IncreasingPriceCrowdsale is Initializable, TimedCrowdsale {
using SafeMath for uint256; using SafeMath for uint256;
uint256 private _initialRate; uint256 private _initialRate;
uint256 private _finalRate; uint256 private _finalRate;
/** /**
* @dev Constructor, takes initial and final rates of tokens received per wei contributed. * @dev Constructor, takes initial and final rates of tokens received per wei contributed.
* @param initialRate Number of tokens a buyer gets per wei at the start of the crowdsale * @param initialRate Number of tokens a buyer gets per wei at the start of the crowdsale
* @param finalRate Number of tokens a buyer gets per wei at the end of the crowdsale * @param finalRate Number of tokens a buyer gets per wei at the end of the crowdsale
*/ */
function initialize(uint256 initialRate, uint256 finalRate) public initializer { function initialize(uint256 initialRate, uint256 finalRate) public initializer {
assert(TimedCrowdsale._hasBeenInitialized()); assert(TimedCrowdsale._hasBeenInitialized());
require(finalRate > 0); require(finalRate > 0);
require(initialRate >= finalRate); require(initialRate >= finalRate);
_initialRate = initialRate; _initialRate = initialRate;
_finalRate = finalRate; _finalRate = finalRate;
} }
/** /**
* @return the initial rate of the crowdsale. * @return the initial rate of the crowdsale.
*/ */
function initialRate() public view returns(uint256) { function initialRate() public view returns(uint256) {
return _initialRate; return _initialRate;
} }
/** /**
* @return the final rate of the crowdsale. * @return the final rate of the crowdsale.
*/ */
function finalRate() public view returns (uint256) { function finalRate() public view returns (uint256) {
return _finalRate; return _finalRate;
} }
/** /**
* @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) {
// solium-disable-next-line security/no-block-members // solium-disable-next-line security/no-block-members
uint256 elapsedTime = block.timestamp.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));
} }
/** /**
* @dev Overrides parent method taking into account variable rate. * @dev Overrides parent method taking into account variable rate.
* @param weiAmount The value in wei to be converted into tokens * @param weiAmount The value in wei to be converted into tokens
* @return The number of tokens _weiAmount wei will buy at present time * @return The number of tokens _weiAmount wei will buy at present time
*/ */
function _getTokenAmount(uint256 weiAmount) function _getTokenAmount(uint256 weiAmount)
internal view returns (uint256) internal view returns (uint256)
{ {
uint256 currentRate = getCurrentRate(); uint256 currentRate = getCurrentRate();
return currentRate.mul(weiAmount); return currentRate.mul(weiAmount);
} }
uint256[50] private ______gap; uint256[50] private ______gap;
} }
...@@ -10,51 +10,51 @@ import "../Crowdsale.sol"; ...@@ -10,51 +10,51 @@ import "../Crowdsale.sol";
* @dev Crowdsale with a limit for total contributions. * @dev Crowdsale with a limit for total contributions.
*/ */
contract CappedCrowdsale is Initializable, Crowdsale { contract CappedCrowdsale is Initializable, Crowdsale {
using SafeMath for uint256; using SafeMath for uint256;
uint256 private _cap; uint256 private _cap;
/** /**
* @dev Constructor, takes maximum amount of wei accepted in the crowdsale. * @dev Constructor, takes maximum amount of wei accepted in the crowdsale.
* @param cap Max amount of wei to be contributed * @param cap Max amount of wei to be contributed
*/ */
function initialize(uint256 cap) public initializer { function initialize(uint256 cap) public initializer {
assert(Crowdsale._hasBeenInitialized()); assert(Crowdsale._hasBeenInitialized());
require(cap > 0); require(cap > 0);
_cap = cap; _cap = cap;
} }
/** /**
* @return the cap of the crowdsale. * @return the cap of the crowdsale.
*/ */
function cap() public view returns(uint256) { function cap() public view returns(uint256) {
return _cap; return _cap;
} }
/** /**
* @dev Checks whether the cap has been reached. * @dev Checks whether the cap has been reached.
* @return Whether the cap was reached * @return Whether the cap was reached
*/ */
function capReached() public view returns (bool) { function capReached() public view returns (bool) {
return weiRaised() >= _cap; return weiRaised() >= _cap;
} }
/** /**
* @dev Extend parent behavior requiring purchase to respect the funding cap. * @dev Extend parent behavior requiring purchase to respect the funding cap.
* @param beneficiary Token purchaser * @param beneficiary Token purchaser
* @param weiAmount Amount of wei contributed * @param weiAmount Amount of wei contributed
*/ */
function _preValidatePurchase( function _preValidatePurchase(
address beneficiary, address beneficiary,
uint256 weiAmount uint256 weiAmount
) )
internal internal
{ {
super._preValidatePurchase(beneficiary, weiAmount); super._preValidatePurchase(beneficiary, weiAmount);
require(weiRaised().add(weiAmount) <= _cap); require(weiRaised().add(weiAmount) <= _cap);
} }
uint256[50] private ______gap; uint256[50] private ______gap;
} }
...@@ -11,78 +11,78 @@ import "../../access/roles/CapperRole.sol"; ...@@ -11,78 +11,78 @@ import "../../access/roles/CapperRole.sol";
* @dev Crowdsale with per-beneficiary caps. * @dev Crowdsale with per-beneficiary caps.
*/ */
contract IndividuallyCappedCrowdsale is Initializable, Crowdsale, CapperRole { contract IndividuallyCappedCrowdsale is Initializable, Crowdsale, CapperRole {
using SafeMath for uint256; using SafeMath for uint256;
mapping(address => uint256) private _contributions; mapping(address => uint256) private _contributions;
mapping(address => uint256) private _caps; mapping(address => uint256) private _caps;
function initialize(address sender) public initializer { function initialize(address sender) public initializer {
assert(Crowdsale._hasBeenInitialized()); assert(Crowdsale._hasBeenInitialized());
CapperRole.initialize(sender); CapperRole.initialize(sender);
} }
/** /**
* @dev Sets a specific beneficiary's maximum contribution. * @dev Sets a specific beneficiary's maximum contribution.
* @param beneficiary Address to be capped * @param beneficiary Address to be capped
* @param cap Wei limit for individual contribution * @param cap Wei limit for individual contribution
*/ */
function setCap(address beneficiary, uint256 cap) external onlyCapper { function setCap(address beneficiary, uint256 cap) external onlyCapper {
_caps[beneficiary] = cap; _caps[beneficiary] = cap;
} }
/** /**
* @dev Returns the cap of a specific beneficiary. * @dev Returns the cap of a specific beneficiary.
* @param beneficiary Address whose cap is to be checked * @param beneficiary Address whose cap is to be checked
* @return Current cap for individual beneficiary * @return Current cap for individual beneficiary
*/ */
function getCap(address beneficiary) public view returns (uint256) { function getCap(address beneficiary) public view returns (uint256) {
return _caps[beneficiary]; return _caps[beneficiary];
} }
/** /**
* @dev Returns the amount contributed so far by a specific beneficiary. * @dev Returns the amount contributed so far by a specific beneficiary.
* @param beneficiary Address of contributor * @param beneficiary Address of contributor
* @return Beneficiary contribution so far * @return Beneficiary contribution so far
*/ */
function getContribution(address beneficiary) function getContribution(address beneficiary)
public view returns (uint256) public view returns (uint256)
{ {
return _contributions[beneficiary]; return _contributions[beneficiary];
} }
/** /**
* @dev Extend parent behavior requiring purchase to respect the beneficiary's funding cap. * @dev Extend parent behavior requiring purchase to respect the beneficiary's funding cap.
* @param beneficiary Token purchaser * @param beneficiary Token purchaser
* @param weiAmount Amount of wei contributed * @param weiAmount Amount of wei contributed
*/ */
function _preValidatePurchase( function _preValidatePurchase(
address beneficiary, address beneficiary,
uint256 weiAmount uint256 weiAmount
) )
internal internal
{ {
super._preValidatePurchase(beneficiary, weiAmount); super._preValidatePurchase(beneficiary, weiAmount);
require( require(
_contributions[beneficiary].add(weiAmount) <= _caps[beneficiary]); _contributions[beneficiary].add(weiAmount) <= _caps[beneficiary]);
} }
/** /**
* @dev Extend parent behavior to update beneficiary contributions * @dev Extend parent behavior to update beneficiary contributions
* @param beneficiary Token purchaser * @param beneficiary Token purchaser
* @param weiAmount Amount of wei contributed * @param weiAmount Amount of wei contributed
*/ */
function _updatePurchasingState( function _updatePurchasingState(
address beneficiary, address beneficiary,
uint256 weiAmount uint256 weiAmount
) )
internal internal
{ {
super._updatePurchasingState(beneficiary, weiAmount); super._updatePurchasingState(beneficiary, weiAmount);
_contributions[beneficiary] = _contributions[beneficiary].add( _contributions[beneficiary] = _contributions[beneficiary].add(
weiAmount); weiAmount);
} }
uint256[50] private ______gap; uint256[50] private ______gap;
} }
...@@ -10,85 +10,85 @@ import "../Crowdsale.sol"; ...@@ -10,85 +10,85 @@ import "../Crowdsale.sol";
* @dev Crowdsale accepting contributions only within a time frame. * @dev Crowdsale accepting contributions only within a time frame.
*/ */
contract TimedCrowdsale is Initializable, Crowdsale { contract TimedCrowdsale is Initializable, Crowdsale {
using SafeMath for uint256; using SafeMath for uint256;
uint256 private _openingTime; uint256 private _openingTime;
uint256 private _closingTime; uint256 private _closingTime;
/** /**
* @dev Reverts if not in crowdsale time range. * @dev Reverts if not in crowdsale time range.
*/ */
modifier onlyWhileOpen { modifier onlyWhileOpen {
require(isOpen()); require(isOpen());
_; _;
} }
/** /**
* @dev Constructor, takes crowdsale opening and closing times. * @dev Constructor, takes crowdsale opening and closing times.
* @param openingTime Crowdsale opening time * @param openingTime Crowdsale opening time
* @param closingTime Crowdsale closing time * @param closingTime Crowdsale closing time
*/ */
function initialize(uint256 openingTime, uint256 closingTime) public initializer { function initialize(uint256 openingTime, uint256 closingTime) public initializer {
assert(Crowdsale._hasBeenInitialized()); assert(Crowdsale._hasBeenInitialized());
// solium-disable-next-line security/no-block-members // solium-disable-next-line security/no-block-members
require(openingTime >= block.timestamp); require(openingTime >= block.timestamp);
require(closingTime >= openingTime); require(closingTime >= openingTime);
_openingTime = openingTime; _openingTime = openingTime;
_closingTime = closingTime; _closingTime = closingTime;
} }
/** /**
* @return the crowdsale opening time. * @return the crowdsale opening time.
*/ */
function openingTime() public view returns(uint256) { function openingTime() public view returns(uint256) {
return _openingTime; return _openingTime;
} }
/** /**
* @return the crowdsale closing time. * @return the crowdsale closing time.
*/ */
function closingTime() public view returns(uint256) { function closingTime() public view returns(uint256) {
return _closingTime; return _closingTime;
} }
/** /**
* @return true if the crowdsale is open, false otherwise. * @return true if the crowdsale is open, false otherwise.
*/ */
function isOpen() public view returns (bool) { function isOpen() public view returns (bool) {
// solium-disable-next-line security/no-block-members // solium-disable-next-line security/no-block-members
return block.timestamp >= _openingTime && block.timestamp <= _closingTime; return block.timestamp >= _openingTime && block.timestamp <= _closingTime;
} }
/** /**
* @dev Checks whether the period in which the crowdsale is open has already elapsed. * @dev Checks whether the period in which the crowdsale is open has already elapsed.
* @return Whether crowdsale period has elapsed * @return Whether crowdsale period has elapsed
*/ */
function hasClosed() public view returns (bool) { function hasClosed() public view returns (bool) {
// solium-disable-next-line security/no-block-members // solium-disable-next-line security/no-block-members
return block.timestamp > _closingTime; return block.timestamp > _closingTime;
} }
function _hasBeenInitialized() internal view returns (bool) { function _hasBeenInitialized() internal view returns (bool) {
return ((_openingTime > 0) && (_closingTime > 0)); return ((_openingTime > 0) && (_closingTime > 0));
} }
/** /**
* @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
* @param weiAmount Amount of wei contributed * @param weiAmount Amount of wei contributed
*/ */
function _preValidatePurchase( function _preValidatePurchase(
address beneficiary, address beneficiary,
uint256 weiAmount uint256 weiAmount
) )
internal internal
onlyWhileOpen onlyWhileOpen
{ {
super._preValidatePurchase(beneficiary, weiAmount); super._preValidatePurchase(beneficiary, weiAmount);
} }
uint256[50] private ______gap; uint256[50] private ______gap;
} }
...@@ -10,63 +10,63 @@ pragma solidity ^0.4.24; ...@@ -10,63 +10,63 @@ pragma solidity ^0.4.24;
library ECDSA { library ECDSA {
/** /**
* @dev Recover signer address from a message by using their signature * @dev Recover signer address from a message by using their signature
* @param hash bytes32 message, the hash is the signed message. What is recovered is the signer address. * @param hash bytes32 message, the hash is the signed message. What is recovered is the signer address.
* @param signature bytes signature, the signature is generated using web3.eth.sign() * @param signature bytes signature, the signature is generated using web3.eth.sign()
*/ */
function recover(bytes32 hash, bytes signature) function recover(bytes32 hash, bytes signature)
internal internal
pure pure
returns (address) returns (address)
{ {
bytes32 r; bytes32 r;
bytes32 s; bytes32 s;
uint8 v; uint8 v;
// Check the signature length // Check the signature length
if (signature.length != 65) { if (signature.length != 65) {
return (address(0)); return (address(0));
} }
// 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 // ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly. // currently is to use assembly.
// solium-disable-next-line security/no-inline-assembly // solium-disable-next-line security/no-inline-assembly
assembly { assembly {
r := mload(add(signature, 32)) r := mload(add(signature, 32))
s := mload(add(signature, 64)) s := mload(add(signature, 64))
v := byte(0, mload(add(signature, 96))) v := byte(0, mload(add(signature, 96)))
} }
// Version of signature should be 27 or 28, but 0 and 1 are also possible versions // Version of signature should be 27 or 28, but 0 and 1 are also possible versions
if (v < 27) { if (v < 27) {
v += 27; v += 27;
} }
// If the version is correct return the signer address // If the version is correct return the signer address
if (v != 27 && v != 28) { if (v != 27 && v != 28) {
return (address(0)); return (address(0));
} else { } else {
// solium-disable-next-line arg-overflow // solium-disable-next-line arg-overflow
return ecrecover(hash, v, r, s); return ecrecover(hash, v, r, s);
}
} }
}
/** /**
* toEthSignedMessageHash * toEthSignedMessageHash
* @dev prefix a bytes32 value with "\x19Ethereum Signed Message:" * @dev prefix a bytes32 value with "\x19Ethereum Signed Message:"
* and hash the result * and hash the result
*/ */
function toEthSignedMessageHash(bytes32 hash) function toEthSignedMessageHash(bytes32 hash)
internal internal
pure pure
returns (bytes32) returns (bytes32)
{ {
// 32 is the length in bytes of hash, // 32 is the length in bytes of hash,
// enforced by the type signature above // enforced by the type signature above
return keccak256( return keccak256(
abi.encodePacked("\x19Ethereum Signed Message:\n32", hash) abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)
); );
} }
} }
...@@ -7,37 +7,37 @@ pragma solidity ^0.4.24; ...@@ -7,37 +7,37 @@ pragma solidity ^0.4.24;
* https://github.com/ameensol/merkle-tree-solidity/blob/master/src/MerkleProof.sol * https://github.com/ameensol/merkle-tree-solidity/blob/master/src/MerkleProof.sol
*/ */
library MerkleProof { library MerkleProof {
/** /**
* @dev Verifies a Merkle proof proving the existence of a leaf in a Merkle tree. Assumes that each pair of leaves * @dev Verifies a Merkle proof proving the existence of a leaf in a Merkle tree. Assumes that each pair of leaves
* and each pair of pre-images are sorted. * and each pair of pre-images are sorted.
* @param proof Merkle proof containing sibling hashes on the branch from the leaf to the root of the Merkle tree * @param proof Merkle proof containing sibling hashes on the branch from the leaf to the root of the Merkle tree
* @param root Merkle root * @param root Merkle root
* @param leaf Leaf of Merkle tree * @param leaf Leaf of Merkle tree
*/ */
function verify( function verify(
bytes32[] proof, bytes32[] proof,
bytes32 root, bytes32 root,
bytes32 leaf bytes32 leaf
) )
internal internal
pure pure
returns (bool) returns (bool)
{ {
bytes32 computedHash = leaf; bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) { for (uint256 i = 0; i < proof.length; i++) {
bytes32 proofElement = proof[i]; bytes32 proofElement = proof[i];
if (computedHash < proofElement) { if (computedHash < proofElement) {
// Hash(current computed hash + current element of the proof) // Hash(current computed hash + current element of the proof)
computedHash = keccak256(abi.encodePacked(computedHash, proofElement)); computedHash = keccak256(abi.encodePacked(computedHash, proofElement));
} else { } else {
// Hash(current element of the proof + current computed hash) // Hash(current element of the proof + current computed hash)
computedHash = keccak256(abi.encodePacked(proofElement, computedHash)); computedHash = keccak256(abi.encodePacked(proofElement, computedHash));
} }
} }
// Check if the computed hash (root) is equal to the provided root // Check if the computed hash (root) is equal to the provided root
return computedHash == root; return computedHash == root;
} }
} }
...@@ -15,15 +15,15 @@ pragma solidity ^0.4.24; ...@@ -15,15 +15,15 @@ pragma solidity ^0.4.24;
*/ */
library Counter { library Counter {
struct Counter { struct Counter {
uint256 current; // default: 0 uint256 current; // default: 0
} }
function next(Counter storage index) function next(Counter storage index)
internal internal
returns (uint256) returns (uint256)
{ {
index.current += 1; index.current += 1;
return index.current; return index.current;
} }
} }
...@@ -11,25 +11,25 @@ import "../../token/ERC20/IERC20.sol"; ...@@ -11,25 +11,25 @@ import "../../token/ERC20/IERC20.sol";
* @dev TODO - update https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/token/ERC721/IERC721.sol#L17 when 1046 is finalized * @dev TODO - update https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/token/ERC721/IERC721.sol#L17 when 1046 is finalized
*/ */
contract ERC20TokenMetadata is Initializable, IERC20 { contract ERC20TokenMetadata is Initializable, IERC20 {
function tokenURI() external view returns (string); function tokenURI() external view returns (string);
uint256[50] private ______gap; uint256[50] private ______gap;
} }
contract ERC20WithMetadata is Initializable, ERC20TokenMetadata { contract ERC20WithMetadata is Initializable, ERC20TokenMetadata {
string private _tokenURI = ""; string private _tokenURI = "";
function initialize(string tokenURI) function initialize(string tokenURI)
public public
initializer initializer
{ {
_tokenURI = tokenURI; _tokenURI = tokenURI;
} }
function tokenURI() external view returns (string) { function tokenURI() external view returns (string) {
return _tokenURI; return _tokenURI;
} }
uint256[50] private ______gap; uint256[50] private ______gap;
} }
...@@ -34,71 +34,71 @@ import "../math/Math.sol"; ...@@ -34,71 +34,71 @@ import "../math/Math.sol";
* ``` * ```
*/ */
contract ERC20Migrator is Initializable { contract ERC20Migrator is Initializable {
using SafeERC20 for IERC20; using SafeERC20 for IERC20;
/// Address of the old token contract /// Address of the old token contract
IERC20 private _legacyToken; IERC20 private _legacyToken;
/// Address of the new token contract /// Address of the new token contract
ERC20Mintable private _newToken; ERC20Mintable private _newToken;
/** /**
* @param legacyToken address of the old token contract * @param legacyToken address of the old token contract
*/ */
function initialize(IERC20 legacyToken) public initializer { function initialize(IERC20 legacyToken) public initializer {
require(legacyToken != address(0)); require(legacyToken != address(0));
_legacyToken = legacyToken; _legacyToken = legacyToken;
} }
/** /**
* @dev Returns the legacy token that is being migrated. * @dev Returns the legacy token that is being migrated.
*/ */
function legacyToken() public view returns (IERC20) { function legacyToken() public view returns (IERC20) {
return _legacyToken; return _legacyToken;
} }
/** /**
* @dev Returns the new token to which we are migrating. * @dev Returns the new token to which we are migrating.
*/ */
function newToken() public view returns (IERC20) { function newToken() public view returns (IERC20) {
return _newToken; return _newToken;
} }
/** /**
* @dev Begins the migration by setting which is the new token that will be * @dev Begins the migration by setting which is the new token that will be
* minted. This contract must be a minter for the new token. * minted. This contract must be a minter for the new token.
* @param newToken the token that will be minted * @param newToken the token that will be minted
*/ */
function beginMigration(ERC20Mintable newToken) public { function beginMigration(ERC20Mintable newToken) public {
require(_newToken == address(0)); require(_newToken == address(0));
require(newToken != address(0)); require(newToken != address(0));
require(newToken.isMinter(this)); require(newToken.isMinter(this));
_newToken = newToken; _newToken = newToken;
} }
/** /**
* @dev Transfers part of an account's balance in the old token to this * @dev Transfers part of an account's balance in the old token to this
* contract, and mints the same amount of new tokens for that account. * contract, and mints the same amount of new tokens for that account.
* @param account whose tokens will be migrated * @param account whose tokens will be migrated
* @param amount amount of tokens to be migrated * @param amount amount of tokens to be migrated
*/ */
function migrate(address account, uint256 amount) public { function migrate(address account, uint256 amount) public {
_legacyToken.safeTransferFrom(account, this, amount); _legacyToken.safeTransferFrom(account, this, amount);
_newToken.mint(account, amount); _newToken.mint(account, amount);
} }
/** /**
* @dev Transfers all of an account's allowed balance in the old token to * @dev Transfers all of an account's allowed balance in the old token to
* this contract, and mints the same amount of new tokens for that account. * this contract, and mints the same amount of new tokens for that account.
* @param account whose tokens will be migrated * @param account whose tokens will be migrated
*/ */
function migrateAll(address account) public { function migrateAll(address account) public {
uint256 balance = _legacyToken.balanceOf(account); uint256 balance = _legacyToken.balanceOf(account);
uint256 allowance = _legacyToken.allowance(account, this); uint256 allowance = _legacyToken.allowance(account, this);
uint256 amount = Math.min(balance, allowance); uint256 amount = Math.min(balance, allowance);
migrate(account, amount); migrate(account, amount);
} }
uint256[50] private ______gap; uint256[50] private ______gap;
} }
...@@ -30,116 +30,116 @@ import "../cryptography/ECDSA.sol"; ...@@ -30,116 +30,116 @@ import "../cryptography/ECDSA.sol";
* much more complex. See https://ethereum.stackexchange.com/a/50616 for more details. * much more complex. See https://ethereum.stackexchange.com/a/50616 for more details.
*/ */
contract SignatureBouncer is Initializable, SignerRole { contract SignatureBouncer is Initializable, SignerRole {
using ECDSA for bytes32; using ECDSA for bytes32;
// Function selectors are 4 bytes long, as documented in // Function selectors are 4 bytes long, as documented in
// https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector // https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector
uint256 private constant _METHOD_ID_SIZE = 4; uint256 private constant _METHOD_ID_SIZE = 4;
// Signature size is 65 bytes (tightly packed v + r + s), but gets padded to 96 bytes // Signature size is 65 bytes (tightly packed v + r + s), but gets padded to 96 bytes
uint256 private constant _SIGNATURE_SIZE = 96; uint256 private constant _SIGNATURE_SIZE = 96;
/** /**
* @dev requires that a valid signature of a signer was provided * @dev requires that a valid signature of a signer was provided
*/ */
modifier onlyValidSignature(bytes signature) modifier onlyValidSignature(bytes signature)
{ {
require(_isValidSignature(msg.sender, signature)); require(_isValidSignature(msg.sender, signature));
_; _;
} }
/** /**
* @dev requires that a valid signature with a specifed method of a signer was provided * @dev requires that a valid signature with a specifed method of a signer was provided
*/ */
modifier onlyValidSignatureAndMethod(bytes signature) modifier onlyValidSignatureAndMethod(bytes signature)
{ {
require(_isValidSignatureAndMethod(msg.sender, signature)); require(_isValidSignatureAndMethod(msg.sender, signature));
_; _;
} }
/** /**
* @dev requires that a valid signature with a specifed method and params of a signer was provided * @dev requires that a valid signature with a specifed method and params of a signer was provided
*/ */
modifier onlyValidSignatureAndData(bytes signature) modifier onlyValidSignatureAndData(bytes signature)
{ {
require(_isValidSignatureAndData(msg.sender, signature)); require(_isValidSignatureAndData(msg.sender, signature));
_; _;
} }
function initialize(address sender) public initializer { function initialize(address sender) public initializer {
SignerRole.initialize(sender); SignerRole.initialize(sender);
} }
/** /**
* @dev is the signature of `this + sender` from a signer? * @dev is the signature of `this + sender` from a signer?
* @return bool * @return bool
*/ */
function _isValidSignature(address account, bytes signature) function _isValidSignature(address account, bytes signature)
internal internal
view view
returns (bool) returns (bool)
{ {
return _isValidDataHash( return _isValidDataHash(
keccak256(abi.encodePacked(address(this), account)), keccak256(abi.encodePacked(address(this), account)),
signature signature
); );
} }
/** /**
* @dev is the signature of `this + sender + methodId` from a signer? * @dev is the signature of `this + sender + methodId` from a signer?
* @return bool * @return bool
*/ */
function _isValidSignatureAndMethod(address account, bytes signature) function _isValidSignatureAndMethod(address account, bytes signature)
internal internal
view view
returns (bool) returns (bool)
{ {
bytes memory data = new bytes(_METHOD_ID_SIZE); bytes memory data = new bytes(_METHOD_ID_SIZE);
for (uint i = 0; i < data.length; i++) { for (uint i = 0; i < data.length; i++) {
data[i] = msg.data[i]; data[i] = msg.data[i];
}
return _isValidDataHash(
keccak256(abi.encodePacked(address(this), account, data)),
signature
);
} }
return _isValidDataHash(
keccak256(abi.encodePacked(address(this), account, data)),
signature
);
}
/** /**
* @dev is the signature of `this + sender + methodId + params(s)` from a signer? * @dev is the signature of `this + sender + methodId + params(s)` from a signer?
* @notice the signature parameter of the method being validated must be the "last" parameter * @notice the signature parameter of the method being validated must be the "last" parameter
* @return bool * @return bool
*/ */
function _isValidSignatureAndData(address account, bytes signature) function _isValidSignatureAndData(address account, bytes signature)
internal internal
view view
returns (bool) returns (bool)
{ {
require(msg.data.length > _SIGNATURE_SIZE); require(msg.data.length > _SIGNATURE_SIZE);
bytes memory data = new bytes(msg.data.length - _SIGNATURE_SIZE); bytes memory data = new bytes(msg.data.length - _SIGNATURE_SIZE);
for (uint i = 0; i < data.length; i++) { for (uint i = 0; i < data.length; i++) {
data[i] = msg.data[i]; data[i] = msg.data[i];
}
return _isValidDataHash(
keccak256(abi.encodePacked(address(this), account, data)),
signature
);
} }
return _isValidDataHash(
keccak256(abi.encodePacked(address(this), account, data)),
signature
);
}
/** /**
* @dev internal function to convert a hash to an eth signed message * @dev internal function to convert a hash to an eth signed message
* and then recover the signature and check it against the signer role * and then recover the signature and check it against the signer role
* @return bool * @return bool
*/ */
function _isValidDataHash(bytes32 hash, bytes signature) function _isValidDataHash(bytes32 hash, bytes signature)
internal internal
view view
returns (bool) returns (bool)
{ {
address signer = hash address signer = hash
.toEthSignedMessageHash() .toEthSignedMessageHash()
.recover(signature); .recover(signature);
return signer != address(0) && isSigner(signer); return signer != address(0) && isSigner(signer);
} }
uint256[50] private ______gap; uint256[50] private ______gap;
} }
...@@ -15,167 +15,167 @@ import "../math/SafeMath.sol"; ...@@ -15,167 +15,167 @@ import "../math/SafeMath.sol";
* owner. * owner.
*/ */
contract TokenVesting is Initializable, Ownable { contract TokenVesting is Initializable, Ownable {
using SafeMath for uint256; using SafeMath for uint256;
using SafeERC20 for IERC20; using SafeERC20 for IERC20;
event Released(uint256 amount); event Released(uint256 amount);
event Revoked(); event Revoked();
// beneficiary of tokens after they are released // beneficiary of tokens after they are released
address private _beneficiary; address private _beneficiary;
uint256 private _cliff; uint256 private _cliff;
uint256 private _start; uint256 private _start;
uint256 private _duration; uint256 private _duration;
bool private _revocable; bool private _revocable;
mapping (address => uint256) private _released; mapping (address => uint256) private _released;
mapping (address => bool) private _revoked; mapping (address => bool) private _revoked;
/** /**
* @dev Creates a vesting contract that vests its balance of any ERC20 token to the * @dev Creates a vesting contract that vests its balance of any ERC20 token to the
* beneficiary, gradually in a linear fashion until start + duration. By then all * beneficiary, gradually in a linear fashion until start + duration. By then all
* of the balance will have vested. * of the balance will have vested.
* @param beneficiary address of the beneficiary to whom vested tokens are transferred * @param beneficiary address of the beneficiary to whom vested tokens are transferred
* @param cliffDuration duration in seconds of the cliff in which tokens will begin to vest * @param cliffDuration duration in seconds of the cliff in which tokens will begin to vest
* @param start the time (as Unix time) at which point vesting starts * @param start the time (as Unix time) at which point vesting starts
* @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 initialize( function initialize(
address beneficiary, address beneficiary,
uint256 start, uint256 start,
uint256 cliffDuration, uint256 cliffDuration,
uint256 duration, uint256 duration,
bool revocable, bool revocable,
address sender address sender
) )
public public
initializer initializer
{ {
Ownable.initialize(sender); Ownable.initialize(sender);
require(beneficiary != address(0)); require(beneficiary != address(0));
require(cliffDuration <= duration); require(cliffDuration <= duration);
_beneficiary = beneficiary; _beneficiary = beneficiary;
_revocable = revocable; _revocable = revocable;
_duration = duration; _duration = duration;
_cliff = start.add(cliffDuration); _cliff = start.add(cliffDuration);
_start = start; _start = start;
}
/**
* @return the beneficiary of the tokens.
*/
function beneficiary() public view returns(address) {
return _beneficiary;
}
/**
* @return the cliff time of the token vesting.
*/
function cliff() public view returns(uint256) {
return _cliff;
}
/**
* @return the start time of the token vesting.
*/
function start() public view returns(uint256) {
return _start;
}
/**
* @return the duration of the token vesting.
*/
function duration() public view returns(uint256) {
return _duration;
}
/**
* @return true if the vesting is revocable.
*/
function revocable() public view returns(bool) {
return _revocable;
}
/**
* @return the amount of the token released.
*/
function released(address token) public view returns(uint256) {
return _released[token];
}
/**
* @return true if the token is revoked.
*/
function revoked(address token) public view returns(bool) {
return _revoked[token];
}
/**
* @notice Transfers vested tokens to beneficiary.
* @param token ERC20 token which is being vested
*/
function release(IERC20 token) public {
uint256 unreleased = releasableAmount(token);
require(unreleased > 0);
_released[token] = _released[token].add(unreleased);
token.safeTransfer(_beneficiary, unreleased);
emit Released(unreleased);
}
/**
* @notice Allows the owner to revoke the vesting. Tokens already vested
* remain in the contract, the rest are returned to the owner.
* @param token ERC20 token which is being vested
*/
function revoke(IERC20 token) public onlyOwner {
require(_revocable);
require(!_revoked[token]);
uint256 balance = token.balanceOf(address(this));
uint256 unreleased = releasableAmount(token);
uint256 refund = balance.sub(unreleased);
_revoked[token] = true;
token.safeTransfer(owner(), refund);
emit Revoked();
}
/**
* @dev Calculates the amount that has already vested but hasn't been released yet.
* @param token ERC20 token which is being vested
*/
function releasableAmount(IERC20 token) public view returns (uint256) {
return vestedAmount(token).sub(_released[token]);
}
/**
* @dev Calculates the amount that has already vested.
* @param token ERC20 token which is being vested
*/
function vestedAmount(IERC20 token) public view returns (uint256) {
uint256 currentBalance = token.balanceOf(this);
uint256 totalBalance = currentBalance.add(_released[token]);
if (block.timestamp < _cliff) {
return 0;
} else if (block.timestamp >= _start.add(_duration) || _revoked[token]) {
return totalBalance;
} else {
return totalBalance.mul(block.timestamp.sub(_start)).div(_duration);
} }
}
uint256[50] private ______gap; /**
* @return the beneficiary of the tokens.
*/
function beneficiary() public view returns(address) {
return _beneficiary;
}
/**
* @return the cliff time of the token vesting.
*/
function cliff() public view returns(uint256) {
return _cliff;
}
/**
* @return the start time of the token vesting.
*/
function start() public view returns(uint256) {
return _start;
}
/**
* @return the duration of the token vesting.
*/
function duration() public view returns(uint256) {
return _duration;
}
/**
* @return true if the vesting is revocable.
*/
function revocable() public view returns(bool) {
return _revocable;
}
/**
* @return the amount of the token released.
*/
function released(address token) public view returns(uint256) {
return _released[token];
}
/**
* @return true if the token is revoked.
*/
function revoked(address token) public view returns(bool) {
return _revoked[token];
}
/**
* @notice Transfers vested tokens to beneficiary.
* @param token ERC20 token which is being vested
*/
function release(IERC20 token) public {
uint256 unreleased = releasableAmount(token);
require(unreleased > 0);
_released[token] = _released[token].add(unreleased);
token.safeTransfer(_beneficiary, unreleased);
emit Released(unreleased);
}
/**
* @notice Allows the owner to revoke the vesting. Tokens already vested
* remain in the contract, the rest are returned to the owner.
* @param token ERC20 token which is being vested
*/
function revoke(IERC20 token) public onlyOwner {
require(_revocable);
require(!_revoked[token]);
uint256 balance = token.balanceOf(address(this));
uint256 unreleased = releasableAmount(token);
uint256 refund = balance.sub(unreleased);
_revoked[token] = true;
token.safeTransfer(owner(), refund);
emit Revoked();
}
/**
* @dev Calculates the amount that has already vested but hasn't been released yet.
* @param token ERC20 token which is being vested
*/
function releasableAmount(IERC20 token) public view returns (uint256) {
return vestedAmount(token).sub(_released[token]);
}
/**
* @dev Calculates the amount that has already vested.
* @param token ERC20 token which is being vested
*/
function vestedAmount(IERC20 token) public view returns (uint256) {
uint256 currentBalance = token.balanceOf(this);
uint256 totalBalance = currentBalance.add(_released[token]);
if (block.timestamp < _cliff) {
return 0;
} else if (block.timestamp >= _start.add(_duration) || _revoked[token]) {
return totalBalance;
} else {
return totalBalance.mul(block.timestamp.sub(_start)).div(_duration);
}
}
uint256[50] private ______gap;
} }
...@@ -14,19 +14,19 @@ import "../token/ERC20/ERC20Mintable.sol"; ...@@ -14,19 +14,19 @@ import "../token/ERC20/ERC20Mintable.sol";
*/ */
contract SampleCrowdsaleToken is Initializable, ERC20Mintable { contract SampleCrowdsaleToken is Initializable, ERC20Mintable {
string public name; string public name;
string public symbol; string public symbol;
uint8 public decimals; uint8 public decimals;
function initialize(address sender) public initializer { function initialize(address sender) public initializer {
ERC20Mintable.initialize(sender); ERC20Mintable.initialize(sender);
name = "Sample Crowdsale Token"; name = "Sample Crowdsale Token";
symbol = "SCT"; symbol = "SCT";
decimals = 18; decimals = 18;
} }
uint256[50] private ______gap; uint256[50] private ______gap;
} }
...@@ -48,27 +48,27 @@ contract SampleCrowdsaleToken is Initializable, ERC20Mintable { ...@@ -48,27 +48,27 @@ contract SampleCrowdsaleToken is Initializable, ERC20Mintable {
// solium-disable-next-line max-len // solium-disable-next-line max-len
contract SampleCrowdsale is Initializable, Crowdsale, CappedCrowdsale, RefundableCrowdsale, MintedCrowdsale { contract SampleCrowdsale is Initializable, Crowdsale, CappedCrowdsale, RefundableCrowdsale, MintedCrowdsale {
function initialize( function initialize(
uint256 openingTime, uint256 openingTime,
uint256 closingTime, uint256 closingTime,
uint256 rate, uint256 rate,
address wallet, address wallet,
uint256 cap, uint256 cap,
ERC20Mintable token, ERC20Mintable token,
uint256 goal uint256 goal
) )
public public
initializer initializer
{ {
Crowdsale.initialize(rate, wallet, token); Crowdsale.initialize(rate, wallet, token);
CappedCrowdsale.initialize(cap); CappedCrowdsale.initialize(cap);
TimedCrowdsale.initialize(openingTime, closingTime); TimedCrowdsale.initialize(openingTime, closingTime);
RefundableCrowdsale.initialize(goal); RefundableCrowdsale.initialize(goal);
//As goal needs to be met for a successful crowdsale //As goal needs to be met for a successful crowdsale
//the value needs to less or equal than a cap which is limit for accepted funds //the value needs to less or equal than a cap which is limit for accepted funds
require(goal <= cap); require(goal <= cap);
} }
uint256[50] private ______gap; uint256[50] private ______gap;
} }
...@@ -13,19 +13,19 @@ import "../token/ERC20/ERC20.sol"; ...@@ -13,19 +13,19 @@ import "../token/ERC20/ERC20.sol";
*/ */
contract SimpleToken is Initializable, ERC20 { contract SimpleToken is Initializable, ERC20 {
string public constant name = "SimpleToken"; string public constant name = "SimpleToken";
string public constant symbol = "SIM"; string public constant symbol = "SIM";
uint8 public constant decimals = 18; uint8 public constant decimals = 18;
uint256 public constant INITIAL_SUPPLY = 10000 * (10 ** uint256(decimals)); uint256 public constant INITIAL_SUPPLY = 10000 * (10 ** uint256(decimals));
/** /**
* @dev Constructor that gives sender all of existing tokens. * @dev Constructor that gives sender all of existing tokens.
*/ */
function initialize(address sender) public initializer { function initialize(address sender) public initializer {
_mint(sender, INITIAL_SUPPLY); _mint(sender, INITIAL_SUPPLY);
} }
uint256[50] private ______gap; uint256[50] private ______gap;
} }
...@@ -11,32 +11,32 @@ import "../token/ERC20/ERC20Pausable.sol"; ...@@ -11,32 +11,32 @@ import "../token/ERC20/ERC20Pausable.sol";
* *
*/ */
contract StandardToken is Initializable, ERC20Detailed, ERC20Mintable, ERC20Pausable { contract StandardToken is Initializable, ERC20Detailed, ERC20Mintable, ERC20Pausable {
function initialize( function initialize(
string name, string symbol, uint8 decimals, uint256 initialSupply, address initialHolder, string name, string symbol, uint8 decimals, uint256 initialSupply, address initialHolder,
address[] minters, address[] pausers address[] minters, address[] pausers
) public initializer { ) public initializer {
ERC20Detailed.initialize(name, symbol, decimals); ERC20Detailed.initialize(name, symbol, decimals);
// Mint the initial supply // Mint the initial supply
if (initialSupply > 0) { // To allow passing a null address when not doing any initial supply if (initialSupply > 0) { // To allow passing a null address when not doing any initial supply
_mint(initialHolder, initialSupply); _mint(initialHolder, initialSupply);
}
// Initialize the minter and pauser roles, and renounce them
ERC20Mintable.initialize(address(this));
renounceMinter();
ERC20Pausable.initialize(address(this));
renouncePauser();
// Add the requested minters and pausers (this can be done after renouncing since
// these are the internal calls)
for (uint256 i = 0; i < minters.length; ++i) {
_addMinter(minters[i]);
}
for (i = 0; i < pausers.length; ++i) {
_addPauser(pausers[i]);
}
} }
// Initialize the minter and pauser roles, and renounce them
ERC20Mintable.initialize(address(this));
renounceMinter();
ERC20Pausable.initialize(address(this));
renouncePauser();
// Add the requested minters and pausers (this can be done after renouncing since
// these are the internal calls)
for (uint256 i = 0; i < minters.length; ++i) {
_addMinter(minters[i]);
}
for (i = 0; i < pausers.length; ++i) {
_addPauser(pausers[i]);
}
}
} }
...@@ -11,48 +11,48 @@ import "./IERC165.sol"; ...@@ -11,48 +11,48 @@ import "./IERC165.sol";
*/ */
contract ERC165 is Initializable, IERC165 { contract ERC165 is Initializable, IERC165 {
bytes4 private constant _InterfaceId_ERC165 = 0x01ffc9a7; bytes4 private constant _InterfaceId_ERC165 = 0x01ffc9a7;
/** /**
* 0x01ffc9a7 === * 0x01ffc9a7 ===
* bytes4(keccak256('supportsInterface(bytes4)')) * bytes4(keccak256('supportsInterface(bytes4)'))
*/ */
/** /**
* @dev a mapping of interface id to whether or not it's supported * @dev a mapping of interface id to whether or not it's supported
*/ */
mapping(bytes4 => bool) internal _supportedInterfaces; mapping(bytes4 => bool) internal _supportedInterfaces;
/** /**
* @dev A contract implementing SupportsInterfaceWithLookup * @dev A contract implementing SupportsInterfaceWithLookup
* implement ERC165 itself * implement ERC165 itself
*/ */
function initialize() function initialize()
public public
initializer initializer
{ {
_registerInterface(_InterfaceId_ERC165); _registerInterface(_InterfaceId_ERC165);
} }
/** /**
* @dev implement supportsInterface(bytes4) using a lookup table * @dev implement supportsInterface(bytes4) using a lookup table
*/ */
function supportsInterface(bytes4 interfaceId) function supportsInterface(bytes4 interfaceId)
public public
view view
returns (bool) returns (bool)
{ {
return _supportedInterfaces[interfaceId]; return _supportedInterfaces[interfaceId];
} }
/** /**
* @dev private method for registering an interface * @dev private method for registering an interface
*/ */
function _registerInterface(bytes4 interfaceId) function _registerInterface(bytes4 interfaceId)
internal internal
{ {
require(interfaceId != 0xffffffff); require(interfaceId != 0xffffffff);
_supportedInterfaces[interfaceId] = true; _supportedInterfaces[interfaceId] = true;
} }
uint256[50] private ______gap; uint256[50] private ______gap;
} }
...@@ -7,14 +7,14 @@ pragma solidity ^0.4.24; ...@@ -7,14 +7,14 @@ pragma solidity ^0.4.24;
*/ */
interface IERC165 { interface IERC165 {
/** /**
* @notice Query if a contract implements an interface * @notice Query if a contract implements an interface
* @param interfaceId The interface identifier, as specified in ERC-165 * @param interfaceId The interface identifier, as specified in ERC-165
* @dev Interface identification is specified in ERC-165. This function * @dev Interface identification is specified in ERC-165. This function
* uses less than 30,000 gas. * uses less than 30,000 gas.
*/ */
function supportsInterface(bytes4 interfaceId) function supportsInterface(bytes4 interfaceId)
external external
view view
returns (bool); returns (bool);
} }
...@@ -9,53 +9,53 @@ import "../access/roles/PauserRole.sol"; ...@@ -9,53 +9,53 @@ import "../access/roles/PauserRole.sol";
* @dev Base contract which allows children to implement an emergency stop mechanism. * @dev Base contract which allows children to implement an emergency stop mechanism.
*/ */
contract Pausable is Initializable, PauserRole { contract Pausable is Initializable, PauserRole {
event Paused(); event Paused();
event Unpaused(); event Unpaused();
bool private _paused = false; bool private _paused = false;
function initialize(address sender) public initializer { function initialize(address sender) public initializer {
PauserRole.initialize(sender); PauserRole.initialize(sender);
} }
/** /**
* @return true if the contract is paused, false otherwise. * @return true if the contract is paused, false otherwise.
*/ */
function paused() public view returns(bool) { function paused() public view returns(bool) {
return _paused; return _paused;
} }
/** /**
* @dev Modifier to make a function callable only when the contract is not paused. * @dev Modifier to make a function callable only when the contract is not paused.
*/ */
modifier whenNotPaused() { modifier whenNotPaused() {
require(!_paused); require(!_paused);
_; _;
} }
/** /**
* @dev Modifier to make a function callable only when the contract is paused. * @dev Modifier to make a function callable only when the contract is paused.
*/ */
modifier whenPaused() { modifier whenPaused() {
require(_paused); require(_paused);
_; _;
} }
/** /**
* @dev called by the owner to pause, triggers stopped state * @dev called by the owner to pause, triggers stopped state
*/ */
function pause() public onlyPauser whenNotPaused { function pause() public onlyPauser whenNotPaused {
_paused = true; _paused = true;
emit Paused(); emit Paused();
} }
/** /**
* @dev called by the owner to unpause, returns to normal state * @dev called by the owner to unpause, returns to normal state
*/ */
function unpause() public onlyPauser whenPaused { function unpause() public onlyPauser whenPaused {
_paused = false; _paused = false;
emit Unpaused(); emit Unpaused();
} }
uint256[50] private ______gap; uint256[50] private ______gap;
} }
...@@ -6,16 +6,16 @@ pragma solidity ^0.4.24; ...@@ -6,16 +6,16 @@ pragma solidity ^0.4.24;
* @dev Assorted math operations * @dev Assorted math operations
*/ */
library Math { library Math {
function max(uint256 a, uint256 b) internal pure returns (uint256) { function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a >= b ? a : b; return a >= b ? a : b;
} }
function min(uint256 a, uint256 b) internal pure returns (uint256) { function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b; return a < b ? a : b;
} }
function average(uint256 a, uint256 b) internal pure returns (uint256) { function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow, so we distribute // (a + b) / 2 can overflow, so we distribute
return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2);
} }
} }
...@@ -7,60 +7,60 @@ pragma solidity ^0.4.24; ...@@ -7,60 +7,60 @@ pragma solidity ^0.4.24;
*/ */
library SafeMath { library SafeMath {
/** /**
* @dev Multiplies two numbers, reverts on overflow. * @dev Multiplies two numbers, reverts on overflow.
*/ */
function mul(uint256 a, uint256 b) internal pure returns (uint256) { function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested. // benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) { if (a == 0) {
return 0; return 0;
} }
uint256 c = a * b; uint256 c = a * b;
require(c / a == b); require(c / a == b);
return c; return c;
} }
/** /**
* @dev Integer division of two numbers truncating the quotient, reverts on division by zero. * @dev Integer division of two numbers truncating the quotient, reverts on division by zero.
*/ */
function div(uint256 a, uint256 b) internal pure returns (uint256) { function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0); // Solidity only automatically asserts when dividing by 0 require(b > 0); // Solidity only automatically asserts when dividing by 0
uint256 c = a / b; uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold // assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c; return c;
} }
/** /**
* @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend). * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend).
*/ */
function sub(uint256 a, uint256 b) internal pure returns (uint256) { function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a); require(b <= a);
uint256 c = a - b; uint256 c = a - b;
return c; return c;
} }
/** /**
* @dev Adds two numbers, reverts on overflow. * @dev Adds two numbers, reverts on overflow.
*/ */
function add(uint256 a, uint256 b) internal pure returns (uint256) { function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b; uint256 c = a + b;
require(c >= a); require(c >= a);
return c; return c;
} }
/** /**
* @dev Divides two numbers and returns the remainder (unsigned integer modulo), * @dev Divides two numbers and returns the remainder (unsigned integer modulo),
* reverts when dividing by zero. * reverts when dividing by zero.
*/ */
function mod(uint256 a, uint256 b) internal pure returns (uint256) { function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0); require(b != 0);
return a % b; return a % b;
} }
} }
...@@ -6,16 +6,16 @@ import "../crowdsale/emission/AllowanceCrowdsale.sol"; ...@@ -6,16 +6,16 @@ import "../crowdsale/emission/AllowanceCrowdsale.sol";
contract AllowanceCrowdsaleImpl is AllowanceCrowdsale { contract AllowanceCrowdsaleImpl is AllowanceCrowdsale {
constructor ( constructor (
uint256 rate, uint256 rate,
address wallet, address wallet,
IERC20 token, IERC20 token,
address tokenWallet address tokenWallet
) )
public public
{ {
Crowdsale.initialize(rate, wallet, token); Crowdsale.initialize(rate, wallet, token);
AllowanceCrowdsale.initialize(tokenWallet); AllowanceCrowdsale.initialize(tokenWallet);
} }
} }
...@@ -6,16 +6,16 @@ import "../crowdsale/validation/CappedCrowdsale.sol"; ...@@ -6,16 +6,16 @@ import "../crowdsale/validation/CappedCrowdsale.sol";
contract CappedCrowdsaleImpl is CappedCrowdsale { contract CappedCrowdsaleImpl is CappedCrowdsale {
constructor ( constructor (
uint256 rate, uint256 rate,
address wallet, address wallet,
IERC20 token, IERC20 token,
uint256 cap uint256 cap
) )
public public
{ {
Crowdsale.initialize(rate, wallet, token); Crowdsale.initialize(rate, wallet, token);
CappedCrowdsale.initialize(cap); CappedCrowdsale.initialize(cap);
} }
} }
...@@ -4,19 +4,19 @@ import "../access/roles/CapperRole.sol"; ...@@ -4,19 +4,19 @@ import "../access/roles/CapperRole.sol";
contract CapperRoleMock is CapperRole { contract CapperRoleMock is CapperRole {
constructor() public { constructor() public {
CapperRole.initialize(msg.sender); CapperRole.initialize(msg.sender);
} }
function removeCapper(address account) public { function removeCapper(address account) public {
_removeCapper(account); _removeCapper(account);
} }
function onlyCapperMock() public view onlyCapper { function onlyCapperMock() public view onlyCapper {
} }
// Causes a compilation error if super._removeCapper is not internal // Causes a compilation error if super._removeCapper is not internal
function _removeCapper(address account) internal { function _removeCapper(address account) internal {
super._removeCapper(account); super._removeCapper(account);
} }
} }
...@@ -5,17 +5,17 @@ import "../payment/ConditionalEscrow.sol"; ...@@ -5,17 +5,17 @@ import "../payment/ConditionalEscrow.sol";
// mock class using ConditionalEscrow // mock class using ConditionalEscrow
contract ConditionalEscrowMock is ConditionalEscrow { contract ConditionalEscrowMock is ConditionalEscrow {
mapping(address => bool) private _allowed; mapping(address => bool) private _allowed;
constructor() public { constructor() public {
ConditionalEscrow.initialize(msg.sender); ConditionalEscrow.initialize(msg.sender);
} }
function setAllowed(address payee, bool allowed) public { function setAllowed(address payee, bool allowed) public {
_allowed[payee] = allowed; _allowed[payee] = allowed;
} }
function withdrawalAllowed(address payee) public view returns (bool) { function withdrawalAllowed(address payee) public view returns (bool) {
return _allowed[payee]; return _allowed[payee];
} }
} }
...@@ -4,18 +4,18 @@ import "../drafts/Counter.sol"; ...@@ -4,18 +4,18 @@ import "../drafts/Counter.sol";
contract CounterImpl { contract CounterImpl {
using Counter for Counter.Counter; using Counter for Counter.Counter;
uint256 public theId; uint256 public theId;
// use whatever key you want to track your counters // use whatever key you want to track your counters
mapping(string => Counter.Counter) private _counters; mapping(string => Counter.Counter) private _counters;
function doThing(string key) function doThing(string key)
public public
returns (uint256) returns (uint256)
{ {
theId = _counters[key].next(); theId = _counters[key].next();
return theId; return theId;
} }
} }
...@@ -4,7 +4,7 @@ import "../crowdsale/Crowdsale.sol"; ...@@ -4,7 +4,7 @@ import "../crowdsale/Crowdsale.sol";
contract CrowdsaleMock is Crowdsale { contract CrowdsaleMock is Crowdsale {
constructor(uint256 rate, address wallet, IERC20 token) public { constructor(uint256 rate, address wallet, IERC20 token) public {
Crowdsale.initialize(rate, wallet, token); Crowdsale.initialize(rate, wallet, token);
} }
} }
...@@ -5,13 +5,13 @@ import "../token/ERC20/ERC20Detailed.sol"; ...@@ -5,13 +5,13 @@ import "../token/ERC20/ERC20Detailed.sol";
contract ERC20DetailedMock is ERC20, ERC20Detailed { contract ERC20DetailedMock is ERC20, ERC20Detailed {
constructor( constructor(
string name, string name,
string symbol, string symbol,
uint8 decimals uint8 decimals
) )
public public
{ {
ERC20Detailed.initialize(name, symbol, decimals); ERC20Detailed.initialize(name, symbol, decimals);
} }
} }
...@@ -4,21 +4,21 @@ import "../cryptography/ECDSA.sol"; ...@@ -4,21 +4,21 @@ import "../cryptography/ECDSA.sol";
contract ECDSAMock { contract ECDSAMock {
using ECDSA for bytes32; using ECDSA for bytes32;
function recover(bytes32 hash, bytes signature) function recover(bytes32 hash, bytes signature)
public public
pure pure
returns (address) returns (address)
{ {
return hash.recover(signature); return hash.recover(signature);
} }
function toEthSignedMessageHash(bytes32 hash) function toEthSignedMessageHash(bytes32 hash)
public public
pure pure
returns (bytes32) returns (bytes32)
{ {
return hash.toEthSignedMessageHash(); return hash.toEthSignedMessageHash();
} }
} }
...@@ -13,57 +13,57 @@ import "../../introspection/IERC165.sol"; ...@@ -13,57 +13,57 @@ import "../../introspection/IERC165.sol";
*/ */
contract SupportsInterfaceWithLookupMock is IERC165 { contract SupportsInterfaceWithLookupMock is IERC165 {
bytes4 public constant InterfaceId_ERC165 = 0x01ffc9a7; bytes4 public constant InterfaceId_ERC165 = 0x01ffc9a7;
/** /**
* 0x01ffc9a7 === * 0x01ffc9a7 ===
* bytes4(keccak256('supportsInterface(bytes4)')) * bytes4(keccak256('supportsInterface(bytes4)'))
*/ */
/** /**
* @dev a mapping of interface id to whether or not it's supported * @dev a mapping of interface id to whether or not it's supported
*/ */
mapping(bytes4 => bool) internal supportedInterfaces; mapping(bytes4 => bool) internal supportedInterfaces;
/** /**
* @dev A contract implementing SupportsInterfaceWithLookup * @dev A contract implementing SupportsInterfaceWithLookup
* implement ERC165 itself * implement ERC165 itself
*/ */
constructor() constructor()
public public
{ {
_registerInterface(InterfaceId_ERC165); _registerInterface(InterfaceId_ERC165);
} }
/** /**
* @dev implement supportsInterface(bytes4) using a lookup table * @dev implement supportsInterface(bytes4) using a lookup table
*/ */
function supportsInterface(bytes4 interfaceId) function supportsInterface(bytes4 interfaceId)
external external
view view
returns (bool) returns (bool)
{ {
return supportedInterfaces[interfaceId]; return supportedInterfaces[interfaceId];
} }
/** /**
* @dev private method for registering an interface * @dev private method for registering an interface
*/ */
function _registerInterface(bytes4 interfaceId) function _registerInterface(bytes4 interfaceId)
internal internal
{ {
require(interfaceId != 0xffffffff); require(interfaceId != 0xffffffff);
supportedInterfaces[interfaceId] = true; supportedInterfaces[interfaceId] = true;
} }
} }
contract ERC165InterfacesSupported is SupportsInterfaceWithLookupMock { contract ERC165InterfacesSupported is SupportsInterfaceWithLookupMock {
constructor (bytes4[] interfaceIds) constructor (bytes4[] interfaceIds)
public public
{ {
for (uint256 i = 0; i < interfaceIds.length; i++) { for (uint256 i = 0; i < interfaceIds.length; i++) {
_registerInterface(interfaceIds[i]); _registerInterface(interfaceIds[i]);
}
} }
}
} }
...@@ -4,29 +4,29 @@ import "../introspection/ERC165Checker.sol"; ...@@ -4,29 +4,29 @@ import "../introspection/ERC165Checker.sol";
contract ERC165CheckerMock { contract ERC165CheckerMock {
using ERC165Checker for address; using ERC165Checker for address;
function supportsERC165(address account) function supportsERC165(address account)
public public
view view
returns (bool) returns (bool)
{ {
return account.supportsERC165(); return account.supportsERC165();
} }
function supportsInterface(address account, bytes4 interfaceId) function supportsInterface(address account, bytes4 interfaceId)
public public
view view
returns (bool) returns (bool)
{ {
return account.supportsInterface(interfaceId); return account.supportsInterface(interfaceId);
} }
function supportsInterfaces(address account, bytes4[] interfaceIds) function supportsInterfaces(address account, bytes4[] interfaceIds)
public public
view view
returns (bool) returns (bool)
{ {
return account.supportsInterfaces(interfaceIds); return account.supportsInterfaces(interfaceIds);
} }
} }
...@@ -4,13 +4,13 @@ import "../introspection/ERC165.sol"; ...@@ -4,13 +4,13 @@ import "../introspection/ERC165.sol";
contract ERC165Mock is ERC165 { contract ERC165Mock is ERC165 {
constructor() public { constructor() public {
ERC165.initialize(); ERC165.initialize();
} }
function registerInterface(bytes4 interfaceId) function registerInterface(bytes4 interfaceId)
public public
{ {
_registerInterface(interfaceId); _registerInterface(interfaceId);
} }
} }
...@@ -5,8 +5,8 @@ import "../token/ERC20/ERC20Burnable.sol"; ...@@ -5,8 +5,8 @@ import "../token/ERC20/ERC20Burnable.sol";
contract ERC20BurnableMock is ERC20Burnable { contract ERC20BurnableMock is ERC20Burnable {
constructor(address initialAccount, uint256 initialBalance) public { constructor(address initialAccount, uint256 initialBalance) public {
_mint(initialAccount, initialBalance); _mint(initialAccount, initialBalance);
} }
} }
...@@ -6,8 +6,8 @@ import "./MinterRoleMock.sol"; ...@@ -6,8 +6,8 @@ import "./MinterRoleMock.sol";
contract ERC20CappedMock is ERC20Capped, MinterRoleMock { contract ERC20CappedMock is ERC20Capped, MinterRoleMock {
constructor(uint256 cap) public { constructor(uint256 cap) public {
ERC20Capped.initialize(cap, msg.sender); ERC20Capped.initialize(cap, msg.sender);
} }
} }
...@@ -5,8 +5,8 @@ import "../drafts/ERC20Migrator.sol"; ...@@ -5,8 +5,8 @@ import "../drafts/ERC20Migrator.sol";
contract ERC20MigratorMock is ERC20Migrator { contract ERC20MigratorMock is ERC20Migrator {
constructor(IERC20 legacyToken) public { constructor(IERC20 legacyToken) public {
ERC20Migrator.initialize(legacyToken); ERC20Migrator.initialize(legacyToken);
} }
} }
...@@ -6,7 +6,7 @@ import "./MinterRoleMock.sol"; ...@@ -6,7 +6,7 @@ import "./MinterRoleMock.sol";
contract ERC20MintableMock is ERC20Mintable, MinterRoleMock { contract ERC20MintableMock is ERC20Mintable, MinterRoleMock {
constructor() public { constructor() public {
ERC20Mintable.initialize(msg.sender); ERC20Mintable.initialize(msg.sender);
} }
} }
...@@ -6,20 +6,20 @@ import "../token/ERC20/ERC20.sol"; ...@@ -6,20 +6,20 @@ import "../token/ERC20/ERC20.sol";
// mock class using ERC20 // mock class using ERC20
contract ERC20Mock is ERC20 { contract ERC20Mock is ERC20 {
constructor(address initialAccount, uint256 initialBalance) public { constructor(address initialAccount, uint256 initialBalance) public {
_mint(initialAccount, initialBalance); _mint(initialAccount, initialBalance);
} }
function mint(address account, uint256 amount) public { function mint(address account, uint256 amount) public {
_mint(account, amount); _mint(account, amount);
} }
function burn(address account, uint256 amount) public { function burn(address account, uint256 amount) public {
_burn(account, amount); _burn(account, amount);
} }
function burnFrom(address account, uint256 amount) public { function burnFrom(address account, uint256 amount) public {
_burnFrom(account, amount); _burnFrom(account, amount);
} }
} }
...@@ -7,10 +7,10 @@ import "./PauserRoleMock.sol"; ...@@ -7,10 +7,10 @@ import "./PauserRoleMock.sol";
// mock class using ERC20Pausable // mock class using ERC20Pausable
contract ERC20PausableMock is ERC20Pausable, PauserRoleMock { contract ERC20PausableMock is ERC20Pausable, PauserRoleMock {
constructor(address initialAccount, uint initialBalance) public { constructor(address initialAccount, uint initialBalance) public {
ERC20Pausable.initialize(msg.sender); ERC20Pausable.initialize(msg.sender);
_mint(initialAccount, initialBalance); _mint(initialAccount, initialBalance);
} }
} }
...@@ -5,7 +5,7 @@ import "../drafts/ERC1046/TokenMetadata.sol"; ...@@ -5,7 +5,7 @@ import "../drafts/ERC1046/TokenMetadata.sol";
contract ERC20WithMetadataMock is ERC20, ERC20WithMetadata { contract ERC20WithMetadataMock is ERC20, ERC20WithMetadata {
constructor(string tokenURI) public { constructor(string tokenURI) public {
ERC20WithMetadata.initialize(tokenURI); ERC20WithMetadata.initialize(tokenURI);
} }
} }
...@@ -12,24 +12,24 @@ import "../token/ERC721/ERC721Burnable.sol"; ...@@ -12,24 +12,24 @@ import "../token/ERC721/ERC721Burnable.sol";
* and a public setter for metadata URI * and a public setter for metadata URI
*/ */
contract ERC721FullMock is ERC721Full, ERC721Mintable, ERC721MetadataMintable, ERC721Burnable { contract ERC721FullMock is ERC721Full, ERC721Mintable, ERC721MetadataMintable, ERC721Burnable {
constructor(string name, string symbol) public constructor(string name, string symbol) public
{ {
ERC721.initialize(); ERC721.initialize();
ERC721Metadata.initialize(name, symbol); ERC721Metadata.initialize(name, symbol);
ERC721Enumerable.initialize(); ERC721Enumerable.initialize();
ERC721Mintable.initialize(msg.sender); ERC721Mintable.initialize(msg.sender);
ERC721MetadataMintable.initialize(msg.sender); ERC721MetadataMintable.initialize(msg.sender);
} }
function exists(uint256 tokenId) public view returns (bool) { function exists(uint256 tokenId) public view returns (bool) {
return _exists(tokenId); return _exists(tokenId);
} }
function setTokenURI(uint256 tokenId, string uri) public { function setTokenURI(uint256 tokenId, string uri) public {
_setTokenURI(tokenId, uri); _setTokenURI(tokenId, uri);
} }
function removeTokenFrom(address from, uint256 tokenId) public { function removeTokenFrom(address from, uint256 tokenId) public {
_removeTokenFrom(from, tokenId); _removeTokenFrom(from, tokenId);
} }
} }
...@@ -10,15 +10,15 @@ import "../token/ERC721/ERC721Burnable.sol"; ...@@ -10,15 +10,15 @@ import "../token/ERC721/ERC721Burnable.sol";
* @title ERC721MintableBurnableImpl * @title ERC721MintableBurnableImpl
*/ */
contract ERC721MintableBurnableImpl contract ERC721MintableBurnableImpl
is ERC721Full, ERC721Mintable, ERC721MetadataMintable, ERC721Burnable { is ERC721Full, ERC721Mintable, ERC721MetadataMintable, ERC721Burnable {
constructor() constructor()
public public
{ {
ERC721.initialize(); ERC721.initialize();
ERC721Metadata.initialize("Test", "TEST"); ERC721Metadata.initialize("Test", "TEST");
ERC721Enumerable.initialize(); ERC721Enumerable.initialize();
ERC721Mintable.initialize(msg.sender); ERC721Mintable.initialize(msg.sender);
ERC721MetadataMintable.initialize(msg.sender); ERC721MetadataMintable.initialize(msg.sender);
} }
} }
...@@ -8,15 +8,15 @@ import "../token/ERC721/ERC721.sol"; ...@@ -8,15 +8,15 @@ import "../token/ERC721/ERC721.sol";
* 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
*/ */
contract ERC721Mock is ERC721 { contract ERC721Mock is ERC721 {
constructor() public { constructor() public {
ERC721.initialize(); ERC721.initialize();
} }
function mint(address to, uint256 tokenId) public { function mint(address to, uint256 tokenId) public {
_mint(to, tokenId); _mint(to, tokenId);
} }
function burn(uint256 tokenId) public { function burn(uint256 tokenId) public {
_burn(ownerOf(tokenId), tokenId); _burn(ownerOf(tokenId), tokenId);
} }
} }
...@@ -9,20 +9,20 @@ import "./PauserRoleMock.sol"; ...@@ -9,20 +9,20 @@ import "./PauserRoleMock.sol";
* This mock just provides a public mint, burn and exists functions for testing purposes * This mock just provides a public mint, burn and exists functions for testing purposes
*/ */
contract ERC721PausableMock is ERC721Pausable, PauserRoleMock { contract ERC721PausableMock is ERC721Pausable, PauserRoleMock {
constructor() { constructor() {
ERC721.initialize(); ERC721.initialize();
ERC721Pausable.initialize(msg.sender); ERC721Pausable.initialize(msg.sender);
} }
function mint(address to, uint256 tokenId) public { function mint(address to, uint256 tokenId) public {
super._mint(to, tokenId); super._mint(to, tokenId);
} }
function burn(uint256 tokenId) public { function burn(uint256 tokenId) public {
super._burn(ownerOf(tokenId), tokenId); super._burn(ownerOf(tokenId), tokenId);
} }
function exists(uint256 tokenId) public view returns (bool) { function exists(uint256 tokenId) public view returns (bool) {
return super._exists(tokenId); return super._exists(tokenId);
} }
} }
...@@ -4,39 +4,39 @@ import "../token/ERC721/IERC721Receiver.sol"; ...@@ -4,39 +4,39 @@ import "../token/ERC721/IERC721Receiver.sol";
contract ERC721ReceiverMock is IERC721Receiver { contract ERC721ReceiverMock is IERC721Receiver {
bytes4 private _retval; bytes4 private _retval;
bool private _reverts; bool private _reverts;
event Received( event Received(
address operator, address operator,
address from, address from,
uint256 tokenId, uint256 tokenId,
bytes data, bytes data,
uint256 gas uint256 gas
); );
constructor(bytes4 retval, bool reverts) public { constructor(bytes4 retval, bool reverts) public {
_retval = retval; _retval = retval;
_reverts = reverts; _reverts = reverts;
} }
function onERC721Received( function onERC721Received(
address operator, address operator,
address from, address from,
uint256 tokenId, uint256 tokenId,
bytes data bytes data
) )
public public
returns(bytes4) returns(bytes4)
{ {
require(!_reverts); require(!_reverts);
emit Received( emit Received(
operator, operator,
from, from,
tokenId, tokenId,
data, data,
gasleft() // msg.gas was deprecated in solidityv0.4.21 gasleft() // msg.gas was deprecated in solidityv0.4.21
); );
return _retval; return _retval;
} }
} }
...@@ -3,7 +3,7 @@ pragma solidity ^0.4.24; ...@@ -3,7 +3,7 @@ pragma solidity ^0.4.24;
import "../payment/Escrow.sol"; import "../payment/Escrow.sol";
contract EscrowMock is Escrow { contract EscrowMock is Escrow {
constructor() public { constructor() public {
Escrow.initialize(msg.sender); Escrow.initialize(msg.sender);
} }
} }
...@@ -6,17 +6,17 @@ import "../crowdsale/distribution/FinalizableCrowdsale.sol"; ...@@ -6,17 +6,17 @@ import "../crowdsale/distribution/FinalizableCrowdsale.sol";
contract FinalizableCrowdsaleImpl is FinalizableCrowdsale { contract FinalizableCrowdsaleImpl is FinalizableCrowdsale {
constructor ( constructor (
uint256 openingTime, uint256 openingTime,
uint256 closingTime, uint256 closingTime,
uint256 rate, uint256 rate,
address wallet, address wallet,
IERC20 token IERC20 token
) )
public public
{ {
Crowdsale.initialize(rate, wallet, token); Crowdsale.initialize(rate, wallet, token);
TimedCrowdsale.initialize(openingTime, closingTime); TimedCrowdsale.initialize(openingTime, closingTime);
} }
} }
...@@ -8,9 +8,9 @@ pragma solidity ^0.4.24; ...@@ -8,9 +8,9 @@ pragma solidity ^0.4.24;
// @author Remco Bloemen <remco@neufund.org> // @author Remco Bloemen <remco@neufund.org>
contract ForceEther { contract ForceEther {
constructor() public payable { } constructor() public payable { }
function destroyAndSend(address recipient) public { function destroyAndSend(address recipient) public {
selfdestruct(recipient); selfdestruct(recipient);
} }
} }
...@@ -6,19 +6,19 @@ import "../math/SafeMath.sol"; ...@@ -6,19 +6,19 @@ import "../math/SafeMath.sol";
contract IncreasingPriceCrowdsaleImpl is IncreasingPriceCrowdsale { contract IncreasingPriceCrowdsaleImpl is IncreasingPriceCrowdsale {
constructor ( constructor (
uint256 openingTime, uint256 openingTime,
uint256 closingTime, uint256 closingTime,
address wallet, address wallet,
IERC20 token, IERC20 token,
uint256 initialRate, uint256 initialRate,
uint256 finalRate uint256 finalRate
) )
public public
{ {
Crowdsale.initialize(initialRate, wallet, token); Crowdsale.initialize(initialRate, wallet, token);
TimedCrowdsale.initialize(openingTime, closingTime); TimedCrowdsale.initialize(openingTime, closingTime);
IncreasingPriceCrowdsale.initialize(initialRate, finalRate); IncreasingPriceCrowdsale.initialize(initialRate, finalRate);
} }
} }
...@@ -6,16 +6,16 @@ import "./CapperRoleMock.sol"; ...@@ -6,16 +6,16 @@ import "./CapperRoleMock.sol";
contract IndividuallyCappedCrowdsaleImpl contract IndividuallyCappedCrowdsaleImpl
is Crowdsale, IndividuallyCappedCrowdsale, CapperRoleMock { is Crowdsale, IndividuallyCappedCrowdsale, CapperRoleMock {
constructor( constructor(
uint256 rate, uint256 rate,
address wallet, address wallet,
IERC20 token IERC20 token
) )
public public
{ {
Crowdsale.initialize(rate, wallet, token); Crowdsale.initialize(rate, wallet, token);
IndividuallyCappedCrowdsale.initialize(msg.sender); IndividuallyCappedCrowdsale.initialize(msg.sender);
} }
} }
...@@ -5,15 +5,15 @@ import "../math/Math.sol"; ...@@ -5,15 +5,15 @@ import "../math/Math.sol";
contract MathMock { contract MathMock {
function max(uint256 a, uint256 b) public pure returns (uint256) { function max(uint256 a, uint256 b) public pure returns (uint256) {
return Math.max(a, b); return Math.max(a, b);
} }
function min(uint256 a, uint256 b) public pure returns (uint256) { function min(uint256 a, uint256 b) public pure returns (uint256) {
return Math.min(a, b); return Math.min(a, b);
} }
function average(uint256 a, uint256 b) public pure returns (uint256) { function average(uint256 a, uint256 b) public pure returns (uint256) {
return Math.average(a, b); return Math.average(a, b);
} }
} }
...@@ -5,15 +5,15 @@ import { MerkleProof } from "../cryptography/MerkleProof.sol"; ...@@ -5,15 +5,15 @@ import { MerkleProof } from "../cryptography/MerkleProof.sol";
contract MerkleProofWrapper { contract MerkleProofWrapper {
function verify( function verify(
bytes32[] proof, bytes32[] proof,
bytes32 root, bytes32 root,
bytes32 leaf bytes32 leaf
) )
public public
pure pure
returns (bool) returns (bool)
{ {
return MerkleProof.verify(proof, root, leaf); return MerkleProof.verify(proof, root, leaf);
} }
} }
...@@ -3,48 +3,48 @@ pragma solidity ^0.4.24; ...@@ -3,48 +3,48 @@ pragma solidity ^0.4.24;
contract MessageHelper { contract MessageHelper {
event Show(bytes32 b32, uint256 number, string text); event Show(bytes32 b32, uint256 number, string text);
event Buy(bytes32 b32, uint256 number, string text, uint256 value); event Buy(bytes32 b32, uint256 number, string text, uint256 value);
function showMessage( function showMessage(
bytes32 _message, bytes32 _message,
uint256 _number, uint256 _number,
string _text string _text
) )
public public
returns (bool) returns (bool)
{ {
emit Show(_message, _number, _text); emit Show(_message, _number, _text);
return true; return true;
} }
function buyMessage( function buyMessage(
bytes32 _message, bytes32 _message,
uint256 _number, uint256 _number,
string _text string _text
) )
public public
payable payable
returns (bool) returns (bool)
{ {
emit Buy( emit Buy(
_message, _message,
_number, _number,
_text, _text,
msg.value); msg.value);
return true; return true;
} }
function fail() public { function fail() public {
require(false); require(false);
} }
function call(address _to, bytes _data) public returns (bool) { function call(address _to, bytes _data) public returns (bool) {
// solium-disable-next-line security/no-low-level-calls // solium-disable-next-line security/no-low-level-calls
if (_to.call(_data)) if (_to.call(_data))
return true; return true;
else else
return false; return false;
} }
} }
...@@ -6,14 +6,14 @@ import "../crowdsale/emission/MintedCrowdsale.sol"; ...@@ -6,14 +6,14 @@ import "../crowdsale/emission/MintedCrowdsale.sol";
contract MintedCrowdsaleImpl is MintedCrowdsale { contract MintedCrowdsaleImpl is MintedCrowdsale {
constructor ( constructor (
uint256 rate, uint256 rate,
address wallet, address wallet,
ERC20Mintable token ERC20Mintable token
) )
public public
{ {
Crowdsale.initialize(rate, wallet, token); Crowdsale.initialize(rate, wallet, token);
} }
} }
...@@ -4,19 +4,19 @@ import "../access/roles/MinterRole.sol"; ...@@ -4,19 +4,19 @@ import "../access/roles/MinterRole.sol";
contract MinterRoleMock is MinterRole { contract MinterRoleMock is MinterRole {
constructor() public { constructor() public {
MinterRole.initialize(msg.sender); MinterRole.initialize(msg.sender);
} }
function removeMinter(address account) public { function removeMinter(address account) public {
_removeMinter(account); _removeMinter(account);
} }
function onlyMinterMock() public view onlyMinter { function onlyMinterMock() public view onlyMinter {
} }
// Causes a compilation error if super._removeMinter is not internal // Causes a compilation error if super._removeMinter is not internal
function _removeMinter(address account) internal { function _removeMinter(address account) internal {
super._removeMinter(account); super._removeMinter(account);
} }
} }
...@@ -3,7 +3,7 @@ pragma solidity ^0.4.24; ...@@ -3,7 +3,7 @@ pragma solidity ^0.4.24;
import { Ownable } from "../ownership/Ownable.sol"; import { Ownable } from "../ownership/Ownable.sol";
contract OwnableMock is Ownable { contract OwnableMock is Ownable {
constructor() { constructor() {
Ownable.initialize(msg.sender); Ownable.initialize(msg.sender);
} }
} }
...@@ -6,22 +6,22 @@ import "./PauserRoleMock.sol"; ...@@ -6,22 +6,22 @@ import "./PauserRoleMock.sol";
// mock class using Pausable // mock class using Pausable
contract PausableMock is Pausable, PauserRoleMock { contract PausableMock is Pausable, PauserRoleMock {
bool public drasticMeasureTaken; bool public drasticMeasureTaken;
uint256 public count; uint256 public count;
constructor() public { constructor() public {
Pausable.initialize(msg.sender); Pausable.initialize(msg.sender);
drasticMeasureTaken = false; drasticMeasureTaken = false;
count = 0; count = 0;
} }
function normalProcess() external whenNotPaused { function normalProcess() external whenNotPaused {
count++; count++;
} }
function drasticMeasure() external whenPaused { function drasticMeasure() external whenPaused {
drasticMeasureTaken = true; drasticMeasureTaken = true;
} }
} }
...@@ -4,19 +4,19 @@ import "../access/roles/PauserRole.sol"; ...@@ -4,19 +4,19 @@ import "../access/roles/PauserRole.sol";
contract PauserRoleMock is PauserRole { contract PauserRoleMock is PauserRole {
constructor() public { constructor() public {
PauserRole.initialize(msg.sender); PauserRole.initialize(msg.sender);
} }
function removePauser(address account) public { function removePauser(address account) public {
_removePauser(account); _removePauser(account);
} }
function onlyPauserMock() public view onlyPauser { function onlyPauserMock() public view onlyPauser {
} }
// Causes a compilation error if super._removePauser is not internal // Causes a compilation error if super._removePauser is not internal
function _removePauser(address account) internal { function _removePauser(address account) internal {
super._removePauser(account); super._removePauser(account);
} }
} }
...@@ -6,17 +6,17 @@ import "../crowdsale/distribution/PostDeliveryCrowdsale.sol"; ...@@ -6,17 +6,17 @@ import "../crowdsale/distribution/PostDeliveryCrowdsale.sol";
contract PostDeliveryCrowdsaleImpl is PostDeliveryCrowdsale { contract PostDeliveryCrowdsaleImpl is PostDeliveryCrowdsale {
constructor ( constructor (
uint256 openingTime, uint256 openingTime,
uint256 closingTime, uint256 closingTime,
uint256 rate, uint256 rate,
address wallet, address wallet,
IERC20 token IERC20 token
) )
public public
{ {
Crowdsale.initialize(rate, wallet, token); Crowdsale.initialize(rate, wallet, token);
TimedCrowdsale.initialize(openingTime, closingTime); TimedCrowdsale.initialize(openingTime, closingTime);
} }
} }
...@@ -7,13 +7,13 @@ import "../payment/PullPayment.sol"; ...@@ -7,13 +7,13 @@ import "../payment/PullPayment.sol";
// mock class using PullPayment // mock class using PullPayment
contract PullPaymentMock is PullPayment { contract PullPaymentMock is PullPayment {
constructor() public payable { constructor() public payable {
PullPayment.initialize(); PullPayment.initialize();
} }
// test helper function to call asyncTransfer // test helper function to call asyncTransfer
function callTransfer(address dest, uint256 amount) public { function callTransfer(address dest, uint256 amount) public {
_asyncTransfer(dest, amount); _asyncTransfer(dest, amount);
} }
} }
...@@ -3,9 +3,9 @@ pragma solidity ^0.4.24; ...@@ -3,9 +3,9 @@ pragma solidity ^0.4.24;
contract ReentrancyAttack { contract ReentrancyAttack {
function callSender(bytes4 data) public { function callSender(bytes4 data) public {
// solium-disable-next-line security/no-low-level-calls // solium-disable-next-line security/no-low-level-calls
require(msg.sender.call(abi.encodeWithSelector(data))); require(msg.sender.call(abi.encodeWithSelector(data)));
} }
} }
...@@ -6,41 +6,41 @@ import "./ReentrancyAttack.sol"; ...@@ -6,41 +6,41 @@ import "./ReentrancyAttack.sol";
contract ReentrancyMock is ReentrancyGuard { contract ReentrancyMock is ReentrancyGuard {
uint256 public counter; uint256 public counter;
constructor() public { constructor() public {
ReentrancyGuard.initialize(); ReentrancyGuard.initialize();
counter = 0; counter = 0;
} }
function callback() external nonReentrant { function callback() external nonReentrant {
count(); count();
} }
function countLocalRecursive(uint256 n) public nonReentrant { function countLocalRecursive(uint256 n) public nonReentrant {
if (n > 0) { if (n > 0) {
count(); count();
countLocalRecursive(n - 1); countLocalRecursive(n - 1);
}
} }
}
function countThisRecursive(uint256 n) public nonReentrant {
function countThisRecursive(uint256 n) public nonReentrant { if (n > 0) {
if (n > 0) { count();
count(); // solium-disable-next-line security/no-low-level-calls
// solium-disable-next-line security/no-low-level-calls bool result = address(this).call(abi.encodeWithSignature("countThisRecursive(uint256)", n - 1));
bool result = address(this).call(abi.encodeWithSignature("countThisRecursive(uint256)", n - 1)); require(result == true);
require(result == true); }
} }
}
function countAndCall(ReentrancyAttack attacker) public nonReentrant { function countAndCall(ReentrancyAttack attacker) public nonReentrant {
count(); count();
bytes4 func = bytes4(keccak256("callback()")); bytes4 func = bytes4(keccak256("callback()"));
attacker.callSender(func); attacker.callSender(func);
} }
function count() private { function count() private {
counter += 1; counter += 1;
} }
} }
...@@ -3,7 +3,7 @@ pragma solidity ^0.4.24; ...@@ -3,7 +3,7 @@ pragma solidity ^0.4.24;
import "../payment/RefundEscrow.sol"; import "../payment/RefundEscrow.sol";
contract RefundEscrowMock is RefundEscrow { contract RefundEscrowMock is RefundEscrow {
constructor(address beneficiary) public { constructor(address beneficiary) public {
RefundEscrow.initialize(beneficiary, msg.sender); RefundEscrow.initialize(beneficiary, msg.sender);
} }
} }
...@@ -6,19 +6,19 @@ import "../crowdsale/distribution/RefundableCrowdsale.sol"; ...@@ -6,19 +6,19 @@ import "../crowdsale/distribution/RefundableCrowdsale.sol";
contract RefundableCrowdsaleImpl is Crowdsale, TimedCrowdsale, RefundableCrowdsale { contract RefundableCrowdsaleImpl is Crowdsale, TimedCrowdsale, RefundableCrowdsale {
constructor ( constructor (
uint256 openingTime, uint256 openingTime,
uint256 closingTime, uint256 closingTime,
uint256 rate, uint256 rate,
address wallet, address wallet,
ERC20Mintable token, ERC20Mintable token,
uint256 goal uint256 goal
) )
public public
{ {
Crowdsale.initialize(rate, wallet, token); Crowdsale.initialize(rate, wallet, token);
TimedCrowdsale.initialize(openingTime, closingTime); TimedCrowdsale.initialize(openingTime, closingTime);
RefundableCrowdsale.initialize(goal); RefundableCrowdsale.initialize(goal);
} }
} }
...@@ -4,19 +4,19 @@ import "../access/Roles.sol"; ...@@ -4,19 +4,19 @@ import "../access/Roles.sol";
contract RolesMock { contract RolesMock {
using Roles for Roles.Role; using Roles for Roles.Role;
Roles.Role private dummyRole; Roles.Role private dummyRole;
function add(address account) public { function add(address account) public {
dummyRole.add(account); dummyRole.add(account);
} }
function remove(address account) public { function remove(address account) public {
dummyRole.remove(account); dummyRole.remove(account);
} }
function has(address account) public view returns (bool) { function has(address account) public view returns (bool) {
return dummyRole.has(account); return dummyRole.has(account);
} }
} }
...@@ -5,91 +5,91 @@ import "../token/ERC20/SafeERC20.sol"; ...@@ -5,91 +5,91 @@ import "../token/ERC20/SafeERC20.sol";
contract ERC20FailingMock is IERC20 { contract ERC20FailingMock is IERC20 {
function totalSupply() public view returns (uint256) { function totalSupply() public view returns (uint256) {
return 0; return 0;
} }
function transfer(address, uint256) public returns (bool) { function transfer(address, uint256) public returns (bool) {
return false; return false;
} }
function transferFrom(address, address, uint256) public returns (bool) { function transferFrom(address, address, uint256) public returns (bool) {
return false; return false;
} }
function approve(address, uint256) public returns (bool) { function approve(address, uint256) public returns (bool) {
return false; return false;
} }
function balanceOf(address) public view returns (uint256) { function balanceOf(address) public view returns (uint256) {
return 0; return 0;
} }
function allowance(address, address) public view returns (uint256) { function allowance(address, address) public view returns (uint256) {
return 0; return 0;
} }
} }
contract ERC20SucceedingMock is IERC20 { contract ERC20SucceedingMock is IERC20 {
function totalSupply() public view returns (uint256) { function totalSupply() public view returns (uint256) {
return 0; return 0;
} }
function transfer(address, uint256) public returns (bool) { function transfer(address, uint256) public returns (bool) {
return true; return true;
} }
function transferFrom(address, address, uint256) public returns (bool) { function transferFrom(address, address, uint256) public returns (bool) {
return true; return true;
} }
function approve(address, uint256) public returns (bool) { function approve(address, uint256) public returns (bool) {
return true; return true;
} }
function balanceOf(address) public view returns (uint256) { function balanceOf(address) public view returns (uint256) {
return 0; return 0;
} }
function allowance(address, address) public view returns (uint256) { function allowance(address, address) public view returns (uint256) {
return 0; return 0;
} }
} }
contract SafeERC20Helper { contract SafeERC20Helper {
using SafeERC20 for IERC20; using SafeERC20 for IERC20;
IERC20 private _failing; IERC20 private _failing;
IERC20 private _succeeding; IERC20 private _succeeding;
constructor() public { constructor() public {
_failing = new ERC20FailingMock(); _failing = new ERC20FailingMock();
_succeeding = new ERC20SucceedingMock(); _succeeding = new ERC20SucceedingMock();
} }
function doFailingTransfer() public { function doFailingTransfer() public {
_failing.safeTransfer(address(0), 0); _failing.safeTransfer(address(0), 0);
} }
function doFailingTransferFrom() public { function doFailingTransferFrom() public {
_failing.safeTransferFrom(address(0), address(0), 0); _failing.safeTransferFrom(address(0), address(0), 0);
} }
function doFailingApprove() public { function doFailingApprove() public {
_failing.safeApprove(address(0), 0); _failing.safeApprove(address(0), 0);
} }
function doSucceedingTransfer() public { function doSucceedingTransfer() public {
_succeeding.safeTransfer(address(0), 0); _succeeding.safeTransfer(address(0), 0);
} }
function doSucceedingTransferFrom() public { function doSucceedingTransferFrom() public {
_succeeding.safeTransferFrom(address(0), address(0), 0); _succeeding.safeTransferFrom(address(0), address(0), 0);
} }
function doSucceedingApprove() public { function doSucceedingApprove() public {
_succeeding.safeApprove(address(0), 0); _succeeding.safeApprove(address(0), 0);
} }
} }
...@@ -6,23 +6,23 @@ import "../math/SafeMath.sol"; ...@@ -6,23 +6,23 @@ import "../math/SafeMath.sol";
contract SafeMathMock { contract SafeMathMock {
function mul(uint256 a, uint256 b) public pure returns (uint256) { function mul(uint256 a, uint256 b) public pure returns (uint256) {
return SafeMath.mul(a, b); return SafeMath.mul(a, b);
} }
function div(uint256 a, uint256 b) public pure returns (uint256) { function div(uint256 a, uint256 b) public pure returns (uint256) {
return SafeMath.div(a, b); return SafeMath.div(a, b);
} }
function sub(uint256 a, uint256 b) public pure returns (uint256) { function sub(uint256 a, uint256 b) public pure returns (uint256) {
return SafeMath.sub(a, b); return SafeMath.sub(a, b);
} }
function add(uint256 a, uint256 b) public pure returns (uint256) { function add(uint256 a, uint256 b) public pure returns (uint256) {
return SafeMath.add(a, b); return SafeMath.add(a, b);
} }
function mod(uint256 a, uint256 b) public pure returns (uint256) { function mod(uint256 a, uint256 b) public pure returns (uint256) {
return SafeMath.mod(a, b); return SafeMath.mod(a, b);
} }
} }
...@@ -4,23 +4,23 @@ import "../examples/SampleCrowdsale.sol"; ...@@ -4,23 +4,23 @@ import "../examples/SampleCrowdsale.sol";
contract SampleCrowdsaleTokenMock is SampleCrowdsaleToken { contract SampleCrowdsaleTokenMock is SampleCrowdsaleToken {
constructor() public { constructor() public {
SampleCrowdsaleToken.initialize(msg.sender); SampleCrowdsaleToken.initialize(msg.sender);
} }
} }
contract SampleCrowdsaleMock is SampleCrowdsale { contract SampleCrowdsaleMock is SampleCrowdsale {
constructor( constructor(
uint256 openingTime, uint256 openingTime,
uint256 closingTime, uint256 closingTime,
uint256 rate, uint256 rate,
address wallet, address wallet,
uint256 cap, uint256 cap,
ERC20Mintable token, ERC20Mintable token,
uint256 goal uint256 goal
) )
public public
{ {
SampleCrowdsale.initialize(openingTime, closingTime, rate, wallet, cap, token, goal); SampleCrowdsale.initialize(openingTime, closingTime, rate, wallet, cap, token, goal);
} }
} }
...@@ -4,10 +4,10 @@ import "../ownership/Secondary.sol"; ...@@ -4,10 +4,10 @@ import "../ownership/Secondary.sol";
contract SecondaryMock is Secondary { contract SecondaryMock is Secondary {
constructor() public { constructor() public {
Secondary.initialize(msg.sender); Secondary.initialize(msg.sender);
} }
function onlyPrimaryMock() public view onlyPrimary { function onlyPrimaryMock() public view onlyPrimary {
} }
} }
...@@ -5,74 +5,74 @@ import "./SignerRoleMock.sol"; ...@@ -5,74 +5,74 @@ import "./SignerRoleMock.sol";
contract SignatureBouncerMock is SignatureBouncer, SignerRoleMock { contract SignatureBouncerMock is SignatureBouncer, SignerRoleMock {
constructor() public { constructor() public {
SignatureBouncer.initialize(msg.sender); SignatureBouncer.initialize(msg.sender);
} }
function checkValidSignature(address account, bytes signature) function checkValidSignature(address account, bytes signature)
public public
view view
returns (bool) returns (bool)
{ {
return _isValidSignature(account, signature); return _isValidSignature(account, signature);
} }
function onlyWithValidSignature(bytes signature) function onlyWithValidSignature(bytes signature)
public public
onlyValidSignature(signature) onlyValidSignature(signature)
view view
{ {
} }
function checkValidSignatureAndMethod(address account, bytes signature) function checkValidSignatureAndMethod(address account, bytes signature)
public public
view view
returns (bool) returns (bool)
{ {
return _isValidSignatureAndMethod(account, signature); return _isValidSignatureAndMethod(account, signature);
} }
function onlyWithValidSignatureAndMethod(bytes signature) function onlyWithValidSignatureAndMethod(bytes signature)
public public
onlyValidSignatureAndMethod(signature) onlyValidSignatureAndMethod(signature)
view view
{ {
} }
function checkValidSignatureAndData( function checkValidSignatureAndData(
address account, address account,
bytes, bytes,
uint, uint,
bytes signature bytes signature
) )
public public
view view
returns (bool) returns (bool)
{ {
return _isValidSignatureAndData(account, signature); return _isValidSignatureAndData(account, signature);
} }
function onlyWithValidSignatureAndData(uint, bytes signature) function onlyWithValidSignatureAndData(uint, bytes signature)
public public
onlyValidSignatureAndData(signature) onlyValidSignatureAndData(signature)
view view
{ {
} }
function theWrongMethod(bytes) function theWrongMethod(bytes)
public public
pure pure
{ {
} }
function tooShortMsgData() function tooShortMsgData()
public public
onlyValidSignatureAndData("") onlyValidSignatureAndData("")
view view
{ {
} }
} }
...@@ -4,19 +4,19 @@ import "../access/roles/SignerRole.sol"; ...@@ -4,19 +4,19 @@ import "../access/roles/SignerRole.sol";
contract SignerRoleMock is SignerRole { contract SignerRoleMock is SignerRole {
constructor() public { constructor() public {
SignerRole.initialize(msg.sender); SignerRole.initialize(msg.sender);
} }
function removeSigner(address account) public { function removeSigner(address account) public {
_removeSigner(account); _removeSigner(account);
} }
function onlySignerMock() public view onlySigner { function onlySignerMock() public view onlySigner {
} }
// Causes a compilation error if super._removeSigner is not internal // Causes a compilation error if super._removeSigner is not internal
function _removeSigner(address account) internal { function _removeSigner(address account) internal {
super._removeSigner(account); super._removeSigner(account);
} }
} }
...@@ -3,7 +3,7 @@ pragma solidity ^0.4.24; ...@@ -3,7 +3,7 @@ pragma solidity ^0.4.24;
import "../examples/SimpleToken.sol"; import "../examples/SimpleToken.sol";
contract SimpleTokenMock is SimpleToken { contract SimpleTokenMock is SimpleToken {
constructor() public { constructor() public {
SimpleToken.initialize(msg.sender); SimpleToken.initialize(msg.sender);
} }
} }
...@@ -3,7 +3,7 @@ pragma solidity ^0.4.24; ...@@ -3,7 +3,7 @@ pragma solidity ^0.4.24;
import "../payment/SplitPayment.sol"; import "../payment/SplitPayment.sol";
contract SplitPaymentMock is SplitPayment { contract SplitPaymentMock is SplitPayment {
constructor(address[] payees, uint256[] shares) public { constructor(address[] payees, uint256[] shares) public {
SplitPayment.initialize(payees, shares); SplitPayment.initialize(payees, shares);
} }
} }
...@@ -6,17 +6,17 @@ import "../crowdsale/validation/TimedCrowdsale.sol"; ...@@ -6,17 +6,17 @@ import "../crowdsale/validation/TimedCrowdsale.sol";
contract TimedCrowdsaleImpl is TimedCrowdsale { contract TimedCrowdsaleImpl is TimedCrowdsale {
constructor ( constructor (
uint256 openingTime, uint256 openingTime,
uint256 closingTime, uint256 closingTime,
uint256 rate, uint256 rate,
address wallet, address wallet,
IERC20 token IERC20 token
) )
public public
{ {
Crowdsale.initialize(rate, wallet, token); Crowdsale.initialize(rate, wallet, token);
TimedCrowdsale.initialize(openingTime, closingTime); TimedCrowdsale.initialize(openingTime, closingTime);
} }
} }
...@@ -3,11 +3,11 @@ pragma solidity ^0.4.24; ...@@ -3,11 +3,11 @@ pragma solidity ^0.4.24;
import "../token/ERC20/TokenTimelock.sol"; import "../token/ERC20/TokenTimelock.sol";
contract TokenTimelockMock is TokenTimelock { contract TokenTimelockMock is TokenTimelock {
constructor( constructor(
IERC20 token, IERC20 token,
address beneficiary, address beneficiary,
uint256 releaseTime uint256 releaseTime
) public { ) public {
TokenTimelock.initialize(token, beneficiary, releaseTime); TokenTimelock.initialize(token, beneficiary, releaseTime);
} }
} }
...@@ -3,20 +3,20 @@ pragma solidity ^0.4.24; ...@@ -3,20 +3,20 @@ pragma solidity ^0.4.24;
import "../drafts/TokenVesting.sol"; import "../drafts/TokenVesting.sol";
contract TokenVestingMock is TokenVesting { contract TokenVestingMock is TokenVesting {
constructor( constructor(
address beneficiary, address beneficiary,
uint256 start, uint256 start,
uint256 cliffDuration, uint256 cliffDuration,
uint256 duration, uint256 duration,
bool revocable bool revocable
) public { ) public {
TokenVesting.initialize( TokenVesting.initialize(
beneficiary, beneficiary,
start, start,
cliffDuration, cliffDuration,
duration, duration,
revocable, revocable,
msg.sender msg.sender
); );
} }
} }
...@@ -8,74 +8,74 @@ import "zos-lib/contracts/Initializable.sol"; ...@@ -8,74 +8,74 @@ import "zos-lib/contracts/Initializable.sol";
* functions, this simplifies the implementation of "user permissions". * functions, this simplifies the implementation of "user permissions".
*/ */
contract Ownable is Initializable { contract Ownable is Initializable {
address private _owner; address private _owner;
event OwnershipRenounced(address indexed previousOwner); event OwnershipRenounced(address indexed previousOwner);
event OwnershipTransferred( event OwnershipTransferred(
address indexed previousOwner, address indexed previousOwner,
address indexed newOwner address indexed newOwner
); );
/** /**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender * @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account. * account.
*/ */
function initialize(address sender) public initializer { function initialize(address sender) public initializer {
_owner = sender; _owner = sender;
} }
/** /**
* @return the address of the owner. * @return the address of the owner.
*/ */
function owner() public view returns(address) { function owner() public view returns(address) {
return _owner; return _owner;
} }
/** /**
* @dev Throws if called by any account other than the owner. * @dev Throws if called by any account other than the owner.
*/ */
modifier onlyOwner() { modifier onlyOwner() {
require(isOwner()); require(isOwner());
_; _;
} }
/** /**
* @return true if `msg.sender` is the owner of the contract. * @return true if `msg.sender` is the owner of the contract.
*/ */
function isOwner() public view returns(bool) { function isOwner() public view returns(bool) {
return msg.sender == _owner; return msg.sender == _owner;
} }
/** /**
* @dev Allows the current owner to relinquish control of the contract. * @dev Allows the current owner to relinquish control of the contract.
* @notice Renouncing to ownership will leave the contract without an owner. * @notice Renouncing to ownership will leave the contract without an owner.
* It will not be possible to call the functions with the `onlyOwner` * It will not be possible to call the functions with the `onlyOwner`
* modifier anymore. * modifier anymore.
*/ */
function renounceOwnership() public onlyOwner { function renounceOwnership() public onlyOwner {
emit OwnershipRenounced(_owner); emit OwnershipRenounced(_owner);
_owner = address(0); _owner = address(0);
} }
/** /**
* @dev Allows the current owner to transfer control of the contract to a newOwner. * @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to. * @param newOwner The address to transfer ownership to.
*/ */
function transferOwnership(address newOwner) public onlyOwner { function transferOwnership(address newOwner) public onlyOwner {
_transferOwnership(newOwner); _transferOwnership(newOwner);
} }
/** /**
* @dev Transfers control of the contract to a newOwner. * @dev Transfers control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to. * @param newOwner The address to transfer ownership to.
*/ */
function _transferOwnership(address newOwner) internal { function _transferOwnership(address newOwner) internal {
require(newOwner != address(0)); require(newOwner != address(0));
emit OwnershipTransferred(_owner, newOwner); emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner; _owner = newOwner;
} }
uint256[50] private ______gap; uint256[50] private ______gap;
} }
...@@ -7,32 +7,32 @@ import "zos-lib/contracts/Initializable.sol"; ...@@ -7,32 +7,32 @@ import "zos-lib/contracts/Initializable.sol";
* @dev A Secondary contract can only be used by its primary account (the one that created it) * @dev A Secondary contract can only be used by its primary account (the one that created it)
*/ */
contract Secondary is Initializable { contract Secondary is Initializable {
address private _primary; address private _primary;
/** /**
* @dev Sets the primary account to the one that is creating the Secondary contract. * @dev Sets the primary account to the one that is creating the Secondary contract.
*/ */
function initialize(address sender) public initializer { function initialize(address sender) public initializer {
_primary = sender; _primary = sender;
} }
/** /**
* @dev Reverts if called from any account other than the primary. * @dev Reverts if called from any account other than the primary.
*/ */
modifier onlyPrimary() { modifier onlyPrimary() {
require(msg.sender == _primary); require(msg.sender == _primary);
_; _;
} }
function primary() public view returns (address) { function primary() public view returns (address) {
return _primary; return _primary;
} }
function transferPrimary(address recipient) public onlyPrimary { function transferPrimary(address recipient) public onlyPrimary {
require(recipient != address(0)); require(recipient != address(0));
_primary = recipient; _primary = recipient;
} }
uint256[50] private ______gap; uint256[50] private ______gap;
} }
...@@ -9,21 +9,21 @@ import "./Escrow.sol"; ...@@ -9,21 +9,21 @@ import "./Escrow.sol";
* @dev Base abstract escrow to only allow withdrawal if a condition is met. * @dev Base abstract escrow to only allow withdrawal if a condition is met.
*/ */
contract ConditionalEscrow is Initializable, Escrow { contract ConditionalEscrow is Initializable, Escrow {
function initialize(address sender) public initializer { function initialize(address sender) public initializer {
Escrow.initialize(sender); Escrow.initialize(sender);
} }
/** /**
* @dev Returns whether an address is allowed to withdraw their funds. To be * @dev Returns whether an address is allowed to withdraw their funds. To be
* implemented by derived contracts. * implemented by derived contracts.
* @param payee The destination address of the funds. * @param payee The destination address of the funds.
*/ */
function withdrawalAllowed(address payee) public view returns (bool); function withdrawalAllowed(address payee) public view returns (bool);
function withdraw(address payee) public { function withdraw(address payee) public {
require(withdrawalAllowed(payee)); require(withdrawalAllowed(payee));
super.withdraw(payee); super.withdraw(payee);
} }
uint256[50] private ______gap; uint256[50] private ______gap;
} }
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