contracts icon indicating copy to clipboard operation
contracts copied to clipboard

fix: optimize state changes order in _unsafeTransfer

Open crStiv opened this issue 11 months ago • 0 comments

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}

crStiv avatar Jan 29 '25 01:01 crStiv