fix: honor experimental_preferUniversalLinks on session-request re-opens - #5706
Conversation
…requests AppKit opened a wallet via its universal link on connect when experimental_preferUniversalLinks was set, but persisted the native custom-scheme href as the WalletConnect deeplink choice. universal-provider replays that stored href on every session request, so signing/tx re-opens fell back to the native scheme. Persist the universal-link base as the deeplink choice when the flag is on and a universal link exists, so request re-opens use the same link we connect with. formatNativeUrl now returns the normalized universal base as universalHref. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: ed7b70d The changes in this PR will be included in the next version bump. This PR includes changesets to release 26 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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
9 Skipped Deployments
|
Visual Regression Test Results ✅ PassedChromatic Build: https://www.chromatic.com/build?appId=6493191bf4b10fed8ca7353f&number=960 👉 Please review the visual changes in Chromatic and accept or reject them. |
📦 Bundle Size Check✅ All bundles are within size limits 📊 View detailed bundle sizes> @reown/appkit-monorepo@1.7.1 size /home/runner/work/appkit/appkit > size-limit |
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||
- changeset: list all publishable @reown/appkit-* packages (repo convention) - test: use neutral example domain to avoid DangerJS non-company-domain warning Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Bugbot is not enabled for this team, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
There was a problem hiding this comment.
Pull request overview
Fixes a WalletConnect mobile re-open regression when experimental_preferUniversalLinks is enabled by persisting the universal-link base (instead of the native custom-scheme base) as the WalletConnect deeplink choice, so subsequent session requests re-open the wallet via the same universal link.
Changes:
- Extend
CoreHelperUtil.formatNativeUrl()to also returnuniversalHref(normalized universal-link base). - Update
ConnectionControllerUtil.onConnectMobile()to persistuniversalHrefas the WC deeplink choice when universal links are preferred and available. - Add/expand unit tests to cover universal base persistence and fallback behavior; add a changeset for the patch release.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/scaffold-ui/test/partials/w3m-connecting-wc-mobile.test.ts | Adds assertions that setWcLinking persists the correct base href across universal/native/flag-off scenarios. |
| packages/controllers/tests/utils/CoreHelperUtil.test.ts | Adds coverage for universalHref normalization and undefined behavior when no universal link is provided. |
| packages/controllers/src/utils/TypeUtil.ts | Extends LinkingRecord with optional universalHref. |
| packages/controllers/src/utils/CoreHelperUtil.ts | Returns universalHref from formatNativeUrl() alongside existing redirect fields. |
| packages/controllers/src/utils/ConnectionControllerUtil.ts | Persists the universal-link base when preferred so WC session-request re-opens match the initial link mode. |
| .changeset/prefer-universal-links-deeplink-choice.md | Patch changeset documenting the behavioral fix across the versioned group. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ting Address Copilot review: remove the `as string` assertions in onConnectMobile by narrowing inside the selection ternaries, and collapse the duplicated openHref call into one. Behavior is unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Bugbot is not enabled for this team, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
Problem
With
experimental_preferUniversalLinks: true, AppKit opens a wallet via its universal link on connect (pairing), but every subsequent session request (signing / confirming a tx) re-opens the wallet via its native custom scheme instead, e.g.rn-web3wallet-internal://wc?requestId=...&sessionTopic=....Root cause: at connect time
ConnectionControllerUtil.onConnectMobileopens the universal link but persists the nativehref(safeAppUrl) as the WalletConnect deeplink choice (WALLETCONNECT_DEEPLINK_CHOICE).@walletconnect/universal-providerreplays that storedhrefon everyrequest()(handleDeeplinkRedirectbuilds${href}wc?requestId=...&sessionTopic=...). Since the storedhrefis the native base, all request re-opens use the native scheme.This breaks hosts that embed a dapp in an iOS webview and rely on universal links so they don't have to list every wallet's custom scheme in
LSApplicationQueriesSchemes. Connect works, but the signing step falls back to a native scheme the host can't open. Reproduced headless (appKit.connectWallet(...)), the path WalletConnect Pay uses.onConnectMobileis the single unified path — the headfulw3m-connecting-wc-mobilepartial delegates to it — so one fix covers both headful and headless. No wallet-side or universal-provider change required.Fix
formatNativeUrlnow also returnsuniversalHref, the normalized universal-link base (reuses the samesafeUniversalLinkthat already producesredirectUniversalLink).onConnectMobilepersistsuniversalHrefas the deeplink choice when the flag is on and a universal link exists, so the stored choice matches what we open with.link_mode(native scheme, no regression).Tests
CoreHelperUtil.test.ts:universalHrefequals the normalized universal base, and isundefinedwhen no universal link is passed.w3m-connecting-wc-mobile.test.ts:setWcLinkingreceives the universal base (flag on +link_mode), the native base (nolink_mode), and the native base (flag off).Manual verification (recommended)
On mobile / iOS webview: connect a wallet advertising both
mobile_linkandlink_mode, confirmlocalStorage.WALLETCONNECT_DEEPLINK_CHOICEholds thehttps://…/universal base, then triggerpersonal_sign/eth_sendTransactionand confirm the re-open uses the universal link.🤖 Generated with Claude Code