Skip to content

Conversation

@sidarth16
Copy link
Contributor

Summary

This pull request fixes [#159] — the bug where LibERC721Enumerable.mint() did not assign ownership for newly minted tokens. Without this assignment, the token appeared non-existent (ownerOf[tokenId] == address(0)), causing transferFrom and burn to revert.

Changes Made

  • Added missing s.ownerOf[_tokenId] = _to; in mint() before updating enumeration arrays.
  • Ensured ownership is set prior to emitting Transfer(0x0, _to, tokenId) for consistent event/state ordering.
  • Verified mint now aligns with ERC-721 expected invariants and enumeration logic.

…y minted tokens

The mint() function in LibERC721Enumerable did not assign the new token's
owner in storage (s.ownerOf[tokenId] = _to), causing minted tokens to appear
non-existent and breaking transfer/burn operations. This commit adds the
missing ownership assignment to align mint behavior with ERC-721 expectations
and maintain enumeration consistency.
@sidarth16 sidarth16 changed the title Fix LibERC721Enumerable.sol : set token owner during mint to resolve missing ownership (#159) Fix LibERC721Enumerable.sol : set token owner during mint to resolve missing ownership (Fix #159) Oct 31, 2025
@sidarth16 sidarth16 changed the title Fix LibERC721Enumerable.sol : set token owner during mint to resolve missing ownership (Fix #159) Fix #159 : LibERC721Enumerable.sol now set token owner during mint to resolve missing ownership Oct 31, 2025
@sidarth16
Copy link
Contributor Author

image

Test cases from #111 are now passing with this fix.

@github-actions
Copy link

Coverage Report

Coverage

Metric Coverage Details
Lines 44% 485/1093 lines
Functions 60% 120/200 functions
Branches 28% 51/179 branches

Last updated: Fri, 31 Oct 2025 13:27:52 GMT for commit b2ed443

@github-actions
Copy link

Gas Report

No gas usage changes detected between main and patch-1.

All functions maintain the same gas costs. ✅

Last updated: Fri, 31 Oct 2025 13:28:14 GMT for commit b2ed443

@maxnorm maxnorm mentioned this pull request Oct 31, 2025
7 tasks
@maxnorm maxnorm requested review from adamgall and mudgen and removed request for mudgen October 31, 2025 13:35
Copy link
Collaborator

@adamgall adamgall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering that #111 (which adds ERC721 tests) is not merged yet, I prefer this PR over #161, which includes the same single-line-change as this PR but also includes a duplicate of all of the ERC721 tests from #111.

@adamgall adamgall merged commit 60fe5d2 into Perfect-Abstractions:main Oct 31, 2025
4 checks passed
JackieXu pushed a commit to JackieXu/Compose that referenced this pull request Nov 6, 2025
Fix Perfect-Abstractions#159 : LibERC721Enumerable.sol now set token owner during mint to resolve missing ownership
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