Skip to content

fix gasPrice for legacy chain 88/89 #7638

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

Closed
wants to merge 8 commits into from
Closed

fix gasPrice for legacy chain 88/89 #7638

wants to merge 8 commits into from

Conversation

nischitpra
Copy link
Contributor

@nischitpra nischitpra commented Jul 17, 2025

PR-Codex overview

This PR introduces support for two new blockchain networks, Viction Testnet and Viction Mainnet, in the gas fee handling logic. It modifies the getDefaultGasOverrides function to return specific gas pricing for these networks.

Detailed summary

  • Added Viction Testnet and Viction Mainnet to the gas fee data.
  • Updated the getDefaultGasOverrides function to handle gas pricing for chain.id 88 and 89.
  • Changed the return object to include maxPriorityFeePerGas and maxFeePerGas for the new networks.

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

Summary by CodeRabbit

  • New Features

    • Added support for Viction Mainnet and Testnet, ensuring correct gas fee handling for these networks.
  • Bug Fixes

    • Improved gas override structure for Viction chains to enhance compatibility and transaction reliability.

@nischitpra nischitpra requested review from a team as code owners July 17, 2025 09:52
Copy link

changeset-bot bot commented Jul 17, 2025

⚠️ No Changeset found

Latest commit: 218dd29

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 Jul 17, 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 Jul 18, 2025 8:21am
nebula ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 18, 2025 8:21am
thirdweb_playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 18, 2025 8:21am
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 18, 2025 8:21am
wallet-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 18, 2025 8:21am

Copy link
Contributor

graphite-app bot commented Jul 17, 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

coderabbitai bot commented Jul 17, 2025

Walkthrough

The update modifies gas pricing logic by adding support for Viction Mainnet (chain ID 88) and Viction Testnet (chain ID 89) as forced legacy gas chains. For these two chains, the gas override object now includes maxPriorityFeePerGas and maxFeePerGas fields set to the fetched gas price.

Changes

File(s) Change Summary
packages/thirdweb/src/gas/fee-data.ts Added Viction Mainnet (88) and Testnet (89) to forced legacy gas list; updated gas override logic for these chains to return maxPriorityFeePerGas and maxFeePerGas fields instead of gasPrice.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant getDefaultGasOverrides
    participant Provider

    Caller->>getDefaultGasOverrides: Call with chainId and feeType
    alt feeType is legacy or chainId in forced legacy list
        getDefaultGasOverrides->>Provider: Fetch gasPrice
        alt chainId is 88 or 89 (Viction)
            getDefaultGasOverrides-->>Caller: Return { maxPriorityFeePerGas, maxFeePerGas }
        else other forced legacy chain
            getDefaultGasOverrides-->>Caller: Return { gasPrice }
        end
    else
        getDefaultGasOverrides-->>Caller: Return EIP-1559 overrides
    end
Loading

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 497deab and 218dd29.

📒 Files selected for processing (1)
  • packages/thirdweb/src/gas/fee-data.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/thirdweb/src/gas/fee-data.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Size
  • GitHub Check: Unit Tests
  • GitHub Check: Lint Packages
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/thirdweb/src/wallets/smart/lib/userop.ts (1)

273-276: Consider documenting the legacy chain handling.

The fix correctly addresses legacy chains (88 and 89) that don't support EIP-1559 gas pricing by using gasPrice instead of the EIP-1559 fields. However, consider adding a comment to explain this special handling.

+      // Legacy chains (88, 89) don't support EIP-1559, use gasPrice for both fee fields
       if (chain.id === 88 || chain.id === 89) {
         maxPriorityFeePerGas = feeData.gasPrice ?? 0n;
         maxFeePerGas = feeData.gasPrice ?? 0n;
       }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e125e74 and 10a1c7c.

📒 Files selected for processing (1)
  • packages/thirdweb/src/wallets/smart/lib/userop.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • CLAUDE.md
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T10:25:29.489Z
Learning: Applies to src/wallets/**/*.{ts,tsx} : Support EIP-1193, EIP-5792, EIP-7702 standards in wallet architecture
packages/thirdweb/src/wallets/smart/lib/userop.ts (9)
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T10:25:29.489Z
Learning: Applies to src/wallets/**/*.{ts,tsx} : Support EIP-1193, EIP-5792, EIP-7702 standards in wallet architecture
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T10:25:29.489Z
Learning: Applies to src/wallets/**/*.{ts,tsx} : Smart wallets with account abstraction in wallet architecture
Learnt from: joaquim-verges
PR: thirdweb-dev/js#7268
File: packages/thirdweb/src/wallets/in-app/core/wallet/in-app-core.ts:210-216
Timestamp: 2025-06-03T23:44:40.243Z
Learning: EIP7702 wallets do not need special handling for switching chains, unlike EIP4337 wallets which require reconnection when switching chains. In the switchChain method condition, EIP7702 should be intentionally excluded from the reconnection logic.
Learnt from: MananTank
PR: thirdweb-dev/js#7177
File: apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/public-pages/erc20/_hooks/useTokenPriceData.ts:49-49
Timestamp: 2025-05-27T19:55:25.056Z
Learning: In the ERC20 public pages token price data hook (`useTokenPriceData.ts`), direct array access on `json.data[0]` without optional chaining is intentionally correct and should not be changed to use safety checks.
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T10:25:29.489Z
Learning: Applies to src/wallets/**/*.{ts,tsx} : Unified `Wallet` and `Account` interfaces in wallet architecture
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T10:25:29.489Z
Learning: Applies to src/wallets/**/*.{ts,tsx} : Support for in-app wallets (social/email login) in wallet architecture
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T10:25:29.488Z
Learning: Applies to **/*.test.{ts,tsx} : Use `FORKED_ETHEREUM_CHAIN` for mainnet interactions and `ANVIL_CHAIN` for isolated tests
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T10:25:29.489Z
Learning: Applies to src/extensions/**/*.{ts,tsx} : Auto-generated contracts from ABI definitions in extensions
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T10:25:29.488Z
Learning: Applies to test/src/test-wallets.ts : Predefined test accounts are in `test/src/test-wallets.ts`
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: Size
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: Lint Packages
  • GitHub Check: Unit Tests
  • GitHub Check: Build Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (1)
packages/thirdweb/src/wallets/smart/lib/userop.ts (1)

273-273: Confirm Legacy Chain IDs
It looks like the code’s special-gas‐pricing branch in userop.ts uses hard-coded chain.id === 88 || chain.id === 89, but I couldn’t find any definitions or documentation for those IDs elsewhere in the repo.

Please verify that:

  • 88 and 89 are indeed the intended “legacy” networks requiring this override
  • You update these to named constants (e.g. LEGACY_MAINNET_ID_1, LEGACY_MAINNET_ID_2) and document which chains they map to

Copy link
Member

@0xFirekeeper 0xFirekeeper left a comment

Choose a reason for hiding this comment

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

Add it to the hardcoded list of legacy chains rather than doing this

Copy link
Contributor

github-actions bot commented Jul 17, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 63.24 KB (-0.02% 🔽) 1.3 s (-0.02% 🔽) 288 ms (+121.2% 🔺) 1.6 s
thirdweb (cjs) 353.17 KB (-0.04% 🔽) 7.1 s (-0.04% 🔽) 974 ms (+5.17% 🔺) 8.1 s
thirdweb (minimal + tree-shaking) 5.7 KB (0%) 114 ms (0%) 108 ms (+1708.45% 🔺) 222 ms
thirdweb/chains (tree-shaking) 526 B (0%) 11 ms (0%) 31 ms (+1129.72% 🔺) 41 ms
thirdweb/react (minimal + tree-shaking) 19.59 KB (0%) 392 ms (0%) 121 ms (+582.91% 🔺) 513 ms

Copy link

codecov bot commented Jul 17, 2025

Codecov Report

Attention: Patch coverage is 14.28571% with 12 lines in your changes missing coverage. Please review.

Project coverage is 56.42%. Comparing base (6e62a3a) to head (218dd29).

Files with missing lines Patch % Lines
packages/thirdweb/src/gas/fee-data.ts 14.28% 12 Missing ⚠️

❌ Your patch status has failed because the patch coverage (14.28%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7638      +/-   ##
==========================================
- Coverage   56.43%   56.42%   -0.02%     
==========================================
  Files         908      908              
  Lines       58193    58206      +13     
  Branches     4226     4225       -1     
==========================================
  Hits        32840    32840              
- Misses      25244    25257      +13     
  Partials      109      109              
Flag Coverage Δ
packages 56.42% <14.28%> (-0.02%) ⬇️
Files with missing lines Coverage Δ
packages/thirdweb/src/gas/fee-data.ts 59.66% <14.28%> (-3.43%) ⬇️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/thirdweb/src/gas/fee-data.ts (1)

140-150: Fix formatting and consider extracting the condition.

The logic is functionally correct, but the formatting needs improvement for consistency with the codebase.

Apply this diff to improve formatting:

-    const gasPrice = await getGasPrice({ chain, client, percentMultiplier: 10 })
-    if(chain.id === 88 || chain.id === 89) {
+    const gasPrice = await getGasPrice({ chain, client, percentMultiplier: 10 });
+    if (chain.id === 88 || chain.id === 89) {
       return {
         maxPriorityFeePerGas: gasPrice || 0n,
-        maxFeePerGas: gasPrice || 0n
-      }
+        maxFeePerGas: gasPrice || 0n,
+      };
     }

Consider extracting the condition for better readability:

+const isVictionChain = (chainId: number): boolean => chainId === 88 || chainId === 89;
+
     const gasPrice = await getGasPrice({ chain, client, percentMultiplier: 10 });
-    if (chain.id === 88 || chain.id === 89) {
+    if (isVictionChain(chain.id)) {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 26b6a67 and 4834aa5.

📒 Files selected for processing (1)
  • packages/thirdweb/src/gas/fee-data.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • CLAUDE.md
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T10:25:29.489Z
Learning: Applies to src/wallets/**/*.{ts,tsx} : Support EIP-1193, EIP-5792, EIP-7702 standards in wallet architecture
Learnt from: MananTank
PR: thirdweb-dev/js#7177
File: apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/public-pages/erc20/_hooks/useTokenPriceData.ts:49-49
Timestamp: 2025-05-27T19:55:25.056Z
Learning: In the ERC20 public pages token price data hook (`useTokenPriceData.ts`), direct array access on `json.data[0]` without optional chaining is intentionally correct and should not be changed to use safety checks.
Learnt from: joaquim-verges
PR: thirdweb-dev/js#7268
File: packages/thirdweb/src/wallets/in-app/core/wallet/in-app-core.ts:210-216
Timestamp: 2025-06-03T23:44:40.243Z
Learning: EIP7702 wallets do not need special handling for switching chains, unlike EIP4337 wallets which require reconnection when switching chains. In the switchChain method condition, EIP7702 should be intentionally excluded from the reconnection logic.
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T10:25:29.488Z
Learning: Applies to **/*.test.{ts,tsx} : Use `FORKED_ETHEREUM_CHAIN` for mainnet interactions and `ANVIL_CHAIN` for isolated tests
packages/thirdweb/src/gas/fee-data.ts (3)
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T10:25:29.489Z
Learning: Applies to src/wallets/**/*.{ts,tsx} : Support EIP-1193, EIP-5792, EIP-7702 standards in wallet architecture
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T10:25:29.488Z
Learning: Applies to **/*.test.{ts,tsx} : Use `FORKED_ETHEREUM_CHAIN` for mainnet interactions and `ANVIL_CHAIN` for isolated tests
Learnt from: MananTank
PR: thirdweb-dev/js#7177
File: apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/public-pages/erc20/_hooks/useTokenPriceData.ts:49-49
Timestamp: 2025-05-27T19:55:25.056Z
Learning: In the ERC20 public pages token price data hook (`useTokenPriceData.ts`), direct array access on `json.data[0]` without optional chaining is intentionally correct and should not be changed to use safety checks.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: Size
  • GitHub Check: Unit Tests
  • GitHub Check: Lint Packages
  • GitHub Check: Build Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (1)
packages/thirdweb/src/gas/fee-data.ts (1)

50-51: LGTM! Chain IDs added correctly.

The addition of Viction Mainnet (88) and Viction Testnet (89) to the forced legacy gas price chains follows the established pattern and includes proper documentation.

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.

4 participants