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