-
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
Remove hooks from ERC20 #3838
Remove hooks from ERC20 #3838
Conversation
…m/JulissaDantes/openzeppelin-contracts into refactor/erc20/mint-burn-transfer
@@ -240,14 +225,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 comment
The 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 comment
The 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 transfer
has a check to ensure that from
and to
cannot be the zero address, but if a user sends a mint to address zero it would received both from
and to
as the zero address. There is a test for that case on ln 206
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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if that is the cause of the coverage decrease.
Co-authored-by: Francisco <frangio.1@gmail.com>
Co-authored-by: Francisco <frangio.1@gmail.com>
There is a separate point we need to decide, which is whether the external I think this PR should keep the current behavior, and so we need to add in those external functions the necessary |
…m/JulissaDantes/openzeppelin-contracts into refactor/erc20/mint-burn-transfer
Fixes #3535
The current way to customize token transfers(mint, burn, transfer) is by overriding the hooks
_beforeTokenTransfer
and_afterTokenTransfer
. This refactor removes both hooks from theERC20
contract, and implements the logic inside thetransfer
function, so future customizations only rely on overriding a single function.PR Checklist