Overview
TheAssetList component provides a detailed view of all user assets across multiple chains. It displays aggregated asset balances with the ability to expand each asset to see its distribution across different blockchain networks. The component handles loading states, empty states, and provides rich visual feedback with token icons and chain logos.
Import
Props
BalanceByAssetDto[]
default:"undefined"
Array of balance information for each aggregated asset. Each item contains the total balance, fiat value, and breakdown by individual chains.
Asset[]
required
Array of asset metadata including symbols, names, decimals, and aggregated entities. Used to enrich balance data with proper formatting.
boolean
required
Indicates whether balance data is currently being fetched. Shows skeleton loaders when
true.Type Definitions
Usage
Basic Usage
In Account Modal
Features
Expandable Asset Details
Each asset can be expanded to show its distribution across different chains:Asset Display Information
For each asset, the component shows:- Token Icon: Either from metadata or a generated colored circle with the first letter
- Symbol: Uppercase token symbol (e.g., USDC, ETH)
- Chain Count: Number of chains where the asset exists
- Total Fiat Value: USD value across all chains
- Total Balance: Formatted token amount
Chain Distribution Details
When expanded, each asset shows:- Chain Logo: Visual identifier for the blockchain
- Chain Name: Human-readable chain name (e.g., “Ethereum”, “Polygon”)
- Balance on Chain: Token amount on that specific chain
- Fiat Value: USD value on that chain
- Percentage: Proportion of total asset value on this chain
Component States
- Loading
- Empty State
- Asset List
Shows three skeleton placeholders while fetching data:
Helper Functions
Asset Symbol Extraction
Token Icon Retrieval
Decimal Precision
Chain Information
Icon Color Generation
Generates consistent colors for token icons based on the symbol:Formatting
Fiat Values
All USD values are formatted with 2 decimal places and thousands separators:Token Amounts
Token balances use theformatTokenAmount utility:
Percentage Distribution
Shows what percentage of the asset’s value is on each chain:Styling
Asset Card
- Hover effects:
hover:border-muted-foreground/20 - Smooth transitions:
transition-all duration-200 - Responsive padding:
px-4 py-1
Expanded Section
- Background:
bg-muted/30 - Border top:
border-t border-border - Nested cards:
bg-background rounded-lg
Scrollable Container
Loading Indicator
When loading, shows a small indicator in the header:Asset Filtering
Only displays assets with positive fiat value:Empty State Guidance
Provides helpful onboarding information:1
Send assets
Direct users to send assets to their Account Address
2
Automatic sync
Explain that balances sync across all supported chains
3
Detailed views
Mention the expandable chain breakdowns
Accessibility
- Proper heading hierarchy (
h3,h4,h5) - Semantic HTML with
buttonelements for interactions - Clear visual indicators for expandable content (chevron icons)
- Keyboard navigation support for expansion toggles
- Image fallbacks with text alternatives
Error Handling
Image Loading Failures
Both token icons and chain logos have fallback displays:Performance Considerations
- Sorted assets are memoized through the render cycle
- Expansion state uses
Setfor O(1) lookups - Virtual scrolling could be added for wallets with 100+ assets
- Image loading is lazy and has fallbacks
Related Components
- BalanceDisplay - Simpler balance view
- ConnectButton - Parent component with modal
Best Practices
Always provide asset metadata
Always provide asset metadata
The
assets prop is required for proper decimal formatting and display. Fetch this data using useAssets() hook.Handle undefined balances
Handle undefined balances
The
balances prop is optional to support loading states. Always check for existence before rendering.Consider scroll containers
Consider scroll containers
The component has a max height of 256px. Ensure parent containers accommodate this or adjust the
max-h-64 class.Optimize for many assets
Optimize for many assets
For wallets with 50+ different tokens, consider implementing pagination or virtual scrolling.