Commit e159856b by Francisco Giordano

Merge tag 'v2.3.0' of github.com:OpenZeppelin/openzeppelin-solidity

2.3.0
parents b11ffceb 132e442c
...@@ -6,7 +6,7 @@ about: Report a bug in OpenZeppelin ...@@ -6,7 +6,7 @@ about: Report a bug in OpenZeppelin
<!-- Briefly describe the issue you're experiencing. Tell us what you were trying to do and what happened instead. --> <!-- Briefly describe the issue you're experiencing. Tell us what you were trying to do and what happened instead. -->
<!-- Remember, this is not a place to ask for help debugging code. For that, we welcome you in the OpenZeppelin Slack channel: https://slack.openzeppelin.org/. --> <!-- Remember, this is not a place to ask for help debugging code. For that, we welcome you in the Zeppelin Forum: https://forum.zeppelin.solutions/. -->
**💻 Environment** **💻 Environment**
......
# Configuration for probot-stale - https://github.com/probot/stale
# Number of days of inactivity before an Issue or Pull Request becomes stale
daysUntilStale: 15
# Number of days of inactivity before an Issue or Pull Request with the stale label is closed.
# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.
daysUntilClose: 15
# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable
exemptLabels:
- on hold
# Set to true to ignore issues in a project (defaults to false)
exemptProjects: false
# Set to true to ignore issues in a milestone (defaults to false)
exemptMilestones: false
# Set to true to ignore issues with an assignee (defaults to false)
exemptAssignees: false
# Label to use when marking as stale
staleLabel: stale
# Comment to post when marking as stale. Set to `false` to disable
markComment: >
Hi all!
This Pull Request has not had any recent activity, is it still relevant? If so, what is blocking it?
Is there anything we can do to help move it forward?
Thanks!
# Comment to post when removing the stale label.
# unmarkComment: >
# Your comment here.
# Comment to post when closing a stale Issue or Pull Request.
closeComment: >
Hi folks!
This Pull Request is being closed as there was no response to the previous prompt.
However, please leave a comment whenever you're ready to resume, so it can be reopened.
Thanks again!
# Limit the number of actions per hour, from 1-30. Default is 30
limitPerRun: 30
# Limit to only `issues` or `pulls`
only: pulls
# Optionally, specify configuration settings that are specific to just 'issues' or 'pulls':
# pulls:
# daysUntilStale: 30
# markComment: >
# This pull request has been automatically marked as stale because it has not had
# recent activity. It will be closed if no further activity occurs. Thank you
# for your contributions.
# issues:
# exemptLabels:
# - confirmed
...@@ -42,3 +42,7 @@ build/ ...@@ -42,3 +42,7 @@ build/
# IntelliJ IDE # IntelliJ IDE
.idea .idea
# docsite artifacts
docsite-build
docs/api
...@@ -2,10 +2,11 @@ ...@@ -2,10 +2,11 @@
"extends": "default", "extends": "default",
"rules": { "rules": {
"indent": ["error", 4], "indent": ["error", 4],
"func-order": false,
"bracket-align": false, "bracket-align": false,
"compiler-fixed": false, "compiler-fixed": false,
"no-simple-event-func-name": false, "no-simple-event-func-name": false,
"separate-by-one-line-in-contract": false,
"two-lines-top-level-separator": false "two-lines-top-level-separator": false
} }
} }
# Changelog # Changelog
## 2.3.0 (2019-05-27)
### New features:
* `ERC1820`: added support for interacting with the [ERC1820](https://eips.ethereum.org/EIPS/eip-1820) registry contract (`IERC1820Registry`), as well as base contracts that can be registered as implementers there. ([#1677](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1677))
* `ERC777`: support for the [ERC777 token](https://eips.ethereum.org/EIPS/eip-777), which has multiple improvements over `ERC20` (but is backwards compatible with it) such as built-in burning, a more straightforward permission system, and optional sender and receiver hooks on transfer (mandatory for contracts!). ([#1684](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1684))
* All contracts now have revert reason strings, which give insight into error conditions, and help debug failing transactions. ([#1704](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1704))
### Improvements:
* Reverted the Solidity version bump done in v2.2.0, setting the minimum compiler version to v0.5.0, to prevent unexpected build breakage. Users are encouraged however to stay on top of new compiler releases, which usually include bugfixes. ([#1729](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1729))
### Bugfixes:
* `PostDeliveryCrowdsale`: some validations where skipped when paired with other crowdsale flavors, such as `AllowanceCrowdsale`, or `MintableCrowdsale` and `ERC20Capped`, which could cause buyers to not be able to claim their purchased tokens. ([#1721](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1721))
* `ERC20._transfer`: the `from` argument was allowed to be the zero address, so it was possible to internally trigger a transfer of 0 tokens from the zero address. This address is not a valid destinatary of transfers, nor can it give or receive allowance, so this behavior was inconsistent. It now reverts. ([#1752](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1752))
## 2.2.2 (2019-08-12) ## 2.2.2 (2019-08-12)
### New features: ### New features:
...@@ -14,7 +28,7 @@ ...@@ -14,7 +28,7 @@
### New features: ### New features:
* `ERC20Snapshot`: create snapshots on demand of the token balances and total supply, to later retrieve and e.g. calculate dividends at a past time. ([#1617](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1617)) * `ERC20Snapshot`: create snapshots on demand of the token balances and total supply, to later retrieve and e.g. calculate dividends at a past time. ([#1617](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1617))
* `SafeERC20`: `ERC20` contracts with no return value (i.e. that revert on failure) are now supported. ([#1655](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/)) * `SafeERC20`: `ERC20` contracts with no return value (i.e. that revert on failure) are now supported. ([#1655](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1655))
* `ERC20`: added internal `_approve(address owner, address spender, uint256 value)`, allowing derived contracts to set the allowance of arbitrary accounts. ([#1609](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1609)) * `ERC20`: added internal `_approve(address owner, address spender, uint256 value)`, allowing derived contracts to set the allowance of arbitrary accounts. ([#1609](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1609))
* `ERC20Metadata`: added internal `_setTokenURI(string memory tokenURI)`. ([#1618](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1618)) * `ERC20Metadata`: added internal `_setTokenURI(string memory tokenURI)`. ([#1618](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1618))
* `TimedCrowdsale`: added internal `_extendTime(uint256 newClosingTime)` as well as `TimedCrowdsaleExtended(uint256 prevClosingTime, uint256 newClosingTime)` event allowing to extend the crowdsale, as long as it hasn't already closed. * `TimedCrowdsale`: added internal `_extendTime(uint256 newClosingTime)` as well as `TimedCrowdsaleExtended(uint256 prevClosingTime, uint256 newClosingTime)` event allowing to extend the crowdsale, as long as it hasn't already closed.
...@@ -23,14 +37,14 @@ ...@@ -23,14 +37,14 @@
* Upgraded the minimum compiler version to v0.5.2: this removes many Solidity warnings that were false positives. ([#1606](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1606)) * Upgraded the minimum compiler version to v0.5.2: this removes many Solidity warnings that were false positives. ([#1606](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1606))
* `ECDSA`: `recover` no longer accepts malleable signatures (those using upper-range values for `s`, or 0/1 for `v`). ([#1622](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1622)) * `ECDSA`: `recover` no longer accepts malleable signatures (those using upper-range values for `s`, or 0/1 for `v`). ([#1622](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1622))
* `ERC721`'s transfers are now more gas efficient due to removal of unnecessary `SafeMath` calls. ([#1610](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1610)) * `ERC721`'s transfers are now more gas efficient due to removal of unnecessary `SafeMath` calls. ([#1610](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1610))
* `Counter`'s API has been improved, and is now used by `ERC721` (though it is still in `drafts`). ([#1610](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1610))
* Fixed variable shadowing issues. ([#1606](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1606)) * Fixed variable shadowing issues. ([#1606](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1606))
### Bugfixes: ### Bugfixes:
* (minor) `SafeERC20`: `safeApprove` wasn't properly checking for a zero allowance when attempting to set a non-zero allowance. ([#1647](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1647)) * (minor) `SafeERC20`: `safeApprove` wasn't properly checking for a zero allowance when attempting to set a non-zero allowance. ([#1647](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1647))
### Breaking changes: ### Breaking changes in drafts:
* `TokenMetadata` (in drafts) has been renamed to `ERC20Metadata`. ([#1618](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1618)) * `TokenMetadata` has been renamed to `ERC20Metadata`. ([#1618](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1618))
* The library `Counter` has been renamed to `Counters` and its API has been improved. See an example in `ERC721`, lines [17](https://github.com/OpenZeppelin/openzeppelin-solidity/blob/3cb4a00fce1da76196ac0ac3a0ae9702b99642b5/contracts/token/ERC721/ERC721.sol#L17) and [204](https://github.com/OpenZeppelin/openzeppelin-solidity/blob/3cb4a00fce1da76196ac0ac3a0ae9702b99642b5/contracts/token/ERC721/ERC721.sol#L204). ([#1610](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1610))
## 2.1.3 (2019-02-26) ## 2.1.3 (2019-02-26)
* Backported `SafeERC20.safeApprove` bugfix. ([#1647](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1647)) * Backported `SafeERC20.safeApprove` bugfix. ([#1647](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1647))
......
We're building an improved documentation website. It's still in development and
contributions will be really appreciated.
All of the content for the site is in this repository. The guides are in the
[docs](/docs) directory, and the API Reference is extracted from comments in
the source code. If you want to help improve the content, this is the
repository you should be contributing to.
[`solidity-docgen`](https://github.com/OpenZeppelin/solidity-docgen/tree/next) is the
program that extracts the API Reference from source code.
The [`openzeppelin-docsite`](https://github.com/OpenZeppelin/openzeppelin-docsite/tree/next)
repository hosts the configuration for Docusaurus, the static site generator
that we use.
To run the docsite locally you should run `npm run docsite start` on this
repository. This will live reload as the guides are edited, but not with
changes to the source code comments, for that you need to restart the server.
This should be improved eventually (contributions welcome!).
The MIT License (MIT) The MIT License (MIT)
Copyright (c) 2016 Smart Contract Solutions, Inc. Copyright (c) 2016-2019 zOS Global Limited
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the a copy of this software and associated documentation files (the
......
...@@ -109,4 +109,5 @@ OpenZeppelin is released under the [MIT License](LICENSE). ...@@ -109,4 +109,5 @@ OpenZeppelin is released under the [MIT License](LICENSE).
[API docs]: https://docs.openzeppelin.org/v2.3.0/api/token/erc20 [API docs]: https://docs.openzeppelin.org/v2.3.0/api/token/erc20
[guides]: https://docs.openzeppelin.org/v2.3.0/get-started [guides]: https://docs.openzeppelin.org/v2.3.0/get-started
[forum]: https://forum.zeppelin.solutions [forum]: https://forum.zeppelin.solutions
[Zeppelin]: https://zeppelin.solutions
[contribution guide]: CONTRIBUTING.md [contribution guide]: CONTRIBUTING.md
...@@ -40,7 +40,7 @@ Once the CI run for the new tag is green, publish on npm under the `next` tag. Y ...@@ -40,7 +40,7 @@ Once the CI run for the new tag is green, publish on npm under the `next` tag. Y
npm publish --tag next npm publish --tag next
``` ```
Publish the release notes on GitHub and ask our community manager to announce the release candidate on at least Slack and Twitter. Publish the release notes on GitHub and the forum, and ask our community manager to announce the release candidate on at least Twitter.
## Creating the final release ## Creating the final release
......
---
sections:
- title: Library
contracts:
- Roles
- subdirectory: roles
---
> This page is incomplete. We're working to improve it for the next release. Stay tuned!
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
/** /**
* @title Roles * @title Roles
...@@ -10,31 +10,27 @@ library Roles { ...@@ -10,31 +10,27 @@ library Roles {
} }
/** /**
* @dev give an account access to this role * @dev Give an account access to this role.
*/ */
function add(Role storage role, address account) internal { function add(Role storage role, address account) internal {
require(account != address(0)); require(!has(role, account), "Roles: account already has role");
require(!has(role, account));
role.bearer[account] = true; role.bearer[account] = true;
} }
/** /**
* @dev remove an account's access to this role * @dev Remove an account's access to this role.
*/ */
function remove(Role storage role, address account) internal { function remove(Role storage role, address account) internal {
require(account != address(0)); require(has(role, account), "Roles: account does not have role");
require(has(role, account));
role.bearer[account] = false; role.bearer[account] = false;
} }
/** /**
* @dev check if an account has this role * @dev Check if an account has this role.
* @return bool * @return bool
*/ */
function has(Role storage role, address account) internal view returns (bool) { function has(Role storage role, address account) internal view returns (bool) {
require(account != address(0)); require(account != address(0), "Roles: account is the zero address");
return role.bearer[account]; return role.bearer[account];
} }
} }
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "@openzeppelin/upgrades/contracts/Initializable.sol"; import "@openzeppelin/upgrades/contracts/Initializable.sol";
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "@openzeppelin/upgrades/contracts/Initializable.sol"; import "@openzeppelin/upgrades/contracts/Initializable.sol";
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "@openzeppelin/upgrades/contracts/Initializable.sol"; import "@openzeppelin/upgrades/contracts/Initializable.sol";
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "@openzeppelin/upgrades/contracts/Initializable.sol"; import "@openzeppelin/upgrades/contracts/Initializable.sol";
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "@openzeppelin/upgrades/contracts/Initializable.sol"; import "@openzeppelin/upgrades/contracts/Initializable.sol";
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "@openzeppelin/upgrades/contracts/Initializable.sol"; import "@openzeppelin/upgrades/contracts/Initializable.sol";
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "@openzeppelin/upgrades/contracts/Initializable.sol"; import "@openzeppelin/upgrades/contracts/Initializable.sol";
...@@ -57,9 +57,9 @@ contract Crowdsale is Initializable, Context, ReentrancyGuard { ...@@ -57,9 +57,9 @@ contract Crowdsale is Initializable, Context, ReentrancyGuard {
* @param token Address of the token being sold * @param token Address of the token being sold
*/ */
function initialize(uint256 rate, address payable wallet, IERC20 token) public initializer { function initialize(uint256 rate, address payable wallet, IERC20 token) public initializer {
require(rate > 0); require(rate > 0, "Crowdsale: rate is 0");
require(wallet != address(0)); require(wallet != address(0), "Crowdsale: wallet is the zero address");
require(address(token) != address(0)); require(address(token) != address(0), "Crowdsale: token is the zero address");
_rate = rate; _rate = rate;
_wallet = wallet; _wallet = wallet;
...@@ -143,8 +143,8 @@ contract Crowdsale is Initializable, Context, ReentrancyGuard { ...@@ -143,8 +143,8 @@ contract Crowdsale is Initializable, Context, ReentrancyGuard {
* @param weiAmount Value in wei involved in the purchase * @param weiAmount Value in wei involved in the purchase
*/ */
function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal view { function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal view {
require(beneficiary != address(0)); require(beneficiary != address(0), "Crowdsale: beneficiary is the zero address");
require(weiAmount != 0); require(weiAmount != 0, "Crowdsale: weiAmount is 0");
} }
/** /**
......
---
title: Crowdsales
sections:
- title: Core
contracts:
- Crowdsale
- subdirectory: emission
- subdirectory: price
- subdirectory: validation
- subdirectory: distribution
---
> This page is incomplete. We're working to improve it for the next release. Stay tuned!
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "@openzeppelin/upgrades/contracts/Initializable.sol"; import "@openzeppelin/upgrades/contracts/Initializable.sol";
import "../../math/SafeMath.sol"; import "../../math/SafeMath.sol";
...@@ -28,8 +28,8 @@ contract FinalizableCrowdsale is Initializable, TimedCrowdsale { ...@@ -28,8 +28,8 @@ contract FinalizableCrowdsale is Initializable, TimedCrowdsale {
* work. Calls the contract's finalization function. * work. Calls the contract's finalization function.
*/ */
function finalize() public { function finalize() public {
require(!_finalized); require(!_finalized, "FinalizableCrowdsale: already finalized");
require(hasClosed()); require(hasClosed(), "FinalizableCrowdsale: not closed");
_finalized = true; _finalized = true;
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "@openzeppelin/upgrades/contracts/Initializable.sol"; import "@openzeppelin/upgrades/contracts/Initializable.sol";
import "../validation/TimedCrowdsale.sol"; import "../validation/TimedCrowdsale.sol";
import "../../math/SafeMath.sol"; import "../../math/SafeMath.sol";
import "../../ownership/Secondary.sol";
import "../../token/ERC20/IERC20.sol";
/** /**
* @title PostDeliveryCrowdsale * @title PostDeliveryCrowdsale
...@@ -13,16 +15,25 @@ contract PostDeliveryCrowdsale is Initializable, TimedCrowdsale { ...@@ -13,16 +15,25 @@ contract PostDeliveryCrowdsale is Initializable, TimedCrowdsale {
mapping(address => uint256) private _balances; mapping(address => uint256) private _balances;
function initialize() public initializer {
// conditional added to make initializer idempotent in case of diamond inheritance
if (address(_vault) == address(0)) {
_vault = new __unstable__TokenVault();
_vault.initialize(address(this));
}
}
/** /**
* @dev Withdraw tokens only after crowdsale ends. * @dev Withdraw tokens only after crowdsale ends.
* @param beneficiary Whose tokens will be withdrawn. * @param beneficiary Whose tokens will be withdrawn.
*/ */
function withdrawTokens(address beneficiary) public { function withdrawTokens(address beneficiary) public {
require(hasClosed()); require(hasClosed(), "PostDeliveryCrowdsale: not closed");
uint256 amount = _balances[beneficiary]; uint256 amount = _balances[beneficiary];
require(amount > 0); require(amount > 0, "PostDeliveryCrowdsale: beneficiary is not due any tokens");
_balances[beneficiary] = 0; _balances[beneficiary] = 0;
_deliverTokens(beneficiary, amount); _vault.transfer(token(), beneficiary, amount);
} }
/** /**
...@@ -33,12 +44,35 @@ contract PostDeliveryCrowdsale is Initializable, TimedCrowdsale { ...@@ -33,12 +44,35 @@ contract PostDeliveryCrowdsale is Initializable, TimedCrowdsale {
} }
/** /**
* @dev Overrides parent by storing balances instead of issuing tokens right away. * @dev Overrides parent by storing due balances, and delivering tokens to the vault instead of the end user. This
* ensures that the tokens will be available by the time they are withdrawn (which may not be the case if
* `_deliverTokens` was called later).
* @param beneficiary Token purchaser * @param beneficiary Token purchaser
* @param tokenAmount Amount of tokens purchased * @param tokenAmount Amount of tokens purchased
*/ */
function _processPurchase(address beneficiary, uint256 tokenAmount) internal { function _processPurchase(address beneficiary, uint256 tokenAmount) internal {
_balances[beneficiary] = _balances[beneficiary].add(tokenAmount); _balances[beneficiary] = _balances[beneficiary].add(tokenAmount);
_deliverTokens(address(_vault), tokenAmount);
}
__unstable__TokenVault private _vault;
uint256[49] private ______gap;
}
/**
* @title __unstable__TokenVault
* @dev Similar to an Escrow for tokens, this contract allows its primary account to spend its tokens as it sees fit.
* This contract is an internal helper for PostDeliveryCrowdsale, and should not be used outside of this context.
*/
// solhint-disable-next-line contract-name-camelcase
contract __unstable__TokenVault is Initializable, Secondary {
function initialize(address sender) public initializer {
Secondary.initialize(sender);
}
function transfer(IERC20 token, address to, uint256 amount) public onlyPrimary {
token.transfer(to, amount);
} }
uint256[50] private ______gap; uint256[50] private ______gap;
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "@openzeppelin/upgrades/contracts/Initializable.sol"; import "@openzeppelin/upgrades/contracts/Initializable.sol";
...@@ -9,10 +9,10 @@ import "../../payment/escrow/RefundEscrow.sol"; ...@@ -9,10 +9,10 @@ import "../../payment/escrow/RefundEscrow.sol";
/** /**
* @title RefundableCrowdsale * @title RefundableCrowdsale
* @dev Extension of FinalizableCrowdsale contract that adds a funding goal, and the possibility of users * @dev Extension of `FinalizableCrowdsale` contract that adds a funding goal, and the possibility of users
* getting a refund if goal is not met. * getting a refund if goal is not met.
* *
* Deprecated, use RefundablePostDeliveryCrowdsale instead. Note that if you allow tokens to be traded before the goal * Deprecated, use `RefundablePostDeliveryCrowdsale` instead. Note that if you allow tokens to be traded before the goal
* is met, then an attack is possible in which the attacker purchases tokens from the crowdsale and when they sees that * is met, then an attack is possible in which the attacker purchases tokens from the crowdsale and when they sees that
* the goal is unlikely to be met, they sell their tokens (possibly at a discount). The attacker will be refunded when * the goal is unlikely to be met, they sell their tokens (possibly at a discount). The attacker will be refunded when
* the crowdsale is finalized, and the users that purchased from them will be left with worthless tokens. * the crowdsale is finalized, and the users that purchased from them will be left with worthless tokens.
...@@ -34,7 +34,7 @@ contract RefundableCrowdsale is Initializable, Context, FinalizableCrowdsale { ...@@ -34,7 +34,7 @@ contract RefundableCrowdsale is Initializable, Context, FinalizableCrowdsale {
// FinalizableCrowdsale depends on TimedCrowdsale // FinalizableCrowdsale depends on TimedCrowdsale
assert(TimedCrowdsale._hasBeenInitialized()); assert(TimedCrowdsale._hasBeenInitialized());
require(goal > 0); require(goal > 0, "RefundableCrowdsale: goal is 0");
// conditional added to make initializer idempotent in case of diamond inheritance // conditional added to make initializer idempotent in case of diamond inheritance
if (address(_escrow) == address(0)) { if (address(_escrow) == address(0)) {
_escrow = new RefundEscrow(); _escrow = new RefundEscrow();
...@@ -51,12 +51,12 @@ contract RefundableCrowdsale is Initializable, Context, FinalizableCrowdsale { ...@@ -51,12 +51,12 @@ contract RefundableCrowdsale is Initializable, Context, 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 payable refundee) public { function claimRefund(address payable refundee) public {
require(finalized()); require(finalized(), "RefundableCrowdsale: not finalized");
require(!goalReached()); require(!goalReached(), "RefundableCrowdsale: goal reached");
_escrow.withdraw(refundee); _escrow.withdraw(refundee);
} }
...@@ -70,7 +70,7 @@ contract RefundableCrowdsale is Initializable, Context, FinalizableCrowdsale { ...@@ -70,7 +70,7 @@ contract RefundableCrowdsale is Initializable, Context, FinalizableCrowdsale {
} }
/** /**
* @dev escrow finalization task, called when finalize() is called * @dev Escrow finalization task, called when finalize() is called.
*/ */
function _finalization() internal { function _finalization() internal {
if (goalReached()) { if (goalReached()) {
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "@openzeppelin/upgrades/contracts/Initializable.sol"; import "@openzeppelin/upgrades/contracts/Initializable.sol";
...@@ -13,8 +13,8 @@ import "./PostDeliveryCrowdsale.sol"; ...@@ -13,8 +13,8 @@ import "./PostDeliveryCrowdsale.sol";
*/ */
contract RefundablePostDeliveryCrowdsale is Initializable, RefundableCrowdsale, PostDeliveryCrowdsale { contract RefundablePostDeliveryCrowdsale is Initializable, RefundableCrowdsale, PostDeliveryCrowdsale {
function withdrawTokens(address beneficiary) public { function withdrawTokens(address beneficiary) public {
require(finalized()); require(finalized(), "RefundablePostDeliveryCrowdsale: not finalized");
require(goalReached()); require(goalReached(), "RefundablePostDeliveryCrowdsale: goal not reached");
super.withdrawTokens(beneficiary); super.withdrawTokens(beneficiary);
} }
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "@openzeppelin/upgrades/contracts/Initializable.sol"; import "@openzeppelin/upgrades/contracts/Initializable.sol";
import "../Crowdsale.sol"; import "../Crowdsale.sol";
...@@ -19,12 +19,12 @@ contract AllowanceCrowdsale is Initializable, Crowdsale { ...@@ -19,12 +19,12 @@ contract AllowanceCrowdsale is Initializable, Crowdsale {
/** /**
* @dev Constructor, takes token wallet address. * @dev Constructor, takes token wallet address.
* @param tokenWallet Address holding the tokens, which has approved allowance to the crowdsale * @param tokenWallet Address holding the tokens, which has approved allowance to the crowdsale.
*/ */
function initialize(address tokenWallet) public initializer { function initialize(address tokenWallet) public initializer {
assert(Crowdsale._hasBeenInitialized()); assert(Crowdsale._hasBeenInitialized());
require(tokenWallet != address(0)); require(tokenWallet != address(0), "AllowanceCrowdsale: token wallet is the zero address");
_tokenWallet = tokenWallet; _tokenWallet = tokenWallet;
} }
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "@openzeppelin/upgrades/contracts/Initializable.sol"; import "@openzeppelin/upgrades/contracts/Initializable.sol";
import "../Crowdsale.sol"; import "../Crowdsale.sol";
...@@ -17,7 +17,10 @@ contract MintedCrowdsale is Initializable, Crowdsale { ...@@ -17,7 +17,10 @@ contract MintedCrowdsale is Initializable, Crowdsale {
*/ */
function _deliverTokens(address beneficiary, uint256 tokenAmount) internal { function _deliverTokens(address beneficiary, uint256 tokenAmount) internal {
// Potentially dangerous assumption about the type of the token. // Potentially dangerous assumption about the type of the token.
require(ERC20Mintable(address(token())).mint(beneficiary, tokenAmount)); require(
ERC20Mintable(address(token())).mint(beneficiary, tokenAmount),
"MintedCrowdsale: minting failed"
);
} }
uint256[50] private ______gap; uint256[50] private ______gap;
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "@openzeppelin/upgrades/contracts/Initializable.sol"; import "@openzeppelin/upgrades/contracts/Initializable.sol";
import "../validation/TimedCrowdsale.sol"; import "../validation/TimedCrowdsale.sol";
...@@ -24,8 +24,9 @@ contract IncreasingPriceCrowdsale is Initializable, TimedCrowdsale { ...@@ -24,8 +24,9 @@ contract IncreasingPriceCrowdsale is Initializable, TimedCrowdsale {
function initialize(uint256 initialRate, uint256 finalRate) public initializer { function initialize(uint256 initialRate, uint256 finalRate) public initializer {
assert(TimedCrowdsale._hasBeenInitialized()); assert(TimedCrowdsale._hasBeenInitialized());
require(finalRate > 0); require(finalRate > 0, "IncreasingPriceCrowdsale: final rate is 0");
require(initialRate > finalRate); // solhint-disable-next-line max-line-length
require(initialRate > finalRate, "IncreasingPriceCrowdsale: initial rate is not greater than final rate");
_initialRate = initialRate; _initialRate = initialRate;
_finalRate = finalRate; _finalRate = finalRate;
} }
...@@ -35,7 +36,7 @@ contract IncreasingPriceCrowdsale is Initializable, TimedCrowdsale { ...@@ -35,7 +36,7 @@ contract IncreasingPriceCrowdsale is Initializable, TimedCrowdsale {
* all calls to it are a mistake. * all calls to it are a mistake.
*/ */
function rate() public view returns (uint256) { function rate() public view returns (uint256) {
revert(); revert("IncreasingPriceCrowdsale: rate() called");
} }
/** /**
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "@openzeppelin/upgrades/contracts/Initializable.sol"; import "@openzeppelin/upgrades/contracts/Initializable.sol";
import "../../math/SafeMath.sol"; import "../../math/SafeMath.sol";
...@@ -20,7 +20,7 @@ contract CappedCrowdsale is Initializable, Crowdsale { ...@@ -20,7 +20,7 @@ contract CappedCrowdsale is Initializable, Crowdsale {
function initialize(uint256 cap) public initializer { function initialize(uint256 cap) public initializer {
assert(Crowdsale._hasBeenInitialized()); assert(Crowdsale._hasBeenInitialized());
require(cap > 0); require(cap > 0, "CappedCrowdsale: cap is 0");
_cap = cap; _cap = cap;
} }
...@@ -46,7 +46,7 @@ contract CappedCrowdsale is Initializable, Crowdsale { ...@@ -46,7 +46,7 @@ contract CappedCrowdsale is Initializable, Crowdsale {
*/ */
function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal view { function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal view {
super._preValidatePurchase(beneficiary, weiAmount); super._preValidatePurchase(beneficiary, weiAmount);
require(weiRaised().add(weiAmount) <= _cap); require(weiRaised().add(weiAmount) <= _cap, "CappedCrowdsale: cap exceeded");
} }
uint256[50] private ______gap; uint256[50] private ______gap;
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "@openzeppelin/upgrades/contracts/Initializable.sol"; import "@openzeppelin/upgrades/contracts/Initializable.sol";
import "../../math/SafeMath.sol"; import "../../math/SafeMath.sol";
...@@ -55,11 +55,12 @@ contract IndividuallyCappedCrowdsale is Initializable, Crowdsale, CapperRole { ...@@ -55,11 +55,12 @@ contract IndividuallyCappedCrowdsale is Initializable, Crowdsale, CapperRole {
*/ */
function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal view { function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal view {
super._preValidatePurchase(beneficiary, weiAmount); super._preValidatePurchase(beneficiary, weiAmount);
require(_contributions[beneficiary].add(weiAmount) <= _caps[beneficiary]); // solhint-disable-next-line max-line-length
require(_contributions[beneficiary].add(weiAmount) <= _caps[beneficiary], "IndividuallyCappedCrowdsale: beneficiary's cap exceeded");
} }
/** /**
* @dev Extend parent behavior to update beneficiary contributions * @dev Extend parent behavior to update beneficiary contributions.
* @param beneficiary Token purchaser * @param beneficiary Token purchaser
* @param weiAmount Amount of wei contributed * @param weiAmount Amount of wei contributed
*/ */
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "@openzeppelin/upgrades/contracts/Initializable.sol"; import "@openzeppelin/upgrades/contracts/Initializable.sol";
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "@openzeppelin/upgrades/contracts/Initializable.sol"; import "@openzeppelin/upgrades/contracts/Initializable.sol";
import "../../math/SafeMath.sol"; import "../../math/SafeMath.sol";
...@@ -25,7 +25,7 @@ contract TimedCrowdsale is Initializable, Crowdsale { ...@@ -25,7 +25,7 @@ contract TimedCrowdsale is Initializable, Crowdsale {
* @dev Reverts if not in crowdsale time range. * @dev Reverts if not in crowdsale time range.
*/ */
modifier onlyWhileOpen { modifier onlyWhileOpen {
require(isOpen()); require(isOpen(), "TimedCrowdsale: not open");
_; _;
} }
...@@ -38,8 +38,9 @@ contract TimedCrowdsale is Initializable, Crowdsale { ...@@ -38,8 +38,9 @@ contract TimedCrowdsale is Initializable, Crowdsale {
assert(Crowdsale._hasBeenInitialized()); assert(Crowdsale._hasBeenInitialized());
// solhint-disable-next-line not-rely-on-time // solhint-disable-next-line not-rely-on-time
require(openingTime >= block.timestamp); require(openingTime >= block.timestamp, "TimedCrowdsale: opening time is before current time");
require(closingTime > openingTime); // solhint-disable-next-line max-line-length
require(closingTime > openingTime, "TimedCrowdsale: opening time is not before closing time");
_openingTime = openingTime; _openingTime = openingTime;
_closingTime = closingTime; _closingTime = closingTime;
...@@ -81,7 +82,7 @@ contract TimedCrowdsale is Initializable, Crowdsale { ...@@ -81,7 +82,7 @@ contract TimedCrowdsale is Initializable, Crowdsale {
} }
/** /**
* @dev Extend parent behavior requiring to be within contributing period * @dev Extend parent behavior requiring to be within contributing period.
* @param beneficiary Token purchaser * @param beneficiary Token purchaser
* @param weiAmount Amount of wei contributed * @param weiAmount Amount of wei contributed
*/ */
...@@ -90,12 +91,13 @@ contract TimedCrowdsale is Initializable, Crowdsale { ...@@ -90,12 +91,13 @@ contract TimedCrowdsale is Initializable, Crowdsale {
} }
/** /**
* @dev Extend crowdsale * @dev Extend crowdsale.
* @param newClosingTime Crowdsale closing time * @param newClosingTime Crowdsale closing time
*/ */
function _extendTime(uint256 newClosingTime) internal { function _extendTime(uint256 newClosingTime) internal {
require(!hasClosed()); require(!hasClosed(), "TimedCrowdsale: already closed");
require(newClosingTime > _closingTime); // solhint-disable-next-line max-line-length
require(newClosingTime > _closingTime, "TimedCrowdsale: new closing time is before current closing time");
emit TimedCrowdsaleExtended(_closingTime, newClosingTime); emit TimedCrowdsaleExtended(_closingTime, newClosingTime);
_closingTime = newClosingTime; _closingTime = newClosingTime;
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "../Crowdsale.sol"; import "../Crowdsale.sol";
import "../../access/roles/WhitelistedRole.sol"; import "../../access/roles/WhitelistedRole.sol";
...@@ -21,7 +21,7 @@ contract WhitelistCrowdsale is Initializable, WhitelistedRole, Crowdsale { ...@@ -21,7 +21,7 @@ contract WhitelistCrowdsale is Initializable, WhitelistedRole, Crowdsale {
* @param _weiAmount Amount of wei contributed * @param _weiAmount Amount of wei contributed
*/ */
function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal view { function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal view {
require(isWhitelisted(_beneficiary)); require(isWhitelisted(_beneficiary), "WhitelistCrowdsale: beneficiary doesn't have the Whitelisted role");
super._preValidatePurchase(_beneficiary, _weiAmount); super._preValidatePurchase(_beneficiary, _weiAmount);
} }
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
/** /**
* @title Elliptic curve signature operations * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
* @dev Based on https://gist.github.com/axic/5b33912c6f61ae6fd96d6c4a47afde6d *
* TODO Remove this library once solidity supports passing a signature to ecrecover. * These functions can be used to verify that a message was signed by the holder
* See https://github.com/ethereum/solidity/issues/864 * of the private keys of a given address.
*/ */
library ECDSA { library ECDSA {
/** /**
* @dev Recover signer address from a message by using their signature * @dev Returns the address that signed a hashed message (`hash`) with
* @param hash bytes32 message, the hash is the signed message. What is recovered is the signer address. * `signature`. This address can then be used for verification purposes.
* @param signature bytes signature, the signature is generated using web3.eth.sign() *
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* (.note) This call _does not revert_ if the signature is invalid, or
* if the signer is otherwise unable to be retrieved. In those scenarios,
* the zero address is returned.
*
* (.warning) `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise)
* be too long), and then calling `toEthSignedMessageHash` on it.
*/ */
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
// Check the signature length // Check the signature length
...@@ -55,9 +67,12 @@ library ECDSA { ...@@ -55,9 +67,12 @@ library ECDSA {
} }
/** /**
* toEthSignedMessageHash * @dev Returns an Ethereum Signed Message, created from a `hash`. This
* @dev prefix a bytes32 value with "\x19Ethereum Signed Message:" * replicates the behavior of the
* and hash the result * [`eth_sign`](https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign)
* JSON-RPC method.
*
* See `recover`.
*/ */
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
// 32 is the length in bytes of hash, // 32 is the length in bytes of hash,
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
/** /**
* @title MerkleProof * @dev These functions deal with verification of Merkle trees (hash trees),
* @dev Merkle proof verification based on
* https://github.com/ameensol/merkle-tree-solidity/blob/master/src/MerkleProof.sol
*/ */
library MerkleProof { library MerkleProof {
/** /**
* @dev Verifies a Merkle proof proving the existence of a leaf in a Merkle tree. Assumes that each pair of leaves * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* and each pair of pre-images are sorted. * defined by `root`. For this, a `proof` must be provided, containing
* @param proof Merkle proof containing sibling hashes on the branch from the leaf to the root of the Merkle tree * sibling hashes on the branch from the leaf to the root of the tree. Each
* @param root Merkle root * pair of leaves and each pair of pre-images are assumed to be sorted.
* @param leaf Leaf of Merkle tree
*/ */
function verify(bytes32[] memory 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;
......
---
sections:
- title: Libraries
contracts:
- ECDSA
- MerkleProof
---
This collection of libraries provides simple and safe ways to use different cryptographic primitives.
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "../math/SafeMath.sol"; import "../math/SafeMath.sol";
...@@ -6,7 +6,7 @@ import "../math/SafeMath.sol"; ...@@ -6,7 +6,7 @@ import "../math/SafeMath.sol";
* @title Counters * @title Counters
* @author Matt Condon (@shrugs) * @author Matt Condon (@shrugs)
* @dev Provides counters that can only be incremented or decremented by one. This can be used e.g. to track the number * @dev Provides counters that can only be incremented or decremented by one. This can be used e.g. to track the number
* of elements in a mapping, issuing ERC721 ids, or counting request ids * of elements in a mapping, issuing ERC721 ids, or counting request ids.
* *
* Include with `using Counters for Counters.Counter;` * Include with `using Counters for Counters.Counter;`
* Since it is not possible to overflow a 256 bit integer with increments of one, `increment` can skip the SafeMath * Since it is not possible to overflow a 256 bit integer with increments of one, `increment` can skip the SafeMath
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "@openzeppelin/upgrades/contracts/Initializable.sol"; import "@openzeppelin/upgrades/contracts/Initializable.sol";
import "../../token/ERC20/IERC20.sol"; import "../../token/ERC20/IERC20.sol";
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "@openzeppelin/upgrades/contracts/Initializable.sol"; import "@openzeppelin/upgrades/contracts/Initializable.sol";
import "../token/ERC20/IERC20.sol"; import "../token/ERC20/IERC20.sol";
...@@ -45,7 +45,7 @@ contract ERC20Migrator is Initializable { ...@@ -45,7 +45,7 @@ contract ERC20Migrator is Initializable {
* @param legacyToken address of the old token contract * @param legacyToken address of the old token contract
*/ */
function initialize(IERC20 legacyToken) public initializer { function initialize(IERC20 legacyToken) public initializer {
require(address(legacyToken) != address(0)); require(address(legacyToken) != address(0), "ERC20Migrator: legacy token is the zero address");
_legacyToken = legacyToken; _legacyToken = legacyToken;
} }
...@@ -69,9 +69,10 @@ contract ERC20Migrator is Initializable { ...@@ -69,9 +69,10 @@ contract ERC20Migrator is Initializable {
* @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(address(_newToken) == address(0)); require(address(_newToken) == address(0), "ERC20Migrator: migration already started");
require(address(newToken_) != address(0)); require(address(newToken_) != address(0), "ERC20Migrator: new token is the zero address");
require(newToken_.isMinter(address(this))); //solhint-disable-next-line max-line-length
require(newToken_.isMinter(address(this)), "ERC20Migrator: not a minter for new token");
_newToken = newToken_; _newToken = newToken_;
} }
...@@ -83,7 +84,7 @@ contract ERC20Migrator is Initializable { ...@@ -83,7 +84,7 @@ contract ERC20Migrator is Initializable {
* @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 {
require(address(_newToken) != address(0)); require(address(_newToken) != address(0), "ERC20Migrator: migration not started");
_legacyToken.safeTransferFrom(account, address(this), amount); _legacyToken.safeTransferFrom(account, address(this), amount);
_newToken.mint(account, amount); _newToken.mint(account, amount);
} }
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "@openzeppelin/upgrades/contracts/Initializable.sol"; import "@openzeppelin/upgrades/contracts/Initializable.sol";
import "../math/SafeMath.sol"; import "../math/SafeMath.sol";
...@@ -32,7 +32,7 @@ contract ERC20Snapshot is Initializable, ERC20 { ...@@ -32,7 +32,7 @@ contract ERC20Snapshot is Initializable, ERC20 {
} }
mapping (address => Snapshots) private _accountBalanceSnapshots; mapping (address => Snapshots) private _accountBalanceSnapshots;
Snapshots private _totalSupplySnaphots; Snapshots private _totalSupplySnapshots;
// Snapshot ids increase monotonically, with the first value being 1. An id of 0 is invalid. // Snapshot ids increase monotonically, with the first value being 1. An id of 0 is invalid.
Counters.Counter private _currentSnapshotId; Counters.Counter private _currentSnapshotId;
...@@ -57,7 +57,7 @@ contract ERC20Snapshot is Initializable, ERC20 { ...@@ -57,7 +57,7 @@ contract ERC20Snapshot is Initializable, ERC20 {
} }
function totalSupplyAt(uint256 snapshotId) public view returns(uint256) { function totalSupplyAt(uint256 snapshotId) public view returns(uint256) {
(bool snapshotted, uint256 value) = _valueAt(snapshotId, _totalSupplySnaphots); (bool snapshotted, uint256 value) = _valueAt(snapshotId, _totalSupplySnapshots);
return snapshotted ? value : totalSupply(); return snapshotted ? value : totalSupply();
} }
...@@ -102,8 +102,9 @@ contract ERC20Snapshot is Initializable, ERC20 { ...@@ -102,8 +102,9 @@ contract ERC20Snapshot is Initializable, ERC20 {
function _valueAt(uint256 snapshotId, Snapshots storage snapshots) function _valueAt(uint256 snapshotId, Snapshots storage snapshots)
private view returns (bool, uint256) private view returns (bool, uint256)
{ {
require(snapshotId > 0); require(snapshotId > 0, "ERC20Snapshot: id is 0");
require(snapshotId <= _currentSnapshotId.current()); // solhint-disable-next-line max-line-length
require(snapshotId <= _currentSnapshotId.current(), "ERC20Snapshot: nonexistent id");
uint256 index = snapshots.ids.findUpperBound(snapshotId); uint256 index = snapshots.ids.findUpperBound(snapshotId);
...@@ -119,7 +120,7 @@ contract ERC20Snapshot is Initializable, ERC20 { ...@@ -119,7 +120,7 @@ contract ERC20Snapshot is Initializable, ERC20 {
} }
function _updateTotalSupplySnapshot() private { function _updateTotalSupplySnapshot() private {
_updateSnapshot(_totalSupplySnaphots, totalSupply()); _updateSnapshot(_totalSupplySnapshots, totalSupply());
} }
function _updateSnapshot(Snapshots storage snapshots, uint256 currentValue) private { function _updateSnapshot(Snapshots storage snapshots, uint256 currentValue) private {
......
---
sections:
- title: ERC 20
contracts:
- ERC20Migrator
- ERC20Snapshot
- TokenVesting
- title: Miscellenous
contracts:
- Counters
- SignatureBouncer
- SignedSafeMath
- subdirectory: ERC1046
---
> This page is incomplete. We're working to improve it for the next release. Stay tuned!
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "@openzeppelin/upgrades/contracts/Initializable.sol"; import "@openzeppelin/upgrades/contracts/Initializable.sol";
...@@ -51,7 +51,7 @@ contract SignatureBouncer is Initializable, Context, SignerRole { ...@@ -51,7 +51,7 @@ contract SignatureBouncer is Initializable, Context, SignerRole {
} }
/** /**
* @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 memory signature) { modifier onlyValidSignature(bytes memory signature) {
require(_isValidSignature(_msgSender(), signature), "SignatureBouncer: invalid signature for caller"); require(_isValidSignature(_msgSender(), signature), "SignatureBouncer: invalid signature for caller");
...@@ -59,7 +59,7 @@ contract SignatureBouncer is Initializable, Context, SignerRole { ...@@ -59,7 +59,7 @@ contract SignatureBouncer is Initializable, Context, SignerRole {
} }
/** /**
* @dev requires that a valid signature with a specified method of a signer was provided * @dev Requires that a valid signature with a specified method of a signer was provided.
*/ */
modifier onlyValidSignatureAndMethod(bytes memory signature) { modifier onlyValidSignatureAndMethod(bytes memory signature) {
// solhint-disable-next-line max-line-length // solhint-disable-next-line max-line-length
...@@ -68,7 +68,7 @@ contract SignatureBouncer is Initializable, Context, SignerRole { ...@@ -68,7 +68,7 @@ contract SignatureBouncer is Initializable, Context, SignerRole {
} }
/** /**
* @dev requires that a valid signature with a specified method and params of a signer was provided * @dev Requires that a valid signature with a specified method and params of a signer was provided.
*/ */
modifier onlyValidSignatureAndData(bytes memory signature) { modifier onlyValidSignatureAndData(bytes memory signature) {
// solhint-disable-next-line max-line-length // solhint-disable-next-line max-line-length
...@@ -115,8 +115,8 @@ contract SignatureBouncer is Initializable, Context, SignerRole { ...@@ -115,8 +115,8 @@ contract SignatureBouncer is Initializable, Context, SignerRole {
} }
/** /**
* @dev internal function to convert a hash to an eth signed message * @dev Internal function to convert a hash to an eth signed message
* and then recover the signature and check it against the signer role * and then recover the signature and check it against the signer role.
* @return bool * @return bool
*/ */
function _isValidDataHash(bytes32 hash, bytes memory signature) internal view returns (bool) { function _isValidDataHash(bytes32 hash, bytes memory signature) internal view returns (bool) {
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
/** /**
* @title SignedSafeMath * @title SignedSafeMath
* @dev Signed math operations with safety checks that revert on error * @dev Signed math operations with safety checks that revert on error.
*/ */
library SignedSafeMath { library SignedSafeMath {
int256 constant private INT256_MIN = -2**255; int256 constant private INT256_MIN = -2**255;
...@@ -18,10 +18,10 @@ library SignedSafeMath { ...@@ -18,10 +18,10 @@ library SignedSafeMath {
return 0; return 0;
} }
require(!(a == -1 && b == INT256_MIN)); // This is the only case of overflow not detected by the check below require(!(a == -1 && b == INT256_MIN), "SignedSafeMath: multiplication overflow");
int256 c = a * b; int256 c = a * b;
require(c / a == b); require(c / a == b, "SignedSafeMath: multiplication overflow");
return c; return c;
} }
...@@ -30,8 +30,8 @@ library SignedSafeMath { ...@@ -30,8 +30,8 @@ library SignedSafeMath {
* @dev Integer division of two signed integers truncating the quotient, reverts on division by zero. * @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) { function div(int256 a, int256 b) internal pure returns (int256) {
require(b != 0); // Solidity only automatically asserts when dividing by 0 require(b != 0, "SignedSafeMath: division by zero");
require(!(b == -1 && a == INT256_MIN)); // This is the only case of overflow require(!(b == -1 && a == INT256_MIN), "SignedSafeMath: division overflow");
int256 c = a / b; int256 c = a / b;
...@@ -43,7 +43,7 @@ library SignedSafeMath { ...@@ -43,7 +43,7 @@ library SignedSafeMath {
*/ */
function sub(int256 a, int256 b) internal pure returns (int256) { function sub(int256 a, int256 b) internal pure returns (int256) {
int256 c = a - b; int256 c = a - b;
require((b >= 0 && c <= a) || (b < 0 && c > a)); require((b >= 0 && c <= a) || (b < 0 && c > a), "SignedSafeMath: subtraction overflow");
return c; return c;
} }
...@@ -53,7 +53,7 @@ library SignedSafeMath { ...@@ -53,7 +53,7 @@ library SignedSafeMath {
*/ */
function add(int256 a, int256 b) internal pure returns (int256) { function add(int256 a, int256 b) internal pure returns (int256) {
int256 c = a + b; int256 c = a + b;
require((b >= 0 && c >= a) || (b < 0 && c < a)); require((b >= 0 && c >= a) || (b < 0 && c < a), "SignedSafeMath: addition overflow");
return c; return c;
} }
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "@openzeppelin/upgrades/contracts/Initializable.sol"; import "@openzeppelin/upgrades/contracts/Initializable.sol";
import "../token/ERC20/SafeERC20.sol"; import "../token/ERC20/SafeERC20.sol";
...@@ -50,10 +50,12 @@ contract TokenVesting is Initializable, Ownable { ...@@ -50,10 +50,12 @@ contract TokenVesting is Initializable, Ownable {
function initialize(address beneficiary, uint256 start, uint256 cliffDuration, uint256 duration, bool revocable, address sender) public initializer { function initialize(address beneficiary, uint256 start, uint256 cliffDuration, uint256 duration, bool revocable, address sender) public initializer {
Ownable.initialize(sender); Ownable.initialize(sender);
require(beneficiary != address(0)); require(beneficiary != address(0), "TokenVesting: beneficiary is the zero address");
require(cliffDuration <= duration); // solhint-disable-next-line max-line-length
require(duration > 0); require(cliffDuration <= duration, "TokenVesting: cliff is longer than duration");
require(start.add(duration) > block.timestamp); require(duration > 0, "TokenVesting: duration is 0");
// solhint-disable-next-line max-line-length
require(start.add(duration) > block.timestamp, "TokenVesting: final time is before current time");
_beneficiary = beneficiary; _beneficiary = beneficiary;
_revocable = revocable; _revocable = revocable;
...@@ -118,7 +120,7 @@ contract TokenVesting is Initializable, Ownable { ...@@ -118,7 +120,7 @@ contract TokenVesting is Initializable, Ownable {
function release(IERC20 token) public { function release(IERC20 token) public {
uint256 unreleased = _releasableAmount(token); uint256 unreleased = _releasableAmount(token);
require(unreleased > 0); require(unreleased > 0, "TokenVesting: no tokens are due");
_released[address(token)] = _released[address(token)].add(unreleased); _released[address(token)] = _released[address(token)].add(unreleased);
...@@ -133,8 +135,8 @@ contract TokenVesting is Initializable, Ownable { ...@@ -133,8 +135,8 @@ contract TokenVesting is Initializable, Ownable {
* @param token ERC20 token which is being vested * @param token ERC20 token which is being vested
*/ */
function revoke(IERC20 token) public onlyOwner { function revoke(IERC20 token) public onlyOwner {
require(_revocable); require(_revocable, "TokenVesting: cannot revoke");
require(!_revoked[address(token)]); require(!_revoked[address(token)], "TokenVesting: token already revoked");
uint256 balance = token.balanceOf(address(this)); uint256 balance = token.balanceOf(address(this));
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "@openzeppelin/upgrades/contracts/Initializable.sol"; import "@openzeppelin/upgrades/contracts/Initializable.sol";
import "../crowdsale/validation/CappedCrowdsale.sol"; import "../crowdsale/validation/CappedCrowdsale.sol";
...@@ -55,7 +55,7 @@ contract SampleCrowdsale is Initializable, Crowdsale, CappedCrowdsale, Refundabl ...@@ -55,7 +55,7 @@ contract SampleCrowdsale is Initializable, Crowdsale, CappedCrowdsale, Refundabl
//As goal needs to be met for a successful crowdsale //As goal needs to be met for a successful crowdsale
//the value needs to less or equal than a cap which is limit for accepted funds //the value needs to less or equal than a cap which is limit for accepted funds
require(goal <= cap); require(goal <= cap, "SampleCrowdSale: goal is greater than cap");
} }
uint256[50] private ______gap; uint256[50] private ______gap;
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "@openzeppelin/upgrades/contracts/Initializable.sol"; import "@openzeppelin/upgrades/contracts/Initializable.sol";
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "@openzeppelin/upgrades/contracts/Initializable.sol"; import "@openzeppelin/upgrades/contracts/Initializable.sol";
import "./IERC165.sol"; import "./IERC165.sol";
/** /**
* @title ERC165 * @dev Implementation of the `IERC165` interface.
* @author Matt Condon (@shrugs) *
* @dev Implements ERC165 using a lookup table. * Contracts may inherit from this and call `_registerInterface` to declare
* their support of an interface.
*/ */
contract ERC165 is Initializable, IERC165 { contract ERC165 is Initializable, IERC165 {
bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;
/* /*
* 0x01ffc9a7 === * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7
* bytes4(keccak256('supportsInterface(bytes4)'))
*/ */
bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;
/** /**
* @dev a mapping of interface id to whether or not it's supported * @dev Mapping of interface ids to whether or not it's supported.
*/ */
mapping(bytes4 => bool) private _supportedInterfaces; mapping(bytes4 => bool) private _supportedInterfaces;
/**
* @dev A contract implementing SupportsInterfaceWithLookup
* implement ERC165 itself
*/
function initialize() public initializer { function initialize() public initializer {
// Derived contracts need only register support for their own interfaces,
// we register support for ERC165 itself here
_registerInterface(_INTERFACE_ID_ERC165); _registerInterface(_INTERFACE_ID_ERC165);
} }
/** /**
* @dev implement supportsInterface(bytes4) using a lookup table * @dev See `IERC165.supportsInterface`.
*
* Time complexity O(1), guaranteed to always use less than 30 000 gas.
*/ */
function supportsInterface(bytes4 interfaceId) public view returns (bool) { function supportsInterface(bytes4 interfaceId) public view returns (bool) {
return _supportedInterfaces[interfaceId]; return _supportedInterfaces[interfaceId];
} }
/** /**
* @dev internal method for registering an interface * @dev Registers the contract as an implementer of the interface defined by
* `interfaceId`. Support of the actual ERC165 interface is automatic and
* registering its interface id is not required.
*
* See `IERC165.supportsInterface`.
*
* Requirements:
*
* - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`).
*/ */
function _registerInterface(bytes4 interfaceId) internal { function _registerInterface(bytes4 interfaceId) internal {
require(interfaceId != 0xffffffff); require(interfaceId != 0xffffffff, "ERC165: invalid interface id");
_supportedInterfaces[interfaceId] = true; _supportedInterfaces[interfaceId] = true;
} }
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
/** /**
* @title ERC165Checker * @dev Library used to query support of an interface declared via `IERC165`.
* @dev Use `using ERC165Checker for address`; to include this library *
* https://eips.ethereum.org/EIPS/eip-165 * Note that these functions return the actual result of the query: they do not
* `revert` if an interface is not supported. It is up to the caller to decide
* what to do in these cases.
*/ */
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 _INTERFACE_ID_INVALID = 0xffffffff; bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff;
bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;
/* /*
* 0x01ffc9a7 === * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7
* bytes4(keccak256('supportsInterface(bytes4)'))
*/ */
bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;
/** /**
* @notice Query if a contract supports ERC165 * @dev Returns true if `account` supports the `IERC165` interface,
* @param account The address of the contract to query for support of ERC165
* @return true if the contract at account implements ERC165
*/ */
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
...@@ -28,12 +27,10 @@ library ERC165Checker { ...@@ -28,12 +27,10 @@ library ERC165Checker {
} }
/** /**
* @notice Query if a contract implements an interface, also checks support of ERC165 * @dev Returns true if `account` supports the interface defined by
* @param account The address of the contract to query for support of an interface * `interfaceId`. Support for `IERC165` itself is queried automatically.
* @param interfaceId The interface identifier, as specified in ERC-165 *
* @return true if the contract at account indicates support of the interface with * See `IERC165.supportsInterface`.
* identifier interfaceId, false otherwise
* @dev Interface identification is specified in ERC-165.
*/ */
function _supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) { function _supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) {
// query support of both ERC165 as per the spec and support of _interfaceId // query support of both ERC165 as per the spec and support of _interfaceId
...@@ -42,12 +39,13 @@ library ERC165Checker { ...@@ -42,12 +39,13 @@ library ERC165Checker {
} }
/** /**
* @notice Query if a contract implements interfaces, also checks support of ERC165 * @dev Returns true if `account` supports all the interfaces defined in
* @param account The address of the contract to query for support of an interface * `interfaceIds`. Support for `IERC165` itself is queried automatically.
* @param interfaceIds A list of interface identifiers, as specified in ERC-165 *
* @return true if the contract at account indicates support all interfaces in the * Batch-querying can lead to gas savings by skipping repeated checks for
* interfaceIds list, false otherwise * `IERC165` support.
* @dev Interface identification is specified in ERC-165. *
* See `IERC165.supportsInterface`.
*/ */
function _supportsAllInterfaces(address account, bytes4[] memory 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
......
pragma solidity ^0.5.0;
import "./IERC1820Implementer.sol";
/**
* @dev Implementation of the `IERC1820Implementer` interface.
*
* Contracts may inherit from this and call `_registerInterfaceForAddress` to
* declare their willingness to be implementers.
* `IERC1820Registry.setInterfaceImplementer` should then be called for the
* registration to be complete.
*/
contract ERC1820Implementer is IERC1820Implementer {
bytes32 constant private ERC1820_ACCEPT_MAGIC = keccak256(abi.encodePacked("ERC1820_ACCEPT_MAGIC"));
mapping(bytes32 => mapping(address => bool)) private _supportedInterfaces;
/**
* See `IERC1820Implementer.canImplementInterfaceForAddress`.
*/
function canImplementInterfaceForAddress(bytes32 interfaceHash, address account) external view returns (bytes32) {
return _supportedInterfaces[interfaceHash][account] ? ERC1820_ACCEPT_MAGIC : bytes32(0x00);
}
/**
* @dev Declares the contract as willing to be an implementer of
* `interfaceHash` for `account`.
*
* See `IERC1820Registry.setInterfaceImplementer` and
* `IERC1820Registry.interfaceHash`.
*/
function _registerInterfaceForAddress(bytes32 interfaceHash, address account) internal {
_supportedInterfaces[interfaceHash][account] = true;
}
}
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
/** /**
* @title IERC165 * @dev Interface of the ERC165 standard, as defined in the
* @dev https://eips.ethereum.org/EIPS/eip-165 * [EIP](https://eips.ethereum.org/EIPS/eip-165).
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others (`ERC165Checker`).
*
* For an implementation, see `ERC165`.
*/ */
interface IERC165 { interface IERC165 {
/** /**
* @notice Query if a contract implements an interface * @dev Returns true if this contract implements the interface defined by
* @param interfaceId The interface identifier, as specified in ERC-165 * `interfaceId`. See the corresponding
* @dev Interface identification is specified in ERC-165. This function * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
* uses less than 30,000 gas. * to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/ */
function supportsInterface(bytes4 interfaceId) external view returns (bool); function supportsInterface(bytes4 interfaceId) external view returns (bool);
} }
pragma solidity ^0.5.0;
/**
* @dev Interface for an ERC1820 implementer, as defined in the
* [EIP](https://eips.ethereum.org/EIPS/eip-1820#interface-implementation-erc1820implementerinterface).
* Used by contracts that will be registered as implementers in the
* `IERC1820Registry`.
*/
interface IERC1820Implementer {
/**
* @dev Returns a special value (`ERC1820_ACCEPT_MAGIC`) if this contract
* implements `interfaceHash` for `account`.
*
* See `IERC1820Registry.setInterfaceImplementer`.
*/
function canImplementInterfaceForAddress(bytes32 interfaceHash, address account) external view returns (bytes32);
}
pragma solidity ^0.5.0;
/**
* @dev Interface of the global ERC1820 Registry, as defined in the
* [EIP](https://eips.ethereum.org/EIPS/eip-1820). Accounts may register
* implementers for interfaces in this registry, as well as query support.
*
* Implementers may be shared by multiple accounts, and can also implement more
* than a single interface for each account. Contracts can implement interfaces
* for themselves, but externally-owned accounts (EOA) must delegate this to a
* contract.
*
* `IERC165` interfaces can also be queried via the registry.
*
* For an in-depth explanation and source code analysis, see the EIP text.
*/
interface IERC1820Registry {
/**
* @dev Sets `newManager` as the manager for `account`. A manager of an
* account is able to set interface implementers for it.
*
* By default, each account is its own manager. Passing a value of `0x0` in
* `newManager` will reset the manager to this initial state.
*
* Emits a `ManagerChanged` event.
*
* Requirements:
*
* - the caller must be the current manager for `account`.
*/
function setManager(address account, address newManager) external;
/**
* @dev Returns the manager for `account`.
*
* See `setManager`.
*/
function getManager(address account) external view returns (address);
/**
* @dev Sets the `implementer` contract as `account`'s implementer for
* `interfaceHash`.
*
* `account` being the zero address is an alias for the caller's address.
* The zero address can also be used in `implementer` to remove an old one.
*
* See `interfaceHash` to learn how these are created.
*
* Emits an `InterfaceImplementerSet` event.
*
* Requirements:
*
* - the caller must be the current manager for `account`.
* - `interfaceHash` must not be an `IERC165` interface id (i.e. it must not
* end in 28 zeroes).
* - `implementer` must implement `IERC1820Implementer` and return true when
* queried for support, unless `implementer` is the caller. See
* `IERC1820Implementer.canImplementInterfaceForAddress`.
*/
function setInterfaceImplementer(address account, bytes32 interfaceHash, address implementer) external;
/**
* @dev Returns the implementer of `interfaceHash` for `account`. If no such
* implementer is registered, returns the zero address.
*
* If `interfaceHash` is an `IERC165` interface id (i.e. it ends with 28
* zeroes), `account` will be queried for support of it.
*
* `account` being the zero address is an alias for the caller's address.
*/
function getInterfaceImplementer(address account, bytes32 interfaceHash) external view returns (address);
/**
* @dev Returns the interface hash for an `interfaceName`, as defined in the
* corresponding
* [section of the EIP](https://eips.ethereum.org/EIPS/eip-1820#interface-name).
*/
function interfaceHash(string calldata interfaceName) external pure returns (bytes32);
/**
* @notice Updates the cache with whether the contract implements an ERC165 interface or not.
* @param account Address of the contract for which to update the cache.
* @param interfaceId ERC165 interface for which to update the cache.
*/
function updateERC165Cache(address account, bytes4 interfaceId) external;
/**
* @notice Checks whether a contract implements an ERC165 interface or not.
* If the result is not cached a direct lookup on the contract address is performed.
* If the result is not cached or the cached value is out-of-date, the cache MUST be updated manually by calling
* 'updateERC165Cache' with the contract address.
* @param account Address of the contract to check.
* @param interfaceId ERC165 interface to check.
* @return True if `account.address()` implements `interfaceId`, false otherwise.
*/
function implementsERC165Interface(address account, bytes4 interfaceId) external view returns (bool);
/**
* @notice Checks whether a contract implements an ERC165 interface or not without using nor updating the cache.
* @param account Address of the contract to check.
* @param interfaceId ERC165 interface to check.
* @return True if `account.address()` implements `interfaceId`, false otherwise.
*/
function implementsERC165InterfaceNoCache(address account, bytes4 interfaceId) external view returns (bool);
event InterfaceImplementerSet(address indexed account, bytes32 indexed interfaceHash, address indexed implementer);
event ManagerChanged(address indexed account, address indexed newManager);
}
---
sections:
- title: Local
contracts:
- IERC165
- ERC165
- ERC165Checker
- title: Global
contracts:
- IERC1820Registry
- IERC1820Implementer
- ERC1820Implementer
---
This set of interfaces and contracts deal with [type introspection](https://en.wikipedia.org/wiki/Type_introspection) of contracts, that is, examining which functions can be called on them. This is usually referred to as a contract's _interface_.
Ethereum contracts have no native concept of an interface, so applications must usually simply trust they are not making an incorrect call. For trusted setups this is a non-issue, but often unknown and untrusted third-party addresses need to be interacted with. There may even not be any direct calls to them! (e.g. `ERC20` tokens may be sent to a contract that lacks a way to transfer them out of it, locking them forever). In these cases, a contract _declaring_ its interface can be very helpful in preventing errors.
There are two main ways to approach this.
- Locally, where a contract implements `IERC165` and declares an interface, and a second one queries it directly via `ERC165Checker`.
- Globally, where a global and unique registry (`IERC1820Registry`) is used to register implementers of a certain interface (`IERC1820Implementer`). It is then the registry that is queried, which allows for more complex setups, like contracts implementing interfaces for externally-owned accounts.
Note that, in all cases, accounts simply _declare_ their interfaces, but they are not required to actually implement them. This mechanism can therefore be used to both prevent errors and allow for complex interactions (see `ERC777`), but it must not be relied on for security.
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "@openzeppelin/upgrades/contracts/Initializable.sol"; import "@openzeppelin/upgrades/contracts/Initializable.sol";
...@@ -6,15 +6,31 @@ import "../GSN/Context.sol"; ...@@ -6,15 +6,31 @@ import "../GSN/Context.sol";
import "../access/roles/PauserRole.sol"; import "../access/roles/PauserRole.sol";
/** /**
* @title Pausable * @dev Contract module which allows children to implement an emergency stop
* @dev Base contract which allows children to implement an emergency stop mechanism. * mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/ */
contract Pausable is Initializable, Context, PauserRole { contract Pausable is Initializable, Context, PauserRole {
/**
* @dev Emitted when the pause is triggered by a pauser (`account`).
*/
event Paused(address account); event Paused(address account);
/**
* @dev Emitted when the pause is lifted by a pauser (`account`).
*/
event Unpaused(address account); event Unpaused(address account);
bool private _paused; bool private _paused;
/**
* @dev Initializes the contract in unpaused state. Assigns the Pauser role
* to the deployer.
*/
function initialize(address sender) public initializer { function initialize(address sender) public initializer {
PauserRole.initialize(sender); PauserRole.initialize(sender);
...@@ -22,7 +38,7 @@ contract Pausable is Initializable, Context, PauserRole { ...@@ -22,7 +38,7 @@ contract Pausable is Initializable, Context, PauserRole {
} }
/** /**
* @return true if the contract is paused, false otherwise. * @dev Returns true if the contract is paused, and false otherwise.
*/ */
function paused() public view returns (bool) { function paused() public view returns (bool) {
return _paused; return _paused;
...@@ -32,7 +48,7 @@ contract Pausable is Initializable, Context, PauserRole { ...@@ -32,7 +48,7 @@ contract Pausable is Initializable, Context, PauserRole {
* @dev Modifier to make a function callable only when the contract is not paused. * @dev Modifier to make a function callable only when the contract is not paused.
*/ */
modifier whenNotPaused() { modifier whenNotPaused() {
require(!_paused); require(!_paused, "Pausable: paused");
_; _;
} }
...@@ -40,12 +56,12 @@ contract Pausable is Initializable, Context, PauserRole { ...@@ -40,12 +56,12 @@ contract Pausable is Initializable, Context, PauserRole {
* @dev Modifier to make a function callable only when the contract is paused. * @dev Modifier to make a function callable only when the contract is paused.
*/ */
modifier whenPaused() { modifier whenPaused() {
require(_paused); require(_paused, "Pausable: not paused");
_; _;
} }
/** /**
* @dev called by the owner to pause, triggers stopped state * @dev Called by a pauser to pause, triggers stopped state.
*/ */
function pause() public onlyPauser whenNotPaused { function pause() public onlyPauser whenNotPaused {
_paused = true; _paused = true;
...@@ -53,7 +69,7 @@ contract Pausable is Initializable, Context, PauserRole { ...@@ -53,7 +69,7 @@ contract Pausable is Initializable, Context, PauserRole {
} }
/** /**
* @dev called by the owner to unpause, returns to normal state * @dev Called by a pauser to unpause, returns to normal state.
*/ */
function unpause() public onlyPauser whenPaused { function unpause() public onlyPauser whenPaused {
_paused = false; _paused = false;
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
/** /**
* @title Math * @dev Standard math utilities missing in the Solidity language.
* @dev Assorted math operations
*/ */
library Math { library Math {
/** /**
...@@ -20,9 +19,8 @@ library Math { ...@@ -20,9 +19,8 @@ library Math {
} }
/** /**
* @dev Calculates the average of two numbers. Since these are integers, * @dev Returns the average of two numbers. The result is rounded towards
* averages of an even and odd number cannot be represented, and will be * zero.
* rounded down.
*/ */
function average(uint256 a, uint256 b) internal pure returns (uint256) { function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow, so we distribute // (a + b) / 2 can overflow, so we distribute
......
---
title: Math
sections:
- title: Libraries
contracts:
- SafeMath
- Math
---
These are math-related utilities.
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
/** /**
* @title SafeMath * @dev Wrappers over Solidity's arithmetic operations with added overflow
* @dev Unsigned math operations with safety checks that revert on error * checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ */
library SafeMath { library SafeMath {
/** /**
* @dev Multiplies two unsigned integers, reverts on overflow. * @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, "SafeMath: subtraction overflow");
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/ */
function mul(uint256 a, uint256 b) internal pure returns (uint256) { function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
...@@ -17,17 +64,25 @@ library SafeMath { ...@@ -17,17 +64,25 @@ library SafeMath {
} }
uint256 c = a * b; uint256 c = a * b;
require(c / a == b); require(c / a == b, "SafeMath: multiplication overflow");
return c; return c;
} }
/** /**
* @dev Integer division of two unsigned integers truncating the quotient, reverts on division by zero. * @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/ */
function div(uint256 a, uint256 b) internal pure returns (uint256) { function div(uint256 a, uint256 b) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0 // Solidity only automatically asserts when dividing by 0
require(b > 0); require(b > 0, "SafeMath: division by zero");
uint256 c = a / b; uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold // assert(a == b * c + a % b); // There is no case in which this doesn't hold
...@@ -35,31 +90,18 @@ library SafeMath { ...@@ -35,31 +90,18 @@ library SafeMath {
} }
/** /**
* @dev Subtracts two unsigned integers, reverts on overflow (i.e. if subtrahend is greater than minuend). * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
*/ * Reverts when dividing by zero.
function sub(uint256 a, uint256 b) internal pure returns (uint256) { *
require(b <= a); * Counterpart to Solidity's `%` operator. This function uses a `revert`
uint256 c = a - b; * opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
return c; *
} * Requirements:
* - The divisor cannot be zero.
/**
* @dev Adds two unsigned integers, reverts on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a);
return c;
}
/**
* @dev Divides two unsigned integers and returns the remainder (unsigned integer modulo),
* reverts when dividing by zero.
*/ */
function mod(uint256 a, uint256 b) internal pure returns (uint256) { function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0); require(b != 0, "SafeMath: modulo by zero");
return a % b; return a % b;
} }
} }
pragma solidity ^0.5.2;
contract Acknowledger {
event AcknowledgeFoo(uint256 a);
event AcknowledgeBarSingle(uint256 a);
event AcknowledgeBarDouble(uint256 a, uint256 b);
function foo(uint256 a) public {
emit AcknowledgeFoo(a);
}
function bar(uint256 a) public {
emit AcknowledgeBarSingle(a);
}
function bar(uint256 a, uint256 b) public {
emit AcknowledgeBarDouble(a, b);
}
}
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "../utils/Address.sol"; import "../utils/Address.sol";
......
pragma solidity ^0.5.2; 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";
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "../utils/Arrays.sol"; import "../utils/Arrays.sol";
......
pragma solidity ^0.5.2; 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";
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "../access/roles/CapperRole.sol"; import "../access/roles/CapperRole.sol";
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "../payment/escrow/ConditionalEscrow.sol"; import "../payment/escrow/ConditionalEscrow.sol";
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "../drafts/Counters.sol"; import "../drafts/Counters.sol";
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "../crowdsale/Crowdsale.sol"; import "../crowdsale/Crowdsale.sol";
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "../cryptography/ECDSA.sol"; import "../cryptography/ECDSA.sol";
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "../../introspection/IERC165.sol"; import "../../introspection/IERC165.sol";
...@@ -13,37 +13,36 @@ import "../../introspection/IERC165.sol"; ...@@ -13,37 +13,36 @@ import "../../introspection/IERC165.sol";
* 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 INTERFACE_ID_ERC165 = 0x01ffc9a7;
/* /*
* 0x01ffc9a7 === * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7
* bytes4(keccak256('supportsInterface(bytes4)'))
*/ */
bytes4 public constant INTERFACE_ID_ERC165 = 0x01ffc9a7;
/** /**
* @dev a mapping of interface id to whether or not it's supported * @dev A mapping of interface id to whether or not it's supported.
*/ */
mapping(bytes4 => bool) private _supportedInterfaces; mapping(bytes4 => bool) private _supportedInterfaces;
/** /**
* @dev A contract implementing SupportsInterfaceWithLookup * @dev A contract implementing SupportsInterfaceWithLookup
* implement ERC165 itself * implement ERC165 itself.
*/ */
constructor () public { constructor () public {
_registerInterface(INTERFACE_ID_ERC165); _registerInterface(INTERFACE_ID_ERC165);
} }
/** /**
* @dev implement supportsInterface(bytes4) using a lookup table * @dev Implement supportsInterface(bytes4) using a lookup table.
*/ */
function supportsInterface(bytes4 interfaceId) external view returns (bool) { function supportsInterface(bytes4 interfaceId) external view returns (bool) {
return _supportedInterfaces[interfaceId]; return _supportedInterfaces[interfaceId];
} }
/** /**
* @dev private method for registering an interface * @dev Private method for registering an interface.
*/ */
function _registerInterface(bytes4 interfaceId) internal { function _registerInterface(bytes4 interfaceId) internal {
require(interfaceId != 0xffffffff); require(interfaceId != 0xffffffff, "ERC165InterfacesSupported: invalid interface id");
_supportedInterfaces[interfaceId] = true; _supportedInterfaces[interfaceId] = true;
} }
} }
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
contract ERC165NotSupported { contract ERC165NotSupported {
// solhint-disable-previous-line no-empty-blocks // solhint-disable-previous-line no-empty-blocks
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "../introspection/ERC165Checker.sol"; import "../introspection/ERC165Checker.sol";
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "../introspection/ERC165.sol"; import "../introspection/ERC165.sol";
......
pragma solidity ^0.5.0;
import "../introspection/ERC1820Implementer.sol";
contract ERC1820ImplementerMock is ERC1820Implementer {
function registerInterfaceForAddress(bytes32 interfaceHash, address account) public {
_registerInterfaceForAddress(interfaceHash, account);
}
}
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "../token/ERC20/ERC20Burnable.sol"; import "../token/ERC20/ERC20Burnable.sol";
......
pragma solidity ^0.5.2; 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";
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "../token/ERC20/ERC20Mintable.sol"; import "../token/ERC20/ERC20Mintable.sol";
import "./MinterRoleMock.sol"; import "./MinterRoleMock.sol";
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "../token/ERC20/ERC20.sol"; import "../token/ERC20/ERC20.sol";
...@@ -20,6 +20,10 @@ contract ERC20Mock is ERC20 { ...@@ -20,6 +20,10 @@ contract ERC20Mock is ERC20 {
_burnFrom(account, amount); _burnFrom(account, amount);
} }
function transferInternal(address from, address to, uint256 value) public {
_transfer(from, to, value);
}
function approveInternal(address owner, address spender, uint256 value) public { function approveInternal(address owner, address spender, uint256 value) public {
_approve(owner, spender, value); _approve(owner, spender, value);
} }
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "../token/ERC20/ERC20Pausable.sol"; import "../token/ERC20/ERC20Pausable.sol";
import "./PauserRoleMock.sol"; import "./PauserRoleMock.sol";
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "../drafts/ERC20Snapshot.sol"; import "../drafts/ERC20Snapshot.sol";
......
pragma solidity ^0.5.2; 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";
......
pragma solidity ^0.5.2; 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";
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "../token/ERC721/ERC721.sol"; import "../token/ERC721/ERC721.sol";
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "../token/ERC721/ERC721Pausable.sol"; import "../token/ERC721/ERC721Pausable.sol";
import "./PauserRoleMock.sol"; import "./PauserRoleMock.sol";
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "../token/ERC721/IERC721Receiver.sol"; import "../token/ERC721/IERC721Receiver.sol";
...@@ -16,7 +16,7 @@ contract ERC721ReceiverMock is IERC721Receiver { ...@@ -16,7 +16,7 @@ contract ERC721ReceiverMock is IERC721Receiver {
function onERC721Received(address operator, address from, uint256 tokenId, bytes memory data) function onERC721Received(address operator, address from, uint256 tokenId, bytes memory data)
public returns (bytes4) public returns (bytes4)
{ {
require(!_reverts); require(!_reverts, "ERC721ReceiverMock: reverting");
emit Received(operator, from, tokenId, data, gasleft()); emit Received(operator, from, tokenId, data, gasleft());
return _retval; return _retval;
} }
......
pragma solidity ^0.5.0;
import "../token/ERC777/ERC777.sol";
contract ERC777Mock is ERC777 {
constructor(
address initialHolder,
uint256 initialBalance,
string memory name,
string memory symbol,
address[] memory defaultOperators
) public ERC777(name, symbol, defaultOperators) {
_mint(msg.sender, initialHolder, initialBalance, "", "");
}
function mintInternal (
address operator,
address to,
uint256 amount,
bytes memory userData,
bytes memory operatorData
) public {
_mint(operator, to, amount, userData, operatorData);
}
}
pragma solidity ^0.5.0;
import "../token/ERC777/IERC777.sol";
import "../token/ERC777/IERC777Sender.sol";
import "../token/ERC777/IERC777Recipient.sol";
import "../introspection/IERC1820Registry.sol";
import "../introspection/ERC1820Implementer.sol";
contract ERC777SenderRecipientMock is IERC777Sender, IERC777Recipient, ERC1820Implementer {
event TokensToSendCalled(
address operator,
address from,
address to,
uint256 amount,
bytes data,
bytes operatorData,
address token,
uint256 fromBalance,
uint256 toBalance
);
event TokensReceivedCalled(
address operator,
address from,
address to,
uint256 amount,
bytes data,
bytes operatorData,
address token,
uint256 fromBalance,
uint256 toBalance
);
bool private _shouldRevertSend;
bool private _shouldRevertReceive;
IERC1820Registry private _erc1820 = IERC1820Registry(0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24);
bytes32 constant private TOKENS_SENDER_INTERFACE_HASH = keccak256("ERC777TokensSender");
bytes32 constant private TOKENS_RECIPIENT_INTERFACE_HASH = keccak256("ERC777TokensRecipient");
function tokensToSend(
address operator,
address from,
address to,
uint amount,
bytes calldata userData,
bytes calldata operatorData
) external {
if (_shouldRevertSend) {
revert();
}
IERC777 token = IERC777(msg.sender);
uint256 fromBalance = token.balanceOf(from);
// when called due to burn, to will be the zero address, which will have a balance of 0
uint256 toBalance = token.balanceOf(to);
emit TokensToSendCalled(
operator,
from,
to,
amount,
userData,
operatorData,
address(token),
fromBalance,
toBalance
);
}
function tokensReceived(
address operator,
address from,
address to,
uint amount,
bytes calldata userData,
bytes calldata operatorData
) external{
if (_shouldRevertReceive) {
revert();
}
IERC777 token = IERC777(msg.sender);
uint256 fromBalance = token.balanceOf(from);
// when called due to burn, to will be the zero address, which will have a balance of 0
uint256 toBalance = token.balanceOf(to);
emit TokensReceivedCalled(
operator,
from,
to,
amount,
userData,
operatorData,
address(token),
fromBalance,
toBalance
);
}
function senderFor(address account) public {
_registerInterfaceForAddress(TOKENS_SENDER_INTERFACE_HASH, account);
address self = address(this);
if (account == self) {
registerSender(self);
}
}
function registerSender(address sender) public {
_erc1820.setInterfaceImplementer(address(this), TOKENS_SENDER_INTERFACE_HASH, sender);
}
function recipientFor(address account) public {
_registerInterfaceForAddress(TOKENS_RECIPIENT_INTERFACE_HASH, account);
address self = address(this);
if (account == self) {
registerRecipient(self);
}
}
function registerRecipient(address recipient) public {
_erc1820.setInterfaceImplementer(address(this), TOKENS_RECIPIENT_INTERFACE_HASH, recipient);
}
function setShouldRevertSend(bool shouldRevert) public {
_shouldRevertSend = shouldRevert;
}
function setShouldRevertReceive(bool shouldRevert) public {
_shouldRevertReceive = shouldRevert;
}
function send(IERC777 token, address to, uint256 amount, bytes memory data) public {
// This is 777's send function, not the Solidity send function
token.send(to, amount, data); // solhint-disable-line check-send-result
}
function burn(IERC777 token, uint256 amount, bytes memory data) public {
token.burn(amount, data);
}
}
pragma solidity ^0.5.2;
contract EventEmitter {
event Argumentless();
event ShortUint(uint8 value);
event ShortInt(int8 value);
event LongUint(uint256 value);
event LongInt(int256 value);
event Address(address value);
event Boolean(bool value);
event String(string value);
event LongUintBooleanString(uint256 uintValue, bool booleanValue, string stringValue);
constructor (uint8 uintValue, bool booleanValue, string memory stringValue) public {
emit ShortUint(uintValue);
emit Boolean(booleanValue);
emit String(stringValue);
}
function emitArgumentless() public {
emit Argumentless();
}
function emitShortUint(uint8 value) public {
emit ShortUint(value);
}
function emitShortInt(int8 value) public {
emit ShortInt(value);
}
function emitLongUint(uint256 value) public {
emit LongUint(value);
}
function emitLongInt(int256 value) public {
emit LongInt(value);
}
function emitAddress(address value) public {
emit Address(value);
}
function emitBoolean(bool value) public {
emit Boolean(value);
}
function emitString(string memory value) public {
emit String(value);
}
function emitLongUintBooleanString(uint256 uintValue, bool booleanValue, string memory stringValue) public {
emit LongUintBooleanString(uintValue, booleanValue, stringValue);
}
function emitLongUintAndBoolean(uint256 uintValue, bool boolValue) public {
emit LongUint(uintValue);
emit Boolean(boolValue);
}
function emitStringAndEmitIndirectly(string memory value, IndirectEventEmitter emitter) public {
emit String(value);
emitter.emitStringIndirectly(value);
}
}
contract IndirectEventEmitter {
event IndirectString(string value);
function emitStringIndirectly(string memory value) public {
emit IndirectString(value);
}
}
pragma solidity ^0.5.2;
contract Failer {
uint256[] private array;
function dontFail() public pure {
// solhint-disable-previous-line no-empty-blocks
}
function failWithRevert() public pure {
revert();
}
function failWithThrow() public pure {
assert(false);
}
function failWithOutOfGas() public {
for (uint256 i = 0; i < 2**200; ++i) {
array.push(i);
}
}
}
pragma solidity ^0.5.2; 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";
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "../crowdsale/price/IncreasingPriceCrowdsale.sol"; import "../crowdsale/price/IncreasingPriceCrowdsale.sol";
import "../math/SafeMath.sol"; import "../math/SafeMath.sol";
......
pragma solidity ^0.5.2; 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";
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "../math/Math.sol"; import "../math/Math.sol";
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import { MerkleProof } from "../cryptography/MerkleProof.sol"; import { MerkleProof } from "../cryptography/MerkleProof.sol";
......
pragma solidity ^0.5.2; 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";
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "../access/roles/MinterRole.sol"; import "../access/roles/MinterRole.sol";
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "../ownership/Ownable.sol"; import "../ownership/Ownable.sol";
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "../ownership/Ownable.sol"; import "../ownership/Ownable.sol";
......
pragma solidity ^0.5.2; 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";
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "../lifecycle/Pausable.sol"; import "../lifecycle/Pausable.sol";
import "./PauserRoleMock.sol"; import "./PauserRoleMock.sol";
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "../access/roles/PauserRole.sol"; import "../access/roles/PauserRole.sol";
......
pragma solidity ^0.5.2; 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";
......
pragma solidity ^0.5.2; pragma solidity ^0.5.0;
import "../payment/PullPayment.sol"; import "../payment/PullPayment.sol";
......
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
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