Skip to content

Commit

Permalink
Include event signatures from all contracts in topics list
Browse files Browse the repository at this point in the history
  • Loading branch information
prathamesh0 committed Oct 26, 2023
1 parent 445a50f commit c978ba8
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions packages/util/src/indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,21 +304,19 @@ export class Indexer {

let addresses: string[] | undefined;
let eventSignatures: string[] = [];
const watchedContracts = this.getWatchedContracts();

if (this._serverConfig.filterLogsByAddresses) {
const watchedContracts = this.getWatchedContracts();
addresses = watchedContracts.map((watchedContract): string => {
return watchedContract.address;
});
}

if (this._serverConfig.filterLogsByTopics) {
const eventSignaturesSet = new Set<string>();
watchedContracts.forEach(watchedContract => {
(eventSignaturesMap.get(watchedContract.kind) || []).forEach(sig => {
eventSignaturesSet.add(sig);
});
});
eventSignaturesMap.forEach(sigs => sigs.forEach(sig => {
eventSignaturesSet.add(sig);
}));

eventSignatures = Array.from(eventSignaturesSet);
}
Expand Down Expand Up @@ -396,21 +394,19 @@ export class Indexer {
async fetchEvents (blockHash: string, blockNumber: number, eventSignaturesMap: Map<string, string[]>, parseEventNameAndArgs: (kind: string, logObj: any) => any): Promise<DeepPartial<EventInterface>[]> {
let addresses: string[] | undefined;
let eventSignatures: string[] = [];
const watchedContracts = this.getWatchedContracts();

if (this._serverConfig.filterLogsByAddresses) {
const watchedContracts = this.getWatchedContracts();
addresses = watchedContracts.map((watchedContract): string => {
return watchedContract.address;
});
}

if (this._serverConfig.filterLogsByTopics) {
const eventSignaturesSet = new Set<string>();
watchedContracts.forEach(watchedContract => {
(eventSignaturesMap.get(watchedContract.kind) || []).forEach(sig => {
eventSignaturesSet.add(sig);
});
});
eventSignaturesMap.forEach(sigs => sigs.forEach(sig => {
eventSignaturesSet.add(sig);
}));

eventSignatures = Array.from(eventSignaturesSet);
}
Expand Down

0 comments on commit c978ba8

Please sign in to comment.