Skip to content

Commit af5f855

Browse files
author
Leo Arias
committed
Merge branch 'master' into refactor/past-tense-events
2 parents 23f9ad7 + 132994d commit af5f855

File tree

103 files changed

+2359
-1308
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+2359
-1308
lines changed

.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"eqeqeq": ["error", "smart"],
3333
"generator-star-spacing": ["error", "before"],
3434
"indent": ["error", 2],
35+
"linebreak-style": ["error", "unix"],
3536
"max-len": ["error", 120, 2],
3637
"no-debugger": "off",
3738
"no-dupe-args": "error",

.soliumrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"rules": {
55
"error-reason": "off",
66
"indentation": ["error", 2],
7+
"linebreak-style": ["error", "unix"],
78
"max-len": ["error", 79],
89
"no-constant": ["error"],
910
"no-empty-blocks": "off",

.travis.yml

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,52 @@
11
dist: trusty
2-
sudo: required
2+
sudo: false
33
group: beta
44
language: node_js
55
node_js:
66
- "8"
7+
78
cache:
89
directories:
910
- node_modules
10-
env:
11-
-
12-
- SOLIDITY_COVERAGE=true
13-
- SOLC_NIGHTLY=true
14-
matrix:
11+
12+
jobs:
13+
# XXX fast_finish doesn't work with stages yet. See
14+
# https://github.com/travis-ci/travis-ci/issues/8425
15+
# --elopio - 20180531
1516
fast_finish: true
1617
allow_failures:
1718
- env: SOLIDITY_COVERAGE=true
1819
- env: SOLC_NIGHTLY=true
19-
before_script:
20-
- truffle version
21-
script:
22-
- npm run lint
23-
- npm run lint:sol
24-
- npm run test
20+
include:
21+
# Run the unit test suite three times in parallel.
22+
# The first one gets results faster and is the only one required to pass.
23+
# The second one generates the coverage report.
24+
# The third one is to keep us informed about possible issues with the
25+
# upcoming solidity release.
26+
- stage: tests
27+
name: "unit tests"
28+
script: npm run test
29+
- stage: tests
30+
name: "unit tests with coverage"
31+
script: npm run test
32+
env: SOLIDITY_COVERAGE=true
33+
- stage: tests
34+
name: "unit tests with solc nightly"
35+
script: npm run test
36+
env: SOLC_NIGHTLY=true
37+
# solidity and javascript style tests.
38+
- stage: tests
39+
name: "static tests"
40+
script: npm run lint
41+
- stage: update docs
42+
if: tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+$
43+
addons:
44+
apt:
45+
packages:
46+
- curl
47+
script:
48+
- ./scripts/ci/trigger_docs_update "${TRAVIS_TAG}"
49+
2550
notifications:
2651
slack:
2752
rooms:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ The following provides visibility into how OpenZeppelin's contracts are organize
8989
- **ERC20** - A standard interface for fungible tokens:
9090
- *Interfaces* - Includes the ERC-20 token standard basic interface. I.e., what the contract’s ABI can represent.
9191
- *Implementations* - Includes ERC-20 token implementations that include all required and some optional ERC-20 functionality.
92-
- **ERC721** - A standard interface for non-fungible tokens
92+
- **ERC721** - A standard interface for non-fungible tokens
9393
- *Interfaces* - Includes the ERC-721 token standard basic interface. I.e., what the contract’s ABI can represent.
9494
- *Implementations* - Includes ERC-721 token implementations that include all required and some optional ERC-721 functionality.
9595

RELEASING.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ We release a new version of OpenZeppelin monthly. Release cycles are tracked in
77
Each release has at least one release candidate published first, intended for community review and any critical fixes that may come out of it. At the moment we leave 1 week between the first release candidate and the final release.
88

99
Before starting make sure to verify the following items.
10-
* Your local `master` branch is in sync with your upstream remote.
10+
* Your local `master` branch is in sync with your `upstream` remote (it may have another name depending on your setup).
1111
* Your repo is clean, particularly with no untracked files in the contracts and tests directories. Verify with `git clean -n`.
1212

1313

@@ -44,8 +44,11 @@ Publish the release notes on GitHub and ask our community manager to announce th
4444

4545
## Creating the final release
4646

47+
Make sure to have the latest changes from `upstream` in your local release branch.
48+
4749
```
4850
git checkout release-vX.Y.Z
51+
git pull upstream
4952
```
5053

5154
Change the version string in `package.json`, `package-lock.json` and `ethpm.json` removing the "-rc.R" suffix. Commit these changes and tag the commit as `vX.Y.Z`.
@@ -75,7 +78,14 @@ npm dist-tag rm --otp $2FA_CODE openzeppelin-solidity next
7578

7679
## Merging the release branch
7780

78-
After the final release, the release branch should be merged back into `master`. This merge must not be squashed, because it would lose the tagged release commit, so it should be merged locally and pushed.
81+
After the final release, the release branch should be merged back into `master`. This merge must not be squashed because it would lose the tagged release commit. Since the GitHub repo is set up to only allow squashed merges, the merge should be done locally and pushed.
82+
83+
Make sure to have the latest changes from `upstream` in your local release branch.
84+
85+
```
86+
git checkout release-vX.Y.Z
87+
git pull upstream
88+
```
7989

8090
```
8191
git checkout master

contracts/access/SignatureBouncer.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ contract SignatureBouncer is Ownable, RBAC {
8282
public
8383
onlyOwner
8484
{
85-
require(_bouncer != address(0));
8685
removeRole(_bouncer, ROLE_BOUNCER);
8786
}
8887

contracts/crowdsale/price/IncreasingPriceCrowdsale.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ contract IncreasingPriceCrowdsale is TimedCrowdsale {
2222
* @param _finalRate Number of tokens a buyer gets per wei at the end of the crowdsale
2323
*/
2424
constructor(uint256 _initialRate, uint256 _finalRate) public {
25-
require(_initialRate >= _finalRate);
2625
require(_finalRate > 0);
26+
require(_initialRate >= _finalRate);
2727
initialRate = _initialRate;
2828
finalRate = _finalRate;
2929
}

contracts/examples/SimpleToken.sol

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ contract SimpleToken is StandardToken {
2222
* @dev Constructor that gives msg.sender all of existing tokens.
2323
*/
2424
constructor() public {
25-
totalSupply_ = INITIAL_SUPPLY;
26-
balances[msg.sender] = INITIAL_SUPPLY;
27-
emit Transfer(address(0), msg.sender, INITIAL_SUPPLY);
25+
_mint(msg.sender, INITIAL_SUPPLY);
2826
}
2927

3028
}
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
pragma solidity ^0.4.24;
2+
3+
4+
/**
5+
* @title ERC165Checker
6+
* @dev Use `using ERC165Checker for address`; to include this library
7+
* https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md
8+
*/
9+
library ERC165Checker {
10+
// As per the EIP-165 spec, no interface should ever match 0xffffffff
11+
bytes4 private constant InterfaceId_Invalid = 0xffffffff;
12+
13+
bytes4 private constant InterfaceId_ERC165 = 0x01ffc9a7;
14+
/**
15+
* 0x01ffc9a7 ===
16+
* bytes4(keccak256('supportsInterface(bytes4)'))
17+
*/
18+
19+
20+
/**
21+
* @notice Query if a contract supports ERC165
22+
* @param _address The address of the contract to query for support of ERC165
23+
* @return true if the contract at _address implements ERC165
24+
*/
25+
function supportsERC165(address _address)
26+
internal
27+
view
28+
returns (bool)
29+
{
30+
// Any contract that implements ERC165 must explicitly indicate support of
31+
// InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid
32+
return supportsERC165Interface(_address, InterfaceId_ERC165) &&
33+
!supportsERC165Interface(_address, InterfaceId_Invalid);
34+
}
35+
36+
/**
37+
* @notice Query if a contract implements an interface, also checks support of ERC165
38+
* @param _address The address of the contract to query for support of an interface
39+
* @param _interfaceId The interface identifier, as specified in ERC-165
40+
* @return true if the contract at _address indicates support of the interface with
41+
* identifier _interfaceId, false otherwise
42+
* @dev Interface identification is specified in ERC-165.
43+
*/
44+
function supportsInterface(address _address, bytes4 _interfaceId)
45+
internal
46+
view
47+
returns (bool)
48+
{
49+
// query support of both ERC165 as per the spec and support of _interfaceId
50+
return supportsERC165(_address) &&
51+
supportsERC165Interface(_address, _interfaceId);
52+
}
53+
54+
/**
55+
* @notice Query if a contract implements interfaces, also checks support of ERC165
56+
* @param _address The address of the contract to query for support of an interface
57+
* @param _interfaceIds A list of interface identifiers, as specified in ERC-165
58+
* @return true if the contract at _address indicates support all interfaces in the
59+
* _interfaceIds list, false otherwise
60+
* @dev Interface identification is specified in ERC-165.
61+
*/
62+
function supportsInterfaces(address _address, bytes4[] _interfaceIds)
63+
internal
64+
view
65+
returns (bool)
66+
{
67+
// query support of ERC165 itself
68+
if (!supportsERC165(_address)) {
69+
return false;
70+
}
71+
72+
// query support of each interface in _interfaceIds
73+
for (uint256 i = 0; i < _interfaceIds.length; i++) {
74+
if (!supportsERC165Interface(_address, _interfaceIds[i])) {
75+
return false;
76+
}
77+
}
78+
79+
// all interfaces supported
80+
return true;
81+
}
82+
83+
/**
84+
* @notice Query if a contract implements an interface, does not check ERC165 support
85+
* @param _address The address of the contract to query for support of an interface
86+
* @param _interfaceId The interface identifier, as specified in ERC-165
87+
* @return true if the contract at _address indicates support of the interface with
88+
* identifier _interfaceId, false otherwise
89+
* @dev Assumes that _address contains a contract that supports ERC165, otherwise
90+
* the behavior of this method is undefined. This precondition can be checked
91+
* with the `supportsERC165` method in this library.
92+
* Interface identification is specified in ERC-165.
93+
*/
94+
function supportsERC165Interface(address _address, bytes4 _interfaceId)
95+
private
96+
view
97+
returns (bool)
98+
{
99+
// success determines whether the staticcall succeeded and result determines
100+
// whether the contract at _address indicates support of _interfaceId
101+
(bool success, bool result) = callERC165SupportsInterface(
102+
_address, _interfaceId);
103+
104+
return (success && result);
105+
}
106+
107+
/**
108+
* @notice Calls the function with selector 0x01ffc9a7 (ERC165) and suppresses throw
109+
* @param _address The address of the contract to query for support of an interface
110+
* @param _interfaceId The interface identifier, as specified in ERC-165
111+
* @return success true if the STATICCALL succeeded, false otherwise
112+
* @return result true if the STATICCALL succeeded and the contract at _address
113+
* indicates support of the interface with identifier _interfaceId, false otherwise
114+
*/
115+
function callERC165SupportsInterface(
116+
address _address,
117+
bytes4 _interfaceId
118+
)
119+
private
120+
view
121+
returns (bool success, bool result)
122+
{
123+
bytes memory encodedParams = abi.encodeWithSelector(
124+
InterfaceId_ERC165,
125+
_interfaceId
126+
);
127+
128+
// solium-disable-next-line security/no-inline-assembly
129+
assembly {
130+
let encodedParams_data := add(0x20, encodedParams)
131+
let encodedParams_size := mload(encodedParams)
132+
133+
let output := mload(0x40) // Find empty storage location using "free memory pointer"
134+
mstore(output, 0x0)
135+
136+
success := staticcall(
137+
30000, // 30k gas
138+
_address, // To addr
139+
encodedParams_data,
140+
encodedParams_size,
141+
output,
142+
0x20 // Outputs are 32 bytes long
143+
)
144+
145+
result := mload(output) // Load the result
146+
}
147+
}
148+
}
149+

contracts/math/Math.sol

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,9 @@ library Math {
1313
function min(uint256 _a, uint256 _b) internal pure returns (uint256) {
1414
return _a < _b ? _a : _b;
1515
}
16+
17+
function average(uint256 _a, uint256 _b) internal pure returns (uint256) {
18+
// (_a + _b) / 2 can overflow, so we distribute
19+
return (_a / 2) + (_b / 2) + ((_a % 2 + _b % 2) / 2);
20+
}
1621
}

0 commit comments

Comments
 (0)