Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ERC20 token with snapshoting mechanism (#1209) #1331

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
3b66e70
Add ERC20 token with snapshoting mechanism (#1209)
Sep 18, 2018
1302e6a
Methods visibility corrected
jbogacz Sep 23, 2018
21198bf
Roles now emit events in construction and when renouncing. (#1329)
nventuro Sep 26, 2018
396680b
Add the missing test for ERC721Holder (#1249)
Sep 26, 2018
db2e1d2
Removed assertions from Escrow and SplitPayment. (#1349)
nventuro Sep 26, 2018
5fdeaa8
Removed mintingFinished. (#1351)
nventuro Sep 26, 2018
ae109f6
Improved bounty tests. (#1350)
nventuro Sep 26, 2018
947de54
Add BigNumber support to expectEvent/inLogs (#1026) (#1338)
jbogacz Sep 26, 2018
75c0a59
Add missing tests to ECSDA (#1248)
Sep 26, 2018
536262f
Feature/use expect event in test logs assertions #1232 (#1343)
jbogacz Sep 27, 2018
1a4e534
Add SignatureBouncer test for when msg.data is too short (#1360)
frangio Sep 27, 2018
a688977
Dangling commas are now required. (#1359)
nventuro Sep 29, 2018
fa1dfbd
Fix #1358 Test helper to send funds (#1367)
Aniket-Engg Oct 1, 2018
6ae041b
Fix/#1355 test helper to check balance difference (#1368)
Aniket-Engg Oct 1, 2018
34bc709
Merged latestTime, increaseTime and duration into a time helper. (#1364)
nventuro Oct 2, 2018
269981e
Created test utils directory
nventuro Oct 2, 2018
f4d6f40
Fixed test path.
nventuro Oct 2, 2018
43ebb4f
ERC20 internal transfer method (#1370)
k06a Oct 2, 2018
f3888bb
Removing unrequired `_burn()` override (#1373)
Aniket-Engg Oct 3, 2018
c87433e
Prevents Bounty from being claimed twice (#1374)
Aniket-Engg Oct 3, 2018
5c22880
Update issue templates (#1376)
frangio Oct 4, 2018
ace14d3
Add note about compiling artifacts to releasing steps (#1377)
frangio Oct 4, 2018
fd4de77
Replaces `amount` with `value` for consistency (#1378)
Aniket-Engg Oct 4, 2018
b41b125
`this` is used in tests (#1380)
Aniket-Engg Oct 4, 2018
744f567
Separate ERC721Mintable (#1365)
frangio Oct 4, 2018
308e5e9
Removed unnecessary Secondary inheritance from RefundEscrow. (#1381)
nventuro Oct 4, 2018
b17de01
Removed old, unused mocks. (#1382)
nventuro Oct 6, 2018
41f84f8
Removed selfdestruct from BreakInvariantBounty (#1385)
Aniket-Engg Oct 8, 2018
f7e53d9
Add Arrays library with unit tests (#1209) (#1375)
jbogacz Oct 8, 2018
3acc2b4
Added a constructor to BreakInvariantBounty. (#1395)
nventuro Oct 8, 2018
aa6b6d0
Add ERC20 token with snapshoting mechanism (#1209)
Sep 18, 2018
7f59f86
Methods visibility corrected
jbogacz Sep 23, 2018
360c85e
Use SafeMath.
jbogacz Oct 9, 2018
474ec3d
Merge branch 'fix/ERC20-token-with-snapshots-#1209' of https://github…
jbogacz Oct 9, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
34 changes: 0 additions & 34 deletions .github/ISSUE_TEMPLATE.md

This file was deleted.

21 changes: 21 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: Bug report
about: Report a bug in OpenZeppelin

---

<!-- Briefly describe the issue you're experiencing. Tell us what you were trying to do and what happened instead. -->

<!-- Remember, this is not a place to ask for help debugging code. For that, we welcome you in the OpenZeppelin Slack channel: https://slack.openzeppelin.org/. -->

**πŸ’» Environment**

<!-- Tell us what version of OpenZeppelin you're using, and how you're using it: Truffle, Remix, etc. -->

**πŸ“ Details**

<!-- Describe the problem you have been experiencing in more detail. Include as much information as you think is relevant. Keep in mind that transactions can fail for many reasons; context is key here. -->

**πŸ”’ Code to reproduce bug**

<!-- We will be able to better help if you provide a minimal example that triggers the bug. -->
14 changes: 14 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: Feature request
about: Suggest an idea for OpenZeppelin

---

**🧐 Motivation**
<!-- Is your feature request related to a specific problem? Is it just a crazy idea? Tell us about it! -->

**πŸ“ Details**
<!-- Please describe your feature request in detail. -->

<!-- Make sure that you have reviewed the OpenZeppelin Contributor Guidelines. -->
<!-- https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/CONTRIBUTING.md -->
23 changes: 13 additions & 10 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
<!-- 0. πŸŽ‰ Thank you for submitting a PR! -->

<!-- 1. **Does this close any open issues?** If so, list them here. If not, remove the `Fixes #` line. -->
<!-- 1. Does this close any open issues? Please list them below. -->

Fixes #
<!-- Keep in mind that new features have a better chance of being merged fast if
they were first discussed and designed with the maintainers. If there is no
corresponding issue, please consider opening one for discussion first! -->

# πŸš€ Description
Fixes #

<!-- 2. Describe the changes introduced in this pull request -->
<!-- 2. Describe the changes introduced in this pull request. -->
<!-- Include any context necessary for understanding the PR's purpose. -->

<!-- 3. Before submitting, please review the following checklist: -->

- [ ] πŸ“˜ I've reviewed the [OpenZeppelin Contributor Guidelines](../blob/master/CONTRIBUTING.md)
- [ ] βœ… I've added tests where applicable to test my new functionality.
- [ ] πŸ“– I've made sure that my contracts are well-documented.
- [ ] 🎨 I've run the JS/Solidity linters and fixed any issues (`npm run lint:fix`).
<!-- 3. Before submitting, please make sure that you have:
- reviewed the OpenZeppelin Contributor Guidelines
(https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/CONTRIBUTING.md),
- added tests where applicable to test new functionality,
- made sure that your contracts are well-documented, and
- run the JS/Solidity linters and fixed any issues (`npm run lint:fix`).
-->
12 changes: 12 additions & 0 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ git push upstream vX.Y.Z-rc.R

Draft the release notes in our [GitHub releases](https://github.com/OpenZeppelin/openzeppelin-solidity/releases). Make sure to mark it as a pre-release! Try to be consistent with our previous release notes in the title and format of the text. Release candidates don't need a detailed changelog, but make sure to include a link to GitHub's compare page.

Before publishing on npm you need to generate the build artifacts. This is not done automatically at the moment because of a bug in Truffle. Since some of the contracts should not be included in the package, this is a _hairy_ process that you need to do with care.

1. Delete the `contracts/mocks` and `contracts/examples` directories.
2. Run `truffle compile`. (Note that the Truffle process may never exit and you will have to interrupt it.)
3. Recover the directories using `git checkout`. It doesn't matter if you do this now or later.

Once the CI run for the new tag is green, publish on npm under the `next` tag.

```
Expand Down Expand Up @@ -62,6 +68,12 @@ git push upstream vX.Y.Z

Draft the release notes in GitHub releases. Try to be consistent with our previous release notes in the title and format of the text. Make sure to include a detailed changelog.

Before publishing on npm you need to generate the build artifacts. This is not done automatically at the moment because of a bug in Truffle. Since some of the contracts should not be included in the package, this is a _hairy_ process that you need to do with care.

1. Delete the `contracts/mocks` and `contracts/examples` directories.
2. Run `truffle compile`. (Note that the Truffle process may never exit and you will have to interrupt it.)
3. Recover the directories using `git checkout`. It doesn't matter if you do this now or later.

Once the CI run for the new tag is green, publish on npm.

```
Expand Down
12 changes: 8 additions & 4 deletions contracts/access/roles/CapperRole.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ contract CapperRole {
Roles.Role private cappers;

constructor() public {
cappers.add(msg.sender);
_addCapper(msg.sender);
}

modifier onlyCapper() {
Expand All @@ -24,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 {
Expand Down
12 changes: 8 additions & 4 deletions contracts/access/roles/MinterRole.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ contract MinterRole {
Roles.Role private minters;

constructor() public {
minters.add(msg.sender);
_addMinter(msg.sender);
}

modifier onlyMinter() {
Expand All @@ -24,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 {
Expand Down
12 changes: 8 additions & 4 deletions contracts/access/roles/PauserRole.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ contract PauserRole {
Roles.Role private pausers;

constructor() public {
pausers.add(msg.sender);
_addPauser(msg.sender);
}

modifier onlyPauser() {
Expand All @@ -24,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 {
Expand Down
12 changes: 8 additions & 4 deletions contracts/access/roles/SignerRole.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ contract SignerRole {
Roles.Role private signers;

constructor() public {
signers.add(msg.sender);
_addSigner(msg.sender);
}

modifier onlySigner() {
Expand All @@ -24,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 {
Expand Down
29 changes: 19 additions & 10 deletions contracts/bounties/BreakInvariantBounty.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,29 @@ import "../ownership/Ownable.sol";
* @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;
bool private _claimable;
mapping(address => address) private _researchers;

event TargetCreated(address createdAddress);
event BountyCanceled();

constructor() public {
_claimable = true;
}

/**
* @dev Fallback function allowing the contract to receive funds, if they haven't already been claimed.
*/
function() external payable {
require(!_claimed);
require(_claimable);
}

/**
* @dev Determine if the bounty was claimed.
* @return true if the bounty was claimed, false otherwise.
* @dev Determine if the bounty is claimable.
* @return false if the bounty was claimed, true otherwise.
*/
function claimed() public view returns(bool) {
return _claimed;
function claimable() public view returns(bool) {
return _claimable;
}

/**
Expand All @@ -45,19 +50,23 @@ contract BreakInvariantBounty is PullPayment, Ownable {
* @param target contract
*/
function claim(Target target) public {
require(_claimable);
address researcher = _researchers[target];
require(researcher != address(0));
// Check Target contract invariants
require(!target.checkInvariant());
_asyncTransfer(researcher, address(this).balance);
_claimed = true;
_claimable = false;
}

/**
* @dev Transfers the current balance to the owner and terminates the contract.
* @dev Cancels the bounty and transfers all funds to the owner
*/
function destroy() public onlyOwner {
selfdestruct(owner());
function cancelBounty() public onlyOwner{
require(_claimable);
_asyncTransfer(owner(), address(this).balance);
_claimable = false;
emit BountyCanceled();
}

/**
Expand Down
18 changes: 18 additions & 0 deletions contracts/mocks/ArraysImpl.sol
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,24 @@ pragma solidity ^0.4.24;
// solium-disable-next-line max-len
import {BreakInvariantBounty, Target} from "../bounties/BreakInvariantBounty.sol";

contract SecureInvariantTargetMock is Target {
function checkInvariant() public returns(bool) {
contract TargetMock is Target {
bool private exploited;

function exploitVulnerability() public {
exploited = true;
}

function checkInvariant() public returns (bool) {
if (exploited) {
return false;
}

return true;
}
}

contract SecureInvariantTargetBounty is BreakInvariantBounty {
contract BreakInvariantBountyMock is BreakInvariantBounty {
function _deployContract() internal returns (address) {
return new SecureInvariantTargetMock();
return new TargetMock();
}
}
19 changes: 19 additions & 0 deletions contracts/mocks/ERC20SnapshotMock.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
pragma solidity ^0.4.24;

import "../token/ERC20/ERC20Snapshot.sol";


contract ERC20SnapshotMock is ERC20Snapshot {

constructor(address initialAccount, uint256 initialBalance) public {
_mint(initialAccount, initialBalance);
}

function mint(address account, uint256 amount) public {
_mint(account, amount);
}

function burn(address account, uint256 amount) public {
_burn(account, amount);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does not include _burnFrom from the current v2 RC2 OZ

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a mock for unit test purpose so I don't know if this even need mint and burn functions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

burn and mint functions (and burnFrom) impact the total supply. Which is important to keep history of for specific purposes.

Examples include:
Voting Power
Dividend Share

Which both are dependent on the ratio of held tokens at a specified time. In which knowing the total supply is necessary.

Loading