Add URI resolution for Ethscriptions in ERC721 Collection#139
Conversation
- Introduced `_resolveEthscriptionURI` function to handle `esc://ethscriptions/{id}/data` references, resolving them to their corresponding media URIs.
- Updated `contractURI` method to utilize resolved URIs for logo and banner images, enhancing metadata representation.
- Added comprehensive tests for URI resolution, including validation for regular HTTP URIs, data URIs, and handling of malformed or non-existent ethscription references.
There was a problem hiding this comment.
Pull Request Overview
This PR implements URI resolution for ERC-721 collection metadata, enabling support for esc://ethscriptions/{id}/data references alongside regular HTTP and data URIs. The feature allows collection logos and banners to reference other ethscriptions, which are resolved to their media URIs when building contract metadata.
Key changes:
- Added URI resolution logic to handle
esc://references to ethscriptions - Implemented graceful error handling that returns empty strings instead of reverting on invalid references
- Comprehensive test coverage for regular URIs, data URIs, valid ethscription references, and various invalid/malformed URI formats
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| contracts/test/CollectionURIResolution.t.sol | New test file with comprehensive coverage of URI resolution scenarios including pass-through for HTTP/data URIs, ethscription reference resolution, and error handling for invalid references |
| contracts/src/ERC721EthscriptionsCollection.sol | Added _resolveEthscriptionURI helper function to resolve esc:// references and _parseHexToBytes32 external helper for hex parsing with try/catch support; integrated resolution into contractURI() method |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return ""; // Must be 0x + 64 hex chars | ||
| } | ||
|
|
||
| // Parse hex string to bytes32 using JSONParserLib (reverts on invalid) |
There was a problem hiding this comment.
The comment states "using JSONParserLib (reverts on invalid)" but the code explicitly catches the revert and returns an empty string. The comment should be updated to reflect the actual behavior, e.g., "Parse hex string to bytes32 (returns empty on invalid)".
| // Parse hex string to bytes32 using JSONParserLib (reverts on invalid) | |
| // Parse hex string to bytes32 (returns empty on invalid) |
_resolveEthscriptionURIfunction to handleesc://ethscriptions/{id}/datareferences, resolving them to their corresponding media URIs.contractURImethod to utilize resolved URIs for logo and banner images, enhancing metadata representation.Note
Adds URI resolution for
esc://ethscriptions/{id}/dataincontractURIand introduces tests covering pass-through, valid, and malformed references.contracts/src/ERC721EthscriptionsCollection.sol:_resolveEthscriptionURIto handleesc://ethscriptions/{id}/data, fetching media viaethscriptions.getMediaUriwith try/catch and empty fallback.contractURIto resolvelogoImageUriandbannerImageUriusing the helper._parseHexToBytes32usingJSONParserLiband import it.contracts/test/CollectionURIResolution.t.sol:esc://references, and non-reverting handling of nonexistent/malformed references.Written by Cursor Bugbot for commit 772146b. This will update automatically on new commits. Configure here.