diff --git a/src/executor/executorManager.ts b/src/executor/executorManager.ts index 9e5ed7e4..5544fd4f 100644 --- a/src/executor/executorManager.ts +++ b/src/executor/executorManager.ts @@ -428,7 +428,7 @@ export class ExecutorManager { this.eventManager.emitIncludedOnChain( userOperationHash, status.hash, - Number(status.transactionStatuses.blockTimeStamp) * 1000 + status.transactionStatuses.blockNumber as bigint ) this.monitor.setUserOperationStatus(userOperationHash, { status: "included", @@ -457,7 +457,8 @@ export class ExecutorManager { }) this.eventManager.emitFailedOnChain( userOperationHash, - status.hash + status.hash, + status.transactionStatuses.blockNumber as bigint ) this.logger.info( { diff --git a/src/handlers/eventManager.ts b/src/handlers/eventManager.ts index 18868c3b..5e5f13c7 100644 --- a/src/handlers/eventManager.ts +++ b/src/handlers/eventManager.ts @@ -30,23 +30,37 @@ export class EventManager { } // emits when the userOperation was mined onchain but failed - async emitFailedOnChain(userOperationHash: Hex, transactionHash: Hex) { + async emitFailedOnChain( + userOperationHash: Hex, + transactionHash: Hex, + blockNumber: bigint + ) { await this.emitEvent({ userOperationHash, event: { eventType: "failed_onchain", - transactionHash + transactionHash, + data: { + blockNumber: Number(blockNumber) + } } }) } // emits when the userOperation has been included onchain but bundled by a frontrunner - async emitFrontranOnChain(userOperationHash: Hex, transactionHash: Hex) { + async emitFrontranOnChain( + userOperationHash: Hex, + transactionHash: Hex, + blockNumber: bigint + ) { await this.emitEvent({ userOperationHash, event: { eventType: "frontran_onchain", - transactionHash + transactionHash, + data: { + blockNumber: Number(blockNumber) + } } }) } @@ -55,15 +69,17 @@ export class EventManager { async emitIncludedOnChain( userOperationHash: Hex, transactionHash: Hex, - timestamp: number + blockNumber: bigint ) { await this.emitEvent({ userOperationHash, event: { eventType: "included_onchain", - transactionHash - }, - timestamp + transactionHash, + data: { + blockNumber: Number(blockNumber) + } + } }) } diff --git a/src/types/schemas.ts b/src/types/schemas.ts index 22b12447..b9b64f5d 100644 --- a/src/types/schemas.ts +++ b/src/types/schemas.ts @@ -825,15 +825,24 @@ const OpEventType = z.union([ }), z.object({ eventType: z.literal("included_onchain"), - transactionHash: hexData32Schema + transactionHash: hexData32Schema, + data: z.object({ + blockNumber: z.number() + }) }), z.object({ eventType: z.literal("frontran_onchain"), - transactionHash: hexData32Schema + transactionHash: hexData32Schema, + data: z.object({ + blockNumber: z.number() + }) }), z.object({ eventType: z.literal("failed_onchain"), - transactionHash: hexData32Schema + transactionHash: hexData32Schema, + data: z.object({ + blockNumber: z.number() + }) }) ]) diff --git a/src/utils/userop.ts b/src/utils/userop.ts index b5c6e931..d3c738e7 100644 --- a/src/utils/userop.ts +++ b/src/utils/userop.ts @@ -196,14 +196,11 @@ export const transactionIncluded = async ( [userOperationHash: HexData32]: { accountDeployed: boolean } - blockTimeStamp: bigint + blockNumber: bigint | undefined }> => { try { const rcp = await publicClient.getTransactionReceipt({ hash: txHash }) - const block = await publicClient.getBlock({ - blockHash: rcp.blockHash - }) - const blockTimeStamp = block.timestamp + const blockNumber = rcp.blockNumber if (rcp.status === "success") { // find if any logs are UserOperationEvent or AccountDeployed @@ -283,23 +280,23 @@ export const transactionIncluded = async ( if (success) { return { status: "included", - blockTimeStamp, + blockNumber, ...r } } return { status: "reverted", - blockTimeStamp + blockNumber } } return { status: "failed", - blockTimeStamp + blockNumber } } catch (_e) { return { status: "not_found", - blockTimeStamp: 0n + blockNumber: undefined } } }