Get missing fields in transaction data for subgraph event handlers (#102)

* Get missing fields in event transaction

* Cache transaction data for event handlers in subgraph
This commit is contained in:
2021-12-29 13:21:39 +05:30
committed by GitHub
parent 561c2c9066
commit 9b1aa29afd
8 changed files with 128 additions and 35 deletions
@@ -92,6 +92,16 @@ export class EthClient {
);
}
async getFullTransaction ({ headerId, txHash }: { headerId: number, txHash: string }): Promise<any> {
return this._graphqlClient.query(
ethQueries.getFullTransaction,
{
headerId,
txHash
}
);
}
async getBlockByHash (blockHash?: string): Promise<any> {
const { block } = await this._graphqlClient.query(ethQueries.getBlockByHash, { blockHash });
block.number = parseInt(block.number, 16);
@@ -86,6 +86,7 @@ export const getFullBlocks = gql`
query allEthHeaderCids($blockNumber: BigInt, $blockHash: String) {
allEthHeaderCids(condition: { blockNumber: $blockNumber, blockHash: $blockHash }) {
nodes {
id
cid
blockNumber
blockHash
@@ -106,6 +107,21 @@ query allEthHeaderCids($blockNumber: BigInt, $blockHash: String) {
}
`;
export const getFullTransaction = gql`
query ethTransactionCidByHeaderIdAndTxHash($headerId: Int!, $txHash: String!) {
ethTransactionCidByHeaderIdAndTxHash(headerId: $headerId, txHash: $txHash) {
cid
txHash
index
src
dst
blockByMhKey {
data
}
}
}
`;
export const getBlockByHash = gql`
query block($blockHash: Bytes32) {
block(hash: $blockHash) {
@@ -158,6 +174,7 @@ export default {
getBlockWithTransactions,
getBlocks,
getFullBlocks,
getFullTransaction,
getBlockByHash,
subscribeBlocks,
subscribeTransactions