From c28881c5fb42f252f7d3d9b3b14476f3d5469750 Mon Sep 17 00:00:00 2001 From: jasonzwli <134979033+jasonzwli@users.noreply.github.com> Date: Mon, 28 Aug 2023 09:44:20 +0900 Subject: [PATCH] [gms-1004][chore] add comments to contracts (#72) --- .../token/erc721/abstract/ERC721Hybrid.sol | 231 ++++++++++-------- .../token/erc721/preset/ImmutableERC721.sol | 27 ++ .../erc721/preset/ImmutableERC721MintByID.sol | 9 - ...leERC721HybridPermissionedMintable.test.ts | 30 +-- ...mmutableERC721PermissionedMintable.test.ts | 34 ++- 5 files changed, 187 insertions(+), 144 deletions(-) diff --git a/contracts/token/erc721/abstract/ERC721Hybrid.sol b/contracts/token/erc721/abstract/ERC721Hybrid.sol index 65462fb7..ad7602cd 100644 --- a/contracts/token/erc721/abstract/ERC721Hybrid.sol +++ b/contracts/token/erc721/abstract/ERC721Hybrid.sol @@ -22,8 +22,6 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err uint256 private _idMintTotalSupply = 0; /// @dev A mapping of tokens ids before the threshold that have been burned to prevent re-minting - //mapping(uint256 => bool) public _burnedTokens; - BitMaps.BitMap private _burnedTokens; /// @dev A singular batch transfer request @@ -33,33 +31,52 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err uint256[] tokenIds; } + /// @dev A singular safe burn request. + struct IDBurn { + address owner; + uint256[] tokenIds; + } + + /// @dev A singular Mint by quantity request + struct Mint { + address to; + uint256 quantity; + } + + /// @dev A singular Mint by id request + struct IDMint { + address to; + uint256[] tokenIds; + } + constructor( string memory name_, string memory symbol_ ) ERC721(name_, symbol_) ERC721Psi(name_, symbol_) {} + /** @dev returns the threshold that divides tokens that are minted by id and + * minted by quantity + **/ function bulkMintThreshold() public pure virtual returns (uint256) { return 2**64; } + /// @dev returns the startTokenID for the minting by quantity section of the contract function _startTokenId() internal pure virtual override(ERC721Psi) returns (uint256) { return bulkMintThreshold(); } - // Optimised minting functions - struct Mint { - address to; - uint256 quantity; - } - + /// @dev mints number of tokens specified to the address given via erc721psi function _mintByQuantity(address to, uint256 quantity) internal { ERC721Psi._mint(to, quantity); } + /// @dev safe mints number of tokens specified to the address given via erc721psi function _safeMintByQuantity(address to, uint256 quantity) internal { ERC721Psi._safeMint(to, quantity); } + /// @dev mints number of tokens specified to a multiple specified addresses via erc721psi function _mintBatchByQuantity(Mint[] memory mints) internal { for (uint i = 0; i < mints.length; i++) { Mint memory m = mints[i]; @@ -67,6 +84,7 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err } } + /// @dev safe mints number of tokens specified to a multiple specified addresses via erc721psi function _safeMintBatchByQuantity(Mint[] memory mints) internal { for (uint i = 0; i < mints.length; i++) { Mint memory m = mints[i]; @@ -74,6 +92,7 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err } } + /// @dev mints by id to a specified address via erc721 function _mintByID(address to, uint256 tokenId) internal { if (tokenId >= bulkMintThreshold()){ revert IImmutableERC721IDAboveThreshold(tokenId); @@ -86,6 +105,7 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err _idMintTotalSupply++; } + /// @dev safe mints by id to a specified address via erc721 function _safeMintByID(address to, uint256 tokenId) internal { if (tokenId >= bulkMintThreshold()){ revert IImmutableERC721IDAboveThreshold(tokenId); @@ -98,23 +118,21 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err _idMintTotalSupply++; } + /// @dev mints multiple tokens by id to a specified address via erc721 function _mintBatchByID(address to, uint256[] memory tokenIds) internal { for (uint i = 0; i < tokenIds.length; i++) { _mintByID(to, tokenIds[i]); } } + /// @dev safe mints multiple tokens by id to a specified address via erc721 function _safeMintBatchByID(address to, uint256[] memory tokenIds) internal { for (uint i = 0; i < tokenIds.length; i++) { _safeMintByID(to, tokenIds[i]); } } - struct IDMint { - address to; - uint256[] tokenIds; - } - + /// @dev mints multiple tokens by id to multiple specified addresses via erc721 function _mintBatchByIDToMultiple(IDMint[] memory mints) internal { for (uint i = 0; i < mints.length; i++) { IDMint memory m = mints[i]; @@ -122,6 +140,7 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err } } + /// @dev safe mints multiple tokens by id to multiple specified addresses via erc721 function _safeMintBatchByIDToMultiple(IDMint[] memory mints) internal { for (uint i = 0; i < mints.length; i++) { IDMint memory m = mints[i]; @@ -129,12 +148,50 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err } } + /// @dev checks to see if tokenID exists in the collection function exists(uint256 tokenId) public view virtual returns (bool) { return _exists(tokenId); } - // Overwritten functions from ERC721/ERC721Psi with split routing + /// @dev allows caller to burn a token by id + function burn(uint256 tokenId) public virtual { + if (!_isApprovedOrOwner(_msgSender(), tokenId)) { + revert IImmutableERC721NotOwnerOrOperator(tokenId); + } + _burn(tokenId); + } + + /// @dev allows caller to burn multiple tokens by id + function burnBatch(uint256[] calldata tokenIDs) external { + for (uint i = 0; i < tokenIDs.length; i++) { + burn(tokenIDs[i]); + } + } + + /// @dev Burn a token, checking the owner of the token against the parameter first. + function safeBurn(address owner, uint256 tokenId) public virtual { + address currentOwner = ownerOf(tokenId); + if (currentOwner != owner) { + revert IImmutableERC721MismatchedTokenOwner(tokenId, currentOwner); + } + + burn(tokenId); + } + + /// @dev Burn a batch of tokens, checking the owner of each token first. + function _safeBurnBatch(IDBurn[] memory burns) internal { + for (uint i = 0; i < burns.length; i++) { + IDBurn memory b = burns[i]; + for (uint j = 0; j < b.tokenIds.length; j++) { + safeBurn(b.owner, b.tokenIds[j]); + } + } + } + /** @dev All methods below are overwritten functions from ERC721/ERC721Psi with split routing + * if the token id in the param is below the threshold the erc721 method is invoked. Else + * the erc721psi method is invoked. They then behave like their specified ancestors methods. + **/ function _exists(uint256 tokenId) internal view virtual override(ERC721, ERC721PsiBurnable) returns (bool) { if (tokenId < bulkMintThreshold()) { @@ -158,6 +215,9 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err return ERC721Psi.ownerOf(tokenId); } + /** @dev 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 + **/ function _burn(uint256 tokenId) internal virtual override(ERC721, ERC721PsiBurnable) { if (tokenId < bulkMintThreshold()) { ERC721._burn(tokenId); @@ -168,64 +228,88 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err } } - function burn(uint256 tokenId) public virtual { - if (!_isApprovedOrOwner(_msgSender(), tokenId)) { - revert IImmutableERC721NotOwnerOrOperator(tokenId); + function _approve(address to, uint256 tokenId) internal virtual override(ERC721, ERC721Psi) { + if (tokenId < bulkMintThreshold()) { + return ERC721._approve(to, tokenId); } - _burn(tokenId); + return ERC721Psi._approve(to, tokenId); } - function burnBatch(uint256[] calldata tokenIDs) external { - for (uint i = 0; i < tokenIDs.length; i++) { - burn(tokenIDs[i]); + function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual override(ERC721, ERC721Psi) returns (bool) { + if (tokenId < bulkMintThreshold()) { + return ERC721._isApprovedOrOwner(spender, tokenId); } + return ERC721Psi._isApprovedOrOwner(spender, tokenId); } - /// @dev Burn a token, checking the owner of the token against the parameter first. - function safeBurn(address owner, uint256 tokenId) public virtual { - address currentOwner = ownerOf(tokenId); - if (currentOwner != owner) { - revert IImmutableERC721MismatchedTokenOwner(tokenId, currentOwner); + function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual override(ERC721, ERC721Psi) { + if (tokenId < bulkMintThreshold()) { + return ERC721._safeTransfer(from, to, tokenId, _data); } + return ERC721Psi._safeTransfer(from, to, tokenId, _data); + } - burn(tokenId); + function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override(ERC721, ERC721Psi) { + if (tokenId < bulkMintThreshold()) { + return ERC721.safeTransferFrom(from, to, tokenId, _data); + } + return ERC721Psi.safeTransferFrom(from, to, tokenId, _data); } - /// @dev A singular safe burn request. - struct IDBurn { - address owner; - uint256[] tokenIds; + function isApprovedForAll(address owner, address operator) public view virtual override(ERC721, ERC721Psi) returns (bool) { + return ERC721.isApprovedForAll(owner, operator); } - /// @dev Burn a batch of tokens, checking the owner of each token first. - function _safeBurnBatch(IDBurn[] memory burns) internal { - for (uint i = 0; i < burns.length; i++) { - IDBurn memory b = burns[i]; - for (uint j = 0; j < b.tokenIds.length; j++) { - safeBurn(b.owner, b.tokenIds[j]); - } + function getApproved(uint256 tokenId) public view virtual override(ERC721, ERC721Psi) returns (address) { + if (tokenId < bulkMintThreshold()) { + return ERC721.getApproved(tokenId); + } + return ERC721Psi.getApproved(tokenId); + } + + function approve(address to, uint256 tokenId) public virtual override(ERC721, ERC721Psi) { + if (tokenId < bulkMintThreshold()) { + return ERC721.approve(to, tokenId); } + return ERC721Psi.approve(to, tokenId); + } + + function transferFrom(address from, address to, uint256 tokenId) public virtual override(ERC721, ERC721Psi) { + if (tokenId < bulkMintThreshold()) { + return ERC721.transferFrom(from, to, tokenId); + } + return ERC721Psi.transferFrom(from, to, tokenId); } - /// @dev overriding erc721 and erc721psi _safemint, super calls the `_safeMint` method of - /// the erc721 implementation due to inheritance linearisation + /** @dev methods below are overwritten to always invoke the erc721 equivalent due to linearisation + they do not get invoked by any minting methods in this contract and are only overwritten to satisfy + the compiler + */ + + /** @dev overriding erc721 and erc721psi _safemint, super calls the `_safeMint` method of + * the erc721 implementation due to inheritance linearisation + **/ function _safeMint(address to, uint256 tokenId) internal virtual override(ERC721, ERC721Psi) { super._safeMint(to, tokenId); } - /// @dev overriding erc721 and erc721psi _safemint, super calls the `_safeMint` method of - /// the erc721 implementation due to inheritance linearisation + /** @dev overriding erc721 and erc721psi _safemint, super calls the `_safeMint` method of + * the erc721 implementation due to inheritance linearisation + **/ function _safeMint(address to, uint256 tokenId, bytes memory _data) internal virtual override(ERC721, ERC721Psi) { super._safeMint(to, tokenId, _data); } - /// @dev overriding erc721 and erc721psi _safemint, super calls the `_mint` method of - /// the erc721 implementation due to inheritance linearisation + /** @dev overriding erc721 and erc721psi _safemint, super calls the `_mint` method of + * the erc721 implementation due to inheritance linearisation + **/ function _mint(address to, uint256 tokenId) internal virtual override(ERC721, ERC721Psi) { super._mint(to, tokenId); } - // Overwritten functions with combined implementations + /** @dev 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 (uint) { return ERC721.balanceOf(owner) + ERC721Psi.balanceOf(owner); @@ -235,7 +319,9 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err return ERC721PsiBurnable.totalSupply() + _idMintTotalSupply; } - // Overwritten functions with direct routing + /** @dev Overwritten functions with direct routing. The metadata of the collect remains the same regardless + * of the minting strategy used for the tokenID + **/ function tokenURI(uint256 tokenId) public view virtual override(ERC721, ERC721Psi) returns (string memory) { return ERC721.tokenURI(tokenId); @@ -257,27 +343,6 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err return ERC721._baseURI(); } - function _approve(address to, uint256 tokenId) internal virtual override(ERC721, ERC721Psi) { - if (tokenId < bulkMintThreshold()) { - return ERC721._approve(to, tokenId); - } - return ERC721Psi._approve(to, tokenId); - } - - function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual override(ERC721, ERC721Psi) returns (bool) { - if (tokenId < bulkMintThreshold()) { - return ERC721._isApprovedOrOwner(spender, tokenId); - } - return ERC721Psi._isApprovedOrOwner(spender, tokenId); - } - - function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual override(ERC721, ERC721Psi) { - if (tokenId < bulkMintThreshold()) { - return ERC721._safeTransfer(from, to, tokenId, _data); - } - return ERC721Psi._safeTransfer(from, to, tokenId, _data); - } - function setApprovalForAll(address operator, bool approved) public virtual override(ERC721, ERC721Psi) { return ERC721.setApprovalForAll(operator, approved); } @@ -285,36 +350,4 @@ abstract contract ERC721Hybrid is ERC721PsiBurnable, ERC721, IImmutableERC721Err function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override(ERC721, ERC721Psi) { safeTransferFrom(from, to, tokenId, ""); } - - function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override(ERC721, ERC721Psi) { - if (tokenId < bulkMintThreshold()) { - return ERC721.safeTransferFrom(from, to, tokenId, _data); - } - return ERC721Psi.safeTransferFrom(from, to, tokenId, _data); - } - - function isApprovedForAll(address owner, address operator) public view virtual override(ERC721, ERC721Psi) returns (bool) { - return ERC721.isApprovedForAll(owner, operator); - } - - function getApproved(uint256 tokenId) public view virtual override(ERC721, ERC721Psi) returns (address) { - if (tokenId < bulkMintThreshold()) { - return ERC721.getApproved(tokenId); - } - return ERC721Psi.getApproved(tokenId); - } - - function approve(address to, uint256 tokenId) public virtual override(ERC721, ERC721Psi) { - if (tokenId < bulkMintThreshold()) { - return ERC721.approve(to, tokenId); - } - return ERC721Psi.approve(to, tokenId); - } - - function transferFrom(address from, address to, uint256 tokenId) public virtual override(ERC721, ERC721Psi) { - if (tokenId < bulkMintThreshold()) { - return ERC721.transferFrom(from, to, tokenId); - } - return ERC721Psi.transferFrom(from, to, tokenId); - } } diff --git a/contracts/token/erc721/preset/ImmutableERC721.sol b/contracts/token/erc721/preset/ImmutableERC721.sol index 0c51b253..1ba0c09d 100644 --- a/contracts/token/erc721/preset/ImmutableERC721.sol +++ b/contracts/token/erc721/preset/ImmutableERC721.sol @@ -7,7 +7,16 @@ import { MintingAccessControl } from "../abstract/MintingAccessControl.sol"; import { ImmutableERC721HybridBase } from "../abstract/ImmutableERC721HybridBase.sol"; contract ImmutableERC721 is ImmutableERC721HybridBase { + /// ===== Constructor ===== + /** + * @dev Grants `DEFAULT_ADMIN_ROLE` to the supplied `owner` address + * + * Sets the name and symbol for the collection + * Sets the default admin to `owner` + * Sets the `baseURI` and `tokenURI` + * Sets the royalty receiver and amount (this can not be changed once set) + */ constructor( address owner_, string memory name_, @@ -21,42 +30,60 @@ contract ImmutableERC721 is ImmutableERC721HybridBase { ImmutableERC721HybridBase(owner_, name_, symbol_, baseURI_, contractURI_, royaltyAllowlist_, royaltyReceiver_, feeNumerator_) {} + /// @dev Allows minter to a token by ID to a specified address function mint(address to, uint256 tokenId) external onlyRole(MINTER_ROLE) { _mintByID(to, tokenId); } + /// @dev Allows minter to a token by ID to a specified address with hooks and checks function safeMint(address to, uint256 tokenId) external onlyRole(MINTER_ROLE) { _safeMintByID(to, tokenId); } + /// @dev Allows minter to a number of tokens sequentially to a specified address function mintByQuantity(address to, uint256 quantity) external onlyRole(MINTER_ROLE) { _mintByQuantity(to, quantity); } + /** @dev Allows minter to a number of tokens sequentially to a specified address with hooks + * and checks + **/ function safeMintByQuantity(address to, uint256 quantity) external onlyRole(MINTER_ROLE) { _safeMintByQuantity(to, quantity); } + /// @dev Allows minter to a number of tokens sequentially to a number of specified addresses function mintBatchByQuantity(Mint[] memory mints) external onlyRole(MINTER_ROLE) { _mintBatchByQuantity(mints); } + /** @dev Allows minter to a number of tokens sequentially to a number of specified + * addresses with hooks and checks + **/ function safeMintBatchByQuantity(Mint[] memory mints) external onlyRole(MINTER_ROLE) { _safeMintBatchByQuantity(mints); } + /// @dev Allows minter to a number of tokens by ID to a number of specified addresses function mintBatch(IDMint[] memory mints) external onlyRole(MINTER_ROLE) { _mintBatchByIDToMultiple(mints); } + /** @dev Allows minter to a number of tokens by ID to a number of specified + * addresses with hooks and checks + **/ function safeMintBatch(IDMint[] memory mints) external onlyRole(MINTER_ROLE) { _safeMintBatchByIDToMultiple(mints); } + /// @dev Allows caller to a burn a number of tokens by ID from a specified address function safeBurnBatch(IDBurn[] memory burns) external { _safeBurnBatch(burns); } + /** @dev Allows caller to a transfer a number of tokens by ID from a specified + * address to a number of specified addresses + **/ function safeTransferFromBatch(TransferRequest calldata tr) external { if (tr.tokenIds.length != tr.tos.length) { revert IImmutableERC721MismatchedTransferLengths(); diff --git a/contracts/token/erc721/preset/ImmutableERC721MintByID.sol b/contracts/token/erc721/preset/ImmutableERC721MintByID.sol index 3fffec45..3da993f5 100644 --- a/contracts/token/erc721/preset/ImmutableERC721MintByID.sol +++ b/contracts/token/erc721/preset/ImmutableERC721MintByID.sol @@ -38,15 +38,6 @@ contract ImmutableERC721MintByID is ImmutableERC721Base { ) {} - /// ===== View functions ===== - - /// @dev Returns the supported interfaces - function supportsInterface( - bytes4 interfaceId - ) public view virtual override(ImmutableERC721Base) returns (bool) { - return super.supportsInterface(interfaceId); - } - /// ===== External functions ===== /// @dev Allows minter to mint `tokenID` to `to` diff --git a/test/token/erc721/ImmutableERC721HybridPermissionedMintable.test.ts b/test/token/erc721/ImmutableERC721HybridPermissionedMintable.test.ts index 9f56b467..e8c198fc 100644 --- a/test/token/erc721/ImmutableERC721HybridPermissionedMintable.test.ts +++ b/test/token/erc721/ImmutableERC721HybridPermissionedMintable.test.ts @@ -163,25 +163,23 @@ describe("ImmutableERC721", function () { ); }); - it("Should not allow owner or approved to burn a token when specifying the incorrect owner", async function() { - await expect( - erc721.connect(user).safeBurn(owner.address, 5) - ).to.be.revertedWith('IImmutableERC721MismatchedTokenOwner').withArgs(5, user.address); + it("Should not allow owner or approved to burn a token when specifying the incorrect owner", async function () { + await expect(erc721.connect(user).safeBurn(owner.address, 5)) + .to.be.revertedWith("IImmutableERC721MismatchedTokenOwner") + .withArgs(5, user.address); }); - it("Should allow owner or approved to safely burn a token when specifying the correct owner", async function() { + it("Should allow owner or approved to safely burn a token when specifying the correct owner", async function () { const originalBalance = await erc721.balanceOf(user.address); const originalSupply = await erc721.totalSupply(); await erc721.connect(user).safeBurn(user.address, 5); expect(await erc721.balanceOf(user.address)).to.equal( originalBalance.sub(1) ); - expect(await erc721.totalSupply()).to.equal( - originalSupply.sub(1) - ); + expect(await erc721.totalSupply()).to.equal(originalSupply.sub(1)); }); - it("Should not allow owner or approved to burn a batch of tokens when specifying the incorrect owners", async function() { + it("Should not allow owner or approved to burn a batch of tokens when specifying the incorrect owners", async function () { const burns = [ { owner: user.address, @@ -192,12 +190,12 @@ describe("ImmutableERC721", function () { tokenIds: [9, 10, 11], }, ]; - await expect( - erc721.connect(user).safeBurnBatch(burns) - ).to.be.revertedWith('IImmutableERC721MismatchedTokenOwner').withArgs(12, owner.address); + await expect(erc721.connect(user).safeBurnBatch(burns)) + .to.be.revertedWith("IImmutableERC721MismatchedTokenOwner") + .withArgs(12, owner.address); }); - it("Should allow owner or approved to safely burn a batch of tokens when specifying the correct owners", async function() { + it("Should allow owner or approved to safely burn a batch of tokens when specifying the correct owners", async function () { const originalUserBalance = await erc721.balanceOf(user.address); const originalOwnerBalance = await erc721.balanceOf(owner.address); const originalSupply = await erc721.totalSupply(); @@ -206,7 +204,7 @@ describe("ImmutableERC721", function () { await erc721.connect(user).approve(owner.address, 9); await erc721.connect(user).approve(owner.address, 10); await erc721.connect(user).approve(owner.address, 11); - + const burns = [ { owner: owner.address, @@ -224,9 +222,7 @@ describe("ImmutableERC721", function () { expect(await erc721.balanceOf(owner.address)).to.equal( originalOwnerBalance.sub(3) ); - expect(await erc721.totalSupply()).to.equal( - originalSupply.sub(6) - ); + expect(await erc721.totalSupply()).to.equal(originalSupply.sub(6)); }); it("Should prevent not approved to burn a batch of tokens", async function () { diff --git a/test/token/erc721/ImmutableERC721PermissionedMintable.test.ts b/test/token/erc721/ImmutableERC721PermissionedMintable.test.ts index c659de1b..4e61aa82 100644 --- a/test/token/erc721/ImmutableERC721PermissionedMintable.test.ts +++ b/test/token/erc721/ImmutableERC721PermissionedMintable.test.ts @@ -138,25 +138,23 @@ describe("Immutable ERC721 Permissioned Mintable Test Cases", function () { .withArgs(1); }); - it("Should not allow owner or approved to safely burn a token when specifying the incorrect owner", async function() { - await expect( - erc721.connect(user).safeBurn(owner.address, 3) - ).to.be.revertedWith('IImmutableERC721MismatchedTokenOwner').withArgs(3, user.address); + it("Should not allow owner or approved to safely burn a token when specifying the incorrect owner", async function () { + await expect(erc721.connect(user).safeBurn(owner.address, 3)) + .to.be.revertedWith("IImmutableERC721MismatchedTokenOwner") + .withArgs(3, user.address); }); - it("Should allow owner or approved to safely burn a token when specifying the correct owner", async function() { + it("Should allow owner or approved to safely burn a token when specifying the correct owner", async function () { const originalBalance = await erc721.balanceOf(user.address); const originalSupply = await erc721.totalSupply(); await erc721.connect(user).safeBurn(user.address, 3); expect(await erc721.balanceOf(user.address)).to.equal( originalBalance.sub(1) ); - expect(await erc721.totalSupply()).to.equal( - originalSupply.sub(1) - ); + expect(await erc721.totalSupply()).to.equal(originalSupply.sub(1)); }); - - it("Should not allow owner or approved to burn a batch of tokens when specifying the incorrect owners", async function() { + + it("Should not allow owner or approved to burn a batch of tokens when specifying the incorrect owners", async function () { const burns = [ { owner: user.address, @@ -167,13 +165,13 @@ describe("Immutable ERC721 Permissioned Mintable Test Cases", function () { tokenIds: [4, 5, 6], }, ]; - - await expect( - erc721.connect(user).safeBurnBatch(burns) - ).to.be.revertedWith('IImmutableERC721MismatchedTokenOwner').withArgs(7, owner.address); + + await expect(erc721.connect(user).safeBurnBatch(burns)) + .to.be.revertedWith("IImmutableERC721MismatchedTokenOwner") + .withArgs(7, owner.address); }); - it("Should allow owner or approved to safely burn a batch of tokens when specifying the correct owners", async function() { + it("Should allow owner or approved to safely burn a batch of tokens when specifying the correct owners", async function () { const originalUserBalance = await erc721.balanceOf(user.address); const originalOwnerBalance = await erc721.balanceOf(owner.address); const originalSupply = await erc721.totalSupply(); @@ -182,7 +180,7 @@ describe("Immutable ERC721 Permissioned Mintable Test Cases", function () { await erc721.connect(user).approve(owner.address, 4); await erc721.connect(user).approve(owner.address, 5); await erc721.connect(user).approve(owner.address, 6); - + const burns = [ { owner: owner.address, @@ -200,9 +198,7 @@ describe("Immutable ERC721 Permissioned Mintable Test Cases", function () { expect(await erc721.balanceOf(owner.address)).to.equal( originalOwnerBalance.sub(3) ); - expect(await erc721.totalSupply()).to.equal( - originalSupply.sub(6) - ); + expect(await erc721.totalSupply()).to.equal(originalSupply.sub(6)); }); });