Skip to content

Add multi-wallet simultaneous connections support#5

Merged
Quantumlyy merged 4 commits intomainfrom
claude/multi-wallet-connections-svJ12
Mar 28, 2026
Merged

Add multi-wallet simultaneous connections support#5
Quantumlyy merged 4 commits intomainfrom
claude/multi-wallet-connections-svJ12

Conversation

@Quantumlyy
Copy link
Copy Markdown
Member

Summary

This PR implements multi-wallet simultaneous connections, allowing users to connect multiple wallet connectors at once and switch between them. Previously, only a single active connection was supported.

Key Changes

Core Actions

  • connect(): Updated to allow multiple simultaneous connections. Now only throws ConnectorAlreadyConnectedError if the specific connector is already connected, not if any wallet is connected. Newly connected wallets become the active connection.
  • disconnect(): Added optional connector parameter to disconnect specific wallets while keeping others connected. Automatically switches to another connected wallet if the active one is disconnected.
  • switchConnection(): New action to switch the active connection between already-connected wallets without reconnecting.
  • reconnect(): Updated to support reconnecting multiple recent connectors. Reads from new recentConnectorIds storage key (with fallback to legacy recentConnectorId). Preserves existing connections if reconnection fails.

State Management

  • config.state.connections: Changed from single connection to Map<string, Connection> to track multiple simultaneous connections
  • config.state.current: Now stores the UID of the currently active connector
  • All connector actions (getBalance, sendPayment, signMessage, etc.) now accept optional connector parameter to specify which connection to use (defaults to current)

Storage

  • Migrated from recentConnectorId (single string) to recentConnectorIds (string array)
  • Maintains backward compatibility by reading legacy key first
  • Stores connectors in order of most recent connection

React Hooks

  • useSwitchConnection(): New hook for switching active connections with mutation state management
  • Updated existing hooks to include connector?.uid in query keys for proper cache invalidation when switching connections

Tests

  • Added comprehensive test coverage for multi-wallet scenarios
  • Tests verify switching between connected wallets, disconnecting non-active wallets, and fallback behavior
  • Updated existing tests to reflect new behavior (e.g., "throws if same connector is already connected")

Implementation Details

  • Connections are tracked by connector UID internally
  • When disconnecting the active wallet, the system automatically switches to the first remaining connected wallet
  • Reconnection attempts all recent connectors in order until one succeeds
  • All connector-specific actions properly resolve to the correct connection based on the optional connector parameter or current active connection

https://claude.ai/code/session_01Sts7EuD7ooKxBCJitw6uA7

Quantumlyy and others added 4 commits March 27, 2026 18:52
- connect() now allows connecting additional wallets instead of throwing
  ConnectorAlreadyConnectedError when already connected
- Only throws if the same specific connector is already connected
- Error recovery preserves 'connected' status when other connections exist
- disconnect() removes connector from recentConnectorIds array storage
- reconnect() supports reconnecting multiple wallets from stored IDs
- Added recentConnectorIds to StorageItemMap with legacy fallback

Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: Claude <noreply@anthropic.com>
…to actions

- Add switchConnection() action to change active wallet without disconnecting
- Add optional connector parameter to all 8 actions (getBalance, sendPayment,
  createInvoice, signMessage, estimateFee, getTransaction, getTransactions,
  waitForPayment) so they can target a specific connected wallet
- Export switchConnection from both actions and index entrypoints

Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: Claude <noreply@anthropic.com>
…ery hooks

- Add useSwitchConnection hook wrapping core switchConnection action
- Include connector UID in query keys for useBalance, useGetTransaction,
  and useTransactionHistory for per-connector cache separation
- Export useSwitchConnection from React package

Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: Claude <noreply@anthropic.com>
…ations

Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: Claude <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
mbga-site Ready Ready Preview, Comment Mar 27, 2026 8:41pm

@Quantumlyy Quantumlyy merged commit 58a7ee6 into main Mar 28, 2026
8 checks passed
@Quantumlyy Quantumlyy deleted the claude/multi-wallet-connections-svJ12 branch March 28, 2026 05:38
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.

1 participant