@xyo-network/crypto-nft-collection-witness-plugin 4.2.0 → 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/package.json +24 -20
- package/src/lib/collectionMetrics/lib/probabilityDistributions/binomial/spec/calculateBinomialParamsFromOutcomes.spec.ts +33 -0
- package/src/lib/collectionMetrics/lib/probabilityDistributions/binomial/spec/calculateBinomialParamsFromProbability.spec.ts +33 -0
- package/src/lib/collectionMetrics/lib/spec/calculateAllPropertiesDistribution.spec.ts +27 -0
- package/src/lib/collectionMetrics/lib/spec/testData.json +1804 -0
- package/src/lib/collectionMetrics/spec/getNftCollectionInfo.spec.ts +24 -0
- package/src/lib/spec/getNftCollectionNfts.spec.ts +26 -0
- package/src/lib/spec/tokenTypes.spec.ts +26 -0
- package/src/spec/Plugin.spec.ts +17 -0
- package/src/spec/Witness.spec.ts +101 -0
- package/typedoc.json +0 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/crypto-nft-collection-witness-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,31 +28,35 @@
|
|
|
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
|
-
"@xylabs/assert": "^
|
|
33
|
-
"@xylabs/axios": "^
|
|
34
|
-
"@xylabs/eth-address": "^
|
|
35
|
-
"@xylabs/exists": "^
|
|
36
|
-
"@xylabs/hex": "^
|
|
37
|
-
"@xyo-network/crypto-nft-collection-payload-plugin": "^
|
|
38
|
-
"@xyo-network/crypto-nft-payload-plugin": "^
|
|
39
|
-
"@xyo-network/erc1822-witness": "^
|
|
40
|
-
"@xyo-network/erc1967-witness": "^
|
|
36
|
+
"@xylabs/assert": "^5.0.0",
|
|
37
|
+
"@xylabs/axios": "^5.0.0",
|
|
38
|
+
"@xylabs/eth-address": "^5.0.0",
|
|
39
|
+
"@xylabs/exists": "^5.0.0",
|
|
40
|
+
"@xylabs/hex": "^5.0.0",
|
|
41
|
+
"@xyo-network/crypto-nft-collection-payload-plugin": "^5.0.0",
|
|
42
|
+
"@xyo-network/crypto-nft-payload-plugin": "^5.0.0",
|
|
43
|
+
"@xyo-network/erc1822-witness": "^5.0.0",
|
|
44
|
+
"@xyo-network/erc1967-witness": "^5.0.0",
|
|
41
45
|
"@xyo-network/open-zeppelin-typechain": "^3.5.4",
|
|
42
|
-
"@xyo-network/payload-builder": "^
|
|
43
|
-
"@xyo-network/payload-model": "^
|
|
44
|
-
"@xyo-network/payloadset-plugin": "^
|
|
45
|
-
"@xyo-network/witness-blockchain-abstract": "^
|
|
46
|
-
"@xyo-network/witness-evm-abstract": "^
|
|
46
|
+
"@xyo-network/payload-builder": "^5.0.0",
|
|
47
|
+
"@xyo-network/payload-model": "^5.0.0",
|
|
48
|
+
"@xyo-network/payloadset-plugin": "^5.0.0",
|
|
49
|
+
"@xyo-network/witness-blockchain-abstract": "^5.0.0",
|
|
50
|
+
"@xyo-network/witness-evm-abstract": "^5.0.0",
|
|
47
51
|
"ethers": "^6.15.0"
|
|
48
52
|
},
|
|
49
53
|
"devDependencies": {
|
|
50
54
|
"@types/node": "^24.1.0",
|
|
51
|
-
"@xylabs/ts-scripts-yarn3": "^7.0.
|
|
52
|
-
"@xylabs/tsconfig": "^7.0.
|
|
53
|
-
"@xylabs/vitest-extended": "^
|
|
54
|
-
"@xyo-network/account": "^
|
|
55
|
-
"@xyo-network/account-model": "^
|
|
55
|
+
"@xylabs/ts-scripts-yarn3": "^7.0.2",
|
|
56
|
+
"@xylabs/tsconfig": "^7.0.2",
|
|
57
|
+
"@xylabs/vitest-extended": "^5.0.0",
|
|
58
|
+
"@xyo-network/account": "^5.0.0",
|
|
59
|
+
"@xyo-network/account-model": "^5.0.0",
|
|
56
60
|
"typescript": "^5.8.3",
|
|
57
61
|
"vitest": "^3.2.4"
|
|
58
62
|
},
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import '@xylabs/vitest-extended'
|
|
2
|
+
|
|
3
|
+
import type { BinomialDistributionParameters } from '@xyo-network/crypto-nft-collection-payload-plugin'
|
|
4
|
+
import {
|
|
5
|
+
describe, expect,
|
|
6
|
+
it,
|
|
7
|
+
} from 'vitest'
|
|
8
|
+
|
|
9
|
+
import { calculateBinomialParamsFromOutcomes } from '../calculateBinomialParamsFromOutcomes.ts'
|
|
10
|
+
|
|
11
|
+
describe('calculateBinomialParamsFromOutcomes', () => {
|
|
12
|
+
const data: [values: number[], outcome: BinomialDistributionParameters][] = [
|
|
13
|
+
[[1, 0], {
|
|
14
|
+
mean: 1, p: 0.5, stdDev: 0.707_106_781_186_547_6, variance: 0.5,
|
|
15
|
+
}],
|
|
16
|
+
[[1, 1, 0, 0], {
|
|
17
|
+
mean: 2, p: 0.5, stdDev: 1, variance: 1,
|
|
18
|
+
}],
|
|
19
|
+
[[1, 0, 0, 0], {
|
|
20
|
+
mean: 1, p: 0.25, stdDev: 0.866_025_403_784_438_6, variance: 0.75,
|
|
21
|
+
}],
|
|
22
|
+
[[1, 1, 1, 1], {
|
|
23
|
+
mean: 4, p: 1, stdDev: 0, variance: 0,
|
|
24
|
+
}],
|
|
25
|
+
[[0, 0, 0, 0], {
|
|
26
|
+
mean: 0, p: 0, stdDev: 0, variance: 0,
|
|
27
|
+
}],
|
|
28
|
+
]
|
|
29
|
+
it.each(data)('calculates the params', (values, outcome) => {
|
|
30
|
+
const result = calculateBinomialParamsFromOutcomes(values)
|
|
31
|
+
expect(result).toEqual(outcome)
|
|
32
|
+
})
|
|
33
|
+
})
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import '@xylabs/vitest-extended'
|
|
2
|
+
|
|
3
|
+
import type { BinomialDistributionParameters } from '@xyo-network/crypto-nft-collection-payload-plugin'
|
|
4
|
+
import {
|
|
5
|
+
describe, expect,
|
|
6
|
+
it,
|
|
7
|
+
} from 'vitest'
|
|
8
|
+
|
|
9
|
+
import { calculateBinomialParamsFromProbability } from '../calculateBinomialParamsFromProbability.ts'
|
|
10
|
+
|
|
11
|
+
describe('calculateBinomialParamsFromProbability', () => {
|
|
12
|
+
const data: [values: [trials: number, probability: number], outcome: BinomialDistributionParameters][] = [
|
|
13
|
+
[[2, 0.5], {
|
|
14
|
+
mean: 1, p: 0.5, stdDev: 0.707_106_781_186_547_6, variance: 0.5,
|
|
15
|
+
}],
|
|
16
|
+
[[4, 0.5], {
|
|
17
|
+
mean: 2, p: 0.5, stdDev: 1, variance: 1,
|
|
18
|
+
}],
|
|
19
|
+
[[4, 0.25], {
|
|
20
|
+
mean: 1, p: 0.25, stdDev: 0.866_025_403_784_438_6, variance: 0.75,
|
|
21
|
+
}],
|
|
22
|
+
[[4, 1], {
|
|
23
|
+
mean: 4, p: 1, stdDev: 0, variance: 0,
|
|
24
|
+
}],
|
|
25
|
+
[[4, 0], {
|
|
26
|
+
mean: 0, p: 0, stdDev: 0, variance: 0,
|
|
27
|
+
}],
|
|
28
|
+
]
|
|
29
|
+
it.each(data)('calculates the params', (values, outcome) => {
|
|
30
|
+
const result = calculateBinomialParamsFromProbability(values[0], values[1])
|
|
31
|
+
expect(result).toEqual(outcome)
|
|
32
|
+
})
|
|
33
|
+
})
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import '@xylabs/vitest-extended'
|
|
2
|
+
|
|
3
|
+
import { readFile } from 'node:fs/promises'
|
|
4
|
+
import Path from 'node:path'
|
|
5
|
+
|
|
6
|
+
import type { NftInfo, OpenSeaNftAttribute } from '@xyo-network/crypto-nft-payload-plugin'
|
|
7
|
+
import {
|
|
8
|
+
describe, expect,
|
|
9
|
+
test,
|
|
10
|
+
} from 'vitest'
|
|
11
|
+
|
|
12
|
+
import { calculateAllPropertiesDistribution } from '../calculateAllPropertiesDistribution.ts'
|
|
13
|
+
|
|
14
|
+
describe('calculateAllPropertiesDistribution', () => {
|
|
15
|
+
test('calculates the property distribution', async () => {
|
|
16
|
+
const filePath = Path.join(__dirname, 'testData.json')
|
|
17
|
+
const fileContents = await readFile(filePath, 'utf8')
|
|
18
|
+
const nfts = JSON.parse(fileContents) as NftInfo[]
|
|
19
|
+
const attributes = nfts
|
|
20
|
+
.map(nft => nft.metadata?.attributes as OpenSeaNftAttribute[])
|
|
21
|
+
.map((attributes) => {
|
|
22
|
+
return Object.fromEntries(attributes.map(attribute => [attribute.trait_type, attribute.value]))
|
|
23
|
+
})
|
|
24
|
+
const result = calculateAllPropertiesDistribution(attributes)
|
|
25
|
+
expect(result).toBeObject()
|
|
26
|
+
})
|
|
27
|
+
})
|