@xyo-network/evm-token-interface-diviner 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/package.json +36 -33
- package/dist/neutral/spec/Diviner.spec.d.ts +0 -2
- package/dist/neutral/spec/Diviner.spec.d.ts.map +0 -1
- package/dist/neutral/spec/TokenNode.spec.d.ts +0 -2
- package/dist/neutral/spec/TokenNode.spec.d.ts.map +0 -1
- package/src/spec/Diviner.spec.ts +0 -64
- package/src/spec/TokenNode.spec.ts +0 -152
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/evm-token-interface-diviner",
|
|
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,43 +30,46 @@
|
|
|
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
|
-
"@xyo-network/diviner-abstract": "~5.1.
|
|
38
|
-
"@xyo-network/diviner-model": "~5.1.
|
|
39
|
-
"@xyo-network/evm-contract-witness": "~5.1.
|
|
40
|
-
"@xyo-network/module-model": "~5.1.
|
|
41
|
-
"@xyo-network/open-zeppelin-typechain": "~4.0.
|
|
42
|
-
"@xyo-network/payload-model": "~5.1.
|
|
39
|
+
"@xylabs/assert": "~5.0.37",
|
|
40
|
+
"@xyo-network/diviner-abstract": "~5.1.23",
|
|
41
|
+
"@xyo-network/diviner-model": "~5.1.23",
|
|
42
|
+
"@xyo-network/evm-contract-witness": "~5.1.5",
|
|
43
|
+
"@xyo-network/module-model": "~5.1.23",
|
|
44
|
+
"@xyo-network/open-zeppelin-typechain": "~4.0.10",
|
|
45
|
+
"@xyo-network/payload-model": "~5.1.23",
|
|
43
46
|
"ethers": "~6.15.0"
|
|
44
47
|
},
|
|
45
48
|
"devDependencies": {
|
|
46
|
-
"@xylabs/delay": "~5.0.
|
|
47
|
-
"@xylabs/ts-scripts-yarn3": "~7.
|
|
48
|
-
"@xylabs/tsconfig": "~7.
|
|
49
|
-
"@xylabs/vitest-extended": "~5.0.
|
|
50
|
-
"@xyo-network/archivist-memory": "~5.1.
|
|
51
|
-
"@xyo-network/boundwitness-model": "~5.1.
|
|
52
|
-
"@xyo-network/diviner-boundwitness-memory": "~5.1.
|
|
53
|
-
"@xyo-network/diviner-jsonpatch": "~5.1.
|
|
54
|
-
"@xyo-network/diviner-payload-generic": "~5.1.
|
|
55
|
-
"@xyo-network/diviner-payload-memory": "~5.1.
|
|
56
|
-
"@xyo-network/diviner-payload-model": "~5.1.
|
|
57
|
-
"@xyo-network/diviner-stateful": "~5.1.
|
|
58
|
-
"@xyo-network/diviner-temporal-indexing": "~5.1.
|
|
59
|
-
"@xyo-network/manifest": "~5.1.
|
|
60
|
-
"@xyo-network/module-factory-locator": "~5.1.
|
|
61
|
-
"@xyo-network/node-memory": "~5.1.
|
|
62
|
-
"@xyo-network/open-zeppelin-typechain": "~4.0.
|
|
63
|
-
"@xyo-network/sentinel-model": "~5.1.
|
|
64
|
-
"@xyo-network/wallet": "~5.1.
|
|
65
|
-
"@xyo-network/wallet-model": "~5.1.
|
|
66
|
-
"@xyo-network/witness-evm-abstract": "~5.1.
|
|
67
|
-
"@xyo-network/witness-timestamp": "~5.1.
|
|
68
|
-
"typescript": "~5.9.
|
|
69
|
-
"vitest": "~
|
|
49
|
+
"@xylabs/delay": "~5.0.37",
|
|
50
|
+
"@xylabs/ts-scripts-yarn3": "~7.2.8",
|
|
51
|
+
"@xylabs/tsconfig": "~7.2.8",
|
|
52
|
+
"@xylabs/vitest-extended": "~5.0.37",
|
|
53
|
+
"@xyo-network/archivist-memory": "~5.1.23",
|
|
54
|
+
"@xyo-network/boundwitness-model": "~5.1.23",
|
|
55
|
+
"@xyo-network/diviner-boundwitness-memory": "~5.1.23",
|
|
56
|
+
"@xyo-network/diviner-jsonpatch": "~5.1.23",
|
|
57
|
+
"@xyo-network/diviner-payload-generic": "~5.1.23",
|
|
58
|
+
"@xyo-network/diviner-payload-memory": "~5.1.23",
|
|
59
|
+
"@xyo-network/diviner-payload-model": "~5.1.23",
|
|
60
|
+
"@xyo-network/diviner-stateful": "~5.1.23",
|
|
61
|
+
"@xyo-network/diviner-temporal-indexing": "~5.1.23",
|
|
62
|
+
"@xyo-network/manifest": "~5.1.23",
|
|
63
|
+
"@xyo-network/module-factory-locator": "~5.1.23",
|
|
64
|
+
"@xyo-network/node-memory": "~5.1.23",
|
|
65
|
+
"@xyo-network/open-zeppelin-typechain": "~4.0.10",
|
|
66
|
+
"@xyo-network/sentinel-model": "~5.1.23",
|
|
67
|
+
"@xyo-network/wallet": "~5.1.23",
|
|
68
|
+
"@xyo-network/wallet-model": "~5.1.23",
|
|
69
|
+
"@xyo-network/witness-evm-abstract": "~5.1.23",
|
|
70
|
+
"@xyo-network/witness-timestamp": "~5.1.23",
|
|
71
|
+
"typescript": "~5.9.3",
|
|
72
|
+
"vitest": "~4.0.10"
|
|
70
73
|
},
|
|
71
74
|
"publishConfig": {
|
|
72
75
|
"access": "public"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Diviner.spec.d.ts","sourceRoot":"","sources":["../../../src/spec/Diviner.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TokenNode.spec.d.ts","sourceRoot":"","sources":["../../../src/spec/TokenNode.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
package/src/spec/Diviner.spec.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import '@xylabs/vitest-extended'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
EvmContractSchema, EvmContractWitness, EvmContractWitnessConfigSchema,
|
|
5
|
-
} from '@xyo-network/evm-contract-witness'
|
|
6
|
-
import { EvmAddressSchema, getProvidersFromEnv } from '@xyo-network/witness-evm-abstract'
|
|
7
|
-
import {
|
|
8
|
-
describe, expect,
|
|
9
|
-
it,
|
|
10
|
-
} from 'vitest'
|
|
11
|
-
|
|
12
|
-
import { EvmTokenInterfaceImplementedDiviner, EvmTokenInterfaceImplementedDivinerConfigSchema } from '../Diviner.ts'
|
|
13
|
-
import type { TokenInterface } from '../Payload.ts'
|
|
14
|
-
|
|
15
|
-
describe.skipIf(!process.env.INFURA_PROJECT_ID)('EvmTokenInterfaceImplementedDiviner', () => {
|
|
16
|
-
type TestData = readonly [string, TokenInterface[]]
|
|
17
|
-
const cases: readonly TestData[] = [
|
|
18
|
-
['0x55296f69f40ea6d20e478533c15a6b08b654e758', ['ERC20'] as TokenInterface[]], // XYO ERC20
|
|
19
|
-
['0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D', ['ERC721', 'ERC721Metadata', 'ERC721Enumerable', 'ERC721TokenReceiver'] as TokenInterface[]], // BAYC
|
|
20
|
-
['0x2A6d6a082C410a195157EC4caf67CB9fD718f087', ['ERC1155', 'ERC1155Metadata_URI', 'ERC1155TokenReceiver'] as TokenInterface[]], // Spider Tanks
|
|
21
|
-
] as const
|
|
22
|
-
describe('divine', () => {
|
|
23
|
-
describe('with matching ABI', () => {
|
|
24
|
-
it.each(cases)('returns implemented true', async (address, tokenInterfaces) => {
|
|
25
|
-
const witness = await EvmContractWitness.create({
|
|
26
|
-
account: 'random',
|
|
27
|
-
config: { schema: EvmContractWitnessConfigSchema },
|
|
28
|
-
providers: getProvidersFromEnv,
|
|
29
|
-
})
|
|
30
|
-
const diviner = await EvmTokenInterfaceImplementedDiviner.create({
|
|
31
|
-
account: 'random',
|
|
32
|
-
config: { schema: EvmTokenInterfaceImplementedDivinerConfigSchema, tokenInterfaces },
|
|
33
|
-
})
|
|
34
|
-
const observations = await witness.observe([{ address, schema: EvmAddressSchema }])
|
|
35
|
-
expect(observations?.length).toBeGreaterThan(0)
|
|
36
|
-
const code = observations?.[0].code
|
|
37
|
-
const results = await diviner.divine([{
|
|
38
|
-
address, block: 0, chainId: 1, code, schema: EvmContractSchema,
|
|
39
|
-
}])
|
|
40
|
-
expect(results?.length).toBeGreaterThan(0)
|
|
41
|
-
for (const result of results ?? []) {
|
|
42
|
-
expect(result.address).toBe(address)
|
|
43
|
-
expect(result.implemented).toBeTrue()
|
|
44
|
-
}
|
|
45
|
-
})
|
|
46
|
-
})
|
|
47
|
-
describe('without matching ABI', () => {
|
|
48
|
-
it.each(cases)('returns implemented false', async (address, tokenInterfaces) => {
|
|
49
|
-
const diviner = await EvmTokenInterfaceImplementedDiviner.create({
|
|
50
|
-
account: 'random',
|
|
51
|
-
config: { schema: EvmTokenInterfaceImplementedDivinerConfigSchema, tokenInterfaces },
|
|
52
|
-
})
|
|
53
|
-
const results = await diviner.divine([{
|
|
54
|
-
address, block: 0, chainId: 1, code: '0x00', schema: EvmContractSchema,
|
|
55
|
-
}])
|
|
56
|
-
expect(results?.length).toBeGreaterThan(0)
|
|
57
|
-
for (const result of results ?? []) {
|
|
58
|
-
expect(result.address).toBe(address)
|
|
59
|
-
expect(result.implemented).toBeFalse()
|
|
60
|
-
}
|
|
61
|
-
})
|
|
62
|
-
})
|
|
63
|
-
})
|
|
64
|
-
})
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import '@xylabs/vitest-extended'
|
|
2
|
-
|
|
3
|
-
import { assertEx } from '@xylabs/assert'
|
|
4
|
-
import { delay } from '@xylabs/delay'
|
|
5
|
-
import { MemoryArchivist } from '@xyo-network/archivist-memory'
|
|
6
|
-
import type { BoundWitness } from '@xyo-network/boundwitness-model'
|
|
7
|
-
import { isBoundWitness } from '@xyo-network/boundwitness-model'
|
|
8
|
-
import { MemoryBoundWitnessDiviner } from '@xyo-network/diviner-boundwitness-memory'
|
|
9
|
-
import { JsonPatchDiviner } from '@xyo-network/diviner-jsonpatch'
|
|
10
|
-
import { asDivinerInstance } from '@xyo-network/diviner-model'
|
|
11
|
-
import { GenericPayloadDiviner } from '@xyo-network/diviner-payload-generic'
|
|
12
|
-
import { PayloadDivinerQuerySchema } from '@xyo-network/diviner-payload-model'
|
|
13
|
-
import { StatefulDiviner, StatefulDivinerParams } from '@xyo-network/diviner-stateful'
|
|
14
|
-
import {
|
|
15
|
-
TemporalIndexingDiviner,
|
|
16
|
-
TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner,
|
|
17
|
-
TemporalIndexingDivinerIndexCandidateToIndexDiviner,
|
|
18
|
-
TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner,
|
|
19
|
-
TemporalIndexingDivinerStateToIndexCandidateDiviner,
|
|
20
|
-
} from '@xyo-network/diviner-temporal-indexing'
|
|
21
|
-
import type { EvmContract, EvmContractWitnessParams } from '@xyo-network/evm-contract-witness'
|
|
22
|
-
import { EvmContractWitness, isEvmContract } from '@xyo-network/evm-contract-witness'
|
|
23
|
-
import type { ModuleManifest, PackageManifestPayload } from '@xyo-network/manifest'
|
|
24
|
-
import { ManifestWrapper } from '@xyo-network/manifest'
|
|
25
|
-
import { ModuleFactoryLocator } from '@xyo-network/module-factory-locator'
|
|
26
|
-
import {
|
|
27
|
-
creatableModule, CreatableModuleInstance, ModuleFactory, ModuleState,
|
|
28
|
-
} from '@xyo-network/module-model'
|
|
29
|
-
import type { MemoryNode } from '@xyo-network/node-memory'
|
|
30
|
-
import { Payload } from '@xyo-network/payload-model'
|
|
31
|
-
import { asSentinelInstance } from '@xyo-network/sentinel-model'
|
|
32
|
-
import { HDWallet } from '@xyo-network/wallet'
|
|
33
|
-
import type { WalletInstance } from '@xyo-network/wallet-model'
|
|
34
|
-
import type { EvmAddress } from '@xyo-network/witness-evm-abstract'
|
|
35
|
-
import { EvmAddressSchema, getProviderFromEnv } from '@xyo-network/witness-evm-abstract'
|
|
36
|
-
import type { TimeStamp } from '@xyo-network/witness-timestamp'
|
|
37
|
-
import { isTimestamp, TimestampWitness } from '@xyo-network/witness-timestamp'
|
|
38
|
-
import type { Provider } from 'ethers'
|
|
39
|
-
import {
|
|
40
|
-
beforeAll,
|
|
41
|
-
describe, expect, it,
|
|
42
|
-
} from 'vitest'
|
|
43
|
-
|
|
44
|
-
import { EvmTokenInterfaceImplementedDiviner } from '../Diviner.ts'
|
|
45
|
-
import type { TokenInterface } from '../Payload.ts'
|
|
46
|
-
import { isEvmTokenInterfaceImplemented } from '../Payload.ts'
|
|
47
|
-
import contractWitnessManifest from './Contract.Witness.Index.json' with { type: 'json' }
|
|
48
|
-
import tokenDivinerManifest from './Token.Diviner.Index.json' with { type: 'json' }
|
|
49
|
-
import tokenNodeManifest from './TokenNode.json' with { type: 'json' }
|
|
50
|
-
|
|
51
|
-
const maxProviders = 32
|
|
52
|
-
|
|
53
|
-
@creatableModule<CreatableModuleInstance<StatefulDivinerParams>>()
|
|
54
|
-
class TestStatefulDiviner extends StatefulDiviner {
|
|
55
|
-
callCommitState(state: ModuleState) {
|
|
56
|
-
return this.commitState(state)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
callRetrieveState() {
|
|
60
|
-
return this.retrieveState()
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
protected override divineHandler(payloads?: Payload[]): Promise<Payload[]> {
|
|
64
|
-
return Promise.resolve(payloads ?? [])
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
describe('Contract Node', () => {
|
|
69
|
-
const chainId = 1
|
|
70
|
-
const cases: [TokenInterface, string][] = [
|
|
71
|
-
['ERC721', '0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D'], // BAYC
|
|
72
|
-
['ERC1155', '0x2A6d6a082C410a195157EC4caf67CB9fD718f087'], // Spider Tanks
|
|
73
|
-
]
|
|
74
|
-
const getProviders = () => {
|
|
75
|
-
const providers: Provider[] = []
|
|
76
|
-
for (let i = 0; i < maxProviders; i++) {
|
|
77
|
-
providers.push(getProviderFromEnv())
|
|
78
|
-
}
|
|
79
|
-
return providers
|
|
80
|
-
}
|
|
81
|
-
let wallet: WalletInstance
|
|
82
|
-
let node: MemoryNode
|
|
83
|
-
beforeAll(async () => {
|
|
84
|
-
const mnemonic = 'later puppy sound rebuild rebuild noise ozone amazing hope broccoli crystal grief'
|
|
85
|
-
wallet = await HDWallet.fromPhrase(mnemonic)
|
|
86
|
-
const locator = new ModuleFactoryLocator()
|
|
87
|
-
locator.register(MemoryArchivist.factory())
|
|
88
|
-
locator.register(MemoryBoundWitnessDiviner.factory())
|
|
89
|
-
locator.register(GenericPayloadDiviner.factory())
|
|
90
|
-
locator.register(TimestampWitness.factory())
|
|
91
|
-
locator.register(TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner.factory())
|
|
92
|
-
locator.register(TemporalIndexingDivinerIndexCandidateToIndexDiviner.factory())
|
|
93
|
-
locator.register(TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner.factory())
|
|
94
|
-
locator.register(TemporalIndexingDivinerStateToIndexCandidateDiviner.factory())
|
|
95
|
-
locator.register(TemporalIndexingDiviner.factory())
|
|
96
|
-
locator.register(JsonPatchDiviner.factory())
|
|
97
|
-
locator.register(TestStatefulDiviner.factory())
|
|
98
|
-
locator.register(EvmTokenInterfaceImplementedDiviner.factory())
|
|
99
|
-
locator.register(
|
|
100
|
-
new ModuleFactory(EvmContractWitness, { providers: getProviders } as EvmContractWitnessParams),
|
|
101
|
-
)
|
|
102
|
-
const publicChildren: ModuleManifest[] = [...contractWitnessManifest.nodes, ...tokenDivinerManifest.nodes]
|
|
103
|
-
const manifest = new ManifestWrapper(tokenNodeManifest as PackageManifestPayload, wallet, locator, publicChildren)
|
|
104
|
-
node = assertEx((await manifest.loadNodes()).at(0), () => 'Node not loaded')
|
|
105
|
-
const mods = await node.resolve('*')
|
|
106
|
-
expect(mods).toBeDefined()
|
|
107
|
-
})
|
|
108
|
-
describe('Contract Witness Index Node', () => {
|
|
109
|
-
it.each(cases)('With %s (%s)', async (tokenInterface, address) => {
|
|
110
|
-
const contractSentinel = asSentinelInstance(await node.resolve('EvmContractSentinel'))
|
|
111
|
-
expect(contractSentinel).toBeDefined()
|
|
112
|
-
const collectionCallPayload: EvmAddress = {
|
|
113
|
-
address, chainId, schema: EvmAddressSchema,
|
|
114
|
-
}
|
|
115
|
-
const report = await contractSentinel?.report([collectionCallPayload])
|
|
116
|
-
expect(report).toBeDefined()
|
|
117
|
-
expect(report).toBeArrayOfSize(3)
|
|
118
|
-
const [bw, timestamp, contract] = (report as [BoundWitness, TimeStamp, EvmContract]) ?? []
|
|
119
|
-
expect(isBoundWitness(bw)).toBeTrue()
|
|
120
|
-
expect(isTimestamp(timestamp)).toBeTrue()
|
|
121
|
-
expect(isEvmContract(contract)).toBeTrue()
|
|
122
|
-
expect(contract.address).toBe(address)
|
|
123
|
-
expect(contract.chainId).toBe(chainId)
|
|
124
|
-
expect(contract.code).toBeDefined()
|
|
125
|
-
const divinerName = `${tokenInterface}TokenInterfaceImplementedSentinel`
|
|
126
|
-
const tokenSentinel = asSentinelInstance(await node.resolve(divinerName))
|
|
127
|
-
expect(tokenSentinel).toBeDefined()
|
|
128
|
-
const tokenReport = await tokenSentinel?.report([contract])
|
|
129
|
-
expect(tokenReport).toBeDefined()
|
|
130
|
-
const anyInterfacesImplemented = tokenReport?.filter(isEvmTokenInterfaceImplemented).some(i => i.implemented)
|
|
131
|
-
expect(anyInterfacesImplemented).toBeTrue()
|
|
132
|
-
})
|
|
133
|
-
})
|
|
134
|
-
describe.skip('Token Diviner Index Node', () => {
|
|
135
|
-
beforeAll(async () => {
|
|
136
|
-
// Alow indexers to index
|
|
137
|
-
await delay(1000)
|
|
138
|
-
})
|
|
139
|
-
it.each(cases)('With %s (%s)', async (tokenInterface, address) => {
|
|
140
|
-
const divinerModule = await node.resolve('EvmTokenInterfaceImplementedIndexDiviner')
|
|
141
|
-
expect(divinerModule).toBeDefined()
|
|
142
|
-
const diviner = asDivinerInstance(divinerModule)
|
|
143
|
-
expect(diviner).toBeDefined()
|
|
144
|
-
const query = {
|
|
145
|
-
address, chainId, implemented: true, schema: PayloadDivinerQuerySchema, tokenInterface,
|
|
146
|
-
}
|
|
147
|
-
const result = await diviner?.divine([query])
|
|
148
|
-
expect(result).toBeDefined()
|
|
149
|
-
expect(result).toBeArrayOfSize(1)
|
|
150
|
-
})
|
|
151
|
-
})
|
|
152
|
-
})
|