More efficient enumerable#129
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the ERC721 enumerable implementation to support two distinct patterns: a sequential enumerable variant for collections with sequential, immutable token IDs, and a general enumerable variant for collections supporting arbitrary IDs and burns. The sequential variant eliminates the need for expensive storage operations by leveraging the predictable ID structure.
Key Changes:
- Split enumerable functionality into two specialized mixins based on token ID patterns
- Removed enumerable logic from the base contract and replaced it with extension hooks
- Updated the main Ethscriptions contract to use the optimized sequential enumerable variant
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| ERC721EthscriptionsUpgradeable.sol | Removed enumerable interface and moved token tracking to hooks for derived contracts |
| ERC721EthscriptionsSequentialEnumerableUpgradeable.sol | New mixin implementing efficient enumeration for sequential, immutable token IDs |
| ERC721EthscriptionsEnumerableUpgradeable.sol | New mixin implementing general enumeration with full token tracking for arbitrary IDs |
| Ethscriptions.sol | Updated to inherit from sequential enumerable variant |
| CollectionsERC721.sol | Updated to inherit from general enumerable variant with explicit override declarations |
| ERC721EthscriptionsMixins.t.sol | New comprehensive test suite for both enumerable implementations |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Note
Extract enumerable logic into mixins and switch Ethscriptions to sequential enumerable while Collections uses general enumerable; add tests for both paths.
ERC721EthscriptionsUpgradeableinto hooks (_afterTokenMint,_beforeTokenRemoval) and per-owner tracking; removed global_allTokensmanagement andIERC721Enumerablefrom base.ERC721EthscriptionsEnumerableUpgradeable(sparse IDs, supports burns) andERC721EthscriptionsSequentialEnumerableUpgradeable(sequential IDs, no burns) implementingIERC721Enumerablevia the new hooks.Ethscriptionsnow extendsERC721EthscriptionsSequentialEnumerableUpgradeable(sequential supply, indexable by position).CollectionsERC721now extendsERC721EthscriptionsEnumerableUpgradeable; updated overrides to conform withIERC721/metadata interfaces and enumeration mixin.ERC721EthscriptionsMixins.t.solwith harnesses and tests covering sequential ID enforcement, burn forbiddance, sparse ID tracking across burns, and owner enumeration updates on transfer.Written by Cursor Bugbot for commit c0b8975. This will update automatically on new commits. Configure here.