diff --git a/contracts/access/MintingAccessControl.sol b/contracts/access/MintingAccessControl.sol index cb057679..d12695b4 100644 --- a/contracts/access/MintingAccessControl.sol +++ b/contracts/access/MintingAccessControl.sol @@ -9,21 +9,25 @@ abstract contract MintingAccessControl is AccessControlEnumerable { /// @notice Role to mint tokens bytes32 public constant MINTER_ROLE = bytes32("MINTER_ROLE"); - /** @notice Allows admin grant `user` `MINTER` role + /** + * @notice Allows admin grant `user` `MINTER` role * @param user The address to grant the `MINTER` role to */ function grantMinterRole(address user) public onlyRole(DEFAULT_ADMIN_ROLE) { grantRole(MINTER_ROLE, user); } - /** @notice Allows admin to revoke `MINTER_ROLE` role from `user` + /** + * @notice Allows admin to revoke `MINTER_ROLE` role from `user` * @param user The address to revoke the `MINTER` role from */ function revokeMinterRole(address user) public onlyRole(DEFAULT_ADMIN_ROLE) { revokeRole(MINTER_ROLE, user); } - /** @notice Returns the addresses which have DEFAULT_ADMIN_ROLE */ + /** + * @notice Returns the addresses which have DEFAULT_ADMIN_ROLE + */ function getAdmins() public view returns (address[] memory) { uint256 adminCount = getRoleMemberCount(DEFAULT_ADMIN_ROLE); address[] memory admins = new address[](adminCount); diff --git a/contracts/allowlist/IOperatorAllowlist.sol b/contracts/allowlist/IOperatorAllowlist.sol index bdaef0e3..20fab7d3 100644 --- a/contracts/allowlist/IOperatorAllowlist.sol +++ b/contracts/allowlist/IOperatorAllowlist.sol @@ -6,7 +6,8 @@ pragma solidity 0.8.19; * @notice Required interface of an OperatorAllowlist compliant contract */ interface IOperatorAllowlist { - /** @notice Returns true if an address is Allowlisted false otherwise + /** + * @notice Returns true if an address is Allowlisted false otherwise * @param target the address to be checked against the Allowlist */ function isAllowlisted(address target) external view returns (bool); diff --git a/contracts/bridge/x/v4/CoreV4.sol b/contracts/bridge/x/v4/CoreV4.sol index 8266264a..69f39ed6 100644 --- a/contracts/bridge/x/v4/CoreV4.sol +++ b/contracts/bridge/x/v4/CoreV4.sol @@ -86,31 +86,59 @@ interface CoreV4 { ); event LogDepositCancel(uint256 starkKey, uint256 vaultId, uint256 assetId); event LogDepositCancelReclaimed( - uint256 starkKey, uint256 vaultId, uint256 assetType, uint256 nonQuantizedAmount, uint256 quantizedAmount + uint256 starkKey, + uint256 vaultId, + uint256 assetType, + uint256 nonQuantizedAmount, + uint256 quantizedAmount ); event LogDepositNftCancelReclaimed( - uint256 starkKey, uint256 vaultId, uint256 assetType, uint256 tokenId, uint256 assetId + uint256 starkKey, + uint256 vaultId, + uint256 assetType, + uint256 tokenId, + uint256 assetId ); event LogMintWithdrawalPerformed( - uint256 ownerKey, uint256 assetType, uint256 nonQuantizedAmount, uint256 quantizedAmount, uint256 assetId + uint256 ownerKey, + uint256 assetType, + uint256 nonQuantizedAmount, + uint256 quantizedAmount, + uint256 assetId ); event LogMintableWithdrawalAllowed(uint256 ownerKey, uint256 assetId, uint256 quantizedAmount); event LogNftDeposit( - address depositorEthKey, uint256 starkKey, uint256 vaultId, uint256 assetType, uint256 tokenId, uint256 assetId + address depositorEthKey, + uint256 starkKey, + uint256 vaultId, + uint256 assetType, + uint256 tokenId, + uint256 assetId ); event LogNftWithdrawalAllowed(uint256 ownerKey, uint256 assetId); event LogNftWithdrawalPerformed( - uint256 ownerKey, uint256 assetType, uint256 tokenId, uint256 assetId, address recipient + uint256 ownerKey, + uint256 assetType, + uint256 tokenId, + uint256 assetId, + address recipient ); event LogTokenAdminAdded(address tokenAdmin); event LogTokenAdminRemoved(address tokenAdmin); event LogTokenRegistered(uint256 assetType, bytes assetInfo, uint256 quantum); event LogUserRegistered(address ethKey, uint256 starkKey, address sender); event LogWithdrawalAllowed( - uint256 ownerKey, uint256 assetType, uint256 nonQuantizedAmount, uint256 quantizedAmount + uint256 ownerKey, + uint256 assetType, + uint256 nonQuantizedAmount, + uint256 quantizedAmount ); event LogWithdrawalPerformed( - uint256 ownerKey, uint256 assetType, uint256 nonQuantizedAmount, uint256 quantizedAmount, address recipient + uint256 ownerKey, + uint256 assetType, + uint256 nonQuantizedAmount, + uint256 quantizedAmount, + address recipient ); function defaultVaultWithdrawalLock() external view returns (uint256); @@ -137,24 +165,27 @@ interface CoreV4 { function getAssetInfo(uint256 assetType) external view returns (bytes memory assetInfo); - function getCancellationRequest(uint256 starkKey, uint256 assetId, uint256 vaultId) - external - view - returns (uint256 request); + function getCancellationRequest( + uint256 starkKey, + uint256 assetId, + uint256 vaultId + ) external view returns (uint256 request); - function getDepositBalance(uint256 starkKey, uint256 assetId, uint256 vaultId) - external - view - returns (uint256 balance); + function getDepositBalance( + uint256 starkKey, + uint256 assetId, + uint256 vaultId + ) external view returns (uint256 balance); function getEthKey(uint256 ownerKey) external view returns (address); function getFullWithdrawalRequest(uint256 starkKey, uint256 vaultId) external view returns (uint256 res); - function getQuantizedDepositBalance(uint256 starkKey, uint256 assetId, uint256 vaultId) - external - view - returns (uint256 balance); + function getQuantizedDepositBalance( + uint256 starkKey, + uint256 assetId, + uint256 vaultId + ) external view returns (uint256 balance); function getQuantum(uint256 presumedAssetType) external view returns (uint256 quantum); @@ -241,21 +272,26 @@ interface CoreV4 { event LogDefaultVaultWithdrawalLockSet(uint256 newDefaultLockTime); event LogDepositToVault( - address ethKey, uint256 assetId, uint256 vaultId, uint256 nonQuantizedAmount, uint256 quantizedAmount + address ethKey, + uint256 assetId, + uint256 vaultId, + uint256 nonQuantizedAmount, + uint256 quantizedAmount ); event LogVaultWithdrawalLockSet(address ethKey, uint256 assetId, uint256 vaultId, uint256 timeRelease); event LogWithdrawalFromVault( - address ethKey, uint256 assetId, uint256 vaultId, uint256 nonQuantizedAmount, uint256 quantizedAmount + address ethKey, + uint256 assetId, + uint256 vaultId, + uint256 nonQuantizedAmount, + uint256 quantizedAmount ); function depositERC20ToVault(uint256 assetId, uint256 vaultId, uint256 quantizedAmount) external; function depositEthToVault(uint256 assetId, uint256 vaultId) external payable; - function getQuantizedVaultBalance(address ethKey, uint256 assetId, uint256 vaultId) - external - view - returns (uint256); + function getQuantizedVaultBalance(address ethKey, uint256 assetId, uint256 vaultId) external view returns (uint256); function getVaultBalance(address ethKey, uint256 assetId, uint256 vaultId) external view returns (uint256); diff --git a/contracts/bridge/x/v4/RegistrationV4.sol b/contracts/bridge/x/v4/RegistrationV4.sol index 90ac2656..050168ce 100644 --- a/contracts/bridge/x/v4/RegistrationV4.sol +++ b/contracts/bridge/x/v4/RegistrationV4.sol @@ -20,9 +20,12 @@ contract RegistrationV4 { imx = CoreV4(_imx); } - function registerAndWithdrawAll(address ethKey, uint256 starkKey, bytes calldata signature, uint256 assetType) - external - { + function registerAndWithdrawAll( + address ethKey, + uint256 starkKey, + bytes calldata signature, + uint256 assetType + ) external { if (!isRegistered(starkKey)) { imx.registerEthAddress(ethKey, starkKey, signature); } diff --git a/contracts/deployer/create/OwnableCreateDeploy.sol b/contracts/deployer/create/OwnableCreateDeploy.sol index cad19e0c..5f42ad71 100644 --- a/contracts/deployer/create/OwnableCreateDeploy.sol +++ b/contracts/deployer/create/OwnableCreateDeploy.sol @@ -22,11 +22,14 @@ contract OwnableCreateDeploy { * @param bytecode The bytecode of the contract to be deployed */ // slither-disable-next-line locked-ether + function deploy(bytes memory bytecode) external payable { // solhint-disable-next-line custom-errors require(msg.sender == owner, "CreateDeploy: caller is not the owner"); assembly { - if iszero(create(callvalue(), add(bytecode, 32), mload(bytecode))) { revert(0, 0) } + if iszero(create(callvalue(), add(bytecode, 32), mload(bytecode))) { + revert(0, 0) + } } } } diff --git a/contracts/mocks/MockOnReceive.sol b/contracts/mocks/MockOnReceive.sol index 9ba4bab5..b8c9064a 100644 --- a/contracts/mocks/MockOnReceive.sol +++ b/contracts/mocks/MockOnReceive.sol @@ -15,9 +15,9 @@ contract MockOnReceive { // Attempt to transfer token to another address on receive function onERC721Received( - address /* operator */, - address /* from */, - uint256 tokenId, + address, + /* operator */ address, + /* from */ uint256 tokenId, bytes calldata /* data */ ) public returns (bytes4) { tokenAddress.transferFrom(address(this), recipient, tokenId); diff --git a/contracts/random/offchainsources/chainlink/VRFConsumerBaseV2.sol b/contracts/random/offchainsources/chainlink/VRFConsumerBaseV2.sol index 40e02eff..4c2a3b3e 100644 --- a/contracts/random/offchainsources/chainlink/VRFConsumerBaseV2.sol +++ b/contracts/random/offchainsources/chainlink/VRFConsumerBaseV2.sol @@ -6,7 +6,8 @@ pragma solidity 0.8.19; // using the following command to dependency clashes. // npm install @chainlink/contracts -/** **************************************************************************** +/** + * * @notice Interface for contracts using VRF randomness * ***************************************************************************** * @dev PURPOSE @@ -102,6 +103,7 @@ pragma solidity 0.8.19; abstract contract VRFConsumerBaseV2 { error OnlyCoordinatorCanFulfill(address have, address want); // solhint-disable-next-line chainlink-solidity/prefix-immutable-variables-with-i + address private immutable vrfCoordinator; /** diff --git a/contracts/random/offchainsources/supra/ISupraRouter.sol b/contracts/random/offchainsources/supra/ISupraRouter.sol index c4d2c26a..bd2acdda 100644 --- a/contracts/random/offchainsources/supra/ISupraRouter.sol +++ b/contracts/random/offchainsources/supra/ISupraRouter.sol @@ -4,7 +4,6 @@ pragma solidity 0.8.19; /** * @notice API for interacting with Supra's Verifiable Random Function. */ - interface ISupraRouter { function generateRequest( string memory _functionSig, diff --git a/contracts/token/erc1155/preset/ImmutableERC1155.sol b/contracts/token/erc1155/preset/ImmutableERC1155.sol index 57bf0155..8bc3a993 100644 --- a/contracts/token/erc1155/preset/ImmutableERC1155.sol +++ b/contracts/token/erc1155/preset/ImmutableERC1155.sol @@ -8,7 +8,6 @@ import {ImmutableERC1155Base} from "../abstract/ImmutableERC1155Base.sol"; * @title ImmutableERC1155 * @author @jasonzwli, Immutable */ - contract ImmutableERC1155 is ImmutableERC1155Base { /// ===== Constructor ===== diff --git a/contracts/token/erc20/preset/ImmutableERC20FixedSupplyNoBurn.sol b/contracts/token/erc20/preset/ImmutableERC20FixedSupplyNoBurn.sol index 24581b00..8595c0a4 100644 --- a/contracts/token/erc20/preset/ImmutableERC20FixedSupplyNoBurn.sol +++ b/contracts/token/erc20/preset/ImmutableERC20FixedSupplyNoBurn.sol @@ -6,18 +6,16 @@ import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import {IImmutableERC20Errors} from "./Errors.sol"; - /** - * @notice ERC 20 contract that mints a fixed total supply of tokens when the contract + * @notice ERC 20 contract that mints a fixed total supply of tokens when the contract * is deployed. - * @dev This contract has the concept of an owner, called _hubOwner in the constructor. + * @dev This contract has the concept of an owner, called _hubOwner in the constructor. * This account has no rights to execute any administrative actions within the contract, - * with the exception of transferOwnership. This account is accessed via the owner() - * function. The Immutable Hub uses this function to help associate the ERC 20 contract + * with the exception of transferOwnership. This account is accessed via the owner() + * function. The Immutable Hub uses this function to help associate the ERC 20 contract * with a specific Immutable Hub account. */ contract ImmutableERC20FixedSupplyNoBurn is Ownable, ERC20 { - /** * @dev Mints `_totalSupply` number of token and transfers them to `_owner`. * @@ -25,14 +23,20 @@ contract ImmutableERC20FixedSupplyNoBurn is Ownable, ERC20 { * @param _symbol Token symbol. * @param _totalSupply Supply of the token. * @param _treasurer Initial owner of entire supply of all tokens. - * @param _hubOwner The account associated with Immutable Hub. + * @param _hubOwner The account associated with Immutable Hub. */ - constructor(string memory _name, string memory _symbol, uint256 _totalSupply, address _treasurer, address _hubOwner) ERC20(_name, _symbol) { + constructor( + string memory _name, + string memory _symbol, + uint256 _totalSupply, + address _treasurer, + address _hubOwner + ) ERC20(_name, _symbol) { _mint(_treasurer, _totalSupply); _transferOwnership(_hubOwner); } - /** + /** * @notice Prevent calls to renounce ownership. */ function renounceOwnership() public pure override { diff --git a/contracts/token/erc20/preset/ImmutableERC20MinterBurnerPermit.sol b/contracts/token/erc20/preset/ImmutableERC20MinterBurnerPermit.sol index 04b66483..e9ed7948 100644 --- a/contracts/token/erc20/preset/ImmutableERC20MinterBurnerPermit.sol +++ b/contracts/token/erc20/preset/ImmutableERC20MinterBurnerPermit.sol @@ -12,8 +12,8 @@ import {IImmutableERC20Errors} from "./Errors.sol"; * @notice ERC 20 contract that wraps Open Zeppelin's ERC 20 contract. * This contract has the concept of a hubOwner, called _hubOwner in the constructor. * This account has no rights to execute any administrative actions within the contract, - * with the exception of renouncing their ownership. - * The Immutable Hub uses this function to help associate the ERC 20 contract + * with the exception of renouncing their ownership. + * The Immutable Hub uses this function to help associate the ERC 20 contract * with a specific Immutable Hub account. */ contract ImmutableERC20MinterBurnerPermit is ERC20Capped, ERC20Burnable, ERC20Permit, MintingAccessControl { @@ -24,19 +24,24 @@ contract ImmutableERC20MinterBurnerPermit is ERC20Capped, ERC20Burnable, ERC20Pe * @dev Delegate to Open Zeppelin's contract. * @param _roleAdmin The account that has the DEFAULT_ADMIN_ROLE. * @param _minterAdmin The account that has the MINTER_ROLE. - * @param _hubOwner The account that owns the contract and is associated with Immutable Hub. + * @param _hubOwner The account that owns the contract and is associated with Immutable Hub. * @param _name Name of the token. * @param _symbol Token symbol. * @param _maxTokenSupply The maximum supply of the token. - */ - constructor(address _roleAdmin, address _minterAdmin, address _hubOwner, string memory _name, string memory _symbol, uint256 _maxTokenSupply) ERC20(_name, _symbol) ERC20Permit(_name) ERC20Capped(_maxTokenSupply) { + constructor( + address _roleAdmin, + address _minterAdmin, + address _hubOwner, + string memory _name, + string memory _symbol, + uint256 _maxTokenSupply + ) ERC20(_name, _symbol) ERC20Permit(_name) ERC20Capped(_maxTokenSupply) { _grantRole(DEFAULT_ADMIN_ROLE, _roleAdmin); _grantRole(HUB_OWNER_ROLE, _hubOwner); _grantRole(MINTER_ROLE, _minterAdmin); } - /** * @dev Mints `amount` number of token and transfers them to the `to` address. * @param to the address to mint the tokens to. @@ -46,9 +51,8 @@ contract ImmutableERC20MinterBurnerPermit is ERC20Capped, ERC20Burnable, ERC20Pe _mint(to, amount); } - /** - * @dev Renounces the role `role` from the calling account. Prevents the last hub owner and admin from + * @dev Renounces the role `role` from the calling account. Prevents the last hub owner and admin from * renouncing their role. * @param role The role to renounce. * @param account The account to renounce the role from. @@ -60,12 +64,10 @@ contract ImmutableERC20MinterBurnerPermit is ERC20Capped, ERC20Burnable, ERC20Pe super.renounceRole(role, account); } - /** * @dev Delegate to Open Zeppelin's ERC20Capped contract. */ function _mint(address account, uint256 amount) internal override(ERC20, ERC20Capped) { ERC20Capped._mint(account, amount); } - } diff --git a/contracts/token/erc721/abstract/ERC721Hybrid.sol b/contracts/token/erc721/abstract/ERC721Hybrid.sol index 5580030a..041bd4e8 100644 --- a/contracts/token/erc721/abstract/ERC721Hybrid.sol +++ b/contracts/token/erc721/abstract/ERC721Hybrid.sol @@ -25,9 +25,11 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err /// @notice A mapping of tokens ids before the threshold that have been burned to prevent re-minting BitMaps.BitMap private _burnedTokens; - /** @notice A singular batch transfer request. The length of the tos and tokenIds must be matching + /** + * @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; @@ -54,7 +56,8 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err constructor(string memory name_, string memory symbol_) ERC721(name_, symbol_) ERC721Psi(name_, symbol_) {} - /** @notice allows caller to burn multiple tokens by id + /** + * @notice allows caller to burn multiple tokens by id * @param tokenIDs an array of token ids */ function burnBatch(uint256[] calldata tokenIDs) external { @@ -63,7 +66,8 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err } } - /** @notice burns the specified token id + /** + * @notice burns the specified token id * @param tokenId the id of the token to burn */ function burn(uint256 tokenId) public virtual { @@ -73,7 +77,8 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err _burn(tokenId); } - /** @notice Burn a token, checking the owner of the token against the parameter first. + /** + * @notice Burn a token, checking the owner of the token against the parameter first. * @param owner the owner of the token * @param tokenId the id of the token to burn */ @@ -86,21 +91,25 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err burn(tokenId); } - /** @notice returns the threshold that divides tokens that are minted by id and + /** + * @notice returns the threshold that divides tokens that are minted by id and * minted by quantity */ function mintBatchByQuantityThreshold() public pure virtual returns (uint256) { return 2 ** 128; } - /** @notice checks to see if tokenID exists in the collection + /** + * @notice checks to see if tokenID exists in the collection * @param tokenId the id of the token to check - **/ + * + */ function exists(uint256 tokenId) public view virtual returns (bool) { return _exists(tokenId); } - /** @notice Overwritten functions with combined implementations, supply for the collection is summed as they + /** + * @notice Overwritten functions with combined implementations, supply for the collection is summed as they * are tracked differently by each minting strategy */ function balanceOf(address owner) public view virtual override(ERC721, ERC721Psi) returns (uint256) { @@ -114,7 +123,9 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err return ERC721PsiBurnable.totalSupply() + _idMintTotalSupply; } - /** @notice refer to erc721 or erc721psi */ + /** + * @notice refer to erc721 or erc721psi + */ function ownerOf(uint256 tokenId) public view virtual override(ERC721, ERC721Psi) returns (address) { if (tokenId < mintBatchByQuantityThreshold()) { return ERC721.ownerOf(tokenId); @@ -122,7 +133,8 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err return ERC721Psi.ownerOf(tokenId); } - /** @notice Overwritten functions with direct routing. The metadata of the collect remains the same regardless + /** + * @notice Overwritten functions with direct routing. The metadata of the collect remains the same regardless * of the minting strategy used for the tokenID */ @@ -168,7 +180,9 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err safeTransferFrom(from, to, tokenId, ""); } - /** @notice refer to erc721 or erc721psi */ + /** + * @notice refer to erc721 or erc721psi + */ function safeTransferFrom( address from, address to, @@ -181,7 +195,9 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err return ERC721Psi.safeTransferFrom(from, to, tokenId, _data); } - /** @notice refer to erc721 or erc721psi */ + /** + * @notice refer to erc721 or erc721psi + */ function isApprovedForAll( address owner, address operator @@ -189,7 +205,9 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err return ERC721.isApprovedForAll(owner, operator); } - /** @notice refer to erc721 or erc721psi */ + /** + * @notice refer to erc721 or erc721psi + */ function getApproved(uint256 tokenId) public view virtual override(ERC721, ERC721Psi) returns (address) { if (tokenId < mintBatchByQuantityThreshold()) { return ERC721.getApproved(tokenId); @@ -197,7 +215,9 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err return ERC721Psi.getApproved(tokenId); } - /** @notice refer to erc721 or erc721psi */ + /** + * @notice refer to erc721 or erc721psi + */ function approve(address to, uint256 tokenId) public virtual override(ERC721, ERC721Psi) { if (tokenId < mintBatchByQuantityThreshold()) { return ERC721.approve(to, tokenId); @@ -205,7 +225,9 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err return ERC721Psi.approve(to, tokenId); } - /** @notice refer to erc721 or erc721psi */ + /** + * @notice refer to erc721 or erc721psi + */ function transferFrom(address from, address to, uint256 tokenId) public virtual override(ERC721, ERC721Psi) { if (tokenId < mintBatchByQuantityThreshold()) { return ERC721.transferFrom(from, to, tokenId); @@ -213,7 +235,8 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err return ERC721Psi.transferFrom(from, to, tokenId); } - /** @notice mints number of tokens specified to the address given via erc721psi + /** + * @notice mints number of tokens specified to the address given via erc721psi * @param to the address to mint to * @param quantity the number of tokens to mint */ @@ -221,7 +244,8 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err ERC721Psi._mint(to, quantity); } - /** @notice safe mints number of tokens specified to the address given via erc721psi + /** + * @notice safe mints number of tokens specified to the address given via erc721psi * @param to the address to mint to * @param quantity the number of tokens to mint */ @@ -229,7 +253,8 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err ERC721Psi._safeMint(to, quantity); } - /** @notice mints number of tokens specified to a multiple specified addresses via erc721psi + /** + * @notice mints number of tokens specified to a multiple specified addresses via erc721psi * @param mints an array of mint requests */ function _mintBatchByQuantity(Mint[] calldata mints) internal { @@ -239,7 +264,8 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err } } - /** @notice safe mints number of tokens specified to a multiple specified addresses via erc721psi + /** + * @notice safe mints number of tokens specified to a multiple specified addresses via erc721psi * @param mints an array of mint requests */ function _safeMintBatchByQuantity(Mint[] calldata mints) internal { @@ -249,7 +275,8 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err } } - /** @notice safe mints number of tokens specified to a multiple specified addresses via erc721 + /** + * @notice safe mints number of tokens specified to a multiple specified addresses via erc721 * @param to the address to mint to * @param tokenId the id of the token to mint */ @@ -266,7 +293,8 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err ERC721._mint(to, tokenId); } - /** @notice safe mints number of tokens specified to a multiple specified addresses via erc721 + /** + * @notice safe mints number of tokens specified to a multiple specified addresses via erc721 * @param to the address to mint to * @param tokenId the id of the token to mint */ @@ -283,7 +311,8 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err ERC721._safeMint(to, tokenId); } - /** @notice mints multiple tokens by id to a specified address via erc721 + /** + * @notice mints multiple tokens by id to a specified address via erc721 * @param to the address to mint to * @param tokenIds the ids of the tokens to mint */ @@ -293,17 +322,20 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err } } - /** @notice safe mints multiple tokens by id to a specified address via erc721 + /** + * @notice safe mints multiple tokens by id to a specified address via erc721 * @param to the address to mint to * @param tokenIds the ids of the tokens to mint - **/ + * + */ function _safeMintBatchByID(address to, uint256[] calldata tokenIds) internal { for (uint256 i = 0; i < tokenIds.length; i++) { _safeMintByID(to, tokenIds[i]); } } - /** @notice mints multiple tokens by id to multiple specified addresses via erc721 + /** + * @notice mints multiple tokens by id to multiple specified addresses via erc721 * @param mints an array of mint requests */ function _mintBatchByIDToMultiple(IDMint[] calldata mints) internal { @@ -313,7 +345,8 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err } } - /** @notice safe mints multiple tokens by id to multiple specified addresses via erc721 + /** + * @notice safe mints multiple tokens by id to multiple specified addresses via erc721 * @param mints an array of mint requests */ function _safeMintBatchByIDToMultiple(IDMint[] calldata mints) internal { @@ -323,7 +356,8 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err } } - /** @notice batch burn a tokens by id, checking the owner of the token against the parameter first. + /** + * @notice batch burn a tokens by id, checking the owner of the token against the parameter first. * @param burns array of burn requests */ function _safeBurnBatch(IDBurn[] calldata burns) internal { @@ -335,7 +369,9 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err } } - /** @notice refer to erc721 or erc721psi */ + /** + * @notice refer to erc721 or erc721psi + */ function _transfer(address from, address to, uint256 tokenId) internal virtual override(ERC721, ERC721Psi) { if (tokenId < mintBatchByQuantityThreshold()) { ERC721._transfer(from, to, tokenId); @@ -344,7 +380,8 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err } } - /** @notice burn a token by id, if the token is below the threshold it is burned via erc721 + /** + * @notice burn a token by id, if the token is below the threshold it is burned via erc721 * additional tracking is added for erc721 to prevent re-minting. Refer to erc721 or erc721psi * @param tokenId the id of the token to burn */ @@ -359,7 +396,9 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err } } - /** @notice refer to erc721 or erc721psi */ + /** + * @notice refer to erc721 or erc721psi + */ function _approve(address to, uint256 tokenId) internal virtual override(ERC721, ERC721Psi) { if (tokenId < mintBatchByQuantityThreshold()) { return ERC721._approve(to, tokenId); @@ -367,7 +406,9 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err return ERC721Psi._approve(to, tokenId); } - /** @notice refer to erc721 or erc721psi */ + /** + * @notice refer to erc721 or erc721psi + */ function _safeTransfer( address from, address to, @@ -380,12 +421,14 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err return ERC721Psi._safeTransfer(from, to, tokenId, _data); } - /** @notice methods below are overwritten to always invoke the erc721 equivalent due to linearisation + /** + * @notice methods below are overwritten to always invoke the erc721 equivalent due to linearisation * they do not get invoked explicitly by any external minting methods in this contract and are only overwritten to satisfy * the compiler */ - /** @notice overriding erc721 and erc721psi _safemint, super calls the `_safeMint` method of + /** + * @notice overriding erc721 and erc721psi _safemint, super calls the `_safeMint` method of * the erc721 implementation due to inheritance linearisation. Refer to erc721 */ // slither-disable-next-line dead-code @@ -393,21 +436,25 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err super._safeMint(to, tokenId); } - /** @notice overriding erc721 and erc721psi _safemint, super calls the `_safeMint` method of + /** + * @notice overriding erc721 and erc721psi _safemint, super calls the `_safeMint` method of * the erc721 implementation due to inheritance linearisation. Refer to erc721 */ function _safeMint(address to, uint256 tokenId, bytes memory _data) internal virtual override(ERC721, ERC721Psi) { super._safeMint(to, tokenId, _data); } - /** @notice overriding erc721 and erc721psi _safemint, super calls the `_mint` method of + /** + * @notice overriding erc721 and erc721psi _safemint, super calls the `_mint` method of * the erc721 implementation due to inheritance linearisation. Refer to erc721 */ function _mint(address to, uint256 tokenId) internal virtual override(ERC721, ERC721Psi) { super._mint(to, tokenId); } - /** @notice refer to erc721 or erc721psi */ + /** + * @notice refer to erc721 or erc721psi + */ function _isApprovedOrOwner( address spender, uint256 tokenId @@ -418,7 +465,9 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err return ERC721Psi._isApprovedOrOwner(spender, tokenId); } - /** @notice refer to erc721 or erc721psi */ + /** + * @notice refer to erc721 or erc721psi + */ function _exists(uint256 tokenId) internal view virtual override(ERC721, ERC721PsiBurnable) returns (bool) { if (tokenId < mintBatchByQuantityThreshold()) { return ERC721._ownerOf(tokenId) != address(0) && (!_burnedTokens.get(tokenId)); diff --git a/contracts/token/erc721/abstract/ERC721HybridPermit.sol b/contracts/token/erc721/abstract/ERC721HybridPermit.sol index cd6946fa..bfa52b43 100644 --- a/contracts/token/erc721/abstract/ERC721HybridPermit.sol +++ b/contracts/token/erc721/abstract/ERC721HybridPermit.sol @@ -14,14 +14,16 @@ import {ERC721Hybrid} from "./ERC721Hybrid.sol"; * @title ERC721HybridPermit: An extension of the ERC721Hybrid NFT standard that supports off-chain approval via permits. * @dev This contract implements ERC-4494 as well, allowing tokens to be approved via off-chain signed messages. */ - abstract contract ERC721HybridPermit is ERC721Hybrid, IERC4494, EIP712 { - /** @notice mapping used to keep track of nonces of each token ID for validating + /** + * @notice mapping used to keep track of nonces of each token ID for validating * signatures */ mapping(uint256 tokenId => uint256 nonce) private _nonces; - /** @dev the unique identifier for the permit struct to be EIP 712 compliant */ + /** + * @dev the unique identifier for the permit struct to be EIP 712 compliant + */ bytes32 private constant _PERMIT_TYPEHASH = keccak256( abi.encodePacked( diff --git a/contracts/token/erc721/abstract/ERC721Permit.sol b/contracts/token/erc721/abstract/ERC721Permit.sol index 321f4c7b..a70e42d9 100644 --- a/contracts/token/erc721/abstract/ERC721Permit.sol +++ b/contracts/token/erc721/abstract/ERC721Permit.sol @@ -15,14 +15,16 @@ import {IImmutableERC721Errors} from "../../../errors/Errors.sol"; * @title ERC721Permit: An extension of the ERC721Burnable NFT standard that supports off-chain approval via permits. * @dev This contract implements ERC-4494 as well, allowing tokens to be approved via off-chain signed messages. */ - abstract contract ERC721Permit is ERC721Burnable, IERC4494, EIP712, IImmutableERC721Errors { - /** @notice mapping used to keep track of nonces of each token ID for validating + /** + * @notice mapping used to keep track of nonces of each token ID for validating * signatures */ mapping(uint256 tokenId => uint256 nonce) private _nonces; - /** @dev the unique identifier for the permit struct to be EIP 712 compliant */ + /** + * @dev the unique identifier for the permit struct to be EIP 712 compliant + */ bytes32 private constant _PERMIT_TYPEHASH = keccak256( abi.encodePacked( diff --git a/contracts/token/erc721/abstract/ImmutableERC721Base.sol b/contracts/token/erc721/abstract/ImmutableERC721Base.sol index da41a13f..38d4e07c 100644 --- a/contracts/token/erc721/abstract/ImmutableERC721Base.sol +++ b/contracts/token/erc721/abstract/ImmutableERC721Base.sol @@ -86,7 +86,8 @@ abstract contract ImmutableERC721Base is OperatorAllowlistEnforced, MintingAcces contractURI = contractURI_; } - /** @notice Set the default royalty receiver address + /** + * @notice Set the default royalty receiver address * @param receiver the address to receive the royalty * @param feeNumerator the royalty fee numerator * @dev This can only be called by the an admin. See ERC2981 for more details on _setDefaultRoyalty @@ -95,7 +96,8 @@ abstract contract ImmutableERC721Base is OperatorAllowlistEnforced, MintingAcces _setDefaultRoyalty(receiver, feeNumerator); } - /** @notice Set the royalty receiver address for a specific tokenId + /** + * @notice Set the royalty receiver address for a specific tokenId * @param tokenId the token to set the royalty for * @param receiver the address to receive the royalty * @param feeNumerator the royalty fee numerator @@ -109,7 +111,8 @@ abstract contract ImmutableERC721Base is OperatorAllowlistEnforced, MintingAcces _setTokenRoyalty(tokenId, receiver, feeNumerator); } - /** @notice Set the royalty receiver address for a list of tokenId + /** + * @notice Set the royalty receiver address for a list of tokenId * @param tokenIds the list of tokens to set the royalty for * @param receiver the address to receive the royalty * @param feeNumerator the royalty fee numerator @@ -125,7 +128,8 @@ abstract contract ImmutableERC721Base is OperatorAllowlistEnforced, MintingAcces } } - /** @notice allows owner or operator to burn a single token + /** + * @notice allows owner or operator to burn a single token * @param tokenId the token to burn * @dev see ERC721Burnable for more details */ @@ -136,7 +140,8 @@ abstract contract ImmutableERC721Base is OperatorAllowlistEnforced, MintingAcces _totalSupply--; } - /** @notice Burn a token, checking the owner of the token against the parameter first. + /** + * @notice Burn a token, checking the owner of the token against the parameter first. * @param owner the owner of the token * @param tokenId the token to burn */ @@ -149,7 +154,8 @@ abstract contract ImmutableERC721Base is OperatorAllowlistEnforced, MintingAcces burn(tokenId); } - /** @notice Burn a batch of tokens, checking the owner of the token against the parameter first. + /** + * @notice Burn a batch of tokens, checking the owner of the token against the parameter first. * @param burns list of burn requests including token id and owner address */ function _safeBurnBatch(IDBurn[] calldata burns) public virtual { @@ -185,7 +191,8 @@ abstract contract ImmutableERC721Base is OperatorAllowlistEnforced, MintingAcces super.setApprovalForAll(operator, approved); } - /** @notice Returns the supported interfaces + /** + * @notice Returns the supported interfaces * @param interfaceId the interface to check for support */ function supportsInterface( @@ -200,7 +207,9 @@ abstract contract ImmutableERC721Base is OperatorAllowlistEnforced, MintingAcces return super.supportsInterface(interfaceId); } - /** @notice returns the number of minted - burned tokens */ + /** + * @notice returns the number of minted - burned tokens + */ function totalSupply() public view virtual returns (uint256) { return _totalSupply; } @@ -227,7 +236,8 @@ abstract contract ImmutableERC721Base is OperatorAllowlistEnforced, MintingAcces /// ===== Internal functions ===== - /** @notice mints a batch of tokens with specified ids to a specified address + /** + * @notice mints a batch of tokens with specified ids to a specified address * @param mintRequest list of mint requests including token id and owner address * @dev see ERC721 for more details on _mint */ @@ -243,7 +253,8 @@ abstract contract ImmutableERC721Base is OperatorAllowlistEnforced, MintingAcces } } - /** @notice safe mints a batch of tokens with specified ids to a specified address + /** + * @notice safe mints a batch of tokens with specified ids to a specified address * @param mintRequest list of burn requests including token id and owner address * @dev see ERC721 for more details on _safeMint */ @@ -258,7 +269,8 @@ abstract contract ImmutableERC721Base is OperatorAllowlistEnforced, MintingAcces _totalSupply = _totalSupply + mintRequest.tokenIds.length; } - /** @notice mints specified token id to specified address + /** + * @notice mints specified token id to specified address * @param to the address to mint to * @param tokenId the token to mint * @dev see ERC721 for more details on _mint @@ -270,7 +282,8 @@ abstract contract ImmutableERC721Base is OperatorAllowlistEnforced, MintingAcces super._mint(to, tokenId); } - /** @notice safe mints specified token id to specified address + /** + * @notice safe mints specified token id to specified address * @param to the address to mint to * @param tokenId the token to mint * @dev see ERC721 for more details on _safeMint diff --git a/contracts/token/erc721/abstract/ImmutableERC721HybridBase.sol b/contracts/token/erc721/abstract/ImmutableERC721HybridBase.sol index 5ed8ced3..49e82136 100644 --- a/contracts/token/erc721/abstract/ImmutableERC721HybridBase.sol +++ b/contracts/token/erc721/abstract/ImmutableERC721HybridBase.sol @@ -68,7 +68,8 @@ abstract contract ImmutableERC721HybridBase is return baseURI; } - /** @notice Allows admin to set the base URI + /** + * @notice Allows admin to set the base URI * @param baseURI_ The base URI to set */ function setBaseURI(string memory baseURI_) public onlyRole(DEFAULT_ADMIN_ROLE) { @@ -114,7 +115,8 @@ abstract contract ImmutableERC721HybridBase is super._transfer(from, to, tokenId); } - /** @notice Set the default royalty receiver address + /** + * @notice Set the default royalty receiver address * @param receiver the address to receive the royalty * @param feeNumerator the royalty fee numerator * @dev This can only be called by the an admin. See ERC2981 for more details on _setDefaultRoyalty @@ -123,7 +125,8 @@ abstract contract ImmutableERC721HybridBase is _setDefaultRoyalty(receiver, feeNumerator); } - /** @notice Set the royalty receiver address for a specific tokenId + /** + * @notice Set the royalty receiver address for a specific tokenId * @param tokenId the token to set the royalty for * @param receiver the address to receive the royalty * @param feeNumerator the royalty fee numerator @@ -137,7 +140,8 @@ abstract contract ImmutableERC721HybridBase is _setTokenRoyalty(tokenId, receiver, feeNumerator); } - /** @notice Set the royalty receiver address for a list of tokenId + /** + * @notice Set the royalty receiver address for a list of tokenId * @param tokenIds the list of tokens to set the royalty for * @param receiver the address to receive the royalty * @param feeNumerator the royalty fee numerator diff --git a/contracts/token/erc721/erc721psi/ERC721Psi.sol b/contracts/token/erc721/erc721psi/ERC721Psi.sol index 6475fdfc..098ff2c0 100644 --- a/contracts/token/erc721/erc721psi/ERC721Psi.sol +++ b/contracts/token/erc721/erc721psi/ERC721Psi.sol @@ -1,15 +1,14 @@ // SPDX-License-Identifier: MIT /** - ______ _____ _____ ______ ___ __ _ _ _ - | ____| __ \ / ____|____ |__ \/_ | || || | - | |__ | |__) | | / / ) || | \| |/ | - | __| | _ /| | / / / / | |\_ _/ - | |____| | \ \| |____ / / / /_ | | | | - |______|_| \_\\_____|/_/ |____||_| |_| - - - github: https://github.com/estarriolvetch/ERC721Psi - - npm: https://www.npmjs.com/package/erc721psi - + * ______ _____ _____ ______ ___ __ _ _ _ + * | ____| __ \ / ____|____ |__ \/_ | || || | + * | |__ | |__) | | / / ) || | \| |/ | + * | __| | _ /| | / / / / | |\_ _/ + * | |____| | \ \| |____ / / / /_ | | | | + * |______|_| \_\\_____|/_/ |____||_| |_| + * + * - github: https://github.com/estarriolvetch/ERC721Psi + * - npm: https://www.npmjs.com/package/erc721psi */ // solhint-disable pragma solidity 0.8.19; @@ -93,11 +92,11 @@ contract ERC721Psi is Context, ERC165, IERC721, IERC721Metadata { /** * @dev See {IERC721-balanceOf}. */ - function balanceOf(address owner) public view virtual override returns (uint) { + function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721Psi: balance query for the zero address"); - uint count = 0; - for (uint i = _startTokenId(); i < _nextTokenId(); ++i) { + uint256 count = 0; + for (uint256 i = _startTokenId(); i < _nextTokenId(); ++i) { if (_exists(i)) { if (owner == ownerOf(i)) { ++count; diff --git a/contracts/token/erc721/erc721psi/ERC721PsiBurnable.sol b/contracts/token/erc721/erc721psi/ERC721PsiBurnable.sol index bd96169d..c1c0800e 100644 --- a/contracts/token/erc721/erc721psi/ERC721PsiBurnable.sol +++ b/contracts/token/erc721/erc721psi/ERC721PsiBurnable.sol @@ -1,13 +1,11 @@ // SPDX-License-Identifier: MIT /** - ______ _____ _____ ______ ___ __ _ _ _ - | ____| __ \ / ____|____ |__ \/_ | || || | - | |__ | |__) | | / / ) || | \| |/ | - | __| | _ /| | / / / / | |\_ _/ - | |____| | \ \| |____ / / / /_ | | | | - |______|_| \_\\_____|/_/ |____||_| |_| - - + * ______ _____ _____ ______ ___ __ _ _ _ + * | ____| __ \ / ____|____ |__ \/_ | || || | + * | |__ | |__) | | / / ) || | \| |/ | + * | __| | _ /| | / / / / | |\_ _/ + * | |____| | \ \| |____ / / / /_ | | | | + * |______|_| \_\\_____|/_/ |____||_| |_| */ pragma solidity 0.8.19; @@ -16,6 +14,7 @@ import {ERC721Psi} from "./ERC721Psi.sol"; abstract contract ERC721PsiBurnable is ERC721Psi { using BitMaps for BitMaps.BitMap; + BitMaps.BitMap private _burnedToken; /** @@ -78,7 +77,9 @@ abstract contract ERC721PsiBurnable is ERC721Psi { */ function _popcount(uint256 x) private pure returns (uint256 count) { unchecked { - for (count = 0; x != 0; count++) x &= x - 1; + for (count = 0; x != 0; count++) { + x &= x - 1; + } } } } diff --git a/contracts/token/erc721/preset/ImmutableERC721.sol b/contracts/token/erc721/preset/ImmutableERC721.sol index c2caf870..d37378e6 100644 --- a/contracts/token/erc721/preset/ImmutableERC721.sol +++ b/contracts/token/erc721/preset/ImmutableERC721.sol @@ -41,7 +41,8 @@ contract ImmutableERC721 is ImmutableERC721HybridBase { ) {} - /** @notice Allows minter to mint a token by ID to a specified address + /** + * @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 */ @@ -49,7 +50,8 @@ contract ImmutableERC721 is ImmutableERC721HybridBase { _mintByID(to, tokenId); } - /** @notice Allows minter to mint a token by ID to a specified address with hooks and checks + /** + * @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 */ @@ -57,7 +59,8 @@ contract ImmutableERC721 is ImmutableERC721HybridBase { _safeMintByID(to, tokenId); } - /** @notice Allows minter to mint a number of tokens sequentially to a specified address + /** + * @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 */ @@ -65,7 +68,8 @@ contract ImmutableERC721 is ImmutableERC721HybridBase { _mintByQuantity(to, quantity); } - /** @notice Allows minter to mint a number of tokens sequentially to a specified address with hooks + /** + * @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 @@ -74,21 +78,24 @@ contract ImmutableERC721 is ImmutableERC721HybridBase { _safeMintByQuantity(to, quantity); } - /** @notice Allows minter to mint a number of tokens sequentially to a number of specified addresses + /** + * @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 onlyRole(MINTER_ROLE) { _mintBatchByQuantity(mints); } - /** @notice Allows minter to safe mint a number of tokens sequentially to a number of specified addresses + /** + * @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 onlyRole(MINTER_ROLE) { _safeMintBatchByQuantity(mints); } - /** @notice Allows minter to safe mint a number of tokens by ID to a number of specified + /** + * @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 */ @@ -96,7 +103,8 @@ contract ImmutableERC721 is ImmutableERC721HybridBase { _mintBatchByIDToMultiple(mints); } - /** @notice Allows minter to safe mint a number of tokens by ID to a number of specified + /** + * @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 */ @@ -104,14 +112,16 @@ contract ImmutableERC721 is ImmutableERC721HybridBase { _safeMintBatchByIDToMultiple(mints); } - /** @notice Allows caller to a burn a number of tokens by ID from a specified address + /** + * @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 { _safeBurnBatch(burns); } - /** @notice Allows caller to a transfer a number of tokens by ID from a specified + /** + * @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 */ diff --git a/contracts/token/erc721/preset/ImmutableERC721MintByID.sol b/contracts/token/erc721/preset/ImmutableERC721MintByID.sol index 5259112f..d2c95066 100644 --- a/contracts/token/erc721/preset/ImmutableERC721MintByID.sol +++ b/contracts/token/erc721/preset/ImmutableERC721MintByID.sol @@ -41,7 +41,8 @@ contract ImmutableERC721MintByID is ImmutableERC721Base { ) {} - /** @notice Allows minter to mint `tokenID` to `to` + /** + * @notice Allows minter to mint `tokenID` to `to` * @param to the address to mint the token to * @param tokenID the ID of the token to mint */ @@ -50,7 +51,8 @@ contract ImmutableERC721MintByID is ImmutableERC721Base { _safeMint(to, tokenID, ""); } - /** @notice Allows minter to safe mint `tokenID` to `to` + /** + * @notice Allows minter to safe mint `tokenID` to `to` * @param to the address to mint the token to * @param tokenID the ID of the token to mint */ @@ -97,7 +99,8 @@ contract ImmutableERC721MintByID is ImmutableERC721Base { _safeBurnBatch(burns); } - /** @notice Allows caller to a transfer a number of tokens by ID from a specified + /** + * @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 */ diff --git a/contracts/trading/seaport/zones/immutable-signed-zone/v1/interfaces/SIP7Interface.sol b/contracts/trading/seaport/zones/immutable-signed-zone/v1/interfaces/SIP7Interface.sol index 79808fab..9b96be0a 100644 --- a/contracts/trading/seaport/zones/immutable-signed-zone/v1/interfaces/SIP7Interface.sol +++ b/contracts/trading/seaport/zones/immutable-signed-zone/v1/interfaces/SIP7Interface.sol @@ -16,9 +16,11 @@ interface SIP7Interface { * @dev The struct for storing signer info. */ struct SignerInfo { - bool active; /// If the signer is currently active. - bool previouslyActive; /// If the signer has been active before. + bool active; + /// If the signer is currently active. + bool previouslyActive; } + /// If the signer has been active before. /** * @notice Add a new signer to the zone. diff --git a/contracts/trading/seaport/zones/immutable-signed-zone/v2/ImmutableSignedZoneV2.sol b/contracts/trading/seaport/zones/immutable-signed-zone/v2/ImmutableSignedZoneV2.sol index 5d79556b..01f03efc 100644 --- a/contracts/trading/seaport/zones/immutable-signed-zone/v2/ImmutableSignedZoneV2.sol +++ b/contracts/trading/seaport/zones/immutable-signed-zone/v2/ImmutableSignedZoneV2.sol @@ -22,7 +22,7 @@ import {SIP7Interface} from "./interfaces/SIP7Interface.sol"; * @notice ImmutableSignedZoneV2 is a zone implementation based on the * SIP-7 standard https://github.com/ProjectOpenSea/SIPs/blob/main/SIPS/sip-7.md * implementing substandards 3, 4 and 6. - * + * * The contract is not upgradable. If the contract needs to be changed a new version * should be deployed, and the old version should be removed from the Seaport contract * zone allowlist. @@ -36,21 +36,33 @@ contract ImmutableSignedZoneV2 is SIP7Interface { /// @dev The EIP-712 domain type hash. - bytes32 private constant _EIP_712_DOMAIN_TYPEHASH = keccak256( - abi.encodePacked( - "EIP712Domain(", "string name,", "string version,", "uint256 chainId,", "address verifyingContract", ")" - ) - ); + bytes32 private constant _EIP_712_DOMAIN_TYPEHASH = + keccak256( + abi.encodePacked( + "EIP712Domain(", + "string name,", + "string version,", + "uint256 chainId,", + "address verifyingContract", + ")" + ) + ); /// @dev The EIP-712 domain version value. bytes32 private constant _VERSION_HASH = keccak256(bytes("2.0")); /// @dev The EIP-712 signed order type hash. - bytes32 private constant _SIGNED_ORDER_TYPEHASH = keccak256( - abi.encodePacked( - "SignedOrder(", "address fulfiller,", "uint64 expiration,", "bytes32 orderHash,", "bytes context", ")" - ) - ); + bytes32 private constant _SIGNED_ORDER_TYPEHASH = + keccak256( + abi.encodePacked( + "SignedOrder(", + "address fulfiller,", + "uint64 expiration,", + "bytes32 orderHash,", + "bytes context", + ")" + ) + ); /// @dev The chain ID on which the contract was deployed. uint256 private immutable _CHAIN_ID = block.chainid; @@ -87,9 +99,12 @@ contract ImmutableSignedZoneV2 is * @param owner The address of the owner of this contract. Specified in the * constructor to be CREATE2 / CREATE3 compatible. */ - constructor(string memory zoneName, string memory apiEndpoint, string memory documentationURI, address owner) - ZoneAccessControl(owner) - { + constructor( + string memory zoneName, + string memory apiEndpoint, + string memory documentationURI, + address owner + ) ZoneAccessControl(owner) { // Set the zone name. _ZONE_NAME = zoneName; @@ -171,11 +186,7 @@ contract ImmutableSignedZoneV2 is * * @param newDocumentationURI The new documentation URI. */ - function updateDocumentationURI(string calldata newDocumentationURI) - external - override - onlyRole(ZONE_MANAGER_ROLE) - { + function updateDocumentationURI(string calldata newDocumentationURI) external override onlyRole(ZONE_MANAGER_ROLE) { _documentationURI = newDocumentationURI; } @@ -197,8 +208,12 @@ contract ImmutableSignedZoneV2 is // supported SIP (7) schemas = new Schema[](1); schemas[0].id = 7; - schemas[0].metadata = - abi.encode(_domainSeparator(), _apiEndpoint, _getSupportedSubstandards(), _documentationURI); + schemas[0].metadata = abi.encode( + _domainSeparator(), + _apiEndpoint, + _getSupportedSubstandards(), + _documentationURI + ); } /** @@ -239,12 +254,9 @@ contract ImmutableSignedZoneV2 is * @return validOrderMagicValue A magic value indicating if the order is * currently valid. */ - function validateOrder(ZoneParameters calldata zoneParameters) - external - view - override - returns (bytes4 validOrderMagicValue) - { + function validateOrder( + ZoneParameters calldata zoneParameters + ) external view override returns (bytes4 validOrderMagicValue) { // Put the extraData and orderHash on the stack for cheaper access. bytes calldata extraData = zoneParameters.extraData; bytes32 orderHash = zoneParameters.orderHash; @@ -328,14 +340,14 @@ contract ImmutableSignedZoneV2 is * * @param interfaceId The interface ID to check for support. */ - function supportsInterface(bytes4 interfaceId) - public - view - override(ERC165, ZoneInterface, AccessControlEnumerable) - returns (bool) - { - return interfaceId == type(ZoneInterface).interfaceId || interfaceId == type(SIP5Interface).interfaceId - || interfaceId == type(SIP7Interface).interfaceId || super.supportsInterface(interfaceId); + function supportsInterface( + bytes4 interfaceId + ) public view override(ERC165, ZoneInterface, AccessControlEnumerable) returns (bool) { + return + interfaceId == type(ZoneInterface).interfaceId || + interfaceId == type(SIP5Interface).interfaceId || + interfaceId == type(SIP7Interface).interfaceId || + super.supportsInterface(interfaceId); } /** @@ -381,14 +393,16 @@ contract ImmutableSignedZoneV2 is * @param context The optional variable-length context. * @return signedOrderHash The signedOrder hash. */ - function _deriveSignedOrderHash(address fulfiller, uint64 expiration, bytes32 orderHash, bytes calldata context) - internal - pure - returns (bytes32 signedOrderHash) - { + function _deriveSignedOrderHash( + address fulfiller, + uint64 expiration, + bytes32 orderHash, + bytes calldata context + ) internal pure returns (bytes32 signedOrderHash) { // Derive the signed order hash. - signedOrderHash = - keccak256(abi.encode(_SIGNED_ORDER_TYPEHASH, fulfiller, expiration, orderHash, keccak256(context))); + signedOrderHash = keccak256( + abi.encode(_SIGNED_ORDER_TYPEHASH, fulfiller, expiration, orderHash, keccak256(context)) + ); } /** @@ -434,11 +448,10 @@ contract ImmutableSignedZoneV2 is * @param zoneParameters The zone parameters. * @return Length of substandard segment. */ - function _validateSubstandard3(bytes calldata context, ZoneParameters calldata zoneParameters) - internal - pure - returns (uint256) - { + function _validateSubstandard3( + bytes calldata context, + ZoneParameters calldata zoneParameters + ) internal pure returns (uint256) { if (uint8(context[0]) != 3) { return 0; } @@ -464,11 +477,10 @@ contract ImmutableSignedZoneV2 is * @param zoneParameters The zone parameters. * @return Length of substandard segment. */ - function _validateSubstandard4(bytes calldata context, ZoneParameters calldata zoneParameters) - internal - pure - returns (uint256) - { + function _validateSubstandard4( + bytes calldata context, + ZoneParameters calldata zoneParameters + ) internal pure returns (uint256) { if (uint8(context[0]) != 4) { return 0; } @@ -499,11 +511,10 @@ contract ImmutableSignedZoneV2 is * @param zoneParameters The zone parameters. * @return Length of substandard segment. */ - function _validateSubstandard6(bytes calldata context, ZoneParameters calldata zoneParameters) - internal - pure - returns (uint256) - { + function _validateSubstandard6( + bytes calldata context, + ZoneParameters calldata zoneParameters + ) internal pure returns (uint256) { if (uint8(context[0]) != 6) { return 0; } @@ -528,11 +539,15 @@ contract ImmutableSignedZoneV2 is // from context) amounts of the first offer item. if ( _deriveReceivedItemsHash( - zoneParameters.consideration, originalFirstOfferItemAmount, zoneParameters.offer[0].amount + zoneParameters.consideration, + originalFirstOfferItemAmount, + zoneParameters.offer[0].amount ) != expectedReceivedItemsHash ) { revert Substandard6Violation( - zoneParameters.offer[0].amount, originalFirstOfferItemAmount, zoneParameters.orderHash + zoneParameters.offer[0].amount, + originalFirstOfferItemAmount, + zoneParameters.orderHash ); } @@ -577,11 +592,10 @@ contract ImmutableSignedZoneV2 is * @param values Values array. * @return True if all elements in values exist in sourceArray. */ - function _bytes32ArrayIncludes(bytes32[] calldata sourceArray, bytes32[] memory values) - internal - pure - returns (bool) - { + function _bytes32ArrayIncludes( + bytes32[] calldata sourceArray, + bytes32[] memory values + ) internal pure returns (bool) { // cache the length in memory for loop optimisation uint256 sourceArraySize = sourceArray.length; uint256 valuesSize = values.length; @@ -593,10 +607,10 @@ contract ImmutableSignedZoneV2 is } // Iterate through each element and compare them - for (uint256 i = 0; i < valuesSize;) { + for (uint256 i = 0; i < valuesSize; ) { bool found = false; bytes32 item = values[i]; - for (uint256 j = 0; j < sourceArraySize;) { + for (uint256 j = 0; j < sourceArraySize; ) { if (item == sourceArray[j]) { // if item from values is in sourceArray, break found = true; diff --git a/contracts/trading/seaport/zones/immutable-signed-zone/v2/ZoneAccessControl.sol b/contracts/trading/seaport/zones/immutable-signed-zone/v2/ZoneAccessControl.sol index f45c11a2..4b045746 100644 --- a/contracts/trading/seaport/zones/immutable-signed-zone/v2/ZoneAccessControl.sol +++ b/contracts/trading/seaport/zones/immutable-signed-zone/v2/ZoneAccessControl.sol @@ -7,8 +7,7 @@ pragma solidity 0.8.20; import {AccessControl} from "openzeppelin-contracts-5.0.2/access/AccessControl.sol"; import {IAccessControl} from "openzeppelin-contracts-5.0.2/access/IAccessControl.sol"; import {AccessControlEnumerable} from "openzeppelin-contracts-5.0.2/access/extensions/AccessControlEnumerable.sol"; -import {ZoneAccessControlEventsAndErrors} from - "../../../../../../contracts/trading/seaport/zones/immutable-signed-zone/v2/interfaces/ZoneAccessControlEventsAndErrors.sol"; +import {ZoneAccessControlEventsAndErrors} from "../../../../../../contracts/trading/seaport/zones/immutable-signed-zone/v2/interfaces/ZoneAccessControlEventsAndErrors.sol"; /** * @notice ZoneAccessControl encapsulates access control functionality for the zone. @@ -30,7 +29,10 @@ abstract contract ZoneAccessControl is AccessControlEnumerable, ZoneAccessContro /** * @inheritdoc AccessControl */ - function revokeRole(bytes32 role, address account) public override(AccessControl, IAccessControl) onlyRole(getRoleAdmin(role)) { + function revokeRole( + bytes32 role, + address account + ) public override(AccessControl, IAccessControl) onlyRole(getRoleAdmin(role)) { if (role == DEFAULT_ADMIN_ROLE && super.getRoleMemberCount(DEFAULT_ADMIN_ROLE) == 1) { revert LastDefaultAdminRole(account); } diff --git a/script/trading/seaport/DeployImmutableSignedZoneV2.s.sol b/script/trading/seaport/DeployImmutableSignedZoneV2.s.sol index 69110483..cdabc7af 100644 --- a/script/trading/seaport/DeployImmutableSignedZoneV2.s.sol +++ b/script/trading/seaport/DeployImmutableSignedZoneV2.s.sol @@ -4,7 +4,8 @@ pragma solidity 0.8.20; import "forge-std/Test.sol"; -import {ImmutableSignedZoneV2} from "../../../contracts/trading/seaport/zones/immutable-signed-zone/v2/ImmutableSignedZoneV2.sol"; +import {ImmutableSignedZoneV2} from + "../../../contracts/trading/seaport/zones/immutable-signed-zone/v2/ImmutableSignedZoneV2.sol"; /** * @title IDeployer Interface @@ -51,21 +52,25 @@ contract DeployImmutableSignedZoneV2 is Test { }); // Run deployment against forked testnet - ImmutableSignedZoneV2 deployedContract = _deploy(deploymentArgs, zoneDeploymentArgs); - - // Assert - ( - , - string memory apiEndpoint, - , - string memory documentationURI - ) = deployedContract.sip7Information(); - - assertEq(true, (keccak256(abi.encodePacked(apiEndpoint)) == keccak256(abi.encodePacked(zoneDeploymentArgs.apiEndpoint)))); - assertEq(true, (keccak256(abi.encodePacked(documentationURI)) == keccak256(abi.encodePacked(zoneDeploymentArgs.documentationURI)))); + ImmutableSignedZoneV2 deployedContract = _deploy(deploymentArgs, zoneDeploymentArgs); + + // Assert + (, string memory apiEndpoint,, string memory documentationURI) = deployedContract.sip7Information(); + + assertEq( + true, + (keccak256(abi.encodePacked(apiEndpoint)) == keccak256(abi.encodePacked(zoneDeploymentArgs.apiEndpoint))) + ); + assertEq( + true, + ( + keccak256(abi.encodePacked(documentationURI)) + == keccak256(abi.encodePacked(zoneDeploymentArgs.documentationURI)) + ) + ); } - function deploy() external { + function deploy() external { address signer = vm.envAddress("DEPLOYER_ADDRESS"); address factory = vm.envAddress("OWNABLE_CREATE3_FACTORY_ADDRESS"); address owner = vm.envAddress("OWNER"); diff --git a/script/trading/seaport/DeployImmutableSignedZoneV2Dev.s.sol b/script/trading/seaport/DeployImmutableSignedZoneV2Dev.s.sol index 87549b03..8d122e3e 100644 --- a/script/trading/seaport/DeployImmutableSignedZoneV2Dev.s.sol +++ b/script/trading/seaport/DeployImmutableSignedZoneV2Dev.s.sol @@ -2,19 +2,21 @@ // SPDX-License-Identifier: Apache-2 import {Script} from "forge-std/Script.sol"; -import {ImmutableSignedZoneV2} from "../../../contracts/trading/seaport/zones/immutable-signed-zone/v2/ImmutableSignedZoneV2.sol"; +import {ImmutableSignedZoneV2} from + "../../../contracts/trading/seaport/zones/immutable-signed-zone/v2/ImmutableSignedZoneV2.sol"; // solhint-disable-next-line compiler-version pragma solidity 0.8.20; - // Deploy ImmutableSignedZoneV2 to dev environment (without create3) contract DeployImmutableSignedZoneV2Dev is Script { function run() external { vm.startBroadcast(); // replace args with test values if necessary - ImmutableSignedZoneV2 c = new ImmutableSignedZoneV2("ImmutableSignedZone", "", "", address(0xC606830D8341bc9F5F5Dd7615E9313d2655B505D)); + ImmutableSignedZoneV2 c = new ImmutableSignedZoneV2( + "ImmutableSignedZone", "", "", address(0xC606830D8341bc9F5F5Dd7615E9313d2655B505D) + ); c.grantRole(bytes32("ZONE_MANAGER"), address(0xC606830D8341bc9F5F5Dd7615E9313d2655B505D)); diff --git a/test/allowlist/AllowlistImmutableERC721MintByIDTransferApprovals.t.sol b/test/allowlist/AllowlistImmutableERC721MintByIDTransferApprovals.t.sol index cbb18764..8006ee1c 100644 --- a/test/allowlist/AllowlistImmutableERC721MintByIDTransferApprovals.t.sol +++ b/test/allowlist/AllowlistImmutableERC721MintByIDTransferApprovals.t.sol @@ -10,14 +10,13 @@ import {IImmutableERC721Errors} from "../../contracts/errors/Errors.sol"; import {OperatorAllowlistEnforcementErrors} from "../../contracts/errors/Errors.sol"; import {OperatorAllowlistUpgradeable} from "../../contracts/allowlist/OperatorAllowlistUpgradeable.sol"; import {Sign} from "../utils/Sign.sol"; -import {DeployOperatorAllowlist} from "../utils/DeployAllowlistProxy.sol"; +import {DeployOperatorAllowlist} from "../utils/DeployAllowlistProxy.sol"; import {DeploySCWallet} from "../utils/DeploySCW.sol"; import {DeployMockMarketPlace} from "../utils/DeployMockMarketPlace.sol"; import {MockMarketplace} from "../../contracts/mocks/MockMarketplace.sol"; import {MockDisguisedEOA} from "../../contracts/mocks/MockDisguisedEOA.sol"; import {MockOnReceive} from "../../contracts/mocks/MockOnReceive.sol"; - contract AllowlistERC721TransferApprovals is Test { OperatorAllowlistUpgradeable public allowlist; ImmutableERC721MintByID public immutableERC721MintByID; @@ -47,14 +46,7 @@ contract AllowlistERC721TransferApprovals is Test { allowlist = OperatorAllowlistUpgradeable(proxyAddr); immutableERC721MintByID = new ImmutableERC721MintByID( - admin, - "test", - "USDC", - "test-base-uri", - "test-contract-uri", - address(allowlist), - feeReceiver, - 0 + admin, "test", "USDC", "test-base-uri", "test-contract-uri", address(allowlist), feeReceiver, 0 ); mockEOAFactory = new MockFactory(); @@ -125,7 +117,7 @@ contract AllowlistERC721TransferApprovals is Test { function testShouldApproveWalletInOAL() public { bytes32 salt = keccak256(abi.encodePacked("0x1234")); - (scwAddr, ) = deploySCWScript.run(salt); + (scwAddr,) = deploySCWScript.run(salt); vm.prank(registrar); allowlist.addWalletToAllowlist(scwAddr); @@ -168,7 +160,7 @@ contract AllowlistERC721TransferApprovals is Test { function testBlockTransferForNoneOALWallet() public { bytes32 salt = keccak256(abi.encodePacked("0x1234")); - (scwAddr, ) = deploySCWScript.run(salt); + (scwAddr,) = deploySCWScript.run(salt); vm.startPrank(minter, minter); immutableERC721MintByID.safeMint(minter, 1); @@ -212,7 +204,7 @@ contract AllowlistERC721TransferApprovals is Test { function testTransferToWalletInOAL() public { bytes32 salt = keccak256(abi.encodePacked("0x1234")); - (scwAddr, ) = deploySCWScript.run(salt); + (scwAddr,) = deploySCWScript.run(salt); vm.prank(registrar); allowlist.addWalletToAllowlist(scwAddr); @@ -226,11 +218,11 @@ contract AllowlistERC721TransferApprovals is Test { function testTransferBetweenSCWInOAL() public { bytes32 salt = keccak256(abi.encodePacked("0x1234")); - (address scwAddr1, ) = deploySCWScript.run(salt); + (address scwAddr1,) = deploySCWScript.run(salt); MockWallet scw1 = MockWallet(scwAddr1); bytes32 salt2 = keccak256(abi.encodePacked("0x5678")); - (address scwAddr2, ) = deploySCWScript.run(salt2); + (address scwAddr2,) = deploySCWScript.run(salt2); vm.startPrank(registrar); allowlist.addWalletToAllowlist(scwAddr1); @@ -273,7 +265,4 @@ contract AllowlistERC721TransferApprovals is Test { immutableERC721MintByID.safeTransferFrom(minter, address(onReceive), 1, ""); vm.stopPrank(); } - - - -} \ No newline at end of file +} diff --git a/test/allowlist/AllowlistImmutableERC721TransferApprovals.t.sol b/test/allowlist/AllowlistImmutableERC721TransferApprovals.t.sol index 969be1c0..930b8d97 100644 --- a/test/allowlist/AllowlistImmutableERC721TransferApprovals.t.sol +++ b/test/allowlist/AllowlistImmutableERC721TransferApprovals.t.sol @@ -10,14 +10,13 @@ import {IImmutableERC721Errors} from "../../contracts/errors/Errors.sol"; import {OperatorAllowlistEnforcementErrors} from "../../contracts/errors/Errors.sol"; import {OperatorAllowlistUpgradeable} from "../../contracts/allowlist/OperatorAllowlistUpgradeable.sol"; import {Sign} from "../utils/Sign.sol"; -import {DeployOperatorAllowlist} from "../utils/DeployAllowlistProxy.sol"; +import {DeployOperatorAllowlist} from "../utils/DeployAllowlistProxy.sol"; import {DeploySCWallet} from "../utils/DeploySCW.sol"; import {DeployMockMarketPlace} from "../utils/DeployMockMarketPlace.sol"; import {MockMarketplace} from "../../contracts/mocks/MockMarketplace.sol"; import {MockDisguisedEOA} from "../../contracts/mocks/MockDisguisedEOA.sol"; import {MockOnReceive} from "../../contracts/mocks/MockOnReceive.sol"; - contract AllowlistERC721TransferApprovals is Test { OperatorAllowlistUpgradeable public allowlist; ImmutableERC721 public immutableERC721; @@ -47,14 +46,7 @@ contract AllowlistERC721TransferApprovals is Test { allowlist = OperatorAllowlistUpgradeable(proxyAddr); immutableERC721 = new ImmutableERC721( - admin, - "test", - "USDC", - "test-base-uri", - "test-contract-uri", - address(allowlist), - feeReceiver, - 0 + admin, "test", "USDC", "test-base-uri", "test-contract-uri", address(allowlist), feeReceiver, 0 ); mockEOAFactory = new MockFactory(); @@ -125,7 +117,7 @@ contract AllowlistERC721TransferApprovals is Test { function testShouldApproveWalletInOAL() public { bytes32 salt = keccak256(abi.encodePacked("0x1234")); - (scwAddr, ) = deploySCWScript.run(salt); + (scwAddr,) = deploySCWScript.run(salt); vm.prank(registrar); allowlist.addWalletToAllowlist(scwAddr); @@ -168,7 +160,7 @@ contract AllowlistERC721TransferApprovals is Test { function testBlockTransferForNoneOALWallet() public { bytes32 salt = keccak256(abi.encodePacked("0x1234")); - (scwAddr, ) = deploySCWScript.run(salt); + (scwAddr,) = deploySCWScript.run(salt); vm.startPrank(minter, minter); immutableERC721.safeMint(minter, 1); @@ -188,7 +180,6 @@ contract AllowlistERC721TransferApprovals is Test { vm.stopPrank(); } - function testBlockTransferForNoneOALAddr() public { vm.startPrank(minter, minter); immutableERC721.safeMint(minter, 1); @@ -213,7 +204,7 @@ contract AllowlistERC721TransferApprovals is Test { function testTransferToWalletInOAL() public { bytes32 salt = keccak256(abi.encodePacked("0x1234")); - (scwAddr, ) = deploySCWScript.run(salt); + (scwAddr,) = deploySCWScript.run(salt); vm.prank(registrar); allowlist.addWalletToAllowlist(scwAddr); @@ -227,11 +218,11 @@ contract AllowlistERC721TransferApprovals is Test { function testTransferBetweenSCWInOAL() public { bytes32 salt = keccak256(abi.encodePacked("0x1234")); - (address scwAddr1, ) = deploySCWScript.run(salt); + (address scwAddr1,) = deploySCWScript.run(salt); MockWallet scw1 = MockWallet(scwAddr1); bytes32 salt2 = keccak256(abi.encodePacked("0x5678")); - (address scwAddr2, ) = deploySCWScript.run(salt2); + (address scwAddr2,) = deploySCWScript.run(salt2); vm.startPrank(registrar); allowlist.addWalletToAllowlist(scwAddr1); @@ -274,7 +265,4 @@ contract AllowlistERC721TransferApprovals is Test { immutableERC721.safeTransferFrom(minter, address(onReceive), 1, ""); vm.stopPrank(); } - - - -} \ No newline at end of file +} diff --git a/test/allowlist/OperatorAllowlistUpgradeable.t.sol b/test/allowlist/OperatorAllowlistUpgradeable.t.sol index ed90f124..06a618fe 100644 --- a/test/allowlist/OperatorAllowlistUpgradeable.t.sol +++ b/test/allowlist/OperatorAllowlistUpgradeable.t.sol @@ -7,7 +7,7 @@ import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; import {OperatorAllowlistUpgradeable} from "../../contracts/allowlist/OperatorAllowlistUpgradeable.sol"; import {MockOperatorAllowlistUpgradeable} from "./MockOAL.sol"; import {ImmutableERC721} from "../../contracts/token/erc721/preset/ImmutableERC721.sol"; -import {DeployOperatorAllowlist} from "../utils/DeployAllowlistProxy.sol"; +import {DeployOperatorAllowlist} from "../utils/DeployAllowlistProxy.sol"; import {DeploySCWallet} from "../utils/DeploySCW.sol"; import {IWalletProxy} from "../../contracts/allowlist/IWalletProxy.sol"; @@ -36,14 +36,7 @@ contract OperatorAllowlistTest is Test, OperatorAllowlistUpgradeable { allowlist = OperatorAllowlistUpgradeable(proxyAddr); immutableERC721 = new ImmutableERC721( - admin, - "test", - "USDC", - "test-base-uri", - "test-contract-uri", - address(allowlist), - feeReceiver, - 0 + admin, "test", "USDC", "test-base-uri", "test-contract-uri", address(allowlist), feeReceiver, 0 ); nonAuthorizedWallet = address(0x2); @@ -71,7 +64,7 @@ contract OperatorAllowlistTest is Test, OperatorAllowlistUpgradeable { } function testFailedUpgradeNoPerms() public { - MockOperatorAllowlistUpgradeable oalImplV2 = new MockOperatorAllowlistUpgradeable(); + MockOperatorAllowlistUpgradeable oalImplV2 = new MockOperatorAllowlistUpgradeable(); vm.prank(nonAuthorizedWallet); vm.expectRevert("Must have upgrade role to upgrade"); allowlist.upgradeTo(address(oalImplV2)); @@ -86,16 +79,24 @@ contract OperatorAllowlistTest is Test, OperatorAllowlistUpgradeable { addressTargets[0] = address(0x1); vm.startPrank(admin); - vm.expectRevert("AccessControl: account 0xe48648ee1c7285ff3ad32fa99c427884666caf17 is missing role 0x5245474953545241525f524f4c45000000000000000000000000000000000000"); + vm.expectRevert( + "AccessControl: account 0xe48648ee1c7285ff3ad32fa99c427884666caf17 is missing role 0x5245474953545241525f524f4c45000000000000000000000000000000000000" + ); allowlist.addAddressesToAllowlist(addressTargets); - vm.expectRevert("AccessControl: account 0xe48648ee1c7285ff3ad32fa99c427884666caf17 is missing role 0x5245474953545241525f524f4c45000000000000000000000000000000000000"); + vm.expectRevert( + "AccessControl: account 0xe48648ee1c7285ff3ad32fa99c427884666caf17 is missing role 0x5245474953545241525f524f4c45000000000000000000000000000000000000" + ); allowlist.removeAddressesFromAllowlist(addressTargets); - vm.expectRevert("AccessControl: account 0xe48648ee1c7285ff3ad32fa99c427884666caf17 is missing role 0x5245474953545241525f524f4c45000000000000000000000000000000000000"); + vm.expectRevert( + "AccessControl: account 0xe48648ee1c7285ff3ad32fa99c427884666caf17 is missing role 0x5245474953545241525f524f4c45000000000000000000000000000000000000" + ); allowlist.addWalletToAllowlist(address(0x3)); - vm.expectRevert("AccessControl: account 0xe48648ee1c7285ff3ad32fa99c427884666caf17 is missing role 0x5245474953545241525f524f4c45000000000000000000000000000000000000"); + vm.expectRevert( + "AccessControl: account 0xe48648ee1c7285ff3ad32fa99c427884666caf17 is missing role 0x5245474953545241525f524f4c45000000000000000000000000000000000000" + ); allowlist.removeWalletFromAllowlist(address(0x3)); vm.stopPrank(); @@ -113,7 +114,7 @@ contract OperatorAllowlistTest is Test, OperatorAllowlistUpgradeable { vm.startPrank(registrar); - vm.expectEmit(true, true, true, false, address(allowlist)); + vm.expectEmit(true, true, true, false, address(allowlist)); emit WalletAllowlistChanged(keccak256(abi.encodePacked(deployedBytecode)), scwAddr, true); allowlist.addWalletToAllowlist(scwAddr); assertTrue(allowlist.isAllowlisted(scwAddr)); @@ -123,7 +124,7 @@ contract OperatorAllowlistTest is Test, OperatorAllowlistUpgradeable { allowlist.removeWalletFromAllowlist(scwAddr); assertFalse(allowlist.isAllowlisted(scwAddr)); - vm.stopPrank(); + vm.stopPrank(); } function testShouldAddAndRemoveAnAddressOfAMarketPlaceAndRemoveItFromAllowlist() public { @@ -148,7 +149,7 @@ contract OperatorAllowlistTest is Test, OperatorAllowlistUpgradeable { function testShouldNotAllowlistSCWWithSameBytecodeButDifferentImplementationAddress() public { bytes32 salt1 = keccak256(abi.encodePacked("0x5678")); address firstScwAddr; - (firstScwAddr, ) = deploySCWScript.run(salt1); + (firstScwAddr,) = deploySCWScript.run(salt1); vm.startPrank(registrar); allowlist.addWalletToAllowlist(firstScwAddr); @@ -156,8 +157,8 @@ contract OperatorAllowlistTest is Test, OperatorAllowlistUpgradeable { bytes32 salt2 = keccak256(abi.encodePacked("0x5678")); address secondScwAddr; - (secondScwAddr, ) = deploySCWScript.run(salt2); + (secondScwAddr,) = deploySCWScript.run(salt2); assertFalse(allowlist.isAllowlisted(secondScwAddr)); vm.stopPrank(); } -} \ No newline at end of file +} diff --git a/test/deployer/create2/OwnableCreate2Deployer.t.sol b/test/deployer/create2/OwnableCreate2Deployer.t.sol index ceb3f249..2acc7984 100644 --- a/test/deployer/create2/OwnableCreate2Deployer.t.sol +++ b/test/deployer/create2/OwnableCreate2Deployer.t.sol @@ -4,7 +4,6 @@ pragma solidity 0.8.19; import "forge-std/Test.sol"; import {IDeploy} from "@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IDeploy.sol"; - import {ERC20Mock} from "@openzeppelin/contracts/mocks/ERC20Mock.sol"; import {ERC20MintableBurnable} from "@axelar-network/axelar-gmp-sdk-solidity/contracts/test/token/ERC20MintableBurnable.sol"; diff --git a/test/deployer/create3/OwnableCreate3Deployer.t.sol b/test/deployer/create3/OwnableCreate3Deployer.t.sol index 5732fb04..45352ea6 100644 --- a/test/deployer/create3/OwnableCreate3Deployer.t.sol +++ b/test/deployer/create3/OwnableCreate3Deployer.t.sol @@ -4,7 +4,6 @@ pragma solidity 0.8.19; import "forge-std/Test.sol"; import {IDeploy} from "@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IDeploy.sol"; - import {ERC20Mock} from "@openzeppelin/contracts/mocks/ERC20Mock.sol"; import {ERC20MintableBurnable} from "@axelar-network/axelar-gmp-sdk-solidity/contracts/test/token/ERC20MintableBurnable.sol"; diff --git a/test/payment-splitter/PaymentSplitter.t.sol b/test/payment-splitter/PaymentSplitter.t.sol index 4125cae9..7557aa81 100644 --- a/test/payment-splitter/PaymentSplitter.t.sol +++ b/test/payment-splitter/PaymentSplitter.t.sol @@ -27,7 +27,7 @@ contract PaymentSplitterTest is Test { address registrarAdmin = makeAddr("registrarAdmin"); address fundsAdmin = makeAddr("fundsAdmin"); - address payable [] payees = new address payable[](2); + address payable[] payees = new address payable[](2); IERC20[] erc20s = new IERC20[](2); uint256[] shares = new uint256[](2); @@ -76,16 +76,24 @@ contract PaymentSplitterTest is Test { function testInvalidPermissions() public { vm.prank(defaultAdmin); - vm.expectRevert("AccessControl: account 0x6fcb7bf6c32f0cd3bbc5fde0a55a80d3af6d0050 is missing role 0x544f4b454e5f5245474953545241525f524f4c45000000000000000000000000"); + vm.expectRevert( + "AccessControl: account 0x6fcb7bf6c32f0cd3bbc5fde0a55a80d3af6d0050 is missing role 0x544f4b454e5f5245474953545241525f524f4c45000000000000000000000000" + ); paymentSplitter.addToAllowlist(erc20s); vm.startPrank(registrarAdmin); - vm.expectRevert("AccessControl: account 0xa4985bf934d639cba655d34733ebf617e7f82429 is missing role 0x0000000000000000000000000000000000000000000000000000000000000000"); + vm.expectRevert( + "AccessControl: account 0xa4985bf934d639cba655d34733ebf617e7f82429 is missing role 0x0000000000000000000000000000000000000000000000000000000000000000" + ); paymentSplitter.overridePayees(payees, shares); - vm.expectRevert("AccessControl: account 0xa4985bf934d639cba655d34733ebf617e7f82429 is missing role 0x0000000000000000000000000000000000000000000000000000000000000000"); + vm.expectRevert( + "AccessControl: account 0xa4985bf934d639cba655d34733ebf617e7f82429 is missing role 0x0000000000000000000000000000000000000000000000000000000000000000" + ); paymentSplitter.revokeReleaseFundsRole(fundsAdmin); - vm.expectRevert("AccessControl: account 0xa4985bf934d639cba655d34733ebf617e7f82429 is missing role 0x52454c454153455f46554e44535f524f4c450000000000000000000000000000"); + vm.expectRevert( + "AccessControl: account 0xa4985bf934d639cba655d34733ebf617e7f82429 is missing role 0x52454c454153455f46554e44535f524f4c450000000000000000000000000000" + ); paymentSplitter.releaseAll(); vm.stopPrank(); } @@ -135,8 +143,7 @@ contract PaymentSplitterTest is Test { assertEq(payee2.balance, 80); assertEq(address(paymentSplitter).balance, 0); - - address payable [] memory newPayees = new address payable[](2); + address payable[] memory newPayees = new address payable[](2); uint256[] memory newShares = new uint256[](2); newPayees[0] = payable(payee3); newPayees[1] = payable(payee4); @@ -165,7 +172,6 @@ contract PaymentSplitterTest is Test { mockToken1.mint(address(paymentSplitter), 100); mockToken2.mint(address(paymentSplitter), 100); - vm.prank(fundsAdmin); vm.expectEmit(true, true, true, false, address(paymentSplitter)); @@ -182,7 +188,6 @@ contract PaymentSplitterTest is Test { assertEq(mockToken1.balanceOf(address(paymentSplitter)), 0); assertEq(mockToken2.balanceOf(address(paymentSplitter)), 0); - mockToken1.mint(address(paymentSplitter), 10); mockToken2.mint(address(paymentSplitter), 10); @@ -203,7 +208,6 @@ contract PaymentSplitterTest is Test { mockToken1.mint(address(paymentSplitter), 100); mockToken2.mint(address(paymentSplitter), 100); - vm.prank(fundsAdmin); paymentSplitter.releaseAll(); @@ -216,18 +220,16 @@ contract PaymentSplitterTest is Test { assertEq(mockToken1.balanceOf(address(paymentSplitter)), 0); assertEq(mockToken2.balanceOf(address(paymentSplitter)), 0); - mockToken1.mint(address(paymentSplitter), 10); mockToken2.mint(address(paymentSplitter), 10); - address payable [] memory newPayees = new address payable[](2); + address payable[] memory newPayees = new address payable[](2); uint256[] memory newShares = new uint256[](2); newPayees[0] = payable(payee3); newPayees[1] = payable(payee4); newShares[0] = 1; newShares[1] = 1; - vm.prank(defaultAdmin); paymentSplitter.overridePayees(newPayees, newShares); @@ -251,7 +253,7 @@ contract PaymentSplitterTest is Test { vm.deal(address(paymentSplitter), 100); - address payable [] memory newPayees = new address payable[](2); + address payable[] memory newPayees = new address payable[](2); uint256[] memory newShares = new uint256[](2); newPayees[0] = payable(payee3); newPayees[1] = payable(payee4); @@ -277,7 +279,6 @@ contract PaymentSplitterTest is Test { newErc20s[0] = token1; newErc20s[1] = token2; - vm.startPrank(registrarAdmin); paymentSplitter.addToAllowlist(newErc20s); assertEq(paymentSplitter.erc20Allowlist().length, 4); @@ -295,9 +296,8 @@ contract PaymentSplitterTest is Test { function testReceiveNativeTokenEvent() public { vm.deal(address(this), 100); - vm.expectEmit(true, true, false, false, address(paymentSplitter)); + vm.expectEmit(true, true, false, false, address(paymentSplitter)); emit PaymentReceived(address(this), 100); Address.sendValue(payable(address(paymentSplitter)), 100); } - -} \ No newline at end of file +} diff --git a/test/random/MockGame.sol b/test/random/MockGame.sol index 05025ba7..c2069f36 100644 --- a/test/random/MockGame.sol +++ b/test/random/MockGame.sol @@ -4,18 +4,17 @@ pragma solidity 0.8.19; import {RandomValues} from "contracts/random/RandomValues.sol"; contract MockGame is RandomValues { - constructor(address _randomSeedProvider) RandomValues(_randomSeedProvider) { - } + constructor(address _randomSeedProvider) RandomValues(_randomSeedProvider) {} function requestRandomValueCreation(uint16 _size) external returns (uint256 _randomRequestId) { return _requestRandomValueCreation(_size); } - function fetchRandomValues(uint256 _randomRequestId) external returns(bytes32[] memory _randomValues) { + function fetchRandomValues(uint256 _randomRequestId) external returns (bytes32[] memory _randomValues) { return _fetchRandomValues(_randomRequestId); } - function isRandomValueReady(uint256 _randomRequestId) external view returns(RequestStatus) { + function isRandomValueReady(uint256 _randomRequestId) external view returns (RequestStatus) { return _isRandomValueReady(_randomRequestId); } } diff --git a/test/random/MockOffchainSource.sol b/test/random/MockOffchainSource.sol index 0c799d4b..47111a8a 100644 --- a/test/random/MockOffchainSource.sol +++ b/test/random/MockOffchainSource.sol @@ -4,7 +4,6 @@ pragma solidity 0.8.19; import {IOffchainRandomSource} from "contracts/random/offchainsources/IOffchainRandomSource.sol"; - contract MockOffchainSource is IOffchainRandomSource { uint256 public nextIndex = 1000; bool public isReady; @@ -13,20 +12,23 @@ contract MockOffchainSource is IOffchainRandomSource { isReady = _ready; } - function requestOffchainRandom() external override(IOffchainRandomSource) returns(uint256 _fulfilmentIndex) { + function requestOffchainRandom() external override(IOffchainRandomSource) returns (uint256 _fulfilmentIndex) { return nextIndex++; } - function getOffchainRandom(uint256 _fulfilmentIndex) external view override(IOffchainRandomSource) returns(bytes32 _randomValue) { + function getOffchainRandom(uint256 _fulfilmentIndex) + external + view + override(IOffchainRandomSource) + returns (bytes32 _randomValue) + { if (!isReady) { revert WaitForRandom(); } return keccak256(abi.encodePacked(_fulfilmentIndex)); } - function isOffchainRandomReady(uint256 /* _fulfilmentIndex */) external view returns(bool) { + function isOffchainRandomReady(uint256 /* _fulfilmentIndex */ ) external view returns (bool) { return isReady; } - - } diff --git a/test/random/MockRandomSeedProviderV2.sol b/test/random/MockRandomSeedProviderV2.sol index 8a891505..5a0e0512 100644 --- a/test/random/MockRandomSeedProviderV2.sol +++ b/test/random/MockRandomSeedProviderV2.sol @@ -4,15 +4,13 @@ pragma solidity 0.8.19; import {RandomSeedProvider} from "contracts/random/RandomSeedProvider.sol"; - contract MockRandomSeedProviderV2 is RandomSeedProvider { uint256 internal constant VERSION2 = 2; - function upgrade() external override (RandomSeedProvider) { + function upgrade() external override(RandomSeedProvider) { if (version == VERSION0) { version = VERSION2; - } - else { + } else { revert CanNotUpgradeFrom(version, VERSION2); } } diff --git a/test/random/RandomSeedProvider.t.sol b/test/random/RandomSeedProvider.t.sol index 7320d2cf..ef49b458 100644 --- a/test/random/RandomSeedProvider.t.sol +++ b/test/random/RandomSeedProvider.t.sol @@ -9,11 +9,9 @@ import {RandomSeedProvider} from "contracts/random/RandomSeedProvider.sol"; import {IOffchainRandomSource} from "contracts/random/offchainsources/IOffchainRandomSource.sol"; import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; - - - contract UninitializedRandomSeedProviderTest is Test { error WaitForRandom(); + event OffchainRandomSourceSet(address _offchainRandomSource); event RanDaoEnabled(); event OffchainRandomConsumerAdded(address _consumer); @@ -31,7 +29,6 @@ contract UninitializedRandomSeedProviderTest is Test { ERC1967Proxy public proxyRanDao; RandomSeedProvider public randomSeedProviderRanDao; - address public roleAdmin; address public randomAdmin; address public upgradeAdmin; @@ -41,15 +38,19 @@ contract UninitializedRandomSeedProviderTest is Test { randomAdmin = makeAddr("randomAdmin"); upgradeAdmin = makeAddr("upgradeAdmin"); impl = new RandomSeedProvider(); - proxy = new ERC1967Proxy(address(impl), - abi.encodeWithSelector(RandomSeedProvider.initialize.selector, roleAdmin, randomAdmin, upgradeAdmin, false)); + proxy = new ERC1967Proxy( + address(impl), + abi.encodeWithSelector(RandomSeedProvider.initialize.selector, roleAdmin, randomAdmin, upgradeAdmin, false) + ); randomSeedProvider = RandomSeedProvider(address(proxy)); - proxyRanDao = new ERC1967Proxy(address(impl), - abi.encodeWithSelector(RandomSeedProvider.initialize.selector, roleAdmin, randomAdmin, upgradeAdmin, true)); + proxyRanDao = new ERC1967Proxy( + address(impl), + abi.encodeWithSelector(RandomSeedProvider.initialize.selector, roleAdmin, randomAdmin, upgradeAdmin, true) + ); randomSeedProviderRanDao = RandomSeedProvider(address(proxyRanDao)); - // Ensure we are on a new block number when we start the tests. In particular, don't + // Ensure we are on a new block number when we start the tests. In particular, don't // be on the same block number as when the contracts were deployed. vm.roll(block.number + 1); } @@ -58,8 +59,10 @@ contract UninitializedRandomSeedProviderTest is Test { // This set-up mirrors what is in the setUp function. Have this code here // so that the coverage tool picks up the use of the initialize function. RandomSeedProvider impl1 = new RandomSeedProvider(); - ERC1967Proxy proxy1 = new ERC1967Proxy(address(impl1), - abi.encodeWithSelector(RandomSeedProvider.initialize.selector, roleAdmin, randomAdmin, upgradeAdmin, false)); + ERC1967Proxy proxy1 = new ERC1967Proxy( + address(impl1), + abi.encodeWithSelector(RandomSeedProvider.initialize.selector, roleAdmin, randomAdmin, upgradeAdmin, false) + ); RandomSeedProvider randomSeedProvider1 = RandomSeedProvider(address(proxy1)); vm.roll(block.number + 1); @@ -80,7 +83,6 @@ contract UninitializedRandomSeedProviderTest is Test { randomSeedProvider.initialize(roleAdmin, randomAdmin, upgradeAdmin, true); } - function testGetRandomSeedInitTraditional() public { bytes32 seed = randomSeedProvider.getRandomSeed(0, ONCHAIN); bytes32 expectedInitialSeed = keccak256(abi.encodePacked(block.chainid, blockhash(block.number - 2))); @@ -109,9 +111,9 @@ contract UninitializedRandomSeedProviderTest is Test { } } - contract ControlRandomSeedProviderTest is UninitializedRandomSeedProviderTest { error CanNotUpgradeFrom(uint256 _storageVersion, uint256 _codeVersion); + event Upgraded(address indexed implementation); address public constant NEW_SOURCE = address(10001); @@ -204,8 +206,9 @@ contract ControlRandomSeedProviderTest is UninitializedRandomSeedProviderTest { vm.prank(upgradeAdmin); vm.expectEmit(true, true, true, true); emit Upgraded(address(randomSeedProviderV2)); - randomSeedProvider.upgradeToAndCall(address(randomSeedProviderV2), - abi.encodeWithSelector(randomSeedProviderV2.upgrade.selector)); + randomSeedProvider.upgradeToAndCall( + address(randomSeedProviderV2), abi.encodeWithSelector(randomSeedProviderV2.upgrade.selector) + ); assertEq(randomSeedProvider.version(), 2); } @@ -213,8 +216,9 @@ contract ControlRandomSeedProviderTest is UninitializedRandomSeedProviderTest { MockRandomSeedProviderV2 randomSeedProviderV2 = new MockRandomSeedProviderV2(); vm.expectRevert(); - randomSeedProvider.upgradeToAndCall(address(randomSeedProviderV2), - abi.encodeWithSelector(randomSeedProviderV2.upgrade.selector)); + randomSeedProvider.upgradeToAndCall( + address(randomSeedProviderV2), abi.encodeWithSelector(randomSeedProviderV2.upgrade.selector) + ); } function testNoUpgrade() public { @@ -228,13 +232,15 @@ contract ControlRandomSeedProviderTest is UninitializedRandomSeedProviderTest { RandomSeedProvider randomSeedProviderV0 = new RandomSeedProvider(); vm.prank(upgradeAdmin); - randomSeedProvider.upgradeToAndCall(address(randomSeedProviderV2), - abi.encodeWithSelector(randomSeedProviderV2.upgrade.selector)); + randomSeedProvider.upgradeToAndCall( + address(randomSeedProviderV2), abi.encodeWithSelector(randomSeedProviderV2.upgrade.selector) + ); vm.prank(upgradeAdmin); vm.expectRevert(abi.encodeWithSelector(CanNotUpgradeFrom.selector, 2, 0)); - randomSeedProvider.upgradeToAndCall(address(randomSeedProviderV0), - abi.encodeWithSelector(randomSeedProviderV0.upgrade.selector)); + randomSeedProvider.upgradeToAndCall( + address(randomSeedProviderV0), abi.encodeWithSelector(randomSeedProviderV0.upgrade.selector) + ); } // Check that the downgrade code in MockRandomSeedProviderV2 works too. @@ -248,12 +254,12 @@ contract ControlRandomSeedProviderTest is UninitializedRandomSeedProviderTest { vm.prank(upgradeAdmin); vm.expectRevert(abi.encodeWithSelector(CanNotUpgradeFrom.selector, badVersion, 2)); - randomSeedProvider.upgradeToAndCall(address(randomSeedProviderV2), - abi.encodeWithSelector(randomSeedProviderV2.upgrade.selector)); + randomSeedProvider.upgradeToAndCall( + address(randomSeedProviderV2), abi.encodeWithSelector(randomSeedProviderV2.upgrade.selector) + ); } } - contract OperationalRandomSeedProviderTest is UninitializedRandomSeedProviderTest { MockOffchainSource public offchainSource = new MockOffchainSource(); @@ -292,7 +298,6 @@ contract OperationalRandomSeedProviderTest is UninitializedRandomSeedProviderTes assertNotEq(seed, bytes32(0), "Should not be zero"); } - function testOffchainNextBlock() public { vm.prank(randomAdmin); randomSeedProvider.setOffchainRandomSource(address(offchainSource)); @@ -333,19 +338,18 @@ contract OperationalRandomSeedProviderTest is UninitializedRandomSeedProviderTes randomSeedProvider.getRandomSeed(fulfilmentIndex, source); } - function testTradTwoInOneBlock() public { - (uint256 randomRequestId1, ) = randomSeedProvider.requestRandomSeed(); - (uint256 randomRequestId2, ) = randomSeedProvider.requestRandomSeed(); - (uint256 randomRequestId3, ) = randomSeedProvider.requestRandomSeed(); + (uint256 randomRequestId1,) = randomSeedProvider.requestRandomSeed(); + (uint256 randomRequestId2,) = randomSeedProvider.requestRandomSeed(); + (uint256 randomRequestId3,) = randomSeedProvider.requestRandomSeed(); assertEq(randomRequestId1, randomRequestId2, "Request id 1 and request id 2"); assertEq(randomRequestId1, randomRequestId3, "Request id 1 and request id 3"); } function testRanDaoTwoInOneBlock() public { - (uint256 randomRequestId1, ) = randomSeedProviderRanDao.requestRandomSeed(); - (uint256 randomRequestId2, ) = randomSeedProviderRanDao.requestRandomSeed(); - (uint256 randomRequestId3, ) = randomSeedProviderRanDao.requestRandomSeed(); + (uint256 randomRequestId1,) = randomSeedProviderRanDao.requestRandomSeed(); + (uint256 randomRequestId2,) = randomSeedProviderRanDao.requestRandomSeed(); + (uint256 randomRequestId3,) = randomSeedProviderRanDao.requestRandomSeed(); assertEq(randomRequestId1, randomRequestId2, "Request id 1 and request id 2"); assertEq(randomRequestId1, randomRequestId3, "Request id 1 and request id 3"); } @@ -359,9 +363,9 @@ contract OperationalRandomSeedProviderTest is UninitializedRandomSeedProviderTes randomSeedProvider.addOffchainRandomConsumer(aConsumer); vm.prank(aConsumer); - (uint256 fulfilmentIndex1, ) = randomSeedProvider.requestRandomSeed(); + (uint256 fulfilmentIndex1,) = randomSeedProvider.requestRandomSeed(); vm.prank(aConsumer); - (uint256 fulfilmentIndex2, ) = randomSeedProvider.requestRandomSeed(); + (uint256 fulfilmentIndex2,) = randomSeedProvider.requestRandomSeed(); assertEq(fulfilmentIndex1, fulfilmentIndex2, "Request id 1 and request id 3"); } @@ -511,7 +515,6 @@ contract SwitchingRandomSeedProviderTest is UninitializedRandomSeedProviderTest randomSeedProviderRanDao.getRandomSeed(fulfilmentIndex2, source2); } - function testSwitchOffchainOnchain() public { address aConsumer = makeAddr("aConsumer"); vm.prank(randomAdmin); @@ -540,4 +543,3 @@ contract SwitchingRandomSeedProviderTest is UninitializedRandomSeedProviderTest randomSeedProviderRanDao.getRandomSeed(fulfilmentIndex2, source2); } } - diff --git a/test/random/RandomValues.t.sol b/test/random/RandomValues.t.sol index ca5abf06..62739b5a 100644 --- a/test/random/RandomValues.t.sol +++ b/test/random/RandomValues.t.sol @@ -3,14 +3,11 @@ pragma solidity 0.8.19; import "forge-std/Test.sol"; -import {MockGame,RandomValues} from "./MockGame.sol"; +import {MockGame, RandomValues} from "./MockGame.sol"; import {RandomSeedProvider} from "contracts/random/RandomSeedProvider.sol"; import {IOffchainRandomSource} from "contracts/random/offchainsources/IOffchainRandomSource.sol"; import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; - - - contract UninitializedRandomValuesTest is Test { error RequestForNoRandomBytes(); error RandomValuesPreviouslyFetched(); @@ -34,20 +31,26 @@ contract UninitializedRandomValuesTest is Test { upgradeAdmin = makeAddr("upgradeAdmin"); impl = new RandomSeedProvider(); - proxy = new ERC1967Proxy(address(impl), - abi.encodeWithSelector(RandomSeedProvider.initialize.selector, roleAdmin, randomAdmin, upgradeAdmin, false)); + proxy = new ERC1967Proxy( + address(impl), + abi.encodeWithSelector(RandomSeedProvider.initialize.selector, roleAdmin, randomAdmin, upgradeAdmin, false) + ); randomSeedProvider = RandomSeedProvider(address(proxy)); game1 = new MockGame(address(randomSeedProvider)); - // Ensure we are on a new block number when we start the tests. In particular, don't + // Ensure we are on a new block number when we start the tests. In particular, don't // be on the same block number as when the contracts were deployed. vm.roll(block.number + 1); } function testInit() public { assertEq(address(game1.randomSeedProvider()), address(randomSeedProvider), "randomSeedProvider"); - assertEq(uint256(game1.isRandomValueReady(0)), uint256(RandomValues.RequestStatus.ALREADY_FETCHED), "Should not be ready"); + assertEq( + uint256(game1.isRandomValueReady(0)), + uint256(RandomValues.RequestStatus.ALREADY_FETCHED), + "Should not be ready" + ); } } @@ -61,16 +64,28 @@ contract SingleGameRandomValuesTest is UninitializedRandomValuesTest { function testFirstValue() public returns (bytes32) { uint256 randomRequestId = game1.requestRandomValueCreation(1); - assertEq(uint256(game1.isRandomValueReady(randomRequestId)), uint256(RandomValues.RequestStatus.IN_PROGRESS), "Ready in same block!"); + assertEq( + uint256(game1.isRandomValueReady(randomRequestId)), + uint256(RandomValues.RequestStatus.IN_PROGRESS), + "Ready in same block!" + ); vm.roll(block.number + 1); - assertEq(uint256(game1.isRandomValueReady(randomRequestId)), uint256(RandomValues.RequestStatus.READY), "Should be ready by next block!"); + assertEq( + uint256(game1.isRandomValueReady(randomRequestId)), + uint256(RandomValues.RequestStatus.READY), + "Should be ready by next block!" + ); bytes32[] memory randomValue = game1.fetchRandomValues(randomRequestId); assertEq(randomValue.length, 1, "Random Values length"); assertNotEq(randomValue[0], bytes32(0), "Random Value zero"); - assertEq(uint256(game1.isRandomValueReady(randomRequestId)), uint256(RandomValues.RequestStatus.ALREADY_FETCHED), "Should not be ready"); + assertEq( + uint256(game1.isRandomValueReady(randomRequestId)), + uint256(RandomValues.RequestStatus.ALREADY_FETCHED), + "Should not be ready" + ); return randomValue[0]; } @@ -114,12 +129,24 @@ contract SingleGameRandomValuesTest is UninitializedRandomValuesTest { uint256 randomRequestId1 = game1.requestRandomValueCreation(2); uint256 randomRequestId2 = game2.requestRandomValueCreation(4); - assertEq(uint256(game1.isRandomValueReady(randomRequestId1)), uint256(RandomValues.RequestStatus.IN_PROGRESS), "Ready in same block!"); - assertEq(uint256(game2.isRandomValueReady(randomRequestId2)), uint256(RandomValues.RequestStatus.IN_PROGRESS), "Ready in same block!"); + assertEq( + uint256(game1.isRandomValueReady(randomRequestId1)), + uint256(RandomValues.RequestStatus.IN_PROGRESS), + "Ready in same block!" + ); + assertEq( + uint256(game2.isRandomValueReady(randomRequestId2)), + uint256(RandomValues.RequestStatus.IN_PROGRESS), + "Ready in same block!" + ); vm.roll(block.number + 1); - assertEq(uint256(game1.isRandomValueReady(randomRequestId1)), uint256(RandomValues.RequestStatus.READY), "Ready!"); - assertEq(uint256(game2.isRandomValueReady(randomRequestId2)), uint256(RandomValues.RequestStatus.READY), "Ready!"); + assertEq( + uint256(game1.isRandomValueReady(randomRequestId1)), uint256(RandomValues.RequestStatus.READY), "Ready!" + ); + assertEq( + uint256(game2.isRandomValueReady(randomRequestId2)), uint256(RandomValues.RequestStatus.READY), "Ready!" + ); bytes32[] memory randomValue1 = game1.fetchRandomValues(randomRequestId1); bytes32[] memory randomValue2 = game2.fetchRandomValues(randomRequestId2); diff --git a/test/random/offchainsources/chainlink/ChainlinkSource.t.sol b/test/random/offchainsources/chainlink/ChainlinkSource.t.sol index d7f20a76..b6ddb4d4 100644 --- a/test/random/offchainsources/chainlink/ChainlinkSource.t.sol +++ b/test/random/offchainsources/chainlink/ChainlinkSource.t.sol @@ -11,7 +11,7 @@ import {ChainlinkSourceAdaptor} from "contracts/random/offchainsources/chainlink import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; contract ChainlinkInitTests is Test { - event ConfigChanges( bytes32 _keyHash, uint64 _subId, uint32 _callbackGasLimit); + event ConfigChanges(bytes32 _keyHash, uint64 _subId, uint32 _callbackGasLimit); bytes32 public constant CONFIG_ADMIN_ROLE = keccak256("CONFIG_ADMIN_ROLE"); @@ -38,19 +38,22 @@ contract ChainlinkInitTests is Test { upgradeAdmin = makeAddr("upgradeAdmin"); impl = new RandomSeedProvider(); - proxy = new ERC1967Proxy(address(impl), - abi.encodeWithSelector(RandomSeedProvider.initialize.selector, roleAdmin, randomAdmin, upgradeAdmin, false)); + proxy = new ERC1967Proxy( + address(impl), + abi.encodeWithSelector(RandomSeedProvider.initialize.selector, roleAdmin, randomAdmin, upgradeAdmin, false) + ); randomSeedProvider = RandomSeedProvider(address(proxy)); mockChainlinkCoordinator = new MockCoordinator(); chainlinkSourceAdaptor = new ChainlinkSourceAdaptor( - roleAdmin, configAdmin, address(mockChainlinkCoordinator), KEY_HASH, SUB_ID, CALLBACK_GAS_LIMIT); + roleAdmin, configAdmin, address(mockChainlinkCoordinator), KEY_HASH, SUB_ID, CALLBACK_GAS_LIMIT + ); mockChainlinkCoordinator.setAdaptor(address(chainlinkSourceAdaptor)); vm.prank(randomAdmin); randomSeedProvider.setOffchainRandomSource(address(chainlinkSourceAdaptor)); - // Ensure we are on a new block number when we start the tests. In particular, don't + // Ensure we are on a new block number when we start the tests. In particular, don't // be on the same block number as when the contracts were deployed. vm.roll(block.number + 1); } @@ -58,16 +61,20 @@ contract ChainlinkInitTests is Test { function testInit() public { mockChainlinkCoordinator = new MockCoordinator(); chainlinkSourceAdaptor = new ChainlinkSourceAdaptor( - roleAdmin, configAdmin, address(mockChainlinkCoordinator), KEY_HASH, SUB_ID, CALLBACK_GAS_LIMIT); - - assertEq(address(chainlinkSourceAdaptor.vrfCoordinator()), address(mockChainlinkCoordinator), "vrfCoord not set correctly"); + roleAdmin, configAdmin, address(mockChainlinkCoordinator), KEY_HASH, SUB_ID, CALLBACK_GAS_LIMIT + ); + + assertEq( + address(chainlinkSourceAdaptor.vrfCoordinator()), + address(mockChainlinkCoordinator), + "vrfCoord not set correctly" + ); assertEq(chainlinkSourceAdaptor.keyHash(), KEY_HASH, "keyHash not set correctly"); assertEq(chainlinkSourceAdaptor.subId(), SUB_ID, "subId not set correctly"); assertEq(chainlinkSourceAdaptor.callbackGasLimit(), CALLBACK_GAS_LIMIT, "callbackGasLimit not set correctly"); } } - contract ChainlinkControlTests is ChainlinkInitTests { function testRoleAdmin() public { bytes32 role = CONFIG_ADMIN_ROLE; @@ -104,15 +111,15 @@ contract ChainlinkControlTests is ChainlinkInitTests { uint64 subId = uint64(5); uint32 callbackGasLimit = uint32(200001); - vm.expectRevert(); + vm.expectRevert(); chainlinkSourceAdaptor.configureRequests(keyHash, subId, callbackGasLimit); } } - contract ChainlinkOperationalTests is ChainlinkInitTests { error WaitForRandom(); error UnexpectedRandomWordsLength(uint256 _length); + event RequestId(uint256 _requestId); bytes32 public constant RAND1 = bytes32(uint256(0x1a)); @@ -127,7 +134,6 @@ contract ChainlinkOperationalTests is ChainlinkInitTests { uint256 requestId = abi.decode(entries[0].data, (uint256)); assertEq(fulfilmentIndex, requestId, "Must be the same"); - bool ready = chainlinkSourceAdaptor.isOffchainRandomReady(fulfilmentIndex); assertFalse(ready, "Should not be ready yet"); @@ -196,8 +202,6 @@ contract ChainlinkOperationalTests is ChainlinkInitTests { } } - - contract ChainlinkIntegrationTests is ChainlinkOperationalTests { function testEndToEnd() public { MockGame game = new MockGame(address(randomSeedProvider)); @@ -212,11 +216,19 @@ contract ChainlinkIntegrationTests is ChainlinkOperationalTests { assertEq(entries[0].topics[0], keccak256("RequestId(uint256)")); uint256 fulfilmentIndex = abi.decode(entries[0].data, (uint256)); - assertEq(uint256(game.isRandomValueReady(randomRequestId)), uint256(RandomValues.RequestStatus.IN_PROGRESS), "Should not be ready yet"); + assertEq( + uint256(game.isRandomValueReady(randomRequestId)), + uint256(RandomValues.RequestStatus.IN_PROGRESS), + "Should not be ready yet" + ); mockChainlinkCoordinator.sendFulfill(fulfilmentIndex, uint256(RAND1)); - assertEq(uint256(game.isRandomValueReady(randomRequestId)), uint256(RandomValues.RequestStatus.READY), "Should be ready"); + assertEq( + uint256(game.isRandomValueReady(randomRequestId)), + uint256(RandomValues.RequestStatus.READY), + "Should be ready" + ); bytes32[] memory randomValue = game.fetchRandomValues(randomRequestId); assertEq(randomValue.length, 1, "length"); @@ -245,9 +257,13 @@ contract ChainlinkCoverageFakeTests is ChainlinkInitTests { function testV2BaseChecksCoverage() public { MockCoordinator mockChainlinkCoordinator2 = new MockCoordinator(); mockChainlinkCoordinator2.setAdaptor(address(chainlinkSourceAdaptor)); - vm.expectRevert(abi.encodeWithSelector( - OnlyCoordinatorCanFulfill.selector, address(mockChainlinkCoordinator2), address(mockChainlinkCoordinator))); + vm.expectRevert( + abi.encodeWithSelector( + OnlyCoordinatorCanFulfill.selector, + address(mockChainlinkCoordinator2), + address(mockChainlinkCoordinator) + ) + ); mockChainlinkCoordinator2.sendFulfill(0, 0); } } - diff --git a/test/random/offchainsources/chainlink/MockCoordinator.sol b/test/random/offchainsources/chainlink/MockCoordinator.sol index a6d16757..6e7b7bf2 100644 --- a/test/random/offchainsources/chainlink/MockCoordinator.sol +++ b/test/random/offchainsources/chainlink/MockCoordinator.sol @@ -1,7 +1,8 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.19; -import {VRFCoordinatorV2Interface} from "../../../../contracts/random/offchainsources/chainlink/VRFCoordinatorV2Interface.sol"; +import {VRFCoordinatorV2Interface} from + "../../../../contracts/random/offchainsources/chainlink/VRFCoordinatorV2Interface.sol"; import {ChainlinkSourceAdaptor} from "../../../../contracts/random/offchainsources/chainlink/ChainlinkSourceAdaptor.sol"; contract MockCoordinator is VRFCoordinatorV2Interface { @@ -27,14 +28,11 @@ contract MockCoordinator is VRFCoordinatorV2Interface { adaptor.rawFulfillRandomWords(_requestId, _rand); } - - - function requestRandomWords(bytes32,uint64,uint16,uint32,uint32) external returns (uint256 requestId) { + function requestRandomWords(bytes32, uint64, uint16, uint32, uint32) external returns (uint256 requestId) { requestId = nextIndex++; emit RequestId(requestId); } - // Unused functions function getRequestConfig() external pure returns (uint16, uint32, bytes32[] memory) { @@ -46,18 +44,21 @@ contract MockCoordinator is VRFCoordinatorV2Interface { return subscriptionId; } - function getSubscription(uint64) external pure - returns (uint96 balance, uint64 reqCount, address owner, address[] memory consumers) { + function getSubscription(uint64) + external + pure + returns (uint96 balance, uint64 reqCount, address owner, address[] memory consumers) + { return (uint96(0), uint64(0), address(0), consumers); } function requestSubscriptionOwnerTransfer(uint64, address) external {} function acceptSubscriptionOwnerTransfer(uint64) external {} function addConsumer(uint64, address) external {} - function removeConsumer(uint64, address) external{} - function cancelSubscription(uint64, address) external{} + function removeConsumer(uint64, address) external {} + function cancelSubscription(uint64, address) external {} + function pendingRequestExists(uint64) external view returns (bool) { return pending; } } - diff --git a/test/random/offchainsources/supra/MockSupraRouter.sol b/test/random/offchainsources/supra/MockSupraRouter.sol index 9e7b3e85..cad61e49 100644 --- a/test/random/offchainsources/supra/MockSupraRouter.sol +++ b/test/random/offchainsources/supra/MockSupraRouter.sol @@ -28,27 +28,24 @@ contract MockSupraRouter is ISupraRouter { } function generateRequest( - string memory /* _functionSig */, - uint8 /* _rngCount */, - uint256 /* _numConfirmations */, + string memory, /* _functionSig */ + uint8, /* _rngCount */ + uint256, /* _numConfirmations */ address /* _clientWalletAddress */ ) external returns (uint256 requestId) { requestId = nextIndex++; emit RequestId(requestId); } - // Unused functions function generateRequest( - string memory /* _functionSig */, - uint8 /* _rngCount */, - uint256 /* _numConfirmations */, - uint256 /* _clientSeed */, + string memory, /* _functionSig */ + uint8, /* _rngCount */ + uint256, /* _numConfirmations */ + uint256, /* _clientSeed */ address /* _clientWalletAddress */ ) external returns (uint256 requestId) { requestId = nextIndex++; emit RequestId(requestId); } - } - diff --git a/test/random/offchainsources/supra/SupraSource.t.sol b/test/random/offchainsources/supra/SupraSource.t.sol index 75543fcd..c7f75c8d 100644 --- a/test/random/offchainsources/supra/SupraSource.t.sol +++ b/test/random/offchainsources/supra/SupraSource.t.sol @@ -35,29 +35,28 @@ contract SupraInitTests is Test { configAdmin = makeAddr("configAdmin"); upgradeAdmin = makeAddr("upgradeAdmin"); - impl = new RandomSeedProvider(); - proxy = new ERC1967Proxy(address(impl), - abi.encodeWithSelector(RandomSeedProvider.initialize.selector, roleAdmin, randomAdmin, upgradeAdmin, false)); + proxy = new ERC1967Proxy( + address(impl), + abi.encodeWithSelector(RandomSeedProvider.initialize.selector, roleAdmin, randomAdmin, upgradeAdmin, false) + ); randomSeedProvider = RandomSeedProvider(address(proxy)); mockSupraRouter = new MockSupraRouter(); - supraSourceAdaptor = new SupraSourceAdaptor( - roleAdmin, configAdmin, address(mockSupraRouter), subscription); + supraSourceAdaptor = new SupraSourceAdaptor(roleAdmin, configAdmin, address(mockSupraRouter), subscription); mockSupraRouter.setAdaptor(address(supraSourceAdaptor)); vm.prank(randomAdmin); randomSeedProvider.setOffchainRandomSource(address(supraSourceAdaptor)); - // Ensure we are on a new block number when we start the tests. In particular, don't + // Ensure we are on a new block number when we start the tests. In particular, don't // be on the same block number as when the contracts were deployed. vm.roll(block.number + 1); } function testInit() public { mockSupraRouter = new MockSupraRouter(); - supraSourceAdaptor = new SupraSourceAdaptor( - roleAdmin, configAdmin, address(mockSupraRouter), subscription); + supraSourceAdaptor = new SupraSourceAdaptor(roleAdmin, configAdmin, address(mockSupraRouter), subscription); assertEq(address(supraSourceAdaptor.vrfCoordinator()), address(mockSupraRouter), "vrfCoord not set correctly"); assertEq(supraSourceAdaptor.subscriptionAccount(), subscription, "Subscription account did not match"); @@ -65,7 +64,6 @@ contract SupraInitTests is Test { } } - contract SupraControlTests is SupraInitTests { event SubscriptionChange(address _newSubscription); @@ -98,13 +96,11 @@ contract SupraControlTests is SupraInitTests { function testSetSubscriptionBadAuth() public { address newSub = address(7); - vm.expectRevert(); + vm.expectRevert(); supraSourceAdaptor.setSubscription(newSub); } - } - contract SupraOperationalTests is SupraInitTests { error WaitForRandom(); error UnexpectedRandomWordsLength(uint256 _length); @@ -123,7 +119,6 @@ contract SupraOperationalTests is SupraInitTests { uint256 requestId = abi.decode(entries[0].data, (uint256)); assertEq(fulfilmentIndex, requestId, "Must be the same"); - bool ready = supraSourceAdaptor.isOffchainRandomReady(fulfilmentIndex); assertFalse(ready, "Should not be ready yet"); @@ -192,11 +187,8 @@ contract SupraOperationalTests is SupraInitTests { vm.expectRevert(abi.encodeWithSelector(NotVrfContract.selector)); hackSupraRouter.sendFulfill(fulfilmentIndex, uint256(RAND1)); } - } - - contract SupraIntegrationTests is SupraOperationalTests { function testEndToEnd() public { MockGame game = new MockGame(address(randomSeedProvider)); @@ -211,11 +203,19 @@ contract SupraIntegrationTests is SupraOperationalTests { assertEq(entries[0].topics[0], keccak256("RequestId(uint256)")); uint256 fulfilmentIndex = abi.decode(entries[0].data, (uint256)); - assertEq(uint256(game.isRandomValueReady(randomRequestId)), uint256(RandomValues.RequestStatus.IN_PROGRESS), "Should not be ready yet"); + assertEq( + uint256(game.isRandomValueReady(randomRequestId)), + uint256(RandomValues.RequestStatus.IN_PROGRESS), + "Should not be ready yet" + ); mockSupraRouter.sendFulfill(fulfilmentIndex, uint256(RAND1)); - assertEq(uint256(game.isRandomValueReady(randomRequestId)), uint256(RandomValues.RequestStatus.READY), "Should be ready"); + assertEq( + uint256(game.isRandomValueReady(randomRequestId)), + uint256(RandomValues.RequestStatus.READY), + "Should be ready" + ); bytes32[] memory randomValue = game.fetchRandomValues(randomRequestId); assertEq(randomValue.length, 1, "length"); @@ -224,19 +224,17 @@ contract SupraIntegrationTests is SupraOperationalTests { } contract SupraCoverageFakeTests is SupraInitTests { - // Do calls to unused functions in MockSupraRouter so that it doesn't impact the coverage results. + // Do calls to unused functions in MockSupraRouter so that it doesn't impact the coverage results. function testFixMockCoordinatorCoverage() public { mockSupraRouter = new MockSupraRouter(); mockSupraRouter.setAdaptor(address(supraSourceAdaptor)); string memory str = ""; mockSupraRouter.generateRequest( str, - uint8(0) /* _rngCount */, - uint256(0) /* _numConfirmations */, - uint256(0) /* _clientSeed */, + uint8(0), /* _rngCount */ + uint256(0), /* _numConfirmations */ + uint256(0), /* _clientSeed */ address(0) /* _clientWalletAddress */ ); - } } - diff --git a/test/token/erc1155/ImmutableERC1155.t.sol b/test/token/erc1155/ImmutableERC1155.t.sol index 354e1e41..fd282ea7 100644 --- a/test/token/erc1155/ImmutableERC1155.t.sol +++ b/test/token/erc1155/ImmutableERC1155.t.sol @@ -8,7 +8,7 @@ import {IImmutableERC1155Errors} from "../../../contracts/errors/Errors.sol"; import {OperatorAllowlistEnforcementErrors} from "../../../contracts/errors/Errors.sol"; import {OperatorAllowlistUpgradeable} from "../../../contracts/allowlist/OperatorAllowlistUpgradeable.sol"; import {Sign} from "../../utils/Sign.sol"; -import {DeployOperatorAllowlist} from "../../utils/DeployAllowlistProxy.sol"; +import {DeployOperatorAllowlist} from "../../utils/DeployAllowlistProxy.sol"; import {MockWallet} from "../../../contracts/mocks/MockWallet.sol"; import {MockWalletFactory} from "../../../contracts/mocks/MockWalletFactory.sol"; @@ -22,7 +22,6 @@ contract ImmutableERC1155Test is Test { MockWallet public anotherScw; address[] private operatorAddrs; - uint256 deployerPrivateKey = 1; uint256 ownerPrivateKey = 2; uint256 spenderPrivateKey = 3; @@ -51,13 +50,7 @@ contract ImmutableERC1155Test is Test { operatorAllowlist = OperatorAllowlistUpgradeable(proxyAddr); immutableERC1155 = new ImmutableERC1155( - owner, - "test", - "test-base-uri", - "test-contract-uri", - address(operatorAllowlist), - feeReceiver, - 0 + owner, "test", "test-base-uri", "test-contract-uri", address(operatorAllowlist), feeReceiver, 0 ); operatorAddrs.push(minter); @@ -156,7 +149,9 @@ contract ImmutableERC1155Test is Test { function test_RevertIfNonAdminAttemptsToSetContractURI() public { vm.prank(vm.addr(anotherPrivateKey)); - vm.expectRevert("AccessControl: account 0x1eff47bc3a10a45d4b230b5d10e37751fe6aa718 is missing role 0x0000000000000000000000000000000000000000000000000000000000000000"); + vm.expectRevert( + "AccessControl: account 0x1eff47bc3a10a45d4b230b5d10e37751fe6aa718 is missing role 0x0000000000000000000000000000000000000000000000000000000000000000" + ); immutableERC1155.setContractURI("new-contract-uri"); } @@ -168,7 +163,9 @@ contract ImmutableERC1155Test is Test { function test_RevertIfNonAdminAttemptsToSetBaseURI() public { vm.prank(vm.addr(anotherPrivateKey)); - vm.expectRevert("AccessControl: account 0x1eff47bc3a10a45d4b230b5d10e37751fe6aa718 is missing role 0x0000000000000000000000000000000000000000000000000000000000000000"); + vm.expectRevert( + "AccessControl: account 0x1eff47bc3a10a45d4b230b5d10e37751fe6aa718 is missing role 0x0000000000000000000000000000000000000000000000000000000000000000" + ); immutableERC1155.setBaseURI("new-base-uri"); } @@ -348,10 +345,10 @@ contract ImmutableERC1155Test is Test { vm.stopPrank(); } - /* - * Burn - */ - function test_Burn() public { + /* + * Burn + */ + function test_Burn() public { vm.prank(minter); immutableERC1155.safeMint(owner, 1, 1, ""); vm.prank(owner); diff --git a/test/token/erc20/preset/ImmutableERC20FixedSupplyNoBurn.t.sol b/test/token/erc20/preset/ImmutableERC20FixedSupplyNoBurn.t.sol index d809167e..db1065ff 100644 --- a/test/token/erc20/preset/ImmutableERC20FixedSupplyNoBurn.t.sol +++ b/test/token/erc20/preset/ImmutableERC20FixedSupplyNoBurn.t.sol @@ -6,9 +6,7 @@ import "forge-std/Test.sol"; import {ImmutableERC20FixedSupplyNoBurn} from "contracts/token/erc20/preset/ImmutableERC20FixedSupplyNoBurn.sol"; import {IImmutableERC20Errors} from "contracts/token/erc20/preset/Errors.sol"; - contract ImmutableERC20FixedSupplyNoBurnTest is Test { - ImmutableERC20FixedSupplyNoBurn public erc20; address public treasurer; @@ -48,5 +46,4 @@ contract ImmutableERC20FixedSupplyNoBurnTest is Test { vm.expectRevert(abi.encodeWithSelector(IImmutableERC20Errors.RenounceOwnershipNotAllowed.selector)); erc20.renounceOwnership(); } - } diff --git a/test/token/erc20/preset/ImmutableERC20MinterBurnerPermit.t.sol b/test/token/erc20/preset/ImmutableERC20MinterBurnerPermit.t.sol index 7452e119..b601a189 100644 --- a/test/token/erc20/preset/ImmutableERC20MinterBurnerPermit.t.sol +++ b/test/token/erc20/preset/ImmutableERC20MinterBurnerPermit.t.sol @@ -6,9 +6,7 @@ import "forge-std/Test.sol"; import {ImmutableERC20MinterBurnerPermit} from "contracts/token/erc20/preset/ImmutableERC20MinterBurnerPermit.sol"; import {IImmutableERC20Errors} from "contracts/token/erc20/preset/Errors.sol"; - contract ImmutableERC20MinterBurnerPermitTest is Test { - ImmutableERC20MinterBurnerPermit public erc20; address public minter; @@ -86,7 +84,9 @@ contract ImmutableERC20MinterBurnerPermitTest is Test { address to = makeAddr("to"); uint256 amount = 100; vm.prank(hubOwner); - vm.expectRevert("AccessControl: account 0xa268ae5516b47694c3f15805a560258dbcdefd08 is missing role 0x4d494e5445525f524f4c45000000000000000000000000000000000000000000"); + vm.expectRevert( + "AccessControl: account 0xa268ae5516b47694c3f15805a560258dbcdefd08 is missing role 0x4d494e5445525f524f4c45000000000000000000000000000000000000000000" + ); erc20.mint(to, amount); } @@ -144,16 +144,7 @@ contract ImmutableERC20MinterBurnerPermitTest is Test { uint256 deadline = block.timestamp + 1 days; uint256 nonce = erc20.nonces(owner); - bytes32 structHash = keccak256( - abi.encode( - PERMIT_TYPEHASH, - owner, - spender, - value, - nonce, - deadline - ) - ); + bytes32 structHash = keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonce, deadline)); bytes32 hash = erc20.DOMAIN_SEPARATOR(); hash = keccak256(abi.encodePacked("\x19\x01", hash, structHash)); (uint8 v, bytes32 r, bytes32 s) = vm.sign(ownerPrivateKey, hash); @@ -164,6 +155,4 @@ contract ImmutableERC20MinterBurnerPermitTest is Test { assertEq(erc20.allowance(owner, spender), value); } - - } diff --git a/test/trading/seaport/utils/IImmutableERC721.t.sol b/test/trading/seaport/utils/IImmutableERC721.t.sol index c03f9a12..1156c98e 100644 --- a/test/trading/seaport/utils/IImmutableERC721.t.sol +++ b/test/trading/seaport/utils/IImmutableERC721.t.sol @@ -10,13 +10,15 @@ import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol"; * @notice Interface for Immutable's ERC721 */ interface IImmutableERC721 is IERC721 { - /** @notice Allows minter to mint `tokenID` to `to` + /** + * @notice Allows minter to mint `tokenID` to `to` * @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 admin grant `user` `MINTER` role + /** + * @notice Allows admin grant `user` `MINTER` role * @param user The address to grant the `MINTER` role to */ function grantMinterRole(address user) external; diff --git a/test/trading/seaport/zones/immutable-signed-zone/v2/ImmutableSignedZoneV2.t.sol b/test/trading/seaport/zones/immutable-signed-zone/v2/ImmutableSignedZoneV2.t.sol index 7dabed13..ffc4da87 100644 --- a/test/trading/seaport/zones/immutable-signed-zone/v2/ImmutableSignedZoneV2.t.sol +++ b/test/trading/seaport/zones/immutable-signed-zone/v2/ImmutableSignedZoneV2.t.sol @@ -53,10 +53,7 @@ contract ImmutableSignedZoneV2Test is function test_contructor_grantsAdminRoleToOwner() public { address owner = makeAddr("owner"); ImmutableSignedZoneV2 zone = new ImmutableSignedZoneV2( - "MyZoneName", - "https://www.immutable.com", - "https://www.immutable.com/docs", - owner + "MyZoneName", "https://www.immutable.com", "https://www.immutable.com/docs", owner ); bool ownerHasAdminRole = zone.hasRole(zone.DEFAULT_ADMIN_ROLE(), owner); assertTrue(ownerHasAdminRole); @@ -66,10 +63,7 @@ contract ImmutableSignedZoneV2Test is vm.expectEmit(); emit SeaportCompatibleContractDeployed(); new ImmutableSignedZoneV2( - "MyZoneName", - "https://www.immutable.com", - "https://www.immutable.com/docs", - makeAddr("owner") + "MyZoneName", "https://www.immutable.com", "https://www.immutable.com/docs", makeAddr("owner") ); } @@ -345,12 +339,8 @@ contract ImmutableSignedZoneV2Test is string memory expectedApiEndpoint = "https://www.immutable.com"; string memory expectedDocumentationURI = "https://www.immutable.com/docs"; - ImmutableSignedZoneV2Harness zone = new ImmutableSignedZoneV2Harness( - expectedZoneName, - expectedApiEndpoint, - expectedDocumentationURI, - OWNER - ); + ImmutableSignedZoneV2Harness zone = + new ImmutableSignedZoneV2Harness(expectedZoneName, expectedApiEndpoint, expectedDocumentationURI, OWNER); bytes32 expectedDomainSeparator = zone.exposed_deriveDomainSeparator(); uint256[] memory expectedSubstandards = zone.exposed_getSupportedSubstandards(); @@ -378,12 +368,8 @@ contract ImmutableSignedZoneV2Test is string memory expectedApiEndpoint = "https://www.immutable.com"; string memory expectedDocumentationURI = "https://www.immutable.com/docs"; - ImmutableSignedZoneV2Harness zone = new ImmutableSignedZoneV2Harness( - "MyZoneName", - expectedApiEndpoint, - expectedDocumentationURI, - OWNER - ); + ImmutableSignedZoneV2Harness zone = + new ImmutableSignedZoneV2Harness("MyZoneName", expectedApiEndpoint, expectedDocumentationURI, OWNER); bytes32 expectedDomainSeparator = zone.exposed_deriveDomainSeparator(); uint256[] memory expectedSubstandards = zone.exposed_getSupportedSubstandards(); @@ -455,7 +441,7 @@ contract ImmutableSignedZoneV2Test is consideration: new ReceivedItem[](0), extraData: bytes( hex"01f39fd6e51aad88f6f4ce6ab8827279cfffb9226600000000660f3027d9ef9e6e50a74cc24433373b9cdd97693a02adcc94e562bb59a5af68190ecaea4414dcbe74618f6c77d11cbcf4a8345bbdf46e665249904925c95929ba6606638b779c6b502204fca6bb0539cdc3dc258fe3ce7b53be0c4ad620899167fedaa8" - ), + ), orderHashes: new bytes32[](0), startTime: 0, endTime: 0, @@ -608,7 +594,8 @@ contract ImmutableSignedZoneV2Test is bytes32[] memory orderHashes = new bytes32[](1); orderHashes[0] = bytes32(0x43592598d0419e49d268e9b553427fd7ba1dd091eaa3f6127161e44afb7b40f9); - bytes memory extraData = _buildExtraDataWithoutContext(zone, SIGNER_PRIVATE_KEY, FULFILLER, expiration, orderHash, new bytes(0)); + bytes memory extraData = + _buildExtraDataWithoutContext(zone, SIGNER_PRIVATE_KEY, FULFILLER, expiration, orderHash, new bytes(0)); ZoneParameters memory zoneParameters = ZoneParameters({ orderHash: bytes32(0x43592598d0419e49d268e9b553427fd7ba1dd091eaa3f6127161e44afb7b40f9), @@ -624,7 +611,9 @@ contract ImmutableSignedZoneV2Test is }); vm.expectRevert( - abi.encodeWithSelector(InvalidExtraData.selector, "invalid context, no substandards present", zoneParameters.orderHash) + abi.encodeWithSelector( + InvalidExtraData.selector, "invalid context, no substandards present", zoneParameters.orderHash + ) ); zone.validateOrder(zoneParameters); } @@ -760,7 +749,7 @@ contract ImmutableSignedZoneV2Test is zoneHash: bytes32(0) }); - vm.expectRevert( + vm.expectRevert( abi.encodeWithSelector( InvalidExtraData.selector, "invalid context, no substandards present", zoneParameters.orderHash ) @@ -1479,19 +1468,13 @@ contract ImmutableSignedZoneV2Test is function _newZone(address owner) private returns (ImmutableSignedZoneV2) { return new ImmutableSignedZoneV2( - "MyZoneName", - "https://www.immutable.com", - "https://www.immutable.com/docs", - owner + "MyZoneName", "https://www.immutable.com", "https://www.immutable.com/docs", owner ); } function _newZoneHarness(address owner) private returns (ImmutableSignedZoneV2Harness) { return new ImmutableSignedZoneV2Harness( - "MyZoneName", - "https://www.immutable.com", - "https://www.immutable.com/docs", - owner + "MyZoneName", "https://www.immutable.com", "https://www.immutable.com/docs", owner ); } diff --git a/test/utils/DeployAllowlistProxy.sol b/test/utils/DeployAllowlistProxy.sol index 322d2621..f75359ea 100644 --- a/test/utils/DeployAllowlistProxy.sol +++ b/test/utils/DeployAllowlistProxy.sol @@ -10,17 +10,11 @@ contract DeployOperatorAllowlist { OperatorAllowlistUpgradeable impl = new OperatorAllowlistUpgradeable(); bytes memory initData = abi.encodeWithSelector( - OperatorAllowlistUpgradeable.initialize.selector, - admin, - upgradeAdmin, - registerarAdmin + OperatorAllowlistUpgradeable.initialize.selector, admin, upgradeAdmin, registerarAdmin ); - ERC1967Proxy proxy = new ERC1967Proxy( - address(impl), - initData - ); + ERC1967Proxy proxy = new ERC1967Proxy(address(impl), initData); return address(proxy); } -} \ No newline at end of file +} diff --git a/test/utils/DeployMockMarketPlace.sol b/test/utils/DeployMockMarketPlace.sol index ec8764b7..bdf3e118 100644 --- a/test/utils/DeployMockMarketPlace.sol +++ b/test/utils/DeployMockMarketPlace.sol @@ -3,11 +3,10 @@ pragma solidity ^0.8.19; import {MockMarketplace} from "../../contracts/mocks/MockMarketplace.sol"; - /// Deploys the OperatorAllowlistUpgradeable contract behind an ERC1967 Proxy and returns the address of the proxy contract DeployMockMarketPlace { function run(address erc721Address) external returns (MockMarketplace) { MockMarketplace marketplace = new MockMarketplace(erc721Address); return marketplace; } -} \ No newline at end of file +} diff --git a/test/utils/DeploySCW.sol b/test/utils/DeploySCW.sol index 97a7b222..7229c190 100644 --- a/test/utils/DeploySCW.sol +++ b/test/utils/DeploySCW.sol @@ -1,4 +1,3 @@ - // SPDX-License-Identifier: Apache 2.0 pragma solidity 0.8.19; @@ -20,4 +19,4 @@ contract DeploySCWallet { scw = MockWallet(scwAddress); return (scwAddress, address(mockWalletModule)); } -} \ No newline at end of file +} diff --git a/test/utils/Sign.sol b/test/utils/Sign.sol index 8ed438eb..8c4a88a7 100644 --- a/test/utils/Sign.sol +++ b/test/utils/Sign.sol @@ -12,12 +12,12 @@ contract Sign { _DOMAIN_SEPARATOR = DOMAIN_SEPARATOR_; } - function buildPermitDigest(address owner, address spender, bool approved, uint256 nonce, uint256 deadline) public view returns (bytes32) { - bytes32 structHash = keccak256( - abi.encode( - _PERMIT_TYPEHASH, owner, spender, approved, nonce, deadline - ) - ); + function buildPermitDigest(address owner, address spender, bool approved, uint256 nonce, uint256 deadline) + public + view + returns (bytes32) + { + bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, approved, nonce, deadline)); return keccak256(abi.encodePacked("\x19\x01", _DOMAIN_SEPARATOR, structHash)); } }