@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
27 lines (21 loc) • 595 B
text/typescript
import type { Currency } from "@ledgerhq/types-cryptoassets";
const defaultColor = "#999";
export type ColorableCurrency = {
type: Currency["type"];
color?: string | undefined;
id: string;
ticker: string;
parentCurrency?: {
color?: string | undefined;
};
};
export function getCurrencyColor(currency: ColorableCurrency | Currency): string {
switch (currency.type) {
case "CryptoCurrency":
return currency.color ?? defaultColor;
case "TokenCurrency":
return currency?.parentCurrency?.color ?? defaultColor;
default:
return defaultColor;
}
}