From 2f9d88654d6d8c8ebe766fa865d43aaf21bba48d Mon Sep 17 00:00:00 2001 From: prathamesh0 <42446521+prathamesh0@users.noreply.github.com> Date: Thu, 3 Nov 2022 04:01:28 -0500 Subject: [PATCH] Update API usage to get block events and transactions (#379) * Pass block number when fetching events in a block * Pass block number when fetching a transaction --- packages/erc20-watcher/src/indexer.ts | 3 ++- packages/uni-info-watcher/src/indexer.ts | 6 +++--- packages/uni-watcher/src/indexer.ts | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/erc20-watcher/src/indexer.ts b/packages/erc20-watcher/src/indexer.ts index aecc4728..f64bbc03 100644 --- a/packages/erc20-watcher/src/indexer.ts +++ b/packages/erc20-watcher/src/indexer.ts @@ -515,8 +515,9 @@ export class Indexer implements IndexerInterface { parentHash }: DeepPartial): Promise<[BlockProgress, DeepPartial[]]> { assert(blockHash); + assert(blockNumber); - const dbEvents = await this._baseIndexer.fetchEvents(blockHash, this.parseEventNameAndArgs.bind(this)); + const dbEvents = await this._baseIndexer.fetchEvents(blockHash, blockNumber, this.parseEventNameAndArgs.bind(this)); const block = { id, diff --git a/packages/uni-info-watcher/src/indexer.ts b/packages/uni-info-watcher/src/indexer.ts index bc154397..06ef46f8 100644 --- a/packages/uni-info-watcher/src/indexer.ts +++ b/packages/uni-info-watcher/src/indexer.ts @@ -26,8 +26,7 @@ import { eventProcessingEthCallDuration, getFullTransaction, getFullBlock, - StateKind, - cachePrunedEntitiesCount + StateKind } from '@cerc-io/util'; import { EthClient } from '@cerc-io/ipld-eth-client'; import { StorageLayout, MappingKey } from '@cerc-io/solidity-mapper'; @@ -611,6 +610,7 @@ export class Indexer implements IndexerInterface { parentHash }: DeepPartial): Promise<[BlockProgress, DeepPartial[]]> { assert(blockHash); + assert(blockNumber); const events = await this._uniClient.getEvents(blockHash); @@ -624,7 +624,7 @@ export class Indexer implements IndexerInterface { await Promise.all( Array.from(txHashSet).map(async (txHash: any) => { - const transaction = await getFullTransaction(this._ethClient, txHash); + const transaction = await getFullTransaction(this._ethClient, txHash, blockNumber); transactionsMap.set(txHash, transaction); }) ); diff --git a/packages/uni-watcher/src/indexer.ts b/packages/uni-watcher/src/indexer.ts index 81f5ad05..ee556651 100644 --- a/packages/uni-watcher/src/indexer.ts +++ b/packages/uni-watcher/src/indexer.ts @@ -559,9 +559,10 @@ export class Indexer implements IndexerInterface { parentHash }: DeepPartial): Promise<[BlockProgress, DeepPartial[]]> { assert(blockHash); + assert(blockNumber); // serverConfig.filterLogs should not be set to allow fetching unknown events - const dbEvents = await this._baseIndexer.fetchEvents(blockHash, this.parseEventNameAndArgs.bind(this)); + const dbEvents = await this._baseIndexer.fetchEvents(blockHash, blockNumber, this.parseEventNameAndArgs.bind(this)); const block = { id,