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

fix: optimize state changes order in _unsafeTransfer #463

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

crStiv
Copy link

@crStiv crStiv commented Jan 29, 2025

Reorder state changes in _unsafeTransfer function to follow best practices:

  1. First clear old state (delete idOf[from])
  2. Then set new state (idOf[to] and custodyOf[id])
    This change helps prevent potential reentrancy issues and provides clearer state transition.

PR-Codex overview

This PR focuses on modifying the _unsafeTransfer function in the IdRegistry contract to ensure proper handling of the idOf mapping during token transfers.

Detailed summary

  • Added delete idOf[from]; to remove the ID associated with the from address before transferring.
  • Updated idOf[to] = id; to assign the ID to the to address.
  • Emitted a Transfer event after the ID transfer.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

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.

1 participant