Compare commits
161 Commits
v2.1.0-rc.
...
v2.0.2
| Author | SHA1 | Date | |
|---|---|---|---|
| b047d28476 | |||
| 54268bfeed | |||
| 0c05ce0eb1 | |||
| f28a4427a2 | |||
| e5ba8666de | |||
| 2fa3176399 | |||
| d1f2b19e6e | |||
| a8a3e0be05 | |||
| f38ff1bdbd | |||
| 34fdb0fe23 | |||
| 793de306cf | |||
| 0720923115 | |||
| 95666637b6 | |||
| 0ae92d78eb | |||
| 5e69036bbc | |||
| 6395ddac2c | |||
| a2a28b02e8 | |||
| 84a37e1460 | |||
| 36043ecc3e | |||
| d75ba16223 | |||
| 1961032592 | |||
| fffa406aa4 | |||
| 488c3de389 | |||
| 45747144ff | |||
| bc7ba69f9b | |||
| 423c6523ba | |||
| ecd6c57faa | |||
| 19de09afe1 | |||
| 932a39f5fd | |||
| 6956b935b3 | |||
| 7bdefbeb9a | |||
| 6fe9b340b4 | |||
| b25e8b91a5 | |||
| 14dd3f6610 | |||
| 716efc4b51 | |||
| 143ccf7a74 | |||
| dd750bc094 | |||
| ef83f895b9 | |||
| cd3be5fb02 | |||
| f29e98f772 | |||
| 3df0a786e4 | |||
| 3c4528b8f4 | |||
| 94a7abcebc | |||
| 32d0f6770c | |||
| caa0db9fa9 | |||
| 621d4b30da | |||
| 693907d3c8 | |||
| 2108641a37 | |||
| 418b6f7cb3 | |||
| ed200a0219 | |||
| c4487ba836 | |||
| 2c2d80d9a0 | |||
| 6247a7bf7c | |||
| 22f8660c8e | |||
| 175e2c7254 | |||
| a0a3187b30 | |||
| f3b5f9e8f0 | |||
| e6d5379e39 | |||
| 8bf7356f38 | |||
| d7b7644e68 | |||
| 8dd0739072 | |||
| 838509c0a4 | |||
| e6252d511c | |||
| e2e05294b0 | |||
| 3130a3f3de | |||
| 884d5e0132 | |||
| 8d28bd445a | |||
| d643caf8fe | |||
| a010d88def | |||
| d3116fcea8 | |||
| cda2866e7c | |||
| aa6a44bb20 | |||
| 10642d14ea | |||
| 6ac45333fe | |||
| 0962b9e5e6 | |||
| c630cb4016 | |||
| 21e016378c | |||
| 7cee6df3f7 | |||
| 57325f51ff | |||
| 20a2aa4274 | |||
| 5c1c43d2e1 | |||
| f3a0a6a463 | |||
| 416c4ced2c | |||
| 3f51d342d1 | |||
| 1f54c72d1d | |||
| f90fd5330e | |||
| 653b154b0e | |||
| 6e0ace1914 | |||
| 5b8d5eb5e9 | |||
| 3a3d2b154f | |||
| f3606e3e21 | |||
| 9c16ffcaf4 | |||
| 4c319a1072 | |||
| 5f7e43f170 | |||
| a23d42fc04 | |||
| 2a2519414b | |||
| c46f0353d1 | |||
| 8f4610e007 | |||
| 63ca200016 | |||
| d87e833310 | |||
| 198dbf348c | |||
| 094677f179 | |||
| e6167f1c0b | |||
| 23ddc9db2a | |||
| 8443df3826 | |||
| 6e5596e80c | |||
| f00d13125b | |||
| 3af2f8ad7c | |||
| 59afaca753 | |||
| f35eeed0eb | |||
| 8b19e3c215 | |||
| dca62efba9 | |||
| 923bbb44a8 | |||
| d4c455c180 | |||
| 5ac618681a | |||
| d191247505 | |||
| 9b55e96fa0 | |||
| 8868c0b6d3 | |||
| 534ff92ba5 | |||
| 31ec824aef | |||
| b732b6417e | |||
| 998b5f43fb | |||
| ff31995104 | |||
| 48a7cd4e60 | |||
| acd34a9372 | |||
| 2ce67a25ef | |||
| 700b811813 | |||
| 16f04b13d7 | |||
| e3ad4a5e14 | |||
| 579446d5d9 | |||
| fc07f7a0ff | |||
| dd6054efeb | |||
| 27a6a15d66 | |||
| 32e93579fa | |||
| c8719ce418 | |||
| 39fe05dfad | |||
| be101154fa | |||
| c329fc0a5f | |||
| e55dbc9681 | |||
| 6f1c67af0d | |||
| 5284a6df88 | |||
| 8bce0a4f2e | |||
| 11d2bbc092 | |||
| ff69c54497 | |||
| 6669f3fcee | |||
| 18e16a5db0 | |||
| 95fdc7bd8a | |||
| 27d696aa7d | |||
| ff6a565452 | |||
| 5f079c8605 | |||
| ea335ebc64 | |||
| b1a801566c | |||
| 2eac2a79b7 | |||
| f9fc8d2e96 | |||
| 89c32f5dd7 | |||
| eff3d7ca8e | |||
| 85225ef6ae | |||
| 2010c6b464 | |||
| 03891b00a7 | |||
| d0ec491b1f | |||
| 38536f42f4 |
5
.env.example
Normal file
5
.env.example
Normal file
@ -0,0 +1,5 @@
|
||||
# configure your infura api key (not technically required)
|
||||
INFURA_API_KEY=
|
||||
|
||||
# change the mnemonic that your hd wallet is seeded with
|
||||
MNEMONIC=
|
||||
13
.eslintrc
13
.eslintrc
@ -1,23 +1,22 @@
|
||||
{
|
||||
"extends" : [
|
||||
"standard",
|
||||
"plugin:promise/recommended",
|
||||
"plugin:promise/recommended"
|
||||
],
|
||||
"plugins": [
|
||||
"mocha-no-only",
|
||||
"promise",
|
||||
"promise"
|
||||
],
|
||||
"env": {
|
||||
"browser" : true,
|
||||
"node" : true,
|
||||
"mocha" : true,
|
||||
"jest" : true,
|
||||
"jest" : true
|
||||
},
|
||||
"globals" : {
|
||||
"artifacts": false,
|
||||
"contract": false,
|
||||
"assert": false,
|
||||
"web3": false,
|
||||
"web3": false
|
||||
},
|
||||
"rules": {
|
||||
|
||||
@ -26,7 +25,7 @@
|
||||
|
||||
// Code style
|
||||
"camelcase": ["error", {"properties": "always"}],
|
||||
"comma-dangle": ["error", "always-multiline"],
|
||||
"comma-dangle": ["warn", "always-multiline"],
|
||||
"comma-spacing": ["error", {"before": false, "after": true}],
|
||||
"dot-notation": ["error", {"allowKeywords": true, "allowPattern": ""}],
|
||||
"eol-last": ["error", "always"],
|
||||
@ -50,8 +49,6 @@
|
||||
"semi": ["error", "always"],
|
||||
"space-before-function-paren": ["error", "always"],
|
||||
|
||||
"mocha-no-only/mocha-no-only": ["error"],
|
||||
|
||||
"promise/always-return": "off",
|
||||
"promise/avoid-new": "off",
|
||||
}
|
||||
|
||||
34
.github/ISSUE_TEMPLATE.md
vendored
Normal file
34
.github/ISSUE_TEMPLATE.md
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
## 🎉 Description
|
||||
|
||||
<!-- Briefly describe the issue you are experiencing (or the feature you want to see added to OpenZeppelin). 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/).** -->
|
||||
|
||||
- [ ] 🐛 This is a bug report.
|
||||
- [ ] 📈 This is a feature request.
|
||||
|
||||
<!-- Please check one of the above by placing an x in the box. -->
|
||||
|
||||
## 💻 Environment
|
||||
|
||||
Next, we need to know what your environment looks like.
|
||||
|
||||
- Which version of OpenZeppelin are you using?
|
||||
- What network are you deploying to? Ganache? Ropsten?
|
||||
- How are you deploying your OpenZeppelin-backed contracts? truffle? Remix? Let us know!
|
||||
|
||||
## 📝 Details
|
||||
|
||||
Describe the problem you have been experiencing in more detail. Include as much information as you think is relevant. Keep in mind that transactions can fail for many reasons; context is key here.
|
||||
|
||||
## 🔢 Code To Reproduce Issue [ Good To Have ]
|
||||
|
||||
Please remember that with sample code it's easier to reproduce the bug and it's much faster to fix it.
|
||||
|
||||
```
|
||||
insert short code snippets here
|
||||
```
|
||||
|
||||
<!-- If your code is larger, consider linking us to a repo illustrating your issue. -->
|
||||
|
||||
## 👍 Other Information
|
||||
|
||||
<!-- List any other information that is relevant to your issue. Error logs, related issues, suggestions on how to fix, Stack Overflow links, forum links, etc. -->
|
||||
21
.github/ISSUE_TEMPLATE/bug_report.md
vendored
21
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@ -1,21 +0,0 @@
|
||||
---
|
||||
name: Bug report
|
||||
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. -->
|
||||
|
||||
<!-- 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/. -->
|
||||
|
||||
**💻 Environment**
|
||||
|
||||
<!-- Tell us what version of OpenZeppelin you're using, and how you're using it: Truffle, Remix, etc. -->
|
||||
|
||||
**📝 Details**
|
||||
|
||||
<!-- Describe the problem you have been experiencing in more detail. Include as much information as you think is relevant. Keep in mind that transactions can fail for many reasons; context is key here. -->
|
||||
|
||||
**🔢 Code to reproduce bug**
|
||||
|
||||
<!-- We will be able to better help if you provide a minimal example that triggers the bug. -->
|
||||
14
.github/ISSUE_TEMPLATE/feature_request.md
vendored
14
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@ -1,14 +0,0 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for OpenZeppelin
|
||||
|
||||
---
|
||||
|
||||
**🧐 Motivation**
|
||||
<!-- Is your feature request related to a specific problem? Is it just a crazy idea? Tell us about it! -->
|
||||
|
||||
**📝 Details**
|
||||
<!-- Please describe your feature request in detail. -->
|
||||
|
||||
<!-- Make sure that you have reviewed the OpenZeppelin Contributor Guidelines. -->
|
||||
<!-- https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/CONTRIBUTING.md -->
|
||||
24
.github/PULL_REQUEST_TEMPLATE.md
vendored
24
.github/PULL_REQUEST_TEMPLATE.md
vendored
@ -1,21 +1,17 @@
|
||||
<!-- 0. 🎉 Thank you for submitting a PR! -->
|
||||
|
||||
<!-- 1. Does this close any open issues? Please list them below. -->
|
||||
|
||||
<!-- Keep in mind that new features have a better chance of being merged fast if
|
||||
they were first discussed and designed with the maintainers. If there is no
|
||||
corresponding issue, please consider opening one for discussion first! -->
|
||||
<!-- 1. **Does this close any open issues?** If so, list them here. If not, remove the `Fixes #` line. -->
|
||||
|
||||
Fixes #
|
||||
|
||||
<!-- 2. Describe the changes introduced in this pull request. -->
|
||||
# 🚀 Description
|
||||
|
||||
<!-- 2. Describe the changes introduced in this pull request -->
|
||||
<!-- Include any context necessary for understanding the PR's purpose. -->
|
||||
|
||||
<!-- 3. Before submitting, please make sure that you have:
|
||||
- reviewed the OpenZeppelin Contributor Guidelines
|
||||
(https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/CONTRIBUTING.md),
|
||||
- added tests where applicable to test new functionality,
|
||||
- made sure that your contracts are well-documented,
|
||||
- run the JS/Solidity linters and fixed any issues (`npm run lint:fix`), and
|
||||
- updated the changelog, if applicable.
|
||||
-->
|
||||
<!-- 3. Before submitting, please review the following checklist: -->
|
||||
|
||||
- [ ] 📘 I've reviewed the [OpenZeppelin Contributor Guidelines](../blob/master/CONTRIBUTING.md)
|
||||
- [ ] ✅ I've added tests where applicable to test my new functionality.
|
||||
- [ ] 📖 I've made sure that my contracts are well-documented.
|
||||
- [ ] 🎨 I've run the JS/Solidity linters and fixed any issues (`npm run lint:fix`).
|
||||
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@ -38,5 +38,4 @@ build/
|
||||
# truffle
|
||||
.node-xmlhttprequest-*
|
||||
|
||||
# Temporary directory for 0.5.x compilation
|
||||
solc-0.5
|
||||
.zos.session
|
||||
|
||||
@ -2,10 +2,8 @@
|
||||
"extends": "solium:all",
|
||||
"plugins": ["security"],
|
||||
"rules": {
|
||||
"arg-overflow": "off",
|
||||
"blank-lines": "off",
|
||||
"error-reason": "off",
|
||||
"indentation": ["error", 4],
|
||||
"indentation": ["error", 2],
|
||||
"lbrace": "off",
|
||||
"linebreak-style": ["error", "unix"],
|
||||
"max-len": ["error", 120],
|
||||
|
||||
32
.travis.yml
32
.travis.yml
@ -15,26 +15,38 @@ jobs:
|
||||
# --elopio - 20180531
|
||||
fast_finish: true
|
||||
allow_failures:
|
||||
- env: SOLIDITY_COVERAGE=true
|
||||
- env: SOLC_NIGHTLY=true
|
||||
include:
|
||||
- stage: install
|
||||
script: true
|
||||
install:
|
||||
- npm install
|
||||
- npx npm-install-peers
|
||||
# Run the unit test suite three times in parallel.
|
||||
# The first one gets results faster and is the only one required to pass.
|
||||
# The second one generates the coverage report.
|
||||
# The third one is to keep us informed about possible issues with the
|
||||
# upcoming solidity release.
|
||||
- stage: tests
|
||||
name: "Linter"
|
||||
script: npm run lint
|
||||
|
||||
- stage: tests
|
||||
name: "Unit tests"
|
||||
name: "unit tests"
|
||||
install: npx npm-install-peers
|
||||
script: npm run test
|
||||
|
||||
- stage: tests
|
||||
name: "Unit tests with coverage report"
|
||||
name: "unit tests with coverage"
|
||||
install: npx npm-install-peers
|
||||
script: npm run test
|
||||
env: SOLIDITY_COVERAGE=true
|
||||
|
||||
- stage: tests
|
||||
name: "Unit tests using solc nightly"
|
||||
name: "unit tests with solc nightly"
|
||||
install: npx npm-install-peers
|
||||
script: npm run test
|
||||
env: SOLC_NIGHTLY=true
|
||||
|
||||
# solidity and javascript style tests.
|
||||
- stage: tests
|
||||
name: "static tests"
|
||||
install: npx npm-install-peers
|
||||
script: npm run lint
|
||||
- stage: update docs
|
||||
if: tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+$
|
||||
addons:
|
||||
|
||||
29
CHANGELOG.md
29
CHANGELOG.md
@ -1,29 +0,0 @@
|
||||
# Changelog
|
||||
|
||||
## 2.1.0 (unreleased)
|
||||
|
||||
### New features:
|
||||
* Now targeting the 0.5.x line of Solidity compilers. For 0.4.24 support, use version 2.0 of OpenZeppelin.
|
||||
* `WhitelistCrowdsale`: a crowdsale where only whitelisted accounts (`WhitelistedRole`) can purchase tokens. Adding or removing accounts from the whitelist is done by whitelisters (`WhitelisterRole`). Similar to the pre-2.0 `WhitelistedCrowdsale`. ([#1525](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1525))
|
||||
* `RefundablePostDeliveryCrowdsale`: replacement for `RefundableCrowdsale` (deprecated, see below) where tokens are only granted once the crowdsale ends (if it meets its goal). ([#1543](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1543))
|
||||
* `PausableCrowdsale`: allows for pausers (`PauserRole`) to pause token purchases. Other crowdsale operations (e.g. withdrawals and refunds, if applicable) are not affected. ([#832](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/832))
|
||||
* `ERC20`: `transferFrom` and `_burnFrom ` now emit `Approval` events, to represent the token's state comprehensively through events. ([#1524](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1524))
|
||||
* `ERC721`: added `_burn(uint256 tokenId)`, replacing the similar deprecated function (see below). ([#1550](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1550))
|
||||
* `ERC721`: added `_tokensOfOwner(address owner)`, allowing to internally retrieve the array of an account's owned tokens. ([#1522](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1522))
|
||||
* Crowdsales: all constructors are now `public`, meaning it is not necessary to extend these contracts in order to deploy them. The exception is `FinalizableCrowdsale`, since it is meaningless unless extended. ([#1564](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1564))
|
||||
* `SafeMath`: added overflow-safe operations for signed integers (`int256`). ([#1559](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1559))
|
||||
|
||||
### Improvements:
|
||||
* The compiler version required by `Array` was behind the rest of the libray so it was updated to `v0.4.24`. ([#1553](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1553))
|
||||
* Now conforming to a 4-space indentation code style. ([1508](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1508))
|
||||
* `ERC20`: more gas efficient due to removed redundant `require`s. ([#1409](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1409))
|
||||
* `ERC721`: fixed a bug that prevented internal data structures from being properly cleaned, missing potential gas refunds. ([#1539](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1539) and [#1549](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1549))
|
||||
* `ERC721`: general gas savings on `transferFrom`, `_mint` and `_burn`, due to redudant `require`s and `SSTORE`s. ([#1549](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1549))
|
||||
|
||||
### Bugfixes:
|
||||
|
||||
### Breaking changes:
|
||||
|
||||
### Deprecations:
|
||||
* `ERC721._burn(address owner, uint256 tokenId)`: due to the `owner` parameter being unnecessary. ([#1550](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1550))
|
||||
* `RefundableCrowdsale`: due to trading abuse potential on crowdsales that miss their goal. ([#1543](https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1543))
|
||||
@ -16,14 +16,11 @@ Any exception or additions specific to our project are documented below.
|
||||
|
||||
* Try to avoid acronyms and abbreviations.
|
||||
|
||||
* All state variables should be private.
|
||||
|
||||
* Private state variables should have an underscore prefix.
|
||||
|
||||
```
|
||||
contract TestContract {
|
||||
uint256 private _privateVar;
|
||||
uint256 internal _internalVar;
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
52
README.md
52
README.md
@ -1,58 +1,30 @@
|
||||
# <img src="logo.png" alt="OpenZeppelin" width="400px">
|
||||
|
||||
[](https://www.npmjs.org/package/openzeppelin-solidity)
|
||||
[](https://travis-ci.com/OpenZeppelin/openzeppelin-solidity)
|
||||
[](https://coveralls.io/github/OpenZeppelin/openzeppelin-solidity?branch=master)
|
||||
# OpenZeppelin EVM Package
|
||||
|
||||
[](https://www.npmjs.org/package/openzeppelin-eth)
|
||||
[](https://travis-ci.org/OpenZeppelin/openzeppelin-eth)
|
||||
|
||||
**OpenZeppelin is a library for secure smart contract development.** It provides implementations of standards like ERC20 and ERC721 which you can deploy as-is or extend to suit your needs, as well as Solidity components to build custom contracts and more complex decentralized systems.
|
||||
|
||||
This fork of OpenZeppelin is set up as a **reusable EVM Package**. It is deployed to the kovan, rinkeby, and ropsten test networks, as well as to the main Ethereum network. You can reuse any of the pre-deployed on-chain contracts by simply linking to them using [ZeppelinOS](https://github.com/zeppelinos/zos), or reuse their Solidity source code as with the vanilla version of OpenZeppelin.
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
npm install openzeppelin-solidity
|
||||
npm install openzeppelin-eth
|
||||
```
|
||||
|
||||
## Usage
|
||||
## Pre-deployed contracts
|
||||
|
||||
To write your custom contracts, import ours and extend them through inheritance.
|
||||
|
||||
```solidity
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import 'openzeppelin-solidity/contracts/token/ERC721/ERC721Full.sol';
|
||||
import 'openzeppelin-solidity/contracts/token/ERC721/ERC721Mintable.sol';
|
||||
|
||||
contract MyNFT is ERC721Full, ERC721Mintable {
|
||||
constructor() ERC721Full("MyNFT", "MNFT") public {
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
> You need an ethereum development framework for the above import statements to work! Check out these guides for [Truffle] or [Embark].
|
||||
|
||||
On our site you will find a few [guides] to learn about the diferent parts of OpenZeppelin, as well as [documentation for the API][API docs]. Keep in mind that the API docs are work in progress, and don’t hesitate to ask questions in [our Slack][Slack].
|
||||
|
||||
## Security
|
||||
|
||||
OpenZeppelin the project is maintained by [Zeppelin] the company, and developed following our high standards for code quality and security. OpenZeppelin is meant to provide tested and community-audited code, but please use common sense when doing anything that deals with real money! We take no responsibility for your implementation decisions and any security problems you might experience.
|
||||
|
||||
The core development principles and strategies that OpenZeppelin is based on include: security in depth, simple and modular code, clarity-driven naming conventions, comprehensive unit testing, pre-and-post-condition sanity checks, code consistency, and regular audits.
|
||||
|
||||
Please report any security issues you find to security@openzeppelin.org.
|
||||
|
||||
## Contribute
|
||||
|
||||
OpenZeppelin exists thanks to its contributors. There are many ways you can participate and help build high quality software. Check out the [contribution guide]!
|
||||
- StandaloneERC20
|
||||
- StandaloneERC721
|
||||
- TokenVesting
|
||||
- PaymentSplitter
|
||||
|
||||
## License
|
||||
|
||||
OpenZeppelin is released under the [MIT License](LICENSE).
|
||||
|
||||
|
||||
[API docs]: https://openzeppelin.org/api/docs/token_ERC721_ERC721BasicToken.html
|
||||
[guides]: https://openzeppelin.org/api/docs/get-started.html
|
||||
[Slack]: https://slack.openzeppelin.org
|
||||
[Zeppelin]: https://zeppelin.solutions
|
||||
[contribution guide]: CONTRIBUTING.md
|
||||
[Truffle]: https://truffleframework.com/docs/truffle/quickstart
|
||||
[Embark]: https://embark.status.im/docs/quick_start.html
|
||||
|
||||
@ -34,7 +34,7 @@ git push upstream vX.Y.Z-rc.R
|
||||
|
||||
Draft the release notes in our [GitHub releases](https://github.com/OpenZeppelin/openzeppelin-solidity/releases). Make sure to mark it as a pre-release! Try to be consistent with our previous release notes in the title and format of the text. Release candidates don't need a detailed changelog, but make sure to include a link to GitHub's compare page.
|
||||
|
||||
Once the CI run for the new tag is green, publish on npm under the `next` tag. You should see the contracts compile automatically.
|
||||
Once the CI run for the new tag is green, publish on npm under the `next` tag.
|
||||
|
||||
```
|
||||
npm publish --tag next
|
||||
@ -62,7 +62,7 @@ git push upstream vX.Y.Z
|
||||
|
||||
Draft the release notes in GitHub releases. Try to be consistent with our previous release notes in the title and format of the text. Make sure to include a detailed changelog.
|
||||
|
||||
Once the CI run for the new tag is green, publish on npm. You should see the contracts compile automatically.
|
||||
Once the CI run for the new tag is green, publish on npm.
|
||||
|
||||
```
|
||||
npm publish
|
||||
|
||||
@ -12,7 +12,7 @@ The following provides visibility into how OpenZeppelin's contracts are organize
|
||||
- **introspection** - An interface that can be used to make a contract comply with the ERC-165 standard as well as a contract that implements ERC-165 using a lookup table.
|
||||
- **lifecycle** - A collection of base contracts used to manage the existence and behavior of your contracts and their funds.
|
||||
- **math** - Libraries with safety checks on operations that throw on errors.
|
||||
- **mocks** - A collection of abstract contracts that are primarily used for unit testing. They also serve as good usage examples and demonstrate how to combine contracts with inheritance when developing your own custom applications.
|
||||
- **mocks** - A collection of abstract contracts that are primarily used for unit testing. They also serve as good usage examples and demonstrate how to combine contracts with inheritence when developing your own custom applications.
|
||||
- **ownership** - A collection of smart contracts that can be used to manage contract and token ownership
|
||||
- **payment** - A collection of smart contracts that can be used to manage payments through escrow arrangements, withdrawals, and claims. Includes support for both single payees and multiple payees.
|
||||
- **proposals** - A collection of smart contracts that reflect community Ethereum Improvement Proposals (EIPs). These contracts are under development and standardization. They are not recommended for production, but they are useful for experimentation with pending EIP standards. Go [here](https://github.com/OpenZeppelin/openzeppelin-solidity/wiki/ERC-Process) for more information.
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
|
||||
/**
|
||||
* @title Roles
|
||||
@ -14,8 +15,6 @@ library Roles {
|
||||
*/
|
||||
function add(Role storage role, address account) internal {
|
||||
require(account != address(0));
|
||||
require(!has(role, account));
|
||||
|
||||
role.bearer[account] = true;
|
||||
}
|
||||
|
||||
@ -24,8 +23,6 @@ library Roles {
|
||||
*/
|
||||
function remove(Role storage role, address account) internal {
|
||||
require(account != address(0));
|
||||
require(has(role, account));
|
||||
|
||||
role.bearer[account] = false;
|
||||
}
|
||||
|
||||
@ -33,7 +30,11 @@ library Roles {
|
||||
* @dev check if an account has this role
|
||||
* @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));
|
||||
return role.bearer[account];
|
||||
}
|
||||
|
||||
@ -1,17 +1,21 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "zos-lib/contracts/Initializable.sol";
|
||||
import "../Roles.sol";
|
||||
|
||||
contract CapperRole {
|
||||
|
||||
contract CapperRole is Initializable {
|
||||
using Roles for Roles.Role;
|
||||
|
||||
event CapperAdded(address indexed account);
|
||||
event CapperRemoved(address indexed account);
|
||||
|
||||
Roles.Role private _cappers;
|
||||
Roles.Role private cappers;
|
||||
|
||||
constructor () internal {
|
||||
_addCapper(msg.sender);
|
||||
function initialize(address sender) public initializer {
|
||||
if (!isCapper(sender)) {
|
||||
_addCapper(sender);
|
||||
}
|
||||
}
|
||||
|
||||
modifier onlyCapper() {
|
||||
@ -20,7 +24,7 @@ contract CapperRole {
|
||||
}
|
||||
|
||||
function isCapper(address account) public view returns (bool) {
|
||||
return _cappers.has(account);
|
||||
return cappers.has(account);
|
||||
}
|
||||
|
||||
function addCapper(address account) public onlyCapper {
|
||||
@ -32,12 +36,14 @@ contract CapperRole {
|
||||
}
|
||||
|
||||
function _addCapper(address account) internal {
|
||||
_cappers.add(account);
|
||||
cappers.add(account);
|
||||
emit CapperAdded(account);
|
||||
}
|
||||
|
||||
function _removeCapper(address account) internal {
|
||||
_cappers.remove(account);
|
||||
cappers.remove(account);
|
||||
emit CapperRemoved(account);
|
||||
}
|
||||
|
||||
uint256[50] private ______gap;
|
||||
}
|
||||
|
||||
@ -1,17 +1,21 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "zos-lib/contracts/Initializable.sol";
|
||||
import "../Roles.sol";
|
||||
|
||||
contract MinterRole {
|
||||
|
||||
contract MinterRole is Initializable {
|
||||
using Roles for Roles.Role;
|
||||
|
||||
event MinterAdded(address indexed account);
|
||||
event MinterRemoved(address indexed account);
|
||||
|
||||
Roles.Role private _minters;
|
||||
Roles.Role private minters;
|
||||
|
||||
constructor () internal {
|
||||
_addMinter(msg.sender);
|
||||
function initialize(address sender) public initializer {
|
||||
if (!isMinter(sender)) {
|
||||
_addMinter(sender);
|
||||
}
|
||||
}
|
||||
|
||||
modifier onlyMinter() {
|
||||
@ -20,7 +24,7 @@ contract MinterRole {
|
||||
}
|
||||
|
||||
function isMinter(address account) public view returns (bool) {
|
||||
return _minters.has(account);
|
||||
return minters.has(account);
|
||||
}
|
||||
|
||||
function addMinter(address account) public onlyMinter {
|
||||
@ -32,12 +36,14 @@ contract MinterRole {
|
||||
}
|
||||
|
||||
function _addMinter(address account) internal {
|
||||
_minters.add(account);
|
||||
minters.add(account);
|
||||
emit MinterAdded(account);
|
||||
}
|
||||
|
||||
function _removeMinter(address account) internal {
|
||||
_minters.remove(account);
|
||||
minters.remove(account);
|
||||
emit MinterRemoved(account);
|
||||
}
|
||||
|
||||
uint256[50] private ______gap;
|
||||
}
|
||||
|
||||
@ -1,17 +1,21 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "zos-lib/contracts/Initializable.sol";
|
||||
import "../Roles.sol";
|
||||
|
||||
contract PauserRole {
|
||||
|
||||
contract PauserRole is Initializable {
|
||||
using Roles for Roles.Role;
|
||||
|
||||
event PauserAdded(address indexed account);
|
||||
event PauserRemoved(address indexed account);
|
||||
|
||||
Roles.Role private _pausers;
|
||||
Roles.Role private pausers;
|
||||
|
||||
constructor () internal {
|
||||
_addPauser(msg.sender);
|
||||
function initialize(address sender) public initializer {
|
||||
if (!isPauser(sender)) {
|
||||
_addPauser(sender);
|
||||
}
|
||||
}
|
||||
|
||||
modifier onlyPauser() {
|
||||
@ -20,7 +24,7 @@ contract PauserRole {
|
||||
}
|
||||
|
||||
function isPauser(address account) public view returns (bool) {
|
||||
return _pausers.has(account);
|
||||
return pausers.has(account);
|
||||
}
|
||||
|
||||
function addPauser(address account) public onlyPauser {
|
||||
@ -32,12 +36,14 @@ contract PauserRole {
|
||||
}
|
||||
|
||||
function _addPauser(address account) internal {
|
||||
_pausers.add(account);
|
||||
pausers.add(account);
|
||||
emit PauserAdded(account);
|
||||
}
|
||||
|
||||
function _removePauser(address account) internal {
|
||||
_pausers.remove(account);
|
||||
pausers.remove(account);
|
||||
emit PauserRemoved(account);
|
||||
}
|
||||
|
||||
uint256[50] private ______gap;
|
||||
}
|
||||
|
||||
@ -1,17 +1,21 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "zos-lib/contracts/Initializable.sol";
|
||||
import "../Roles.sol";
|
||||
|
||||
contract SignerRole {
|
||||
|
||||
contract SignerRole is Initializable {
|
||||
using Roles for Roles.Role;
|
||||
|
||||
event SignerAdded(address indexed account);
|
||||
event SignerRemoved(address indexed account);
|
||||
|
||||
Roles.Role private _signers;
|
||||
Roles.Role private signers;
|
||||
|
||||
constructor () internal {
|
||||
_addSigner(msg.sender);
|
||||
function initialize(address sender) public initializer {
|
||||
if (!isSigner(sender)) {
|
||||
_addSigner(sender);
|
||||
}
|
||||
}
|
||||
|
||||
modifier onlySigner() {
|
||||
@ -20,7 +24,7 @@ contract SignerRole {
|
||||
}
|
||||
|
||||
function isSigner(address account) public view returns (bool) {
|
||||
return _signers.has(account);
|
||||
return signers.has(account);
|
||||
}
|
||||
|
||||
function addSigner(address account) public onlySigner {
|
||||
@ -32,12 +36,14 @@ contract SignerRole {
|
||||
}
|
||||
|
||||
function _addSigner(address account) internal {
|
||||
_signers.add(account);
|
||||
signers.add(account);
|
||||
emit SignerAdded(account);
|
||||
}
|
||||
|
||||
function _removeSigner(address account) internal {
|
||||
_signers.remove(account);
|
||||
signers.remove(account);
|
||||
emit SignerRemoved(account);
|
||||
}
|
||||
|
||||
uint256[50] private ______gap;
|
||||
}
|
||||
|
||||
@ -1,50 +0,0 @@
|
||||
pragma solidity ^0.5.0;
|
||||
|
||||
import "../Roles.sol";
|
||||
import "./WhitelisterRole.sol";
|
||||
|
||||
/**
|
||||
* @title WhitelistedRole
|
||||
* @dev Whitelisted accounts have been approved by a Whitelister to perform certain actions (e.g. participate in a
|
||||
* crowdsale). This role is special in that the only accounts that can add it are Whitelisters (who can also remove it),
|
||||
* and not Whitelisteds themselves.
|
||||
*/
|
||||
contract WhitelistedRole is WhitelisterRole {
|
||||
using Roles for Roles.Role;
|
||||
|
||||
event WhitelistedAdded(address indexed account);
|
||||
event WhitelistedRemoved(address indexed account);
|
||||
|
||||
Roles.Role private _whitelisteds;
|
||||
|
||||
modifier onlyWhitelisted() {
|
||||
require(isWhitelisted(msg.sender));
|
||||
_;
|
||||
}
|
||||
|
||||
function isWhitelisted(address account) public view returns (bool) {
|
||||
return _whitelisteds.has(account);
|
||||
}
|
||||
|
||||
function addWhitelisted(address account) public onlyWhitelister {
|
||||
_addWhitelisted(account);
|
||||
}
|
||||
|
||||
function removeWhitelisted(address account) public onlyWhitelister {
|
||||
_removeWhitelisted(account);
|
||||
}
|
||||
|
||||
function renounceWhitelisted() public {
|
||||
_removeWhitelisted(msg.sender);
|
||||
}
|
||||
|
||||
function _addWhitelisted(address account) internal {
|
||||
_whitelisteds.add(account);
|
||||
emit WhitelistedAdded(account);
|
||||
}
|
||||
|
||||
function _removeWhitelisted(address account) internal {
|
||||
_whitelisteds.remove(account);
|
||||
emit WhitelistedRemoved(account);
|
||||
}
|
||||
}
|
||||
@ -1,47 +0,0 @@
|
||||
pragma solidity ^0.5.0;
|
||||
|
||||
import "../Roles.sol";
|
||||
|
||||
/**
|
||||
* @title WhitelisterRole
|
||||
* @dev Whitelisters are responsible for assigning and removing Whitelisted accounts.
|
||||
*/
|
||||
contract WhitelisterRole {
|
||||
using Roles for Roles.Role;
|
||||
|
||||
event WhitelisterAdded(address indexed account);
|
||||
event WhitelisterRemoved(address indexed account);
|
||||
|
||||
Roles.Role private _whitelisters;
|
||||
|
||||
constructor () internal {
|
||||
_addWhitelister(msg.sender);
|
||||
}
|
||||
|
||||
modifier onlyWhitelister() {
|
||||
require(isWhitelister(msg.sender));
|
||||
_;
|
||||
}
|
||||
|
||||
function isWhitelister(address account) public view returns (bool) {
|
||||
return _whitelisters.has(account);
|
||||
}
|
||||
|
||||
function addWhitelister(address account) public onlyWhitelister {
|
||||
_addWhitelister(account);
|
||||
}
|
||||
|
||||
function renounceWhitelister() public {
|
||||
_removeWhitelister(msg.sender);
|
||||
}
|
||||
|
||||
function _addWhitelister(address account) internal {
|
||||
_whitelisters.add(account);
|
||||
emit WhitelisterAdded(account);
|
||||
}
|
||||
|
||||
function _removeWhitelister(address account) internal {
|
||||
_whitelisters.remove(account);
|
||||
emit WhitelisterRemoved(account);
|
||||
}
|
||||
}
|
||||
@ -1,9 +1,10 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "zos-lib/contracts/Initializable.sol";
|
||||
import "../token/ERC20/IERC20.sol";
|
||||
import "../math/SafeMath.sol";
|
||||
import "../token/ERC20/SafeERC20.sol";
|
||||
import "../utils/ReentrancyGuard.sol";
|
||||
|
||||
|
||||
/**
|
||||
* @title Crowdsale
|
||||
@ -17,7 +18,7 @@ import "../utils/ReentrancyGuard.sol";
|
||||
* the methods to add functionality. Consider using 'super' where appropriate to concatenate
|
||||
* behavior.
|
||||
*/
|
||||
contract Crowdsale is ReentrancyGuard {
|
||||
contract Crowdsale is Initializable {
|
||||
using SafeMath for uint256;
|
||||
using SafeERC20 for IERC20;
|
||||
|
||||
@ -25,7 +26,7 @@ contract Crowdsale is ReentrancyGuard {
|
||||
IERC20 private _token;
|
||||
|
||||
// Address where funds are collected
|
||||
address payable private _wallet;
|
||||
address private _wallet;
|
||||
|
||||
// How many token units a buyer gets per wei.
|
||||
// The rate is the conversion between wei and the smallest and indivisible token unit.
|
||||
@ -43,7 +44,12 @@ contract Crowdsale is ReentrancyGuard {
|
||||
* @param value weis paid for purchase
|
||||
* @param amount amount of tokens purchased
|
||||
*/
|
||||
event TokensPurchased(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
|
||||
event TokensPurchased(
|
||||
address indexed purchaser,
|
||||
address indexed beneficiary,
|
||||
uint256 value,
|
||||
uint256 amount
|
||||
);
|
||||
|
||||
/**
|
||||
* @param rate Number of token units a buyer gets per wei
|
||||
@ -53,10 +59,10 @@ contract Crowdsale is ReentrancyGuard {
|
||||
* @param wallet Address where collected funds will be forwarded to
|
||||
* @param token Address of the token being sold
|
||||
*/
|
||||
constructor (uint256 rate, address payable wallet, IERC20 token) public {
|
||||
function initialize(uint256 rate, address wallet, IERC20 token) public initializer {
|
||||
require(rate > 0);
|
||||
require(wallet != address(0));
|
||||
require(address(token) != address(0));
|
||||
require(token != address(0));
|
||||
|
||||
_rate = rate;
|
||||
_wallet = wallet;
|
||||
@ -69,9 +75,6 @@ contract Crowdsale is ReentrancyGuard {
|
||||
|
||||
/**
|
||||
* @dev fallback function ***DO NOT OVERRIDE***
|
||||
* Note that other contracts will transfer fund with a base gas stipend
|
||||
* of 2300, which is not enough to call buyTokens. Consider calling
|
||||
* buyTokens directly when purchasing tokens from a contract.
|
||||
*/
|
||||
function () external payable {
|
||||
buyTokens(msg.sender);
|
||||
@ -80,26 +83,26 @@ contract Crowdsale is ReentrancyGuard {
|
||||
/**
|
||||
* @return the token being sold.
|
||||
*/
|
||||
function token() public view returns (IERC20) {
|
||||
function token() public view returns(IERC20) {
|
||||
return _token;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the address where funds are collected.
|
||||
*/
|
||||
function wallet() public view returns (address payable) {
|
||||
function wallet() public view returns(address) {
|
||||
return _wallet;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the number of token units a buyer gets per wei.
|
||||
*/
|
||||
function rate() public view returns (uint256) {
|
||||
function rate() public view returns(uint256) {
|
||||
return _rate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the amount of wei raised.
|
||||
* @return the mount of wei raised.
|
||||
*/
|
||||
function weiRaised() public view returns (uint256) {
|
||||
return _weiRaised;
|
||||
@ -107,11 +110,10 @@ contract Crowdsale is ReentrancyGuard {
|
||||
|
||||
/**
|
||||
* @dev low level token purchase ***DO NOT OVERRIDE***
|
||||
* This function has a non-reentrancy guard, so it shouldn't be called by
|
||||
* another `nonReentrant` function.
|
||||
* @param beneficiary Recipient of the token purchase
|
||||
* @param beneficiary Address performing the token purchase
|
||||
*/
|
||||
function buyTokens(address beneficiary) public nonReentrant payable {
|
||||
function buyTokens(address beneficiary) public payable {
|
||||
|
||||
uint256 weiAmount = msg.value;
|
||||
_preValidatePurchase(beneficiary, weiAmount);
|
||||
|
||||
@ -122,7 +124,12 @@ contract Crowdsale is ReentrancyGuard {
|
||||
_weiRaised = _weiRaised.add(weiAmount);
|
||||
|
||||
_processPurchase(beneficiary, tokens);
|
||||
emit TokensPurchased(msg.sender, beneficiary, weiAmount, tokens);
|
||||
emit TokensPurchased(
|
||||
msg.sender,
|
||||
beneficiary,
|
||||
weiAmount,
|
||||
tokens
|
||||
);
|
||||
|
||||
_updatePurchasingState(beneficiary, weiAmount);
|
||||
|
||||
@ -134,6 +141,10 @@ contract Crowdsale is ReentrancyGuard {
|
||||
// Internal interface (extensible)
|
||||
// -----------------------------------------
|
||||
|
||||
function _hasBeenInitialized() internal view returns (bool) {
|
||||
return ((_rate > 0) && (_wallet != address(0)) && (_token != address(0)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use `super` in contracts that inherit from Crowdsale to extend their validations.
|
||||
* Example from CappedCrowdsale.sol's _preValidatePurchase method:
|
||||
@ -142,7 +153,12 @@ contract Crowdsale is ReentrancyGuard {
|
||||
* @param beneficiary Address performing the token 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
|
||||
{
|
||||
require(beneficiary != address(0));
|
||||
require(weiAmount != 0);
|
||||
}
|
||||
@ -152,7 +168,12 @@ contract Crowdsale is ReentrancyGuard {
|
||||
* @param beneficiary Address performing the token purchase
|
||||
* @param weiAmount Value in wei involved in the purchase
|
||||
*/
|
||||
function _postValidatePurchase(address beneficiary, uint256 weiAmount) internal view {
|
||||
function _postValidatePurchase(
|
||||
address beneficiary,
|
||||
uint256 weiAmount
|
||||
)
|
||||
internal
|
||||
{
|
||||
// optional override
|
||||
}
|
||||
|
||||
@ -161,16 +182,26 @@ contract Crowdsale is ReentrancyGuard {
|
||||
* @param beneficiary Address performing the token purchase
|
||||
* @param tokenAmount Number of tokens to be emitted
|
||||
*/
|
||||
function _deliverTokens(address beneficiary, uint256 tokenAmount) internal {
|
||||
function _deliverTokens(
|
||||
address beneficiary,
|
||||
uint256 tokenAmount
|
||||
)
|
||||
internal
|
||||
{
|
||||
_token.safeTransfer(beneficiary, tokenAmount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Executed when a purchase has been validated and is ready to be executed. Doesn't necessarily emit/send tokens.
|
||||
* @dev Executed when a purchase has been validated and is ready to be executed. Not necessarily emits/sends tokens.
|
||||
* @param beneficiary Address receiving the tokens
|
||||
* @param tokenAmount Number of tokens to be purchased
|
||||
*/
|
||||
function _processPurchase(address beneficiary, uint256 tokenAmount) internal {
|
||||
function _processPurchase(
|
||||
address beneficiary,
|
||||
uint256 tokenAmount
|
||||
)
|
||||
internal
|
||||
{
|
||||
_deliverTokens(beneficiary, tokenAmount);
|
||||
}
|
||||
|
||||
@ -179,7 +210,12 @@ contract Crowdsale is ReentrancyGuard {
|
||||
* @param beneficiary Address receiving the tokens
|
||||
* @param weiAmount Value in wei involved in the purchase
|
||||
*/
|
||||
function _updatePurchasingState(address beneficiary, uint256 weiAmount) internal {
|
||||
function _updatePurchasingState(
|
||||
address beneficiary,
|
||||
uint256 weiAmount
|
||||
)
|
||||
internal
|
||||
{
|
||||
// optional override
|
||||
}
|
||||
|
||||
@ -188,7 +224,9 @@ contract Crowdsale is ReentrancyGuard {
|
||||
* @param weiAmount Value in wei to be converted into tokens
|
||||
* @return Number of tokens that can be purchased with the specified _weiAmount
|
||||
*/
|
||||
function _getTokenAmount(uint256 weiAmount) internal view returns (uint256) {
|
||||
function _getTokenAmount(uint256 weiAmount)
|
||||
internal view returns (uint256)
|
||||
{
|
||||
return weiAmount.mul(_rate);
|
||||
}
|
||||
|
||||
@ -198,4 +236,6 @@ contract Crowdsale is ReentrancyGuard {
|
||||
function _forwardFunds() internal {
|
||||
_wallet.transfer(msg.value);
|
||||
}
|
||||
|
||||
uint256[50] private ______gap;
|
||||
}
|
||||
|
||||
@ -1,24 +1,22 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "zos-lib/contracts/Initializable.sol";
|
||||
import "../../math/SafeMath.sol";
|
||||
import "../validation/TimedCrowdsale.sol";
|
||||
|
||||
|
||||
/**
|
||||
* @title FinalizableCrowdsale
|
||||
* @dev Extension of Crowdsale with a one-off finalization action, where one
|
||||
* can do extra work after finishing.
|
||||
*/
|
||||
contract FinalizableCrowdsale is TimedCrowdsale {
|
||||
contract FinalizableCrowdsale is Initializable, TimedCrowdsale {
|
||||
using SafeMath for uint256;
|
||||
|
||||
bool private _finalized;
|
||||
bool private _finalized = false;
|
||||
|
||||
event CrowdsaleFinalized();
|
||||
|
||||
constructor () internal {
|
||||
_finalized = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the crowdsale is finalized, false otherwise.
|
||||
*/
|
||||
@ -34,10 +32,10 @@ contract FinalizableCrowdsale is TimedCrowdsale {
|
||||
require(!_finalized);
|
||||
require(hasClosed());
|
||||
|
||||
_finalized = true;
|
||||
|
||||
_finalization();
|
||||
emit CrowdsaleFinalized();
|
||||
|
||||
_finalized = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -45,5 +43,9 @@ contract FinalizableCrowdsale is TimedCrowdsale {
|
||||
* should call super._finalization() to ensure the chain of finalization is
|
||||
* executed entirely.
|
||||
*/
|
||||
function _finalization() internal {}
|
||||
function _finalization() internal {
|
||||
}
|
||||
|
||||
|
||||
uint256[50] private ______gap;
|
||||
}
|
||||
|
||||
@ -1,13 +1,16 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "zos-lib/contracts/Initializable.sol";
|
||||
import "../validation/TimedCrowdsale.sol";
|
||||
import "../../token/ERC20/IERC20.sol";
|
||||
import "../../math/SafeMath.sol";
|
||||
|
||||
|
||||
/**
|
||||
* @title PostDeliveryCrowdsale
|
||||
* @dev Crowdsale that locks tokens from withdrawal until it ends.
|
||||
*/
|
||||
contract PostDeliveryCrowdsale is TimedCrowdsale {
|
||||
contract PostDeliveryCrowdsale is Initializable, TimedCrowdsale {
|
||||
using SafeMath for uint256;
|
||||
|
||||
mapping(address => uint256) private _balances;
|
||||
@ -27,7 +30,7 @@ contract PostDeliveryCrowdsale is TimedCrowdsale {
|
||||
/**
|
||||
* @return the balance of an account.
|
||||
*/
|
||||
function balanceOf(address account) public view returns (uint256) {
|
||||
function balanceOf(address account) public view returns(uint256) {
|
||||
return _balances[account];
|
||||
}
|
||||
|
||||
@ -36,8 +39,15 @@ contract PostDeliveryCrowdsale is TimedCrowdsale {
|
||||
* @param beneficiary Token purchaser
|
||||
* @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);
|
||||
}
|
||||
|
||||
|
||||
uint256[50] private ______gap;
|
||||
}
|
||||
|
||||
@ -1,20 +1,18 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
|
||||
import "zos-lib/contracts/Initializable.sol";
|
||||
import "../../math/SafeMath.sol";
|
||||
import "./FinalizableCrowdsale.sol";
|
||||
import "../../payment/escrow/RefundEscrow.sol";
|
||||
import "../../payment/RefundEscrow.sol";
|
||||
|
||||
|
||||
/**
|
||||
* @title RefundableCrowdsale
|
||||
* @dev Extension of Crowdsale contract that adds a funding goal, and the possibility of users getting a refund if goal
|
||||
* is not met.
|
||||
*
|
||||
* 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
|
||||
* 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.
|
||||
* @dev Extension of Crowdsale contract that adds a funding goal, and
|
||||
* the possibility of users getting a refund if goal is not met.
|
||||
*/
|
||||
contract RefundableCrowdsale is FinalizableCrowdsale {
|
||||
contract RefundableCrowdsale is Initializable, FinalizableCrowdsale {
|
||||
using SafeMath for uint256;
|
||||
|
||||
// minimum amount of funds to be raised in weis
|
||||
@ -27,28 +25,37 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
|
||||
* @dev Constructor, creates RefundEscrow.
|
||||
* @param goal Funding goal
|
||||
*/
|
||||
constructor (uint256 goal) public {
|
||||
function initialize(uint256 goal) public initializer {
|
||||
// FinalizableCrowdsale depends on TimedCrowdsale
|
||||
assert(TimedCrowdsale._hasBeenInitialized());
|
||||
|
||||
require(goal > 0);
|
||||
_escrow = new RefundEscrow(wallet());
|
||||
|
||||
// conditional added to make initializer idempotent in case of diamond inheritance
|
||||
if (address(_escrow) == address(0)) {
|
||||
_escrow = new RefundEscrow();
|
||||
_escrow.initialize(wallet(), address(this));
|
||||
}
|
||||
|
||||
_goal = goal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return minimum amount of funds to be raised in wei.
|
||||
*/
|
||||
function goal() public view returns (uint256) {
|
||||
function goal() public view returns(uint256) {
|
||||
return _goal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Investors can claim refunds here if crowdsale is unsuccessful
|
||||
* @param refundee Whose refund will be claimed.
|
||||
* @param beneficiary Whose refund will be claimed.
|
||||
*/
|
||||
function claimRefund(address payable refundee) public {
|
||||
function claimRefund(address beneficiary) public {
|
||||
require(finalized());
|
||||
require(!goalReached());
|
||||
|
||||
_escrow.withdraw(refundee);
|
||||
_escrow.withdraw(beneficiary);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -79,4 +86,7 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
|
||||
function _forwardFunds() internal {
|
||||
_escrow.deposit.value(msg.value)(msg.sender);
|
||||
}
|
||||
|
||||
|
||||
uint256[50] private ______gap;
|
||||
}
|
||||
|
||||
@ -1,20 +0,0 @@
|
||||
pragma solidity ^0.5.0;
|
||||
|
||||
import "./RefundableCrowdsale.sol";
|
||||
import "./PostDeliveryCrowdsale.sol";
|
||||
|
||||
|
||||
/**
|
||||
* @title RefundablePostDeliveryCrowdsale
|
||||
* @dev Extension of RefundableCrowdsale contract that only delivers the tokens
|
||||
* once the crowdsale has closed and the goal met, preventing refunds to be issued
|
||||
* to token holders.
|
||||
*/
|
||||
contract RefundablePostDeliveryCrowdsale is RefundableCrowdsale, PostDeliveryCrowdsale {
|
||||
function withdrawTokens(address beneficiary) public {
|
||||
require(finalized());
|
||||
require(goalReached());
|
||||
|
||||
super.withdrawTokens(beneficiary);
|
||||
}
|
||||
}
|
||||
@ -1,16 +1,17 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "zos-lib/contracts/Initializable.sol";
|
||||
import "../Crowdsale.sol";
|
||||
import "../../token/ERC20/IERC20.sol";
|
||||
import "../../token/ERC20/SafeERC20.sol";
|
||||
import "../../math/SafeMath.sol";
|
||||
import "../../math/Math.sol";
|
||||
|
||||
|
||||
/**
|
||||
* @title AllowanceCrowdsale
|
||||
* @dev Extension of Crowdsale where tokens are held by a wallet, which approves an allowance to the crowdsale.
|
||||
*/
|
||||
contract AllowanceCrowdsale is Crowdsale {
|
||||
contract AllowanceCrowdsale is Initializable, Crowdsale {
|
||||
using SafeMath for uint256;
|
||||
using SafeERC20 for IERC20;
|
||||
|
||||
@ -20,7 +21,9 @@ contract AllowanceCrowdsale is Crowdsale {
|
||||
* @dev Constructor, takes token wallet address.
|
||||
* @param tokenWallet Address holding the tokens, which has approved allowance to the crowdsale
|
||||
*/
|
||||
constructor (address tokenWallet) public {
|
||||
function initialize(address tokenWallet) public initializer {
|
||||
assert(Crowdsale._hasBeenInitialized());
|
||||
|
||||
require(tokenWallet != address(0));
|
||||
_tokenWallet = tokenWallet;
|
||||
}
|
||||
@ -28,7 +31,7 @@ contract AllowanceCrowdsale is Crowdsale {
|
||||
/**
|
||||
* @return the address of the wallet that will hold the tokens.
|
||||
*/
|
||||
function tokenWallet() public view returns (address) {
|
||||
function tokenWallet() public view returns(address) {
|
||||
return _tokenWallet;
|
||||
}
|
||||
|
||||
@ -37,7 +40,7 @@ contract AllowanceCrowdsale is Crowdsale {
|
||||
* @return Amount of tokens left in the allowance
|
||||
*/
|
||||
function remainingTokens() public view returns (uint256) {
|
||||
return Math.min(token().balanceOf(_tokenWallet), token().allowance(_tokenWallet, address(this)));
|
||||
return token().allowance(_tokenWallet, this);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -45,7 +48,14 @@ contract AllowanceCrowdsale is Crowdsale {
|
||||
* @param beneficiary Token purchaser
|
||||
* @param tokenAmount Amount of tokens purchased
|
||||
*/
|
||||
function _deliverTokens(address beneficiary, uint256 tokenAmount) internal {
|
||||
function _deliverTokens(
|
||||
address beneficiary,
|
||||
uint256 tokenAmount
|
||||
)
|
||||
internal
|
||||
{
|
||||
token().safeTransferFrom(_tokenWallet, beneficiary, tokenAmount);
|
||||
}
|
||||
|
||||
uint256[50] private ______gap;
|
||||
}
|
||||
|
||||
@ -1,21 +1,32 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "zos-lib/contracts/Initializable.sol";
|
||||
import "../Crowdsale.sol";
|
||||
import "../../token/ERC20/ERC20Mintable.sol";
|
||||
|
||||
|
||||
/**
|
||||
* @title MintedCrowdsale
|
||||
* @dev Extension of Crowdsale contract whose tokens are minted in each purchase.
|
||||
* Token ownership should be transferred to MintedCrowdsale for minting.
|
||||
*/
|
||||
contract MintedCrowdsale is Crowdsale {
|
||||
contract MintedCrowdsale is Initializable, Crowdsale {
|
||||
|
||||
/**
|
||||
* @dev Overrides delivery by minting tokens upon purchase.
|
||||
* @param beneficiary Token purchaser
|
||||
* @param tokenAmount Number of tokens to be minted
|
||||
*/
|
||||
function _deliverTokens(address beneficiary, uint256 tokenAmount) internal {
|
||||
function _deliverTokens(
|
||||
address beneficiary,
|
||||
uint256 tokenAmount
|
||||
)
|
||||
internal
|
||||
{
|
||||
// Potentially dangerous assumption about the type of the token.
|
||||
require(ERC20Mintable(address(token())).mint(beneficiary, tokenAmount));
|
||||
require(
|
||||
ERC20Mintable(address(token())).mint(beneficiary, tokenAmount));
|
||||
}
|
||||
|
||||
uint256[50] private ______gap;
|
||||
}
|
||||
|
||||
@ -1,15 +1,17 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "zos-lib/contracts/Initializable.sol";
|
||||
import "../validation/TimedCrowdsale.sol";
|
||||
import "../../math/SafeMath.sol";
|
||||
|
||||
|
||||
/**
|
||||
* @title IncreasingPriceCrowdsale
|
||||
* @dev Extension of Crowdsale contract that increases the price of tokens linearly in time.
|
||||
* Note that what should be provided to the constructor is the initial and final _rates_, that is,
|
||||
* the amount of tokens per wei contributed. Thus, the initial rate must be greater than the final rate.
|
||||
*/
|
||||
contract IncreasingPriceCrowdsale is TimedCrowdsale {
|
||||
contract IncreasingPriceCrowdsale is Initializable, TimedCrowdsale {
|
||||
using SafeMath for uint256;
|
||||
|
||||
uint256 private _initialRate;
|
||||
@ -20,25 +22,19 @@ contract IncreasingPriceCrowdsale is TimedCrowdsale {
|
||||
* @param initialRate Number of tokens a buyer gets per wei at the start of the crowdsale
|
||||
* @param finalRate Number of tokens a buyer gets per wei at the end of the crowdsale
|
||||
*/
|
||||
constructor (uint256 initialRate, uint256 finalRate) public {
|
||||
function initialize(uint256 initialRate, uint256 finalRate) public initializer {
|
||||
assert(TimedCrowdsale._hasBeenInitialized());
|
||||
|
||||
require(finalRate > 0);
|
||||
require(initialRate > finalRate);
|
||||
require(initialRate >= finalRate);
|
||||
_initialRate = initialRate;
|
||||
_finalRate = finalRate;
|
||||
}
|
||||
|
||||
/**
|
||||
* The base rate function is overridden to revert, since this crowdsale doens't use it, and
|
||||
* all calls to it are a mistake.
|
||||
*/
|
||||
function rate() public view returns (uint256) {
|
||||
revert();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the initial rate of the crowdsale.
|
||||
*/
|
||||
function initialRate() public view returns (uint256) {
|
||||
function initialRate() public view returns(uint256) {
|
||||
return _initialRate;
|
||||
}
|
||||
|
||||
@ -55,10 +51,6 @@ contract IncreasingPriceCrowdsale is TimedCrowdsale {
|
||||
* @return The number of tokens a buyer gets per wei at a given time
|
||||
*/
|
||||
function getCurrentRate() public view returns (uint256) {
|
||||
if (!isOpen()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// solium-disable-next-line security/no-block-members
|
||||
uint256 elapsedTime = block.timestamp.sub(openingTime());
|
||||
uint256 timeRange = closingTime().sub(openingTime());
|
||||
@ -71,8 +63,13 @@ contract IncreasingPriceCrowdsale is TimedCrowdsale {
|
||||
* @param weiAmount The value in wei to be converted into tokens
|
||||
* @return The number of tokens _weiAmount wei will buy at present time
|
||||
*/
|
||||
function _getTokenAmount(uint256 weiAmount) internal view returns (uint256) {
|
||||
function _getTokenAmount(uint256 weiAmount)
|
||||
internal view returns (uint256)
|
||||
{
|
||||
uint256 currentRate = getCurrentRate();
|
||||
return currentRate.mul(weiAmount);
|
||||
}
|
||||
|
||||
|
||||
uint256[50] private ______gap;
|
||||
}
|
||||
|
||||
@ -1,13 +1,15 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "zos-lib/contracts/Initializable.sol";
|
||||
import "../../math/SafeMath.sol";
|
||||
import "../Crowdsale.sol";
|
||||
|
||||
|
||||
/**
|
||||
* @title CappedCrowdsale
|
||||
* @dev Crowdsale with a limit for total contributions.
|
||||
*/
|
||||
contract CappedCrowdsale is Crowdsale {
|
||||
contract CappedCrowdsale is Initializable, Crowdsale {
|
||||
using SafeMath for uint256;
|
||||
|
||||
uint256 private _cap;
|
||||
@ -16,7 +18,9 @@ contract CappedCrowdsale is Crowdsale {
|
||||
* @dev Constructor, takes maximum amount of wei accepted in the crowdsale.
|
||||
* @param cap Max amount of wei to be contributed
|
||||
*/
|
||||
constructor (uint256 cap) public {
|
||||
function initialize(uint256 cap) public initializer {
|
||||
assert(Crowdsale._hasBeenInitialized());
|
||||
|
||||
require(cap > 0);
|
||||
_cap = cap;
|
||||
}
|
||||
@ -24,7 +28,7 @@ contract CappedCrowdsale is Crowdsale {
|
||||
/**
|
||||
* @return the cap of the crowdsale.
|
||||
*/
|
||||
function cap() public view returns (uint256) {
|
||||
function cap() public view returns(uint256) {
|
||||
return _cap;
|
||||
}
|
||||
|
||||
@ -41,8 +45,16 @@ contract CappedCrowdsale is Crowdsale {
|
||||
* @param beneficiary Token purchaser
|
||||
* @param weiAmount Amount of wei contributed
|
||||
*/
|
||||
function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal view {
|
||||
function _preValidatePurchase(
|
||||
address beneficiary,
|
||||
uint256 weiAmount
|
||||
)
|
||||
internal
|
||||
{
|
||||
super._preValidatePurchase(beneficiary, weiAmount);
|
||||
require(weiRaised().add(weiAmount) <= _cap);
|
||||
}
|
||||
|
||||
|
||||
uint256[50] private ______gap;
|
||||
}
|
||||
|
||||
@ -1,19 +1,27 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "zos-lib/contracts/Initializable.sol";
|
||||
import "../../math/SafeMath.sol";
|
||||
import "../Crowdsale.sol";
|
||||
import "../../access/roles/CapperRole.sol";
|
||||
|
||||
|
||||
/**
|
||||
* @title IndividuallyCappedCrowdsale
|
||||
* @dev Crowdsale with per-beneficiary caps.
|
||||
*/
|
||||
contract IndividuallyCappedCrowdsale is Crowdsale, CapperRole {
|
||||
contract IndividuallyCappedCrowdsale is Initializable, Crowdsale, CapperRole {
|
||||
using SafeMath for uint256;
|
||||
|
||||
mapping(address => uint256) private _contributions;
|
||||
mapping(address => uint256) private _caps;
|
||||
|
||||
function initialize(address sender) public initializer {
|
||||
assert(Crowdsale._hasBeenInitialized());
|
||||
|
||||
CapperRole.initialize(sender);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Sets a specific beneficiary's maximum contribution.
|
||||
* @param beneficiary Address to be capped
|
||||
@ -37,7 +45,9 @@ contract IndividuallyCappedCrowdsale is Crowdsale, CapperRole {
|
||||
* @param beneficiary Address of contributor
|
||||
* @return Beneficiary contribution so far
|
||||
*/
|
||||
function getContribution(address beneficiary) public view returns (uint256) {
|
||||
function getContribution(address beneficiary)
|
||||
public view returns (uint256)
|
||||
{
|
||||
return _contributions[beneficiary];
|
||||
}
|
||||
|
||||
@ -46,9 +56,15 @@ contract IndividuallyCappedCrowdsale is Crowdsale, CapperRole {
|
||||
* @param beneficiary Token purchaser
|
||||
* @param weiAmount Amount of wei contributed
|
||||
*/
|
||||
function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal view {
|
||||
function _preValidatePurchase(
|
||||
address beneficiary,
|
||||
uint256 weiAmount
|
||||
)
|
||||
internal
|
||||
{
|
||||
super._preValidatePurchase(beneficiary, weiAmount);
|
||||
require(_contributions[beneficiary].add(weiAmount) <= _caps[beneficiary]);
|
||||
require(
|
||||
_contributions[beneficiary].add(weiAmount) <= _caps[beneficiary]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -56,8 +72,17 @@ contract IndividuallyCappedCrowdsale is Crowdsale, CapperRole {
|
||||
* @param beneficiary Token purchaser
|
||||
* @param weiAmount Amount of wei contributed
|
||||
*/
|
||||
function _updatePurchasingState(address beneficiary, uint256 weiAmount) internal {
|
||||
function _updatePurchasingState(
|
||||
address beneficiary,
|
||||
uint256 weiAmount
|
||||
)
|
||||
internal
|
||||
{
|
||||
super._updatePurchasingState(beneficiary, weiAmount);
|
||||
_contributions[beneficiary] = _contributions[beneficiary].add(weiAmount);
|
||||
_contributions[beneficiary] = _contributions[beneficiary].add(
|
||||
weiAmount);
|
||||
}
|
||||
|
||||
|
||||
uint256[50] private ______gap;
|
||||
}
|
||||
|
||||
@ -1,21 +0,0 @@
|
||||
pragma solidity ^0.5.0;
|
||||
|
||||
import "../Crowdsale.sol";
|
||||
import "../../lifecycle/Pausable.sol";
|
||||
|
||||
/**
|
||||
* @title PausableCrowdsale
|
||||
* @dev Extension of Crowdsale contract where purchases can be paused and unpaused by the pauser role.
|
||||
*/
|
||||
contract PausableCrowdsale is Crowdsale, Pausable {
|
||||
|
||||
/**
|
||||
* @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use super to concatenate validations.
|
||||
* Adds the validation that the crowdsale must not be paused.
|
||||
* @param _beneficiary Address performing the token purchase
|
||||
* @param _weiAmount Value in wei involved in the purchase
|
||||
*/
|
||||
function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal view whenNotPaused {
|
||||
return super._preValidatePurchase(_beneficiary, _weiAmount);
|
||||
}
|
||||
}
|
||||
@ -1,13 +1,15 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "zos-lib/contracts/Initializable.sol";
|
||||
import "../../math/SafeMath.sol";
|
||||
import "../Crowdsale.sol";
|
||||
|
||||
|
||||
/**
|
||||
* @title TimedCrowdsale
|
||||
* @dev Crowdsale accepting contributions only within a time frame.
|
||||
*/
|
||||
contract TimedCrowdsale is Crowdsale {
|
||||
contract TimedCrowdsale is Initializable, Crowdsale {
|
||||
using SafeMath for uint256;
|
||||
|
||||
uint256 private _openingTime;
|
||||
@ -26,10 +28,12 @@ contract TimedCrowdsale is Crowdsale {
|
||||
* @param openingTime Crowdsale opening time
|
||||
* @param closingTime Crowdsale closing time
|
||||
*/
|
||||
constructor (uint256 openingTime, uint256 closingTime) public {
|
||||
function initialize(uint256 openingTime, uint256 closingTime) public initializer {
|
||||
assert(Crowdsale._hasBeenInitialized());
|
||||
|
||||
// solium-disable-next-line security/no-block-members
|
||||
require(openingTime >= block.timestamp);
|
||||
require(closingTime > openingTime);
|
||||
require(closingTime >= openingTime);
|
||||
|
||||
_openingTime = openingTime;
|
||||
_closingTime = closingTime;
|
||||
@ -38,14 +42,14 @@ contract TimedCrowdsale is Crowdsale {
|
||||
/**
|
||||
* @return the crowdsale opening time.
|
||||
*/
|
||||
function openingTime() public view returns (uint256) {
|
||||
function openingTime() public view returns(uint256) {
|
||||
return _openingTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the crowdsale closing time.
|
||||
*/
|
||||
function closingTime() public view returns (uint256) {
|
||||
function closingTime() public view returns(uint256) {
|
||||
return _closingTime;
|
||||
}
|
||||
|
||||
@ -66,12 +70,25 @@ contract TimedCrowdsale is Crowdsale {
|
||||
return block.timestamp > _closingTime;
|
||||
}
|
||||
|
||||
function _hasBeenInitialized() internal view returns (bool) {
|
||||
return ((_openingTime > 0) && (_closingTime > 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Extend parent behavior requiring to be within contributing period
|
||||
* @param beneficiary Token purchaser
|
||||
* @param weiAmount Amount of wei contributed
|
||||
*/
|
||||
function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal onlyWhileOpen view {
|
||||
function _preValidatePurchase(
|
||||
address beneficiary,
|
||||
uint256 weiAmount
|
||||
)
|
||||
internal
|
||||
onlyWhileOpen
|
||||
{
|
||||
super._preValidatePurchase(beneficiary, weiAmount);
|
||||
}
|
||||
|
||||
|
||||
uint256[50] private ______gap;
|
||||
}
|
||||
|
||||
@ -1,21 +0,0 @@
|
||||
pragma solidity ^0.5.0;
|
||||
import "../Crowdsale.sol";
|
||||
import "../../access/roles/WhitelistedRole.sol";
|
||||
|
||||
|
||||
/**
|
||||
* @title WhitelistCrowdsale
|
||||
* @dev Crowdsale in which only whitelisted users can contribute.
|
||||
*/
|
||||
contract WhitelistCrowdsale is WhitelistedRole, Crowdsale {
|
||||
/**
|
||||
* @dev Extend parent behavior requiring beneficiary to be whitelisted. Note that no
|
||||
* restriction is imposed on the account sending the transaction.
|
||||
* @param _beneficiary Token beneficiary
|
||||
* @param _weiAmount Amount of wei contributed
|
||||
*/
|
||||
function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal view {
|
||||
require(isWhitelisted(_beneficiary));
|
||||
super._preValidatePurchase(_beneficiary, _weiAmount);
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
|
||||
/**
|
||||
* @title Elliptic curve signature operations
|
||||
@ -8,12 +9,17 @@ pragma solidity ^0.5.0;
|
||||
*/
|
||||
|
||||
library ECDSA {
|
||||
|
||||
/**
|
||||
* @dev Recover signer address from a message by using their signature
|
||||
* @param hash bytes32 message, the hash is the signed message. What is recovered is the signer address.
|
||||
* @param signature bytes signature, the signature is generated using web3.eth.sign()
|
||||
*/
|
||||
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
|
||||
function recover(bytes32 hash, bytes signature)
|
||||
internal
|
||||
pure
|
||||
returns (address)
|
||||
{
|
||||
bytes32 r;
|
||||
bytes32 s;
|
||||
uint8 v;
|
||||
@ -28,9 +34,9 @@ library ECDSA {
|
||||
// currently is to use assembly.
|
||||
// solium-disable-next-line security/no-inline-assembly
|
||||
assembly {
|
||||
r := mload(add(signature, 0x20))
|
||||
s := mload(add(signature, 0x40))
|
||||
v := byte(0, mload(add(signature, 0x60)))
|
||||
r := mload(add(signature, 32))
|
||||
s := mload(add(signature, 64))
|
||||
v := byte(0, mload(add(signature, 96)))
|
||||
}
|
||||
|
||||
// Version of signature should be 27 or 28, but 0 and 1 are also possible versions
|
||||
@ -52,9 +58,15 @@ library ECDSA {
|
||||
* @dev prefix a bytes32 value with "\x19Ethereum Signed Message:"
|
||||
* and hash the result
|
||||
*/
|
||||
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
|
||||
function toEthSignedMessageHash(bytes32 hash)
|
||||
internal
|
||||
pure
|
||||
returns (bytes32)
|
||||
{
|
||||
// 32 is the length in bytes of hash,
|
||||
// enforced by the type signature above
|
||||
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
|
||||
return keccak256(
|
||||
abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
|
||||
/**
|
||||
* @title MerkleProof
|
||||
@ -13,7 +14,15 @@ library MerkleProof {
|
||||
* @param root Merkle root
|
||||
* @param leaf Leaf of Merkle tree
|
||||
*/
|
||||
function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
|
||||
function verify(
|
||||
bytes32[] proof,
|
||||
bytes32 root,
|
||||
bytes32 leaf
|
||||
)
|
||||
internal
|
||||
pure
|
||||
returns (bool)
|
||||
{
|
||||
bytes32 computedHash = leaf;
|
||||
|
||||
for (uint256 i = 0; i < proof.length; i++) {
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
|
||||
/**
|
||||
* @title Counter
|
||||
@ -13,11 +14,15 @@ pragma solidity ^0.5.0;
|
||||
* so it's not something you have to worry about.)
|
||||
*/
|
||||
library Counter {
|
||||
|
||||
struct Counter {
|
||||
uint256 current; // default: 0
|
||||
}
|
||||
|
||||
function next(Counter storage index) internal returns (uint256) {
|
||||
function next(Counter storage index)
|
||||
internal
|
||||
returns (uint256)
|
||||
{
|
||||
index.current += 1;
|
||||
return index.current;
|
||||
}
|
||||
|
||||
@ -1,25 +1,35 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "zos-lib/contracts/Initializable.sol";
|
||||
import "../../token/ERC20/IERC20.sol";
|
||||
|
||||
|
||||
/**
|
||||
* @title ERC-1047 Token Metadata
|
||||
* @dev See https://eips.ethereum.org/EIPS/eip-1046
|
||||
* @dev tokenURI must respond with a URI that implements https://eips.ethereum.org/EIPS/eip-1047
|
||||
* @dev TODO - update https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/token/ERC721/IERC721.sol#L17 when 1046 is finalized
|
||||
*/
|
||||
contract ERC20TokenMetadata is IERC20 {
|
||||
function tokenURI() external view returns (string memory);
|
||||
contract ERC20TokenMetadata is Initializable, IERC20 {
|
||||
function tokenURI() external view returns (string);
|
||||
|
||||
uint256[50] private ______gap;
|
||||
}
|
||||
|
||||
contract ERC20WithMetadata is ERC20TokenMetadata {
|
||||
string private _tokenURI;
|
||||
|
||||
constructor (string memory tokenURI) public {
|
||||
contract ERC20WithMetadata is Initializable, ERC20TokenMetadata {
|
||||
string private _tokenURI = "";
|
||||
|
||||
function initialize(string tokenURI)
|
||||
public
|
||||
initializer
|
||||
{
|
||||
_tokenURI = tokenURI;
|
||||
}
|
||||
|
||||
function tokenURI() external view returns (string memory) {
|
||||
function tokenURI() external view returns (string) {
|
||||
return _tokenURI;
|
||||
}
|
||||
|
||||
uint256[50] private ______gap;
|
||||
}
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "zos-lib/contracts/Initializable.sol";
|
||||
import "../token/ERC20/IERC20.sol";
|
||||
import "../token/ERC20/ERC20Mintable.sol";
|
||||
import "../token/ERC20/SafeERC20.sol";
|
||||
import "../math/Math.sol";
|
||||
|
||||
|
||||
/**
|
||||
* @title ERC20Migrator
|
||||
* @dev This contract can be used to migrate an ERC20 token from one
|
||||
@ -31,7 +33,7 @@ import "../math/Math.sol";
|
||||
* await migrator.beginMigration(newToken.address);
|
||||
* ```
|
||||
*/
|
||||
contract ERC20Migrator {
|
||||
contract ERC20Migrator is Initializable {
|
||||
using SafeERC20 for IERC20;
|
||||
|
||||
/// Address of the old token contract
|
||||
@ -43,8 +45,8 @@ contract ERC20Migrator {
|
||||
/**
|
||||
* @param legacyToken address of the old token contract
|
||||
*/
|
||||
constructor (IERC20 legacyToken) public {
|
||||
require(address(legacyToken) != address(0));
|
||||
function initialize(IERC20 legacyToken) public initializer {
|
||||
require(legacyToken != address(0));
|
||||
_legacyToken = legacyToken;
|
||||
}
|
||||
|
||||
@ -68,9 +70,9 @@ contract ERC20Migrator {
|
||||
* @param newToken the token that will be minted
|
||||
*/
|
||||
function beginMigration(ERC20Mintable newToken) public {
|
||||
require(address(_newToken) == address(0));
|
||||
require(address(newToken) != address(0));
|
||||
require(newToken.isMinter(address(this)));
|
||||
require(_newToken == address(0));
|
||||
require(newToken != address(0));
|
||||
require(newToken.isMinter(this));
|
||||
|
||||
_newToken = newToken;
|
||||
}
|
||||
@ -82,7 +84,7 @@ contract ERC20Migrator {
|
||||
* @param amount amount of tokens to be migrated
|
||||
*/
|
||||
function migrate(address account, uint256 amount) public {
|
||||
_legacyToken.safeTransferFrom(account, address(this), amount);
|
||||
_legacyToken.safeTransferFrom(account, this, amount);
|
||||
_newToken.mint(account, amount);
|
||||
}
|
||||
|
||||
@ -93,8 +95,10 @@ contract ERC20Migrator {
|
||||
*/
|
||||
function migrateAll(address account) public {
|
||||
uint256 balance = _legacyToken.balanceOf(account);
|
||||
uint256 allowance = _legacyToken.allowance(account, address(this));
|
||||
uint256 allowance = _legacyToken.allowance(account, this);
|
||||
uint256 amount = Math.min(balance, allowance);
|
||||
migrate(account, amount);
|
||||
}
|
||||
|
||||
uint256[50] private ______gap;
|
||||
}
|
||||
|
||||
@ -1,40 +1,35 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "zos-lib/contracts/Initializable.sol";
|
||||
import "../access/roles/SignerRole.sol";
|
||||
import "../cryptography/ECDSA.sol";
|
||||
|
||||
|
||||
/**
|
||||
* @title SignatureBouncer
|
||||
* @author PhABC, Shrugs and aflesher
|
||||
* @dev SignatureBouncer allows users to submit a signature as a permission to
|
||||
* do an action.
|
||||
* If the signature is from one of the authorized signer addresses, the
|
||||
* signature is valid.
|
||||
* Note that SignatureBouncer offers no protection against replay attacks, users
|
||||
* must add this themselves!
|
||||
*
|
||||
* @dev SignatureBouncer allows users to submit a signature as a permission to do an action.
|
||||
* If the signature is from one of the authorized signer addresses, the signature
|
||||
* is valid.
|
||||
* Signer addresses can be individual servers signing grants or different
|
||||
* users within a decentralized club that have permission to invite other
|
||||
* members. This technique is useful for whitelists and airdrops; instead of
|
||||
* putting all valid addresses on-chain, simply sign a grant of the form
|
||||
* keccak256(abi.encodePacked(`:contractAddress` + `:granteeAddress`)) using a
|
||||
* valid signer address.
|
||||
* users within a decentralized club that have permission to invite other members.
|
||||
* This technique is useful for whitelists and airdrops; instead of putting all
|
||||
* valid addresses on-chain, simply sign a grant of the form
|
||||
* keccak256(abi.encodePacked(`:contractAddress` + `:granteeAddress`)) using a valid signer address.
|
||||
* Then restrict access to your crowdsale/whitelist/airdrop using the
|
||||
* `onlyValidSignature` modifier (or implement your own using _isValidSignature).
|
||||
* In addition to `onlyValidSignature`, `onlyValidSignatureAndMethod` and
|
||||
* `onlyValidSignatureAndData` can be used to restrict access to only a given
|
||||
* method or a given method with given parameters respectively.
|
||||
* `onlyValidSignatureAndData` can be used to restrict access to only a given method
|
||||
* or a given method with given parameters respectively.
|
||||
* See the tests in SignatureBouncer.test.js for specific usage examples.
|
||||
*
|
||||
* @notice A method that uses the `onlyValidSignatureAndData` modifier must make
|
||||
* the _signature parameter the "last" parameter. You cannot sign a message that
|
||||
* has its own signature in it so the last 128 bytes of msg.data (which
|
||||
* represents the length of the _signature data and the _signaature data itself)
|
||||
* is ignored when validating. Also non fixed sized parameters make constructing
|
||||
* the data in the signature much more complex.
|
||||
* See https://ethereum.stackexchange.com/a/50616 for more details.
|
||||
* @notice A method that uses the `onlyValidSignatureAndData` modifier must make the _signature
|
||||
* parameter the "last" parameter. You cannot sign a message that has its own
|
||||
* signature in it so the last 128 bytes of msg.data (which represents the
|
||||
* length of the _signature data and the _signaature data itself) is ignored when validating.
|
||||
* Also non fixed sized parameters make constructing the data in the signature
|
||||
* much more complex. See https://ethereum.stackexchange.com/a/50616 for more details.
|
||||
*/
|
||||
contract SignatureBouncer is SignerRole {
|
||||
contract SignatureBouncer is Initializable, SignerRole {
|
||||
using ECDSA for bytes32;
|
||||
|
||||
// Function selectors are 4 bytes long, as documented in
|
||||
@ -43,12 +38,11 @@ contract SignatureBouncer is SignerRole {
|
||||
// Signature size is 65 bytes (tightly packed v + r + s), but gets padded to 96 bytes
|
||||
uint256 private constant _SIGNATURE_SIZE = 96;
|
||||
|
||||
constructor () internal {}
|
||||
|
||||
/**
|
||||
* @dev requires that a valid signature of a signer was provided
|
||||
*/
|
||||
modifier onlyValidSignature(bytes memory signature) {
|
||||
modifier onlyValidSignature(bytes signature)
|
||||
{
|
||||
require(_isValidSignature(msg.sender, signature));
|
||||
_;
|
||||
}
|
||||
@ -56,7 +50,8 @@ contract SignatureBouncer is SignerRole {
|
||||
/**
|
||||
* @dev requires that a valid signature with a specifed method of a signer was provided
|
||||
*/
|
||||
modifier onlyValidSignatureAndMethod(bytes memory signature) {
|
||||
modifier onlyValidSignatureAndMethod(bytes signature)
|
||||
{
|
||||
require(_isValidSignatureAndMethod(msg.sender, signature));
|
||||
_;
|
||||
}
|
||||
@ -64,29 +59,48 @@ contract SignatureBouncer is SignerRole {
|
||||
/**
|
||||
* @dev requires that a valid signature with a specifed method and params of a signer was provided
|
||||
*/
|
||||
modifier onlyValidSignatureAndData(bytes memory signature) {
|
||||
modifier onlyValidSignatureAndData(bytes signature)
|
||||
{
|
||||
require(_isValidSignatureAndData(msg.sender, signature));
|
||||
_;
|
||||
}
|
||||
|
||||
function initialize(address sender) public initializer {
|
||||
SignerRole.initialize(sender);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev is the signature of `this + sender` from a signer?
|
||||
* @return bool
|
||||
*/
|
||||
function _isValidSignature(address account, bytes memory signature) internal view returns (bool) {
|
||||
return _isValidDataHash(keccak256(abi.encodePacked(address(this), account)), signature);
|
||||
function _isValidSignature(address account, bytes signature)
|
||||
internal
|
||||
view
|
||||
returns (bool)
|
||||
{
|
||||
return _isValidDataHash(
|
||||
keccak256(abi.encodePacked(address(this), account)),
|
||||
signature
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev is the signature of `this + sender + methodId` from a signer?
|
||||
* @return bool
|
||||
*/
|
||||
function _isValidSignatureAndMethod(address account, bytes memory signature) internal view returns (bool) {
|
||||
function _isValidSignatureAndMethod(address account, bytes signature)
|
||||
internal
|
||||
view
|
||||
returns (bool)
|
||||
{
|
||||
bytes memory data = new bytes(_METHOD_ID_SIZE);
|
||||
for (uint i = 0; i < data.length; i++) {
|
||||
data[i] = msg.data[i];
|
||||
}
|
||||
return _isValidDataHash(keccak256(abi.encodePacked(address(this), account, data)), signature);
|
||||
return _isValidDataHash(
|
||||
keccak256(abi.encodePacked(address(this), account, data)),
|
||||
signature
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -94,15 +108,20 @@ contract SignatureBouncer is SignerRole {
|
||||
* @notice the signature parameter of the method being validated must be the "last" parameter
|
||||
* @return bool
|
||||
*/
|
||||
function _isValidSignatureAndData(address account, bytes memory signature) internal view returns (bool) {
|
||||
function _isValidSignatureAndData(address account, bytes signature)
|
||||
internal
|
||||
view
|
||||
returns (bool)
|
||||
{
|
||||
require(msg.data.length > _SIGNATURE_SIZE);
|
||||
|
||||
bytes memory data = new bytes(msg.data.length - _SIGNATURE_SIZE);
|
||||
for (uint i = 0; i < data.length; i++) {
|
||||
data[i] = msg.data[i];
|
||||
}
|
||||
|
||||
return _isValidDataHash(keccak256(abi.encodePacked(address(this), account, data)), signature);
|
||||
return _isValidDataHash(
|
||||
keccak256(abi.encodePacked(address(this), account, data)),
|
||||
signature
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -110,9 +129,17 @@ contract SignatureBouncer is SignerRole {
|
||||
* and then recover the signature and check it against the signer role
|
||||
* @return bool
|
||||
*/
|
||||
function _isValidDataHash(bytes32 hash, bytes memory signature) internal view returns (bool) {
|
||||
address signer = hash.toEthSignedMessageHash().recover(signature);
|
||||
function _isValidDataHash(bytes32 hash, bytes signature)
|
||||
internal
|
||||
view
|
||||
returns (bool)
|
||||
{
|
||||
address signer = hash
|
||||
.toEthSignedMessageHash()
|
||||
.recover(signature);
|
||||
|
||||
return signer != address(0) && isSigner(signer);
|
||||
}
|
||||
|
||||
uint256[50] private ______gap;
|
||||
}
|
||||
|
||||
@ -1,23 +1,25 @@
|
||||
/* solium-disable security/no-block-members */
|
||||
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "zos-lib/contracts/Initializable.sol";
|
||||
import "../token/ERC20/SafeERC20.sol";
|
||||
import "../ownership/Ownable.sol";
|
||||
import "../math/SafeMath.sol";
|
||||
|
||||
|
||||
/**
|
||||
* @title TokenVesting
|
||||
* @dev A token holder contract that can release its token balance gradually like a
|
||||
* typical vesting scheme, with a cliff and vesting period. Optionally revocable by the
|
||||
* owner.
|
||||
*/
|
||||
contract TokenVesting is Ownable {
|
||||
contract TokenVesting is Initializable, Ownable {
|
||||
using SafeMath for uint256;
|
||||
using SafeERC20 for IERC20;
|
||||
|
||||
event TokensReleased(address token, uint256 amount);
|
||||
event TokenVestingRevoked(address token);
|
||||
event Released(uint256 amount);
|
||||
event Revoked();
|
||||
|
||||
// beneficiary of tokens after they are released
|
||||
address private _beneficiary;
|
||||
@ -41,11 +43,21 @@ contract TokenVesting is Ownable {
|
||||
* @param duration duration in seconds of the period in which the tokens will vest
|
||||
* @param revocable whether the vesting is revocable or not
|
||||
*/
|
||||
constructor (address beneficiary, uint256 start, uint256 cliffDuration, uint256 duration, bool revocable) public {
|
||||
function initialize(
|
||||
address beneficiary,
|
||||
uint256 start,
|
||||
uint256 cliffDuration,
|
||||
uint256 duration,
|
||||
bool revocable,
|
||||
address sender
|
||||
)
|
||||
public
|
||||
initializer
|
||||
{
|
||||
Ownable.initialize(sender);
|
||||
|
||||
require(beneficiary != address(0));
|
||||
require(cliffDuration <= duration);
|
||||
require(duration > 0);
|
||||
require(start.add(duration) > block.timestamp);
|
||||
|
||||
_beneficiary = beneficiary;
|
||||
_revocable = revocable;
|
||||
@ -57,49 +69,49 @@ contract TokenVesting is Ownable {
|
||||
/**
|
||||
* @return the beneficiary of the tokens.
|
||||
*/
|
||||
function beneficiary() public view returns (address) {
|
||||
function beneficiary() public view returns(address) {
|
||||
return _beneficiary;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the cliff time of the token vesting.
|
||||
*/
|
||||
function cliff() public view returns (uint256) {
|
||||
function cliff() public view returns(uint256) {
|
||||
return _cliff;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the start time of the token vesting.
|
||||
*/
|
||||
function start() public view returns (uint256) {
|
||||
function start() public view returns(uint256) {
|
||||
return _start;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the duration of the token vesting.
|
||||
*/
|
||||
function duration() public view returns (uint256) {
|
||||
function duration() public view returns(uint256) {
|
||||
return _duration;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the vesting is revocable.
|
||||
*/
|
||||
function revocable() public view returns (bool) {
|
||||
function revocable() public view returns(bool) {
|
||||
return _revocable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the amount of the token released.
|
||||
*/
|
||||
function released(address token) public view returns (uint256) {
|
||||
function released(address token) public view returns(uint256) {
|
||||
return _released[token];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the token is revoked.
|
||||
*/
|
||||
function revoked(address token) public view returns (bool) {
|
||||
function revoked(address token) public view returns(bool) {
|
||||
return _revoked[token];
|
||||
}
|
||||
|
||||
@ -108,15 +120,15 @@ contract TokenVesting is Ownable {
|
||||
* @param token ERC20 token which is being vested
|
||||
*/
|
||||
function release(IERC20 token) public {
|
||||
uint256 unreleased = _releasableAmount(token);
|
||||
uint256 unreleased = releasableAmount(token);
|
||||
|
||||
require(unreleased > 0);
|
||||
|
||||
_released[address(token)] = _released[address(token)].add(unreleased);
|
||||
_released[token] = _released[token].add(unreleased);
|
||||
|
||||
token.safeTransfer(_beneficiary, unreleased);
|
||||
|
||||
emit TokensReleased(address(token), unreleased);
|
||||
emit Released(unreleased);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -126,42 +138,44 @@ contract TokenVesting is Ownable {
|
||||
*/
|
||||
function revoke(IERC20 token) public onlyOwner {
|
||||
require(_revocable);
|
||||
require(!_revoked[address(token)]);
|
||||
require(!_revoked[token]);
|
||||
|
||||
uint256 balance = token.balanceOf(address(this));
|
||||
|
||||
uint256 unreleased = _releasableAmount(token);
|
||||
uint256 unreleased = releasableAmount(token);
|
||||
uint256 refund = balance.sub(unreleased);
|
||||
|
||||
_revoked[address(token)] = true;
|
||||
_revoked[token] = true;
|
||||
|
||||
token.safeTransfer(owner(), refund);
|
||||
|
||||
emit TokenVestingRevoked(address(token));
|
||||
emit Revoked();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Calculates the amount that has already vested but hasn't been released yet.
|
||||
* @param token ERC20 token which is being vested
|
||||
*/
|
||||
function _releasableAmount(IERC20 token) private view returns (uint256) {
|
||||
return _vestedAmount(token).sub(_released[address(token)]);
|
||||
function releasableAmount(IERC20 token) public view returns (uint256) {
|
||||
return vestedAmount(token).sub(_released[token]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Calculates the amount that has already vested.
|
||||
* @param token ERC20 token which is being vested
|
||||
*/
|
||||
function _vestedAmount(IERC20 token) private view returns (uint256) {
|
||||
uint256 currentBalance = token.balanceOf(address(this));
|
||||
uint256 totalBalance = currentBalance.add(_released[address(token)]);
|
||||
function vestedAmount(IERC20 token) public view returns (uint256) {
|
||||
uint256 currentBalance = token.balanceOf(this);
|
||||
uint256 totalBalance = currentBalance.add(_released[token]);
|
||||
|
||||
if (block.timestamp < _cliff) {
|
||||
return 0;
|
||||
} else if (block.timestamp >= _start.add(_duration) || _revoked[address(token)]) {
|
||||
} else if (block.timestamp >= _start.add(_duration) || _revoked[token]) {
|
||||
return totalBalance;
|
||||
} else {
|
||||
return totalBalance.mul(block.timestamp.sub(_start)).div(_duration);
|
||||
}
|
||||
}
|
||||
|
||||
uint256[50] private ______gap;
|
||||
}
|
||||
|
||||
@ -1,20 +1,35 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "zos-lib/contracts/Initializable.sol";
|
||||
import "../crowdsale/validation/CappedCrowdsale.sol";
|
||||
import "../crowdsale/distribution/RefundableCrowdsale.sol";
|
||||
import "../crowdsale/emission/MintedCrowdsale.sol";
|
||||
import "../token/ERC20/ERC20Mintable.sol";
|
||||
import "../token/ERC20/ERC20Detailed.sol";
|
||||
|
||||
|
||||
/**
|
||||
* @title SampleCrowdsaleToken
|
||||
* @dev Very simple ERC20 Token that can be minted.
|
||||
* It is meant to be used in a crowdsale contract.
|
||||
*/
|
||||
contract SampleCrowdsaleToken is ERC20Mintable, ERC20Detailed {
|
||||
constructor () public ERC20Detailed("Sample Crowdsale Token", "SCT", 18) {}
|
||||
contract SampleCrowdsaleToken is Initializable, ERC20Mintable {
|
||||
|
||||
string public name;
|
||||
string public symbol;
|
||||
uint8 public decimals;
|
||||
|
||||
function initialize(address sender) public initializer {
|
||||
ERC20Mintable.initialize(sender);
|
||||
|
||||
name = "Sample Crowdsale Token";
|
||||
symbol = "SCT";
|
||||
decimals = 18;
|
||||
}
|
||||
|
||||
uint256[50] private ______gap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @title SampleCrowdsale
|
||||
* @dev This is an example of a fully fledged crowdsale.
|
||||
@ -22,8 +37,6 @@ contract SampleCrowdsaleToken is ERC20Mintable, ERC20Detailed {
|
||||
* In this example we are providing following extensions:
|
||||
* CappedCrowdsale - sets a max boundary for raised funds
|
||||
* RefundableCrowdsale - set a min goal to be reached and returns funds if it's not met
|
||||
* MintedCrowdsale - assumes the token can be minted by the crowdsale, which does so
|
||||
* when receiving purchases.
|
||||
*
|
||||
* After adding multiple features it's good practice to run integration tests
|
||||
* to ensure that subcontracts works together as intended.
|
||||
@ -33,24 +46,29 @@ contract SampleCrowdsaleToken is ERC20Mintable, ERC20Detailed {
|
||||
// https://github.com/duaraghav8/Solium/issues/205
|
||||
// --elopio - 2018-05-10
|
||||
// solium-disable-next-line max-len
|
||||
contract SampleCrowdsale is CappedCrowdsale, RefundableCrowdsale, MintedCrowdsale {
|
||||
constructor (
|
||||
contract SampleCrowdsale is Initializable, Crowdsale, CappedCrowdsale, RefundableCrowdsale, MintedCrowdsale {
|
||||
|
||||
function initialize(
|
||||
uint256 openingTime,
|
||||
uint256 closingTime,
|
||||
uint256 rate,
|
||||
address payable wallet,
|
||||
address wallet,
|
||||
uint256 cap,
|
||||
ERC20Mintable token,
|
||||
uint256 goal
|
||||
)
|
||||
public
|
||||
Crowdsale(rate, wallet, token)
|
||||
CappedCrowdsale(cap)
|
||||
TimedCrowdsale(openingTime, closingTime)
|
||||
RefundableCrowdsale(goal)
|
||||
initializer
|
||||
{
|
||||
Crowdsale.initialize(rate, wallet, token);
|
||||
CappedCrowdsale.initialize(cap);
|
||||
TimedCrowdsale.initialize(openingTime, closingTime);
|
||||
RefundableCrowdsale.initialize(goal);
|
||||
|
||||
//As goal needs to be met for a successful crowdsale
|
||||
//the value needs to less or equal than a cap which is limit for accepted funds
|
||||
require(goal <= cap);
|
||||
}
|
||||
|
||||
uint256[50] private ______gap;
|
||||
}
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
|
||||
import "zos-lib/contracts/Initializable.sol";
|
||||
import "../token/ERC20/ERC20.sol";
|
||||
import "../token/ERC20/ERC20Detailed.sol";
|
||||
|
||||
|
||||
/**
|
||||
* @title SimpleToken
|
||||
@ -9,14 +11,21 @@ import "../token/ERC20/ERC20Detailed.sol";
|
||||
* Note they can later distribute these tokens as they wish using `transfer` and other
|
||||
* `ERC20` functions.
|
||||
*/
|
||||
contract SimpleToken is ERC20, ERC20Detailed {
|
||||
uint8 public constant DECIMALS = 18;
|
||||
uint256 public constant INITIAL_SUPPLY = 10000 * (10 ** uint256(DECIMALS));
|
||||
contract SimpleToken is Initializable, ERC20 {
|
||||
|
||||
string public constant name = "SimpleToken";
|
||||
string public constant symbol = "SIM";
|
||||
uint8 public constant decimals = 18;
|
||||
|
||||
uint256 public constant INITIAL_SUPPLY = 10000 * (10 ** uint256(decimals));
|
||||
|
||||
/**
|
||||
* @dev Constructor that gives msg.sender all of existing tokens.
|
||||
* @dev Constructor that gives sender all of existing tokens.
|
||||
*/
|
||||
constructor () public ERC20Detailed("SimpleToken", "SIM", DECIMALS) {
|
||||
_mint(msg.sender, INITIAL_SUPPLY);
|
||||
function initialize(address sender) public initializer {
|
||||
_mint(sender, INITIAL_SUPPLY);
|
||||
}
|
||||
|
||||
|
||||
uint256[50] private ______gap;
|
||||
}
|
||||
|
||||
42
contracts/examples/StandardToken.sol
Normal file
42
contracts/examples/StandardToken.sol
Normal file
@ -0,0 +1,42 @@
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "zos-lib/contracts/Initializable.sol";
|
||||
import "../token/ERC20/ERC20Detailed.sol";
|
||||
import "../token/ERC20/ERC20Mintable.sol";
|
||||
import "../token/ERC20/ERC20Pausable.sol";
|
||||
|
||||
|
||||
/**
|
||||
* @title Standard ERC20 token, with minting and pause functionality.
|
||||
*
|
||||
*/
|
||||
contract StandardToken is Initializable, ERC20Detailed, ERC20Mintable, ERC20Pausable {
|
||||
function initialize(
|
||||
string name, string symbol, uint8 decimals, uint256 initialSupply, address initialHolder,
|
||||
address[] minters, address[] pausers
|
||||
) public initializer {
|
||||
ERC20Detailed.initialize(name, symbol, decimals);
|
||||
|
||||
// Mint the initial supply
|
||||
if (initialSupply > 0) { // To allow passing a null address when not doing any initial supply
|
||||
_mint(initialHolder, initialSupply);
|
||||
}
|
||||
|
||||
// Initialize the minter and pauser roles, and renounce them
|
||||
ERC20Mintable.initialize(address(this));
|
||||
renounceMinter();
|
||||
|
||||
ERC20Pausable.initialize(address(this));
|
||||
renouncePauser();
|
||||
|
||||
// Add the requested minters and pausers (this can be done after renouncing since
|
||||
// these are the internal calls)
|
||||
for (uint256 i = 0; i < minters.length; ++i) {
|
||||
_addMinter(minters[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < pausers.length; ++i) {
|
||||
_addPauser(pausers[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,13 +1,16 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "zos-lib/contracts/Initializable.sol";
|
||||
import "./IERC165.sol";
|
||||
|
||||
|
||||
/**
|
||||
* @title ERC165
|
||||
* @author Matt Condon (@shrugs)
|
||||
* @dev Implements ERC165 using a lookup table.
|
||||
*/
|
||||
contract ERC165 is IERC165 {
|
||||
contract ERC165 is Initializable, IERC165 {
|
||||
|
||||
bytes4 private constant _InterfaceId_ERC165 = 0x01ffc9a7;
|
||||
/**
|
||||
* 0x01ffc9a7 ===
|
||||
@ -17,28 +20,39 @@ contract ERC165 is IERC165 {
|
||||
/**
|
||||
* @dev a mapping of interface id to whether or not it's supported
|
||||
*/
|
||||
mapping(bytes4 => bool) private _supportedInterfaces;
|
||||
mapping(bytes4 => bool) internal _supportedInterfaces;
|
||||
|
||||
/**
|
||||
* @dev A contract implementing SupportsInterfaceWithLookup
|
||||
* implement ERC165 itself
|
||||
*/
|
||||
constructor () internal {
|
||||
function initialize()
|
||||
public
|
||||
initializer
|
||||
{
|
||||
_registerInterface(_InterfaceId_ERC165);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev implement supportsInterface(bytes4) using a lookup table
|
||||
*/
|
||||
function supportsInterface(bytes4 interfaceId) external view returns (bool) {
|
||||
function supportsInterface(bytes4 interfaceId)
|
||||
public
|
||||
view
|
||||
returns (bool)
|
||||
{
|
||||
return _supportedInterfaces[interfaceId];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev internal 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);
|
||||
_supportedInterfaces[interfaceId] = true;
|
||||
}
|
||||
|
||||
uint256[50] private ______gap;
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
|
||||
/**
|
||||
* @title ERC165Checker
|
||||
@ -15,16 +16,21 @@ library ERC165Checker {
|
||||
* bytes4(keccak256('supportsInterface(bytes4)'))
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @notice Query if a contract supports ERC165
|
||||
* @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
|
||||
// InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid
|
||||
return _supportsERC165Interface(account, _InterfaceId_ERC165) &&
|
||||
!_supportsERC165Interface(account, _InterfaceId_Invalid);
|
||||
return supportsERC165Interface(account, _InterfaceId_ERC165) &&
|
||||
!supportsERC165Interface(account, _InterfaceId_Invalid);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -35,10 +41,14 @@ library ERC165Checker {
|
||||
* 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
|
||||
return _supportsERC165(account) &&
|
||||
_supportsERC165Interface(account, interfaceId);
|
||||
return supportsERC165(account) &&
|
||||
supportsERC165Interface(account, interfaceId);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -49,15 +59,19 @@ library ERC165Checker {
|
||||
* interfaceIds list, false otherwise
|
||||
* @dev Interface identification is specified in ERC-165.
|
||||
*/
|
||||
function _supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) {
|
||||
function supportsInterfaces(address account, bytes4[] interfaceIds)
|
||||
internal
|
||||
view
|
||||
returns (bool)
|
||||
{
|
||||
// query support of ERC165 itself
|
||||
if (!_supportsERC165(account)) {
|
||||
if (!supportsERC165(account)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// query support of each interface in _interfaceIds
|
||||
for (uint256 i = 0; i < interfaceIds.length; i++) {
|
||||
if (!_supportsERC165Interface(account, interfaceIds[i])) {
|
||||
if (!supportsERC165Interface(account, interfaceIds[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -77,10 +91,15 @@ library ERC165Checker {
|
||||
* with the `supportsERC165` method in this library.
|
||||
* Interface identification is specified in ERC-165.
|
||||
*/
|
||||
function _supportsERC165Interface(address account, bytes4 interfaceId) private view returns (bool) {
|
||||
function supportsERC165Interface(address account, bytes4 interfaceId)
|
||||
private
|
||||
view
|
||||
returns (bool)
|
||||
{
|
||||
// success determines whether the staticcall succeeded and result determines
|
||||
// whether the contract at account indicates support of _interfaceId
|
||||
(bool success, bool result) = _callERC165SupportsInterface(account, interfaceId);
|
||||
(bool success, bool result) = callERC165SupportsInterface(
|
||||
account, interfaceId);
|
||||
|
||||
return (success && result);
|
||||
}
|
||||
@ -93,12 +112,18 @@ library ERC165Checker {
|
||||
* @return result true if the STATICCALL succeeded and the contract at account
|
||||
* indicates support of the interface with identifier interfaceId, false otherwise
|
||||
*/
|
||||
function _callERC165SupportsInterface(address account, bytes4 interfaceId)
|
||||
function callERC165SupportsInterface(
|
||||
address account,
|
||||
bytes4 interfaceId
|
||||
)
|
||||
private
|
||||
view
|
||||
returns (bool success, bool result)
|
||||
{
|
||||
bytes memory encodedParams = abi.encodeWithSelector(_InterfaceId_ERC165,interfaceId);
|
||||
bytes memory encodedParams = abi.encodeWithSelector(
|
||||
_InterfaceId_ERC165,
|
||||
interfaceId
|
||||
);
|
||||
|
||||
// solium-disable-next-line security/no-inline-assembly
|
||||
assembly {
|
||||
|
||||
@ -1,15 +1,20 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
|
||||
/**
|
||||
* @title IERC165
|
||||
* @dev https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md
|
||||
*/
|
||||
interface IERC165 {
|
||||
|
||||
/**
|
||||
* @notice Query if a contract implements an interface
|
||||
* @param interfaceId The interface identifier, as specified in ERC-165
|
||||
* @dev Interface identification is specified in ERC-165. This function
|
||||
* uses less than 30,000 gas.
|
||||
*/
|
||||
function supportsInterface(bytes4 interfaceId) external view returns (bool);
|
||||
function supportsInterface(bytes4 interfaceId)
|
||||
external
|
||||
view
|
||||
returns (bool);
|
||||
}
|
||||
|
||||
@ -1,25 +1,27 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "zos-lib/contracts/Initializable.sol";
|
||||
import "../access/roles/PauserRole.sol";
|
||||
|
||||
|
||||
/**
|
||||
* @title Pausable
|
||||
* @dev Base contract which allows children to implement an emergency stop mechanism.
|
||||
*/
|
||||
contract Pausable is PauserRole {
|
||||
event Paused(address account);
|
||||
event Unpaused(address account);
|
||||
contract Pausable is Initializable, PauserRole {
|
||||
event Paused();
|
||||
event Unpaused();
|
||||
|
||||
bool private _paused;
|
||||
bool private _paused = false;
|
||||
|
||||
constructor () internal {
|
||||
_paused = false;
|
||||
function initialize(address sender) public initializer {
|
||||
PauserRole.initialize(sender);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the contract is paused, false otherwise.
|
||||
*/
|
||||
function paused() public view returns (bool) {
|
||||
function paused() public view returns(bool) {
|
||||
return _paused;
|
||||
}
|
||||
|
||||
@ -44,7 +46,7 @@ contract Pausable is PauserRole {
|
||||
*/
|
||||
function pause() public onlyPauser whenNotPaused {
|
||||
_paused = true;
|
||||
emit Paused(msg.sender);
|
||||
emit Paused();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -52,6 +54,8 @@ contract Pausable is PauserRole {
|
||||
*/
|
||||
function unpause() public onlyPauser whenPaused {
|
||||
_paused = false;
|
||||
emit Unpaused(msg.sender);
|
||||
emit Unpaused();
|
||||
}
|
||||
|
||||
uint256[50] private ______gap;
|
||||
}
|
||||
|
||||
@ -1,29 +1,19 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
|
||||
/**
|
||||
* @title Math
|
||||
* @dev Assorted math operations
|
||||
*/
|
||||
library Math {
|
||||
/**
|
||||
* @dev Returns the largest of two numbers.
|
||||
*/
|
||||
function max(uint256 a, uint256 b) internal pure returns (uint256) {
|
||||
return a >= b ? a : b;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Returns the smallest of two numbers.
|
||||
*/
|
||||
function min(uint256 a, uint256 b) internal pure returns (uint256) {
|
||||
return a < b ? a : b;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Calculates the average of two numbers. Since these are integers,
|
||||
* averages of an even and odd number cannot be represented, and will be
|
||||
* rounded down.
|
||||
*/
|
||||
function average(uint256 a, uint256 b) internal pure returns (uint256) {
|
||||
// (a + b) / 2 can overflow, so we distribute
|
||||
return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2);
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
|
||||
/**
|
||||
* @title SafeMath
|
||||
* @dev Math operations with safety checks that revert on error
|
||||
*/
|
||||
library SafeMath {
|
||||
int256 constant private INT256_MIN = -2**255;
|
||||
|
||||
/**
|
||||
* @dev Multiplies two unsigned integers, reverts on overflow.
|
||||
* @dev Multiplies two numbers, reverts on overflow.
|
||||
*/
|
||||
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
|
||||
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
|
||||
@ -25,30 +25,10 @@ library SafeMath {
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Multiplies two signed integers, reverts on overflow.
|
||||
*/
|
||||
function mul(int256 a, int256 b) internal pure returns (int256) {
|
||||
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
|
||||
// benefit is lost if 'b' is also tested.
|
||||
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
|
||||
if (a == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
require(!(a == -1 && b == INT256_MIN)); // This is the only case of overflow not detected by the check below
|
||||
|
||||
int256 c = a * b;
|
||||
require(c / a == b);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Integer division of two unsigned integers truncating the quotient, reverts on division by zero.
|
||||
* @dev Integer division of two numbers truncating the quotient, reverts on division by zero.
|
||||
*/
|
||||
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
||||
// Solidity only automatically asserts when dividing by 0
|
||||
require(b > 0);
|
||||
require(b > 0); // Solidity only automatically asserts when dividing by 0
|
||||
uint256 c = a / b;
|
||||
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
|
||||
|
||||
@ -56,19 +36,7 @@ library SafeMath {
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Integer division of two signed integers truncating the quotient, reverts on division by zero.
|
||||
*/
|
||||
function div(int256 a, int256 b) internal pure returns (int256) {
|
||||
require(b != 0); // Solidity only automatically asserts when dividing by 0
|
||||
require(!(b == -1 && a == INT256_MIN)); // This is the only case of overflow
|
||||
|
||||
int256 c = a / b;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Subtracts two unsigned integers, reverts on overflow (i.e. if subtrahend is greater than minuend).
|
||||
* @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend).
|
||||
*/
|
||||
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
|
||||
require(b <= a);
|
||||
@ -78,17 +46,7 @@ library SafeMath {
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Subtracts two signed integers, reverts on overflow.
|
||||
*/
|
||||
function sub(int256 a, int256 b) internal pure returns (int256) {
|
||||
int256 c = a - b;
|
||||
require((b >= 0 && c <= a) || (b < 0 && c > a));
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Adds two unsigned integers, reverts on overflow.
|
||||
* @dev Adds two numbers, reverts on overflow.
|
||||
*/
|
||||
function add(uint256 a, uint256 b) internal pure returns (uint256) {
|
||||
uint256 c = a + b;
|
||||
@ -98,17 +56,7 @@ library SafeMath {
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Adds two signed integers, reverts on overflow.
|
||||
*/
|
||||
function add(int256 a, int256 b) internal pure returns (int256) {
|
||||
int256 c = a + b;
|
||||
require((b >= 0 && c >= a) || (b < 0 && c < a));
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Divides two unsigned integers and returns the remainder (unsigned integer modulo),
|
||||
* @dev Divides two numbers and returns the remainder (unsigned integer modulo),
|
||||
* reverts when dividing by zero.
|
||||
*/
|
||||
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
|
||||
|
||||
@ -1,19 +0,0 @@
|
||||
pragma solidity ^0.5.0;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
pragma solidity ^0.5.0;
|
||||
|
||||
import "../utils/Address.sol";
|
||||
|
||||
contract AddressImpl {
|
||||
function isContract(address account) external view returns (bool) {
|
||||
return Address.isContract(account);
|
||||
}
|
||||
}
|
||||
@ -1,12 +1,21 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "../token/ERC20/IERC20.sol";
|
||||
import "../crowdsale/emission/AllowanceCrowdsale.sol";
|
||||
|
||||
|
||||
contract AllowanceCrowdsaleImpl is AllowanceCrowdsale {
|
||||
constructor (uint256 rate, address payable wallet, IERC20 token, address tokenWallet)
|
||||
|
||||
constructor (
|
||||
uint256 rate,
|
||||
address wallet,
|
||||
IERC20 token,
|
||||
address tokenWallet
|
||||
)
|
||||
public
|
||||
Crowdsale(rate, wallet, token)
|
||||
AllowanceCrowdsale(tokenWallet)
|
||||
{}
|
||||
{
|
||||
Crowdsale.initialize(rate, wallet, token);
|
||||
AllowanceCrowdsale.initialize(tokenWallet);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
pragma solidity ^0.5.0;
|
||||
|
||||
import "../utils/Arrays.sol";
|
||||
|
||||
contract ArraysImpl {
|
||||
using Arrays for uint256[];
|
||||
|
||||
uint256[] private array;
|
||||
|
||||
constructor (uint256[] memory _array) public {
|
||||
array = _array;
|
||||
}
|
||||
|
||||
function findUpperBound(uint256 _element) external view returns (uint256) {
|
||||
return array.findUpperBound(_element);
|
||||
}
|
||||
}
|
||||
@ -1,12 +1,21 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "../token/ERC20/IERC20.sol";
|
||||
import "../crowdsale/validation/CappedCrowdsale.sol";
|
||||
|
||||
|
||||
contract CappedCrowdsaleImpl is CappedCrowdsale {
|
||||
constructor (uint256 rate, address payable wallet, IERC20 token, uint256 cap)
|
||||
|
||||
constructor (
|
||||
uint256 rate,
|
||||
address wallet,
|
||||
IERC20 token,
|
||||
uint256 cap
|
||||
)
|
||||
public
|
||||
Crowdsale(rate, wallet, token)
|
||||
CappedCrowdsale(cap)
|
||||
{}
|
||||
{
|
||||
Crowdsale.initialize(rate, wallet, token);
|
||||
CappedCrowdsale.initialize(cap);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,8 +1,13 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "../access/roles/CapperRole.sol";
|
||||
|
||||
|
||||
contract CapperRoleMock is CapperRole {
|
||||
constructor() public {
|
||||
CapperRole.initialize(msg.sender);
|
||||
}
|
||||
|
||||
function removeCapper(address account) public {
|
||||
_removeCapper(account);
|
||||
}
|
||||
|
||||
@ -1,11 +1,16 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "../payment/ConditionalEscrow.sol";
|
||||
|
||||
import "../payment/escrow/ConditionalEscrow.sol";
|
||||
|
||||
// mock class using ConditionalEscrow
|
||||
contract ConditionalEscrowMock is ConditionalEscrow {
|
||||
mapping(address => bool) private _allowed;
|
||||
|
||||
constructor() public {
|
||||
ConditionalEscrow.initialize(msg.sender);
|
||||
}
|
||||
|
||||
function setAllowed(address payee, bool allowed) public {
|
||||
_allowed[payee] = allowed;
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "../drafts/Counter.sol";
|
||||
|
||||
|
||||
contract CounterImpl {
|
||||
using Counter for Counter.Counter;
|
||||
|
||||
@ -10,7 +11,10 @@ contract CounterImpl {
|
||||
// use whatever key you want to track your counters
|
||||
mapping(string => Counter.Counter) private _counters;
|
||||
|
||||
function doThing(string memory key) public returns (uint256) {
|
||||
function doThing(string key)
|
||||
public
|
||||
returns (uint256)
|
||||
{
|
||||
theId = _counters[key].next();
|
||||
return theId;
|
||||
}
|
||||
|
||||
@ -1,7 +1,10 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "../crowdsale/Crowdsale.sol";
|
||||
|
||||
|
||||
contract CrowdsaleMock is Crowdsale {
|
||||
constructor (uint256 rate, address payable wallet, IERC20 token) public Crowdsale(rate, wallet, token) {}
|
||||
constructor(uint256 rate, address wallet, IERC20 token) public {
|
||||
Crowdsale.initialize(rate, wallet, token);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,17 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "../token/ERC20/ERC20.sol";
|
||||
import "../token/ERC20/ERC20Detailed.sol";
|
||||
|
||||
|
||||
contract ERC20DetailedMock is ERC20, ERC20Detailed {
|
||||
constructor (string memory name, string memory symbol, uint8 decimals) ERC20Detailed(name, symbol, decimals) public {}
|
||||
constructor(
|
||||
string name,
|
||||
string symbol,
|
||||
uint8 decimals
|
||||
)
|
||||
public
|
||||
{
|
||||
ERC20Detailed.initialize(name, symbol, decimals);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,15 +1,24 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "../cryptography/ECDSA.sol";
|
||||
|
||||
|
||||
contract ECDSAMock {
|
||||
using ECDSA for bytes32;
|
||||
|
||||
function recover(bytes32 hash, bytes memory signature) public pure returns (address) {
|
||||
function recover(bytes32 hash, bytes signature)
|
||||
public
|
||||
pure
|
||||
returns (address)
|
||||
{
|
||||
return hash.recover(signature);
|
||||
}
|
||||
|
||||
function toEthSignedMessageHash(bytes32 hash) public pure returns (bytes32) {
|
||||
function toEthSignedMessageHash(bytes32 hash)
|
||||
public
|
||||
pure
|
||||
returns (bytes32)
|
||||
{
|
||||
return hash.toEthSignedMessageHash();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "../../introspection/IERC165.sol";
|
||||
|
||||
|
||||
/**
|
||||
* https://github.com/ethereum/EIPs/blob/master/EIPS/eip-214.md#specification
|
||||
* > Any attempts to make state-changing operations inside an execution instance with STATIC set to true will instead throw an exception.
|
||||
@ -11,6 +12,7 @@ import "../../introspection/IERC165.sol";
|
||||
* solidity-coverage ignores the /mocks folder, so we duplicate its implementation here to avoid instrumenting it
|
||||
*/
|
||||
contract SupportsInterfaceWithLookupMock is IERC165 {
|
||||
|
||||
bytes4 public constant InterfaceId_ERC165 = 0x01ffc9a7;
|
||||
/**
|
||||
* 0x01ffc9a7 ===
|
||||
@ -20,34 +22,46 @@ contract SupportsInterfaceWithLookupMock is IERC165 {
|
||||
/**
|
||||
* @dev a mapping of interface id to whether or not it's supported
|
||||
*/
|
||||
mapping(bytes4 => bool) private _supportedInterfaces;
|
||||
mapping(bytes4 => bool) internal supportedInterfaces;
|
||||
|
||||
/**
|
||||
* @dev A contract implementing SupportsInterfaceWithLookup
|
||||
* implement ERC165 itself
|
||||
*/
|
||||
constructor () public {
|
||||
constructor()
|
||||
public
|
||||
{
|
||||
_registerInterface(InterfaceId_ERC165);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev implement supportsInterface(bytes4) using a lookup table
|
||||
*/
|
||||
function supportsInterface(bytes4 interfaceId) external view returns (bool) {
|
||||
return _supportedInterfaces[interfaceId];
|
||||
function supportsInterface(bytes4 interfaceId)
|
||||
external
|
||||
view
|
||||
returns (bool)
|
||||
{
|
||||
return supportedInterfaces[interfaceId];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev private method for registering an interface
|
||||
*/
|
||||
function _registerInterface(bytes4 interfaceId) internal {
|
||||
function _registerInterface(bytes4 interfaceId)
|
||||
internal
|
||||
{
|
||||
require(interfaceId != 0xffffffff);
|
||||
_supportedInterfaces[interfaceId] = true;
|
||||
supportedInterfaces[interfaceId] = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
contract ERC165InterfacesSupported is SupportsInterfaceWithLookupMock {
|
||||
constructor (bytes4[] memory interfaceIds) public {
|
||||
constructor (bytes4[] interfaceIds)
|
||||
public
|
||||
{
|
||||
for (uint256 i = 0; i < interfaceIds.length; i++) {
|
||||
_registerInterface(interfaceIds[i]);
|
||||
}
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
contract ERC165NotSupported {}
|
||||
|
||||
contract ERC165NotSupported {
|
||||
|
||||
}
|
||||
|
||||
@ -1,19 +1,32 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "../introspection/ERC165Checker.sol";
|
||||
|
||||
|
||||
contract ERC165CheckerMock {
|
||||
using ERC165Checker for address;
|
||||
|
||||
function supportsERC165(address account) public view returns (bool) {
|
||||
return account._supportsERC165();
|
||||
function supportsERC165(address account)
|
||||
public
|
||||
view
|
||||
returns (bool)
|
||||
{
|
||||
return account.supportsERC165();
|
||||
}
|
||||
|
||||
function supportsInterface(address account, bytes4 interfaceId) public view returns (bool) {
|
||||
return account._supportsInterface(interfaceId);
|
||||
function supportsInterface(address account, bytes4 interfaceId)
|
||||
public
|
||||
view
|
||||
returns (bool)
|
||||
{
|
||||
return account.supportsInterface(interfaceId);
|
||||
}
|
||||
|
||||
function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) public view returns (bool) {
|
||||
return account._supportsAllInterfaces(interfaceIds);
|
||||
function supportsInterfaces(address account, bytes4[] interfaceIds)
|
||||
public
|
||||
view
|
||||
returns (bool)
|
||||
{
|
||||
return account.supportsInterfaces(interfaceIds);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,9 +1,16 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "../introspection/ERC165.sol";
|
||||
|
||||
|
||||
contract ERC165Mock is ERC165 {
|
||||
function registerInterface(bytes4 interfaceId) public {
|
||||
constructor() public {
|
||||
ERC165.initialize();
|
||||
}
|
||||
|
||||
function registerInterface(bytes4 interfaceId)
|
||||
public
|
||||
{
|
||||
_registerInterface(interfaceId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "../token/ERC20/ERC20Burnable.sol";
|
||||
|
||||
|
||||
contract ERC20BurnableMock is ERC20Burnable {
|
||||
constructor (address initialAccount, uint256 initialBalance) public {
|
||||
|
||||
constructor(address initialAccount, uint256 initialBalance) public {
|
||||
_mint(initialAccount, initialBalance);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
13
contracts/mocks/ERC20CappedMock.sol
Normal file
13
contracts/mocks/ERC20CappedMock.sol
Normal file
@ -0,0 +1,13 @@
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "../token/ERC20/ERC20Capped.sol";
|
||||
import "./MinterRoleMock.sol";
|
||||
|
||||
|
||||
contract ERC20CappedMock is ERC20Capped, MinterRoleMock {
|
||||
|
||||
constructor(uint256 cap) public {
|
||||
ERC20Capped.initialize(cap, msg.sender);
|
||||
}
|
||||
|
||||
}
|
||||
12
contracts/mocks/ERC20MigratorMock.sol
Normal file
12
contracts/mocks/ERC20MigratorMock.sol
Normal file
@ -0,0 +1,12 @@
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "../drafts/ERC20Migrator.sol";
|
||||
|
||||
|
||||
contract ERC20MigratorMock is ERC20Migrator {
|
||||
|
||||
constructor(IERC20 legacyToken) public {
|
||||
ERC20Migrator.initialize(legacyToken);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,7 +1,12 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "../token/ERC20/ERC20Mintable.sol";
|
||||
import "./MinterRoleMock.sol";
|
||||
|
||||
|
||||
contract ERC20MintableMock is ERC20Mintable, MinterRoleMock {
|
||||
|
||||
constructor() public {
|
||||
ERC20Mintable.initialize(msg.sender);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "../token/ERC20/ERC20.sol";
|
||||
|
||||
|
||||
// mock class using ERC20
|
||||
contract ERC20Mock is ERC20 {
|
||||
constructor (address initialAccount, uint256 initialBalance) public {
|
||||
|
||||
constructor(address initialAccount, uint256 initialBalance) public {
|
||||
_mint(initialAccount, initialBalance);
|
||||
}
|
||||
|
||||
@ -19,4 +21,5 @@ contract ERC20Mock is ERC20 {
|
||||
function burnFrom(address account, uint256 amount) public {
|
||||
_burnFrom(account, amount);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,11 +1,16 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "../token/ERC20/ERC20Pausable.sol";
|
||||
import "./PauserRoleMock.sol";
|
||||
|
||||
|
||||
// mock class using ERC20Pausable
|
||||
contract ERC20PausableMock is ERC20Pausable, PauserRoleMock {
|
||||
constructor (address initialAccount, uint initialBalance) public {
|
||||
|
||||
constructor(address initialAccount, uint initialBalance) public {
|
||||
ERC20Pausable.initialize(msg.sender);
|
||||
|
||||
_mint(initialAccount, initialBalance);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "../token/ERC20/ERC20.sol";
|
||||
import "../drafts/ERC1046/TokenMetadata.sol";
|
||||
|
||||
|
||||
contract ERC20WithMetadataMock is ERC20, ERC20WithMetadata {
|
||||
constructor (string memory tokenURI) public ERC20WithMetadata(tokenURI) {}
|
||||
constructor(string tokenURI) public {
|
||||
ERC20WithMetadata.initialize(tokenURI);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,27 +1,35 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "../token/ERC721/ERC721Full.sol";
|
||||
import "../token/ERC721/ERC721Mintable.sol";
|
||||
import "../token/ERC721/ERC721MetadataMintable.sol";
|
||||
import "../token/ERC721/ERC721Burnable.sol";
|
||||
|
||||
|
||||
/**
|
||||
* @title ERC721FullMock
|
||||
* This mock just provides public functions for setting metadata URI, getting all tokens of an owner,
|
||||
* checking token existence, removal of a token from an address
|
||||
* This mock just provides a public mint and burn functions for testing purposes,
|
||||
* and a public setter for metadata URI
|
||||
*/
|
||||
contract ERC721FullMock is ERC721Full, ERC721Mintable, ERC721MetadataMintable, ERC721Burnable {
|
||||
constructor (string memory name, string memory symbol) public ERC721Mintable() ERC721Full(name, symbol) {}
|
||||
constructor(string name, string symbol) public
|
||||
{
|
||||
ERC721.initialize();
|
||||
ERC721Metadata.initialize(name, symbol);
|
||||
ERC721Enumerable.initialize();
|
||||
ERC721Mintable.initialize(msg.sender);
|
||||
ERC721MetadataMintable.initialize(msg.sender);
|
||||
}
|
||||
|
||||
function exists(uint256 tokenId) public view returns (bool) {
|
||||
return _exists(tokenId);
|
||||
}
|
||||
|
||||
function tokensOfOwner(address owner) public view returns (uint256[] memory) {
|
||||
return _tokensOfOwner(owner);
|
||||
}
|
||||
|
||||
function setTokenURI(uint256 tokenId, string memory uri) public {
|
||||
function setTokenURI(uint256 tokenId, string uri) public {
|
||||
_setTokenURI(tokenId, uri);
|
||||
}
|
||||
|
||||
function removeTokenFrom(address from, uint256 tokenId) public {
|
||||
_removeTokenFrom(from, tokenId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,13 +1,24 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "../token/ERC721/ERC721Full.sol";
|
||||
import "../token/ERC721/ERC721Mintable.sol";
|
||||
import "../token/ERC721/ERC721MetadataMintable.sol";
|
||||
import "../token/ERC721/ERC721Burnable.sol";
|
||||
|
||||
|
||||
/**
|
||||
* @title ERC721MintableBurnableImpl
|
||||
*/
|
||||
contract ERC721MintableBurnableImpl is ERC721Full, ERC721Mintable, ERC721MetadataMintable, ERC721Burnable {
|
||||
constructor () ERC721Mintable() ERC721Full("Test", "TEST") public {}
|
||||
contract ERC721MintableBurnableImpl
|
||||
is ERC721Full, ERC721Mintable, ERC721MetadataMintable, ERC721Burnable {
|
||||
|
||||
constructor()
|
||||
public
|
||||
{
|
||||
ERC721.initialize();
|
||||
ERC721Metadata.initialize("Test", "TEST");
|
||||
ERC721Enumerable.initialize();
|
||||
ERC721Mintable.initialize(msg.sender);
|
||||
ERC721MetadataMintable.initialize(msg.sender);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,21 +1,22 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "../token/ERC721/ERC721.sol";
|
||||
|
||||
|
||||
/**
|
||||
* @title ERC721Mock
|
||||
* This mock just provides a public mint and burn functions for testing purposes
|
||||
*/
|
||||
contract ERC721Mock is ERC721 {
|
||||
constructor() public {
|
||||
ERC721.initialize();
|
||||
}
|
||||
|
||||
function mint(address to, uint256 tokenId) public {
|
||||
_mint(to, tokenId);
|
||||
}
|
||||
|
||||
function burn(address owner, uint256 tokenId) public {
|
||||
_burn(owner, tokenId);
|
||||
}
|
||||
|
||||
function burn(uint256 tokenId) public {
|
||||
_burn(tokenId);
|
||||
_burn(ownerOf(tokenId), tokenId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,19 +1,25 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "../token/ERC721/ERC721Pausable.sol";
|
||||
import "./PauserRoleMock.sol";
|
||||
|
||||
|
||||
/**
|
||||
* @title ERC721PausableMock
|
||||
* This mock just provides a public mint, burn and exists functions for testing purposes
|
||||
*/
|
||||
contract ERC721PausableMock is ERC721Pausable, PauserRoleMock {
|
||||
constructor() {
|
||||
ERC721.initialize();
|
||||
ERC721Pausable.initialize(msg.sender);
|
||||
}
|
||||
|
||||
function mint(address to, uint256 tokenId) public {
|
||||
super._mint(to, tokenId);
|
||||
}
|
||||
|
||||
function burn(uint256 tokenId) public {
|
||||
super._burn(tokenId);
|
||||
super._burn(ownerOf(tokenId), tokenId);
|
||||
}
|
||||
|
||||
function exists(uint256 tokenId) public view returns (bool) {
|
||||
|
||||
@ -1,21 +1,42 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "../token/ERC721/IERC721Receiver.sol";
|
||||
|
||||
|
||||
contract ERC721ReceiverMock is IERC721Receiver {
|
||||
bytes4 private _retval;
|
||||
bool private _reverts;
|
||||
|
||||
event Received(address operator, address from, uint256 tokenId, bytes data, uint256 gas);
|
||||
event Received(
|
||||
address operator,
|
||||
address from,
|
||||
uint256 tokenId,
|
||||
bytes data,
|
||||
uint256 gas
|
||||
);
|
||||
|
||||
constructor (bytes4 retval, bool reverts) public {
|
||||
constructor(bytes4 retval, bool reverts) public {
|
||||
_retval = retval;
|
||||
_reverts = reverts;
|
||||
}
|
||||
|
||||
function onERC721Received(address operator, address from, uint256 tokenId, bytes memory data) public returns (bytes4) {
|
||||
function onERC721Received(
|
||||
address operator,
|
||||
address from,
|
||||
uint256 tokenId,
|
||||
bytes data
|
||||
)
|
||||
public
|
||||
returns(bytes4)
|
||||
{
|
||||
require(!_reverts);
|
||||
emit Received(operator, from, tokenId, data, gasleft());
|
||||
emit Received(
|
||||
operator,
|
||||
from,
|
||||
tokenId,
|
||||
data,
|
||||
gasleft() // msg.gas was deprecated in solidityv0.4.21
|
||||
);
|
||||
return _retval;
|
||||
}
|
||||
}
|
||||
|
||||
9
contracts/mocks/EscrowMock.sol
Normal file
9
contracts/mocks/EscrowMock.sol
Normal file
@ -0,0 +1,9 @@
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "../payment/Escrow.sol";
|
||||
|
||||
contract EscrowMock is Escrow {
|
||||
constructor() public {
|
||||
Escrow.initialize(msg.sender);
|
||||
}
|
||||
}
|
||||
@ -1,73 +0,0 @@
|
||||
pragma solidity ^0.5.0;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -1,22 +0,0 @@
|
||||
pragma solidity ^0.5.0;
|
||||
|
||||
contract Failer {
|
||||
uint256[] private array;
|
||||
|
||||
function dontFail() public pure {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,13 +1,22 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "../token/ERC20/IERC20.sol";
|
||||
import "../crowdsale/distribution/FinalizableCrowdsale.sol";
|
||||
|
||||
|
||||
contract FinalizableCrowdsaleImpl is FinalizableCrowdsale {
|
||||
|
||||
constructor (uint256 openingTime, uint256 closingTime, uint256 rate, address payable wallet, IERC20 token)
|
||||
constructor (
|
||||
uint256 openingTime,
|
||||
uint256 closingTime,
|
||||
uint256 rate,
|
||||
address wallet,
|
||||
IERC20 token
|
||||
)
|
||||
public
|
||||
Crowdsale(rate, wallet, token)
|
||||
TimedCrowdsale(openingTime, closingTime)
|
||||
{}
|
||||
{
|
||||
Crowdsale.initialize(rate, wallet, token);
|
||||
TimedCrowdsale.initialize(openingTime, closingTime);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
16
contracts/mocks/ForceEther.sol
Normal file
16
contracts/mocks/ForceEther.sol
Normal file
@ -0,0 +1,16 @@
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
|
||||
// @title Force Ether into a contract.
|
||||
// @notice even
|
||||
// if the contract is not payable.
|
||||
// @notice To use, construct the contract with the target as argument.
|
||||
// @author Remco Bloemen <remco@neufund.org>
|
||||
contract ForceEther {
|
||||
|
||||
constructor() public payable { }
|
||||
|
||||
function destroyAndSend(address recipient) public {
|
||||
selfdestruct(recipient);
|
||||
}
|
||||
}
|
||||
@ -1,20 +1,24 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "../crowdsale/price/IncreasingPriceCrowdsale.sol";
|
||||
import "../math/SafeMath.sol";
|
||||
|
||||
|
||||
contract IncreasingPriceCrowdsaleImpl is IncreasingPriceCrowdsale {
|
||||
|
||||
constructor (
|
||||
uint256 openingTime,
|
||||
uint256 closingTime,
|
||||
address payable wallet,
|
||||
address wallet,
|
||||
IERC20 token,
|
||||
uint256 initialRate,
|
||||
uint256 finalRate
|
||||
)
|
||||
public
|
||||
Crowdsale(initialRate, wallet, token)
|
||||
TimedCrowdsale(openingTime, closingTime)
|
||||
IncreasingPriceCrowdsale(initialRate, finalRate)
|
||||
{}
|
||||
{
|
||||
Crowdsale.initialize(initialRate, wallet, token);
|
||||
TimedCrowdsale.initialize(openingTime, closingTime);
|
||||
IncreasingPriceCrowdsale.initialize(initialRate, finalRate);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,10 +1,21 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "../token/ERC20/IERC20.sol";
|
||||
import "../crowdsale/validation/IndividuallyCappedCrowdsale.sol";
|
||||
import "./CapperRoleMock.sol";
|
||||
|
||||
contract IndividuallyCappedCrowdsaleImpl is IndividuallyCappedCrowdsale, CapperRoleMock {
|
||||
constructor (uint256 rate, address payable wallet, IERC20 token) public Crowdsale(rate, wallet, token)
|
||||
{}
|
||||
|
||||
contract IndividuallyCappedCrowdsaleImpl
|
||||
is Crowdsale, IndividuallyCappedCrowdsale, CapperRoleMock {
|
||||
|
||||
constructor(
|
||||
uint256 rate,
|
||||
address wallet,
|
||||
IERC20 token
|
||||
)
|
||||
public
|
||||
{
|
||||
Crowdsale.initialize(rate, wallet, token);
|
||||
IndividuallyCappedCrowdsale.initialize(msg.sender);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
|
||||
import "../math/Math.sol";
|
||||
|
||||
|
||||
contract MathMock {
|
||||
function max(uint256 a, uint256 b) public pure returns (uint256) {
|
||||
return Math.max(a, b);
|
||||
|
||||
@ -1,9 +1,19 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import { MerkleProof } from "../cryptography/MerkleProof.sol";
|
||||
|
||||
|
||||
contract MerkleProofWrapper {
|
||||
function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) public pure returns (bool) {
|
||||
|
||||
function verify(
|
||||
bytes32[] proof,
|
||||
bytes32 root,
|
||||
bytes32 leaf
|
||||
)
|
||||
public
|
||||
pure
|
||||
returns (bool)
|
||||
{
|
||||
return MerkleProof.verify(proof, root, leaf);
|
||||
}
|
||||
}
|
||||
|
||||
50
contracts/mocks/MessageHelper.sol
Normal file
50
contracts/mocks/MessageHelper.sol
Normal file
@ -0,0 +1,50 @@
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
|
||||
contract MessageHelper {
|
||||
|
||||
event Show(bytes32 b32, uint256 number, string text);
|
||||
event Buy(bytes32 b32, uint256 number, string text, uint256 value);
|
||||
|
||||
function showMessage(
|
||||
bytes32 _message,
|
||||
uint256 _number,
|
||||
string _text
|
||||
)
|
||||
public
|
||||
returns (bool)
|
||||
{
|
||||
emit Show(_message, _number, _text);
|
||||
return true;
|
||||
}
|
||||
|
||||
function buyMessage(
|
||||
bytes32 _message,
|
||||
uint256 _number,
|
||||
string _text
|
||||
)
|
||||
public
|
||||
payable
|
||||
returns (bool)
|
||||
{
|
||||
emit Buy(
|
||||
_message,
|
||||
_number,
|
||||
_text,
|
||||
msg.value);
|
||||
return true;
|
||||
}
|
||||
|
||||
function fail() public {
|
||||
require(false);
|
||||
}
|
||||
|
||||
function call(address _to, bytes _data) public returns (bool) {
|
||||
// solium-disable-next-line security/no-low-level-calls
|
||||
if (_to.call(_data))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,8 +1,19 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "../token/ERC20/ERC20Mintable.sol";
|
||||
import "../crowdsale/emission/MintedCrowdsale.sol";
|
||||
|
||||
|
||||
contract MintedCrowdsaleImpl is MintedCrowdsale {
|
||||
constructor (uint256 rate, address payable wallet, ERC20Mintable token) public Crowdsale(rate, wallet, token) {}
|
||||
|
||||
constructor (
|
||||
uint256 rate,
|
||||
address wallet,
|
||||
ERC20Mintable token
|
||||
)
|
||||
public
|
||||
{
|
||||
Crowdsale.initialize(rate, wallet, token);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,8 +1,13 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "../access/roles/MinterRole.sol";
|
||||
|
||||
|
||||
contract MinterRoleMock is MinterRole {
|
||||
constructor() public {
|
||||
MinterRole.initialize(msg.sender);
|
||||
}
|
||||
|
||||
function removeMinter(address account) public {
|
||||
_removeMinter(account);
|
||||
}
|
||||
|
||||
@ -1,15 +0,0 @@
|
||||
pragma solidity ^0.5.0;
|
||||
|
||||
import "../ownership/Ownable.sol";
|
||||
|
||||
/**
|
||||
* @title Ownable interface id calculator.
|
||||
* @dev See the EIP165 specification for more information:
|
||||
* https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md#specification
|
||||
*/
|
||||
contract OwnableInterfaceId {
|
||||
function getInterfaceId() public pure returns (bytes4) {
|
||||
Ownable i;
|
||||
return i.owner.selector ^ i.isOwner.selector ^ i.renounceOwnership.selector ^ i.transferOwnership.selector;
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,9 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "../ownership/Ownable.sol";
|
||||
import { Ownable } from "../ownership/Ownable.sol";
|
||||
|
||||
contract OwnableMock is Ownable {}
|
||||
contract OwnableMock is Ownable {
|
||||
constructor() {
|
||||
Ownable.initialize(msg.sender);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,9 +0,0 @@
|
||||
pragma solidity ^0.5.0;
|
||||
|
||||
import "../token/ERC20/ERC20.sol";
|
||||
import "../crowdsale/validation/PausableCrowdsale.sol";
|
||||
|
||||
contract PausableCrowdsaleImpl is PausableCrowdsale {
|
||||
constructor (uint256 _rate, address payable _wallet, ERC20 _token) public Crowdsale(_rate, _wallet, _token) {
|
||||
}
|
||||
}
|
||||
@ -1,14 +1,17 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "../lifecycle/Pausable.sol";
|
||||
import "./PauserRoleMock.sol";
|
||||
|
||||
|
||||
// mock class using Pausable
|
||||
contract PausableMock is Pausable, PauserRoleMock {
|
||||
bool public drasticMeasureTaken;
|
||||
uint256 public count;
|
||||
|
||||
constructor () public {
|
||||
constructor() public {
|
||||
Pausable.initialize(msg.sender);
|
||||
|
||||
drasticMeasureTaken = false;
|
||||
count = 0;
|
||||
}
|
||||
@ -20,4 +23,5 @@ contract PausableMock is Pausable, PauserRoleMock {
|
||||
function drasticMeasure() external whenPaused {
|
||||
drasticMeasureTaken = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,8 +1,13 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "../access/roles/PauserRole.sol";
|
||||
|
||||
|
||||
contract PauserRoleMock is PauserRole {
|
||||
constructor() public {
|
||||
PauserRole.initialize(msg.sender);
|
||||
}
|
||||
|
||||
function removePauser(address account) public {
|
||||
_removePauser(account);
|
||||
}
|
||||
|
||||
@ -1,12 +1,22 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "../token/ERC20/IERC20.sol";
|
||||
import "../crowdsale/distribution/PostDeliveryCrowdsale.sol";
|
||||
|
||||
|
||||
contract PostDeliveryCrowdsaleImpl is PostDeliveryCrowdsale {
|
||||
constructor (uint256 openingTime, uint256 closingTime, uint256 rate, address payable wallet, IERC20 token)
|
||||
|
||||
constructor (
|
||||
uint256 openingTime,
|
||||
uint256 closingTime,
|
||||
uint256 rate,
|
||||
address wallet,
|
||||
IERC20 token
|
||||
)
|
||||
public
|
||||
TimedCrowdsale(openingTime, closingTime)
|
||||
Crowdsale(rate, wallet, token)
|
||||
{}
|
||||
{
|
||||
Crowdsale.initialize(rate, wallet, token);
|
||||
TimedCrowdsale.initialize(openingTime, closingTime);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,13 +1,19 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
|
||||
import "../payment/PullPayment.sol";
|
||||
|
||||
|
||||
// mock class using PullPayment
|
||||
contract PullPaymentMock is PullPayment {
|
||||
constructor () public payable { }
|
||||
|
||||
constructor() public payable {
|
||||
PullPayment.initialize();
|
||||
}
|
||||
|
||||
// test helper function to call asyncTransfer
|
||||
function callTransfer(address dest, uint256 amount) public {
|
||||
_asyncTransfer(dest, amount);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
|
||||
contract ReentrancyAttack {
|
||||
|
||||
function callSender(bytes4 data) public {
|
||||
// solium-disable-next-line security/no-low-level-calls
|
||||
(bool success,) = msg.sender.call(abi.encodeWithSelector(data));
|
||||
require(success);
|
||||
require(msg.sender.call(abi.encodeWithSelector(data)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,12 +1,15 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "../utils/ReentrancyGuard.sol";
|
||||
import "./ReentrancyAttack.sol";
|
||||
|
||||
|
||||
contract ReentrancyMock is ReentrancyGuard {
|
||||
|
||||
uint256 public counter;
|
||||
|
||||
constructor () public {
|
||||
constructor() public {
|
||||
ReentrancyGuard.initialize();
|
||||
counter = 0;
|
||||
}
|
||||
|
||||
@ -25,8 +28,8 @@ contract ReentrancyMock is ReentrancyGuard {
|
||||
if (n > 0) {
|
||||
count();
|
||||
// solium-disable-next-line security/no-low-level-calls
|
||||
(bool success,) = address(this).call(abi.encodeWithSignature("countThisRecursive(uint256)", n - 1));
|
||||
require(success);
|
||||
bool result = address(this).call(abi.encodeWithSignature("countThisRecursive(uint256)", n - 1));
|
||||
require(result == true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,4 +42,5 @@ contract ReentrancyMock is ReentrancyGuard {
|
||||
function count() private {
|
||||
counter += 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
9
contracts/mocks/RefundEscrowMock.sol
Normal file
9
contracts/mocks/RefundEscrowMock.sol
Normal file
@ -0,0 +1,9 @@
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "../payment/RefundEscrow.sol";
|
||||
|
||||
contract RefundEscrowMock is RefundEscrow {
|
||||
constructor(address beneficiary) public {
|
||||
RefundEscrow.initialize(beneficiary, msg.sender);
|
||||
}
|
||||
}
|
||||
@ -1,20 +1,24 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity ^0.4.24;
|
||||
|
||||
import "../token/ERC20/IERC20.sol";
|
||||
import "../token/ERC20/ERC20Mintable.sol";
|
||||
import "../crowdsale/distribution/RefundableCrowdsale.sol";
|
||||
|
||||
contract RefundableCrowdsaleImpl is RefundableCrowdsale {
|
||||
|
||||
contract RefundableCrowdsaleImpl is Crowdsale, TimedCrowdsale, RefundableCrowdsale {
|
||||
|
||||
constructor (
|
||||
uint256 openingTime,
|
||||
uint256 closingTime,
|
||||
uint256 rate,
|
||||
address payable wallet,
|
||||
IERC20 token,
|
||||
address wallet,
|
||||
ERC20Mintable token,
|
||||
uint256 goal
|
||||
)
|
||||
public
|
||||
Crowdsale(rate, wallet, token)
|
||||
TimedCrowdsale(openingTime, closingTime)
|
||||
RefundableCrowdsale(goal)
|
||||
{}
|
||||
{
|
||||
Crowdsale.initialize(rate, wallet, token);
|
||||
TimedCrowdsale.initialize(openingTime, closingTime);
|
||||
RefundableCrowdsale.initialize(goal);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user