Skip to content

Commit

Permalink
Merge pull request #10 from XYOracleNetwork/feature/evm-token-interfa…
Browse files Browse the repository at this point in the history
…ce-diviner-index

EVM Contract Index Tests
  • Loading branch information
JoelBCarter authored Dec 14, 2023
2 parents e94f6b3 + c9dfdfe commit 398ce1c
Show file tree
Hide file tree
Showing 8 changed files with 716 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
"--forceExit",
"--runInBand",
"--testTimeout=120000",
"packages/payloadset/packages/crypto/packages/nft/packages/contract/packages/function-read/src/spec/Contract.Sentinel.Node.spec.ts"
"packages/payloadset/packages/evm/packages/token-interface/packages/diviner/src/spec/TokenNode.spec.ts"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,26 @@
"ethers": "^6.9.0"
},
"devDependencies": {
"@xylabs/delay": "^2.13.20",
"@xylabs/jest-helpers": "^2.13.20",
"@xylabs/ts-scripts-yarn3": "^3.2.19",
"@xylabs/tsconfig": "^3.2.19",
"@xyo-network/account": "^2.84.3",
"@xyo-network/boundwitness-model": "^2.84.3",
"@xyo-network/diviner-boundwitness-memory": "^2.84.3",
"@xyo-network/diviner-jsonpatch": "^2.84.3",
"@xyo-network/diviner-payload-memory": "^2.84.3",
"@xyo-network/diviner-payload-model": "^2.84.3",
"@xyo-network/diviner-stateful": "^2.84.3",
"@xyo-network/diviner-temporal-indexing": "^2.84.3",
"@xyo-network/evm-contract-witness": "workspace:~",
"@xyo-network/manifest": "^2.84.3",
"@xyo-network/memory-archivist": "^2.84.3",
"@xyo-network/node-memory": "^2.84.3",
"@xyo-network/open-zeppelin-typechain": "^3.0.5",
"@xyo-network/sentinel-model": "^2.84.3",
"@xyo-network/witness-blockchain-abstract": "^2.84.3",
"@xyo-network/witness-timestamp": "^2.84.3",
"jest": "^29.7.0",
"typescript": "^5.3.3"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,19 @@ export class EvmTokenInterfaceImplementedDiviner<
Object.entries(this.tokenInterfaces).forEach(([tokenInterface, abi]) => {
// Check if the contract implements the interface abi
const contractInterface = new Interface(abi)
const implementations: boolean[] = []
contractInterface.forEachFunction(({ selector }) => {
const result: EvmTokenInterfaceImplemented = {
address,
chainId,
implemented: byteCode.includes(BigInt(selector).toString(16)),
schema: EvmTokenInterfaceImplementedSchema,
tokenInterface: tokenInterface as TokenInterface,
}
results.push(result)
implementations.push(byteCode.includes(BigInt(selector).toString(16)))
})
const implemented = implementations.every((implementation) => implementation)
const result: EvmTokenInterfaceImplemented = {
address,
chainId,
implemented,
schema: EvmTokenInterfaceImplementedSchema,
tokenInterface: tokenInterface as TokenInterface,
}
results.push(result)
})

return results
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
{
"$schema": "https://raw.githubusercontent.com/XYOracleNetwork/sdk-xyo-client-js/main/packages/manifest/src/schema.json",
"nodes": [
{
"config": {
"accountPath": "m/44'/60'/1",
"name": "ContractWitnessIndexNode",
"schema": "network.xyo.node.config"
},
"modules": {
"private": [
{
"config": {
"language": "javascript",
"name": "AddressStateArchivist",
"schema": "network.xyo.archivist.config",
"storeQueries": false
}
},
{
"config": {
"archivist": "AddressStateArchivist",
"language": "javascript",
"name": "AddressStateBoundWitnessDiviner",
"schema": "network.xyo.diviner.boundwitness.config"
}
},
{
"config": {
"archivist": "AddressStateArchivist",
"language": "javascript",
"name": "AddressStatePayloadDiviner",
"schema": "network.xyo.diviner.payload.config"
}
},
{
"config": {
"language": "javascript",
"name": "EvmContractDivinerIndexArchivist",
"schema": "network.xyo.archivist.config"
}
},
{
"config": {
"archivist": "EvmContractDivinerIndexArchivist",
"language": "javascript",
"name": "EvmContractDivinerIndexBoundWitnessDiviner",
"schema": "network.xyo.diviner.boundwitness.config"
}
},
{
"config": {
"archivist": "EvmContractDivinerIndexArchivist",
"language": "javascript",
"name": "EvmContractDivinerIndexPayloadDiviner",
"schema": "network.xyo.diviner.payload.config"
}
},
{
"config": {
"filter": {
"payload_schemas": ["network.xyo.evm.contract"]
},
"labels": {
"network.xyo.diviner.stage": "stateToIndexCandidateDiviner"
},
"language": "javascript",
"name": "EvmContractStateToIndexCandidateDiviner",
"payloadStore": {
"archivist": "Archivist",
"boundWitnessDiviner": "BoundWitnessDiviner",
"payloadDiviner": "PayloadDiviner"
},
"schema": "network.xyo.diviner.indexing.temporal.stage.stateToIndexCandidateDiviner.config"
}
},
{
"config": {
"labels": {
"network.xyo.diviner.stage": "indexCandidateToIndexDiviner"
},
"language": "javascript",
"name": "EvmContractIndexCandidateToEvmContractIndexDiviner",
"schema": "network.xyo.diviner.indexing.temporal.stage.indexCandidateToIndexDiviner.config",
"schemaTransforms": {
"network.xyo.evm.contract": [
{
"destinationField": "address",
"sourcePathExpression": "$.address"
},
{
"destinationField": "chainId",
"sourcePathExpression": "$.chainId"
}
],
"network.xyo.timestamp": [
{
"destinationField": "timestamp",
"sourcePathExpression": "$.timestamp"
}
]
}
}
},
{
"config": {
"divinerQuerySchema": "network.xyo.diviner.payload.query",
"indexQuerySchema": "network.xyo.diviner.payload.query",
"indexSchema": "network.xyo.diviner.indexing.temporal.result.index",
"labels": {
"network.xyo.diviner.stage": "divinerQueryToIndexQueryDiviner"
},
"language": "javascript",
"name": "EvmContractQueryToEvmContractIndexQueryDiviner",
"schema": "network.xyo.diviner.indexing.temporal.stage.divinerQueryToIndexQueryDiviner.config",
"schemaTransforms": {
"network.xyo.diviner.payload.query": [
{
"destinationField": "address",
"sourcePathExpression": "$.address"
},
{
"defaultValue": 1,
"destinationField": "chainId",
"sourcePathExpression": "$.chainId"
},
{
"defaultValue": 1,
"destinationField": "limit",
"sourcePathExpression": "$.limit"
},
{
"defaultValue": 0,
"destinationField": "offset",
"sourcePathExpression": "$.offset"
},
{
"defaultValue": "desc",
"destinationField": "order",
"sourcePathExpression": "$.order"
}
]
}
}
},
{
"config": {
"labels": {
"network.xyo.diviner.stage": "indexQueryResponseToDivinerQueryResponseDiviner"
},
"language": "javascript",
"name": "EvmContractIndexQueryResponseToEvmContractQueryResponseDiviner",
"schema": "network.xyo.diviner.indexing.temporal.stage.indexQueryResponseToDivinerQueryResponseDiviner.config"
}
},
{
"config": {
"language": "javascript",
"name": "EvmContractWitness",
"schema": "network.xyo.evm.contract.witness.config"
}
},
{
"config": {
"language": "javascript",
"name": "TimestampWitness",
"schema": "network.xyo.witness.timestamp.config"
}
}
],
"public": [
{
"config": {
"indexStore": {
"archivist": "EvmContractDivinerIndexArchivist",
"boundWitnessDiviner": "EvmContractDivinerIndexBoundWitnessDiviner",
"payloadDiviner": "EvmContractDivinerIndexPayloadDiviner"
},
"indexingDivinerStages": {
"divinerQueryToIndexQueryDiviner": "EvmContractQueryToEvmContractIndexQueryDiviner",
"indexCandidateToIndexDiviner": "EvmContractIndexCandidateToEvmContractIndexDiviner",
"indexQueryResponseToDivinerQueryResponseDiviner": "EvmContractIndexQueryResponseToEvmContractQueryResponseDiviner",
"stateToIndexCandidateDiviner": "EvmContractStateToIndexCandidateDiviner"
},
"language": "javascript",
"name": "EvmContractIndexDiviner",
"pollFrequency": 1,
"schema": "network.xyo.diviner.indexing.temporal.config",
"stateStore": {
"archivist": "AddressStateArchivist",
"boundWitnessDiviner": "AddressStateBoundWitnessDiviner",
"payloadDiviner": "AddressStatePayloadDiviner"
}
}
},
{
"config": {
"archiving": {
"archivists": ["Archivist"]
},
"language": "javascript",
"name": "EvmContractSentinel",
"schema": "network.xyo.sentinel.config",
"synchronous": "true",
"tasks": [
{
"input": true,
"module": "TimestampWitness"
},
{
"input": true,
"module": "EvmContractWitness"
}
]
}
}
]
}
}
],
"schema": "network.xyo.manifest"
}
Loading

0 comments on commit 398ce1c

Please sign in to comment.