UNPKG

@ledgerhq/coin-celo

Version:
47 lines 1.78 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.toTransactionRaw = exports.formatTransaction = void 0; const bignumber_js_1 = require("bignumber.js"); 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 formatTransaction = (t, account) => ` SEND ${t.useAllAmount ? "MAX CELO" : (0, index_2.formatCurrencyUnit)((0, index_1.getAccountCurrency)(account).units[0], t.amount, { showCode: true, disableRounding: true, })} TO ${t.recipient}`; exports.formatTransaction = formatTransaction; const fromTransactionRaw = (tr) => { const common = (0, serialization_1.fromTransactionCommonRaw)(tr); return { ...common, family: tr.family, fees: tr.fees ? new bignumber_js_1.BigNumber(tr.fees) : null, mode: tr.mode, index: tr.index, }; }; const toTransactionRaw = (t) => { const common = (0, serialization_1.toTransactionCommonRaw)(t); return { ...common, family: t.family, fees: t.fees?.toString() || null, mode: t.mode, index: t.index, }; }; exports.toTransactionRaw = toTransactionRaw; exports.default = { formatTransaction: exports.formatTransaction, fromTransactionRaw, toTransactionRaw: exports.toTransactionRaw, fromTransactionStatusRaw: serialization_1.fromTransactionStatusRawCommon, toTransactionStatusRaw: serialization_1.toTransactionStatusRawCommon, formatTransactionStatus: formatters_1.formatTransactionStatus, }; //# sourceMappingURL=transaction.js.map