@hashgraph/nft-utilities
Advanced tools
Comparing version 1.0.0 to 1.1.0
{ | ||
"name": "@hashgraph/nft-utilities", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "NFT Utilities for Hedera Hashgraph", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -13,3 +13,3 @@ <div align="center"> | ||
2. **Local metadata validator:** Verify a local folder containing multiple JSON metadata files against the standard before publishing the NFT collection on the Hedera network. | ||
3. **Risk score calculation:** Calculate a risk score for a token from the token information or by passing a token ID of an NFT on the Hedera testnet or mainnet. | ||
3. **Risk score calculation:** Calculate a risk score for an NFT collection from the token information or by passing a token ID of an NFT on the Hedera testnet or mainnet. | ||
4. **Rarity score calculation:** Calculate the rarity scores for a local folder containing multiple JSON metadata files for an NFT collection. | ||
@@ -226,14 +226,19 @@ | ||
The total risk score is calculated based on the presence of certain keys for the token. Each key type has an associated weight. | ||
The total risk score is calculated based on the presence of certain `keys` for the token or the presence of an `INFINITE` `supply_type`. Each key or property has an associated weight. | ||
```js | ||
const defaultWeights = { | ||
admin_key: 200, | ||
wipe_key: 200, | ||
freeze_key: 50, | ||
supply_key: 20, | ||
kyc_key: 50, | ||
pause_key: 50, | ||
fee_schedule_key: 40 | ||
} | ||
keys: { | ||
admin_key: 200, | ||
wipe_key: 200, | ||
freeze_key: 50, | ||
supply_key: 20, | ||
kyc_key: 50, | ||
pause_key: 50, | ||
fee_schedule_key: 40 | ||
}, | ||
properties: { | ||
supply_type_infinite: 20 | ||
} | ||
}; | ||
``` | ||
@@ -240,0 +245,0 @@ |
@@ -24,9 +24,14 @@ /*- | ||
const defaultWeights = { | ||
admin_key: 200, | ||
wipe_key: 200, | ||
freeze_key: 50, | ||
supply_key: 20, | ||
kyc_key: 50, | ||
pause_key: 50, | ||
fee_schedule_key: 40 | ||
keys: { | ||
admin_key: 200, | ||
wipe_key: 200, | ||
freeze_key: 50, | ||
supply_key: 20, | ||
kyc_key: 50, | ||
pause_key: 50, | ||
fee_schedule_key: 40 | ||
}, | ||
properties: { | ||
supply_type_infinite: 20 | ||
} | ||
}; | ||
@@ -54,8 +59,12 @@ | ||
// Check if the property is present in the weights object and not null | ||
if (metadata[key] && key in defaultWeights) { | ||
if (metadata[key] && key in defaultWeights.keys) { | ||
// If it is, add the associated risk weight to the risk score | ||
riskScore += defaultWeights[key]; | ||
riskScore += defaultWeights.keys[key]; | ||
} | ||
} | ||
if (metadata.supply_type === "INFINITE") { | ||
riskScore += defaultWeights.properties.supply_type_infinite; | ||
} | ||
const riskLevel = calculateRiskLevel(riskScore) | ||
@@ -87,7 +96,11 @@ | ||
// Check if the property is present in the weights object and not null | ||
if (metadata[key] && key in defaultWeights) { | ||
if (metadata[key] && key in defaultWeights.keys) { | ||
// If it is, add the associated risk weight to the risk score | ||
riskScore += defaultWeights[key]; | ||
riskScore += defaultWeights.keys[key]; | ||
} | ||
} | ||
if (metadata.supply_type === "INFINITE") { | ||
riskScore += defaultWeights.properties.supply_type_infinite; | ||
} | ||
@@ -94,0 +107,0 @@ const riskLevel = calculateRiskLevel(riskScore) |
109981
47
2201
387