Compare commits

...

80 Commits

Author SHA1 Message Date
06e265b38d Release v2.0.0 2018-10-21 15:33:49 +00:00
7789814606 Release candidate v2.0.0-rc.4 2018-10-21 00:54:34 +00:00
643ac86d0a Improved some ERC721 internal shenanigans (#1450)
* Made _clearApproval private, added clarifying comments in _addTokenTo and _removeTokenFrom.

* Added approval information.

(cherry picked from commit 8204f6a71f)
2018-10-20 22:15:00 +00:00
ae339333d7 Add warning about trading tokens before refundable crowdsale goal is met (#1452)
This attack was reported in https://github.com/OpenZeppelin/openzeppelin-solidity/issues/877

(cherry picked from commit 80458ebc72)
2018-10-20 22:13:08 +00:00
1a4009f817 Crowdsale.buyTokens is now nonReentrant. (#1438)
(cherry picked from commit 6d415c508b)
2018-10-20 22:13:02 +00:00
ecae7608f9 InitialRate must be strictly larger than finalRate. (#1441)
(cherry picked from commit a936cbf5fb)
2018-10-20 22:12:55 +00:00
47b5d61844 Fixed how allowance crowdsale checks remaining tokens. (#1449)
(cherry picked from commit 1ac1ac984e)
2018-10-20 22:12:48 +00:00
984fe23a46 Deleted unnecessary import. (#1437)
* Deleted unnecessary import.

* Added back SafeMath.

* Removed another unnecessary import.

(cherry picked from commit bbe804a14b)
2018-10-20 22:09:30 +00:00
5cdf4de1f6 Made SampleCrowdsale a bit clearer. (#1448) 2018-10-20 22:09:22 +00:00
a9bffb3787 Now setting the finalized flag before doing finalization to prevent possbile reentrancy issues. (#1447)
(cherry picked from commit 5bb865218f)
2018-10-20 22:09:12 +00:00
6e53c4e129 Crowdsale docs improvements. (#1446)
* Added a small Crowdsale fallback gas warning.

* Fixed a couple typos.

(cherry picked from commit 94692acb14)
2018-10-20 22:09:04 +00:00
95411da289 Renamed internal ERC721 check function. (#1445)
(cherry picked from commit 384dff9abe)
2018-10-20 22:08:49 +00:00
e237530538 Made tokenURI external, as per the spec. (#1444)
(cherry picked from commit 5bf3907862)
2018-10-20 22:08:40 +00:00
0ead40ae03 ERC20Capped now capps _all_ minting, even internal calls. (#1443)
(cherry picked from commit c8220aeea8)
2018-10-20 22:08:34 +00:00
2e848e12d1 IncPriceCrowdsale consistently returns 0 outside of the crowdsale window. (#1442)
(cherry picked from commit 9155bfe27f)
2018-10-20 22:08:27 +00:00
6e055019d4 Closing time must be strictly after opening time. (#1440)
(cherry picked from commit 1c5f16ae26)
2018-10-20 22:08:18 +00:00
5ee55c4af3 Internal crowdsales (#1439)
* Made some internal crowdsale methods internal.

* Made all Crowdsale constructors internal.

(cherry picked from commit d9fdffe88e)
2018-10-20 22:07:59 +00:00
1b27b4bb34 Improved SafeERC20 allowance handling (#1407)
* signing prefix added

* Minor improvement

* Tests changed

* Successfully tested

* Minor improvements

* Minor improvements

* Revert "Dangling commas are now required. (#1359)"

This reverts commit a6889776f4.

* updates

* fixes #1404

* approve failing test

* suggested changes done

* ISafeERC20 removed

* allowance methods in library

* Improved SafeERC20 tests.

* Fixed test coverage.

(cherry picked from commit 315f426f5c)
2018-10-20 22:07:38 +00:00
4115686b4f TokenVesting improvements (#1431)
* Improved TokenVesting events.

* Added extra checks to TokenVesting.

* Renamed the events.

* Fixed linter error.

* Fixed a test that failed to cover a require.

* Renamed TokensRevoked to TokenVestingRevoked.

(cherry picked from commit 67dac7ae99)
2018-10-20 22:07:00 +00:00
6db4f0bc8f SplitPayment improvements (#1417)
* Renamed file, added events and set _addPayee to private

* unwanted file

* adjusted test

* adjusted test

* PaymentReceived event added

* Added event testing.

* Fix static tests

(cherry picked from commit a07499796a)
2018-10-20 22:06:40 +00:00
5f3ecd9c64 Added address of pauser/unpauser in events (#1410)
* Added address of pauser/unpauser in events

* Added the account to the Pausable tests.

(cherry picked from commit fcab9c89f2)
2018-10-20 22:06:24 +00:00
c126e3e81a Events added to Secondary (#1425)
* Update contracts/ownership/Secondary.sol

* Update Secondary.sol

* Update Secondary.test.js

* Update Secondary.test.js

* Update Secondary.sol

(cherry picked from commit cbe414864f)
2018-10-20 22:06:10 +00:00
ab932e1873 Added leading underscore to internal functions, renamed supportsInterfaces. (#1435)
(cherry picked from commit 0231fac514)
2018-10-20 22:05:51 +00:00
4394107660 Added replay attack notice to SignatureBouncer. (#1434)
(cherry picked from commit ff0c048ad9)
2018-10-20 22:05:31 +00:00
422b42bb6a Made some inherit-only contracts internal. (#1433)
* Made some inherit-only contracts internal.

* Added OwnableMock.

(cherry picked from commit 96d6103e0b)
2018-10-20 22:05:15 +00:00
3b34436b44 Made some TokenVesting public functions private. (#1427)
* Made some TokenVesting public functions private.

* Fixed linter error.

(cherry picked from commit df3c113711)
2018-10-20 22:05:01 +00:00
c5a8680a9c Moved Escrows into an escrow subdirectory, improved docs. (#1430)
* Moved Escrows into an escrow subdirectory, improved docs.

* Fixed escrow mock.

* Fixed some more imports.

(cherry picked from commit f3df2dab3d)
2018-10-20 22:04:33 +00:00
88f48be287 Removed default value assignments. (#1432)
(cherry picked from commit cfef58361f)
2018-10-20 22:04:11 +00:00
26f9cc8e74 Moved some test files around to better reflect the directory layout. (#1428)
(cherry picked from commit d8ab8a00f2)
2018-10-20 22:03:46 +00:00
56806bb295 Now using hex for asm memory addresses. (#1429)
(cherry picked from commit 2733cb4a41)
2018-10-20 22:03:14 +00:00
1cf96ef0d1 Make state variables private (#1426)
* added function to renounce ownership

* Make state variables private (#1411)

(cherry picked from commit 03765e08b9)
2018-10-20 22:02:36 +00:00
5d596fc786 Added Math.sol docstrings. (#1423)
(cherry picked from commit a3e312d133)
2018-10-20 22:02:08 +00:00
2514959f34 Fixed a typo in a comment. (#1422)
(cherry picked from commit 3341dd8899)
2018-10-20 22:01:54 +00:00
1b79b536cd Roles.add and remove now require pre-conditions on the account. (#1421)
(cherry picked from commit 3bd30f7382)
2018-10-20 22:01:22 +00:00
e990525c2e RefundEscrow's events renamed (#1418)
* fixes #1414

(cherry picked from commit 844a96d0b9)
2018-10-20 22:00:49 +00:00
2c40ffa011 Improve encapsulation on ERC165 and update code style guide (#1379)
* use prefix underscore for internal state variables

* make _supportedInterfaces private

(cherry picked from commit 03dfb2965c)
2018-10-20 22:00:13 +00:00
10a5864fdf First test helpers tests (#1369)
* Removed unused advanceToBlock.

* Added advanceBlock tests.

* Fixed advanceToBlock tests.

* Added single argument tests.

* Finished inLogs tests.

* Fixed linter errors.

* Fixed linter errors.

(cherry picked from commit 9f822906b8)
2018-10-20 21:59:32 +00:00
7ec6079784 Fix typo in ARCHITECTURE.md (#1406)
(cherry picked from commit eb92fd1f48)
2018-10-20 21:57:17 +00:00
5e82a64a01 Add a code style rule to make all state variables private (#1390)
(cherry picked from commit 076cb7decd)
2018-10-20 21:56:56 +00:00
3266de1b5c Non-constructor initialization removed (#1403)
* signing prefix added

* Minor improvement

* Tests changed

* Successfully tested

* Minor improvements

* Minor improvements

* Revert "Dangling commas are now required. (#1359)"

This reverts commit a6889776f4.

* updates

* fixes #1391

(cherry picked from commit da67e435b1)
2018-10-20 21:56:18 +00:00
7cd0d5a452 Replaced assertJump, assertRevert and expectThrow with shouldFail. (#1363)
* Replaced assertJump, assertRevert and expectThrow with shouldFail.

* Fixed linter errors.

* Fixed typo.

* Made the helpers async.

(cherry picked from commit b0da0fded0)
2018-10-20 21:54:50 +00:00
620d524398 Improves Ownable events (#1397)
* signing prefix added

* Minor improvement

* Tests changed

* Successfully tested

* Minor improvements

* Minor improvements

* Revert "Dangling commas are now required. (#1359)"

This reverts commit a6889776f4.

* updates

* fixes #1392

* event tests added

* constructor event added

(cherry picked from commit af42c39e6c)
2018-10-20 21:53:33 +00:00
eae40c93b6 this is used in tests (#1380)
* signing prefix added

* Minor improvement

* Tests changed

* Successfully tested

* Minor improvements

* Minor improvements

* Revert "Dangling commas are now required. (#1359)"

This reverts commit a6889776f4.

* updates

* fixes #1200

* suggested change

(cherry picked from commit b41b125c15)
2018-10-20 21:35:26 +00:00
109eba9273 Replaces amount with value for consistency (#1378)
* fixes #1372

* done in ERC20Capped and ERC20Mintable

(cherry picked from commit fd4de77651)
2018-10-20 21:32:45 +00:00
13fb1f662a Fixed test path.
(cherry picked from commit f4d6f40442)
2018-10-20 21:31:48 +00:00
2f3f0d3c8a Created test utils directory
(cherry picked from commit 269981ee6a)
2018-10-20 21:31:34 +00:00
0678f67289 Merged latestTime, increaseTime and duration into a time helper. (#1364)
(cherry picked from commit 34bc709bc2)
2018-10-20 21:31:21 +00:00
b03932529c Fix/#1355 test helper to check balance difference (#1368)
* signing prefix added

* Minor improvement

* Tests changed

* Successfully tested

* Minor improvements

* Minor improvements

* Revert "Dangling commas are now required. (#1359)"

This reverts commit a6889776f4.

* fixex #1355

* linting

* suggested changes

* Update BreakInvariantBounty.test.js

(cherry picked from commit 6ae041bca6)
2018-10-20 21:30:15 +00:00
c25a1e366f Fix #1358 Test helper to send funds (#1367)
* signing prefix added

* Minor improvement

* Tests changed

* Successfully tested

* Minor improvements

* Minor improvements

* Revert "Dangling commas are now required. (#1359)"

This reverts commit a6889776f4.

* fixes #1358

* linting done

* suggested changes

(cherry picked from commit fa1dfbd113)
2018-10-20 21:29:21 +00:00
598a0358fc Dangling commas are now required. (#1359)
(cherry picked from commit a6889776f4)
2018-10-20 21:23:12 +00:00
39db4b4b05 Feature/use expect event in test logs assertions #1232 (#1343)
* Add BigNumber support to expectEvent/inLogs (#1026)

* switched direct logs array check to expectEvent method in AllowanceCrowdsale.test.js

* Refactor expectEvent.inLogs function to use simple value number check

* Introduced should.be.bignumber method to compare BigNumber values

* Use expectEvent to test logs (#1232)

* Removed trailing space

(cherry picked from commit 536262f2ec)
2018-10-20 21:22:54 +00:00
a9af619c59 Add BigNumber support to expectEvent/inLogs (#1026) (#1338)
* Add BigNumber support to expectEvent/inLogs (#1026)

* switched direct logs array check to expectEvent method in AllowanceCrowdsale.test.js

* Refactor expectEvent.inLogs function to use simple value number check

* Introduced should.be.bignumber method to compare BigNumber values

* Destructure transaction object to extract logs field

(cherry picked from commit 947de54cee)
2018-10-20 21:22:05 +00:00
62ed8e2fe4 Removed BreakInvariantBounty. (#1424)
(cherry picked from commit 9be0f100c4)
2018-10-20 21:20:57 +00:00
e7aa8dedbc Turn off blank-lines Solium rule (#1284)
* turn off blank-lines rule

* remove triple newlines

(cherry picked from commit 9b37104655)
2018-10-20 21:07:49 +00:00
49d2dd9e08 Add Mock suffix to variable names #1172 (#1324)
* Add Mock suffix to variable names #1172

* Add Impl suffix to variable names

(cherry picked from commit 4b21fcf5af)
2018-10-20 20:59:51 +00:00
a3bb56769e Remove lodash from tests (#1323)
(cherry picked from commit d062352de7)
2018-10-20 20:59:13 +00:00
f8b0cec15b Add unit test specific to Address utils (#1251) (#1316)
(cherry picked from commit 7825caa1fd)
2018-10-20 20:57:15 +00:00
7ea34d9e97 Update ERC20.sol (#1313)
correct typo in doc

(cherry picked from commit b644c72eb0)
2018-10-20 20:56:34 +00:00
2a8146a45d Fix README snippet typo
(cherry picked from commit 0b8296e525)
2018-10-20 20:55:59 +00:00
2e14386eda fix readme snippet so it is concrete
(cherry picked from commit 651f6d8b57)
2018-10-20 20:54:53 +00:00
9f5b73df37 added a test helper with common constants (#1400)
* signing prefix added

* Minor improvement

* Tests changed

* Successfully tested

* Minor improvements

* Minor improvements

* Revert "Dangling commas are now required. (#1359)"

This reverts commit a6889776f4.

* updates

* fixes #1206

(cherry picked from commit 58a42443df)
2018-10-18 19:05:17 -03:00
a811a0be28 Improves Ownable events (#1397)
* signing prefix added

* Minor improvement

* Tests changed

* Successfully tested

* Minor improvements

* Minor improvements

* Revert "Dangling commas are now required. (#1359)"

This reverts commit a6889776f4.

* updates

* fixes #1392

* event tests added

* constructor event added

(cherry picked from commit af42c39e6c)
2018-10-18 19:03:56 -03:00
9c76d28245 Added a constructor to BreakInvariantBounty. (#1395)
(cherry picked from commit 3acc2b4216)
2018-10-18 19:02:57 -03:00
8d6250cd5a Add Arrays library with unit tests (#1209) (#1375)
*     Add Arrays library with unit tests (#1209)

    * prepared due to snapshot token requirements
    * add library with method to find upper bound
    * add unit test for basic and edge cases

* Imporove documentation for Arrays library

Simplify Arrays.test.js to use short arrays as test date

* Added comment for uint256 mid variable.
* Explaned why uint256 mid variable calculated as Math.average is safe to use as index of array.

(cherry picked from commit f7e53d90fa)
2018-10-18 19:02:50 -03:00
66bad4ff2a Removed selfdestruct from BreakInvariantBounty (#1385)
* signing prefix added

* Minor improvement

* Tests changed

* Successfully tested

* Minor improvements

* Minor improvements

* Revert "Dangling commas are now required. (#1359)"

This reverts commit a6889776f4.

* updates

* fixes #1384

* introduced claimable and cancelBounty

* cancelBounty tests

* Update BreakInvariantBounty.test.js

(cherry picked from commit 41f84f8b40)
2018-10-18 19:02:42 -03:00
41e74dd8d8 Removed old, unused mocks. (#1382)
(cherry picked from commit b17de011dc)
2018-10-18 18:53:09 -03:00
2d30918149 Release candidate v2.0.0-rc.3 2018-10-04 11:17:57 -03:00
0db1f8144d Removed unnecessary Secondary inheritance from RefundEscrow. (#1381)
(cherry picked from commit 308e5e9cc0)
2018-10-04 11:15:53 -03:00
ffeae0d83e ERC20 internal transfer method (#1370)
(cherry picked from commit 43ebb4fc43)
2018-10-04 11:14:05 -03:00
38ca422170 Removing unrequired _burn() override (#1373)
* signing prefix added

* Minor improvement

* Tests changed

* Successfully tested

* Minor improvements

* Minor improvements

* Revert "Dangling commas are now required. (#1359)"

This reverts commit a6889776f4.

* updates

* fixes #1371

* Removed extra whitespace

(cherry picked from commit f3888bb0b0)
2018-10-04 11:13:05 -03:00
7c984968d8 Prevents Bounty from being claimed twice (#1374)
* signing prefix added

* Minor improvement

* Tests changed

* Successfully tested

* Minor improvements

* Minor improvements

* Revert "Dangling commas are now required. (#1359)"

This reverts commit a6889776f4.

* updates

* fixes #1356

* Removed extra semicolon.

(cherry picked from commit c87433e0c2)
2018-10-04 11:12:45 -03:00
bd8345a153 Separate ERC721Mintable (#1365)
* separate part of ERC721Mintable into ERC721MetadataMintable

* remove mint and burn from 721 tests

* Fixed linter error.

* fix ERC721 mint tests

* Minor fixes.

(cherry picked from commit 744f567f40)
2018-10-04 11:12:05 -03:00
76169cda40 Fixed a broken payment test (+ another small fix) (#1318)
* Fixed a broken payment test

* In PR template, npm run lint:fix, not lint:all:fix

* In SplitPayment test, replaced an await-in-loop with Promise.all

(cherry picked from commit b79196f911)
2018-09-28 11:36:06 -03:00
08bf6bbed9 Add missing tests to ECSDA (#1248)
* fix: refactor sign.js and related tests

* fix: remove unused dep

* fix: update package.json correctly

* Add missing tests to ECRecovery

* fix lint

* Reorganize the tests

* Reuse signature

* fix static errors

* Apply suggestions by @frangion and @nventuro

* Remove only

* More suggestions

* Remove unnecessary max-len

* remove only

(cherry picked from commit 75c0a59bb4)
2018-09-28 11:28:46 -03:00
8c394de450 Add SignatureBouncer test for when msg.data is too short (#1360)
* add test for msg.data too short

* fix test to hit that branch

* Update SignatureBouncer.test.js

(cherry picked from commit 1a4e5346ed)
2018-09-28 09:38:48 -03:00
fa5ecd03cb Improved bounty tests. (#1350)
* Improved bounty tests.

* Fixed linter errors.

* Addressed review comments.

(cherry picked from commit ae109f69cc)
2018-09-26 16:37:31 -03:00
1b0c6b94b9 Removed mintingFinished. (#1351)
* Removed mintingFinished from ERC20Mintable.

* Removed MintingFinished from ERC721Mintable.

* Removed MintingFinished event.

(cherry picked from commit 5fdeaa81d5)
2018-09-26 16:06:27 -03:00
652243b7c3 Removed assertions from Escrow and SplitPayment. (#1349)
(cherry picked from commit db2e1d2c74)
2018-09-26 12:57:15 -03:00
c9e8a66e85 Add the missing test for ERC721Holder (#1249)
* Add the missing test for ERC721Holder

* fix lint

* Move the holder test to a separate file

(cherry picked from commit 396680b856)
2018-09-26 12:15:08 -03:00
e7c99dd7dd Roles now emit events in construction and when renouncing. (#1329)
* release candidate v2.0.0-rc.1

* fix linter error

(cherry picked from commit c12a1c6898)

* Roles now emit events in construction and when renouncing.

(cherry picked from commit 21198bf1c1)
2018-09-26 12:14:34 -03:00
198 changed files with 2004 additions and 1726 deletions

View File

@ -25,7 +25,7 @@
// Code style
"camelcase": ["error", {"properties": "always"}],
"comma-dangle": ["warn", "always-multiline"],
"comma-dangle": ["error", "always-multiline"],
"comma-spacing": ["error", {"before": false, "after": true}],
"dot-notation": ["error", {"allowKeywords": true, "allowPattern": ""}],
"eol-last": ["error", "always"],

View File

@ -14,4 +14,4 @@ Fixes #
- [ ] 📘 I've reviewed the [OpenZeppelin Contributor Guidelines](../blob/master/CONTRIBUTING.md)
- [ ] ✅ I've added tests where applicable to test my new functionality.
- [ ] 📖 I've made sure that my contracts are well-documented.
- [ ] 🎨 I've run the JS/Solidity linters and fixed any issues (`npm run lint:all:fix`).
- [ ] 🎨 I've run the JS/Solidity linters and fixed any issues (`npm run lint:fix`).

View File

@ -2,6 +2,7 @@
"extends": "solium:all",
"plugins": ["security"],
"rules": {
"blank-lines": "off",
"error-reason": "off",
"indentation": ["error", 2],
"lbrace": "off",

View File

@ -16,11 +16,14 @@ Any exception or additions specific to our project are documented below.
* Try to avoid acronyms and abbreviations.
* All state variables should be private.
* Private state variables should have an underscore prefix.
```
contract TestContract {
uint256 private _privateVar;
uint256 internal _internalVar;
}
```

View File

@ -17,10 +17,14 @@ npm install openzeppelin-solidity
To write your custom contracts, import ours and extend them through inheritance.
```solidity
import 'openzeppelin-solidity/contracts/token/ERC721/ERC721.sol';
pragma solidity ^0.4.24;
import 'openzeppelin-solidity/contracts/token/ERC721/ERC721Full.sol';
import 'openzeppelin-solidity/contracts/token/ERC721/ERC721Mintable.sol';
contract MyNFT is ERC721, ERC721Mintable {
contract MyNFT is ERC721Full, ERC721Mintable {
constructor() ERC721Full("MyNFT", "MNFT") public {
}
}
```

View File

@ -12,7 +12,7 @@ The following provides visibility into how OpenZeppelin's contracts are organize
- **introspection** - An interface that can be used to make a contract comply with the ERC-165 standard as well as a contract that implements ERC-165 using a lookup table.
- **lifecycle** - A collection of base contracts used to manage the existence and behavior of your contracts and their funds.
- **math** - Libraries with safety checks on operations that throw on errors.
- **mocks** - A collection of abstract contracts that are primarily used for unit testing. They also serve as good usage examples and demonstrate how to combine contracts with inheritence when developing your own custom applications.
- **mocks** - A collection of abstract contracts that are primarily used for unit testing. They also serve as good usage examples and demonstrate how to combine contracts with inheritance when developing your own custom applications.
- **ownership** - A collection of smart contracts that can be used to manage contract and token ownership
- **payment** - A collection of smart contracts that can be used to manage payments through escrow arrangements, withdrawals, and claims. Includes support for both single payees and multiple payees.
- **proposals** - A collection of smart contracts that reflect community Ethereum Improvement Proposals (EIPs). These contracts are under development and standardization. They are not recommended for production, but they are useful for experimentation with pending EIP standards. Go [here](https://github.com/OpenZeppelin/openzeppelin-solidity/wiki/ERC-Process) for more information.

View File

@ -1,6 +1,5 @@
pragma solidity ^0.4.24;
/**
* @title Roles
* @dev Library for managing addresses assigned to a Role.
@ -15,6 +14,8 @@ library Roles {
*/
function add(Role storage role, address account) internal {
require(account != address(0));
require(!has(role, account));
role.bearer[account] = true;
}
@ -23,6 +24,8 @@ library Roles {
*/
function remove(Role storage role, address account) internal {
require(account != address(0));
require(has(role, account));
role.bearer[account] = false;
}

View File

@ -2,7 +2,6 @@ pragma solidity ^0.4.24;
import "../Roles.sol";
contract CapperRole {
using Roles for Roles.Role;
@ -11,8 +10,8 @@ contract CapperRole {
Roles.Role private cappers;
constructor() public {
cappers.add(msg.sender);
constructor() internal {
_addCapper(msg.sender);
}
modifier onlyCapper() {
@ -25,12 +24,16 @@ contract CapperRole {
}
function addCapper(address account) public onlyCapper {
cappers.add(account);
emit CapperAdded(account);
_addCapper(account);
}
function renounceCapper() public {
cappers.remove(msg.sender);
_removeCapper(msg.sender);
}
function _addCapper(address account) internal {
cappers.add(account);
emit CapperAdded(account);
}
function _removeCapper(address account) internal {

View File

@ -2,7 +2,6 @@ pragma solidity ^0.4.24;
import "../Roles.sol";
contract MinterRole {
using Roles for Roles.Role;
@ -11,8 +10,8 @@ contract MinterRole {
Roles.Role private minters;
constructor() public {
minters.add(msg.sender);
constructor() internal {
_addMinter(msg.sender);
}
modifier onlyMinter() {
@ -25,12 +24,16 @@ contract MinterRole {
}
function addMinter(address account) public onlyMinter {
minters.add(account);
emit MinterAdded(account);
_addMinter(account);
}
function renounceMinter() public {
minters.remove(msg.sender);
_removeMinter(msg.sender);
}
function _addMinter(address account) internal {
minters.add(account);
emit MinterAdded(account);
}
function _removeMinter(address account) internal {

View File

@ -2,7 +2,6 @@ pragma solidity ^0.4.24;
import "../Roles.sol";
contract PauserRole {
using Roles for Roles.Role;
@ -11,8 +10,8 @@ contract PauserRole {
Roles.Role private pausers;
constructor() public {
pausers.add(msg.sender);
constructor() internal {
_addPauser(msg.sender);
}
modifier onlyPauser() {
@ -25,12 +24,16 @@ contract PauserRole {
}
function addPauser(address account) public onlyPauser {
pausers.add(account);
emit PauserAdded(account);
_addPauser(account);
}
function renouncePauser() public {
pausers.remove(msg.sender);
_removePauser(msg.sender);
}
function _addPauser(address account) internal {
pausers.add(account);
emit PauserAdded(account);
}
function _removePauser(address account) internal {

View File

@ -2,7 +2,6 @@ pragma solidity ^0.4.24;
import "../Roles.sol";
contract SignerRole {
using Roles for Roles.Role;
@ -11,8 +10,8 @@ contract SignerRole {
Roles.Role private signers;
constructor() public {
signers.add(msg.sender);
constructor() internal {
_addSigner(msg.sender);
}
modifier onlySigner() {
@ -25,12 +24,16 @@ contract SignerRole {
}
function addSigner(address account) public onlySigner {
signers.add(account);
emit SignerAdded(account);
_addSigner(account);
}
function renounceSigner() public {
signers.remove(msg.sender);
_removeSigner(msg.sender);
}
function _addSigner(address account) internal {
signers.add(account);
emit SignerAdded(account);
}
function _removeSigner(address account) internal {

View File

@ -3,7 +3,7 @@ pragma solidity ^0.4.24;
import "../token/ERC20/IERC20.sol";
import "../math/SafeMath.sol";
import "../token/ERC20/SafeERC20.sol";
import "../utils/ReentrancyGuard.sol";
/**
* @title Crowdsale
@ -17,7 +17,7 @@ import "../token/ERC20/SafeERC20.sol";
* the methods to add functionality. Consider using 'super' where appropriate to concatenate
* behavior.
*/
contract Crowdsale {
contract Crowdsale is ReentrancyGuard {
using SafeMath for uint256;
using SafeERC20 for IERC20;
@ -58,7 +58,7 @@ contract Crowdsale {
* @param wallet Address where collected funds will be forwarded to
* @param token Address of the token being sold
*/
constructor(uint256 rate, address wallet, IERC20 token) public {
constructor(uint256 rate, address wallet, IERC20 token) internal {
require(rate > 0);
require(wallet != address(0));
require(token != address(0));
@ -74,6 +74,9 @@ contract Crowdsale {
/**
* @dev fallback function ***DO NOT OVERRIDE***
* Note that other contracts will transfer fund with a base gas stipend
* of 2300, which is not enough to call buyTokens. Consider calling
* buyTokens directly when purchasing tokens from a contract.
*/
function () external payable {
buyTokens(msg.sender);
@ -101,7 +104,7 @@ contract Crowdsale {
}
/**
* @return the mount of wei raised.
* @return the amount of wei raised.
*/
function weiRaised() public view returns (uint256) {
return _weiRaised;
@ -109,9 +112,11 @@ contract Crowdsale {
/**
* @dev low level token purchase ***DO NOT OVERRIDE***
* @param beneficiary Address performing the token purchase
* This function has a non-reentrancy guard, so it shouldn't be called by
* another `nonReentrant` function.
* @param beneficiary Recipient of the token purchase
*/
function buyTokens(address beneficiary) public payable {
function buyTokens(address beneficiary) public nonReentrant payable {
uint256 weiAmount = msg.value;
_preValidatePurchase(beneficiary, weiAmount);
@ -153,6 +158,7 @@ contract Crowdsale {
uint256 weiAmount
)
internal
view
{
require(beneficiary != address(0));
require(weiAmount != 0);
@ -168,6 +174,7 @@ contract Crowdsale {
uint256 weiAmount
)
internal
view
{
// optional override
}
@ -187,7 +194,7 @@ contract Crowdsale {
}
/**
* @dev Executed when a purchase has been validated and is ready to be executed. Not necessarily emits/sends tokens.
* @dev Executed when a purchase has been validated and is ready to be executed. Doesn't necessarily emit/send tokens.
* @param beneficiary Address receiving the tokens
* @param tokenAmount Number of tokens to be purchased
*/

View File

@ -3,7 +3,6 @@ pragma solidity ^0.4.24;
import "../../math/SafeMath.sol";
import "../validation/TimedCrowdsale.sol";
/**
* @title FinalizableCrowdsale
* @dev Extension of Crowdsale with a one-off finalization action, where one
@ -12,10 +11,14 @@ import "../validation/TimedCrowdsale.sol";
contract FinalizableCrowdsale is TimedCrowdsale {
using SafeMath for uint256;
bool private _finalized = false;
bool private _finalized;
event CrowdsaleFinalized();
constructor() internal {
_finalized = false;
}
/**
* @return true if the crowdsale is finalized, false otherwise.
*/
@ -31,10 +34,10 @@ contract FinalizableCrowdsale is TimedCrowdsale {
require(!_finalized);
require(hasClosed());
_finalized = true;
_finalization();
emit CrowdsaleFinalized();
_finalized = true;
}
/**
@ -44,5 +47,4 @@ contract FinalizableCrowdsale is TimedCrowdsale {
*/
function _finalization() internal {
}
}

View File

@ -1,10 +1,8 @@
pragma solidity ^0.4.24;
import "../validation/TimedCrowdsale.sol";
import "../../token/ERC20/IERC20.sol";
import "../../math/SafeMath.sol";
/**
* @title PostDeliveryCrowdsale
* @dev Crowdsale that locks tokens from withdrawal until it ends.
@ -14,6 +12,8 @@ contract PostDeliveryCrowdsale is TimedCrowdsale {
mapping(address => uint256) private _balances;
constructor() internal {}
/**
* @dev Withdraw tokens only after crowdsale ends.
* @param beneficiary Whose tokens will be withdrawn.

View File

@ -1,15 +1,26 @@
pragma solidity ^0.4.24;
import "../../math/SafeMath.sol";
import "./FinalizableCrowdsale.sol";
import "../../payment/RefundEscrow.sol";
import "../../payment/escrow/RefundEscrow.sol";
/**
* @title RefundableCrowdsale
* @dev Extension of Crowdsale contract that adds a funding goal, and
* the possibility of users getting a refund if goal is not met.
* WARNING: note that if you allow tokens to be traded before the goal
* is met, then an attack is possible in which the attacker purchases
* tokens from the crowdsale and when they sees that the goal is
* unlikely to be met, they sell their tokens (possibly at a discount).
* The attacker will be refunded when the crowdsale is finalized, and
* the users that purchased from them will be left with worthless
* tokens. There are many possible ways to avoid this, like making the
* the crowdsale inherit from PostDeliveryCrowdsale, or imposing
* restrictions on token trading until the crowdsale is finalized.
* This is being discussed in
* https://github.com/OpenZeppelin/openzeppelin-solidity/issues/877
* This contract will be updated when we agree on a general solution
* for this problem.
*/
contract RefundableCrowdsale is FinalizableCrowdsale {
using SafeMath for uint256;
@ -24,7 +35,7 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
* @dev Constructor, creates RefundEscrow.
* @param goal Funding goal
*/
constructor(uint256 goal) public {
constructor(uint256 goal) internal {
require(goal > 0);
_escrow = new RefundEscrow(wallet());
_goal = goal;

View File

@ -4,7 +4,7 @@ import "../Crowdsale.sol";
import "../../token/ERC20/IERC20.sol";
import "../../token/ERC20/SafeERC20.sol";
import "../../math/SafeMath.sol";
import "../../math/Math.sol";
/**
* @title AllowanceCrowdsale
@ -20,7 +20,7 @@ contract AllowanceCrowdsale is Crowdsale {
* @dev Constructor, takes token wallet address.
* @param tokenWallet Address holding the tokens, which has approved allowance to the crowdsale
*/
constructor(address tokenWallet) public {
constructor(address tokenWallet) internal {
require(tokenWallet != address(0));
_tokenWallet = tokenWallet;
}
@ -37,7 +37,10 @@ contract AllowanceCrowdsale is Crowdsale {
* @return Amount of tokens left in the allowance
*/
function remainingTokens() public view returns (uint256) {
return token().allowance(_tokenWallet, this);
return Math.min(
token().balanceOf(_tokenWallet),
token().allowance(_tokenWallet, this)
);
}
/**

View File

@ -3,13 +3,13 @@ pragma solidity ^0.4.24;
import "../Crowdsale.sol";
import "../../token/ERC20/ERC20Mintable.sol";
/**
* @title MintedCrowdsale
* @dev Extension of Crowdsale contract whose tokens are minted in each purchase.
* Token ownership should be transferred to MintedCrowdsale for minting.
*/
contract MintedCrowdsale is Crowdsale {
constructor() internal {}
/**
* @dev Overrides delivery by minting tokens upon purchase.

View File

@ -3,7 +3,6 @@ pragma solidity ^0.4.24;
import "../validation/TimedCrowdsale.sol";
import "../../math/SafeMath.sol";
/**
* @title IncreasingPriceCrowdsale
* @dev Extension of Crowdsale contract that increases the price of tokens linearly in time.
@ -21,13 +20,21 @@ contract IncreasingPriceCrowdsale is TimedCrowdsale {
* @param initialRate Number of tokens a buyer gets per wei at the start of the crowdsale
* @param finalRate Number of tokens a buyer gets per wei at the end of the crowdsale
*/
constructor(uint256 initialRate, uint256 finalRate) public {
constructor(uint256 initialRate, uint256 finalRate) internal {
require(finalRate > 0);
require(initialRate >= finalRate);
require(initialRate > finalRate);
_initialRate = initialRate;
_finalRate = finalRate;
}
/**
* The base rate function is overridden to revert, since this crowdsale doens't use it, and
* all calls to it are a mistake.
*/
function rate() public view returns(uint256) {
revert();
}
/**
* @return the initial rate of the crowdsale.
*/
@ -48,6 +55,10 @@ contract IncreasingPriceCrowdsale is TimedCrowdsale {
* @return The number of tokens a buyer gets per wei at a given time
*/
function getCurrentRate() public view returns (uint256) {
if (!isOpen()) {
return 0;
}
// solium-disable-next-line security/no-block-members
uint256 elapsedTime = block.timestamp.sub(openingTime());
uint256 timeRange = closingTime().sub(openingTime());

View File

@ -3,7 +3,6 @@ pragma solidity ^0.4.24;
import "../../math/SafeMath.sol";
import "../Crowdsale.sol";
/**
* @title CappedCrowdsale
* @dev Crowdsale with a limit for total contributions.
@ -17,7 +16,7 @@ contract CappedCrowdsale is Crowdsale {
* @dev Constructor, takes maximum amount of wei accepted in the crowdsale.
* @param cap Max amount of wei to be contributed
*/
constructor(uint256 cap) public {
constructor(uint256 cap) internal {
require(cap > 0);
_cap = cap;
}
@ -47,6 +46,7 @@ contract CappedCrowdsale is Crowdsale {
uint256 weiAmount
)
internal
view
{
super._preValidatePurchase(beneficiary, weiAmount);
require(weiRaised().add(weiAmount) <= _cap);

View File

@ -4,7 +4,6 @@ import "../../math/SafeMath.sol";
import "../Crowdsale.sol";
import "../../access/roles/CapperRole.sol";
/**
* @title IndividuallyCappedCrowdsale
* @dev Crowdsale with per-beneficiary caps.
@ -15,6 +14,8 @@ contract IndividuallyCappedCrowdsale is Crowdsale, CapperRole {
mapping(address => uint256) private _contributions;
mapping(address => uint256) private _caps;
constructor() internal {}
/**
* @dev Sets a specific beneficiary's maximum contribution.
* @param beneficiary Address to be capped
@ -54,6 +55,7 @@ contract IndividuallyCappedCrowdsale is Crowdsale, CapperRole {
uint256 weiAmount
)
internal
view
{
super._preValidatePurchase(beneficiary, weiAmount);
require(

View File

@ -3,7 +3,6 @@ pragma solidity ^0.4.24;
import "../../math/SafeMath.sol";
import "../Crowdsale.sol";
/**
* @title TimedCrowdsale
* @dev Crowdsale accepting contributions only within a time frame.
@ -27,10 +26,10 @@ contract TimedCrowdsale is Crowdsale {
* @param openingTime Crowdsale opening time
* @param closingTime Crowdsale closing time
*/
constructor(uint256 openingTime, uint256 closingTime) public {
constructor(uint256 openingTime, uint256 closingTime) internal {
// solium-disable-next-line security/no-block-members
require(openingTime >= block.timestamp);
require(closingTime >= openingTime);
require(closingTime > openingTime);
_openingTime = openingTime;
_closingTime = closingTime;
@ -78,6 +77,7 @@ contract TimedCrowdsale is Crowdsale {
)
internal
onlyWhileOpen
view
{
super._preValidatePurchase(beneficiary, weiAmount);
}

View File

@ -1,6 +1,5 @@
pragma solidity ^0.4.24;
/**
* @title Elliptic curve signature operations
* @dev Based on https://gist.github.com/axic/5b33912c6f61ae6fd96d6c4a47afde6d
@ -34,9 +33,9 @@ library ECDSA {
// currently is to use assembly.
// solium-disable-next-line security/no-inline-assembly
assembly {
r := mload(add(signature, 32))
s := mload(add(signature, 64))
v := byte(0, mload(add(signature, 96)))
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
// Version of signature should be 27 or 28, but 0 and 1 are also possible versions

View File

@ -1,6 +1,5 @@
pragma solidity ^0.4.24;
/**
* @title MerkleProof
* @dev Merkle proof verification based on

View File

@ -1,87 +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 {
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);
}

View File

@ -1,6 +1,5 @@
pragma solidity ^0.4.24;
/**
* @title Counter
* @author Matt Condon (@shrugs)

View File

@ -2,7 +2,6 @@ pragma solidity ^0.4.24;
import "../../token/ERC20/IERC20.sol";
/**
* @title ERC-1047 Token Metadata
* @dev See https://eips.ethereum.org/EIPS/eip-1046
@ -13,9 +12,8 @@ contract ERC20TokenMetadata is IERC20 {
function tokenURI() external view returns (string);
}
contract ERC20WithMetadata is ERC20TokenMetadata {
string private _tokenURI = "";
string private _tokenURI;
constructor(string tokenURI)
public

View File

@ -5,7 +5,6 @@ import "../token/ERC20/ERC20Mintable.sol";
import "../token/ERC20/SafeERC20.sol";
import "../math/Math.sol";
/**
* @title ERC20Migrator
* @dev This contract can be used to migrate an ERC20 token from one

View File

@ -3,30 +3,36 @@ pragma solidity ^0.4.24;
import "../access/roles/SignerRole.sol";
import "../cryptography/ECDSA.sol";
/**
* @title SignatureBouncer
* @author PhABC, Shrugs and aflesher
* @dev SignatureBouncer allows users to submit a signature as a permission to do an action.
* If the signature is from one of the authorized signer addresses, the signature
* is valid.
* @dev SignatureBouncer allows users to submit a signature as a permission to
* do an action.
* If the signature is from one of the authorized signer addresses, the
* signature is valid.
* Note that SignatureBouncer offers no protection against replay attacks, users
* must add this themselves!
*
* Signer addresses can be individual servers signing grants or different
* users within a decentralized club that have permission to invite other members.
* This technique is useful for whitelists and airdrops; instead of putting all
* valid addresses on-chain, simply sign a grant of the form
* keccak256(abi.encodePacked(`:contractAddress` + `:granteeAddress`)) using a valid signer address.
* users within a decentralized club that have permission to invite other
* members. This technique is useful for whitelists and airdrops; instead of
* putting all valid addresses on-chain, simply sign a grant of the form
* keccak256(abi.encodePacked(`:contractAddress` + `:granteeAddress`)) using a
* valid signer address.
* Then restrict access to your crowdsale/whitelist/airdrop using the
* `onlyValidSignature` modifier (or implement your own using _isValidSignature).
* In addition to `onlyValidSignature`, `onlyValidSignatureAndMethod` and
* `onlyValidSignatureAndData` can be used to restrict access to only a given method
* or a given method with given parameters respectively.
* `onlyValidSignatureAndData` can be used to restrict access to only a given
* method or a given method with given parameters respectively.
* See the tests in SignatureBouncer.test.js for specific usage examples.
* @notice A method that uses the `onlyValidSignatureAndData` modifier must make the _signature
* parameter the "last" parameter. You cannot sign a message that has its own
* signature in it so the last 128 bytes of msg.data (which represents the
* length of the _signature data and the _signaature data itself) is ignored when validating.
* Also non fixed sized parameters make constructing the data in the signature
* much more complex. See https://ethereum.stackexchange.com/a/50616 for more details.
*
* @notice A method that uses the `onlyValidSignatureAndData` modifier must make
* the _signature parameter the "last" parameter. You cannot sign a message that
* has its own signature in it so the last 128 bytes of msg.data (which
* represents the length of the _signature data and the _signaature data itself)
* is ignored when validating. Also non fixed sized parameters make constructing
* the data in the signature much more complex.
* See https://ethereum.stackexchange.com/a/50616 for more details.
*/
contract SignatureBouncer is SignerRole {
using ECDSA for bytes32;
@ -37,6 +43,8 @@ contract SignatureBouncer is SignerRole {
// Signature size is 65 bytes (tightly packed v + r + s), but gets padded to 96 bytes
uint256 private constant _SIGNATURE_SIZE = 96;
constructor() internal {}
/**
* @dev requires that a valid signature of a signer was provided
*/

View File

@ -6,7 +6,6 @@ import "../token/ERC20/SafeERC20.sol";
import "../ownership/Ownable.sol";
import "../math/SafeMath.sol";
/**
* @title TokenVesting
* @dev A token holder contract that can release its token balance gradually like a
@ -17,8 +16,8 @@ contract TokenVesting is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
event Released(uint256 amount);
event Revoked();
event TokensReleased(address token, uint256 amount);
event TokenVestingRevoked(address token);
// beneficiary of tokens after they are released
address private _beneficiary;
@ -53,6 +52,8 @@ contract TokenVesting is Ownable {
{
require(beneficiary != address(0));
require(cliffDuration <= duration);
require(duration > 0);
require(start.add(duration) > block.timestamp);
_beneficiary = beneficiary;
_revocable = revocable;
@ -115,7 +116,7 @@ contract TokenVesting is Ownable {
* @param token ERC20 token which is being vested
*/
function release(IERC20 token) public {
uint256 unreleased = releasableAmount(token);
uint256 unreleased = _releasableAmount(token);
require(unreleased > 0);
@ -123,7 +124,7 @@ contract TokenVesting is Ownable {
token.safeTransfer(_beneficiary, unreleased);
emit Released(unreleased);
emit TokensReleased(token, unreleased);
}
/**
@ -137,29 +138,29 @@ contract TokenVesting is Ownable {
uint256 balance = token.balanceOf(address(this));
uint256 unreleased = releasableAmount(token);
uint256 unreleased = _releasableAmount(token);
uint256 refund = balance.sub(unreleased);
_revoked[token] = true;
token.safeTransfer(owner(), refund);
emit Revoked();
emit TokenVestingRevoked(token);
}
/**
* @dev Calculates the amount that has already vested but hasn't been released yet.
* @param token ERC20 token which is being vested
*/
function releasableAmount(IERC20 token) public view returns (uint256) {
return vestedAmount(token).sub(_released[token]);
function _releasableAmount(IERC20 token) private view returns (uint256) {
return _vestedAmount(token).sub(_released[token]);
}
/**
* @dev Calculates the amount that has already vested.
* @param token ERC20 token which is being vested
*/
function vestedAmount(IERC20 token) public view returns (uint256) {
function _vestedAmount(IERC20 token) private view returns (uint256) {
uint256 currentBalance = token.balanceOf(this);
uint256 totalBalance = currentBalance.add(_released[token]);

View File

@ -4,21 +4,17 @@ import "../crowdsale/validation/CappedCrowdsale.sol";
import "../crowdsale/distribution/RefundableCrowdsale.sol";
import "../crowdsale/emission/MintedCrowdsale.sol";
import "../token/ERC20/ERC20Mintable.sol";
import "../token/ERC20/ERC20Detailed.sol";
/**
* @title SampleCrowdsaleToken
* @dev Very simple ERC20 Token that can be minted.
* It is meant to be used in a crowdsale contract.
*/
contract SampleCrowdsaleToken is ERC20Mintable {
string public constant name = "Sample Crowdsale Token";
string public constant symbol = "SCT";
uint8 public constant decimals = 18;
contract SampleCrowdsaleToken is ERC20Mintable, ERC20Detailed {
constructor() public ERC20Detailed("Sample Crowdsale Token", "SCT", 18) {}
}
/**
* @title SampleCrowdsale
* @dev This is an example of a fully fledged crowdsale.
@ -26,6 +22,8 @@ contract SampleCrowdsaleToken is ERC20Mintable {
* In this example we are providing following extensions:
* CappedCrowdsale - sets a max boundary for raised funds
* RefundableCrowdsale - set a min goal to be reached and returns funds if it's not met
* MintedCrowdsale - assumes the token can be minted by the crowdsale, which does so
* when receiving purchases.
*
* After adding multiple features it's good practice to run integration tests
* to ensure that subcontracts works together as intended.

View File

@ -1,9 +1,7 @@
pragma solidity ^0.4.24;
import "../token/ERC20/ERC20.sol";
/**
* @title SimpleToken
* @dev Very simple ERC20 Token example, where all tokens are pre-assigned to the creator.

View File

@ -2,7 +2,6 @@ pragma solidity ^0.4.24;
import "./IERC165.sol";
/**
* @title ERC165
* @author Matt Condon (@shrugs)
@ -19,14 +18,14 @@ contract ERC165 is IERC165 {
/**
* @dev a mapping of interface id to whether or not it's supported
*/
mapping(bytes4 => bool) internal _supportedInterfaces;
mapping(bytes4 => bool) private _supportedInterfaces;
/**
* @dev A contract implementing SupportsInterfaceWithLookup
* implement ERC165 itself
*/
constructor()
public
internal
{
_registerInterface(_InterfaceId_ERC165);
}
@ -43,7 +42,7 @@ contract ERC165 is IERC165 {
}
/**
* @dev private method for registering an interface
* @dev internal method for registering an interface
*/
function _registerInterface(bytes4 interfaceId)
internal

View File

@ -1,6 +1,5 @@
pragma solidity ^0.4.24;
/**
* @title ERC165Checker
* @dev Use `using ERC165Checker for address`; to include this library
@ -16,21 +15,20 @@ library ERC165Checker {
* bytes4(keccak256('supportsInterface(bytes4)'))
*/
/**
* @notice Query if a contract supports ERC165
* @param account The address of the contract to query for support of ERC165
* @return true if the contract at account implements ERC165
*/
function supportsERC165(address account)
function _supportsERC165(address account)
internal
view
returns (bool)
{
// Any contract that implements ERC165 must explicitly indicate support of
// InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid
return supportsERC165Interface(account, _InterfaceId_ERC165) &&
!supportsERC165Interface(account, _InterfaceId_Invalid);
return _supportsERC165Interface(account, _InterfaceId_ERC165) &&
!_supportsERC165Interface(account, _InterfaceId_Invalid);
}
/**
@ -41,14 +39,14 @@ library ERC165Checker {
* identifier interfaceId, false otherwise
* @dev Interface identification is specified in ERC-165.
*/
function supportsInterface(address account, bytes4 interfaceId)
function _supportsInterface(address account, bytes4 interfaceId)
internal
view
returns (bool)
{
// query support of both ERC165 as per the spec and support of _interfaceId
return supportsERC165(account) &&
supportsERC165Interface(account, interfaceId);
return _supportsERC165(account) &&
_supportsERC165Interface(account, interfaceId);
}
/**
@ -59,19 +57,19 @@ library ERC165Checker {
* interfaceIds list, false otherwise
* @dev Interface identification is specified in ERC-165.
*/
function supportsInterfaces(address account, bytes4[] interfaceIds)
function _supportsAllInterfaces(address account, bytes4[] interfaceIds)
internal
view
returns (bool)
{
// query support of ERC165 itself
if (!supportsERC165(account)) {
if (!_supportsERC165(account)) {
return false;
}
// query support of each interface in _interfaceIds
for (uint256 i = 0; i < interfaceIds.length; i++) {
if (!supportsERC165Interface(account, interfaceIds[i])) {
if (!_supportsERC165Interface(account, interfaceIds[i])) {
return false;
}
}
@ -91,14 +89,14 @@ library ERC165Checker {
* with the `supportsERC165` method in this library.
* Interface identification is specified in ERC-165.
*/
function supportsERC165Interface(address account, bytes4 interfaceId)
function _supportsERC165Interface(address account, bytes4 interfaceId)
private
view
returns (bool)
{
// success determines whether the staticcall succeeded and result determines
// whether the contract at account indicates support of _interfaceId
(bool success, bool result) = callERC165SupportsInterface(
(bool success, bool result) = _callERC165SupportsInterface(
account, interfaceId);
return (success && result);
@ -112,7 +110,7 @@ library ERC165Checker {
* @return result true if the STATICCALL succeeded and the contract at account
* indicates support of the interface with identifier interfaceId, false otherwise
*/
function callERC165SupportsInterface(
function _callERC165SupportsInterface(
address account,
bytes4 interfaceId
)

View File

@ -1,6 +1,5 @@
pragma solidity ^0.4.24;
/**
* @title IERC165
* @dev https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md

View File

@ -2,17 +2,19 @@ pragma solidity ^0.4.24;
import "../access/roles/PauserRole.sol";
/**
* @title Pausable
* @dev Base contract which allows children to implement an emergency stop mechanism.
*/
contract Pausable is PauserRole {
event Paused();
event Unpaused();
event Paused(address account);
event Unpaused(address account);
bool private _paused = false;
bool private _paused;
constructor() internal {
_paused = false;
}
/**
* @return true if the contract is paused, false otherwise.
@ -42,7 +44,7 @@ contract Pausable is PauserRole {
*/
function pause() public onlyPauser whenNotPaused {
_paused = true;
emit Paused();
emit Paused(msg.sender);
}
/**
@ -50,6 +52,6 @@ contract Pausable is PauserRole {
*/
function unpause() public onlyPauser whenPaused {
_paused = false;
emit Unpaused();
emit Unpaused(msg.sender);
}
}

View File

@ -1,19 +1,29 @@
pragma solidity ^0.4.24;
/**
* @title Math
* @dev Assorted math operations
*/
library Math {
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a >= b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Calculates the average of two numbers. Since these are integers,
* averages of an even and odd number cannot be represented, and will be
* rounded down.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow, so we distribute
return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2);

View File

@ -1,6 +1,5 @@
pragma solidity ^0.4.24;
/**
* @title SafeMath
* @dev Math operations with safety checks that revert on error

View File

@ -0,0 +1,14 @@
pragma solidity ^0.4.24;
import "../utils/Address.sol";
contract AddressImpl {
function isContract(address account)
external
view
returns (bool)
{
return Address.isContract(account);
}
}

View File

@ -3,7 +3,6 @@ pragma solidity ^0.4.24;
import "../token/ERC20/IERC20.sol";
import "../crowdsale/emission/AllowanceCrowdsale.sol";
contract AllowanceCrowdsaleImpl is AllowanceCrowdsale {
constructor (

View File

@ -0,0 +1,18 @@
pragma solidity ^0.4.24;
import "../utils/Arrays.sol";
contract ArraysImpl {
using Arrays for uint256[];
uint256[] private array;
constructor(uint256[] _array) public {
array = _array;
}
function findUpperBound(uint256 _element) external view returns (uint256) {
return array.findUpperBound(_element);
}
}

View File

@ -3,7 +3,6 @@ pragma solidity ^0.4.24;
import "../token/ERC20/IERC20.sol";
import "../crowdsale/validation/CappedCrowdsale.sol";
contract CappedCrowdsaleImpl is CappedCrowdsale {
constructor (

View File

@ -2,7 +2,6 @@ pragma solidity ^0.4.24;
import "../access/roles/CapperRole.sol";
contract CapperRoleMock is CapperRole {
function removeCapper(address account) public {
_removeCapper(account);

View File

@ -1,8 +1,6 @@
pragma solidity ^0.4.24;
import "../payment/ConditionalEscrow.sol";
import "../payment/escrow/ConditionalEscrow.sol";
// mock class using ConditionalEscrow
contract ConditionalEscrowMock is ConditionalEscrow {

View File

@ -2,7 +2,6 @@ pragma solidity ^0.4.24;
import "../drafts/Counter.sol";
contract CounterImpl {
using Counter for Counter.Counter;

View File

@ -0,0 +1,9 @@
pragma solidity ^0.4.24;
import "../crowdsale/Crowdsale.sol";
contract CrowdsaleMock is Crowdsale {
constructor(uint256 rate, address wallet, IERC20 token) public
Crowdsale(rate, wallet, token) {
}
}

View File

@ -3,7 +3,6 @@ pragma solidity ^0.4.24;
import "../token/ERC20/ERC20.sol";
import "../token/ERC20/ERC20Detailed.sol";
contract ERC20DetailedMock is ERC20, ERC20Detailed {
constructor(
string name,

View File

@ -1,9 +1,7 @@
pragma solidity ^0.4.24;
import "../cryptography/ECDSA.sol";
contract ECDSAMock {
using ECDSA for bytes32;

View File

@ -2,7 +2,6 @@ pragma solidity ^0.4.24;
import "../../introspection/IERC165.sol";
/**
* https://github.com/ethereum/EIPs/blob/master/EIPS/eip-214.md#specification
* > Any attempts to make state-changing operations inside an execution instance with STATIC set to true will instead throw an exception.
@ -22,7 +21,7 @@ contract SupportsInterfaceWithLookupMock is IERC165 {
/**
* @dev a mapping of interface id to whether or not it's supported
*/
mapping(bytes4 => bool) internal supportedInterfaces;
mapping(bytes4 => bool) private _supportedInterfaces;
/**
* @dev A contract implementing SupportsInterfaceWithLookup
@ -42,7 +41,7 @@ contract SupportsInterfaceWithLookupMock is IERC165 {
view
returns (bool)
{
return supportedInterfaces[interfaceId];
return _supportedInterfaces[interfaceId];
}
/**
@ -52,12 +51,10 @@ contract SupportsInterfaceWithLookupMock is IERC165 {
internal
{
require(interfaceId != 0xffffffff);
supportedInterfaces[interfaceId] = true;
_supportedInterfaces[interfaceId] = true;
}
}
contract ERC165InterfacesSupported is SupportsInterfaceWithLookupMock {
constructor (bytes4[] interfaceIds)
public

View File

@ -1,6 +1,5 @@
pragma solidity ^0.4.24;
contract ERC165NotSupported {
}

View File

@ -2,7 +2,6 @@ pragma solidity ^0.4.24;
import "../introspection/ERC165Checker.sol";
contract ERC165CheckerMock {
using ERC165Checker for address;
@ -11,7 +10,7 @@ contract ERC165CheckerMock {
view
returns (bool)
{
return account.supportsERC165();
return account._supportsERC165();
}
function supportsInterface(address account, bytes4 interfaceId)
@ -19,14 +18,14 @@ contract ERC165CheckerMock {
view
returns (bool)
{
return account.supportsInterface(interfaceId);
return account._supportsInterface(interfaceId);
}
function supportsInterfaces(address account, bytes4[] interfaceIds)
function supportsAllInterfaces(address account, bytes4[] interfaceIds)
public
view
returns (bool)
{
return account.supportsInterfaces(interfaceIds);
return account._supportsAllInterfaces(interfaceIds);
}
}

View File

@ -2,7 +2,6 @@ pragma solidity ^0.4.24;
import "../introspection/ERC165.sol";
contract ERC165Mock is ERC165 {
function registerInterface(bytes4 interfaceId)
public

View File

@ -2,7 +2,6 @@ pragma solidity ^0.4.24;
import "../token/ERC20/ERC20Burnable.sol";
contract ERC20BurnableMock is ERC20Burnable {
constructor(address initialAccount, uint256 initialBalance) public {

View File

@ -3,6 +3,5 @@ pragma solidity ^0.4.24;
import "../token/ERC20/ERC20Mintable.sol";
import "./MinterRoleMock.sol";
contract ERC20MintableMock is ERC20Mintable, MinterRoleMock {
}

View File

@ -2,7 +2,6 @@ pragma solidity ^0.4.24;
import "../token/ERC20/ERC20.sol";
// mock class using ERC20
contract ERC20Mock is ERC20 {

View File

@ -3,7 +3,6 @@ pragma solidity ^0.4.24;
import "../token/ERC20/ERC20Pausable.sol";
import "./PauserRoleMock.sol";
// mock class using ERC20Pausable
contract ERC20PausableMock is ERC20Pausable, PauserRoleMock {

View File

@ -3,7 +3,6 @@ pragma solidity ^0.4.24;
import "../token/ERC20/ERC20.sol";
import "../drafts/ERC1046/TokenMetadata.sol";
contract ERC20WithMetadataMock is ERC20, ERC20WithMetadata {
constructor(string tokenURI) public
ERC20WithMetadata(tokenURI)

View File

@ -2,15 +2,17 @@ pragma solidity ^0.4.24;
import "../token/ERC721/ERC721Full.sol";
import "../token/ERC721/ERC721Mintable.sol";
import "../token/ERC721/ERC721MetadataMintable.sol";
import "../token/ERC721/ERC721Burnable.sol";
/**
* @title ERC721Mock
* @title ERC721FullMock
* This mock just provides a public mint and burn functions for testing purposes,
* and a public setter for metadata URI
*/
contract ERC721FullMock is ERC721Full, ERC721Mintable, ERC721Burnable {
contract ERC721FullMock
is ERC721Full, ERC721Mintable, ERC721MetadataMintable, ERC721Burnable {
constructor(string name, string symbol) public
ERC721Mintable()
ERC721Full(name, symbol)

View File

@ -2,14 +2,14 @@ pragma solidity ^0.4.24;
import "../token/ERC721/ERC721Full.sol";
import "../token/ERC721/ERC721Mintable.sol";
import "../token/ERC721/ERC721MetadataMintable.sol";
import "../token/ERC721/ERC721Burnable.sol";
/**
* @title ERC721MintableBurnableImpl
*/
contract ERC721MintableBurnableImpl
is ERC721Full, ERC721Mintable, ERC721Burnable {
is ERC721Full, ERC721Mintable, ERC721MetadataMintable, ERC721Burnable {
constructor()
ERC721Mintable()

View File

@ -2,7 +2,6 @@ pragma solidity ^0.4.24;
import "../token/ERC721/ERC721.sol";
/**
* @title ERC721Mock
* This mock just provides a public mint and burn functions for testing purposes

View File

@ -3,7 +3,6 @@ pragma solidity ^0.4.24;
import "../token/ERC721/ERC721Pausable.sol";
import "./PauserRoleMock.sol";
/**
* @title ERC721PausableMock
* This mock just provides a public mint, burn and exists functions for testing purposes

View File

@ -2,7 +2,6 @@ pragma solidity ^0.4.24;
import "../token/ERC721/IERC721Receiver.sol";
contract ERC721ReceiverMock is IERC721Receiver {
bytes4 private _retval;
bool private _reverts;

View File

@ -0,0 +1,62 @@
pragma solidity ^0.4.24;
contract EventEmitter {
event Argumentless();
event ShortUint(uint8 value);
event ShortInt(int8 value);
event LongUint(uint256 value);
event LongInt(int256 value);
event Address(address value);
event Boolean(bool value);
event String(string value);
event LongUintBooleanString(
uint256 uintValue,
bool booleanValue,
string stringValue
);
function emitArgumentless() public {
emit Argumentless();
}
function emitShortUint(uint8 value) public {
emit ShortUint(value);
}
function emitShortInt(int8 value) public {
emit ShortInt(value);
}
function emitLongUint(uint256 value) public {
emit LongUint(value);
}
function emitLongInt(int256 value) public {
emit LongInt(value);
}
function emitAddress(address value) public {
emit Address(value);
}
function emitBoolean(bool value) public {
emit Boolean(value);
}
function emitString(string value) public {
emit String(value);
}
function emitLongUintBooleanString(
uint256 uintValue,
bool booleanValue,
string stringValue)
public {
emit LongUintBooleanString(uintValue, booleanValue, stringValue);
}
function emitLongUintAndBoolean(uint256 uintValue, bool boolValue) public {
emit LongUint(uintValue);
emit Boolean(boolValue);
}
}

View File

@ -3,7 +3,6 @@ pragma solidity ^0.4.24;
import "../token/ERC20/IERC20.sol";
import "../crowdsale/distribution/FinalizableCrowdsale.sol";
contract FinalizableCrowdsaleImpl is FinalizableCrowdsale {
constructor (

View File

@ -1,16 +0,0 @@
pragma solidity ^0.4.24;
// @title Force Ether into a contract.
// @notice even
// if the contract is not payable.
// @notice To use, construct the contract with the target as argument.
// @author Remco Bloemen <remco@neufund.org>
contract ForceEther {
constructor() public payable { }
function destroyAndSend(address recipient) public {
selfdestruct(recipient);
}
}

View File

@ -3,7 +3,6 @@ pragma solidity ^0.4.24;
import "../crowdsale/price/IncreasingPriceCrowdsale.sol";
import "../math/SafeMath.sol";
contract IncreasingPriceCrowdsaleImpl is IncreasingPriceCrowdsale {
constructor (

View File

@ -4,7 +4,6 @@ import "../token/ERC20/IERC20.sol";
import "../crowdsale/validation/IndividuallyCappedCrowdsale.sol";
import "./CapperRoleMock.sol";
contract IndividuallyCappedCrowdsaleImpl
is IndividuallyCappedCrowdsale, CapperRoleMock {

View File

@ -1,20 +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 InsecureInvariantTargetMock is Target {
function checkInvariant() public returns(bool) {
return false;
}
}
contract InsecureInvariantTargetBounty is BreakInvariantBounty {
function _deployContract() internal returns (address) {
return new InsecureInvariantTargetMock();
}
}

View File

@ -1,9 +1,7 @@
pragma solidity ^0.4.24;
import "../math/Math.sol";
contract MathMock {
function max(uint256 a, uint256 b) public pure returns (uint256) {
return Math.max(a, b);

View File

@ -2,7 +2,6 @@ pragma solidity ^0.4.24;
import { MerkleProof } from "../cryptography/MerkleProof.sol";
contract MerkleProofWrapper {
function verify(

View File

@ -1,50 +0,0 @@
pragma solidity ^0.4.24;
contract MessageHelper {
event Show(bytes32 b32, uint256 number, string text);
event Buy(bytes32 b32, uint256 number, string text, uint256 value);
function showMessage(
bytes32 _message,
uint256 _number,
string _text
)
public
returns (bool)
{
emit Show(_message, _number, _text);
return true;
}
function buyMessage(
bytes32 _message,
uint256 _number,
string _text
)
public
payable
returns (bool)
{
emit Buy(
_message,
_number,
_text,
msg.value);
return true;
}
function fail() public {
require(false);
}
function call(address _to, bytes _data) public returns (bool) {
// solium-disable-next-line security/no-low-level-calls
if (_to.call(_data))
return true;
else
return false;
}
}

View File

@ -3,7 +3,6 @@ pragma solidity ^0.4.24;
import "../token/ERC20/ERC20Mintable.sol";
import "../crowdsale/emission/MintedCrowdsale.sol";
contract MintedCrowdsaleImpl is MintedCrowdsale {
constructor (

View File

@ -2,7 +2,6 @@ pragma solidity ^0.4.24;
import "../access/roles/MinterRole.sol";
contract MinterRoleMock is MinterRole {
function removeMinter(address account) public {
_removeMinter(account);

View File

@ -0,0 +1,6 @@
pragma solidity ^0.4.24;
import "../ownership/Ownable.sol";
contract OwnableMock is Ownable {
}

View File

@ -1,10 +1,8 @@
pragma solidity ^0.4.24;
import "../lifecycle/Pausable.sol";
import "./PauserRoleMock.sol";
// mock class using Pausable
contract PausableMock is Pausable, PauserRoleMock {
bool public drasticMeasureTaken;

View File

@ -2,7 +2,6 @@ pragma solidity ^0.4.24;
import "../access/roles/PauserRole.sol";
contract PauserRoleMock is PauserRole {
function removePauser(address account) public {
_removePauser(account);

View File

@ -3,7 +3,6 @@ pragma solidity ^0.4.24;
import "../token/ERC20/IERC20.sol";
import "../crowdsale/distribution/PostDeliveryCrowdsale.sol";
contract PostDeliveryCrowdsaleImpl is PostDeliveryCrowdsale {
constructor (

View File

@ -1,9 +1,7 @@
pragma solidity ^0.4.24;
import "../payment/PullPayment.sol";
// mock class using PullPayment
contract PullPaymentMock is PullPayment {

View File

@ -1,6 +1,5 @@
pragma solidity ^0.4.24;
contract ReentrancyAttack {
function callSender(bytes4 data) public {

View File

@ -3,7 +3,6 @@ pragma solidity ^0.4.24;
import "../utils/ReentrancyGuard.sol";
import "./ReentrancyAttack.sol";
contract ReentrancyMock is ReentrancyGuard {
uint256 public counter;

View File

@ -3,7 +3,6 @@ pragma solidity ^0.4.24;
import "../token/ERC20/ERC20Mintable.sol";
import "../crowdsale/distribution/RefundableCrowdsale.sol";
contract RefundableCrowdsaleImpl is RefundableCrowdsale {
constructor (

View File

@ -2,7 +2,6 @@ pragma solidity ^0.4.24;
import "../access/Roles.sol";
contract RolesMock {
using Roles for Roles.Role;

View File

@ -3,11 +3,8 @@ pragma solidity ^0.4.24;
import "../token/ERC20/IERC20.sol";
import "../token/ERC20/SafeERC20.sol";
contract ERC20FailingMock is IERC20 {
function totalSupply() public view returns (uint256) {
return 0;
}
contract ERC20FailingMock {
uint256 private _allowance;
function transfer(address, uint256) public returns (bool) {
return false;
@ -21,20 +18,13 @@ contract ERC20FailingMock is IERC20 {
return false;
}
function balanceOf(address) public view returns (uint256) {
return 0;
}
function allowance(address, address) public view returns (uint256) {
return 0;
}
}
contract ERC20SucceedingMock is IERC20 {
function totalSupply() public view returns (uint256) {
return 0;
}
contract ERC20SucceedingMock {
uint256 private _allowance;
function transfer(address, uint256) public returns (bool) {
return true;
@ -48,16 +38,15 @@ contract ERC20SucceedingMock is IERC20 {
return true;
}
function balanceOf(address) public view returns (uint256) {
return 0;
function setAllowance(uint256 allowance_) public {
_allowance = allowance_;
}
function allowance(address, address) public view returns (uint256) {
return 0;
return _allowance;
}
}
contract SafeERC20Helper {
using SafeERC20 for IERC20;
@ -65,10 +54,12 @@ contract SafeERC20Helper {
IERC20 private _succeeding;
constructor() public {
_failing = new ERC20FailingMock();
_succeeding = new ERC20SucceedingMock();
_failing = IERC20(new ERC20FailingMock());
_succeeding = IERC20(new ERC20SucceedingMock());
}
// Using _failing
function doFailingTransfer() public {
_failing.safeTransfer(address(0), 0);
}
@ -81,6 +72,16 @@ contract SafeERC20Helper {
_failing.safeApprove(address(0), 0);
}
function doFailingIncreaseAllowance() public {
_failing.safeIncreaseAllowance(address(0), 0);
}
function doFailingDecreaseAllowance() public {
_failing.safeDecreaseAllowance(address(0), 0);
}
// Using _succeeding
function doSucceedingTransfer() public {
_succeeding.safeTransfer(address(0), 0);
}
@ -89,7 +90,23 @@ contract SafeERC20Helper {
_succeeding.safeTransferFrom(address(0), address(0), 0);
}
function doSucceedingApprove() public {
_succeeding.safeApprove(address(0), 0);
function doSucceedingApprove(uint256 amount) public {
_succeeding.safeApprove(address(0), amount);
}
function doSucceedingIncreaseAllowance(uint256 amount) public {
_succeeding.safeIncreaseAllowance(address(0), amount);
}
function doSucceedingDecreaseAllowance(uint256 amount) public {
_succeeding.safeDecreaseAllowance(address(0), amount);
}
function setAllowance(uint256 allowance_) public {
ERC20SucceedingMock(_succeeding).setAllowance(allowance_);
}
function allowance() public view returns (uint256) {
return _succeeding.allowance(address(0), address(0));
}
}

View File

@ -1,9 +1,7 @@
pragma solidity ^0.4.24;
import "../math/SafeMath.sol";
contract SafeMathMock {
function mul(uint256 a, uint256 b) public pure returns (uint256) {

View File

@ -2,7 +2,6 @@ pragma solidity ^0.4.24;
import "../ownership/Secondary.sol";
contract SecondaryMock is Secondary {
function onlyPrimaryMock() public view onlyPrimary {
}

View File

@ -1,20 +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 SecureInvariantTargetMock is Target {
function checkInvariant() public returns(bool) {
return true;
}
}
contract SecureInvariantTargetBounty is BreakInvariantBounty {
function _deployContract() internal returns (address) {
return new SecureInvariantTargetMock();
}
}

View File

@ -3,7 +3,6 @@ pragma solidity ^0.4.24;
import "../drafts/SignatureBouncer.sol";
import "./SignerRoleMock.sol";
contract SignatureBouncerMock is SignatureBouncer, SignerRoleMock {
function checkValidSignature(address account, bytes signature)
public
@ -64,4 +63,11 @@ contract SignatureBouncerMock is SignatureBouncer, SignerRoleMock {
{
}
function tooShortMsgData()
public
onlyValidSignatureAndData("")
view
{
}
}

View File

@ -2,7 +2,6 @@ pragma solidity ^0.4.24;
import "../access/roles/SignerRole.sol";
contract SignerRoleMock is SignerRole {
function removeSigner(address account) public {
_removeSigner(account);

View File

@ -3,7 +3,6 @@ pragma solidity ^0.4.24;
import "../token/ERC20/IERC20.sol";
import "../crowdsale/validation/TimedCrowdsale.sol";
contract TimedCrowdsaleImpl is TimedCrowdsale {
constructor (

View File

@ -1,6 +1,5 @@
pragma solidity ^0.4.24;
/**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
@ -9,20 +8,18 @@ pragma solidity ^0.4.24;
contract Ownable {
address private _owner;
event OwnershipRenounced(address indexed previousOwner);
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor() public {
constructor() internal {
_owner = msg.sender;
emit OwnershipTransferred(address(0), _owner);
}
/**
@ -54,7 +51,7 @@ contract Ownable {
* modifier anymore.
*/
function renounceOwnership() public onlyOwner {
emit OwnershipRenounced(_owner);
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}

View File

@ -1,6 +1,5 @@
pragma solidity ^0.4.24;
/**
* @title Secondary
* @dev A Secondary contract can only be used by its primary account (the one that created it)
@ -8,11 +7,16 @@ pragma solidity ^0.4.24;
contract Secondary {
address private _primary;
event PrimaryTransferred(
address recipient
);
/**
* @dev Sets the primary account to the one that is creating the Secondary contract.
*/
constructor() public {
constructor() internal {
_primary = msg.sender;
emit PrimaryTransferred(_primary);
}
/**
@ -23,13 +27,20 @@ contract Secondary {
_;
}
/**
* @return the address of the primary.
*/
function primary() public view returns (address) {
return _primary;
}
/**
* @dev Transfers contract to a new primary.
* @param recipient The address of new primary.
*/
function transferPrimary(address recipient) public onlyPrimary {
require(recipient != address(0));
_primary = recipient;
emit PrimaryTransferred(_primary);
}
}

View File

@ -2,17 +2,20 @@ pragma solidity ^0.4.24;
import "../math/SafeMath.sol";
/**
* @title SplitPayment
* @title PaymentSplitter
* @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.
*/
contract SplitPayment {
contract PaymentSplitter {
using SafeMath for uint256;
uint256 private _totalShares = 0;
uint256 private _totalReleased = 0;
event PayeeAdded(address account, uint256 shares);
event PaymentReleased(address to, uint256 amount);
event PaymentReceived(address from, uint256 amount);
uint256 private _totalShares;
uint256 private _totalReleased;
mapping(address => uint256) private _shares;
mapping(address => uint256) private _released;
@ -33,7 +36,9 @@ contract SplitPayment {
/**
* @dev payable fallback
*/
function () external payable {}
function () external payable {
emit PaymentReceived(msg.sender, msg.value);
}
/**
* @return the total shares of the contract.
@ -85,12 +90,12 @@ contract SplitPayment {
);
require(payment != 0);
assert(address(this).balance >= payment);
_released[account] = _released[account].add(payment);
_totalReleased = _totalReleased.add(payment);
account.transfer(payment);
emit PaymentReleased(account, payment);
}
/**
@ -98,7 +103,7 @@ contract SplitPayment {
* @param account The address of the payee to add.
* @param shares_ The number of shares owned by the payee.
*/
function _addPayee(address account, uint256 shares_) internal {
function _addPayee(address account, uint256 shares_) private {
require(account != address(0));
require(shares_ > 0);
require(_shares[account] == 0);
@ -106,5 +111,6 @@ contract SplitPayment {
_payees.push(account);
_shares[account] = shares_;
_totalShares = _totalShares.add(shares_);
emit PayeeAdded(account, shares_);
}
}

View File

@ -1,7 +1,6 @@
pragma solidity ^0.4.24;
import "./Escrow.sol";
import "./escrow/Escrow.sol";
/**
* @title PullPayment
@ -11,7 +10,7 @@ import "./Escrow.sol";
contract PullPayment {
Escrow private _escrow;
constructor() public {
constructor() internal {
_escrow = new Escrow();
}

View File

@ -2,10 +2,10 @@ pragma solidity ^0.4.24;
import "./Escrow.sol";
/**
* @title ConditionalEscrow
* @dev Base abstract escrow to only allow withdrawal if a condition is met.
* @dev Intended usage: See Escrow.sol. Same usage guidelines apply here.
*/
contract ConditionalEscrow is Escrow {
/**

View File

@ -1,15 +1,19 @@
pragma solidity ^0.4.24;
import "../math/SafeMath.sol";
import "../ownership/Secondary.sol";
import "../../math/SafeMath.sol";
import "../../ownership/Secondary.sol";
/**
/**
* @title Escrow
* @dev Base escrow contract, holds funds destinated to a payee until they
* withdraw them. The contract that uses the escrow as its payment method
* should be its primary, and provide public methods redirecting to the escrow's
* deposit and withdraw.
* @dev Base escrow contract, holds funds designated for a payee until they
* withdraw them.
* @dev Intended usage: This contract (and derived escrow contracts) should be a
* standalone contract, that only interacts with the contract that instantiated
* it. That way, it is guaranteed that all Ether will be handled according to
* the Escrow rules, and there is no need to check for payable functions or
* transfers in the inheritance tree. The contract that uses the escrow as its
* payment method should be its primary, and provide public methods redirecting
* to the escrow's deposit and withdraw.
*/
contract Escrow is Secondary {
using SafeMath for uint256;
@ -40,7 +44,6 @@ contract Escrow is Secondary {
*/
function withdraw(address payee) public onlyPrimary {
uint256 payment = _deposits[payee];
assert(address(this).balance >= payment);
_deposits[payee] = 0;

View File

@ -1,19 +1,22 @@
pragma solidity ^0.4.24;
import "./ConditionalEscrow.sol";
import "../ownership/Secondary.sol";
/**
* @title RefundEscrow
* @dev Escrow that holds funds for a beneficiary, deposited from multiple parties.
* The primary account may close the deposit period, and allow for either withdrawal
* by the beneficiary, or refunds to the depositors.
* @dev Escrow that holds funds for a beneficiary, deposited from multiple
* parties.
* @dev Intended usage: See Escrow.sol. Same usage guidelines apply here.
* @dev The primary account (that is, the contract that instantiates this
* contract) may deposit, close the deposit period, and allow for either
* withdrawal by the beneficiary, or refunds to the depositors. All interactions
* with RefundEscrow will be made through the primary contract. See the
* RefundableCrowdsale contract for an example of RefundEscrows use.
*/
contract RefundEscrow is Secondary, ConditionalEscrow {
contract RefundEscrow is ConditionalEscrow {
enum State { Active, Refunding, Closed }
event Closed();
event RefundsClosed();
event RefundsEnabled();
State private _state;
@ -59,7 +62,7 @@ contract RefundEscrow is Secondary, ConditionalEscrow {
function close() public onlyPrimary {
require(_state == State.Active);
_state = State.Closed;
emit Closed();
emit RefundsClosed();
}
/**

View File

@ -3,7 +3,6 @@ pragma solidity ^0.4.24;
import "./IERC20.sol";
import "../../math/SafeMath.sol";
/**
* @title Standard ERC20 token
*
@ -29,7 +28,7 @@ contract ERC20 is IERC20 {
/**
* @dev Gets the balance of the specified address.
* @param owner The address to query the the balance of.
* @param owner The address to query the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address owner) public view returns (uint256) {
@ -59,12 +58,7 @@ contract ERC20 is IERC20 {
* @param value The amount to be transferred.
*/
function transfer(address to, uint256 value) public returns (bool) {
require(value <= _balances[msg.sender]);
require(to != address(0));
_balances[msg.sender] = _balances[msg.sender].sub(value);
_balances[to] = _balances[to].add(value);
emit Transfer(msg.sender, to, value);
_transfer(msg.sender, to, value);
return true;
}
@ -99,14 +93,10 @@ contract ERC20 is IERC20 {
public
returns (bool)
{
require(value <= _balances[from]);
require(value <= _allowed[from][msg.sender]);
require(to != address(0));
_balances[from] = _balances[from].sub(value);
_balances[to] = _balances[to].add(value);
_allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value);
emit Transfer(from, to, value);
_transfer(from, to, value);
return true;
}
@ -158,33 +148,48 @@ contract ERC20 is IERC20 {
return true;
}
/**
* @dev Transfer token for a specified addresses
* @param from The address to transfer from.
* @param to The address to transfer to.
* @param value The amount to be transferred.
*/
function _transfer(address from, address to, uint256 value) internal {
require(value <= _balances[from]);
require(to != address(0));
_balances[from] = _balances[from].sub(value);
_balances[to] = _balances[to].add(value);
emit Transfer(from, to, value);
}
/**
* @dev Internal function that mints an amount of the token and assigns it to
* an account. This encapsulates the modification of balances such that the
* proper events are emitted.
* @param account The account that will receive the created tokens.
* @param amount The amount that will be created.
* @param value The amount that will be created.
*/
function _mint(address account, uint256 amount) internal {
function _mint(address account, uint256 value) internal {
require(account != 0);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
_totalSupply = _totalSupply.add(value);
_balances[account] = _balances[account].add(value);
emit Transfer(address(0), account, value);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account.
* @param account The account whose tokens will be burnt.
* @param amount The amount that will be burnt.
* @param value The amount that will be burnt.
*/
function _burn(address account, uint256 amount) internal {
function _burn(address account, uint256 value) internal {
require(account != 0);
require(amount <= _balances[account]);
require(value <= _balances[account]);
_totalSupply = _totalSupply.sub(amount);
_balances[account] = _balances[account].sub(amount);
emit Transfer(account, address(0), amount);
_totalSupply = _totalSupply.sub(value);
_balances[account] = _balances[account].sub(value);
emit Transfer(account, address(0), value);
}
/**
@ -192,15 +197,15 @@ contract ERC20 is IERC20 {
* account, deducting from the sender's allowance for said account. Uses the
* internal burn function.
* @param account The account whose tokens will be burnt.
* @param amount The amount that will be burnt.
* @param value The amount that will be burnt.
*/
function _burnFrom(address account, uint256 amount) internal {
require(amount <= _allowed[account][msg.sender]);
function _burnFrom(address account, uint256 value) internal {
require(value <= _allowed[account][msg.sender]);
// Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted,
// this function needs to emit an event with the updated approval.
_allowed[account][msg.sender] = _allowed[account][msg.sender].sub(
amount);
_burn(account, amount);
value);
_burn(account, value);
}
}

View File

@ -2,7 +2,6 @@ pragma solidity ^0.4.24;
import "./ERC20.sol";
/**
* @title Burnable Token
* @dev Token that can be irreversibly burned (destroyed).
@ -25,12 +24,4 @@ contract ERC20Burnable is ERC20 {
function burnFrom(address from, uint256 value) public {
_burnFrom(from, value);
}
/**
* @dev Overrides ERC20._burn in order for burn and burnFrom to emit
* an additional Burn event.
*/
function _burn(address who, uint256 value) internal {
super._burn(who, value);
}
}

View File

@ -2,7 +2,6 @@ pragma solidity ^0.4.24;
import "./ERC20Mintable.sol";
/**
* @title Capped token
* @dev Mintable token with a token cap.
@ -25,22 +24,8 @@ contract ERC20Capped is ERC20Mintable {
return _cap;
}
/**
* @dev Function to mint tokens
* @param to The address that will receive the minted tokens.
* @param amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(
address to,
uint256 amount
)
public
returns (bool)
{
require(totalSupply().add(amount) <= _cap);
return super.mint(to, amount);
function _mint(address account, uint256 value) internal {
require(totalSupply().add(value) <= _cap);
super._mint(account, value);
}
}

View File

@ -2,7 +2,6 @@ pragma solidity ^0.4.24;
import "./IERC20.sol";
/**
* @title ERC20Detailed token
* @dev The decimals are only for visualization purposes.

View File

@ -3,59 +3,26 @@ pragma solidity ^0.4.24;
import "./ERC20.sol";
import "../../access/roles/MinterRole.sol";
/**
* @title ERC20Mintable
* @dev ERC20 minting logic
*/
contract ERC20Mintable is ERC20, MinterRole {
event MintingFinished();
bool private _mintingFinished = false;
modifier onlyBeforeMintingFinished() {
require(!_mintingFinished);
_;
}
/**
* @return true if the minting is finished.
*/
function mintingFinished() public view returns(bool) {
return _mintingFinished;
}
/**
* @dev Function to mint tokens
* @param to The address that will receive the minted tokens.
* @param amount The amount of tokens to mint.
* @param value The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(
address to,
uint256 amount
uint256 value
)
public
onlyMinter
onlyBeforeMintingFinished
returns (bool)
{
_mint(to, amount);
return true;
}
/**
* @dev Function to stop minting new tokens.
* @return True if the operation was successful.
*/
function finishMinting()
public
onlyMinter
onlyBeforeMintingFinished
returns (bool)
{
_mintingFinished = true;
emit MintingFinished();
_mint(to, value);
return true;
}
}

Some files were not shown because too many files have changed in this diff Show More