Skip to content

fix: move wallet extension detection into useWallets hook#68

Merged
satoshai-dev merged 1 commit intomainfrom
fix/wallet-detection-at-hook-level
Apr 6, 2026
Merged

fix: move wallet extension detection into useWallets hook#68
satoshai-dev merged 1 commit intomainfrom
fix/wallet-detection-at-hook-level

Conversation

@satoshai-dev
Copy link
Copy Markdown
Owner

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

Summary

  • useWallets now calls getStacksWallets() directly on every render, merging fresh window-global detection with the provider's configured wallet list
  • This ensures extensions injected after React 19 hydration are detected by the time a consumer reads the wallet list (e.g. when a connect-wallet drawer opens)
  • Reverts the provider-level useState/useEffect approach from fix: re-check installed wallets after mount for late-injecting extensions #66 in favor of this simpler hook-level solution
  • Provider still controls which wallets are listed; the hook only patches the available flag with fresh detection

Test plan

  • 213 tests pass (5 updated useWallets tests, 2 updated provider tests)
  • Build passes (pnpm build)
  • Manual: open app with Xverse/Leather installed → Connect Wallet → verify both show as "Installed"

Instead of relying solely on the provider's render-time detection
(which can miss extensions that inject after React hydration),
useWallets now calls getStacksWallets() directly on every render.
This ensures fresh detection at the point of consumption — by the
time a user opens a connect-wallet drawer, extensions are detected.

Reverts the provider-level useState/useEffect approach from #66
in favor of this simpler hook-level solution.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@satoshai-dev satoshai-dev force-pushed the fix/wallet-detection-at-hook-level branch from e2326d3 to d6df3e1 Compare April 6, 2026 13:16
@satoshai-dev satoshai-dev merged commit 752d7b9 into main Apr 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.

1 participant