MCPcopy
hub / github.com/BlueWallet/BlueWallet / formatBalanceWithoutSuffix

Function formatBalanceWithoutSuffix

loc/index.ts:399–412  ·  view source on GitHub ↗
(balance = 0, toUnit: string, withFormatting = false)

Source from the content-addressed store, hash-verified

397 * @returns {string}
398 */
399export function formatBalanceWithoutSuffix(balance = 0, toUnit: string, withFormatting = false): string | number {
400 if (toUnit === undefined) {
401 return balance;
402 }
403 if (toUnit === BitcoinUnit.BTC) {
404 const value = new BigNumber(balance).dividedBy(100000000).toFixed(8);
405 return removeTrailingZeros(value);
406 } else if (toUnit === BitcoinUnit.SATS) {
407 return withFormatting ? new Intl.NumberFormat().format(balance).toString() : String(balance);
408 } else {
409 console.debug('[UnitSwitch/Fiat] formatBalanceWithoutSuffix to fiat', { balance, unit: toUnit, withFormatting });
410 return satoshiToLocalCurrency(balance);
411 }
412}
413
414/**
415 * Should be used when we need a simple string to be put in text input, for example

Callers 15

AmountInputFunction · 0.90
confirmWalletDeletionFunction · 0.90
LnurlPayFunction · 0.90
TransactionStatusFunction · 0.90
handleSendTransactionFunction · 0.90
SendDetailsFunction · 0.90

Calls 3

satoshiToLocalCurrencyFunction · 0.90
removeTrailingZerosFunction · 0.85
toStringMethod · 0.80

Tested by

no test coverage detected