Commit e5b94c14 by Nicolás Venturo

Merge branch 'release-v2.1.0'

parents 14a59b29 79145fa5
{
"extends": "default",
"rules": {
"indent": ["error", 4],
"bracket-align": false,
"compiler-fixed": false,
"no-simple-event-func-name": false,
"two-lines-top-level-separator": false
}
}
{
"extends": "solium:all",
"plugins": ["security"],
"rules": {
"arg-overflow": "off",
"blank-lines": "off",
"error-reason": "off",
"indentation": ["error", 4],
"lbrace": "off",
"linebreak-style": ["error", "unix"],
"max-len": ["error", 120],
"no-constant": ["error"],
"no-empty-blocks": "off",
"quotes": ["error", "double"],
"uppercase": "off",
"visibility-first": "error",
"security/enforce-explicit-visibility": ["error"],
"security/no-block-members": ["warning"],
"security/no-inline-assembly": ["warning"]
}
}
...@@ -25,10 +25,11 @@ jobs: ...@@ -25,10 +25,11 @@ jobs:
name: "Unit tests" name: "Unit tests"
script: npm run test script: npm run test
- stage: tests # solidity-coverage fails at parsing 0.5.x code
name: "Unit tests with coverage report" # - stage: tests
script: npm run test # name: "Unit tests with coverage report"
env: SOLIDITY_COVERAGE=true # script: npm run test
# env: SOLIDITY_COVERAGE=true
- stage: tests - stage: tests
name: "Unit tests using solc nightly" name: "Unit tests using solc nightly"
......
# Changelog # Changelog
## 2.1.0 (unreleased) ## 2.2.0 (unreleased)
## 2.1.1 (2019-04-01)
* Version bump to avoid conflict in the npm registry.
## 2.1.0 (2019-04-01)
### New features: ### New features:
* `WhitelistCrowdsale`: a crowdsale where only whitelisted accounts (`WhitelistedRole`) can purchase tokens. Adding or removing accounts from the whitelist is done by whitelisters (`WhitelisterRole`). Similar to the pre-2.0 `WhitelistedCrowdsale`. ([#1525](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1525)) * Now targeting the 0.5.x line of Solidity compilers. For 0.4.24 support, use version 2.0 of OpenZeppelin.
* `WhitelistCrowdsale`: a crowdsale where only whitelisted accounts (`WhitelistedRole`) can purchase tokens. Adding or removing accounts from the whitelist is done by whitelist admins (`WhitelistAdminRole`). Similar to the pre-2.0 `WhitelistedCrowdsale`. ([#1525](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1525), [#1589](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1589))
* `RefundablePostDeliveryCrowdsale`: replacement for `RefundableCrowdsale` (deprecated, see below) where tokens are only granted once the crowdsale ends (if it meets its goal). ([#1543](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1543)) * `RefundablePostDeliveryCrowdsale`: replacement for `RefundableCrowdsale` (deprecated, see below) where tokens are only granted once the crowdsale ends (if it meets its goal). ([#1543](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1543))
* `PausableCrowdsale`: allows for pausers (`PauserRole`) to pause token purchases. Other crowdsale operations (e.g. withdrawals and refunds, if applicable) are not affected. ([#832](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/832)) * `PausableCrowdsale`: allows for pausers (`PauserRole`) to pause token purchases. Other crowdsale operations (e.g. withdrawals and refunds, if applicable) are not affected. ([#832](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/832))
* `ERC20`: `transferFrom` and `_burnFrom ` now emit `Approval` events, to represent the token's state comprehensively through events. ([#1524](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1524)) * `ERC20`: `transferFrom` and `_burnFrom ` now emit `Approval` events, to represent the token's state comprehensively through events. ([#1524](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1524))
* `ERC721`: added `_burn(uint256 tokenId)`, replacing the similar deprecated function (see below). ([#1550](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1550)) * `ERC721`: added `_burn(uint256 tokenId)`, replacing the similar deprecated function (see below). ([#1550](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1550))
* `ERC721`: added `_tokensOfOwner(address owner)`, allowing to internally retrieve the array of an account's owned tokens. ([#1522](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1522)) * `ERC721`: added `_tokensOfOwner(address owner)`, allowing to internally retrieve the array of an account's owned tokens. ([#1522](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1522))
* Crowdsales: all constructors are now `public`, meaning it is not necessary to extend these contracts in order to deploy them. The exception is `FinalizableCrowdsale`, since it is meaningless unless extended. ([#1564](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1564)) * Crowdsales: all constructors are now `public`, meaning it is not necessary to extend these contracts in order to deploy them. The exception is `FinalizableCrowdsale`, since it is meaningless unless extended. ([#1564](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1564))
* `SafeMath`: added overflow-safe operations for signed integers (`int256`). ([#1559](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1559)) * `SignedSafeMath`: added overflow-safe operations for signed integers (`int256`). ([#1559](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1559), [#1588](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1588))
### Improvements: ### Improvements:
* The compiler version required by `Array` was behind the rest of the libray so it was updated to `v0.4.24`. ([#1553](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1553)) * The compiler version required by `Array` was behind the rest of the libray so it was updated to `v0.4.24`. ([#1553](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1553))
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
/** /**
* @title Roles * @title Roles
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../Roles.sol"; import "../Roles.sol";
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../Roles.sol"; import "../Roles.sol";
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../Roles.sol"; import "../Roles.sol";
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../Roles.sol"; import "../Roles.sol";
......
pragma solidity ^0.5.0;
import "../Roles.sol";
/**
* @title WhitelistAdminRole
* @dev WhitelistAdmins are responsible for assigning and removing Whitelisted accounts.
*/
contract WhitelistAdminRole {
using Roles for Roles.Role;
event WhitelistAdminAdded(address indexed account);
event WhitelistAdminRemoved(address indexed account);
Roles.Role private _whitelistAdmins;
constructor () internal {
_addWhitelistAdmin(msg.sender);
}
modifier onlyWhitelistAdmin() {
require(isWhitelistAdmin(msg.sender));
_;
}
function isWhitelistAdmin(address account) public view returns (bool) {
return _whitelistAdmins.has(account);
}
function addWhitelistAdmin(address account) public onlyWhitelistAdmin {
_addWhitelistAdmin(account);
}
function renounceWhitelistAdmin() public {
_removeWhitelistAdmin(msg.sender);
}
function _addWhitelistAdmin(address account) internal {
_whitelistAdmins.add(account);
emit WhitelistAdminAdded(account);
}
function _removeWhitelistAdmin(address account) internal {
_whitelistAdmins.remove(account);
emit WhitelistAdminRemoved(account);
}
}
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../Roles.sol"; import "../Roles.sol";
import "./WhitelisterRole.sol"; import "./WhitelistAdminRole.sol";
/** /**
* @title WhitelistedRole * @title WhitelistedRole
* @dev Whitelisted accounts have been approved by a Whitelister to perform certain actions (e.g. participate in a * @dev Whitelisted accounts have been approved by a WhitelistAdmin to perform certain actions (e.g. participate in a
* crowdsale). This role is special in that the only accounts that can add it are Whitelisters (who can also remove it), * crowdsale). This role is special in that the only accounts that can add it are WhitelistAdmins (who can also remove
* and not Whitelisteds themselves. * it), and not Whitelisteds themselves.
*/ */
contract WhitelistedRole is WhitelisterRole { contract WhitelistedRole is WhitelistAdminRole {
using Roles for Roles.Role; using Roles for Roles.Role;
event WhitelistedAdded(address indexed account); event WhitelistedAdded(address indexed account);
...@@ -26,11 +26,11 @@ contract WhitelistedRole is WhitelisterRole { ...@@ -26,11 +26,11 @@ contract WhitelistedRole is WhitelisterRole {
return _whitelisteds.has(account); return _whitelisteds.has(account);
} }
function addWhitelisted(address account) public onlyWhitelister { function addWhitelisted(address account) public onlyWhitelistAdmin {
_addWhitelisted(account); _addWhitelisted(account);
} }
function removeWhitelisted(address account) public onlyWhitelister { function removeWhitelisted(address account) public onlyWhitelistAdmin {
_removeWhitelisted(account); _removeWhitelisted(account);
} }
......
pragma solidity ^0.4.24;
import "../Roles.sol";
/**
* @title WhitelisterRole
* @dev Whitelisters are responsible for assigning and removing Whitelisted accounts.
*/
contract WhitelisterRole {
using Roles for Roles.Role;
event WhitelisterAdded(address indexed account);
event WhitelisterRemoved(address indexed account);
Roles.Role private _whitelisters;
constructor () internal {
_addWhitelister(msg.sender);
}
modifier onlyWhitelister() {
require(isWhitelister(msg.sender));
_;
}
function isWhitelister(address account) public view returns (bool) {
return _whitelisters.has(account);
}
function addWhitelister(address account) public onlyWhitelister {
_addWhitelister(account);
}
function renounceWhitelister() public {
_removeWhitelister(msg.sender);
}
function _addWhitelister(address account) internal {
_whitelisters.add(account);
emit WhitelisterAdded(account);
}
function _removeWhitelister(address account) internal {
_whitelisters.remove(account);
emit WhitelisterRemoved(account);
}
}
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../token/ERC20/IERC20.sol"; import "../token/ERC20/IERC20.sol";
import "../math/SafeMath.sol"; import "../math/SafeMath.sol";
...@@ -25,7 +25,7 @@ contract Crowdsale is ReentrancyGuard { ...@@ -25,7 +25,7 @@ contract Crowdsale is ReentrancyGuard {
IERC20 private _token; IERC20 private _token;
// Address where funds are collected // Address where funds are collected
address private _wallet; address payable private _wallet;
// How many token units a buyer gets per wei. // How many token units a buyer gets per wei.
// The rate is the conversion between wei and the smallest and indivisible token unit. // The rate is the conversion between wei and the smallest and indivisible token unit.
...@@ -53,20 +53,16 @@ contract Crowdsale is ReentrancyGuard { ...@@ -53,20 +53,16 @@ contract Crowdsale is ReentrancyGuard {
* @param wallet Address where collected funds will be forwarded to * @param wallet Address where collected funds will be forwarded to
* @param token Address of the token being sold * @param token Address of the token being sold
*/ */
constructor (uint256 rate, address wallet, IERC20 token) public { constructor (uint256 rate, address payable wallet, IERC20 token) public {
require(rate > 0); require(rate > 0);
require(wallet != address(0)); require(wallet != address(0));
require(token != address(0)); require(address(token) != address(0));
_rate = rate; _rate = rate;
_wallet = wallet; _wallet = wallet;
_token = token; _token = token;
} }
// -----------------------------------------
// Crowdsale external interface
// -----------------------------------------
/** /**
* @dev fallback function ***DO NOT OVERRIDE*** * @dev fallback function ***DO NOT OVERRIDE***
* Note that other contracts will transfer fund with a base gas stipend * Note that other contracts will transfer fund with a base gas stipend
...@@ -87,7 +83,7 @@ contract Crowdsale is ReentrancyGuard { ...@@ -87,7 +83,7 @@ contract Crowdsale is ReentrancyGuard {
/** /**
* @return the address where funds are collected. * @return the address where funds are collected.
*/ */
function wallet() public view returns (address) { function wallet() public view returns (address payable) {
return _wallet; return _wallet;
} }
...@@ -130,12 +126,9 @@ contract Crowdsale is ReentrancyGuard { ...@@ -130,12 +126,9 @@ contract Crowdsale is ReentrancyGuard {
_postValidatePurchase(beneficiary, weiAmount); _postValidatePurchase(beneficiary, weiAmount);
} }
// -----------------------------------------
// Internal interface (extensible)
// -----------------------------------------
/** /**
* @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use `super` in contracts that inherit from Crowdsale to extend their validations. * @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met.
* Use `super` in contracts that inherit from Crowdsale to extend their validations.
* Example from CappedCrowdsale.sol's _preValidatePurchase method: * Example from CappedCrowdsale.sol's _preValidatePurchase method:
* super._preValidatePurchase(beneficiary, weiAmount); * super._preValidatePurchase(beneficiary, weiAmount);
* require(weiRaised().add(weiAmount) <= cap); * require(weiRaised().add(weiAmount) <= cap);
...@@ -148,16 +141,18 @@ contract Crowdsale is ReentrancyGuard { ...@@ -148,16 +141,18 @@ contract Crowdsale is ReentrancyGuard {
} }
/** /**
* @dev Validation of an executed purchase. Observe state and use revert statements to undo rollback when valid conditions are not met. * @dev Validation of an executed purchase. Observe state and use revert statements to undo rollback when valid
* conditions are not met.
* @param beneficiary Address performing the token purchase * @param beneficiary Address performing the token purchase
* @param weiAmount Value in wei involved in the purchase * @param weiAmount Value in wei involved in the purchase
*/ */
function _postValidatePurchase(address beneficiary, uint256 weiAmount) internal view { function _postValidatePurchase(address beneficiary, uint256 weiAmount) internal view {
// optional override // solhint-disable-previous-line no-empty-blocks
} }
/** /**
* @dev Source of tokens. Override this method to modify the way in which the crowdsale ultimately gets and sends its tokens. * @dev Source of tokens. Override this method to modify the way in which the crowdsale ultimately gets and sends
* its tokens.
* @param beneficiary Address performing the token purchase * @param beneficiary Address performing the token purchase
* @param tokenAmount Number of tokens to be emitted * @param tokenAmount Number of tokens to be emitted
*/ */
...@@ -166,7 +161,8 @@ contract Crowdsale is ReentrancyGuard { ...@@ -166,7 +161,8 @@ contract Crowdsale is ReentrancyGuard {
} }
/** /**
* @dev Executed when a purchase has been validated and is ready to be executed. Doesn't necessarily emit/send tokens. * @dev Executed when a purchase has been validated and is ready to be executed. Doesn't necessarily emit/send
* tokens.
* @param beneficiary Address receiving the tokens * @param beneficiary Address receiving the tokens
* @param tokenAmount Number of tokens to be purchased * @param tokenAmount Number of tokens to be purchased
*/ */
...@@ -175,12 +171,13 @@ contract Crowdsale is ReentrancyGuard { ...@@ -175,12 +171,13 @@ contract Crowdsale is ReentrancyGuard {
} }
/** /**
* @dev Override for extensions that require an internal state to check for validity (current user contributions, etc.) * @dev Override for extensions that require an internal state to check for validity (current user contributions,
* etc.)
* @param beneficiary Address receiving the tokens * @param beneficiary Address receiving the tokens
* @param weiAmount Value in wei involved in the purchase * @param weiAmount Value in wei involved in the purchase
*/ */
function _updatePurchasingState(address beneficiary, uint256 weiAmount) internal { function _updatePurchasingState(address beneficiary, uint256 weiAmount) internal {
// optional override // solhint-disable-previous-line no-empty-blocks
} }
/** /**
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../../math/SafeMath.sol"; import "../../math/SafeMath.sol";
import "../validation/TimedCrowdsale.sol"; import "../validation/TimedCrowdsale.sol";
...@@ -45,5 +45,7 @@ contract FinalizableCrowdsale is TimedCrowdsale { ...@@ -45,5 +45,7 @@ contract FinalizableCrowdsale is TimedCrowdsale {
* should call super._finalization() to ensure the chain of finalization is * should call super._finalization() to ensure the chain of finalization is
* executed entirely. * executed entirely.
*/ */
function _finalization() internal {} function _finalization() internal {
// solhint-disable-previous-line no-empty-blocks
}
} }
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../validation/TimedCrowdsale.sol"; import "../validation/TimedCrowdsale.sol";
import "../../math/SafeMath.sol"; import "../../math/SafeMath.sol";
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../../math/SafeMath.sol"; import "../../math/SafeMath.sol";
import "./FinalizableCrowdsale.sol"; import "./FinalizableCrowdsale.sol";
...@@ -44,7 +44,7 @@ contract RefundableCrowdsale is FinalizableCrowdsale { ...@@ -44,7 +44,7 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
* @dev Investors can claim refunds here if crowdsale is unsuccessful * @dev Investors can claim refunds here if crowdsale is unsuccessful
* @param refundee Whose refund will be claimed. * @param refundee Whose refund will be claimed.
*/ */
function claimRefund(address refundee) public { function claimRefund(address payable refundee) public {
require(finalized()); require(finalized());
require(!goalReached()); require(!goalReached());
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "./RefundableCrowdsale.sol"; import "./RefundableCrowdsale.sol";
import "./PostDeliveryCrowdsale.sol"; import "./PostDeliveryCrowdsale.sol";
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../Crowdsale.sol"; import "../Crowdsale.sol";
import "../../token/ERC20/IERC20.sol"; import "../../token/ERC20/IERC20.sol";
...@@ -37,7 +37,7 @@ contract AllowanceCrowdsale is Crowdsale { ...@@ -37,7 +37,7 @@ contract AllowanceCrowdsale is Crowdsale {
* @return Amount of tokens left in the allowance * @return Amount of tokens left in the allowance
*/ */
function remainingTokens() public view returns (uint256) { function remainingTokens() public view returns (uint256) {
return Math.min(token().balanceOf(_tokenWallet), token().allowance(_tokenWallet, this)); return Math.min(token().balanceOf(_tokenWallet), token().allowance(_tokenWallet, address(this)));
} }
/** /**
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../Crowdsale.sol"; import "../Crowdsale.sol";
import "../../token/ERC20/ERC20Mintable.sol"; import "../../token/ERC20/ERC20Mintable.sol";
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../validation/TimedCrowdsale.sol"; import "../validation/TimedCrowdsale.sol";
import "../../math/SafeMath.sol"; import "../../math/SafeMath.sol";
...@@ -59,7 +59,7 @@ contract IncreasingPriceCrowdsale is TimedCrowdsale { ...@@ -59,7 +59,7 @@ contract IncreasingPriceCrowdsale is TimedCrowdsale {
return 0; return 0;
} }
// solium-disable-next-line security/no-block-members // solhint-disable-next-line not-rely-on-time
uint256 elapsedTime = block.timestamp.sub(openingTime()); uint256 elapsedTime = block.timestamp.sub(openingTime());
uint256 timeRange = closingTime().sub(openingTime()); uint256 timeRange = closingTime().sub(openingTime());
uint256 rateRange = _initialRate.sub(_finalRate); uint256 rateRange = _initialRate.sub(_finalRate);
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../../math/SafeMath.sol"; import "../../math/SafeMath.sol";
import "../Crowdsale.sol"; import "../Crowdsale.sol";
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../../math/SafeMath.sol"; import "../../math/SafeMath.sol";
import "../Crowdsale.sol"; import "../Crowdsale.sol";
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../Crowdsale.sol"; import "../Crowdsale.sol";
import "../../lifecycle/Pausable.sol"; import "../../lifecycle/Pausable.sol";
/** /**
* @title PausableCrowdsale * @title PausableCrowdsale
* @dev Extension of Crowdsale contract where purchases can be paused and unpaused by the pauser role. * @dev Extension of Crowdsale contract where purchases can be paused and unpaused by the pauser role.
*/ */
contract PausableCrowdsale is Crowdsale, Pausable { contract PausableCrowdsale is Crowdsale, Pausable {
/** /**
* @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use super to concatenate validations. * @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met.
* Use super to concatenate validations.
* Adds the validation that the crowdsale must not be paused. * Adds the validation that the crowdsale must not be paused.
* @param _beneficiary Address performing the token purchase * @param _beneficiary Address performing the token purchase
* @param _weiAmount Value in wei involved in the purchase * @param _weiAmount Value in wei involved in the purchase
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../../math/SafeMath.sol"; import "../../math/SafeMath.sol";
import "../Crowdsale.sol"; import "../Crowdsale.sol";
...@@ -27,7 +27,7 @@ contract TimedCrowdsale is Crowdsale { ...@@ -27,7 +27,7 @@ contract TimedCrowdsale is Crowdsale {
* @param closingTime Crowdsale closing time * @param closingTime Crowdsale closing time
*/ */
constructor (uint256 openingTime, uint256 closingTime) public { constructor (uint256 openingTime, uint256 closingTime) public {
// solium-disable-next-line security/no-block-members // solhint-disable-next-line not-rely-on-time
require(openingTime >= block.timestamp); require(openingTime >= block.timestamp);
require(closingTime > openingTime); require(closingTime > openingTime);
...@@ -53,7 +53,7 @@ contract TimedCrowdsale is Crowdsale { ...@@ -53,7 +53,7 @@ contract TimedCrowdsale is Crowdsale {
* @return true if the crowdsale is open, false otherwise. * @return true if the crowdsale is open, false otherwise.
*/ */
function isOpen() public view returns (bool) { function isOpen() public view returns (bool) {
// solium-disable-next-line security/no-block-members // solhint-disable-next-line not-rely-on-time
return block.timestamp >= _openingTime && block.timestamp <= _closingTime; return block.timestamp >= _openingTime && block.timestamp <= _closingTime;
} }
...@@ -62,7 +62,7 @@ contract TimedCrowdsale is Crowdsale { ...@@ -62,7 +62,7 @@ contract TimedCrowdsale is Crowdsale {
* @return Whether crowdsale period has elapsed * @return Whether crowdsale period has elapsed
*/ */
function hasClosed() public view returns (bool) { function hasClosed() public view returns (bool) {
// solium-disable-next-line security/no-block-members // solhint-disable-next-line not-rely-on-time
return block.timestamp > _closingTime; return block.timestamp > _closingTime;
} }
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../Crowdsale.sol"; import "../Crowdsale.sol";
import "../../access/roles/WhitelistedRole.sol"; import "../../access/roles/WhitelistedRole.sol";
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
/** /**
* @title Elliptic curve signature operations * @title Elliptic curve signature operations
...@@ -13,7 +13,7 @@ library ECDSA { ...@@ -13,7 +13,7 @@ library ECDSA {
* @param hash bytes32 message, the hash is the signed message. What is recovered is the signer address. * @param hash bytes32 message, the hash is the signed message. What is recovered is the signer address.
* @param signature bytes signature, the signature is generated using web3.eth.sign() * @param signature bytes signature, the signature is generated using web3.eth.sign()
*/ */
function recover(bytes32 hash, bytes signature) internal pure returns (address) { function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
bytes32 r; bytes32 r;
bytes32 s; bytes32 s;
uint8 v; uint8 v;
...@@ -26,7 +26,7 @@ library ECDSA { ...@@ -26,7 +26,7 @@ library ECDSA {
// Divide the signature in r, s and v variables // Divide the signature in r, s and v variables
// ecrecover takes the signature parameters, and the only way to get them // ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly. // currently is to use assembly.
// solium-disable-next-line security/no-inline-assembly // solhint-disable-next-line no-inline-assembly
assembly { assembly {
r := mload(add(signature, 0x20)) r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40)) s := mload(add(signature, 0x40))
...@@ -42,7 +42,6 @@ library ECDSA { ...@@ -42,7 +42,6 @@ library ECDSA {
if (v != 27 && v != 28) { if (v != 27 && v != 28) {
return (address(0)); return (address(0));
} else { } else {
// solium-disable-next-line arg-overflow
return ecrecover(hash, v, r, s); return ecrecover(hash, v, r, s);
} }
} }
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
/** /**
* @title MerkleProof * @title MerkleProof
...@@ -13,7 +13,7 @@ library MerkleProof { ...@@ -13,7 +13,7 @@ library MerkleProof {
* @param root Merkle root * @param root Merkle root
* @param leaf Leaf of Merkle tree * @param leaf Leaf of Merkle tree
*/ */
function verify(bytes32[] proof, bytes32 root, bytes32 leaf) internal pure returns (bool) { function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
bytes32 computedHash = leaf; bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) { for (uint256 i = 0; i < proof.length; i++) {
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
/** /**
* @title Counter * @title Counter
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../../token/ERC20/IERC20.sol"; import "../../token/ERC20/IERC20.sol";
...@@ -6,20 +6,19 @@ import "../../token/ERC20/IERC20.sol"; ...@@ -6,20 +6,19 @@ import "../../token/ERC20/IERC20.sol";
* @title ERC-1047 Token Metadata * @title ERC-1047 Token Metadata
* @dev See https://eips.ethereum.org/EIPS/eip-1046 * @dev See https://eips.ethereum.org/EIPS/eip-1046
* @dev tokenURI must respond with a URI that implements https://eips.ethereum.org/EIPS/eip-1047 * @dev tokenURI must respond with a URI that implements https://eips.ethereum.org/EIPS/eip-1047
* @dev TODO - update https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/token/ERC721/IERC721.sol#L17 when 1046 is finalized
*/ */
contract ERC20TokenMetadata is IERC20 { contract ERC20TokenMetadata is IERC20 {
function tokenURI() external view returns (string); function tokenURI() external view returns (string memory);
} }
contract ERC20WithMetadata is ERC20TokenMetadata { contract ERC20WithMetadata is ERC20TokenMetadata {
string private _tokenURI; string private _tokenURI;
constructor (string tokenURI) public { constructor (string memory tokenURI) public {
_tokenURI = tokenURI; _tokenURI = tokenURI;
} }
function tokenURI() external view returns (string) { function tokenURI() external view returns (string memory) {
return _tokenURI; return _tokenURI;
} }
} }
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../token/ERC20/IERC20.sol"; import "../token/ERC20/IERC20.sol";
import "../token/ERC20/ERC20Mintable.sol"; import "../token/ERC20/ERC20Mintable.sol";
...@@ -44,7 +44,7 @@ contract ERC20Migrator { ...@@ -44,7 +44,7 @@ contract ERC20Migrator {
* @param legacyToken address of the old token contract * @param legacyToken address of the old token contract
*/ */
constructor (IERC20 legacyToken) public { constructor (IERC20 legacyToken) public {
require(legacyToken != address(0)); require(address(legacyToken) != address(0));
_legacyToken = legacyToken; _legacyToken = legacyToken;
} }
...@@ -68,9 +68,9 @@ contract ERC20Migrator { ...@@ -68,9 +68,9 @@ contract ERC20Migrator {
* @param newToken the token that will be minted * @param newToken the token that will be minted
*/ */
function beginMigration(ERC20Mintable newToken) public { function beginMigration(ERC20Mintable newToken) public {
require(_newToken == address(0)); require(address(_newToken) == address(0));
require(newToken != address(0)); require(address(newToken) != address(0));
require(newToken.isMinter(this)); require(newToken.isMinter(address(this)));
_newToken = newToken; _newToken = newToken;
} }
...@@ -82,7 +82,7 @@ contract ERC20Migrator { ...@@ -82,7 +82,7 @@ contract ERC20Migrator {
* @param amount amount of tokens to be migrated * @param amount amount of tokens to be migrated
*/ */
function migrate(address account, uint256 amount) public { function migrate(address account, uint256 amount) public {
_legacyToken.safeTransferFrom(account, this, amount); _legacyToken.safeTransferFrom(account, address(this), amount);
_newToken.mint(account, amount); _newToken.mint(account, amount);
} }
...@@ -93,7 +93,7 @@ contract ERC20Migrator { ...@@ -93,7 +93,7 @@ contract ERC20Migrator {
*/ */
function migrateAll(address account) public { function migrateAll(address account) public {
uint256 balance = _legacyToken.balanceOf(account); uint256 balance = _legacyToken.balanceOf(account);
uint256 allowance = _legacyToken.allowance(account, this); uint256 allowance = _legacyToken.allowance(account, address(this));
uint256 amount = Math.min(balance, allowance); uint256 amount = Math.min(balance, allowance);
migrate(account, amount); migrate(account, amount);
} }
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../access/roles/SignerRole.sol"; import "../access/roles/SignerRole.sol";
import "../cryptography/ECDSA.sol"; import "../cryptography/ECDSA.sol";
...@@ -43,12 +43,14 @@ contract SignatureBouncer is SignerRole { ...@@ -43,12 +43,14 @@ contract SignatureBouncer is SignerRole {
// Signature size is 65 bytes (tightly packed v + r + s), but gets padded to 96 bytes // Signature size is 65 bytes (tightly packed v + r + s), but gets padded to 96 bytes
uint256 private constant _SIGNATURE_SIZE = 96; uint256 private constant _SIGNATURE_SIZE = 96;
constructor () internal {} constructor () internal {
// solhint-disable-previous-line no-empty-blocks
}
/** /**
* @dev requires that a valid signature of a signer was provided * @dev requires that a valid signature of a signer was provided
*/ */
modifier onlyValidSignature(bytes signature) { modifier onlyValidSignature(bytes memory signature) {
require(_isValidSignature(msg.sender, signature)); require(_isValidSignature(msg.sender, signature));
_; _;
} }
...@@ -56,7 +58,7 @@ contract SignatureBouncer is SignerRole { ...@@ -56,7 +58,7 @@ contract SignatureBouncer is SignerRole {
/** /**
* @dev requires that a valid signature with a specifed method of a signer was provided * @dev requires that a valid signature with a specifed method of a signer was provided
*/ */
modifier onlyValidSignatureAndMethod(bytes signature) { modifier onlyValidSignatureAndMethod(bytes memory signature) {
require(_isValidSignatureAndMethod(msg.sender, signature)); require(_isValidSignatureAndMethod(msg.sender, signature));
_; _;
} }
...@@ -64,7 +66,7 @@ contract SignatureBouncer is SignerRole { ...@@ -64,7 +66,7 @@ contract SignatureBouncer is SignerRole {
/** /**
* @dev requires that a valid signature with a specifed method and params of a signer was provided * @dev requires that a valid signature with a specifed method and params of a signer was provided
*/ */
modifier onlyValidSignatureAndData(bytes signature) { modifier onlyValidSignatureAndData(bytes memory signature) {
require(_isValidSignatureAndData(msg.sender, signature)); require(_isValidSignatureAndData(msg.sender, signature));
_; _;
} }
...@@ -73,7 +75,7 @@ contract SignatureBouncer is SignerRole { ...@@ -73,7 +75,7 @@ contract SignatureBouncer is SignerRole {
* @dev is the signature of `this + sender` from a signer? * @dev is the signature of `this + sender` from a signer?
* @return bool * @return bool
*/ */
function _isValidSignature(address account, bytes signature) internal view returns (bool) { function _isValidSignature(address account, bytes memory signature) internal view returns (bool) {
return _isValidDataHash(keccak256(abi.encodePacked(address(this), account)), signature); return _isValidDataHash(keccak256(abi.encodePacked(address(this), account)), signature);
} }
...@@ -81,7 +83,7 @@ contract SignatureBouncer is SignerRole { ...@@ -81,7 +83,7 @@ contract SignatureBouncer is SignerRole {
* @dev is the signature of `this + sender + methodId` from a signer? * @dev is the signature of `this + sender + methodId` from a signer?
* @return bool * @return bool
*/ */
function _isValidSignatureAndMethod(address account, bytes signature) internal view returns (bool) { function _isValidSignatureAndMethod(address account, bytes memory signature) internal view returns (bool) {
bytes memory data = new bytes(_METHOD_ID_SIZE); bytes memory data = new bytes(_METHOD_ID_SIZE);
for (uint i = 0; i < data.length; i++) { for (uint i = 0; i < data.length; i++) {
data[i] = msg.data[i]; data[i] = msg.data[i];
...@@ -94,7 +96,7 @@ contract SignatureBouncer is SignerRole { ...@@ -94,7 +96,7 @@ contract SignatureBouncer is SignerRole {
* @notice the signature parameter of the method being validated must be the "last" parameter * @notice the signature parameter of the method being validated must be the "last" parameter
* @return bool * @return bool
*/ */
function _isValidSignatureAndData(address account, bytes signature) internal view returns (bool) { function _isValidSignatureAndData(address account, bytes memory signature) internal view returns (bool) {
require(msg.data.length > _SIGNATURE_SIZE); require(msg.data.length > _SIGNATURE_SIZE);
bytes memory data = new bytes(msg.data.length - _SIGNATURE_SIZE); bytes memory data = new bytes(msg.data.length - _SIGNATURE_SIZE);
...@@ -110,7 +112,7 @@ contract SignatureBouncer is SignerRole { ...@@ -110,7 +112,7 @@ contract SignatureBouncer is SignerRole {
* and then recover the signature and check it against the signer role * and then recover the signature and check it against the signer role
* @return bool * @return bool
*/ */
function _isValidDataHash(bytes32 hash, bytes signature) internal view returns (bool) { function _isValidDataHash(bytes32 hash, bytes memory signature) internal view returns (bool) {
address signer = hash.toEthSignedMessageHash().recover(signature); address signer = hash.toEthSignedMessageHash().recover(signature);
return signer != address(0) && isSigner(signer); return signer != address(0) && isSigner(signer);
......
pragma solidity ^0.5.0;
/**
* @title SignedSafeMath
* @dev Signed math operations with safety checks that revert on error
*/
library SignedSafeMath {
int256 constant private INT256_MIN = -2**255;
/**
* @dev Multiplies two signed integers, reverts on overflow.
*/
function mul(int256 a, int256 b) internal pure returns (int256) {
// 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;
}
require(!(a == -1 && b == INT256_MIN)); // This is the only case of overflow not detected by the check below
int256 c = a * b;
require(c / a == b);
return c;
}
/**
* @dev Integer division of two signed integers truncating the quotient, reverts on division by zero.
*/
function div(int256 a, int256 b) internal pure returns (int256) {
require(b != 0); // Solidity only automatically asserts when dividing by 0
require(!(b == -1 && a == INT256_MIN)); // This is the only case of overflow
int256 c = a / b;
return c;
}
/**
* @dev Subtracts two signed integers, reverts on overflow.
*/
function sub(int256 a, int256 b) internal pure returns (int256) {
int256 c = a - b;
require((b >= 0 && c <= a) || (b < 0 && c > a));
return c;
}
/**
* @dev Adds two signed integers, reverts on overflow.
*/
function add(int256 a, int256 b) internal pure returns (int256) {
int256 c = a + b;
require((b >= 0 && c >= a) || (b < 0 && c < a));
return c;
}
}
/* solium-disable security/no-block-members */ pragma solidity ^0.5.0;
pragma solidity ^0.4.24;
import "../token/ERC20/SafeERC20.sol"; import "../token/ERC20/SafeERC20.sol";
import "../ownership/Ownable.sol"; import "../ownership/Ownable.sol";
...@@ -13,6 +11,12 @@ import "../math/SafeMath.sol"; ...@@ -13,6 +11,12 @@ import "../math/SafeMath.sol";
* owner. * owner.
*/ */
contract TokenVesting is Ownable { contract TokenVesting is Ownable {
// The vesting schedule is time-based (i.e. using block timestamps as opposed to e.g. block numbers), and is
// therefore sensitive to timestamp manipulation (which is something miners can do, to a certain degree). Therefore,
// it is recommended to avoid using short time durations (less than a minute). Typical vesting schemes, with a cliff
// period of a year and a duration of four years, are safe to use.
// solhint-disable not-rely-on-time
using SafeMath for uint256; using SafeMath for uint256;
using SafeERC20 for IERC20; using SafeERC20 for IERC20;
...@@ -22,6 +26,7 @@ contract TokenVesting is Ownable { ...@@ -22,6 +26,7 @@ contract TokenVesting is Ownable {
// beneficiary of tokens after they are released // beneficiary of tokens after they are released
address private _beneficiary; address private _beneficiary;
// Durations and timestamps are expressed in UNIX time, the same units as block.timestamp.
uint256 private _cliff; uint256 private _cliff;
uint256 private _start; uint256 private _start;
uint256 private _duration; uint256 private _duration;
...@@ -112,11 +117,11 @@ contract TokenVesting is Ownable { ...@@ -112,11 +117,11 @@ contract TokenVesting is Ownable {
require(unreleased > 0); require(unreleased > 0);
_released[token] = _released[token].add(unreleased); _released[address(token)] = _released[address(token)].add(unreleased);
token.safeTransfer(_beneficiary, unreleased); token.safeTransfer(_beneficiary, unreleased);
emit TokensReleased(token, unreleased); emit TokensReleased(address(token), unreleased);
} }
/** /**
...@@ -126,18 +131,18 @@ contract TokenVesting is Ownable { ...@@ -126,18 +131,18 @@ contract TokenVesting is Ownable {
*/ */
function revoke(IERC20 token) public onlyOwner { function revoke(IERC20 token) public onlyOwner {
require(_revocable); require(_revocable);
require(!_revoked[token]); require(!_revoked[address(token)]);
uint256 balance = token.balanceOf(address(this)); uint256 balance = token.balanceOf(address(this));
uint256 unreleased = _releasableAmount(token); uint256 unreleased = _releasableAmount(token);
uint256 refund = balance.sub(unreleased); uint256 refund = balance.sub(unreleased);
_revoked[token] = true; _revoked[address(token)] = true;
token.safeTransfer(owner(), refund); token.safeTransfer(owner(), refund);
emit TokenVestingRevoked(token); emit TokenVestingRevoked(address(token));
} }
/** /**
...@@ -145,7 +150,7 @@ contract TokenVesting is Ownable { ...@@ -145,7 +150,7 @@ contract TokenVesting is Ownable {
* @param token ERC20 token which is being vested * @param token ERC20 token which is being vested
*/ */
function _releasableAmount(IERC20 token) private view returns (uint256) { function _releasableAmount(IERC20 token) private view returns (uint256) {
return _vestedAmount(token).sub(_released[token]); return _vestedAmount(token).sub(_released[address(token)]);
} }
/** /**
...@@ -154,11 +159,11 @@ contract TokenVesting is Ownable { ...@@ -154,11 +159,11 @@ contract TokenVesting is Ownable {
*/ */
function _vestedAmount(IERC20 token) private view returns (uint256) { function _vestedAmount(IERC20 token) private view returns (uint256) {
uint256 currentBalance = token.balanceOf(address(this)); uint256 currentBalance = token.balanceOf(address(this));
uint256 totalBalance = currentBalance.add(_released[token]); uint256 totalBalance = currentBalance.add(_released[address(token)]);
if (block.timestamp < _cliff) { if (block.timestamp < _cliff) {
return 0; return 0;
} else if (block.timestamp >= _start.add(_duration) || _revoked[token]) { } else if (block.timestamp >= _start.add(_duration) || _revoked[address(token)]) {
return totalBalance; return totalBalance;
} else { } else {
return totalBalance.mul(block.timestamp.sub(_start)).div(_duration); return totalBalance.mul(block.timestamp.sub(_start)).div(_duration);
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../crowdsale/validation/CappedCrowdsale.sol"; import "../crowdsale/validation/CappedCrowdsale.sol";
import "../crowdsale/distribution/RefundableCrowdsale.sol"; import "../crowdsale/distribution/RefundableCrowdsale.sol";
...@@ -12,7 +12,9 @@ import "../token/ERC20/ERC20Detailed.sol"; ...@@ -12,7 +12,9 @@ import "../token/ERC20/ERC20Detailed.sol";
* It is meant to be used in a crowdsale contract. * It is meant to be used in a crowdsale contract.
*/ */
contract SampleCrowdsaleToken is ERC20Mintable, ERC20Detailed { contract SampleCrowdsaleToken is ERC20Mintable, ERC20Detailed {
constructor () public ERC20Detailed("Sample Crowdsale Token", "SCT", 18) {} constructor () public ERC20Detailed("Sample Crowdsale Token", "SCT", 18) {
// solhint-disable-previous-line no-empty-blocks
}
} }
/** /**
...@@ -28,17 +30,12 @@ contract SampleCrowdsaleToken is ERC20Mintable, ERC20Detailed { ...@@ -28,17 +30,12 @@ contract SampleCrowdsaleToken is ERC20Mintable, ERC20Detailed {
* After adding multiple features it's good practice to run integration tests * After adding multiple features it's good practice to run integration tests
* to ensure that subcontracts works together as intended. * to ensure that subcontracts works together as intended.
*/ */
// XXX There doesn't seem to be a way to split this line that keeps solium
// happy. See:
// https://github.com/duaraghav8/Solium/issues/205
// --elopio - 2018-05-10
// solium-disable-next-line max-len
contract SampleCrowdsale is CappedCrowdsale, RefundableCrowdsale, MintedCrowdsale { contract SampleCrowdsale is CappedCrowdsale, RefundableCrowdsale, MintedCrowdsale {
constructor ( constructor (
uint256 openingTime, uint256 openingTime,
uint256 closingTime, uint256 closingTime,
uint256 rate, uint256 rate,
address wallet, address payable wallet,
uint256 cap, uint256 cap,
ERC20Mintable token, ERC20Mintable token,
uint256 goal uint256 goal
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../token/ERC20/ERC20.sol"; import "../token/ERC20/ERC20.sol";
import "../token/ERC20/ERC20Detailed.sol"; import "../token/ERC20/ERC20Detailed.sol";
...@@ -10,12 +10,13 @@ import "../token/ERC20/ERC20Detailed.sol"; ...@@ -10,12 +10,13 @@ import "../token/ERC20/ERC20Detailed.sol";
* `ERC20` functions. * `ERC20` functions.
*/ */
contract SimpleToken is ERC20, ERC20Detailed { contract SimpleToken is ERC20, ERC20Detailed {
uint256 public constant INITIAL_SUPPLY = 10000 * (10 ** uint256(decimals())); uint8 public constant DECIMALS = 18;
uint256 public constant INITIAL_SUPPLY = 10000 * (10 ** uint256(DECIMALS));
/** /**
* @dev Constructor that gives msg.sender all of existing tokens. * @dev Constructor that gives msg.sender all of existing tokens.
*/ */
constructor () public ERC20Detailed("SimpleToken", "SIM", 18) { constructor () public ERC20Detailed("SimpleToken", "SIM", DECIMALS) {
_mint(msg.sender, INITIAL_SUPPLY); _mint(msg.sender, INITIAL_SUPPLY);
} }
} }
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "./IERC165.sol"; import "./IERC165.sol";
...@@ -8,7 +8,7 @@ import "./IERC165.sol"; ...@@ -8,7 +8,7 @@ import "./IERC165.sol";
* @dev Implements ERC165 using a lookup table. * @dev Implements ERC165 using a lookup table.
*/ */
contract ERC165 is IERC165 { contract ERC165 is IERC165 {
bytes4 private constant _InterfaceId_ERC165 = 0x01ffc9a7; bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;
/** /**
* 0x01ffc9a7 === * 0x01ffc9a7 ===
* bytes4(keccak256('supportsInterface(bytes4)')) * bytes4(keccak256('supportsInterface(bytes4)'))
...@@ -24,7 +24,7 @@ contract ERC165 is IERC165 { ...@@ -24,7 +24,7 @@ contract ERC165 is IERC165 {
* implement ERC165 itself * implement ERC165 itself
*/ */
constructor () internal { constructor () internal {
_registerInterface(_InterfaceId_ERC165); _registerInterface(_INTERFACE_ID_ERC165);
} }
/** /**
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
/** /**
* @title ERC165Checker * @title ERC165Checker
...@@ -7,9 +7,9 @@ pragma solidity ^0.4.24; ...@@ -7,9 +7,9 @@ pragma solidity ^0.4.24;
*/ */
library ERC165Checker { library ERC165Checker {
// As per the EIP-165 spec, no interface should ever match 0xffffffff // As per the EIP-165 spec, no interface should ever match 0xffffffff
bytes4 private constant _InterfaceId_Invalid = 0xffffffff; bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff;
bytes4 private constant _InterfaceId_ERC165 = 0x01ffc9a7; bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;
/** /**
* 0x01ffc9a7 === * 0x01ffc9a7 ===
* bytes4(keccak256('supportsInterface(bytes4)')) * bytes4(keccak256('supportsInterface(bytes4)'))
...@@ -23,8 +23,8 @@ library ERC165Checker { ...@@ -23,8 +23,8 @@ library ERC165Checker {
function _supportsERC165(address account) internal view returns (bool) { function _supportsERC165(address account) internal view returns (bool) {
// Any contract that implements ERC165 must explicitly indicate support of // Any contract that implements ERC165 must explicitly indicate support of
// InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid // InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid
return _supportsERC165Interface(account, _InterfaceId_ERC165) && return _supportsERC165Interface(account, _INTERFACE_ID_ERC165) &&
!_supportsERC165Interface(account, _InterfaceId_Invalid); !_supportsERC165Interface(account, _INTERFACE_ID_INVALID);
} }
/** /**
...@@ -49,7 +49,7 @@ library ERC165Checker { ...@@ -49,7 +49,7 @@ library ERC165Checker {
* interfaceIds list, false otherwise * interfaceIds list, false otherwise
* @dev Interface identification is specified in ERC-165. * @dev Interface identification is specified in ERC-165.
*/ */
function _supportsAllInterfaces(address account, bytes4[] interfaceIds) internal view returns (bool) { function _supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) {
// query support of ERC165 itself // query support of ERC165 itself
if (!_supportsERC165(account)) { if (!_supportsERC165(account)) {
return false; return false;
...@@ -98,9 +98,9 @@ library ERC165Checker { ...@@ -98,9 +98,9 @@ library ERC165Checker {
view view
returns (bool success, bool result) returns (bool success, bool result)
{ {
bytes memory encodedParams = abi.encodeWithSelector(_InterfaceId_ERC165,interfaceId); bytes memory encodedParams = abi.encodeWithSelector(_INTERFACE_ID_ERC165, interfaceId);
// solium-disable-next-line security/no-inline-assembly // solhint-disable-next-line no-inline-assembly
assembly { assembly {
let encodedParams_data := add(0x20, encodedParams) let encodedParams_data := add(0x20, encodedParams)
let encodedParams_size := mload(encodedParams) let encodedParams_size := mload(encodedParams)
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
/** /**
* @title IERC165 * @title IERC165
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../access/roles/PauserRole.sol"; import "../access/roles/PauserRole.sol";
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
/** /**
* @title Math * @title Math
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
/** /**
* @title SafeMath * @title SafeMath
* @dev Math operations with safety checks that revert on error * @dev Unsigned math operations with safety checks that revert on error
*/ */
library SafeMath { library SafeMath {
int256 constant private INT256_MIN = -2**255;
/** /**
* @dev Multiplies two unsigned integers, reverts on overflow. * @dev Multiplies two unsigned integers, reverts on overflow.
*/ */
...@@ -25,25 +23,6 @@ library SafeMath { ...@@ -25,25 +23,6 @@ library SafeMath {
} }
/** /**
* @dev Multiplies two signed integers, reverts on overflow.
*/
function mul(int256 a, int256 b) internal pure returns (int256) {
// 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;
}
require(!(a == -1 && b == INT256_MIN)); // This is the only case of overflow not detected by the check below
int256 c = a * b;
require(c / a == b);
return c;
}
/**
* @dev Integer division of two unsigned integers truncating the quotient, reverts on division by zero. * @dev Integer division of two unsigned integers truncating the quotient, reverts on division by zero.
*/ */
function div(uint256 a, uint256 b) internal pure returns (uint256) { function div(uint256 a, uint256 b) internal pure returns (uint256) {
...@@ -56,18 +35,6 @@ library SafeMath { ...@@ -56,18 +35,6 @@ library SafeMath {
} }
/** /**
* @dev Integer division of two signed integers truncating the quotient, reverts on division by zero.
*/
function div(int256 a, int256 b) internal pure returns (int256) {
require(b != 0); // Solidity only automatically asserts when dividing by 0
require(!(b == -1 && a == INT256_MIN)); // This is the only case of overflow
int256 c = a / b;
return c;
}
/**
* @dev Subtracts two unsigned integers, reverts on overflow (i.e. if subtrahend is greater than minuend). * @dev Subtracts two unsigned integers, reverts on overflow (i.e. if subtrahend is greater than minuend).
*/ */
function sub(uint256 a, uint256 b) internal pure returns (uint256) { function sub(uint256 a, uint256 b) internal pure returns (uint256) {
...@@ -78,16 +45,6 @@ library SafeMath { ...@@ -78,16 +45,6 @@ library SafeMath {
} }
/** /**
* @dev Subtracts two signed integers, reverts on overflow.
*/
function sub(int256 a, int256 b) internal pure returns (int256) {
int256 c = a - b;
require((b >= 0 && c <= a) || (b < 0 && c > a));
return c;
}
/**
* @dev Adds two unsigned integers, reverts on overflow. * @dev Adds two unsigned integers, reverts on overflow.
*/ */
function add(uint256 a, uint256 b) internal pure returns (uint256) { function add(uint256 a, uint256 b) internal pure returns (uint256) {
...@@ -98,16 +55,6 @@ library SafeMath { ...@@ -98,16 +55,6 @@ library SafeMath {
} }
/** /**
* @dev Adds two signed integers, reverts on overflow.
*/
function add(int256 a, int256 b) internal pure returns (int256) {
int256 c = a + b;
require((b >= 0 && c >= a) || (b < 0 && c < a));
return c;
}
/**
* @dev Divides two unsigned integers and returns the remainder (unsigned integer modulo), * @dev Divides two unsigned integers and returns the remainder (unsigned integer modulo),
* reverts when dividing by zero. * reverts when dividing by zero.
*/ */
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
contract Acknowledger { contract Acknowledger {
event AcknowledgeFoo(uint256 a); event AcknowledgeFoo(uint256 a);
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../utils/Address.sol"; import "../utils/Address.sol";
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../token/ERC20/IERC20.sol"; import "../token/ERC20/IERC20.sol";
import "../crowdsale/emission/AllowanceCrowdsale.sol"; import "../crowdsale/emission/AllowanceCrowdsale.sol";
contract AllowanceCrowdsaleImpl is AllowanceCrowdsale { contract AllowanceCrowdsaleImpl is AllowanceCrowdsale {
constructor (uint256 rate, address wallet, IERC20 token, address tokenWallet) constructor (uint256 rate, address payable wallet, IERC20 token, address tokenWallet)
public public
Crowdsale(rate, wallet, token) Crowdsale(rate, wallet, token)
AllowanceCrowdsale(tokenWallet) AllowanceCrowdsale(tokenWallet)
{} {
// solhint-disable-previous-line no-empty-blocks
}
} }
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../utils/Arrays.sol"; import "../utils/Arrays.sol";
...@@ -7,7 +7,7 @@ contract ArraysImpl { ...@@ -7,7 +7,7 @@ contract ArraysImpl {
uint256[] private array; uint256[] private array;
constructor (uint256[] _array) public { constructor (uint256[] memory _array) public {
array = _array; array = _array;
} }
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../token/ERC20/IERC20.sol"; import "../token/ERC20/IERC20.sol";
import "../crowdsale/validation/CappedCrowdsale.sol"; import "../crowdsale/validation/CappedCrowdsale.sol";
contract CappedCrowdsaleImpl is CappedCrowdsale { contract CappedCrowdsaleImpl is CappedCrowdsale {
constructor (uint256 rate, address wallet, IERC20 token, uint256 cap) constructor (uint256 rate, address payable wallet, IERC20 token, uint256 cap)
public public
Crowdsale(rate, wallet, token) Crowdsale(rate, wallet, token)
CappedCrowdsale(cap) CappedCrowdsale(cap)
{} {
// solhint-disable-previous-line no-empty-blocks
}
} }
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../access/roles/CapperRole.sol"; import "../access/roles/CapperRole.sol";
...@@ -8,6 +8,7 @@ contract CapperRoleMock is CapperRole { ...@@ -8,6 +8,7 @@ contract CapperRoleMock is CapperRole {
} }
function onlyCapperMock() public view onlyCapper { function onlyCapperMock() public view onlyCapper {
// solhint-disable-previous-line no-empty-blocks
} }
// Causes a compilation error if super._removeCapper is not internal // Causes a compilation error if super._removeCapper is not internal
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../payment/escrow/ConditionalEscrow.sol"; import "../payment/escrow/ConditionalEscrow.sol";
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../drafts/Counter.sol"; import "../drafts/Counter.sol";
...@@ -10,7 +10,7 @@ contract CounterImpl { ...@@ -10,7 +10,7 @@ contract CounterImpl {
// use whatever key you want to track your counters // use whatever key you want to track your counters
mapping(string => Counter.Counter) private _counters; mapping(string => Counter.Counter) private _counters;
function doThing(string key) public returns (uint256) { function doThing(string memory key) public returns (uint256) {
theId = _counters[key].next(); theId = _counters[key].next();
return theId; return theId;
} }
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../crowdsale/Crowdsale.sol"; import "../crowdsale/Crowdsale.sol";
contract CrowdsaleMock is Crowdsale { contract CrowdsaleMock is Crowdsale {
constructor (uint256 rate, address wallet, IERC20 token) public Crowdsale(rate, wallet, token) {} constructor (uint256 rate, address payable wallet, IERC20 token) public Crowdsale(rate, wallet, token) {
// solhint-disable-previous-line no-empty-blocks
}
} }
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../cryptography/ECDSA.sol"; import "../cryptography/ECDSA.sol";
contract ECDSAMock { contract ECDSAMock {
using ECDSA for bytes32; using ECDSA for bytes32;
function recover(bytes32 hash, bytes signature) public pure returns (address) { function recover(bytes32 hash, bytes memory signature) public pure returns (address) {
return hash.recover(signature); return hash.recover(signature);
} }
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../../introspection/IERC165.sol"; import "../../introspection/IERC165.sol";
/** /**
* https://github.com/ethereum/EIPs/blob/master/EIPS/eip-214.md#specification * https://github.com/ethereum/EIPs/blob/master/EIPS/eip-214.md#specification
* > Any attempts to make state-changing operations inside an execution instance with STATIC set to true will instead throw an exception. * > Any attempts to make state-changing operations inside an execution instance with STATIC set to true will instead
* throw an exception.
* > These operations include [...], LOG0, LOG1, LOG2, [...] * > These operations include [...], LOG0, LOG1, LOG2, [...]
* *
* therefore, because this contract is staticcall'd we need to not emit events (which is how solidity-coverage works) * therefore, because this contract is staticcall'd we need to not emit events (which is how solidity-coverage works)
* solidity-coverage ignores the /mocks folder, so we duplicate its implementation here to avoid instrumenting it * solidity-coverage ignores the /mocks folder, so we duplicate its implementation here to avoid instrumenting it
*/ */
contract SupportsInterfaceWithLookupMock is IERC165 { contract SupportsInterfaceWithLookupMock is IERC165 {
bytes4 public constant InterfaceId_ERC165 = 0x01ffc9a7; bytes4 public constant INTERFACE_ID_ERC165 = 0x01ffc9a7;
/** /**
* 0x01ffc9a7 === * 0x01ffc9a7 ===
* bytes4(keccak256('supportsInterface(bytes4)')) * bytes4(keccak256('supportsInterface(bytes4)'))
...@@ -27,7 +28,7 @@ contract SupportsInterfaceWithLookupMock is IERC165 { ...@@ -27,7 +28,7 @@ contract SupportsInterfaceWithLookupMock is IERC165 {
* implement ERC165 itself * implement ERC165 itself
*/ */
constructor () public { constructor () public {
_registerInterface(InterfaceId_ERC165); _registerInterface(INTERFACE_ID_ERC165);
} }
/** /**
...@@ -47,7 +48,7 @@ contract SupportsInterfaceWithLookupMock is IERC165 { ...@@ -47,7 +48,7 @@ contract SupportsInterfaceWithLookupMock is IERC165 {
} }
contract ERC165InterfacesSupported is SupportsInterfaceWithLookupMock { contract ERC165InterfacesSupported is SupportsInterfaceWithLookupMock {
constructor (bytes4[] interfaceIds) public { constructor (bytes4[] memory interfaceIds) public {
for (uint256 i = 0; i < interfaceIds.length; i++) { for (uint256 i = 0; i < interfaceIds.length; i++) {
_registerInterface(interfaceIds[i]); _registerInterface(interfaceIds[i]);
} }
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
contract ERC165NotSupported {} contract ERC165NotSupported {
// solhint-disable-previous-line no-empty-blocks
}
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../introspection/ERC165Checker.sol"; import "../introspection/ERC165Checker.sol";
...@@ -13,7 +13,7 @@ contract ERC165CheckerMock { ...@@ -13,7 +13,7 @@ contract ERC165CheckerMock {
return account._supportsInterface(interfaceId); return account._supportsInterface(interfaceId);
} }
function supportsAllInterfaces(address account, bytes4[] interfaceIds) public view returns (bool) { function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) public view returns (bool) {
return account._supportsAllInterfaces(interfaceIds); return account._supportsAllInterfaces(interfaceIds);
} }
} }
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../introspection/ERC165.sol"; import "../introspection/ERC165.sol";
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../token/ERC20/ERC20Burnable.sol"; import "../token/ERC20/ERC20Burnable.sol";
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../token/ERC20/ERC20.sol"; import "../token/ERC20/ERC20.sol";
import "../token/ERC20/ERC20Detailed.sol"; import "../token/ERC20/ERC20Detailed.sol";
contract ERC20DetailedMock is ERC20, ERC20Detailed { contract ERC20DetailedMock is ERC20, ERC20Detailed {
constructor (string name, string symbol, uint8 decimals) ERC20Detailed(name, symbol, decimals) public {} constructor (string memory name, string memory symbol, uint8 decimals)
public
ERC20Detailed(name, symbol, decimals)
{
// solhint-disable-previous-line no-empty-blocks
}
} }
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../token/ERC20/ERC20Mintable.sol"; import "../token/ERC20/ERC20Mintable.sol";
import "./MinterRoleMock.sol"; import "./MinterRoleMock.sol";
contract ERC20MintableMock is ERC20Mintable, MinterRoleMock { contract ERC20MintableMock is ERC20Mintable, MinterRoleMock {
// solhint-disable-previous-line no-empty-blocks
} }
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../token/ERC20/ERC20.sol"; import "../token/ERC20/ERC20.sol";
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../token/ERC20/ERC20Pausable.sol"; import "../token/ERC20/ERC20Pausable.sol";
import "./PauserRoleMock.sol"; import "./PauserRoleMock.sol";
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../token/ERC20/ERC20.sol"; import "../token/ERC20/ERC20.sol";
import "../drafts/ERC1046/TokenMetadata.sol"; import "../drafts/ERC1046/TokenMetadata.sol";
contract ERC20WithMetadataMock is ERC20, ERC20WithMetadata { contract ERC20WithMetadataMock is ERC20, ERC20WithMetadata {
constructor (string tokenURI) public ERC20WithMetadata(tokenURI) {} constructor (string memory tokenURI) public ERC20WithMetadata(tokenURI) {
// solhint-disable-previous-line no-empty-blocks
}
} }
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../token/ERC721/ERC721Full.sol"; import "../token/ERC721/ERC721Full.sol";
import "../token/ERC721/ERC721Mintable.sol"; import "../token/ERC721/ERC721Mintable.sol";
...@@ -11,7 +11,9 @@ import "../token/ERC721/ERC721Burnable.sol"; ...@@ -11,7 +11,9 @@ import "../token/ERC721/ERC721Burnable.sol";
* checking token existence, removal of a token from an address * checking token existence, removal of a token from an address
*/ */
contract ERC721FullMock is ERC721Full, ERC721Mintable, ERC721MetadataMintable, ERC721Burnable { contract ERC721FullMock is ERC721Full, ERC721Mintable, ERC721MetadataMintable, ERC721Burnable {
constructor (string name, string symbol) public ERC721Mintable() ERC721Full(name, symbol) {} constructor (string memory name, string memory symbol) public ERC721Mintable() ERC721Full(name, symbol) {
// solhint-disable-previous-line no-empty-blocks
}
function exists(uint256 tokenId) public view returns (bool) { function exists(uint256 tokenId) public view returns (bool) {
return _exists(tokenId); return _exists(tokenId);
...@@ -21,7 +23,7 @@ contract ERC721FullMock is ERC721Full, ERC721Mintable, ERC721MetadataMintable, E ...@@ -21,7 +23,7 @@ contract ERC721FullMock is ERC721Full, ERC721Mintable, ERC721MetadataMintable, E
return _tokensOfOwner(owner); return _tokensOfOwner(owner);
} }
function setTokenURI(uint256 tokenId, string uri) public { function setTokenURI(uint256 tokenId, string memory uri) public {
_setTokenURI(tokenId, uri); _setTokenURI(tokenId, uri);
} }
} }
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../token/ERC721/ERC721Full.sol"; import "../token/ERC721/ERC721Full.sol";
import "../token/ERC721/ERC721Mintable.sol"; import "../token/ERC721/ERC721Mintable.sol";
...@@ -9,5 +9,7 @@ import "../token/ERC721/ERC721Burnable.sol"; ...@@ -9,5 +9,7 @@ import "../token/ERC721/ERC721Burnable.sol";
* @title ERC721MintableBurnableImpl * @title ERC721MintableBurnableImpl
*/ */
contract ERC721MintableBurnableImpl is ERC721Full, ERC721Mintable, ERC721MetadataMintable, ERC721Burnable { contract ERC721MintableBurnableImpl is ERC721Full, ERC721Mintable, ERC721MetadataMintable, ERC721Burnable {
constructor () ERC721Mintable() ERC721Full("Test", "TEST") public {} constructor () public ERC721Mintable() ERC721Full("Test", "TEST") {
// solhint-disable-previous-line no-empty-blocks
}
} }
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../token/ERC721/ERC721.sol"; import "../token/ERC721/ERC721.sol";
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../token/ERC721/ERC721Pausable.sol"; import "../token/ERC721/ERC721Pausable.sol";
import "./PauserRoleMock.sol"; import "./PauserRoleMock.sol";
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../token/ERC721/IERC721Receiver.sol"; import "../token/ERC721/IERC721Receiver.sol";
...@@ -13,7 +13,9 @@ contract ERC721ReceiverMock is IERC721Receiver { ...@@ -13,7 +13,9 @@ contract ERC721ReceiverMock is IERC721Receiver {
_reverts = reverts; _reverts = reverts;
} }
function onERC721Received(address operator, address from, uint256 tokenId, bytes data) public returns (bytes4) { function onERC721Received(address operator, address from, uint256 tokenId, bytes memory data)
public returns (bytes4)
{
require(!_reverts); require(!_reverts);
emit Received(operator, from, tokenId, data, gasleft()); emit Received(operator, from, tokenId, data, gasleft());
return _retval; return _retval;
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
contract EventEmitter { contract EventEmitter {
event Argumentless(); event Argumentless();
...@@ -11,7 +11,7 @@ contract EventEmitter { ...@@ -11,7 +11,7 @@ contract EventEmitter {
event String(string value); event String(string value);
event LongUintBooleanString(uint256 uintValue, bool booleanValue, string stringValue); event LongUintBooleanString(uint256 uintValue, bool booleanValue, string stringValue);
constructor (uint8 uintValue, bool booleanValue, string stringValue) public { constructor (uint8 uintValue, bool booleanValue, string memory stringValue) public {
emit ShortUint(uintValue); emit ShortUint(uintValue);
emit Boolean(booleanValue); emit Boolean(booleanValue);
emit String(stringValue); emit String(stringValue);
...@@ -45,11 +45,11 @@ contract EventEmitter { ...@@ -45,11 +45,11 @@ contract EventEmitter {
emit Boolean(value); emit Boolean(value);
} }
function emitString(string value) public { function emitString(string memory value) public {
emit String(value); emit String(value);
} }
function emitLongUintBooleanString(uint256 uintValue, bool booleanValue, string stringValue) public { function emitLongUintBooleanString(uint256 uintValue, bool booleanValue, string memory stringValue) public {
emit LongUintBooleanString(uintValue, booleanValue, stringValue); emit LongUintBooleanString(uintValue, booleanValue, stringValue);
} }
...@@ -58,7 +58,7 @@ contract EventEmitter { ...@@ -58,7 +58,7 @@ contract EventEmitter {
emit Boolean(boolValue); emit Boolean(boolValue);
} }
function emitStringAndEmitIndirectly(string value, IndirectEventEmitter emitter) public { function emitStringAndEmitIndirectly(string memory value, IndirectEventEmitter emitter) public {
emit String(value); emit String(value);
emitter.emitStringIndirectly(value); emitter.emitStringIndirectly(value);
} }
...@@ -67,7 +67,7 @@ contract EventEmitter { ...@@ -67,7 +67,7 @@ contract EventEmitter {
contract IndirectEventEmitter { contract IndirectEventEmitter {
event IndirectString(string value); event IndirectString(string value);
function emitStringIndirectly(string value) public { function emitStringIndirectly(string memory value) public {
emit IndirectString(value); emit IndirectString(value);
} }
} }
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
contract Failer { contract Failer {
uint256[] private array; uint256[] private array;
function dontFail() public pure { function dontFail() public pure {
// solhint-disable-previous-line no-empty-blocks
} }
function failWithRevert() public pure { function failWithRevert() public pure {
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../token/ERC20/IERC20.sol"; import "../token/ERC20/IERC20.sol";
import "../crowdsale/distribution/FinalizableCrowdsale.sol"; import "../crowdsale/distribution/FinalizableCrowdsale.sol";
contract FinalizableCrowdsaleImpl is FinalizableCrowdsale { contract FinalizableCrowdsaleImpl is FinalizableCrowdsale {
constructor (uint256 openingTime, uint256 closingTime, uint256 rate, address payable wallet, IERC20 token)
constructor (uint256 openingTime, uint256 closingTime, uint256 rate, address wallet, IERC20 token)
public public
Crowdsale(rate, wallet, token) Crowdsale(rate, wallet, token)
TimedCrowdsale(openingTime, closingTime) TimedCrowdsale(openingTime, closingTime)
{} {
// solhint-disable-previous-line no-empty-blocks
}
} }
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../crowdsale/price/IncreasingPriceCrowdsale.sol"; import "../crowdsale/price/IncreasingPriceCrowdsale.sol";
import "../math/SafeMath.sol"; import "../math/SafeMath.sol";
...@@ -7,7 +7,7 @@ contract IncreasingPriceCrowdsaleImpl is IncreasingPriceCrowdsale { ...@@ -7,7 +7,7 @@ contract IncreasingPriceCrowdsaleImpl is IncreasingPriceCrowdsale {
constructor ( constructor (
uint256 openingTime, uint256 openingTime,
uint256 closingTime, uint256 closingTime,
address wallet, address payable wallet,
IERC20 token, IERC20 token,
uint256 initialRate, uint256 initialRate,
uint256 finalRate uint256 finalRate
...@@ -16,5 +16,7 @@ contract IncreasingPriceCrowdsaleImpl is IncreasingPriceCrowdsale { ...@@ -16,5 +16,7 @@ contract IncreasingPriceCrowdsaleImpl is IncreasingPriceCrowdsale {
Crowdsale(initialRate, wallet, token) Crowdsale(initialRate, wallet, token)
TimedCrowdsale(openingTime, closingTime) TimedCrowdsale(openingTime, closingTime)
IncreasingPriceCrowdsale(initialRate, finalRate) IncreasingPriceCrowdsale(initialRate, finalRate)
{} {
// solhint-disable-previous-line no-empty-blocks
}
} }
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../token/ERC20/IERC20.sol"; import "../token/ERC20/IERC20.sol";
import "../crowdsale/validation/IndividuallyCappedCrowdsale.sol"; import "../crowdsale/validation/IndividuallyCappedCrowdsale.sol";
import "./CapperRoleMock.sol"; import "./CapperRoleMock.sol";
contract IndividuallyCappedCrowdsaleImpl is IndividuallyCappedCrowdsale, CapperRoleMock { contract IndividuallyCappedCrowdsaleImpl is IndividuallyCappedCrowdsale, CapperRoleMock {
constructor (uint256 rate, address wallet, IERC20 token) public Crowdsale(rate, wallet, token) constructor (uint256 rate, address payable wallet, IERC20 token) public Crowdsale(rate, wallet, token) {
{} // solhint-disable-previous-line no-empty-blocks
}
} }
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../math/Math.sol"; import "../math/Math.sol";
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import { MerkleProof } from "../cryptography/MerkleProof.sol"; import { MerkleProof } from "../cryptography/MerkleProof.sol";
contract MerkleProofWrapper { contract MerkleProofWrapper {
function verify(bytes32[] proof, bytes32 root, bytes32 leaf) public pure returns (bool) { function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) public pure returns (bool) {
return MerkleProof.verify(proof, root, leaf); return MerkleProof.verify(proof, root, leaf);
} }
} }
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../token/ERC20/ERC20Mintable.sol"; import "../token/ERC20/ERC20Mintable.sol";
import "../crowdsale/emission/MintedCrowdsale.sol"; import "../crowdsale/emission/MintedCrowdsale.sol";
contract MintedCrowdsaleImpl is MintedCrowdsale { contract MintedCrowdsaleImpl is MintedCrowdsale {
constructor (uint256 rate, address wallet, ERC20Mintable token) public Crowdsale(rate, wallet, token) {} constructor (uint256 rate, address payable wallet, ERC20Mintable token) public Crowdsale(rate, wallet, token) {
// solhint-disable-previous-line no-empty-blocks
}
} }
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../access/roles/MinterRole.sol"; import "../access/roles/MinterRole.sol";
...@@ -8,6 +8,7 @@ contract MinterRoleMock is MinterRole { ...@@ -8,6 +8,7 @@ contract MinterRoleMock is MinterRole {
} }
function onlyMinterMock() public view onlyMinter { function onlyMinterMock() public view onlyMinter {
// solhint-disable-previous-line no-empty-blocks
} }
// Causes a compilation error if super._removeMinter is not internal // Causes a compilation error if super._removeMinter is not internal
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../ownership/Ownable.sol"; import "../ownership/Ownable.sol";
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../ownership/Ownable.sol"; import "../ownership/Ownable.sol";
contract OwnableMock is Ownable {} contract OwnableMock is Ownable {
// solhint-disable-previous-line no-empty-blocks
}
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../token/ERC20/ERC20.sol"; import "../token/ERC20/ERC20.sol";
import "../crowdsale/validation/PausableCrowdsale.sol"; import "../crowdsale/validation/PausableCrowdsale.sol";
contract PausableCrowdsaleImpl is PausableCrowdsale { contract PausableCrowdsaleImpl is PausableCrowdsale {
constructor (uint256 _rate, address _wallet, ERC20 _token) public Crowdsale(_rate, _wallet, _token) { constructor (uint256 _rate, address payable _wallet, ERC20 _token) public Crowdsale(_rate, _wallet, _token) {
// solhint-disable-previous-line no-empty-blocks
} }
} }
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../lifecycle/Pausable.sol"; import "../lifecycle/Pausable.sol";
import "./PauserRoleMock.sol"; import "./PauserRoleMock.sol";
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../access/roles/PauserRole.sol"; import "../access/roles/PauserRole.sol";
...@@ -8,6 +8,7 @@ contract PauserRoleMock is PauserRole { ...@@ -8,6 +8,7 @@ contract PauserRoleMock is PauserRole {
} }
function onlyPauserMock() public view onlyPauser { function onlyPauserMock() public view onlyPauser {
// solhint-disable-previous-line no-empty-blocks
} }
// Causes a compilation error if super._removePauser is not internal // Causes a compilation error if super._removePauser is not internal
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../token/ERC20/IERC20.sol"; import "../token/ERC20/IERC20.sol";
import "../crowdsale/distribution/PostDeliveryCrowdsale.sol"; import "../crowdsale/distribution/PostDeliveryCrowdsale.sol";
contract PostDeliveryCrowdsaleImpl is PostDeliveryCrowdsale { contract PostDeliveryCrowdsaleImpl is PostDeliveryCrowdsale {
constructor (uint256 openingTime, uint256 closingTime, uint256 rate, address wallet, IERC20 token) constructor (uint256 openingTime, uint256 closingTime, uint256 rate, address payable wallet, IERC20 token)
public public
TimedCrowdsale(openingTime, closingTime) TimedCrowdsale(openingTime, closingTime)
Crowdsale(rate, wallet, token) Crowdsale(rate, wallet, token)
{} {
// solhint-disable-previous-line no-empty-blocks
}
} }
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../payment/PullPayment.sol"; import "../payment/PullPayment.sol";
// mock class using PullPayment // mock class using PullPayment
contract PullPaymentMock is PullPayment { contract PullPaymentMock is PullPayment {
constructor () public payable { } constructor () public payable {
// solhint-disable-previous-line no-empty-blocks
}
// test helper function to call asyncTransfer // test helper function to call asyncTransfer
function callTransfer(address dest, uint256 amount) public { function callTransfer(address dest, uint256 amount) public {
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
contract ReentrancyAttack { contract ReentrancyAttack {
function callSender(bytes4 data) public { function callSender(bytes4 data) public {
// solium-disable-next-line security/no-low-level-calls // solhint-disable-next-line avoid-low-level-calls
require(msg.sender.call(abi.encodeWithSelector(data))); (bool success,) = msg.sender.call(abi.encodeWithSelector(data));
require(success);
} }
} }
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../utils/ReentrancyGuard.sol"; import "../utils/ReentrancyGuard.sol";
import "./ReentrancyAttack.sol"; import "./ReentrancyAttack.sol";
...@@ -24,9 +24,9 @@ contract ReentrancyMock is ReentrancyGuard { ...@@ -24,9 +24,9 @@ contract ReentrancyMock is ReentrancyGuard {
function countThisRecursive(uint256 n) public nonReentrant { function countThisRecursive(uint256 n) public nonReentrant {
if (n > 0) { if (n > 0) {
count(); count();
// solium-disable-next-line security/no-low-level-calls // solhint-disable-next-line avoid-low-level-calls
bool result = address(this).call(abi.encodeWithSignature("countThisRecursive(uint256)", n - 1)); (bool success,) = address(this).call(abi.encodeWithSignature("countThisRecursive(uint256)", n - 1));
require(result == true); require(success);
} }
} }
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../token/ERC20/IERC20.sol"; import "../token/ERC20/IERC20.sol";
import "../crowdsale/distribution/RefundableCrowdsale.sol"; import "../crowdsale/distribution/RefundableCrowdsale.sol";
...@@ -8,7 +8,7 @@ contract RefundableCrowdsaleImpl is RefundableCrowdsale { ...@@ -8,7 +8,7 @@ contract RefundableCrowdsaleImpl is RefundableCrowdsale {
uint256 openingTime, uint256 openingTime,
uint256 closingTime, uint256 closingTime,
uint256 rate, uint256 rate,
address wallet, address payable wallet,
IERC20 token, IERC20 token,
uint256 goal uint256 goal
) )
...@@ -16,5 +16,7 @@ contract RefundableCrowdsaleImpl is RefundableCrowdsale { ...@@ -16,5 +16,7 @@ contract RefundableCrowdsaleImpl is RefundableCrowdsale {
Crowdsale(rate, wallet, token) Crowdsale(rate, wallet, token)
TimedCrowdsale(openingTime, closingTime) TimedCrowdsale(openingTime, closingTime)
RefundableCrowdsale(goal) RefundableCrowdsale(goal)
{} {
// solhint-disable-previous-line no-empty-blocks
}
} }
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../token/ERC20/IERC20.sol"; import "../token/ERC20/IERC20.sol";
import "../crowdsale/distribution/RefundablePostDeliveryCrowdsale.sol"; import "../crowdsale/distribution/RefundablePostDeliveryCrowdsale.sol";
...@@ -8,7 +8,7 @@ contract RefundablePostDeliveryCrowdsaleImpl is RefundablePostDeliveryCrowdsale ...@@ -8,7 +8,7 @@ contract RefundablePostDeliveryCrowdsaleImpl is RefundablePostDeliveryCrowdsale
uint256 openingTime, uint256 openingTime,
uint256 closingTime, uint256 closingTime,
uint256 rate, uint256 rate,
address wallet, address payable wallet,
IERC20 token, IERC20 token,
uint256 goal uint256 goal
) )
...@@ -16,5 +16,7 @@ contract RefundablePostDeliveryCrowdsaleImpl is RefundablePostDeliveryCrowdsale ...@@ -16,5 +16,7 @@ contract RefundablePostDeliveryCrowdsaleImpl is RefundablePostDeliveryCrowdsale
Crowdsale(rate, wallet, token) Crowdsale(rate, wallet, token)
TimedCrowdsale(openingTime, closingTime) TimedCrowdsale(openingTime, closingTime)
RefundableCrowdsale(goal) RefundableCrowdsale(goal)
{} {
// solhint-disable-previous-line no-empty-blocks
}
} }
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../access/Roles.sol"; import "../access/Roles.sol";
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../token/ERC20/IERC20.sol"; import "../token/ERC20/IERC20.sol";
import "../token/ERC20/SafeERC20.sol"; import "../token/ERC20/SafeERC20.sol";
...@@ -54,12 +54,10 @@ contract SafeERC20Helper { ...@@ -54,12 +54,10 @@ contract SafeERC20Helper {
IERC20 private _succeeding; IERC20 private _succeeding;
constructor () public { constructor () public {
_failing = IERC20(new ERC20FailingMock()); _failing = IERC20(address(new ERC20FailingMock()));
_succeeding = IERC20(new ERC20SucceedingMock()); _succeeding = IERC20(address(new ERC20SucceedingMock()));
} }
// Using _failing
function doFailingTransfer() public { function doFailingTransfer() public {
_failing.safeTransfer(address(0), 0); _failing.safeTransfer(address(0), 0);
} }
...@@ -80,8 +78,6 @@ contract SafeERC20Helper { ...@@ -80,8 +78,6 @@ contract SafeERC20Helper {
_failing.safeDecreaseAllowance(address(0), 0); _failing.safeDecreaseAllowance(address(0), 0);
} }
// Using _succeeding
function doSucceedingTransfer() public { function doSucceedingTransfer() public {
_succeeding.safeTransfer(address(0), 0); _succeeding.safeTransfer(address(0), 0);
} }
...@@ -103,7 +99,7 @@ contract SafeERC20Helper { ...@@ -103,7 +99,7 @@ contract SafeERC20Helper {
} }
function setAllowance(uint256 allowance_) public { function setAllowance(uint256 allowance_) public {
ERC20SucceedingMock(_succeeding).setAllowance(allowance_); ERC20SucceedingMock(address(_succeeding)).setAllowance(allowance_);
} }
function allowance() public view returns (uint256) { function allowance() public view returns (uint256) {
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../math/SafeMath.sol"; import "../math/SafeMath.sol";
contract SafeMathMock { contract SafeMathMock {
function mulUints(uint256 a, uint256 b) public pure returns (uint256) { function mul(uint256 a, uint256 b) public pure returns (uint256) {
return SafeMath.mul(a, b); return SafeMath.mul(a, b);
} }
function mulInts(int256 a, int256 b) public pure returns (int256) { function div(uint256 a, uint256 b) public pure returns (uint256) {
return SafeMath.mul(a, b);
}
function divUints(uint256 a, uint256 b) public pure returns (uint256) {
return SafeMath.div(a, b);
}
function divInts(int256 a, int256 b) public pure returns (int256) {
return SafeMath.div(a, b); return SafeMath.div(a, b);
} }
function subUints(uint256 a, uint256 b) public pure returns (uint256) { function sub(uint256 a, uint256 b) public pure returns (uint256) {
return SafeMath.sub(a, b);
}
function subInts(int256 a, int256 b) public pure returns (int256) {
return SafeMath.sub(a, b); return SafeMath.sub(a, b);
} }
function addUints(uint256 a, uint256 b) public pure returns (uint256) { function add(uint256 a, uint256 b) public pure returns (uint256) {
return SafeMath.add(a, b);
}
function addInts(int256 a, int256 b) public pure returns (int256) {
return SafeMath.add(a, b); return SafeMath.add(a, b);
} }
function modUints(uint256 a, uint256 b) public pure returns (uint256) { function mod(uint256 a, uint256 b) public pure returns (uint256) {
return SafeMath.mod(a, b); return SafeMath.mod(a, b);
} }
} }
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../ownership/Secondary.sol"; import "../ownership/Secondary.sol";
contract SecondaryMock is Secondary { contract SecondaryMock is Secondary {
function onlyPrimaryMock() public view onlyPrimary {} function onlyPrimaryMock() public view onlyPrimary {
// solhint-disable-previous-line no-empty-blocks
}
} }
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../drafts/SignatureBouncer.sol"; import "../drafts/SignatureBouncer.sol";
import "./SignerRoleMock.sol"; import "./SignerRoleMock.sol";
contract SignatureBouncerMock is SignatureBouncer, SignerRoleMock { contract SignatureBouncerMock is SignatureBouncer, SignerRoleMock {
function checkValidSignature(address account, bytes signature) public view returns (bool) { function checkValidSignature(address account, bytes memory signature)
public view returns (bool)
{
return _isValidSignature(account, signature); return _isValidSignature(account, signature);
} }
function onlyWithValidSignature(bytes signature) public onlyValidSignature(signature) view {} function onlyWithValidSignature(bytes memory signature)
public onlyValidSignature(signature) view
{
// solhint-disable-previous-line no-empty-blocks
}
function checkValidSignatureAndMethod(address account, bytes signature) public view returns (bool) { function checkValidSignatureAndMethod(address account, bytes memory signature)
public view returns (bool)
{
return _isValidSignatureAndMethod(account, signature); return _isValidSignatureAndMethod(account, signature);
} }
function onlyWithValidSignatureAndMethod(bytes signature) public onlyValidSignatureAndMethod(signature) view {} function onlyWithValidSignatureAndMethod(bytes memory signature)
public onlyValidSignatureAndMethod(signature) view
{
// solhint-disable-previous-line no-empty-blocks
}
function checkValidSignatureAndData(address account, bytes, uint, bytes signature) public view returns (bool) { function checkValidSignatureAndData(address account, bytes memory, uint, bytes memory signature)
public view returns (bool)
{
return _isValidSignatureAndData(account, signature); return _isValidSignatureAndData(account, signature);
} }
function onlyWithValidSignatureAndData(uint, bytes signature) public onlyValidSignatureAndData(signature) view {} function onlyWithValidSignatureAndData(uint, bytes memory signature)
public onlyValidSignatureAndData(signature) view
{
// solhint-disable-previous-line no-empty-blocks
}
function theWrongMethod(bytes) public pure {} function theWrongMethod(bytes memory) public pure {
// solhint-disable-previous-line no-empty-blocks
}
function tooShortMsgData() public onlyValidSignatureAndData("") view {} function tooShortMsgData() public onlyValidSignatureAndData("") view {
// solhint-disable-previous-line no-empty-blocks
}
} }
pragma solidity ^0.5.0;
import "../drafts/SignedSafeMath.sol";
contract SignedSafeMathMock {
function mul(int256 a, int256 b) public pure returns (int256) {
return SignedSafeMath.mul(a, b);
}
function div(int256 a, int256 b) public pure returns (int256) {
return SignedSafeMath.div(a, b);
}
function sub(int256 a, int256 b) public pure returns (int256) {
return SignedSafeMath.sub(a, b);
}
function add(int256 a, int256 b) public pure returns (int256) {
return SignedSafeMath.add(a, b);
}
}
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../access/roles/SignerRole.sol"; import "../access/roles/SignerRole.sol";
...@@ -8,6 +8,7 @@ contract SignerRoleMock is SignerRole { ...@@ -8,6 +8,7 @@ contract SignerRoleMock is SignerRole {
} }
function onlySignerMock() public view onlySigner { function onlySignerMock() public view onlySigner {
// solhint-disable-previous-line no-empty-blocks
} }
// Causes a compilation error if super._removeSigner is not internal // Causes a compilation error if super._removeSigner is not internal
......
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../token/ERC20/IERC20.sol"; import "../token/ERC20/IERC20.sol";
import "../crowdsale/validation/TimedCrowdsale.sol"; import "../crowdsale/validation/TimedCrowdsale.sol";
contract TimedCrowdsaleImpl is TimedCrowdsale { contract TimedCrowdsaleImpl is TimedCrowdsale {
constructor (uint256 openingTime, uint256 closingTime, uint256 rate, address wallet, IERC20 token) constructor (uint256 openingTime, uint256 closingTime, uint256 rate, address payable wallet, IERC20 token)
public public
Crowdsale(rate, wallet, token) Crowdsale(rate, wallet, token)
TimedCrowdsale(openingTime, closingTime) TimedCrowdsale(openingTime, closingTime)
{} {
// solhint-disable-previous-line no-empty-blocks
}
} }
pragma solidity ^0.5.0;
import "../access/roles/WhitelistAdminRole.sol";
contract WhitelistAdminRoleMock is WhitelistAdminRole {
function removeWhitelistAdmin(address account) public {
_removeWhitelistAdmin(account);
}
function onlyWhitelistAdminMock() public view onlyWhitelistAdmin {
// solhint-disable-previous-line no-empty-blocks
}
// Causes a compilation error if super._removeWhitelistAdmin is not internal
function _removeWhitelistAdmin(address account) internal {
super._removeWhitelistAdmin(account);
}
}
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../token/ERC20/IERC20.sol"; import "../token/ERC20/IERC20.sol";
import "../crowdsale/validation/WhitelistCrowdsale.sol"; import "../crowdsale/validation/WhitelistCrowdsale.sol";
...@@ -6,5 +6,7 @@ import "../crowdsale/Crowdsale.sol"; ...@@ -6,5 +6,7 @@ import "../crowdsale/Crowdsale.sol";
contract WhitelistCrowdsaleImpl is Crowdsale, WhitelistCrowdsale { contract WhitelistCrowdsaleImpl is Crowdsale, WhitelistCrowdsale {
constructor (uint256 _rate, address _wallet, IERC20 _token) Crowdsale(_rate, _wallet, _token) public {} constructor (uint256 _rate, address payable _wallet, IERC20 _token) public Crowdsale(_rate, _wallet, _token) {
// solhint-disable-previous-line no-empty-blocks
}
} }
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
import "../access/roles/WhitelistedRole.sol"; import "../access/roles/WhitelistedRole.sol";
contract WhitelistedRoleMock is WhitelistedRole { contract WhitelistedRoleMock is WhitelistedRole {
function onlyWhitelistedMock() public view onlyWhitelisted { function onlyWhitelistedMock() public view onlyWhitelisted {
// solhint-disable-previous-line no-empty-blocks
} }
} }
pragma solidity ^0.4.24;
import "../access/roles/WhitelisterRole.sol";
contract WhitelisterRoleMock is WhitelisterRole {
function removeWhitelister(address account) public {
_removeWhitelister(account);
}
function onlyWhitelisterMock() public view onlyWhitelister {
}
// Causes a compilation error if super._removeWhitelister is not internal
function _removeWhitelister(address account) internal {
super._removeWhitelister(account);
}
}
pragma solidity ^0.4.24; pragma solidity ^0.5.0;
/** /**
* @title Ownable * @title Ownable
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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