Skip to content

Conversation

@0xFirekeeper
Copy link
Member

@0xFirekeeper 0xFirekeeper commented Jan 14, 2026

The getZkGasFees function now falls back to standard EVM gas estimation methods when the zks_estimateFee RPC method is unavailable. This improves compatibility with zkSync chains that do not support zks_estimateFee and ensures transactions can still be processed. Corresponding tests have been added to verify the fallback logic.


PR-Codex overview

This PR focuses on enhancing the sendEip712Transaction functionality to support fallback mechanisms for gas fee estimation on zkSync chains that do not support zks_estimateFee, ensuring robust transaction processing.

Detailed summary

  • Updated thirdweb package version in .changeset/spotty-experts-rest.md.
  • Added defineChain import in send-eip712-transaction.test.ts.
  • Introduced a new test case to verify fallback to standard EVM methods for gas estimation.
  • Refactored send-eip712-transaction.ts to implement a try-catch for fee estimation, falling back to standard methods if zks_estimateFee fails.
  • Adjusted gas fee calculations to ensure proper values are returned when using fallback methods.

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

Summary by CodeRabbit

  • Bug Fixes

    • Gas fee estimation for zkSync transactions now includes a fallback to standard EVM-based estimation when the primary zkSync method is unavailable, ensuring transactions can still be priced and submitted.
  • Tests

    • Added test coverage that verifies the gas fee estimation fallback behavior and default fallback values when primary estimation is not supported.

✏️ Tip: You can customize this high-level summary in your review settings.

The getZkGasFees function now falls back to standard EVM gas estimation methods when the zks_estimateFee RPC method is unavailable. This improves compatibility with zkSync chains that do not support zks_estimateFee and ensures transactions can still be processed. Corresponding tests have been added to verify the fallback logic.
@0xFirekeeper 0xFirekeeper requested review from a team as code owners January 14, 2026 15:46
@changeset-bot
Copy link

changeset-bot bot commented Jan 14, 2026

🦋 Changeset detected

Latest commit: 9522486

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
thirdweb Patch
@thirdweb-dev/nebula Patch
@thirdweb-dev/wagmi-adapter Patch
wagmi-inapp Patch

Not sure what this means? Click here to learn what changesets are.

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

@vercel
Copy link

vercel bot commented Jan 14, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
docs-v2 Ready Ready Preview, Comment Jan 14, 2026 4:03pm
nebula Ready Ready Preview, Comment Jan 14, 2026 4:03pm
thirdweb_playground Ready Ready Preview, Comment Jan 14, 2026 4:03pm
thirdweb-www Ready Ready Preview, Comment Jan 14, 2026 4:03pm
wallet-ui Ready Ready Preview, Comment Jan 14, 2026 4:03pm

@github-actions github-actions bot added packages SDK Involves changes to the thirdweb SDK labels Jan 14, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 14, 2026

Walkthrough

Adds a fallback path to getZkGasFees that first tries zkSync's zks_estimateFee RPC and, on failure, falls back to EVM-style estimation using dynamic imports of estimateGas and gas data; tests add a case verifying fallback behavior and gasPerPubdata = 100000n.

Changes

Cohort / File(s) Summary
zkSync Gas Fee Estimation (implementation)
packages/thirdweb/src/transaction/actions/zksync/send-eip712-transaction.ts
Adds try-first zks_estimateFee path; on RPC failure dynamically imports and uses EVM estimateGas + gas data modules to compute gas, max fees, and sets fallback gasPerPubdata = 100000n
zkSync Gas Fee Estimation (tests)
packages/thirdweb/src/transaction/actions/zksync/send-eip712-transaction.test.ts
Adds a test validating fallback behavior when zks_estimateFee is unavailable; asserts non-zero gas fields and gasPerPubdata default
Changeset / release note
.changeset/spotty-experts-rest.md
Adds a patch changeset noting newer zkOS chains omit zks_rpc endpoints and require EVM fallback

Sequence Diagram

sequenceDiagram
    participant Test as Test/Caller
    participant getZkGasFees as getZkGasFees()
    participant ZkSyncRPC as zkSync RPC (zks_estimateFee)
    participant EVM as EVM Estimation (estimateGas)
    participant GasData as Gas Data Modules

    Test->>getZkGasFees: call(transaction, from)
    getZkGasFees->>ZkSyncRPC: request zks_estimateFee
    alt zkSync RPC responds
        ZkSyncRPC-->>getZkGasFees: zk gas + fees
        getZkGasFees-->>Test: return zkSync-formatted fees
    else RPC fails/error
        getZkGasFees->>EVM: dynamically import & call estimateGas
        getZkGasFees->>GasData: dynamically import fee data modules
        EVM-->>getZkGasFees: gas estimate
        GasData-->>getZkGasFees: fee data
        getZkGasFees-->>getZkGasFees: compute fallback fees (gasPerPubdata=100000n)
        getZkGasFees-->>Test: return fallback fees
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The PR description lacks required sections from the template: no PR title format, no issue tag, and no 'How to test' section detailing testing methodology. Add PR title in format '[SDK/Dashboard/Portal] Feature/Fix: ...', include issue tag (TEAM-0000), and describe testing approach including unit tests or playground verification.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding a fallback mechanism for gas fee estimation in zkSync when the primary method is unavailable.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

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 (2)
packages/thirdweb/src/transaction/actions/zksync/send-eip712-transaction.ts (2)

206-206: Consider logging or categorizing the caught error for debugging.

The empty catch swallows all errors, including potential network issues or malformed responses. While the fallback behavior is correct, silently failing without any logging could make debugging difficult in production.

💡 Optional improvement to add minimal error context
-    } catch {
+    } catch (error) {
       // Fallback to standard EVM methods if zks_estimateFee is not available
+      // Intentionally catching all errors - zks_estimateFee may not be supported

213-220: Pre-defined gas values get doubled, which may be unexpected.

When the user specifies gas but not maxFeePerGas, the function enters the estimation block. The fallback path reuses the user's gas value but still multiplies it by 2 (line 220). This is consistent with the zkSync path behavior but could surprise callers who expect their explicit gas value to be preserved.

Consider documenting this behavior or only applying the multiplier when gas was actually estimated:

♻️ Proposed fix to preserve user-specified gas
       const [estimatedGas, gasOverrides] = await Promise.all([
         gas === undefined
           ? estimateGas({ transaction, from })
           : Promise.resolve(gas),
         getDefaultGasOverrides(transaction.client, transaction.chain),
       ]);

-      gas = estimatedGas * 2n; // overestimating similar to zkSync estimation
+      // Only apply multiplier if we actually estimated gas
+      gas = gas === undefined ? estimatedGas * 2n : estimatedGas;
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 621f187 and 9319962.

📒 Files selected for processing (2)
  • packages/thirdweb/src/transaction/actions/zksync/send-eip712-transaction.test.ts
  • packages/thirdweb/src/transaction/actions/zksync/send-eip712-transaction.ts
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each TypeScript file to one stateless, single-responsibility function for clarity
Re-use shared types from @/types or local types.ts barrels
Prefer type aliases over interface except for nominal shapes in TypeScript
Avoid any and unknown in TypeScript unless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial, Pick, etc.) in TypeScript

**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each file to one stateless, single-responsibility function for clarity and testability
Re-use shared types from @/types or local types.ts barrel exports
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics whenever possible
Choose composition over inheritance; leverage utility types (Partial, Pick, etc.)
Comment only ambiguous logic in TypeScript files; avoid restating TypeScript types and signatures in prose

Files:

  • packages/thirdweb/src/transaction/actions/zksync/send-eip712-transaction.test.ts
  • packages/thirdweb/src/transaction/actions/zksync/send-eip712-transaction.ts
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.test.{ts,tsx}: Place tests alongside code: foo.tsfoo.test.ts in the same directory
Use real function invocations with stub data in tests; avoid brittle mocks
Use Mock Service Worker (MSW) for fetch/HTTP call interception in tests
Keep tests deterministic and side-effect free
Use predefined test accounts from test/src/test-wallets.ts in tests
Use FORKED_ETHEREUM_CHAIN for mainnet interactions and ANVIL_CHAIN for isolated tests

**/*.test.{ts,tsx}: Co-locate tests with source files using the pattern foo.ts ↔ foo.test.ts
Use real function invocations with stub data in tests; avoid brittle mocks
For network interactions in tests, use Mock Service Worker (MSW) to intercept fetch/HTTP calls, mocking only scenarios that are hard to reproduce
Keep tests deterministic and side-effect free; Vitest is pre-configured

Files:

  • packages/thirdweb/src/transaction/actions/zksync/send-eip712-transaction.test.ts
packages/thirdweb/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

packages/thirdweb/src/**/*.{ts,tsx}: Comment only ambiguous logic in SDK code; avoid restating TypeScript in prose
Load heavy dependencies inside async paths to keep initial bundle lean (e.g. const { jsPDF } = await import("jspdf");)

Lazy-load heavy dependencies inside async paths to keep the initial bundle lean (e.g., const { jsPDF } = await import('jspdf');)

Files:

  • packages/thirdweb/src/transaction/actions/zksync/send-eip712-transaction.test.ts
  • packages/thirdweb/src/transaction/actions/zksync/send-eip712-transaction.ts
**/*.{js,jsx,ts,tsx,json}

📄 CodeRabbit inference engine (AGENTS.md)

Biome governs formatting and linting; its rules live in biome.json. Run pnpm fix & pnpm lint before committing, ensure there are no linting errors

Files:

  • packages/thirdweb/src/transaction/actions/zksync/send-eip712-transaction.test.ts
  • packages/thirdweb/src/transaction/actions/zksync/send-eip712-transaction.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Lazy-import optional features; avoid top-level side-effects

Files:

  • packages/thirdweb/src/transaction/actions/zksync/send-eip712-transaction.test.ts
  • packages/thirdweb/src/transaction/actions/zksync/send-eip712-transaction.ts
🧬 Code graph analysis (2)
packages/thirdweb/src/transaction/actions/zksync/send-eip712-transaction.test.ts (2)
packages/thirdweb/src/exports/thirdweb.ts (1)
  • prepareTransaction (181-181)
packages/thirdweb/src/transaction/actions/zksync/send-eip712-transaction.ts (1)
  • getZkGasFees (164-244)
packages/thirdweb/src/transaction/actions/zksync/send-eip712-transaction.ts (1)
packages/thirdweb/src/gas/fee-data.ts (1)
  • getDefaultGasOverrides (127-154)
⏰ 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, vite)
  • GitHub Check: Lint Packages
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: Unit Tests
  • GitHub Check: Size
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: Build Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (3)
packages/thirdweb/src/transaction/actions/zksync/send-eip712-transaction.ts (2)

221-235: LGTM!

The fallback gas fee handling correctly accommodates both EIP-1559 and legacy fee structures from getDefaultGasOverrides. The 2x multiplier maintains consistency with the zkSync path for fast inclusion.


183-243: Good implementation of fallback mechanism with lazy imports.

The fallback logic correctly handles the case when zks_estimateFee is unavailable by falling back to standard EVM estimation methods. The dynamic imports (import("../estimate-gas.js") and import("../../../gas/fee-data.js")) follow the coding guidelines for lazy-loading heavy dependencies in async paths.

packages/thirdweb/src/transaction/actions/zksync/send-eip712-transaction.test.ts (1)

8-14: LGTM!

The new imports for defineChain and getZkGasFees are appropriate for testing the fallback mechanism.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

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

🤖 Fix all issues with AI agents
In @.changeset/spotty-experts-rest.md:
- Line 5: Update the changeset sentence "newer zkos chains no longer support
zks\_ rpc endpoints, fallback to evm std" to a clear, correctly spelled
sentence: capitalize and correct "zkos" to "zkSync", remove the unnecessary
backslash in "zks\_", and replace "evm std" with "the EVM standard" (e.g.,
"Newer zkSync chains no longer support zks RPC endpoints; fall back to the EVM
standard."). Also add a short clarifying phrase if helpful (for example, what
component falls back or why) to make the intent explicit.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 9319962 and 9522486.

📒 Files selected for processing (2)
  • .changeset/spotty-experts-rest.md
  • packages/thirdweb/src/transaction/actions/zksync/send-eip712-transaction.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/thirdweb/src/transaction/actions/zksync/send-eip712-transaction.test.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: Build Packages
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: Lint Packages
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: Size
  • GitHub Check: Unit Tests
  • GitHub Check: Analyze (javascript)

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

"thirdweb": patch
---

newer zkos chains no longer support zks\_ rpc endpoints, fallback to evm std
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix typos and improve clarity in the changeset description.

The description contains several issues:

  • "zkos" should be "zkSync"
  • Escaped underscore in "zks_" may be unnecessary
  • "evm std" should be "EVM standard"
  • Missing article and could be more descriptive
📝 Proposed fix for clarity
-newer zkos chains no longer support zks\_ rpc endpoints, fallback to evm std
+Newer zkSync chains no longer support zks_ RPC endpoints; fall back to the EVM standard
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
newer zkos chains no longer support zks\_ rpc endpoints, fallback to evm std
Newer zkSync chains no longer support zks_ RPC endpoints; fall back to the EVM standard
🤖 Prompt for AI Agents
In @.changeset/spotty-experts-rest.md at line 5, Update the changeset sentence
"newer zkos chains no longer support zks\_ rpc endpoints, fallback to evm std"
to a clear, correctly spelled sentence: capitalize and correct "zkos" to
"zkSync", remove the unnecessary backslash in "zks\_", and replace "evm std"
with "the EVM standard" (e.g., "Newer zkSync chains no longer support zks RPC
endpoints; fall back to the EVM standard."). Also add a short clarifying phrase
if helpful (for example, what component falls back or why) to make the intent
explicit.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 14, 2026

size-limit report 📦

Path Size
@thirdweb-dev/nexus (esm) 105.66 KB (0%)
@thirdweb-dev/nexus (cjs) 319.47 KB (0%)

@codecov
Copy link

codecov bot commented Jan 14, 2026

Codecov Report

❌ Patch coverage is 61.53846% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 53.06%. Comparing base (621f187) to head (9522486).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...nsaction/actions/zksync/send-eip712-transaction.ts 61.53% 15 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8637      +/-   ##
==========================================
+ Coverage   52.97%   53.06%   +0.08%     
==========================================
  Files         932      932              
  Lines       62270    62298      +28     
  Branches     4096     4105       +9     
==========================================
+ Hits        32987    33057      +70     
+ Misses      29184    29142      -42     
  Partials       99       99              
Flag Coverage Δ
packages 53.06% <61.53%> (+0.08%) ⬆️
Files with missing lines Coverage Δ
...nsaction/actions/zksync/send-eip712-transaction.ts 41.75% <61.53%> (+35.12%) ⬆️
🚀 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.

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.

2 participants