Skip to content

Commit 3233f4e

Browse files
committed
feat: Add support for forcing legacy transactions in chain configuration
1 parent 4e703fd commit 3233f4e

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

packages/thirdweb/src/chains/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ export type ChainOptions = {
2626
increaseZeroByteCount?: boolean;
2727
};
2828
faucets?: Array<string>;
29+
fees?: {
30+
/**
31+
* Whether to force legacy transactions (pre EIP-1559) for this chain
32+
*/
33+
forceLegacyTransactions?: boolean;
34+
};
2935
};
3036

3137
/**

packages/thirdweb/src/gas/fee-data.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,21 @@ export async function getDefaultGasOverrides(
114114
client: ThirdwebClient,
115115
chain: Chain,
116116
) {
117-
// if chain is in the force gas price list, always use gas price
118-
if (!FORCE_GAS_PRICE_CHAIN_IDS.includes(chain.id)) {
119-
const feeData = await getDynamicFeeData(client, chain);
120-
if (
121-
feeData.maxFeePerGas !== null &&
122-
feeData.maxPriorityFeePerGas !== null
123-
) {
124-
return {
125-
maxFeePerGas: feeData.maxFeePerGas,
126-
maxPriorityFeePerGas: feeData.maxPriorityFeePerGas,
127-
};
128-
}
117+
// if chain is configured to force legacy transactions or is in the legacy chain list
118+
if (
119+
chain.fees?.forceLegacyTransactions ||
120+
FORCE_GAS_PRICE_CHAIN_IDS.includes(chain.id)
121+
) {
122+
return {
123+
gasPrice: await getGasPrice({ client, chain, percentMultiplier: 10 }),
124+
};
125+
}
126+
const feeData = await getDynamicFeeData(client, chain);
127+
if (feeData.maxFeePerGas !== null && feeData.maxPriorityFeePerGas !== null) {
128+
return {
129+
maxFeePerGas: feeData.maxFeePerGas,
130+
maxPriorityFeePerGas: feeData.maxPriorityFeePerGas,
131+
};
129132
}
130133
return {
131134
gasPrice: await getGasPrice({ client, chain, percentMultiplier: 10 }),

0 commit comments

Comments
 (0)