Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@poprank/rankings

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@poprank/rankings - npm Package Compare versions

Comparing version 1.1.2 to 1.1.3

28

lib/rarity/rarity.js

@@ -141,3 +141,5 @@ "use strict";

return;
minNonWeightComponent = Math.min(minNonWeightComponent, calculateBaseTraitScore(trait.traitCount, collectionSize, traitTypeArray.length));
if (minNonWeightComponent > calculateBaseTraitScore(trait.traitCount, collectionSize, traitTypeArray.length)) {
minNonWeightComponent = Math.min(minNonWeightComponent, calculateBaseTraitScore(trait.traitCount, collectionSize, traitTypeArray.length));
}
});

@@ -192,20 +194,28 @@ });

var trait = (_a = nft.traits.find(function (t) { return t.typeValue === traitType; })) !== null && _a !== void 0 ? _a : traitValuesOfThisType.find(function (t) { return t.category === 'None'; });
var value = trait.value, typeValue = trait.typeValue;
var currTraitValueCount = traitValuesOfThisType.find(function (t) { return t.value === value; }).traitCount;
var pushRatedTraitToCollectionTraits = function (rarity, count) {
if (!collectionTraits[typeValue])
collectionTraits[typeValue] = [];
if (!collectionTraits[typeValue].find(function (t) { return t.value === value; }))
collectionTraits[typeValue].push((__assign(__assign({}, trait), { traitCount: count, rarityTraitSum: rarity })));
};
// For all non trait-count meta traits, don't calculate the rarity. If it's not none though, still
// add it to the end traits array
if (traitValuesOfThisType.find(function (t) { return t.category === 'Meta' && t.typeValue !== rarity_meta_1.TRAIT_COUNT; })) {
if (trait.category !== 'None')
if (trait.category !== 'None') {
pushRatedTraitToCollectionTraits(0, currTraitValueCount);
nftTraitsWithRarity.push(__assign(__assign({}, trait), { traitCount: 1, rarityTraitSum: 0 }));
}
return;
}
var value = trait.value, typeValue = trait.typeValue;
var currTraitValueCount = traitValuesOfThisType.find(function (t) { return t.value === value; }).traitCount;
var collectionTraitValueCountPairs = collectionTraitsNoRarity[typeValue];
var traitTypeCount = collectionTraitValueCountPairs.length;
var currTraitRarity = (0, exports.calculateTraitScore)(currTraitValueCount, nfts.length, traitTypeCount, weight);
if (!collectionTraits[typeValue])
collectionTraits[typeValue] = [];
if (!collectionTraits[typeValue].find(function (t) { return t.value === value; }))
collectionTraits[typeValue].push((__assign(__assign({}, trait), { traitCount: currTraitValueCount, rarityTraitSum: currTraitRarity })));
rarityTraitSum += currTraitRarity;
nftTraitsWithRarity.push(__assign(__assign({}, trait), { traitCount: 1, rarityTraitSum: currTraitRarity }));
// Push this trait to the collection-wide object if it's not there
pushRatedTraitToCollectionTraits(currTraitRarity, currTraitValueCount);
// Don't add "None" traits to the final array, they're implicit
if (trait.category !== 'None')
nftTraitsWithRarity.push(__assign(__assign({}, trait), { traitCount: 1, rarityTraitSum: currTraitRarity }));
});

@@ -212,0 +222,0 @@ nftsWithRarity.push(__assign(__assign({}, nft), { traits: nftTraitsWithRarity, rarityTraitSum: +rarityTraitSum.toFixed(3) }));

{
"name": "@poprank/rankings",
"version": "1.1.2",
"version": "1.1.3",
"description": "PopRank's NFT rarity and aesthetic ranking logic",

@@ -5,0 +5,0 @@ "publishConfig": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc