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

[ERC721] Delete approved if have #252

Closed

Conversation

rotcivegaf
Copy link

Description

Clear getApproved only if have an approved address

Statistically, this would save gas, the sum of an owner transfer and isApprovedForAll transfer is greater than an approved transfer

Save 80 gas if the getApproved haven't a approved
Spend 150 gas if the getApproved have a approved
(In each transferFrom, according to my tests)

Checklist

Ensure you completed all of the steps below before submitting your pull request:

  • Ran forge snapshot?
  • Ran npm run lint?
  • Ran forge test?

Pull requests with an incomplete checklist will be thrown out.

@rotcivegaf
Copy link
Author

What do you think about:

  • Emitting the Approval event if the approved is cleared?
  • Use the same pattern in the _burn function

@transmissions11
Copy link
Owner

uh ser i dont see any changes in the diff... and you've installed solmate... in solmate?

@transmissions11
Copy link
Owner

i'd like to see the diffs before i comment on those changes (im a codecel lol i cant think in human terms)

@Vectorized
Copy link
Contributor

Vectorized commented May 25, 2022

Wow, this actually does work. But the code is missing.

@rotcivegaf Thanks for the suggestion! Will credit you on the next release of ERC721A.

We don't need to emit an Approval event in this case, as the Transfer event will be sufficient to signal the reset of any approval. chiru-labs/ERC721A#274

@rotcivegaf rotcivegaf closed this May 25, 2022
@rotcivegaf rotcivegaf deleted the ERC721-deleteApprovedIfHave branch May 25, 2022 17:55
@rotcivegaf
Copy link
Author

Sorry, I needed to sleep, I forgot push the change...
Check #255 PR

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