mirror of
https://github.com/cerc-io/watcher-ts
synced 2026-09-12 02:27:31 +00:00
Handle array and struct type event params in codegen (#150)
* Handle array and struct type event params * Refactor parse event in watcher indexer code
This commit is contained in:
@@ -50,11 +50,6 @@ const log = debug('vulcanize:indexer');
|
||||
|
||||
export const KIND_PHISHERREGISTRY = 'PhisherRegistry';
|
||||
|
||||
const DELEGATIONTRIGGERED_EVENT = 'DelegationTriggered';
|
||||
const MEMBERSTATUSUPDATED_EVENT = 'MemberStatusUpdated';
|
||||
const OWNERSHIPTRANSFERRED_EVENT = 'OwnershipTransferred';
|
||||
const PHISHERSTATUSUPDATED_EVENT = 'PhisherStatusUpdated';
|
||||
|
||||
export type ResultEvent = {
|
||||
block: {
|
||||
cid: string;
|
||||
@@ -517,9 +512,6 @@ export class Indexer implements IPLDIndexerInterface {
|
||||
}
|
||||
|
||||
parseEventNameAndArgs (kind: string, logObj: any): any {
|
||||
let eventName = UNKNOWN_EVENT_NAME;
|
||||
let eventInfo = {};
|
||||
|
||||
const { topics, data } = logObj;
|
||||
|
||||
const contract = this._contractMap.get(kind);
|
||||
@@ -527,13 +519,7 @@ export class Indexer implements IPLDIndexerInterface {
|
||||
|
||||
const logDescription = contract.parseLog({ data, topics });
|
||||
|
||||
switch (kind) {
|
||||
case KIND_PHISHERREGISTRY: {
|
||||
({ eventName, eventInfo } = this.parsePhisherRegistryEvent(logDescription));
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
const { eventName, eventInfo } = this._baseIndexer.parseEvent(logDescription);
|
||||
|
||||
return {
|
||||
eventName,
|
||||
@@ -542,59 +528,6 @@ export class Indexer implements IPLDIndexerInterface {
|
||||
};
|
||||
}
|
||||
|
||||
parsePhisherRegistryEvent (logDescription: ethers.utils.LogDescription): { eventName: string, eventInfo: any } {
|
||||
let eventName = UNKNOWN_EVENT_NAME;
|
||||
let eventInfo = {};
|
||||
|
||||
switch (logDescription.name) {
|
||||
case DELEGATIONTRIGGERED_EVENT: {
|
||||
eventName = logDescription.name;
|
||||
const [principal, agent] = logDescription.args;
|
||||
eventInfo = {
|
||||
principal,
|
||||
agent
|
||||
};
|
||||
|
||||
break;
|
||||
}
|
||||
case MEMBERSTATUSUPDATED_EVENT: {
|
||||
eventName = logDescription.name;
|
||||
const [entity, isMember] = logDescription.args;
|
||||
eventInfo = {
|
||||
entity: entity.hash,
|
||||
isMember
|
||||
};
|
||||
|
||||
break;
|
||||
}
|
||||
case OWNERSHIPTRANSFERRED_EVENT: {
|
||||
eventName = logDescription.name;
|
||||
const [previousOwner, newOwner] = logDescription.args;
|
||||
eventInfo = {
|
||||
previousOwner,
|
||||
newOwner
|
||||
};
|
||||
|
||||
break;
|
||||
}
|
||||
case PHISHERSTATUSUPDATED_EVENT: {
|
||||
eventName = logDescription.name;
|
||||
const [entity, isPhisher] = logDescription.args;
|
||||
eventInfo = {
|
||||
entity: entity.hash,
|
||||
isPhisher
|
||||
};
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
eventName,
|
||||
eventInfo
|
||||
};
|
||||
}
|
||||
|
||||
async getIPLDStatus (): Promise<IpldStatus | undefined> {
|
||||
return this._db.getIPLDStatus();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user