Skip to content

Commit

Permalink
fix: use network symbol as default
Browse files Browse the repository at this point in the history
  • Loading branch information
deansallinen committed Oct 1, 2024
1 parent fba6c42 commit a8d3681
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions src/routes/[network]/api/account/[[name]]/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getChainDefinitionFromParams, getNetwork, NetworkState } from '$lib/sta
import { getCacheHeaders } from '$lib/utils';
import type { LightAPIBalanceResponse, LightAPIBalanceRow } from '$lib/types.js';
import type { RequestHandler } from './$types';
import { type NameType } from '@wharfkit/antelope';
import { Asset, type NameType } from '@wharfkit/antelope';

export const GET: RequestHandler = async ({ fetch, params }) => {
const chain = getChainDefinitionFromParams(params.network);
Expand All @@ -29,21 +29,13 @@ export const GET: RequestHandler = async ({ fetch, params }) => {

// If no response from the light API, add the core liquid balance as a default if it exists
if (!balances.length && chain.systemToken) {
if (account_data.core_liquid_balance) {
balances.push({
contract: chain.systemToken.contract.toString(),
amount: account_data.core_liquid_balance.quantity,
decimals: account_data.core_liquid_balance.symbol.precision.toString(),
currency: account_data.core_liquid_balance.symbol.code.toString()
});
} else {
balances.push({
contract: chain.systemToken.contract.toString(),
amount: '0',
decimals: '0',
currency: ''
});
}
const symbol = Asset.Symbol.from(network.config.symbol);
balances.push({
contract: String(chain.systemToken.contract),
amount: '0',
decimals: String(symbol.precision),
currency: String(symbol.code)
});
}

return json(
Expand Down

0 comments on commit a8d3681

Please sign in to comment.