Enable walletconnect to Stellar Wallets Kit - #2178
Conversation
|
Preview is available here: |
There was a problem hiding this comment.
Pull request overview
Adds WalletConnect support to Stellar Lab through Stellar Wallets Kit.
Changes:
- Lazily loads WalletConnect for mainnet and testnet.
- Adds session restoration, disconnection handling, and CSP permissions.
- Configures deployment credentials and documents setup.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/components/WalletKit/walletConnect.ts |
Configures the WalletConnect module. |
src/components/WalletKit/WalletKitContextProvider.tsx |
Registers WalletConnect asynchronously. |
src/components/WalletKit/ConnectWallet.tsx |
Adds session restoration and disconnection handling. |
src/middleware.ts |
Permits required WalletConnect resources. |
tests/unit/walletConnect.test.ts |
Tests network and configuration support. |
README.md |
Documents WalletConnect setup. |
Dockerfile |
Adds the project ID build argument. |
Makefile |
Passes the project ID to Docker. |
.github/workflows/laboratory-build.yml |
Supplies the deployment secret. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Preview is available here: |
3 similar comments
|
Preview is available here: |
|
Preview is available here: |
|
Preview is available here: |
7f4a051 to
653883f
Compare
|
Preview is available here: |
1 similar comment
|
Preview is available here: |
696dedb to
66f62a1
Compare
|
Preview is available here: |
1 similar comment
|
Preview is available here: |
Register the kit's WalletConnectModule so users can connect mobile wallets, including Freighter mobile, by scanning a QR code. Closes #2172. WalletConnect is offered on mainnet and testnet only, since those are the only Stellar chains it exposes (stellar:pubnet / stellar:testnet), and is loaded on demand — when a wallet modal opens or a saved session is restored — rather than at startup. It pulls in @reown/appkit and the WalletConnect sign client, about 320 kB gzipped that most sessions never need, so the module lives in its own chunk behind a dynamic import. CSP additions in middleware.ts, all found by exercising the connect flow in a browser: wss://relay.walletconnect.org for the relay (the `https:` source doesn't cover the wss: scheme), fonts.reown.com, api.web3modal.org for wallet images, and verify.walletconnect.org for the domain-attestation iframe. Sessions survive a reload — the kit persists the address and session topic to localStorage — so a saved session is restored without re-scanning. The restore path verifies the sign client actually holds an unexpired session authorizing that address on the current chain before reporting a connected wallet, otherwise every later signing request would fail with no explanation. Auto-connect can't go through the module's getAddress(), which ignores skipRequestAccess and would start a fresh pairing on every load. Switching networks ends a WalletConnect session: it's approved for a single chain, and updating allowedChains only affects the next pairing, so signing over the old topic with a new chain id would fail. Disconnect also tears down the kit's own state, and the kit's DISCONNECT event is mirrored into Lab's so a session dropped by the wallet doesn't leave a stale address. The project id comes from NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID, plumbed through the Dockerfile, Makefile and laboratory-build.yml via the WALLET_CONNECT_PROJECT_ID secret. A default is committed so the kube PR preview — which can't inject build-time env vars — has one; production should override it with an SDF-owned project. Whichever project is used, its allowlist must include the deployed origin or the relay refuses the connection outright with 3000 (Unauthorized: origin not allowed). Note that WalletConnect signing requires an https origin: from http://localhost, Freighter mobile approves the session and returns the account but then refuses to sign, reporting the domain as not connected. Local testing needs a tunnel or the kube preview. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
walletconnect to Stellar Wallets Kit
3ed4327 to
987846c
Compare
|
Preview is available here: |
|
Preview is available here: |
I added the preview link to
allowlistfor the Reown project ID I used so you can test this flow on the preview link. Freighter doesn't allow signing onlocalhost.Q: The free model is for 1-seat, 500-MAU personal project. Do we need a bigger seat?
Successful flow result:
6181b8c0b69a24e5bf828338cde23f48166514c723768b88a2163b956dee0719(link)Sign Message screenshot:
wallet extensionThe error message that appears when signing via link not listed on
allowlist: