Skip to content

Conversation

@joaquim-verges
Copy link
Member

@joaquim-verges joaquim-verges commented Jul 31, 2025

Fixes BLD-30


PR-Codex overview

This PR enhances the connectWC and autoConnectWC functions in the controller.ts file to support asynchronous session handlers and includes additional wallet information. It also introduces a new utility function, requestAndOpenWallet, to streamline wallet interactions.

Detailed summary

  • Added sessionHandler type to support Promise<void>.
  • Introduced walletInfo retrieval for connectWC and autoConnectWC.
  • Updated onConnect to pass walletInfo and sessionHandler.
  • Created requestAndOpenWallet for handling requests and opening the wallet.
  • Modified createAccount to include sessionRequestHandler and walletInfo.
  • Adapted transaction methods to utilize requestAndOpenWallet.

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

Summary by CodeRabbit

  • New Features
    • Improved WalletConnect session handling with support for asynchronous session requests and wallet-specific deep linking, enabling smoother user redirection to wallet apps.
  • Enhancements
    • Enhanced control and context during wallet connection, transaction signing, and message signing flows for a more seamless user experience.

@vercel
Copy link

vercel bot commented Jul 31, 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 31, 2025 9:33pm
nebula ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 31, 2025 9:33pm
thirdweb_playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 31, 2025 9:33pm
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 31, 2025 9:33pm
wallet-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 31, 2025 9:33pm

@changeset-bot
Copy link

changeset-bot bot commented Jul 31, 2025

⚠️ No Changeset found

Latest commit: e8ef574

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 31, 2025

Walkthrough

The update refactors the WalletConnect controller to enhance session request handling and wallet metadata management. It introduces asynchronous session request handlers, propagates wallet information throughout connection flows, and adds deep linking support for wallet redirection. Function signatures are updated to accept new parameters, and a helper function for provider requests is implemented.

Changes

Cohort / File(s) Change Summary
WalletConnect Controller Enhancements
packages/thirdweb/src/wallets/wallet-connect/controller.ts
- Updated function signatures for connectWC, autoConnectWC, initProvider, and onConnect to accept walletInfo and asynchronous sessionRequestHandler.
- Added requestAndOpenWallet helper to manage provider requests and trigger session handlers with deep link URLs.
- Enhanced provider metadata with redirect URLs for native/universal app redirection.
- Updated internal flows to propagate wallet info and session handlers.

Sequence Diagram(s)

sequenceDiagram
    participant App
    participant Controller
    participant Provider
    participant Wallet

    App->>Controller: connectWC(options, emitter, walletId, storage, sessionRequestHandler)
    Controller->>Provider: initProvider(options, walletId, sessionRequestHandler)
    Provider-->>Controller: provider instance (with metadata)
    Controller->>Wallet: Fetch walletInfo
    Controller->>App: onConnect(address, chain, provider, emitter, storage, client, walletInfo, sessionRequestHandler)
    App->>Controller: request (e.g., send transaction)
    Controller->>Controller: requestAndOpenWallet({provider, payload, chain, walletInfo, sessionRequestHandler})
    Controller->>Wallet: sessionRequestHandler(deepLinkURL) (async)
    Controller->>Provider: provider.request(payload)
    Provider-->>Controller: result
    Controller-->>App: result
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~35 minutes

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

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.
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch _WalletConnect_Add_deep_linking_support_for_transaction_signing

🪧 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 generate unit tests to generate unit tests for 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.

@github-actions github-actions bot added packages SDK Involves changes to the thirdweb SDK labels Jul 31, 2025
Copy link
Member Author


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.

@joaquim-verges joaquim-verges changed the title [WalletConnect] Add deep linking support for transaction signing [SDK] Add WalletConnect deep linking support for transaction signing Jul 31, 2025
@joaquim-verges joaquim-verges changed the title [SDK] Add WalletConnect deep linking support for transaction signing [SDK] Add WalletConnect deep linking support Jul 31, 2025
@joaquim-verges joaquim-verges marked this pull request as ready for review July 31, 2025 21:23
@joaquim-verges joaquim-verges requested review from a team as code owners July 31, 2025 21:23
@linear
Copy link

linear bot commented Jul 31, 2025

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: 2

🔭 Outside diff range comments (1)
packages/thirdweb/src/wallets/wallet-connect/controller.ts (1)

328-331: Address TODO: Add error handling for sessionRequestHandler.

The TODO comment indicates missing error handling. If sessionRequestHandler fails, it could leave the user in an undefined state.

       if (sessionRequestHandler && walletLinkToOpen) {
-        // TODO: propagate error when this fails
-        await sessionRequestHandler(walletLinkToOpen);
+        try {
+          await sessionRequestHandler(walletLinkToOpen);
+        } catch (error) {
+          console.error('Failed to handle session request:', error);
+          // Consider emitting an error event or showing user feedback
+        }
       }
♻️ Duplicate comments (1)
packages/thirdweb/src/wallets/wallet-connect/controller.ts (1)

219-220: Add error handling for wallet info retrieval.

Same issue as in connectWC - the getWalletInfo call needs error handling.

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

456-479: Well-structured deep linking implementation.

The introduction of requestAndOpenWallet as a centralized helper for handling wallet requests with deep linking is a good architectural decision. It provides a single point of control for the request/response flow while ensuring the wallet app is opened before transactions.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6258f74 and e8ef574.

📒 Files selected for processing (1)
  • packages/thirdweb/src/wallets/wallet-connect/controller.ts (12 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{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

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
🧠 Learnings (9)
📓 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/** : Support for in-app wallets (social/email login)
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
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
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-07-18T19:19:55.613Z
Learning: Applies to packages/thirdweb/src/wallets/** : Smart wallets with account abstraction
📚 Learning: applies to packages/thirdweb/src/wallets/** : unified `wallet` and `account` interfaces in wallet ar...
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
📚 Learning: applies to packages/thirdweb/src/wallets/** : eip-1193, eip-5792, eip-7702 standard support in walle...
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

Applied to files:

  • packages/thirdweb/src/wallets/wallet-connect/controller.ts
📚 Learning: applies to packages/thirdweb/src/wallets/** : support for in-app wallets (social/email login)...
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/** : Support for in-app wallets (social/email login)

Applied to files:

  • packages/thirdweb/src/wallets/wallet-connect/controller.ts
📚 Learning: applies to packages/thirdweb/src/wallets/** : smart wallets with account abstraction...
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/** : Smart wallets with account abstraction

Applied to files:

  • packages/thirdweb/src/wallets/wallet-connect/controller.ts
📚 Learning: eip7702 wallets do not need special handling for switching chains, unlike eip4337 wallets which requ...
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.

Applied to files:

  • packages/thirdweb/src/wallets/wallet-connect/controller.ts
📚 Learning: applies to dashboard/**/*client.tsx : interactive ui that relies on hooks (`usestate`, `useeffect`, ...
Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/*client.tsx : Interactive UI that relies on hooks (`useState`, `useEffect`, React Query, wallet hooks).

Applied to files:

  • packages/thirdweb/src/wallets/wallet-connect/controller.ts
📚 Learning: in the logout flow in apps/dashboard/src/app/(app)/account/components/accountheader.tsx, when `dolog...
Learnt from: jnsdls
PR: thirdweb-dev/js#7364
File: apps/dashboard/src/app/(app)/account/components/AccountHeader.tsx:36-41
Timestamp: 2025-06-18T02:13:34.500Z
Learning: In the logout flow in apps/dashboard/src/app/(app)/account/components/AccountHeader.tsx, when `doLogout()` fails, the cleanup steps (resetAnalytics(), wallet disconnect, router refresh) should NOT execute. This is intentional to maintain consistency - if server-side logout fails, client-side cleanup should not occur.

Applied to files:

  • packages/thirdweb/src/wallets/wallet-connect/controller.ts
📚 Learning: applies to test/src/test-wallets.ts : predefined test accounts are in `test/src/test-wallets.ts`...
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-18T19:19:55.613Z
Learning: Applies to test/src/test-wallets.ts : Predefined test accounts are in `test/src/test-wallets.ts`

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). (8)
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: Size
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: Unit Tests
  • GitHub Check: Lint Packages
  • GitHub Check: Build Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (3)
packages/thirdweb/src/wallets/wallet-connect/controller.ts (3)

1-4: LGTM!

Import additions are appropriate for the new deep linking functionality.

Also applies to: 45-45


347-361: LGTM! Consistent parameter propagation.

The function signature and parameter destructuring properly handle the new deep linking parameters.


481-498: LGTM! Proper parameter propagation throughout the connection lifecycle.

The function correctly handles the new parameters and passes them to all createAccount calls.

@github-actions
Copy link
Contributor

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 63.15 KB (0%) 1.3 s (0%) 305 ms (+53.2% 🔺) 1.6 s
thirdweb (cjs) 353.02 KB (0%) 7.1 s (0%) 1.6 s (+3.25% 🔺) 8.7 s
thirdweb (minimal + tree-shaking) 5.7 KB (0%) 114 ms (0%) 62 ms (+284.28% 🔺) 176 ms
thirdweb/chains (tree-shaking) 526 B (0%) 11 ms (0%) 30 ms (+226.03% 🔺) 40 ms
thirdweb/react (minimal + tree-shaking) 19.3 KB (0%) 386 ms (0%) 69 ms (+143.12% 🔺) 455 ms

@codecov
Copy link

codecov bot commented Jul 31, 2025

Codecov Report

❌ Patch coverage is 0% with 79 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.37%. Comparing base (ed65f4c) to head (e8ef574).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
.../thirdweb/src/wallets/wallet-connect/controller.ts 0.00% 79 Missing ⚠️

❌ Your patch status has failed because the patch coverage (0.00%) 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    #7772      +/-   ##
==========================================
- Coverage   56.42%   56.37%   -0.06%     
==========================================
  Files         904      904              
  Lines       58674    58735      +61     
  Branches     4139     4137       -2     
==========================================
+ Hits        33108    33113       +5     
- Misses      25461    25517      +56     
  Partials      105      105              
Flag Coverage Δ
packages 56.37% <0.00%> (-0.06%) ⬇️
Files with missing lines Coverage Δ
.../thirdweb/src/wallets/wallet-connect/controller.ts 8.40% <0.00%> (-1.24%) ⬇️

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

@joaquim-verges joaquim-verges merged commit 710ac32 into main Jul 31, 2025
26 of 27 checks passed
@joaquim-verges joaquim-verges deleted the _WalletConnect_Add_deep_linking_support_for_transaction_signing branch July 31, 2025 21:42
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