How to use the @ledgerhq/live-common/lib/currencies.formatCurrencyUnit function in @ledgerhq/live-common

To help you get started, we’ve selected a few @ledgerhq/live-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LedgerHQ / ledger-live-common / cli / src / accountFormatters.js View on Github external
ta =>
        "\n  " +
        ta.type +
        " " +
        getAccountName(ta) +
        ": " +
        formatCurrencyUnit(getAccountUnit(ta), ta.balance, {
          showCode: true,
          disableRounding: true
        }) +
        " (" +
        ta.operations.length +
        " ops)"
    )
github LedgerHQ / ledger-live-common / tools / src / demos / countervalues / components / ReversePrice.js View on Github external
render() {
    const { from, to, value, reversed } = this.props;
    if (!reversed) return null;
    return (
      <span>
        <strong>
          {formatCurrencyUnit(to.units[0], value, { showCode: true })}
        </strong>
        {" = "}
        <strong>
          {formatCurrencyUnit(from.units[0], reversed, { showCode: true })}
        </strong>
      </span>
    );
  }
}
github LedgerHQ / ledger-live-mobile / src / api / Ripple.js View on Github external
export const formatAPICurrencyXRP = (amount: BigNumber) => {
  const value = formatCurrencyUnit(rippleUnit, amount, {
    showAllDigits: true,
    disableRounding: true,
    useGrouping: false,
  });
  return { currency: "XRP", value };
};
github LedgerHQ / ledger-live-common / demo / src / demos / countervalue-intermediary / components / Price.js View on Github external
render() {
    const { to, countervalue } = this.props;
    if (!countervalue) return null;
    return (
      <span>
        <strong>
          {formatCurrencyUnit(to.units[0], countervalue, { showCode: true })}
        </strong>
      </span>
    );
  }
}
github LedgerHQ / ledger-live-mobile / src / components / CurrencyUnitValue.js View on Github external
render() {
    const { unit, value, ...rest } = this.props;
    return formatCurrencyUnit(unit, value, {
      ...rest,
    });
  }
}
github LedgerHQ / ledger-live-desktop / scripts / cli / txBetweenAccounts.js View on Github external
choices: accounts.map(account => ({
        name: `${account.name} | ${chalk.green(
          formatCurrencyUnit(account.unit, account.balance, {
            showCode: true,
          }),
        )}`,
        value: account,
      })),
      name: 'account',
github LedgerHQ / ledger-live-desktop / src / components / base / InputCurrency / index.js View on Github external
function format(unit: Unit, value: BigNumber, { locale, isFocused, showAllDigits, subMagnitude }) {
  return formatCurrencyUnit(unit, value, {
    locale,
    useGrouping: !isFocused,
    disableRounding: true,
    showAllDigits: !!showAllDigits && !isFocused,
    subMagnitude: value.isLessThan(1) ? subMagnitude : 0,
  })
}
github LedgerHQ / ledger-live-common / cli / src / accountFormatters.js View on Github external
const format = (op, level = 0) => {
    const amount = formatCurrencyUnit(
      unitByAccountId(op.accountId),
      getOperationAmountNumber(op),
      {
        showCode: true,
        alwaysShowSign: true
      }
    );
    const spaces = Array((level + 1) * 2)
      .fill(" ")
      .join("");
    const extra = level > 0 ? "" : `${op.hash}     ${op.date.toISOString()}`;
    const head = `${(spaces + amount).padEnd(20)} ${op.type.padEnd(
      11
    )}${extra}`;
    const sub = (op.subOperations || [])
      .concat(op.internalOperations || [])
github LedgerHQ / ledger-live-common / tools / src / demos / countervalues / components / Price.js View on Github external
render() {
    const { from, to, value, countervalue } = this.props;
    if (!countervalue) return null;
    return (
      <span>
        <strong>
          {formatCurrencyUnit(from.units[0], value, { showCode: true })}
        </strong>
        {" = "}
        <strong>
          {formatCurrencyUnit(to.units[0], countervalue, { showCode: true })}
        </strong>
      </span>
    );
  }
}
github LedgerHQ / ledger-live-common / tools / src / demos / assets / index.js View on Github external
const counter = counterpartFor(t);
      if (rates[counter.ticker]) {
        const ratePerExchange = (rates[counter.ticker] || {})[t.ticker] || {};
        exchange = Object.keys(ratePerExchange)[0];
        if (exchange) {
          const latest = ratePerExchange[exchange].latest || 0;

          if (counter !== usdFiat) {
            if (rates[usdFiat.ticker]) {
              const intermRatePerExchange =
                (rates[usdFiat.ticker] || {})[counter.ticker] || {};
              const intermExchange = Object.keys(intermRatePerExchange)[0];
              if (intermExchange) {
                const intermLatest =
                  intermRatePerExchange[intermExchange].latest || 0;
                usdValue = formatCurrencyUnit(
                  usdFiat.units[0],
                  BigNumber(latest)
                    .times(intermLatest)
                    .times(10 ** t.units[0].magnitude)
                );
              }
            }
          } else {
            usdValue = formatCurrencyUnit(
              counter.units[0],
              BigNumber(latest).times(10 ** t.units[0].magnitude)
            );
          }

          formatted = formatCurrencyUnit(
            counter.units[0],