Skip to content

Commit

Permalink
Update API usage to get block events and transactions (#379)
Browse files Browse the repository at this point in the history
* Pass block number when fetching events in a block

* Pass block number when fetching a transaction
  • Loading branch information
prathamesh0 authored Nov 3, 2022
1 parent da397dd commit 2f9d886
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion packages/erc20-watcher/src/indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,9 @@ export class Indexer implements IndexerInterface {
parentHash
}: DeepPartial<BlockProgress>): Promise<[BlockProgress, DeepPartial<Event>[]]> {
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,
Expand Down
6 changes: 3 additions & 3 deletions packages/uni-info-watcher/src/indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -611,6 +610,7 @@ export class Indexer implements IndexerInterface {
parentHash
}: DeepPartial<BlockProgress>): Promise<[BlockProgress, DeepPartial<Event>[]]> {
assert(blockHash);
assert(blockNumber);

const events = await this._uniClient.getEvents(blockHash);

Expand All @@ -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);
})
);
Expand Down
3 changes: 2 additions & 1 deletion packages/uni-watcher/src/indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -559,9 +559,10 @@ export class Indexer implements IndexerInterface {
parentHash
}: DeepPartial<BlockProgress>): Promise<[BlockProgress, DeepPartial<Event>[]]> {
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,
Expand Down

0 comments on commit 2f9d886

Please sign in to comment.