Skip to content

Commit 56a9b3b

Browse files
authored
feat: add support for gasPrice in transaction overrides and schemas (#784)
* feat: add support for gasPrice in transaction overrides and schemas * remove debug log statements for gas price in sendTransactionWorker
1 parent d8f1ed9 commit 56a9b3b

File tree

5 files changed

+10
-3
lines changed

5 files changed

+10
-3
lines changed

src/server/schemas/transaction/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ export const toTransactionSchema = (
266266
if (transaction.status === "sent") {
267267
return transaction.gasPrice?.toString() ?? null;
268268
}
269-
return null;
269+
return transaction.overrides?.gasPrice?.toString() ?? null;
270270
};
271271

272272
const resolveMaxFeePerGas = (): string | null => {

src/server/schemas/txOverrides.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ export const txOverridesSchema = Type.Object({
1010
description: "Gas limit for the transaction",
1111
}),
1212

13-
// Overriding `gasPrice` is currently not supported.
14-
13+
gasPrice: Type.Optional({
14+
...WeiAmountStringSchema,
15+
description:
16+
"Gas price for the transaction. Do not use this if maxFeePerGas is set or if you want to use EIP-1559 type transactions. Only use this if you want to use legacy transactions.",
17+
}),
1518
maxFeePerGas: Type.Optional({
1619
...WeiAmountStringSchema,
1720
description: "Maximum fee per gas",

src/server/utils/transactionOverrides.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const parseTransactionOverrides = (
1818
return {
1919
overrides: {
2020
gas: maybeBigInt(overrides.gas),
21+
gasPrice: maybeBigInt(overrides.gasPrice),
2122
maxFeePerGas: maybeBigInt(overrides.maxFeePerGas),
2223
maxPriorityFeePerGas: maybeBigInt(overrides.maxPriorityFeePerGas),
2324
},

src/utils/transaction/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export type InsertedTransaction = {
2828
// User-provided overrides.
2929
overrides?: {
3030
gas?: bigint;
31+
gasPrice?: bigint;
3132
maxFeePerGas?: bigint;
3233
maxPriorityFeePerGas?: bigint;
3334
};

src/worker/tasks/sendTransactionWorker.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ const _sendTransaction = async (
320320
// Apply gas setting overrides.
321321
// Do not set `maxFeePerGas` to estimate the onchain value.
322322
gas: overrides?.gas,
323+
gasPrice: overrides?.gasPrice,
323324
maxPriorityFeePerGas: overrides?.maxPriorityFeePerGas,
324325
},
325326
});
@@ -403,6 +404,7 @@ const _sendTransaction = async (
403404
}
404405

405406
await addSentNonce(chainId, from, nonce);
407+
406408
return {
407409
...queuedTransaction,
408410
status: "sent",

0 commit comments

Comments
 (0)