Skip to content

feat: add ERC7572 interface for contracts that expose contract level metadata #5686

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fluffy-bananas-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'openzeppelin-solidity': patch
---

`IERC7572`: Add interface to support contract-level metadata.
8 changes: 2 additions & 6 deletions contracts/interfaces/draft-IERC6909.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
pragma solidity ^0.8.20;

import {IERC165} from "../utils/introspection/IERC165.sol";
import {IERC7572} from "./draft-IERC7572.sol";

/**
* @dev Required interface of an ERC-6909 compliant contract, as defined in the
Expand Down Expand Up @@ -102,12 +103,7 @@ interface IERC6909Metadata is IERC6909 {
/**
* @dev Optional extension of {IERC6909} that adds content URI functions.
*/
interface IERC6909ContentURI is IERC6909 {
/**
* @dev Returns URI for the contract.
*/
function contractURI() external view returns (string memory);

interface IERC6909ContentURI is IERC6909, IERC7572 {
/**
* @dev Returns the URI for the token of type `id`.
*/
Expand Down
18 changes: 18 additions & 0 deletions contracts/interfaces/draft-IERC7572.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (interfaces/draft-IERC7572.sol)

pragma solidity ^0.8.20;

/// @title ERC-7572 Contract Level Metadata
/// @dev Required interface of an ERC-7572 compliant contract, as defined in the
/// https://eips.ethereum.org/EIPS/eip-7572[ERC].
interface IERC7572 {
/// @dev This event should be emitted on updates to the contract metadata
/// to indicate to offchain indexers that they should query the contract
/// for the latest URI.
event ContractURIUpdated();

/// @dev Returns an offchain resource for contract metadata or onchain JSON
/// data string (data:application/json;utf8,{}).
function contractURI() external view returns (string memory);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
pragma solidity ^0.8.20;

import {ERC6909} from "../draft-ERC6909.sol";
import {IERC7572} from "../../../interfaces/draft-IERC7572.sol";
import {IERC6909ContentURI} from "../../../interfaces/draft-IERC6909.sol";

/**
Expand All @@ -13,13 +14,10 @@ contract ERC6909ContentURI is ERC6909, IERC6909ContentURI {
string private _contractURI;
mapping(uint256 id => string) private _tokenURIs;

/// @dev Event emitted when the contract URI is changed. See https://eips.ethereum.org/EIPS/eip-7572[ERC-7572] for details.
event ContractURIUpdated();

/// @dev See {IERC1155-URI}
event URI(string value, uint256 indexed id);

/// @inheritdoc IERC6909ContentURI
/// @inheritdoc IERC7572
function contractURI() public view virtual override returns (string memory) {
return _contractURI;
}
Expand Down