|
3 | 3 | import { formatTokenAmountBestMatch, IAsset } from '@core/wallet'
|
4 | 4 | import { formatCurrency, localize } from '@core/i18n'
|
5 | 5 | import { getMarketAmountFromAssetValue } from '@core/market/utils'
|
6 |
| - import { DEFAULT_MANA } from '@core/network' |
| 6 | + import { DEFAULT_MANA, NetworkId } from '@core/network' |
| 7 | + import { activeProfile } from '@core/profile' |
7 | 8 |
|
8 | 9 | export let asset: IAsset
|
9 | 10 | export let mana: IAsset
|
10 | 11 |
|
11 | 12 | $: availableMarketValue = getMarketAmountFromAssetValue(asset?.balance?.available, asset)
|
12 | 13 | $: totalMarketValue = getMarketAmountFromAssetValue(asset?.balance?.total, asset)
|
13 | 14 | $: disabled = Number.isNaN(totalMarketValue) || Number.isNaN(availableMarketValue)
|
| 15 | + $: isNotTestnetOrCustomNetwork = |
| 16 | + $activeProfile?.network?.id !== NetworkId.Testnet && $activeProfile?.network?.id !== NetworkId.Custom |
14 | 17 |
|
15 | 18 | let isToggled = false
|
16 | 19 | function toggle(): void {
|
|
22 | 25 | <button on:click={toggle} type="button" {disabled}>
|
23 | 26 | <div class="flex flex-col flex-wrap items-start space-y-1">
|
24 | 27 | <Text type={TextType.h1} fontWeight={FontWeight.semibold}>
|
25 |
| - {isToggled |
| 28 | + {isToggled && isNotTestnetOrCustomNetwork |
26 | 29 | ? formatCurrency(totalMarketValue)
|
27 | 30 | : formatTokenAmountBestMatch(asset?.balance?.total, asset?.metadata)}
|
28 | 31 | </Text>
|
29 | 32 | <Text type={TextType.p} fontWeight={FontWeight.medium} color="gray-600" darkColor="gray-500">
|
30 | 33 | {localize('general.availableBalanceWithValue', {
|
31 | 34 | values: {
|
32 |
| - balance: isToggled |
33 |
| - ? formatCurrency(availableMarketValue) |
34 |
| - : formatTokenAmountBestMatch(asset?.balance?.available, asset?.metadata), |
| 35 | + balance: |
| 36 | + isToggled && isNotTestnetOrCustomNetwork |
| 37 | + ? formatCurrency(availableMarketValue) |
| 38 | + : formatTokenAmountBestMatch(asset?.balance?.available, asset?.metadata), |
35 | 39 | },
|
36 | 40 | })}
|
37 | 41 | </Text>
|
|
0 commit comments