Change postgraphile queries to work with v3 schema (#112)

This commit is contained in:
nikugogoi 2022-04-28 17:13:32 +05:30 committed by GitHub
parent 654edf4008
commit eca09ad66b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 11 deletions

View File

@ -35,6 +35,12 @@ Install packages (Node.JS v16.13.1):
yarn yarn
``` ```
Build packages:
```bash
yarn build
```
## Tests ## Tests
* [graph-node](./packages/graph-node/README.md) * [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` `chainConfig = "./chain.json" # ETH_CHAIN_CONFIG`
## Watchers
* [eden-watcher](./packages/eden-watcher/README.md)
## Databases ## Databases
Note: Requires `postgres12`. Note: Requires `postgres12`.

View File

@ -167,7 +167,7 @@ export class GraphWatcher {
const eventFragment = contractInterface.getEvent(eventSignature); const eventFragment = contractInterface.getEvent(eventSignature);
const tx = await this._getTransactionData(blockData.headerId, txHash); const tx = await this._getTransactionData(txHash);
const data = { const data = {
block: blockData, block: blockData,
@ -299,14 +299,14 @@ export class GraphWatcher {
} }
} }
async _getTransactionData (headerId: number, txHash: string): Promise<Transaction> { async _getTransactionData (txHash: string): Promise<Transaction> {
let transaction = this._transactionsMap.get(txHash); let transaction = this._transactionsMap.get(txHash);
if (transaction) { if (transaction) {
return transaction; return transaction;
} }
transaction = await getFullTransaction(this._postgraphileClient, headerId, txHash); transaction = await getFullTransaction(this._postgraphileClient, txHash);
assert(transaction); assert(transaction);
this._transactionsMap.set(txHash, transaction); this._transactionsMap.set(txHash, transaction);

View File

@ -92,11 +92,10 @@ export class EthClient {
); );
} }
async getFullTransaction ({ headerId, txHash }: { headerId: number, txHash: string }): Promise<any> { async getFullTransaction (txHash: string): Promise<any> {
return this._graphqlClient.query( return this._graphqlClient.query(
ethQueries.getFullTransaction, ethQueries.getFullTransaction,
{ {
headerId,
txHash txHash
} }
); );

View File

@ -86,7 +86,6 @@ export const getFullBlocks = gql`
query allEthHeaderCids($blockNumber: BigInt, $blockHash: String) { query allEthHeaderCids($blockNumber: BigInt, $blockHash: String) {
allEthHeaderCids(condition: { blockNumber: $blockNumber, blockHash: $blockHash }) { allEthHeaderCids(condition: { blockNumber: $blockNumber, blockHash: $blockHash }) {
nodes { nodes {
id
cid cid
blockNumber blockNumber
blockHash blockHash
@ -108,8 +107,8 @@ query allEthHeaderCids($blockNumber: BigInt, $blockHash: String) {
`; `;
export const getFullTransaction = gql` export const getFullTransaction = gql`
query ethTransactionCidByHeaderIdAndTxHash($headerId: Int!, $txHash: String!) { query ethTransactionCidByTxHash($txHash: String!) {
ethTransactionCidByHeaderIdAndTxHash(headerId: $headerId, txHash: $txHash) { ethTransactionCidByTxHash(txHash: $txHash) {
cid cid
txHash txHash
index index

View File

@ -213,10 +213,10 @@ export const getFullBlock = async (ethClient: EthClient, ethProvider: providers.
}; };
}; };
export const getFullTransaction = async (ethClient: EthClient, headerId: number, txHash: string): Promise<any> => { export const getFullTransaction = async (ethClient: EthClient, txHash: string): Promise<any> => {
const { const {
ethTransactionCidByHeaderIdAndTxHash: fullTx ethTransactionCidByTxHash: fullTx
} = await ethClient.getFullTransaction({ headerId, txHash }); } = await ethClient.getFullTransaction(txHash);
assert(fullTx.blockByMhKey); assert(fullTx.blockByMhKey);