mirror of
https://github.com/cerc-io/watcher-ts
synced 2025-08-02 12:32:07 +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 log = debug('vulcanize:indexer');
|
||||||
|
|
||||||
const KIND_EDENNETWORK = 'EdenNetwork';
|
const KIND_EDENNETWORK = 'EdenNetwork';
|
||||||
const KIND_MERKLEDISTRIBUTOR = 'MerkleDistributor';
|
const KIND_MERKLEDISTRIBUTOR = 'EdenNetworkDistribution';
|
||||||
const KIND_DISTRIBUTORGOVERNANCE = 'DistributorGovernance';
|
const KIND_DISTRIBUTORGOVERNANCE = 'EdenNetworkGovernance';
|
||||||
|
|
||||||
const TRANSFER_EVENT = 'Transfer';
|
const TRANSFER_EVENT = 'Transfer';
|
||||||
const APPROVAL_EVENT = 'Approval';
|
const APPROVAL_EVENT = 'Approval';
|
||||||
|
@ -123,16 +123,25 @@ export class GraphWatcher {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get event handler based on event signature.
|
const { instance: { exports: instanceExports }, contractInterface } = this._dataSourceMap[contract];
|
||||||
const eventHandler = dataSource.mapping.eventHandlers.find((eventHandler: any) => eventHandler.event === eventSignature);
|
|
||||||
|
// 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) {
|
if (!eventHandler) {
|
||||||
log(`No handler configured in subgraph for event ${eventSignature}`);
|
log(`No handler configured in subgraph for event ${eventSignature}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { instance: { exports: instanceExports }, contractInterface } = this._dataSourceMap[contract];
|
|
||||||
|
|
||||||
const eventFragment = contractInterface.getEvent(eventSignature);
|
const eventFragment = contractInterface.getEvent(eventSignature);
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
|
Loading…
Reference in New Issue
Block a user