Skip to content

feat: handle WalletConnect session events and zombie detection#57

Merged
satoshai-dev merged 4 commits intomainfrom
feat/wallet-connect-session-events
Mar 6, 2026
Merged

feat: handle WalletConnect session events and zombie detection#57
satoshai-dev merged 4 commits intomainfrom
feat/wallet-connect-session-events

Conversation

@satoshai-dev
Copy link
Copy Markdown
Owner

@satoshai-dev satoshai-dev commented Mar 6, 2026

Summary

  • Add useWalletConnect hook that handles the full WalletConnect session lifecycle
  • Detect zombie sessions on restore via relay ping with 10s timeout — cleans up stale state instead of silently timing out for 5 minutes
  • Listen for disconnect, accountsChanged, stx_accountChange (SIP-030), and stx_accountsChanged events
  • Handle all account data formats: SIP-030 { address, publicKey } objects, plain addresses, and CAIP-10 strings
  • Stabilize onDisconnect with useCallback to prevent effect cancellation loop
  • Proper WC type definitions — no any types
  • Wire the hook into StacksWalletProvider alongside useXverse

Closes #51

Test plan

  • Build passes
  • Typecheck passes
  • Lint passes
  • 175/175 tests pass (31 new tests for helpers + hook)
  • Manual: connect via WalletConnect, disconnect from wallet side — kit clears state
  • Manual: connect via WalletConnect, close wallet app, reload dApp — zombie session detected and cleaned up within 10s

🤖 Generated with Claude Code

satoshai-dev and others added 4 commits March 6, 2026 14:46
Add useWalletConnect hook that listens for disconnect and accountsChanged
events from the underlying UniversalProvider, and validates restored
sessions via relay ping to detect zombie connections.

Closes #51

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Define WcUniversalProvider, WcSignClient, WcSession, and
WcStacksConnectProvider interfaces. Update global.d.ts to use the
typed WcStacksConnectProvider instead of unknown.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Wrap onDisconnect in useCallback to prevent effect cancellation loop
- Add 10s ping timeout to avoid 5-min WC default hang
- Listen for stx_accountChange (SIP-030) and stx_accountsChanged events
- Handle SIP-030 { address, publicKey } objects in extractStacksAddress
- Handle plain addresses from UniversalProvider (not just CAIP-10)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@satoshai-dev satoshai-dev merged commit 4ededf1 into main Mar 6, 2026
1 check passed
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.

Handle WalletConnect session events (disconnect, account changes)

1 participant