From 7c2ab40065be393aa8e12ed7c922376e855817a8 Mon Sep 17 00:00:00 2001 From: Dmytro Date: Mon, 14 Nov 2022 18:18:42 +0000 Subject: [PATCH] Fix token naming --- src/components/TokenList/TokenList.tsx | 4 ++-- .../TokenList/{iconsHelper.ts => helper.ts} | 14 +++++++++++++- .../TokenListSection/TokenListSection.tsx | 4 ++-- 3 files changed, 17 insertions(+), 5 deletions(-) rename src/components/TokenList/{iconsHelper.ts => helper.ts} (79%) diff --git a/src/components/TokenList/TokenList.tsx b/src/components/TokenList/TokenList.tsx index 1c2822a..2d75ce2 100644 --- a/src/components/TokenList/TokenList.tsx +++ b/src/components/TokenList/TokenList.tsx @@ -17,7 +17,7 @@ import TokenBalance from './TokenBalance'; import styles from "../WidgetUI/WidgetUI.scss"; import localStyles from "./TokenList.scss"; -import { getIconSrc, iconPath } from "./iconsHelper"; +import { getIconSrc, iconPath, getTokenName } from "./helper"; export default function TokenList(props) { @@ -63,7 +63,7 @@ export default function TokenList(props) { styles.mp__flexGrow, styles.mp__margRi10 )}> - {props.token.unwrappedSymbol ? props.token.unwrappedSymbol : props.token.name} + {getTokenName(props.token)}

diff --git a/src/components/TokenList/iconsHelper.ts b/src/components/TokenList/helper.ts similarity index 79% rename from src/components/TokenList/iconsHelper.ts rename to src/components/TokenList/helper.ts index 7763699..5f11b93 100644 --- a/src/components/TokenList/iconsHelper.ts +++ b/src/components/TokenList/helper.ts @@ -17,13 +17,25 @@ */ /** - * @file iconsHelper.ts + * @file helper.ts * @copyright SKALE Labs 2022-Present */ import TokenData from '../../core/dataclasses/TokenData'; +export function getTokenSymbol(token: TokenData): string { + let symbol = token.unwrappedSymbol ? token.unwrappedSymbol : token.symbol; + if (token.clone) symbol = token.cloneSymbol ? token.cloneSymbol : symbol; + return symbol; +} + + +export function getTokenName(token: TokenData): string { + return token.name ? token.name : getTokenSymbol(token); +} + + function importAll(r) { const images = {}; r.keys().map((item, index) => { images[item.replace('./', '')] = r(item); }); diff --git a/src/components/TokenListSection/TokenListSection.tsx b/src/components/TokenListSection/TokenListSection.tsx index 55a1be1..f3ca9b9 100644 --- a/src/components/TokenListSection/TokenListSection.tsx +++ b/src/components/TokenListSection/TokenListSection.tsx @@ -11,7 +11,7 @@ import TokenBalance from '../TokenList/TokenBalance'; import styles from "../WidgetUI/WidgetUI.scss"; import localStyles from "./TokenListSection.scss"; -import { getIconSrc } from "../TokenList/iconsHelper"; +import { getIconSrc, getTokenName } from "../TokenList/helper"; export default function TokenListSection(props) { @@ -49,7 +49,7 @@ export default function TokenListSection(props) { styles.mp__flexGrow, styles.mp__margRi10 )}> - {props.tokens[key].unwrappedSymbol ? props.tokens[key].unwrappedSymbol : props.tokens[key].name} + {getTokenName(props.tokens[key])}