@hashgraph/nft-utilities
Advanced tools
Comparing version
@@ -24,4 +24,4 @@ /** | ||
* @return {RarityResult[]} Array of objects with rarity information for each NFT | ||
*/ | ||
*/ | ||
declare const calculateRarity: (dir: string) => RarityResult[]; | ||
export { calculateRarity }; |
@@ -27,3 +27,3 @@ "use strict"; | ||
* @return {RarityResult[]} Array of objects with rarity information for each NFT | ||
*/ | ||
*/ | ||
const calculateRarity = (dir) => { | ||
@@ -38,2 +38,14 @@ const filenames = (0, files_1.getJSONFilesForDir)(dir); | ||
file.filedata.attributes.forEach((NFTAttribute) => { | ||
// Skip special types of attributes in the rarity calculation (Openrarity specification) | ||
if (NFTAttribute.display_type == 'percentage' || | ||
NFTAttribute.display_type == 'boost' || | ||
NFTAttribute.display_type == 'color' || | ||
NFTAttribute.display_type == 'datetime' || | ||
NFTAttribute.display_type == 'boolean') { | ||
return traitRarities.push({ | ||
trait: NFTAttribute.trait_type, | ||
value: NFTAttribute.value, | ||
rarity: 0, | ||
}); | ||
} | ||
const attributeConfigObject = attributesMap.find((attribute) => attribute.trait_type === NFTAttribute.trait_type); | ||
@@ -75,2 +87,4 @@ if (!attributeConfigObject) | ||
files.forEach((file) => { | ||
if (!file.filedata.attributes) | ||
throw new Error(`Attributes not found in file ${file.filename}. Please ensure that your metadata file is valid.`); | ||
file.filedata.attributes.forEach((attribute) => { | ||
@@ -77,0 +91,0 @@ const matchedAttributeIndex = attributesMap.findIndex((attributeObject) => attribute.trait_type === attributeObject.trait_type); |
@@ -24,4 +24,4 @@ /** | ||
* @return {RarityResult[]} Array of objects with rarity information for each NFT | ||
*/ | ||
*/ | ||
declare const calculateRarity: (dir: string) => RarityResult[]; | ||
export { calculateRarity }; |
@@ -27,3 +27,3 @@ "use strict"; | ||
* @return {RarityResult[]} Array of objects with rarity information for each NFT | ||
*/ | ||
*/ | ||
const calculateRarity = (dir) => { | ||
@@ -38,2 +38,14 @@ const filenames = (0, files_1.getJSONFilesForDir)(dir); | ||
file.filedata.attributes.forEach((NFTAttribute) => { | ||
// Skip special types of attributes in the rarity calculation (Openrarity specification) | ||
if (NFTAttribute.display_type == 'percentage' || | ||
NFTAttribute.display_type == 'boost' || | ||
NFTAttribute.display_type == 'color' || | ||
NFTAttribute.display_type == 'datetime' || | ||
NFTAttribute.display_type == 'boolean') { | ||
return traitRarities.push({ | ||
trait: NFTAttribute.trait_type, | ||
value: NFTAttribute.value, | ||
rarity: 0, | ||
}); | ||
} | ||
const attributeConfigObject = attributesMap.find((attribute) => attribute.trait_type === NFTAttribute.trait_type); | ||
@@ -75,2 +87,4 @@ if (!attributeConfigObject) | ||
files.forEach((file) => { | ||
if (!file.filedata.attributes) | ||
throw new Error(`Attributes not found in file ${file.filename}. Please ensure that your metadata file is valid.`); | ||
file.filedata.attributes.forEach((attribute) => { | ||
@@ -77,0 +91,0 @@ const matchedAttributeIndex = attributesMap.findIndex((attributeObject) => attribute.trait_type === attributeObject.trait_type); |
{ | ||
"name": "@hashgraph/nft-utilities", | ||
"version": "2.1.5", | ||
"version": "2.2.0", | ||
"description": "NFT Utilities for Hedera Hashgraph", | ||
@@ -5,0 +5,0 @@ "author": "Michiel Mulders", |
141459
1.09%2900
0.97%