Skip to content

Commit fdfae42

Browse files
committed
set onchainStatus for userop
1 parent cf932d9 commit fdfae42

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/server/schemas/transaction/index.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,13 @@ export const TransactionSchema = Type.Object({
193193
userOpHash: Type.Union([Type.String(), Type.Null()]),
194194
functionName: Type.Union([Type.String(), Type.Null()]),
195195
functionArgs: Type.Union([Type.String(), Type.Null()]),
196+
// @deprecated
196197
onChainTxStatus: Type.Union([Type.Number(), Type.Null()]),
198+
onchainStatus: Type.Union([
199+
Type.Literal("success"),
200+
Type.Literal("reverted"),
201+
Type.Null(),
202+
]),
197203
effectiveGasPrice: Type.Union([
198204
Type.String({
199205
description: "Effective Gas Price",
@@ -228,7 +234,7 @@ export const toTransactionSchema = (
228234
return null;
229235
};
230236

231-
const resolveOnchainStatus = () => {
237+
const resolveOnchainTxStatus = () => {
232238
if (transaction.status === "mined") {
233239
return transaction.onchainStatus === "success" ? 1 : 0;
234240
}
@@ -288,7 +294,9 @@ export const toTransactionSchema = (
288294
blockNumber:
289295
"minedAtBlock" in transaction ? Number(transaction.minedAtBlock) : null,
290296
retryCount: "retryCount" in transaction ? transaction.resendCount : 0,
291-
onChainTxStatus: resolveOnchainStatus(),
297+
onChainTxStatus: resolveOnchainTxStatus(),
298+
onchainStatus:
299+
"onchainStatus" in transaction ? transaction.onchainStatus : null,
292300
effectiveGasPrice:
293301
"effectiveGasPrice" in transaction && transaction.effectiveGasPrice
294302
? transaction.effectiveGasPrice.toString()

src/worker/tasks/mineTransactionWorker.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ const _mineUserOp = async (
192192
chain,
193193
userOpHash,
194194
});
195-
196195
if (!userOpReceiptRaw) {
197196
return null;
198197
}
@@ -215,7 +214,7 @@ const _mineUserOp = async (
215214
minedAt: new Date(),
216215
minedAtBlock: receipt.blockNumber,
217216
transactionType: receipt.type,
218-
onchainStatus: receipt.status,
217+
onchainStatus: userOpReceiptRaw.success ? "success" : "reverted",
219218
gasUsed: receipt.gasUsed,
220219
effectiveGasPrice: receipt.effectiveGasPrice,
221220
gas: receipt.gasUsed,

0 commit comments

Comments
 (0)