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

ERC-721: Clear approval in burn() #2099

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

zgrannan
Copy link
Contributor

@zgrannan zgrannan commented Feb 6, 2024

Summary

  • [n] y/n | Does it introduce breaking changes?
  • [n] y/n | Is it dependant on the specific version of cargo-contract or pallet-contracts?

burn() should probably clear token approval for the token. Otherwise, the following sequence of events is possible:

  1. Alice mints a token with id T
  2. Alice grants approval to Bob for T
  3. Alice burns the token
  4. Frank mints the token, also with id T
  5. Bob transfers the token to himself.

Mainly the concern would be that steps 1-3 could be performed by someone frontrunning, i.e. they see a pending transaction for step 4 in the mempool, and perform steps 1-3 first.

This PR updates the burn function to also clear the token approval, and adds a test for the described scenario above (with step 5 failing).

Checklist before requesting a review

  • My code follows the style guidelines of this project
  • I have added an entry to CHANGELOG.md
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • Any dependent changes have been merged and published in downstream modules

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.

None yet

1 participant