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
StandardToken encapsulation #1197
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
cb75f00
make StandardToken state variables private
frangio 371fe3e
simplify mocks
frangio 4762191
document new internal functions
frangio 5f89cdf
fix link to ERC20 document
frangio 8120c46
revert order of Transfer and Mint events
frangio dc8b3bc
Revert "simplify mocks"
frangio 2cd86bf
add tests for new internal functions
frangio 6b3f6d6
Merge branch 'master' into erc20-encapsulation
nventuro 53f7b0e
add check for null account
frangio bc88f3c
add checks for balances and allowance
frangio 78f4b9e
add inline docs to BurnableToken._burn
frangio 34a967b
remove redundant checks and clarify why
frangio 24cb9cf
Merge remote-tracking branch 'upstream/master' into erc20-encapsulation
frangio File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
const { assertRevert } = require('../../helpers/assertRevert'); | ||
const expectEvent = require('../../helpers/expectEvent'); | ||
|
||
const BigNumber = web3.BigNumber; | ||
|
||
|
@@ -7,6 +8,8 @@ require('chai') | |
.should(); | ||
|
||
function shouldBehaveLikeMintableToken (owner, minter, [anyone]) { | ||
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'; | ||
|
||
describe('as a basic mintable token', function () { | ||
describe('after token creation', function () { | ||
it('sender should be token owner', async function () { | ||
|
@@ -104,11 +107,16 @@ function shouldBehaveLikeMintableToken (owner, minter, [anyone]) { | |
it('emits a mint and a transfer event', async function () { | ||
const { logs } = await this.token.mint(owner, amount, { from }); | ||
|
||
logs.length.should.eq(2); | ||
logs[0].event.should.eq('Mint'); | ||
logs[0].args.to.should.eq(owner); | ||
logs[0].args.amount.should.be.bignumber.equal(amount); | ||
logs[1].event.should.eq('Transfer'); | ||
const mintEvent = expectEvent.inLogs(logs, 'Mint', { | ||
to: owner, | ||
}); | ||
mintEvent.args.amount.should.be.bignumber.equal(amount); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can actually put that in the args object as well:
and it will do the bignumber equals check. likewise below There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
const transferEvent = expectEvent.inLogs(logs, 'Transfer', { | ||
from: ZERO_ADDRESS, | ||
to: owner, | ||
}); | ||
transferEvent.args.value.should.be.bignumber.equal(amount); | ||
}); | ||
}); | ||
|
||
|
This file contains 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
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.
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 confusing: the
public
burn
function calls theinternal
_burn
function, which then callssuper._burn
and emits an event. Why not remove theinternal _burn
and just call base function from the public one?edit: you did it right in the
mint
function, so I'm assuming this wasn't intentional :)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 did this because both
burn
andburnFrom
need to add theBurn
event. I felt it was better than adding the event in both. What do you think?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.
That's even worse now that I realize it lol.
burnFrom
calls_burnFrom
, which calls the overriden_burn
, which calls the originalburn
: unless you know the details ofStandardToken
, you can't tell thatburnFrom
will emit aBurn
event. The reason why you did it makes sense though.I think the problem is the missing comment: if the overridden function said something like 'adds the Burn event when burning', it may read more clearly.