mirror of
https://github.com/cerc-io/watcher-ts
synced 2026-09-08 16:54:08 +00:00
Filter logs by events specified in subgraph config (#473)
* Use topic hash of events from config file * Add eventSignaturesMap field in IndexerInterface * Add eventSignaturesMap property in Indexer class --------- Co-authored-by: neeraj <neeraj.rtly@gmail.com>
This commit is contained in:
@@ -125,6 +125,21 @@ export class GraphWatcher {
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
this.fillEventSignatureMap();
|
||||
}
|
||||
|
||||
fillEventSignatureMap () {
|
||||
this._dataSources.forEach(contract => {
|
||||
if (contract.kind === 'ethereum/contract' && contract.mapping.kind === 'ethereum/events') {
|
||||
const contractName = contract.name;
|
||||
const topicHashes = contract.mapping.eventHandlers.map((handler: any) => {
|
||||
return this._dataSourceMap[contractName].contractInterface.getEventTopic(utils.EventFragment.from(handler.event).name);
|
||||
});
|
||||
assert(this._indexer);
|
||||
this._indexer.eventSignaturesMap.set(contractName, topicHashes);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
get dataSources (): any[] {
|
||||
|
||||
@@ -27,6 +27,7 @@ import { GetStorageAt, getStorageValue, MappingKey, StorageLayout } from '@cerc-
|
||||
export class Indexer implements IndexerInterface {
|
||||
_getStorageAt: GetStorageAt;
|
||||
_storageLayoutMap: Map<string, StorageLayout> = new Map();
|
||||
eventSignaturesMap: Map<string, string[]> = new Map();
|
||||
|
||||
constructor (ethClient: EthClient, storageLayoutMap?: Map<string, StorageLayout>) {
|
||||
this._getStorageAt = ethClient.getStorageAt.bind(ethClient);
|
||||
|
||||
Reference in New Issue
Block a user