-
Notifications
You must be signed in to change notification settings - Fork 11.8k
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 complex crowdsale example #331 #342
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! Thanks @jakub-wojciechowski. A couple of comments.
Let's put both contracts (crowdsale and token) in the same SampleCrowdsale.sol
file. I envision each file in examples/
to be like a self-contained tutorial which you can read from top to bottom to learn about a part of OpenZeppelin.
Keep in mind this will be where newcomers will come to learn, so the examples should be thoroughly documented and explain what each line does. You don't need to include that in this PR, though go ahead if you want to!
The test is great too. It'll be useful as an integration test of all crowdsale features.
|
||
string public constant name = "Sample Crowdsale Token"; | ||
string public constant symbol = "SCT"; | ||
uint256 public constant decimals = 18; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
decimals
should be uint8
according to ERC20. (I've just realized this is wrong in the SimpleToken
example too.)
test/SampleCrowdsale.js
Outdated
(await this.crowdsale.startBlock()).should.be.bignumber.equal(this.startBlock); | ||
(await this.crowdsale.endBlock()).should.be.bignumber.equal(this.endBlock); | ||
(await this.crowdsale.rate()).should.be.bignumber.equal(RATE); | ||
(await this.crowdsale.wallet()).should.be.bignumber.equal(wallet); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd have to confirm but I'm pretty sure Truffle returns address
typed values as strings, not BigNumber instances. The test works because addresses are numbers anyway and they get converted, but it would be best to compare them as strings.
Thx for the comments @frangio. I'm glad that you liked integration tests :) |
Add complex crowdsale example OpenZeppelin#331
Resolves #331
Submitted together with SampleCrowdsaleToken to illustrate which components are needed to launch a crowdsale. Contains tests to demonstrate basic features of a crowdsale and to assure that combining different subclasses maintains their functionalities.