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