Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions frontend/lib/format.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
const xlm = new Intl.NumberFormat("en-US", {

const _numberFmt = new Intl.NumberFormat("en-US", {
minimumFractionDigits: 2,
maximumFractionDigits: 7,
});

/**
* FIX #18: formatAmount accepts an explicit assetCode instead of always
* appending "XLM". Defaults to "USDC" to match the product description
* (stablecoin rent payments), but every call site can override.
*
* Migration path for existing callers:
* formatXLM(amount) -> formatAmount(amount) // shows USDC
* formatXLM(amount) -> formatAmount(amount, "XLM") // old behaviour
*/
export function formatAmount(amount: number, assetCode = "USDC"): string {
return ;
}

/**
* @deprecated Use formatAmount(amount, assetCode) instead.
* Kept for incremental migration of existing call sites.
*/
export function formatXLM(amount: number): string {
return `${xlm.format(amount)} XLM`;
return formatAmount(amount, "XLM");
}

export function shortAddress(addr: string, head = 6, tail = 4): string {
return `${addr.slice(0, head)}…${addr.slice(-tail)}`;
return ;
}