From 6b2d78980bc699d41aaa29bee107aeab3bc9c078 Mon Sep 17 00:00:00 2001 From: Marco Lipparini <1532277+liarco@users.noreply.github.com> Date: Wed, 13 Apr 2022 01:37:00 +0200 Subject: [PATCH] Improving walletOfOwner efficiency (#233) * Improving walletOfOwner efficiency * Using "_currentIndex" instead of "maxSupply" --- smart-contract/contracts/YourNftToken.sol | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/smart-contract/contracts/YourNftToken.sol b/smart-contract/contracts/YourNftToken.sol index c3d3b3475..20f00c5ba 100644 --- a/smart-contract/contracts/YourNftToken.sol +++ b/smart-contract/contracts/YourNftToken.sol @@ -79,10 +79,10 @@ contract YourNftToken is ERC721A, Ownable, ReentrancyGuard { uint256 ownedTokenIndex = 0; address latestOwnerAddress; - while (ownedTokenIndex < ownerTokenCount && currentTokenId <= maxSupply) { - if (_exists(currentTokenId)) { - TokenOwnership memory ownership = _ownerships[currentTokenId]; + while (ownedTokenIndex < ownerTokenCount && currentTokenId < _currentIndex) { + TokenOwnership memory ownership = _ownerships[currentTokenId]; + if (!ownership.burned) { if (ownership.addr != address(0)) { latestOwnerAddress = ownership.addr; }