mirror of
https://github.com/cerc-io/watcher-ts
synced 2025-07-31 20:12:06 +00:00
Update codegen templates
This commit is contained in:
parent
ef0302e23d
commit
27b8c480bc
@ -2,6 +2,7 @@ className: Contract
|
||||
indexOn:
|
||||
- columns:
|
||||
- address
|
||||
- kind
|
||||
unique: true
|
||||
columns:
|
||||
- name: id
|
||||
|
@ -525,23 +525,27 @@ export class Indexer implements IndexerInterface {
|
||||
}
|
||||
|
||||
{{/if}}
|
||||
parseEventNameAndArgs (kind: string, logObj: any): { eventParsed: boolean, eventDetails: any } {
|
||||
parseEventNameAndArgs (watchedContracts: Contract[], logObj: any): { eventParsed: boolean, eventDetails: any } {
|
||||
const { topics, data } = logObj;
|
||||
let logDescription: ethers.utils.LogDescription | undefined;
|
||||
|
||||
const contract = this._contractMap.get(kind);
|
||||
assert(contract);
|
||||
for (const watchedContract of watchedContracts) {
|
||||
const contract = this._contractMap.get(watchedContract.kind);
|
||||
assert(contract);
|
||||
|
||||
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: {} };
|
||||
try {
|
||||
logDescription = contract.parseLog({ data, topics });
|
||||
break;
|
||||
} catch (err) {
|
||||
// Continue loop only if no matching event found
|
||||
if (!((err as Error).message.includes('no matching event'))) {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw err;
|
||||
if (!logDescription) {
|
||||
return { eventParsed: false, eventDetails: {} };
|
||||
}
|
||||
|
||||
const { eventName, eventInfo, eventSignature } = this._baseIndexer.parseEvent(logDescription);
|
||||
@ -647,8 +651,8 @@ export class Indexer implements IndexerInterface {
|
||||
return this._baseIndexer.getEventsByFilter(blockHash, contract, name);
|
||||
}
|
||||
|
||||
isWatchedContract (address : string): Contract | undefined {
|
||||
return this._baseIndexer.isWatchedContract(address);
|
||||
isContractAddressWatched (address : string): Contract[] | undefined {
|
||||
return this._baseIndexer.isContractAddressWatched(address);
|
||||
}
|
||||
|
||||
getWatchedContracts (): Contract[] {
|
||||
|
Loading…
Reference in New Issue
Block a user