From c286bd3cc075d53123c9244737bdc7be6c9dc37f Mon Sep 17 00:00:00 2001 From: Nhan Phan Date: Thu, 20 Jun 2024 20:47:35 -0700 Subject: [PATCH] filter out collection fields not applicable on asset on derivation (#149) --- clients/js/src/helpers/state.ts | 8 +++----- clients/js/test/helps/fetch.test.ts | 4 ++++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/clients/js/src/helpers/state.ts b/clients/js/src/helpers/state.ts index 3389c9d2..fce68fe5 100644 --- a/clients/js/src/helpers/state.ts +++ b/clients/js/src/helpers/state.ts @@ -127,12 +127,10 @@ export function deriveAssetPlugins( } }); + const { numMinted, currentSize, masterEdition, ...colRest } = collection; // remove collection only fields + return { - ...{ - ...collection, - // the following plugins can only be on the collection - masterEdition: undefined, - }, + ...colRest, ...asset, ...externalPluginAdapters, }; diff --git a/clients/js/test/helps/fetch.test.ts b/clients/js/test/helps/fetch.test.ts index 5375a57b..6e60c594 100644 --- a/clients/js/test/helps/fetch.test.ts +++ b/clients/js/test/helps/fetch.test.ts @@ -131,6 +131,8 @@ test('it can use helper to fetch assets by collection and derive plugins', async fetchedAssets.forEach((asset) => { if (asset.publicKey === override.publicKey) { t.like(asset, { + numMinted: undefined, + currentSize: undefined, attributes: { attributeList: [ { @@ -142,6 +144,8 @@ test('it can use helper to fetch assets by collection and derive plugins', async }); } else { t.like(asset, { + numMinted: undefined, + currentSize: undefined, freezeDelegate: { frozen: true, },