Skip to content

Commit

Permalink
fix events service
Browse files Browse the repository at this point in the history
  • Loading branch information
0xSulpiride committed Nov 24, 2023
1 parent a6dc4de commit a38fc43
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
12 changes: 12 additions & 0 deletions packages/executor/src/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
BundlingService,
ReputationService,
P2PService,
EventsService,
} from "./services";
import { Config } from "./config";
import { BundlingMode, NetworkConfig } from "./interfaces";
Expand Down Expand Up @@ -46,6 +47,7 @@ export class Executor {
public userOpValidationService: UserOpValidationService;
public reputationService: ReputationService;
public p2pService: P2PService;
public eventsService: EventsService;

private db: IDbController;

Expand Down Expand Up @@ -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,
Expand Down
17 changes: 10 additions & 7 deletions packages/executor/src/services/EventsService.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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
Expand Down Expand Up @@ -75,14 +76,16 @@ export class EventsService {
| SignatureAggregatorChangedEvent
): Promise<void> {
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;
}
}
Expand Down Expand Up @@ -119,7 +122,7 @@ export class EventsService {
}

private async includedAddress(data: string | null): Promise<void> {
if (data != null && data.length > 42) {
if (data != null && data.length >= 42) {
const addr = data.slice(0, 42);
await this.reputationService.updateIncludedStatus(addr);
}
Expand Down

0 comments on commit a38fc43

Please sign in to comment.