-
Notifications
You must be signed in to change notification settings - Fork 12.4k
Added PausableCrowdsale contract #832
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
Merged
frangio
merged 32 commits into
OpenZeppelin:master
from
TalAter:feature/pausable-crowdsale
Dec 14, 2018
Merged
Changes from 30 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
7f34509
Added PausableCrowdsale contract
TalAter e47775c
Merge branch 'master' into feature/pausable-crowdsale
3a1bbe6
Merge branch 'master' into feature/pausable-crowdsale
TalAter 35e799c
Changed inheritance order to prevent "Linearization of inheritance grβ¦
TalAter 965df41
Merge branch 'master' into feature/pausable-crowdsale
TalAter 0661e31
Updated mock PausableCrowdsaleImpl to new constructor syntax
TalAter 3d69c02
Broke function definition to multiple lines
TalAter aa48346
Rename events to past-tense in PausableCrowdsale test
TalAter 4b9a631
Removed should.be.fullfilled from PausableCrowdsale tests
TalAter 19f8b75
Change import assertRevert to require in PausableCrowdsale tests
TalAter e9181d7
Remove dependency on chai-as-promised and added BigNumber support in β¦
TalAter 5f356dd
Merge branch 'master' of github.com:OpenZeppelin/openzeppelin-soliditβ¦
frangio 547c7c5
reindent solidity with 4 spaces
frangio 35ade39
add missing view modifier in _preValidatePurchase
frangio 5b74f79
convert assertRevert to new shoulFail helper
frangio 665608a
Merge branch 'master' of github.com:OpenZeppelin/openzeppelin-soliditβ¦
frangio 7f49a78
add new setup helper
frangio 17474f1
use expectEvent
frangio 775d802
convert to assert to chai should style
frangio f669ea6
add description to beforeEach blocks
frangio d2d1ca7
extract common step to beforeEach
frangio f35c7e1
improve documentation
frangio 5f3e5d7
revert inheritance error
frangio 10f9335
move PausableCrowdsale into crowdsale/validation
frangio 1d612fa
make documentation more specific
frangio 61b2e85
put whitespace in line with convention
frangio 1ea7a14
improve test suite account names
frangio 7cf3287
undo beforeEach descriptions
frangio e6cbaf4
simplify tests
frangio 268182e
fix transaction senders to be the anyone account
frangio 1f2522e
make transaction senders more explicit
frangio 955ac0f
remove mocha only
frangio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| pragma solidity ^0.4.18; | ||
|
|
||
| import "../Crowdsale.sol"; | ||
| import "../../lifecycle/Pausable.sol"; | ||
|
|
||
|
|
||
| /** | ||
| * @title PausableCrowdsale | ||
| * @dev Extension of Crowdsale contract where purchases can be paused and unpaused by the pauser role. | ||
| */ | ||
| contract PausableCrowdsale is Crowdsale, Pausable { | ||
|
|
||
| /** | ||
| * @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use super to concatenate validations. | ||
| * Adds the validation that the crowdsale must not be paused. | ||
| * @param _beneficiary Address performing the token purchase | ||
| * @param _weiAmount Value in wei involved in the purchase | ||
| */ | ||
| function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal view whenNotPaused { | ||
| return super._preValidatePurchase(_beneficiary, _weiAmount); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| pragma solidity ^0.4.18; | ||
|
|
||
| import "../token/ERC20/ERC20.sol"; | ||
| import "../crowdsale/validation/PausableCrowdsale.sol"; | ||
|
|
||
| contract PausableCrowdsaleImpl is PausableCrowdsale { | ||
| constructor (uint256 _rate, address _wallet, ERC20 _token) public Crowdsale(_rate, _wallet, _token) { | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| const shouldFail = require('../helpers/shouldFail'); | ||
|
|
||
| const PausableCrowdsale = artifacts.require('PausableCrowdsaleImpl'); | ||
| const SimpleToken = artifacts.require('SimpleToken'); | ||
|
|
||
| require('../helpers/setup'); | ||
|
|
||
| contract('PausableCrowdsale', function ([_, pauser, wallet, anyone]) { | ||
| const rate = 1; | ||
| const value = 1; | ||
|
|
||
| beforeEach(async function () { | ||
| const from = pauser; | ||
|
|
||
| this.token = await SimpleToken.new({ from }); | ||
| this.crowdsale = await PausableCrowdsale.new(rate, wallet, this.token.address, { from }); | ||
| await this.token.transfer(this.crowdsale.address, 2 * value, { from }); | ||
| }); | ||
|
|
||
| it('purchases work', async function () { | ||
| const from = anyone; | ||
|
|
||
| await this.crowdsale.sendTransaction({ from, value }); | ||
frangio marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| await this.crowdsale.buyTokens(from, { from, value }); | ||
| }); | ||
|
|
||
| context('after pause', function () { | ||
| beforeEach(async function () { | ||
| await this.crowdsale.pause({ from: pauser }); | ||
| }); | ||
|
|
||
| it('purchases do not work', async function () { | ||
| const from = anyone; | ||
|
|
||
| await shouldFail.reverting(this.crowdsale.sendTransaction({ from, value })); | ||
| await shouldFail.reverting(this.crowdsale.buyTokens(from, { from, value })); | ||
| }); | ||
|
|
||
| context('after unpause', function () { | ||
| beforeEach(async function () { | ||
| await this.crowdsale.unpause({ from: pauser }); | ||
| }); | ||
|
|
||
| it('purchases work', async function () { | ||
| const from = anyone; | ||
|
|
||
| await this.crowdsale.sendTransaction({ from, value }); | ||
| await this.crowdsale.buyTokens(from, { from, value }); | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.