fix(walletconnect): restore per-session channel id as the Snap request origin - #34284
fix(walletconnect): restore per-session channel id as the Snap request origin#34284adonesky1 wants to merge 4 commits into
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
PR template — items to address before "Ready for review"Warnings — informational, address before merging:
See docs/readme/ready-for-review.md for the full Definition of Ready for Review. |
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection: Key impacted areas:
The changes are in Performance Test Selection: |
|



Description
refactor(walletconnect): use stable origin for Tron snap requests replaced the per-session WalletConnect
channelIdwith the shared constant'wallet-connect'as theoriginpassed toMultichainRoutingService:handleRequest. That collapses every WalletConnect dapp into a single Snap-visible principal:MultichainRoutingServiceforwardsoriginverbatim intoSnapKeyring.submitRequest/SnapController:handleRequest, so Snaps can no longer distinguish one WC session from another. Any Snap-side logic keyed on the request origin (display, SIWS domain checks, per-origin state) would treat all WalletConnect dapps as equivalent. This is the "origin confusion" flagged in the follow-up Slack discussion, where the alignment reached was:originstays unspoofable, always: for remote transports (WC/SDK) that is the wallet-generated connection/channel ID, mirroring how EVM permissions are keyed.originMetadata) with explicit unverified framing, and never feeds Blockaid/SIWS. This half requires Snaps-platform support first (WPC-1194 / WPC-1195) and is deliberately not included here.This PR restores the invariant: the per-session
channelIdis threaded again fromWalletConnect2Session.handleAdapterRequest→ adapter →createSnapCaller→MultichainRoutingService. It also:originaccurately on the adapter contract (the pre-existing doc called it a "URL-like dapp origin", which is what invited the regression): it is the unspoofable session identifier, never the self-reported URL, never a shared transport constant.WALLET_CONNECT_ORIGIN = 'wallet-connect'constant, which also collided confusingly with the legacyWALLET_CONNECT_ORIGIN = 'wc::'inapp/util/walletconnect.router.test.tspinning the invariant at the exact point the regression happened: the router must forward the caller-supplied per-session origin and keep distinct sessions distinct.Known, accepted tradeoff (short-term, per the Slack thread): Snaps may render the channel UUID in confirmation UI instead of a friendly label. The proper fix for display is the upcoming
originMetadatafield with unverified framing, not a shared origin.Video Demo
Screen.Recording.2026-08-04.at.4.54.26.PM.mov
Snap-side compatibility notes
Verified against the Snap sources before making this change:
@metamask/tron-wallet-snap1.33.1) never validates the origin:formatOriginmapsmetamask→ "MetaMask", extracts the hostname from valid URLs, and falls back to the raw string otherwise. Channel IDs as origin is how Tron-over-WC originally shipped. Note the premise of refactor(walletconnect): use stable origin for Tron snap requests ("MUST stay in sync with the Snaps' known-origin label map") never shipped for Tron: that map only exists in the still-open fix: handle non-url origins, so on current production the shared constant renders as the literal string "wallet-connect" in confirmations for every WC dapp.parseOriginthrows on non-URL origins and is called from the confirmation views, so a channel-ID origin would break rendering of every signing confirmation. The open fix: handle non-url origins does not resolve this for channel IDs: it only whitelistsmetamask/wallet-connect(and forwardswallet-connectto Blockaid as the scan origin), i.e. it was designed around the shared-constant approach this PR reverts. Before Solana-over-WalletConnect lands, that Snap needs to accept arbitrary non-URL origins (hide from display, keep out of Blockaid) per the WPC-1194 / WPC-1195 direction.Changelog
CHANGELOG entry: null
Related issues
Fixes: regression introduced in refactor(walletconnect): use stable origin for Tron snap requests
Related: WPC-1194, WPC-1195, WAPI-1576
Manual testing steps
Feature: Tron WalletConnect Snap origin
Screenshots/Recordings
N/A. Routing-layer change covered by unit tests; no wallet UI changes.
Before
N/A
After
N/A
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Security-sensitive origin semantics for Snap routing are corrected, but behavior changes from the prior shared-origin approach and may affect Snap UI or per-origin logic until separate unverified metadata lands.
Overview
Reverts a regression where every WalletConnect dapp was collapsed into one Snap-visible principal via a shared
'wallet-connect'origin onMultichainRoutingService:handleRequest.WalletConnect2Sessionnow passesthis.channelIdinto non-EVM adapter handling asorigin, and that value is threaded through adapters (e.g. TronhandleRequest) andcreateSnapCallerintoMultichainRoutingService, so Snaps see one distinct principal per WC session again. The multichainWALLET_CONNECT_ORIGINconstant is removed;AdapterRequestContext/ router JSDoc describeoriginas the unspoofable session id, not the dapp metadata URL.New
router.test.ts(and updated adapter/helper tests) assert the caller-supplied per-session origin is forwarded and that different channel ids stay distinct.Reviewed by Cursor Bugbot for commit 15fd716. Bugbot is set up for automated code reviews on this repo. Configure here.