From 35350ffdc752ced1fe3e3dfc3938d32e6ff76406 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Tue, 19 Mar 2024 17:28:09 +0530 Subject: [PATCH] Catch no matching event errors while parsing logs --- src/indexer.ts | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/indexer.ts b/src/indexer.ts index 2077a4f..d6acb75 100644 --- a/src/indexer.ts +++ b/src/indexer.ts @@ -513,20 +513,34 @@ export class Indexer implements IndexerInterface { console.timeEnd('time:indexer#processBlockAfterEvents-dump_subgraph_state'); } - parseEventNameAndArgs (kind: string, logObj: any): any { + parseEventNameAndArgs (kind: string, logObj: any): { eventParsed: boolean, eventDetails: any } { const { topics, data } = logObj; const contract = this._contractMap.get(kind); assert(contract); - const logDescription = contract.parseLog({ data, topics }); + let logDescription: ethers.utils.LogDescription; + try { + logDescription = contract.parseLog({ data, topics }); + } catch (err) { + // Return if no matching event found + if ((err as Error).message.includes('no matching event')) { + log(`WARNING: Skipping event for contract ${kind} as no matching event found in the ABI`); + return { eventParsed: false, eventDetails: {} }; + } + + throw err; + } const { eventName, eventInfo, eventSignature } = this._baseIndexer.parseEvent(logDescription); return { - eventName, - eventInfo, - eventSignature + eventParsed: true, + eventDetails: { + eventName, + eventInfo, + eventSignature + } }; }