@xyo-network/crypto-nft-collection-diviner-score-plugin 4.1.1 → 5.0.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/dist/browser/index.d.ts +4 -33
- package/dist/neutral/index.d.ts +4 -33
- package/dist/node/index.d.ts +4 -33
- package/package.json +19 -16
- package/src/lib/rating/criteria/scoring/metadata/spec/scoreIndividualAttributes.spec.ts +32 -0
- package/src/lib/rating/criteria/scoring/metadata/spec/scoreTotalAttributes.spec.ts +32 -0
- package/src/lib/rating/criteria/scoring/spec/total.spec.ts +42 -0
- package/src/lib/rating/spec/analyzeNftCollection.spec.ts +38 -0
- package/src/lib/rating/spec/testData.json +1041 -0
- package/src/spec/Diviner.spec.ts +79 -0
- package/src/spec/Plugin.spec.ts +17 -0
- package/typedoc.json +0 -5
package/dist/browser/index.d.ts
CHANGED
|
@@ -1,33 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { Schema, Payload } from '@xyo-network/payload-model';
|
|
6
|
-
import { WeightedScoringCriteria, Score } from '@xyo-network/crypto-nft-score-model';
|
|
7
|
-
import * as _xyo_network_payloadset_plugin from '@xyo-network/payloadset-plugin';
|
|
8
|
-
|
|
9
|
-
type NftCollectionScoreDivinerParams = DivinerParams<AnyConfigSchema<NftCollectionScoreDivinerConfig>>;
|
|
10
|
-
declare class NftCollectionScoreDiviner<TParams extends NftCollectionScoreDivinerParams = NftCollectionScoreDivinerParams> extends AbstractDiviner<TParams> {
|
|
11
|
-
static readonly configSchemas: Schema[];
|
|
12
|
-
static readonly defaultConfigSchema: Schema;
|
|
13
|
-
protected divineHandler: (payloads?: Payload[]) => Promise<Payload[]>;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
declare const scoringCriteria: {
|
|
17
|
-
[key: string]: WeightedScoringCriteria<NftCollectionInfo>;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
type ScoringCriteriaKey = keyof typeof scoringCriteria & PropertyKey;
|
|
21
|
-
type NftCollectionAnalysis = {
|
|
22
|
-
[key in ScoringCriteriaKey]: Score;
|
|
23
|
-
};
|
|
24
|
-
declare const analyzeNftCollection: (
|
|
25
|
-
/**
|
|
26
|
-
* The NFT to evaluate
|
|
27
|
-
*/
|
|
28
|
-
nft: NftCollectionInfo) => Promise<NftCollectionAnalysis>;
|
|
29
|
-
|
|
30
|
-
declare const NftCollectionScoreDivinerPlugin: () => _xyo_network_payloadset_plugin.PayloadSetDivinerPlugin<NftCollectionScoreDiviner<NftCollectionScoreDivinerParams>>;
|
|
31
|
-
|
|
32
|
-
export { NftCollectionScoreDiviner, NftCollectionScoreDivinerPlugin, analyzeNftCollection, NftCollectionScoreDivinerPlugin as default, scoringCriteria };
|
|
33
|
-
export type { NftCollectionAnalysis, NftCollectionScoreDivinerParams, ScoringCriteriaKey };
|
|
1
|
+
export * from './Diviner.ts';
|
|
2
|
+
export * from './lib/index.ts';
|
|
3
|
+
export { NftCollectionScoreDivinerPlugin as default, NftCollectionScoreDivinerPlugin } from './Plugin.ts';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/neutral/index.d.ts
CHANGED
|
@@ -1,33 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { Schema, Payload } from '@xyo-network/payload-model';
|
|
6
|
-
import { WeightedScoringCriteria, Score } from '@xyo-network/crypto-nft-score-model';
|
|
7
|
-
import * as _xyo_network_payloadset_plugin from '@xyo-network/payloadset-plugin';
|
|
8
|
-
|
|
9
|
-
type NftCollectionScoreDivinerParams = DivinerParams<AnyConfigSchema<NftCollectionScoreDivinerConfig>>;
|
|
10
|
-
declare class NftCollectionScoreDiviner<TParams extends NftCollectionScoreDivinerParams = NftCollectionScoreDivinerParams> extends AbstractDiviner<TParams> {
|
|
11
|
-
static readonly configSchemas: Schema[];
|
|
12
|
-
static readonly defaultConfigSchema: Schema;
|
|
13
|
-
protected divineHandler: (payloads?: Payload[]) => Promise<Payload[]>;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
declare const scoringCriteria: {
|
|
17
|
-
[key: string]: WeightedScoringCriteria<NftCollectionInfo>;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
type ScoringCriteriaKey = keyof typeof scoringCriteria & PropertyKey;
|
|
21
|
-
type NftCollectionAnalysis = {
|
|
22
|
-
[key in ScoringCriteriaKey]: Score;
|
|
23
|
-
};
|
|
24
|
-
declare const analyzeNftCollection: (
|
|
25
|
-
/**
|
|
26
|
-
* The NFT to evaluate
|
|
27
|
-
*/
|
|
28
|
-
nft: NftCollectionInfo) => Promise<NftCollectionAnalysis>;
|
|
29
|
-
|
|
30
|
-
declare const NftCollectionScoreDivinerPlugin: () => _xyo_network_payloadset_plugin.PayloadSetDivinerPlugin<NftCollectionScoreDiviner<NftCollectionScoreDivinerParams>>;
|
|
31
|
-
|
|
32
|
-
export { NftCollectionScoreDiviner, NftCollectionScoreDivinerPlugin, analyzeNftCollection, NftCollectionScoreDivinerPlugin as default, scoringCriteria };
|
|
33
|
-
export type { NftCollectionAnalysis, NftCollectionScoreDivinerParams, ScoringCriteriaKey };
|
|
1
|
+
export * from './Diviner.ts';
|
|
2
|
+
export * from './lib/index.ts';
|
|
3
|
+
export { NftCollectionScoreDivinerPlugin as default, NftCollectionScoreDivinerPlugin } from './Plugin.ts';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1,33 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { Schema, Payload } from '@xyo-network/payload-model';
|
|
6
|
-
import { WeightedScoringCriteria, Score } from '@xyo-network/crypto-nft-score-model';
|
|
7
|
-
import * as _xyo_network_payloadset_plugin from '@xyo-network/payloadset-plugin';
|
|
8
|
-
|
|
9
|
-
type NftCollectionScoreDivinerParams = DivinerParams<AnyConfigSchema<NftCollectionScoreDivinerConfig>>;
|
|
10
|
-
declare class NftCollectionScoreDiviner<TParams extends NftCollectionScoreDivinerParams = NftCollectionScoreDivinerParams> extends AbstractDiviner<TParams> {
|
|
11
|
-
static readonly configSchemas: Schema[];
|
|
12
|
-
static readonly defaultConfigSchema: Schema;
|
|
13
|
-
protected divineHandler: (payloads?: Payload[]) => Promise<Payload[]>;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
declare const scoringCriteria: {
|
|
17
|
-
[key: string]: WeightedScoringCriteria<NftCollectionInfo>;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
type ScoringCriteriaKey = keyof typeof scoringCriteria & PropertyKey;
|
|
21
|
-
type NftCollectionAnalysis = {
|
|
22
|
-
[key in ScoringCriteriaKey]: Score;
|
|
23
|
-
};
|
|
24
|
-
declare const analyzeNftCollection: (
|
|
25
|
-
/**
|
|
26
|
-
* The NFT to evaluate
|
|
27
|
-
*/
|
|
28
|
-
nft: NftCollectionInfo) => Promise<NftCollectionAnalysis>;
|
|
29
|
-
|
|
30
|
-
declare const NftCollectionScoreDivinerPlugin: () => _xyo_network_payloadset_plugin.PayloadSetDivinerPlugin<NftCollectionScoreDiviner<NftCollectionScoreDivinerParams>>;
|
|
31
|
-
|
|
32
|
-
export { NftCollectionScoreDiviner, NftCollectionScoreDivinerPlugin, analyzeNftCollection, NftCollectionScoreDivinerPlugin as default, scoringCriteria };
|
|
33
|
-
export type { NftCollectionAnalysis, NftCollectionScoreDivinerParams, ScoringCriteriaKey };
|
|
1
|
+
export * from './Diviner.ts';
|
|
2
|
+
export * from './lib/index.ts';
|
|
3
|
+
export { NftCollectionScoreDivinerPlugin as default, NftCollectionScoreDivinerPlugin } from './Plugin.ts';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/crypto-nft-collection-diviner-score-plugin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Typescript/Javascript Plugins for XYO Platform",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -28,25 +28,28 @@
|
|
|
28
28
|
},
|
|
29
29
|
"module": "dist/neutral/index.mjs",
|
|
30
30
|
"types": "dist/neutral/index.d.ts",
|
|
31
|
+
"files": [
|
|
32
|
+
"dist",
|
|
33
|
+
"src"
|
|
34
|
+
],
|
|
31
35
|
"dependencies": {
|
|
32
|
-
"@xyo-network/crypto-nft-collection-payload-plugin": "^
|
|
33
|
-
"@xyo-network/crypto-nft-payload-plugin": "^
|
|
34
|
-
"@xyo-network/crypto-nft-score-model": "^
|
|
35
|
-
"@xyo-network/diviner-abstract": "^
|
|
36
|
-
"@xyo-network/diviner-model": "^
|
|
37
|
-
"@xyo-network/module-model": "^
|
|
38
|
-
"@xyo-network/payload-builder": "^
|
|
39
|
-
"@xyo-network/payload-model": "^
|
|
40
|
-
"@xyo-network/payloadset-plugin": "^
|
|
36
|
+
"@xyo-network/crypto-nft-collection-payload-plugin": "^5.0.0",
|
|
37
|
+
"@xyo-network/crypto-nft-payload-plugin": "^5.0.0",
|
|
38
|
+
"@xyo-network/crypto-nft-score-model": "^5.0.0",
|
|
39
|
+
"@xyo-network/diviner-abstract": "^5.0.0",
|
|
40
|
+
"@xyo-network/diviner-model": "^5.0.0",
|
|
41
|
+
"@xyo-network/module-model": "^5.0.0",
|
|
42
|
+
"@xyo-network/payload-builder": "^5.0.0",
|
|
43
|
+
"@xyo-network/payload-model": "^5.0.0",
|
|
44
|
+
"@xyo-network/payloadset-plugin": "^5.0.0"
|
|
41
45
|
},
|
|
42
46
|
"devDependencies": {
|
|
43
|
-
"@xylabs/ts-scripts-yarn3": "^7.0.
|
|
44
|
-
"@xylabs/tsconfig": "^7.0.
|
|
45
|
-
"@xylabs/vitest-extended": "^
|
|
46
|
-
"@xyo-network/account": "^
|
|
47
|
-
"@xyo-network/payload-wrapper": "^
|
|
47
|
+
"@xylabs/ts-scripts-yarn3": "^7.0.2",
|
|
48
|
+
"@xylabs/tsconfig": "^7.0.2",
|
|
49
|
+
"@xylabs/vitest-extended": "^5.0.0",
|
|
50
|
+
"@xyo-network/account": "^5.0.0",
|
|
51
|
+
"@xyo-network/payload-wrapper": "^5.0.0",
|
|
48
52
|
"ethers": "^6.15.0",
|
|
49
|
-
"knip": "^5.62.0",
|
|
50
53
|
"typescript": "^5.8.3",
|
|
51
54
|
"vitest": "^3.2.4"
|
|
52
55
|
},
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import '@xylabs/vitest-extended'
|
|
2
|
+
|
|
3
|
+
import { readFile } from 'node:fs/promises'
|
|
4
|
+
import Path from 'node:path'
|
|
5
|
+
|
|
6
|
+
import type { NftCollectionInfo } from '@xyo-network/crypto-nft-collection-payload-plugin'
|
|
7
|
+
import {
|
|
8
|
+
beforeAll,
|
|
9
|
+
describe, expect, it,
|
|
10
|
+
} from 'vitest'
|
|
11
|
+
|
|
12
|
+
import { scoreIndividualAttributes } from '../scoreIndividualAttributes.ts'
|
|
13
|
+
|
|
14
|
+
describe('scoreIndividualAttributes', () => {
|
|
15
|
+
let collections: NftCollectionInfo[]
|
|
16
|
+
beforeAll(async () => {
|
|
17
|
+
const filePath = Path.join(__dirname, '../../../../spec', 'testData.json')
|
|
18
|
+
const fileContents = await readFile(filePath, 'utf8')
|
|
19
|
+
collections = JSON.parse(fileContents) as NftCollectionInfo[]
|
|
20
|
+
})
|
|
21
|
+
it('evaluates the NFT collection', () => {
|
|
22
|
+
for (let collection of collections) {
|
|
23
|
+
const score = scoreIndividualAttributes(collection)
|
|
24
|
+
const [total, possible] = score
|
|
25
|
+
expect(total).toBeNumber()
|
|
26
|
+
expect(total).not.toBeNegative()
|
|
27
|
+
expect(possible).toBeNumber()
|
|
28
|
+
expect(possible).not.toBeNegative()
|
|
29
|
+
expect(total).toBeLessThanOrEqual(possible)
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
})
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import '@xylabs/vitest-extended'
|
|
2
|
+
|
|
3
|
+
import { readFile } from 'node:fs/promises'
|
|
4
|
+
import Path from 'node:path'
|
|
5
|
+
|
|
6
|
+
import type { NftCollectionInfo } from '@xyo-network/crypto-nft-collection-payload-plugin'
|
|
7
|
+
import {
|
|
8
|
+
beforeAll,
|
|
9
|
+
describe, expect, it,
|
|
10
|
+
} from 'vitest'
|
|
11
|
+
|
|
12
|
+
import { scoreTotalAttributes } from '../scoreTotalAttributes.ts'
|
|
13
|
+
|
|
14
|
+
describe('scoreTotalAttributes', () => {
|
|
15
|
+
let collections: NftCollectionInfo[]
|
|
16
|
+
beforeAll(async () => {
|
|
17
|
+
const filePath = Path.join(__dirname, '../../../../spec', 'testData.json')
|
|
18
|
+
const fileContents = await readFile(filePath, 'utf8')
|
|
19
|
+
collections = JSON.parse(fileContents) as NftCollectionInfo[]
|
|
20
|
+
})
|
|
21
|
+
it('evaluates the NFT collection', () => {
|
|
22
|
+
for (let collection of collections) {
|
|
23
|
+
const score = scoreTotalAttributes(collection)
|
|
24
|
+
const [total, possible] = score
|
|
25
|
+
expect(total).toBeNumber()
|
|
26
|
+
expect(total).not.toBeNegative()
|
|
27
|
+
expect(possible).toBeNumber()
|
|
28
|
+
expect(possible).not.toBeNegative()
|
|
29
|
+
expect(total).toBeLessThanOrEqual(possible)
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
})
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import '@xylabs/vitest-extended'
|
|
2
|
+
|
|
3
|
+
import type { NftCollectionCount } from '@xyo-network/crypto-nft-collection-payload-plugin'
|
|
4
|
+
import {
|
|
5
|
+
describe, expect,
|
|
6
|
+
it,
|
|
7
|
+
} from 'vitest'
|
|
8
|
+
|
|
9
|
+
import { scoreTotal } from '../total.ts'
|
|
10
|
+
|
|
11
|
+
describe('scoreTotal', () => {
|
|
12
|
+
const values: [total: number, expected: number][] = [
|
|
13
|
+
[1, 0],
|
|
14
|
+
[2, 0],
|
|
15
|
+
[3, 0],
|
|
16
|
+
[10, 1],
|
|
17
|
+
[20, 1],
|
|
18
|
+
[30, 2],
|
|
19
|
+
[100, 3],
|
|
20
|
+
[200, 4],
|
|
21
|
+
[300, 5],
|
|
22
|
+
[1000, 7],
|
|
23
|
+
[2000, 9],
|
|
24
|
+
[3000, 9],
|
|
25
|
+
[10_000, 10],
|
|
26
|
+
[20_000, 10],
|
|
27
|
+
[30_000, 9],
|
|
28
|
+
[100_000, 7],
|
|
29
|
+
[200_000, 6],
|
|
30
|
+
[300_000, 5],
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
it.each(values)('scores %s as %s', (total, expected) => {
|
|
34
|
+
const collection: NftCollectionCount = { total }
|
|
35
|
+
const [score, possible] = scoreTotal(collection)
|
|
36
|
+
expect(score).toBeNumber()
|
|
37
|
+
expect(score).not.toBeNegative()
|
|
38
|
+
expect(possible).not.toBeNegative()
|
|
39
|
+
expect(possible).toBeNumber()
|
|
40
|
+
expect(score).toBe(expected)
|
|
41
|
+
})
|
|
42
|
+
})
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import '@xylabs/vitest-extended'
|
|
2
|
+
|
|
3
|
+
import { readFile } from 'node:fs/promises'
|
|
4
|
+
import Path from 'node:path'
|
|
5
|
+
|
|
6
|
+
import type { NftCollectionInfo } from '@xyo-network/crypto-nft-collection-payload-plugin'
|
|
7
|
+
import {
|
|
8
|
+
beforeAll,
|
|
9
|
+
describe, expect, it,
|
|
10
|
+
} from 'vitest'
|
|
11
|
+
|
|
12
|
+
import { analyzeNftCollection } from '../analyzeNftCollection.ts'
|
|
13
|
+
|
|
14
|
+
describe('analyzeNftCollection', () => {
|
|
15
|
+
let collections: NftCollectionInfo[]
|
|
16
|
+
beforeAll(async () => {
|
|
17
|
+
const filePath = Path.join(__dirname, 'testData.json')
|
|
18
|
+
const fileContents = await readFile(filePath, 'utf8')
|
|
19
|
+
collections = JSON.parse(fileContents) as NftCollectionInfo[]
|
|
20
|
+
})
|
|
21
|
+
it('evaluates the NFT collection', async () => {
|
|
22
|
+
await Promise.all(
|
|
23
|
+
collections.map(async (collection) => {
|
|
24
|
+
const rating = await analyzeNftCollection(collection)
|
|
25
|
+
expect(rating).toBeObject()
|
|
26
|
+
for (let [key, score] of Object.entries(rating)) {
|
|
27
|
+
expect(key).toBeString()
|
|
28
|
+
const [total, possible] = score
|
|
29
|
+
expect(total).toBeNumber()
|
|
30
|
+
expect(total).not.toBeNegative()
|
|
31
|
+
expect(possible).toBeNumber()
|
|
32
|
+
expect(possible).not.toBeNegative()
|
|
33
|
+
expect(total).toBeLessThanOrEqual(possible)
|
|
34
|
+
}
|
|
35
|
+
}),
|
|
36
|
+
)
|
|
37
|
+
})
|
|
38
|
+
})
|