Remove enumerable from ERC721 and add an ERC721Enumerable extension#2511
Merged
Conversation
311b3bc to
0383c05
Compare
Collaborator
Author
|
Average gas usage given by eth-gas-reporter
|
…ntracts into feature/ERC721Light
frangio
reviewed
Feb 18, 2021
Comment on lines
+70
to
+79
| if (from == address(0)) { | ||
| _addTokenToAllTokensEnumeration(tokenId); | ||
| } else if (from != to) { | ||
| _removeTokenFromOwnerEnumeration(from, tokenId); | ||
| } | ||
| if (to == address(0)) { | ||
| _removeTokenFromAllTokensEnumeration(tokenId); | ||
| } else if (to != from) { | ||
| _addTokenToOwnerEnumeration(to, tokenId); | ||
| } |
Contributor
There was a problem hiding this comment.
I think this is a little clearer.
Suggested change
| if (from == address(0)) { | |
| _addTokenToAllTokensEnumeration(tokenId); | |
| } else if (from != to) { | |
| _removeTokenFromOwnerEnumeration(from, tokenId); | |
| } | |
| if (to == address(0)) { | |
| _removeTokenFromAllTokensEnumeration(tokenId); | |
| } else if (to != from) { | |
| _addTokenToOwnerEnumeration(to, tokenId); | |
| } | |
| if (from == address(0)) { | |
| _addTokenToAllTokensEnumeration(tokenId); | |
| } | |
| if (to == address(0)) { | |
| _removeTokenFromAllTokensEnumeration(tokenId); | |
| } | |
| if (to != from) { | |
| _removeTokenFromOwnerEnumeration(from, tokenId); | |
| _addTokenToOwnerEnumeration(to, tokenId); | |
| } |
Collaborator
Author
There was a problem hiding this comment.
this would not work:
_removeTokenFromOwnerEnumeration(from, tokenId);must not be called iffrom == address(0)_addTokenToOwnerEnumeration(to, tokenId);must not be called ifto == address(0)
Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
a679d75 to
c39ef2d
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
EnumerableSet and EnumerableMap heavily rely on sstore & sload, which are very expensive operations. At the same time, the Enumerable aspect can be tracked offchain using tools like thegraph.
Developer should have the choice between having this enumerable functionality (and pay the gas price), or drop it if onchain access to these information is sufficient.
PR Checklist