Skip to content

feat: adopt eip-6963 for connected-wallet name and icon - #3055

Open
gomesalexandre wants to merge 1 commit into
DefiLlama:mainfrom
gomesalexandre:feat_eip6963_wallet_discovery
Open

feat: adopt eip-6963 for connected-wallet name and icon#3055
gomesalexandre wants to merge 1 commit into
DefiLlama:mainfrom
gomesalexandre:feat_eip6963_wallet_discovery

Conversation

@gomesalexandre

Copy link
Copy Markdown

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 the is* 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 helper resolveConnectedWalletInfo(providers, connectedProvider). It matches the announced provider to the connected one by object identity (also checking selectedProvider for multiplexing wallets) and returns { name, icon }, or null when 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 for eip6963:announceProvider, dispatches eip6963:requestProvider, de-dupes announcements by info.uuid.
  • components/header/index.js - the connected-wallet chip now prefers the discovered icon/name, falling back to walletIcons[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 existing tests/ convention):

$ node --test tests/eip6963.test.js
✔ returns the name/icon of the announced provider matching window.ethereum
✔ matches via selectedProvider when the wallet multiplexes
✔ returns null when no announced provider matches the connected one
✔ returns null for empty / missing inputs
✔ icon is null when the announcement omits a usable icon
✔ skips a matching provider that announced no usable name
✔ ignores malformed detail entries without throwing
ℹ pass 7  ℹ fail 0

next build passes.

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.

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>
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.

Wallet detection: any plans to adopt EIP-6963?

1 participant