Skip to content

Commit 2753d03

Browse files
committed
feat: add support for gasPrice in transaction overrides and schemas
1 parent b0fd43e commit 2753d03

File tree

5 files changed

+13
-3
lines changed

5 files changed

+13
-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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,8 @@ const _sendTransaction = async (
305305
// This call throws if the execution would be reverted.
306306
// The nonce is _not_ set yet.
307307

308+
console.log("override gas price", overrides?.gasPrice);
309+
308310
let populatedTransaction: PopulatedTransaction;
309311
try {
310312
populatedTransaction = await toSerializableTransaction({
@@ -320,6 +322,7 @@ const _sendTransaction = async (
320322
// Apply gas setting overrides.
321323
// Do not set `maxFeePerGas` to estimate the onchain value.
322324
gas: overrides?.gas,
325+
gasPrice: overrides?.gasPrice,
323326
maxPriorityFeePerGas: overrides?.maxPriorityFeePerGas,
324327
},
325328
});
@@ -403,6 +406,8 @@ const _sendTransaction = async (
403406
}
404407

405408
await addSentNonce(chainId, from, nonce);
409+
console.log("populated transaction gas price", populatedTransaction.gasPrice);
410+
406411
return {
407412
...queuedTransaction,
408413
status: "sent",

0 commit comments

Comments
 (0)