diff --git a/src/lib/state/client/account.svelte.ts b/src/lib/state/client/account.svelte.ts index f8b165b21..7ab709db6 100644 --- a/src/lib/state/client/account.svelte.ts +++ b/src/lib/state/client/account.svelte.ts @@ -43,7 +43,7 @@ export class AccountState { ); public balances = $derived.by(() => this.network - ? getBalances(this.sources, this.network.chain.id, this.network.tokenmeta) + ? getBalances(this.sources, this.network.chain.id, this.network.tokenmeta, this.balance) : undefined ); public delegations = $derived(getDelegations(this.sources)); @@ -216,12 +216,25 @@ export function getBalance(network: NetworkState, sources: DataSources): Balance export function getBalances( sources: DataSources, chain: Checksum256, - tokenmeta?: TokenMeta[] + tokenmeta?: TokenMeta[], + balance?: Balance ): TokenBalance[] { if (sources.light_account) { const balances: TokenBalance[] = []; + + //If the value of system token is 0, + //for example, the chain does not support lightapi. + //replace it with the value of liquid sources.light_account?.forEach((lightAccount) => { - const asset = Asset.from(`${lightAccount.amount} ${lightAccount.currency}`); + let amount = lightAccount.amount; + if ( + !Number(amount) && + balance?.liquid && + balance.liquid.symbol.name === lightAccount.currency + ) { + amount = String(balance.liquid.value); + } + const asset = Asset.from(`${amount} ${lightAccount.currency}`); const contract = Name.from(lightAccount.contract); const id = TokenIdentifier.from({ chain: chain,