From 639c2e3b0e7c24b5bdf908795ef1c9cf868b2390 Mon Sep 17 00:00:00 2001 From: Martin Macharia Date: Wed, 20 Sep 2023 12:07:40 +0200 Subject: [PATCH] Update the removeSupportAllNFTs method --- 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 b5ec26df12..9864c793a5 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 a22bc7d664..a8b1415751 100644 --- a/framework/test/unit/modules/nft/method.spec.ts +++ b/framework/test/unit/modules/nft/method.spec.ts @@ -1191,6 +1191,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', () => {