From 22213a76f79e470d6c75f734120b277bb344e378 Mon Sep 17 00:00:00 2001 From: Martin Macharia Date: Thu, 21 Sep 2023 13:58:49 +0200 Subject: [PATCH] Update the removeSupportAllNFTs method (#9017) --- framework/src/modules/nft/method.ts | 2 ++ framework/test/unit/modules/nft/method.spec.ts | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/framework/src/modules/nft/method.ts b/framework/src/modules/nft/method.ts index 48731fdc3b..c1443aabb6 100644 --- a/framework/src/modules/nft/method.ts +++ b/framework/src/modules/nft/method.ts @@ -711,6 +711,8 @@ export class NFTMethod extends BaseMethod { await supportedNFTsStore.del(methodContext, key); } + await supportedNFTsStore.del(methodContext, ALL_SUPPORTED_NFTS_KEY); + this.events.get(AllNFTsSupportRemovedEvent).log(methodContext); } diff --git a/framework/test/unit/modules/nft/method.spec.ts b/framework/test/unit/modules/nft/method.spec.ts index 991d64ebf1..6f4e07a140 100644 --- a/framework/test/unit/modules/nft/method.spec.ts +++ b/framework/test/unit/modules/nft/method.spec.ts @@ -1189,6 +1189,20 @@ describe('NFTMethod', () => { checkEventResult(methodContext.eventQueue, 1, AllNFTsSupportRemovedEvent, 0, {}, null); }); + + it('should remove all existing entries even if the ALL_SUPPORTED_NFTS_KEY entry exists', async () => { + await supportedNFTsStore.save(methodContext, ALL_SUPPORTED_NFTS_KEY, { + supportedCollectionIDArray: [], + }); + + await expect(method.removeSupportAllNFTs(methodContext)).resolves.toBeUndefined(); + await expect( + supportedNFTsStore.has(methodContext, ALL_SUPPORTED_NFTS_KEY), + ).resolves.toBeFalse(); + + checkEventResult(methodContext.eventQueue, 1, AllNFTsSupportRemovedEvent, 0, {}, null); + expect(methodContext.eventQueue.getEvents()).toHaveLength(1); + }); }); describe('supportAllNFTsFromChain', () => {