@xyo-network/crypto-nft-witness-wallet-plugin 5.1.3 → 5.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.mjs +6 -4
- package/dist/browser/index.mjs.map +1 -1
- package/dist/browser/lib/getAssetsFromWallet.d.ts.map +1 -1
- package/dist/browser/lib/getNftMetadata.d.ts.map +1 -1
- package/dist/browser/lib/getNftsFromWalletFromOpenSea.d.ts.map +1 -1
- package/dist/neutral/index.mjs +6 -4
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/lib/getAssetsFromWallet.d.ts.map +1 -1
- package/dist/neutral/lib/getNftMetadata.d.ts.map +1 -1
- package/dist/neutral/lib/getNftsFromWalletFromOpenSea.d.ts.map +1 -1
- package/dist/node/index.mjs +6 -4
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/lib/getAssetsFromWallet.d.ts.map +1 -1
- package/dist/node/lib/getNftMetadata.d.ts.map +1 -1
- package/dist/node/lib/getNftsFromWalletFromOpenSea.d.ts.map +1 -1
- package/package.json +48 -41
- package/src/lib/getAssetsFromWallet.ts +3 -2
- package/src/lib/getNftMetadata.ts +3 -2
- package/src/lib/getNftsFromWalletFromOpenSea.ts +3 -2
- package/dist/browser/lib/spec/getNftsOwnedByAddress.spec.d.ts +0 -2
- package/dist/browser/lib/spec/getNftsOwnedByAddress.spec.d.ts.map +0 -1
- package/dist/browser/lib/spec/getNftsOwnedByAddressWithMeta.spec.d.ts +0 -2
- package/dist/browser/lib/spec/getNftsOwnedByAddressWithMeta.spec.d.ts.map +0 -1
- package/dist/browser/spec/Plugin.spec.d.ts +0 -2
- package/dist/browser/spec/Plugin.spec.d.ts.map +0 -1
- package/dist/browser/spec/Witness.Index.spec.d.ts +0 -2
- package/dist/browser/spec/Witness.Index.spec.d.ts.map +0 -1
- package/dist/browser/spec/Witness.spec.d.ts +0 -2
- package/dist/browser/spec/Witness.spec.d.ts.map +0 -1
- package/dist/neutral/lib/spec/getNftsOwnedByAddress.spec.d.ts +0 -2
- package/dist/neutral/lib/spec/getNftsOwnedByAddress.spec.d.ts.map +0 -1
- package/dist/neutral/lib/spec/getNftsOwnedByAddressWithMeta.spec.d.ts +0 -2
- package/dist/neutral/lib/spec/getNftsOwnedByAddressWithMeta.spec.d.ts.map +0 -1
- package/dist/neutral/spec/Plugin.spec.d.ts +0 -2
- package/dist/neutral/spec/Plugin.spec.d.ts.map +0 -1
- package/dist/neutral/spec/Witness.Index.spec.d.ts +0 -2
- package/dist/neutral/spec/Witness.Index.spec.d.ts.map +0 -1
- package/dist/neutral/spec/Witness.spec.d.ts +0 -2
- package/dist/neutral/spec/Witness.spec.d.ts.map +0 -1
- package/dist/node/lib/spec/getNftsOwnedByAddress.spec.d.ts +0 -2
- package/dist/node/lib/spec/getNftsOwnedByAddress.spec.d.ts.map +0 -1
- package/dist/node/lib/spec/getNftsOwnedByAddressWithMeta.spec.d.ts +0 -2
- package/dist/node/lib/spec/getNftsOwnedByAddressWithMeta.spec.d.ts.map +0 -1
- package/dist/node/spec/Plugin.spec.d.ts +0 -2
- package/dist/node/spec/Plugin.spec.d.ts.map +0 -1
- package/dist/node/spec/Witness.Index.spec.d.ts +0 -2
- package/dist/node/spec/Witness.Index.spec.d.ts.map +0 -1
- package/dist/node/spec/Witness.spec.d.ts +0 -2
- package/dist/node/spec/Witness.spec.d.ts.map +0 -1
- package/src/lib/spec/getNftsOwnedByAddress.spec.ts +0 -34
- package/src/lib/spec/getNftsOwnedByAddressWithMeta.spec.ts +0 -34
- package/src/spec/Plugin.spec.ts +0 -17
- package/src/spec/Witness.Index.spec.ts +0 -262
- package/src/spec/Witness.spec.ts +0 -60
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/crypto-nft-witness-wallet-plugin",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.5",
|
|
4
4
|
"description": "Typescript/Javascript Plugins for XYO Platform",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -30,53 +30,60 @@
|
|
|
30
30
|
"types": "dist/neutral/index.d.ts",
|
|
31
31
|
"files": [
|
|
32
32
|
"dist",
|
|
33
|
-
"src"
|
|
33
|
+
"src",
|
|
34
|
+
"!**/*.bench.*",
|
|
35
|
+
"!**/*.spec.*",
|
|
36
|
+
"!**/*.test.*"
|
|
34
37
|
],
|
|
35
38
|
"dependencies": {
|
|
36
|
-
"@xylabs/assert": "~5.0.
|
|
37
|
-
"@xylabs/axios": "~5.0.
|
|
38
|
-
"@xylabs/eth-address": "~5.0.
|
|
39
|
-
"@xylabs/hex": "~5.0.
|
|
40
|
-
"@xyo-network/crypto-nft-collection-payload-plugin": "~5.1.
|
|
41
|
-
"@xyo-network/crypto-nft-payload-plugin": "~5.1.
|
|
42
|
-
"@xyo-network/erc1822-witness": "~5.1.
|
|
43
|
-
"@xyo-network/erc1967-witness": "~5.1.
|
|
44
|
-
"@xyo-network/open-zeppelin-typechain": "~4.0.
|
|
45
|
-
"@xyo-network/payload-model": "~5.1.
|
|
46
|
-
"@xyo-network/payloadset-plugin": "~5.1.
|
|
47
|
-
"@xyo-network/witness-blockchain-abstract": "~5.1.
|
|
48
|
-
"@xyo-network/witness-evm-abstract": "~5.1.
|
|
39
|
+
"@xylabs/assert": "~5.0.37",
|
|
40
|
+
"@xylabs/axios": "~5.0.37",
|
|
41
|
+
"@xylabs/eth-address": "~5.0.37",
|
|
42
|
+
"@xylabs/hex": "~5.0.37",
|
|
43
|
+
"@xyo-network/crypto-nft-collection-payload-plugin": "~5.1.5",
|
|
44
|
+
"@xyo-network/crypto-nft-payload-plugin": "~5.1.5",
|
|
45
|
+
"@xyo-network/erc1822-witness": "~5.1.5",
|
|
46
|
+
"@xyo-network/erc1967-witness": "~5.1.5",
|
|
47
|
+
"@xyo-network/open-zeppelin-typechain": "~4.0.10",
|
|
48
|
+
"@xyo-network/payload-model": "~5.1.23",
|
|
49
|
+
"@xyo-network/payloadset-plugin": "~5.1.23",
|
|
50
|
+
"@xyo-network/witness-blockchain-abstract": "~5.1.23",
|
|
51
|
+
"@xyo-network/witness-evm-abstract": "~5.1.23",
|
|
49
52
|
"ethers": "~6.15.0",
|
|
50
|
-
"lru-cache": "~11.
|
|
53
|
+
"lru-cache": "~11.2.2",
|
|
51
54
|
"parse-data-url": "~6.0.0"
|
|
52
55
|
},
|
|
53
56
|
"devDependencies": {
|
|
54
57
|
"@types/parse-data-url": "~3.0.2",
|
|
55
|
-
"@xylabs/array": "~5.0.
|
|
56
|
-
"@xylabs/delay": "~5.0.
|
|
57
|
-
"@xylabs/exists": "~5.0.
|
|
58
|
-
"@xylabs/ts-scripts-yarn3": "~7.
|
|
59
|
-
"@xylabs/tsconfig": "~7.
|
|
60
|
-
"@xylabs/vitest-extended": "~5.0.
|
|
61
|
-
"@xyo-network/archivist-memory": "~5.1.
|
|
62
|
-
"@xyo-network/archivist-model": "~5.1.
|
|
63
|
-
"@xyo-network/boundwitness-builder": "~5.1.
|
|
64
|
-
"@xyo-network/boundwitness-model": "~5.1.
|
|
65
|
-
"@xyo-network/diviner-boundwitness-memory": "~5.1.
|
|
66
|
-
"@xyo-network/diviner-model": "~5.1.
|
|
67
|
-
"@xyo-network/diviner-payload-generic": "~5.1.
|
|
68
|
-
"@xyo-network/diviner-payload-model": "~5.1.
|
|
69
|
-
"@xyo-network/diviner-temporal-indexing": "~5.1.
|
|
70
|
-
"@xyo-network/manifest": "~5.1.
|
|
71
|
-
"@xyo-network/module-factory-locator": "~5.1.
|
|
72
|
-
"@xyo-network/module-model": "~5.1.
|
|
73
|
-
"@xyo-network/node-memory": "~5.1.
|
|
74
|
-
"@xyo-network/payload-builder": "~5.1.
|
|
75
|
-
"@xyo-network/payload-wrapper": "~5.1.
|
|
76
|
-
"@xyo-network/wallet": "~5.1.
|
|
77
|
-
"@xyo-network/witness-blockchain": "~5.1.
|
|
78
|
-
"
|
|
79
|
-
"
|
|
58
|
+
"@xylabs/array": "~5.0.37",
|
|
59
|
+
"@xylabs/delay": "~5.0.37",
|
|
60
|
+
"@xylabs/exists": "~5.0.37",
|
|
61
|
+
"@xylabs/ts-scripts-yarn3": "~7.2.8",
|
|
62
|
+
"@xylabs/tsconfig": "~7.2.8",
|
|
63
|
+
"@xylabs/vitest-extended": "~5.0.37",
|
|
64
|
+
"@xyo-network/archivist-memory": "~5.1.23",
|
|
65
|
+
"@xyo-network/archivist-model": "~5.1.23",
|
|
66
|
+
"@xyo-network/boundwitness-builder": "~5.1.23",
|
|
67
|
+
"@xyo-network/boundwitness-model": "~5.1.23",
|
|
68
|
+
"@xyo-network/diviner-boundwitness-memory": "~5.1.23",
|
|
69
|
+
"@xyo-network/diviner-model": "~5.1.23",
|
|
70
|
+
"@xyo-network/diviner-payload-generic": "~5.1.23",
|
|
71
|
+
"@xyo-network/diviner-payload-model": "~5.1.23",
|
|
72
|
+
"@xyo-network/diviner-temporal-indexing": "~5.1.23",
|
|
73
|
+
"@xyo-network/manifest": "~5.1.23",
|
|
74
|
+
"@xyo-network/module-factory-locator": "~5.1.23",
|
|
75
|
+
"@xyo-network/module-model": "~5.1.23",
|
|
76
|
+
"@xyo-network/node-memory": "~5.1.23",
|
|
77
|
+
"@xyo-network/payload-builder": "~5.1.23",
|
|
78
|
+
"@xyo-network/payload-wrapper": "~5.1.23",
|
|
79
|
+
"@xyo-network/wallet": "~5.1.23",
|
|
80
|
+
"@xyo-network/witness-blockchain": "~5.1.23",
|
|
81
|
+
"axios": "~1.13.2",
|
|
82
|
+
"typescript": "~5.9.3",
|
|
83
|
+
"vitest": "~4.0.10"
|
|
84
|
+
},
|
|
85
|
+
"peerDependencies": {
|
|
86
|
+
"axios": "~1.13.2"
|
|
80
87
|
},
|
|
81
88
|
"publishConfig": {
|
|
82
89
|
"access": "public"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { assertEx } from '@xylabs/assert'
|
|
2
|
-
import {
|
|
2
|
+
import { axiosJsonConfig } from '@xylabs/axios'
|
|
3
|
+
import { Axios } from 'axios'
|
|
3
4
|
|
|
4
5
|
interface QuickNodeAsset {
|
|
5
6
|
chain: string
|
|
@@ -25,7 +26,7 @@ interface QuickNodeFetchNftsResult {
|
|
|
25
26
|
export const getAssetsFromWallet = async (address: string, maxNfts = 10, timeout = 2000) => {
|
|
26
27
|
const endpoint = assertEx(process.env.QUICKNODE_API_URI, () => 'No endpoint found')
|
|
27
28
|
|
|
28
|
-
const axios = new
|
|
29
|
+
const axios = new Axios(axiosJsonConfig({ timeout }))
|
|
29
30
|
|
|
30
31
|
const assets: QuickNodeAsset[] = []
|
|
31
32
|
let done = false
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/* eslint-disable complexity */
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { axiosJsonConfig } from '@xylabs/axios'
|
|
4
4
|
import type { NftMetadata } from '@xyo-network/crypto-nft-payload-plugin'
|
|
5
5
|
import { ERC721URIStorage__factory, ERC1155URIStorage__factory } from '@xyo-network/open-zeppelin-typechain'
|
|
6
6
|
import { checkIpfsUrl } from '@xyo-network/witness-blockchain-abstract'
|
|
7
|
+
import { Axios } from 'axios'
|
|
7
8
|
import type { Provider } from 'ethers'
|
|
8
9
|
import parseDataUrl from 'parse-data-url'
|
|
9
10
|
|
|
@@ -107,7 +108,7 @@ export const getNftMetadata = async (
|
|
|
107
108
|
console.log(`tokenMetadataUri [uri1155]: ${uri1155}`)
|
|
108
109
|
console.log(`tokenMetadataUri [defaultUri]: ${defaultUri}`)
|
|
109
110
|
} */
|
|
110
|
-
const axios = new
|
|
111
|
+
const axios = new Axios(axiosJsonConfig({ timeout: 5000 }))
|
|
111
112
|
try {
|
|
112
113
|
if (tokenMetadataUri && tokenMetadataUri.length > 0) {
|
|
113
114
|
checkedMetaDataUri = tokenMetadataUri ? checkIpfsUrl(tokenMetadataUri, ipfsGateway) : tokenMetadataUri
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { assertEx } from '@xylabs/assert'
|
|
2
|
-
import {
|
|
2
|
+
import { axiosJsonConfig } from '@xylabs/axios'
|
|
3
3
|
import type { EthAddress } from '@xylabs/hex'
|
|
4
|
+
import { Axios } from 'axios'
|
|
4
5
|
|
|
5
6
|
interface OpenSeaNFT {
|
|
6
7
|
/*
|
|
@@ -56,7 +57,7 @@ interface OpenSeaNFT {
|
|
|
56
57
|
export const getNftsFromWalletFromOpenSea = async (address: string, maxNfts = 200, timeout = 2000) => {
|
|
57
58
|
const apiKey = assertEx(process.env.OPENSEA_API_KEY, () => 'No opensea key found')
|
|
58
59
|
|
|
59
|
-
const axios = new
|
|
60
|
+
const axios = new Axios(axiosJsonConfig({ headers: { 'x-api-key': apiKey }, timeout }))
|
|
60
61
|
|
|
61
62
|
const nfts = (await axios.get<{ nfts: OpenSeaNFT[] }>(`https://api.opensea.io/api/v2/chain/ethereum/account/${address}/nfts?limit=${maxNfts}`)).data
|
|
62
63
|
.nfts
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getNftsOwnedByAddress.spec.d.ts","sourceRoot":"","sources":["../../../../src/lib/spec/getNftsOwnedByAddress.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getNftsOwnedByAddressWithMeta.spec.d.ts","sourceRoot":"","sources":["../../../../src/lib/spec/getNftsOwnedByAddressWithMeta.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Plugin.spec.d.ts","sourceRoot":"","sources":["../../../src/spec/Plugin.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Witness.Index.spec.d.ts","sourceRoot":"","sources":["../../../src/spec/Witness.Index.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Witness.spec.d.ts","sourceRoot":"","sources":["../../../src/spec/Witness.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getNftsOwnedByAddress.spec.d.ts","sourceRoot":"","sources":["../../../../src/lib/spec/getNftsOwnedByAddress.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getNftsOwnedByAddressWithMeta.spec.d.ts","sourceRoot":"","sources":["../../../../src/lib/spec/getNftsOwnedByAddressWithMeta.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Plugin.spec.d.ts","sourceRoot":"","sources":["../../../src/spec/Plugin.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Witness.Index.spec.d.ts","sourceRoot":"","sources":["../../../src/spec/Witness.Index.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Witness.spec.d.ts","sourceRoot":"","sources":["../../../src/spec/Witness.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getNftsOwnedByAddress.spec.d.ts","sourceRoot":"","sources":["../../../../src/lib/spec/getNftsOwnedByAddress.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getNftsOwnedByAddressWithMeta.spec.d.ts","sourceRoot":"","sources":["../../../../src/lib/spec/getNftsOwnedByAddressWithMeta.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Plugin.spec.d.ts","sourceRoot":"","sources":["../../../src/spec/Plugin.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Witness.Index.spec.d.ts","sourceRoot":"","sources":["../../../src/spec/Witness.Index.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Witness.spec.d.ts","sourceRoot":"","sources":["../../../src/spec/Witness.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import '@xylabs/vitest-extended'
|
|
2
|
-
|
|
3
|
-
import { getProviderFromEnv } from '@xyo-network/witness-blockchain-abstract'
|
|
4
|
-
import {
|
|
5
|
-
describe, expect,
|
|
6
|
-
it,
|
|
7
|
-
} from 'vitest'
|
|
8
|
-
|
|
9
|
-
import { getNftsOwnedByAddress } from '../getNftsOwnedByAddress.ts'
|
|
10
|
-
|
|
11
|
-
type TestData = [chainName: string, address: string, chainId: number]
|
|
12
|
-
|
|
13
|
-
describe.skipIf(!process.env.INFURA_PROJECT_ID)('getNftsOwnedByAddress', () => {
|
|
14
|
-
const testData: TestData[] = [
|
|
15
|
-
// ['Ethereum Mainnet', '0xacdaEEb57ff6886fC8e203B9Dd4C2b241DF89b7a', 1],
|
|
16
|
-
['Ethereum Mainnet', '0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D', 1],
|
|
17
|
-
// ['Polygon Mainnet', '0x5ABa56bF7eeB050796e14504c8547e0f6cA1d794', 137],
|
|
18
|
-
]
|
|
19
|
-
it.each(testData)('gets NFTs owned by the address on %s', async (_chainName, address, chainId) => {
|
|
20
|
-
const start = Date.now()
|
|
21
|
-
const provider = getProviderFromEnv(chainId)
|
|
22
|
-
const nfts = await getNftsOwnedByAddress(address, [provider], 10)
|
|
23
|
-
expect(nfts.length).toBeGreaterThan(0)
|
|
24
|
-
for (const nft of nfts) {
|
|
25
|
-
expect(nft.address).toBeString()
|
|
26
|
-
expect(nft.supply).toBeString()
|
|
27
|
-
if (nft?.metadata) {
|
|
28
|
-
expect(nft.metadata).toBeObject()
|
|
29
|
-
}
|
|
30
|
-
expect(nft.types).toBeArray()
|
|
31
|
-
}
|
|
32
|
-
console.log(`getNftsOwnedByAddressWithMeta Time: ${Date.now() - start}ms`)
|
|
33
|
-
})
|
|
34
|
-
})
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import '@xylabs/vitest-extended'
|
|
2
|
-
|
|
3
|
-
import { getProviderFromEnv } from '@xyo-network/witness-blockchain-abstract'
|
|
4
|
-
import {
|
|
5
|
-
describe, expect,
|
|
6
|
-
it,
|
|
7
|
-
} from 'vitest'
|
|
8
|
-
|
|
9
|
-
import { getNftsOwnedByAddressWithMetadata } from '../getNftsOwnedByAddress.ts'
|
|
10
|
-
|
|
11
|
-
type TestData = [chainName: string, address: string, chainId: number]
|
|
12
|
-
|
|
13
|
-
describe.skipIf(!process.env.INFURA_PROJECT_ID)('getNftsOwnedByAddressWithMeta', () => {
|
|
14
|
-
const testData: TestData[] = [
|
|
15
|
-
['Ethereum Mainnet', '0xacdaEEb57ff6886fC8e203B9Dd4C2b241DF89b7a', 1],
|
|
16
|
-
// ['Ethereum Mainnet', '0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D', 1],
|
|
17
|
-
// ['Polygon Mainnet', '0x5ABa56bF7eeB050796e14504c8547e0f6cA1d794', 137],
|
|
18
|
-
]
|
|
19
|
-
it.each(testData)('gets NFTs owned by the address on %s', async (_chainName, address, chainId) => {
|
|
20
|
-
const start = Date.now()
|
|
21
|
-
const provider = getProviderFromEnv(chainId)
|
|
22
|
-
const nfts = await getNftsOwnedByAddressWithMetadata(address, [provider], 200)
|
|
23
|
-
expect(nfts.length).toBeGreaterThan(0)
|
|
24
|
-
for (const nft of nfts) {
|
|
25
|
-
expect(nft.address).toBeString()
|
|
26
|
-
expect(nft.supply).toBeString()
|
|
27
|
-
if (nft?.metadata) {
|
|
28
|
-
expect(nft.metadata).toBeObject()
|
|
29
|
-
}
|
|
30
|
-
expect(nft.types).toBeArray()
|
|
31
|
-
}
|
|
32
|
-
console.log(`getNftsOwnedByAddressWithMeta [${nfts.length}] Time: ${Date.now() - start}ms`)
|
|
33
|
-
}, 20_000)
|
|
34
|
-
})
|
package/src/spec/Plugin.spec.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import '@xylabs/vitest-extended'
|
|
2
|
-
|
|
3
|
-
import { PayloadSetPluginResolver } from '@xyo-network/payloadset-plugin'
|
|
4
|
-
import {
|
|
5
|
-
describe, expect,
|
|
6
|
-
test,
|
|
7
|
-
} from 'vitest'
|
|
8
|
-
|
|
9
|
-
import { CryptoWalletNftWitnessPlugin } from '../Plugin.ts'
|
|
10
|
-
|
|
11
|
-
describe('CryptoWalletNftWitnessPlugin', () => {
|
|
12
|
-
test('Add to Resolver', async () => {
|
|
13
|
-
const plugin = CryptoWalletNftWitnessPlugin()
|
|
14
|
-
const resolver = await new PayloadSetPluginResolver().register(plugin)
|
|
15
|
-
expect(resolver.resolve(plugin.set)).toBeDefined()
|
|
16
|
-
})
|
|
17
|
-
})
|
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
import '@xylabs/vitest-extended'
|
|
2
|
-
|
|
3
|
-
import { distinct } from '@xylabs/array'
|
|
4
|
-
import { assertEx } from '@xylabs/assert'
|
|
5
|
-
import { delay } from '@xylabs/delay'
|
|
6
|
-
import { exists } from '@xylabs/exists'
|
|
7
|
-
import type { Address } from '@xylabs/hex'
|
|
8
|
-
import { MemoryArchivist } from '@xyo-network/archivist-memory'
|
|
9
|
-
import { asArchivistInstance } from '@xyo-network/archivist-model'
|
|
10
|
-
import { BoundWitnessBuilder } from '@xyo-network/boundwitness-builder'
|
|
11
|
-
import type { BoundWitness } from '@xyo-network/boundwitness-model'
|
|
12
|
-
import { isBoundWitness } from '@xyo-network/boundwitness-model'
|
|
13
|
-
import type { NftInfo } from '@xyo-network/crypto-nft-payload-plugin'
|
|
14
|
-
import { NftSchema } from '@xyo-network/crypto-nft-payload-plugin'
|
|
15
|
-
import { MemoryBoundWitnessDiviner } from '@xyo-network/diviner-boundwitness-memory'
|
|
16
|
-
import { asDivinerInstance } from '@xyo-network/diviner-model'
|
|
17
|
-
import { GenericPayloadDiviner } from '@xyo-network/diviner-payload-generic'
|
|
18
|
-
import type { PayloadDivinerQueryPayload } from '@xyo-network/diviner-payload-model'
|
|
19
|
-
import { PayloadDivinerQuerySchema } from '@xyo-network/diviner-payload-model'
|
|
20
|
-
import type { TemporalIndexingDivinerResultIndex } from '@xyo-network/diviner-temporal-indexing'
|
|
21
|
-
import {
|
|
22
|
-
isTemporalIndexingDivinerResultIndex,
|
|
23
|
-
TemporalIndexingDiviner,
|
|
24
|
-
TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner,
|
|
25
|
-
TemporalIndexingDivinerIndexCandidateToIndexDiviner,
|
|
26
|
-
TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner,
|
|
27
|
-
TemporalIndexingDivinerStateToIndexCandidateDiviner,
|
|
28
|
-
} from '@xyo-network/diviner-temporal-indexing'
|
|
29
|
-
import type { PackageManifestPayload } from '@xyo-network/manifest'
|
|
30
|
-
import { ManifestWrapper } from '@xyo-network/manifest'
|
|
31
|
-
import { ModuleFactoryLocator } from '@xyo-network/module-factory-locator'
|
|
32
|
-
import type { Labels, ModuleState } from '@xyo-network/module-model'
|
|
33
|
-
import { isModuleState } from '@xyo-network/module-model'
|
|
34
|
-
import type { MemoryNode } from '@xyo-network/node-memory'
|
|
35
|
-
import { PayloadBuilder } from '@xyo-network/payload-builder'
|
|
36
|
-
import type { WithStorageMeta } from '@xyo-network/payload-model'
|
|
37
|
-
import { HDWallet } from '@xyo-network/wallet'
|
|
38
|
-
import {
|
|
39
|
-
beforeAll,
|
|
40
|
-
describe, expect, it,
|
|
41
|
-
} from 'vitest'
|
|
42
|
-
|
|
43
|
-
import imageThumbnailDivinerManifest from './Witness.Index.json' with { type: 'json' }
|
|
44
|
-
|
|
45
|
-
type Query = PayloadDivinerQueryPayload & { address: string; chainId?: number }
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* @group slow
|
|
49
|
-
*/
|
|
50
|
-
describe.skip('CryptoWalletNftWitness Index', () => {
|
|
51
|
-
let node: MemoryNode
|
|
52
|
-
let sut: TemporalIndexingDiviner
|
|
53
|
-
const data: NftInfo[] = [
|
|
54
|
-
// 0x0000000000000000000000000000000000000000
|
|
55
|
-
{
|
|
56
|
-
address: '0x0000000000000000000000000000000000000000',
|
|
57
|
-
chainId: 1,
|
|
58
|
-
schema: NftSchema,
|
|
59
|
-
supply: '1',
|
|
60
|
-
tokenId: '0',
|
|
61
|
-
type: 'ERC721',
|
|
62
|
-
types: ['ERC721'],
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
address: '0x0000000000000000000000000000000000000000',
|
|
66
|
-
chainId: 1,
|
|
67
|
-
schema: NftSchema,
|
|
68
|
-
supply: '1',
|
|
69
|
-
tokenId: '1',
|
|
70
|
-
type: 'ERC721',
|
|
71
|
-
types: ['ERC721'],
|
|
72
|
-
},
|
|
73
|
-
// 0x0000000000000000000000000000000000000001
|
|
74
|
-
// chainId: 2
|
|
75
|
-
{
|
|
76
|
-
address: '0x0000000000000000000000000000000000000001',
|
|
77
|
-
chainId: 2,
|
|
78
|
-
schema: NftSchema,
|
|
79
|
-
supply: '1',
|
|
80
|
-
tokenId: '0',
|
|
81
|
-
type: 'ERC721',
|
|
82
|
-
types: ['ERC721'],
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
address: '0x0000000000000000000000000000000000000001',
|
|
86
|
-
chainId: 2,
|
|
87
|
-
schema: NftSchema,
|
|
88
|
-
supply: '1',
|
|
89
|
-
tokenId: '1',
|
|
90
|
-
type: 'ERC721',
|
|
91
|
-
types: ['ERC721'],
|
|
92
|
-
},
|
|
93
|
-
// 0x0000000000000000000000000000000000000002
|
|
94
|
-
// ERC1155
|
|
95
|
-
{
|
|
96
|
-
address: '0x0000000000000000000000000000000000000002',
|
|
97
|
-
chainId: 1,
|
|
98
|
-
schema: NftSchema,
|
|
99
|
-
supply: '1',
|
|
100
|
-
tokenId: '0',
|
|
101
|
-
type: 'ERC1155',
|
|
102
|
-
types: ['ERC1155'],
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
address: '0x0000000000000000000000000000000000000002',
|
|
106
|
-
chainId: 1,
|
|
107
|
-
schema: NftSchema,
|
|
108
|
-
supply: '1',
|
|
109
|
-
tokenId: '1',
|
|
110
|
-
type: 'ERC1155',
|
|
111
|
-
types: ['ERC1155'],
|
|
112
|
-
},
|
|
113
|
-
// 0x0000000000000000000000000000000000000003
|
|
114
|
-
// Duplicate observations
|
|
115
|
-
{
|
|
116
|
-
address: '0x0000000000000000000000000000000000000003',
|
|
117
|
-
chainId: 1,
|
|
118
|
-
metadata: { foo: 'bar' },
|
|
119
|
-
schema: NftSchema,
|
|
120
|
-
supply: '1',
|
|
121
|
-
tokenId: '0',
|
|
122
|
-
type: 'ERC721',
|
|
123
|
-
types: ['ERC721'],
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
address: '0x0000000000000000000000000000000000000003',
|
|
127
|
-
chainId: 1,
|
|
128
|
-
metadata: { baz: 'qix' },
|
|
129
|
-
schema: NftSchema,
|
|
130
|
-
supply: '1',
|
|
131
|
-
tokenId: '0',
|
|
132
|
-
type: 'ERC721',
|
|
133
|
-
types: ['ERC721'],
|
|
134
|
-
},
|
|
135
|
-
]
|
|
136
|
-
beforeAll(async () => {
|
|
137
|
-
const labels: Labels = { 'network.xyo.crypto.nft': 'diviner' }
|
|
138
|
-
const wallet = await HDWallet.random()
|
|
139
|
-
const locator = new ModuleFactoryLocator()
|
|
140
|
-
locator.register(MemoryArchivist.factory())
|
|
141
|
-
locator.register(MemoryBoundWitnessDiviner.factory())
|
|
142
|
-
locator.register(GenericPayloadDiviner.factory())
|
|
143
|
-
locator.register(TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner.factory(), labels)
|
|
144
|
-
locator.register(TemporalIndexingDivinerIndexCandidateToIndexDiviner.factory(), labels)
|
|
145
|
-
locator.register(TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner.factory(), labels)
|
|
146
|
-
locator.register(TemporalIndexingDivinerStateToIndexCandidateDiviner.factory(), labels)
|
|
147
|
-
locator.register(TemporalIndexingDiviner.factory(), labels)
|
|
148
|
-
const manifest = imageThumbnailDivinerManifest as PackageManifestPayload
|
|
149
|
-
const manifestWrapper = new ManifestWrapper(manifest, wallet, locator)
|
|
150
|
-
node = await manifestWrapper.loadNodeFromIndex(0)
|
|
151
|
-
await node.start()
|
|
152
|
-
|
|
153
|
-
const privateModules = manifest.nodes[0].modules?.private ?? []
|
|
154
|
-
const publicModules = manifest.nodes[0].modules?.public ?? []
|
|
155
|
-
const mods = await node.resolve('*')
|
|
156
|
-
expect(mods.length).toBe(privateModules.length + publicModules.length)
|
|
157
|
-
|
|
158
|
-
// Insert NFTS into archivist
|
|
159
|
-
const payloads = (
|
|
160
|
-
await Promise.all(
|
|
161
|
-
data.map(async (nft) => {
|
|
162
|
-
const timestamp = { schema: 'network.xyo.timestamp', timestamp: Date.now() }
|
|
163
|
-
const [bw, payloads] = await new BoundWitnessBuilder().payloads([nft, timestamp]).build()
|
|
164
|
-
return [bw, ...payloads]
|
|
165
|
-
}),
|
|
166
|
-
)
|
|
167
|
-
).flat()
|
|
168
|
-
|
|
169
|
-
const NftArchivist = assertEx(asArchivistInstance<MemoryArchivist>(await node.resolve('NftArchivist')))
|
|
170
|
-
await NftArchivist.insert(payloads)
|
|
171
|
-
|
|
172
|
-
sut = assertEx(asDivinerInstance<TemporalIndexingDiviner>(await node.resolve('NftDiviner')))
|
|
173
|
-
|
|
174
|
-
// Allow enough time for diviner to divine
|
|
175
|
-
await delay(5000)
|
|
176
|
-
}, 40_000)
|
|
177
|
-
describe('diviner state', () => {
|
|
178
|
-
let stateArchivist: MemoryArchivist
|
|
179
|
-
beforeAll(async () => {
|
|
180
|
-
const mod = await node.resolve('AddressStateArchivist')
|
|
181
|
-
stateArchivist = assertEx(asArchivistInstance<MemoryArchivist>(mod))
|
|
182
|
-
})
|
|
183
|
-
it('has expected bound witnesses', async () => {
|
|
184
|
-
const payloads = await stateArchivist.all()
|
|
185
|
-
const stateBoundWitnesses = payloads.filter(isBoundWitness) as WithStorageMeta<BoundWitness>[]
|
|
186
|
-
expect(stateBoundWitnesses).toBeArrayOfSize(2)
|
|
187
|
-
for (const stateBoundWitness of stateBoundWitnesses) {
|
|
188
|
-
expect(stateBoundWitness).toBeObject()
|
|
189
|
-
expect(stateBoundWitness.addresses).toBeArrayOfSize(1)
|
|
190
|
-
expect(stateBoundWitness.addresses).toContain(sut.address)
|
|
191
|
-
}
|
|
192
|
-
})
|
|
193
|
-
it('has expected state', async () => {
|
|
194
|
-
const payloads = await stateArchivist.all()
|
|
195
|
-
const statePayloads = payloads.filter(isModuleState) as WithStorageMeta<ModuleState>[]
|
|
196
|
-
expect(statePayloads).toBeArrayOfSize(2)
|
|
197
|
-
expect(statePayloads.at(-1)).toBeObject()
|
|
198
|
-
const statePayload = assertEx(statePayloads.at(-1))
|
|
199
|
-
expect(statePayload.state).toBeObject()
|
|
200
|
-
expect(statePayload.state?.offset).toBe(data.length)
|
|
201
|
-
})
|
|
202
|
-
})
|
|
203
|
-
describe('diviner index', () => {
|
|
204
|
-
let indexArchivist: MemoryArchivist
|
|
205
|
-
beforeAll(async () => {
|
|
206
|
-
const mod = await node.resolve('NftDivinerIndexArchivist')
|
|
207
|
-
indexArchivist = assertEx(asArchivistInstance<MemoryArchivist>(mod))
|
|
208
|
-
})
|
|
209
|
-
it('has expected index', async () => {
|
|
210
|
-
const payloads = await indexArchivist.all()
|
|
211
|
-
const indexPayloads = payloads.filter(isTemporalIndexingDivinerResultIndex)
|
|
212
|
-
expect(indexPayloads).toBeArrayOfSize(data.length)
|
|
213
|
-
})
|
|
214
|
-
})
|
|
215
|
-
describe('with no Nft for the provided Address', () => {
|
|
216
|
-
const address = '0x9000000000000000000000000000000000000000' as Address
|
|
217
|
-
const schema = PayloadDivinerQuerySchema
|
|
218
|
-
it('returns nothing', async () => {
|
|
219
|
-
const query: Query = { address, schema }
|
|
220
|
-
const result = await sut.divine([query])
|
|
221
|
-
expect(result).toBeArrayOfSize(0)
|
|
222
|
-
})
|
|
223
|
-
})
|
|
224
|
-
describe('with Nfts for the provided Address', () => {
|
|
225
|
-
const schema = PayloadDivinerQuerySchema
|
|
226
|
-
describe('with filter criteria', () => {
|
|
227
|
-
describe('for address', () => {
|
|
228
|
-
const addresses = data
|
|
229
|
-
.filter(nft => nft.chainId === 1)
|
|
230
|
-
.map(nft => nft.address)
|
|
231
|
-
.filter(distinct)
|
|
232
|
-
const cases: NftInfo[] = addresses.map(address => data.findLast(nft => nft.address === address)).filter(exists)
|
|
233
|
-
it.each(cases)('returns the most recent instance of that address using the default chainId', async (payload) => {
|
|
234
|
-
const { address } = payload
|
|
235
|
-
const query = { address, schema } as Query
|
|
236
|
-
const results = (await sut.divine([query])) as WithStorageMeta<TemporalIndexingDivinerResultIndex>[]
|
|
237
|
-
const result = results.find(isTemporalIndexingDivinerResultIndex)
|
|
238
|
-
await verifyIsExpectedNft(result, payload)
|
|
239
|
-
})
|
|
240
|
-
})
|
|
241
|
-
describe('for address & chainId', () => {
|
|
242
|
-
const addresses = data.map(nft => nft.address).filter(distinct)
|
|
243
|
-
const cases: NftInfo[] = addresses.map(address => data.findLast(nft => nft.address === address)).filter(exists)
|
|
244
|
-
it.each(cases)('returns the most recent instance of that address & chainId', async (payload) => {
|
|
245
|
-
const { address, chainId } = payload
|
|
246
|
-
const query = {
|
|
247
|
-
address, chainId, schema,
|
|
248
|
-
} as Query
|
|
249
|
-
const results = (await sut.divine([query])) as WithStorageMeta<TemporalIndexingDivinerResultIndex>[]
|
|
250
|
-
const result = results.find(isTemporalIndexingDivinerResultIndex)
|
|
251
|
-
await verifyIsExpectedNft(result, payload)
|
|
252
|
-
})
|
|
253
|
-
})
|
|
254
|
-
})
|
|
255
|
-
})
|
|
256
|
-
const verifyIsExpectedNft = async (result: TemporalIndexingDivinerResultIndex | undefined, payload: NftInfo | undefined) => {
|
|
257
|
-
expect(result).toBeDefined()
|
|
258
|
-
expect(payload).toBeDefined()
|
|
259
|
-
const expected = await PayloadBuilder.dataHash(assertEx(payload))
|
|
260
|
-
expect(result?.$sources).toContain(expected)
|
|
261
|
-
}
|
|
262
|
-
})
|