-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
Remove hooks from ERC20 #3838
Remove hooks from ERC20 #3838
Changes from all commits
50db94a
2e68978
bdd94d1
e03c773
616c148
c2d0313
a81f1a5
caf4374
4f3adcb
bbecd36
054777e
b3da557
27c7090
b4ab7c7
dcbc275
c3350bd
8565f15
a56afc4
3ec8abf
4213df3
0fc5d3a
975ed99
00ed155
0d74d66
7110896
4e09ef8
ed853fa
a2bc30c
ed66c58
5e67170
fe5abf4
1083de9
a7a9ff1
d6fdf53
5e0688b
b66eb88
d55e714
8abfed7
278c6d0
56e648a
2fc018e
fa58b35
58a28b9
a6ce9e1
ee4b86a
fc25740
30876ac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,15 +118,13 @@ abstract contract ERC20Snapshot is ERC20 { | |
return snapshotted ? value : totalSupply(); | ||
} | ||
|
||
// Update balance and/or total supply snapshots before the values are modified. This is implemented | ||
// in the _beforeTokenTransfer hook, which is executed for _mint, _burn, and _transfer operations. | ||
function _beforeTokenTransfer( | ||
// Update balance and/or total supply snapshots before the values are modified. This is executed | ||
// for _mint, _burn, and _transfer operations. | ||
function _update( | ||
address from, | ||
address to, | ||
uint256 amount | ||
) internal virtual override { | ||
super._beforeTokenTransfer(from, to, amount); | ||
|
||
if (from == address(0)) { | ||
// mint | ||
_updateAccountSnapshot(to); | ||
|
@@ -140,6 +138,7 @@ abstract contract ERC20Snapshot is ERC20 { | |
_updateAccountSnapshot(from); | ||
_updateAccountSnapshot(to); | ||
} | ||
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. this part will not work properly if update from 0 to 0 |
||
super._update(from, to, amount); | ||
} | ||
|
||
function _valueAt(uint256 snapshotId, Snapshots storage snapshots) private view returns (bool, uint256) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -158,8 +158,9 @@ function shouldBehaveLikeERC20 (errorPrefix, initialSupply, initialHolder, recip | |
}); | ||
|
||
it('reverts', async function () { | ||
await expectRevert(this.token.transferFrom( | ||
tokenOwner, to, amount, { from: spender }), `${errorPrefix}: transfer to the zero address`, | ||
await expectRevert( | ||
this.token.transferFrom(tokenOwner, to, amount, { from: spender }), | ||
`${errorPrefix}: transfer to the zero address`, | ||
); | ||
}); | ||
}); | ||
|
@@ -240,14 +241,6 @@ function shouldBehaveLikeERC20Transfer (errorPrefix, from, to, balance, transfer | |
}); | ||
}); | ||
}); | ||
|
||
describe('when the recipient is the zero address', function () { | ||
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. Why is this removed? 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. Since everything goes through the transfer, it cannot know if its coming from mint or burn, so 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. Line 206 is testing that you cannot mint to address 0. That is a valid test, but its separate from this. This tests that you cannot call transfer to the address 0. Tests are checking for behavior correctness. Its ok (and I think its needed) to have multiple tests that are resolved by the same require in different context. I think this test should have been kept. 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. I wonder if that is the cause of the coverage decrease. |
||
it('reverts', async function () { | ||
await expectRevert(transfer.call(this, from, ZERO_ADDRESS, balance), | ||
`${errorPrefix}: transfer to the zero address`, | ||
); | ||
}); | ||
}); | ||
} | ||
|
||
function shouldBehaveLikeERC20Approve (errorPrefix, owner, spender, supply, approve) { | ||
|
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.
What is the rational for using
ERC20.totalSupply()
instead oftotalSupply()
?