@xyo-network/evm-call-witness 5.1.2 → 5.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +44 -41
- package/dist/neutral/spec/Sentinel.collection.spec.d.ts +0 -2
- package/dist/neutral/spec/Sentinel.collection.spec.d.ts.map +0 -1
- package/dist/neutral/spec/Sentinel.token.enumerate.spec.d.ts +0 -2
- package/dist/neutral/spec/Sentinel.token.enumerate.spec.d.ts.map +0 -1
- package/dist/neutral/spec/Sentinel.token.spec.d.ts +0 -2
- package/dist/neutral/spec/Sentinel.token.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/neutral/spec/imported/AddressToContract/AddressToContractIndex/Contract.Sentinel.Node.spec.d.ts +0 -2
- package/dist/neutral/spec/imported/AddressToContract/AddressToContractIndex/Contract.Sentinel.Node.spec.d.ts.map +0 -1
- package/dist/neutral/spec/imported/AddressToContract/CollectionInfo/Sentinel.collection.spec.d.ts +0 -2
- package/dist/neutral/spec/imported/AddressToContract/CollectionInfo/Sentinel.collection.spec.d.ts.map +0 -1
- package/dist/neutral/spec/imported/AddressToContract/ManualTokenIteration/Sentinel.token.spec.d.ts +0 -2
- package/dist/neutral/spec/imported/AddressToContract/ManualTokenIteration/Sentinel.token.spec.d.ts.map +0 -1
- package/dist/neutral/spec/imported/AddressToTotalSupplyIndex/Erc721.TotalSupply.Index.spec.d.ts +0 -2
- package/dist/neutral/spec/imported/AddressToTotalSupplyIndex/Erc721.TotalSupply.Index.spec.d.ts.map +0 -1
- package/dist/neutral/spec/imported/NftIndexToNftIdIndex/Erc721.NftId.Index.spec.d.ts +0 -2
- package/dist/neutral/spec/imported/NftIndexToNftIdIndex/Erc721.NftId.Index.spec.d.ts.map +0 -1
- package/dist/neutral/spec/imported/TotalSupplyToNftIndexIndex/Erc721.NftIndex.Index.spec.d.ts +0 -2
- package/dist/neutral/spec/imported/TotalSupplyToNftIndexIndex/Erc721.NftIndex.Index.spec.d.ts.map +0 -1
- package/src/spec/Sentinel.collection.spec.ts +0 -127
- package/src/spec/Sentinel.token.enumerate.spec.ts +0 -138
- package/src/spec/Sentinel.token.spec.ts +0 -131
- package/src/spec/Witness.spec.ts +0 -43
- package/src/spec/imported/AddressToContract/AddressToContractIndex/Contract.Sentinel.Node.spec.ts +0 -183
- package/src/spec/imported/AddressToContract/CollectionInfo/Sentinel.collection.spec.ts +0 -143
- package/src/spec/imported/AddressToContract/ManualTokenIteration/Sentinel.token.spec.ts +0 -187
- package/src/spec/imported/AddressToTotalSupplyIndex/Erc721.TotalSupply.Index.spec.ts +0 -101
- package/src/spec/imported/NftIndexToNftIdIndex/Erc721.NftId.Index.spec.ts +0 -118
- package/src/spec/imported/TotalSupplyToNftIndexIndex/Erc721.NftIndex.Index.spec.ts +0 -124
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import '@xylabs/vitest-extended'
|
|
2
|
-
|
|
3
|
-
import { delay } from '@xylabs/delay'
|
|
4
|
-
import { MemoryBoundWitnessDiviner } from '@xyo-network/diviner-boundwitness-memory'
|
|
5
|
-
import { JsonPatchDiviner } from '@xyo-network/diviner-jsonpatch'
|
|
6
|
-
import { JsonPathAggregateDiviner } from '@xyo-network/diviner-jsonpath-aggregate-memory'
|
|
7
|
-
import { asDivinerInstance } from '@xyo-network/diviner-model'
|
|
8
|
-
import { GenericPayloadDiviner } from '@xyo-network/diviner-payload-generic'
|
|
9
|
-
import { PayloadDivinerQuerySchema } from '@xyo-network/diviner-payload-model'
|
|
10
|
-
import { RangeDiviner } from '@xyo-network/diviner-range'
|
|
11
|
-
import {
|
|
12
|
-
TemporalIndexingDiviner,
|
|
13
|
-
TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner,
|
|
14
|
-
TemporalIndexingDivinerIndexCandidateToIndexDiviner,
|
|
15
|
-
TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner,
|
|
16
|
-
TemporalIndexingDivinerStateToIndexCandidateDiviner,
|
|
17
|
-
} from '@xyo-network/diviner-temporal-indexing'
|
|
18
|
-
import { isNftId } from '@xyo-network/evm-nft-id-payload-plugin'
|
|
19
|
-
import type { PackageManifestPayload } from '@xyo-network/manifest'
|
|
20
|
-
import { ManifestWrapper } from '@xyo-network/manifest'
|
|
21
|
-
import { ModuleFactoryLocator } from '@xyo-network/module-factory-locator'
|
|
22
|
-
import { ModuleFactory } from '@xyo-network/module-model'
|
|
23
|
-
import type { MemoryNode } from '@xyo-network/node-memory'
|
|
24
|
-
import { ERC721Enumerable__factory } from '@xyo-network/open-zeppelin-typechain'
|
|
25
|
-
import { asSentinelInstance } from '@xyo-network/sentinel-model'
|
|
26
|
-
import { HDWallet } from '@xyo-network/wallet'
|
|
27
|
-
import type { WalletInstance } from '@xyo-network/wallet-model'
|
|
28
|
-
import { getProvidersFromEnv } from '@xyo-network/witness-evm-abstract'
|
|
29
|
-
import { TimestampWitness } from '@xyo-network/witness-timestamp'
|
|
30
|
-
import {
|
|
31
|
-
beforeAll, describe, expect,
|
|
32
|
-
it,
|
|
33
|
-
} from 'vitest'
|
|
34
|
-
|
|
35
|
-
import { EvmCallDiviner } from '../../../Diviner.ts'
|
|
36
|
-
import type { EvmCallWitnessParams } from '../../../model.ts'
|
|
37
|
-
import { EvmCallSchema } from '../../../Payload.ts'
|
|
38
|
-
import { EvmCallWitness } from '../../../Witness.ts'
|
|
39
|
-
import nodeManifest from './Erc721.NftId.Index.json' with { type: 'json' }
|
|
40
|
-
|
|
41
|
-
describe.skipIf(!process.env.INFURA_PROJECT_ID).skip('Erc721.NftId.Index', () => {
|
|
42
|
-
let wallet: WalletInstance
|
|
43
|
-
let node: MemoryNode
|
|
44
|
-
|
|
45
|
-
beforeAll(async () => {
|
|
46
|
-
const mnemonic = 'later puppy sound rebuild rebuild noise ozone amazing hope broccoli crystal grief'
|
|
47
|
-
wallet = await HDWallet.fromPhrase(mnemonic)
|
|
48
|
-
const locator = new ModuleFactoryLocator()
|
|
49
|
-
locator.register(MemoryBoundWitnessDiviner.factory())
|
|
50
|
-
locator.register(GenericPayloadDiviner.factory())
|
|
51
|
-
locator.register(TimestampWitness.factory())
|
|
52
|
-
locator.register(EvmCallDiviner.factory())
|
|
53
|
-
locator.register(TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner.factory())
|
|
54
|
-
locator.register(TemporalIndexingDivinerIndexCandidateToIndexDiviner.factory())
|
|
55
|
-
locator.register(TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner.factory())
|
|
56
|
-
locator.register(TemporalIndexingDivinerStateToIndexCandidateDiviner.factory())
|
|
57
|
-
locator.register(TemporalIndexingDiviner.factory())
|
|
58
|
-
locator.register(JsonPatchDiviner.factory())
|
|
59
|
-
locator.register(JsonPathAggregateDiviner.factory())
|
|
60
|
-
locator.register(RangeDiviner.factory())
|
|
61
|
-
|
|
62
|
-
locator.register(
|
|
63
|
-
new ModuleFactory(EvmCallWitness, {
|
|
64
|
-
config: { abi: ERC721Enumerable__factory.abi },
|
|
65
|
-
providers: getProvidersFromEnv,
|
|
66
|
-
} as EvmCallWitnessParams),
|
|
67
|
-
{ 'network.xyo.evm.interface': 'Erc721Enumerable' },
|
|
68
|
-
)
|
|
69
|
-
const manifest = new ManifestWrapper(nodeManifest as PackageManifestPayload, wallet, locator)
|
|
70
|
-
node = await manifest.loadNodeFromIndex(0)
|
|
71
|
-
})
|
|
72
|
-
type TestData = readonly [string]
|
|
73
|
-
const cases: readonly TestData[] = [
|
|
74
|
-
['0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D'], // BAYC
|
|
75
|
-
] as const
|
|
76
|
-
describe.skipIf(!process.env.INFURA_PROJECT_ID)('Sentinel', () => {
|
|
77
|
-
const tokensToCheck = 16
|
|
78
|
-
const tokenIds = Array.from({ length: tokensToCheck }).map((_, tokenIndex) => tokenIndex)
|
|
79
|
-
const tokenIndexes = tokenIds.map(tokenId => tokenId)
|
|
80
|
-
const chainId = 1
|
|
81
|
-
const functionName = 'tokenByIndex'
|
|
82
|
-
describe('Sentinel', () => {
|
|
83
|
-
it.each(cases)('returns NftIndexes', async (address) => {
|
|
84
|
-
const sentinel = asSentinelInstance(await node.resolve('Sentinel'))
|
|
85
|
-
for (const tokenIndex of tokenIndexes) {
|
|
86
|
-
const inputs = [{
|
|
87
|
-
address, args: [`0x${BigInt(tokenIndex).toString(16)}`], chainId, functionName, schema: EvmCallSchema,
|
|
88
|
-
}]
|
|
89
|
-
const observations = await sentinel?.report(inputs)
|
|
90
|
-
const nftIds = observations?.filter(isNftId)
|
|
91
|
-
expect(nftIds?.length).toBe(1)
|
|
92
|
-
for (const nftId of nftIds ?? []) {
|
|
93
|
-
expect(nftId.address).toBe(address)
|
|
94
|
-
expect(nftId.chainId).toBe(chainId)
|
|
95
|
-
expect(nftId.tokenId).toBeString()
|
|
96
|
-
expect(tokenIds).toContain(Number(BigInt(nftId.tokenId)))
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
})
|
|
100
|
-
})
|
|
101
|
-
describe('Index', () => {
|
|
102
|
-
it.each(cases)('returns indexed NftIndex results', async (address) => {
|
|
103
|
-
await delay(100)
|
|
104
|
-
const diviner = asDivinerInstance(await node.resolve('IndexDiviner'))
|
|
105
|
-
expect(diviner).toBeDefined()
|
|
106
|
-
for (const tokenIndex of tokenIndexes) {
|
|
107
|
-
const tokenId = `0x${BigInt(tokenIndex).toString(16)}`
|
|
108
|
-
const query = {
|
|
109
|
-
address, chainId, length: 1, schema: PayloadDivinerQuerySchema, tokenId,
|
|
110
|
-
}
|
|
111
|
-
const result = await diviner?.divine([query])
|
|
112
|
-
expect(result).toBeDefined()
|
|
113
|
-
expect(result).toBeArrayOfSize(1)
|
|
114
|
-
}
|
|
115
|
-
})
|
|
116
|
-
})
|
|
117
|
-
})
|
|
118
|
-
})
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import '@xylabs/vitest-extended'
|
|
2
|
-
|
|
3
|
-
import { MemoryBoundWitnessDiviner } from '@xyo-network/diviner-boundwitness-memory'
|
|
4
|
-
import { JsonPatchDiviner } from '@xyo-network/diviner-jsonpatch'
|
|
5
|
-
import { JsonPathAggregateDiviner } from '@xyo-network/diviner-jsonpath-aggregate-memory'
|
|
6
|
-
import { asDivinerInstance } from '@xyo-network/diviner-model'
|
|
7
|
-
import { GenericPayloadDiviner } from '@xyo-network/diviner-payload-generic'
|
|
8
|
-
import { PayloadDivinerQuerySchema } from '@xyo-network/diviner-payload-model'
|
|
9
|
-
import { RangeDiviner } from '@xyo-network/diviner-range'
|
|
10
|
-
import {
|
|
11
|
-
TemporalIndexingDiviner,
|
|
12
|
-
TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner,
|
|
13
|
-
TemporalIndexingDivinerIndexCandidateToIndexDiviner,
|
|
14
|
-
TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner,
|
|
15
|
-
TemporalIndexingDivinerStateToIndexCandidateDiviner,
|
|
16
|
-
} from '@xyo-network/diviner-temporal-indexing'
|
|
17
|
-
import { isNftIndex } from '@xyo-network/evm-nft-id-payload-plugin'
|
|
18
|
-
import type { PackageManifestPayload } from '@xyo-network/manifest'
|
|
19
|
-
import { ManifestWrapper } from '@xyo-network/manifest'
|
|
20
|
-
import { ModuleFactoryLocator } from '@xyo-network/module-factory-locator'
|
|
21
|
-
import { ModuleFactory } from '@xyo-network/module-model'
|
|
22
|
-
import type { MemoryNode } from '@xyo-network/node-memory'
|
|
23
|
-
import { ERC721Enumerable__factory } from '@xyo-network/open-zeppelin-typechain'
|
|
24
|
-
import { asSentinelInstance } from '@xyo-network/sentinel-model'
|
|
25
|
-
import { HDWallet } from '@xyo-network/wallet'
|
|
26
|
-
import type { WalletInstance } from '@xyo-network/wallet-model'
|
|
27
|
-
import { getProvidersFromEnv } from '@xyo-network/witness-evm-abstract'
|
|
28
|
-
import { TimestampWitness } from '@xyo-network/witness-timestamp'
|
|
29
|
-
import {
|
|
30
|
-
beforeAll, describe, expect,
|
|
31
|
-
it,
|
|
32
|
-
} from 'vitest'
|
|
33
|
-
|
|
34
|
-
import { EvmCallDiviner } from '../../../Diviner.ts'
|
|
35
|
-
import type { EvmCallWitnessParams } from '../../../model.ts'
|
|
36
|
-
import type { EvmCallResult } from '../../../Payload.ts'
|
|
37
|
-
import { EvmCallWitness } from '../../../Witness.ts'
|
|
38
|
-
import nodeManifest from './Erc721.NftIndex.Index.json' with { type: 'json' }
|
|
39
|
-
|
|
40
|
-
describe.runIf(process.env.INFURA_PROJECT_ID).skip('Erc721.NftIndex.Index', () => {
|
|
41
|
-
let wallet: WalletInstance
|
|
42
|
-
let node: MemoryNode
|
|
43
|
-
|
|
44
|
-
beforeAll(async () => {
|
|
45
|
-
const mnemonic = 'later puppy sound rebuild rebuild noise ozone amazing hope broccoli crystal grief'
|
|
46
|
-
wallet = await HDWallet.fromPhrase(mnemonic)
|
|
47
|
-
const locator = new ModuleFactoryLocator()
|
|
48
|
-
locator.register(MemoryBoundWitnessDiviner.factory())
|
|
49
|
-
locator.register(GenericPayloadDiviner.factory())
|
|
50
|
-
locator.register(TimestampWitness.factory())
|
|
51
|
-
locator.register(EvmCallDiviner.factory())
|
|
52
|
-
locator.register(TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner.factory())
|
|
53
|
-
locator.register(TemporalIndexingDivinerIndexCandidateToIndexDiviner.factory())
|
|
54
|
-
locator.register(TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner.factory())
|
|
55
|
-
locator.register(TemporalIndexingDivinerStateToIndexCandidateDiviner.factory())
|
|
56
|
-
locator.register(TemporalIndexingDiviner.factory())
|
|
57
|
-
locator.register(JsonPatchDiviner.factory())
|
|
58
|
-
locator.register(JsonPathAggregateDiviner.factory())
|
|
59
|
-
locator.register(RangeDiviner.factory())
|
|
60
|
-
|
|
61
|
-
locator.register(
|
|
62
|
-
new ModuleFactory(EvmCallWitness, {
|
|
63
|
-
config: { abi: ERC721Enumerable__factory.abi },
|
|
64
|
-
providers: getProvidersFromEnv,
|
|
65
|
-
} as EvmCallWitnessParams),
|
|
66
|
-
{ 'network.xyo.evm.interface': 'Erc721Enumerable' },
|
|
67
|
-
)
|
|
68
|
-
const manifest = new ManifestWrapper(nodeManifest as PackageManifestPayload, wallet, locator)
|
|
69
|
-
node = await manifest.loadNodeFromIndex(0)
|
|
70
|
-
})
|
|
71
|
-
type TestData = readonly [string]
|
|
72
|
-
const cases: readonly TestData[] = [
|
|
73
|
-
['0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D'], // BAYC
|
|
74
|
-
] as const
|
|
75
|
-
describe('Sentinel', () => {
|
|
76
|
-
const totalSupply = 100
|
|
77
|
-
describe('Sentinel', () => {
|
|
78
|
-
it.each(cases)('returns NftIndexes', async (address) => {
|
|
79
|
-
const sentinel = asSentinelInstance(await node.resolve('Sentinel'))
|
|
80
|
-
const chainId = 1
|
|
81
|
-
const input: EvmCallResult = {
|
|
82
|
-
address,
|
|
83
|
-
args: [],
|
|
84
|
-
chainId,
|
|
85
|
-
functionName: 'totalSupply',
|
|
86
|
-
result: `${totalSupply}`,
|
|
87
|
-
schema: 'network.xyo.evm.call.result',
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const observations = (await sentinel?.report([input])) ?? []
|
|
91
|
-
const nftIndexes = observations?.filter(isNftIndex)
|
|
92
|
-
expect(nftIndexes?.length).toBe(totalSupply)
|
|
93
|
-
for (const nftIndex of nftIndexes ?? []) {
|
|
94
|
-
expect(nftIndex.address).toBe(address)
|
|
95
|
-
expect(nftIndex.chainId).toBe(chainId)
|
|
96
|
-
expect(nftIndex.index).toBeNumber()
|
|
97
|
-
}
|
|
98
|
-
})
|
|
99
|
-
})
|
|
100
|
-
describe('Index', () => {
|
|
101
|
-
beforeAll(async () => {
|
|
102
|
-
const delay = (ms: number) => {
|
|
103
|
-
return new Promise(resolve => setTimeout(resolve, ms))
|
|
104
|
-
}
|
|
105
|
-
// Delay enough time for the diviners to index the results
|
|
106
|
-
await delay(4000)
|
|
107
|
-
})
|
|
108
|
-
it.each(cases)('returns indexed NftIndex results', async (address) => {
|
|
109
|
-
const diviner = asDivinerInstance(await node.resolve('IndexDiviner'))
|
|
110
|
-
expect(diviner).toBeDefined()
|
|
111
|
-
// Check we've indexed the results by sampling the first and last index
|
|
112
|
-
const sampleIndexes = [0, totalSupply - 1]
|
|
113
|
-
for (const index of sampleIndexes) {
|
|
114
|
-
const query = {
|
|
115
|
-
address, chainId: 1, index, schema: PayloadDivinerQuerySchema,
|
|
116
|
-
}
|
|
117
|
-
const result = await diviner?.divine([query])
|
|
118
|
-
expect(result).toBeDefined()
|
|
119
|
-
expect(result).toBeArrayOfSize(1)
|
|
120
|
-
}
|
|
121
|
-
})
|
|
122
|
-
})
|
|
123
|
-
})
|
|
124
|
-
})
|