diff --git a/app/src/lib/format.ts b/app/src/lib/format.ts index 039585a..c218012 100644 --- a/app/src/lib/format.ts +++ b/app/src/lib/format.ts @@ -1,3 +1,5 @@ +import type { SolistingStateCurrency } from '@solisting/sdk' + export function abbrev(pk: string | null | undefined): string { if (!pk) return '—' return `${pk.slice(0, 4)}…${pk.slice(-4)}` @@ -25,10 +27,14 @@ export function exact(ts: number): string { return new Date(ts * 1000).toUTCString() } +type CurrencyWithSymbol = + | { __kind: 'Sol' } + | (Extract & { symbol?: string }) + export function priceStr( - currency: { __kind: 'Sol' } | { __kind: 'Spl'; decimals: number; symbol?: string }, + currency: CurrencyWithSymbol, price: bigint | number, ): string { if (currency.__kind === 'Sol') return fmtSol(price) - return fmtTok(price, currency.decimals, (currency as { symbol?: string }).symbol ?? 'SPL') + return fmtTok(price, currency.decimals, currency.symbol ?? 'SPL') }