From 1240070c019b0546a84e8ba0f6b0ff0b089e7bfe Mon Sep 17 00:00:00 2001 From: sagivmis <74502370+sagivmis@users.noreply.github.com> Date: Tue, 19 Apr 2022 13:55:12 +0300 Subject: [PATCH] NFT's metadata doesn't contain 'custom_fields' attribute --- backend/utils/functions/getRarity_fromMetadata.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/utils/functions/getRarity_fromMetadata.js b/backend/utils/functions/getRarity_fromMetadata.js index d375c866b8..eeebc7ca2a 100644 --- a/backend/utils/functions/getRarity_fromMetadata.js +++ b/backend/utils/functions/getRarity_fromMetadata.js @@ -17,7 +17,7 @@ function processRarity(nfts) { // check if attributes exist if(nft?.attributes?.length > 0) { // loop through all attributes - for(attribute of nft.attributes) { + for(const attribute of nft.attributes) { // add trait type to rarity object if it doesn't exist if(!rarity[attribute.trait_type]) { rarity[attribute.trait_type] = {} @@ -57,7 +57,7 @@ function processRarity(nfts) { }) // sort nfts by edition again - nfts.sort((a, b) => a.custom_fields.edition - b.custom_fields.edition) + nfts.sort((a, b) => a.edition - b.edition) fs.writeFileSync(`${basePath}/build/json/_metadata_with_rarity.json`, JSON.stringify(nfts, null, 2)); }