UNPKG

@ledgerhq/coin-ton

Version:
65 lines 2.25 kB
"use strict"; 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 core_1 = require("@ton/core"); const bignumber_js_1 = require("bignumber.js"); const constants_1 = require("./constants"); function getDeviceTransactionConfig(input) { const fields = []; const tokenTransfer = Boolean(input.account && (0, index_1.isTokenAccount)(input.account)); fields.push({ type: "address", label: "To", address: input.transaction.recipient, }); if (tokenTransfer) { fields.push({ type: "text", label: "Jetton amount", value: (0, index_2.formatCurrencyUnit)((0, index_1.getAccountCurrency)(input.account).units[0], input.transaction.amount, { showCode: true, disableRounding: true, }), }); fields.push({ type: "text", label: "Amount", value: input.parentAccount ? (0, index_2.formatCurrencyUnit)((0, index_1.getAccountCurrency)(input.parentAccount).units[0], (0, bignumber_js_1.BigNumber)((0, core_1.toNano)(constants_1.TOKEN_TRANSFER_MAX_FEE).toString()), { showCode: true, disableRounding: true, }) : constants_1.TOKEN_TRANSFER_MAX_FEE, }); } else { if (input.transaction.useAllAmount) { fields.push({ type: "text", label: "Amount", value: "ALL YOUR TONs", }); } else { fields.push({ type: "amount", label: "Amount", }); } fields.push({ type: "fees", label: "Fee", }); } if (!input.transaction.comment.isEncrypted && input.transaction.comment.text) { fields.push({ type: "text", label: "Comment", value: input.transaction.comment.text, }); } return fields; } exports.default = getDeviceTransactionConfig; //# sourceMappingURL=deviceTransactionConfig.js.map