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
```
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`.

View File

@ -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<Transaction> {
async _getTransactionData (txHash: string): Promise<Transaction> {
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);

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(
ethQueries.getFullTransaction,
{
headerId,
txHash
}
);

View File

@ -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

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 {
ethTransactionCidByHeaderIdAndTxHash: fullTx
} = await ethClient.getFullTransaction({ headerId, txHash });
ethTransactionCidByTxHash: fullTx
} = await ethClient.getFullTransaction(txHash);
assert(fullTx.blockByMhKey);