1
- import assert from "assert " ;
2
- import { Job , Processor , Worker } from "bullmq " ;
1
+ import { Worker , type Job , type Processor } from "bullmq " ;
2
+ import assert from "node:assert " ;
3
3
import superjson from "superjson" ;
4
4
import {
5
- Address ,
6
5
eth_getTransactionByHash ,
7
6
eth_getTransactionReceipt ,
8
7
getAddress ,
9
8
getRpcClient ,
9
+ type Address ,
10
10
} from "thirdweb" ;
11
11
import { stringify } from "thirdweb/utils" ;
12
12
import { getUserOpReceipt , getUserOpReceiptRaw } from "thirdweb/wallets/smart" ;
@@ -21,16 +21,16 @@ import { logger } from "../../utils/logger";
21
21
import { recordMetrics } from "../../utils/prometheus" ;
22
22
import { redis } from "../../utils/redis/redis" ;
23
23
import { thirdwebClient } from "../../utils/sdk" ;
24
- import {
24
+ import type {
25
25
ErroredTransaction ,
26
26
MinedTransaction ,
27
27
SentTransaction ,
28
28
} from "../../utils/transaction/types" ;
29
29
import { enqueueTransactionWebhook } from "../../utils/transaction/webhook" ;
30
30
import { reportUsage } from "../../utils/usage" ;
31
31
import {
32
- MineTransactionData ,
33
32
MineTransactionQueue ,
33
+ type MineTransactionData ,
34
34
} from "../queues/mineTransactionQueue" ;
35
35
import { SendTransactionQueue } from "../queues/sendTransactionQueue" ;
36
36
@@ -59,7 +59,7 @@ const handler: Processor<any, void, string> = async (job: Job<string>) => {
59
59
}
60
60
61
61
if ( ! resultTransaction ) {
62
- job . log ( ` Transaction is not mined yet. Check again later...` ) ;
62
+ job . log ( " Transaction is not mined yet. Check again later..." ) ;
63
63
throw new Error ( "NOT_CONFIRMED_YET" ) ;
64
64
}
65
65
@@ -153,6 +153,11 @@ const _mineTransaction = async (
153
153
service : "worker" ,
154
154
} ) ;
155
155
156
+ const errorMessage =
157
+ receipt . status === "reverted"
158
+ ? "The transaction failed onchain. See: https://portal.thirdweb.com/engine/troubleshooting"
159
+ : undefined ;
160
+
156
161
return {
157
162
...sentTransaction ,
158
163
status : "mined" ,
@@ -164,6 +169,7 @@ const _mineTransaction = async (
164
169
gasUsed : receipt . gasUsed ,
165
170
effectiveGasPrice : receipt . effectiveGasPrice ,
166
171
cumulativeGasUsed : receipt . cumulativeGasUsed ,
172
+ errorMessage,
167
173
} ;
168
174
}
169
175
}
@@ -233,7 +239,7 @@ const _mineUserOp = async (
233
239
} catch ( e ) {
234
240
if ( e instanceof Error ) {
235
241
errorMessage = e . message ;
236
- await job . log ( " Failed to get userOpReceipt: " + e . message ) ;
242
+ await job . log ( ` Failed to get userOpReceipt: ${ e . message } ` ) ;
237
243
} else {
238
244
throw e ;
239
245
}
0 commit comments