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

Merged
merged 2 commits into from
Nov 15, 2024

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

@cmichi
Copy link
Collaborator

cmichi commented Nov 6, 2024

@zgrannan Thank you for the PR, it took a while to get back here. Could you please merge master and resolve the conflicts?

@zgrannan zgrannan force-pushed the zgrannan/burn-clear-approval branch from e1326c1 to dbb4030 Compare November 14, 2024 22:28
@cmichi cmichi merged commit a0b2dce into use-ink:master Nov 15, 2024
32 of 33 checks passed
@cmichi
Copy link
Collaborator

cmichi commented Nov 15, 2024

Thank you, @zgrannan!

@cmichi cmichi mentioned this pull request Nov 28, 2024
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.

2 participants