From e227754cc175f309626a9136b8d471baeeed383c Mon Sep 17 00:00:00 2001 From: fewensa Date: Thu, 19 Oct 2023 04:58:55 +0000 Subject: [PATCH 01/13] subapi --- thegraph/ormpipe/README.md | 29 --- .../abis/{AirnodeDapi.json => Subapi.json} | 168 +++++++++++++--- thegraph/ormpipe/networks.json | 30 +-- thegraph/ormpipe/package.json | 10 +- thegraph/ormpipe/schema.graphql | 152 ++------------ thegraph/ormpipe/src/airnode-dapi.ts | 92 --------- thegraph/ormpipe/src/ormp-oracle.ts | 63 ------ thegraph/ormpipe/src/ormp-protocol.ts | 107 ---------- thegraph/ormpipe/src/ormp-relayer.ts | 72 ------- .../ormpipe/subgraph-arbitrum-goerli.yaml | 130 ------------ thegraph/ormpipe/subgraph-pangolin.yaml | 130 ------------ thegraph/ormpipe/tests/airnode-dapi-utils.ts | 170 ---------------- thegraph/ormpipe/tests/airnode-dapi.test.ts | 53 ----- thegraph/ormpipe/tests/ormp-oracle-utils.ts | 77 -------- thegraph/ormpipe/tests/ormp-oracle.test.ts | 53 ----- thegraph/ormpipe/tests/ormp-protocol-utils.ts | 128 ------------ thegraph/ormpipe/tests/ormp-protocol.test.ts | 68 ------- thegraph/ormpipe/tests/ormp-relayer-utils.ts | 114 ----------- thegraph/ormpipe/tests/ormp-relayer.test.ts | 67 ------- thegraph/ormpipe/yarn.lock | 187 +++++++++--------- 20 files changed, 266 insertions(+), 1634 deletions(-) delete mode 100644 thegraph/ormpipe/README.md rename thegraph/ormpipe/abis/{AirnodeDapi.json => Subapi.json} (71%) delete mode 100644 thegraph/ormpipe/src/airnode-dapi.ts delete mode 100644 thegraph/ormpipe/src/ormp-oracle.ts delete mode 100644 thegraph/ormpipe/src/ormp-protocol.ts delete mode 100644 thegraph/ormpipe/src/ormp-relayer.ts delete mode 100644 thegraph/ormpipe/subgraph-arbitrum-goerli.yaml delete mode 100644 thegraph/ormpipe/subgraph-pangolin.yaml delete mode 100644 thegraph/ormpipe/tests/airnode-dapi-utils.ts delete mode 100644 thegraph/ormpipe/tests/airnode-dapi.test.ts delete mode 100644 thegraph/ormpipe/tests/ormp-oracle-utils.ts delete mode 100644 thegraph/ormpipe/tests/ormp-oracle.test.ts delete mode 100644 thegraph/ormpipe/tests/ormp-protocol-utils.ts delete mode 100644 thegraph/ormpipe/tests/ormp-protocol.test.ts delete mode 100644 thegraph/ormpipe/tests/ormp-relayer-utils.ts delete mode 100644 thegraph/ormpipe/tests/ormp-relayer.test.ts diff --git a/thegraph/ormpipe/README.md b/thegraph/ormpipe/README.md deleted file mode 100644 index f833c9d..0000000 --- a/thegraph/ormpipe/README.md +++ /dev/null @@ -1,29 +0,0 @@ -ormpipe -=== - - - -adresses - -ormp: https://github.com/darwinia-network/ORMP/tree/main/script/deploy/output -airnode: https://github.com/darwinia-oracle-dao/airnode-dapi/blob/main/bin/addr.json - -## deploy - - -### deploy to thegraph studio - -``` -npm run deploy:studio \ - -- ormpipe-arbitrum-goerli subgraph-arbitrum-goerli.yaml -``` - -### deploy to hosted server (by Darwinia) - -``` -npm run deploy:darwinia \ - -- --access-token= \ - ormpipe-pangolin \ - subgraph-pangolin.yaml -``` - diff --git a/thegraph/ormpipe/abis/AirnodeDapi.json b/thegraph/ormpipe/abis/Subapi.json similarity index 71% rename from thegraph/ormpipe/abis/AirnodeDapi.json rename to thegraph/ormpipe/abis/Subapi.json index e0ebc9c..8e6f1f1 100644 --- a/thegraph/ormpipe/abis/AirnodeDapi.json +++ b/thegraph/ormpipe/abis/Subapi.json @@ -1,10 +1,8 @@ [ { "inputs": [ - { "internalType": "string", "name": "name_", "type": "string" }, - { "internalType": "address", "name": "airnodeRrp", "type": "address" }, { "internalType": "address", "name": "dao", "type": "address" }, - { "internalType": "uint256", "name": "fee_", "type": "uint256" } + { "internalType": "address", "name": "ormp", "type": "address" } ], "stateMutability": "nonpayable", "type": "constructor" @@ -34,7 +32,7 @@ } ], "indexed": false, - "internalType": "struct AirnodeMessageRootDapi.Beacon", + "internalType": "struct SubAPI.Beacon", "name": "beacon", "type": "tuple" } @@ -46,32 +44,17 @@ "anonymous": false, "inputs": [ { + "components": [ + { "internalType": "uint256", "name": "count", "type": "uint256" }, + { "internalType": "bytes32", "name": "root", "type": "bytes32" } + ], "indexed": false, - "internalType": "bytes32", - "name": "msgRoot", - "type": "bytes32" - } - ], - "name": "AggregatedMessageRoot", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "beaconId", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "msgRoot", - "type": "bytes32" + "internalType": "struct SubAPIFeed.ORMPData", + "name": "ormpData", + "type": "tuple" } ], - "name": "AirnodeMessageRootFeedUpdated", + "name": "AggregatedORMPData", "type": "event" }, { @@ -169,6 +152,36 @@ "name": "RemoveBeacon", "type": "event" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "beaconId", + "type": "bytes32" + }, + { + "components": [ + { "internalType": "uint256", "name": "count", "type": "uint256" }, + { "internalType": "bytes32", "name": "root", "type": "bytes32" } + ], + "indexed": false, + "internalType": "struct SubAPIFeed.ORMPData", + "name": "msgRoot", + "type": "tuple" + } + ], + "name": "SubAPIFeedUpdated", + "type": "event" + }, + { + "inputs": [], + "name": "ORMP", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, { "inputs": [], "name": "acceptOwnership", @@ -193,7 +206,7 @@ "type": "address" } ], - "internalType": "struct AirnodeMessageRootDapi.Beacon", + "internalType": "struct SubAPI.Beacon", "name": "beacon", "type": "tuple" } @@ -249,7 +262,7 @@ "type": "address" } ], - "internalType": "struct AirnodeMessageRootDapi.Beacon", + "internalType": "struct SubAPI.Beacon", "name": "beacon", "type": "tuple" } @@ -261,6 +274,32 @@ "stateMutability": "pure", "type": "function" }, + { + "inputs": [ + { + "components": [ + { "internalType": "uint256", "name": "count", "type": "uint256" }, + { "internalType": "bytes32", "name": "root", "type": "bytes32" } + ], + "internalType": "struct SubAPIFeed.ORMPData", + "name": "a", + "type": "tuple" + }, + { + "components": [ + { "internalType": "uint256", "name": "count", "type": "uint256" }, + { "internalType": "bytes32", "name": "root", "type": "bytes32" } + ], + "internalType": "struct SubAPIFeed.ORMPData", + "name": "b", + "type": "tuple" + } + ], + "name": "eq", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "pure", + "type": "function" + }, { "inputs": [], "name": "fee", @@ -293,7 +332,15 @@ ], "name": "getDataFeedWithId", "outputs": [ - { "internalType": "bytes32", "name": "msgRoot", "type": "bytes32" } + { + "components": [ + { "internalType": "uint256", "name": "count", "type": "uint256" }, + { "internalType": "bytes32", "name": "root", "type": "bytes32" } + ], + "internalType": "struct SubAPIFeed.ORMPData", + "name": "msgRoot", + "type": "tuple" + } ], "stateMutability": "view", "type": "function" @@ -326,6 +373,13 @@ "stateMutability": "view", "type": "function" }, + { + "inputs": [], + "name": "localCommitment", + "outputs": [{ "internalType": "bytes", "name": "", "type": "bytes" }], + "stateMutability": "view", + "type": "function" + }, { "inputs": [], "name": "messageRoot", @@ -340,6 +394,32 @@ "stateMutability": "view", "type": "function" }, + { + "inputs": [ + { + "components": [ + { "internalType": "uint256", "name": "count", "type": "uint256" }, + { "internalType": "bytes32", "name": "root", "type": "bytes32" } + ], + "internalType": "struct SubAPIFeed.ORMPData", + "name": "a", + "type": "tuple" + }, + { + "components": [ + { "internalType": "uint256", "name": "count", "type": "uint256" }, + { "internalType": "bytes32", "name": "root", "type": "bytes32" } + ], + "internalType": "struct SubAPIFeed.ORMPData", + "name": "b", + "type": "tuple" + } + ], + "name": "neq", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "pure", + "type": "function" + }, { "inputs": [], "name": "owner", @@ -354,6 +434,16 @@ "stateMutability": "view", "type": "function" }, + { + "inputs": [], + "name": "remoteCommitment", + "outputs": [ + { "internalType": "uint256", "name": "count", "type": "uint256" }, + { "internalType": "bytes32", "name": "root", "type": "bytes32" } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [ { "internalType": "bytes32", "name": "beaconId", "type": "bytes32" } @@ -387,7 +477,7 @@ "type": "address" } ], - "internalType": "struct AirnodeMessageRootDapi.Beacon[]", + "internalType": "struct SubAPI.Beacon[]", "name": "beacons", "type": "tuple[]" } @@ -397,6 +487,15 @@ "stateMutability": "payable", "type": "function" }, + { + "inputs": [ + { "internalType": "address", "name": "_airnodeRrp", "type": "address" } + ], + "name": "setAirnodeRrp", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [ { "internalType": "uint256", "name": "fee_", "type": "uint256" } @@ -406,6 +505,13 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [{ "internalType": "string", "name": "name_", "type": "string" }], + "name": "setName", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [ { "internalType": "address", "name": "newOwner", "type": "address" } diff --git a/thegraph/ormpipe/networks.json b/thegraph/ormpipe/networks.json index 32709f5..27c0c92 100644 --- a/thegraph/ormpipe/networks.json +++ b/thegraph/ormpipe/networks.json @@ -1,30 +1,16 @@ { - "arbitrum-goerli": { - "AirnodeDapi": { - "address": "0xa681492DBAd5a3999cFCE2d72196d5784dd08D0c" - }, - "OrmpOracle": { - "address": "0x000000003e2E2C9C8DD469E129E02E1666898E76" - }, - "OrmpRelayer": { - "address": "0x000000007e24Da6666c773280804d8021E12e13F" - }, + "fantom": { "OrmpProtocol": { - "address": "0x0000000000BD9dcFDa5C60697039E2b3B28b079b" - } - }, - "pangolin": { - "AirnodeDapi": { - "address": "0x770713580e5c618A4D29D7E8c0d7604276B63832" + "address": "0x0034607daf9c1dc6628f6e09E81bB232B6603A89" + }, + "Subapi": { + "address": "0x007471Db6AD668b30a7CE648589a4C8C4f65a36f" }, "OrmpOracle": { - "address": "0x000000003e2E2C9C8DD469E129E02E1666898E76" + "address": "0x0002396F1D52323fcd1ae8079b38808F046882c3" }, "OrmpRelayer": { - "address": "0x000000007e24Da6666c773280804d8021E12e13F" - }, - "OrmpProtocol": { - "address": "0x0000000000BD9dcFDa5C60697039E2b3B28b079b" + "address": "0x007EED6207c9AF3715964Fb7f8B5f44E002a3498" } } -} +} \ No newline at end of file diff --git a/thegraph/ormpipe/package.json b/thegraph/ormpipe/package.json index bbe3a9d..4831765 100644 --- a/thegraph/ormpipe/package.json +++ b/thegraph/ormpipe/package.json @@ -1,13 +1,13 @@ { "name": "ormpipe", - "version": "0.0.1", + "license": "UNLICENSED", "scripts": { "codegen": "graph codegen", "build": "graph build", - "deploy:studio": "graph deploy --node https://api.studio.thegraph.com/deploy/", - "create:darwinia": "graph create --node https://thegraph-g2.darwinia.network/ormpipe/deploy/", - "remove:darwinia": "graph remove --node https://thegraph-g2.darwinia.network/ormpipe/deploy/", - "deploy:darwinia": "graph deploy --node https://thegraph-g2.darwinia.network/ormpipe/deploy/ --ipfs http://g2.generic.darwinia.network:5001/", + "deploy": "graph deploy --node https://api.studio.thegraph.com/deploy/ ormpipe", + "create-local": "graph create --node http://localhost:8020/ ormpipe", + "remove-local": "graph remove --node http://localhost:8020/ ormpipe", + "deploy-local": "graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 ormpipe", "test": "graph test" }, "dependencies": { diff --git a/thegraph/ormpipe/schema.graphql b/thegraph/ormpipe/schema.graphql index 38e915f..de3c254 100644 --- a/thegraph/ormpipe/schema.graphql +++ b/thegraph/ormpipe/schema.graphql @@ -1,7 +1,6 @@ +## === subapi -# --- airnode dpi - -type AirnodeDapiAddBeacon @entity(immutable: true) { +type AddBeacon @entity(immutable: true) { id: Bytes! beaconId: Bytes! # bytes32 beacon_airnode: Bytes! # address @@ -13,15 +12,16 @@ type AirnodeDapiAddBeacon @entity(immutable: true) { transactionHash: Bytes! } -type AirnodeDapiAggregatedMessageRoot @entity(immutable: true) { +type AggregatedORMPData @entity(immutable: true) { id: Bytes! - msgRoot: Bytes! # bytes32 + ormpData_count: BigInt! # uint256 + ormpData_root: Bytes! # bytes32 blockNumber: BigInt! blockTimestamp: BigInt! transactionHash: Bytes! } -type AirnodeDapiAirnodeRrpCompleted @entity(immutable: true) { +type AirnodeRrpCompleted @entity(immutable: true) { id: Bytes! beaconId: Bytes! # bytes32 requestId: Bytes! # bytes32 @@ -31,7 +31,7 @@ type AirnodeDapiAirnodeRrpCompleted @entity(immutable: true) { transactionHash: Bytes! } -type AirnodeDapiAirnodeRrpRequested @entity(immutable: true) { +type AirnodeRrpRequested @entity(immutable: true) { id: Bytes! beaconId: Bytes! # bytes32 requestId: Bytes! # bytes32 @@ -40,152 +40,40 @@ type AirnodeDapiAirnodeRrpRequested @entity(immutable: true) { transactionHash: Bytes! } -type AirnodeDapiRemoveBeacon @entity(immutable: true) { - id: Bytes! - beaconId: Bytes! # bytes32 - blockNumber: BigInt! - blockTimestamp: BigInt! - transactionHash: Bytes! -} - -# --- ormp protocol - -type OrmpProtocolAppConfigUpdated @entity(immutable: true) { - id: Bytes! - ua: Bytes! # address - oracle: Bytes! # address - relayer: Bytes! # address - blockNumber: BigInt! - blockTimestamp: BigInt! - transactionHash: Bytes! -} - -type OrmpProtocolClearFailedMessage @entity(immutable: true) { - id: Bytes! - msgHash: Bytes! # bytes32 - blockNumber: BigInt! - blockTimestamp: BigInt! - transactionHash: Bytes! -} - -type OrmpProtocolMessageAccepted @entity(immutable: true) { - id: Bytes! - msgHash: Bytes! # bytes32 - root: Bytes! # bytes32 - message_channel: Bytes! # address - message_index: BigInt! # uint256 - message_fromChainId: BigInt! # uint256 - message_from: Bytes! # address - message_toChainId: BigInt! # uint256 - message_to: Bytes! # address - message_encoded: Bytes! # bytes - blockNumber: BigInt! - blockTimestamp: BigInt! - transactionHash: Bytes! -} - -type OrmpProtocolMessageDispatched @entity(immutable: true) { +type OwnershipTransferStarted @entity(immutable: true) { id: Bytes! - msgHash: Bytes! # bytes32 - dispatchResult: Boolean! # bool + previousOwner: Bytes! # address + newOwner: Bytes! # address blockNumber: BigInt! blockTimestamp: BigInt! transactionHash: Bytes! } -type OrmpProtocolRetryFailedMessage @entity(immutable: true) { +type OwnershipTransferred @entity(immutable: true) { id: Bytes! - msgHash: Bytes! # bytes32 - dispatchResult: Boolean! # bool + previousOwner: Bytes! # address + newOwner: Bytes! # address blockNumber: BigInt! blockTimestamp: BigInt! transactionHash: Bytes! } -type OrmpProtocolSetDefaultConfig @entity(immutable: true) { +type RemoveBeacon @entity(immutable: true) { id: Bytes! - oracle: Bytes! # address - relayer: Bytes! # address - blockNumber: BigInt! - blockTimestamp: BigInt! - transactionHash: Bytes! -} - -## -- ormp oracle - -type OrmpOracleAssigned @entity(immutable: true) { - id: Bytes! - msgHash: Bytes! # bytes32 - fee: BigInt! # uint256 - blockNumber: BigInt! - blockTimestamp: BigInt! - transactionHash: Bytes! -} - -type OrmpOracleSetApproved @entity(immutable: true) { - id: Bytes! - operator: Bytes! # address - approve: Boolean! # bool - blockNumber: BigInt! - blockTimestamp: BigInt! - transactionHash: Bytes! -} - -type OrmpOracleSetDapi @entity(immutable: true) { - id: Bytes! - chainId: BigInt! # uint256 - dapi: Bytes! # address - blockNumber: BigInt! - blockTimestamp: BigInt! - transactionHash: Bytes! -} - -type OrmpOracleSetFee @entity(immutable: true) { - id: Bytes! - chainId: BigInt! # uint256 - fee: BigInt! # uint256 - blockNumber: BigInt! - blockTimestamp: BigInt! - transactionHash: Bytes! -} - -## -- ormp relayer -type OrmpRelayerAssigned @entity(immutable: true) { - id: Bytes! - msgHash: Bytes! # bytes32 - fee: BigInt! # uint256 - params: Bytes! # bytes - proof: [Bytes!]! # bytes32[32] - blockNumber: BigInt! - blockTimestamp: BigInt! - transactionHash: Bytes! -} - -type OrmpRelayerSetApproved @entity(immutable: true) { - id: Bytes! - operator: Bytes! # address - approve: Boolean! # bool + beaconId: Bytes! # bytes32 blockNumber: BigInt! blockTimestamp: BigInt! transactionHash: Bytes! } -type OrmpRelayerSetDstConfig @entity(immutable: true) { +type SubAPIFeedUpdated @entity(immutable: true) { id: Bytes! - chainId: BigInt! # uint256 - baseGas: BigInt! # uint64 - gasPerByte: BigInt! # uint64 + beaconId: Bytes! # bytes32 + msgRoot_count: BigInt! # uint256 + msgRoot_root: Bytes! # bytes32 blockNumber: BigInt! blockTimestamp: BigInt! transactionHash: Bytes! } -type OrmpRelayerSetDstPrice @entity(immutable: true) { - id: Bytes! - chainId: BigInt! # uint256 - dstPriceRatio: BigInt! # uint128 - dstGasPriceInWei: BigInt! # uint128 - blockNumber: BigInt! - blockTimestamp: BigInt! - transactionHash: Bytes! -} +## ========== ormp protocol diff --git a/thegraph/ormpipe/src/airnode-dapi.ts b/thegraph/ormpipe/src/airnode-dapi.ts deleted file mode 100644 index 8022c80..0000000 --- a/thegraph/ormpipe/src/airnode-dapi.ts +++ /dev/null @@ -1,92 +0,0 @@ -import { - AddBeacon as AddBeaconEvent, - AggregatedMessageRoot as AggregatedMessageRootEvent, - AirnodeRrpCompleted as AirnodeRrpCompletedEvent, - AirnodeRrpRequested as AirnodeRrpRequestedEvent, - RemoveBeacon as RemoveBeaconEvent -} from "../generated/AirnodeDapi/AirnodeDapi" -import { - AirnodeDapiAddBeacon, - AirnodeDapiAggregatedMessageRoot, - AirnodeDapiAirnodeRrpCompleted, - AirnodeDapiAirnodeRrpRequested, - AirnodeDapiRemoveBeacon -} from "../generated/schema" - -export function handleAddBeacon(event: AddBeaconEvent): void { - let entity = new AirnodeDapiAddBeacon( - event.transaction.hash.concatI32(event.logIndex.toI32()) - ) - entity.beaconId = event.params.beaconId - entity.beacon_airnode = event.params.beacon.airnode - entity.beacon_endpointId = event.params.beacon.endpointId - entity.beacon_sponsor = event.params.beacon.sponsor - entity.beacon_sponsorWallet = event.params.beacon.sponsorWallet - - entity.blockNumber = event.block.number - entity.blockTimestamp = event.block.timestamp - entity.transactionHash = event.transaction.hash - - entity.save() -} - -export function handleAggregatedMessageRoot( - event: AggregatedMessageRootEvent -): void { - let entity = new AirnodeDapiAggregatedMessageRoot( - event.transaction.hash.concatI32(event.logIndex.toI32()) - ) - entity.msgRoot = event.params.msgRoot - - entity.blockNumber = event.block.number - entity.blockTimestamp = event.block.timestamp - entity.transactionHash = event.transaction.hash - - entity.save() -} - -export function handleAirnodeRrpCompleted( - event: AirnodeRrpCompletedEvent -): void { - let entity = new AirnodeDapiAirnodeRrpCompleted( - event.transaction.hash.concatI32(event.logIndex.toI32()) - ) - entity.beaconId = event.params.beaconId - entity.requestId = event.params.requestId - entity.data = event.params.data - - entity.blockNumber = event.block.number - entity.blockTimestamp = event.block.timestamp - entity.transactionHash = event.transaction.hash - - entity.save() -} - -export function handleAirnodeRrpRequested( - event: AirnodeRrpRequestedEvent -): void { - let entity = new AirnodeDapiAirnodeRrpRequested( - event.transaction.hash.concatI32(event.logIndex.toI32()) - ) - entity.beaconId = event.params.beaconId - entity.requestId = event.params.requestId - - entity.blockNumber = event.block.number - entity.blockTimestamp = event.block.timestamp - entity.transactionHash = event.transaction.hash - - entity.save() -} - -export function handleRemoveBeacon(event: RemoveBeaconEvent): void { - let entity = new AirnodeDapiRemoveBeacon( - event.transaction.hash.concatI32(event.logIndex.toI32()) - ) - entity.beaconId = event.params.beaconId - - entity.blockNumber = event.block.number - entity.blockTimestamp = event.block.timestamp - entity.transactionHash = event.transaction.hash - - entity.save() -} diff --git a/thegraph/ormpipe/src/ormp-oracle.ts b/thegraph/ormpipe/src/ormp-oracle.ts deleted file mode 100644 index 744c053..0000000 --- a/thegraph/ormpipe/src/ormp-oracle.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { - Assigned as AssignedEvent, - SetApproved as SetApprovedEvent, - SetDapi as SetDapiEvent, - SetFee as SetFeeEvent -} from "../generated/OrmpOracle/OrmpOracle" -import {OrmpOracleAssigned, OrmpOracleSetApproved, OrmpOracleSetDapi, OrmpOracleSetFee} from "../generated/schema" - -export function handleAssigned(event: AssignedEvent): void { - let entity = new OrmpOracleAssigned( - event.transaction.hash.concatI32(event.logIndex.toI32()) - ) - entity.msgHash = event.params.msgHash - entity.fee = event.params.fee - - entity.blockNumber = event.block.number - entity.blockTimestamp = event.block.timestamp - entity.transactionHash = event.transaction.hash - - entity.save() -} - -export function handleSetApproved(event: SetApprovedEvent): void { - let entity = new OrmpOracleSetApproved( - event.transaction.hash.concatI32(event.logIndex.toI32()) - ) - entity.operator = event.params.operator - entity.approve = event.params.approve - - entity.blockNumber = event.block.number - entity.blockTimestamp = event.block.timestamp - entity.transactionHash = event.transaction.hash - - entity.save() -} - -export function handleSetDapi(event: SetDapiEvent): void { - let entity = new OrmpOracleSetDapi( - event.transaction.hash.concatI32(event.logIndex.toI32()) - ) - entity.chainId = event.params.chainId - entity.dapi = event.params.dapi - - entity.blockNumber = event.block.number - entity.blockTimestamp = event.block.timestamp - entity.transactionHash = event.transaction.hash - - entity.save() -} - -export function handleSetFee(event: SetFeeEvent): void { - let entity = new OrmpOracleSetFee( - event.transaction.hash.concatI32(event.logIndex.toI32()) - ) - entity.chainId = event.params.chainId - entity.fee = event.params.fee - - entity.blockNumber = event.block.number - entity.blockTimestamp = event.block.timestamp - entity.transactionHash = event.transaction.hash - - entity.save() -} diff --git a/thegraph/ormpipe/src/ormp-protocol.ts b/thegraph/ormpipe/src/ormp-protocol.ts deleted file mode 100644 index 46e4ee5..0000000 --- a/thegraph/ormpipe/src/ormp-protocol.ts +++ /dev/null @@ -1,107 +0,0 @@ -import { - AppConfigUpdated as AppConfigUpdatedEvent, - ClearFailedMessage as ClearFailedMessageEvent, - MessageAccepted as MessageAcceptedEvent, - MessageDispatched as MessageDispatchedEvent, - RetryFailedMessage as RetryFailedMessageEvent, - SetDefaultConfig as SetDefaultConfigEvent -} from "../generated/OrmpProtocol/OrmpProtocol" -import { - OrmpProtocolAppConfigUpdated, - OrmpProtocolClearFailedMessage, - OrmpProtocolMessageAccepted, - OrmpProtocolMessageDispatched, - OrmpProtocolRetryFailedMessage, - OrmpProtocolSetDefaultConfig -} from "../generated/schema" - -export function handleAppConfigUpdated(event: AppConfigUpdatedEvent): void { - let entity = new OrmpProtocolAppConfigUpdated( - event.transaction.hash.concatI32(event.logIndex.toI32()) - ) - entity.ua = event.params.ua - entity.oracle = event.params.oracle - entity.relayer = event.params.relayer - - entity.blockNumber = event.block.number - entity.blockTimestamp = event.block.timestamp - entity.transactionHash = event.transaction.hash - - entity.save() -} - -export function handleClearFailedMessage(event: ClearFailedMessageEvent): void { - let entity = new OrmpProtocolClearFailedMessage( - event.transaction.hash.concatI32(event.logIndex.toI32()) - ) - entity.msgHash = event.params.msgHash - - entity.blockNumber = event.block.number - entity.blockTimestamp = event.block.timestamp - entity.transactionHash = event.transaction.hash - - entity.save() -} - -export function handleMessageAccepted(event: MessageAcceptedEvent): void { - let entity = new OrmpProtocolMessageAccepted( - event.transaction.hash.concatI32(event.logIndex.toI32()) - ) - entity.msgHash = event.params.msgHash - entity.root = event.params.root - entity.message_channel = event.params.message.channel - entity.message_index = event.params.message.index - entity.message_fromChainId = event.params.message.fromChainId - entity.message_from = event.params.message.from - entity.message_toChainId = event.params.message.toChainId - entity.message_to = event.params.message.to - entity.message_encoded = event.params.message.encoded - - entity.blockNumber = event.block.number - entity.blockTimestamp = event.block.timestamp - entity.transactionHash = event.transaction.hash - - entity.save() -} - -export function handleMessageDispatched(event: MessageDispatchedEvent): void { - let entity = new OrmpProtocolMessageDispatched( - event.transaction.hash.concatI32(event.logIndex.toI32()) - ) - entity.msgHash = event.params.msgHash - entity.dispatchResult = event.params.dispatchResult - - entity.blockNumber = event.block.number - entity.blockTimestamp = event.block.timestamp - entity.transactionHash = event.transaction.hash - - entity.save() -} - -export function handleRetryFailedMessage(event: RetryFailedMessageEvent): void { - let entity = new OrmpProtocolRetryFailedMessage( - event.transaction.hash.concatI32(event.logIndex.toI32()) - ) - entity.msgHash = event.params.msgHash - entity.dispatchResult = event.params.dispatchResult - - entity.blockNumber = event.block.number - entity.blockTimestamp = event.block.timestamp - entity.transactionHash = event.transaction.hash - - entity.save() -} - -export function handleSetDefaultConfig(event: SetDefaultConfigEvent): void { - let entity = new OrmpProtocolSetDefaultConfig( - event.transaction.hash.concatI32(event.logIndex.toI32()) - ) - entity.oracle = event.params.oracle - entity.relayer = event.params.relayer - - entity.blockNumber = event.block.number - entity.blockTimestamp = event.block.timestamp - entity.transactionHash = event.transaction.hash - - entity.save() -} diff --git a/thegraph/ormpipe/src/ormp-relayer.ts b/thegraph/ormpipe/src/ormp-relayer.ts deleted file mode 100644 index b8a710c..0000000 --- a/thegraph/ormpipe/src/ormp-relayer.ts +++ /dev/null @@ -1,72 +0,0 @@ -import { - Assigned as AssignedEvent, - SetApproved as SetApprovedEvent, - SetDstConfig as SetDstConfigEvent, - SetDstPrice as SetDstPriceEvent -} from "../generated/OrmpRelayer/OrmpRelayer" -import { - OrmpRelayerAssigned, - OrmpRelayerSetApproved, - OrmpRelayerSetDstConfig, - OrmpRelayerSetDstPrice -} from "../generated/schema" - -export function handleAssigned(event: AssignedEvent): void { - let entity = new OrmpRelayerAssigned( - event.transaction.hash.concatI32(event.logIndex.toI32()) - ) - entity.msgHash = event.params.msgHash - entity.fee = event.params.fee - entity.params = event.params.params - entity.proof = event.params.proof - - entity.blockNumber = event.block.number - entity.blockTimestamp = event.block.timestamp - entity.transactionHash = event.transaction.hash - - entity.save() -} - -export function handleSetApproved(event: SetApprovedEvent): void { - let entity = new OrmpRelayerSetApproved( - event.transaction.hash.concatI32(event.logIndex.toI32()) - ) - entity.operator = event.params.operator - entity.approve = event.params.approve - - entity.blockNumber = event.block.number - entity.blockTimestamp = event.block.timestamp - entity.transactionHash = event.transaction.hash - - entity.save() -} - -export function handleSetDstConfig(event: SetDstConfigEvent): void { - let entity = new OrmpRelayerSetDstConfig( - event.transaction.hash.concatI32(event.logIndex.toI32()) - ) - entity.chainId = event.params.chainId - entity.baseGas = event.params.baseGas - entity.gasPerByte = event.params.gasPerByte - - entity.blockNumber = event.block.number - entity.blockTimestamp = event.block.timestamp - entity.transactionHash = event.transaction.hash - - entity.save() -} - -export function handleSetDstPrice(event: SetDstPriceEvent): void { - let entity = new OrmpRelayerSetDstPrice( - event.transaction.hash.concatI32(event.logIndex.toI32()) - ) - entity.chainId = event.params.chainId - entity.dstPriceRatio = event.params.dstPriceRatio - entity.dstGasPriceInWei = event.params.dstGasPriceInWei - - entity.blockNumber = event.block.number - entity.blockTimestamp = event.block.timestamp - entity.transactionHash = event.transaction.hash - - entity.save() -} diff --git a/thegraph/ormpipe/subgraph-arbitrum-goerli.yaml b/thegraph/ormpipe/subgraph-arbitrum-goerli.yaml deleted file mode 100644 index e48dd02..0000000 --- a/thegraph/ormpipe/subgraph-arbitrum-goerli.yaml +++ /dev/null @@ -1,130 +0,0 @@ -specVersion: 0.0.5 -schema: - file: ./schema.graphql -dataSources: - - kind: ethereum - name: AirnodeDapi - network: arbitrum-goerli - source: - address: "0xa681492DBAd5a3999cFCE2d72196d5784dd08D0c" - abi: AirnodeDapi - startBlock: 34570517 - mapping: - kind: ethereum/events - apiVersion: 0.0.7 - language: wasm/assemblyscript - entities: - - AirnodeDapiAddBeacon - - AirnodeDapiAggregatedMessageRoot - - AirnodeDapiAirnodeRrpCompleted - - AirnodeDapiAirnodeRrpRequested - - AirnodeDapiRemoveBeacon - abis: - - name: AirnodeDapi - file: ./abis/AirnodeDapi.json - eventHandlers: - - event: AddBeacon(indexed bytes32,(address,bytes32,address,address)) - handler: handleAddBeacon - - event: AggregatedMessageRoot(bytes32) - handler: handleAggregatedMessageRoot - - event: AirnodeRrpCompleted(indexed bytes32,indexed bytes32,bytes) - handler: handleAirnodeRrpCompleted - - event: AirnodeRrpRequested(indexed bytes32,indexed bytes32) - handler: handleAirnodeRrpRequested - - event: RemoveBeacon(indexed bytes32) - handler: handleRemoveBeacon - file: ./src/airnode-dapi.ts - - kind: ethereum - name: OrmpProtocol - network: arbitrum-goerli - source: - address: "0x0000000000BD9dcFDa5C60697039E2b3B28b079b" - abi: OrmpProtocol - startBlock: 37626207 - mapping: - kind: ethereum/events - apiVersion: 0.0.7 - language: wasm/assemblyscript - entities: - - OrmpProtocolAppConfigUpdated - - OrmpProtocolClearFailedMessage - - OrmpProtocolMessageAccepted - - OrmpProtocolMessageDispatched - - OrmpProtocolRetryFailedMessage - - OrmpProtocolSetDefaultConfig - abis: - - name: OrmpProtocol - file: ./abis/OrmpProtocol.json - eventHandlers: - - event: AppConfigUpdated(indexed address,address,address) - handler: handleAppConfigUpdated - - event: ClearFailedMessage(indexed bytes32) - handler: handleClearFailedMessage - - event: MessageAccepted(indexed - bytes32,bytes32,(address,uint256,uint256,address,uint256,address,bytes)) - handler: handleMessageAccepted - - event: MessageDispatched(indexed bytes32,bool) - handler: handleMessageDispatched - - event: RetryFailedMessage(indexed bytes32,bool) - handler: handleRetryFailedMessage - - event: SetDefaultConfig(address,address) - handler: handleSetDefaultConfig - file: ./src/ormp-protocol.ts - - kind: ethereum - name: OrmpOracle - network: arbitrum-goerli - source: - address: "0x000000003e2E2C9C8DD469E129E02E1666898E76" - abi: OrmpOracle - startBlock: 37626227 - mapping: - kind: ethereum/events - apiVersion: 0.0.7 - language: wasm/assemblyscript - entities: - - OrmpOracleAssigned - - OrmpOracleSetApproved - - OrmpOracleSetDapi - - OrmpOracleSetFee - abis: - - name: OrmpOracle - file: ./abis/OrmpOracle.json - eventHandlers: - - event: Assigned(indexed bytes32,uint256) - handler: handleAssigned - - event: SetApproved(address,bool) - handler: handleSetApproved - - event: SetDapi(indexed uint256,address) - handler: handleSetDapi - - event: SetFee(indexed uint256,uint256) - handler: handleSetFee - file: ./src/ormp-oracle.ts - - kind: ethereum - name: OrmpRelayer - network: arbitrum-goerli - source: - address: "0x000000007e24Da6666c773280804d8021E12e13F" - abi: OrmpRelayer - startBlock: 37626244 - mapping: - kind: ethereum/events - apiVersion: 0.0.7 - language: wasm/assemblyscript - entities: - - OrmpRelayerAssigned - - OrmpRelayerSetApproved - - OrmpRelayerSetDstConfig - - OrmpRelayerSetDstPrice - abis: - - name: OrmpRelayer - file: ./abis/OrmpRelayer.json - eventHandlers: - - event: Assigned(indexed bytes32,uint256,bytes,bytes32[32]) - handler: handleAssigned - - event: SetApproved(address,bool) - handler: handleSetApproved - - event: SetDstConfig(indexed uint256,uint64,uint64) - handler: handleSetDstConfig - - event: SetDstPrice(indexed uint256,uint128,uint128) - handler: handleSetDstPrice - file: ./src/ormp-relayer.ts diff --git a/thegraph/ormpipe/subgraph-pangolin.yaml b/thegraph/ormpipe/subgraph-pangolin.yaml deleted file mode 100644 index 90a7433..0000000 --- a/thegraph/ormpipe/subgraph-pangolin.yaml +++ /dev/null @@ -1,130 +0,0 @@ -specVersion: 0.0.5 -schema: - file: ./schema.graphql -dataSources: - - kind: ethereum - name: AirnodeDapi - network: pangolin - source: - address: "0x770713580e5c618A4D29D7E8c0d7604276B63832" - abi: AirnodeDapi - startBlock: 1285147 - mapping: - kind: ethereum/events - apiVersion: 0.0.7 - language: wasm/assemblyscript - entities: - - AirnodeDapiAddBeacon - - AirnodeDapiAggregatedMessageRoot - - AirnodeDapiAirnodeRrpCompleted - - AirnodeDapiAirnodeRrpRequested - - AirnodeDapiRemoveBeacon - abis: - - name: AirnodeDapi - file: ./abis/AirnodeDapi.json - eventHandlers: - - event: AddBeacon(indexed bytes32,(address,bytes32,address,address)) - handler: handleAddBeacon - - event: AggregatedMessageRoot(bytes32) - handler: handleAggregatedMessageRoot - - event: AirnodeRrpCompleted(indexed bytes32,indexed bytes32,bytes) - handler: handleAirnodeRrpCompleted - - event: AirnodeRrpRequested(indexed bytes32,indexed bytes32) - handler: handleAirnodeRrpRequested - - event: RemoveBeacon(indexed bytes32) - handler: handleRemoveBeacon - file: ./src/airnode-dapi.ts - - kind: ethereum - name: OrmpProtocol - network: pangolin - source: - address: "0x0000000000BD9dcFDa5C60697039E2b3B28b079b" - abi: OrmpProtocol - startBlock: 1367206 - mapping: - kind: ethereum/events - apiVersion: 0.0.7 - language: wasm/assemblyscript - entities: - - OrmpProtocolAppConfigUpdated - - OrmpProtocolClearFailedMessage - - OrmpProtocolMessageAccepted - - OrmpProtocolMessageDispatched - - OrmpProtocolRetryFailedMessage - - OrmpProtocolSetDefaultConfig - abis: - - name: OrmpProtocol - file: ./abis/OrmpProtocol.json - eventHandlers: - - event: AppConfigUpdated(indexed address,address,address) - handler: handleAppConfigUpdated - - event: ClearFailedMessage(indexed bytes32) - handler: handleClearFailedMessage - - event: MessageAccepted(indexed - bytes32,bytes32,(address,uint256,uint256,address,uint256,address,bytes)) - handler: handleMessageAccepted - - event: MessageDispatched(indexed bytes32,bool) - handler: handleMessageDispatched - - event: RetryFailedMessage(indexed bytes32,bool) - handler: handleRetryFailedMessage - - event: SetDefaultConfig(address,address) - handler: handleSetDefaultConfig - file: ./src/ormp-protocol.ts - - kind: ethereum - name: OrmpOracle - network: pangolin - source: - address: "0x000000003e2E2C9C8DD469E129E02E1666898E76" - abi: OrmpOracle - startBlock: 1367206 - mapping: - kind: ethereum/events - apiVersion: 0.0.7 - language: wasm/assemblyscript - entities: - - OrmpOracleAssigned - - OrmpOracleSetApproved - - OrmpOracleSetDapi - - OrmpOracleSetFee - abis: - - name: OrmpOracle - file: ./abis/OrmpOracle.json - eventHandlers: - - event: Assigned(indexed bytes32,uint256) - handler: handleAssigned - - event: SetApproved(address,bool) - handler: handleSetApproved - - event: SetDapi(indexed uint256,address) - handler: handleSetDapi - - event: SetFee(indexed uint256,uint256) - handler: handleSetFee - file: ./src/ormp-oracle.ts - - kind: ethereum - name: OrmpRelayer - network: pangolin - source: - address: "0x000000007e24Da6666c773280804d8021E12e13F" - abi: OrmpRelayer - startBlock: 1367206 - mapping: - kind: ethereum/events - apiVersion: 0.0.7 - language: wasm/assemblyscript - entities: - - OrmpRelayerAssigned - - OrmpRelayerSetApproved - - OrmpRelayerSetDstConfig - - OrmpRelayerSetDstPrice - abis: - - name: OrmpRelayer - file: ./abis/OrmpRelayer.json - eventHandlers: - - event: Assigned(indexed bytes32,uint256,bytes,bytes32[32]) - handler: handleAssigned - - event: SetApproved(address,bool) - handler: handleSetApproved - - event: SetDstConfig(indexed uint256,uint64,uint64) - handler: handleSetDstConfig - - event: SetDstPrice(indexed uint256,uint128,uint128) - handler: handleSetDstPrice - file: ./src/ormp-relayer.ts diff --git a/thegraph/ormpipe/tests/airnode-dapi-utils.ts b/thegraph/ormpipe/tests/airnode-dapi-utils.ts deleted file mode 100644 index ec6083a..0000000 --- a/thegraph/ormpipe/tests/airnode-dapi-utils.ts +++ /dev/null @@ -1,170 +0,0 @@ -import { newMockEvent } from "matchstick-as" -import { ethereum, Bytes, Address } from "@graphprotocol/graph-ts" -import { - AddBeacon, - AggregatedMessageRoot, - AirnodeMessageRootFeedUpdated, - AirnodeRrpCompleted, - AirnodeRrpRequested, - OwnershipTransferStarted, - OwnershipTransferred, - RemoveBeacon -} from "../generated/AirnodeDapi/AirnodeDapi" - -export function createAddBeaconEvent( - beaconId: Bytes, - beacon: ethereum.Tuple -): AddBeacon { - let addBeaconEvent = changetype(newMockEvent()) - - addBeaconEvent.parameters = new Array() - - addBeaconEvent.parameters.push( - new ethereum.EventParam("beaconId", ethereum.Value.fromFixedBytes(beaconId)) - ) - addBeaconEvent.parameters.push( - new ethereum.EventParam("beacon", ethereum.Value.fromTuple(beacon)) - ) - - return addBeaconEvent -} - -export function createAggregatedMessageRootEvent( - msgRoot: Bytes -): AggregatedMessageRoot { - let aggregatedMessageRootEvent = changetype( - newMockEvent() - ) - - aggregatedMessageRootEvent.parameters = new Array() - - aggregatedMessageRootEvent.parameters.push( - new ethereum.EventParam("msgRoot", ethereum.Value.fromFixedBytes(msgRoot)) - ) - - return aggregatedMessageRootEvent -} - -export function createAirnodeMessageRootFeedUpdatedEvent( - beaconId: Bytes, - msgRoot: Bytes -): AirnodeMessageRootFeedUpdated { - let airnodeMessageRootFeedUpdatedEvent = changetype< - AirnodeMessageRootFeedUpdated - >(newMockEvent()) - - airnodeMessageRootFeedUpdatedEvent.parameters = new Array() - - airnodeMessageRootFeedUpdatedEvent.parameters.push( - new ethereum.EventParam("beaconId", ethereum.Value.fromFixedBytes(beaconId)) - ) - airnodeMessageRootFeedUpdatedEvent.parameters.push( - new ethereum.EventParam("msgRoot", ethereum.Value.fromFixedBytes(msgRoot)) - ) - - return airnodeMessageRootFeedUpdatedEvent -} - -export function createAirnodeRrpCompletedEvent( - beaconId: Bytes, - requestId: Bytes, - data: Bytes -): AirnodeRrpCompleted { - let airnodeRrpCompletedEvent = changetype(newMockEvent()) - - airnodeRrpCompletedEvent.parameters = new Array() - - airnodeRrpCompletedEvent.parameters.push( - new ethereum.EventParam("beaconId", ethereum.Value.fromFixedBytes(beaconId)) - ) - airnodeRrpCompletedEvent.parameters.push( - new ethereum.EventParam( - "requestId", - ethereum.Value.fromFixedBytes(requestId) - ) - ) - airnodeRrpCompletedEvent.parameters.push( - new ethereum.EventParam("data", ethereum.Value.fromBytes(data)) - ) - - return airnodeRrpCompletedEvent -} - -export function createAirnodeRrpRequestedEvent( - beaconId: Bytes, - requestId: Bytes -): AirnodeRrpRequested { - let airnodeRrpRequestedEvent = changetype(newMockEvent()) - - airnodeRrpRequestedEvent.parameters = new Array() - - airnodeRrpRequestedEvent.parameters.push( - new ethereum.EventParam("beaconId", ethereum.Value.fromFixedBytes(beaconId)) - ) - airnodeRrpRequestedEvent.parameters.push( - new ethereum.EventParam( - "requestId", - ethereum.Value.fromFixedBytes(requestId) - ) - ) - - return airnodeRrpRequestedEvent -} - -export function createOwnershipTransferStartedEvent( - previousOwner: Address, - newOwner: Address -): OwnershipTransferStarted { - let ownershipTransferStartedEvent = changetype( - newMockEvent() - ) - - ownershipTransferStartedEvent.parameters = new Array() - - ownershipTransferStartedEvent.parameters.push( - new ethereum.EventParam( - "previousOwner", - ethereum.Value.fromAddress(previousOwner) - ) - ) - ownershipTransferStartedEvent.parameters.push( - new ethereum.EventParam("newOwner", ethereum.Value.fromAddress(newOwner)) - ) - - return ownershipTransferStartedEvent -} - -export function createOwnershipTransferredEvent( - previousOwner: Address, - newOwner: Address -): OwnershipTransferred { - let ownershipTransferredEvent = changetype( - newMockEvent() - ) - - ownershipTransferredEvent.parameters = new Array() - - ownershipTransferredEvent.parameters.push( - new ethereum.EventParam( - "previousOwner", - ethereum.Value.fromAddress(previousOwner) - ) - ) - ownershipTransferredEvent.parameters.push( - new ethereum.EventParam("newOwner", ethereum.Value.fromAddress(newOwner)) - ) - - return ownershipTransferredEvent -} - -export function createRemoveBeaconEvent(beaconId: Bytes): RemoveBeacon { - let removeBeaconEvent = changetype(newMockEvent()) - - removeBeaconEvent.parameters = new Array() - - removeBeaconEvent.parameters.push( - new ethereum.EventParam("beaconId", ethereum.Value.fromFixedBytes(beaconId)) - ) - - return removeBeaconEvent -} diff --git a/thegraph/ormpipe/tests/airnode-dapi.test.ts b/thegraph/ormpipe/tests/airnode-dapi.test.ts deleted file mode 100644 index cc5ec05..0000000 --- a/thegraph/ormpipe/tests/airnode-dapi.test.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { - assert, - describe, - test, - clearStore, - beforeAll, - afterAll -} from "matchstick-as/assembly/index" -import { Bytes, Address } from "@graphprotocol/graph-ts" -import { AirnodeDapiAddBeacon } from "../generated/schema" -import { AddBeacon as AddBeaconEvent } from "../generated/AirnodeDapi/AirnodeDapi" -import { handleAddBeacon } from "../src/airnode-dapi" -import { createAddBeaconEvent } from "./airnode-dapi-utils" - -// Tests structure (matchstick-as >=0.5.0) -// https://thegraph.com/docs/en/developer/matchstick/#tests-structure-0-5-0 - -describe("Describe entity assertions", () => { - beforeAll(() => { - let beaconId = Bytes.fromI32(1234567890) - let beacon = "ethereum.Tuple Not implemented" - let newAddBeaconEvent = createAddBeaconEvent(beaconId, beacon) - handleAddBeacon(newAddBeaconEvent) - }) - - afterAll(() => { - clearStore() - }) - - // For more test scenarios, see: - // https://thegraph.com/docs/en/developer/matchstick/#write-a-unit-test - - test("AddBeacon created and stored", () => { - assert.entityCount("AddBeacon", 1) - - // 0xa16081f360e3847006db660bae1c6d1b2e17ec2a is the default address used in newMockEvent() function - assert.fieldEquals( - "AddBeacon", - "0xa16081f360e3847006db660bae1c6d1b2e17ec2a-1", - "beaconId", - "1234567890" - ) - assert.fieldEquals( - "AddBeacon", - "0xa16081f360e3847006db660bae1c6d1b2e17ec2a-1", - "beacon", - "ethereum.Tuple Not implemented" - ) - - // More assert options: - // https://thegraph.com/docs/en/developer/matchstick/#asserts - }) -}) diff --git a/thegraph/ormpipe/tests/ormp-oracle-utils.ts b/thegraph/ormpipe/tests/ormp-oracle-utils.ts deleted file mode 100644 index 85e570e..0000000 --- a/thegraph/ormpipe/tests/ormp-oracle-utils.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { newMockEvent } from "matchstick-as" -import { ethereum, Bytes, BigInt, Address } from "@graphprotocol/graph-ts" -import { - Assigned, - SetApproved, - SetDapi, - SetFee -} from "../generated/OrmpOracle/OrmpOracle" - -export function createAssignedEvent(msgHash: Bytes, fee: BigInt): Assigned { - let assignedEvent = changetype(newMockEvent()) - - assignedEvent.parameters = new Array() - - assignedEvent.parameters.push( - new ethereum.EventParam("msgHash", ethereum.Value.fromFixedBytes(msgHash)) - ) - assignedEvent.parameters.push( - new ethereum.EventParam("fee", ethereum.Value.fromUnsignedBigInt(fee)) - ) - - return assignedEvent -} - -export function createSetApprovedEvent( - operator: Address, - approve: boolean -): SetApproved { - let setApprovedEvent = changetype(newMockEvent()) - - setApprovedEvent.parameters = new Array() - - setApprovedEvent.parameters.push( - new ethereum.EventParam("operator", ethereum.Value.fromAddress(operator)) - ) - setApprovedEvent.parameters.push( - new ethereum.EventParam("approve", ethereum.Value.fromBoolean(approve)) - ) - - return setApprovedEvent -} - -export function createSetDapiEvent(chainId: BigInt, dapi: Address): SetDapi { - let setDapiEvent = changetype(newMockEvent()) - - setDapiEvent.parameters = new Array() - - setDapiEvent.parameters.push( - new ethereum.EventParam( - "chainId", - ethereum.Value.fromUnsignedBigInt(chainId) - ) - ) - setDapiEvent.parameters.push( - new ethereum.EventParam("dapi", ethereum.Value.fromAddress(dapi)) - ) - - return setDapiEvent -} - -export function createSetFeeEvent(chainId: BigInt, fee: BigInt): SetFee { - let setFeeEvent = changetype(newMockEvent()) - - setFeeEvent.parameters = new Array() - - setFeeEvent.parameters.push( - new ethereum.EventParam( - "chainId", - ethereum.Value.fromUnsignedBigInt(chainId) - ) - ) - setFeeEvent.parameters.push( - new ethereum.EventParam("fee", ethereum.Value.fromUnsignedBigInt(fee)) - ) - - return setFeeEvent -} diff --git a/thegraph/ormpipe/tests/ormp-oracle.test.ts b/thegraph/ormpipe/tests/ormp-oracle.test.ts deleted file mode 100644 index 2214338..0000000 --- a/thegraph/ormpipe/tests/ormp-oracle.test.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { - assert, - describe, - test, - clearStore, - beforeAll, - afterAll -} from "matchstick-as/assembly/index" -import { Bytes, BigInt, Address } from "@graphprotocol/graph-ts" -import { OrmpOracleAssigned } from "../generated/schema" -import { Assigned as AssignedEvent } from "../generated/OrmpOracle/OrmpOracle" -import { handleAssigned } from "../src/ormp-oracle" -import { createAssignedEvent } from "./ormp-oracle-utils" - -// Tests structure (matchstick-as >=0.5.0) -// https://thegraph.com/docs/en/developer/matchstick/#tests-structure-0-5-0 - -describe("Describe entity assertions", () => { - beforeAll(() => { - let msgHash = Bytes.fromI32(1234567890) - let fee = BigInt.fromI32(234) - let newAssignedEvent = createAssignedEvent(msgHash, fee) - handleAssigned(newAssignedEvent) - }) - - afterAll(() => { - clearStore() - }) - - // For more test scenarios, see: - // https://thegraph.com/docs/en/developer/matchstick/#write-a-unit-test - - test("Assigned created and stored", () => { - assert.entityCount("Assigned", 1) - - // 0xa16081f360e3847006db660bae1c6d1b2e17ec2a is the default address used in newMockEvent() function - assert.fieldEquals( - "Assigned", - "0xa16081f360e3847006db660bae1c6d1b2e17ec2a-1", - "msgHash", - "1234567890" - ) - assert.fieldEquals( - "Assigned", - "0xa16081f360e3847006db660bae1c6d1b2e17ec2a-1", - "fee", - "234" - ) - - // More assert options: - // https://thegraph.com/docs/en/developer/matchstick/#asserts - }) -}) diff --git a/thegraph/ormpipe/tests/ormp-protocol-utils.ts b/thegraph/ormpipe/tests/ormp-protocol-utils.ts deleted file mode 100644 index 1296885..0000000 --- a/thegraph/ormpipe/tests/ormp-protocol-utils.ts +++ /dev/null @@ -1,128 +0,0 @@ -import { newMockEvent } from "matchstick-as" -import { ethereum, Address, Bytes } from "@graphprotocol/graph-ts" -import { - AppConfigUpdated, - ClearFailedMessage, - MessageAccepted, - MessageDispatched, - RetryFailedMessage, - SetDefaultConfig -} from "../generated/OrmpProtocol/OrmpProtocol" - -export function createAppConfigUpdatedEvent( - ua: Address, - oracle: Address, - relayer: Address -): AppConfigUpdated { - let appConfigUpdatedEvent = changetype(newMockEvent()) - - appConfigUpdatedEvent.parameters = new Array() - - appConfigUpdatedEvent.parameters.push( - new ethereum.EventParam("ua", ethereum.Value.fromAddress(ua)) - ) - appConfigUpdatedEvent.parameters.push( - new ethereum.EventParam("oracle", ethereum.Value.fromAddress(oracle)) - ) - appConfigUpdatedEvent.parameters.push( - new ethereum.EventParam("relayer", ethereum.Value.fromAddress(relayer)) - ) - - return appConfigUpdatedEvent -} - -export function createClearFailedMessageEvent( - msgHash: Bytes -): ClearFailedMessage { - let clearFailedMessageEvent = changetype(newMockEvent()) - - clearFailedMessageEvent.parameters = new Array() - - clearFailedMessageEvent.parameters.push( - new ethereum.EventParam("msgHash", ethereum.Value.fromFixedBytes(msgHash)) - ) - - return clearFailedMessageEvent -} - -export function createMessageAcceptedEvent( - msgHash: Bytes, - root: Bytes, - message: ethereum.Tuple -): MessageAccepted { - let messageAcceptedEvent = changetype(newMockEvent()) - - messageAcceptedEvent.parameters = new Array() - - messageAcceptedEvent.parameters.push( - new ethereum.EventParam("msgHash", ethereum.Value.fromFixedBytes(msgHash)) - ) - messageAcceptedEvent.parameters.push( - new ethereum.EventParam("root", ethereum.Value.fromFixedBytes(root)) - ) - messageAcceptedEvent.parameters.push( - new ethereum.EventParam("message", ethereum.Value.fromTuple(message)) - ) - - return messageAcceptedEvent -} - -export function createMessageDispatchedEvent( - msgHash: Bytes, - dispatchResult: boolean -): MessageDispatched { - let messageDispatchedEvent = changetype(newMockEvent()) - - messageDispatchedEvent.parameters = new Array() - - messageDispatchedEvent.parameters.push( - new ethereum.EventParam("msgHash", ethereum.Value.fromFixedBytes(msgHash)) - ) - messageDispatchedEvent.parameters.push( - new ethereum.EventParam( - "dispatchResult", - ethereum.Value.fromBoolean(dispatchResult) - ) - ) - - return messageDispatchedEvent -} - -export function createRetryFailedMessageEvent( - msgHash: Bytes, - dispatchResult: boolean -): RetryFailedMessage { - let retryFailedMessageEvent = changetype(newMockEvent()) - - retryFailedMessageEvent.parameters = new Array() - - retryFailedMessageEvent.parameters.push( - new ethereum.EventParam("msgHash", ethereum.Value.fromFixedBytes(msgHash)) - ) - retryFailedMessageEvent.parameters.push( - new ethereum.EventParam( - "dispatchResult", - ethereum.Value.fromBoolean(dispatchResult) - ) - ) - - return retryFailedMessageEvent -} - -export function createSetDefaultConfigEvent( - oracle: Address, - relayer: Address -): SetDefaultConfig { - let setDefaultConfigEvent = changetype(newMockEvent()) - - setDefaultConfigEvent.parameters = new Array() - - setDefaultConfigEvent.parameters.push( - new ethereum.EventParam("oracle", ethereum.Value.fromAddress(oracle)) - ) - setDefaultConfigEvent.parameters.push( - new ethereum.EventParam("relayer", ethereum.Value.fromAddress(relayer)) - ) - - return setDefaultConfigEvent -} diff --git a/thegraph/ormpipe/tests/ormp-protocol.test.ts b/thegraph/ormpipe/tests/ormp-protocol.test.ts deleted file mode 100644 index f579a50..0000000 --- a/thegraph/ormpipe/tests/ormp-protocol.test.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { - assert, - describe, - test, - clearStore, - beforeAll, - afterAll -} from "matchstick-as/assembly/index" -import { Address, Bytes } from "@graphprotocol/graph-ts" -import { OrmpProtocolAppConfigUpdated } from "../generated/schema" -import { AppConfigUpdated as AppConfigUpdatedEvent } from "../generated/OrmpProtocol/OrmpProtocol" -import { handleAppConfigUpdated } from "../src/ormp-protocol" -import { createAppConfigUpdatedEvent } from "./ormp-protocol-utils" - -// Tests structure (matchstick-as >=0.5.0) -// https://thegraph.com/docs/en/developer/matchstick/#tests-structure-0-5-0 - -describe("Describe entity assertions", () => { - beforeAll(() => { - let ua = Address.fromString("0x0000000000000000000000000000000000000001") - let oracle = Address.fromString( - "0x0000000000000000000000000000000000000001" - ) - let relayer = Address.fromString( - "0x0000000000000000000000000000000000000001" - ) - let newAppConfigUpdatedEvent = createAppConfigUpdatedEvent( - ua, - oracle, - relayer - ) - handleAppConfigUpdated(newAppConfigUpdatedEvent) - }) - - afterAll(() => { - clearStore() - }) - - // For more test scenarios, see: - // https://thegraph.com/docs/en/developer/matchstick/#write-a-unit-test - - test("AppConfigUpdated created and stored", () => { - assert.entityCount("AppConfigUpdated", 1) - - // 0xa16081f360e3847006db660bae1c6d1b2e17ec2a is the default address used in newMockEvent() function - assert.fieldEquals( - "AppConfigUpdated", - "0xa16081f360e3847006db660bae1c6d1b2e17ec2a-1", - "ua", - "0x0000000000000000000000000000000000000001" - ) - assert.fieldEquals( - "AppConfigUpdated", - "0xa16081f360e3847006db660bae1c6d1b2e17ec2a-1", - "oracle", - "0x0000000000000000000000000000000000000001" - ) - assert.fieldEquals( - "AppConfigUpdated", - "0xa16081f360e3847006db660bae1c6d1b2e17ec2a-1", - "relayer", - "0x0000000000000000000000000000000000000001" - ) - - // More assert options: - // https://thegraph.com/docs/en/developer/matchstick/#asserts - }) -}) diff --git a/thegraph/ormpipe/tests/ormp-relayer-utils.ts b/thegraph/ormpipe/tests/ormp-relayer-utils.ts deleted file mode 100644 index c188173..0000000 --- a/thegraph/ormpipe/tests/ormp-relayer-utils.ts +++ /dev/null @@ -1,114 +0,0 @@ -import { newMockEvent } from "matchstick-as" -import { ethereum, Bytes, BigInt, Address } from "@graphprotocol/graph-ts" -import { - Assigned, - SetApproved, - SetDstConfig, - SetDstPrice -} from "../generated/OrmpRelayer/OrmpRelayer" - -export function createAssignedEvent( - msgHash: Bytes, - fee: BigInt, - params: Bytes, - proof: Array -): Assigned { - let assignedEvent = changetype(newMockEvent()) - - assignedEvent.parameters = new Array() - - assignedEvent.parameters.push( - new ethereum.EventParam("msgHash", ethereum.Value.fromFixedBytes(msgHash)) - ) - assignedEvent.parameters.push( - new ethereum.EventParam("fee", ethereum.Value.fromUnsignedBigInt(fee)) - ) - assignedEvent.parameters.push( - new ethereum.EventParam("params", ethereum.Value.fromBytes(params)) - ) - assignedEvent.parameters.push( - new ethereum.EventParam("proof", ethereum.Value.fromFixedBytesArray(proof)) - ) - - return assignedEvent -} - -export function createSetApprovedEvent( - operator: Address, - approve: boolean -): SetApproved { - let setApprovedEvent = changetype(newMockEvent()) - - setApprovedEvent.parameters = new Array() - - setApprovedEvent.parameters.push( - new ethereum.EventParam("operator", ethereum.Value.fromAddress(operator)) - ) - setApprovedEvent.parameters.push( - new ethereum.EventParam("approve", ethereum.Value.fromBoolean(approve)) - ) - - return setApprovedEvent -} - -export function createSetDstConfigEvent( - chainId: BigInt, - baseGas: BigInt, - gasPerByte: BigInt -): SetDstConfig { - let setDstConfigEvent = changetype(newMockEvent()) - - setDstConfigEvent.parameters = new Array() - - setDstConfigEvent.parameters.push( - new ethereum.EventParam( - "chainId", - ethereum.Value.fromUnsignedBigInt(chainId) - ) - ) - setDstConfigEvent.parameters.push( - new ethereum.EventParam( - "baseGas", - ethereum.Value.fromUnsignedBigInt(baseGas) - ) - ) - setDstConfigEvent.parameters.push( - new ethereum.EventParam( - "gasPerByte", - ethereum.Value.fromUnsignedBigInt(gasPerByte) - ) - ) - - return setDstConfigEvent -} - -export function createSetDstPriceEvent( - chainId: BigInt, - dstPriceRatio: BigInt, - dstGasPriceInWei: BigInt -): SetDstPrice { - let setDstPriceEvent = changetype(newMockEvent()) - - setDstPriceEvent.parameters = new Array() - - setDstPriceEvent.parameters.push( - new ethereum.EventParam( - "chainId", - ethereum.Value.fromUnsignedBigInt(chainId) - ) - ) - setDstPriceEvent.parameters.push( - new ethereum.EventParam( - "dstPriceRatio", - ethereum.Value.fromUnsignedBigInt(dstPriceRatio) - ) - ) - setDstPriceEvent.parameters.push( - new ethereum.EventParam( - "dstGasPriceInWei", - ethereum.Value.fromUnsignedBigInt(dstGasPriceInWei) - ) - ) - - return setDstPriceEvent -} diff --git a/thegraph/ormpipe/tests/ormp-relayer.test.ts b/thegraph/ormpipe/tests/ormp-relayer.test.ts deleted file mode 100644 index 36e1cb1..0000000 --- a/thegraph/ormpipe/tests/ormp-relayer.test.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { - assert, - describe, - test, - clearStore, - beforeAll, - afterAll -} from "matchstick-as/assembly/index" -import { Bytes, BigInt, Address } from "@graphprotocol/graph-ts" -import { OrmpRelayerAssigned } from "../generated/schema" -import { Assigned as AssignedEvent } from "../generated/OrmpRelayer/OrmpRelayer" -import { handleAssigned } from "../src/ormp-relayer" -import { createAssignedEvent } from "./ormp-relayer-utils" - -// Tests structure (matchstick-as >=0.5.0) -// https://thegraph.com/docs/en/developer/matchstick/#tests-structure-0-5-0 - -describe("Describe entity assertions", () => { - beforeAll(() => { - let msgHash = Bytes.fromI32(1234567890) - let fee = BigInt.fromI32(234) - let params = Bytes.fromI32(1234567890) - let proof = [Bytes.fromI32(1234567890)] - let newAssignedEvent = createAssignedEvent(msgHash, fee, params, proof) - handleAssigned(newAssignedEvent) - }) - - afterAll(() => { - clearStore() - }) - - // For more test scenarios, see: - // https://thegraph.com/docs/en/developer/matchstick/#write-a-unit-test - - test("Assigned created and stored", () => { - assert.entityCount("Assigned", 1) - - // 0xa16081f360e3847006db660bae1c6d1b2e17ec2a is the default address used in newMockEvent() function - assert.fieldEquals( - "Assigned", - "0xa16081f360e3847006db660bae1c6d1b2e17ec2a-1", - "msgHash", - "1234567890" - ) - assert.fieldEquals( - "Assigned", - "0xa16081f360e3847006db660bae1c6d1b2e17ec2a-1", - "fee", - "234" - ) - assert.fieldEquals( - "Assigned", - "0xa16081f360e3847006db660bae1c6d1b2e17ec2a-1", - "params", - "1234567890" - ) - assert.fieldEquals( - "Assigned", - "0xa16081f360e3847006db660bae1c6d1b2e17ec2a-1", - "proof", - "[1234567890]" - ) - - // More assert options: - // https://thegraph.com/docs/en/developer/matchstick/#asserts - }) -}) diff --git a/thegraph/ormpipe/yarn.lock b/thegraph/ormpipe/yarn.lock index 950e2ad..5cd6cad 100644 --- a/thegraph/ormpipe/yarn.lock +++ b/thegraph/ormpipe/yarn.lock @@ -3,24 +3,24 @@ "@babel/code-frame@^7.0.0": - version "7.22.10" - resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.22.10.tgz#1c20e612b768fefa75f6e90d6ecb86329247f0a3" - integrity sha512-/KKIMG4UEL35WmI9OlvMhurwtytjvXoFcGNrOvyG9zIzA8YmPjVtIZUf7b05+TPO7G7/GEmLHDaoCgACHl9hhA== + version "7.22.13" + resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.22.13.tgz#e3c1c099402598483b7a8c46a721d1038803755e" + integrity sha512-XktuhWlJ5g+3TJXc5upd9Ks1HutSArik6jf2eAjYFyIOf4ej3RN+184cZbzDvbPnuTJIUhPKKJE3cIsYTiAT3w== dependencies: - "@babel/highlight" "^7.22.10" + "@babel/highlight" "^7.22.13" chalk "^2.4.2" -"@babel/helper-validator-identifier@^7.22.5": - version "7.22.5" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.5.tgz#9544ef6a33999343c8740fa51350f30eeaaaf193" - integrity sha512-aJXu+6lErq8ltp+JhkJUfk1MTGyuA4v7f3pA+BJ5HLfNC6nAQ0Cpi9uOquUj8Hehg0aUiHzWQbOVJGao6ztBAQ== +"@babel/helper-validator-identifier@^7.22.20": + version "7.22.20" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz#c4ae002c61d2879e724581d96665583dbc1dc0e0" + integrity sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A== -"@babel/highlight@^7.22.10": - version "7.22.10" - resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.22.10.tgz#02a3f6d8c1cb4521b2fd0ab0da8f4739936137d7" - integrity sha512-78aUtVcT7MUscr0K5mIEnkwxPE0MaxkR5RxRwuHaQ+JuU5AmTPhY+do2mdzVTnIJJpyBglql2pehuBIWHug+WQ== +"@babel/highlight@^7.22.13": + version "7.22.20" + resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.22.20.tgz#4ca92b71d80554b01427815e06f2df965b9c1f54" + integrity sha512-dkdMCN3py0+ksCgYmGG8jKeGA/8Tk+gJwSYYlFGxG5lmhfKNoAy004YpLxpS1W2J8m/EK2Ew+yOs9pVRwO89mg== dependencies: - "@babel/helper-validator-identifier" "^7.22.5" + "@babel/helper-validator-identifier" "^7.22.20" chalk "^2.4.2" js-tokens "^4.0.0" @@ -362,13 +362,13 @@ wrap-ansi "^7.0.0" "@peculiar/asn1-schema@^2.3.6": - version "2.3.6" - resolved "https://registry.yarnpkg.com/@peculiar/asn1-schema/-/asn1-schema-2.3.6.tgz#3dd3c2ade7f702a9a94dfb395c192f5fa5d6b922" - integrity sha512-izNRxPoaeJeg/AyH8hER6s+H7p4itk+03QCa4sbxI3lNdseQYCuxzgsuNK8bTXChtLTjpJz6NmXKA73qLa3rCA== + version "2.3.8" + resolved "https://registry.yarnpkg.com/@peculiar/asn1-schema/-/asn1-schema-2.3.8.tgz#04b38832a814e25731232dd5be883460a156da3b" + integrity sha512-ULB1XqHKx1WBU/tTFIA+uARuRoBVZ4pNdOA878RDrRbBfBGcSzi5HBkdScC6ZbHn8z7L8gmKCgPC1LHRrP46tA== dependencies: asn1js "^3.0.5" - pvtsutils "^1.3.2" - tslib "^2.4.0" + pvtsutils "^1.3.5" + tslib "^2.6.2" "@peculiar/json-schema@^1.1.12": version "1.1.12" @@ -467,16 +467,16 @@ integrity sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA== "@types/bn.js@^5.1.0": - version "5.1.1" - resolved "https://registry.yarnpkg.com/@types/bn.js/-/bn.js-5.1.1.tgz#b51e1b55920a4ca26e9285ff79936bbdec910682" - integrity sha512-qNrYbZqMx0uJAfKnKclPh+dTwK33KfLHYqtyODwd5HnXOjnkhc4qgn3BrK6RWyGZm5+sIFE7Q7Vz6QQtJB7w7g== + version "5.1.3" + resolved "https://registry.yarnpkg.com/@types/bn.js/-/bn.js-5.1.3.tgz#0857f00da3bf888a26a44b4a477c7819b17dacc5" + integrity sha512-wT1B4iIO82ecXkdN6waCK8Ou7E71WU+mP1osDA5Q8c6Ur+ozU2vIKUIhSpUr6uE5L2YHocKS1Z2jG2fBC1YVeg== dependencies: "@types/node" "*" "@types/cli-progress@^3.11.0": - version "3.11.0" - resolved "https://registry.yarnpkg.com/@types/cli-progress/-/cli-progress-3.11.0.tgz#ec79df99b26757c3d1c7170af8422e0fc95eef7e" - integrity sha512-XhXhBv1R/q2ahF3BM7qT5HLzJNlIL0wbcGyZVjqOTqAybAnsLisd7gy1UCyIqpL+5Iv6XhlSyzjLCnI2sIdbCg== + version "3.11.4" + resolved "https://registry.yarnpkg.com/@types/cli-progress/-/cli-progress-3.11.4.tgz#58d9e60bd5fd85a57984890ef9c9d831a0dda896" + integrity sha512-yufTxeeNCZuEIxx2uebK8lpSAsJM4lvzakm/VxzYhDtqhXCzwH9jpn7nPCxzrROuEbLATqhFq4MIPoG0tlrsvw== dependencies: "@types/node" "*" @@ -488,9 +488,9 @@ "@types/node" "*" "@types/connect@^3.4.33": - version "3.4.35" - resolved "https://registry.yarnpkg.com/@types/connect/-/connect-3.4.35.tgz#5fcf6ae445e4021d1fc2219a4873cc73a3bb2ad1" - integrity sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ== + version "3.4.37" + resolved "https://registry.yarnpkg.com/@types/connect/-/connect-3.4.37.tgz#c66a96689fd3127c8772eb3e9e5c6028ec1a9af5" + integrity sha512-zBUSRqkfZ59OcwXon4HVxhx5oWCJmc0OtBTK05M+p0dYjgN6iTwIL2T/WbsQZrEsdnwaF9cWQ+azOnpPvIqY3Q== dependencies: "@types/node" "*" @@ -512,9 +512,11 @@ integrity sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ== "@types/node@*", "@types/node@>=13.7.0": - version "20.5.0" - resolved "https://registry.yarnpkg.com/@types/node/-/node-20.5.0.tgz#7fc8636d5f1aaa3b21e6245e97d56b7f56702313" - integrity sha512-Mgq7eCtoTjT89FqNoTzzXg2XvCi5VMhRV6+I2aYanc6kQCBImeNaAYRs/DyoVqk1YEUJK5gN9VO7HRIdz4Wo3Q== + version "20.8.7" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.8.7.tgz#ad23827850843de973096edfc5abc9e922492a25" + integrity sha512-21TKHHh3eUHIi2MloeptJWALuCu5H7HQTdTrWIFReA8ad+aggoX+lRes3ex7/FtpC+sVUpFMQ+QTfYr74mruiQ== + dependencies: + undici-types "~5.25.1" "@types/node@^10.0.3": version "10.17.60" @@ -532,26 +534,26 @@ integrity sha512-tktOkFUA4kXx2hhhrB8bIFb5TbwzS4uOhKEmwiD+NoiL0qtP2OQ9mFldbgD4dV1djrlBYP6eBuQZiWjuHUpqFw== "@types/parse-json@^4.0.0": - version "4.0.0" - resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0" - integrity sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA== + version "4.0.1" + resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.1.tgz#27f7559836ad796cea31acb63163b203756a5b4e" + integrity sha512-3YmXzzPAdOTVljVMkTMBdBEvlOLg2cDQaDhnnhT3nT9uDbnJzjWhKlzb+desT12Y7tGqaN6d+AbozcKzyL36Ng== "@types/pbkdf2@^3.0.0": - version "3.1.0" - resolved "https://registry.yarnpkg.com/@types/pbkdf2/-/pbkdf2-3.1.0.tgz#039a0e9b67da0cdc4ee5dab865caa6b267bb66b1" - integrity sha512-Cf63Rv7jCQ0LaL8tNXmEyqTHuIJxRdlS5vMh1mj5voN4+QFhVZnlZruezqpWYDiJ8UTzhP0VmeLXCmBk66YrMQ== + version "3.1.1" + resolved "https://registry.yarnpkg.com/@types/pbkdf2/-/pbkdf2-3.1.1.tgz#c290c1f0d3dc364af94c2c5ee92046a13b7f89fd" + integrity sha512-4HCoGwR3221nOc7G0Z/6KgTNGgaaFGkbGrtUJsB+zlKX2LBVjFHHIUkieMBgHHXgBH5Gq6dZHJKdBYdtlhBQvw== dependencies: "@types/node" "*" "@types/qs@^6.2.31": - version "6.9.7" - resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.7.tgz#63bb7d067db107cc1e457c303bc25d511febf6cb" - integrity sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw== + version "6.9.9" + resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.9.tgz#66f7b26288f6799d279edf13da7ccd40d2fa9197" + integrity sha512-wYLxw35euwqGvTDx6zfY1vokBFnsK0HNrzc6xNHchxfO2hpuRg74GbkEW7e3sSmPvj0TjCDT1VCa6OtHXnubsg== "@types/secp256k1@^4.0.1": - version "4.0.3" - resolved "https://registry.yarnpkg.com/@types/secp256k1/-/secp256k1-4.0.3.tgz#1b8e55d8e00f08ee7220b4d59a6abe89c37a901c" - integrity sha512-Da66lEIFeIz9ltsdMZcpQvmrmmoqrfju8pm1BH8WbYjZSwUgCwXLb9C+9XYogwBITnbsSaMdVPb2ekf7TV+03w== + version "4.0.5" + resolved "https://registry.yarnpkg.com/@types/secp256k1/-/secp256k1-4.0.5.tgz#14b1766b4fbc198b0af5599d9fd21c89056633ce" + integrity sha512-aIonTBMErtE3T9MxDvTZRzcrT/mCqpEZBw3CCY/i+oG9n57N/+7obBkhFgavUAIrX21bU0LHg1XRgtaLdelBhA== dependencies: "@types/node" "*" @@ -1100,9 +1102,9 @@ cli-progress@^3.12.0: string-width "^4.2.3" cli-spinners@^2.2.0: - version "2.9.0" - resolved "https://registry.yarnpkg.com/cli-spinners/-/cli-spinners-2.9.0.tgz#5881d0ad96381e117bbe07ad91f2008fe6ffd8db" - integrity sha512-4/aL9X3Wh0yiMQlE+eeRhWP6vclO3QRtw1JHKIT0FFUs5FjpFmESqtMvYZ0+lbzBw900b95mS0hohy+qn2VK/g== + version "2.9.1" + resolved "https://registry.yarnpkg.com/cli-spinners/-/cli-spinners-2.9.1.tgz#9c0b9dad69a6d47cbb4333c14319b060ed395a35" + integrity sha512-jHgecW0pxkonBJdrKsqxgRX9AcG+u/5k0Q7WPDfi8AogLAdwxEkyYYNWwZ5GvVFoFx2uiY1eNcSK00fh+1+FyQ== cli-table3@0.6.0: version "0.6.0" @@ -1531,9 +1533,9 @@ fast-deep-equal@^3.1.1: integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== fast-fifo@^1.0.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/fast-fifo/-/fast-fifo-1.3.0.tgz#03e381bcbfb29932d7c3afde6e15e83e05ab4d8b" - integrity sha512-IgfweLvEpwyA4WgiQe9Nx6VV2QkML2NkvZnk1oKnIzXgXdWxuhF7zw4DvLTPZJn6PIUneiAXPF24QmoEqHTjyw== + version "1.3.2" + resolved "https://registry.yarnpkg.com/fast-fifo/-/fast-fifo-1.3.2.tgz#286e31de96eb96d38a97899815740ba2a4f3640c" + integrity sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ== fast-glob@^3.2.9: version "3.3.1" @@ -1587,9 +1589,9 @@ fill-range@^7.0.1: to-regex-range "^5.0.1" follow-redirects@^1.14.0: - version "1.15.2" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.2.tgz#b460864144ba63f2681096f274c4e57026da2c13" - integrity sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA== + version "1.15.3" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.3.tgz#fe2f3ef2690afce7e82ed0b44db08165b207123a" + integrity sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q== forever-agent@~0.6.1: version "0.6.1" @@ -1650,14 +1652,14 @@ fs.realpath@^1.0.0: integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== fsevents@~2.3.2: - version "2.3.2" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" - integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== + version "2.3.3" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6" + integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== function-bind@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" - integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== + version "1.1.2" + resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.2.tgz#2c02d864d97f3ea6c8830c464cbd11ab6eab7a1c" + integrity sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA== get-intrinsic@^1.0.2: version "1.2.1" @@ -1789,9 +1791,9 @@ graphql@15.5.0: integrity sha512-OmaM7y0kaK31NKG31q4YbD2beNYa6jBBKtMFT6gLYJljHLJr42IqJ8KX08u3Li/0ifzTU5HjmoOOrwa5BRLeDA== graphql@^16.6.0: - version "16.7.1" - resolved "https://registry.yarnpkg.com/graphql/-/graphql-16.7.1.tgz#11475b74a7bff2aefd4691df52a0eca0abd9b642" - integrity sha512-DRYR9tf+UGU0KOsMcKAlXeFfX89UiiIZ0dRU3mR0yJfu6OjZqUcp68NnFLnqQU5RexygFoDy1EW+ccOYcPfmHg== + version "16.8.1" + resolved "https://registry.yarnpkg.com/graphql/-/graphql-16.8.1.tgz#1930a965bef1170603702acdb68aedd3f3cf6f07" + integrity sha512-59LZHPdGZVh695Ud9lRzPBVTtlX9ZCV150Er2W43ro37wVof0ctenSaskPPjN7lVTIN8mSZt8PHUNKZuNQUuxw== har-schema@^2.0.0: version "2.0.0" @@ -1827,11 +1829,9 @@ has-symbols@^1.0.3: integrity sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A== has@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" - integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== - dependencies: - function-bind "^1.1.1" + version "1.0.4" + resolved "https://registry.yarnpkg.com/has/-/has-1.0.4.tgz#2eb2860e000011dae4f1406a86fe80e530fb2ec6" + integrity sha512-qdSAmqLF6209RFj4VVItywPMbm3vWylknmB3nvNiUIs72xAimcM8nVYxYr7ncvZq5qzk9MKIZR8ijqD/1QuYjQ== hash-base@^3.0.0: version "3.1.0" @@ -2313,9 +2313,9 @@ jsprim@^1.2.2: verror "1.10.0" keccak@^3.0.0: - version "3.0.3" - resolved "https://registry.yarnpkg.com/keccak/-/keccak-3.0.3.tgz#4bc35ad917be1ef54ff246f904c2bbbf9ac61276" - integrity sha512-JZrLIAJWuZxKbCilMpNz5Vj7Vtb4scDG3dMXLOsbzBmQGyjwE61BbW7bJkfKKCShXiQZt3T6sBgALRtmd+nZaQ== + version "3.0.4" + resolved "https://registry.yarnpkg.com/keccak/-/keccak-3.0.4.tgz#edc09b89e633c0549da444432ecf062ffadee86d" + integrity sha512-3vKuW0jV8J3XNTzvfyicFR5qvxrSAGl7KIhvgOu5cmWwM7tZRj3fMbj/pfIf4be7aznbc+prBWGjywox/g2Y6Q== dependencies: node-addon-api "^2.0.0" node-gyp-build "^4.2.0" @@ -2549,9 +2549,9 @@ minipass@^5.0.0: integrity sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ== "minipass@^5.0.0 || ^6.0.2 || ^7.0.0": - version "7.0.3" - resolved "https://registry.yarnpkg.com/minipass/-/minipass-7.0.3.tgz#05ea638da44e475037ed94d1c7efcc76a25e1974" - integrity sha512-LhbbwCfz3vsb12j/WkWQPZfKTsgqIe1Nf/ti1pKjYESGLHIVjWU96G9/ljLH4F9mWNVhlQOm0VySdAWzf05dpg== + version "7.0.4" + resolved "https://registry.yarnpkg.com/minipass/-/minipass-7.0.4.tgz#dbce03740f50a4786ba994c1fb908844d27b038c" + integrity sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ== minizlib@^2.1.1: version "2.1.2" @@ -2633,16 +2633,16 @@ node-addon-api@^2.0.0: integrity sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA== node-fetch@^2.6.8: - version "2.6.12" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.12.tgz#02eb8e22074018e3d5a83016649d04df0e348fba" - integrity sha512-C/fGU2E8ToujUivIO0H+tpQ6HWo4eEmchoPIoXtxCrVghxdKq+QOHqEZW7tuP3KlV3bC8FRMO5nMCC7Zm1VP6g== + version "2.7.0" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d" + integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A== dependencies: whatwg-url "^5.0.0" node-gyp-build@^4.2.0: - version "4.6.0" - resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.6.0.tgz#0c52e4cbf54bbd28b709820ef7b6a3c2d6209055" - integrity sha512-NTZVKn9IylLwUzaKjkas1e4u2DLNcV4rdYagA4PWdPwW87Bi7z+BznyKSRwS/761tV/lzCGXplWsiaMjLqP2zQ== + version "4.6.1" + resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.6.1.tgz#24b6d075e5e391b8d5539d98c7fc5c210cac8a3e" + integrity sha512-24vnklJmyRS8ViBNI8KbtK/r/DmXQMRiOMXTNz2nrTnAYUwjmEEbnnpB/+kt+yWRv73bPsSPRFddrcIbAxSiMQ== normalize-path@^3.0.0, normalize-path@~3.0.0: version "3.0.0" @@ -2675,9 +2675,9 @@ object-assign@^4.1.0: integrity sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg== object-inspect@^1.9.0: - version "1.12.3" - resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.12.3.tgz#ba62dffd67ee256c8c086dfae69e016cd1f198b9" - integrity sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g== + version "1.13.0" + resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.13.0.tgz#42695d3879e1cd5bda6df5062164d80c996e23e2" + integrity sha512-HQ4J+ic8hKrgIt3mqk6cVOVrW2ozL4KdvHlqpBv9vDYWx9ysAgENAdvy4FoGF+KFdhR7nQTNm5J0ctAeOwn+3g== object-treeify@^1.1.33: version "1.1.33" @@ -2867,10 +2867,10 @@ punycode@^2.1.0, punycode@^2.1.1: resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.0.tgz#f67fa67c94da8f4d0cfff981aee4118064199b8f" integrity sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA== -pvtsutils@^1.3.2: - version "1.3.3" - resolved "https://registry.yarnpkg.com/pvtsutils/-/pvtsutils-1.3.3.tgz#29ef8ea50318d1187b15260b1d0b32e57eea32dc" - integrity sha512-6sAOMlXyrJ+8tRN5IAaYfuYZRp1C2uJ0SyDynEFxL+VY8kCRib9Lpj/+KPaNFpaQWr/iRik5nrzz6iaNlxgEGA== +pvtsutils@^1.3.2, pvtsutils@^1.3.5: + version "1.3.5" + resolved "https://registry.yarnpkg.com/pvtsutils/-/pvtsutils-1.3.5.tgz#b8705b437b7b134cd7fd858f025a23456f1ce910" + integrity sha512-ARvb14YB9Nm2Xi6nBq1ZX6dAM0FsJnuk+31aUp4TrcZEdKUlSqOqsxJHUPJDNE3qiIp+iUPEIeR6Je/tgV7zsA== dependencies: tslib "^2.6.1" @@ -3315,9 +3315,9 @@ tar-stream@^1.1.2: xtend "^4.0.0" tar@^6.1.0: - version "6.1.15" - resolved "https://registry.yarnpkg.com/tar/-/tar-6.1.15.tgz#c9738b0b98845a3b344d334b8fa3041aaba53a69" - integrity sha512-/zKt9UyngnxIT/EAGYuxaMYgOIJiP81ab9ZfkILq4oNLPFX50qyYmu7jRj9qeXoxmJHjGlbH0+cm2uy1WCs10A== + version "6.2.0" + resolved "https://registry.yarnpkg.com/tar/-/tar-6.2.0.tgz#b14ce49a79cb1cd23bc9b016302dea5474493f73" + integrity sha512-/Wo7DcT0u5HUV486xg675HtjNd3BXZ6xDbzsCUZPt5iw8bTQ63bP0Raut3mvro9u+CUyq7YQd8Cx55fsZXxqLQ== dependencies: chownr "^2.0.0" fs-minipass "^2.0.0" @@ -3415,10 +3415,10 @@ ts-node@^10.9.1: v8-compile-cache-lib "^3.0.1" yn "3.1.1" -tslib@^2.0.0, tslib@^2.3.1, tslib@^2.4.0, tslib@^2.5.0, tslib@^2.6.1: - version "2.6.1" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.1.tgz#fd8c9a0ff42590b25703c0acb3de3d3f4ede0410" - integrity sha512-t0hLfiEKfMUoqhG+U1oid7Pva4bbDPHYfJNiB7BiIjRkj1pyC++4N3huJfqY6aRH6VTB0rvtzQwjM4K6qpfOig== +tslib@^2.0.0, tslib@^2.3.1, tslib@^2.4.0, tslib@^2.5.0, tslib@^2.6.1, tslib@^2.6.2: + version "2.6.2" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae" + integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q== tunnel-agent@^0.6.0: version "0.6.0" @@ -3449,6 +3449,11 @@ uint8arrays@^3.0.0: dependencies: multiformats "^9.4.2" +undici-types@~5.25.1: + version "5.25.3" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.25.3.tgz#e044115914c85f0bcbb229f346ab739f064998c3" + integrity sha512-Ga1jfYwRn7+cP9v8auvEXN1rX3sWqlayd4HP7OKk4mZWylEmu3KzXDUGrQUN6Ol7qo1gPvB2e5gX6udnyEPgdA== + universalify@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717" From 6c07dbe0abbf60da33632776e839ede3421f63d8 Mon Sep 17 00:00:00 2001 From: fewensa Date: Thu, 19 Oct 2023 04:59:08 +0000 Subject: [PATCH 02/13] subapi --- thegraph/ormpipe/src/subapi.ts | 144 +++++++++++++++++++++ thegraph/ormpipe/tests/subapi-utils.ts | 166 +++++++++++++++++++++++++ thegraph/ormpipe/tests/subapi.test.ts | 53 ++++++++ 3 files changed, 363 insertions(+) create mode 100644 thegraph/ormpipe/src/subapi.ts create mode 100644 thegraph/ormpipe/tests/subapi-utils.ts create mode 100644 thegraph/ormpipe/tests/subapi.test.ts diff --git a/thegraph/ormpipe/src/subapi.ts b/thegraph/ormpipe/src/subapi.ts new file mode 100644 index 0000000..5acc246 --- /dev/null +++ b/thegraph/ormpipe/src/subapi.ts @@ -0,0 +1,144 @@ +import { + AddBeacon as AddBeaconEvent, + AggregatedORMPData as AggregatedORMPDataEvent, + AirnodeRrpCompleted as AirnodeRrpCompletedEvent, + AirnodeRrpRequested as AirnodeRrpRequestedEvent, + OwnershipTransferStarted as OwnershipTransferStartedEvent, + OwnershipTransferred as OwnershipTransferredEvent, + RemoveBeacon as RemoveBeaconEvent, + SubAPIFeedUpdated as SubAPIFeedUpdatedEvent +} from "../generated/Subapi/Subapi" +import { + AddBeacon, + AggregatedORMPData, + AirnodeRrpCompleted, + AirnodeRrpRequested, + OwnershipTransferStarted, + OwnershipTransferred, + RemoveBeacon, + SubAPIFeedUpdated +} from "../generated/schema" + +export function handleAddBeacon(event: AddBeaconEvent): void { + let entity = new AddBeacon( + event.transaction.hash.concatI32(event.logIndex.toI32()) + ) + entity.beaconId = event.params.beaconId + entity.beacon_airnode = event.params.beacon.airnode + entity.beacon_endpointId = event.params.beacon.endpointId + entity.beacon_sponsor = event.params.beacon.sponsor + entity.beacon_sponsorWallet = event.params.beacon.sponsorWallet + + entity.blockNumber = event.block.number + entity.blockTimestamp = event.block.timestamp + entity.transactionHash = event.transaction.hash + + entity.save() +} + +export function handleAggregatedORMPData(event: AggregatedORMPDataEvent): void { + let entity = new AggregatedORMPData( + event.transaction.hash.concatI32(event.logIndex.toI32()) + ) + entity.ormpData_count = event.params.ormpData.count + entity.ormpData_root = event.params.ormpData.root + + entity.blockNumber = event.block.number + entity.blockTimestamp = event.block.timestamp + entity.transactionHash = event.transaction.hash + + entity.save() +} + +export function handleAirnodeRrpCompleted( + event: AirnodeRrpCompletedEvent +): void { + let entity = new AirnodeRrpCompleted( + event.transaction.hash.concatI32(event.logIndex.toI32()) + ) + entity.beaconId = event.params.beaconId + entity.requestId = event.params.requestId + entity.data = event.params.data + + entity.blockNumber = event.block.number + entity.blockTimestamp = event.block.timestamp + entity.transactionHash = event.transaction.hash + + entity.save() +} + +export function handleAirnodeRrpRequested( + event: AirnodeRrpRequestedEvent +): void { + let entity = new AirnodeRrpRequested( + event.transaction.hash.concatI32(event.logIndex.toI32()) + ) + entity.beaconId = event.params.beaconId + entity.requestId = event.params.requestId + + entity.blockNumber = event.block.number + entity.blockTimestamp = event.block.timestamp + entity.transactionHash = event.transaction.hash + + entity.save() +} + +export function handleOwnershipTransferStarted( + event: OwnershipTransferStartedEvent +): void { + let entity = new OwnershipTransferStarted( + event.transaction.hash.concatI32(event.logIndex.toI32()) + ) + entity.previousOwner = event.params.previousOwner + entity.newOwner = event.params.newOwner + + entity.blockNumber = event.block.number + entity.blockTimestamp = event.block.timestamp + entity.transactionHash = event.transaction.hash + + entity.save() +} + +export function handleOwnershipTransferred( + event: OwnershipTransferredEvent +): void { + let entity = new OwnershipTransferred( + event.transaction.hash.concatI32(event.logIndex.toI32()) + ) + entity.previousOwner = event.params.previousOwner + entity.newOwner = event.params.newOwner + + entity.blockNumber = event.block.number + entity.blockTimestamp = event.block.timestamp + entity.transactionHash = event.transaction.hash + + entity.save() +} + +export function handleRemoveBeacon(event: RemoveBeaconEvent): void { + let entity = new RemoveBeacon( + event.transaction.hash.concatI32(event.logIndex.toI32()) + ) + entity.beaconId = event.params.beaconId + + entity.blockNumber = event.block.number + entity.blockTimestamp = event.block.timestamp + entity.transactionHash = event.transaction.hash + + entity.save() +} + +export function handleSubAPIFeedUpdated(event: SubAPIFeedUpdatedEvent): void { + let entity = new SubAPIFeedUpdated( + event.transaction.hash.concatI32(event.logIndex.toI32()) + ) + entity.beaconId = event.params.beaconId + entity.msgRoot_count = event.params.msgRoot.count + entity.msgRoot_root = event.params.msgRoot.root + + entity.blockNumber = event.block.number + entity.blockTimestamp = event.block.timestamp + entity.transactionHash = event.transaction.hash + + entity.save() +} diff --git a/thegraph/ormpipe/tests/subapi-utils.ts b/thegraph/ormpipe/tests/subapi-utils.ts new file mode 100644 index 0000000..7e29de5 --- /dev/null +++ b/thegraph/ormpipe/tests/subapi-utils.ts @@ -0,0 +1,166 @@ +import { newMockEvent } from "matchstick-as" +import { ethereum, Bytes, Address } from "@graphprotocol/graph-ts" +import { + AddBeacon, + AggregatedORMPData, + AirnodeRrpCompleted, + AirnodeRrpRequested, + OwnershipTransferStarted, + OwnershipTransferred, + RemoveBeacon, + SubAPIFeedUpdated +} from "../generated/Subapi/Subapi" + +export function createAddBeaconEvent( + beaconId: Bytes, + beacon: ethereum.Tuple +): AddBeacon { + let addBeaconEvent = changetype(newMockEvent()) + + addBeaconEvent.parameters = new Array() + + addBeaconEvent.parameters.push( + new ethereum.EventParam("beaconId", ethereum.Value.fromFixedBytes(beaconId)) + ) + addBeaconEvent.parameters.push( + new ethereum.EventParam("beacon", ethereum.Value.fromTuple(beacon)) + ) + + return addBeaconEvent +} + +export function createAggregatedORMPDataEvent( + ormpData: ethereum.Tuple +): AggregatedORMPData { + let aggregatedOrmpDataEvent = changetype(newMockEvent()) + + aggregatedOrmpDataEvent.parameters = new Array() + + aggregatedOrmpDataEvent.parameters.push( + new ethereum.EventParam("ormpData", ethereum.Value.fromTuple(ormpData)) + ) + + return aggregatedOrmpDataEvent +} + +export function createAirnodeRrpCompletedEvent( + beaconId: Bytes, + requestId: Bytes, + data: Bytes +): AirnodeRrpCompleted { + let airnodeRrpCompletedEvent = changetype(newMockEvent()) + + airnodeRrpCompletedEvent.parameters = new Array() + + airnodeRrpCompletedEvent.parameters.push( + new ethereum.EventParam("beaconId", ethereum.Value.fromFixedBytes(beaconId)) + ) + airnodeRrpCompletedEvent.parameters.push( + new ethereum.EventParam( + "requestId", + ethereum.Value.fromFixedBytes(requestId) + ) + ) + airnodeRrpCompletedEvent.parameters.push( + new ethereum.EventParam("data", ethereum.Value.fromBytes(data)) + ) + + return airnodeRrpCompletedEvent +} + +export function createAirnodeRrpRequestedEvent( + beaconId: Bytes, + requestId: Bytes +): AirnodeRrpRequested { + let airnodeRrpRequestedEvent = changetype(newMockEvent()) + + airnodeRrpRequestedEvent.parameters = new Array() + + airnodeRrpRequestedEvent.parameters.push( + new ethereum.EventParam("beaconId", ethereum.Value.fromFixedBytes(beaconId)) + ) + airnodeRrpRequestedEvent.parameters.push( + new ethereum.EventParam( + "requestId", + ethereum.Value.fromFixedBytes(requestId) + ) + ) + + return airnodeRrpRequestedEvent +} + +export function createOwnershipTransferStartedEvent( + previousOwner: Address, + newOwner: Address +): OwnershipTransferStarted { + let ownershipTransferStartedEvent = changetype( + newMockEvent() + ) + + ownershipTransferStartedEvent.parameters = new Array() + + ownershipTransferStartedEvent.parameters.push( + new ethereum.EventParam( + "previousOwner", + ethereum.Value.fromAddress(previousOwner) + ) + ) + ownershipTransferStartedEvent.parameters.push( + new ethereum.EventParam("newOwner", ethereum.Value.fromAddress(newOwner)) + ) + + return ownershipTransferStartedEvent +} + +export function createOwnershipTransferredEvent( + previousOwner: Address, + newOwner: Address +): OwnershipTransferred { + let ownershipTransferredEvent = changetype( + newMockEvent() + ) + + ownershipTransferredEvent.parameters = new Array() + + ownershipTransferredEvent.parameters.push( + new ethereum.EventParam( + "previousOwner", + ethereum.Value.fromAddress(previousOwner) + ) + ) + ownershipTransferredEvent.parameters.push( + new ethereum.EventParam("newOwner", ethereum.Value.fromAddress(newOwner)) + ) + + return ownershipTransferredEvent +} + +export function createRemoveBeaconEvent(beaconId: Bytes): RemoveBeacon { + let removeBeaconEvent = changetype(newMockEvent()) + + removeBeaconEvent.parameters = new Array() + + removeBeaconEvent.parameters.push( + new ethereum.EventParam("beaconId", ethereum.Value.fromFixedBytes(beaconId)) + ) + + return removeBeaconEvent +} + +export function createSubAPIFeedUpdatedEvent( + beaconId: Bytes, + msgRoot: ethereum.Tuple +): SubAPIFeedUpdated { + let subApiFeedUpdatedEvent = changetype(newMockEvent()) + + subApiFeedUpdatedEvent.parameters = new Array() + + subApiFeedUpdatedEvent.parameters.push( + new ethereum.EventParam("beaconId", ethereum.Value.fromFixedBytes(beaconId)) + ) + subApiFeedUpdatedEvent.parameters.push( + new ethereum.EventParam("msgRoot", ethereum.Value.fromTuple(msgRoot)) + ) + + return subApiFeedUpdatedEvent +} diff --git a/thegraph/ormpipe/tests/subapi.test.ts b/thegraph/ormpipe/tests/subapi.test.ts new file mode 100644 index 0000000..6a9f077 --- /dev/null +++ b/thegraph/ormpipe/tests/subapi.test.ts @@ -0,0 +1,53 @@ +import { + assert, + describe, + test, + clearStore, + beforeAll, + afterAll +} from "matchstick-as/assembly/index" +import { Bytes, Address } from "@graphprotocol/graph-ts" +import { AddBeacon } from "../generated/schema" +import { AddBeacon as AddBeaconEvent } from "../generated/Subapi/Subapi" +import { handleAddBeacon } from "../src/subapi" +import { createAddBeaconEvent } from "./subapi-utils" + +// Tests structure (matchstick-as >=0.5.0) +// https://thegraph.com/docs/en/developer/matchstick/#tests-structure-0-5-0 + +describe("Describe entity assertions", () => { + beforeAll(() => { + let beaconId = Bytes.fromI32(1234567890) + let beacon = "ethereum.Tuple Not implemented" + let newAddBeaconEvent = createAddBeaconEvent(beaconId, beacon) + handleAddBeacon(newAddBeaconEvent) + }) + + afterAll(() => { + clearStore() + }) + + // For more test scenarios, see: + // https://thegraph.com/docs/en/developer/matchstick/#write-a-unit-test + + test("AddBeacon created and stored", () => { + assert.entityCount("AddBeacon", 1) + + // 0xa16081f360e3847006db660bae1c6d1b2e17ec2a is the default address used in newMockEvent() function + assert.fieldEquals( + "AddBeacon", + "0xa16081f360e3847006db660bae1c6d1b2e17ec2a-1", + "beaconId", + "1234567890" + ) + assert.fieldEquals( + "AddBeacon", + "0xa16081f360e3847006db660bae1c6d1b2e17ec2a-1", + "beacon", + "ethereum.Tuple Not implemented" + ) + + // More assert options: + // https://thegraph.com/docs/en/developer/matchstick/#asserts + }) +}) From 9b4edb1be61383eff823e81047b56d1057395646 Mon Sep 17 00:00:00 2001 From: fewensa Date: Thu, 19 Oct 2023 05:03:07 +0000 Subject: [PATCH 03/13] ormp protocol --- thegraph/ormpipe/schema.graphql | 60 ++++++++ thegraph/ormpipe/src/ormp-protocol.ts | 107 +++++++++++++++ thegraph/ormpipe/tests/ormp-protocol-utils.ts | 128 ++++++++++++++++++ thegraph/ormpipe/tests/ormp-protocol.test.ts | 68 ++++++++++ 4 files changed, 363 insertions(+) create mode 100644 thegraph/ormpipe/src/ormp-protocol.ts create mode 100644 thegraph/ormpipe/tests/ormp-protocol-utils.ts create mode 100644 thegraph/ormpipe/tests/ormp-protocol.test.ts diff --git a/thegraph/ormpipe/schema.graphql b/thegraph/ormpipe/schema.graphql index de3c254..00260cd 100644 --- a/thegraph/ormpipe/schema.graphql +++ b/thegraph/ormpipe/schema.graphql @@ -77,3 +77,63 @@ type SubAPIFeedUpdated @entity(immutable: true) { } ## ========== ormp protocol +type OrmpProtocolAppConfigUpdated @entity(immutable: true) { + id: Bytes! + ua: Bytes! # address + oracle: Bytes! # address + relayer: Bytes! # address + blockNumber: BigInt! + blockTimestamp: BigInt! + transactionHash: Bytes! +} + +type OrmpProtocolClearFailedMessage @entity(immutable: true) { + id: Bytes! + msgHash: Bytes! # bytes32 + blockNumber: BigInt! + blockTimestamp: BigInt! + transactionHash: Bytes! +} + +type OrmpProtocolMessageAccepted @entity(immutable: true) { + id: Bytes! + msgHash: Bytes! # bytes32 + root: Bytes! # bytes32 + message_channel: Bytes! # address + message_index: BigInt! # uint256 + message_fromChainId: BigInt! # uint256 + message_from: Bytes! # address + message_toChainId: BigInt! # uint256 + message_to: Bytes! # address + message_encoded: Bytes! # bytes + blockNumber: BigInt! + blockTimestamp: BigInt! + transactionHash: Bytes! +} + +type OrmpProtocolMessageDispatched @entity(immutable: true) { + id: Bytes! + msgHash: Bytes! # bytes32 + dispatchResult: Boolean! # bool + blockNumber: BigInt! + blockTimestamp: BigInt! + transactionHash: Bytes! +} + +type OrmpProtocolRetryFailedMessage @entity(immutable: true) { + id: Bytes! + msgHash: Bytes! # bytes32 + dispatchResult: Boolean! # bool + blockNumber: BigInt! + blockTimestamp: BigInt! + transactionHash: Bytes! +} + +type OrmpProtocolSetDefaultConfig @entity(immutable: true) { + id: Bytes! + oracle: Bytes! # address + relayer: Bytes! # address + blockNumber: BigInt! + blockTimestamp: BigInt! + transactionHash: Bytes! +} diff --git a/thegraph/ormpipe/src/ormp-protocol.ts b/thegraph/ormpipe/src/ormp-protocol.ts new file mode 100644 index 0000000..46e4ee5 --- /dev/null +++ b/thegraph/ormpipe/src/ormp-protocol.ts @@ -0,0 +1,107 @@ +import { + AppConfigUpdated as AppConfigUpdatedEvent, + ClearFailedMessage as ClearFailedMessageEvent, + MessageAccepted as MessageAcceptedEvent, + MessageDispatched as MessageDispatchedEvent, + RetryFailedMessage as RetryFailedMessageEvent, + SetDefaultConfig as SetDefaultConfigEvent +} from "../generated/OrmpProtocol/OrmpProtocol" +import { + OrmpProtocolAppConfigUpdated, + OrmpProtocolClearFailedMessage, + OrmpProtocolMessageAccepted, + OrmpProtocolMessageDispatched, + OrmpProtocolRetryFailedMessage, + OrmpProtocolSetDefaultConfig +} from "../generated/schema" + +export function handleAppConfigUpdated(event: AppConfigUpdatedEvent): void { + let entity = new OrmpProtocolAppConfigUpdated( + event.transaction.hash.concatI32(event.logIndex.toI32()) + ) + entity.ua = event.params.ua + entity.oracle = event.params.oracle + entity.relayer = event.params.relayer + + entity.blockNumber = event.block.number + entity.blockTimestamp = event.block.timestamp + entity.transactionHash = event.transaction.hash + + entity.save() +} + +export function handleClearFailedMessage(event: ClearFailedMessageEvent): void { + let entity = new OrmpProtocolClearFailedMessage( + event.transaction.hash.concatI32(event.logIndex.toI32()) + ) + entity.msgHash = event.params.msgHash + + entity.blockNumber = event.block.number + entity.blockTimestamp = event.block.timestamp + entity.transactionHash = event.transaction.hash + + entity.save() +} + +export function handleMessageAccepted(event: MessageAcceptedEvent): void { + let entity = new OrmpProtocolMessageAccepted( + event.transaction.hash.concatI32(event.logIndex.toI32()) + ) + entity.msgHash = event.params.msgHash + entity.root = event.params.root + entity.message_channel = event.params.message.channel + entity.message_index = event.params.message.index + entity.message_fromChainId = event.params.message.fromChainId + entity.message_from = event.params.message.from + entity.message_toChainId = event.params.message.toChainId + entity.message_to = event.params.message.to + entity.message_encoded = event.params.message.encoded + + entity.blockNumber = event.block.number + entity.blockTimestamp = event.block.timestamp + entity.transactionHash = event.transaction.hash + + entity.save() +} + +export function handleMessageDispatched(event: MessageDispatchedEvent): void { + let entity = new OrmpProtocolMessageDispatched( + event.transaction.hash.concatI32(event.logIndex.toI32()) + ) + entity.msgHash = event.params.msgHash + entity.dispatchResult = event.params.dispatchResult + + entity.blockNumber = event.block.number + entity.blockTimestamp = event.block.timestamp + entity.transactionHash = event.transaction.hash + + entity.save() +} + +export function handleRetryFailedMessage(event: RetryFailedMessageEvent): void { + let entity = new OrmpProtocolRetryFailedMessage( + event.transaction.hash.concatI32(event.logIndex.toI32()) + ) + entity.msgHash = event.params.msgHash + entity.dispatchResult = event.params.dispatchResult + + entity.blockNumber = event.block.number + entity.blockTimestamp = event.block.timestamp + entity.transactionHash = event.transaction.hash + + entity.save() +} + +export function handleSetDefaultConfig(event: SetDefaultConfigEvent): void { + let entity = new OrmpProtocolSetDefaultConfig( + event.transaction.hash.concatI32(event.logIndex.toI32()) + ) + entity.oracle = event.params.oracle + entity.relayer = event.params.relayer + + entity.blockNumber = event.block.number + entity.blockTimestamp = event.block.timestamp + entity.transactionHash = event.transaction.hash + + entity.save() +} diff --git a/thegraph/ormpipe/tests/ormp-protocol-utils.ts b/thegraph/ormpipe/tests/ormp-protocol-utils.ts new file mode 100644 index 0000000..1296885 --- /dev/null +++ b/thegraph/ormpipe/tests/ormp-protocol-utils.ts @@ -0,0 +1,128 @@ +import { newMockEvent } from "matchstick-as" +import { ethereum, Address, Bytes } from "@graphprotocol/graph-ts" +import { + AppConfigUpdated, + ClearFailedMessage, + MessageAccepted, + MessageDispatched, + RetryFailedMessage, + SetDefaultConfig +} from "../generated/OrmpProtocol/OrmpProtocol" + +export function createAppConfigUpdatedEvent( + ua: Address, + oracle: Address, + relayer: Address +): AppConfigUpdated { + let appConfigUpdatedEvent = changetype(newMockEvent()) + + appConfigUpdatedEvent.parameters = new Array() + + appConfigUpdatedEvent.parameters.push( + new ethereum.EventParam("ua", ethereum.Value.fromAddress(ua)) + ) + appConfigUpdatedEvent.parameters.push( + new ethereum.EventParam("oracle", ethereum.Value.fromAddress(oracle)) + ) + appConfigUpdatedEvent.parameters.push( + new ethereum.EventParam("relayer", ethereum.Value.fromAddress(relayer)) + ) + + return appConfigUpdatedEvent +} + +export function createClearFailedMessageEvent( + msgHash: Bytes +): ClearFailedMessage { + let clearFailedMessageEvent = changetype(newMockEvent()) + + clearFailedMessageEvent.parameters = new Array() + + clearFailedMessageEvent.parameters.push( + new ethereum.EventParam("msgHash", ethereum.Value.fromFixedBytes(msgHash)) + ) + + return clearFailedMessageEvent +} + +export function createMessageAcceptedEvent( + msgHash: Bytes, + root: Bytes, + message: ethereum.Tuple +): MessageAccepted { + let messageAcceptedEvent = changetype(newMockEvent()) + + messageAcceptedEvent.parameters = new Array() + + messageAcceptedEvent.parameters.push( + new ethereum.EventParam("msgHash", ethereum.Value.fromFixedBytes(msgHash)) + ) + messageAcceptedEvent.parameters.push( + new ethereum.EventParam("root", ethereum.Value.fromFixedBytes(root)) + ) + messageAcceptedEvent.parameters.push( + new ethereum.EventParam("message", ethereum.Value.fromTuple(message)) + ) + + return messageAcceptedEvent +} + +export function createMessageDispatchedEvent( + msgHash: Bytes, + dispatchResult: boolean +): MessageDispatched { + let messageDispatchedEvent = changetype(newMockEvent()) + + messageDispatchedEvent.parameters = new Array() + + messageDispatchedEvent.parameters.push( + new ethereum.EventParam("msgHash", ethereum.Value.fromFixedBytes(msgHash)) + ) + messageDispatchedEvent.parameters.push( + new ethereum.EventParam( + "dispatchResult", + ethereum.Value.fromBoolean(dispatchResult) + ) + ) + + return messageDispatchedEvent +} + +export function createRetryFailedMessageEvent( + msgHash: Bytes, + dispatchResult: boolean +): RetryFailedMessage { + let retryFailedMessageEvent = changetype(newMockEvent()) + + retryFailedMessageEvent.parameters = new Array() + + retryFailedMessageEvent.parameters.push( + new ethereum.EventParam("msgHash", ethereum.Value.fromFixedBytes(msgHash)) + ) + retryFailedMessageEvent.parameters.push( + new ethereum.EventParam( + "dispatchResult", + ethereum.Value.fromBoolean(dispatchResult) + ) + ) + + return retryFailedMessageEvent +} + +export function createSetDefaultConfigEvent( + oracle: Address, + relayer: Address +): SetDefaultConfig { + let setDefaultConfigEvent = changetype(newMockEvent()) + + setDefaultConfigEvent.parameters = new Array() + + setDefaultConfigEvent.parameters.push( + new ethereum.EventParam("oracle", ethereum.Value.fromAddress(oracle)) + ) + setDefaultConfigEvent.parameters.push( + new ethereum.EventParam("relayer", ethereum.Value.fromAddress(relayer)) + ) + + return setDefaultConfigEvent +} diff --git a/thegraph/ormpipe/tests/ormp-protocol.test.ts b/thegraph/ormpipe/tests/ormp-protocol.test.ts new file mode 100644 index 0000000..f579a50 --- /dev/null +++ b/thegraph/ormpipe/tests/ormp-protocol.test.ts @@ -0,0 +1,68 @@ +import { + assert, + describe, + test, + clearStore, + beforeAll, + afterAll +} from "matchstick-as/assembly/index" +import { Address, Bytes } from "@graphprotocol/graph-ts" +import { OrmpProtocolAppConfigUpdated } from "../generated/schema" +import { AppConfigUpdated as AppConfigUpdatedEvent } from "../generated/OrmpProtocol/OrmpProtocol" +import { handleAppConfigUpdated } from "../src/ormp-protocol" +import { createAppConfigUpdatedEvent } from "./ormp-protocol-utils" + +// Tests structure (matchstick-as >=0.5.0) +// https://thegraph.com/docs/en/developer/matchstick/#tests-structure-0-5-0 + +describe("Describe entity assertions", () => { + beforeAll(() => { + let ua = Address.fromString("0x0000000000000000000000000000000000000001") + let oracle = Address.fromString( + "0x0000000000000000000000000000000000000001" + ) + let relayer = Address.fromString( + "0x0000000000000000000000000000000000000001" + ) + let newAppConfigUpdatedEvent = createAppConfigUpdatedEvent( + ua, + oracle, + relayer + ) + handleAppConfigUpdated(newAppConfigUpdatedEvent) + }) + + afterAll(() => { + clearStore() + }) + + // For more test scenarios, see: + // https://thegraph.com/docs/en/developer/matchstick/#write-a-unit-test + + test("AppConfigUpdated created and stored", () => { + assert.entityCount("AppConfigUpdated", 1) + + // 0xa16081f360e3847006db660bae1c6d1b2e17ec2a is the default address used in newMockEvent() function + assert.fieldEquals( + "AppConfigUpdated", + "0xa16081f360e3847006db660bae1c6d1b2e17ec2a-1", + "ua", + "0x0000000000000000000000000000000000000001" + ) + assert.fieldEquals( + "AppConfigUpdated", + "0xa16081f360e3847006db660bae1c6d1b2e17ec2a-1", + "oracle", + "0x0000000000000000000000000000000000000001" + ) + assert.fieldEquals( + "AppConfigUpdated", + "0xa16081f360e3847006db660bae1c6d1b2e17ec2a-1", + "relayer", + "0x0000000000000000000000000000000000000001" + ) + + // More assert options: + // https://thegraph.com/docs/en/developer/matchstick/#asserts + }) +}) From fda24548835b4f7d59d91a142e11d83ac3c9d8c9 Mon Sep 17 00:00:00 2001 From: fewensa Date: Thu, 19 Oct 2023 05:06:54 +0000 Subject: [PATCH 04/13] ormp oracle --- thegraph/ormpipe/schema.graphql | 39 +++++++++++ thegraph/ormpipe/src/ormp-oracle.ts | 63 +++++++++++++++++ thegraph/ormpipe/tests/ormp-oracle-utils.ts | 77 +++++++++++++++++++++ thegraph/ormpipe/tests/ormp-oracle.test.ts | 53 ++++++++++++++ 4 files changed, 232 insertions(+) create mode 100644 thegraph/ormpipe/src/ormp-oracle.ts create mode 100644 thegraph/ormpipe/tests/ormp-oracle-utils.ts create mode 100644 thegraph/ormpipe/tests/ormp-oracle.test.ts diff --git a/thegraph/ormpipe/schema.graphql b/thegraph/ormpipe/schema.graphql index 00260cd..34bcbde 100644 --- a/thegraph/ormpipe/schema.graphql +++ b/thegraph/ormpipe/schema.graphql @@ -137,3 +137,42 @@ type OrmpProtocolSetDefaultConfig @entity(immutable: true) { blockTimestamp: BigInt! transactionHash: Bytes! } + +## ======= ormp oracle +type OrmpOracleAssigned @entity(immutable: true) { + id: Bytes! + msgHash: Bytes! # bytes32 + fee: BigInt! # uint256 + blockNumber: BigInt! + blockTimestamp: BigInt! + transactionHash: Bytes! +} + +type OrmpOracleSetApproved @entity(immutable: true) { + id: Bytes! + operator: Bytes! # address + approve: Boolean! # bool + blockNumber: BigInt! + blockTimestamp: BigInt! + transactionHash: Bytes! +} + +type OrmpOracleSetDapi @entity(immutable: true) { + id: Bytes! + chainId: BigInt! # uint256 + dapi: Bytes! # address + blockNumber: BigInt! + blockTimestamp: BigInt! + transactionHash: Bytes! +} + +type OrmpOracleSetFee @entity(immutable: true) { + id: Bytes! + chainId: BigInt! # uint256 + fee: BigInt! # uint256 + blockNumber: BigInt! + blockTimestamp: BigInt! + transactionHash: Bytes! +} + +## ===== ormp relayer diff --git a/thegraph/ormpipe/src/ormp-oracle.ts b/thegraph/ormpipe/src/ormp-oracle.ts new file mode 100644 index 0000000..744c053 --- /dev/null +++ b/thegraph/ormpipe/src/ormp-oracle.ts @@ -0,0 +1,63 @@ +import { + Assigned as AssignedEvent, + SetApproved as SetApprovedEvent, + SetDapi as SetDapiEvent, + SetFee as SetFeeEvent +} from "../generated/OrmpOracle/OrmpOracle" +import {OrmpOracleAssigned, OrmpOracleSetApproved, OrmpOracleSetDapi, OrmpOracleSetFee} from "../generated/schema" + +export function handleAssigned(event: AssignedEvent): void { + let entity = new OrmpOracleAssigned( + event.transaction.hash.concatI32(event.logIndex.toI32()) + ) + entity.msgHash = event.params.msgHash + entity.fee = event.params.fee + + entity.blockNumber = event.block.number + entity.blockTimestamp = event.block.timestamp + entity.transactionHash = event.transaction.hash + + entity.save() +} + +export function handleSetApproved(event: SetApprovedEvent): void { + let entity = new OrmpOracleSetApproved( + event.transaction.hash.concatI32(event.logIndex.toI32()) + ) + entity.operator = event.params.operator + entity.approve = event.params.approve + + entity.blockNumber = event.block.number + entity.blockTimestamp = event.block.timestamp + entity.transactionHash = event.transaction.hash + + entity.save() +} + +export function handleSetDapi(event: SetDapiEvent): void { + let entity = new OrmpOracleSetDapi( + event.transaction.hash.concatI32(event.logIndex.toI32()) + ) + entity.chainId = event.params.chainId + entity.dapi = event.params.dapi + + entity.blockNumber = event.block.number + entity.blockTimestamp = event.block.timestamp + entity.transactionHash = event.transaction.hash + + entity.save() +} + +export function handleSetFee(event: SetFeeEvent): void { + let entity = new OrmpOracleSetFee( + event.transaction.hash.concatI32(event.logIndex.toI32()) + ) + entity.chainId = event.params.chainId + entity.fee = event.params.fee + + entity.blockNumber = event.block.number + entity.blockTimestamp = event.block.timestamp + entity.transactionHash = event.transaction.hash + + entity.save() +} diff --git a/thegraph/ormpipe/tests/ormp-oracle-utils.ts b/thegraph/ormpipe/tests/ormp-oracle-utils.ts new file mode 100644 index 0000000..85e570e --- /dev/null +++ b/thegraph/ormpipe/tests/ormp-oracle-utils.ts @@ -0,0 +1,77 @@ +import { newMockEvent } from "matchstick-as" +import { ethereum, Bytes, BigInt, Address } from "@graphprotocol/graph-ts" +import { + Assigned, + SetApproved, + SetDapi, + SetFee +} from "../generated/OrmpOracle/OrmpOracle" + +export function createAssignedEvent(msgHash: Bytes, fee: BigInt): Assigned { + let assignedEvent = changetype(newMockEvent()) + + assignedEvent.parameters = new Array() + + assignedEvent.parameters.push( + new ethereum.EventParam("msgHash", ethereum.Value.fromFixedBytes(msgHash)) + ) + assignedEvent.parameters.push( + new ethereum.EventParam("fee", ethereum.Value.fromUnsignedBigInt(fee)) + ) + + return assignedEvent +} + +export function createSetApprovedEvent( + operator: Address, + approve: boolean +): SetApproved { + let setApprovedEvent = changetype(newMockEvent()) + + setApprovedEvent.parameters = new Array() + + setApprovedEvent.parameters.push( + new ethereum.EventParam("operator", ethereum.Value.fromAddress(operator)) + ) + setApprovedEvent.parameters.push( + new ethereum.EventParam("approve", ethereum.Value.fromBoolean(approve)) + ) + + return setApprovedEvent +} + +export function createSetDapiEvent(chainId: BigInt, dapi: Address): SetDapi { + let setDapiEvent = changetype(newMockEvent()) + + setDapiEvent.parameters = new Array() + + setDapiEvent.parameters.push( + new ethereum.EventParam( + "chainId", + ethereum.Value.fromUnsignedBigInt(chainId) + ) + ) + setDapiEvent.parameters.push( + new ethereum.EventParam("dapi", ethereum.Value.fromAddress(dapi)) + ) + + return setDapiEvent +} + +export function createSetFeeEvent(chainId: BigInt, fee: BigInt): SetFee { + let setFeeEvent = changetype(newMockEvent()) + + setFeeEvent.parameters = new Array() + + setFeeEvent.parameters.push( + new ethereum.EventParam( + "chainId", + ethereum.Value.fromUnsignedBigInt(chainId) + ) + ) + setFeeEvent.parameters.push( + new ethereum.EventParam("fee", ethereum.Value.fromUnsignedBigInt(fee)) + ) + + return setFeeEvent +} diff --git a/thegraph/ormpipe/tests/ormp-oracle.test.ts b/thegraph/ormpipe/tests/ormp-oracle.test.ts new file mode 100644 index 0000000..2214338 --- /dev/null +++ b/thegraph/ormpipe/tests/ormp-oracle.test.ts @@ -0,0 +1,53 @@ +import { + assert, + describe, + test, + clearStore, + beforeAll, + afterAll +} from "matchstick-as/assembly/index" +import { Bytes, BigInt, Address } from "@graphprotocol/graph-ts" +import { OrmpOracleAssigned } from "../generated/schema" +import { Assigned as AssignedEvent } from "../generated/OrmpOracle/OrmpOracle" +import { handleAssigned } from "../src/ormp-oracle" +import { createAssignedEvent } from "./ormp-oracle-utils" + +// Tests structure (matchstick-as >=0.5.0) +// https://thegraph.com/docs/en/developer/matchstick/#tests-structure-0-5-0 + +describe("Describe entity assertions", () => { + beforeAll(() => { + let msgHash = Bytes.fromI32(1234567890) + let fee = BigInt.fromI32(234) + let newAssignedEvent = createAssignedEvent(msgHash, fee) + handleAssigned(newAssignedEvent) + }) + + afterAll(() => { + clearStore() + }) + + // For more test scenarios, see: + // https://thegraph.com/docs/en/developer/matchstick/#write-a-unit-test + + test("Assigned created and stored", () => { + assert.entityCount("Assigned", 1) + + // 0xa16081f360e3847006db660bae1c6d1b2e17ec2a is the default address used in newMockEvent() function + assert.fieldEquals( + "Assigned", + "0xa16081f360e3847006db660bae1c6d1b2e17ec2a-1", + "msgHash", + "1234567890" + ) + assert.fieldEquals( + "Assigned", + "0xa16081f360e3847006db660bae1c6d1b2e17ec2a-1", + "fee", + "234" + ) + + // More assert options: + // https://thegraph.com/docs/en/developer/matchstick/#asserts + }) +}) From 8a6b403c437c127ff18a4fdecb29fe4e95f18da0 Mon Sep 17 00:00:00 2001 From: fewensa Date: Thu, 19 Oct 2023 05:09:20 +0000 Subject: [PATCH 05/13] ormp relayer --- thegraph/ormpipe/schema.graphql | 39 +++++ thegraph/ormpipe/src/ormp-relayer.ts | 72 +++++++++ .../ormpipe/subgraph-arbitrum-sepolia.yaml | 139 ++++++++++++++++++ thegraph/ormpipe/subgraph-crab.yaml | 139 ++++++++++++++++++ thegraph/ormpipe/tests/ormp-relayer-utils.ts | 114 ++++++++++++++ thegraph/ormpipe/tests/ormp-relayer.test.ts | 67 +++++++++ 6 files changed, 570 insertions(+) create mode 100644 thegraph/ormpipe/src/ormp-relayer.ts create mode 100644 thegraph/ormpipe/subgraph-arbitrum-sepolia.yaml create mode 100644 thegraph/ormpipe/subgraph-crab.yaml create mode 100644 thegraph/ormpipe/tests/ormp-relayer-utils.ts create mode 100644 thegraph/ormpipe/tests/ormp-relayer.test.ts diff --git a/thegraph/ormpipe/schema.graphql b/thegraph/ormpipe/schema.graphql index 34bcbde..8f2951c 100644 --- a/thegraph/ormpipe/schema.graphql +++ b/thegraph/ormpipe/schema.graphql @@ -176,3 +176,42 @@ type OrmpOracleSetFee @entity(immutable: true) { } ## ===== ormp relayer +type OrmpRelayerAssigned @entity(immutable: true) { + id: Bytes! + msgHash: Bytes! # bytes32 + fee: BigInt! # uint256 + params: Bytes! # bytes + proof: [Bytes!]! # bytes32[32] + blockNumber: BigInt! + blockTimestamp: BigInt! + transactionHash: Bytes! +} + +type OrmpRelayerSetApproved @entity(immutable: true) { + id: Bytes! + operator: Bytes! # address + approve: Boolean! # bool + blockNumber: BigInt! + blockTimestamp: BigInt! + transactionHash: Bytes! +} + +type OrmpRelayerSetDstConfig @entity(immutable: true) { + id: Bytes! + chainId: BigInt! # uint256 + baseGas: BigInt! # uint64 + gasPerByte: BigInt! # uint64 + blockNumber: BigInt! + blockTimestamp: BigInt! + transactionHash: Bytes! +} + +type OrmpRelayerSetDstPrice @entity(immutable: true) { + id: Bytes! + chainId: BigInt! # uint256 + dstPriceRatio: BigInt! # uint128 + dstGasPriceInWei: BigInt! # uint128 + blockNumber: BigInt! + blockTimestamp: BigInt! + transactionHash: Bytes! +} diff --git a/thegraph/ormpipe/src/ormp-relayer.ts b/thegraph/ormpipe/src/ormp-relayer.ts new file mode 100644 index 0000000..b8a710c --- /dev/null +++ b/thegraph/ormpipe/src/ormp-relayer.ts @@ -0,0 +1,72 @@ +import { + Assigned as AssignedEvent, + SetApproved as SetApprovedEvent, + SetDstConfig as SetDstConfigEvent, + SetDstPrice as SetDstPriceEvent +} from "../generated/OrmpRelayer/OrmpRelayer" +import { + OrmpRelayerAssigned, + OrmpRelayerSetApproved, + OrmpRelayerSetDstConfig, + OrmpRelayerSetDstPrice +} from "../generated/schema" + +export function handleAssigned(event: AssignedEvent): void { + let entity = new OrmpRelayerAssigned( + event.transaction.hash.concatI32(event.logIndex.toI32()) + ) + entity.msgHash = event.params.msgHash + entity.fee = event.params.fee + entity.params = event.params.params + entity.proof = event.params.proof + + entity.blockNumber = event.block.number + entity.blockTimestamp = event.block.timestamp + entity.transactionHash = event.transaction.hash + + entity.save() +} + +export function handleSetApproved(event: SetApprovedEvent): void { + let entity = new OrmpRelayerSetApproved( + event.transaction.hash.concatI32(event.logIndex.toI32()) + ) + entity.operator = event.params.operator + entity.approve = event.params.approve + + entity.blockNumber = event.block.number + entity.blockTimestamp = event.block.timestamp + entity.transactionHash = event.transaction.hash + + entity.save() +} + +export function handleSetDstConfig(event: SetDstConfigEvent): void { + let entity = new OrmpRelayerSetDstConfig( + event.transaction.hash.concatI32(event.logIndex.toI32()) + ) + entity.chainId = event.params.chainId + entity.baseGas = event.params.baseGas + entity.gasPerByte = event.params.gasPerByte + + entity.blockNumber = event.block.number + entity.blockTimestamp = event.block.timestamp + entity.transactionHash = event.transaction.hash + + entity.save() +} + +export function handleSetDstPrice(event: SetDstPriceEvent): void { + let entity = new OrmpRelayerSetDstPrice( + event.transaction.hash.concatI32(event.logIndex.toI32()) + ) + entity.chainId = event.params.chainId + entity.dstPriceRatio = event.params.dstPriceRatio + entity.dstGasPriceInWei = event.params.dstGasPriceInWei + + entity.blockNumber = event.block.number + entity.blockTimestamp = event.block.timestamp + entity.transactionHash = event.transaction.hash + + entity.save() +} diff --git a/thegraph/ormpipe/subgraph-arbitrum-sepolia.yaml b/thegraph/ormpipe/subgraph-arbitrum-sepolia.yaml new file mode 100644 index 0000000..7325668 --- /dev/null +++ b/thegraph/ormpipe/subgraph-arbitrum-sepolia.yaml @@ -0,0 +1,139 @@ +specVersion: 0.0.5 +schema: + file: ./schema.graphql +dataSources: + - kind: ethereum + name: Subapi + network: fantom + source: + address: "0x007471Db6AD668b30a7CE648589a4C8C4f65a36f" + abi: Subapi + startBlock: 624384 + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - AddBeacon + - AggregatedORMPData + - AirnodeRrpCompleted + - AirnodeRrpRequested + - OwnershipTransferStarted + - OwnershipTransferred + - RemoveBeacon + - SubAPIFeedUpdated + abis: + - name: Subapi + file: ./abis/Subapi.json + eventHandlers: + - event: AddBeacon(indexed bytes32,(address,bytes32,address,address)) + handler: handleAddBeacon + - event: AggregatedORMPData((uint256,bytes32)) + handler: handleAggregatedORMPData + - event: AirnodeRrpCompleted(indexed bytes32,indexed bytes32,bytes) + handler: handleAirnodeRrpCompleted + - event: AirnodeRrpRequested(indexed bytes32,indexed bytes32) + handler: handleAirnodeRrpRequested + - event: OwnershipTransferStarted(indexed address,indexed address) + handler: handleOwnershipTransferStarted + - event: OwnershipTransferred(indexed address,indexed address) + handler: handleOwnershipTransferred + - event: RemoveBeacon(indexed bytes32) + handler: handleRemoveBeacon + - event: SubAPIFeedUpdated(indexed bytes32,(uint256,bytes32)) + handler: handleSubAPIFeedUpdated + file: ./src/subapi.ts + - kind: ethereum + name: OrmpProtocol + network: fantom + source: + address: "0x0034607daf9c1dc6628f6e09E81bB232B6603A89" + abi: OrmpProtocol + startBlock: 624067 + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - OrmpProtocolAppConfigUpdated + - OrmpProtocolClearFailedMessage + - OrmpProtocolMessageAccepted + - OrmpProtocolMessageDispatched + - OrmpProtocolRetryFailedMessage + - OrmpProtocolSetDefaultConfig + abis: + - name: OrmpProtocol + file: ./abis/OrmpProtocol.json + eventHandlers: + - event: AppConfigUpdated(indexed address,address,address) + handler: handleAppConfigUpdated + - event: ClearFailedMessage(indexed bytes32) + handler: handleClearFailedMessage + - event: MessageAccepted(indexed + bytes32,bytes32,(address,uint256,uint256,address,uint256,address,bytes)) + handler: handleMessageAccepted + - event: MessageDispatched(indexed bytes32,bool) + handler: handleMessageDispatched + - event: RetryFailedMessage(indexed bytes32,bool) + handler: handleRetryFailedMessage + - event: SetDefaultConfig(address,address) + handler: handleSetDefaultConfig + file: ./src/ormp-protocol.ts + - kind: ethereum + name: OrmpOracle + network: fantom + source: + address: "0x0002396F1D52323fcd1ae8079b38808F046882c3" + abi: OrmpOracle + startBlock: 624068 + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - Assigned + - SetApproved + - SetDapi + - SetFee + abis: + - name: OrmpOracle + file: ./abis/OrmpOracle.json + eventHandlers: + - event: Assigned(indexed bytes32,uint256) + handler: handleAssigned + - event: SetApproved(address,bool) + handler: handleSetApproved + - event: SetDapi(indexed uint256,address) + handler: handleSetDapi + - event: SetFee(indexed uint256,uint256) + handler: handleSetFee + file: ./src/ormp-oracle.ts + - kind: ethereum + name: OrmpRelayer + network: fantom + source: + address: "0x007EED6207c9AF3715964Fb7f8B5f44E002a3498" + abi: OrmpRelayer + startBlock: 624069 + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - OrmpRelayerAssigned + - OrmpRelayerSetApproved + - SetDstConfig + - SetDstPrice + abis: + - name: OrmpRelayer + file: ./abis/OrmpRelayer.json + eventHandlers: + - event: Assigned(indexed bytes32,uint256,bytes,bytes32[32]) + handler: handleAssigned + - event: SetApproved(address,bool) + handler: handleSetApproved + - event: SetDstConfig(indexed uint256,uint64,uint64) + handler: handleSetDstConfig + - event: SetDstPrice(indexed uint256,uint128,uint128) + handler: handleSetDstPrice + file: ./src/ormp-relayer.ts diff --git a/thegraph/ormpipe/subgraph-crab.yaml b/thegraph/ormpipe/subgraph-crab.yaml new file mode 100644 index 0000000..7325668 --- /dev/null +++ b/thegraph/ormpipe/subgraph-crab.yaml @@ -0,0 +1,139 @@ +specVersion: 0.0.5 +schema: + file: ./schema.graphql +dataSources: + - kind: ethereum + name: Subapi + network: fantom + source: + address: "0x007471Db6AD668b30a7CE648589a4C8C4f65a36f" + abi: Subapi + startBlock: 624384 + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - AddBeacon + - AggregatedORMPData + - AirnodeRrpCompleted + - AirnodeRrpRequested + - OwnershipTransferStarted + - OwnershipTransferred + - RemoveBeacon + - SubAPIFeedUpdated + abis: + - name: Subapi + file: ./abis/Subapi.json + eventHandlers: + - event: AddBeacon(indexed bytes32,(address,bytes32,address,address)) + handler: handleAddBeacon + - event: AggregatedORMPData((uint256,bytes32)) + handler: handleAggregatedORMPData + - event: AirnodeRrpCompleted(indexed bytes32,indexed bytes32,bytes) + handler: handleAirnodeRrpCompleted + - event: AirnodeRrpRequested(indexed bytes32,indexed bytes32) + handler: handleAirnodeRrpRequested + - event: OwnershipTransferStarted(indexed address,indexed address) + handler: handleOwnershipTransferStarted + - event: OwnershipTransferred(indexed address,indexed address) + handler: handleOwnershipTransferred + - event: RemoveBeacon(indexed bytes32) + handler: handleRemoveBeacon + - event: SubAPIFeedUpdated(indexed bytes32,(uint256,bytes32)) + handler: handleSubAPIFeedUpdated + file: ./src/subapi.ts + - kind: ethereum + name: OrmpProtocol + network: fantom + source: + address: "0x0034607daf9c1dc6628f6e09E81bB232B6603A89" + abi: OrmpProtocol + startBlock: 624067 + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - OrmpProtocolAppConfigUpdated + - OrmpProtocolClearFailedMessage + - OrmpProtocolMessageAccepted + - OrmpProtocolMessageDispatched + - OrmpProtocolRetryFailedMessage + - OrmpProtocolSetDefaultConfig + abis: + - name: OrmpProtocol + file: ./abis/OrmpProtocol.json + eventHandlers: + - event: AppConfigUpdated(indexed address,address,address) + handler: handleAppConfigUpdated + - event: ClearFailedMessage(indexed bytes32) + handler: handleClearFailedMessage + - event: MessageAccepted(indexed + bytes32,bytes32,(address,uint256,uint256,address,uint256,address,bytes)) + handler: handleMessageAccepted + - event: MessageDispatched(indexed bytes32,bool) + handler: handleMessageDispatched + - event: RetryFailedMessage(indexed bytes32,bool) + handler: handleRetryFailedMessage + - event: SetDefaultConfig(address,address) + handler: handleSetDefaultConfig + file: ./src/ormp-protocol.ts + - kind: ethereum + name: OrmpOracle + network: fantom + source: + address: "0x0002396F1D52323fcd1ae8079b38808F046882c3" + abi: OrmpOracle + startBlock: 624068 + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - Assigned + - SetApproved + - SetDapi + - SetFee + abis: + - name: OrmpOracle + file: ./abis/OrmpOracle.json + eventHandlers: + - event: Assigned(indexed bytes32,uint256) + handler: handleAssigned + - event: SetApproved(address,bool) + handler: handleSetApproved + - event: SetDapi(indexed uint256,address) + handler: handleSetDapi + - event: SetFee(indexed uint256,uint256) + handler: handleSetFee + file: ./src/ormp-oracle.ts + - kind: ethereum + name: OrmpRelayer + network: fantom + source: + address: "0x007EED6207c9AF3715964Fb7f8B5f44E002a3498" + abi: OrmpRelayer + startBlock: 624069 + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - OrmpRelayerAssigned + - OrmpRelayerSetApproved + - SetDstConfig + - SetDstPrice + abis: + - name: OrmpRelayer + file: ./abis/OrmpRelayer.json + eventHandlers: + - event: Assigned(indexed bytes32,uint256,bytes,bytes32[32]) + handler: handleAssigned + - event: SetApproved(address,bool) + handler: handleSetApproved + - event: SetDstConfig(indexed uint256,uint64,uint64) + handler: handleSetDstConfig + - event: SetDstPrice(indexed uint256,uint128,uint128) + handler: handleSetDstPrice + file: ./src/ormp-relayer.ts diff --git a/thegraph/ormpipe/tests/ormp-relayer-utils.ts b/thegraph/ormpipe/tests/ormp-relayer-utils.ts new file mode 100644 index 0000000..c188173 --- /dev/null +++ b/thegraph/ormpipe/tests/ormp-relayer-utils.ts @@ -0,0 +1,114 @@ +import { newMockEvent } from "matchstick-as" +import { ethereum, Bytes, BigInt, Address } from "@graphprotocol/graph-ts" +import { + Assigned, + SetApproved, + SetDstConfig, + SetDstPrice +} from "../generated/OrmpRelayer/OrmpRelayer" + +export function createAssignedEvent( + msgHash: Bytes, + fee: BigInt, + params: Bytes, + proof: Array +): Assigned { + let assignedEvent = changetype(newMockEvent()) + + assignedEvent.parameters = new Array() + + assignedEvent.parameters.push( + new ethereum.EventParam("msgHash", ethereum.Value.fromFixedBytes(msgHash)) + ) + assignedEvent.parameters.push( + new ethereum.EventParam("fee", ethereum.Value.fromUnsignedBigInt(fee)) + ) + assignedEvent.parameters.push( + new ethereum.EventParam("params", ethereum.Value.fromBytes(params)) + ) + assignedEvent.parameters.push( + new ethereum.EventParam("proof", ethereum.Value.fromFixedBytesArray(proof)) + ) + + return assignedEvent +} + +export function createSetApprovedEvent( + operator: Address, + approve: boolean +): SetApproved { + let setApprovedEvent = changetype(newMockEvent()) + + setApprovedEvent.parameters = new Array() + + setApprovedEvent.parameters.push( + new ethereum.EventParam("operator", ethereum.Value.fromAddress(operator)) + ) + setApprovedEvent.parameters.push( + new ethereum.EventParam("approve", ethereum.Value.fromBoolean(approve)) + ) + + return setApprovedEvent +} + +export function createSetDstConfigEvent( + chainId: BigInt, + baseGas: BigInt, + gasPerByte: BigInt +): SetDstConfig { + let setDstConfigEvent = changetype(newMockEvent()) + + setDstConfigEvent.parameters = new Array() + + setDstConfigEvent.parameters.push( + new ethereum.EventParam( + "chainId", + ethereum.Value.fromUnsignedBigInt(chainId) + ) + ) + setDstConfigEvent.parameters.push( + new ethereum.EventParam( + "baseGas", + ethereum.Value.fromUnsignedBigInt(baseGas) + ) + ) + setDstConfigEvent.parameters.push( + new ethereum.EventParam( + "gasPerByte", + ethereum.Value.fromUnsignedBigInt(gasPerByte) + ) + ) + + return setDstConfigEvent +} + +export function createSetDstPriceEvent( + chainId: BigInt, + dstPriceRatio: BigInt, + dstGasPriceInWei: BigInt +): SetDstPrice { + let setDstPriceEvent = changetype(newMockEvent()) + + setDstPriceEvent.parameters = new Array() + + setDstPriceEvent.parameters.push( + new ethereum.EventParam( + "chainId", + ethereum.Value.fromUnsignedBigInt(chainId) + ) + ) + setDstPriceEvent.parameters.push( + new ethereum.EventParam( + "dstPriceRatio", + ethereum.Value.fromUnsignedBigInt(dstPriceRatio) + ) + ) + setDstPriceEvent.parameters.push( + new ethereum.EventParam( + "dstGasPriceInWei", + ethereum.Value.fromUnsignedBigInt(dstGasPriceInWei) + ) + ) + + return setDstPriceEvent +} diff --git a/thegraph/ormpipe/tests/ormp-relayer.test.ts b/thegraph/ormpipe/tests/ormp-relayer.test.ts new file mode 100644 index 0000000..36e1cb1 --- /dev/null +++ b/thegraph/ormpipe/tests/ormp-relayer.test.ts @@ -0,0 +1,67 @@ +import { + assert, + describe, + test, + clearStore, + beforeAll, + afterAll +} from "matchstick-as/assembly/index" +import { Bytes, BigInt, Address } from "@graphprotocol/graph-ts" +import { OrmpRelayerAssigned } from "../generated/schema" +import { Assigned as AssignedEvent } from "../generated/OrmpRelayer/OrmpRelayer" +import { handleAssigned } from "../src/ormp-relayer" +import { createAssignedEvent } from "./ormp-relayer-utils" + +// Tests structure (matchstick-as >=0.5.0) +// https://thegraph.com/docs/en/developer/matchstick/#tests-structure-0-5-0 + +describe("Describe entity assertions", () => { + beforeAll(() => { + let msgHash = Bytes.fromI32(1234567890) + let fee = BigInt.fromI32(234) + let params = Bytes.fromI32(1234567890) + let proof = [Bytes.fromI32(1234567890)] + let newAssignedEvent = createAssignedEvent(msgHash, fee, params, proof) + handleAssigned(newAssignedEvent) + }) + + afterAll(() => { + clearStore() + }) + + // For more test scenarios, see: + // https://thegraph.com/docs/en/developer/matchstick/#write-a-unit-test + + test("Assigned created and stored", () => { + assert.entityCount("Assigned", 1) + + // 0xa16081f360e3847006db660bae1c6d1b2e17ec2a is the default address used in newMockEvent() function + assert.fieldEquals( + "Assigned", + "0xa16081f360e3847006db660bae1c6d1b2e17ec2a-1", + "msgHash", + "1234567890" + ) + assert.fieldEquals( + "Assigned", + "0xa16081f360e3847006db660bae1c6d1b2e17ec2a-1", + "fee", + "234" + ) + assert.fieldEquals( + "Assigned", + "0xa16081f360e3847006db660bae1c6d1b2e17ec2a-1", + "params", + "1234567890" + ) + assert.fieldEquals( + "Assigned", + "0xa16081f360e3847006db660bae1c6d1b2e17ec2a-1", + "proof", + "[1234567890]" + ) + + // More assert options: + // https://thegraph.com/docs/en/developer/matchstick/#asserts + }) +}) From 38ebcd515501ec0c97c3a9efe6e1118785ec8b57 Mon Sep 17 00:00:00 2001 From: fewensa Date: Thu, 19 Oct 2023 05:12:01 +0000 Subject: [PATCH 06/13] update start block for crab --- thegraph/ormpipe/subgraph-crab.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/thegraph/ormpipe/subgraph-crab.yaml b/thegraph/ormpipe/subgraph-crab.yaml index 7325668..22b182a 100644 --- a/thegraph/ormpipe/subgraph-crab.yaml +++ b/thegraph/ormpipe/subgraph-crab.yaml @@ -8,7 +8,7 @@ dataSources: source: address: "0x007471Db6AD668b30a7CE648589a4C8C4f65a36f" abi: Subapi - startBlock: 624384 + startBlock: 1525921 mapping: kind: ethereum/events apiVersion: 0.0.7 @@ -49,7 +49,7 @@ dataSources: source: address: "0x0034607daf9c1dc6628f6e09E81bB232B6603A89" abi: OrmpProtocol - startBlock: 624067 + startBlock: 1525422 mapping: kind: ethereum/events apiVersion: 0.0.7 @@ -85,7 +85,7 @@ dataSources: source: address: "0x0002396F1D52323fcd1ae8079b38808F046882c3" abi: OrmpOracle - startBlock: 624068 + startBlock: 1525423 mapping: kind: ethereum/events apiVersion: 0.0.7 @@ -114,7 +114,7 @@ dataSources: source: address: "0x007EED6207c9AF3715964Fb7f8B5f44E002a3498" abi: OrmpRelayer - startBlock: 624069 + startBlock: 1525423 mapping: kind: ethereum/events apiVersion: 0.0.7 From 285fba1da2e2c105cedbb2bb63872a6a395258f0 Mon Sep 17 00:00:00 2001 From: fewensa Date: Thu, 19 Oct 2023 05:14:02 +0000 Subject: [PATCH 07/13] update networks --- thegraph/ormpipe/networks.json | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/thegraph/ormpipe/networks.json b/thegraph/ormpipe/networks.json index 27c0c92..01a9376 100644 --- a/thegraph/ormpipe/networks.json +++ b/thegraph/ormpipe/networks.json @@ -1,5 +1,19 @@ { - "fantom": { + "arbitrum-sepolia": { + "OrmpProtocol": { + "address": "0x0034607daf9c1dc6628f6e09E81bB232B6603A89" + }, + "Subapi": { + "address": "0x007471Db6AD668b30a7CE648589a4C8C4f65a36f" + }, + "OrmpOracle": { + "address": "0x0002396F1D52323fcd1ae8079b38808F046882c3" + }, + "OrmpRelayer": { + "address": "0x007EED6207c9AF3715964Fb7f8B5f44E002a3498" + } + }, + "crab": { "OrmpProtocol": { "address": "0x0034607daf9c1dc6628f6e09E81bB232B6603A89" }, @@ -13,4 +27,4 @@ "address": "0x007EED6207c9AF3715964Fb7f8B5f44E002a3498" } } -} \ No newline at end of file +} From f107c4ac6e98d2ac50f612ee1f5eccc9f853a845 Mon Sep 17 00:00:00 2001 From: fewensa Date: Thu, 19 Oct 2023 05:15:33 +0000 Subject: [PATCH 08/13] update scripts --- thegraph/ormpipe/package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/thegraph/ormpipe/package.json b/thegraph/ormpipe/package.json index 4831765..b1947d5 100644 --- a/thegraph/ormpipe/package.json +++ b/thegraph/ormpipe/package.json @@ -4,10 +4,10 @@ "scripts": { "codegen": "graph codegen", "build": "graph build", - "deploy": "graph deploy --node https://api.studio.thegraph.com/deploy/ ormpipe", - "create-local": "graph create --node http://localhost:8020/ ormpipe", - "remove-local": "graph remove --node http://localhost:8020/ ormpipe", - "deploy-local": "graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 ormpipe", + "deploy:studio": "graph deploy --node https://api.studio.thegraph.com/deploy/", + "create:darwinia": "graph create --node https://thegraph-g2.darwinia.network/ormpipe/deploy/", + "remove:darwinia": "graph remove --node https://thegraph-g2.darwinia.network/ormpipe/deploy/", + "deploy:darwinia": "graph deploy --node https://thegraph-g2.darwinia.network/ormpipe/deploy/ --ipfs http://g2.generic.darwinia.network:5001/", "test": "graph test" }, "dependencies": { From 139ad742a184f982183cc0d964b69b86e7d30b86 Mon Sep 17 00:00:00 2001 From: fewensa Date: Thu, 19 Oct 2023 05:21:23 +0000 Subject: [PATCH 09/13] update config and entities name --- thegraph/ormpipe/package.json | 2 +- thegraph/ormpipe/schema.graphql | 16 ++++----- thegraph/ormpipe/src/subapi.ts | 32 ++++++++--------- .../ormpipe/subgraph-arbitrum-sepolia.yaml | 36 +++++++++---------- thegraph/ormpipe/subgraph-crab.yaml | 36 +++++++++---------- 5 files changed, 61 insertions(+), 61 deletions(-) diff --git a/thegraph/ormpipe/package.json b/thegraph/ormpipe/package.json index b1947d5..bbe3a9d 100644 --- a/thegraph/ormpipe/package.json +++ b/thegraph/ormpipe/package.json @@ -1,6 +1,6 @@ { "name": "ormpipe", - "license": "UNLICENSED", + "version": "0.0.1", "scripts": { "codegen": "graph codegen", "build": "graph build", diff --git a/thegraph/ormpipe/schema.graphql b/thegraph/ormpipe/schema.graphql index 8f2951c..530d343 100644 --- a/thegraph/ormpipe/schema.graphql +++ b/thegraph/ormpipe/schema.graphql @@ -1,6 +1,6 @@ ## === subapi -type AddBeacon @entity(immutable: true) { +type SubapiAddBeacon @entity(immutable: true) { id: Bytes! beaconId: Bytes! # bytes32 beacon_airnode: Bytes! # address @@ -12,7 +12,7 @@ type AddBeacon @entity(immutable: true) { transactionHash: Bytes! } -type AggregatedORMPData @entity(immutable: true) { +type SubapiAggregatedORMPData @entity(immutable: true) { id: Bytes! ormpData_count: BigInt! # uint256 ormpData_root: Bytes! # bytes32 @@ -21,7 +21,7 @@ type AggregatedORMPData @entity(immutable: true) { transactionHash: Bytes! } -type AirnodeRrpCompleted @entity(immutable: true) { +type SubapiAirnodeRrpCompleted @entity(immutable: true) { id: Bytes! beaconId: Bytes! # bytes32 requestId: Bytes! # bytes32 @@ -31,7 +31,7 @@ type AirnodeRrpCompleted @entity(immutable: true) { transactionHash: Bytes! } -type AirnodeRrpRequested @entity(immutable: true) { +type SubapiAirnodeRrpRequested @entity(immutable: true) { id: Bytes! beaconId: Bytes! # bytes32 requestId: Bytes! # bytes32 @@ -40,7 +40,7 @@ type AirnodeRrpRequested @entity(immutable: true) { transactionHash: Bytes! } -type OwnershipTransferStarted @entity(immutable: true) { +type SubapiOwnershipTransferStarted @entity(immutable: true) { id: Bytes! previousOwner: Bytes! # address newOwner: Bytes! # address @@ -49,7 +49,7 @@ type OwnershipTransferStarted @entity(immutable: true) { transactionHash: Bytes! } -type OwnershipTransferred @entity(immutable: true) { +type SubapiOwnershipTransferred @entity(immutable: true) { id: Bytes! previousOwner: Bytes! # address newOwner: Bytes! # address @@ -58,7 +58,7 @@ type OwnershipTransferred @entity(immutable: true) { transactionHash: Bytes! } -type RemoveBeacon @entity(immutable: true) { +type SubapiRemoveBeacon @entity(immutable: true) { id: Bytes! beaconId: Bytes! # bytes32 blockNumber: BigInt! @@ -66,7 +66,7 @@ type RemoveBeacon @entity(immutable: true) { transactionHash: Bytes! } -type SubAPIFeedUpdated @entity(immutable: true) { +type SubapiSubAPIFeedUpdated @entity(immutable: true) { id: Bytes! beaconId: Bytes! # bytes32 msgRoot_count: BigInt! # uint256 diff --git a/thegraph/ormpipe/src/subapi.ts b/thegraph/ormpipe/src/subapi.ts index 5acc246..ac66e71 100644 --- a/thegraph/ormpipe/src/subapi.ts +++ b/thegraph/ormpipe/src/subapi.ts @@ -9,18 +9,18 @@ import { SubAPIFeedUpdated as SubAPIFeedUpdatedEvent } from "../generated/Subapi/Subapi" import { - AddBeacon, - AggregatedORMPData, - AirnodeRrpCompleted, - AirnodeRrpRequested, - OwnershipTransferStarted, - OwnershipTransferred, - RemoveBeacon, - SubAPIFeedUpdated + SubapiAddBeacon, + SubapiAggregatedORMPData, + SubapiAirnodeRrpCompleted, + SubapiAirnodeRrpRequested, + SubapiOwnershipTransferStarted, + SubapiOwnershipTransferred, + SubapiRemoveBeacon, + SubapiSubAPIFeedUpdated } from "../generated/schema" export function handleAddBeacon(event: AddBeaconEvent): void { - let entity = new AddBeacon( + let entity = new SubapiAddBeacon( event.transaction.hash.concatI32(event.logIndex.toI32()) ) entity.beaconId = event.params.beaconId @@ -37,7 +37,7 @@ export function handleAddBeacon(event: AddBeaconEvent): void { } export function handleAggregatedORMPData(event: AggregatedORMPDataEvent): void { - let entity = new AggregatedORMPData( + let entity = new SubapiAggregatedORMPData( event.transaction.hash.concatI32(event.logIndex.toI32()) ) entity.ormpData_count = event.params.ormpData.count @@ -53,7 +53,7 @@ export function handleAggregatedORMPData(event: AggregatedORMPDataEvent): void { export function handleAirnodeRrpCompleted( event: AirnodeRrpCompletedEvent ): void { - let entity = new AirnodeRrpCompleted( + let entity = new SubapiAirnodeRrpCompleted( event.transaction.hash.concatI32(event.logIndex.toI32()) ) entity.beaconId = event.params.beaconId @@ -70,7 +70,7 @@ export function handleAirnodeRrpCompleted( export function handleAirnodeRrpRequested( event: AirnodeRrpRequestedEvent ): void { - let entity = new AirnodeRrpRequested( + let entity = new SubapiAirnodeRrpRequested( event.transaction.hash.concatI32(event.logIndex.toI32()) ) entity.beaconId = event.params.beaconId @@ -86,7 +86,7 @@ export function handleAirnodeRrpRequested( export function handleOwnershipTransferStarted( event: OwnershipTransferStartedEvent ): void { - let entity = new OwnershipTransferStarted( + let entity = new SubapiOwnershipTransferStarted( event.transaction.hash.concatI32(event.logIndex.toI32()) ) entity.previousOwner = event.params.previousOwner @@ -102,7 +102,7 @@ export function handleOwnershipTransferStarted( export function handleOwnershipTransferred( event: OwnershipTransferredEvent ): void { - let entity = new OwnershipTransferred( + let entity = new SubapiOwnershipTransferred( event.transaction.hash.concatI32(event.logIndex.toI32()) ) entity.previousOwner = event.params.previousOwner @@ -116,7 +116,7 @@ export function handleOwnershipTransferred( } export function handleRemoveBeacon(event: RemoveBeaconEvent): void { - let entity = new RemoveBeacon( + let entity = new SubapiRemoveBeacon( event.transaction.hash.concatI32(event.logIndex.toI32()) ) entity.beaconId = event.params.beaconId @@ -129,7 +129,7 @@ export function handleRemoveBeacon(event: RemoveBeaconEvent): void { } export function handleSubAPIFeedUpdated(event: SubAPIFeedUpdatedEvent): void { - let entity = new SubAPIFeedUpdated( + let entity = new SubapiSubAPIFeedUpdated( event.transaction.hash.concatI32(event.logIndex.toI32()) ) entity.beaconId = event.params.beaconId diff --git a/thegraph/ormpipe/subgraph-arbitrum-sepolia.yaml b/thegraph/ormpipe/subgraph-arbitrum-sepolia.yaml index 7325668..320820c 100644 --- a/thegraph/ormpipe/subgraph-arbitrum-sepolia.yaml +++ b/thegraph/ormpipe/subgraph-arbitrum-sepolia.yaml @@ -4,7 +4,7 @@ schema: dataSources: - kind: ethereum name: Subapi - network: fantom + network: arbitrum-sepolia source: address: "0x007471Db6AD668b30a7CE648589a4C8C4f65a36f" abi: Subapi @@ -14,14 +14,14 @@ dataSources: apiVersion: 0.0.7 language: wasm/assemblyscript entities: - - AddBeacon - - AggregatedORMPData - - AirnodeRrpCompleted - - AirnodeRrpRequested - - OwnershipTransferStarted - - OwnershipTransferred - - RemoveBeacon - - SubAPIFeedUpdated + - SubapiAddBeacon + - SubapiAggregatedORMPData + - SubapiAirnodeRrpCompleted + - SubapiAirnodeRrpRequested + - SubapiOwnershipTransferStarted + - SubapiOwnershipTransferred + - SubapiRemoveBeacon + - SubapiSubAPIFeedUpdated abis: - name: Subapi file: ./abis/Subapi.json @@ -45,7 +45,7 @@ dataSources: file: ./src/subapi.ts - kind: ethereum name: OrmpProtocol - network: fantom + network: arbitrum-sepolia source: address: "0x0034607daf9c1dc6628f6e09E81bB232B6603A89" abi: OrmpProtocol @@ -81,7 +81,7 @@ dataSources: file: ./src/ormp-protocol.ts - kind: ethereum name: OrmpOracle - network: fantom + network: arbitrum-sepolia source: address: "0x0002396F1D52323fcd1ae8079b38808F046882c3" abi: OrmpOracle @@ -91,10 +91,10 @@ dataSources: apiVersion: 0.0.7 language: wasm/assemblyscript entities: - - Assigned - - SetApproved - - SetDapi - - SetFee + - OrmpOracleAssigned + - OrmpOracleSetApproved + - OrmpOracleSetDapi + - OrmpOracleSetFee abis: - name: OrmpOracle file: ./abis/OrmpOracle.json @@ -110,7 +110,7 @@ dataSources: file: ./src/ormp-oracle.ts - kind: ethereum name: OrmpRelayer - network: fantom + network: arbitrum-sepolia source: address: "0x007EED6207c9AF3715964Fb7f8B5f44E002a3498" abi: OrmpRelayer @@ -122,8 +122,8 @@ dataSources: entities: - OrmpRelayerAssigned - OrmpRelayerSetApproved - - SetDstConfig - - SetDstPrice + - OrmpRelayerSetDstConfig + - OrmpRelayerSetDstPrice abis: - name: OrmpRelayer file: ./abis/OrmpRelayer.json diff --git a/thegraph/ormpipe/subgraph-crab.yaml b/thegraph/ormpipe/subgraph-crab.yaml index 22b182a..e88eec7 100644 --- a/thegraph/ormpipe/subgraph-crab.yaml +++ b/thegraph/ormpipe/subgraph-crab.yaml @@ -4,7 +4,7 @@ schema: dataSources: - kind: ethereum name: Subapi - network: fantom + network: crab source: address: "0x007471Db6AD668b30a7CE648589a4C8C4f65a36f" abi: Subapi @@ -14,14 +14,14 @@ dataSources: apiVersion: 0.0.7 language: wasm/assemblyscript entities: - - AddBeacon - - AggregatedORMPData - - AirnodeRrpCompleted - - AirnodeRrpRequested - - OwnershipTransferStarted - - OwnershipTransferred - - RemoveBeacon - - SubAPIFeedUpdated + - SubapiAddBeacon + - SubapiAggregatedORMPData + - SubapiAirnodeRrpCompleted + - SubapiAirnodeRrpRequested + - SubapiOwnershipTransferStarted + - SubapiOwnershipTransferred + - SubapiRemoveBeacon + - SubapiSubAPIFeedUpdated abis: - name: Subapi file: ./abis/Subapi.json @@ -45,7 +45,7 @@ dataSources: file: ./src/subapi.ts - kind: ethereum name: OrmpProtocol - network: fantom + network: crab source: address: "0x0034607daf9c1dc6628f6e09E81bB232B6603A89" abi: OrmpProtocol @@ -81,7 +81,7 @@ dataSources: file: ./src/ormp-protocol.ts - kind: ethereum name: OrmpOracle - network: fantom + network: crab source: address: "0x0002396F1D52323fcd1ae8079b38808F046882c3" abi: OrmpOracle @@ -91,10 +91,10 @@ dataSources: apiVersion: 0.0.7 language: wasm/assemblyscript entities: - - Assigned - - SetApproved - - SetDapi - - SetFee + - OrmpOracleAssigned + - OrmpOracleSetApproved + - OrmpOracleSetDapi + - OrmpOracleSetFee abis: - name: OrmpOracle file: ./abis/OrmpOracle.json @@ -110,7 +110,7 @@ dataSources: file: ./src/ormp-oracle.ts - kind: ethereum name: OrmpRelayer - network: fantom + network: crab source: address: "0x007EED6207c9AF3715964Fb7f8B5f44E002a3498" abi: OrmpRelayer @@ -122,8 +122,8 @@ dataSources: entities: - OrmpRelayerAssigned - OrmpRelayerSetApproved - - SetDstConfig - - SetDstPrice + - OrmpRelayerSetDstConfig + - OrmpRelayerSetDstPrice abis: - name: OrmpRelayer file: ./abis/OrmpRelayer.json From 958800722b7be94e67653bac882d9d5947030d05 Mon Sep 17 00:00:00 2001 From: fewensa Date: Thu, 19 Oct 2023 08:03:19 +0000 Subject: [PATCH 10/13] update address --- thegraph/ormpipe/subgraph-arbitrum-sepolia.yaml | 4 ++-- thegraph/ormpipe/subgraph-crab.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/thegraph/ormpipe/subgraph-arbitrum-sepolia.yaml b/thegraph/ormpipe/subgraph-arbitrum-sepolia.yaml index 320820c..ec2a642 100644 --- a/thegraph/ormpipe/subgraph-arbitrum-sepolia.yaml +++ b/thegraph/ormpipe/subgraph-arbitrum-sepolia.yaml @@ -6,9 +6,9 @@ dataSources: name: Subapi network: arbitrum-sepolia source: - address: "0x007471Db6AD668b30a7CE648589a4C8C4f65a36f" + address: "0x001F4321429B1E2DF774bdAe0fc62A7394652E0F" abi: Subapi - startBlock: 624384 + startBlock: 628572 mapping: kind: ethereum/events apiVersion: 0.0.7 diff --git a/thegraph/ormpipe/subgraph-crab.yaml b/thegraph/ormpipe/subgraph-crab.yaml index e88eec7..62d7d5d 100644 --- a/thegraph/ormpipe/subgraph-crab.yaml +++ b/thegraph/ormpipe/subgraph-crab.yaml @@ -6,9 +6,9 @@ dataSources: name: Subapi network: crab source: - address: "0x007471Db6AD668b30a7CE648589a4C8C4f65a36f" + address: "0x001F4321429B1E2DF774bdAe0fc62A7394652E0F" abi: Subapi - startBlock: 1525921 + startBlock: 1531532 mapping: kind: ethereum/events apiVersion: 0.0.7 From 5dd76c4ae35bd1c513256221c3a156b71b9319f0 Mon Sep 17 00:00:00 2001 From: fewensa Date: Thu, 19 Oct 2023 14:00:07 +0000 Subject: [PATCH 11/13] add seq to oracle and relayer assigned --- thegraph/ormpipe/schema.graphql | 2 ++ thegraph/ormpipe/src/ormp-oracle.ts | 1 + thegraph/ormpipe/src/ormp-relayer.ts | 1 + 3 files changed, 4 insertions(+) diff --git a/thegraph/ormpipe/schema.graphql b/thegraph/ormpipe/schema.graphql index 530d343..70d224b 100644 --- a/thegraph/ormpipe/schema.graphql +++ b/thegraph/ormpipe/schema.graphql @@ -146,6 +146,7 @@ type OrmpOracleAssigned @entity(immutable: true) { blockNumber: BigInt! blockTimestamp: BigInt! transactionHash: Bytes! + seq: BigInt! } type OrmpOracleSetApproved @entity(immutable: true) { @@ -185,6 +186,7 @@ type OrmpRelayerAssigned @entity(immutable: true) { blockNumber: BigInt! blockTimestamp: BigInt! transactionHash: Bytes! + seq: BigInt! } type OrmpRelayerSetApproved @entity(immutable: true) { diff --git a/thegraph/ormpipe/src/ormp-oracle.ts b/thegraph/ormpipe/src/ormp-oracle.ts index 744c053..3cf3b36 100644 --- a/thegraph/ormpipe/src/ormp-oracle.ts +++ b/thegraph/ormpipe/src/ormp-oracle.ts @@ -17,6 +17,7 @@ export function handleAssigned(event: AssignedEvent): void { entity.blockTimestamp = event.block.timestamp entity.transactionHash = event.transaction.hash + entity.seq = event.block.number.plus(event.logIndex); entity.save() } diff --git a/thegraph/ormpipe/src/ormp-relayer.ts b/thegraph/ormpipe/src/ormp-relayer.ts index b8a710c..fdca5a9 100644 --- a/thegraph/ormpipe/src/ormp-relayer.ts +++ b/thegraph/ormpipe/src/ormp-relayer.ts @@ -24,6 +24,7 @@ export function handleAssigned(event: AssignedEvent): void { entity.blockTimestamp = event.block.timestamp entity.transactionHash = event.transaction.hash + entity.seq = event.block.number.plus(event.logIndex); entity.save() } From a0d5d4a05eebac98bd74dc152d8c844b56d24cd3 Mon Sep 17 00:00:00 2001 From: fewensa Date: Fri, 20 Oct 2023 03:37:02 +0000 Subject: [PATCH 12/13] fix test --- thegraph/ormpipe/tests/subapi.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/thegraph/ormpipe/tests/subapi.test.ts b/thegraph/ormpipe/tests/subapi.test.ts index 6a9f077..10f3bfe 100644 --- a/thegraph/ormpipe/tests/subapi.test.ts +++ b/thegraph/ormpipe/tests/subapi.test.ts @@ -7,7 +7,7 @@ import { afterAll } from "matchstick-as/assembly/index" import { Bytes, Address } from "@graphprotocol/graph-ts" -import { AddBeacon } from "../generated/schema" +import { SubapiAddBeacon } from "../generated/schema" import { AddBeacon as AddBeaconEvent } from "../generated/Subapi/Subapi" import { handleAddBeacon } from "../src/subapi" import { createAddBeaconEvent } from "./subapi-utils" From 8f43f13a1fa0b1a100ee2e74c48b9a7a3ae5b625 Mon Sep 17 00:00:00 2001 From: fewensa Date: Mon, 23 Oct 2023 08:57:40 +0000 Subject: [PATCH 13/13] update address --- thegraph/ormpipe/subgraph-arbitrum-sepolia.yaml | 4 ++-- thegraph/ormpipe/subgraph-crab.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/thegraph/ormpipe/subgraph-arbitrum-sepolia.yaml b/thegraph/ormpipe/subgraph-arbitrum-sepolia.yaml index ec2a642..39b5dde 100644 --- a/thegraph/ormpipe/subgraph-arbitrum-sepolia.yaml +++ b/thegraph/ormpipe/subgraph-arbitrum-sepolia.yaml @@ -6,9 +6,9 @@ dataSources: name: Subapi network: arbitrum-sepolia source: - address: "0x001F4321429B1E2DF774bdAe0fc62A7394652E0F" + address: "0x00945C032A37454333d7044a52a5A42Aa0f6c608" abi: Subapi - startBlock: 628572 + startBlock: 646559 mapping: kind: ethereum/events apiVersion: 0.0.7 diff --git a/thegraph/ormpipe/subgraph-crab.yaml b/thegraph/ormpipe/subgraph-crab.yaml index 62d7d5d..0a23d9f 100644 --- a/thegraph/ormpipe/subgraph-crab.yaml +++ b/thegraph/ormpipe/subgraph-crab.yaml @@ -6,9 +6,9 @@ dataSources: name: Subapi network: crab source: - address: "0x001F4321429B1E2DF774bdAe0fc62A7394652E0F" + address: "0x00945C032A37454333d7044a52a5A42Aa0f6c608" abi: Subapi - startBlock: 1531532 + startBlock: 1558666 mapping: kind: ethereum/events apiVersion: 0.0.7