Commit bce2d68e by Francisco Giordano

convert 2 spaces to 4 spaces

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