Skip to content

Conversation

@joaquim-verges
Copy link
Member

@joaquim-verges joaquim-verges commented Nov 24, 2025


PR-Codex overview

This PR focuses on enhancing the thirdweb wallet functionality by preventing unnecessary chain switching for the cb wallet if it is already connected to the correct blockchain.

Detailed summary

  • Added a check to see if the current connected chain matches the desired chain in coinbase-web.ts.
  • If the chains match, the function returns early, avoiding unnecessary chain switching.

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

Summary by CodeRabbit

  • Bug Fixes
    • Optimized Coinbase wallet chain switching to skip redundant operations when already connected to the target network, improving performance and reducing unnecessary network requests.

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

@vercel
Copy link

vercel bot commented Nov 24, 2025

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

Project Deployment Preview Comments Updated (UTC)
docs-v2 Ready Ready Preview Comment Nov 24, 2025 11:19pm
nebula Ready Ready Preview Comment Nov 24, 2025 11:19pm
thirdweb_playground Ready Ready Preview Comment Nov 24, 2025 11:19pm
thirdweb-www Ready Ready Preview Comment Nov 24, 2025 11:19pm
wallet-ui Ready Ready Preview Comment Nov 24, 2025 11:19pm

@changeset-bot
Copy link

changeset-bot bot commented Nov 24, 2025

🦋 Changeset detected

Latest commit: d3f9b4d

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 24, 2025

Walkthrough

The pull request adds a changeset for a patch release and modifies the Coinbase wallet integration to check if the wallet is already connected to the target chain before attempting a chain switch operation.

Changes

Cohort / File(s) Summary
Release documentation
.changeset/vast-nails-wash.md
Introduces a patch changeset documenting the fix.
Coinbase wallet chain switching logic
packages/thirdweb/src/wallets/coinbase/coinbase-web.ts
Adds an early exit check in switchChainCoinbaseWalletSDK that queries the current chain via eth_chainId, and returns immediately if the target chain ID matches, avoiding redundant chain switch attempts.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • The changeset addition is straightforward documentation.
  • The logic change is a simple pre-check (early return) added before existing chain-switch logic; no control flow restructuring or complex interactions.
  • Verify that eth_chainId query and chain ID comparison are correct and handle edge cases (e.g., null/undefined returns).

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description is incomplete. It lacks required template sections including issue tag (TEAM-####), 'Notes for the reviewer', and 'How to test' sections, though it includes an auto-generated PR-Codex overview. Add missing required sections: include Linear issue tag, provide reviewer notes about any important implementation details, and document testing procedures (unit tests, playground, etc.).
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: skipping chain switching for Coinbase Wallet when already on the correct chain, matching the core objective of the PR.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch _Wallet_Skip_chain_switching_for_Coinbase_Wallet_if_already_on_correct_chain

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • TEAM-0000: Entity not found: Issue - Could not find referenced Issue.

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

@joaquim-verges joaquim-verges changed the title [Wallet] Skip chain switching for Coinbase Wallet if already on correct chain [SDK] Skip chain switching for Coinbase Wallet if already on correct chain Nov 24, 2025
@github-actions github-actions bot added packages SDK Involves changes to the thirdweb SDK labels Nov 24, 2025
@joaquim-verges joaquim-verges marked this pull request as ready for review November 24, 2025 23:06
@joaquim-verges joaquim-verges requested review from a team as code owners November 24, 2025 23:06
Copy link
Member Author

joaquim-verges commented Nov 24, 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.

This stack of pull requests is managed by Graphite. Learn more about stacking.

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)
.changeset/vast-nails-wash.md (1)

1-5: Patch bump is correct; consider polishing the description copy

The patch bump for thirdweb matches the scope here (internal behavioral change, no public API change). Nice alignment with the changeset guidelines.

Minor, optional wording tweak for readability and docs/searchability:

-Dont attempt chain switching for cb wallet if already connected to the right chain
+Don't attempt chain switching for Coinbase Wallet when already connected to the target chain

This:

  • Fixes the missing apostrophe in “Don't”.
  • Spells out “Coinbase Wallet” instead of “cb wallet”.
  • Uses “target chain” which is a bit clearer than “right chain”.

Based on learnings, this remains a patch-level change.

📜 Review details

Configuration used: CodeRabbit 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 9809d5c and d3f9b4d.

📒 Files selected for processing (2)
  • .changeset/vast-nails-wash.md (1 hunks)
  • packages/thirdweb/src/wallets/coinbase/coinbase-web.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{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/wallets/coinbase/coinbase-web.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/wallets/coinbase/coinbase-web.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/wallets/coinbase/coinbase-web.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

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

Files:

  • packages/thirdweb/src/wallets/coinbase/coinbase-web.ts
🧠 Learnings (4)
📓 Common learnings
Learnt from: joaquim-verges
Repo: thirdweb-dev/js PR: 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.
📚 Learning: 2025-06-03T23:44:40.243Z
Learnt from: joaquim-verges
Repo: thirdweb-dev/js PR: 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.

Applied to files:

  • packages/thirdweb/src/wallets/coinbase/coinbase-web.ts
  • .changeset/vast-nails-wash.md
📚 Learning: 2025-11-24T22:45:01.181Z
Learnt from: CR
Repo: thirdweb-dev/js PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T22:45:01.181Z
Learning: Applies to packages/**/.changeset/*.md : Each change in packages/* should contain a changeset for the appropriate package with the appropriate version bump: patch for changes that don't impact the public API, minor for any new/modified public API

Applied to files:

  • .changeset/vast-nails-wash.md
📚 Learning: 2025-06-06T23:46:08.795Z
Learnt from: MananTank
Repo: thirdweb-dev/js PR: 7298
File: apps/dashboard/src/app/nebula-app/move-funds/move-funds.tsx:424-424
Timestamp: 2025-06-06T23:46:08.795Z
Learning: The thirdweb project has an ESLint rule that restricts direct usage of `defineChain`. When it's necessary to use `defineChain` directly, it's acceptable to disable the rule with `// eslint-disable-next-line no-restricted-syntax`.

Applied to files:

  • .changeset/vast-nails-wash.md
🧬 Code graph analysis (1)
packages/thirdweb/src/wallets/coinbase/coinbase-web.ts (1)
packages/thirdweb/src/chains/utils.ts (1)
  • getCachedChain (79-89)
⏰ 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: Size
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: Unit Tests
  • GitHub Check: Build Packages
  • GitHub Check: Lint Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (1)
packages/thirdweb/src/wallets/coinbase/coinbase-web.ts (1)

477-485: Early chain check is correct and aligns with existing chain utilities

The new eth_chainId pre-check with normalizeChainId and getCachedChain is consistent with how this file already handles chain IDs, and the early return when connectedChain?.id === chain.id cleanly avoids redundant wallet_switchEthereumChain calls while keeping existing switch/add behavior intact for real mismatches.

This should address the Coinbase Wallet “already on chain” case without introducing new edge cases. ✅

@github-actions
Copy link
Contributor

github-actions bot commented Nov 24, 2025

size-limit report 📦

Path Size
@thirdweb-dev/nexus (esm) 104.88 KB (0%)
@thirdweb-dev/nexus (cjs) 316.6 KB (0%)

@codecov
Copy link

codecov bot commented Nov 24, 2025

Codecov Report

❌ Patch coverage is 0% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.82%. Comparing base (9809d5c) to head (d3f9b4d).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...ages/thirdweb/src/wallets/coinbase/coinbase-web.ts 0.00% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8453      +/-   ##
==========================================
- Coverage   54.83%   54.82%   -0.01%     
==========================================
  Files         919      919              
  Lines       60868    60875       +7     
  Branches     4140     4141       +1     
==========================================
  Hits        33374    33374              
- Misses      27392    27400       +8     
+ Partials      102      101       -1     
Flag Coverage Δ
packages 54.82% <0.00%> (-0.01%) ⬇️
Files with missing lines Coverage Δ
...ages/thirdweb/src/wallets/coinbase/coinbase-web.ts 33.93% <0.00%> (-0.73%) ⬇️

... and 1 file 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.

@joaquim-verges joaquim-verges merged commit 52aba0f into main Nov 24, 2025
23 of 26 checks passed
@joaquim-verges joaquim-verges deleted the _Wallet_Skip_chain_switching_for_Coinbase_Wallet_if_already_on_correct_chain branch November 24, 2025 23:13
@joaquim-verges joaquim-verges mentioned this pull request Nov 24, 2025
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