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