diff --git a/src/ERC1155Common.sol b/src/ERC1155Common.sol index 8dc8cbb..d91ba8a 100644 --- a/src/ERC1155Common.sol +++ b/src/ERC1155Common.sol @@ -2,6 +2,7 @@ // Compatible with OpenZeppelin Contracts ^5.0.0 pragma solidity ^0.8.20; +import { IERC165 } from "@openzeppelin/contracts/interfaces/IERC165.sol"; import { AccessControlEnumerable } from "@openzeppelin/contracts/access/AccessControlEnumerable.sol"; import { ERC1155 } from "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; @@ -105,16 +106,12 @@ contract ERC1155Common is return string.concat(uri_, tokenId.toString()); } - /** - * @dev Collection name. - */ + /// @inheritdoc IERC1155Common function name() public view virtual returns (string memory) { return _name; } - /** - * @dev Collection symbol. - */ + /// @inheritdoc IERC1155Common function symbol() public view virtual returns (string memory) { return _symbol; } @@ -126,7 +123,7 @@ contract ERC1155Common is public view virtual - override(ERC1155, AccessControlEnumerable) + override(IERC165, ERC1155, AccessControlEnumerable) returns (bool) { return interfaceId == type(IERC1155Common).interfaceId || super.supportsInterface(interfaceId); diff --git a/src/interfaces/IERC1155Common.sol b/src/interfaces/IERC1155Common.sol index 017025a..4df32ae 100644 --- a/src/interfaces/IERC1155Common.sol +++ b/src/interfaces/IERC1155Common.sol @@ -1,7 +1,16 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.0; -interface IERC1155Common { +import { IAccessControlEnumerable } from "@openzeppelin/contracts/access/IAccessControlEnumerable.sol"; +import { IERC1155 } from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol"; + +interface IERC1155Common is IAccessControlEnumerable, IERC1155 { + /// @dev Return the name of the collection. + function name() external view returns (string memory); + + /// @dev Return the symbol of the collection. + function symbol() external view returns (string memory); + /** * @dev Mints a single ERC1155 token and assigns it to the specified address. * diff --git a/test/foundry/SampleERC1155.t.sol b/test/foundry/SampleERC1155.t.sol index e89dfa7..c723c9b 100644 --- a/test/foundry/SampleERC1155.t.sol +++ b/test/foundry/SampleERC1155.t.sol @@ -4,6 +4,7 @@ pragma solidity ^0.8.13; import "forge-std/Test.sol"; import { Strings } from "@openzeppelin/contracts/utils/Strings.sol"; import { SampleERC1155, ERC1155Common } from "../../src/mock/SampleERC1155.sol"; +import { IERC165 } from "@openzeppelin/contracts/interfaces/IERC165.sol"; import { IERC1155 } from "@openzeppelin/contracts/interfaces/IERC1155.sol"; import { IAccessControlEnumerable } from "@openzeppelin/contracts/access/IAccessControlEnumerable.sol"; import { IERC1155Common } from "src/interfaces/IERC1155Common.sol"; @@ -51,6 +52,7 @@ contract SampleERC1155Test is Test { assertEq(_token().supportsInterface(type(IERC1155).interfaceId), true); assertEq(_token().supportsInterface(type(IAccessControlEnumerable).interfaceId), true); assertEq(_token().supportsInterface(type(IERC1155Common).interfaceId), true); + assertEq(_token().supportsInterface(type(IERC165).interfaceId), true); } function _token() internal view virtual returns (ERC1155Common) { diff --git a/test/foundry/SampleNFT1155Launchpad.t.sol b/test/foundry/SampleNFT1155Launchpad.t.sol index 4c7ddaf..2731fa1 100644 --- a/test/foundry/SampleNFT1155Launchpad.t.sol +++ b/test/foundry/SampleNFT1155Launchpad.t.sol @@ -5,7 +5,7 @@ import "forge-std/Test.sol"; import { Strings } from "@openzeppelin/contracts/utils/Strings.sol"; import { SampleNFT1155Launchpad, SampleERC1155 } from "../../src/mock/launchpad/SampleNFT1155Launchpad.sol"; import { INFTLaunchpad } from "src/interfaces/launchpad/INFTLaunchpad.sol"; -import { IERC1155Common } from "src/interfaces/IERC1155Common.sol"; +import { IERC1155Common, IAccessControlEnumerable, IERC1155 } from "src/interfaces/IERC1155Common.sol"; contract SampleERC1155LaunchpadTest is Test { using Strings for uint256; @@ -21,9 +21,11 @@ contract SampleERC1155LaunchpadTest is Test { _t = new SampleNFT1155Launchpad(admin, NAME, SYMBOL, BASE_URI); } - function testSupportInterface() public { + function testSupportsInterface() public { assertEq(_token().supportsInterface(type(INFTLaunchpad).interfaceId), true); assertEq(_token().supportsInterface(type(IERC1155Common).interfaceId), true); + assertEq(_token().supportsInterface(type(IAccessControlEnumerable).interfaceId), true); + assertEq(_token().supportsInterface(type(IERC1155).interfaceId), true); } function _token() internal view virtual returns (SampleNFT1155Launchpad) {