mirror of
https://github.com/cerc-io/watcher-ts
synced 2026-09-12 10:37:32 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user