Skip to content

Commit

Permalink
fix: resolve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
huyhuynh3103 committed Nov 14, 2024
1 parent c79dd17 commit ee7c169
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
11 changes: 4 additions & 7 deletions src/ERC1155Common.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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;
}
Expand All @@ -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);
Expand Down
11 changes: 10 additions & 1 deletion src/interfaces/IERC1155Common.sol
Original file line number Diff line number Diff line change
@@ -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.
*
Expand Down
2 changes: 2 additions & 0 deletions test/foundry/SampleERC1155.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 4 additions & 2 deletions test/foundry/SampleNFT1155Launchpad.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down

0 comments on commit ee7c169

Please sign in to comment.