From eca09ad66b9ff5aa3c02bb166b95e42065cbd4d3 Mon Sep 17 00:00:00 2001 From: nikugogoi Date: Thu, 28 Apr 2022 17:13:32 +0530 Subject: [PATCH] Change postgraphile queries to work with v3 schema (#112) --- README.md | 10 ++++++++++ packages/graph-node/src/watcher.ts | 6 +++--- packages/ipld-eth-client/src/eth-client.ts | 3 +-- packages/ipld-eth-client/src/eth-queries.ts | 5 ++--- packages/util/src/misc.ts | 6 +++--- 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index e7cfc8e6..c4b01ee5 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,12 @@ Install packages (Node.JS v16.13.1): yarn ``` +Build packages: + +```bash +yarn build +``` + ## Tests * [graph-node](./packages/graph-node/README.md) @@ -53,6 +59,10 @@ The default config files used by the watchers assume the following services are `chainConfig = "./chain.json" # ETH_CHAIN_CONFIG` +## Watchers + +* [eden-watcher](./packages/eden-watcher/README.md) + ## Databases Note: Requires `postgres12`. diff --git a/packages/graph-node/src/watcher.ts b/packages/graph-node/src/watcher.ts index 71fdda3a..c368ea4c 100644 --- a/packages/graph-node/src/watcher.ts +++ b/packages/graph-node/src/watcher.ts @@ -167,7 +167,7 @@ export class GraphWatcher { const eventFragment = contractInterface.getEvent(eventSignature); - const tx = await this._getTransactionData(blockData.headerId, txHash); + const tx = await this._getTransactionData(txHash); const data = { block: blockData, @@ -299,14 +299,14 @@ export class GraphWatcher { } } - async _getTransactionData (headerId: number, txHash: string): Promise { + async _getTransactionData (txHash: string): Promise { let transaction = this._transactionsMap.get(txHash); if (transaction) { return transaction; } - transaction = await getFullTransaction(this._postgraphileClient, headerId, txHash); + transaction = await getFullTransaction(this._postgraphileClient, txHash); assert(transaction); this._transactionsMap.set(txHash, transaction); diff --git a/packages/ipld-eth-client/src/eth-client.ts b/packages/ipld-eth-client/src/eth-client.ts index 00956410..06306c62 100644 --- a/packages/ipld-eth-client/src/eth-client.ts +++ b/packages/ipld-eth-client/src/eth-client.ts @@ -92,11 +92,10 @@ export class EthClient { ); } - async getFullTransaction ({ headerId, txHash }: { headerId: number, txHash: string }): Promise { + async getFullTransaction (txHash: string): Promise { return this._graphqlClient.query( ethQueries.getFullTransaction, { - headerId, txHash } ); diff --git a/packages/ipld-eth-client/src/eth-queries.ts b/packages/ipld-eth-client/src/eth-queries.ts index ad1dfea7..0996b29d 100644 --- a/packages/ipld-eth-client/src/eth-queries.ts +++ b/packages/ipld-eth-client/src/eth-queries.ts @@ -86,7 +86,6 @@ export const getFullBlocks = gql` query allEthHeaderCids($blockNumber: BigInt, $blockHash: String) { allEthHeaderCids(condition: { blockNumber: $blockNumber, blockHash: $blockHash }) { nodes { - id cid blockNumber blockHash @@ -108,8 +107,8 @@ query allEthHeaderCids($blockNumber: BigInt, $blockHash: String) { `; export const getFullTransaction = gql` -query ethTransactionCidByHeaderIdAndTxHash($headerId: Int!, $txHash: String!) { - ethTransactionCidByHeaderIdAndTxHash(headerId: $headerId, txHash: $txHash) { +query ethTransactionCidByTxHash($txHash: String!) { + ethTransactionCidByTxHash(txHash: $txHash) { cid txHash index diff --git a/packages/util/src/misc.ts b/packages/util/src/misc.ts index ada8df1a..589025f1 100644 --- a/packages/util/src/misc.ts +++ b/packages/util/src/misc.ts @@ -213,10 +213,10 @@ export const getFullBlock = async (ethClient: EthClient, ethProvider: providers. }; }; -export const getFullTransaction = async (ethClient: EthClient, headerId: number, txHash: string): Promise => { +export const getFullTransaction = async (ethClient: EthClient, txHash: string): Promise => { const { - ethTransactionCidByHeaderIdAndTxHash: fullTx - } = await ethClient.getFullTransaction({ headerId, txHash }); + ethTransactionCidByTxHash: fullTx + } = await ethClient.getFullTransaction(txHash); assert(fullTx.blockByMhKey);