feat(wallet): EIP-6963 multi-wallet discovery in the browser bridge#392
Merged
Conversation
The bridge page grabbed the single injected `window.ethereum`, which is
ambiguous when several wallet extensions are installed. Adopt EIP-6963: on load
dispatch `eip6963:requestProvider` and collect each `eip6963:announceProvider`
({info:{name,icon,rdns,uuid}, provider}) into a list; route every provider call
(eth_requestAccounts / eth_chainId / wallet_switch|addEthereumChain /
eth_sendTransaction / accountsChanged) through one selected active provider.
- 1 wallet → auto-select; >=2 → hand-rolled picker (icon+name); 0 announced →
fall back to window.ethereum (older wallets), else a clear no-wallet message.
- Also subscribe chainChanged (page only heard accountsChanged) to warn on a
mid-session network switch; ensureChain still corrects it before each tx.
- Transport / session daemon / /api contract untouched.
- Playwright mock now announces via eip6963:announceProvider (keeps
window.ethereum too) so the Tier-2 lanes discover it.
Verified: Tier-2 browser-signing suite 9 passed / 1 skipped (nightly deploy).
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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
The browser-wallet bridge page grabbed the single injected
window.ethereum, which is ambiguous when multiple wallet extensions are installed (they clobber each other on that global). Adopt the standard EIP-6963 discovery mechanism.On load the page dispatches
eip6963:requestProviderand collects eacheip6963:announceProvider({info:{name,icon,rdns,uuid}, provider}) into a list, then routes every provider call —eth_requestAccounts,eth_chainId,wallet_switchEthereumChain,wallet_addEthereumChain,eth_sendTransaction,accountsChanged— through one selected active provider instead ofwindow.ethereum.Behavior
window.ethereum(older wallets that don't speak 6963), else a clear "no wallet detected" message.chainChanged(the page only heardaccountsChanged) to warn on a mid-session network switch;ensureChain()still corrects it before each tx.Scope
src/lib/wallet/bridgePage.ts(the inline page) + the Playwright mock. Transport, session daemon, and the/api/*contract are untouched — the active-provider layer only funnels the same calls through a chosen object.e2e/fixtures/mockProvider.ts) now announces viaeip6963:announceProvider(and keepswindow.ethereum) so the browser-signing lanes discover it.Test
Local Tier-2 browser-signing suite: 9 passed / 1 skipped (the skip is the nightly Docker deploy lane) — staking (validator-join + session reuse), config-default walletMode, reject (4001) + tab-closed error lanes, and the full wallet-session lifecycle. tsc clean; build inlines the page.