Refactor ERC721 Ethscriptions Collection and Manager Contracts#138
Conversation
- Updated the `ERC721EthscriptionsCollection` to replace the `factory` address with a `manager` contract for improved control and management. - Enhanced the `ERC721EthscriptionsCollectionManager` to utilize a deduplicated storage approach for string fields, optimizing metadata handling. - Introduced new functions for retrieving collection metadata and membership details, improving data accessibility. - Adjusted tests to reflect changes in data structures and ensure accurate validation of collection metadata retrieval.
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the collection storage system to use deduplicated blob storage instead of storing strings directly in storage, significantly reducing gas costs for duplicate values. The changes introduce a new internal CollectionRecord struct that stores references to deduplicated blobs, while the existing struct is renamed to CollectionMetadata for external API consumption.
Key changes:
- Introduces deduplicated blob storage for collection string fields (name, symbol, description, URIs, links)
- Renames the external-facing struct from
CollectionRecordtoCollectionMetadata - Adds new helper functions (
readString,getCollectionByAddress,getMembershipOfEthscription) - Changes visibility modifiers from
private/publictointernalfor better extensibility
Reviewed Changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| contracts/src/ERC721EthscriptionsCollectionManager.sol | Introduces deduplicated storage system with CollectionRecord (internal) and CollectionMetadata (external view struct), updates all collection creation and editing logic to use DedupedBlobStore |
| contracts/src/libraries/DedupedBlobStore.sol | Adds readString convenience wrapper to avoid repetitive string() casting when reading stored blobs |
| contracts/src/ERC721EthscriptionsCollection.sol | Refactors factory field to manager with proper type, adds contractURI function for OpenSea integration |
| contracts/src/Ethscriptions.sol | Changes contentStorage and metadataStorage visibility from public to internal for consistency |
| contracts/test/CollectionsProtocol.t.sol | Updates type references from CollectionRecord to CollectionMetadata to match refactored API |
| contracts/test/CollectionsManager.t.sol | Updates type references from CollectionRecord to CollectionMetadata to match refactored API |
| contracts/test/AddressPrediction.t.sol | Updates type references from CollectionRecord to CollectionMetadata to match refactored API |
| Gemfile.lock | Updates facet_rails_common dependency revision |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /// @dev Convenience wrapper to avoid repetitive string() casting | ||
| /// @param ref The storage reference (packed or SSTORE2 pointer) | ||
| /// @return str The retrieved data as string | ||
| function readString(bytes32 ref) internal view returns (string memory) { |
There was a problem hiding this comment.
The return value documentation at line 98 specifies @return str but the function signature doesn't name the return value. For consistency with the NatSpec comment, consider adding the name to the return declaration: returns (string memory str) or update the documentation to @return The retrieved data as string.
| function readString(bytes32 ref) internal view returns (string memory) { | |
| function readString(bytes32 ref) internal view returns (string memory str) { |
ERC721EthscriptionsCollectionto replace thefactoryaddress with amanagercontract for improved control and management.ERC721EthscriptionsCollectionManagerto utilize a deduplicated storage approach for string fields, optimizing metadata handling.Note
Switch collection to a typed manager, add collection-level
contractURI, refactor manager to deduplicate string metadata with new view getters, and update tests accordingly.ERC721EthscriptionsCollection:factoryaddress withmanager(ERC721EthscriptionsCollectionManager) and update access control/lookups.contractURI()returning OpenSea-style collection JSON.tokenURIto usemanagerdirectly.ERC721EthscriptionsCollectionManager:DedupedBlobStore;CollectionRecordnow storesbytes32refs; addCollectionMetadataview struct.getCollection(bytes32)now returnsCollectionMetadata; addgetCollectionByAddress(address)andgetMembershipOfEthscription(bytes32).internal; minor initialization cleanup.Ethscriptions:contentStorage/metadataStoragevisibility tointernal.DedupedBlobStore: addreadString(bytes32)helper.CollectionMetadatagetters and new manager API; adjust address prediction and protocol tests accordingly.Written by Cursor Bugbot for commit f7f0997. This will update automatically on new commits. Configure here.