Skip to content

Commit 6334d14

Browse files
feat: fix available balance toggle on tesnet and custom network (#8501)
* fix available balance toggle on tesnet and custom network * fix: move to variable * fix import --------- Co-authored-by: Begoña Álvarez de la Cruz <[email protected]>
1 parent 299fc94 commit 6334d14

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

packages/shared/components/labels/TogglableAssetBalanceLabel.svelte

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@
33
import { formatTokenAmountBestMatch, IAsset } from '@core/wallet'
44
import { formatCurrency, localize } from '@core/i18n'
55
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'
78
89
export let asset: IAsset
910
export let mana: IAsset
1011
1112
$: availableMarketValue = getMarketAmountFromAssetValue(asset?.balance?.available, asset)
1213
$: totalMarketValue = getMarketAmountFromAssetValue(asset?.balance?.total, asset)
1314
$: disabled = Number.isNaN(totalMarketValue) || Number.isNaN(availableMarketValue)
15+
$: isNotTestnetOrCustomNetwork =
16+
$activeProfile?.network?.id !== NetworkId.Testnet && $activeProfile?.network?.id !== NetworkId.Custom
1417
1518
let isToggled = false
1619
function toggle(): void {
@@ -22,16 +25,17 @@
2225
<button on:click={toggle} type="button" {disabled}>
2326
<div class="flex flex-col flex-wrap items-start space-y-1">
2427
<Text type={TextType.h1} fontWeight={FontWeight.semibold}>
25-
{isToggled
28+
{isToggled && isNotTestnetOrCustomNetwork
2629
? formatCurrency(totalMarketValue)
2730
: formatTokenAmountBestMatch(asset?.balance?.total, asset?.metadata)}
2831
</Text>
2932
<Text type={TextType.p} fontWeight={FontWeight.medium} color="gray-600" darkColor="gray-500">
3033
{localize('general.availableBalanceWithValue', {
3134
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),
3539
},
3640
})}
3741
</Text>

0 commit comments

Comments
 (0)