@xyo-network/crypto-nft-diviner-score-plugin 2.99.3 → 2.99.5
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 +1 -1
- package/dist/browser/Plugin.d.mts +1 -1
- package/dist/browser/Plugin.d.ts +1 -1
- package/dist/browser/index.cjs +233 -126
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.d.cts +3 -3
- package/dist/browser/index.d.mts +3 -3
- package/dist/browser/index.d.ts +3 -3
- package/dist/browser/{index.js → index.mjs} +237 -132
- package/dist/browser/index.mjs.map +1 -0
- package/dist/browser/lib/index.d.cts +1 -1
- package/dist/browser/lib/index.d.mts +1 -1
- package/dist/browser/lib/index.d.ts +1 -1
- package/dist/browser/lib/rating/analyzeNft.d.cts +1 -1
- package/dist/browser/lib/rating/analyzeNft.d.mts +1 -1
- package/dist/browser/lib/rating/analyzeNft.d.ts +1 -1
- package/dist/browser/lib/rating/criteria/index.d.cts +1 -1
- package/dist/browser/lib/rating/criteria/index.d.mts +1 -1
- package/dist/browser/lib/rating/criteria/index.d.ts +1 -1
- package/dist/browser/lib/rating/criteria/scoring/index.d.cts +5 -5
- package/dist/browser/lib/rating/criteria/scoring/index.d.mts +5 -5
- package/dist/browser/lib/rating/criteria/scoring/index.d.ts +5 -5
- package/dist/browser/lib/rating/criteria/scoring/metadata/attributes/index.d.cts +1 -1
- package/dist/browser/lib/rating/criteria/scoring/metadata/attributes/index.d.mts +1 -1
- package/dist/browser/lib/rating/criteria/scoring/metadata/attributes/index.d.ts +1 -1
- package/dist/browser/lib/rating/criteria/scoring/metadata/index.d.cts +9 -9
- package/dist/browser/lib/rating/criteria/scoring/metadata/index.d.mts +9 -9
- package/dist/browser/lib/rating/criteria/scoring/metadata/index.d.ts +9 -9
- package/dist/browser/lib/rating/criteria/scoring/metadata/lib/index.d.cts +1 -1
- package/dist/browser/lib/rating/criteria/scoring/metadata/lib/index.d.mts +1 -1
- package/dist/browser/lib/rating/criteria/scoring/metadata/lib/index.d.ts +1 -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.map +1 -1
- package/dist/browser/lib/rating/criteria/scoring/metadata/lib/urlHelpers.d.ts.map +1 -1
- package/dist/browser/lib/rating/index.d.cts +2 -2
- package/dist/browser/lib/rating/index.d.mts +2 -2
- package/dist/browser/lib/rating/index.d.ts +2 -2
- package/dist/neutral/Plugin.d.cts +1 -1
- package/dist/neutral/Plugin.d.mts +1 -1
- package/dist/neutral/Plugin.d.ts +1 -1
- package/dist/neutral/index.cjs +233 -126
- package/dist/neutral/index.cjs.map +1 -1
- package/dist/neutral/index.d.cts +3 -3
- package/dist/neutral/index.d.mts +3 -3
- package/dist/neutral/index.d.ts +3 -3
- package/dist/neutral/{index.js → index.mjs} +237 -132
- package/dist/neutral/index.mjs.map +1 -0
- package/dist/neutral/lib/index.d.cts +1 -1
- package/dist/neutral/lib/index.d.mts +1 -1
- package/dist/neutral/lib/index.d.ts +1 -1
- package/dist/neutral/lib/rating/analyzeNft.d.cts +1 -1
- package/dist/neutral/lib/rating/analyzeNft.d.mts +1 -1
- package/dist/neutral/lib/rating/analyzeNft.d.ts +1 -1
- package/dist/neutral/lib/rating/criteria/index.d.cts +1 -1
- package/dist/neutral/lib/rating/criteria/index.d.mts +1 -1
- package/dist/neutral/lib/rating/criteria/index.d.ts +1 -1
- package/dist/neutral/lib/rating/criteria/scoring/index.d.cts +5 -5
- package/dist/neutral/lib/rating/criteria/scoring/index.d.mts +5 -5
- package/dist/neutral/lib/rating/criteria/scoring/index.d.ts +5 -5
- package/dist/neutral/lib/rating/criteria/scoring/metadata/attributes/index.d.cts +1 -1
- package/dist/neutral/lib/rating/criteria/scoring/metadata/attributes/index.d.mts +1 -1
- package/dist/neutral/lib/rating/criteria/scoring/metadata/attributes/index.d.ts +1 -1
- package/dist/neutral/lib/rating/criteria/scoring/metadata/index.d.cts +9 -9
- package/dist/neutral/lib/rating/criteria/scoring/metadata/index.d.mts +9 -9
- package/dist/neutral/lib/rating/criteria/scoring/metadata/index.d.ts +9 -9
- package/dist/neutral/lib/rating/criteria/scoring/metadata/lib/index.d.cts +1 -1
- package/dist/neutral/lib/rating/criteria/scoring/metadata/lib/index.d.mts +1 -1
- package/dist/neutral/lib/rating/criteria/scoring/metadata/lib/index.d.ts +1 -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.map +1 -1
- package/dist/neutral/lib/rating/criteria/scoring/metadata/lib/urlHelpers.d.ts.map +1 -1
- package/dist/neutral/lib/rating/index.d.cts +2 -2
- package/dist/neutral/lib/rating/index.d.mts +2 -2
- package/dist/neutral/lib/rating/index.d.ts +2 -2
- package/dist/node/Plugin.d.cts +1 -1
- package/dist/node/Plugin.d.mts +1 -1
- package/dist/node/Plugin.d.ts +1 -1
- package/dist/node/index.cjs +244 -133
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +3 -3
- package/dist/node/index.d.mts +3 -3
- package/dist/node/index.d.ts +3 -3
- package/dist/node/{index.js → index.mjs} +248 -139
- package/dist/node/index.mjs.map +1 -0
- package/dist/node/lib/index.d.cts +1 -1
- package/dist/node/lib/index.d.mts +1 -1
- package/dist/node/lib/index.d.ts +1 -1
- package/dist/node/lib/rating/analyzeNft.d.cts +1 -1
- package/dist/node/lib/rating/analyzeNft.d.mts +1 -1
- package/dist/node/lib/rating/analyzeNft.d.ts +1 -1
- package/dist/node/lib/rating/criteria/index.d.cts +1 -1
- package/dist/node/lib/rating/criteria/index.d.mts +1 -1
- package/dist/node/lib/rating/criteria/index.d.ts +1 -1
- package/dist/node/lib/rating/criteria/scoring/index.d.cts +5 -5
- package/dist/node/lib/rating/criteria/scoring/index.d.mts +5 -5
- package/dist/node/lib/rating/criteria/scoring/index.d.ts +5 -5
- package/dist/node/lib/rating/criteria/scoring/metadata/attributes/index.d.cts +1 -1
- package/dist/node/lib/rating/criteria/scoring/metadata/attributes/index.d.mts +1 -1
- package/dist/node/lib/rating/criteria/scoring/metadata/attributes/index.d.ts +1 -1
- package/dist/node/lib/rating/criteria/scoring/metadata/index.d.cts +9 -9
- package/dist/node/lib/rating/criteria/scoring/metadata/index.d.mts +9 -9
- package/dist/node/lib/rating/criteria/scoring/metadata/index.d.ts +9 -9
- package/dist/node/lib/rating/criteria/scoring/metadata/lib/index.d.cts +1 -1
- package/dist/node/lib/rating/criteria/scoring/metadata/lib/index.d.mts +1 -1
- package/dist/node/lib/rating/criteria/scoring/metadata/lib/index.d.ts +1 -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.map +1 -1
- package/dist/node/lib/rating/criteria/scoring/metadata/lib/urlHelpers.d.ts.map +1 -1
- package/dist/node/lib/rating/index.d.cts +2 -2
- package/dist/node/lib/rating/index.d.mts +2 -2
- package/dist/node/lib/rating/index.d.ts +2 -2
- package/package.json +19 -20
- package/src/Diviner.ts +1 -1
- package/src/Plugin.ts +1 -1
- package/src/index.ts +3 -3
- package/src/lib/index.ts +1 -1
- package/src/lib/rating/analyzeNft.ts +2 -2
- package/src/lib/rating/criteria/index.ts +1 -1
- package/src/lib/rating/criteria/scoring/index.ts +5 -5
- package/src/lib/rating/criteria/scoring/metadata/animationUrl.ts +1 -1
- package/src/lib/rating/criteria/scoring/metadata/attributes/index.ts +1 -1
- package/src/lib/rating/criteria/scoring/metadata/externalUrl.ts +1 -1
- package/src/lib/rating/criteria/scoring/metadata/image.ts +1 -1
- package/src/lib/rating/criteria/scoring/metadata/imageData.ts +2 -2
- package/src/lib/rating/criteria/scoring/metadata/index.ts +9 -9
- package/src/lib/rating/criteria/scoring/metadata/lib/index.ts +1 -1
- package/src/lib/rating/criteria/scoring/metadata/lib/urlHelpers.ts +1 -1
- package/src/lib/rating/criteria/scoring/metadata/youtubeUrl.ts +1 -1
- package/src/lib/rating/criteria/scoringCriteria.ts +6 -6
- package/src/lib/rating/index.ts +2 -2
- package/dist/browser/index.js.map +0 -1
- package/dist/neutral/index.js.map +0 -1
- package/dist/node/index.js.map +0 -1
|
@@ -1,53 +1,63 @@
|
|
|
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
|
+
|
|
1
9
|
// src/Diviner.ts
|
|
2
|
-
import {
|
|
3
|
-
isNftInfo,
|
|
4
|
-
NftScoreDivinerConfigSchema,
|
|
5
|
-
NftScoreSchema
|
|
6
|
-
} from "@xyo-network/crypto-nft-payload-plugin";
|
|
10
|
+
import { isNftInfo, NftScoreDivinerConfigSchema, NftScoreSchema } from "@xyo-network/crypto-nft-payload-plugin";
|
|
7
11
|
import { AbstractDiviner } from "@xyo-network/diviner-abstract";
|
|
8
12
|
import { PayloadBuilder } from "@xyo-network/payload-builder";
|
|
9
13
|
|
|
10
14
|
// src/lib/rating/criteria/scoring/contract.ts
|
|
11
15
|
import { FAIL, PASS } from "@xyo-network/crypto-nft-score-model";
|
|
12
16
|
import { isAddress } from "ethers";
|
|
13
|
-
var scoreContractAddress = (nft) => {
|
|
17
|
+
var scoreContractAddress = /* @__PURE__ */ __name((nft) => {
|
|
14
18
|
if (!nft.address) return FAIL;
|
|
15
19
|
if (typeof nft.address !== "string") return FAIL;
|
|
16
20
|
if (!isAddress(nft.address)) return FAIL;
|
|
17
21
|
return PASS;
|
|
18
|
-
};
|
|
22
|
+
}, "scoreContractAddress");
|
|
19
23
|
|
|
20
24
|
// src/lib/rating/criteria/scoring/metadata/animationUrl.ts
|
|
21
25
|
import { incrementPossible, incrementTotal, incrementTotalAndPossible, PASS as PASS2 } from "@xyo-network/crypto-nft-score-model";
|
|
22
26
|
|
|
23
27
|
// src/lib/rating/criteria/scoring/metadata/lib/urlHelpers.ts
|
|
24
28
|
import { URL } from "@xylabs/url";
|
|
25
|
-
var web3Protocols = [
|
|
26
|
-
|
|
29
|
+
var web3Protocols = [
|
|
30
|
+
"ipfs:",
|
|
31
|
+
"ar:"
|
|
32
|
+
];
|
|
33
|
+
var toUrl = /* @__PURE__ */ __name((url) => {
|
|
27
34
|
if (!url) return void 0;
|
|
28
35
|
try {
|
|
29
36
|
return new URL(url);
|
|
30
37
|
} catch {
|
|
31
38
|
return void 0;
|
|
32
39
|
}
|
|
33
|
-
};
|
|
34
|
-
var isValidUrl = (url) => toUrl(url) !== void 0;
|
|
35
|
-
var isWeb3 = (url) => web3Protocols.some((protocol) => {
|
|
40
|
+
}, "toUrl");
|
|
41
|
+
var isValidUrl = /* @__PURE__ */ __name((url) => toUrl(url) !== void 0, "isValidUrl");
|
|
42
|
+
var isWeb3 = /* @__PURE__ */ __name((url) => web3Protocols.some((protocol) => {
|
|
36
43
|
var _a;
|
|
37
44
|
return protocol === ((_a = toUrl(url)) == null ? void 0 : _a.protocol);
|
|
38
|
-
});
|
|
39
|
-
var isSecure = (url) => {
|
|
45
|
+
}), "isWeb3");
|
|
46
|
+
var isSecure = /* @__PURE__ */ __name((url) => {
|
|
40
47
|
var _a;
|
|
41
48
|
return isWeb3(url) || ((_a = toUrl(url)) == null ? void 0 : _a.protocol) === "https:";
|
|
42
|
-
};
|
|
49
|
+
}, "isSecure");
|
|
43
50
|
|
|
44
51
|
// src/lib/rating/criteria/scoring/metadata/animationUrl.ts
|
|
45
|
-
var scoreNftAnimationUrl = (nft) => {
|
|
52
|
+
var scoreNftAnimationUrl = /* @__PURE__ */ __name((nft) => {
|
|
46
53
|
var _a;
|
|
47
54
|
return scoreAnimationUrl((_a = nft.metadata) == null ? void 0 : _a.animation_url);
|
|
48
|
-
};
|
|
49
|
-
var scoreAnimationUrl = (animation_url) => {
|
|
50
|
-
const score = [
|
|
55
|
+
}, "scoreNftAnimationUrl");
|
|
56
|
+
var scoreAnimationUrl = /* @__PURE__ */ __name((animation_url) => {
|
|
57
|
+
const score = [
|
|
58
|
+
0,
|
|
59
|
+
0
|
|
60
|
+
];
|
|
51
61
|
if (animation_url === void 0 || animation_url === null) return PASS2;
|
|
52
62
|
incrementPossible(score);
|
|
53
63
|
if (typeof animation_url !== "string") return score;
|
|
@@ -58,11 +68,11 @@ var scoreAnimationUrl = (animation_url) => {
|
|
|
58
68
|
incrementTotalAndPossible(score);
|
|
59
69
|
if (!isWeb3(animation_url)) return score;
|
|
60
70
|
return incrementTotal(score);
|
|
61
|
-
};
|
|
71
|
+
}, "scoreAnimationUrl");
|
|
62
72
|
|
|
63
73
|
// src/lib/rating/criteria/scoring/metadata/attributes/evaluateAttributes.ts
|
|
64
74
|
import { incrementPossible as incrementPossible2, incrementTotal as incrementTotal2, incrementTotalAndPossible as incrementTotalAndPossible2 } from "@xyo-network/crypto-nft-score-model";
|
|
65
|
-
var isDate = (value) => {
|
|
75
|
+
var isDate = /* @__PURE__ */ __name((value) => {
|
|
66
76
|
if (isNumber(value)) {
|
|
67
77
|
try {
|
|
68
78
|
new Date(value);
|
|
@@ -72,26 +82,41 @@ var isDate = (value) => {
|
|
|
72
82
|
}
|
|
73
83
|
}
|
|
74
84
|
return false;
|
|
75
|
-
};
|
|
76
|
-
var isNumber = (value) => typeof value === "number";
|
|
77
|
-
var isPercentage = (value) => isNumber(value) && value >= 0 && value <= 100;
|
|
78
|
-
var isNonEmptyString = (value) => typeof value === "string" && value.length > 0;
|
|
79
|
-
var isNonEmptyStringOrNumber = (value) => value === "number" || isNonEmptyString(value);
|
|
80
|
-
var evaluateNftAttributes = (nft) => {
|
|
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) => {
|
|
81
91
|
var _a, _b;
|
|
82
|
-
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) : [
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
+
];
|
|
87
106
|
for (const attribute of attributes) {
|
|
88
107
|
const [attributeTotal, attributePossible] = evaluateAttribute(attribute);
|
|
89
108
|
incrementTotalAndPossible2(score, attributeTotal, attributePossible);
|
|
90
109
|
}
|
|
91
|
-
return [
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
110
|
+
return [
|
|
111
|
+
1,
|
|
112
|
+
1
|
|
113
|
+
];
|
|
114
|
+
}, "evaluateAttributes");
|
|
115
|
+
var evaluateAttribute = /* @__PURE__ */ __name((attribute) => {
|
|
116
|
+
const score = [
|
|
117
|
+
0,
|
|
118
|
+
1
|
|
119
|
+
];
|
|
95
120
|
const max_value = attribute == null ? void 0 : attribute.max_value;
|
|
96
121
|
const trait_type = attribute == null ? void 0 : attribute.trait_type;
|
|
97
122
|
const value = attribute == null ? void 0 : attribute.value;
|
|
@@ -104,8 +129,8 @@ var evaluateAttribute = (attribute) => {
|
|
|
104
129
|
if (isNumber(max_value) && isNumber(value) && value <= max_value) incrementTotal2(score);
|
|
105
130
|
}
|
|
106
131
|
return score;
|
|
107
|
-
};
|
|
108
|
-
var validDisplayType = (attribute) => {
|
|
132
|
+
}, "evaluateAttribute");
|
|
133
|
+
var validDisplayType = /* @__PURE__ */ __name((attribute) => {
|
|
109
134
|
switch (attribute == null ? void 0 : attribute.display_type) {
|
|
110
135
|
case "number":
|
|
111
136
|
case "boost_number": {
|
|
@@ -130,64 +155,79 @@ var validDisplayType = (attribute) => {
|
|
|
130
155
|
}
|
|
131
156
|
}
|
|
132
157
|
return false;
|
|
133
|
-
};
|
|
158
|
+
}, "validDisplayType");
|
|
134
159
|
|
|
135
160
|
// src/lib/rating/criteria/scoring/metadata/backgroundColor.ts
|
|
136
161
|
import { incrementPossible as incrementPossible3, incrementTotal as incrementTotal3, incrementTotalAndPossible as incrementTotalAndPossible3, PASS as PASS3 } from "@xyo-network/crypto-nft-score-model";
|
|
137
162
|
var isHexColor = /^[\da-f]{6}$/i;
|
|
138
|
-
var scoreNftBackgroundColor = (nft) => {
|
|
163
|
+
var scoreNftBackgroundColor = /* @__PURE__ */ __name((nft) => {
|
|
139
164
|
var _a;
|
|
140
165
|
return scoreBackgroundColor((_a = nft.metadata) == null ? void 0 : _a.background_color);
|
|
141
|
-
};
|
|
142
|
-
var scoreBackgroundColor = (background_color) => {
|
|
143
|
-
const score = [
|
|
166
|
+
}, "scoreNftBackgroundColor");
|
|
167
|
+
var scoreBackgroundColor = /* @__PURE__ */ __name((background_color) => {
|
|
168
|
+
const score = [
|
|
169
|
+
0,
|
|
170
|
+
0
|
|
171
|
+
];
|
|
144
172
|
if (background_color === void 0 || background_color === null) return PASS3;
|
|
145
173
|
incrementPossible3(score);
|
|
146
174
|
if (typeof background_color !== "string") return score;
|
|
147
175
|
incrementTotalAndPossible3(score);
|
|
148
176
|
if (!isHexColor.test(background_color.toUpperCase())) return score;
|
|
149
177
|
return incrementTotal3(score);
|
|
150
|
-
};
|
|
178
|
+
}, "scoreBackgroundColor");
|
|
151
179
|
|
|
152
180
|
// src/lib/rating/criteria/scoring/metadata/description.ts
|
|
153
181
|
import { incrementTotal as incrementTotal4 } from "@xyo-network/crypto-nft-score-model";
|
|
154
|
-
var scoreNftDescription = (nft) => {
|
|
182
|
+
var scoreNftDescription = /* @__PURE__ */ __name((nft) => {
|
|
155
183
|
var _a;
|
|
156
184
|
return scoreDescription((_a = nft.metadata) == null ? void 0 : _a.description);
|
|
157
|
-
};
|
|
158
|
-
var scoreDescription = (description) => {
|
|
159
|
-
const score = [
|
|
185
|
+
}, "scoreNftDescription");
|
|
186
|
+
var scoreDescription = /* @__PURE__ */ __name((description) => {
|
|
187
|
+
const score = [
|
|
188
|
+
0,
|
|
189
|
+
1
|
|
190
|
+
];
|
|
160
191
|
if (!description || typeof description !== "string") return score;
|
|
161
192
|
return incrementTotal4(score);
|
|
162
|
-
};
|
|
193
|
+
}, "scoreDescription");
|
|
163
194
|
|
|
164
195
|
// src/lib/rating/criteria/scoring/metadata/externalUrl.ts
|
|
165
196
|
import { incrementTotal as incrementTotal5 } from "@xyo-network/crypto-nft-score-model";
|
|
166
|
-
var scoreNftExternalUrl = (nft) => {
|
|
197
|
+
var scoreNftExternalUrl = /* @__PURE__ */ __name((nft) => {
|
|
167
198
|
var _a;
|
|
168
199
|
return scoreExternalUrl((_a = nft == null ? void 0 : nft.metadata) == null ? void 0 : _a.external_url);
|
|
169
|
-
};
|
|
170
|
-
var scoreExternalUrl = (external_url) => {
|
|
171
|
-
const score = [
|
|
200
|
+
}, "scoreNftExternalUrl");
|
|
201
|
+
var scoreExternalUrl = /* @__PURE__ */ __name((external_url) => {
|
|
202
|
+
const score = [
|
|
203
|
+
0,
|
|
204
|
+
2
|
|
205
|
+
];
|
|
172
206
|
if (external_url === void 0 || external_url === null || typeof external_url !== "string" || !isValidUrl(external_url)) return score;
|
|
173
207
|
incrementTotal5(score);
|
|
174
208
|
if (!isSecure(external_url)) return score;
|
|
175
209
|
return incrementTotal5(score);
|
|
176
|
-
};
|
|
210
|
+
}, "scoreExternalUrl");
|
|
177
211
|
|
|
178
212
|
// src/lib/rating/criteria/scoring/metadata/image.ts
|
|
179
213
|
import { incrementTotal as incrementTotal6, PASS as PASS4 } from "@xyo-network/crypto-nft-score-model";
|
|
180
214
|
var MaxPossibleImageScore = 3;
|
|
181
|
-
var scoreNftImage = (nft) => {
|
|
215
|
+
var scoreNftImage = /* @__PURE__ */ __name((nft) => {
|
|
182
216
|
var _a, _b, _c;
|
|
183
217
|
if ((_a = nft == null ? void 0 : nft.metadata) == null ? void 0 : _a.image) {
|
|
184
218
|
return scoreImage((_b = nft.metadata) == null ? void 0 : _b.image);
|
|
185
219
|
} else {
|
|
186
|
-
return ((_c = nft.metadata) == null ? void 0 : _c.image_data) ? PASS4 : [
|
|
220
|
+
return ((_c = nft.metadata) == null ? void 0 : _c.image_data) ? PASS4 : [
|
|
221
|
+
0,
|
|
222
|
+
MaxPossibleImageScore
|
|
223
|
+
];
|
|
187
224
|
}
|
|
188
|
-
};
|
|
189
|
-
var scoreImage = (image) => {
|
|
190
|
-
const score = [
|
|
225
|
+
}, "scoreNftImage");
|
|
226
|
+
var scoreImage = /* @__PURE__ */ __name((image) => {
|
|
227
|
+
const score = [
|
|
228
|
+
0,
|
|
229
|
+
MaxPossibleImageScore
|
|
230
|
+
];
|
|
191
231
|
if (!image || typeof image !== "string" || !isValidUrl(image)) return score;
|
|
192
232
|
incrementTotal6(score);
|
|
193
233
|
if (!isSecure(image)) return score;
|
|
@@ -195,13 +235,13 @@ var scoreImage = (image) => {
|
|
|
195
235
|
if (!isWeb3(image)) return score;
|
|
196
236
|
incrementTotal6(score);
|
|
197
237
|
return score;
|
|
198
|
-
};
|
|
238
|
+
}, "scoreImage");
|
|
199
239
|
|
|
200
240
|
// src/lib/rating/criteria/scoring/metadata/imageData.ts
|
|
201
241
|
import { PASS as PASS5 } from "@xyo-network/crypto-nft-score-model";
|
|
202
242
|
import { parse } from "svg-parser";
|
|
203
243
|
var MaxPossibleImageDataScore = 1;
|
|
204
|
-
var isValidImageData = (image_data) => {
|
|
244
|
+
var isValidImageData = /* @__PURE__ */ __name((image_data) => {
|
|
205
245
|
if (!image_data.startsWith("<svg")) return false;
|
|
206
246
|
try {
|
|
207
247
|
parse(image_data);
|
|
@@ -209,49 +249,64 @@ var isValidImageData = (image_data) => {
|
|
|
209
249
|
} catch {
|
|
210
250
|
return false;
|
|
211
251
|
}
|
|
212
|
-
};
|
|
213
|
-
var scoreNftImageData = (nft) => {
|
|
252
|
+
}, "isValidImageData");
|
|
253
|
+
var scoreNftImageData = /* @__PURE__ */ __name((nft) => {
|
|
214
254
|
var _a, _b, _c;
|
|
215
255
|
if ((_a = nft == null ? void 0 : nft.metadata) == null ? void 0 : _a.image_data) {
|
|
216
256
|
return scoreImageData((_b = nft.metadata) == null ? void 0 : _b.image_data);
|
|
217
257
|
} else {
|
|
218
|
-
return ((_c = nft.metadata) == null ? void 0 : _c.image) ? PASS5 : [
|
|
258
|
+
return ((_c = nft.metadata) == null ? void 0 : _c.image) ? PASS5 : [
|
|
259
|
+
0,
|
|
260
|
+
MaxPossibleImageDataScore
|
|
261
|
+
];
|
|
219
262
|
}
|
|
220
|
-
};
|
|
221
|
-
var scoreImageData = (image_data) => {
|
|
222
|
-
return !image_data || typeof image_data !== "string" || !isValidImageData(image_data) ? [
|
|
223
|
-
|
|
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");
|
|
224
273
|
|
|
225
274
|
// src/lib/rating/criteria/scoring/metadata/name.ts
|
|
226
275
|
import { incrementTotal as incrementTotal7 } from "@xyo-network/crypto-nft-score-model";
|
|
227
|
-
var scoreNftName = (nft) => {
|
|
276
|
+
var scoreNftName = /* @__PURE__ */ __name((nft) => {
|
|
228
277
|
var _a;
|
|
229
278
|
return scoreName((_a = nft.metadata) == null ? void 0 : _a.name);
|
|
230
|
-
};
|
|
231
|
-
var scoreName = (name) => {
|
|
232
|
-
const score = [
|
|
279
|
+
}, "scoreNftName");
|
|
280
|
+
var scoreName = /* @__PURE__ */ __name((name) => {
|
|
281
|
+
const score = [
|
|
282
|
+
0,
|
|
283
|
+
1
|
|
284
|
+
];
|
|
233
285
|
if (!name || typeof name !== "string") return score;
|
|
234
286
|
return incrementTotal7(score);
|
|
235
|
-
};
|
|
287
|
+
}, "scoreName");
|
|
236
288
|
|
|
237
289
|
// src/lib/rating/criteria/scoring/metadata/youtubeUrl.ts
|
|
238
290
|
import { incrementTotal as incrementTotal8, PASS as PASS6 } from "@xyo-network/crypto-nft-score-model";
|
|
239
|
-
var scoreNftYoutubeUrl = (nft) => {
|
|
291
|
+
var scoreNftYoutubeUrl = /* @__PURE__ */ __name((nft) => {
|
|
240
292
|
var _a;
|
|
241
293
|
return scoreYoutubeUrl((_a = nft == null ? void 0 : nft.metadata) == null ? void 0 : _a.youtube_url);
|
|
242
|
-
};
|
|
243
|
-
var scoreYoutubeUrl = (youtube_url) => {
|
|
294
|
+
}, "scoreNftYoutubeUrl");
|
|
295
|
+
var scoreYoutubeUrl = /* @__PURE__ */ __name((youtube_url) => {
|
|
244
296
|
if (youtube_url === void 0 || youtube_url === null) return PASS6;
|
|
245
|
-
const score = [
|
|
297
|
+
const score = [
|
|
298
|
+
0,
|
|
299
|
+
2
|
|
300
|
+
];
|
|
246
301
|
if (typeof youtube_url !== "string" || !isValidUrl(youtube_url)) return score;
|
|
247
302
|
incrementTotal8(score);
|
|
248
303
|
if (!isSecure(youtube_url)) return score;
|
|
249
304
|
return incrementTotal8(score);
|
|
250
|
-
};
|
|
305
|
+
}, "scoreYoutubeUrl");
|
|
251
306
|
|
|
252
307
|
// src/lib/rating/criteria/scoring/supply.ts
|
|
253
308
|
import { FAIL as FAIL2, PASS as PASS7 } from "@xyo-network/crypto-nft-score-model";
|
|
254
|
-
var scoreSupply = (nft) => {
|
|
309
|
+
var scoreSupply = /* @__PURE__ */ __name((nft) => {
|
|
255
310
|
if (!nft.supply) return FAIL2;
|
|
256
311
|
if (typeof nft.supply !== "string") return FAIL2;
|
|
257
312
|
try {
|
|
@@ -259,11 +314,11 @@ var scoreSupply = (nft) => {
|
|
|
259
314
|
} catch {
|
|
260
315
|
return FAIL2;
|
|
261
316
|
}
|
|
262
|
-
};
|
|
317
|
+
}, "scoreSupply");
|
|
263
318
|
|
|
264
319
|
// src/lib/rating/criteria/scoring/tokenId.ts
|
|
265
320
|
import { FAIL as FAIL3, PASS as PASS8 } from "@xyo-network/crypto-nft-score-model";
|
|
266
|
-
var scoreTokenId = (nft) => {
|
|
321
|
+
var scoreTokenId = /* @__PURE__ */ __name((nft) => {
|
|
267
322
|
if (!nft.tokenId) return FAIL3;
|
|
268
323
|
if (typeof nft.tokenId !== "string") return FAIL3;
|
|
269
324
|
try {
|
|
@@ -271,94 +326,148 @@ var scoreTokenId = (nft) => {
|
|
|
271
326
|
} catch {
|
|
272
327
|
return FAIL3;
|
|
273
328
|
}
|
|
274
|
-
};
|
|
329
|
+
}, "scoreTokenId");
|
|
275
330
|
|
|
276
331
|
// src/lib/rating/criteria/scoring/type.ts
|
|
277
332
|
import { FAIL as FAIL4, PASS as PASS9 } from "@xyo-network/crypto-nft-score-model";
|
|
278
|
-
var scoreType = (nft) => {
|
|
333
|
+
var scoreType = /* @__PURE__ */ __name((nft) => {
|
|
279
334
|
if (!nft.type) return FAIL4;
|
|
280
335
|
if (typeof nft.type !== "string") return FAIL4;
|
|
281
336
|
const type = nft.type.toUpperCase();
|
|
282
337
|
if (type !== "ERC721" && type !== "ERC1155") return FAIL4;
|
|
283
338
|
return PASS9;
|
|
284
|
-
};
|
|
339
|
+
}, "scoreType");
|
|
285
340
|
|
|
286
341
|
// src/lib/rating/criteria/scoringCriteria.ts
|
|
287
342
|
var attributesScoringCriteria = {
|
|
288
|
-
Attributes: {
|
|
343
|
+
Attributes: {
|
|
344
|
+
score: evaluateNftAttributes,
|
|
345
|
+
weight: 1
|
|
346
|
+
}
|
|
289
347
|
};
|
|
290
348
|
var metadataScoringCriteria = {
|
|
291
|
-
"Animation URL": {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
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
|
+
},
|
|
299
381
|
...attributesScoringCriteria
|
|
300
382
|
};
|
|
301
383
|
var scoringCriteria = {
|
|
302
|
-
"Contract Address": {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
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
|
+
},
|
|
306
400
|
...metadataScoringCriteria
|
|
307
401
|
};
|
|
308
402
|
|
|
309
403
|
// src/lib/rating/analyzeNft.ts
|
|
310
|
-
var analyzeNft = async (nft) => {
|
|
311
|
-
const result = Object.fromEntries(
|
|
312
|
-
await
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
);
|
|
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
|
+
})));
|
|
320
413
|
return result;
|
|
321
|
-
};
|
|
414
|
+
}, "analyzeNft");
|
|
322
415
|
|
|
323
416
|
// src/Diviner.ts
|
|
324
|
-
var toNftScorePayload = (nftInfo, scores) => {
|
|
417
|
+
var toNftScorePayload = /* @__PURE__ */ __name((nftInfo, scores) => {
|
|
325
418
|
const { address, chainId, type } = nftInfo;
|
|
326
|
-
return {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
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) => {
|
|
333
430
|
const nftInfos = (payloads == null ? void 0 : payloads.filter(isNftInfo)) ?? [];
|
|
334
|
-
const results = await Promise.all(
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
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
|
+
}));
|
|
345
445
|
return results;
|
|
346
|
-
};
|
|
347
|
-
};
|
|
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;
|
|
348
455
|
|
|
349
456
|
// src/Plugin.ts
|
|
350
457
|
import { NftSchema } from "@xyo-network/crypto-nft-payload-plugin";
|
|
351
458
|
import { PayloadSetSchema } from "@xyo-network/payload-model";
|
|
352
459
|
import { createPayloadSetDivinerPlugin } from "@xyo-network/payloadset-plugin";
|
|
353
|
-
var NftScoreDivinerPlugin = () => createPayloadSetDivinerPlugin(
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
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");
|
|
362
471
|
export {
|
|
363
472
|
NftScoreDiviner,
|
|
364
473
|
NftScoreDivinerPlugin,
|
|
@@ -367,4 +476,4 @@ export {
|
|
|
367
476
|
isNftScore,
|
|
368
477
|
scoringCriteria
|
|
369
478
|
};
|
|
370
|
-
//# sourceMappingURL=index.
|
|
479
|
+
//# sourceMappingURL=index.mjs.map
|