Skip to content

Commit

Permalink
fix(bridge-ui): truncate selected token name to 5 characters (#16066)
Browse files Browse the repository at this point in the history
  • Loading branch information
leppaludi committed Feb 26, 2024
1 parent f064224 commit dc24155
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import type { Token } from '$libs/token';
import { classNames } from '$libs/util/classNames';
import { noop } from '$libs/util/noop';
import { truncateString } from '$libs/util/truncateString';
import { account } from '$stores/account';
import AddCustomErc20 from './AddCustomERC20.svelte';
Expand Down Expand Up @@ -102,7 +103,7 @@
<i role="img" aria-label={ct.name}>
<Erc20 />
</i>
<span class="body-bold">{ct.symbol}</span>
<span class="body-bold">{truncateString(ct.symbol, 10)}</span>
</div>
</li>
{/each}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import { ETHToken, fetchBalance as getTokenBalance, type Token, TokenType } from '$libs/token';
import { getTokenAddresses } from '$libs/token/getTokenAddresses';
import { getLogger } from '$libs/util/logger';
import { truncateString } from '$libs/util/truncateString';
import { uid } from '$libs/util/uid';
import { type Account, account } from '$stores/account';
import { connectedSourceChain } from '$stores/network';
Expand Down Expand Up @@ -230,7 +231,7 @@
<svelte:component this={Erc20} size={20} />
</i>
{/if}
<span class={textClass}>{value.symbol}</span>
<span class={textClass}>{truncateString(value.symbol, 5)}</span>
</div>
{/if}
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/bridge-ui/src/libs/util/balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function renderBalance(balance: Maybe<GetBalanceReturnType>) {
if (!balance) return '0.00';
// if (typeof balance === 'bigint') return balance.toString();
const maxlength = Number(balance.formatted) < 0.000001 ? balance.decimals : 6;
return `${truncateString(balance.formatted, maxlength, '')} ${balance.symbol}`;
return `${truncateString(balance.formatted, maxlength, '')} ${truncateString(balance.symbol, 5)}`;
}

export function renderEthBalance(balance: bigint, maxlength = 8): string {
Expand Down

0 comments on commit dc24155

Please sign in to comment.