Skip to content

Commit

Permalink
fix: wallet-ui asset icon management (#428)
Browse files Browse the repository at this point in the history
* fix: wallet-ui asset icon management

* chore: fix comments
  • Loading branch information
khanti42 authored Nov 22, 2024
1 parent 3debd47 commit 9f43a22
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 14 deletions.
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

0 comments on commit 9f43a22

Please sign in to comment.