Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
33c4d65
Initial forge tests
drinkcoffee Jan 10, 2025
35ba4ac
Added initial test
drinkcoffee Jan 10, 2025
84bad32
Create initial performance tests
drinkcoffee Jan 13, 2025
5c9f3a9
Mint at 15K per block to max out the blocks
drinkcoffee Jan 13, 2025
80bce5d
Added more tests
drinkcoffee Jan 14, 2025
0f14037
Add more tests
drinkcoffee Jan 14, 2025
bf0837f
Revise import order
drinkcoffee Jan 15, 2025
f70f480
Initial compiling version of PsiV2
drinkcoffee Jan 16, 2025
011ccb4
Resolved issues with PsiV2
drinkcoffee Jan 17, 2025
47c0079
Fixed issue with determing existance of an NFT
drinkcoffee Jan 17, 2025
f72216a
Improve documentation. Prefill by 160K
drinkcoffee Jan 20, 2025
dedbc6b
Migrate ERC721 tests to forge
drinkcoffee Jan 29, 2025
5861530
Improve ERC 721 test coverage
drinkcoffee Jan 29, 2025
e48d49c
Added more tests
drinkcoffee Jan 31, 2025
a74fa1b
Add more tests and remove dead code
drinkcoffee Feb 3, 2025
f5c0f86
Added documentation for ERC721PsiV2
drinkcoffee Feb 4, 2025
3f56c1b
Added more tests
drinkcoffee Feb 5, 2025
540e221
Change solidity version
drinkcoffee Feb 6, 2025
c53427a
Merge branch 'main' into peter-solidity-version
drinkcoffee Feb 6, 2025
bea8ee7
Merge branch 'peter-solidity-version' into peter-erc721-perf
drinkcoffee Feb 6, 2025
ce033e3
Add more tests
drinkcoffee Feb 6, 2025
36c41e7
Added transferFrom tests
drinkcoffee Feb 6, 2025
59b6c1a
Added more tests
drinkcoffee Feb 7, 2025
6912c29
Rename files
drinkcoffee Feb 7, 2025
4045cac
Merge branch 'main' into peter-erc721-perf
drinkcoffee Feb 7, 2025
0f31fa1
Add documentation for ERC 721 contracts
drinkcoffee Feb 7, 2025
2be5039
Fix prettier issues
drinkcoffee Feb 9, 2025
c5f3ec5
Fix solidity version and remove dead code
drinkcoffee Feb 10, 2025
0cc0e1b
Add solhint support for PsiV2
drinkcoffee Feb 10, 2025
e7e359c
Fixed last Slither warning
drinkcoffee Feb 10, 2025
df57fa4
Remove temporary file
drinkcoffee Feb 10, 2025
a6f485c
Remove dead code
drinkcoffee Feb 10, 2025
78bf98b
Improve test coverage
drinkcoffee Feb 10, 2025
af2bca0
Resolve solhint issues
drinkcoffee Feb 10, 2025
0506c39
erc721v2-audit
rytimx Feb 18, 2025
9c17a6b
remove corpus
rytimx Feb 18, 2025
71b28fa
updated test cases
rytimx Feb 21, 2025
73ee829
Fix build issues
drinkcoffee Feb 24, 2025
c0ca6a4
Fix up sub-modules
drinkcoffee Feb 24, 2025
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
Next Next commit
Initial forge tests
  • Loading branch information
drinkcoffee committed Jan 10, 2025
commit 33c4d6501d49f8d1194dc0a9eeaf7cf3b1d45876
108 changes: 108 additions & 0 deletions contracts/token/erc721/interfaces/IImmutableERC721.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// Copyright Immutable Pty Ltd 2018 - 2023
// SPDX-License-Identifier: Apache 2.0
pragma solidity 0.8.19;

import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol";


interface IImmutableERC721 is IERC721, IERC721Metadata {
/// @dev Caller tried to mint an already burned token
error IImmutableERC721TokenAlreadyBurned(uint256 tokenId);

/// @dev Caller tried to mint an already burned token
error IImmutableERC721SendingToZerothAddress();

/// @dev Caller tried to mint an already burned token
error IImmutableERC721MismatchedTransferLengths();

/// @dev Caller tried to mint a tokenid that is above the hybrid threshold
error IImmutableERC721IDAboveThreshold(uint256 tokenId);

/// @dev Caller is not approved or owner
error IImmutableERC721NotOwnerOrOperator(uint256 tokenId);

/// @dev Current token owner is not what was expected
error IImmutableERC721MismatchedTokenOwner(uint256 tokenId, address currentOwner);

/// @dev Signer is zeroth address
error SignerCannotBeZerothAddress();

/// @dev Deadline exceeded for permit
error PermitExpired();

/// @dev Derived signature is invalid (EIP721 and EIP1271)
error InvalidSignature();


/**
* @notice A singular batch transfer request. The length of the tos and tokenIds must be matching
* batch transfers will transfer the specified ids to their matching address via index.
*
*/
struct TransferRequest {
address from;
address[] tos;
uint256[] tokenIds;
}

/// @notice A singular safe burn request.
struct IDBurn {
address owner;
uint256[] tokenIds;
}

/// @notice A singular Mint by quantity request
struct Mint {
address to;
uint256 quantity;
}

/// @notice A singular Mint by id request
struct IDMint {
address to;
uint256[] tokenIds;
}


/**
* @notice Allows minter to mint a token by ID to a specified address
* @param to the address to mint the token to
* @param tokenId the ID of the token to mint
*/
function mint(address to, uint256 tokenId) external;

/**
* @notice Allows minter to mint a token by ID to a specified address with hooks and checks
* @param to the address to mint the token to
* @param tokenId the ID of the token to mint
*/
function safeMint(address to, uint256 tokenId) external;

/**
* @notice Allows minter to safe mint a number of tokens by ID to a number of specified
* addresses with hooks and checks. Check ERC721Hybrid for details on _mintBatchByIDToMultiple
* @param mints the list of IDMint struct containing the to, and tokenIds
*/
function mintBatch(IDMint[] calldata mints) external;

/**
* @notice Allows minter to safe mint a number of tokens by ID to a number of specified
* addresses with hooks and checks. Check ERC721Hybrid for details on _safeMintBatchByIDToMultiple
* @param mints the list of IDMint struct containing the to, and tokenIds
*/
function safeMintBatch(IDMint[] calldata mints) external;

/**
* @notice Allows caller to a burn a number of tokens by ID from a specified address
* @param burns the IDBurn struct containing the to, and tokenIds
*/
function safeBurnBatch(IDBurn[] calldata burns) external;

/**
* @notice Allows caller to a transfer a number of tokens by ID from a specified
* address to a number of specified addresses
* @param tr the TransferRequest struct containing the from, tos, and tokenIds
*/
function safeTransferFromBatch(TransferRequest calldata tr) external;
}
41 changes: 41 additions & 0 deletions contracts/token/erc721/interfaces/IImmutableERC721ByQuantity.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright Immutable Pty Ltd 2018 - 2023
// SPDX-License-Identifier: Apache 2.0
pragma solidity 0.8.19;

import {IImmutableERC721} from "./IImmutableERC721.sol";

interface IImmutableERC721ByQuantity is IImmutableERC721 {
/**
* @notice Allows minter to mint a number of tokens sequentially to a specified address
* @param to the address to mint the token to
* @param quantity the number of tokens to mint
*/
function mintByQuantity(address to, uint256 quantity) external;

/**
* @notice Allows minter to mint a number of tokens sequentially to a specified address with hooks
* and checks
* @param to the address to mint the token to
* @param quantity the number of tokens to mint
*/
function safeMintByQuantity(address to, uint256 quantity) external;

/**
* @notice Allows minter to mint a number of tokens sequentially to a number of specified addresses
* @param mints the list of Mint struct containing the to, and the number of tokens to mint
*/
function mintBatchByQuantity(Mint[] calldata mints) external;

/**
* @notice Allows minter to safe mint a number of tokens sequentially to a number of specified addresses
* @param mints the list of Mint struct containing the to, and the number of tokens to mint
*/
function safeMintBatchByQuantity(Mint[] calldata mints) external;

/**
* @notice checks to see if tokenID exists in the collection
* @param tokenId the id of the token to check
*
*/
function exists(uint256 tokenId) external view returns (bool);
}
46 changes: 46 additions & 0 deletions test/token/erc721/ERC721Base.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright Immutable Pty Ltd 2018 - 2025
// SPDX-License-Identifier: Apache 2.0

pragma solidity ^0.8.19;

// solhint-disable-next-line no-global-import
import "forge-std/Test.sol";
import {IImmutableERC721} from "../../../contracts/token/erc721/interfaces/IImmutableERC721.sol";
import {OperatorAllowlistUpgradeable} from "../../../contracts/allowlist/OperatorAllowlistUpgradeable.sol";
import {DeployOperatorAllowlist} from "../../utils/DeployAllowlistProxy.sol";


/**
* Base contract for all ERC 721 tests.
*/
abstract contract ERC721BaseTest is Test {
IImmutableERC721 public erc721;

OperatorAllowlistUpgradeable public allowlist;

address public owner;
address public feeReceiver;
address public operatorAllowListAdmin;
address public operatorAllowListUpgrader;
address public operatorAllowListRegistrar;

string public name;
string public symbol;
string public baseURI;
string public contractURI;
address public royaltyReceiver;
uint96 public feeNumerator;

function setUp() public virtual {
owner = makeAddr("hubOwner");
feeReceiver = makeAddr("feeReceiver");
name = "ERC721Preset";
symbol = "EP";
baseURI = "https://baseURI.com/";
contractURI = "https://contractURI.com";

DeployOperatorAllowlist deployScript = new DeployOperatorAllowlist();
address proxyAddr = deployScript.run(operatorAllowListAdmin, operatorAllowListUpgrader, operatorAllowListRegistrar);
allowlist = OperatorAllowlistUpgradeable(proxyAddr);
}
}
19 changes: 19 additions & 0 deletions test/token/erc721/ERC721ByQuantityBase.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright Immutable Pty Ltd 2018 - 2025
// SPDX-License-Identifier: Apache 2.0

pragma solidity ^0.8.19;

import {ERC721BaseTest} from "./ERC721Base.t.sol";
import {IImmutableERC721ByQuantity} from "../../../contracts/token/erc721/interfaces/IImmutableERC721ByQuantity.sol";


/**
* Base contract for all ERC 721 by quantity tests.
*/
abstract contract ERC721ByQuantityBaseTest is ERC721BaseTest {
IImmutableERC721ByQuantity public erc721BQ;

function setUp() public virtual override {
super.setUp();
}
}
20 changes: 20 additions & 0 deletions test/token/erc721/ERC721ByQuantityPerf.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright Immutable Pty Ltd 2018 - 2025
// SPDX-License-Identifier: Apache 2.0

pragma solidity ^0.8.19;

import {ERC721ByQuantityBaseTest} from "./ERC721ByQuantityBase.t.sol";


/**
* Contract for all ERC 721 by quantity perfromance tests.
*/
abstract contract ERC721ByQuantityPerfTest is ERC721ByQuantityBaseTest {

function setUp() public virtual override {
super.setUp();
}



}
25 changes: 25 additions & 0 deletions test/token/erc721/ImmutableERC721ByQuantityPerf.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright Immutable Pty Ltd 2018 - 2025
// SPDX-License-Identifier: Apache 2.0

pragma solidity ^0.8.19;

import {ERC721ByQuantityPerfTest} from "./ERC721ByQuantityPerf.t.sol";
import {ImmutableERC721} from "../../../contracts/token/erc721/preset/ImmutableERC721.sol";
import {IImmutableERC721ByQuantity} from "../../../contracts/token/erc721/interfaces/IImmutableERC721ByQuantity.sol";

/**
* Contract for ERC 721 by quantity perfromance tests, for ImmutableERC721.sol (that is, v1).
*/
contract ImmutableERC721ByQuantityPerfTest is ERC721ByQuantityPerfTest {
function setUp() public override {
super.setUp();

ImmutableERC721 immutableERC721 = new ImmutableERC721(
owner, name, symbol, baseURI, contractURI, address(allowlist), feeReceiver, 300
);

// ImmutableERC721 does not implement the interface, and hence must be cast to the
// interface type.
erc721BQ = IImmutableERC721ByQuantity(address(immutableERC721));
}
}