Skip to content
6 changes: 6 additions & 0 deletions packages/thirdweb/src/chains/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ export type ChainOptions = {
increaseZeroByteCount?: boolean;
};
faucets?: Array<string>;
fees?: {
/**
* Whether to force legacy transactions (pre EIP-1559) for this chain
*/
forceLegacyTransactions?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't like the boolean because its inflexible, a type: "legacy" might be better (and matches viem/ox APIs)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might also want this on the transaction level if the user is providing it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed on both counts. So something like feeType: "legacy" | "eip1559"?

};
};

/**
Expand Down
27 changes: 15 additions & 12 deletions packages/thirdweb/src/gas/fee-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,21 @@
client: ThirdwebClient,
chain: Chain,
) {
// if chain is in the force gas price list, always use gas price
if (!FORCE_GAS_PRICE_CHAIN_IDS.includes(chain.id)) {
const feeData = await getDynamicFeeData(client, chain);
if (
feeData.maxFeePerGas !== null &&
feeData.maxPriorityFeePerGas !== null
) {
return {
maxFeePerGas: feeData.maxFeePerGas,
maxPriorityFeePerGas: feeData.maxPriorityFeePerGas,
};
}
// if chain is configured to force legacy transactions or is in the legacy chain list
if (
chain.fees?.forceLegacyTransactions ||
FORCE_GAS_PRICE_CHAIN_IDS.includes(chain.id)
) {
return {
gasPrice: await getGasPrice({ client, chain, percentMultiplier: 10 }),
};
}

Check warning on line 125 in packages/thirdweb/src/gas/fee-data.ts

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/gas/fee-data.ts#L122-L125

Added lines #L122 - L125 were not covered by tests
const feeData = await getDynamicFeeData(client, chain);
if (feeData.maxFeePerGas !== null && feeData.maxPriorityFeePerGas !== null) {
return {
maxFeePerGas: feeData.maxFeePerGas,
maxPriorityFeePerGas: feeData.maxPriorityFeePerGas,
};
}
return {
gasPrice: await getGasPrice({ client, chain, percentMultiplier: 10 }),
Expand Down
Loading