Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: wallet-ui asset icon management #428

Merged
merged 3 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/wallet-ui/src/assets/images/usdc-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions packages/wallet-ui/src/assets/images/usdt-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 12 additions & 13 deletions packages/wallet-ui/src/assets/types/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@ import ethIcon from '../images/eth-icon.svg';
import starknetIcon from '../images/starknet-icon.svg';
import daiIcon from '../images/dai-icon.svg';
import aaveIcon from '../images/aave-icon.svg';
import usdcIcon from '../images/usdc-icon.svg';
import usdtIcon from '../images/usdt-icon.svg';

export const assetIcons = [ethIcon, daiIcon, aaveIcon];
export enum AssetIconsIndex {
Ether = 0,
DAI = 1,
AAVE = 2,
}

export const getAssetIcon = (assetName: string): string => {
let iconIndex = -1;
if (Object.keys(AssetIconsIndex).indexOf(assetName) !== -1) {
iconIndex = AssetIconsIndex[assetName as keyof typeof AssetIconsIndex];
}
export const assetIcons: Record<string, string> = {
ETH: ethIcon,
DAI: daiIcon,
AAVE: aaveIcon,
USDC: usdcIcon,
USDT: usdtIcon,
STRK: starknetIcon, // Default to starknetIcon for STRK
};

return assetName ? assetIcons[iconIndex] : starknetIcon;
export const getAssetIcon = (assetSymbol: string): string => {
return assetIcons[assetSymbol] || starknetIcon; // Use starknetIcon as fallback
};
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const AssetListItemView = ({
<Left>
<DoubleIcons
tokenName={asset.name}
icon1={getAssetIcon(asset.name)}
icon1={getAssetIcon(asset.symbol)}
icon2={getAssetIcon('')}
/>
<Column>
Expand Down
Loading