From f5db390c1723531d818d159966c53a8cce80f2d0 Mon Sep 17 00:00:00 2001 From: huyhuynh3103 Date: Sun, 29 Dec 2024 16:39:03 +0700 Subject: [PATCH] fix: remove underscore and useless _requireOwned --- src/ERC721Common.sol | 19 +++++++------ test/foundry/SampleNFT1155Launchpad.t.sol | 34 ----------------------- test/foundry/SampleNFT721Launchpad.t.sol | 31 --------------------- 3 files changed, 10 insertions(+), 74 deletions(-) delete mode 100644 test/foundry/SampleNFT1155Launchpad.t.sol delete mode 100644 test/foundry/SampleNFT721Launchpad.t.sol diff --git a/src/ERC721Common.sol b/src/ERC721Common.sol index 8cf5abb..1e06461 100644 --- a/src/ERC721Common.sol +++ b/src/ERC721Common.sol @@ -8,15 +8,16 @@ import { ERC721Nonce } from "./refs/ERC721Nonce.sol"; import { ERC721 } from "@openzeppelin/contracts/token/ERC721/ERC721.sol"; contract ERC721Common is ERC721Nonce, ERC721PresetMinterPauserAutoIdCustomized, IERC721State, IERC721Common { - constructor(string memory name, string memory symbol, string memory baseTokenURI) - ERC721PresetMinterPauserAutoIdCustomized(name, symbol, baseTokenURI) - { } + constructor( + string memory name, + string memory symbol, + string memory baseTokenURI + ) ERC721PresetMinterPauserAutoIdCustomized(name, symbol, baseTokenURI) { } /// @inheritdoc IERC721State function stateOf( uint256 tokenId ) external view virtual override returns (bytes memory) { - _requireOwned(tokenId); return abi.encodePacked(ownerOf(tokenId), nonces[tokenId], tokenId); } @@ -76,13 +77,13 @@ contract ERC721Common is ERC721Nonce, ERC721PresetMinterPauserAutoIdCustomized, * - the caller must have the `MINTER_ROLE`. */ function bulkMint( - address[] calldata _recipients + address[] calldata recipients ) external virtual onlyRole(MINTER_ROLE) returns (uint256[] memory tokenIds) { - require(_recipients.length > 0, "ERC721Common: invalid array lengths"); - tokenIds = new uint256[](_recipients.length); + require(recipients.length > 0, "ERC721Common: invalid array lengths"); + tokenIds = new uint256[](recipients.length); - for (uint256 _i = 0; _i < _recipients.length; _i++) { - tokenIds[_i] = _mintFor(_recipients[_i]); + for (uint256 i; i < recipients.length; i++) { + tokenIds[i] = _mintFor(recipients[i]); } } } diff --git a/test/foundry/SampleNFT1155Launchpad.t.sol b/test/foundry/SampleNFT1155Launchpad.t.sol deleted file mode 100644 index 2731fa1..0000000 --- a/test/foundry/SampleNFT1155Launchpad.t.sol +++ /dev/null @@ -1,34 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -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, IAccessControlEnumerable, IERC1155 } from "src/interfaces/IERC1155Common.sol"; - -contract SampleERC1155LaunchpadTest is Test { - using Strings for uint256; - - address admin = makeAddr("admin"); - string public constant NAME = "SampleERC721"; - string public constant SYMBOL = "NFT"; - string public constant BASE_URI = "http://example.com/"; - - SampleNFT1155Launchpad internal _t; - - function setUp() public virtual { - _t = new SampleNFT1155Launchpad(admin, NAME, SYMBOL, BASE_URI); - } - - 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) { - return _t; - } -} diff --git a/test/foundry/SampleNFT721Launchpad.t.sol b/test/foundry/SampleNFT721Launchpad.t.sol deleted file mode 100644 index 1d5d0c0..0000000 --- a/test/foundry/SampleNFT721Launchpad.t.sol +++ /dev/null @@ -1,31 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -import "forge-std/Test.sol"; -import { Strings } from "@openzeppelin/contracts/utils/Strings.sol"; -import { SampleNFT721Launchpad } from "../../src/mock/launchpad/SampleNFT721Launchpad.sol"; -import { INFTLaunchpad } from "src/interfaces/launchpad/INFTLaunchpad.sol"; -import { IERC721Common } from "src/interfaces/IERC721Common.sol"; - -contract SampleNFT721LaunchpadTest is Test { - using Strings for uint256; - - string public constant NAME = "SampleERC721"; - string public constant SYMBOL = "NFT"; - string public constant BASE_URI = "http://example.com/"; - - SampleNFT721Launchpad internal _t; - - function setUp() public virtual { - _t = new SampleNFT721Launchpad(NAME, SYMBOL, BASE_URI); - } - - function testSupportInterface() public { - assertEq(_token().supportsInterface(type(INFTLaunchpad).interfaceId), true); - assertEq(_token().supportsInterface(type(IERC721Common).interfaceId), true); - } - - function _token() internal view virtual returns (SampleNFT721Launchpad) { - return _t; - } -}