UNPKG

@ledgerhq/coin-casper

Version:
53 lines 2.09 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.fromTransactionRaw = exports.formatTransaction = void 0; const formatters_1 = require("@ledgerhq/coin-framework/formatters"); const serialization_1 = require("@ledgerhq/coin-framework/serialization"); const index_1 = require("@ledgerhq/coin-framework/account/index"); const index_2 = require("@ledgerhq/coin-framework/currencies/index"); const bignumber_js_1 = __importDefault(require("bignumber.js")); const formatTransaction = ({ recipient, useAllAmount, amount }, account) => ` SEND ${useAllAmount ? "MAX" : amount.isZero() ? "" : " " + (0, index_2.formatCurrencyUnit)((0, index_1.getAccountCurrency)(account).units[0], amount, { showCode: true, disableRounding: true, })} TO ${recipient}`; exports.formatTransaction = formatTransaction; const fromTransactionRaw = (tr) => { const common = (0, serialization_1.fromTransactionCommonRaw)(tr); return { ...common, family: tr.family, fees: new bignumber_js_1.default(tr.fees), amount: new bignumber_js_1.default(tr.amount), transferId: tr.transferId, }; }; exports.fromTransactionRaw = fromTransactionRaw; const toTransactionRaw = (t) => { const common = (0, serialization_1.toTransactionCommonRaw)(t); return { ...common, family: t.family, amount: t.amount.toFixed(), fees: t.fees.toString(), transferId: t.transferId, }; }; exports.default = { formatTransaction: exports.formatTransaction, fromTransactionRaw: exports.fromTransactionRaw, toTransactionRaw, fromTransactionStatusRaw: serialization_1.fromTransactionStatusRawCommon, toTransactionStatusRaw: serialization_1.toTransactionStatusRawCommon, formatTransactionStatus: formatters_1.formatTransactionStatus, }; //# sourceMappingURL=transaction.js.map