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