-
Notifications
You must be signed in to change notification settings - Fork 620
SDK: Fix Safe wallet connection issues with WalletConnect #8327
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: Fix Safe wallet connection issues with WalletConnect #8327
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: c08fb13 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
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 |
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
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. |
WalkthroughAdds 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., Changes
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
Comment |
size-limit report 📦
|
Codecov Report❌ Patch coverage is
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
🚀 New features to boost your workflow:
|
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 -->
709af11 to
c08fb13
Compare
There was a problem hiding this 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
firstAccountOnnow 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.
📒 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 inpackages/*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@/typesor localtypes.tsbarrels
Prefer type aliases over interface except for nominal shapes
Avoidanyandunknownunless 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@/typeswhere applicable
Prefertypealiases overinterfaceexcept for nominal shapes
Avoidanyandunknownunless 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/**: UnifiedWalletandAccountinterfaces 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@exampleand 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.

PR-Codex overview
This PR addresses issues with the
Safewallet connection when usingWalletConnect, enhancing the reliability of account retrieval.Detailed summary
accountincontroller.tsto clarify it retrieves the address from mainnet if available.firstAccountOnfunction to return the first account if no account matches the specifiedcaip.Summary by CodeRabbit