@xyo-network/crypto-nft-diviner-score-plugin 5.3.2 → 5.3.4
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/Diviner.d.ts +13 -0
- package/dist/browser/Diviner.d.ts.map +1 -0
- package/dist/browser/Plugin.d.ts +3 -0
- package/dist/browser/Plugin.d.ts.map +1 -0
- package/dist/browser/index.d.ts +4 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.mjs +374 -0
- package/dist/browser/index.mjs.map +1 -0
- package/dist/browser/lib/index.d.ts +2 -0
- package/dist/browser/lib/index.d.ts.map +1 -0
- package/dist/browser/lib/rating/analyzeNft.d.ts +13 -0
- package/dist/browser/lib/rating/analyzeNft.d.ts.map +1 -0
- package/dist/browser/lib/rating/criteria/index.d.ts +2 -0
- package/dist/browser/lib/rating/criteria/index.d.ts.map +1 -0
- package/dist/browser/lib/rating/criteria/scoring/contract.d.ts +4 -0
- package/dist/browser/lib/rating/criteria/scoring/contract.d.ts.map +1 -0
- package/dist/browser/lib/rating/criteria/scoring/index.d.ts +6 -0
- package/dist/browser/lib/rating/criteria/scoring/index.d.ts.map +1 -0
- package/dist/browser/lib/rating/criteria/scoring/metadata/animationUrl.d.ts +5 -0
- package/dist/browser/lib/rating/criteria/scoring/metadata/animationUrl.d.ts.map +1 -0
- package/dist/browser/lib/rating/criteria/scoring/metadata/attributes/evaluateAttributes.d.ts +6 -0
- package/dist/browser/lib/rating/criteria/scoring/metadata/attributes/evaluateAttributes.d.ts.map +1 -0
- package/dist/browser/lib/rating/criteria/scoring/metadata/attributes/index.d.ts +2 -0
- package/dist/browser/lib/rating/criteria/scoring/metadata/attributes/index.d.ts.map +1 -0
- package/dist/browser/lib/rating/criteria/scoring/metadata/backgroundColor.d.ts +5 -0
- package/dist/browser/lib/rating/criteria/scoring/metadata/backgroundColor.d.ts.map +1 -0
- package/dist/browser/lib/rating/criteria/scoring/metadata/description.d.ts +5 -0
- package/dist/browser/lib/rating/criteria/scoring/metadata/description.d.ts.map +1 -0
- package/dist/browser/lib/rating/criteria/scoring/metadata/externalUrl.d.ts +5 -0
- package/dist/browser/lib/rating/criteria/scoring/metadata/externalUrl.d.ts.map +1 -0
- package/dist/browser/lib/rating/criteria/scoring/metadata/image.d.ts +5 -0
- package/dist/browser/lib/rating/criteria/scoring/metadata/image.d.ts.map +1 -0
- package/dist/browser/lib/rating/criteria/scoring/metadata/imageData.d.ts +5 -0
- package/dist/browser/lib/rating/criteria/scoring/metadata/imageData.d.ts.map +1 -0
- package/dist/browser/lib/rating/criteria/scoring/metadata/index.d.ts +10 -0
- package/dist/browser/lib/rating/criteria/scoring/metadata/index.d.ts.map +1 -0
- package/dist/browser/lib/rating/criteria/scoring/metadata/lib/index.d.ts +2 -0
- package/dist/browser/lib/rating/criteria/scoring/metadata/lib/index.d.ts.map +1 -0
- package/dist/browser/lib/rating/criteria/scoring/metadata/lib/urlHelpers.d.ts +7 -0
- package/dist/browser/lib/rating/criteria/scoring/metadata/lib/urlHelpers.d.ts.map +1 -0
- package/dist/browser/lib/rating/criteria/scoring/metadata/name.d.ts +5 -0
- package/dist/browser/lib/rating/criteria/scoring/metadata/name.d.ts.map +1 -0
- package/dist/browser/lib/rating/criteria/scoring/metadata/youtubeUrl.d.ts +5 -0
- package/dist/browser/lib/rating/criteria/scoring/metadata/youtubeUrl.d.ts.map +1 -0
- package/dist/browser/lib/rating/criteria/scoring/supply.d.ts +4 -0
- package/dist/browser/lib/rating/criteria/scoring/supply.d.ts.map +1 -0
- package/dist/browser/lib/rating/criteria/scoring/tokenId.d.ts +10 -0
- package/dist/browser/lib/rating/criteria/scoring/tokenId.d.ts.map +1 -0
- package/dist/browser/lib/rating/criteria/scoring/type.d.ts +4 -0
- package/dist/browser/lib/rating/criteria/scoring/type.d.ts.map +1 -0
- package/dist/browser/lib/rating/criteria/scoringCriteria.d.ts +55 -0
- package/dist/browser/lib/rating/criteria/scoringCriteria.d.ts.map +1 -0
- package/dist/browser/lib/rating/index.d.ts +3 -0
- package/dist/browser/lib/rating/index.d.ts.map +1 -0
- package/dist/neutral/Diviner.d.ts +13 -0
- package/dist/neutral/Diviner.d.ts.map +1 -0
- package/dist/neutral/Plugin.d.ts +3 -0
- package/dist/neutral/Plugin.d.ts.map +1 -0
- package/dist/neutral/index.d.ts +4 -0
- package/dist/neutral/index.d.ts.map +1 -0
- package/dist/neutral/index.mjs +374 -0
- package/dist/neutral/index.mjs.map +1 -0
- package/dist/neutral/lib/index.d.ts +2 -0
- package/dist/neutral/lib/index.d.ts.map +1 -0
- package/dist/neutral/lib/rating/analyzeNft.d.ts +13 -0
- package/dist/neutral/lib/rating/analyzeNft.d.ts.map +1 -0
- package/dist/neutral/lib/rating/criteria/index.d.ts +2 -0
- package/dist/neutral/lib/rating/criteria/index.d.ts.map +1 -0
- package/dist/neutral/lib/rating/criteria/scoring/contract.d.ts +4 -0
- package/dist/neutral/lib/rating/criteria/scoring/contract.d.ts.map +1 -0
- package/dist/neutral/lib/rating/criteria/scoring/index.d.ts +6 -0
- package/dist/neutral/lib/rating/criteria/scoring/index.d.ts.map +1 -0
- package/dist/neutral/lib/rating/criteria/scoring/metadata/animationUrl.d.ts +5 -0
- package/dist/neutral/lib/rating/criteria/scoring/metadata/animationUrl.d.ts.map +1 -0
- package/dist/neutral/lib/rating/criteria/scoring/metadata/attributes/evaluateAttributes.d.ts +6 -0
- package/dist/neutral/lib/rating/criteria/scoring/metadata/attributes/evaluateAttributes.d.ts.map +1 -0
- package/dist/neutral/lib/rating/criteria/scoring/metadata/attributes/index.d.ts +2 -0
- package/dist/neutral/lib/rating/criteria/scoring/metadata/attributes/index.d.ts.map +1 -0
- package/dist/neutral/lib/rating/criteria/scoring/metadata/backgroundColor.d.ts +5 -0
- package/dist/neutral/lib/rating/criteria/scoring/metadata/backgroundColor.d.ts.map +1 -0
- package/dist/neutral/lib/rating/criteria/scoring/metadata/description.d.ts +5 -0
- package/dist/neutral/lib/rating/criteria/scoring/metadata/description.d.ts.map +1 -0
- package/dist/neutral/lib/rating/criteria/scoring/metadata/externalUrl.d.ts +5 -0
- package/dist/neutral/lib/rating/criteria/scoring/metadata/externalUrl.d.ts.map +1 -0
- package/dist/neutral/lib/rating/criteria/scoring/metadata/image.d.ts +5 -0
- package/dist/neutral/lib/rating/criteria/scoring/metadata/image.d.ts.map +1 -0
- package/dist/neutral/lib/rating/criteria/scoring/metadata/imageData.d.ts +5 -0
- package/dist/neutral/lib/rating/criteria/scoring/metadata/imageData.d.ts.map +1 -0
- package/dist/neutral/lib/rating/criteria/scoring/metadata/index.d.ts +10 -0
- package/dist/neutral/lib/rating/criteria/scoring/metadata/index.d.ts.map +1 -0
- package/dist/neutral/lib/rating/criteria/scoring/metadata/lib/index.d.ts +2 -0
- package/dist/neutral/lib/rating/criteria/scoring/metadata/lib/index.d.ts.map +1 -0
- package/dist/neutral/lib/rating/criteria/scoring/metadata/lib/urlHelpers.d.ts +7 -0
- package/dist/neutral/lib/rating/criteria/scoring/metadata/lib/urlHelpers.d.ts.map +1 -0
- package/dist/neutral/lib/rating/criteria/scoring/metadata/name.d.ts +5 -0
- package/dist/neutral/lib/rating/criteria/scoring/metadata/name.d.ts.map +1 -0
- package/dist/neutral/lib/rating/criteria/scoring/metadata/youtubeUrl.d.ts +5 -0
- package/dist/neutral/lib/rating/criteria/scoring/metadata/youtubeUrl.d.ts.map +1 -0
- package/dist/neutral/lib/rating/criteria/scoring/supply.d.ts +4 -0
- package/dist/neutral/lib/rating/criteria/scoring/supply.d.ts.map +1 -0
- package/dist/neutral/lib/rating/criteria/scoring/tokenId.d.ts +10 -0
- package/dist/neutral/lib/rating/criteria/scoring/tokenId.d.ts.map +1 -0
- package/dist/neutral/lib/rating/criteria/scoring/type.d.ts +4 -0
- package/dist/neutral/lib/rating/criteria/scoring/type.d.ts.map +1 -0
- package/dist/neutral/lib/rating/criteria/scoringCriteria.d.ts +55 -0
- package/dist/neutral/lib/rating/criteria/scoringCriteria.d.ts.map +1 -0
- package/dist/neutral/lib/rating/index.d.ts +3 -0
- package/dist/neutral/lib/rating/index.d.ts.map +1 -0
- package/dist/node/Diviner.d.ts +13 -0
- package/dist/node/Diviner.d.ts.map +1 -0
- package/dist/node/Plugin.d.ts +3 -0
- package/dist/node/Plugin.d.ts.map +1 -0
- package/dist/node/index.d.ts +4 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.mjs +374 -0
- package/dist/node/index.mjs.map +1 -0
- package/dist/node/lib/index.d.ts +2 -0
- package/dist/node/lib/index.d.ts.map +1 -0
- package/dist/node/lib/rating/analyzeNft.d.ts +13 -0
- package/dist/node/lib/rating/analyzeNft.d.ts.map +1 -0
- package/dist/node/lib/rating/criteria/index.d.ts +2 -0
- package/dist/node/lib/rating/criteria/index.d.ts.map +1 -0
- package/dist/node/lib/rating/criteria/scoring/contract.d.ts +4 -0
- package/dist/node/lib/rating/criteria/scoring/contract.d.ts.map +1 -0
- package/dist/node/lib/rating/criteria/scoring/index.d.ts +6 -0
- package/dist/node/lib/rating/criteria/scoring/index.d.ts.map +1 -0
- package/dist/node/lib/rating/criteria/scoring/metadata/animationUrl.d.ts +5 -0
- package/dist/node/lib/rating/criteria/scoring/metadata/animationUrl.d.ts.map +1 -0
- package/dist/node/lib/rating/criteria/scoring/metadata/attributes/evaluateAttributes.d.ts +6 -0
- package/dist/node/lib/rating/criteria/scoring/metadata/attributes/evaluateAttributes.d.ts.map +1 -0
- package/dist/node/lib/rating/criteria/scoring/metadata/attributes/index.d.ts +2 -0
- package/dist/node/lib/rating/criteria/scoring/metadata/attributes/index.d.ts.map +1 -0
- package/dist/node/lib/rating/criteria/scoring/metadata/backgroundColor.d.ts +5 -0
- package/dist/node/lib/rating/criteria/scoring/metadata/backgroundColor.d.ts.map +1 -0
- package/dist/node/lib/rating/criteria/scoring/metadata/description.d.ts +5 -0
- package/dist/node/lib/rating/criteria/scoring/metadata/description.d.ts.map +1 -0
- package/dist/node/lib/rating/criteria/scoring/metadata/externalUrl.d.ts +5 -0
- package/dist/node/lib/rating/criteria/scoring/metadata/externalUrl.d.ts.map +1 -0
- package/dist/node/lib/rating/criteria/scoring/metadata/image.d.ts +5 -0
- package/dist/node/lib/rating/criteria/scoring/metadata/image.d.ts.map +1 -0
- package/dist/node/lib/rating/criteria/scoring/metadata/imageData.d.ts +5 -0
- package/dist/node/lib/rating/criteria/scoring/metadata/imageData.d.ts.map +1 -0
- package/dist/node/lib/rating/criteria/scoring/metadata/index.d.ts +10 -0
- package/dist/node/lib/rating/criteria/scoring/metadata/index.d.ts.map +1 -0
- package/dist/node/lib/rating/criteria/scoring/metadata/lib/index.d.ts +2 -0
- package/dist/node/lib/rating/criteria/scoring/metadata/lib/index.d.ts.map +1 -0
- package/dist/node/lib/rating/criteria/scoring/metadata/lib/urlHelpers.d.ts +7 -0
- package/dist/node/lib/rating/criteria/scoring/metadata/lib/urlHelpers.d.ts.map +1 -0
- package/dist/node/lib/rating/criteria/scoring/metadata/name.d.ts +5 -0
- package/dist/node/lib/rating/criteria/scoring/metadata/name.d.ts.map +1 -0
- package/dist/node/lib/rating/criteria/scoring/metadata/youtubeUrl.d.ts +5 -0
- package/dist/node/lib/rating/criteria/scoring/metadata/youtubeUrl.d.ts.map +1 -0
- package/dist/node/lib/rating/criteria/scoring/supply.d.ts +4 -0
- package/dist/node/lib/rating/criteria/scoring/supply.d.ts.map +1 -0
- package/dist/node/lib/rating/criteria/scoring/tokenId.d.ts +10 -0
- package/dist/node/lib/rating/criteria/scoring/tokenId.d.ts.map +1 -0
- package/dist/node/lib/rating/criteria/scoring/type.d.ts +4 -0
- package/dist/node/lib/rating/criteria/scoring/type.d.ts.map +1 -0
- package/dist/node/lib/rating/criteria/scoringCriteria.d.ts +55 -0
- package/dist/node/lib/rating/criteria/scoringCriteria.d.ts.map +1 -0
- package/dist/node/lib/rating/index.d.ts +3 -0
- package/dist/node/lib/rating/index.d.ts.map +1 -0
- package/package.json +15 -7
- package/src/Diviner.ts +0 -53
- package/src/Plugin.ts +0 -16
- package/src/index.ts +0 -3
- package/src/lib/index.ts +0 -1
- package/src/lib/rating/analyzeNft.ts +0 -28
- package/src/lib/rating/criteria/index.ts +0 -1
- package/src/lib/rating/criteria/scoring/contract.ts +0 -11
- package/src/lib/rating/criteria/scoring/index.ts +0 -5
- package/src/lib/rating/criteria/scoring/metadata/animationUrl.ts +0 -27
- package/src/lib/rating/criteria/scoring/metadata/attributes/evaluateAttributes.ts +0 -90
- package/src/lib/rating/criteria/scoring/metadata/attributes/index.ts +0 -1
- package/src/lib/rating/criteria/scoring/metadata/backgroundColor.ts +0 -21
- package/src/lib/rating/criteria/scoring/metadata/description.ts +0 -13
- package/src/lib/rating/criteria/scoring/metadata/externalUrl.ts +0 -16
- package/src/lib/rating/criteria/scoring/metadata/image.ts +0 -30
- package/src/lib/rating/criteria/scoring/metadata/imageData.ts +0 -36
- package/src/lib/rating/criteria/scoring/metadata/index.ts +0 -9
- package/src/lib/rating/criteria/scoring/metadata/lib/index.ts +0 -1
- package/src/lib/rating/criteria/scoring/metadata/lib/urlHelpers.ts +0 -16
- package/src/lib/rating/criteria/scoring/metadata/name.ts +0 -12
- package/src/lib/rating/criteria/scoring/metadata/spec/testHelpers.ts +0 -33
- package/src/lib/rating/criteria/scoring/metadata/youtubeUrl.ts +0 -17
- package/src/lib/rating/criteria/scoring/supply.ts +0 -13
- package/src/lib/rating/criteria/scoring/tokenId.ts +0 -19
- package/src/lib/rating/criteria/scoring/type.ts +0 -11
- package/src/lib/rating/criteria/scoringCriteria.ts +0 -37
- package/src/lib/rating/index.ts +0 -2
- package/src/spec/testData.json +0 -20109
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { NftInfoFields, OpenSeaNftInfoFields } from '@xyo-network/crypto-nft-payload-plugin';
|
|
2
|
+
import type { ScaledScore } from '@xyo-network/crypto-nft-score-model';
|
|
3
|
+
export declare const scoreNftYoutubeUrl: (nft: NftInfoFields | OpenSeaNftInfoFields) => ScaledScore;
|
|
4
|
+
export declare const scoreYoutubeUrl: (youtube_url: unknown) => ScaledScore;
|
|
5
|
+
//# sourceMappingURL=youtubeUrl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"youtubeUrl.d.ts","sourceRoot":"","sources":["../../../../../../../src/lib/rating/criteria/scoring/metadata/youtubeUrl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAA;AACjG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAA;AAKtE,eAAO,MAAM,kBAAkB,GAAI,KAAK,aAAa,GAAG,oBAAoB,KAAG,WAE9E,CAAA;AACD,eAAO,MAAM,eAAe,GAAI,aAAa,OAAO,KAAG,WAOtD,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { NftInfoFields } from '@xyo-network/crypto-nft-payload-plugin';
|
|
2
|
+
import type { PassFailScoringFunction } from '@xyo-network/crypto-nft-score-model';
|
|
3
|
+
export declare const scoreSupply: PassFailScoringFunction<NftInfoFields>;
|
|
4
|
+
//# sourceMappingURL=supply.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supply.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/rating/criteria/scoring/supply.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAA;AAC3E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAA;AAGlF,eAAO,MAAM,WAAW,EAAE,uBAAuB,CAAC,aAAa,CAQ9D,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { NftInfoFields } from '@xyo-network/crypto-nft-payload-plugin';
|
|
2
|
+
import type { PassFailScoringFunction } from '@xyo-network/crypto-nft-score-model';
|
|
3
|
+
/**
|
|
4
|
+
* Callers SHALL NOT assume that ID numbers have any specific pattern to them, and
|
|
5
|
+
* MUST treat the ID as a "black box"
|
|
6
|
+
* @param nft
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export declare const scoreTokenId: PassFailScoringFunction<NftInfoFields>;
|
|
10
|
+
//# sourceMappingURL=tokenId.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokenId.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/rating/criteria/scoring/tokenId.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAA;AAC3E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAA;AAGlF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,uBAAuB,CAAC,aAAa,CAQ/D,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/rating/criteria/scoring/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAA;AAC3E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAA;AAGlF,eAAO,MAAM,SAAS,EAAE,uBAAuB,CAAC,aAAa,CAM5D,CAAA"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export declare const scoringCriteria: {
|
|
2
|
+
Attributes: {
|
|
3
|
+
score: (nft: import("@xyo-network/crypto-nft-payload-plugin").NftInfoFields | import("@xyo-network/crypto-nft-payload-plugin").OpenSeaNftInfoFields) => import("@xyo-network/crypto-nft-score-model").ScaledScore;
|
|
4
|
+
weight: number;
|
|
5
|
+
};
|
|
6
|
+
'Animation URL': {
|
|
7
|
+
score: (nft: import("@xyo-network/crypto-nft-payload-plugin").NftInfoFields | import("@xyo-network/crypto-nft-payload-plugin").OpenSeaNftInfoFields) => import("@xyo-network/crypto-nft-score-model").ScaledScore;
|
|
8
|
+
weight: number;
|
|
9
|
+
};
|
|
10
|
+
'Background Color': {
|
|
11
|
+
score: (nft: import("@xyo-network/crypto-nft-payload-plugin").NftInfoFields | import("@xyo-network/crypto-nft-payload-plugin").OpenSeaNftInfoFields) => import("@xyo-network/crypto-nft-score-model").ScaledScore;
|
|
12
|
+
weight: number;
|
|
13
|
+
};
|
|
14
|
+
Description: {
|
|
15
|
+
score: (nft: import("@xyo-network/crypto-nft-payload-plugin").NftInfoFields | import("@xyo-network/crypto-nft-payload-plugin").OpenSeaNftInfoFields) => import("@xyo-network/crypto-nft-score-model").ScaledScore;
|
|
16
|
+
weight: number;
|
|
17
|
+
};
|
|
18
|
+
'External Url': {
|
|
19
|
+
score: (nft: import("@xyo-network/crypto-nft-payload-plugin").NftInfoFields | import("@xyo-network/crypto-nft-payload-plugin").OpenSeaNftInfoFields) => import("@xyo-network/crypto-nft-score-model").ScaledScore;
|
|
20
|
+
weight: number;
|
|
21
|
+
};
|
|
22
|
+
Image: {
|
|
23
|
+
score: (nft: import("@xyo-network/crypto-nft-payload-plugin").NftInfoFields | import("@xyo-network/crypto-nft-payload-plugin").OpenSeaNftInfoFields) => import("@xyo-network/crypto-nft-score-model").ScaledScore;
|
|
24
|
+
weight: number;
|
|
25
|
+
};
|
|
26
|
+
'Image Data': {
|
|
27
|
+
score: (nft: import("@xyo-network/crypto-nft-payload-plugin").NftInfoFields | import("@xyo-network/crypto-nft-payload-plugin").OpenSeaNftInfoFields) => import("@xyo-network/crypto-nft-score-model").ScaledScore;
|
|
28
|
+
weight: number;
|
|
29
|
+
};
|
|
30
|
+
Name: {
|
|
31
|
+
score: (nft: import("@xyo-network/crypto-nft-payload-plugin").NftInfoFields | import("@xyo-network/crypto-nft-payload-plugin").OpenSeaNftInfoFields) => import("@xyo-network/crypto-nft-score-model").ScaledScore;
|
|
32
|
+
weight: number;
|
|
33
|
+
};
|
|
34
|
+
'YouTube URL': {
|
|
35
|
+
score: (nft: import("@xyo-network/crypto-nft-payload-plugin").NftInfoFields | import("@xyo-network/crypto-nft-payload-plugin").OpenSeaNftInfoFields) => import("@xyo-network/crypto-nft-score-model").ScaledScore;
|
|
36
|
+
weight: number;
|
|
37
|
+
};
|
|
38
|
+
'Contract Address': {
|
|
39
|
+
score: import("@xyo-network/crypto-nft-score-model").PassFailScoringFunction<import("@xyo-network/crypto-nft-payload-plugin").NftInfoFields>;
|
|
40
|
+
weight: number;
|
|
41
|
+
};
|
|
42
|
+
Supply: {
|
|
43
|
+
score: import("@xyo-network/crypto-nft-score-model").PassFailScoringFunction<import("@xyo-network/crypto-nft-payload-plugin").NftInfoFields>;
|
|
44
|
+
weight: number;
|
|
45
|
+
};
|
|
46
|
+
'Token Id': {
|
|
47
|
+
score: import("@xyo-network/crypto-nft-score-model").PassFailScoringFunction<import("@xyo-network/crypto-nft-payload-plugin").NftInfoFields>;
|
|
48
|
+
weight: number;
|
|
49
|
+
};
|
|
50
|
+
Type: {
|
|
51
|
+
score: import("@xyo-network/crypto-nft-score-model").PassFailScoringFunction<import("@xyo-network/crypto-nft-payload-plugin").NftInfoFields>;
|
|
52
|
+
weight: number;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=scoringCriteria.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scoringCriteria.d.ts","sourceRoot":"","sources":["../../../../../src/lib/rating/criteria/scoringCriteria.ts"],"names":[],"mappings":"AA8BA,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAM3B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/rating/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,qBAAqB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/crypto-nft-diviner-score-plugin",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.4",
|
|
4
4
|
"description": "Typescript/Javascript Plugins for XYO Platform",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -30,19 +30,19 @@
|
|
|
30
30
|
"types": "dist/neutral/index.d.ts",
|
|
31
31
|
"files": [
|
|
32
32
|
"dist",
|
|
33
|
-
"
|
|
34
|
-
"!**/*.bench.*",
|
|
35
|
-
"!**/*.spec.*",
|
|
36
|
-
"!**/*.test.*"
|
|
33
|
+
"README.md"
|
|
37
34
|
],
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@xyo-network/crypto-nft-payload-plugin": "~5.3.4",
|
|
37
|
+
"@xyo-network/crypto-nft-score-model": "~5.3.4"
|
|
38
|
+
},
|
|
38
39
|
"devDependencies": {
|
|
39
40
|
"@types/svg-parser": "~2.0.6",
|
|
40
41
|
"@xylabs/sdk-js": "^5.0.90",
|
|
42
|
+
"@xylabs/ts-scripts-common": "~7.5.10",
|
|
41
43
|
"@xylabs/ts-scripts-yarn3": "~7.5.10",
|
|
42
44
|
"@xylabs/tsconfig": "~7.5.10",
|
|
43
45
|
"@xylabs/vitest-extended": "~5.0.90",
|
|
44
|
-
"@xyo-network/crypto-nft-payload-plugin": "~5.3.2",
|
|
45
|
-
"@xyo-network/crypto-nft-score-model": "~5.3.2",
|
|
46
46
|
"@xyo-network/diviner-abstract": "~5.3.5",
|
|
47
47
|
"@xyo-network/diviner-model": "~5.3.5",
|
|
48
48
|
"@xyo-network/module-model": "~5.3.5",
|
|
@@ -57,6 +57,14 @@
|
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"@xylabs/sdk-js": "^5",
|
|
60
|
+
"@xyo-network/diviner-abstract": "^5",
|
|
61
|
+
"@xyo-network/diviner-model": "^5",
|
|
62
|
+
"@xyo-network/module-model": "^5",
|
|
63
|
+
"@xyo-network/payload-model": "^5",
|
|
64
|
+
"@xyo-network/payloadset-plugin": "^5",
|
|
65
|
+
"@xyo-network/sdk-js": "^5",
|
|
66
|
+
"ethers": "^6",
|
|
67
|
+
"svg-parser": "^2",
|
|
60
68
|
"zod": "^4"
|
|
61
69
|
},
|
|
62
70
|
"publishConfig": {
|
package/src/Diviner.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
NftInfo,
|
|
3
|
-
NftScore,
|
|
4
|
-
NftScoreDivinerConfig,
|
|
5
|
-
} from '@xyo-network/crypto-nft-payload-plugin'
|
|
6
|
-
import {
|
|
7
|
-
isNftInfo,
|
|
8
|
-
NftScoreDivinerConfigSchema,
|
|
9
|
-
NftScoreSchema,
|
|
10
|
-
} from '@xyo-network/crypto-nft-payload-plugin'
|
|
11
|
-
import { AbstractDiviner } from '@xyo-network/diviner-abstract'
|
|
12
|
-
import type { DivinerParams } from '@xyo-network/diviner-model'
|
|
13
|
-
import type { AnyConfigSchema } from '@xyo-network/module-model'
|
|
14
|
-
import type { Payload, Schema } from '@xyo-network/payload-model'
|
|
15
|
-
import { PayloadBuilder } from '@xyo-network/sdk-js'
|
|
16
|
-
|
|
17
|
-
import type { NftAnalysis } from './lib/index.ts'
|
|
18
|
-
import { analyzeNft } from './lib/index.ts'
|
|
19
|
-
|
|
20
|
-
export type NftScoreDivinerParams = DivinerParams<AnyConfigSchema<NftScoreDivinerConfig>>
|
|
21
|
-
|
|
22
|
-
const toNftScorePayload = (nftInfo: NftInfo, scores: NftAnalysis): NftScore => {
|
|
23
|
-
const {
|
|
24
|
-
|
|
25
|
-
address, chainId, types,
|
|
26
|
-
} = nftInfo
|
|
27
|
-
return {
|
|
28
|
-
address, chainId, schema: NftScoreSchema, scores, types,
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export const isNftScore = (payload: Payload): payload is NftScore => payload.schema === NftScoreSchema
|
|
33
|
-
|
|
34
|
-
export class NftScoreDiviner<TParams extends NftScoreDivinerParams = NftScoreDivinerParams> extends AbstractDiviner<TParams> {
|
|
35
|
-
static override readonly configSchemas: Schema[] = [...super.configSchemas, NftScoreDivinerConfigSchema]
|
|
36
|
-
static override readonly defaultConfigSchema: Schema = NftScoreDivinerConfigSchema
|
|
37
|
-
|
|
38
|
-
protected override divineHandler = async (payloads?: Payload[]): Promise<Payload[]> => {
|
|
39
|
-
const nftInfos = payloads?.filter(isNftInfo) ?? []
|
|
40
|
-
const results = await Promise.all(
|
|
41
|
-
nftInfos.map<Promise<NftScore>>(async (nftInfo) => {
|
|
42
|
-
const [score, sourceHash] = await Promise.all([
|
|
43
|
-
// Analyze the NFT
|
|
44
|
-
toNftScorePayload(nftInfo, await analyzeNft(nftInfo)),
|
|
45
|
-
// Hash the source payload
|
|
46
|
-
PayloadBuilder.dataHash(nftInfo),
|
|
47
|
-
])
|
|
48
|
-
return { ...score, sources: [sourceHash] }
|
|
49
|
-
}),
|
|
50
|
-
)
|
|
51
|
-
return results
|
|
52
|
-
}
|
|
53
|
-
}
|
package/src/Plugin.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { NftSchema } from '@xyo-network/crypto-nft-payload-plugin'
|
|
2
|
-
import { PayloadSetSchema } from '@xyo-network/payload-model'
|
|
3
|
-
import { createPayloadSetDivinerPlugin } from '@xyo-network/payloadset-plugin'
|
|
4
|
-
|
|
5
|
-
import { NftScoreDiviner } from './Diviner.ts'
|
|
6
|
-
|
|
7
|
-
export const NftScoreDivinerPlugin = () =>
|
|
8
|
-
createPayloadSetDivinerPlugin<NftScoreDiviner>(
|
|
9
|
-
{ required: { [NftSchema]: 1 }, schema: PayloadSetSchema },
|
|
10
|
-
{
|
|
11
|
-
diviner: async (params) => {
|
|
12
|
-
const result = await NftScoreDiviner.create(params)
|
|
13
|
-
return result
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
)
|
package/src/index.ts
DELETED
package/src/lib/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './rating/index.ts'
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { NftInfoFields } from '@xyo-network/crypto-nft-payload-plugin'
|
|
2
|
-
import type { Score } from '@xyo-network/crypto-nft-score-model'
|
|
3
|
-
|
|
4
|
-
import { scoringCriteria } from './criteria/index.ts'
|
|
5
|
-
|
|
6
|
-
export type ScoringCriteriaKey = keyof typeof scoringCriteria & PropertyKey
|
|
7
|
-
|
|
8
|
-
export type NftAnalysis = {
|
|
9
|
-
[key in ScoringCriteriaKey]: Score
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const analyzeNft = async (
|
|
13
|
-
/**
|
|
14
|
-
* The NFT to evaluate
|
|
15
|
-
*/
|
|
16
|
-
nft: NftInfoFields,
|
|
17
|
-
): Promise<NftAnalysis> => {
|
|
18
|
-
const result = Object.fromEntries(
|
|
19
|
-
await Promise.all(
|
|
20
|
-
Object.entries(scoringCriteria).map(async ([key, { score, weight }]) => {
|
|
21
|
-
const rawScore = await score(nft)
|
|
22
|
-
const weighted = rawScore.map(v => v * weight) as Score
|
|
23
|
-
return [key, weighted] as const
|
|
24
|
-
}),
|
|
25
|
-
),
|
|
26
|
-
) as NftAnalysis
|
|
27
|
-
return result
|
|
28
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './scoringCriteria.ts'
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { NftInfoFields } from '@xyo-network/crypto-nft-payload-plugin'
|
|
2
|
-
import type { PassFailScoringFunction } from '@xyo-network/crypto-nft-score-model'
|
|
3
|
-
import { FAIL, PASS } from '@xyo-network/crypto-nft-score-model'
|
|
4
|
-
import { isAddress } from 'ethers'
|
|
5
|
-
|
|
6
|
-
export const scoreContractAddress: PassFailScoringFunction<NftInfoFields> = (nft: NftInfoFields) => {
|
|
7
|
-
if (!nft.address) return FAIL
|
|
8
|
-
if (typeof nft.address !== 'string') return FAIL
|
|
9
|
-
if (!isAddress(nft.address)) return FAIL
|
|
10
|
-
return PASS
|
|
11
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { NftInfoFields, OpenSeaNftInfoFields } from '@xyo-network/crypto-nft-payload-plugin'
|
|
2
|
-
import type { ScaledScore } from '@xyo-network/crypto-nft-score-model'
|
|
3
|
-
import {
|
|
4
|
-
incrementPossible, incrementTotal, incrementTotalAndPossible, PASS,
|
|
5
|
-
} from '@xyo-network/crypto-nft-score-model'
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
isSecure, isValidUrl, isWeb3,
|
|
9
|
-
} from './lib/index.ts'
|
|
10
|
-
|
|
11
|
-
export const scoreNftAnimationUrl = (nft: NftInfoFields | OpenSeaNftInfoFields): ScaledScore => {
|
|
12
|
-
return scoreAnimationUrl(nft.metadata?.animation_url)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const scoreAnimationUrl = (animation_url: unknown): ScaledScore => {
|
|
16
|
-
const score: ScaledScore = [0, 0]
|
|
17
|
-
if (animation_url === undefined || animation_url === null) return PASS
|
|
18
|
-
incrementPossible(score)
|
|
19
|
-
if (typeof animation_url !== 'string') return score
|
|
20
|
-
incrementTotalAndPossible(score)
|
|
21
|
-
if (!isValidUrl(animation_url)) return score
|
|
22
|
-
incrementTotalAndPossible(score)
|
|
23
|
-
if (!isSecure(animation_url)) return score
|
|
24
|
-
incrementTotalAndPossible(score)
|
|
25
|
-
if (!isWeb3(animation_url)) return score
|
|
26
|
-
return incrementTotal(score)
|
|
27
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
NftAttribute, NftInfoFields, OpenSeaNftAttribute, OpenSeaNftInfoFields,
|
|
3
|
-
} from '@xyo-network/crypto-nft-payload-plugin'
|
|
4
|
-
import type { ScaledScore } from '@xyo-network/crypto-nft-score-model'
|
|
5
|
-
import {
|
|
6
|
-
incrementPossible, incrementTotal, incrementTotalAndPossible,
|
|
7
|
-
} from '@xyo-network/crypto-nft-score-model'
|
|
8
|
-
|
|
9
|
-
const isDate = (value: unknown): value is Date => {
|
|
10
|
-
if (isNumber(value)) {
|
|
11
|
-
try {
|
|
12
|
-
new Date(value)
|
|
13
|
-
return true
|
|
14
|
-
} catch {
|
|
15
|
-
return false
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return false
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const isNumber = (value: unknown): value is number => typeof value === 'number'
|
|
22
|
-
|
|
23
|
-
const isPercentage = (value: unknown): boolean => isNumber(value) && value >= 0 && value <= 100
|
|
24
|
-
|
|
25
|
-
const isNonEmptyString = (value: unknown): value is string => typeof value === 'string' && value.length > 0
|
|
26
|
-
|
|
27
|
-
const isNonEmptyStringOrNumber = (value: unknown): value is string | number => value === 'number' || isNonEmptyString(value)
|
|
28
|
-
|
|
29
|
-
export const evaluateNftAttributes = (nft: NftInfoFields | OpenSeaNftInfoFields): ScaledScore =>
|
|
30
|
-
nft?.metadata?.attributes ? evaluateAttributes(nft?.metadata?.attributes) : [0, 1]
|
|
31
|
-
|
|
32
|
-
export const evaluateAttributes = (attributes: NftAttribute[] | OpenSeaNftAttribute[] | unknown): ScaledScore => {
|
|
33
|
-
if (!attributes || !Array.isArray(attributes) || attributes.length === 0) return [0, 1]
|
|
34
|
-
const score: ScaledScore = [0, 0]
|
|
35
|
-
for (const attribute of attributes) {
|
|
36
|
-
const [attributeTotal, attributePossible] = evaluateAttribute(attribute)
|
|
37
|
-
incrementTotalAndPossible(score, attributeTotal, attributePossible)
|
|
38
|
-
}
|
|
39
|
-
return [1, 1]
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export const evaluateAttribute = (attribute: OpenSeaNftAttribute): ScaledScore => {
|
|
43
|
-
const score: ScaledScore = [0, 1]
|
|
44
|
-
const max_value = attribute?.max_value
|
|
45
|
-
const trait_type = attribute?.trait_type
|
|
46
|
-
const value = attribute?.value
|
|
47
|
-
|
|
48
|
-
// Validate trait_type & value
|
|
49
|
-
if (!attribute || typeof attribute !== 'object' || !isNonEmptyString(trait_type) || !isNonEmptyStringOrNumber(value)) return score
|
|
50
|
-
incrementTotal(score)
|
|
51
|
-
|
|
52
|
-
// Validate display_type
|
|
53
|
-
incrementPossible(score)
|
|
54
|
-
if (validDisplayType(attribute)) incrementTotal(score)
|
|
55
|
-
|
|
56
|
-
// Validate max_value
|
|
57
|
-
if (max_value !== undefined) {
|
|
58
|
-
incrementPossible(score)
|
|
59
|
-
if (isNumber(max_value) && isNumber(value) && value <= max_value) incrementTotal(score)
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return score
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const validDisplayType = (attribute: OpenSeaNftAttribute): boolean => {
|
|
66
|
-
switch (attribute?.display_type) {
|
|
67
|
-
case 'number':
|
|
68
|
-
case 'boost_number': {
|
|
69
|
-
if (isNumber(attribute?.value)) return true
|
|
70
|
-
break
|
|
71
|
-
}
|
|
72
|
-
case 'boost_percentage': {
|
|
73
|
-
if (isPercentage(attribute?.value)) return true
|
|
74
|
-
break
|
|
75
|
-
}
|
|
76
|
-
case 'date': {
|
|
77
|
-
if (isDate(attribute?.value)) return true
|
|
78
|
-
break
|
|
79
|
-
}
|
|
80
|
-
case 'string':
|
|
81
|
-
case undefined: {
|
|
82
|
-
if (isNonEmptyString(attribute?.value)) return true
|
|
83
|
-
break
|
|
84
|
-
}
|
|
85
|
-
default: {
|
|
86
|
-
break
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return false
|
|
90
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './evaluateAttributes.ts'
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { NftInfoFields, OpenSeaNftInfoFields } from '@xyo-network/crypto-nft-payload-plugin'
|
|
2
|
-
import type { ScaledScore } from '@xyo-network/crypto-nft-score-model'
|
|
3
|
-
import {
|
|
4
|
-
incrementPossible, incrementTotal, incrementTotalAndPossible, PASS,
|
|
5
|
-
} from '@xyo-network/crypto-nft-score-model'
|
|
6
|
-
|
|
7
|
-
const isHexColor = /^[\da-f]{6}$/i
|
|
8
|
-
|
|
9
|
-
export const scoreNftBackgroundColor = (nft: NftInfoFields | OpenSeaNftInfoFields): ScaledScore => {
|
|
10
|
-
return scoreBackgroundColor(nft.metadata?.background_color)
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const scoreBackgroundColor = (background_color: unknown): ScaledScore => {
|
|
14
|
-
const score: ScaledScore = [0, 0]
|
|
15
|
-
if (background_color === undefined || background_color === null) return PASS
|
|
16
|
-
incrementPossible(score)
|
|
17
|
-
if (typeof background_color !== 'string') return score
|
|
18
|
-
incrementTotalAndPossible(score)
|
|
19
|
-
if (!isHexColor.test(background_color.toUpperCase())) return score
|
|
20
|
-
return incrementTotal(score)
|
|
21
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { NftInfoFields, OpenSeaNftInfoFields } from '@xyo-network/crypto-nft-payload-plugin'
|
|
2
|
-
import type { ScaledScore } from '@xyo-network/crypto-nft-score-model'
|
|
3
|
-
import { incrementTotal } from '@xyo-network/crypto-nft-score-model'
|
|
4
|
-
|
|
5
|
-
export const scoreNftDescription = (nft: NftInfoFields | OpenSeaNftInfoFields): ScaledScore => {
|
|
6
|
-
return scoreDescription(nft.metadata?.description)
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const scoreDescription = (description: unknown): ScaledScore => {
|
|
10
|
-
const score: ScaledScore = [0, 1]
|
|
11
|
-
if (!description || typeof description !== 'string') return score
|
|
12
|
-
return incrementTotal(score)
|
|
13
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { NftInfoFields, OpenSeaNftInfoFields } from '@xyo-network/crypto-nft-payload-plugin'
|
|
2
|
-
import type { ScaledScore } from '@xyo-network/crypto-nft-score-model'
|
|
3
|
-
import { incrementTotal } from '@xyo-network/crypto-nft-score-model'
|
|
4
|
-
|
|
5
|
-
import { isSecure, isValidUrl } from './lib/index.ts'
|
|
6
|
-
|
|
7
|
-
export const scoreNftExternalUrl = (nft: NftInfoFields | OpenSeaNftInfoFields): ScaledScore => {
|
|
8
|
-
return scoreExternalUrl(nft?.metadata?.external_url)
|
|
9
|
-
}
|
|
10
|
-
export const scoreExternalUrl = (external_url: unknown): ScaledScore => {
|
|
11
|
-
const score: ScaledScore = [0, 2]
|
|
12
|
-
if (external_url === undefined || external_url === null || typeof external_url !== 'string' || !isValidUrl(external_url)) return score
|
|
13
|
-
incrementTotal(score)
|
|
14
|
-
if (!isSecure(external_url)) return score
|
|
15
|
-
return incrementTotal(score)
|
|
16
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { NftInfoFields, OpenSeaNftInfoFields } from '@xyo-network/crypto-nft-payload-plugin'
|
|
2
|
-
import type { ScaledScore } from '@xyo-network/crypto-nft-score-model'
|
|
3
|
-
import { incrementTotal, PASS } from '@xyo-network/crypto-nft-score-model'
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
isSecure, isValidUrl, isWeb3,
|
|
7
|
-
} from './lib/index.ts'
|
|
8
|
-
|
|
9
|
-
const MaxPossibleImageScore = 3
|
|
10
|
-
|
|
11
|
-
export const scoreNftImage = (nft: NftInfoFields | OpenSeaNftInfoFields): ScaledScore => {
|
|
12
|
-
// If there's no image data
|
|
13
|
-
if (nft?.metadata?.image) {
|
|
14
|
-
return scoreImage(nft.metadata?.image)
|
|
15
|
-
} else {
|
|
16
|
-
// but there is image data, skip this scoring criteria, otherwise fail it completely
|
|
17
|
-
return nft.metadata?.image_data ? PASS : [0, MaxPossibleImageScore]
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const scoreImage = (image: unknown): ScaledScore => {
|
|
22
|
-
const score: ScaledScore = [0, MaxPossibleImageScore]
|
|
23
|
-
if (!image || typeof image !== 'string' || !isValidUrl(image)) return score
|
|
24
|
-
incrementTotal(score)
|
|
25
|
-
if (!isSecure(image)) return score
|
|
26
|
-
incrementTotal(score)
|
|
27
|
-
if (!isWeb3(image)) return score
|
|
28
|
-
incrementTotal(score)
|
|
29
|
-
return score
|
|
30
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { NftInfoFields, OpenSeaNftInfoFields } from '@xyo-network/crypto-nft-payload-plugin'
|
|
2
|
-
import type { ScaledScore } from '@xyo-network/crypto-nft-score-model'
|
|
3
|
-
import { PASS } from '@xyo-network/crypto-nft-score-model'
|
|
4
|
-
import { parse } from 'svg-parser'
|
|
5
|
-
|
|
6
|
-
const MaxPossibleImageDataScore = 1
|
|
7
|
-
|
|
8
|
-
// TODO: There is probably a deeper check we can do
|
|
9
|
-
// here, but this is a good start
|
|
10
|
-
const isValidImageData = (image_data: string): boolean => {
|
|
11
|
-
// If it doesn't start with an svg tag, it's not an svg
|
|
12
|
-
if (!image_data.startsWith('<svg')) return false
|
|
13
|
-
try {
|
|
14
|
-
// If it can't be parsed, it's not an svg
|
|
15
|
-
parse(image_data)
|
|
16
|
-
return true
|
|
17
|
-
} catch {
|
|
18
|
-
return false
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const scoreNftImageData = (nft: NftInfoFields | OpenSeaNftInfoFields): ScaledScore => {
|
|
23
|
-
// If there's no image data
|
|
24
|
-
if (nft?.metadata?.image_data) {
|
|
25
|
-
return scoreImageData(nft.metadata?.image_data)
|
|
26
|
-
} else {
|
|
27
|
-
// but there is an image, skip this scoring criteria, otherwise fail it completely
|
|
28
|
-
return nft.metadata?.image ? PASS : [0, MaxPossibleImageDataScore]
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export const scoreImageData = (image_data: unknown): ScaledScore => {
|
|
33
|
-
return !image_data || typeof image_data !== 'string' || !isValidImageData(image_data)
|
|
34
|
-
? [0, MaxPossibleImageDataScore]
|
|
35
|
-
: [MaxPossibleImageDataScore, MaxPossibleImageDataScore]
|
|
36
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export * from './animationUrl.ts'
|
|
2
|
-
export * from './attributes/index.ts'
|
|
3
|
-
export * from './backgroundColor.ts'
|
|
4
|
-
export * from './description.ts'
|
|
5
|
-
export * from './externalUrl.ts'
|
|
6
|
-
export * from './image.ts'
|
|
7
|
-
export * from './imageData.ts'
|
|
8
|
-
export * from './name.ts'
|
|
9
|
-
export * from './youtubeUrl.ts'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './urlHelpers.ts'
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export const web3Protocols = ['ipfs:', 'ar:']
|
|
2
|
-
|
|
3
|
-
export const toUrl = (url?: string | null): URL | undefined => {
|
|
4
|
-
if (!url) return undefined
|
|
5
|
-
try {
|
|
6
|
-
return new URL(url)
|
|
7
|
-
} catch {
|
|
8
|
-
return undefined
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const isValidUrl = (url?: string | null): boolean => toUrl(url) !== undefined
|
|
13
|
-
// eslint-disable-next-line unicorn/prefer-includes
|
|
14
|
-
export const isWeb3 = (url?: string | null): boolean => web3Protocols.some(protocol => protocol === toUrl(url)?.protocol)
|
|
15
|
-
export const isWeb2 = (url?: string | null): boolean => !isWeb3(url)
|
|
16
|
-
export const isSecure = (url?: string | null): boolean => isWeb3(url) || toUrl(url)?.protocol === 'https:'
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { NftInfoFields, OpenSeaNftInfoFields } from '@xyo-network/crypto-nft-payload-plugin'
|
|
2
|
-
import type { ScaledScore } from '@xyo-network/crypto-nft-score-model'
|
|
3
|
-
import { incrementTotal } from '@xyo-network/crypto-nft-score-model'
|
|
4
|
-
|
|
5
|
-
export const scoreNftName = (nft: NftInfoFields | OpenSeaNftInfoFields): ScaledScore => {
|
|
6
|
-
return scoreName(nft.metadata?.name)
|
|
7
|
-
}
|
|
8
|
-
export const scoreName = (name: unknown): ScaledScore => {
|
|
9
|
-
const score: ScaledScore = [0, 1]
|
|
10
|
-
if (!name || typeof name !== 'string') return score
|
|
11
|
-
return incrementTotal(score)
|
|
12
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import '@xylabs/vitest-extended'
|
|
2
|
-
|
|
3
|
-
import type { ScaledScore } from '@xyo-network/crypto-nft-score-model'
|
|
4
|
-
import { PASS } from '@xyo-network/crypto-nft-score-model'
|
|
5
|
-
import { expect } from 'vitest'
|
|
6
|
-
|
|
7
|
-
export const expectMaxPossibleScore = (score: ScaledScore) => {
|
|
8
|
-
const [total, possible] = score
|
|
9
|
-
expect(total).toBeNumber()
|
|
10
|
-
expect(total).toBePositive()
|
|
11
|
-
expect(possible).toBeNumber()
|
|
12
|
-
expect(possible).toBePositive()
|
|
13
|
-
expect(total).toEqual(possible)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const expectLoweredScore = (score: ScaledScore) => {
|
|
17
|
-
const [total, possible] = score
|
|
18
|
-
expect(total).toBeNumber()
|
|
19
|
-
expect(total).not.toBeNegative()
|
|
20
|
-
expect(possible).toBeNumber()
|
|
21
|
-
expect(possible).toBePositive()
|
|
22
|
-
expect(total).toBeLessThan(possible)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export const expectMiniumScore = (score: ScaledScore) => {
|
|
26
|
-
const [total] = score
|
|
27
|
-
expectLoweredScore(score)
|
|
28
|
-
expect(total).toBe(0)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export const expectNoScore = (score: ScaledScore) => {
|
|
32
|
-
expect(score).toEqual(PASS)
|
|
33
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { NftInfoFields, OpenSeaNftInfoFields } from '@xyo-network/crypto-nft-payload-plugin'
|
|
2
|
-
import type { ScaledScore } from '@xyo-network/crypto-nft-score-model'
|
|
3
|
-
import { incrementTotal, PASS } from '@xyo-network/crypto-nft-score-model'
|
|
4
|
-
|
|
5
|
-
import { isSecure, isValidUrl } from './lib/index.ts'
|
|
6
|
-
|
|
7
|
-
export const scoreNftYoutubeUrl = (nft: NftInfoFields | OpenSeaNftInfoFields): ScaledScore => {
|
|
8
|
-
return scoreYoutubeUrl(nft?.metadata?.youtube_url)
|
|
9
|
-
}
|
|
10
|
-
export const scoreYoutubeUrl = (youtube_url: unknown): ScaledScore => {
|
|
11
|
-
if (youtube_url === undefined || youtube_url === null) return PASS
|
|
12
|
-
const score: ScaledScore = [0, 2]
|
|
13
|
-
if (typeof youtube_url !== 'string' || !isValidUrl(youtube_url)) return score
|
|
14
|
-
incrementTotal(score)
|
|
15
|
-
if (!isSecure(youtube_url)) return score
|
|
16
|
-
return incrementTotal(score)
|
|
17
|
-
}
|