diff --git a/src/lib/state/client/account.svelte.ts b/src/lib/state/client/account.svelte.ts index 0c4c1e1b..981b8597 100644 --- a/src/lib/state/client/account.svelte.ts +++ b/src/lib/state/client/account.svelte.ts @@ -20,7 +20,7 @@ import { calculateValue } from '$lib/utils'; const defaultDataSources = { get_account: undefined, - light_account: [], + balances: [], delegated: [], rex: undefined, rexfund: undefined @@ -79,7 +79,7 @@ export class AccountState { this.last_update = new Date(); this.sources = { get_account: json.account_data, - light_account: json.balances, + balances: json.balances, delegated: json.delegated, rex: json.rex, rexfund: json.rexfund @@ -218,29 +218,27 @@ export function getBalances( chain: Checksum256, tokenmeta?: TokenMeta[] ): TokenBalance[] { - if (sources.light_account) { + if (sources.balances) { const balances: TokenBalance[] = []; - sources.light_account.forEach((lightAccount) => { - lightAccount.balances?.forEach((balance) => { - const asset = Asset.from(`${balance.amount} ${balance.currency}`); - const contract = Name.from(balance.contract); - const id = TokenIdentifier.from({ - chain: chain, - contract: contract, - symbol: asset.symbol - }); - const metadata = - tokenmeta && tokenmeta.length > 0 - ? tokenmeta.find((meta) => meta.id.equals(id)) - : undefined; - balances.push( - TokenBalance.from({ - asset, - contract, - metadata: metadata || TokenMeta.from({ id: { chain, contract, symbol: asset.symbol } }) - }) - ); + sources.balances?.forEach((balance) => { + const asset = Asset.from(`${balance.amount} ${balance.currency}`); + const contract = Name.from(balance.contract); + const id = TokenIdentifier.from({ + chain: chain, + contract: contract, + symbol: asset.symbol }); + const metadata = + tokenmeta && tokenmeta.length > 0 + ? tokenmeta.find((meta) => meta.id.equals(id)) + : undefined; + balances.push( + TokenBalance.from({ + asset, + contract, + metadata: metadata || TokenMeta.from({ id: { chain, contract, symbol: asset.symbol } }) + }) + ); }); return balances; diff --git a/src/lib/types.ts b/src/lib/types.ts index acfa1a60..a014632e 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -34,7 +34,7 @@ export class ActivityAction extends Struct { export interface DataSources { get_account?: API.v1.AccountObject | undefined; - light_account: LightAPIBalanceResponse[]; + balances: LightAPIBalanceRow[]; delegated: SystemContract.Types.delegated_bandwidth[]; rex?: SystemContract.Types.rex_balance; rexfund?: SystemContract.Types.rex_fund;