Skip to content
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 further hardcoded function resolution #4309

Merged
merged 3 commits into from
Jun 6, 2023

Conversation

frangio
Copy link
Contributor

@frangio frangio commented Jun 3, 2023

For some reason I missed these in #4299.

The one in ERC721Enumerable._removeTokenFromOwnerEnumeration is interesting and deserves attention. We were using ERC721.balanceOf because we are more confident that it's the length of the enumeration than when we use the potentially overridden balanceOf. I've just made it call balanceOf now because I don't see a way around this, other than introducing a storage inefficiency by storing the length which is redundant with the balance mapping.


For the record here is how I am checking that these changes are exhaustive. (rg = ripgrep)

rg '^(abstract )?contract (\w+).*' contracts -I -g '*.sol' --replace '\b$2\.\w+\(' > patterns
rg -f patterns -g '*.sol'

The only remaining ones are ERC2771Context._msgData() and ERC2771Context._msgSender() in a mock, but without this we get a compiler warning.

@changeset-bot
Copy link

changeset-bot bot commented Jun 3, 2023

⚠️ No Changeset found

Latest commit: 29ed898

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes changesets to release 1 package
Name Type
openzeppelin-solidity Major

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@frangio frangio requested a review from a team June 3, 2023 01:30
Amxx
Amxx previously approved these changes Jun 5, 2023
Copy link
Collaborator

@Amxx Amxx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

There are many restrictions to combining the ERC721Enumerable module with "custom" balanceOf. This is why this module is not compatible with ERC721Concecutive (for example).
Maybe we will want to clarify the assumption that this module makes.

ernestognw
ernestognw previously approved these changes Jun 5, 2023
Copy link
Member

@ernestognw ernestognw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also agree with with adding a warning about the risks of using custom balanceOf

@frangio frangio dismissed stale reviews from ernestognw and Amxx via 29ed898 June 6, 2023 16:17
@frangio frangio requested a review from ernestognw June 6, 2023 16:17
Copy link
Member

@ernestognw ernestognw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merging since it already implements the suggestion @Amxx and I mentioned.

@ernestognw ernestognw merged commit 85696d8 into OpenZeppelin:master Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants