feat(token-logo): render chain icons for native tokens#464
Merged
gabitoesmiapodo merged 6 commits intodevelopfrom Apr 21, 2026
Merged
feat(token-logo): render chain icons for native tokens#464gabitoesmiapodo merged 6 commits intodevelopfrom
gabitoesmiapodo merged 6 commits intodevelopfrom
Conversation
Native tokens (ETH, POL, OP, ARB, etc.) previously rendered the letter-placeholder because buildNativeToken() has no logoURI. Detect native tokens in TokenLogo via isNativeToken(token.address) and render the matching @web3icons/react NetworkXxx component keyed by chainId, falling back to the existing img/placeholder for unmapped chains. Closes #164
- hoist Chakra system to module scope in provider.tsx and export it - use real project system in TokenLogo tests instead of bare defaultConfig - replace Placeholder useState+useEffect+useCallback with useMemo - fix padStart pad char from '6' to '0' in generateHexColor - tighten nativeTokenIcons from Partial<Record> to Record so adding a chain to networks.config.ts surfaces a TS error on missing icon entry
Contributor
There was a problem hiding this comment.
Pull request overview
Adds native-token chain icons to TokenLogo so native assets (ETH, POL, etc.) render a well-known chain icon instead of the letter-placeholder when logoURI is missing.
Changes:
- Introduces a static
chainId -> @web3icons/reactmapping for native token icons. - Refactors
TokenLogointo a folder module and renders mapped chain icons for native tokens. - Exports the Chakra
systemfromProviderand extendsTokenLogotests for mapped/unmapped native-token behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/components/ui/provider.tsx | Moves Chakra system creation to module scope and exports system for reuse (tests). |
| src/components/sharedComponents/TokenLogo/nativeTokenIcons.tsx | Adds chainId-to-icon mapping for configured networks. |
| src/components/sharedComponents/TokenLogo/index.tsx | Updates TokenLogo rendering logic to use native chain icons before other fallbacks. |
| src/components/sharedComponents/TokenLogo/TokenLogo.test.tsx | Adds assertions for mapped native icon rendering and unmapped fallback behavior. |
Comments suppressed due to low confidence (3)
src/components/sharedComponents/TokenLogo/index.tsx:76
- The JSDoc claims native tokens are detected via
token.address === env.PUBLIC_NATIVE_TOKEN_ADDRESS, but the implementation usesisNativeToken()(lowercases before comparing). Please update the comment to match the actual detection logic so future readers don’t rely on an equality check that can fail for checksummed addresses.
src/components/sharedComponents/TokenLogo/index.tsx:110 - PR description says the chain icon should be used when
logoURIis absent, but this code returns the native chain icon whenever the token is native (even if alogoURIis provided). Consider gating the native-icon branch on!logoURI(or!logoURI || hasError) so a future explicit nativelogoURIwouldn’t be ignored.
src/components/sharedComponents/TokenLogo/index.tsx:101 nativeTokenIcons[token.chainId as ChainsIds]relies on a type assertion that defeats the “unmapped chain => placeholder” behavior you’re explicitly testing. Prefer typingnativeTokenIconsas a partial map (e.g.Partial<Record<number, IconComponent>>) and indexing withtoken.chainIddirectly, so TypeScript models the possibility ofundefinedwithout casts.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Collaborator
Author
|
Responding to the three low-confidence suggestions in #pullrequestreview-4148478875:
|
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.
Summary
Closes #164
Native tokens (ETH, MATIC, etc.) previously fell through to the colored placeholder circle in
TokenLogobecausebuildNativeToken()producesTokenobjects with nologoURI. This introduces a static chain-ID-to-icon mapping soTokenLogocan resolve and render the well-known chain icon for native tokens directly, without requiring any change to the token data layer.Changes
nativeTokenIcons.tsxwith a static mapping of chain IDs to SVG chain iconsTokenLogofrom a single file into a folder (TokenLogo/index.tsx+TokenLogo/nativeTokenIcons.tsx)TokenLogoto check for a native token icon whenlogoURIis absent, before falling back to the placeholderTokenLogo.test.tsxwith assertions covering unmapped-chain fallback behaviorsrc/components/ui/provider.tsxto accommodate the icon integrationAcceptance criteria
TokenLogodisplay their chain-specific icon instead of the colored placeholderTest plan
Automated tests
src/components/sharedComponents/TokenLogo/TokenLogo.test.tsxManual verification
Open the token select component on a configured network. Verify native tokens (e.g., ETH on Ethereum) display their chain icon instead of a colored letter placeholder. Verify that a network with no mapped icon still shows the placeholder without errors.
Breaking changes
None.
Checklist
Screenshots
Screen.Recording.2026-04-21.at.11.25.33.mov