feat(solana): legacy window.solana provider behind Phantom masking toggle#66
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a Phantom-compatible
window.solanalegacy 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 onwindow.solana.isPhantom === true— never saw us, because the extension deliberately never touched the global. This closes that gap.How
solana-provider.ts—KeepKeySolanaProviderexposing the Phantom surface:connect/disconnect/signMessage/signTransaction/signAllTransactions/signAndSendTransaction/request, plusconnect/disconnect/accountChangedevents and a PublicKey-likepublicKey.solana_connect,solana_signMessage,solana_signTransaction,solana_signAndSendTransaction,solana_disconnect) — no new background handlers.serialize()in → device-sign → graft fee-payer signature back viaaddSignature()), so we never bundle@solana/web3.js.enablePhantomMaskingtoggle (default on), wired through storage (customStorage.ts), the content-scriptdata-maskinghandoff (pages/content), andinjected.ts.window.solana— a real Phantom/Solflare install is never clobbered.Honesty note
isPhantom: trueis impersonation, identical in spirit to the existingisMetaMask: trueEVM masking. It's off-able in Settings, and the honest Wallet Standard registration always runs regardless of the toggle.Test plan
window.solananot mounted; Wallet Standard still workswindow.solana🤖 Generated with Claude Code