From a269faf7feea05c7d8f9d29bb94ff787a7d32d5f Mon Sep 17 00:00:00 2001 From: marie-fourier Date: Mon, 1 Apr 2024 16:55:25 +0500 Subject: [PATCH] getUserOpByHash - fetch userop from mempool too --- packages/executor/src/modules/eth.ts | 14 ++++++++++++++ packages/types/src/api/interfaces.ts | 6 +++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/packages/executor/src/modules/eth.ts b/packages/executor/src/modules/eth.ts index 760abdf6..4dd4650e 100644 --- a/packages/executor/src/modules/eth.ts +++ b/packages/executor/src/modules/eth.ts @@ -307,6 +307,20 @@ export class Eth { async getUserOperationByHash( hash: string ): Promise { + const entry = await this.mempoolService.getEntryByHash(hash); + if (entry) { + let transaction: Partial = {}; + if (entry.transaction) { + transaction = await this.provider.getTransaction(entry.transaction); + } + return { + userOperation: entry.userOp, + entryPoint: entry.entryPoint, + transactionHash: transaction.hash, + blockHash: transaction.blockHash, + blockNumber: transaction.blockNumber, + }; + } const [entryPoint, event] = await this.getUserOperationEvent(hash); if (!entryPoint || !event) { return null; diff --git a/packages/types/src/api/interfaces.ts b/packages/types/src/api/interfaces.ts index d6960252..cb2e437b 100644 --- a/packages/types/src/api/interfaces.ts +++ b/packages/types/src/api/interfaces.ts @@ -16,9 +16,9 @@ export type EstimatedUserOperationGas = export type UserOperationByHashResponse = { userOperation: UserOperationStruct; entryPoint: string; - blockNumber: number; - blockHash: string; - transactionHash: string; + blockNumber?: number; + blockHash?: string; + transactionHash?: string; }; export type GetGasPriceResponse = {