feat: adopt eip-6963 for connected-wallet name and icon - #3055
Open
gomesalexandre wants to merge 1 commit into
Open
feat: adopt eip-6963 for connected-wallet name and icon#3055gomesalexandre wants to merge 1 commit into
gomesalexandre wants to merge 1 commit into
Conversation
The header wallet chip derived its name/icon from a hardcoded allowlist of legacy window.ethereum.is* flags, so any wallet not on the list (rabby, zerion, rainbow, frame, okx, ...) showed a generic name and the metamask icon. Prefer the wallet's own EIP-6963 announcement for the connected provider, keeping the is* allowlist purely as a fallback for wallets that don't announce. - utils/eip6963.js: pure, dependency-free matching helper (unit-tested) - hooks/useEip6963.jsx: SSR-safe announceProvider/requestProvider discovery - components/header/index.js: chip prefers discovered name/icon, allowlist fallback closes DefiLlama#2994 Co-Authored-By: Claude Opus 4.8 <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.
closes #2994
what
Adopt EIP-6963 (Multi Injected Provider Discovery) for the connected-wallet name and icon.
Today the wallet chip in the header derives its name/icon from a hardcoded allowlist of legacy
window.ethereum.is*flags (getProvider()+constants/walletIcons.js). Anything not on that list (Rabby, Zerion, Rainbow, Frame, OKX, ...) falls back to a generic name and the MetaMask icon, so a Rabby user sees a MetaMask fox next to their address.This uses the wallet's own EIP-6963 announcement (
{ info: { name, icon, rdns, uuid }, provider }) to show the real name/icon of whatever the user actually connected, and keeps theis*allowlist purely as a fallback for wallets that don't announce yet.how
utils/eip6963.js- a small, dependency-free (no React/DOM) module with the pure matching helperresolveConnectedWalletInfo(providers, connectedProvider). It matches the announced provider to the connected one by object identity (also checkingselectedProviderfor multiplexing wallets) and returns{ name, icon }, ornullwhen nothing matches. Kept plain CJS so it can be unit-tested and named-imported from the ESM app source.hooks/useEip6963.jsx- SSR-safe discovery hook: listens foreip6963:announceProvider, dispatcheseip6963:requestProvider, de-dupes announcements byinfo.uuid.components/header/index.js- the connected-wallet chip now prefers the discoveredicon/name, falling back towalletIcons[getProvider()]/getProvider()exactly as before.Additive and backwards-compatible: no behavior change for the wallets already on the allowlist; the fallback path is untouched.
tests
tests/eip6963.test.js(Node's built-in runner, no new dep - matches the existingtests/convention):next buildpasses.note
The pure matching logic is unit-tested; the thin event-listener glue in the hook is best verified live in a browser with a couple of injected wallets (e.g. MetaMask + Rabby) to confirm the announced icon renders. Happy to iterate if you'd like the same treatment extended to the "add to network" button copy in
renderProviderText.