From a0e3b3f0bd57d4757a3f112b2584a562497b4b72 Mon Sep 17 00:00:00 2001 From: z0r0z <92001561+z0r0z@users.noreply.github.com> Date: Thu, 17 Nov 2022 07:57:56 +0900 Subject: [PATCH 1/7] =?UTF-8?q?=E2=9A=A1=20=20Optimize=20&&=20checks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ⚡ Optimize && checks --- src/tokens/ERC1155/ERC1155.sol | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/tokens/ERC1155/ERC1155.sol b/src/tokens/ERC1155/ERC1155.sol index 1e85989..8ea8304 100644 --- a/src/tokens/ERC1155/ERC1155.sol +++ b/src/tokens/ERC1155/ERC1155.sol @@ -72,7 +72,8 @@ abstract contract ERC1155 { uint256 amount, bytes calldata data ) public virtual { - if (msg.sender != from && !isApprovedForAll[from][msg.sender]) revert Unauthorized(); + if (msg.sender != from) + if (!isApprovedForAll[from][msg.sender]) revert Unauthorized(); balanceOf[from][id] -= amount; balanceOf[to][id] += amount; @@ -96,7 +97,8 @@ abstract contract ERC1155 { ) public virtual { if (ids.length != amounts.length) revert LengthMismatch(); - if (msg.sender != from && !isApprovedForAll[from][msg.sender]) revert Unauthorized(); + if (msg.sender != from) + if (!isApprovedForAll[from][msg.sender]) revert Unauthorized(); // Storing these outside the loop saves ~15 gas per iteration. uint256 id; @@ -149,9 +151,9 @@ abstract contract ERC1155 { function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { return - interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165 - interfaceId == 0xd9b67a26 || // ERC165 Interface ID for ERC1155 - interfaceId == 0x0e89341c; // ERC165 Interface ID for ERC1155MetadataURI + interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165. + interfaceId == 0xd9b67a26 || // ERC165 Interface ID for ERC1155. + interfaceId == 0x0e89341c; // ERC165 Interface ID for ERC1155MetadataURI. } /// ----------------------------------------------------------------------- From 80d8c2000cd1052c30b78e645eb4702cfd499ece Mon Sep 17 00:00:00 2001 From: z0r0z <92001561+z0r0z@users.noreply.github.com> Date: Thu, 17 Nov 2022 07:58:39 +0900 Subject: [PATCH 2/7] =?UTF-8?q?=E2=9C=A8=20=20Single=20supply=20token?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✨ Single supply token --- src/tokens/ERC1155/ERC1155B.sol | 283 ++++++++++++++++++++++++++++++++ 1 file changed, 283 insertions(+) create mode 100644 src/tokens/ERC1155/ERC1155B.sol diff --git a/src/tokens/ERC1155/ERC1155B.sol b/src/tokens/ERC1155/ERC1155B.sol new file mode 100644 index 0000000..b33bb89 --- /dev/null +++ b/src/tokens/ERC1155/ERC1155B.sol @@ -0,0 +1,283 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.4; + +import {ERC1155TokenReceiver} from "./ERC1155.sol"; + +/// @notice Modern, minimalist and gas-optimized ERC1155 implementation for single supply ids. +/// @author Solbase (https://github.com/Sol-DAO/solbase/blob/main/src/tokens/ERC1155/ERC1155B.sol) +/// @author Modified from Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC1155B.sol) +abstract contract ERC1155B { + /// ----------------------------------------------------------------------- + /// Events + /// ----------------------------------------------------------------------- + + event TransferSingle( + address indexed operator, + address indexed from, + address indexed to, + uint256 id, + uint256 amount + ); + + event TransferBatch( + address indexed operator, + address indexed from, + address indexed to, + uint256[] ids, + uint256[] amounts + ); + + event ApprovalForAll(address indexed owner, address indexed operator, bool approved); + + event URI(string value, uint256 indexed id); + + /// ----------------------------------------------------------------------- + /// Custom Errors + /// ----------------------------------------------------------------------- + + error Unauthorized(); + + error WrongFrom(); + + error InvalidAmount(); + + error UnsafeRecipient(); + + error InvalidRecipient(); + + error LengthMismatch(); + + error AlreadyMinted(); + + error InvalidFrom(); + + error NotMinted(); + + /// ----------------------------------------------------------------------- + /// ERC1155 Storage + /// ----------------------------------------------------------------------- + + mapping(address => mapping(address => bool)) public isApprovedForAll; + + /// ----------------------------------------------------------------------- + /// ERC1155B Storage + /// ----------------------------------------------------------------------- + + mapping(uint256 => address) public ownerOf; + + function balanceOf(address owner, uint256 id) public view virtual returns (uint256 bal) { + address idOwner = ownerOf[id]; + + assembly { + // We avoid branching by using assembly to take + // the bool output of eq() and use it as a uint. + bal := eq(idOwner, owner) + } + } + + /// ----------------------------------------------------------------------- + /// Metadata Logic + /// ----------------------------------------------------------------------- + + function uri(uint256 id) public view virtual returns (string memory); + + /// ----------------------------------------------------------------------- + /// ERC1155 Logic + /// ----------------------------------------------------------------------- + + function setApprovalForAll(address operator, bool approved) public virtual { + isApprovedForAll[msg.sender][operator] = approved; + + emit ApprovalForAll(msg.sender, operator, approved); + } + + function safeTransferFrom( + address from, + address to, + uint256 id, + uint256 amount, + bytes calldata data + ) public virtual { + if (msg.sender != from) + if (!isApprovedForAll[from][msg.sender]) revert Unauthorized(); + + if (from != ownerOf[id]) revert WrongFrom(); // Can only transfer from the owner. + + // Can only transfer 1 with ERC1155B. + if (amount != 1) revert InvalidAmount(); + + ownerOf[id] = to; + + emit TransferSingle(msg.sender, from, to, id, amount); + + if (to.code.length != 0) { + if ( + ERC1155TokenReceiver(to).onERC1155Received(msg.sender, from, id, 1, data) != + ERC1155TokenReceiver.onERC1155Received.selector + ) revert UnsafeRecipient(); + } else if (to == address(0)) revert InvalidRecipient(); + } + + function safeBatchTransferFrom( + address from, + address to, + uint256[] calldata ids, + uint256[] calldata amounts, + bytes calldata data + ) public virtual { + if (ids.length != amounts.length) revert LengthMismatch(); + + if (msg.sender != from) + if (!isApprovedForAll[from][msg.sender]) revert Unauthorized(); + + // Storing these outside the loop saves ~15 gas per iteration. + uint256 id; + uint256 amount; + + // Unchecked because the only math done is incrementing + // the array index counter which cannot possibly overflow. + unchecked { + for (uint256 i = 0; i < ids.length; i++) { + id = ids[i]; + amount = amounts[i]; + + // Can only transfer from the owner. + if (from != ownerOf[id]) revert WrongFrom(); + + // Can only transfer 1 with ERC1155B. + if (amount != 1) revert InvalidAmount(); + + ownerOf[id] = to; + } + } + + emit TransferBatch(msg.sender, from, to, ids, amounts); + + if (to.code.length != 0) { + if ( + ERC1155TokenReceiver(to).onERC1155BatchReceived(msg.sender, from, ids, amounts, data) != + ERC1155TokenReceiver.onERC1155BatchReceived.selector + ) revert UnsafeRecipient(); + } else if (to == address(0)) revert InvalidRecipient(); + } + + function balanceOfBatch( + address[] calldata owners, + uint256[] calldata ids + ) public view virtual returns (uint256[] memory balances) { + if (owners.length != ids.length) revert LengthMismatch(); + + balances = new uint256[](owners.length); + + // Unchecked because the only math done is incrementing + // the array index counter which cannot possibly overflow. + unchecked { + for (uint256 i = 0; i < owners.length; ++i) { + balances[i] = balanceOf(owners[i], ids[i]); + } + } + } + + /// ----------------------------------------------------------------------- + /// ERC165 Logic + /// ----------------------------------------------------------------------- + + function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { + return + interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165. + interfaceId == 0xd9b67a26 || // ERC165 Interface ID for ERC1155. + interfaceId == 0x0e89341c; // ERC165 Interface ID for ERC1155MetadataURI. + } + + /// ----------------------------------------------------------------------- + /// Internal Mint/Burn Logic + /// ----------------------------------------------------------------------- + + function _mint(address to, uint256 id, bytes memory data) internal virtual { + // Minting twice would effectively be a force transfer. + if (ownerOf[id] != address(0)) revert AlreadyMinted(); + + ownerOf[id] = to; + + emit TransferSingle(msg.sender, address(0), to, id, 1); + + if (to.code.length != 0) { + if ( + ERC1155TokenReceiver(to).onERC1155Received(msg.sender, address(0), id, 1, data) != + ERC1155TokenReceiver.onERC1155Received.selector + ) revert UnsafeRecipient(); + } else if (to == address(0)) revert InvalidRecipient(); + } + + function _batchMint(address to, uint256[] memory ids, bytes memory data) internal virtual { + uint256 idsLength = ids.length; // Saves MLOADs. + + // Generate an amounts array locally to use in the event below. + uint256[] memory amounts = new uint256[](idsLength); + + uint256 id; // Storing outside the loop saves ~7 gas per iteration. + + // Unchecked because the only math done is incrementing + // the array index counter which cannot possibly overflow. + unchecked { + for (uint256 i = 0; i < idsLength; ++i) { + id = ids[i]; + + // Minting twice would effectively be a force transfer. + if (ownerOf[id] != address(0)) revert AlreadyMinted(); + + ownerOf[id] = to; + + amounts[i] = 1; + } + } + + emit TransferBatch(msg.sender, address(0), to, ids, amounts); + + if (to.code.length != 0) { + if ( + ERC1155TokenReceiver(to).onERC1155BatchReceived(msg.sender, address(0), ids, amounts, data) != + ERC1155TokenReceiver.onERC1155BatchReceived.selector + ) revert UnsafeRecipient(); + } else if (to == address(0)) revert InvalidRecipient(); + } + + function _batchBurn(address from, uint256[] memory ids) internal virtual { + // Burning unminted tokens makes no sense. + if (from == address(0)) revert InvalidFrom(); + + uint256 idsLength = ids.length; // Saves MLOADs. + + // Generate an amounts array locally to use in the event below. + uint256[] memory amounts = new uint256[](idsLength); + + uint256 id; // Storing outside the loop saves ~7 gas per iteration. + + // Unchecked because the only math done is incrementing + // the array index counter which cannot possibly overflow. + unchecked { + for (uint256 i = 0; i < idsLength; ++i) { + id = ids[i]; + + // Can only transfer from the owner. + if (from != ownerOf[id]) revert WrongFrom(); + + ownerOf[id] = address(0); + + amounts[i] = 1; + } + } + + emit TransferBatch(msg.sender, from, address(0), ids, amounts); + } + + function _burn(uint256 id) internal virtual { + address owner = ownerOf[id]; + + if (owner == address(0)) revert NotMinted(); + + ownerOf[id] = address(0); + + emit TransferSingle(msg.sender, owner, address(0), id, 1); + } +} From bc99709d603dee8b8f8b17c63f7fd65caf0ea34f Mon Sep 17 00:00:00 2001 From: z0r0z <92001561+z0r0z@users.noreply.github.com> Date: Thu, 17 Nov 2022 07:59:46 +0900 Subject: [PATCH 3/7] =?UTF-8?q?=F0=9F=94=A7=20=20Tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🔧 Tests --- test/ERC1155B.t.sol | 662 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 662 insertions(+) create mode 100644 test/ERC1155B.t.sol diff --git a/test/ERC1155B.t.sol b/test/ERC1155B.t.sol new file mode 100644 index 0000000..0b960af --- /dev/null +++ b/test/ERC1155B.t.sol @@ -0,0 +1,662 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.4; + +import {DSTestPlus} from "./utils/DSTestPlus.sol"; +import {DSInvariantTest} from "./utils/DSInvariantTest.sol"; + +import {MockERC1155B} from "./utils/mocks/MockERC1155B.sol"; +import {ERC1155BUser} from "./utils/users/ERC1155BUser.sol"; + +import {ERC1155TokenReceiver} from "../src/tokens/ERC1155/ERC1155.sol"; + +// TODO: test invalid_amount errors +// TODO: test ownerOf() +// TODO: fuzz testing +// TODO: test custom safe batch transfer +// TODO: test cant burn unminted tokens + +contract ERC1155BRecipient is ERC1155TokenReceiver { + address public operator; + address public from; + uint256 public id; + uint256 public amount; + bytes public mintData; + + function onERC1155Received( + address _operator, + address _from, + uint256 _id, + uint256 _amount, + bytes calldata _data + ) public override returns (bytes4) { + operator = _operator; + from = _from; + id = _id; + amount = _amount; + mintData = _data; + + return ERC1155TokenReceiver.onERC1155Received.selector; + } + + address public batchOperator; + address public batchFrom; + uint256[] internal _batchIds; + uint256[] internal _batchAmounts; + bytes public batchData; + + function batchIds() external view returns (uint256[] memory) { + return _batchIds; + } + + function batchAmounts() external view returns (uint256[] memory) { + return _batchAmounts; + } + + function onERC1155BatchReceived( + address _operator, + address _from, + uint256[] calldata _ids, + uint256[] calldata _amounts, + bytes calldata _data + ) external override returns (bytes4) { + batchOperator = _operator; + batchFrom = _from; + _batchIds = _ids; + _batchAmounts = _amounts; + batchData = _data; + + return ERC1155TokenReceiver.onERC1155BatchReceived.selector; + } +} + +contract RevertingERC1155Recipient is ERC1155TokenReceiver { + function onERC1155Received( + address, + address, + uint256, + uint256, + bytes calldata + ) public pure override returns (bytes4) { + revert(string(abi.encodePacked(ERC1155TokenReceiver.onERC1155Received.selector))); + } + + function onERC1155BatchReceived( + address, + address, + uint256[] calldata, + uint256[] calldata, + bytes calldata + ) external pure override returns (bytes4) { + revert(string(abi.encodePacked(ERC1155TokenReceiver.onERC1155BatchReceived.selector))); + } +} + +contract WrongReturnDataERC1155BRecipient is ERC1155TokenReceiver { + function onERC1155Received( + address, + address, + uint256, + uint256, + bytes calldata + ) public pure override returns (bytes4) { + return 0xCAFEBEEF; + } + + function onERC1155BatchReceived( + address, + address, + uint256[] calldata, + uint256[] calldata, + bytes calldata + ) external pure override returns (bytes4) { + return 0xCAFEBEEF; + } +} + +contract NonERC1155BRecipient {} + +contract ERC1155BTest is DSTestPlus, ERC1155TokenReceiver { + MockERC1155B token; + + mapping(address => mapping(uint256 => uint256)) public userMintAmounts; + mapping(address => mapping(uint256 => uint256)) public userTransferOrBurnAmounts; + + function setUp() public { + token = new MockERC1155B(); + } + + function testMintToEOA() public { + token.mint(address(0xBEEF), 1337, ""); + + assertEq(token.balanceOf(address(0xBEEF), 1337), 1); + } + + function testMintToERC1155Recipient() public { + ERC1155BRecipient to = new ERC1155BRecipient(); + + token.mint(address(to), 1337, "testing 123"); + + assertEq(token.balanceOf(address(to), 1337), 1); + + assertEq(to.operator(), address(this)); + assertEq(to.from(), address(0)); + assertEq(to.id(), 1337); + assertBytesEq(to.mintData(), "testing 123"); + } + + function testBatchMintToEOA() public { + uint256[] memory ids = new uint256[](5); + ids[0] = 1337; + ids[1] = 1338; + ids[2] = 1339; + ids[3] = 1340; + ids[4] = 1341; + + token.batchMint(address(0xBEEF), ids, ""); + + assertEq(token.balanceOf(address(0xBEEF), 1337), 1); + assertEq(token.balanceOf(address(0xBEEF), 1338), 1); + assertEq(token.balanceOf(address(0xBEEF), 1339), 1); + assertEq(token.balanceOf(address(0xBEEF), 1340), 1); + assertEq(token.balanceOf(address(0xBEEF), 1341), 1); + } + + function testBatchMintToERC1155Recipient() public { + ERC1155BRecipient to = new ERC1155BRecipient(); + + uint256[] memory ids = new uint256[](5); + ids[0] = 1337; + ids[1] = 1338; + ids[2] = 1339; + ids[3] = 1340; + ids[4] = 1341; + + uint256[] memory amounts = new uint256[](5); + amounts[0] = 1; + amounts[1] = 1; + amounts[2] = 1; + amounts[3] = 1; + amounts[4] = 1; + + token.batchMint(address(to), ids, "testing 123"); + + assertEq(to.batchOperator(), address(this)); + assertEq(to.batchFrom(), address(0)); + assertUintArrayEq(to.batchIds(), ids); + assertUintArrayEq(to.batchAmounts(), amounts); + assertBytesEq(to.batchData(), "testing 123"); + + assertEq(token.balanceOf(address(to), 1337), 1); + assertEq(token.balanceOf(address(to), 1338), 1); + assertEq(token.balanceOf(address(to), 1339), 1); + assertEq(token.balanceOf(address(to), 1340), 1); + assertEq(token.balanceOf(address(to), 1341), 1); + } + + function testBurn() public { + token.mint(address(0xBEEF), 1337, ""); + + token.burn(1337); + + assertEq(token.balanceOf(address(0xBEEF), 1337), 0); + } + + function testBatchBurn() public { + uint256[] memory ids = new uint256[](5); + ids[0] = 1337; + ids[1] = 1338; + ids[2] = 1339; + ids[3] = 1340; + ids[4] = 1341; + + token.batchMint(address(0xBEEF), ids, ""); + + token.batchBurn(address(0xBEEF), ids); + + assertEq(token.balanceOf(address(0xBEEF), 1337), 0); + assertEq(token.balanceOf(address(0xBEEF), 1338), 0); + assertEq(token.balanceOf(address(0xBEEF), 1339), 0); + assertEq(token.balanceOf(address(0xBEEF), 1340), 0); + assertEq(token.balanceOf(address(0xBEEF), 1341), 0); + } + + function testApproveAll() public { + token.setApprovalForAll(address(0xBEEF), true); + + assertTrue(token.isApprovedForAll(address(this), address(0xBEEF))); + } + + function testSafeTransferFromToEOA() public { + ERC1155BUser from = new ERC1155BUser(token); + + token.mint(address(from), 1337, ""); + + from.setApprovalForAll(address(this), true); + + token.safeTransferFrom(address(from), address(0xBEEF), 1337, 1, ""); + + assertEq(token.balanceOf(address(0xBEEF), 1337), 1); + assertEq(token.balanceOf(address(from), 1337), 0); + } + + function testSafeTransferFromToERC1155Recipient() public { + ERC1155BRecipient to = new ERC1155BRecipient(); + + ERC1155BUser from = new ERC1155BUser(token); + + token.mint(address(from), 1337, ""); + + from.setApprovalForAll(address(this), true); + + token.safeTransferFrom(address(from), address(to), 1337, 1, "testing 123"); + + assertEq(to.operator(), address(this)); + assertEq(to.from(), address(from)); + assertEq(to.id(), 1337); + assertBytesEq(to.mintData(), "testing 123"); + + assertEq(token.balanceOf(address(to), 1337), 1); + assertEq(token.balanceOf(address(from), 1337), 0); + } + + function testSafeTransferFromSelf() public { + token.mint(address(this), 1337, ""); + + token.safeTransferFrom(address(this), address(0xBEEF), 1337, 1, ""); + + assertEq(token.balanceOf(address(0xBEEF), 1337), 1); + assertEq(token.balanceOf(address(this), 1337), 0); + } + + function testSafeBatchTransferFromToEOA() public { + ERC1155BUser from = new ERC1155BUser(token); + + uint256[] memory ids = new uint256[](5); + ids[0] = 1337; + ids[1] = 1338; + ids[2] = 1339; + ids[3] = 1340; + ids[4] = 1341; + + uint256[] memory transferAmounts = new uint256[](5); + transferAmounts[0] = 1; + transferAmounts[1] = 1; + transferAmounts[2] = 1; + transferAmounts[3] = 1; + transferAmounts[4] = 1; + + token.batchMint(address(from), ids, ""); + + from.setApprovalForAll(address(this), true); + + token.safeBatchTransferFrom(address(from), address(0xBEEF), ids, transferAmounts, ""); + + assertEq(token.balanceOf(address(from), 1337), 0); + assertEq(token.balanceOf(address(0xBEEF), 1337), 1); + + assertEq(token.balanceOf(address(from), 1338), 0); + assertEq(token.balanceOf(address(0xBEEF), 1338), 1); + + assertEq(token.balanceOf(address(from), 1339), 0); + assertEq(token.balanceOf(address(0xBEEF), 1339), 1); + + assertEq(token.balanceOf(address(from), 1340), 0); + assertEq(token.balanceOf(address(0xBEEF), 1340), 1); + + assertEq(token.balanceOf(address(from), 1341), 0); + assertEq(token.balanceOf(address(0xBEEF), 1341), 1); + } + + function testSafeBatchTransferFromToERC1155Recipient() public { + ERC1155BUser from = new ERC1155BUser(token); + + ERC1155BRecipient to = new ERC1155BRecipient(); + + uint256[] memory ids = new uint256[](5); + ids[0] = 1337; + ids[1] = 1338; + ids[2] = 1339; + ids[3] = 1340; + ids[4] = 1341; + + uint256[] memory transferAmounts = new uint256[](5); + transferAmounts[0] = 1; + transferAmounts[1] = 1; + transferAmounts[2] = 1; + transferAmounts[3] = 1; + transferAmounts[4] = 1; + + token.batchMint(address(from), ids, ""); + + from.setApprovalForAll(address(this), true); + + token.safeBatchTransferFrom(address(from), address(to), ids, transferAmounts, "testing 123"); + + assertEq(to.batchOperator(), address(this)); + assertEq(to.batchFrom(), address(from)); + assertUintArrayEq(to.batchIds(), ids); + assertUintArrayEq(to.batchAmounts(), transferAmounts); + assertBytesEq(to.batchData(), "testing 123"); + + assertEq(token.balanceOf(address(from), 1337), 0); + assertEq(token.balanceOf(address(to), 1337), 1); + + assertEq(token.balanceOf(address(from), 1338), 0); + assertEq(token.balanceOf(address(to), 1338), 1); + + assertEq(token.balanceOf(address(from), 1339), 0); + assertEq(token.balanceOf(address(to), 1339), 1); + + assertEq(token.balanceOf(address(from), 1340), 0); + assertEq(token.balanceOf(address(to), 1340), 1); + + assertEq(token.balanceOf(address(from), 1341), 0); + assertEq(token.balanceOf(address(to), 1341), 1); + } + + function testBatchBalanceOf() public { + address[] memory tos = new address[](5); + tos[0] = address(0xBEEF); + tos[1] = address(0xCAFE); + tos[2] = address(0xFACE); + tos[3] = address(0xDEAD); + tos[4] = address(0xFEED); + + uint256[] memory ids = new uint256[](5); + ids[0] = 1337; + ids[1] = 1338; + ids[2] = 1339; + ids[3] = 1340; + ids[4] = 1341; + + token.mint(address(0xBEEF), 1337, ""); + token.mint(address(0xCAFE), 1338, ""); + token.mint(address(0xFACE), 1339, ""); + token.mint(address(0xDEAD), 1340, ""); + token.mint(address(0xFEED), 1341, ""); + + uint256[] memory balances = token.balanceOfBatch(tos, ids); + + assertEq(balances[0], 1); + assertEq(balances[1], 1); + assertEq(balances[2], 1); + assertEq(balances[3], 1); + assertEq(balances[4], 1); + } + + function testFailMintToZero() public { + token.mint(address(0), 1337, ""); + } + + function testFailMintToNonERC1155Recipient() public { + token.mint(address(new NonERC1155BRecipient()), 1337, ""); + } + + function testFailMintToRevertingERC1155Recipient() public { + token.mint(address(new RevertingERC1155Recipient()), 1337, ""); + } + + function testFailMintToWrongReturnDataERC1155Recipient() public { + token.mint(address(new RevertingERC1155Recipient()), 1337, ""); + } + + function testFailBurnInsufficientBalance() public { + token.burn(1337); + } + + function testFailSafeTransferFromInsufficientBalance() public { + ERC1155BUser from = new ERC1155BUser(token); + + from.setApprovalForAll(address(this), true); + + token.safeTransferFrom(address(from), address(0xBEEF), 1337, 1, ""); + } + + function testFailSafeTransferFromSelfInsufficientBalance() public { + token.safeTransferFrom(address(this), address(0xBEEF), 1337, 1, ""); + } + + function testFailSafeTransferFromToZero() public { + token.safeTransferFrom(address(this), address(0), 1337, 1, ""); + } + + function testFailSafeTransferFromToNonERC1155Recipient() public { + token.mint(address(this), 1337, ""); + token.safeTransferFrom(address(this), address(new NonERC1155BRecipient()), 1337, 1, ""); + } + + function testFailSafeTransferFromToRevertingERC1155Recipient() public { + token.mint(address(this), 1337, ""); + token.safeTransferFrom(address(this), address(new RevertingERC1155Recipient()), 1337, 1, ""); + } + + function testFailSafeTransferFromToWrongReturnDataERC1155Recipient() public { + token.mint(address(this), 1337, ""); + token.safeTransferFrom(address(this), address(new WrongReturnDataERC1155BRecipient()), 1337, 1, ""); + } + + function testFailSafeBatchTransferInsufficientBalance() public { + ERC1155BUser from = new ERC1155BUser(token); + + uint256[] memory ids = new uint256[](5); + ids[0] = 1337; + ids[1] = 1338; + ids[2] = 1339; + ids[3] = 1340; + ids[4] = 1341; + + uint256[] memory transferAmounts = new uint256[](5); + transferAmounts[0] = 1; + transferAmounts[1] = 1; + transferAmounts[2] = 1; + transferAmounts[3] = 1; + transferAmounts[4] = 1; + + from.setApprovalForAll(address(this), true); + + token.safeBatchTransferFrom(address(from), address(0xBEEF), ids, transferAmounts, ""); + } + + function testFailSafeBatchTransferFromToZero() public { + ERC1155BUser from = new ERC1155BUser(token); + + uint256[] memory ids = new uint256[](5); + ids[0] = 1337; + ids[1] = 1338; + ids[2] = 1339; + ids[3] = 1340; + ids[4] = 1341; + + uint256[] memory transferAmounts = new uint256[](5); + transferAmounts[0] = 1; + transferAmounts[1] = 1; + transferAmounts[2] = 1; + transferAmounts[3] = 1; + transferAmounts[4] = 1; + + token.batchMint(address(from), ids, ""); + + from.setApprovalForAll(address(this), true); + + token.safeBatchTransferFrom(address(from), address(0), ids, transferAmounts, ""); + } + + function testFailSafeBatchTransferFromToNonERC1155Recipient() public { + ERC1155BUser from = new ERC1155BUser(token); + + uint256[] memory ids = new uint256[](5); + ids[0] = 1337; + ids[1] = 1338; + ids[2] = 1339; + ids[3] = 1340; + ids[4] = 1341; + + uint256[] memory transferAmounts = new uint256[](5); + transferAmounts[0] = 1; + transferAmounts[1] = 1; + transferAmounts[2] = 1; + transferAmounts[3] = 1; + transferAmounts[4] = 1; + + token.batchMint(address(from), ids, ""); + + from.setApprovalForAll(address(this), true); + + token.safeBatchTransferFrom(address(from), address(new NonERC1155BRecipient()), ids, transferAmounts, ""); + } + + function testFailSafeBatchTransferFromToRevertingERC1155Recipient() public { + ERC1155BUser from = new ERC1155BUser(token); + + uint256[] memory ids = new uint256[](5); + ids[0] = 1337; + ids[1] = 1338; + ids[2] = 1339; + ids[3] = 1340; + ids[4] = 1341; + + uint256[] memory transferAmounts = new uint256[](5); + transferAmounts[0] = 1; + transferAmounts[1] = 1; + transferAmounts[2] = 1; + transferAmounts[3] = 1; + transferAmounts[4] = 1; + + token.batchMint(address(from), ids, ""); + + from.setApprovalForAll(address(this), true); + + token.safeBatchTransferFrom(address(from), address(new RevertingERC1155Recipient()), ids, transferAmounts, ""); + } + + function testFailSafeBatchTransferFromToWrongReturnDataERC1155Recipient() public { + ERC1155BUser from = new ERC1155BUser(token); + + uint256[] memory ids = new uint256[](5); + ids[0] = 1337; + ids[1] = 1338; + ids[2] = 1339; + ids[3] = 1340; + ids[4] = 1341; + + uint256[] memory transferAmounts = new uint256[](5); + transferAmounts[0] = 1; + transferAmounts[1] = 1; + transferAmounts[2] = 1; + transferAmounts[3] = 1; + transferAmounts[4] = 1; + + token.batchMint(address(from), ids, ""); + + from.setApprovalForAll(address(this), true); + + token.safeBatchTransferFrom( + address(from), + address(new WrongReturnDataERC1155BRecipient()), + ids, + transferAmounts, + "" + ); + } + + function testFailSafeBatchTransferFromWithArrayLengthMismatch() public { + ERC1155BUser from = new ERC1155BUser(token); + + uint256[] memory ids = new uint256[](5); + ids[0] = 1337; + ids[1] = 1338; + ids[2] = 1339; + ids[3] = 1340; + ids[4] = 1341; + + uint256[] memory transferAmounts = new uint256[](4); + transferAmounts[0] = 1; + transferAmounts[1] = 1; + transferAmounts[2] = 1; + transferAmounts[3] = 1; + + token.batchMint(address(from), ids, ""); + + from.setApprovalForAll(address(this), true); + + token.safeBatchTransferFrom(address(from), address(0xBEEF), ids, transferAmounts, ""); + } + + function testFailBatchMintToZero() public { + uint256[] memory ids = new uint256[](5); + ids[0] = 1337; + ids[1] = 1338; + ids[2] = 1339; + ids[3] = 1340; + ids[4] = 1341; + + token.batchMint(address(0), ids, ""); + } + + function testFailBatchMintToNonERC1155Recipient() public { + NonERC1155BRecipient to = new NonERC1155BRecipient(); + + uint256[] memory ids = new uint256[](5); + ids[0] = 1337; + ids[1] = 1338; + ids[2] = 1339; + ids[3] = 1340; + ids[4] = 1341; + + token.batchMint(address(to), ids, ""); + } + + function testFailBatchMintToRevertingERC1155Recipient() public { + RevertingERC1155Recipient to = new RevertingERC1155Recipient(); + + uint256[] memory ids = new uint256[](5); + ids[0] = 1337; + ids[1] = 1338; + ids[2] = 1339; + ids[3] = 1340; + ids[4] = 1341; + + token.batchMint(address(to), ids, ""); + } + + function testFailBatchMintToWrongReturnDataERC1155Recipient() public { + WrongReturnDataERC1155BRecipient to = new WrongReturnDataERC1155BRecipient(); + + uint256[] memory ids = new uint256[](5); + ids[0] = 1337; + ids[1] = 1338; + ids[2] = 1339; + ids[3] = 1340; + ids[4] = 1341; + + token.batchMint(address(to), ids, ""); + } + + function testFailBatchBurnInsufficientBalance() public { + uint256[] memory ids = new uint256[](5); + ids[0] = 1337; + ids[1] = 1338; + ids[2] = 1339; + ids[3] = 1340; + ids[4] = 1341; + + token.batchBurn(address(0xBEEF), ids); + } + + function testFailBalanceOfBatchWithArrayMismatch() public view { + address[] memory tos = new address[](5); + tos[0] = address(0xBEEF); + tos[1] = address(0xCAFE); + tos[2] = address(0xFACE); + tos[3] = address(0xDEAD); + tos[4] = address(0xFEED); + + uint256[] memory ids = new uint256[](4); + ids[0] = 1337; + ids[1] = 1338; + ids[2] = 1339; + ids[3] = 1340; + + token.balanceOfBatch(tos, ids); + } +} From 736c9b8ff09b605d9ca939557b4c828614364fd4 Mon Sep 17 00:00:00 2001 From: z0r0z <92001561+z0r0z@users.noreply.github.com> Date: Thu, 17 Nov 2022 08:00:19 +0900 Subject: [PATCH 4/7] =?UTF-8?q?=E2=9C=8D=EF=B8=8F=20=20mock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✍️ mock --- test/utils/mocks/MockERC1155B.sol | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 test/utils/mocks/MockERC1155B.sol diff --git a/test/utils/mocks/MockERC1155B.sol b/test/utils/mocks/MockERC1155B.sol new file mode 100644 index 0000000..d21d46a --- /dev/null +++ b/test/utils/mocks/MockERC1155B.sol @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.4; + +import {ERC1155B} from "../../../src/tokens/ERC1155/ERC1155B.sol"; + +contract MockERC1155B is ERC1155B { + function uri(uint256) public pure virtual override returns (string memory) {} + + function mint(address to, uint256 id, bytes memory data) public virtual { + _mint(to, id, data); + } + + function batchMint(address to, uint256[] memory ids, bytes memory data) public virtual { + _batchMint(to, ids, data); + } + + function burn(uint256 id) public virtual { + _burn(id); + } + + function batchBurn(address from, uint256[] memory ids) public virtual { + _batchBurn(from, ids); + } +} From e72e3f3760d710732d0640d68ae7622d069094f3 Mon Sep 17 00:00:00 2001 From: z0r0z <92001561+z0r0z@users.noreply.github.com> Date: Thu, 17 Nov 2022 08:02:35 +0900 Subject: [PATCH 5/7] =?UTF-8?q?=E2=9C=8B=20user?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✋ user --- test/utils/user/ERC1155BUser.sol | 51 ++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 test/utils/user/ERC1155BUser.sol diff --git a/test/utils/user/ERC1155BUser.sol b/test/utils/user/ERC1155BUser.sol new file mode 100644 index 0000000..ac23d2c --- /dev/null +++ b/test/utils/user/ERC1155BUser.sol @@ -0,0 +1,51 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.4; + +import {ERC1155TokenReceiver} from "../../../src/tokens/ERC1155/ERC1155.sol"; +import {ERC1155B} from "../../../src/tokens/ERC1155/ERC1155B.sol"; + +contract ERC1155BUser is ERC1155TokenReceiver { + ERC1155B token; + + constructor(ERC1155B _token) { + token = _token; + } + + function onERC1155Received( + address, + address, + uint256, + uint256, + bytes calldata + ) external virtual override returns (bytes4) { + return ERC1155TokenReceiver.onERC1155Received.selector; + } + + function onERC1155BatchReceived( + address, + address, + uint256[] calldata, + uint256[] calldata, + bytes calldata + ) external virtual override returns (bytes4) { + return ERC1155TokenReceiver.onERC1155BatchReceived.selector; + } + + function setApprovalForAll(address operator, bool approved) public virtual { + token.setApprovalForAll(operator, approved); + } + + function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes memory data) public virtual { + token.safeTransferFrom(from, to, id, amount, data); + } + + function safeBatchTransferFrom( + address from, + address to, + uint256[] memory ids, + uint256[] memory amounts, + bytes memory data + ) public virtual { + token.safeBatchTransferFrom(from, to, ids, amounts, data); + } +} From cb7a77fec310ee1193069b52a1db0fdc96338384 Mon Sep 17 00:00:00 2001 From: z0r0z <92001561+z0r0z@users.noreply.github.com> Date: Thu, 17 Nov 2022 08:05:52 +0900 Subject: [PATCH 6/7] =?UTF-8?q?=F0=9F=93=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 📸 --- .gas-snapshot | 120 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 78 insertions(+), 42 deletions(-) diff --git a/.gas-snapshot b/.gas-snapshot index 355014a..0386df9 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -76,29 +76,29 @@ EIP712Test:testDigest() (gas: 12916) ERC1155Test:testApproveAll() (gas: 30986) ERC1155Test:testApproveAll(address,bool) (runs: 256, μ: 16849, ~: 11417) ERC1155Test:testBatchBalanceOf() (gas: 157423) -ERC1155Test:testBatchBalanceOf(address[],uint256[],uint256[],bytes) (runs: 256, μ: 3305275, ~: 2594045) +ERC1155Test:testBatchBalanceOf(address[],uint256[],uint256[],bytes) (runs: 256, μ: 3305324, ~: 2594045) ERC1155Test:testBatchBurn() (gas: 151176) -ERC1155Test:testBatchBurn(address,uint256[],uint256[],uint256[],bytes) (runs: 256, μ: 3457909, ~: 3062676) +ERC1155Test:testBatchBurn(address,uint256[],uint256[],uint256[],bytes) (runs: 256, μ: 3454382, ~: 3061084) ERC1155Test:testBatchMintToEOA() (gas: 137377) -ERC1155Test:testBatchMintToEOA(address,uint256[],uint256[],bytes) (runs: 256, μ: 3265687, ~: 2944287) +ERC1155Test:testBatchMintToEOA(address,uint256[],uint256[],bytes) (runs: 256, μ: 3268753, ~: 2944287) ERC1155Test:testBatchMintToERC1155Recipient() (gas: 994281) -ERC1155Test:testBatchMintToERC1155Recipient(uint256[],uint256[],bytes) (runs: 256, μ: 7335949, ~: 6374701) +ERC1155Test:testBatchMintToERC1155Recipient(uint256[],uint256[],bytes) (runs: 256, μ: 7336833, ~: 6396501) ERC1155Test:testBurn() (gas: 38582) -ERC1155Test:testBurn(address,uint256,uint256,bytes,uint256) (runs: 256, μ: 40155, ~: 42088) +ERC1155Test:testBurn(address,uint256,uint256,bytes,uint256) (runs: 256, μ: 40205, ~: 42088) ERC1155Test:testFailBalanceOfBatchWithArrayMismatch() (gas: 7880) ERC1155Test:testFailBalanceOfBatchWithArrayMismatch(address[],uint256[]) (runs: 256, μ: 53333, ~: 54013) ERC1155Test:testFailBatchBurnInsufficientBalance() (gas: 136224) -ERC1155Test:testFailBatchBurnInsufficientBalance(address,uint256[],uint256[],uint256[],bytes) (runs: 256, μ: 1281911, ~: 441110) +ERC1155Test:testFailBatchBurnInsufficientBalance(address,uint256[],uint256[],uint256[],bytes) (runs: 256, μ: 1279357, ~: 441110) ERC1155Test:testFailBatchBurnWithArrayLengthMismatch() (gas: 135529) ERC1155Test:testFailBatchBurnWithArrayLengthMismatch(address,uint256[],uint256[],uint256[],bytes) (runs: 256, μ: 77061, ~: 78670) ERC1155Test:testFailBatchMintToNonERC1155Recipient() (gas: 167341) -ERC1155Test:testFailBatchMintToNonERC1155Recipient(uint256[],uint256[],bytes) (runs: 256, μ: 3133059, ~: 2675353) +ERC1155Test:testFailBatchMintToNonERC1155Recipient(uint256[],uint256[],bytes) (runs: 256, μ: 3133943, ~: 2675353) ERC1155Test:testFailBatchMintToRevertingERC1155Recipient() (gas: 357438) -ERC1155Test:testFailBatchMintToRevertingERC1155Recipient(uint256[],uint256[],bytes) (runs: 256, μ: 3323175, ~: 2865467) +ERC1155Test:testFailBatchMintToRevertingERC1155Recipient(uint256[],uint256[],bytes) (runs: 256, μ: 3324058, ~: 2865467) ERC1155Test:testFailBatchMintToWrongReturnDataERC1155Recipient() (gas: 310714) -ERC1155Test:testFailBatchMintToWrongReturnDataERC1155Recipient(uint256[],uint256[],bytes) (runs: 256, μ: 3276477, ~: 2818770) +ERC1155Test:testFailBatchMintToWrongReturnDataERC1155Recipient(uint256[],uint256[],bytes) (runs: 256, μ: 3277360, ~: 2818770) ERC1155Test:testFailBatchMintToZero() (gas: 131711) -ERC1155Test:testFailBatchMintToZero(uint256[],uint256[],bytes) (runs: 256, μ: 3073494, ~: 2614560) +ERC1155Test:testFailBatchMintToZero(uint256[],uint256[],bytes) (runs: 256, μ: 3074378, ~: 2614560) ERC1155Test:testFailBatchMintWithArrayMismatch() (gas: 9547) ERC1155Test:testFailBatchMintWithArrayMismatch(address,uint256[],uint256[],bytes) (runs: 256, μ: 69176, ~: 68740) ERC1155Test:testFailBurnInsufficientBalance() (gas: 34834) @@ -111,44 +111,80 @@ ERC1155Test:testFailMintToWrongReturnDataERC155Recipient() (gas: 257930) ERC1155Test:testFailMintToWrongReturnDataERC155Recipient(uint256,uint256,bytes) (runs: 256, μ: 258210, ~: 258892) ERC1155Test:testFailMintToZero() (gas: 33587) ERC1155Test:testFailMintToZero(uint256,uint256,bytes) (runs: 256, μ: 33676, ~: 34406) -ERC1155Test:testFailSafeBatchTransferFromToNonERC1155Recipient() (gas: 321547) -ERC1155Test:testFailSafeBatchTransferFromToNonERC1155Recipient(uint256[],uint256[],uint256[],bytes,bytes) (runs: 256, μ: 3498217, ~: 2963179) -ERC1155Test:testFailSafeBatchTransferFromToRevertingERC1155Recipient() (gas: 511704) -ERC1155Test:testFailSafeBatchTransferFromToRevertingERC1155Recipient(uint256[],uint256[],uint256[],bytes,bytes) (runs: 256, μ: 3688332, ~: 3153288) -ERC1155Test:testFailSafeBatchTransferFromToWrongReturnDataERC1155Recipient() (gas: 464939) -ERC1155Test:testFailSafeBatchTransferFromToWrongReturnDataERC1155Recipient(uint256[],uint256[],uint256[],bytes,bytes) (runs: 256, μ: 3641594, ~: 3106553) -ERC1155Test:testFailSafeBatchTransferFromToZero() (gas: 286668) -ERC1155Test:testFailSafeBatchTransferFromToZero(uint256[],uint256[],uint256[],bytes,bytes) (runs: 256, μ: 3462979, ~: 2928024) +ERC1155Test:testFailSafeBatchTransferFromToNonERC1155Recipient() (gas: 321529) +ERC1155Test:testFailSafeBatchTransferFromToNonERC1155Recipient(uint256[],uint256[],uint256[],bytes,bytes) (runs: 256, μ: 3501826, ~: 2966443) +ERC1155Test:testFailSafeBatchTransferFromToRevertingERC1155Recipient() (gas: 511686) +ERC1155Test:testFailSafeBatchTransferFromToRevertingERC1155Recipient(uint256[],uint256[],uint256[],bytes,bytes) (runs: 256, μ: 3691941, ~: 3156552) +ERC1155Test:testFailSafeBatchTransferFromToWrongReturnDataERC1155Recipient() (gas: 464921) +ERC1155Test:testFailSafeBatchTransferFromToWrongReturnDataERC1155Recipient(uint256[],uint256[],uint256[],bytes,bytes) (runs: 256, μ: 3645203, ~: 3109817) +ERC1155Test:testFailSafeBatchTransferFromToZero() (gas: 286650) +ERC1155Test:testFailSafeBatchTransferFromToZero(uint256[],uint256[],uint256[],bytes,bytes) (runs: 256, μ: 3466588, ~: 2931230) ERC1155Test:testFailSafeBatchTransferFromWithArrayLengthMismatch() (gas: 162739) ERC1155Test:testFailSafeBatchTransferFromWithArrayLengthMismatch(address,uint256[],uint256[],uint256[],bytes,bytes) (runs: 256, μ: 81109, ~: 81961) -ERC1155Test:testFailSafeBatchTransferInsufficientBalance() (gas: 163702) -ERC1155Test:testFailSafeBatchTransferInsufficientBalance(address,uint256[],uint256[],uint256[],bytes,bytes) (runs: 256, μ: 1499863, ~: 500326) -ERC1155Test:testFailSafeTransferFromInsufficientBalance() (gas: 63261) -ERC1155Test:testFailSafeTransferFromInsufficientBalance(address,uint256,uint256,uint256,bytes,bytes) (runs: 256, μ: 63977, ~: 67392) -ERC1155Test:testFailSafeTransferFromSelfInsufficientBalance() (gas: 34297) -ERC1155Test:testFailSafeTransferFromSelfInsufficientBalance(address,uint256,uint256,uint256,bytes,bytes) (runs: 256, μ: 36227, ~: 38462) -ERC1155Test:testFailSafeTransferFromToNonERC155Recipient() (gas: 96517) -ERC1155Test:testFailSafeTransferFromToNonERC155Recipient(uint256,uint256,uint256,bytes,bytes) (runs: 256, μ: 96619, ~: 100533) -ERC1155Test:testFailSafeTransferFromToRevertingERC1155Recipient() (gas: 286316) -ERC1155Test:testFailSafeTransferFromToRevertingERC1155Recipient(uint256,uint256,uint256,bytes,bytes) (runs: 256, μ: 286367, ~: 290281) -ERC1155Test:testFailSafeTransferFromToWrongReturnDataERC1155Recipient() (gas: 239516) -ERC1155Test:testFailSafeTransferFromToWrongReturnDataERC1155Recipient(uint256,uint256,uint256,bytes,bytes) (runs: 256, μ: 239590, ~: 243504) -ERC1155Test:testFailSafeTransferFromToZero() (gas: 61942) -ERC1155Test:testFailSafeTransferFromToZero(uint256,uint256,uint256,bytes,bytes) (runs: 256, μ: 62029, ~: 65945) +ERC1155Test:testFailSafeBatchTransferInsufficientBalance() (gas: 163684) +ERC1155Test:testFailSafeBatchTransferInsufficientBalance(address,uint256[],uint256[],uint256[],bytes,bytes) (runs: 256, μ: 1501898, ~: 500326) +ERC1155Test:testFailSafeTransferFromInsufficientBalance() (gas: 63243) +ERC1155Test:testFailSafeTransferFromInsufficientBalance(address,uint256,uint256,uint256,bytes,bytes) (runs: 256, μ: 63960, ~: 67374) +ERC1155Test:testFailSafeTransferFromSelfInsufficientBalance() (gas: 34271) +ERC1155Test:testFailSafeTransferFromSelfInsufficientBalance(address,uint256,uint256,uint256,bytes,bytes) (runs: 256, μ: 36202, ~: 38436) +ERC1155Test:testFailSafeTransferFromToNonERC155Recipient() (gas: 96491) +ERC1155Test:testFailSafeTransferFromToNonERC155Recipient(uint256,uint256,uint256,bytes,bytes) (runs: 256, μ: 96593, ~: 100507) +ERC1155Test:testFailSafeTransferFromToRevertingERC1155Recipient() (gas: 286290) +ERC1155Test:testFailSafeTransferFromToRevertingERC1155Recipient(uint256,uint256,uint256,bytes,bytes) (runs: 256, μ: 286341, ~: 290255) +ERC1155Test:testFailSafeTransferFromToWrongReturnDataERC1155Recipient() (gas: 239490) +ERC1155Test:testFailSafeTransferFromToWrongReturnDataERC1155Recipient(uint256,uint256,uint256,bytes,bytes) (runs: 256, μ: 239564, ~: 243478) +ERC1155Test:testFailSafeTransferFromToZero() (gas: 61916) +ERC1155Test:testFailSafeTransferFromToZero(uint256,uint256,uint256,bytes,bytes) (runs: 256, μ: 62003, ~: 65919) ERC1155Test:testMintToEOA() (gas: 34719) ERC1155Test:testMintToEOA(address,uint256,uint256,bytes) (runs: 256, μ: 35359, ~: 35839) ERC1155Test:testMintToERC1155Recipient() (gas: 659903) ERC1155Test:testMintToERC1155Recipient(uint256,uint256,bytes) (runs: 256, μ: 689586, ~: 682903) -ERC1155Test:testSafeBatchTransferFromToEOA() (gas: 298000) -ERC1155Test:testSafeBatchTransferFromToEOA(address,uint256[],uint256[],uint256[],bytes,bytes) (runs: 256, μ: 4697311, ~: 3744489) -ERC1155Test:testSafeBatchTransferFromToERC1155Recipient() (gas: 1174050) -ERC1155Test:testSafeBatchTransferFromToERC1155Recipient(uint256[],uint256[],uint256[],bytes,bytes) (runs: 256, μ: 7688971, ~: 6517171) -ERC1155Test:testSafeTransferFromSelf() (gas: 64177) -ERC1155Test:testSafeTransferFromSelf(uint256,uint256,bytes,uint256,address,bytes) (runs: 256, μ: 64711, ~: 68552) -ERC1155Test:testSafeTransferFromToEOA() (gas: 93183) -ERC1155Test:testSafeTransferFromToEOA(uint256,uint256,bytes,uint256,address,bytes) (runs: 256, μ: 93494, ~: 97454) -ERC1155Test:testSafeTransferFromToERC1155Recipient() (gas: 738159) -ERC1155Test:testSafeTransferFromToERC1155Recipient(uint256,uint256,bytes,uint256,bytes) (runs: 256, μ: 768159, ~: 764321) +ERC1155Test:testSafeBatchTransferFromToEOA() (gas: 297982) +ERC1155Test:testSafeBatchTransferFromToEOA(address,uint256[],uint256[],uint256[],bytes,bytes) (runs: 256, μ: 4701420, ~: 3744055) +ERC1155Test:testSafeBatchTransferFromToERC1155Recipient() (gas: 1174032) +ERC1155Test:testSafeBatchTransferFromToERC1155Recipient(uint256[],uint256[],uint256[],bytes,bytes) (runs: 256, μ: 7695348, ~: 6560852) +ERC1155Test:testSafeTransferFromSelf() (gas: 64151) +ERC1155Test:testSafeTransferFromSelf(uint256,uint256,bytes,uint256,address,bytes) (runs: 256, μ: 64685, ~: 68526) +ERC1155Test:testSafeTransferFromToEOA() (gas: 93165) +ERC1155Test:testSafeTransferFromToEOA(uint256,uint256,bytes,uint256,address,bytes) (runs: 256, μ: 93476, ~: 97436) +ERC1155Test:testSafeTransferFromToERC1155Recipient() (gas: 738141) +ERC1155Test:testSafeTransferFromToERC1155Recipient(uint256,uint256,bytes,uint256,bytes) (runs: 256, μ: 767986, ~: 764303) +ERC1155BTest:testApproveAll() (gas: 30991) +ERC1155BTest:testBatchBalanceOf() (gas: 156936) +ERC1155BTest:testBatchBurn() (gas: 114495) +ERC1155BTest:testBatchMintToEOA() (gas: 135777) +ERC1155BTest:testBatchMintToERC1155Recipient() (gas: 993173) +ERC1155BTest:testBurn() (gas: 26484) +ERC1155BTest:testFailBalanceOfBatchWithArrayMismatch() (gas: 7814) +ERC1155BTest:testFailBatchBurnInsufficientBalance() (gas: 9999) +ERC1155BTest:testFailBatchMintToNonERC1155Recipient() (gas: 166047) +ERC1155BTest:testFailBatchMintToRevertingERC1155Recipient() (gas: 356186) +ERC1155BTest:testFailBatchMintToWrongReturnDataERC1155Recipient() (gas: 309446) +ERC1155BTest:testFailBatchMintToZero() (gas: 30897) +ERC1155BTest:testFailBurnInsufficientBalance() (gas: 7715) +ERC1155BTest:testFailMintToNonERC1155Recipient() (gas: 68174) +ERC1155BTest:testFailMintToRevertingERC1155Recipient() (gas: 257955) +ERC1155BTest:testFailMintToWrongReturnDataERC1155Recipient() (gas: 257954) +ERC1155BTest:testFailMintToZero() (gas: 13642) +ERC1155BTest:testFailSafeBatchTransferFromToNonERC1155Recipient() (gas: 720974) +ERC1155BTest:testFailSafeBatchTransferFromToRevertingERC1155Recipient() (gas: 911045) +ERC1155BTest:testFailSafeBatchTransferFromToWrongReturnDataERC1155Recipient() (gas: 864349) +ERC1155BTest:testFailSafeBatchTransferFromToZero() (gas: 686073) +ERC1155BTest:testFailSafeBatchTransferFromWithArrayLengthMismatch() (gas: 673475) +ERC1155BTest:testFailSafeBatchTransferInsufficientBalance() (gas: 550651) +ERC1155BTest:testFailSafeTransferFromInsufficientBalance() (gas: 548032) +ERC1155BTest:testFailSafeTransferFromSelfInsufficientBalance() (gas: 8311) +ERC1155BTest:testFailSafeTransferFromToNonERC1155Recipient() (gas: 74183) +ERC1155BTest:testFailSafeTransferFromToRevertingERC1155Recipient() (gas: 263961) +ERC1155BTest:testFailSafeTransferFromToWrongReturnDataERC1155Recipient() (gas: 217205) +ERC1155BTest:testFailSafeTransferFromToZero() (gas: 8292) +ERC1155BTest:testMintToEOA() (gas: 34590) +ERC1155BTest:testMintToERC1155Recipient() (gas: 659786) +ERC1155BTest:testSafeBatchTransferFromToEOA() (gas: 696833) +ERC1155BTest:testSafeBatchTransferFromToERC1155Recipient() (gas: 1572647) +ERC1155BTest:testSafeTransferFromSelf() (gas: 41752) +ERC1155BTest:testSafeTransferFromToEOA() (gas: 581441) +ERC1155BTest:testSafeTransferFromToERC1155Recipient() (gas: 1226190) ERC1155PermitTest:testFailPermitBadDeadline() (gas: 65971) ERC1155PermitTest:testFailPermitBadDeadline(uint248,uint256,address) (runs: 256, μ: 66918, ~: 66918) ERC1155PermitTest:testFailPermitBadNonce() (gas: 65933) From e38510e62bec3811cac0525d162ce1015c995e83 Mon Sep 17 00:00:00 2001 From: z0r0z <92001561+z0r0z@users.noreply.github.com> Date: Thu, 17 Nov 2022 08:11:35 +0900 Subject: [PATCH 7/7] =?UTF-8?q?=F0=9F=A5=A2=20=20fix=20link?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🥢 fix link --- test/utils/{user => users}/ERC1155BUser.sol | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/utils/{user => users}/ERC1155BUser.sol (100%) diff --git a/test/utils/user/ERC1155BUser.sol b/test/utils/users/ERC1155BUser.sol similarity index 100% rename from test/utils/user/ERC1155BUser.sol rename to test/utils/users/ERC1155BUser.sol