Skip to content

Conversation

@MananTank
Copy link
Member

@MananTank MananTank commented Oct 28, 2025


PR-Codex overview

This PR addresses issues with the Safe wallet connection when using WalletConnect, enhancing the reliability of account retrieval.

Detailed summary

  • Updated the comment for account in controller.ts to clarify it retrieves the address from mainnet if available.
  • Modified the firstAccountOn function to return the first account if no account matches the specified caip.

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

Summary by CodeRabbit

  • Bug Fixes
    • Fixed Safe wallet connection issues with WalletConnect.
    • Improved account selection fallback when a mainnet account isn't available, so WalletConnect can connect using an available account.

@vercel
Copy link

vercel bot commented Oct 28, 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 Oct 28, 2025 5:27pm
nebula Ready Ready Preview Comment Oct 28, 2025 5:27pm
thirdweb_playground Ready Ready Preview Comment Oct 28, 2025 5:27pm
thirdweb-www Ready Ready Preview Comment Oct 28, 2025 5:27pm
wallet-ui Ready Ready Preview Comment Oct 28, 2025 5:27pm

@changeset-bot
Copy link

changeset-bot bot commented Oct 28, 2025

🦋 Changeset detected

Latest commit: c08fb13

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

@MananTank MananTank marked this pull request as ready for review October 28, 2025 17:05
@MananTank MananTank requested review from a team as code owners October 28, 2025 17:05
@github-actions github-actions bot added packages SDK Involves changes to the thirdweb SDK labels Oct 28, 2025
Copy link
Member Author

MananTank commented Oct 28, 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.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 28, 2025

Walkthrough

Adds a changeset declaring a patch release for "thirdweb" and updates the WalletConnect controller to relax account selection: when no account matches the requested CAIP (e.g., eip155:1), the code falls back to the first account in the namespace.

Changes

Cohort / File(s) Summary
Release metadata
.changeset/early-spoons-say.md
New changeset declaring a patch bump for thirdweb with description: "Fix Safe wallet connection issues with WalletConnect."
WalletConnect controller
packages/thirdweb/src/wallets/wallet-connect/controller.ts
connectWC now requests the first account via firstAccountOn(provider.session, 'eip155:1'). firstAccountOn updated to fall back to the namespace's first account if none match the specified CAIP; address portion is still returned.

Sequence Diagram(s)

sequenceDiagram
  participant App
  participant Controller as WalletConnectController
  participant Session as WCSession (namespaces)

  Note over Controller,Session #DDEBF7: connectWC -> firstAccountOn
  Controller->>Session: request accounts for CAIP 'eip155:1'
  alt Found account with eip155:1
    Session-->>Controller: returns matching account(s)
    Controller-->>App: return address (extracted from CAIP)
  else No eip155:1 account
    Session-->>Controller: return namespace accounts (non-eip155)
    Note right of Controller #FCE4D6: fallback to first account in namespace
    Controller-->>App: return address (extracted from first account)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Areas needing attention:
    • Ensure firstAccountOn correctly handles namespaces that exist but have empty account arrays.
    • Verify the fallback doesn't cause cross-chain address mismatches or unexpected account selection in multi-chain sessions.
    • Confirm comments and documentation reflect the relaxed guarantee about address chain (CAIP) matching.

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The PR description contains mostly placeholder template comments with limited content in the required sections. While a PR-Codex overview is present that describes the changes made (updating a comment for account retrieval and modifying firstAccountOn function), critical required sections from the template are missing or unfilled. Specifically, the issue tag (TEAM-0000 format) is not provided, the "How to test" section is absent, and the structured template format is not followed. Although the PR-Codex provides some useful context, the description is largely incomplete relative to the repository's defined template requirements. The author should fill out the PR description template more completely by adding the Linear issue tag (TEAM-0000), providing explicit "How to test" instructions (unit tests, specific testing scenarios, or playground steps), and expanding the "Notes for the reviewer" section. While the PR-Codex overview is helpful, it should supplement rather than replace the structured template sections. This ensures consistency with repository standards and provides clear guidance for reviewers and future reference.
Docstring Coverage ⚠️ Warning Docstring coverage is 25.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 PR title "SDK: Fix Safe wallet connection issues with WalletConnect" is directly related to the main change in the changeset and clearly communicates the primary purpose of the pull request. The title accurately reflects both the changeset description and the code modifications to the wallet connection controller, making it specific and actionable for developers reviewing the change history. The title is concise, avoids vague language, and provides sufficient clarity about what was fixed.
✨ 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 10-28-sdk_fix_safe_wallet_connection_issues_with_walletconnect

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.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 28, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 64.55 KB (0%) 1.3 s (0%) 214 ms (+270.23% 🔺) 1.6 s
thirdweb (cjs) 366.18 KB (0%) 7.4 s (0%) 638 ms (+30.18% 🔺) 8 s
thirdweb (minimal + tree-shaking) 5.73 KB (0%) 115 ms (0%) 121 ms (+5696.17% 🔺) 236 ms
thirdweb/chains (tree-shaking) 526 B (0%) 11 ms (0%) 99 ms (+5489.44% 🔺) 110 ms
thirdweb/react (minimal + tree-shaking) 19.09 KB (0%) 382 ms (0%) 109 ms (+3833.26% 🔺) 491 ms

@codecov
Copy link

codecov bot commented Oct 28, 2025

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.89%. Comparing base (68cca6f) to head (c08fb13).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
.../thirdweb/src/wallets/wallet-connect/controller.ts 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8327      +/-   ##
==========================================
- Coverage   54.89%   54.89%   -0.01%     
==========================================
  Files         919      919              
  Lines       60701    60702       +1     
  Branches     4133     4130       -3     
==========================================
- Hits        33323    33321       -2     
- Misses      27277    27279       +2     
- Partials      101      102       +1     
Flag Coverage Δ
packages 54.89% <0.00%> (-0.01%) ⬇️
Files with missing lines Coverage Δ
.../thirdweb/src/wallets/wallet-connect/controller.ts 7.13% <0.00%> (-0.02%) ⬇️

... and 4 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.

@graphite-app
Copy link
Contributor

graphite-app bot commented Oct 28, 2025

Merge activity

<!--

## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes"

If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000):

## Notes for the reviewer

Anything important to call out? Be sure to also clarify these in your comments.

## How to test

Unit tests, playground, etc.

-->

<!-- start pr-codex -->

---

## PR-Codex overview

This PR addresses issues with the Safe wallet connection when using `WalletConnect`, ensuring better handling of account retrieval.

### Detailed summary

- Updated the comment for `account` retrieval to clarify that it grabs the address from mainnet if available.
- Modified the `firstAccountOn` function to return the first account from the session if no matching account is found.

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

<!-- end pr-codex -->

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **Bug Fixes**
  * Fixed Safe wallet connection issues with WalletConnect

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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/wallets/wallet-connect/controller.ts (1)

160-160: Consider clarifying the comment to reflect fallback behavior.

The comment states "grab the address from mainnet if available" but doesn't mention that firstAccountOn now falls back to the first account in the namespace if mainnet is unavailable. While the address is chain-agnostic across EVM chains, a more precise comment would help future maintainers understand the behavior.

Consider this revision:

-  const account = firstAccountOn(provider.session, `eip155:1`); // grab the address from mainnet if available
+  const account = firstAccountOn(provider.session, `eip155:1`); // prefer mainnet account; falls back to first available account if mainnet not in session
📜 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 709af11 and c08fb13.

📒 Files selected for processing (2)
  • .changeset/early-spoons-say.md (1 hunks)
  • packages/thirdweb/src/wallets/wallet-connect/controller.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
.changeset/*.md

📄 CodeRabbit inference engine (AGENTS.md)

.changeset/*.md: Each change in packages/* must include a changeset for the appropriate package
Version bump rules: patch for non‑API changes; minor for new/modified public API

Files:

  • .changeset/early-spoons-say.md
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each 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
Avoid any and unknown unless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial, Pick, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose

**/*.{ts,tsx}: Use explicit function declarations and explicit return types in TypeScript
Limit each file to one stateless, single‑responsibility function
Re‑use shared types from @/types where applicable
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics when possible
Prefer composition over inheritance; use utility types (Partial, Pick, etc.)
Lazy‑import optional features and avoid top‑level side‑effects to reduce bundle size

Files:

  • packages/thirdweb/src/wallets/wallet-connect/controller.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Load heavy dependencies inside async paths to keep initial bundle lean (lazy loading)

Files:

  • packages/thirdweb/src/wallets/wallet-connect/controller.ts
packages/thirdweb/src/wallets/**

📄 CodeRabbit inference engine (CLAUDE.md)

packages/thirdweb/src/wallets/**: Unified Wallet and Account interfaces in wallet architecture
Support for in-app wallets (social/email login)
Smart wallets with account abstraction
EIP-1193, EIP-5792, EIP-7702 standard support in wallet modules

Files:

  • packages/thirdweb/src/wallets/wallet-connect/controller.ts
packages/thirdweb/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

packages/thirdweb/**/*.{ts,tsx}: Every public symbol must have comprehensive TSDoc with at least one compiling @example and a custom tag (@beta, @internal, @experimental, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose
Lazy‑load heavy dependencies inside async paths (e.g., const { jsPDF } = await import("jspdf"))

Files:

  • packages/thirdweb/src/wallets/wallet-connect/controller.ts
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-18T19:19:55.613Z
Learning: Applies to packages/thirdweb/src/wallets/** : EIP-1193, EIP-5792, EIP-7702 standard support in wallet modules
📚 Learning: 2025-07-18T19:19:55.613Z
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-18T19:19:55.613Z
Learning: Applies to packages/thirdweb/src/wallets/** : Unified `Wallet` and `Account` interfaces in wallet architecture

Applied to files:

  • packages/thirdweb/src/wallets/wallet-connect/controller.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: Size
  • GitHub Check: Unit Tests
  • GitHub Check: Lint Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (2)
.changeset/early-spoons-say.md (1)

1-5: LGTM! Changeset correctly declares a patch release.

The patch version bump is appropriate for this bug fix, as the changes improve internal WalletConnect logic without modifying public APIs or function signatures.

packages/thirdweb/src/wallets/wallet-connect/controller.ts (1)

292-296: Fix is correct; fallback behavior is intentional and properly documented.

The fallback to ns?.accounts[0] is intentionally designed for auto-connection scenarios where mainnet may not be available (as explicitly stated in the line 160 comment: "grab the address from mainnet if available"). Error handling at line 162-164 still throws if no accounts exist, preventing completely silent failures. Ethereum addresses are identical across EVM chains, making cross-chain address fallback technically valid.

The fix successfully addresses Safe wallet connections while maintaining safety through the existing error check.

@graphite-app graphite-app bot merged commit c08fb13 into main Oct 28, 2025
23 of 24 checks passed
@graphite-app graphite-app bot deleted the 10-28-sdk_fix_safe_wallet_connection_issues_with_walletconnect branch October 28, 2025 17:29
@joaquim-verges joaquim-verges mentioned this pull request Oct 28, 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.

3 participants