From 1de2a06f724c3cfdd7e6d561e50c59e84b8cef3c Mon Sep 17 00:00:00 2001 From: Harpal Jadeja Date: Thu, 29 Sep 2022 19:12:24 +0530 Subject: [PATCH] fix(nft): fix internalNFTRevokeAll function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `internalNFTRevokeAll` function checked if there are no `approved_account_ids` only then it would go ahead and revoke, which is contradictory 😅. Made the fix to revoke when there are `approved_account_ids` in `token`. --- src/nft-contract/approval.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nft-contract/approval.ts b/src/nft-contract/approval.ts index 9bd1745..0a97114 100644 --- a/src/nft-contract/approval.ts +++ b/src/nft-contract/approval.ts @@ -166,7 +166,7 @@ export function internalNftRevokeAll({ assert(predecessorAccountId == token.owner_id, "only token owner can revoke"); //only revoke if the approved account IDs for the token is not empty - if (token.approved_account_ids && Object.keys(token.approved_account_ids).length === 0 && Object.getPrototypeOf(token.approved_account_ids) === Object.prototype) { + if (token.approved_account_ids && Object.keys(token.approved_account_ids).length !== 0 && Object.getPrototypeOf(token.approved_account_ids) === Object.prototype) { //refund the approved account IDs to the caller of the function refundApprovedAccountIds(predecessorAccountId, token.approved_account_ids); //clear the approved account IDs @@ -174,4 +174,4 @@ export function internalNftRevokeAll({ //insert the token back into the tokens_by_id collection with the approved account IDs cleared contract.tokensById.set(tokenId, token); } -} \ No newline at end of file +}