Skip to content

feat(solana): legacy window.solana provider behind Phantom masking toggle#66

Merged
BitHighlander merged 2 commits into
developfrom
solana-legacy
Jun 16, 2026
Merged

feat(solana): legacy window.solana provider behind Phantom masking toggle#66
BitHighlander merged 2 commits into
developfrom
solana-legacy

Conversation

@BitHighlander

Copy link
Copy Markdown
Collaborator

What

Adds a Phantom-compatible window.solana legacy provider — the Solana counterpart to the existing MetaMask (window.ethereum) masking.

Why

Modern Solana dApps discover KeepKey via the Wallet Standard registry (solana-wallet-standard.ts) and that path is unchanged. But legacy dApps — including everything built on @solana/wallet-adapter-phantom, which gates detection on window.solana.isPhantom === true — never saw us, because the extension deliberately never touched the global. This closes that gap.

How

  • solana-provider.tsKeepKeySolanaProvider exposing the Phantom surface: connect / disconnect / signMessage / signTransaction / signAllTransactions / signAndSendTransaction / request, plus connect/disconnect/accountChanged events and a PublicKey-like publicKey.
    • Routes through the same background RPC methods the Wallet Standard wallet already uses (solana_connect, solana_signMessage, solana_signTransaction, solana_signAndSendTransaction, solana_disconnect) — no new background handlers.
    • Transactions are handled duck-typed (serialize() in → device-sign → graft fee-payer signature back via addSignature()), so we never bundle @solana/web3.js.
  • Gated on a new enablePhantomMasking toggle (default on), wired through storage (customStorage.ts), the content-script data-masking handoff (pages/content), and injected.ts.
  • Mounted only if no other wallet already claims window.solana — a real Phantom/Solflare install is never clobbered.
  • Settings UI toggle + Phantom brand asset.

Honesty note

isPhantom: true is impersonation, identical in spirit to the existing isMetaMask: true EVM masking. It's off-able in Settings, and the honest Wallet Standard registration always runs regardless of the toggle.

Test plan

  • Toggle on (default) → legacy Solana dApp (wallet-adapter-phantom) detects KeepKey, connect + sign + send works
  • Toggle off → window.solana not mounted; Wallet Standard still works
  • Real Phantom installed → KeepKey does not clobber window.solana
  • Refresh dApp after toggling (snapshot is read-once per page load)

🤖 Generated with Claude Code

…ggle

Modern Solana dApps discover KeepKey via the Wallet Standard registry
(solana-wallet-standard.ts), but legacy dApps — including everything built
on @solana/wallet-adapter-phantom, which gates detection on
window.solana.isPhantom === true — never saw us because we deliberately
never touched the global.

Adds a Phantom-compatible window.solana shim as the Solana counterpart to
the existing MetaMask (window.ethereum) masking:

- solana-provider.ts: KeepKeySolanaProvider exposing connect/disconnect/
  signMessage/signTransaction/signAllTransactions/signAndSendTransaction/
  request + connect/disconnect/accountChanged events and a PublicKey-like
  publicKey. Routes through the same background RPC methods the Wallet
  Standard wallet already uses — no new background handlers. Transactions
  are handled duck-typed (serialize() in, graft the device signature back
  via addSignature()) so we never bundle @solana/web3.js.
- Gated on a new enablePhantomMasking toggle (default on), wired through
  storage, the content-script data-masking handoff, and injected.ts.
- Mounted only if no other wallet already claims window.solana, so a real
  Phantom/Solflare install is never clobbered.
- Settings UI toggle + Phantom brand asset.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@BitHighlander BitHighlander merged commit 5f58423 into develop Jun 16, 2026
4 checks passed
@BitHighlander BitHighlander deleted the solana-legacy branch June 16, 2026 20:06
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