Compare commits
161 Commits
v2.4.0-bet
...
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 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -37,3 +37,5 @@ build/
|
|||||||
|
|
||||||
# truffle
|
# truffle
|
||||||
.node-xmlhttprequest-*
|
.node-xmlhttprequest-*
|
||||||
|
|
||||||
|
.zos.session
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
"indentation": ["error", 2],
|
"indentation": ["error", 2],
|
||||||
"lbrace": "off",
|
"lbrace": "off",
|
||||||
"linebreak-style": ["error", "unix"],
|
"linebreak-style": ["error", "unix"],
|
||||||
"max-len": ["error", 79],
|
"max-len": ["error", 120],
|
||||||
"no-constant": ["error"],
|
"no-constant": ["error"],
|
||||||
"no-empty-blocks": "off",
|
"no-empty-blocks": "off",
|
||||||
"quotes": ["error", "double"],
|
"quotes": ["error", "double"],
|
||||||
|
|||||||
@ -18,6 +18,11 @@ jobs:
|
|||||||
- env: SOLIDITY_COVERAGE=true
|
- env: SOLIDITY_COVERAGE=true
|
||||||
- env: SOLC_NIGHTLY=true
|
- env: SOLC_NIGHTLY=true
|
||||||
include:
|
include:
|
||||||
|
- stage: install
|
||||||
|
script: true
|
||||||
|
install:
|
||||||
|
- npm install
|
||||||
|
- npx npm-install-peers
|
||||||
# Run the unit test suite three times in parallel.
|
# Run the unit test suite three times in parallel.
|
||||||
# The first one gets results faster and is the only one required to pass.
|
# The first one gets results faster and is the only one required to pass.
|
||||||
# The second one generates the coverage report.
|
# The second one generates the coverage report.
|
||||||
@ -25,18 +30,22 @@ jobs:
|
|||||||
# upcoming solidity release.
|
# upcoming solidity release.
|
||||||
- stage: tests
|
- stage: tests
|
||||||
name: "unit tests"
|
name: "unit tests"
|
||||||
|
install: npx npm-install-peers
|
||||||
script: npm run test
|
script: npm run test
|
||||||
- stage: tests
|
- stage: tests
|
||||||
name: "unit tests with coverage"
|
name: "unit tests with coverage"
|
||||||
|
install: npx npm-install-peers
|
||||||
script: npm run test
|
script: npm run test
|
||||||
env: SOLIDITY_COVERAGE=true
|
env: SOLIDITY_COVERAGE=true
|
||||||
- stage: tests
|
- stage: tests
|
||||||
name: "unit tests with solc nightly"
|
name: "unit tests with solc nightly"
|
||||||
|
install: npx npm-install-peers
|
||||||
script: npm run test
|
script: npm run test
|
||||||
env: SOLC_NIGHTLY=true
|
env: SOLC_NIGHTLY=true
|
||||||
# solidity and javascript style tests.
|
# solidity and javascript style tests.
|
||||||
- stage: tests
|
- stage: tests
|
||||||
name: "static tests"
|
name: "static tests"
|
||||||
|
install: npx npm-install-peers
|
||||||
script: npm run lint
|
script: npm run lint
|
||||||
- stage: update docs
|
- stage: update docs
|
||||||
if: tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+$
|
if: tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+$
|
||||||
|
|||||||
48
README.md
48
README.md
@ -1,54 +1,30 @@
|
|||||||
# <img src="logo.png" alt="OpenZeppelin" width="400px">
|
# <img src="logo.png" alt="OpenZeppelin" width="400px">
|
||||||
|
|
||||||
[](https://www.npmjs.org/package/openzeppelin-solidity)
|
# OpenZeppelin EVM Package
|
||||||
[](https://travis-ci.org/OpenZeppelin/openzeppelin-solidity)
|
|
||||||
[](https://coveralls.io/github/OpenZeppelin/openzeppelin-solidity?branch=master)
|
[](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.
|
**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
|
## 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.
|
- StandaloneERC20
|
||||||
|
- StandaloneERC721
|
||||||
```solidity
|
- TokenVesting
|
||||||
import 'openzeppelin-solidity/contracts/token/ERC721/ERC721.sol';
|
- PaymentSplitter
|
||||||
import 'openzeppelin-solidity/contracts/token/ERC721/ERC721Mintable.sol';
|
|
||||||
|
|
||||||
contract MyNFT is ERC721, ERC721Mintable {
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
> 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]!
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
OpenZeppelin is released under the [MIT License](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
|
[Slack]: https://slack.openzeppelin.org
|
||||||
[Zeppelin]: https://zeppelin.solutions
|
[Zeppelin]: https://zeppelin.solutions
|
||||||
[contribution guide]: CONTRIBUTING.md
|
|
||||||
[Truffle]: https://truffleframework.com/docs/truffle/quickstart
|
|
||||||
[Embark]: https://embark.status.im/docs/quick_start.html
|
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "../Roles.sol";
|
import "../Roles.sol";
|
||||||
|
|
||||||
|
|
||||||
contract CapperRole {
|
contract CapperRole is Initializable {
|
||||||
using Roles for Roles.Role;
|
using Roles for Roles.Role;
|
||||||
|
|
||||||
event CapperAdded(address indexed account);
|
event CapperAdded(address indexed account);
|
||||||
@ -11,8 +12,10 @@ contract CapperRole {
|
|||||||
|
|
||||||
Roles.Role private cappers;
|
Roles.Role private cappers;
|
||||||
|
|
||||||
constructor() public {
|
function initialize(address sender) public initializer {
|
||||||
_addCapper(msg.sender);
|
if (!isCapper(sender)) {
|
||||||
|
_addCapper(sender);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
modifier onlyCapper() {
|
modifier onlyCapper() {
|
||||||
@ -41,4 +44,6 @@ contract CapperRole {
|
|||||||
cappers.remove(account);
|
cappers.remove(account);
|
||||||
emit CapperRemoved(account);
|
emit CapperRemoved(account);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "../Roles.sol";
|
import "../Roles.sol";
|
||||||
|
|
||||||
|
|
||||||
contract MinterRole {
|
contract MinterRole is Initializable {
|
||||||
using Roles for Roles.Role;
|
using Roles for Roles.Role;
|
||||||
|
|
||||||
event MinterAdded(address indexed account);
|
event MinterAdded(address indexed account);
|
||||||
@ -11,8 +12,10 @@ contract MinterRole {
|
|||||||
|
|
||||||
Roles.Role private minters;
|
Roles.Role private minters;
|
||||||
|
|
||||||
constructor() public {
|
function initialize(address sender) public initializer {
|
||||||
_addMinter(msg.sender);
|
if (!isMinter(sender)) {
|
||||||
|
_addMinter(sender);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
modifier onlyMinter() {
|
modifier onlyMinter() {
|
||||||
@ -41,4 +44,6 @@ contract MinterRole {
|
|||||||
minters.remove(account);
|
minters.remove(account);
|
||||||
emit MinterRemoved(account);
|
emit MinterRemoved(account);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "../Roles.sol";
|
import "../Roles.sol";
|
||||||
|
|
||||||
|
|
||||||
contract PauserRole {
|
contract PauserRole is Initializable {
|
||||||
using Roles for Roles.Role;
|
using Roles for Roles.Role;
|
||||||
|
|
||||||
event PauserAdded(address indexed account);
|
event PauserAdded(address indexed account);
|
||||||
@ -11,8 +12,10 @@ contract PauserRole {
|
|||||||
|
|
||||||
Roles.Role private pausers;
|
Roles.Role private pausers;
|
||||||
|
|
||||||
constructor() public {
|
function initialize(address sender) public initializer {
|
||||||
_addPauser(msg.sender);
|
if (!isPauser(sender)) {
|
||||||
|
_addPauser(sender);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
modifier onlyPauser() {
|
modifier onlyPauser() {
|
||||||
@ -41,4 +44,6 @@ contract PauserRole {
|
|||||||
pausers.remove(account);
|
pausers.remove(account);
|
||||||
emit PauserRemoved(account);
|
emit PauserRemoved(account);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "../Roles.sol";
|
import "../Roles.sol";
|
||||||
|
|
||||||
|
|
||||||
contract SignerRole {
|
contract SignerRole is Initializable {
|
||||||
using Roles for Roles.Role;
|
using Roles for Roles.Role;
|
||||||
|
|
||||||
event SignerAdded(address indexed account);
|
event SignerAdded(address indexed account);
|
||||||
@ -11,8 +12,10 @@ contract SignerRole {
|
|||||||
|
|
||||||
Roles.Role private signers;
|
Roles.Role private signers;
|
||||||
|
|
||||||
constructor() public {
|
function initialize(address sender) public initializer {
|
||||||
_addSigner(msg.sender);
|
if (!isSigner(sender)) {
|
||||||
|
_addSigner(sender);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
modifier onlySigner() {
|
modifier onlySigner() {
|
||||||
@ -41,4 +44,6 @@ contract SignerRole {
|
|||||||
signers.remove(account);
|
signers.remove(account);
|
||||||
emit SignerRemoved(account);
|
emit SignerRemoved(account);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "../token/ERC20/IERC20.sol";
|
import "../token/ERC20/IERC20.sol";
|
||||||
import "../math/SafeMath.sol";
|
import "../math/SafeMath.sol";
|
||||||
import "../token/ERC20/SafeERC20.sol";
|
import "../token/ERC20/SafeERC20.sol";
|
||||||
@ -17,7 +18,7 @@ import "../token/ERC20/SafeERC20.sol";
|
|||||||
* the methods to add functionality. Consider using 'super' where appropriate to concatenate
|
* the methods to add functionality. Consider using 'super' where appropriate to concatenate
|
||||||
* behavior.
|
* behavior.
|
||||||
*/
|
*/
|
||||||
contract Crowdsale {
|
contract Crowdsale is Initializable {
|
||||||
using SafeMath for uint256;
|
using SafeMath for uint256;
|
||||||
using SafeERC20 for IERC20;
|
using SafeERC20 for IERC20;
|
||||||
|
|
||||||
@ -58,7 +59,7 @@ contract Crowdsale {
|
|||||||
* @param wallet Address where collected funds will be forwarded to
|
* @param wallet Address where collected funds will be forwarded to
|
||||||
* @param token Address of the token being sold
|
* @param token Address of the token being sold
|
||||||
*/
|
*/
|
||||||
constructor(uint256 rate, address wallet, IERC20 token) public {
|
function initialize(uint256 rate, address wallet, IERC20 token) public initializer {
|
||||||
require(rate > 0);
|
require(rate > 0);
|
||||||
require(wallet != address(0));
|
require(wallet != address(0));
|
||||||
require(token != address(0));
|
require(token != address(0));
|
||||||
@ -140,6 +141,10 @@ contract Crowdsale {
|
|||||||
// Internal interface (extensible)
|
// 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.
|
* @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use `super` in contracts that inherit from Crowdsale to extend their validations.
|
||||||
* Example from CappedCrowdsale.sol's _preValidatePurchase method:
|
* Example from CappedCrowdsale.sol's _preValidatePurchase method:
|
||||||
@ -231,4 +236,6 @@ contract Crowdsale {
|
|||||||
function _forwardFunds() internal {
|
function _forwardFunds() internal {
|
||||||
_wallet.transfer(msg.value);
|
_wallet.transfer(msg.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "../../math/SafeMath.sol";
|
import "../../math/SafeMath.sol";
|
||||||
import "../validation/TimedCrowdsale.sol";
|
import "../validation/TimedCrowdsale.sol";
|
||||||
|
|
||||||
@ -9,7 +10,7 @@ import "../validation/TimedCrowdsale.sol";
|
|||||||
* @dev Extension of Crowdsale with a one-off finalization action, where one
|
* @dev Extension of Crowdsale with a one-off finalization action, where one
|
||||||
* can do extra work after finishing.
|
* can do extra work after finishing.
|
||||||
*/
|
*/
|
||||||
contract FinalizableCrowdsale is TimedCrowdsale {
|
contract FinalizableCrowdsale is Initializable, TimedCrowdsale {
|
||||||
using SafeMath for uint256;
|
using SafeMath for uint256;
|
||||||
|
|
||||||
bool private _finalized = false;
|
bool private _finalized = false;
|
||||||
@ -45,4 +46,6 @@ contract FinalizableCrowdsale is TimedCrowdsale {
|
|||||||
function _finalization() internal {
|
function _finalization() internal {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "../validation/TimedCrowdsale.sol";
|
import "../validation/TimedCrowdsale.sol";
|
||||||
import "../../token/ERC20/IERC20.sol";
|
import "../../token/ERC20/IERC20.sol";
|
||||||
import "../../math/SafeMath.sol";
|
import "../../math/SafeMath.sol";
|
||||||
@ -9,7 +10,7 @@ import "../../math/SafeMath.sol";
|
|||||||
* @title PostDeliveryCrowdsale
|
* @title PostDeliveryCrowdsale
|
||||||
* @dev Crowdsale that locks tokens from withdrawal until it ends.
|
* @dev Crowdsale that locks tokens from withdrawal until it ends.
|
||||||
*/
|
*/
|
||||||
contract PostDeliveryCrowdsale is TimedCrowdsale {
|
contract PostDeliveryCrowdsale is Initializable, TimedCrowdsale {
|
||||||
using SafeMath for uint256;
|
using SafeMath for uint256;
|
||||||
|
|
||||||
mapping(address => uint256) private _balances;
|
mapping(address => uint256) private _balances;
|
||||||
@ -47,4 +48,6 @@ contract PostDeliveryCrowdsale is TimedCrowdsale {
|
|||||||
_balances[beneficiary] = _balances[beneficiary].add(tokenAmount);
|
_balances[beneficiary] = _balances[beneficiary].add(tokenAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "../../math/SafeMath.sol";
|
import "../../math/SafeMath.sol";
|
||||||
import "./FinalizableCrowdsale.sol";
|
import "./FinalizableCrowdsale.sol";
|
||||||
import "../../payment/RefundEscrow.sol";
|
import "../../payment/RefundEscrow.sol";
|
||||||
@ -11,7 +12,7 @@ import "../../payment/RefundEscrow.sol";
|
|||||||
* @dev Extension of Crowdsale contract that adds a funding goal, and
|
* @dev Extension of Crowdsale contract that adds a funding goal, and
|
||||||
* the possibility of users getting a refund if goal is not met.
|
* the possibility of users getting a refund if goal is not met.
|
||||||
*/
|
*/
|
||||||
contract RefundableCrowdsale is FinalizableCrowdsale {
|
contract RefundableCrowdsale is Initializable, FinalizableCrowdsale {
|
||||||
using SafeMath for uint256;
|
using SafeMath for uint256;
|
||||||
|
|
||||||
// minimum amount of funds to be raised in weis
|
// minimum amount of funds to be raised in weis
|
||||||
@ -24,9 +25,18 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
|
|||||||
* @dev Constructor, creates RefundEscrow.
|
* @dev Constructor, creates RefundEscrow.
|
||||||
* @param goal Funding goal
|
* @param goal Funding goal
|
||||||
*/
|
*/
|
||||||
constructor(uint256 goal) public {
|
function initialize(uint256 goal) public initializer {
|
||||||
|
// FinalizableCrowdsale depends on TimedCrowdsale
|
||||||
|
assert(TimedCrowdsale._hasBeenInitialized());
|
||||||
|
|
||||||
require(goal > 0);
|
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;
|
_goal = goal;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,4 +87,6 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
|
|||||||
_escrow.deposit.value(msg.value)(msg.sender);
|
_escrow.deposit.value(msg.value)(msg.sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "../Crowdsale.sol";
|
import "../Crowdsale.sol";
|
||||||
import "../../token/ERC20/IERC20.sol";
|
import "../../token/ERC20/IERC20.sol";
|
||||||
import "../../token/ERC20/SafeERC20.sol";
|
import "../../token/ERC20/SafeERC20.sol";
|
||||||
@ -10,7 +11,7 @@ import "../../math/SafeMath.sol";
|
|||||||
* @title AllowanceCrowdsale
|
* @title AllowanceCrowdsale
|
||||||
* @dev Extension of Crowdsale where tokens are held by a wallet, which approves an allowance to the crowdsale.
|
* @dev Extension of Crowdsale where tokens are held by a wallet, which approves an allowance to the crowdsale.
|
||||||
*/
|
*/
|
||||||
contract AllowanceCrowdsale is Crowdsale {
|
contract AllowanceCrowdsale is Initializable, Crowdsale {
|
||||||
using SafeMath for uint256;
|
using SafeMath for uint256;
|
||||||
using SafeERC20 for IERC20;
|
using SafeERC20 for IERC20;
|
||||||
|
|
||||||
@ -20,7 +21,9 @@ contract AllowanceCrowdsale is Crowdsale {
|
|||||||
* @dev Constructor, takes token wallet address.
|
* @dev Constructor, takes token wallet address.
|
||||||
* @param tokenWallet Address holding the tokens, which has approved allowance to the crowdsale
|
* @param tokenWallet Address holding the tokens, which has approved allowance to the crowdsale
|
||||||
*/
|
*/
|
||||||
constructor(address tokenWallet) public {
|
function initialize(address tokenWallet) public initializer {
|
||||||
|
assert(Crowdsale._hasBeenInitialized());
|
||||||
|
|
||||||
require(tokenWallet != address(0));
|
require(tokenWallet != address(0));
|
||||||
_tokenWallet = tokenWallet;
|
_tokenWallet = tokenWallet;
|
||||||
}
|
}
|
||||||
@ -53,4 +56,6 @@ contract AllowanceCrowdsale is Crowdsale {
|
|||||||
{
|
{
|
||||||
token().safeTransferFrom(_tokenWallet, beneficiary, tokenAmount);
|
token().safeTransferFrom(_tokenWallet, beneficiary, tokenAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "../Crowdsale.sol";
|
import "../Crowdsale.sol";
|
||||||
import "../../token/ERC20/ERC20Mintable.sol";
|
import "../../token/ERC20/ERC20Mintable.sol";
|
||||||
|
|
||||||
@ -9,7 +10,7 @@ import "../../token/ERC20/ERC20Mintable.sol";
|
|||||||
* @dev Extension of Crowdsale contract whose tokens are minted in each purchase.
|
* @dev Extension of Crowdsale contract whose tokens are minted in each purchase.
|
||||||
* Token ownership should be transferred to MintedCrowdsale for minting.
|
* 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.
|
* @dev Overrides delivery by minting tokens upon purchase.
|
||||||
@ -26,4 +27,6 @@ contract MintedCrowdsale is Crowdsale {
|
|||||||
require(
|
require(
|
||||||
ERC20Mintable(address(token())).mint(beneficiary, tokenAmount));
|
ERC20Mintable(address(token())).mint(beneficiary, tokenAmount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "../validation/TimedCrowdsale.sol";
|
import "../validation/TimedCrowdsale.sol";
|
||||||
import "../../math/SafeMath.sol";
|
import "../../math/SafeMath.sol";
|
||||||
|
|
||||||
@ -10,7 +11,7 @@ import "../../math/SafeMath.sol";
|
|||||||
* Note that what should be provided to the constructor is the initial and final _rates_, that is,
|
* 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.
|
* 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;
|
using SafeMath for uint256;
|
||||||
|
|
||||||
uint256 private _initialRate;
|
uint256 private _initialRate;
|
||||||
@ -21,7 +22,9 @@ contract IncreasingPriceCrowdsale is TimedCrowdsale {
|
|||||||
* @param initialRate Number of tokens a buyer gets per wei at the start of the crowdsale
|
* @param initialRate Number of tokens a buyer gets per wei at the start of the crowdsale
|
||||||
* @param finalRate Number of tokens a buyer gets per wei at the end of the crowdsale
|
* @param finalRate Number of tokens a buyer gets per wei at the end of the crowdsale
|
||||||
*/
|
*/
|
||||||
constructor(uint256 initialRate, uint256 finalRate) public {
|
function initialize(uint256 initialRate, uint256 finalRate) public initializer {
|
||||||
|
assert(TimedCrowdsale._hasBeenInitialized());
|
||||||
|
|
||||||
require(finalRate > 0);
|
require(finalRate > 0);
|
||||||
require(initialRate >= finalRate);
|
require(initialRate >= finalRate);
|
||||||
_initialRate = initialRate;
|
_initialRate = initialRate;
|
||||||
@ -67,4 +70,6 @@ contract IncreasingPriceCrowdsale is TimedCrowdsale {
|
|||||||
return currentRate.mul(weiAmount);
|
return currentRate.mul(weiAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "../../math/SafeMath.sol";
|
import "../../math/SafeMath.sol";
|
||||||
import "../Crowdsale.sol";
|
import "../Crowdsale.sol";
|
||||||
|
|
||||||
@ -8,7 +9,7 @@ import "../Crowdsale.sol";
|
|||||||
* @title CappedCrowdsale
|
* @title CappedCrowdsale
|
||||||
* @dev Crowdsale with a limit for total contributions.
|
* @dev Crowdsale with a limit for total contributions.
|
||||||
*/
|
*/
|
||||||
contract CappedCrowdsale is Crowdsale {
|
contract CappedCrowdsale is Initializable, Crowdsale {
|
||||||
using SafeMath for uint256;
|
using SafeMath for uint256;
|
||||||
|
|
||||||
uint256 private _cap;
|
uint256 private _cap;
|
||||||
@ -17,7 +18,9 @@ contract CappedCrowdsale is Crowdsale {
|
|||||||
* @dev Constructor, takes maximum amount of wei accepted in the crowdsale.
|
* @dev Constructor, takes maximum amount of wei accepted in the crowdsale.
|
||||||
* @param cap Max amount of wei to be contributed
|
* @param cap Max amount of wei to be contributed
|
||||||
*/
|
*/
|
||||||
constructor(uint256 cap) public {
|
function initialize(uint256 cap) public initializer {
|
||||||
|
assert(Crowdsale._hasBeenInitialized());
|
||||||
|
|
||||||
require(cap > 0);
|
require(cap > 0);
|
||||||
_cap = cap;
|
_cap = cap;
|
||||||
}
|
}
|
||||||
@ -52,4 +55,6 @@ contract CappedCrowdsale is Crowdsale {
|
|||||||
require(weiRaised().add(weiAmount) <= _cap);
|
require(weiRaised().add(weiAmount) <= _cap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "../../math/SafeMath.sol";
|
import "../../math/SafeMath.sol";
|
||||||
import "../Crowdsale.sol";
|
import "../Crowdsale.sol";
|
||||||
import "../../access/roles/CapperRole.sol";
|
import "../../access/roles/CapperRole.sol";
|
||||||
@ -9,12 +10,18 @@ import "../../access/roles/CapperRole.sol";
|
|||||||
* @title IndividuallyCappedCrowdsale
|
* @title IndividuallyCappedCrowdsale
|
||||||
* @dev Crowdsale with per-beneficiary caps.
|
* @dev Crowdsale with per-beneficiary caps.
|
||||||
*/
|
*/
|
||||||
contract IndividuallyCappedCrowdsale is Crowdsale, CapperRole {
|
contract IndividuallyCappedCrowdsale is Initializable, Crowdsale, CapperRole {
|
||||||
using SafeMath for uint256;
|
using SafeMath for uint256;
|
||||||
|
|
||||||
mapping(address => uint256) private _contributions;
|
mapping(address => uint256) private _contributions;
|
||||||
mapping(address => uint256) private _caps;
|
mapping(address => uint256) private _caps;
|
||||||
|
|
||||||
|
function initialize(address sender) public initializer {
|
||||||
|
assert(Crowdsale._hasBeenInitialized());
|
||||||
|
|
||||||
|
CapperRole.initialize(sender);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Sets a specific beneficiary's maximum contribution.
|
* @dev Sets a specific beneficiary's maximum contribution.
|
||||||
* @param beneficiary Address to be capped
|
* @param beneficiary Address to be capped
|
||||||
@ -76,4 +83,6 @@ contract IndividuallyCappedCrowdsale is Crowdsale, CapperRole {
|
|||||||
weiAmount);
|
weiAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "../../math/SafeMath.sol";
|
import "../../math/SafeMath.sol";
|
||||||
import "../Crowdsale.sol";
|
import "../Crowdsale.sol";
|
||||||
|
|
||||||
@ -8,7 +9,7 @@ import "../Crowdsale.sol";
|
|||||||
* @title TimedCrowdsale
|
* @title TimedCrowdsale
|
||||||
* @dev Crowdsale accepting contributions only within a time frame.
|
* @dev Crowdsale accepting contributions only within a time frame.
|
||||||
*/
|
*/
|
||||||
contract TimedCrowdsale is Crowdsale {
|
contract TimedCrowdsale is Initializable, Crowdsale {
|
||||||
using SafeMath for uint256;
|
using SafeMath for uint256;
|
||||||
|
|
||||||
uint256 private _openingTime;
|
uint256 private _openingTime;
|
||||||
@ -27,7 +28,9 @@ contract TimedCrowdsale is Crowdsale {
|
|||||||
* @param openingTime Crowdsale opening time
|
* @param openingTime Crowdsale opening time
|
||||||
* @param closingTime Crowdsale closing 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
|
// solium-disable-next-line security/no-block-members
|
||||||
require(openingTime >= block.timestamp);
|
require(openingTime >= block.timestamp);
|
||||||
require(closingTime >= openingTime);
|
require(closingTime >= openingTime);
|
||||||
@ -67,6 +70,10 @@ contract TimedCrowdsale is Crowdsale {
|
|||||||
return block.timestamp > _closingTime;
|
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
|
* @dev Extend parent behavior requiring to be within contributing period
|
||||||
* @param beneficiary Token purchaser
|
* @param beneficiary Token purchaser
|
||||||
@ -82,4 +89,6 @@ contract TimedCrowdsale is Crowdsale {
|
|||||||
super._preValidatePurchase(beneficiary, weiAmount);
|
super._preValidatePurchase(beneficiary, weiAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,88 +0,0 @@
|
|||||||
pragma solidity ^0.4.24;
|
|
||||||
|
|
||||||
|
|
||||||
import "../payment/PullPayment.sol";
|
|
||||||
import "../ownership/Ownable.sol";
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @title BreakInvariantBounty
|
|
||||||
* @dev This bounty will pay out to a researcher if they break invariant logic of the contract.
|
|
||||||
*/
|
|
||||||
contract BreakInvariantBounty is PullPayment, Ownable {
|
|
||||||
bool private _claimed;
|
|
||||||
mapping(address => address) private _researchers;
|
|
||||||
|
|
||||||
event TargetCreated(address createdAddress);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dev Fallback function allowing the contract to receive funds, if they haven't already been claimed.
|
|
||||||
*/
|
|
||||||
function() external payable {
|
|
||||||
require(!_claimed);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dev Determine if the bounty was claimed.
|
|
||||||
* @return true if the bounty was claimed, false otherwise.
|
|
||||||
*/
|
|
||||||
function claimed() public view returns(bool) {
|
|
||||||
return _claimed;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dev Create and deploy the target contract (extension of Target contract), and sets the
|
|
||||||
* msg.sender as a researcher
|
|
||||||
* @return A target contract
|
|
||||||
*/
|
|
||||||
function createTarget() public returns(Target) {
|
|
||||||
Target target = Target(_deployContract());
|
|
||||||
_researchers[target] = msg.sender;
|
|
||||||
emit TargetCreated(target);
|
|
||||||
return target;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dev Transfers the contract funds to the researcher that proved the contract is broken.
|
|
||||||
* @param target contract
|
|
||||||
*/
|
|
||||||
function claim(Target target) public {
|
|
||||||
require(!_claimed);
|
|
||||||
address researcher = _researchers[target];
|
|
||||||
require(researcher != address(0));
|
|
||||||
// Check Target contract invariants
|
|
||||||
require(!target.checkInvariant());
|
|
||||||
_asyncTransfer(researcher, address(this).balance);
|
|
||||||
_claimed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dev Transfers the current balance to the owner and terminates the contract.
|
|
||||||
*/
|
|
||||||
function destroy() public onlyOwner {
|
|
||||||
selfdestruct(owner());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dev Internal function to deploy the target contract.
|
|
||||||
* @return A target contract address
|
|
||||||
*/
|
|
||||||
function _deployContract() internal returns(address);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @title Target
|
|
||||||
* @dev Your main contract should inherit from this class and implement the checkInvariant method.
|
|
||||||
*/
|
|
||||||
contract Target {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dev Checks all values a contract assumes to be true all the time. If this function returns
|
|
||||||
* false, the contract is broken in some way and is in an inconsistent state.
|
|
||||||
* In order to win the bounty, security researchers will try to cause this broken state.
|
|
||||||
* @return True if all invariant values are correct, false otherwise.
|
|
||||||
*/
|
|
||||||
function checkInvariant() public returns(bool);
|
|
||||||
}
|
|
||||||
@ -1,5 +1,6 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "../../token/ERC20/IERC20.sol";
|
import "../../token/ERC20/IERC20.sol";
|
||||||
|
|
||||||
|
|
||||||
@ -9,16 +10,19 @@ import "../../token/ERC20/IERC20.sol";
|
|||||||
* @dev tokenURI must respond with a URI that implements https://eips.ethereum.org/EIPS/eip-1047
|
* @dev tokenURI must respond with a URI that implements https://eips.ethereum.org/EIPS/eip-1047
|
||||||
* @dev TODO - update https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/token/ERC721/IERC721.sol#L17 when 1046 is finalized
|
* @dev TODO - update https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/token/ERC721/IERC721.sol#L17 when 1046 is finalized
|
||||||
*/
|
*/
|
||||||
contract ERC20TokenMetadata is IERC20 {
|
contract ERC20TokenMetadata is Initializable, IERC20 {
|
||||||
function tokenURI() external view returns (string);
|
function tokenURI() external view returns (string);
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
contract ERC20WithMetadata is ERC20TokenMetadata {
|
contract ERC20WithMetadata is Initializable, ERC20TokenMetadata {
|
||||||
string private _tokenURI = "";
|
string private _tokenURI = "";
|
||||||
|
|
||||||
constructor(string tokenURI)
|
function initialize(string tokenURI)
|
||||||
public
|
public
|
||||||
|
initializer
|
||||||
{
|
{
|
||||||
_tokenURI = tokenURI;
|
_tokenURI = tokenURI;
|
||||||
}
|
}
|
||||||
@ -26,4 +30,6 @@ contract ERC20WithMetadata is ERC20TokenMetadata {
|
|||||||
function tokenURI() external view returns (string) {
|
function tokenURI() external view returns (string) {
|
||||||
return _tokenURI;
|
return _tokenURI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "../token/ERC20/IERC20.sol";
|
import "../token/ERC20/IERC20.sol";
|
||||||
import "../token/ERC20/ERC20Mintable.sol";
|
import "../token/ERC20/ERC20Mintable.sol";
|
||||||
import "../token/ERC20/SafeERC20.sol";
|
import "../token/ERC20/SafeERC20.sol";
|
||||||
@ -32,7 +33,7 @@ import "../math/Math.sol";
|
|||||||
* await migrator.beginMigration(newToken.address);
|
* await migrator.beginMigration(newToken.address);
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
contract ERC20Migrator {
|
contract ERC20Migrator is Initializable {
|
||||||
using SafeERC20 for IERC20;
|
using SafeERC20 for IERC20;
|
||||||
|
|
||||||
/// Address of the old token contract
|
/// Address of the old token contract
|
||||||
@ -44,7 +45,7 @@ contract ERC20Migrator {
|
|||||||
/**
|
/**
|
||||||
* @param legacyToken address of the old token contract
|
* @param legacyToken address of the old token contract
|
||||||
*/
|
*/
|
||||||
constructor(IERC20 legacyToken) public {
|
function initialize(IERC20 legacyToken) public initializer {
|
||||||
require(legacyToken != address(0));
|
require(legacyToken != address(0));
|
||||||
_legacyToken = legacyToken;
|
_legacyToken = legacyToken;
|
||||||
}
|
}
|
||||||
@ -98,4 +99,6 @@ contract ERC20Migrator {
|
|||||||
uint256 amount = Math.min(balance, allowance);
|
uint256 amount = Math.min(balance, allowance);
|
||||||
migrate(account, amount);
|
migrate(account, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "../access/roles/SignerRole.sol";
|
import "../access/roles/SignerRole.sol";
|
||||||
import "../cryptography/ECDSA.sol";
|
import "../cryptography/ECDSA.sol";
|
||||||
|
|
||||||
@ -28,7 +29,7 @@ import "../cryptography/ECDSA.sol";
|
|||||||
* Also non fixed sized parameters make constructing the data in the signature
|
* 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.
|
* 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;
|
using ECDSA for bytes32;
|
||||||
|
|
||||||
// Function selectors are 4 bytes long, as documented in
|
// Function selectors are 4 bytes long, as documented in
|
||||||
@ -64,6 +65,10 @@ contract SignatureBouncer is SignerRole {
|
|||||||
_;
|
_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function initialize(address sender) public initializer {
|
||||||
|
SignerRole.initialize(sender);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev is the signature of `this + sender` from a signer?
|
* @dev is the signature of `this + sender` from a signer?
|
||||||
* @return bool
|
* @return bool
|
||||||
@ -135,4 +140,6 @@ contract SignatureBouncer is SignerRole {
|
|||||||
|
|
||||||
return signer != address(0) && isSigner(signer);
|
return signer != address(0) && isSigner(signer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "../token/ERC20/SafeERC20.sol";
|
import "../token/ERC20/SafeERC20.sol";
|
||||||
import "../ownership/Ownable.sol";
|
import "../ownership/Ownable.sol";
|
||||||
import "../math/SafeMath.sol";
|
import "../math/SafeMath.sol";
|
||||||
@ -13,7 +14,7 @@ import "../math/SafeMath.sol";
|
|||||||
* typical vesting scheme, with a cliff and vesting period. Optionally revocable by the
|
* typical vesting scheme, with a cliff and vesting period. Optionally revocable by the
|
||||||
* owner.
|
* owner.
|
||||||
*/
|
*/
|
||||||
contract TokenVesting is Ownable {
|
contract TokenVesting is Initializable, Ownable {
|
||||||
using SafeMath for uint256;
|
using SafeMath for uint256;
|
||||||
using SafeERC20 for IERC20;
|
using SafeERC20 for IERC20;
|
||||||
|
|
||||||
@ -42,15 +43,19 @@ contract TokenVesting is Ownable {
|
|||||||
* @param duration duration in seconds of the period in which the tokens will vest
|
* @param duration duration in seconds of the period in which the tokens will vest
|
||||||
* @param revocable whether the vesting is revocable or not
|
* @param revocable whether the vesting is revocable or not
|
||||||
*/
|
*/
|
||||||
constructor(
|
function initialize(
|
||||||
address beneficiary,
|
address beneficiary,
|
||||||
uint256 start,
|
uint256 start,
|
||||||
uint256 cliffDuration,
|
uint256 cliffDuration,
|
||||||
uint256 duration,
|
uint256 duration,
|
||||||
bool revocable
|
bool revocable,
|
||||||
|
address sender
|
||||||
)
|
)
|
||||||
public
|
public
|
||||||
|
initializer
|
||||||
{
|
{
|
||||||
|
Ownable.initialize(sender);
|
||||||
|
|
||||||
require(beneficiary != address(0));
|
require(beneficiary != address(0));
|
||||||
require(cliffDuration <= duration);
|
require(cliffDuration <= duration);
|
||||||
|
|
||||||
@ -171,4 +176,6 @@ contract TokenVesting is Ownable {
|
|||||||
return totalBalance.mul(block.timestamp.sub(_start)).div(_duration);
|
return totalBalance.mul(block.timestamp.sub(_start)).div(_duration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "../crowdsale/validation/CappedCrowdsale.sol";
|
import "../crowdsale/validation/CappedCrowdsale.sol";
|
||||||
import "../crowdsale/distribution/RefundableCrowdsale.sol";
|
import "../crowdsale/distribution/RefundableCrowdsale.sol";
|
||||||
import "../crowdsale/emission/MintedCrowdsale.sol";
|
import "../crowdsale/emission/MintedCrowdsale.sol";
|
||||||
@ -11,11 +12,21 @@ import "../token/ERC20/ERC20Mintable.sol";
|
|||||||
* @dev Very simple ERC20 Token that can be minted.
|
* @dev Very simple ERC20 Token that can be minted.
|
||||||
* It is meant to be used in a crowdsale contract.
|
* It is meant to be used in a crowdsale contract.
|
||||||
*/
|
*/
|
||||||
contract SampleCrowdsaleToken is ERC20Mintable {
|
contract SampleCrowdsaleToken is Initializable, ERC20Mintable {
|
||||||
|
|
||||||
string public constant name = "Sample Crowdsale Token";
|
string public name;
|
||||||
string public constant symbol = "SCT";
|
string public symbol;
|
||||||
uint8 public constant decimals = 18;
|
uint8 public decimals;
|
||||||
|
|
||||||
|
function initialize(address sender) public initializer {
|
||||||
|
ERC20Mintable.initialize(sender);
|
||||||
|
|
||||||
|
name = "Sample Crowdsale Token";
|
||||||
|
symbol = "SCT";
|
||||||
|
decimals = 18;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -35,9 +46,9 @@ contract SampleCrowdsaleToken is ERC20Mintable {
|
|||||||
// https://github.com/duaraghav8/Solium/issues/205
|
// https://github.com/duaraghav8/Solium/issues/205
|
||||||
// --elopio - 2018-05-10
|
// --elopio - 2018-05-10
|
||||||
// solium-disable-next-line max-len
|
// solium-disable-next-line max-len
|
||||||
contract SampleCrowdsale is CappedCrowdsale, RefundableCrowdsale, MintedCrowdsale {
|
contract SampleCrowdsale is Initializable, Crowdsale, CappedCrowdsale, RefundableCrowdsale, MintedCrowdsale {
|
||||||
|
|
||||||
constructor(
|
function initialize(
|
||||||
uint256 openingTime,
|
uint256 openingTime,
|
||||||
uint256 closingTime,
|
uint256 closingTime,
|
||||||
uint256 rate,
|
uint256 rate,
|
||||||
@ -47,13 +58,17 @@ contract SampleCrowdsale is CappedCrowdsale, RefundableCrowdsale, MintedCrowdsal
|
|||||||
uint256 goal
|
uint256 goal
|
||||||
)
|
)
|
||||||
public
|
public
|
||||||
Crowdsale(rate, wallet, token)
|
initializer
|
||||||
CappedCrowdsale(cap)
|
|
||||||
TimedCrowdsale(openingTime, closingTime)
|
|
||||||
RefundableCrowdsale(goal)
|
|
||||||
{
|
{
|
||||||
|
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
|
//As goal needs to be met for a successful crowdsale
|
||||||
//the value needs to less or equal than a cap which is limit for accepted funds
|
//the value needs to less or equal than a cap which is limit for accepted funds
|
||||||
require(goal <= cap);
|
require(goal <= cap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "../token/ERC20/ERC20.sol";
|
import "../token/ERC20/ERC20.sol";
|
||||||
|
|
||||||
|
|
||||||
@ -10,7 +11,7 @@ import "../token/ERC20/ERC20.sol";
|
|||||||
* Note they can later distribute these tokens as they wish using `transfer` and other
|
* Note they can later distribute these tokens as they wish using `transfer` and other
|
||||||
* `ERC20` functions.
|
* `ERC20` functions.
|
||||||
*/
|
*/
|
||||||
contract SimpleToken is ERC20 {
|
contract SimpleToken is Initializable, ERC20 {
|
||||||
|
|
||||||
string public constant name = "SimpleToken";
|
string public constant name = "SimpleToken";
|
||||||
string public constant symbol = "SIM";
|
string public constant symbol = "SIM";
|
||||||
@ -19,10 +20,12 @@ contract SimpleToken is ERC20 {
|
|||||||
uint256 public constant INITIAL_SUPPLY = 10000 * (10 ** uint256(decimals));
|
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 {
|
function initialize(address sender) public initializer {
|
||||||
_mint(msg.sender, INITIAL_SUPPLY);
|
_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,5 +1,6 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "./IERC165.sol";
|
import "./IERC165.sol";
|
||||||
|
|
||||||
|
|
||||||
@ -8,7 +9,7 @@ import "./IERC165.sol";
|
|||||||
* @author Matt Condon (@shrugs)
|
* @author Matt Condon (@shrugs)
|
||||||
* @dev Implements ERC165 using a lookup table.
|
* @dev Implements ERC165 using a lookup table.
|
||||||
*/
|
*/
|
||||||
contract ERC165 is IERC165 {
|
contract ERC165 is Initializable, IERC165 {
|
||||||
|
|
||||||
bytes4 private constant _InterfaceId_ERC165 = 0x01ffc9a7;
|
bytes4 private constant _InterfaceId_ERC165 = 0x01ffc9a7;
|
||||||
/**
|
/**
|
||||||
@ -25,8 +26,9 @@ contract ERC165 is IERC165 {
|
|||||||
* @dev A contract implementing SupportsInterfaceWithLookup
|
* @dev A contract implementing SupportsInterfaceWithLookup
|
||||||
* implement ERC165 itself
|
* implement ERC165 itself
|
||||||
*/
|
*/
|
||||||
constructor()
|
function initialize()
|
||||||
public
|
public
|
||||||
|
initializer
|
||||||
{
|
{
|
||||||
_registerInterface(_InterfaceId_ERC165);
|
_registerInterface(_InterfaceId_ERC165);
|
||||||
}
|
}
|
||||||
@ -35,7 +37,7 @@ contract ERC165 is IERC165 {
|
|||||||
* @dev implement supportsInterface(bytes4) using a lookup table
|
* @dev implement supportsInterface(bytes4) using a lookup table
|
||||||
*/
|
*/
|
||||||
function supportsInterface(bytes4 interfaceId)
|
function supportsInterface(bytes4 interfaceId)
|
||||||
external
|
public
|
||||||
view
|
view
|
||||||
returns (bool)
|
returns (bool)
|
||||||
{
|
{
|
||||||
@ -51,4 +53,6 @@ contract ERC165 is IERC165 {
|
|||||||
require(interfaceId != 0xffffffff);
|
require(interfaceId != 0xffffffff);
|
||||||
_supportedInterfaces[interfaceId] = true;
|
_supportedInterfaces[interfaceId] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "../access/roles/PauserRole.sol";
|
import "../access/roles/PauserRole.sol";
|
||||||
|
|
||||||
|
|
||||||
@ -7,12 +8,15 @@ import "../access/roles/PauserRole.sol";
|
|||||||
* @title Pausable
|
* @title Pausable
|
||||||
* @dev Base contract which allows children to implement an emergency stop mechanism.
|
* @dev Base contract which allows children to implement an emergency stop mechanism.
|
||||||
*/
|
*/
|
||||||
contract Pausable is PauserRole {
|
contract Pausable is Initializable, PauserRole {
|
||||||
event Paused();
|
event Paused();
|
||||||
event Unpaused();
|
event Unpaused();
|
||||||
|
|
||||||
bool private _paused = false;
|
bool private _paused = false;
|
||||||
|
|
||||||
|
function initialize(address sender) public initializer {
|
||||||
|
PauserRole.initialize(sender);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if the contract is paused, false otherwise.
|
* @return true if the contract is paused, false otherwise.
|
||||||
@ -52,4 +56,6 @@ contract Pausable is PauserRole {
|
|||||||
_paused = false;
|
_paused = false;
|
||||||
emit Unpaused();
|
emit Unpaused();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,9 +13,9 @@ contract AllowanceCrowdsaleImpl is AllowanceCrowdsale {
|
|||||||
address tokenWallet
|
address tokenWallet
|
||||||
)
|
)
|
||||||
public
|
public
|
||||||
Crowdsale(rate, wallet, token)
|
|
||||||
AllowanceCrowdsale(tokenWallet)
|
|
||||||
{
|
{
|
||||||
|
Crowdsale.initialize(rate, wallet, token);
|
||||||
|
AllowanceCrowdsale.initialize(tokenWallet);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,29 +0,0 @@
|
|||||||
pragma solidity ^0.4.24;
|
|
||||||
|
|
||||||
// When this line is split, truffle parsing fails.
|
|
||||||
// See: https://github.com/ethereum/solidity/issues/4871
|
|
||||||
// solium-disable-next-line max-len
|
|
||||||
import {BreakInvariantBounty, Target} from "../drafts/BreakInvariantBounty.sol";
|
|
||||||
|
|
||||||
|
|
||||||
contract TargetMock is Target {
|
|
||||||
bool private exploited;
|
|
||||||
|
|
||||||
function exploitVulnerability() public {
|
|
||||||
exploited = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkInvariant() public returns (bool) {
|
|
||||||
if (exploited) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
contract BreakInvariantBountyMock is BreakInvariantBounty {
|
|
||||||
function _deployContract() internal returns (address) {
|
|
||||||
return new TargetMock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -13,9 +13,9 @@ contract CappedCrowdsaleImpl is CappedCrowdsale {
|
|||||||
uint256 cap
|
uint256 cap
|
||||||
)
|
)
|
||||||
public
|
public
|
||||||
Crowdsale(rate, wallet, token)
|
|
||||||
CappedCrowdsale(cap)
|
|
||||||
{
|
{
|
||||||
|
Crowdsale.initialize(rate, wallet, token);
|
||||||
|
CappedCrowdsale.initialize(cap);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,10 @@ import "../access/roles/CapperRole.sol";
|
|||||||
|
|
||||||
|
|
||||||
contract CapperRoleMock is CapperRole {
|
contract CapperRoleMock is CapperRole {
|
||||||
|
constructor() public {
|
||||||
|
CapperRole.initialize(msg.sender);
|
||||||
|
}
|
||||||
|
|
||||||
function removeCapper(address account) public {
|
function removeCapper(address account) public {
|
||||||
_removeCapper(account);
|
_removeCapper(account);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
|
||||||
import "../payment/ConditionalEscrow.sol";
|
import "../payment/ConditionalEscrow.sol";
|
||||||
|
|
||||||
|
|
||||||
@ -8,6 +7,10 @@ import "../payment/ConditionalEscrow.sol";
|
|||||||
contract ConditionalEscrowMock is ConditionalEscrow {
|
contract ConditionalEscrowMock is ConditionalEscrow {
|
||||||
mapping(address => bool) private _allowed;
|
mapping(address => bool) private _allowed;
|
||||||
|
|
||||||
|
constructor() public {
|
||||||
|
ConditionalEscrow.initialize(msg.sender);
|
||||||
|
}
|
||||||
|
|
||||||
function setAllowed(address payee, bool allowed) public {
|
function setAllowed(address payee, bool allowed) public {
|
||||||
_allowed[payee] = allowed;
|
_allowed[payee] = allowed;
|
||||||
}
|
}
|
||||||
|
|||||||
10
contracts/mocks/CrowdsaleMock.sol
Normal file
10
contracts/mocks/CrowdsaleMock.sol
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "../crowdsale/Crowdsale.sol";
|
||||||
|
|
||||||
|
|
||||||
|
contract CrowdsaleMock is Crowdsale {
|
||||||
|
constructor(uint256 rate, address wallet, IERC20 token) public {
|
||||||
|
Crowdsale.initialize(rate, wallet, token);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -10,7 +10,8 @@ contract ERC20DetailedMock is ERC20, ERC20Detailed {
|
|||||||
string symbol,
|
string symbol,
|
||||||
uint8 decimals
|
uint8 decimals
|
||||||
)
|
)
|
||||||
ERC20Detailed(name, symbol, decimals)
|
|
||||||
public
|
public
|
||||||
{}
|
{
|
||||||
|
ERC20Detailed.initialize(name, symbol, decimals);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
|
||||||
import "../cryptography/ECDSA.sol";
|
import "../cryptography/ECDSA.sol";
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,10 @@ import "../introspection/ERC165.sol";
|
|||||||
|
|
||||||
|
|
||||||
contract ERC165Mock is ERC165 {
|
contract ERC165Mock is ERC165 {
|
||||||
|
constructor() public {
|
||||||
|
ERC165.initialize();
|
||||||
|
}
|
||||||
|
|
||||||
function registerInterface(bytes4 interfaceId)
|
function registerInterface(bytes4 interfaceId)
|
||||||
public
|
public
|
||||||
{
|
{
|
||||||
|
|||||||
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -5,4 +5,8 @@ import "./MinterRoleMock.sol";
|
|||||||
|
|
||||||
|
|
||||||
contract ERC20MintableMock is ERC20Mintable, MinterRoleMock {
|
contract ERC20MintableMock is ERC20Mintable, MinterRoleMock {
|
||||||
|
|
||||||
|
constructor() public {
|
||||||
|
ERC20Mintable.initialize(msg.sender);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,6 +8,8 @@ import "./PauserRoleMock.sol";
|
|||||||
contract ERC20PausableMock is ERC20Pausable, PauserRoleMock {
|
contract ERC20PausableMock is ERC20Pausable, PauserRoleMock {
|
||||||
|
|
||||||
constructor(address initialAccount, uint initialBalance) public {
|
constructor(address initialAccount, uint initialBalance) public {
|
||||||
|
ERC20Pausable.initialize(msg.sender);
|
||||||
|
|
||||||
_mint(initialAccount, initialBalance);
|
_mint(initialAccount, initialBalance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,8 +5,7 @@ import "../drafts/ERC1046/TokenMetadata.sol";
|
|||||||
|
|
||||||
|
|
||||||
contract ERC20WithMetadataMock is ERC20, ERC20WithMetadata {
|
contract ERC20WithMetadataMock is ERC20, ERC20WithMetadata {
|
||||||
constructor(string tokenURI) public
|
constructor(string tokenURI) public {
|
||||||
ERC20WithMetadata(tokenURI)
|
ERC20WithMetadata.initialize(tokenURI);
|
||||||
{
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,13 +11,15 @@ import "../token/ERC721/ERC721Burnable.sol";
|
|||||||
* This mock just provides a public mint and burn functions for testing purposes,
|
* This mock just provides a public mint and burn functions for testing purposes,
|
||||||
* and a public setter for metadata URI
|
* and a public setter for metadata URI
|
||||||
*/
|
*/
|
||||||
contract ERC721FullMock
|
contract ERC721FullMock is ERC721Full, ERC721Mintable, ERC721MetadataMintable, ERC721Burnable {
|
||||||
is ERC721Full, ERC721Mintable, ERC721MetadataMintable, ERC721Burnable {
|
|
||||||
|
|
||||||
constructor(string name, string symbol) public
|
constructor(string name, string symbol) public
|
||||||
ERC721Mintable()
|
{
|
||||||
ERC721Full(name, symbol)
|
ERC721.initialize();
|
||||||
{}
|
ERC721Metadata.initialize(name, symbol);
|
||||||
|
ERC721Enumerable.initialize();
|
||||||
|
ERC721Mintable.initialize(msg.sender);
|
||||||
|
ERC721MetadataMintable.initialize(msg.sender);
|
||||||
|
}
|
||||||
|
|
||||||
function exists(uint256 tokenId) public view returns (bool) {
|
function exists(uint256 tokenId) public view returns (bool) {
|
||||||
return _exists(tokenId);
|
return _exists(tokenId);
|
||||||
|
|||||||
@ -13,9 +13,12 @@ contract ERC721MintableBurnableImpl
|
|||||||
is ERC721Full, ERC721Mintable, ERC721MetadataMintable, ERC721Burnable {
|
is ERC721Full, ERC721Mintable, ERC721MetadataMintable, ERC721Burnable {
|
||||||
|
|
||||||
constructor()
|
constructor()
|
||||||
ERC721Mintable()
|
|
||||||
ERC721Full("Test", "TEST")
|
|
||||||
public
|
public
|
||||||
{
|
{
|
||||||
|
ERC721.initialize();
|
||||||
|
ERC721Metadata.initialize("Test", "TEST");
|
||||||
|
ERC721Enumerable.initialize();
|
||||||
|
ERC721Mintable.initialize(msg.sender);
|
||||||
|
ERC721MetadataMintable.initialize(msg.sender);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,6 +8,10 @@ import "../token/ERC721/ERC721.sol";
|
|||||||
* This mock just provides a public mint and burn functions for testing purposes
|
* This mock just provides a public mint and burn functions for testing purposes
|
||||||
*/
|
*/
|
||||||
contract ERC721Mock is ERC721 {
|
contract ERC721Mock is ERC721 {
|
||||||
|
constructor() public {
|
||||||
|
ERC721.initialize();
|
||||||
|
}
|
||||||
|
|
||||||
function mint(address to, uint256 tokenId) public {
|
function mint(address to, uint256 tokenId) public {
|
||||||
_mint(to, tokenId);
|
_mint(to, tokenId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,11 @@ import "./PauserRoleMock.sol";
|
|||||||
* This mock just provides a public mint, burn and exists functions for testing purposes
|
* This mock just provides a public mint, burn and exists functions for testing purposes
|
||||||
*/
|
*/
|
||||||
contract ERC721PausableMock is ERC721Pausable, PauserRoleMock {
|
contract ERC721PausableMock is ERC721Pausable, PauserRoleMock {
|
||||||
|
constructor() {
|
||||||
|
ERC721.initialize();
|
||||||
|
ERC721Pausable.initialize(msg.sender);
|
||||||
|
}
|
||||||
|
|
||||||
function mint(address to, uint256 tokenId) public {
|
function mint(address to, uint256 tokenId) public {
|
||||||
super._mint(to, tokenId);
|
super._mint(to, tokenId);
|
||||||
}
|
}
|
||||||
|
|||||||
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -14,9 +14,9 @@ contract FinalizableCrowdsaleImpl is FinalizableCrowdsale {
|
|||||||
IERC20 token
|
IERC20 token
|
||||||
)
|
)
|
||||||
public
|
public
|
||||||
Crowdsale(rate, wallet, token)
|
|
||||||
TimedCrowdsale(openingTime, closingTime)
|
|
||||||
{
|
{
|
||||||
|
Crowdsale.initialize(rate, wallet, token);
|
||||||
|
TimedCrowdsale.initialize(openingTime, closingTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,10 +15,10 @@ contract IncreasingPriceCrowdsaleImpl is IncreasingPriceCrowdsale {
|
|||||||
uint256 finalRate
|
uint256 finalRate
|
||||||
)
|
)
|
||||||
public
|
public
|
||||||
Crowdsale(initialRate, wallet, token)
|
|
||||||
TimedCrowdsale(openingTime, closingTime)
|
|
||||||
IncreasingPriceCrowdsale(initialRate, finalRate)
|
|
||||||
{
|
{
|
||||||
|
Crowdsale.initialize(initialRate, wallet, token);
|
||||||
|
TimedCrowdsale.initialize(openingTime, closingTime);
|
||||||
|
IncreasingPriceCrowdsale.initialize(initialRate, finalRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import "./CapperRoleMock.sol";
|
|||||||
|
|
||||||
|
|
||||||
contract IndividuallyCappedCrowdsaleImpl
|
contract IndividuallyCappedCrowdsaleImpl
|
||||||
is IndividuallyCappedCrowdsale, CapperRoleMock {
|
is Crowdsale, IndividuallyCappedCrowdsale, CapperRoleMock {
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
uint256 rate,
|
uint256 rate,
|
||||||
@ -14,7 +14,8 @@ contract IndividuallyCappedCrowdsaleImpl
|
|||||||
IERC20 token
|
IERC20 token
|
||||||
)
|
)
|
||||||
public
|
public
|
||||||
Crowdsale(rate, wallet, token)
|
|
||||||
{
|
{
|
||||||
|
Crowdsale.initialize(rate, wallet, token);
|
||||||
|
IndividuallyCappedCrowdsale.initialize(msg.sender);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,8 +12,8 @@ contract MintedCrowdsaleImpl is MintedCrowdsale {
|
|||||||
ERC20Mintable token
|
ERC20Mintable token
|
||||||
)
|
)
|
||||||
public
|
public
|
||||||
Crowdsale(rate, wallet, token)
|
|
||||||
{
|
{
|
||||||
|
Crowdsale.initialize(rate, wallet, token);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,10 @@ import "../access/roles/MinterRole.sol";
|
|||||||
|
|
||||||
|
|
||||||
contract MinterRoleMock is MinterRole {
|
contract MinterRoleMock is MinterRole {
|
||||||
|
constructor() public {
|
||||||
|
MinterRole.initialize(msg.sender);
|
||||||
|
}
|
||||||
|
|
||||||
function removeMinter(address account) public {
|
function removeMinter(address account) public {
|
||||||
_removeMinter(account);
|
_removeMinter(account);
|
||||||
}
|
}
|
||||||
|
|||||||
9
contracts/mocks/OwnableMock.sol
Normal file
9
contracts/mocks/OwnableMock.sol
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import { Ownable } from "../ownership/Ownable.sol";
|
||||||
|
|
||||||
|
contract OwnableMock is Ownable {
|
||||||
|
constructor() {
|
||||||
|
Ownable.initialize(msg.sender);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,6 +1,5 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
|
||||||
import "../lifecycle/Pausable.sol";
|
import "../lifecycle/Pausable.sol";
|
||||||
import "./PauserRoleMock.sol";
|
import "./PauserRoleMock.sol";
|
||||||
|
|
||||||
@ -11,6 +10,8 @@ contract PausableMock is Pausable, PauserRoleMock {
|
|||||||
uint256 public count;
|
uint256 public count;
|
||||||
|
|
||||||
constructor() public {
|
constructor() public {
|
||||||
|
Pausable.initialize(msg.sender);
|
||||||
|
|
||||||
drasticMeasureTaken = false;
|
drasticMeasureTaken = false;
|
||||||
count = 0;
|
count = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,10 @@ import "../access/roles/PauserRole.sol";
|
|||||||
|
|
||||||
|
|
||||||
contract PauserRoleMock is PauserRole {
|
contract PauserRoleMock is PauserRole {
|
||||||
|
constructor() public {
|
||||||
|
PauserRole.initialize(msg.sender);
|
||||||
|
}
|
||||||
|
|
||||||
function removePauser(address account) public {
|
function removePauser(address account) public {
|
||||||
_removePauser(account);
|
_removePauser(account);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,9 +14,9 @@ contract PostDeliveryCrowdsaleImpl is PostDeliveryCrowdsale {
|
|||||||
IERC20 token
|
IERC20 token
|
||||||
)
|
)
|
||||||
public
|
public
|
||||||
TimedCrowdsale(openingTime, closingTime)
|
|
||||||
Crowdsale(rate, wallet, token)
|
|
||||||
{
|
{
|
||||||
|
Crowdsale.initialize(rate, wallet, token);
|
||||||
|
TimedCrowdsale.initialize(openingTime, closingTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,7 +7,9 @@ import "../payment/PullPayment.sol";
|
|||||||
// mock class using PullPayment
|
// mock class using PullPayment
|
||||||
contract PullPaymentMock is PullPayment {
|
contract PullPaymentMock is PullPayment {
|
||||||
|
|
||||||
constructor() public payable { }
|
constructor() public payable {
|
||||||
|
PullPayment.initialize();
|
||||||
|
}
|
||||||
|
|
||||||
// test helper function to call asyncTransfer
|
// test helper function to call asyncTransfer
|
||||||
function callTransfer(address dest, uint256 amount) public {
|
function callTransfer(address dest, uint256 amount) public {
|
||||||
|
|||||||
@ -9,6 +9,7 @@ contract ReentrancyMock is ReentrancyGuard {
|
|||||||
uint256 public counter;
|
uint256 public counter;
|
||||||
|
|
||||||
constructor() public {
|
constructor() public {
|
||||||
|
ReentrancyGuard.initialize();
|
||||||
counter = 0;
|
counter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -4,7 +4,7 @@ import "../token/ERC20/ERC20Mintable.sol";
|
|||||||
import "../crowdsale/distribution/RefundableCrowdsale.sol";
|
import "../crowdsale/distribution/RefundableCrowdsale.sol";
|
||||||
|
|
||||||
|
|
||||||
contract RefundableCrowdsaleImpl is RefundableCrowdsale {
|
contract RefundableCrowdsaleImpl is Crowdsale, TimedCrowdsale, RefundableCrowdsale {
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
uint256 openingTime,
|
uint256 openingTime,
|
||||||
@ -15,10 +15,10 @@ contract RefundableCrowdsaleImpl is RefundableCrowdsale {
|
|||||||
uint256 goal
|
uint256 goal
|
||||||
)
|
)
|
||||||
public
|
public
|
||||||
Crowdsale(rate, wallet, token)
|
|
||||||
TimedCrowdsale(openingTime, closingTime)
|
|
||||||
RefundableCrowdsale(goal)
|
|
||||||
{
|
{
|
||||||
|
Crowdsale.initialize(rate, wallet, token);
|
||||||
|
TimedCrowdsale.initialize(openingTime, closingTime);
|
||||||
|
RefundableCrowdsale.initialize(goal);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
26
contracts/mocks/SampleCrowdsaleMock.sol
Normal file
26
contracts/mocks/SampleCrowdsaleMock.sol
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "../examples/SampleCrowdsale.sol";
|
||||||
|
|
||||||
|
|
||||||
|
contract SampleCrowdsaleTokenMock is SampleCrowdsaleToken {
|
||||||
|
constructor() public {
|
||||||
|
SampleCrowdsaleToken.initialize(msg.sender);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
contract SampleCrowdsaleMock is SampleCrowdsale {
|
||||||
|
constructor(
|
||||||
|
uint256 openingTime,
|
||||||
|
uint256 closingTime,
|
||||||
|
uint256 rate,
|
||||||
|
address wallet,
|
||||||
|
uint256 cap,
|
||||||
|
ERC20Mintable token,
|
||||||
|
uint256 goal
|
||||||
|
)
|
||||||
|
public
|
||||||
|
{
|
||||||
|
SampleCrowdsale.initialize(openingTime, closingTime, rate, wallet, cap, token, goal);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -4,6 +4,10 @@ import "../ownership/Secondary.sol";
|
|||||||
|
|
||||||
|
|
||||||
contract SecondaryMock is Secondary {
|
contract SecondaryMock is Secondary {
|
||||||
|
constructor() public {
|
||||||
|
Secondary.initialize(msg.sender);
|
||||||
|
}
|
||||||
|
|
||||||
function onlyPrimaryMock() public view onlyPrimary {
|
function onlyPrimaryMock() public view onlyPrimary {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,10 @@ import "./SignerRoleMock.sol";
|
|||||||
|
|
||||||
|
|
||||||
contract SignatureBouncerMock is SignatureBouncer, SignerRoleMock {
|
contract SignatureBouncerMock is SignatureBouncer, SignerRoleMock {
|
||||||
|
constructor() public {
|
||||||
|
SignatureBouncer.initialize(msg.sender);
|
||||||
|
}
|
||||||
|
|
||||||
function checkValidSignature(address account, bytes signature)
|
function checkValidSignature(address account, bytes signature)
|
||||||
public
|
public
|
||||||
view
|
view
|
||||||
|
|||||||
@ -4,6 +4,10 @@ import "../access/roles/SignerRole.sol";
|
|||||||
|
|
||||||
|
|
||||||
contract SignerRoleMock is SignerRole {
|
contract SignerRoleMock is SignerRole {
|
||||||
|
constructor() public {
|
||||||
|
SignerRole.initialize(msg.sender);
|
||||||
|
}
|
||||||
|
|
||||||
function removeSigner(address account) public {
|
function removeSigner(address account) public {
|
||||||
_removeSigner(account);
|
_removeSigner(account);
|
||||||
}
|
}
|
||||||
|
|||||||
9
contracts/mocks/SimpleTokenMock.sol
Normal file
9
contracts/mocks/SimpleTokenMock.sol
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "../examples/SimpleToken.sol";
|
||||||
|
|
||||||
|
contract SimpleTokenMock is SimpleToken {
|
||||||
|
constructor() public {
|
||||||
|
SimpleToken.initialize(msg.sender);
|
||||||
|
}
|
||||||
|
}
|
||||||
9
contracts/mocks/SplitPaymentMock.sol
Normal file
9
contracts/mocks/SplitPaymentMock.sol
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "../payment/SplitPayment.sol";
|
||||||
|
|
||||||
|
contract SplitPaymentMock is SplitPayment {
|
||||||
|
constructor(address[] payees, uint256[] shares) public {
|
||||||
|
SplitPayment.initialize(payees, shares);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -14,9 +14,9 @@ contract TimedCrowdsaleImpl is TimedCrowdsale {
|
|||||||
IERC20 token
|
IERC20 token
|
||||||
)
|
)
|
||||||
public
|
public
|
||||||
Crowdsale(rate, wallet, token)
|
|
||||||
TimedCrowdsale(openingTime, closingTime)
|
|
||||||
{
|
{
|
||||||
|
Crowdsale.initialize(rate, wallet, token);
|
||||||
|
TimedCrowdsale.initialize(openingTime, closingTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
13
contracts/mocks/TokenTimelockMock.sol
Normal file
13
contracts/mocks/TokenTimelockMock.sol
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "../token/ERC20/TokenTimelock.sol";
|
||||||
|
|
||||||
|
contract TokenTimelockMock is TokenTimelock {
|
||||||
|
constructor(
|
||||||
|
IERC20 token,
|
||||||
|
address beneficiary,
|
||||||
|
uint256 releaseTime
|
||||||
|
) public {
|
||||||
|
TokenTimelock.initialize(token, beneficiary, releaseTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
22
contracts/mocks/TokenVestingMock.sol
Normal file
22
contracts/mocks/TokenVestingMock.sol
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "../drafts/TokenVesting.sol";
|
||||||
|
|
||||||
|
contract TokenVestingMock is TokenVesting {
|
||||||
|
constructor(
|
||||||
|
address beneficiary,
|
||||||
|
uint256 start,
|
||||||
|
uint256 cliffDuration,
|
||||||
|
uint256 duration,
|
||||||
|
bool revocable
|
||||||
|
) public {
|
||||||
|
TokenVesting.initialize(
|
||||||
|
beneficiary,
|
||||||
|
start,
|
||||||
|
cliffDuration,
|
||||||
|
duration,
|
||||||
|
revocable,
|
||||||
|
msg.sender
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,12 +1,13 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @title Ownable
|
* @title Ownable
|
||||||
* @dev The Ownable contract has an owner address, and provides basic authorization control
|
* @dev The Ownable contract has an owner address, and provides basic authorization control
|
||||||
* functions, this simplifies the implementation of "user permissions".
|
* functions, this simplifies the implementation of "user permissions".
|
||||||
*/
|
*/
|
||||||
contract Ownable {
|
contract Ownable is Initializable {
|
||||||
address private _owner;
|
address private _owner;
|
||||||
|
|
||||||
|
|
||||||
@ -21,8 +22,8 @@ contract Ownable {
|
|||||||
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
|
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
|
||||||
* account.
|
* account.
|
||||||
*/
|
*/
|
||||||
constructor() public {
|
function initialize(address sender) public initializer {
|
||||||
_owner = msg.sender;
|
_owner = sender;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -75,4 +76,6 @@ contract Ownable {
|
|||||||
emit OwnershipTransferred(_owner, newOwner);
|
emit OwnershipTransferred(_owner, newOwner);
|
||||||
_owner = newOwner;
|
_owner = newOwner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,18 +1,19 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @title Secondary
|
* @title Secondary
|
||||||
* @dev A Secondary contract can only be used by its primary account (the one that created it)
|
* @dev A Secondary contract can only be used by its primary account (the one that created it)
|
||||||
*/
|
*/
|
||||||
contract Secondary {
|
contract Secondary is Initializable {
|
||||||
address private _primary;
|
address private _primary;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Sets the primary account to the one that is creating the Secondary contract.
|
* @dev Sets the primary account to the one that is creating the Secondary contract.
|
||||||
*/
|
*/
|
||||||
constructor() public {
|
function initialize(address sender) public initializer {
|
||||||
_primary = msg.sender;
|
_primary = sender;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -32,4 +33,6 @@ contract Secondary {
|
|||||||
|
|
||||||
_primary = recipient;
|
_primary = recipient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "./Escrow.sol";
|
import "./Escrow.sol";
|
||||||
|
|
||||||
|
|
||||||
@ -7,7 +8,11 @@ import "./Escrow.sol";
|
|||||||
* @title ConditionalEscrow
|
* @title ConditionalEscrow
|
||||||
* @dev Base abstract escrow to only allow withdrawal if a condition is met.
|
* @dev Base abstract escrow to only allow withdrawal if a condition is met.
|
||||||
*/
|
*/
|
||||||
contract ConditionalEscrow is Escrow {
|
contract ConditionalEscrow is Initializable, Escrow {
|
||||||
|
function initialize(address sender) public initializer {
|
||||||
|
Escrow.initialize(sender);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Returns whether an address is allowed to withdraw their funds. To be
|
* @dev Returns whether an address is allowed to withdraw their funds. To be
|
||||||
* implemented by derived contracts.
|
* implemented by derived contracts.
|
||||||
@ -19,4 +24,6 @@ contract ConditionalEscrow is Escrow {
|
|||||||
require(withdrawalAllowed(payee));
|
require(withdrawalAllowed(payee));
|
||||||
super.withdraw(payee);
|
super.withdraw(payee);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "../math/SafeMath.sol";
|
import "../math/SafeMath.sol";
|
||||||
import "../ownership/Secondary.sol";
|
import "../ownership/Secondary.sol";
|
||||||
|
|
||||||
@ -11,7 +12,7 @@ import "../ownership/Secondary.sol";
|
|||||||
* should be its primary, and provide public methods redirecting to the escrow's
|
* should be its primary, and provide public methods redirecting to the escrow's
|
||||||
* deposit and withdraw.
|
* deposit and withdraw.
|
||||||
*/
|
*/
|
||||||
contract Escrow is Secondary {
|
contract Escrow is Initializable, Secondary {
|
||||||
using SafeMath for uint256;
|
using SafeMath for uint256;
|
||||||
|
|
||||||
event Deposited(address indexed payee, uint256 weiAmount);
|
event Deposited(address indexed payee, uint256 weiAmount);
|
||||||
@ -19,6 +20,10 @@ contract Escrow is Secondary {
|
|||||||
|
|
||||||
mapping(address => uint256) private _deposits;
|
mapping(address => uint256) private _deposits;
|
||||||
|
|
||||||
|
function initialize(address sender) public initializer {
|
||||||
|
Secondary.initialize(sender);
|
||||||
|
}
|
||||||
|
|
||||||
function depositsOf(address payee) public view returns (uint256) {
|
function depositsOf(address payee) public view returns (uint256) {
|
||||||
return _deposits[payee];
|
return _deposits[payee];
|
||||||
}
|
}
|
||||||
@ -47,4 +52,6 @@ contract Escrow is Secondary {
|
|||||||
|
|
||||||
emit Withdrawn(payee, payment);
|
emit Withdrawn(payee, payment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "./Escrow.sol";
|
import "./Escrow.sol";
|
||||||
|
|
||||||
|
|
||||||
@ -8,11 +9,15 @@ import "./Escrow.sol";
|
|||||||
* @dev Base contract supporting async send for pull payments. Inherit from this
|
* @dev Base contract supporting async send for pull payments. Inherit from this
|
||||||
* contract and use _asyncTransfer instead of send or transfer.
|
* contract and use _asyncTransfer instead of send or transfer.
|
||||||
*/
|
*/
|
||||||
contract PullPayment {
|
contract PullPayment is Initializable {
|
||||||
Escrow private _escrow;
|
Escrow private _escrow;
|
||||||
|
|
||||||
constructor() public {
|
function initialize() public initializer {
|
||||||
_escrow = new Escrow();
|
// conditional added to make initializer idempotent in case of diamond inheritance
|
||||||
|
if (address(_escrow) == address(0)) {
|
||||||
|
_escrow = new Escrow();
|
||||||
|
_escrow.initialize(address(this));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -39,4 +44,6 @@ contract PullPayment {
|
|||||||
function _asyncTransfer(address dest, uint256 amount) internal {
|
function _asyncTransfer(address dest, uint256 amount) internal {
|
||||||
_escrow.deposit.value(amount)(dest);
|
_escrow.deposit.value(amount)(dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "./ConditionalEscrow.sol";
|
import "./ConditionalEscrow.sol";
|
||||||
|
|
||||||
|
|
||||||
@ -9,7 +10,7 @@ import "./ConditionalEscrow.sol";
|
|||||||
* The primary account may close the deposit period, and allow for either withdrawal
|
* The primary account may close the deposit period, and allow for either withdrawal
|
||||||
* by the beneficiary, or refunds to the depositors.
|
* by the beneficiary, or refunds to the depositors.
|
||||||
*/
|
*/
|
||||||
contract RefundEscrow is ConditionalEscrow {
|
contract RefundEscrow is Initializable, ConditionalEscrow {
|
||||||
enum State { Active, Refunding, Closed }
|
enum State { Active, Refunding, Closed }
|
||||||
|
|
||||||
event Closed();
|
event Closed();
|
||||||
@ -22,7 +23,9 @@ contract RefundEscrow is ConditionalEscrow {
|
|||||||
* @dev Constructor.
|
* @dev Constructor.
|
||||||
* @param beneficiary The beneficiary of the deposits.
|
* @param beneficiary The beneficiary of the deposits.
|
||||||
*/
|
*/
|
||||||
constructor(address beneficiary) public {
|
function initialize(address beneficiary, address sender) public initializer {
|
||||||
|
ConditionalEscrow.initialize(sender);
|
||||||
|
|
||||||
require(beneficiary != address(0));
|
require(beneficiary != address(0));
|
||||||
_beneficiary = beneficiary;
|
_beneficiary = beneficiary;
|
||||||
_state = State.Active;
|
_state = State.Active;
|
||||||
@ -84,4 +87,6 @@ contract RefundEscrow is ConditionalEscrow {
|
|||||||
function withdrawalAllowed(address payee) public view returns (bool) {
|
function withdrawalAllowed(address payee) public view returns (bool) {
|
||||||
return _state == State.Refunding;
|
return _state == State.Refunding;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "../math/SafeMath.sol";
|
import "../math/SafeMath.sol";
|
||||||
|
|
||||||
|
|
||||||
@ -8,11 +9,11 @@ import "../math/SafeMath.sol";
|
|||||||
* @dev This contract can be used when payments need to be received by a group
|
* @dev This contract can be used when payments need to be received by a group
|
||||||
* of people and split proportionately to some number of shares they own.
|
* of people and split proportionately to some number of shares they own.
|
||||||
*/
|
*/
|
||||||
contract SplitPayment {
|
contract SplitPayment is Initializable {
|
||||||
using SafeMath for uint256;
|
using SafeMath for uint256;
|
||||||
|
|
||||||
uint256 private _totalShares = 0;
|
uint256 private _totalShares;
|
||||||
uint256 private _totalReleased = 0;
|
uint256 private _totalReleased;
|
||||||
|
|
||||||
mapping(address => uint256) private _shares;
|
mapping(address => uint256) private _shares;
|
||||||
mapping(address => uint256) private _released;
|
mapping(address => uint256) private _released;
|
||||||
@ -21,7 +22,7 @@ contract SplitPayment {
|
|||||||
/**
|
/**
|
||||||
* @dev Constructor
|
* @dev Constructor
|
||||||
*/
|
*/
|
||||||
constructor(address[] payees, uint256[] shares) public payable {
|
function initialize(address[] payees, uint256[] shares) public payable initializer {
|
||||||
require(payees.length == shares.length);
|
require(payees.length == shares.length);
|
||||||
require(payees.length > 0);
|
require(payees.length > 0);
|
||||||
|
|
||||||
@ -106,4 +107,6 @@ contract SplitPayment {
|
|||||||
_shares[account] = shares_;
|
_shares[account] = shares_;
|
||||||
_totalShares = _totalShares.add(shares_);
|
_totalShares = _totalShares.add(shares_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "./IERC20.sol";
|
import "./IERC20.sol";
|
||||||
import "../../math/SafeMath.sol";
|
import "../../math/SafeMath.sol";
|
||||||
|
|
||||||
@ -11,7 +12,7 @@ import "../../math/SafeMath.sol";
|
|||||||
* https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md
|
* https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md
|
||||||
* Originally based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
|
* Originally based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
|
||||||
*/
|
*/
|
||||||
contract ERC20 is IERC20 {
|
contract ERC20 is Initializable, IERC20 {
|
||||||
using SafeMath for uint256;
|
using SafeMath for uint256;
|
||||||
|
|
||||||
mapping (address => uint256) private _balances;
|
mapping (address => uint256) private _balances;
|
||||||
@ -209,4 +210,6 @@ contract ERC20 is IERC20 {
|
|||||||
amount);
|
amount);
|
||||||
_burn(account, amount);
|
_burn(account, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "./ERC20.sol";
|
import "./ERC20.sol";
|
||||||
|
|
||||||
|
|
||||||
@ -7,7 +8,7 @@ import "./ERC20.sol";
|
|||||||
* @title Burnable Token
|
* @title Burnable Token
|
||||||
* @dev Token that can be irreversibly burned (destroyed).
|
* @dev Token that can be irreversibly burned (destroyed).
|
||||||
*/
|
*/
|
||||||
contract ERC20Burnable is ERC20 {
|
contract ERC20Burnable is Initializable, ERC20 {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Burns a specific amount of tokens.
|
* @dev Burns a specific amount of tokens.
|
||||||
@ -25,4 +26,6 @@ contract ERC20Burnable is ERC20 {
|
|||||||
function burnFrom(address from, uint256 value) public {
|
function burnFrom(address from, uint256 value) public {
|
||||||
_burnFrom(from, value);
|
_burnFrom(from, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "./ERC20Mintable.sol";
|
import "./ERC20Mintable.sol";
|
||||||
|
|
||||||
|
|
||||||
@ -7,13 +8,16 @@ import "./ERC20Mintable.sol";
|
|||||||
* @title Capped token
|
* @title Capped token
|
||||||
* @dev Mintable token with a token cap.
|
* @dev Mintable token with a token cap.
|
||||||
*/
|
*/
|
||||||
contract ERC20Capped is ERC20Mintable {
|
contract ERC20Capped is Initializable, ERC20Mintable {
|
||||||
|
|
||||||
uint256 private _cap;
|
uint256 private _cap;
|
||||||
|
|
||||||
constructor(uint256 cap)
|
function initialize(uint256 cap, address sender)
|
||||||
public
|
public
|
||||||
|
initializer
|
||||||
{
|
{
|
||||||
|
ERC20Mintable.initialize(sender);
|
||||||
|
|
||||||
require(cap > 0);
|
require(cap > 0);
|
||||||
_cap = cap;
|
_cap = cap;
|
||||||
}
|
}
|
||||||
@ -43,4 +47,6 @@ contract ERC20Capped is ERC20Mintable {
|
|||||||
return super.mint(to, amount);
|
return super.mint(to, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "./IERC20.sol";
|
import "./IERC20.sol";
|
||||||
|
|
||||||
|
|
||||||
@ -9,12 +10,12 @@ import "./IERC20.sol";
|
|||||||
* All the operations are done using the smallest and indivisible token unit,
|
* All the operations are done using the smallest and indivisible token unit,
|
||||||
* just as on Ethereum all the operations are done in wei.
|
* just as on Ethereum all the operations are done in wei.
|
||||||
*/
|
*/
|
||||||
contract ERC20Detailed is IERC20 {
|
contract ERC20Detailed is Initializable, IERC20 {
|
||||||
string private _name;
|
string private _name;
|
||||||
string private _symbol;
|
string private _symbol;
|
||||||
uint8 private _decimals;
|
uint8 private _decimals;
|
||||||
|
|
||||||
constructor(string name, string symbol, uint8 decimals) public {
|
function initialize(string name, string symbol, uint8 decimals) public initializer {
|
||||||
_name = name;
|
_name = name;
|
||||||
_symbol = symbol;
|
_symbol = symbol;
|
||||||
_decimals = decimals;
|
_decimals = decimals;
|
||||||
@ -40,4 +41,6 @@ contract ERC20Detailed is IERC20 {
|
|||||||
function decimals() public view returns(uint8) {
|
function decimals() public view returns(uint8) {
|
||||||
return _decimals;
|
return _decimals;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "./ERC20.sol";
|
import "./ERC20.sol";
|
||||||
import "../../access/roles/MinterRole.sol";
|
import "../../access/roles/MinterRole.sol";
|
||||||
|
|
||||||
@ -8,7 +9,11 @@ import "../../access/roles/MinterRole.sol";
|
|||||||
* @title ERC20Mintable
|
* @title ERC20Mintable
|
||||||
* @dev ERC20 minting logic
|
* @dev ERC20 minting logic
|
||||||
*/
|
*/
|
||||||
contract ERC20Mintable is ERC20, MinterRole {
|
contract ERC20Mintable is Initializable, ERC20, MinterRole {
|
||||||
|
function initialize(address sender) public initializer {
|
||||||
|
MinterRole.initialize(sender);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Function to mint tokens
|
* @dev Function to mint tokens
|
||||||
* @param to The address that will receive the minted tokens.
|
* @param to The address that will receive the minted tokens.
|
||||||
@ -26,4 +31,6 @@ contract ERC20Mintable is ERC20, MinterRole {
|
|||||||
_mint(to, amount);
|
_mint(to, amount);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "./ERC20.sol";
|
import "./ERC20.sol";
|
||||||
import "../../lifecycle/Pausable.sol";
|
import "../../lifecycle/Pausable.sol";
|
||||||
|
|
||||||
@ -8,7 +9,11 @@ import "../../lifecycle/Pausable.sol";
|
|||||||
* @title Pausable token
|
* @title Pausable token
|
||||||
* @dev ERC20 modified with pausable transfers.
|
* @dev ERC20 modified with pausable transfers.
|
||||||
**/
|
**/
|
||||||
contract ERC20Pausable is ERC20, Pausable {
|
contract ERC20Pausable is Initializable, ERC20, Pausable {
|
||||||
|
|
||||||
|
function initialize(address sender) public initializer {
|
||||||
|
Pausable.initialize(sender);
|
||||||
|
}
|
||||||
|
|
||||||
function transfer(
|
function transfer(
|
||||||
address to,
|
address to,
|
||||||
@ -65,4 +70,6 @@ contract ERC20Pausable is ERC20, Pausable {
|
|||||||
{
|
{
|
||||||
return super.decreaseAllowance(spender, subtractedValue);
|
return super.decreaseAllowance(spender, subtractedValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
65
contracts/token/ERC20/StandaloneERC20.sol
Normal file
65
contracts/token/ERC20/StandaloneERC20.sol
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
|
import "./ERC20Detailed.sol";
|
||||||
|
import "./ERC20Mintable.sol";
|
||||||
|
import "./ERC20Pausable.sol";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @title Standard ERC20 token, with minting and pause functionality.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
contract StandaloneERC20 is Initializable, ERC20Detailed, ERC20Mintable, ERC20Pausable {
|
||||||
|
function initialize(
|
||||||
|
string name, string symbol, uint8 decimals, uint256 initialSupply, address initialHolder,
|
||||||
|
address[] minters, address[] pausers
|
||||||
|
) public initializer {
|
||||||
|
require(initialSupply > 0);
|
||||||
|
|
||||||
|
ERC20Detailed.initialize(name, symbol, decimals);
|
||||||
|
|
||||||
|
// Mint the 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]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function initialize(
|
||||||
|
string name, string symbol, uint8 decimals, address[] minters, address[] pausers
|
||||||
|
) public initializer {
|
||||||
|
ERC20Detailed.initialize(name, symbol, decimals);
|
||||||
|
|
||||||
|
// 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,5 +1,6 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "./SafeERC20.sol";
|
import "./SafeERC20.sol";
|
||||||
|
|
||||||
|
|
||||||
@ -8,7 +9,7 @@ import "./SafeERC20.sol";
|
|||||||
* @dev TokenTimelock is a token holder contract that will allow a
|
* @dev TokenTimelock is a token holder contract that will allow a
|
||||||
* beneficiary to extract the tokens after a given release time
|
* beneficiary to extract the tokens after a given release time
|
||||||
*/
|
*/
|
||||||
contract TokenTimelock {
|
contract TokenTimelock is Initializable {
|
||||||
using SafeERC20 for IERC20;
|
using SafeERC20 for IERC20;
|
||||||
|
|
||||||
// ERC20 basic token contract being held
|
// ERC20 basic token contract being held
|
||||||
@ -20,12 +21,13 @@ contract TokenTimelock {
|
|||||||
// timestamp when token release is enabled
|
// timestamp when token release is enabled
|
||||||
uint256 private _releaseTime;
|
uint256 private _releaseTime;
|
||||||
|
|
||||||
constructor(
|
function initialize(
|
||||||
IERC20 token,
|
IERC20 token,
|
||||||
address beneficiary,
|
address beneficiary,
|
||||||
uint256 releaseTime
|
uint256 releaseTime
|
||||||
)
|
)
|
||||||
public
|
public
|
||||||
|
initializer
|
||||||
{
|
{
|
||||||
// solium-disable-next-line security/no-block-members
|
// solium-disable-next-line security/no-block-members
|
||||||
require(releaseTime > block.timestamp);
|
require(releaseTime > block.timestamp);
|
||||||
@ -67,4 +69,6 @@ contract TokenTimelock {
|
|||||||
|
|
||||||
_token.safeTransfer(_beneficiary, amount);
|
_token.safeTransfer(_beneficiary, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "./IERC721.sol";
|
import "./IERC721.sol";
|
||||||
import "./IERC721Receiver.sol";
|
import "./IERC721Receiver.sol";
|
||||||
import "../../math/SafeMath.sol";
|
import "../../math/SafeMath.sol";
|
||||||
@ -11,7 +12,7 @@ import "../../introspection/ERC165.sol";
|
|||||||
* @title ERC721 Non-Fungible Token Standard basic implementation
|
* @title ERC721 Non-Fungible Token Standard basic implementation
|
||||||
* @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
|
* @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
|
||||||
*/
|
*/
|
||||||
contract ERC721 is ERC165, IERC721 {
|
contract ERC721 is Initializable, ERC165, IERC721 {
|
||||||
|
|
||||||
using SafeMath for uint256;
|
using SafeMath for uint256;
|
||||||
using Address for address;
|
using Address for address;
|
||||||
@ -46,13 +47,20 @@ contract ERC721 is ERC165, IERC721 {
|
|||||||
* bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)'))
|
* bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)'))
|
||||||
*/
|
*/
|
||||||
|
|
||||||
constructor()
|
function initialize()
|
||||||
public
|
public
|
||||||
|
initializer
|
||||||
{
|
{
|
||||||
|
ERC165.initialize();
|
||||||
|
|
||||||
// register the supported interfaces to conform to ERC721 via ERC165
|
// register the supported interfaces to conform to ERC721 via ERC165
|
||||||
_registerInterface(_InterfaceId_ERC721);
|
_registerInterface(_InterfaceId_ERC721);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _hasBeenInitialized() internal view returns (bool) {
|
||||||
|
return supportsInterface(_InterfaceId_ERC721);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Gets the balance of the specified address
|
* @dev Gets the balance of the specified address
|
||||||
* @param owner address to query the balance of
|
* @param owner address to query the balance of
|
||||||
@ -323,4 +331,6 @@ contract ERC721 is ERC165, IERC721 {
|
|||||||
msg.sender, from, tokenId, _data);
|
msg.sender, from, tokenId, _data);
|
||||||
return (retval == _ERC721_RECEIVED);
|
return (retval == _ERC721_RECEIVED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,13 +1,16 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "./ERC721.sol";
|
import "./ERC721.sol";
|
||||||
|
|
||||||
|
|
||||||
contract ERC721Burnable is ERC721 {
|
contract ERC721Burnable is Initializable, ERC721 {
|
||||||
function burn(uint256 tokenId)
|
function burn(uint256 tokenId)
|
||||||
public
|
public
|
||||||
{
|
{
|
||||||
require(_isApprovedOrOwner(msg.sender, tokenId));
|
require(_isApprovedOrOwner(msg.sender, tokenId));
|
||||||
_burn(ownerOf(tokenId), tokenId);
|
_burn(ownerOf(tokenId), tokenId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,12 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "./IERC721Enumerable.sol";
|
import "./IERC721Enumerable.sol";
|
||||||
import "./ERC721.sol";
|
import "./ERC721.sol";
|
||||||
import "../../introspection/ERC165.sol";
|
import "../../introspection/ERC165.sol";
|
||||||
|
|
||||||
|
|
||||||
contract ERC721Enumerable is ERC165, ERC721, IERC721Enumerable {
|
contract ERC721Enumerable is Initializable, ERC165, ERC721, IERC721Enumerable {
|
||||||
// Mapping from owner to list of owned token IDs
|
// Mapping from owner to list of owned token IDs
|
||||||
mapping(address => uint256[]) private _ownedTokens;
|
mapping(address => uint256[]) private _ownedTokens;
|
||||||
|
|
||||||
@ -29,11 +30,17 @@ contract ERC721Enumerable is ERC165, ERC721, IERC721Enumerable {
|
|||||||
/**
|
/**
|
||||||
* @dev Constructor function
|
* @dev Constructor function
|
||||||
*/
|
*/
|
||||||
constructor() public {
|
function initialize() public initializer {
|
||||||
|
require(ERC721._hasBeenInitialized());
|
||||||
|
|
||||||
// register the supported interface to conform to ERC721 via ERC165
|
// register the supported interface to conform to ERC721 via ERC165
|
||||||
_registerInterface(_InterfaceId_ERC721Enumerable);
|
_registerInterface(_InterfaceId_ERC721Enumerable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _hasBeenInitialized() internal view returns (bool) {
|
||||||
|
return supportsInterface(_InterfaceId_ERC721Enumerable);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Gets the token ID at a given index of the tokens list of the requested owner
|
* @dev Gets the token ID at a given index of the tokens list of the requested owner
|
||||||
* @param owner address owning the tokens list to be accessed
|
* @param owner address owning the tokens list to be accessed
|
||||||
@ -143,4 +150,6 @@ contract ERC721Enumerable is ERC165, ERC721, IERC721Enumerable {
|
|||||||
_allTokensIndex[tokenId] = 0;
|
_allTokensIndex[tokenId] = 0;
|
||||||
_allTokensIndex[lastToken] = tokenIndex;
|
_allTokensIndex[lastToken] = tokenIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "./ERC721.sol";
|
import "./ERC721.sol";
|
||||||
import "./ERC721Enumerable.sol";
|
import "./ERC721Enumerable.sol";
|
||||||
import "./ERC721Metadata.sol";
|
import "./ERC721Metadata.sol";
|
||||||
@ -11,9 +12,6 @@ import "./ERC721Metadata.sol";
|
|||||||
* Moreover, it includes approve all functionality using operator terminology
|
* Moreover, it includes approve all functionality using operator terminology
|
||||||
* @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
|
* @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
|
||||||
*/
|
*/
|
||||||
contract ERC721Full is ERC721, ERC721Enumerable, ERC721Metadata {
|
contract ERC721Full is Initializable, ERC721, ERC721Enumerable, ERC721Metadata {
|
||||||
constructor(string name, string symbol) ERC721Metadata(name, symbol)
|
uint256[50] private ______gap;
|
||||||
public
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "./IERC721Receiver.sol";
|
import "./IERC721Receiver.sol";
|
||||||
|
|
||||||
|
|
||||||
contract ERC721Holder is IERC721Receiver {
|
contract ERC721Holder is Initializable, IERC721Receiver {
|
||||||
function onERC721Received(
|
function onERC721Received(
|
||||||
address,
|
address,
|
||||||
address,
|
address,
|
||||||
@ -15,4 +16,6 @@ contract ERC721Holder is IERC721Receiver {
|
|||||||
{
|
{
|
||||||
return this.onERC721Received.selector;
|
return this.onERC721Received.selector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,12 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "./ERC721.sol";
|
import "./ERC721.sol";
|
||||||
import "./IERC721Metadata.sol";
|
import "./IERC721Metadata.sol";
|
||||||
import "../../introspection/ERC165.sol";
|
import "../../introspection/ERC165.sol";
|
||||||
|
|
||||||
|
|
||||||
contract ERC721Metadata is ERC165, ERC721, IERC721Metadata {
|
contract ERC721Metadata is Initializable, ERC165, ERC721, IERC721Metadata {
|
||||||
// Token name
|
// Token name
|
||||||
string internal _name;
|
string internal _name;
|
||||||
|
|
||||||
@ -26,7 +27,9 @@ contract ERC721Metadata is ERC165, ERC721, IERC721Metadata {
|
|||||||
/**
|
/**
|
||||||
* @dev Constructor function
|
* @dev Constructor function
|
||||||
*/
|
*/
|
||||||
constructor(string name, string symbol) public {
|
function initialize(string name, string symbol) public initializer {
|
||||||
|
require(ERC721._hasBeenInitialized());
|
||||||
|
|
||||||
_name = name;
|
_name = name;
|
||||||
_symbol = symbol;
|
_symbol = symbol;
|
||||||
|
|
||||||
@ -34,6 +37,10 @@ contract ERC721Metadata is ERC165, ERC721, IERC721Metadata {
|
|||||||
_registerInterface(InterfaceId_ERC721Metadata);
|
_registerInterface(InterfaceId_ERC721Metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _hasBeenInitialized() internal view returns (bool) {
|
||||||
|
return supportsInterface(InterfaceId_ERC721Metadata);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Gets the token name
|
* @dev Gets the token name
|
||||||
* @return string representing the token name
|
* @return string representing the token name
|
||||||
@ -85,4 +92,6 @@ contract ERC721Metadata is ERC165, ERC721, IERC721Metadata {
|
|||||||
delete _tokenURIs[tokenId];
|
delete _tokenURIs[tokenId];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "./ERC721Metadata.sol";
|
import "./ERC721Metadata.sol";
|
||||||
import "../../access/roles/MinterRole.sol";
|
import "../../access/roles/MinterRole.sol";
|
||||||
|
|
||||||
@ -8,7 +9,13 @@ import "../../access/roles/MinterRole.sol";
|
|||||||
* @title ERC721MetadataMintable
|
* @title ERC721MetadataMintable
|
||||||
* @dev ERC721 minting logic with metadata
|
* @dev ERC721 minting logic with metadata
|
||||||
*/
|
*/
|
||||||
contract ERC721MetadataMintable is ERC721, ERC721Metadata, MinterRole {
|
contract ERC721MetadataMintable is Initializable, ERC721, ERC721Metadata, MinterRole {
|
||||||
|
function initialize(address sender) public initializer {
|
||||||
|
require(ERC721._hasBeenInitialized());
|
||||||
|
require(ERC721Metadata._hasBeenInitialized());
|
||||||
|
MinterRole.initialize(sender);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Function to mint tokens
|
* @dev Function to mint tokens
|
||||||
* @param to The address that will receive the minted tokens.
|
* @param to The address that will receive the minted tokens.
|
||||||
@ -29,4 +36,6 @@ contract ERC721MetadataMintable is ERC721, ERC721Metadata, MinterRole {
|
|||||||
_setTokenURI(tokenId, tokenURI);
|
_setTokenURI(tokenId, tokenURI);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "./ERC721.sol";
|
import "./ERC721.sol";
|
||||||
import "../../access/roles/MinterRole.sol";
|
import "../../access/roles/MinterRole.sol";
|
||||||
|
|
||||||
@ -8,7 +9,12 @@ import "../../access/roles/MinterRole.sol";
|
|||||||
* @title ERC721Mintable
|
* @title ERC721Mintable
|
||||||
* @dev ERC721 minting logic
|
* @dev ERC721 minting logic
|
||||||
*/
|
*/
|
||||||
contract ERC721Mintable is ERC721, MinterRole {
|
contract ERC721Mintable is Initializable, ERC721, MinterRole {
|
||||||
|
function initialize(address sender) public initializer {
|
||||||
|
require(ERC721._hasBeenInitialized());
|
||||||
|
MinterRole.initialize(sender);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Function to mint tokens
|
* @dev Function to mint tokens
|
||||||
* @param to The address that will receive the minted tokens.
|
* @param to The address that will receive the minted tokens.
|
||||||
@ -26,4 +32,6 @@ contract ERC721Mintable is ERC721, MinterRole {
|
|||||||
_mint(to, tokenId);
|
_mint(to, tokenId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "./ERC721.sol";
|
import "./ERC721.sol";
|
||||||
import "../../lifecycle/Pausable.sol";
|
import "../../lifecycle/Pausable.sol";
|
||||||
|
|
||||||
@ -8,7 +9,12 @@ import "../../lifecycle/Pausable.sol";
|
|||||||
* @title ERC721 Non-Fungible Pausable token
|
* @title ERC721 Non-Fungible Pausable token
|
||||||
* @dev ERC721 modified with pausable transfers.
|
* @dev ERC721 modified with pausable transfers.
|
||||||
**/
|
**/
|
||||||
contract ERC721Pausable is ERC721, Pausable {
|
contract ERC721Pausable is Initializable, ERC721, Pausable {
|
||||||
|
function initialize(address sender) public initializer {
|
||||||
|
require(ERC721._hasBeenInitialized());
|
||||||
|
Pausable.initialize(sender);
|
||||||
|
}
|
||||||
|
|
||||||
function approve(
|
function approve(
|
||||||
address to,
|
address to,
|
||||||
uint256 tokenId
|
uint256 tokenId
|
||||||
@ -39,4 +45,6 @@ contract ERC721Pausable is ERC721, Pausable {
|
|||||||
{
|
{
|
||||||
super.transferFrom(from, to, tokenId);
|
super.transferFrom(from, to, tokenId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "../../introspection/IERC165.sol";
|
import "../../introspection/IERC165.sol";
|
||||||
|
|
||||||
|
|
||||||
@ -7,7 +8,7 @@ import "../../introspection/IERC165.sol";
|
|||||||
* @title ERC721 Non-Fungible Token Standard basic interface
|
* @title ERC721 Non-Fungible Token Standard basic interface
|
||||||
* @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
|
* @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
|
||||||
*/
|
*/
|
||||||
contract IERC721 is IERC165 {
|
contract IERC721 is Initializable, IERC165 {
|
||||||
|
|
||||||
event Transfer(
|
event Transfer(
|
||||||
address indexed from,
|
address indexed from,
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "./IERC721.sol";
|
import "./IERC721.sol";
|
||||||
|
|
||||||
|
|
||||||
@ -7,7 +8,7 @@ import "./IERC721.sol";
|
|||||||
* @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
|
* @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
|
||||||
* @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
|
* @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
|
||||||
*/
|
*/
|
||||||
contract IERC721Enumerable is IERC721 {
|
contract IERC721Enumerable is Initializable, IERC721 {
|
||||||
function totalSupply() public view returns (uint256);
|
function totalSupply() public view returns (uint256);
|
||||||
function tokenOfOwnerByIndex(
|
function tokenOfOwnerByIndex(
|
||||||
address owner,
|
address owner,
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "./IERC721.sol";
|
import "./IERC721.sol";
|
||||||
import "./IERC721Enumerable.sol";
|
import "./IERC721Enumerable.sol";
|
||||||
import "./IERC721Metadata.sol";
|
import "./IERC721Metadata.sol";
|
||||||
@ -9,5 +10,5 @@ import "./IERC721Metadata.sol";
|
|||||||
* @title ERC-721 Non-Fungible Token Standard, full implementation interface
|
* @title ERC-721 Non-Fungible Token Standard, full implementation interface
|
||||||
* @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
|
* @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
|
||||||
*/
|
*/
|
||||||
contract IERC721Full is IERC721, IERC721Enumerable, IERC721Metadata {
|
contract IERC721Full is Initializable, IERC721, IERC721Enumerable, IERC721Metadata {
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
import "./IERC721.sol";
|
import "./IERC721.sol";
|
||||||
|
|
||||||
|
|
||||||
@ -7,7 +8,7 @@ import "./IERC721.sol";
|
|||||||
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
|
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
|
||||||
* @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
|
* @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
|
||||||
*/
|
*/
|
||||||
contract IERC721Metadata is IERC721 {
|
contract IERC721Metadata is Initializable, IERC721 {
|
||||||
function name() external view returns (string);
|
function name() external view returns (string);
|
||||||
function symbol() external view returns (string);
|
function symbol() external view returns (string);
|
||||||
function tokenURI(uint256 tokenId) public view returns (string);
|
function tokenURI(uint256 tokenId) public view returns (string);
|
||||||
|
|||||||
40
contracts/token/ERC721/StandaloneERC721.sol
Normal file
40
contracts/token/ERC721/StandaloneERC721.sol
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
|
import "./ERC721.sol";
|
||||||
|
import "./ERC721Enumerable.sol";
|
||||||
|
import "./ERC721Metadata.sol";
|
||||||
|
import "./ERC721MetadataMintable.sol";
|
||||||
|
import "./ERC721Pausable.sol";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @title Standard ERC721 token, with minting and pause functionality.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
contract StandaloneERC721
|
||||||
|
is Initializable, ERC721, ERC721Enumerable, ERC721Metadata, ERC721MetadataMintable, ERC721Pausable
|
||||||
|
{
|
||||||
|
function initialize(string name, string symbol, address[] minters, address[] pausers) public initializer {
|
||||||
|
ERC721.initialize();
|
||||||
|
ERC721Enumerable.initialize();
|
||||||
|
ERC721Metadata.initialize(name, symbol);
|
||||||
|
|
||||||
|
// Initialize the minter and pauser roles, and renounce them
|
||||||
|
ERC721MetadataMintable.initialize(address(this));
|
||||||
|
renounceMinter();
|
||||||
|
|
||||||
|
ERC721Pausable.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]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -25,5 +25,4 @@ library Address {
|
|||||||
assembly { size := extcodesize(account) }
|
assembly { size := extcodesize(account) }
|
||||||
return size > 0;
|
return size > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "zos-lib/contracts/Initializable.sol";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @title Helps contracts guard against reentrancy attacks.
|
* @title Helps contracts guard against reentrancy attacks.
|
||||||
@ -7,10 +8,14 @@ pragma solidity ^0.4.24;
|
|||||||
* @dev If you mark a function `nonReentrant`, you should also
|
* @dev If you mark a function `nonReentrant`, you should also
|
||||||
* mark it `external`.
|
* mark it `external`.
|
||||||
*/
|
*/
|
||||||
contract ReentrancyGuard {
|
contract ReentrancyGuard is Initializable {
|
||||||
|
|
||||||
/// @dev counter to allow mutex lock with only one SSTORE operation
|
/// @dev counter to allow mutex lock with only one SSTORE operation
|
||||||
uint256 private _guardCounter = 1;
|
uint256 private _guardCounter;
|
||||||
|
|
||||||
|
function initialize() public initializer {
|
||||||
|
_guardCounter = 1;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Prevents a contract from calling itself, directly or indirectly.
|
* @dev Prevents a contract from calling itself, directly or indirectly.
|
||||||
@ -27,4 +32,5 @@ contract ReentrancyGuard {
|
|||||||
require(localCounter == _guardCounter);
|
require(localCounter == _guardCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256[50] private ______gap;
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user