From a38fc4373b0d0b59ccc788e55570b821de5cbedf Mon Sep 17 00:00:00 2001 From: marie-fourier Date: Fri, 24 Nov 2023 14:12:34 +0500 Subject: [PATCH] fix events service --- packages/executor/src/executor.ts | 12 ++++++++++++ packages/executor/src/services/EventsService.ts | 17 ++++++++++------- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/packages/executor/src/executor.ts b/packages/executor/src/executor.ts index 1f1493e8..9a856c56 100644 --- a/packages/executor/src/executor.ts +++ b/packages/executor/src/executor.ts @@ -11,6 +11,7 @@ import { BundlingService, ReputationService, P2PService, + EventsService, } from "./services"; import { Config } from "./config"; import { BundlingMode, NetworkConfig } from "./interfaces"; @@ -46,6 +47,7 @@ export class Executor { public userOpValidationService: UserOpValidationService; public reputationService: ReputationService; public p2pService: P2PService; + public eventsService: EventsService; private db: IDbController; @@ -102,6 +104,16 @@ export class Executor { this.logger, this.metrics ); + this.eventsService = new EventsService( + this.chainId, + this.provider, + this.logger, + this.reputationService, + this.networkConfig.entryPoints, + this.db + ); + this.eventsService.initEventListener(); + this.web3 = new Web3(this.config); this.debug = new Debug( this.provider, diff --git a/packages/executor/src/services/EventsService.ts b/packages/executor/src/services/EventsService.ts index 8be009e3..a2d1d254 100644 --- a/packages/executor/src/services/EventsService.ts +++ b/packages/executor/src/services/EventsService.ts @@ -1,5 +1,5 @@ import { providers } from "ethers"; -import { IDbController } from "types/lib"; +import { IDbController, Logger } from "types/lib"; import { IEntryPoint } from "types/lib/executor/contracts"; import { IEntryPoint__factory } from "types/lib/executor/contracts/factories"; import { @@ -20,6 +20,7 @@ export class EventsService { constructor( private chainId: number, private provider: providers.JsonRpcProvider, + private logger: Logger, private reputationService: ReputationService, private entryPointAddrs: string[], private db: IDbController @@ -75,14 +76,16 @@ export class EventsService { | SignatureAggregatorChangedEvent ): Promise { switch (ev.event) { - case "UserOperationEventEvent": - await this.handleUserOperationEvent(ev as any); + case "UserOperationEvent": + await this.handleUserOperationEvent(ev as UserOperationEventEvent); break; case "AccountDeployedEvent": - await this.handleAccountDeployedEvent(ev as any); + await this.handleAccountDeployedEvent(ev as AccountDeployedEvent); break; - case "SignatureAggregatorForUserOperationsEvent": - await this.handleAggregatorChangedEvent(ev as any); + case "SignatureAggregatorForUserOperations": + await this.handleAggregatorChangedEvent( + ev as SignatureAggregatorChangedEvent + ); break; } } @@ -119,7 +122,7 @@ export class EventsService { } private async includedAddress(data: string | null): Promise { - if (data != null && data.length > 42) { + if (data != null && data.length >= 42) { const addr = data.slice(0, 42); await this.reputationService.updateIncludedStatus(addr); }