Skip to content

Enable walletconnect to Stellar Wallets Kit - #2178

Open
jeesunikim wants to merge 6 commits into
mainfrom
walletsconnect
Open

Enable walletconnect to Stellar Wallets Kit#2178
jeesunikim wants to merge 6 commits into
mainfrom
walletsconnect

Conversation

@jeesunikim

@jeesunikim jeesunikim commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

I added the preview link to allowlist for the Reown project ID I used so you can test this flow on the preview link. Freighter doesn't allow signing on localhost.

Q: The free model is for 1-seat, 500-MAU personal project. Do we need a bigger seat?

Successful flow result:

  • hash 6181b8c0b69a24e5bf828338cde23f48166514c723768b88a2163b956dee0719 (link)
IMG_3716 IMG_3717

Sign Message screenshot:

  • unauthenticated, wrote a message, and signed via wallet extension
wallet-connect-sign-message

The error message that appears when signing via link not listed onallowlist:

Screenshot 2026-08-17 at 10 24 23 PM

Copilot AI balanced review requested due to automatic review settings August 14, 2026 20:33
@github-project-automation github-project-automation Bot moved this to Backlog (Not Ready) in DevX Aug 14, 2026
@stellar-jenkins-ci

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/components/WalletKit/walletConnect.ts Outdated
Comment thread src/components/WalletKit/WalletKitContextProvider.tsx Outdated
Comment thread src/components/WalletKit/ConnectWallet.tsx
@stellar-jenkins-ci

Copy link
Copy Markdown

3 similar comments
@stellar-jenkins-ci

Copy link
Copy Markdown

@stellar-jenkins-ci

Copy link
Copy Markdown

@stellar-jenkins-ci

Copy link
Copy Markdown

@stellar-jenkins-ci

Copy link
Copy Markdown

1 similar comment
@stellar-jenkins-ci

Copy link
Copy Markdown

@stellar-jenkins-ci

Copy link
Copy Markdown

1 similar comment
@stellar-jenkins-ci

Copy link
Copy Markdown

jeesunikim and others added 4 commits August 21, 2026 11:42
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>
@jeesunikim
jeesunikim requested a review from quietbits August 21, 2026 21:47
@jeesunikim jeesunikim changed the title Enable wallets connect to Stellar Wallets Kit Enable walletconnect to Stellar Wallets Kit Aug 21, 2026
@stellar-jenkins-ci

Copy link
Copy Markdown

@stellar-jenkins-ci

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog (Not Ready)

Development

Successfully merging this pull request may close these issues.

2 participants