Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Feb 16, 2023
1 parent 5e5f76d commit 05bd2b9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
13 changes: 8 additions & 5 deletions contracts/ERC721AUpgradeable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -442,11 +442,14 @@ contract ERC721AUpgradeable is ERC721A__Initializable, IERC721AUpgradeable {
*
* Tokens start existing when they are minted. See {_mint}.
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return
_startTokenId() <= tokenId &&
tokenId < ERC721AStorage.layout()._currentIndex && // If within bounds,
ERC721AStorage.layout()._packedOwnerships[tokenId] & _BITMASK_BURNED == 0; // and not burned.
function _exists(uint256 tokenId) internal view virtual returns (bool result) {
if (_startTokenId() <= tokenId) {
if (tokenId < ERC721AStorage.layout()._currentIndex) {
uint256 packed;
while ((packed = ERC721AStorage.layout()._packedOwnerships[tokenId]) == 0) --tokenId;
result = packed & _BITMASK_BURNED == 0;
}
}
}

/**
Expand Down
4 changes: 4 additions & 0 deletions test/ERC721A.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,10 @@ const createTestSuite = ({ contract, constructorArgs }) =>
if (3 <= i && i < 3 + 2) {
await expect(this.erc721a.ownerOf(this.startTokenId + i))
.to.be.revertedWith('OwnerQueryForNonexistentToken');
await expect(this.erc721a.getApproved(this.startTokenId + i))
.to.be.revertedWith('ApprovalQueryForNonexistentToken');
await expect(this.erc721a.tokenURI(this.startTokenId + i))
.to.be.revertedWith('URIQueryForNonexistentToken');
} else {
expect(await this.erc721a.ownerOf(this.startTokenId + i)).to.eq(owner.address);
}
Expand Down

0 comments on commit 05bd2b9

Please sign in to comment.