mirror of
https://github.com/cerc-io/watcher-ts
synced 2026-09-08 08:54:05 +00:00
Support events handlers in multiple data sources for a contract address (#526)
* Support processing events in multiple subgraph datasources for a single contract address * Fix parsing event topic in graph-node watcher * Update codegen templates * Fix dummy indexer method in graph-node test * Upgrade package versions to 0.2.102
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@cerc-io/codegen",
|
||||
"version": "0.2.101",
|
||||
"version": "0.2.102",
|
||||
"description": "Code generator",
|
||||
"private": true,
|
||||
"main": "index.js",
|
||||
@@ -20,7 +20,7 @@
|
||||
},
|
||||
"homepage": "https://github.com/cerc-io/watcher-ts#readme",
|
||||
"dependencies": {
|
||||
"@cerc-io/util": "^0.2.101",
|
||||
"@cerc-io/util": "^0.2.102",
|
||||
"@graphql-tools/load-files": "^6.5.2",
|
||||
"@npmcli/package-json": "^5.0.0",
|
||||
"@poanet/solidity-flattener": "https://github.com/vulcanize/solidity-flattener.git",
|
||||
|
||||
@@ -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[] {
|
||||
|
||||
@@ -41,12 +41,12 @@
|
||||
"homepage": "https://github.com/cerc-io/watcher-ts#readme",
|
||||
"dependencies": {
|
||||
"@apollo/client": "^3.3.19",
|
||||
"@cerc-io/cli": "^0.2.101",
|
||||
"@cerc-io/ipld-eth-client": "^0.2.101",
|
||||
"@cerc-io/solidity-mapper": "^0.2.101",
|
||||
"@cerc-io/util": "^0.2.101",
|
||||
"@cerc-io/cli": "^0.2.102",
|
||||
"@cerc-io/ipld-eth-client": "^0.2.102",
|
||||
"@cerc-io/solidity-mapper": "^0.2.102",
|
||||
"@cerc-io/util": "^0.2.102",
|
||||
{{#if (subgraphPath)}}
|
||||
"@cerc-io/graph-node": "^0.2.101",
|
||||
"@cerc-io/graph-node": "^0.2.102",
|
||||
{{/if}}
|
||||
"@ethersproject/providers": "^5.4.4",
|
||||
"debug": "^4.3.1",
|
||||
|
||||
Reference in New Issue
Block a user