-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathToripunks.ts
40 lines (34 loc) · 1.32 KB
/
Toripunks.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import Collection from "./Collection";
export default class Toripunks extends Collection {
name: string = "toripunks"
constructor() {
super("toripunks")
}
async computeScore(rarity: any, collections: any): Promise<any> {
// Compute attributes rarity and score
for (let [trait, values] of Object.entries(rarity)) {
for (let [val, _] of Object.entries(values as any)) {
rarity[trait][val].score = 1 / rarity[trait][val].count / this.config.nft_max_supply
}
}
// Set scores on nft
for (let [id, nft] of Object.entries(collections)) {
let score = 0
for (const attr of (nft as any).info.extension.attributes) {
if (!rarity[attr.trait_type][attr.value]) {
continue
}
score += rarity[attr.trait_type][attr.value].score
if (attr.trait_type === "1:1") {
score += 100_000
} else if (attr.trait_type === "Exclusive" && attr.value === "Yes") {
score += 10_000
}
}
collections[id.toString()].id = id
collections[id.toString()].score = score
}
collections = this.orderByScore(collections)
return collections
}
}