mirror of
https://github.com/cerc-io/watcher-ts
synced 2024-11-19 20:36:19 +00:00
Get event handler using cleaned subgraph event signature (#73)
This commit is contained in:
parent
d4e79ceee4
commit
3d3ebb0e43
@ -51,8 +51,8 @@ import { Slash } from './entity/Slash';
|
||||
const log = debug('vulcanize:indexer');
|
||||
|
||||
const KIND_EDENNETWORK = 'EdenNetwork';
|
||||
const KIND_MERKLEDISTRIBUTOR = 'MerkleDistributor';
|
||||
const KIND_DISTRIBUTORGOVERNANCE = 'DistributorGovernance';
|
||||
const KIND_MERKLEDISTRIBUTOR = 'EdenNetworkDistribution';
|
||||
const KIND_DISTRIBUTORGOVERNANCE = 'EdenNetworkGovernance';
|
||||
|
||||
const TRANSFER_EVENT = 'Transfer';
|
||||
const APPROVAL_EVENT = 'Approval';
|
||||
|
@ -123,16 +123,25 @@ export class GraphWatcher {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get event handler based on event signature.
|
||||
const eventHandler = dataSource.mapping.eventHandlers.find((eventHandler: any) => eventHandler.event === eventSignature);
|
||||
const { instance: { exports: instanceExports }, contractInterface } = this._dataSourceMap[contract];
|
||||
|
||||
// Get event handler based on event topic (from event signature).
|
||||
const eventTopic = contractInterface.getEventTopic(eventSignature);
|
||||
const eventHandler = dataSource.mapping.eventHandlers.find((eventHandler: any) => {
|
||||
// The event signature we get from logDescription is different than that given in the subgraph yaml file.
|
||||
// For eg. event in subgraph.yaml: Stake(indexed address,uint256); from logDescription: Stake(address,uint256)
|
||||
// ethers.js doesn't recognize the subgraph event signature with indexed keyword before param type.
|
||||
// Match event topics from cleaned subgraph event signature (Stake(indexed address,uint256) -> Stake(address,uint256)).
|
||||
const subgraphEventTopic = contractInterface.getEventTopic(eventHandler.event.replace(/indexed /g, ''));
|
||||
|
||||
return subgraphEventTopic === eventTopic;
|
||||
});
|
||||
|
||||
if (!eventHandler) {
|
||||
log(`No handler configured in subgraph for event ${eventSignature}`);
|
||||
return;
|
||||
}
|
||||
|
||||
const { instance: { exports: instanceExports }, contractInterface } = this._dataSourceMap[contract];
|
||||
|
||||
const eventFragment = contractInterface.getEvent(eventSignature);
|
||||
|
||||
const data = {
|
||||
|
Loading…
Reference in New Issue
Block a user