@xyo-network/crypto-nft-diviner-score-plugin 2.70.0
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/LICENSE +165 -0
- package/README.md +13 -0
- package/dist/cjs/Diviner.js +30 -0
- package/dist/cjs/Diviner.js.map +1 -0
- package/dist/cjs/Plugin.js +16 -0
- package/dist/cjs/Plugin.js.map +1 -0
- package/dist/cjs/index.js +11 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/lib/index.js +5 -0
- package/dist/cjs/lib/index.js.map +1 -0
- package/dist/cjs/lib/rating/analyzeNft.js +19 -0
- package/dist/cjs/lib/rating/analyzeNft.js.map +1 -0
- package/dist/cjs/lib/rating/criteria/index.js +5 -0
- package/dist/cjs/lib/rating/criteria/index.js.map +1 -0
- package/dist/cjs/lib/rating/criteria/scoring/contract.js +16 -0
- package/dist/cjs/lib/rating/criteria/scoring/contract.js.map +1 -0
- package/dist/cjs/lib/rating/criteria/scoring/index.js +9 -0
- package/dist/cjs/lib/rating/criteria/scoring/index.js.map +1 -0
- package/dist/cjs/lib/rating/criteria/scoring/lib/index.js +6 -0
- package/dist/cjs/lib/rating/criteria/scoring/lib/index.js.map +1 -0
- package/dist/cjs/lib/rating/criteria/scoring/lib/isValidPositiveBigNumber.js +10 -0
- package/dist/cjs/lib/rating/criteria/scoring/lib/isValidPositiveBigNumber.js.map +1 -0
- package/dist/cjs/lib/rating/criteria/scoring/lib/toBigNumber.js +14 -0
- package/dist/cjs/lib/rating/criteria/scoring/lib/toBigNumber.js.map +1 -0
- package/dist/cjs/lib/rating/criteria/scoring/metadata/animationUrl.js +30 -0
- package/dist/cjs/lib/rating/criteria/scoring/metadata/animationUrl.js.map +1 -0
- package/dist/cjs/lib/rating/criteria/scoring/metadata/attributes/evaluateAttributes.js +86 -0
- package/dist/cjs/lib/rating/criteria/scoring/metadata/attributes/evaluateAttributes.js.map +1 -0
- package/dist/cjs/lib/rating/criteria/scoring/metadata/attributes/index.js +5 -0
- package/dist/cjs/lib/rating/criteria/scoring/metadata/attributes/index.js.map +1 -0
- package/dist/cjs/lib/rating/criteria/scoring/metadata/backgroundColor.js +24 -0
- package/dist/cjs/lib/rating/criteria/scoring/metadata/backgroundColor.js.map +1 -0
- package/dist/cjs/lib/rating/criteria/scoring/metadata/description.js +17 -0
- package/dist/cjs/lib/rating/criteria/scoring/metadata/description.js.map +1 -0
- package/dist/cjs/lib/rating/criteria/scoring/metadata/externalUrl.js +21 -0
- package/dist/cjs/lib/rating/criteria/scoring/metadata/externalUrl.js.map +1 -0
- package/dist/cjs/lib/rating/criteria/scoring/metadata/image.js +33 -0
- package/dist/cjs/lib/rating/criteria/scoring/metadata/image.js.map +1 -0
- package/dist/cjs/lib/rating/criteria/scoring/metadata/imageData.js +40 -0
- package/dist/cjs/lib/rating/criteria/scoring/metadata/imageData.js.map +1 -0
- package/dist/cjs/lib/rating/criteria/scoring/metadata/index.js +13 -0
- package/dist/cjs/lib/rating/criteria/scoring/metadata/index.js.map +1 -0
- package/dist/cjs/lib/rating/criteria/scoring/metadata/lib/index.js +5 -0
- package/dist/cjs/lib/rating/criteria/scoring/metadata/lib/index.js.map +1 -0
- package/dist/cjs/lib/rating/criteria/scoring/metadata/lib/urlHelpers.js +25 -0
- package/dist/cjs/lib/rating/criteria/scoring/metadata/lib/urlHelpers.js.map +1 -0
- package/dist/cjs/lib/rating/criteria/scoring/metadata/name.js +17 -0
- package/dist/cjs/lib/rating/criteria/scoring/metadata/name.js.map +1 -0
- package/dist/cjs/lib/rating/criteria/scoring/metadata/youtubeUrl.js +23 -0
- package/dist/cjs/lib/rating/criteria/scoring/metadata/youtubeUrl.js.map +1 -0
- package/dist/cjs/lib/rating/criteria/scoring/supply.js +20 -0
- package/dist/cjs/lib/rating/criteria/scoring/supply.js.map +1 -0
- package/dist/cjs/lib/rating/criteria/scoring/tokenId.js +26 -0
- package/dist/cjs/lib/rating/criteria/scoring/tokenId.js.map +1 -0
- package/dist/cjs/lib/rating/criteria/scoring/type.js +16 -0
- package/dist/cjs/lib/rating/criteria/scoring/type.js.map +1 -0
- package/dist/cjs/lib/rating/criteria/scoringCriteria.js +10 -0
- package/dist/cjs/lib/rating/criteria/scoringCriteria.js.map +1 -0
- package/dist/cjs/lib/rating/index.js +6 -0
- package/dist/cjs/lib/rating/index.js.map +1 -0
- package/dist/cjs/lib/rating/score.js +23 -0
- package/dist/cjs/lib/rating/score.js.map +1 -0
- package/dist/esm/Diviner.js +20 -0
- package/dist/esm/Diviner.js.map +1 -0
- package/dist/esm/Plugin.js +11 -0
- package/dist/esm/Plugin.js.map +1 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lib/index.js +2 -0
- package/dist/esm/lib/index.js.map +1 -0
- package/dist/esm/lib/rating/analyzeNft.js +14 -0
- package/dist/esm/lib/rating/analyzeNft.js.map +1 -0
- package/dist/esm/lib/rating/criteria/index.js +2 -0
- package/dist/esm/lib/rating/criteria/index.js.map +1 -0
- package/dist/esm/lib/rating/criteria/scoring/contract.js +12 -0
- package/dist/esm/lib/rating/criteria/scoring/contract.js.map +1 -0
- package/dist/esm/lib/rating/criteria/scoring/index.js +6 -0
- package/dist/esm/lib/rating/criteria/scoring/index.js.map +1 -0
- package/dist/esm/lib/rating/criteria/scoring/lib/index.js +3 -0
- package/dist/esm/lib/rating/criteria/scoring/lib/index.js.map +1 -0
- package/dist/esm/lib/rating/criteria/scoring/lib/isValidPositiveBigNumber.js +6 -0
- package/dist/esm/lib/rating/criteria/scoring/lib/isValidPositiveBigNumber.js.map +1 -0
- package/dist/esm/lib/rating/criteria/scoring/lib/toBigNumber.js +10 -0
- package/dist/esm/lib/rating/criteria/scoring/lib/toBigNumber.js.map +1 -0
- package/dist/esm/lib/rating/criteria/scoring/metadata/animationUrl.js +24 -0
- package/dist/esm/lib/rating/criteria/scoring/metadata/animationUrl.js.map +1 -0
- package/dist/esm/lib/rating/criteria/scoring/metadata/attributes/evaluateAttributes.js +80 -0
- package/dist/esm/lib/rating/criteria/scoring/metadata/attributes/evaluateAttributes.js.map +1 -0
- package/dist/esm/lib/rating/criteria/scoring/metadata/attributes/index.js +2 -0
- package/dist/esm/lib/rating/criteria/scoring/metadata/attributes/index.js.map +1 -0
- package/dist/esm/lib/rating/criteria/scoring/metadata/backgroundColor.js +18 -0
- package/dist/esm/lib/rating/criteria/scoring/metadata/backgroundColor.js.map +1 -0
- package/dist/esm/lib/rating/criteria/scoring/metadata/description.js +11 -0
- package/dist/esm/lib/rating/criteria/scoring/metadata/description.js.map +1 -0
- package/dist/esm/lib/rating/criteria/scoring/metadata/externalUrl.js +15 -0
- package/dist/esm/lib/rating/criteria/scoring/metadata/externalUrl.js.map +1 -0
- package/dist/esm/lib/rating/criteria/scoring/metadata/image.js +27 -0
- package/dist/esm/lib/rating/criteria/scoring/metadata/image.js.map +1 -0
- package/dist/esm/lib/rating/criteria/scoring/metadata/imageData.js +34 -0
- package/dist/esm/lib/rating/criteria/scoring/metadata/imageData.js.map +1 -0
- package/dist/esm/lib/rating/criteria/scoring/metadata/index.js +10 -0
- package/dist/esm/lib/rating/criteria/scoring/metadata/index.js.map +1 -0
- package/dist/esm/lib/rating/criteria/scoring/metadata/lib/index.js +2 -0
- package/dist/esm/lib/rating/criteria/scoring/metadata/lib/index.js.map +1 -0
- package/dist/esm/lib/rating/criteria/scoring/metadata/lib/urlHelpers.js +17 -0
- package/dist/esm/lib/rating/criteria/scoring/metadata/lib/urlHelpers.js.map +1 -0
- package/dist/esm/lib/rating/criteria/scoring/metadata/name.js +11 -0
- package/dist/esm/lib/rating/criteria/scoring/metadata/name.js.map +1 -0
- package/dist/esm/lib/rating/criteria/scoring/metadata/youtubeUrl.js +17 -0
- package/dist/esm/lib/rating/criteria/scoring/metadata/youtubeUrl.js.map +1 -0
- package/dist/esm/lib/rating/criteria/scoring/supply.js +16 -0
- package/dist/esm/lib/rating/criteria/scoring/supply.js.map +1 -0
- package/dist/esm/lib/rating/criteria/scoring/tokenId.js +22 -0
- package/dist/esm/lib/rating/criteria/scoring/tokenId.js.map +1 -0
- package/dist/esm/lib/rating/criteria/scoring/type.js +12 -0
- package/dist/esm/lib/rating/criteria/scoring/type.js.map +1 -0
- package/dist/esm/lib/rating/criteria/scoringCriteria.js +23 -0
- package/dist/esm/lib/rating/criteria/scoringCriteria.js.map +1 -0
- package/dist/esm/lib/rating/index.js +3 -0
- package/dist/esm/lib/rating/index.js.map +1 -0
- package/dist/esm/lib/rating/score.js +17 -0
- package/dist/esm/lib/rating/score.js.map +1 -0
- package/dist/types/Diviner.d.ts +16 -0
- package/dist/types/Diviner.d.ts.map +1 -0
- package/dist/types/Plugin.d.ts +47 -0
- package/dist/types/Plugin.d.ts.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/lib/index.d.ts +2 -0
- package/dist/types/lib/index.d.ts.map +1 -0
- package/dist/types/lib/rating/analyzeNft.d.ts +9 -0
- package/dist/types/lib/rating/analyzeNft.d.ts.map +1 -0
- package/dist/types/lib/rating/criteria/index.d.ts +2 -0
- package/dist/types/lib/rating/criteria/index.d.ts.map +1 -0
- package/dist/types/lib/rating/criteria/scoring/contract.d.ts +3 -0
- package/dist/types/lib/rating/criteria/scoring/contract.d.ts.map +1 -0
- package/dist/types/lib/rating/criteria/scoring/index.d.ts +6 -0
- package/dist/types/lib/rating/criteria/scoring/index.d.ts.map +1 -0
- package/dist/types/lib/rating/criteria/scoring/lib/index.d.ts +3 -0
- package/dist/types/lib/rating/criteria/scoring/lib/index.d.ts.map +1 -0
- package/dist/types/lib/rating/criteria/scoring/lib/isValidPositiveBigNumber.d.ts +2 -0
- package/dist/types/lib/rating/criteria/scoring/lib/isValidPositiveBigNumber.d.ts.map +1 -0
- package/dist/types/lib/rating/criteria/scoring/lib/toBigNumber.d.ts +3 -0
- package/dist/types/lib/rating/criteria/scoring/lib/toBigNumber.d.ts.map +1 -0
- package/dist/types/lib/rating/criteria/scoring/metadata/animationUrl.d.ts +5 -0
- package/dist/types/lib/rating/criteria/scoring/metadata/animationUrl.d.ts.map +1 -0
- package/dist/types/lib/rating/criteria/scoring/metadata/attributes/evaluateAttributes.d.ts +6 -0
- package/dist/types/lib/rating/criteria/scoring/metadata/attributes/evaluateAttributes.d.ts.map +1 -0
- package/dist/types/lib/rating/criteria/scoring/metadata/attributes/index.d.ts +2 -0
- package/dist/types/lib/rating/criteria/scoring/metadata/attributes/index.d.ts.map +1 -0
- package/dist/types/lib/rating/criteria/scoring/metadata/backgroundColor.d.ts +5 -0
- package/dist/types/lib/rating/criteria/scoring/metadata/backgroundColor.d.ts.map +1 -0
- package/dist/types/lib/rating/criteria/scoring/metadata/description.d.ts +5 -0
- package/dist/types/lib/rating/criteria/scoring/metadata/description.d.ts.map +1 -0
- package/dist/types/lib/rating/criteria/scoring/metadata/externalUrl.d.ts +5 -0
- package/dist/types/lib/rating/criteria/scoring/metadata/externalUrl.d.ts.map +1 -0
- package/dist/types/lib/rating/criteria/scoring/metadata/image.d.ts +5 -0
- package/dist/types/lib/rating/criteria/scoring/metadata/image.d.ts.map +1 -0
- package/dist/types/lib/rating/criteria/scoring/metadata/imageData.d.ts +5 -0
- package/dist/types/lib/rating/criteria/scoring/metadata/imageData.d.ts.map +1 -0
- package/dist/types/lib/rating/criteria/scoring/metadata/index.d.ts +10 -0
- package/dist/types/lib/rating/criteria/scoring/metadata/index.d.ts.map +1 -0
- package/dist/types/lib/rating/criteria/scoring/metadata/lib/index.d.ts +2 -0
- package/dist/types/lib/rating/criteria/scoring/metadata/lib/index.d.ts.map +1 -0
- package/dist/types/lib/rating/criteria/scoring/metadata/lib/urlHelpers.d.ts +8 -0
- package/dist/types/lib/rating/criteria/scoring/metadata/lib/urlHelpers.d.ts.map +1 -0
- package/dist/types/lib/rating/criteria/scoring/metadata/name.d.ts +5 -0
- package/dist/types/lib/rating/criteria/scoring/metadata/name.d.ts.map +1 -0
- package/dist/types/lib/rating/criteria/scoring/metadata/youtubeUrl.d.ts +5 -0
- package/dist/types/lib/rating/criteria/scoring/metadata/youtubeUrl.d.ts.map +1 -0
- package/dist/types/lib/rating/criteria/scoring/supply.d.ts +3 -0
- package/dist/types/lib/rating/criteria/scoring/supply.d.ts.map +1 -0
- package/dist/types/lib/rating/criteria/scoring/tokenId.d.ts +9 -0
- package/dist/types/lib/rating/criteria/scoring/tokenId.d.ts.map +1 -0
- package/dist/types/lib/rating/criteria/scoring/type.d.ts +3 -0
- package/dist/types/lib/rating/criteria/scoring/type.d.ts.map +1 -0
- package/dist/types/lib/rating/criteria/scoringCriteria.d.ts +55 -0
- package/dist/types/lib/rating/criteria/scoringCriteria.d.ts.map +1 -0
- package/dist/types/lib/rating/index.d.ts +3 -0
- package/dist/types/lib/rating/index.d.ts.map +1 -0
- package/dist/types/lib/rating/score.d.ts +18 -0
- package/dist/types/lib/rating/score.d.ts.map +1 -0
- package/package.json +68 -0
- package/src/Diviner.ts +37 -0
- package/src/Plugin.ts +16 -0
- package/src/index.ts +9 -0
- package/src/lib/index.ts +1 -0
- package/src/lib/rating/analyzeNft.ts +28 -0
- package/src/lib/rating/criteria/index.ts +1 -0
- package/src/lib/rating/criteria/scoring/contract.ts +11 -0
- package/src/lib/rating/criteria/scoring/index.ts +5 -0
- package/src/lib/rating/criteria/scoring/lib/index.ts +2 -0
- package/src/lib/rating/criteria/scoring/lib/isValidPositiveBigNumber.ts +6 -0
- package/src/lib/rating/criteria/scoring/lib/toBigNumber.ts +9 -0
- package/src/lib/rating/criteria/scoring/metadata/animationUrl.ts +22 -0
- package/src/lib/rating/criteria/scoring/metadata/attributes/evaluateAttributes.ts +86 -0
- package/src/lib/rating/criteria/scoring/metadata/attributes/index.ts +1 -0
- package/src/lib/rating/criteria/scoring/metadata/backgroundColor.ts +19 -0
- package/src/lib/rating/criteria/scoring/metadata/description.ts +13 -0
- package/src/lib/rating/criteria/scoring/metadata/externalUrl.ts +15 -0
- package/src/lib/rating/criteria/scoring/metadata/image.ts +27 -0
- package/src/lib/rating/criteria/scoring/metadata/imageData.ts +36 -0
- package/src/lib/rating/criteria/scoring/metadata/index.ts +9 -0
- package/src/lib/rating/criteria/scoring/metadata/lib/index.ts +1 -0
- package/src/lib/rating/criteria/scoring/metadata/lib/urlHelpers.ts +17 -0
- package/src/lib/rating/criteria/scoring/metadata/name.ts +12 -0
- package/src/lib/rating/criteria/scoring/metadata/spec/testHelpers.ts +29 -0
- package/src/lib/rating/criteria/scoring/metadata/youtubeUrl.ts +16 -0
- package/src/lib/rating/criteria/scoring/supply.ts +15 -0
- package/src/lib/rating/criteria/scoring/tokenId.ts +21 -0
- package/src/lib/rating/criteria/scoring/type.ts +11 -0
- package/src/lib/rating/criteria/scoringCriteria.ts +39 -0
- package/src/lib/rating/index.ts +2 -0
- package/src/lib/rating/score.ts +33 -0
- package/typedoc.json +5 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../src/lib/rating/criteria/scoring/metadata/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { URL } from '@xylabs/url';
|
|
2
|
+
export declare const web3Protocols: string[];
|
|
3
|
+
export declare const toUrl: (url?: string | null) => URL | undefined;
|
|
4
|
+
export declare const isValidUrl: (url?: string | null) => boolean;
|
|
5
|
+
export declare const isWeb3: (url?: string | null) => boolean;
|
|
6
|
+
export declare const isWeb2: (url?: string | null) => boolean;
|
|
7
|
+
export declare const isSecure: (url?: string | null) => boolean;
|
|
8
|
+
//# sourceMappingURL=urlHelpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"urlHelpers.d.ts","sourceRoot":"","sources":["../../../../../../../../src/lib/rating/criteria/scoring/metadata/lib/urlHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAEjC,eAAO,MAAM,aAAa,UAAmB,CAAA;AAE7C,eAAO,MAAM,KAAK,SAAU,MAAM,GAAG,IAAI,KAAG,GAAG,GAAG,SAOjD,CAAA;AAED,eAAO,MAAM,UAAU,SAAU,MAAM,GAAG,IAAI,KAAG,OAAmC,CAAA;AACpF,eAAO,MAAM,MAAM,SAAU,MAAM,GAAG,IAAI,KAAG,OAA8E,CAAA;AAC3H,eAAO,MAAM,MAAM,SAAU,MAAM,GAAG,IAAI,KAAG,OAAuB,CAAA;AACpE,eAAO,MAAM,QAAQ,SAAU,MAAM,GAAG,IAAI,KAAG,OAA2D,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { NftInfo, OpenSeaNftInfo } from '@xyo-network/crypto-nft-payload-plugin';
|
|
2
|
+
import { ScaledScore } from '../../../score';
|
|
3
|
+
export declare const scoreNftName: (nft: NftInfo | OpenSeaNftInfo) => ScaledScore;
|
|
4
|
+
export declare const scoreName: (name: unknown) => ScaledScore;
|
|
5
|
+
//# sourceMappingURL=name.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"name.d.ts","sourceRoot":"","sources":["../../../../../../../src/lib/rating/criteria/scoring/metadata/name.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAA;AAEhF,OAAO,EAAkB,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAE5D,eAAO,MAAM,YAAY,QAAS,OAAO,GAAG,cAAc,gBAEzD,CAAA;AACD,eAAO,MAAM,SAAS,SAAU,OAAO,gBAItC,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { NftInfo, OpenSeaNftInfo } from '@xyo-network/crypto-nft-payload-plugin';
|
|
2
|
+
import { ScaledScore } from '../../../score';
|
|
3
|
+
export declare const scoreNftYoutubeUrl: (nft: NftInfo | OpenSeaNftInfo) => 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,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAA;AAEhF,OAAO,EAAwB,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAGlE,eAAO,MAAM,kBAAkB,QAAS,OAAO,GAAG,cAAc,gBAE/D,CAAA;AACD,eAAO,MAAM,eAAe,gBAAiB,OAAO,gBAOnD,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supply.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/rating/criteria/scoring/supply.ts"],"names":[],"mappings":"AAEA,OAAO,EAAc,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAGjE,eAAO,MAAM,WAAW,EAAE,uBASzB,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PassFailScoringFunction } from '../../score';
|
|
2
|
+
/**
|
|
3
|
+
* Callers SHALL NOT assume that ID numbers have any specific pattern to them, and
|
|
4
|
+
* MUST treat the ID as a "black box"
|
|
5
|
+
* @param nft
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export declare const scoreTokenId: PassFailScoringFunction;
|
|
9
|
+
//# 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":"AAEA,OAAO,EAAc,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAGjE;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,uBAS1B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/rating/criteria/scoring/type.ts"],"names":[],"mappings":"AAEA,OAAO,EAAc,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAEjE,eAAO,MAAM,SAAS,EAAE,uBAMvB,CAAA"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export declare const scoringCriteria: {
|
|
2
|
+
Attributes: {
|
|
3
|
+
score: (nft: import("@xyo-network/crypto-nft-payload-plugin").NftInfo | import("@xyo-network/crypto-nft-payload-plugin").OpenSeaNftInfo) => import("..").ScaledScore;
|
|
4
|
+
weight: number;
|
|
5
|
+
};
|
|
6
|
+
'Animation URL': {
|
|
7
|
+
score: (nft: import("@xyo-network/crypto-nft-payload-plugin").NftInfo | import("@xyo-network/crypto-nft-payload-plugin").OpenSeaNftInfo) => import("..").ScaledScore;
|
|
8
|
+
weight: number;
|
|
9
|
+
};
|
|
10
|
+
'Background Color': {
|
|
11
|
+
score: (nft: import("@xyo-network/crypto-nft-payload-plugin").NftInfo | import("@xyo-network/crypto-nft-payload-plugin").OpenSeaNftInfo) => import("..").ScaledScore;
|
|
12
|
+
weight: number;
|
|
13
|
+
};
|
|
14
|
+
Description: {
|
|
15
|
+
score: (nft: import("@xyo-network/crypto-nft-payload-plugin").NftInfo | import("@xyo-network/crypto-nft-payload-plugin").OpenSeaNftInfo) => import("..").ScaledScore;
|
|
16
|
+
weight: number;
|
|
17
|
+
};
|
|
18
|
+
'External Url': {
|
|
19
|
+
score: (nft: import("@xyo-network/crypto-nft-payload-plugin").NftInfo | import("@xyo-network/crypto-nft-payload-plugin").OpenSeaNftInfo) => import("..").ScaledScore;
|
|
20
|
+
weight: number;
|
|
21
|
+
};
|
|
22
|
+
Image: {
|
|
23
|
+
score: (nft: import("@xyo-network/crypto-nft-payload-plugin").NftInfo | import("@xyo-network/crypto-nft-payload-plugin").OpenSeaNftInfo) => import("..").ScaledScore;
|
|
24
|
+
weight: number;
|
|
25
|
+
};
|
|
26
|
+
'Image Data': {
|
|
27
|
+
score: (nft: import("@xyo-network/crypto-nft-payload-plugin").NftInfo | import("@xyo-network/crypto-nft-payload-plugin").OpenSeaNftInfo) => import("..").ScaledScore;
|
|
28
|
+
weight: number;
|
|
29
|
+
};
|
|
30
|
+
Name: {
|
|
31
|
+
score: (nft: import("@xyo-network/crypto-nft-payload-plugin").NftInfo | import("@xyo-network/crypto-nft-payload-plugin").OpenSeaNftInfo) => import("..").ScaledScore;
|
|
32
|
+
weight: number;
|
|
33
|
+
};
|
|
34
|
+
'YouTube URL': {
|
|
35
|
+
score: (nft: import("@xyo-network/crypto-nft-payload-plugin").NftInfo | import("@xyo-network/crypto-nft-payload-plugin").OpenSeaNftInfo) => import("..").ScaledScore;
|
|
36
|
+
weight: number;
|
|
37
|
+
};
|
|
38
|
+
'Contract Address': {
|
|
39
|
+
score: import("..").PassFailScoringFunction;
|
|
40
|
+
weight: number;
|
|
41
|
+
};
|
|
42
|
+
Supply: {
|
|
43
|
+
score: import("..").PassFailScoringFunction;
|
|
44
|
+
weight: number;
|
|
45
|
+
};
|
|
46
|
+
'Token Id': {
|
|
47
|
+
score: import("..").PassFailScoringFunction;
|
|
48
|
+
weight: number;
|
|
49
|
+
};
|
|
50
|
+
Type: {
|
|
51
|
+
score: import("..").PassFailScoringFunction;
|
|
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":"AAgCA,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,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { NftInfo } from '@xyo-network/crypto-nft-payload-plugin';
|
|
2
|
+
export type PassFailScore = [total: number, possible: 1];
|
|
3
|
+
export declare const PASS: PassFailScore;
|
|
4
|
+
export declare const FAIL: PassFailScore;
|
|
5
|
+
export type ScaledScore = [total: number, possible: number];
|
|
6
|
+
export declare const SKIP: ScaledScore;
|
|
7
|
+
export type Score = ScaledScore | PassFailScore;
|
|
8
|
+
export type PassFailScoringFunction = (nft: NftInfo) => PassFailScore | Promise<PassFailScore>;
|
|
9
|
+
export type ScaledScoringFunction = (nft: NftInfo) => Score | Promise<Score>;
|
|
10
|
+
export type ScoringFunction = PassFailScoringFunction | ScaledScoringFunction;
|
|
11
|
+
export interface WeightedScoringCriteria {
|
|
12
|
+
score: ScoringFunction;
|
|
13
|
+
weight: number;
|
|
14
|
+
}
|
|
15
|
+
export declare const incrementTotal: (score: ScaledScore, by?: number) => ScaledScore;
|
|
16
|
+
export declare const incrementPossible: (score: ScaledScore, by?: number) => ScaledScore;
|
|
17
|
+
export declare const incrementTotalAndPossible: (score: ScaledScore, totalBy?: number, possibleBy?: number) => ScaledScore;
|
|
18
|
+
//# sourceMappingURL=score.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"score.d.ts","sourceRoot":"","sources":["../../../../src/lib/rating/score.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wCAAwC,CAAA;AAEhE,MAAM,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAA;AACxD,eAAO,MAAM,IAAI,EAAE,aAAsB,CAAA;AACzC,eAAO,MAAM,IAAI,EAAE,aAAsB,CAAA;AACzC,MAAM,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;AAC3D,eAAO,MAAM,IAAI,EAAE,WAAoB,CAAA;AACvC,MAAM,MAAM,KAAK,GAAG,WAAW,GAAG,aAAa,CAAA;AAE/C,MAAM,MAAM,uBAAuB,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA;AAC9F,MAAM,MAAM,qBAAqB,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAA;AAC5E,MAAM,MAAM,eAAe,GAAG,uBAAuB,GAAG,qBAAqB,CAAA;AAE7E,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,eAAe,CAAA;IACtB,MAAM,EAAE,MAAM,CAAA;CACf;AAED,eAAO,MAAM,cAAc,kDAG1B,CAAA;AAED,eAAO,MAAM,iBAAiB,kDAG7B,CAAA;AAED,eAAO,MAAM,yBAAyB,4EAIrC,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xyo-network/crypto-nft-diviner-score-plugin",
|
|
3
|
+
"author": {
|
|
4
|
+
"email": "support@xyo.network",
|
|
5
|
+
"name": "XYO Development Team",
|
|
6
|
+
"url": "https://xyo.network"
|
|
7
|
+
},
|
|
8
|
+
"bugs": {
|
|
9
|
+
"email": "support@xyo.network",
|
|
10
|
+
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/issues"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@ethersproject/address": "^5.7.0",
|
|
14
|
+
"@xylabs/bignumber": "^2.9.3",
|
|
15
|
+
"@xylabs/url": "^2.9.3",
|
|
16
|
+
"@xyo-network/abstract-diviner": "~2.70.0",
|
|
17
|
+
"@xyo-network/core": "~2.70.0",
|
|
18
|
+
"@xyo-network/crypto-nft-payload-plugin": "~2.70.0",
|
|
19
|
+
"@xyo-network/diviner-model": "~2.70.0",
|
|
20
|
+
"@xyo-network/module": "~2.70.0",
|
|
21
|
+
"@xyo-network/payload-model": "~2.70.0",
|
|
22
|
+
"@xyo-network/payloadset-plugin": "~2.70.0",
|
|
23
|
+
"svg-parser": "^2.0.4"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/svg-parser": "^2.0.3",
|
|
27
|
+
"@xylabs/jest-helpers": "^2.9.3",
|
|
28
|
+
"@xylabs/ts-scripts-yarn3": "^2.19.0",
|
|
29
|
+
"@xylabs/tsconfig": "^2.19.0",
|
|
30
|
+
"ethers": "^5.7.2",
|
|
31
|
+
"jest": "^29.6.2",
|
|
32
|
+
"typescript": "^5.1.6"
|
|
33
|
+
},
|
|
34
|
+
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
35
|
+
"browser": "dist/esm/index.js",
|
|
36
|
+
"docs": "dist/docs.json",
|
|
37
|
+
"exports": {
|
|
38
|
+
".": {
|
|
39
|
+
"node": {
|
|
40
|
+
"import": "./dist/esm/index.js",
|
|
41
|
+
"require": "./dist/cjs/index.js"
|
|
42
|
+
},
|
|
43
|
+
"browser": {
|
|
44
|
+
"import": "./dist/esm/index.js",
|
|
45
|
+
"require": "./dist/cjs/index.js"
|
|
46
|
+
},
|
|
47
|
+
"default": "./dist/esm/index.js"
|
|
48
|
+
},
|
|
49
|
+
"./dist/docs.json": {
|
|
50
|
+
"default": "./dist/docs.json"
|
|
51
|
+
},
|
|
52
|
+
"./package.json": "./package.json"
|
|
53
|
+
},
|
|
54
|
+
"main": "dist/cjs/index.js",
|
|
55
|
+
"module": "dist/esm/index.js",
|
|
56
|
+
"homepage": "https://xyo.network",
|
|
57
|
+
"license": "LGPL-3.0",
|
|
58
|
+
"publishConfig": {
|
|
59
|
+
"access": "public"
|
|
60
|
+
},
|
|
61
|
+
"repository": {
|
|
62
|
+
"type": "git",
|
|
63
|
+
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js.git"
|
|
64
|
+
},
|
|
65
|
+
"sideEffects": false,
|
|
66
|
+
"types": "dist/types/index.d.ts",
|
|
67
|
+
"version": "2.70.0"
|
|
68
|
+
}
|
package/src/Diviner.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { AbstractDiviner } from '@xyo-network/abstract-diviner'
|
|
2
|
+
import { PayloadHasher } from '@xyo-network/core'
|
|
3
|
+
import {
|
|
4
|
+
isNftInfoPayload,
|
|
5
|
+
NftScoreDivinerConfig,
|
|
6
|
+
NftScoreDivinerConfigSchema,
|
|
7
|
+
NftScorePayload,
|
|
8
|
+
NftScoreSchema,
|
|
9
|
+
} from '@xyo-network/crypto-nft-payload-plugin'
|
|
10
|
+
import { DivinerParams } from '@xyo-network/diviner-model'
|
|
11
|
+
import { AnyConfigSchema } from '@xyo-network/module'
|
|
12
|
+
import { Payload } from '@xyo-network/payload-model'
|
|
13
|
+
|
|
14
|
+
import { analyzeNft, NftAnalysis } from './lib'
|
|
15
|
+
|
|
16
|
+
export type NftScoreDivinerParams = DivinerParams<AnyConfigSchema<NftScoreDivinerConfig>>
|
|
17
|
+
|
|
18
|
+
const toNftScorePayload = (rating: NftAnalysis): NftScorePayload => {
|
|
19
|
+
return { ...rating, schema: NftScoreSchema } as NftScorePayload
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const isNftScorePayload = (payload: Payload): payload is NftScorePayload => payload.schema === NftScoreSchema
|
|
23
|
+
|
|
24
|
+
export class NftScoreDiviner<TParams extends NftScoreDivinerParams = NftScoreDivinerParams> extends AbstractDiviner<TParams> {
|
|
25
|
+
static override configSchemas = [NftScoreDivinerConfigSchema]
|
|
26
|
+
|
|
27
|
+
protected override divineHandler = async (payloads?: Payload[]): Promise<Payload[]> => {
|
|
28
|
+
const nfts = payloads?.filter(isNftInfoPayload) ?? []
|
|
29
|
+
const results = await Promise.all(
|
|
30
|
+
nfts.map<Promise<NftScorePayload>>(async (p) => {
|
|
31
|
+
const [score, sourceHash] = await Promise.all([toNftScorePayload(await analyzeNft(p)), PayloadHasher.hashAsync(p)])
|
|
32
|
+
return { ...score, sources: [sourceHash] }
|
|
33
|
+
}),
|
|
34
|
+
)
|
|
35
|
+
return results
|
|
36
|
+
}
|
|
37
|
+
}
|
package/src/Plugin.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
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'
|
|
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
ADDED
package/src/lib/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './rating'
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { NftInfo } from '@xyo-network/crypto-nft-payload-plugin'
|
|
2
|
+
|
|
3
|
+
import { scoringCriteria } from './criteria'
|
|
4
|
+
import { Score } from './score'
|
|
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: NftInfo,
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './scoringCriteria'
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { isAddress } from '@ethersproject/address'
|
|
2
|
+
import { NftInfo } from '@xyo-network/crypto-nft-payload-plugin'
|
|
3
|
+
|
|
4
|
+
import { FAIL, PASS, PassFailScoringFunction } from '../../score'
|
|
5
|
+
|
|
6
|
+
export const scoreContractAddress: PassFailScoringFunction = (nft: NftInfo) => {
|
|
7
|
+
if (!nft.contract) return FAIL
|
|
8
|
+
if (typeof nft.contract !== 'string') return FAIL
|
|
9
|
+
if (!isAddress(nft.contract)) return FAIL
|
|
10
|
+
return PASS
|
|
11
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { NftInfo, OpenSeaNftInfo } from '@xyo-network/crypto-nft-payload-plugin'
|
|
2
|
+
|
|
3
|
+
import { incrementPossible, incrementTotal, incrementTotalAndPossible, PASS, ScaledScore } from '../../../score'
|
|
4
|
+
import { isSecure, isValidUrl, isWeb3 } from './lib'
|
|
5
|
+
|
|
6
|
+
export const scoreNftAnimationUrl = (nft: NftInfo | OpenSeaNftInfo): ScaledScore => {
|
|
7
|
+
return scoreAnimationUrl(nft.metadata?.animation_url)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const scoreAnimationUrl = (animation_url: unknown): ScaledScore => {
|
|
11
|
+
const score: ScaledScore = [0, 0]
|
|
12
|
+
if (animation_url === undefined || animation_url === null) return PASS
|
|
13
|
+
incrementPossible(score)
|
|
14
|
+
if (typeof animation_url !== 'string') return score
|
|
15
|
+
incrementTotalAndPossible(score)
|
|
16
|
+
if (!isValidUrl(animation_url)) return score
|
|
17
|
+
incrementTotalAndPossible(score)
|
|
18
|
+
if (!isSecure(animation_url)) return score
|
|
19
|
+
incrementTotalAndPossible(score)
|
|
20
|
+
if (!isWeb3(animation_url)) return score
|
|
21
|
+
return incrementTotal(score)
|
|
22
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { NftAttribute, NftInfo, OpenSeaNftAttribute, OpenSeaNftInfo } from '@xyo-network/crypto-nft-payload-plugin'
|
|
2
|
+
|
|
3
|
+
import { incrementPossible, incrementTotal, incrementTotalAndPossible, ScaledScore } from '../../../../score'
|
|
4
|
+
|
|
5
|
+
const isDate = (value: unknown): value is Date => {
|
|
6
|
+
if (isNumber(value)) {
|
|
7
|
+
try {
|
|
8
|
+
new Date(value)
|
|
9
|
+
return true
|
|
10
|
+
} catch (error) {
|
|
11
|
+
return false
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return false
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const isNumber = (value: unknown): value is number => typeof value === 'number'
|
|
18
|
+
|
|
19
|
+
const isPercentage = (value: unknown): boolean => isNumber(value) && value >= 0 && value <= 100
|
|
20
|
+
|
|
21
|
+
const isNonEmptyString = (value: unknown): value is string => typeof value === 'string' && value.length > 0
|
|
22
|
+
|
|
23
|
+
const isNonEmptyStringOrNumber = (value: unknown): value is string | number => value === 'number' || isNonEmptyString(value)
|
|
24
|
+
|
|
25
|
+
export const evaluateNftAttributes = (nft: NftInfo | OpenSeaNftInfo): ScaledScore =>
|
|
26
|
+
!nft?.metadata?.attributes ? [0, 1] : evaluateAttributes(nft?.metadata?.attributes)
|
|
27
|
+
|
|
28
|
+
export const evaluateAttributes = (attributes: NftAttribute[] | OpenSeaNftAttribute[] | unknown): ScaledScore => {
|
|
29
|
+
if (!attributes || !Array.isArray(attributes) || attributes.length === 0) return [0, 1]
|
|
30
|
+
const score: ScaledScore = [0, 0]
|
|
31
|
+
for (const attribute of attributes) {
|
|
32
|
+
const [attributeTotal, attributePossible] = evaluateAttribute(attribute)
|
|
33
|
+
incrementTotalAndPossible(score, attributeTotal, attributePossible)
|
|
34
|
+
}
|
|
35
|
+
return [1, 1]
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const evaluateAttribute = (attribute: OpenSeaNftAttribute): ScaledScore => {
|
|
39
|
+
const score: ScaledScore = [0, 1]
|
|
40
|
+
const max_value = attribute?.max_value
|
|
41
|
+
const trait_type = attribute?.trait_type
|
|
42
|
+
const value = attribute?.value
|
|
43
|
+
|
|
44
|
+
// Validate trait_type & value
|
|
45
|
+
if (!attribute || typeof attribute !== 'object' || !isNonEmptyString(trait_type) || !isNonEmptyStringOrNumber(value)) return score
|
|
46
|
+
incrementTotal(score)
|
|
47
|
+
|
|
48
|
+
// Validate display_type
|
|
49
|
+
incrementPossible(score)
|
|
50
|
+
if (validDisplayType(attribute)) incrementTotal(score)
|
|
51
|
+
|
|
52
|
+
// Validate max_value
|
|
53
|
+
if (max_value !== undefined) {
|
|
54
|
+
incrementPossible(score)
|
|
55
|
+
if (isNumber(max_value) && isNumber(value) && value <= max_value) incrementTotal(score)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return score
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const validDisplayType = (attribute: OpenSeaNftAttribute): boolean => {
|
|
62
|
+
switch (attribute?.display_type) {
|
|
63
|
+
case 'number':
|
|
64
|
+
case 'boost_number': {
|
|
65
|
+
if (isNumber(attribute?.value)) return true
|
|
66
|
+
break
|
|
67
|
+
}
|
|
68
|
+
case 'boost_percentage': {
|
|
69
|
+
if (isPercentage(attribute?.value)) return true
|
|
70
|
+
break
|
|
71
|
+
}
|
|
72
|
+
case 'date': {
|
|
73
|
+
if (isDate(attribute?.value)) return true
|
|
74
|
+
break
|
|
75
|
+
}
|
|
76
|
+
case 'string':
|
|
77
|
+
case undefined: {
|
|
78
|
+
if (isNonEmptyString(attribute?.value)) return true
|
|
79
|
+
break
|
|
80
|
+
}
|
|
81
|
+
default: {
|
|
82
|
+
break
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return false
|
|
86
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './evaluateAttributes'
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { NftInfo, OpenSeaNftInfo } from '@xyo-network/crypto-nft-payload-plugin'
|
|
2
|
+
|
|
3
|
+
import { incrementPossible, incrementTotal, incrementTotalAndPossible, PASS, ScaledScore } from '../../../score'
|
|
4
|
+
|
|
5
|
+
const isHexColor = /^[0-9A-F]{6}$/i
|
|
6
|
+
|
|
7
|
+
export const scoreNftBackgroundColor = (nft: NftInfo | OpenSeaNftInfo): ScaledScore => {
|
|
8
|
+
return scoreBackgroundColor(nft.metadata?.background_color)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const scoreBackgroundColor = (background_color: unknown): ScaledScore => {
|
|
12
|
+
const score: ScaledScore = [0, 0]
|
|
13
|
+
if (background_color === undefined || background_color === null) return PASS
|
|
14
|
+
incrementPossible(score)
|
|
15
|
+
if (typeof background_color !== 'string') return score
|
|
16
|
+
incrementTotalAndPossible(score)
|
|
17
|
+
if (!background_color.toUpperCase().match(isHexColor)) return score
|
|
18
|
+
return incrementTotal(score)
|
|
19
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { NftInfo, OpenSeaNftInfo } from '@xyo-network/crypto-nft-payload-plugin'
|
|
2
|
+
|
|
3
|
+
import { incrementTotal, ScaledScore } from '../../../score'
|
|
4
|
+
|
|
5
|
+
export const scoreNftDescription = (nft: NftInfo | OpenSeaNftInfo): 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
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { NftInfo, OpenSeaNftInfo } from '@xyo-network/crypto-nft-payload-plugin'
|
|
2
|
+
|
|
3
|
+
import { incrementTotal, ScaledScore } from '../../../score'
|
|
4
|
+
import { isSecure, isValidUrl } from './lib'
|
|
5
|
+
|
|
6
|
+
export const scoreNftExternalUrl = (nft: NftInfo | OpenSeaNftInfo): ScaledScore => {
|
|
7
|
+
return scoreExternalUrl(nft?.metadata?.external_url)
|
|
8
|
+
}
|
|
9
|
+
export const scoreExternalUrl = (external_url: unknown): ScaledScore => {
|
|
10
|
+
const score: ScaledScore = [0, 2]
|
|
11
|
+
if (external_url === undefined || external_url === null || typeof external_url !== 'string' || !isValidUrl(external_url)) return score
|
|
12
|
+
incrementTotal(score)
|
|
13
|
+
if (!isSecure(external_url)) return score
|
|
14
|
+
return incrementTotal(score)
|
|
15
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { NftInfo, OpenSeaNftInfo } from '@xyo-network/crypto-nft-payload-plugin'
|
|
2
|
+
|
|
3
|
+
import { incrementTotal, PASS, ScaledScore } from '../../../score'
|
|
4
|
+
import { isSecure, isValidUrl, isWeb3 } from './lib'
|
|
5
|
+
|
|
6
|
+
const MaxPossibleImageScore = 3
|
|
7
|
+
|
|
8
|
+
export const scoreNftImage = (nft: NftInfo | OpenSeaNftInfo): ScaledScore => {
|
|
9
|
+
// If there's no image data
|
|
10
|
+
if (!nft?.metadata?.image) {
|
|
11
|
+
// but there is image data, skip this scoring criteria, otherwise fail it completely
|
|
12
|
+
return nft.metadata?.image_data ? PASS : [0, MaxPossibleImageScore]
|
|
13
|
+
} else {
|
|
14
|
+
return scoreImage(nft.metadata?.image)
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const scoreImage = (image: unknown): ScaledScore => {
|
|
19
|
+
const score: ScaledScore = [0, MaxPossibleImageScore]
|
|
20
|
+
if (!image || typeof image !== 'string' || !isValidUrl(image)) return score
|
|
21
|
+
incrementTotal(score)
|
|
22
|
+
if (!isSecure(image)) return score
|
|
23
|
+
incrementTotal(score)
|
|
24
|
+
if (!isWeb3(image)) return score
|
|
25
|
+
incrementTotal(score)
|
|
26
|
+
return score
|
|
27
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { NftInfo, OpenSeaNftInfo } from '@xyo-network/crypto-nft-payload-plugin'
|
|
2
|
+
import { parse } from 'svg-parser'
|
|
3
|
+
|
|
4
|
+
import { PASS, ScaledScore } from '../../../score'
|
|
5
|
+
|
|
6
|
+
const MaxPossibleImageDataScore = 1
|
|
7
|
+
|
|
8
|
+
// NOTE: 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 (error) {
|
|
18
|
+
return false
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const scoreNftImageData = (nft: NftInfo | OpenSeaNftInfo): ScaledScore => {
|
|
23
|
+
// If there's no image data
|
|
24
|
+
if (!nft?.metadata?.image_data) {
|
|
25
|
+
// but there is an image, skip this scoring criteria, otherwise fail it completely
|
|
26
|
+
return nft.metadata?.image ? PASS : [0, MaxPossibleImageDataScore]
|
|
27
|
+
} else {
|
|
28
|
+
return scoreImageData(nft.metadata?.image_data)
|
|
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
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './animationUrl'
|
|
2
|
+
export * from './attributes'
|
|
3
|
+
export * from './backgroundColor'
|
|
4
|
+
export * from './description'
|
|
5
|
+
export * from './externalUrl'
|
|
6
|
+
export * from './image'
|
|
7
|
+
export * from './imageData'
|
|
8
|
+
export * from './name'
|
|
9
|
+
export * from './youtubeUrl'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './urlHelpers'
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { URL } from '@xylabs/url'
|
|
2
|
+
|
|
3
|
+
export const web3Protocols = ['ipfs:', 'ar:']
|
|
4
|
+
|
|
5
|
+
export const toUrl = (url?: string | null): URL | undefined => {
|
|
6
|
+
if (!url) return undefined
|
|
7
|
+
try {
|
|
8
|
+
return new URL(url)
|
|
9
|
+
} catch (e) {
|
|
10
|
+
return undefined
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const isValidUrl = (url?: string | null): boolean => toUrl(url) !== undefined
|
|
15
|
+
export const isWeb3 = (url?: string | null): boolean => web3Protocols.some((protocol) => protocol === toUrl(url)?.protocol)
|
|
16
|
+
export const isWeb2 = (url?: string | null): boolean => !isWeb3(url)
|
|
17
|
+
export const isSecure = (url?: string | null): boolean => isWeb3(url) || toUrl(url)?.protocol === 'https:'
|