fix: set ownerOf in LibERC721Enumerable mint function #161
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes the critical bug in LibERC721Enumerable.mint() where the ownerOf mapping was not being set for newly minted tokens. This caused minted tokens to be unusable - they existed in enumeration arrays but had no recorded owner, making ownerOf() queries fail and preventing any transfers.
The fix adds the single missing line s.ownerOf[_tokenId] = _to; to properly record token ownership during minting, matching the implementation in the standard LibERC721 library.
Changes Made
Bug Fix
src/token/ERC721/ERC721Enumerable/LibERC721Enumerable.sol: Added missing s.ownerOf[_tokenId] = _to assignment in mint() function (line 126)
Test Coverage Added
test/token/ERC721/ERC721Enumerable/LibERC721Enumerable.t.sol: 32 comprehensive tests for the library's internal functions (mint, burn, transfer, enumeration)
test/token/ERC721/ERC721Enumerable/ERC721EnumerableFacet.t.sol: 42 comprehensive tests for the facet's public interface
test/token/ERC721/ERC721Enumerable/harnesses/: Test harnesses to expose internal library functions for testing
Code is formatted with forge fmt
Tests are included - All new functionality has comprehensive tests
All tests pass - Run forge test and ensure everything works
Test Results
All 429 tests pass successfully:
Test Coverage Details
LibERC721Enumerable: 32 tests covering mint (with owner verification), burn, transfer, enumeration tracking, edge cases, and fuzz tests
ERC721EnumerableFacet: 42 tests covering all public functions including metadata, balance/ownership queries, enumeration, approvals, transfers, and safe transfers
The tests specifically validate the bug fix by asserting that ownerOf() returns the correct address after minting, which was the core issue.