UNPKG

@ledgerhq/coin-algorand

Version:
35 lines 1.24 kB
import { getAccountCurrency } from "@ledgerhq/coin-framework/account/index"; import { formatCurrencyUnit } from "@ledgerhq/coin-framework/currencies/index"; import invariant from "invariant"; function formatOperationSpecifics(op, unit) { const { rewards } = op.extra; return rewards ? ` REWARDS : ${unit ? formatCurrencyUnit(unit, rewards, { showCode: true, disableRounding: true, }).padEnd(16) : rewards.toString()}` : ""; } function formatAccountSpecifics(account) { const { algorandResources } = account; invariant(algorandResources, "algorand account expected"); const unit = getAccountCurrency(account).units[0]; const formatConfig = { disableRounding: true, alwaysShowSign: false, showCode: true, }; let str = " "; str += formatCurrencyUnit(unit, account.spendableBalance, formatConfig) + " spendable. "; if (algorandResources.rewards.gt(0)) { str += formatCurrencyUnit(unit, algorandResources.rewards, formatConfig) + " rewards. "; } return str; } export default { formatAccountSpecifics, formatOperationSpecifics, }; //# sourceMappingURL=formatters.js.map