Skip to content
Merged
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/curly-pandas-flow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'openzeppelin-solidity': patch
---

`ERC6909ContentURI`: Add ERC-165 detection for the `IERC6909ContentURI` interface.
6 changes: 6 additions & 0 deletions contracts/token/ERC6909/extensions/ERC6909ContentURI.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pragma solidity ^0.8.20;

import {ERC6909} from "../ERC6909.sol";
import {IERC6909ContentURI} from "../../../interfaces/IERC6909.sol";
import {IERC165} from "../../../utils/introspection/IERC165.sol";

/**
* @dev Implementation of the Content URI extension defined in ERC6909.
Expand All @@ -19,6 +20,11 @@ contract ERC6909ContentURI is ERC6909, IERC6909ContentURI {
/// @dev See {IERC1155-URI}
event URI(string value, uint256 indexed id);

/// @inheritdoc IERC165
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC6909, IERC165) returns (bool) {
return interfaceId == type(IERC6909ContentURI).interfaceId || super.supportsInterface(interfaceId);
}

/// @inheritdoc IERC6909ContentURI
function contractURI() public view virtual override returns (string memory) {
return _contractURI;
Expand Down
3 changes: 3 additions & 0 deletions test/token/ERC6909/extensions/ERC6909ContentURI.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { ethers } = require('hardhat');
const { expect } = require('chai');
const { loadFixture } = require('@nomicfoundation/hardhat-network-helpers');
const { shouldSupportInterfaces } = require('../../../utils/introspection/SupportsInterface.behavior');

async function fixture() {
const token = await ethers.deployContract('$ERC6909ContentURI');
Expand Down Expand Up @@ -46,4 +47,6 @@ describe('ERC6909ContentURI', function () {
.withArgs('https://example.com/1', 1n);
});
});

shouldSupportInterfaces(['ERC6909', 'ERC6909ContentURI']);
});
1 change: 1 addition & 0 deletions test/utils/introspection/SupportsInterface.behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ const SIGNATURES = {
'approve(address,uint256,uint256)',
'setOperator(address,bool)',
],
ERC6909ContentURI: ['contractURI()', 'tokenURI(uint256)'],
};

const INTERFACE_IDS = mapValues(SIGNATURES, interfaceId);
Expand Down