@ledgerhq/coin-algorand
Version:
Ledger Algorand Coin integration
40 lines • 1.52 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const index_1 = require("@ledgerhq/coin-framework/account/index");
const index_2 = require("@ledgerhq/coin-framework/currencies/index");
const invariant_1 = __importDefault(require("invariant"));
function formatOperationSpecifics(op, unit) {
const { rewards } = op.extra;
return rewards
? ` REWARDS : ${unit
? (0, index_2.formatCurrencyUnit)(unit, rewards, {
showCode: true,
disableRounding: true,
}).padEnd(16)
: rewards.toString()}`
: "";
}
function formatAccountSpecifics(account) {
const { algorandResources } = account;
(0, invariant_1.default)(algorandResources, "algorand account expected");
const unit = (0, index_1.getAccountCurrency)(account).units[0];
const formatConfig = {
disableRounding: true,
alwaysShowSign: false,
showCode: true,
};
let str = " ";
str += (0, index_2.formatCurrencyUnit)(unit, account.spendableBalance, formatConfig) + " spendable. ";
if (algorandResources.rewards.gt(0)) {
str += (0, index_2.formatCurrencyUnit)(unit, algorandResources.rewards, formatConfig) + " rewards. ";
}
return str;
}
exports.default = {
formatAccountSpecifics,
formatOperationSpecifics,
};
//# sourceMappingURL=formatters.js.map