Skip to content

Feat/add utxo namespace to wallet connect#1421

Open
RyukTheCoder wants to merge 3 commits into
feat/migrate-wallet-connectfrom
feat/add-utxo-namespace-to-wallet-connect
Open

Feat/add utxo namespace to wallet connect#1421
RyukTheCoder wants to merge 3 commits into
feat/migrate-wallet-connectfrom
feat/add-utxo-namespace-to-wallet-connect

Conversation

@RyukTheCoder

@RyukTheCoder RyukTheCoder commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Add a UTXO namespace to the WalletConnect hub provider with Bitcoin connect/disconnect/eager-connect support and a transfer signer.

Changes

  • New namespaces/utxo with connect, disconnect, and eager-connect actions
  • Bitcoin transfer signer (signers/utxo.ts) and BTC entry in provider metadata

Test Plan

  • UTXO: connect WalletConnect with BTC namespace selected; verify Bitcoin address is returned
  • UTXO: sign a Bitcoin transfer (if applicable in your test flow)

Checklist:

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • Implemented a user interface (UI) change, referencing our Figma design to ensure pixel-perfect precision.

@RyukTheCoder
RyukTheCoder force-pushed the feat/migrate-wallet-connect branch from 295e061 to 7b2bfaf Compare June 15, 2026 09:12
@RyukTheCoder
RyukTheCoder force-pushed the feat/migrate-wallet-connect branch from a52aed4 to 9666f4e Compare July 7, 2026 11:45
@RyukTheCoder
RyukTheCoder force-pushed the feat/add-utxo-namespace-to-wallet-connect branch from dac176a to c943ef6 Compare July 7, 2026 13:35
@RyukTheCoder
RyukTheCoder force-pushed the feat/migrate-wallet-connect branch 2 times, most recently from 1364020 to b287aa2 Compare July 7, 2026 14:32
@RyukTheCoder
RyukTheCoder force-pushed the feat/add-utxo-namespace-to-wallet-connect branch from c943ef6 to 3d64d8b Compare July 7, 2026 15:19
Comment thread wallets/provider-walletconnect-2/src/namespaces/utxo/hooks.ts

@arlert-armin arlert-armin 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.

LGTM

@RyukTheCoder RyukTheCoder mentioned this pull request Jul 15, 2026
5 tasks
@RyukTheCoder
RyukTheCoder force-pushed the feat/add-utxo-namespace-to-wallet-connect branch from 2265133 to 7ae71b5 Compare July 15, 2026 14:09
AppKit's controllers (RouterController, ChainController, ...) are
module-level singletons, so a per-namespace modal rebuilt on each switch
re-ran AppKit init against the same globals and left the previous open's
router history behind - a stray back button in the modal header when
opening BTC after EVM (or the reverse).

Build the modal once with both networks registered up front and choose
the active one per connect with switchNetwork, so open() sees a matching
active chain and takes its clean, non-switching path.

- modal.ts: single instance ([mainnet, bitcoin]); prepareModalForNamespace
  runs ready() + switchNetwork() before open. The active chain is now
  shared mutable state, safe only because connects are serialized by the
  adapter's #sessionQueue.
- modal-cache.ts: build once, no per-namespace rebuild.
- adapter.ts: drop namespace from getModal (one instance now).
- lifecycle.ts: call prepareModalForNamespace before open; reuse
  WC_NAMESPACE_TO_CAIP for the open namespace instead of sniffing the
  payload keys.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@RyukTheCoder

Copy link
Copy Markdown
Contributor Author

c40a8b0 — fix(walletconnect-2): share one AppKit modal across namespaces

Bug: a stray back button appeared in the WalletConnect modal header when opening one namespace's modal after the other (e.g. connect EVM, then open BTC).

Root cause: AppKit's controllers (RouterController, ChainController, …) are module-level singletons. The per-namespace modal was rebuilt on every switch, so each rebuild re-ran AppKit init against those same globals and left the previous open's router history behind → an extra router step → the back arrow. There was never really more than one live instance to begin with.

Fix: build the modal once with both networks registered up front ([mainnet, bitcoin]) and pick the active one per connect with switchNetwork. open() then sees a matching active chain and takes its clean, non-switching path — no back button.

Changes:

  • modal.ts — single instance; prepareModalForNamespace runs ready() + switchNetwork() before open(). The active chain is now shared mutable state, safe only because connects are serialized by the adapter's #sessionQueue (documented inline).
  • modal-cache.ts — build once, no per-namespace rebuild.
  • adapter.ts — drop namespace from getModal (one instance now).
  • lifecycle.ts — call prepareModalForNamespace before open; reuse WC_NAMESPACE_TO_CAIP for the open namespace instead of sniffing the connect-payload keys.

Note: the earlier ConnectorController filter attempt and the extra @reown/appkit-controllers dependency were reverted — the 530→9/40 wallet count turned out to be a harmless placeholder, not a bug. This commit is back-button-only, no new dependency.

Green: ts-check, lint, build all pass.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants