Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SDK] Feature: Add support for forcing legacy transactions in chain configuration #6180

Merged
merged 9 commits into from
Feb 27, 2025

Conversation

d4mr
Copy link
Member

@d4mr d4mr commented Feb 6, 2025

solves TOOL-3532


PR-Codex overview

This PR introduces enhancements related to transaction types and fee handling in the thirdweb package, adding support for new transaction types and fee structures.

Detailed summary

  • Added feeType to ChainOptions.
  • Introduced TransactionType with various types.
  • Updated StaticPrepareTransactionOptions to include type.
  • Modified transaction serialization to handle type.
  • Enhanced gas fee calculation to prioritize transaction fee types.
  • Updated getDefaultGasOverrides to consider feeType.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

@d4mr d4mr requested review from a team as code owners February 6, 2025 01:05
Copy link

changeset-bot bot commented Feb 6, 2025

⚠️ No Changeset found

Latest commit: 66fbe30

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Feb 6, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 26, 2025 11:52am
login ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 26, 2025 11:52am
thirdweb_playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 26, 2025 11:52am
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 26, 2025 11:52am
wallet-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 26, 2025 11:52am

Copy link

graphite-app bot commented Feb 6, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge-queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

Copy link
Contributor

github-actions bot commented Feb 6, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 46.56 KB (+0.01% 🔺) 932 ms (+0.01% 🔺) 591 ms (+65.27% 🔺) 1.6 s
thirdweb (cjs) 124.42 KB (+0.14% 🔺) 2.5 s (+0.14% 🔺) 814 ms (-21.18% 🔽) 3.4 s
thirdweb (minimal + tree-shaking) 5.6 KB (0%) 112 ms (0%) 135 ms (+75.33% 🔺) 247 ms
thirdweb/chains (tree-shaking) 506 B (0%) 10 ms (0%) 61 ms (+309.82% 🔺) 71 ms
thirdweb/react (minimal + tree-shaking) 19.35 KB (0%) 387 ms (0%) 207 ms (+49.53% 🔺) 594 ms

Copy link

codecov bot commented Feb 6, 2025

Codecov Report

Attention: Patch coverage is 91.02564% with 7 lines in your changes missing coverage. Please review.

Project coverage is 56.84%. Comparing base (35b7a0e) to head (842c37e).
Report is 43 commits behind head on main.

Files with missing lines Patch % Lines
packages/thirdweb/src/gas/fee-data.ts 76.00% 5 Missing and 1 partial ⚠️
packages/thirdweb/src/adapters/ethers5.ts 50.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6180   +/-   ##
=======================================
  Coverage   56.83%   56.84%           
=======================================
  Files        1168     1168           
  Lines       64789    64818   +29     
  Branches     5259     5264    +5     
=======================================
+ Hits        36825    36843   +18     
- Misses      27237    27248   +11     
  Partials      727      727           
Flag Coverage Δ *Carryforward flag
legacy_packages 65.68% <ø> (ø) Carriedforward from b2b1e46
packages 55.05% <91.02%> (+<0.01%) ⬆️

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
...transaction/actions/to-serializable-transaction.ts 78.72% <100.00%> (+2.81%) ⬆️
...es/thirdweb/src/transaction/prepare-transaction.ts 100.00% <100.00%> (ø)
packages/thirdweb/src/adapters/ethers5.ts 53.82% <50.00%> (-0.02%) ⬇️
packages/thirdweb/src/gas/fee-data.ts 71.60% <76.00%> (-2.26%) ⬇️

... and 2 files with indirect coverage changes

/**
* Whether to force legacy transactions (pre EIP-1559) for this chain
*/
forceLegacyTransactions?: boolean;
Copy link
Member

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
Member

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
Member 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"?

resolvePromisedValue(transaction.maxFeePerGas),
resolvePromisedValue(transaction.maxPriorityFeePerGas),
resolvePromisedValue(transaction.gasPrice),
resolvePromisedValue(transaction.feeType),
Copy link
Member

Choose a reason for hiding this comment

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

so we have it on the chain, on the tx AND in the function itself? seems a bit much no?

Copy link
Member

@gregfromstl gregfromstl Feb 6, 2025

Choose a reason for hiding this comment

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

It should come from the chains DB if possible but the user override only on the transaction. User override takes precedence

Copy link
Member Author

Choose a reason for hiding this comment

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

for context, I felt this need on engine where I need to expose configuration that allows users to force legacy transactions on a chain. Especially important when engine sends nonce cancellation transactions which are not user triggered. (I could manage this in engine too, but felt like it could be a more general thing so the SDK would benefit from it)

Copy link
Member

Choose a reason for hiding this comment

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

yeah chain level makes sense to me

resolvePromisedValue(transaction.maxFeePerGas),
resolvePromisedValue(transaction.maxPriorityFeePerGas),
resolvePromisedValue(transaction.gasPrice),
resolvePromisedValue(transaction.feeType),
Copy link
Member

Choose a reason for hiding this comment

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

yeah chain level makes sense to me

@@ -40,6 +43,7 @@ const FORCE_GAS_PRICE_CHAIN_IDS = [
1942999413, // Humanity Testnet
1952959480, // Lumia Testnet
994873017, // Lumia Mainnet
1942999413, // Humanity Mainnet
Copy link

Choose a reason for hiding this comment

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

The chain ID 1942999413 appears twice in FORCE_GAS_PRICE_CHAIN_IDS - once for Humanity Testnet and again for Humanity Mainnet. This appears to be a duplicate entry. If these networks truly have the same chain ID, one entry should be removed. If they are meant to be different networks, one of the chain IDs needs to be corrected.

Spotted by Graphite Reviewer

Is this helpful? React 👍 or 👎 to let us know.

Copy link
Member

Choose a reason for hiding this comment

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

looks like the bot is right @d4mr

@@ -17,6 +17,7 @@ export type StaticPrepareTransactionOptions = {
maxFeePerGas?: bigint | undefined;
maxPriorityFeePerGas?: bigint | undefined;
maxFeePerBlobGas?: bigint | undefined;
feeType?: FeeType | undefined;
Copy link
Member

Choose a reason for hiding this comment

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

actually lets not add this, lets just do the chain one.

this prop is too similar the tx.type one which also indicates if its a legacy or 1559 tx

Copy link
Member Author

Choose a reason for hiding this comment

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

we still would want a way to tell at the transaction level, hey please calculate the gas and send as legacy. If not this interface, we can use a different one, any thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

we have type in SerializableTransaction already should map to that

@@ -40,6 +43,7 @@ const FORCE_GAS_PRICE_CHAIN_IDS = [
1942999413, // Humanity Testnet
1952959480, // Lumia Testnet
994873017, // Lumia Mainnet
1942999413, // Humanity Mainnet
Copy link
Member

Choose a reason for hiding this comment

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

looks like the bot is right @d4mr

Copy link
Contributor

This PR has been inactive for 7 days. It is now marked as stale and will be closed in 2 days if no further activity occurs.

@github-actions github-actions bot added the Stale label Feb 26, 2025
}
// TODO: resolvedFeeType here could be "EIP1559", but we could not get EIP1559 fee data. should we throw?
Copy link
Member Author

Choose a reason for hiding this comment

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

@joaquim-verges wdyt about this btw

Copy link
Member

Choose a reason for hiding this comment

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

lets not throw, i think there's some cases where both type=1559 + gasprice are valid. polygon being one example IIRC

}
// TODO: resolvedFeeType here could be "EIP1559", but we could not get EIP1559 fee data. should we throw?
Copy link
Member

Choose a reason for hiding this comment

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

lets not throw, i think there's some cases where both type=1559 + gasprice are valid. polygon being one example IIRC

@github-actions github-actions bot removed the Stale label Feb 27, 2025
@joaquim-verges joaquim-verges merged commit 862db40 into main Feb 27, 2025
29 of 30 checks passed
@joaquim-verges joaquim-verges deleted the pb/force-legacy branch February 27, 2025 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
packages SDK Involves changes to the thirdweb SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants