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:
2023-11-16 11:54:49 +05:30
committed by GitHub
co-authored by neeraj
parent 8e9d5092fc
commit 5b95335fde
4 changed files with 24 additions and 7 deletions
+15
View File
@@ -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);