Skip to content

Commit 053fb8d

Browse files
authored
Update logs for processTx (#345)
1 parent 6021100 commit 053fb8d

File tree

1 file changed

+42
-12
lines changed

1 file changed

+42
-12
lines changed

src/worker/tasks/processTx.ts

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Static } from "@sinclair/typebox";
22
import {
33
StaticJsonRpcBatchProvider,
44
getDefaultGasOverrides,
5+
toEther,
56
} from "@thirdweb-dev/sdk";
67
import { ERC4337EthersSigner } from "@thirdweb-dev/wallets/dist/declarations/src/evm/connectors/smart-wallet/lib/erc4337-signer";
78
import { ethers } from "ethers";
@@ -64,7 +65,7 @@ export const processTx = async () => {
6465
service: "worker",
6566
level: "info",
6667
queueId: tx.queueId,
67-
message: `Cancelled by user`,
68+
message: `Cancelled`,
6869
});
6970
continue;
7071
}
@@ -73,7 +74,7 @@ export const processTx = async () => {
7374
service: "worker",
7475
level: "info",
7576
queueId: tx.queueId,
76-
message: `Picked up by worker`,
77+
message: `Processing`,
7778
});
7879

7980
await updateTx({
@@ -163,7 +164,7 @@ export const processTx = async () => {
163164
logger({
164165
service: "worker",
165166
level: "warn",
166-
message: `[Low Wallet Balance] [${walletAddress}] ${message}`,
167+
message: `[${walletAddress}] ${message}`,
167168
});
168169
}
169170

@@ -224,7 +225,25 @@ export const processTx = async () => {
224225
...gasOverrides,
225226
});
226227

227-
// TODO: Add debug/trace level info on transaction info
228+
logger({
229+
service: "worker",
230+
level: "debug",
231+
queueId: tx.queueId,
232+
message: `Populated`,
233+
data: {
234+
nonce: txRequest.nonce?.toString(),
235+
gasLimit: txRequest.gasLimit?.toString(),
236+
gasPrice: txRequest.gasPrice
237+
? toEther(txRequest.gasPrice)
238+
: undefined,
239+
maxFeePerGas: txRequest.maxFeePerGas
240+
? toEther(txRequest.maxFeePerGas)
241+
: undefined,
242+
maxPriorityFeePerGas: txRequest.maxPriorityFeePerGas
243+
? toEther(txRequest.maxPriorityFeePerGas)
244+
: undefined,
245+
},
246+
});
228247

229248
// TODO: We need to target specific cases
230249
// Bump gas limit to avoid occasional out of gas errors
@@ -233,12 +252,19 @@ export const processTx = async () => {
233252
: undefined;
234253

235254
const signature = await signer.signTransaction(txRequest);
255+
const rpcRequest = {
256+
id: 0,
257+
jsonrpc: "2.0",
258+
method: "eth_sendRawTransaction",
259+
params: [signature],
260+
};
236261

237262
logger({
238263
service: "worker",
239264
level: "debug",
240265
queueId: tx.queueId,
241-
message: `Sending transaction to ${provider.connection.url}`,
266+
message: `Sending to ${provider.connection.url}`,
267+
data: rpcRequest,
242268
});
243269

244270
const res = await fetch(provider.connection.url, {
@@ -251,14 +277,18 @@ export const processTx = async () => {
251277
}
252278
: {}),
253279
},
254-
body: JSON.stringify({
255-
id: 0,
256-
jsonrpc: "2.0",
257-
method: "eth_sendRawTransaction",
258-
params: [signature],
259-
}),
280+
body: JSON.stringify(rpcRequest),
260281
});
261282
const rpcResponse = (await res.json()) as RpcResponse;
283+
284+
logger({
285+
service: "worker",
286+
level: "debug",
287+
queueId: tx.queueId,
288+
message: `Received response`,
289+
data: rpcResponse,
290+
});
291+
262292
rpcResponses.push({
263293
queueId: tx.queueId!,
264294
tx: txRequest,
@@ -332,7 +362,7 @@ export const processTx = async () => {
332362
service: "worker",
333363
level: "warn",
334364
queueId,
335-
message: `Failed to send`,
365+
message: `Received error from RPC`,
336366
error: res.error,
337367
});
338368

0 commit comments

Comments
 (0)