-
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 enumerable from ERC721 and add an ERC721Enumerable extension #2511
Conversation
311b3bc
to
0383c05
Compare
Average gas usage given by eth-gas-reporter
|
…ntracts into feature/ERC721Light
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.
Looks good overall.
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); | ||
} |
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 think this is a little clearer.
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); | |
} |
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 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
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 good to merge.
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