-
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
Consider alternative design for token transfers and hooks #3535
Comments
In our We have token delegation and snapshots with majority of its logic in |
Other hooks that we have:
|
This is implemented in
|
Hey everyone, I am writing my own implementation of the _update hook for ERC721 and I have one Idea that I would like to share I made one compromise, to remove the batchSize from the update, all updates are for one token. (I've updated the code in this PR but is not final yet: #4171) How this interacts with the rest: there is a new function increaseBalance that is called in _mintBatch in ERC721Consecutive, My biggest doubt so far, I'm struggling to refactor ERC721ConsecutiveMock, If this case is removes the _update function for one token only solves very well the other cases |
The way to customize token transfers today is by overriding the hooks
_beforeTokenTransfer
and_afterTokenTransfer
. This was designed this way because there are multiple related operations (mint, transfer, burn) that would generally be customized in a uniform way (e.g. "pause transfers" should also pause mints), and they are different functions all of which invoke the same hooks.An alternative that we can consider is instead to have a single entry point for all of these operations, a
_transfer
function that mints if the "from" argument is 0, etc., as suggested in #3109 for ERC20 (the same applies to other tokens). Hooks can then be removed because customizing transfers can be done by overriding this single function instead of overriding the hooks.The text was updated successfully, but these errors were encountered: