@xyo-network/crypto-nft-diviner-score-plugin 2.99.5 → 2.99.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/browser/Plugin.d.cts +2 -2
  2. package/dist/browser/Plugin.d.mts +2 -2
  3. package/dist/browser/Plugin.d.ts +2 -2
  4. package/dist/browser/index.cjs +127 -235
  5. package/dist/browser/index.cjs.map +1 -1
  6. package/dist/browser/index.mjs +131 -237
  7. package/dist/browser/index.mjs.map +1 -1
  8. package/dist/browser/lib/rating/criteria/scoring/metadata/lib/urlHelpers.d.cts +0 -1
  9. package/dist/browser/lib/rating/criteria/scoring/metadata/lib/urlHelpers.d.cts.map +1 -1
  10. package/dist/browser/lib/rating/criteria/scoring/metadata/lib/urlHelpers.d.mts +0 -1
  11. package/dist/browser/lib/rating/criteria/scoring/metadata/lib/urlHelpers.d.mts.map +1 -1
  12. package/dist/browser/lib/rating/criteria/scoring/metadata/lib/urlHelpers.d.ts +0 -1
  13. package/dist/browser/lib/rating/criteria/scoring/metadata/lib/urlHelpers.d.ts.map +1 -1
  14. package/dist/neutral/Plugin.d.cts +2 -2
  15. package/dist/neutral/Plugin.d.mts +2 -2
  16. package/dist/neutral/Plugin.d.ts +2 -2
  17. package/dist/neutral/index.cjs +127 -235
  18. package/dist/neutral/index.cjs.map +1 -1
  19. package/dist/neutral/index.mjs +131 -237
  20. package/dist/neutral/index.mjs.map +1 -1
  21. package/dist/neutral/lib/rating/criteria/scoring/metadata/lib/urlHelpers.d.cts +0 -1
  22. package/dist/neutral/lib/rating/criteria/scoring/metadata/lib/urlHelpers.d.cts.map +1 -1
  23. package/dist/neutral/lib/rating/criteria/scoring/metadata/lib/urlHelpers.d.mts +0 -1
  24. package/dist/neutral/lib/rating/criteria/scoring/metadata/lib/urlHelpers.d.mts.map +1 -1
  25. package/dist/neutral/lib/rating/criteria/scoring/metadata/lib/urlHelpers.d.ts +0 -1
  26. package/dist/neutral/lib/rating/criteria/scoring/metadata/lib/urlHelpers.d.ts.map +1 -1
  27. package/dist/node/Plugin.d.cts +2 -2
  28. package/dist/node/Plugin.d.mts +2 -2
  29. package/dist/node/Plugin.d.ts +2 -2
  30. package/dist/node/index.cjs +134 -246
  31. package/dist/node/index.cjs.map +1 -1
  32. package/dist/node/index.mjs +138 -248
  33. package/dist/node/index.mjs.map +1 -1
  34. package/dist/node/lib/rating/criteria/scoring/metadata/lib/urlHelpers.d.cts +0 -1
  35. package/dist/node/lib/rating/criteria/scoring/metadata/lib/urlHelpers.d.cts.map +1 -1
  36. package/dist/node/lib/rating/criteria/scoring/metadata/lib/urlHelpers.d.mts +0 -1
  37. package/dist/node/lib/rating/criteria/scoring/metadata/lib/urlHelpers.d.mts.map +1 -1
  38. package/dist/node/lib/rating/criteria/scoring/metadata/lib/urlHelpers.d.ts +0 -1
  39. package/dist/node/lib/rating/criteria/scoring/metadata/lib/urlHelpers.d.ts.map +1 -1
  40. package/package.json +13 -14
  41. package/src/lib/rating/criteria/scoring/metadata/lib/urlHelpers.ts +0 -2
@@ -1,51 +1,45 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
-
4
1
  // src/Diviner.ts
5
- import { isNftInfo, NftScoreDivinerConfigSchema, NftScoreSchema } from "@xyo-network/crypto-nft-payload-plugin";
2
+ import {
3
+ isNftInfo,
4
+ NftScoreDivinerConfigSchema,
5
+ NftScoreSchema
6
+ } from "@xyo-network/crypto-nft-payload-plugin";
6
7
  import { AbstractDiviner } from "@xyo-network/diviner-abstract";
7
8
  import { PayloadBuilder } from "@xyo-network/payload-builder";
8
9
 
9
10
  // src/lib/rating/criteria/scoring/contract.ts
10
11
  import { FAIL, PASS } from "@xyo-network/crypto-nft-score-model";
11
12
  import { isAddress } from "ethers";
12
- var scoreContractAddress = /* @__PURE__ */ __name((nft) => {
13
+ var scoreContractAddress = (nft) => {
13
14
  if (!nft.address) return FAIL;
14
15
  if (typeof nft.address !== "string") return FAIL;
15
16
  if (!isAddress(nft.address)) return FAIL;
16
17
  return PASS;
17
- }, "scoreContractAddress");
18
+ };
18
19
 
19
20
  // src/lib/rating/criteria/scoring/metadata/animationUrl.ts
20
21
  import { incrementPossible, incrementTotal, incrementTotalAndPossible, PASS as PASS2 } from "@xyo-network/crypto-nft-score-model";
21
22
 
22
23
  // src/lib/rating/criteria/scoring/metadata/lib/urlHelpers.ts
23
- import { URL } from "@xylabs/url";
24
- var web3Protocols = [
25
- "ipfs:",
26
- "ar:"
27
- ];
28
- var toUrl = /* @__PURE__ */ __name((url) => {
24
+ var web3Protocols = ["ipfs:", "ar:"];
25
+ var toUrl = (url) => {
29
26
  if (!url) return void 0;
30
27
  try {
31
28
  return new URL(url);
32
29
  } catch {
33
30
  return void 0;
34
31
  }
35
- }, "toUrl");
36
- var isValidUrl = /* @__PURE__ */ __name((url) => toUrl(url) !== void 0, "isValidUrl");
37
- var isWeb3 = /* @__PURE__ */ __name((url) => web3Protocols.some((protocol) => protocol === toUrl(url)?.protocol), "isWeb3");
38
- var isSecure = /* @__PURE__ */ __name((url) => isWeb3(url) || toUrl(url)?.protocol === "https:", "isSecure");
32
+ };
33
+ var isValidUrl = (url) => toUrl(url) !== void 0;
34
+ var isWeb3 = (url) => web3Protocols.some((protocol) => protocol === toUrl(url)?.protocol);
35
+ var isSecure = (url) => isWeb3(url) || toUrl(url)?.protocol === "https:";
39
36
 
40
37
  // src/lib/rating/criteria/scoring/metadata/animationUrl.ts
41
- var scoreNftAnimationUrl = /* @__PURE__ */ __name((nft) => {
38
+ var scoreNftAnimationUrl = (nft) => {
42
39
  return scoreAnimationUrl(nft.metadata?.animation_url);
43
- }, "scoreNftAnimationUrl");
44
- var scoreAnimationUrl = /* @__PURE__ */ __name((animation_url) => {
45
- const score = [
46
- 0,
47
- 0
48
- ];
40
+ };
41
+ var scoreAnimationUrl = (animation_url) => {
42
+ const score = [0, 0];
49
43
  if (animation_url === void 0 || animation_url === null) return PASS2;
50
44
  incrementPossible(score);
51
45
  if (typeof animation_url !== "string") return score;
@@ -56,11 +50,11 @@ var scoreAnimationUrl = /* @__PURE__ */ __name((animation_url) => {
56
50
  incrementTotalAndPossible(score);
57
51
  if (!isWeb3(animation_url)) return score;
58
52
  return incrementTotal(score);
59
- }, "scoreAnimationUrl");
53
+ };
60
54
 
61
55
  // src/lib/rating/criteria/scoring/metadata/attributes/evaluateAttributes.ts
62
56
  import { incrementPossible as incrementPossible2, incrementTotal as incrementTotal2, incrementTotalAndPossible as incrementTotalAndPossible2 } from "@xyo-network/crypto-nft-score-model";
63
- var isDate = /* @__PURE__ */ __name((value) => {
57
+ var isDate = (value) => {
64
58
  if (isNumber(value)) {
65
59
  try {
66
60
  new Date(value);
@@ -70,38 +64,23 @@ var isDate = /* @__PURE__ */ __name((value) => {
70
64
  }
71
65
  }
72
66
  return false;
73
- }, "isDate");
74
- var isNumber = /* @__PURE__ */ __name((value) => typeof value === "number", "isNumber");
75
- var isPercentage = /* @__PURE__ */ __name((value) => isNumber(value) && value >= 0 && value <= 100, "isPercentage");
76
- var isNonEmptyString = /* @__PURE__ */ __name((value) => typeof value === "string" && value.length > 0, "isNonEmptyString");
77
- var isNonEmptyStringOrNumber = /* @__PURE__ */ __name((value) => value === "number" || isNonEmptyString(value), "isNonEmptyStringOrNumber");
78
- var evaluateNftAttributes = /* @__PURE__ */ __name((nft) => nft?.metadata?.attributes ? evaluateAttributes(nft?.metadata?.attributes) : [
79
- 0,
80
- 1
81
- ], "evaluateNftAttributes");
82
- var evaluateAttributes = /* @__PURE__ */ __name((attributes) => {
83
- if (!attributes || !Array.isArray(attributes) || attributes.length === 0) return [
84
- 0,
85
- 1
86
- ];
87
- const score = [
88
- 0,
89
- 0
90
- ];
67
+ };
68
+ var isNumber = (value) => typeof value === "number";
69
+ var isPercentage = (value) => isNumber(value) && value >= 0 && value <= 100;
70
+ var isNonEmptyString = (value) => typeof value === "string" && value.length > 0;
71
+ var isNonEmptyStringOrNumber = (value) => value === "number" || isNonEmptyString(value);
72
+ var evaluateNftAttributes = (nft) => nft?.metadata?.attributes ? evaluateAttributes(nft?.metadata?.attributes) : [0, 1];
73
+ var evaluateAttributes = (attributes) => {
74
+ if (!attributes || !Array.isArray(attributes) || attributes.length === 0) return [0, 1];
75
+ const score = [0, 0];
91
76
  for (const attribute of attributes) {
92
77
  const [attributeTotal, attributePossible] = evaluateAttribute(attribute);
93
78
  incrementTotalAndPossible2(score, attributeTotal, attributePossible);
94
79
  }
95
- return [
96
- 1,
97
- 1
98
- ];
99
- }, "evaluateAttributes");
100
- var evaluateAttribute = /* @__PURE__ */ __name((attribute) => {
101
- const score = [
102
- 0,
103
- 1
104
- ];
80
+ return [1, 1];
81
+ };
82
+ var evaluateAttribute = (attribute) => {
83
+ const score = [0, 1];
105
84
  const max_value = attribute?.max_value;
106
85
  const trait_type = attribute?.trait_type;
107
86
  const value = attribute?.value;
@@ -114,8 +93,8 @@ var evaluateAttribute = /* @__PURE__ */ __name((attribute) => {
114
93
  if (isNumber(max_value) && isNumber(value) && value <= max_value) incrementTotal2(score);
115
94
  }
116
95
  return score;
117
- }, "evaluateAttribute");
118
- var validDisplayType = /* @__PURE__ */ __name((attribute) => {
96
+ };
97
+ var validDisplayType = (attribute) => {
119
98
  switch (attribute?.display_type) {
120
99
  case "number":
121
100
  case "boost_number": {
@@ -140,75 +119,60 @@ var validDisplayType = /* @__PURE__ */ __name((attribute) => {
140
119
  }
141
120
  }
142
121
  return false;
143
- }, "validDisplayType");
122
+ };
144
123
 
145
124
  // src/lib/rating/criteria/scoring/metadata/backgroundColor.ts
146
125
  import { incrementPossible as incrementPossible3, incrementTotal as incrementTotal3, incrementTotalAndPossible as incrementTotalAndPossible3, PASS as PASS3 } from "@xyo-network/crypto-nft-score-model";
147
126
  var isHexColor = /^[\da-f]{6}$/i;
148
- var scoreNftBackgroundColor = /* @__PURE__ */ __name((nft) => {
127
+ var scoreNftBackgroundColor = (nft) => {
149
128
  return scoreBackgroundColor(nft.metadata?.background_color);
150
- }, "scoreNftBackgroundColor");
151
- var scoreBackgroundColor = /* @__PURE__ */ __name((background_color) => {
152
- const score = [
153
- 0,
154
- 0
155
- ];
129
+ };
130
+ var scoreBackgroundColor = (background_color) => {
131
+ const score = [0, 0];
156
132
  if (background_color === void 0 || background_color === null) return PASS3;
157
133
  incrementPossible3(score);
158
134
  if (typeof background_color !== "string") return score;
159
135
  incrementTotalAndPossible3(score);
160
136
  if (!isHexColor.test(background_color.toUpperCase())) return score;
161
137
  return incrementTotal3(score);
162
- }, "scoreBackgroundColor");
138
+ };
163
139
 
164
140
  // src/lib/rating/criteria/scoring/metadata/description.ts
165
141
  import { incrementTotal as incrementTotal4 } from "@xyo-network/crypto-nft-score-model";
166
- var scoreNftDescription = /* @__PURE__ */ __name((nft) => {
142
+ var scoreNftDescription = (nft) => {
167
143
  return scoreDescription(nft.metadata?.description);
168
- }, "scoreNftDescription");
169
- var scoreDescription = /* @__PURE__ */ __name((description) => {
170
- const score = [
171
- 0,
172
- 1
173
- ];
144
+ };
145
+ var scoreDescription = (description) => {
146
+ const score = [0, 1];
174
147
  if (!description || typeof description !== "string") return score;
175
148
  return incrementTotal4(score);
176
- }, "scoreDescription");
149
+ };
177
150
 
178
151
  // src/lib/rating/criteria/scoring/metadata/externalUrl.ts
179
152
  import { incrementTotal as incrementTotal5 } from "@xyo-network/crypto-nft-score-model";
180
- var scoreNftExternalUrl = /* @__PURE__ */ __name((nft) => {
153
+ var scoreNftExternalUrl = (nft) => {
181
154
  return scoreExternalUrl(nft?.metadata?.external_url);
182
- }, "scoreNftExternalUrl");
183
- var scoreExternalUrl = /* @__PURE__ */ __name((external_url) => {
184
- const score = [
185
- 0,
186
- 2
187
- ];
155
+ };
156
+ var scoreExternalUrl = (external_url) => {
157
+ const score = [0, 2];
188
158
  if (external_url === void 0 || external_url === null || typeof external_url !== "string" || !isValidUrl(external_url)) return score;
189
159
  incrementTotal5(score);
190
160
  if (!isSecure(external_url)) return score;
191
161
  return incrementTotal5(score);
192
- }, "scoreExternalUrl");
162
+ };
193
163
 
194
164
  // src/lib/rating/criteria/scoring/metadata/image.ts
195
165
  import { incrementTotal as incrementTotal6, PASS as PASS4 } from "@xyo-network/crypto-nft-score-model";
196
166
  var MaxPossibleImageScore = 3;
197
- var scoreNftImage = /* @__PURE__ */ __name((nft) => {
167
+ var scoreNftImage = (nft) => {
198
168
  if (nft?.metadata?.image) {
199
169
  return scoreImage(nft.metadata?.image);
200
170
  } else {
201
- return nft.metadata?.image_data ? PASS4 : [
202
- 0,
203
- MaxPossibleImageScore
204
- ];
171
+ return nft.metadata?.image_data ? PASS4 : [0, MaxPossibleImageScore];
205
172
  }
206
- }, "scoreNftImage");
207
- var scoreImage = /* @__PURE__ */ __name((image) => {
208
- const score = [
209
- 0,
210
- MaxPossibleImageScore
211
- ];
173
+ };
174
+ var scoreImage = (image) => {
175
+ const score = [0, MaxPossibleImageScore];
212
176
  if (!image || typeof image !== "string" || !isValidUrl(image)) return score;
213
177
  incrementTotal6(score);
214
178
  if (!isSecure(image)) return score;
@@ -216,13 +180,13 @@ var scoreImage = /* @__PURE__ */ __name((image) => {
216
180
  if (!isWeb3(image)) return score;
217
181
  incrementTotal6(score);
218
182
  return score;
219
- }, "scoreImage");
183
+ };
220
184
 
221
185
  // src/lib/rating/criteria/scoring/metadata/imageData.ts
222
186
  import { PASS as PASS5 } from "@xyo-network/crypto-nft-score-model";
223
187
  import { parse } from "svg-parser";
224
188
  var MaxPossibleImageDataScore = 1;
225
- var isValidImageData = /* @__PURE__ */ __name((image_data) => {
189
+ var isValidImageData = (image_data) => {
226
190
  if (!image_data.startsWith("<svg")) return false;
227
191
  try {
228
192
  parse(image_data);
@@ -230,61 +194,46 @@ var isValidImageData = /* @__PURE__ */ __name((image_data) => {
230
194
  } catch {
231
195
  return false;
232
196
  }
233
- }, "isValidImageData");
234
- var scoreNftImageData = /* @__PURE__ */ __name((nft) => {
197
+ };
198
+ var scoreNftImageData = (nft) => {
235
199
  if (nft?.metadata?.image_data) {
236
200
  return scoreImageData(nft.metadata?.image_data);
237
201
  } else {
238
- return nft.metadata?.image ? PASS5 : [
239
- 0,
240
- MaxPossibleImageDataScore
241
- ];
202
+ return nft.metadata?.image ? PASS5 : [0, MaxPossibleImageDataScore];
242
203
  }
243
- }, "scoreNftImageData");
244
- var scoreImageData = /* @__PURE__ */ __name((image_data) => {
245
- return !image_data || typeof image_data !== "string" || !isValidImageData(image_data) ? [
246
- 0,
247
- MaxPossibleImageDataScore
248
- ] : [
249
- MaxPossibleImageDataScore,
250
- MaxPossibleImageDataScore
251
- ];
252
- }, "scoreImageData");
204
+ };
205
+ var scoreImageData = (image_data) => {
206
+ return !image_data || typeof image_data !== "string" || !isValidImageData(image_data) ? [0, MaxPossibleImageDataScore] : [MaxPossibleImageDataScore, MaxPossibleImageDataScore];
207
+ };
253
208
 
254
209
  // src/lib/rating/criteria/scoring/metadata/name.ts
255
210
  import { incrementTotal as incrementTotal7 } from "@xyo-network/crypto-nft-score-model";
256
- var scoreNftName = /* @__PURE__ */ __name((nft) => {
211
+ var scoreNftName = (nft) => {
257
212
  return scoreName(nft.metadata?.name);
258
- }, "scoreNftName");
259
- var scoreName = /* @__PURE__ */ __name((name) => {
260
- const score = [
261
- 0,
262
- 1
263
- ];
213
+ };
214
+ var scoreName = (name) => {
215
+ const score = [0, 1];
264
216
  if (!name || typeof name !== "string") return score;
265
217
  return incrementTotal7(score);
266
- }, "scoreName");
218
+ };
267
219
 
268
220
  // src/lib/rating/criteria/scoring/metadata/youtubeUrl.ts
269
221
  import { incrementTotal as incrementTotal8, PASS as PASS6 } from "@xyo-network/crypto-nft-score-model";
270
- var scoreNftYoutubeUrl = /* @__PURE__ */ __name((nft) => {
222
+ var scoreNftYoutubeUrl = (nft) => {
271
223
  return scoreYoutubeUrl(nft?.metadata?.youtube_url);
272
- }, "scoreNftYoutubeUrl");
273
- var scoreYoutubeUrl = /* @__PURE__ */ __name((youtube_url) => {
224
+ };
225
+ var scoreYoutubeUrl = (youtube_url) => {
274
226
  if (youtube_url === void 0 || youtube_url === null) return PASS6;
275
- const score = [
276
- 0,
277
- 2
278
- ];
227
+ const score = [0, 2];
279
228
  if (typeof youtube_url !== "string" || !isValidUrl(youtube_url)) return score;
280
229
  incrementTotal8(score);
281
230
  if (!isSecure(youtube_url)) return score;
282
231
  return incrementTotal8(score);
283
- }, "scoreYoutubeUrl");
232
+ };
284
233
 
285
234
  // src/lib/rating/criteria/scoring/supply.ts
286
235
  import { FAIL as FAIL2, PASS as PASS7 } from "@xyo-network/crypto-nft-score-model";
287
- var scoreSupply = /* @__PURE__ */ __name((nft) => {
236
+ var scoreSupply = (nft) => {
288
237
  if (!nft.supply) return FAIL2;
289
238
  if (typeof nft.supply !== "string") return FAIL2;
290
239
  try {
@@ -292,11 +241,11 @@ var scoreSupply = /* @__PURE__ */ __name((nft) => {
292
241
  } catch {
293
242
  return FAIL2;
294
243
  }
295
- }, "scoreSupply");
244
+ };
296
245
 
297
246
  // src/lib/rating/criteria/scoring/tokenId.ts
298
247
  import { FAIL as FAIL3, PASS as PASS8 } from "@xyo-network/crypto-nft-score-model";
299
- var scoreTokenId = /* @__PURE__ */ __name((nft) => {
248
+ var scoreTokenId = (nft) => {
300
249
  if (!nft.tokenId) return FAIL3;
301
250
  if (typeof nft.tokenId !== "string") return FAIL3;
302
251
  try {
@@ -304,149 +253,94 @@ var scoreTokenId = /* @__PURE__ */ __name((nft) => {
304
253
  } catch {
305
254
  return FAIL3;
306
255
  }
307
- }, "scoreTokenId");
256
+ };
308
257
 
309
258
  // src/lib/rating/criteria/scoring/type.ts
310
259
  import { FAIL as FAIL4, PASS as PASS9 } from "@xyo-network/crypto-nft-score-model";
311
- var scoreType = /* @__PURE__ */ __name((nft) => {
260
+ var scoreType = (nft) => {
312
261
  if (!nft.type) return FAIL4;
313
262
  if (typeof nft.type !== "string") return FAIL4;
314
263
  const type = nft.type.toUpperCase();
315
264
  if (type !== "ERC721" && type !== "ERC1155") return FAIL4;
316
265
  return PASS9;
317
- }, "scoreType");
266
+ };
318
267
 
319
268
  // src/lib/rating/criteria/scoringCriteria.ts
320
269
  var attributesScoringCriteria = {
321
- Attributes: {
322
- score: evaluateNftAttributes,
323
- weight: 1
324
- }
270
+ Attributes: { score: evaluateNftAttributes, weight: 1 }
325
271
  };
326
272
  var metadataScoringCriteria = {
327
- "Animation URL": {
328
- score: scoreNftAnimationUrl,
329
- weight: 1
330
- },
331
- "Background Color": {
332
- score: scoreNftBackgroundColor,
333
- weight: 1
334
- },
335
- "Description": {
336
- score: scoreNftDescription,
337
- weight: 1
338
- },
339
- "External Url": {
340
- score: scoreNftExternalUrl,
341
- weight: 1
342
- },
343
- "Image": {
344
- score: scoreNftImage,
345
- weight: 1
346
- },
347
- "Image Data": {
348
- score: scoreNftImageData,
349
- weight: 1
350
- },
351
- "Name": {
352
- score: scoreNftName,
353
- weight: 1
354
- },
355
- "YouTube URL": {
356
- score: scoreNftYoutubeUrl,
357
- weight: 1
358
- },
273
+ "Animation URL": { score: scoreNftAnimationUrl, weight: 1 },
274
+ "Background Color": { score: scoreNftBackgroundColor, weight: 1 },
275
+ "Description": { score: scoreNftDescription, weight: 1 },
276
+ "External Url": { score: scoreNftExternalUrl, weight: 1 },
277
+ "Image": { score: scoreNftImage, weight: 1 },
278
+ "Image Data": { score: scoreNftImageData, weight: 1 },
279
+ "Name": { score: scoreNftName, weight: 1 },
280
+ "YouTube URL": { score: scoreNftYoutubeUrl, weight: 1 },
359
281
  ...attributesScoringCriteria
360
282
  };
361
283
  var scoringCriteria = {
362
- "Contract Address": {
363
- score: scoreContractAddress,
364
- weight: 1
365
- },
366
- "Supply": {
367
- score: scoreSupply,
368
- weight: 1
369
- },
370
- "Token Id": {
371
- score: scoreTokenId,
372
- weight: 1
373
- },
374
- "Type": {
375
- score: scoreType,
376
- weight: 1
377
- },
284
+ "Contract Address": { score: scoreContractAddress, weight: 1 },
285
+ "Supply": { score: scoreSupply, weight: 1 },
286
+ "Token Id": { score: scoreTokenId, weight: 1 },
287
+ "Type": { score: scoreType, weight: 1 },
378
288
  ...metadataScoringCriteria
379
289
  };
380
290
 
381
291
  // src/lib/rating/analyzeNft.ts
382
- var analyzeNft = /* @__PURE__ */ __name(async (nft) => {
383
- const result = Object.fromEntries(await Promise.all(Object.entries(scoringCriteria).map(async ([key, { score, weight }]) => {
384
- const rawScore = await score(nft);
385
- const weighted = rawScore.map((v) => v * weight);
386
- return [
387
- key,
388
- weighted
389
- ];
390
- })));
292
+ var analyzeNft = async (nft) => {
293
+ const result = Object.fromEntries(
294
+ await Promise.all(
295
+ Object.entries(scoringCriteria).map(async ([key, { score, weight }]) => {
296
+ const rawScore = await score(nft);
297
+ const weighted = rawScore.map((v) => v * weight);
298
+ return [key, weighted];
299
+ })
300
+ )
301
+ );
391
302
  return result;
392
- }, "analyzeNft");
303
+ };
393
304
 
394
305
  // src/Diviner.ts
395
- var toNftScorePayload = /* @__PURE__ */ __name((nftInfo, scores) => {
306
+ var toNftScorePayload = (nftInfo, scores) => {
396
307
  const { address, chainId, type } = nftInfo;
397
- return {
398
- address,
399
- chainId,
400
- schema: NftScoreSchema,
401
- scores,
402
- type
403
- };
404
- }, "toNftScorePayload");
405
- var isNftScore = /* @__PURE__ */ __name((payload) => payload.schema === NftScoreSchema, "isNftScore");
308
+ return { address, chainId, schema: NftScoreSchema, scores, type };
309
+ };
310
+ var isNftScore = (payload) => payload.schema === NftScoreSchema;
406
311
  var NftScoreDiviner = class extends AbstractDiviner {
407
- static {
408
- __name(this, "NftScoreDiviner");
409
- }
410
- static configSchemas = [
411
- ...super.configSchemas,
412
- NftScoreDivinerConfigSchema
413
- ];
312
+ static configSchemas = [...super.configSchemas, NftScoreDivinerConfigSchema];
414
313
  static defaultConfigSchema = NftScoreDivinerConfigSchema;
415
- divineHandler = /* @__PURE__ */ __name(async (payloads) => {
314
+ divineHandler = async (payloads) => {
416
315
  const nftInfos = payloads?.filter(isNftInfo) ?? [];
417
- const results = await Promise.all(nftInfos.map(async (nftInfo) => {
418
- const [score, sourceHash] = await Promise.all([
419
- // Analyze the NFT
420
- toNftScorePayload(nftInfo, await analyzeNft(nftInfo)),
421
- // Hash the source payload
422
- PayloadBuilder.dataHash(nftInfo)
423
- ]);
424
- return {
425
- ...score,
426
- sources: [
427
- sourceHash
428
- ]
429
- };
430
- }));
316
+ const results = await Promise.all(
317
+ nftInfos.map(async (nftInfo) => {
318
+ const [score, sourceHash] = await Promise.all([
319
+ // Analyze the NFT
320
+ toNftScorePayload(nftInfo, await analyzeNft(nftInfo)),
321
+ // Hash the source payload
322
+ PayloadBuilder.dataHash(nftInfo)
323
+ ]);
324
+ return { ...score, sources: [sourceHash] };
325
+ })
326
+ );
431
327
  return results;
432
- }, "divineHandler");
328
+ };
433
329
  };
434
330
 
435
331
  // src/Plugin.ts
436
332
  import { NftSchema } from "@xyo-network/crypto-nft-payload-plugin";
437
333
  import { PayloadSetSchema } from "@xyo-network/payload-model";
438
334
  import { createPayloadSetDivinerPlugin } from "@xyo-network/payloadset-plugin";
439
- var NftScoreDivinerPlugin = /* @__PURE__ */ __name(() => createPayloadSetDivinerPlugin({
440
- required: {
441
- [NftSchema]: 1
442
- },
443
- schema: PayloadSetSchema
444
- }, {
445
- diviner: /* @__PURE__ */ __name(async (params) => {
446
- const result = await NftScoreDiviner.create(params);
447
- return result;
448
- }, "diviner")
449
- }), "NftScoreDivinerPlugin");
335
+ var NftScoreDivinerPlugin = () => createPayloadSetDivinerPlugin(
336
+ { required: { [NftSchema]: 1 }, schema: PayloadSetSchema },
337
+ {
338
+ diviner: async (params) => {
339
+ const result = await NftScoreDiviner.create(params);
340
+ return result;
341
+ }
342
+ }
343
+ );
450
344
  export {
451
345
  NftScoreDiviner,
452
346
  NftScoreDivinerPlugin,