UNPKG

@ledgerhq/coin-aptos

Version:
90 lines 3.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const formatCurrencyUnit_1 = require("@ledgerhq/coin-framework/currencies/formatCurrencyUnit"); const helpers_1 = require("@ledgerhq/coin-framework/account/helpers"); async function getDeviceTransactionConfig({ account, parentAccount, transaction, }) { const { mode } = transaction; const fields = []; const mainAccount = (0, helpers_1.getMainAccount)(account, parentAccount); const { fees } = transaction; if (fees) { fields.push({ type: "text", label: "Transaction Fee", value: (0, formatCurrencyUnit_1.formatCurrencyUnit)((0, helpers_1.getAccountCurrency)(mainAccount).units[0], fees, { showCode: true, disableRounding: true, }), }); } if (mode === "send") { if (account.type === "TokenAccount") { fields.push({ type: "text", label: "Type", value: "Token transfer", }); fields.push({ type: "text", label: "Amount", value: (0, formatCurrencyUnit_1.formatCurrencyUnit)((0, helpers_1.getAccountCurrency)(account).units[0], transaction.amount, { showCode: true, disableRounding: true, }), }); } else if (account.type === "Account") { fields.push({ type: "text", label: "Amount", value: (0, formatCurrencyUnit_1.formatCurrencyUnit)((0, helpers_1.getAccountCurrency)(account).units[0], transaction.amount, { showCode: true, disableRounding: true, }), }); } } else if ((mode === "stake" || mode === "restake") && account.type === "Account") { fields.push({ type: "text", label: "Delegate to", value: transaction.recipient, }); fields.push({ type: "text", label: "Amount", value: (0, formatCurrencyUnit_1.formatCurrencyUnit)((0, helpers_1.getAccountCurrency)(account).units[0], transaction.amount, { showCode: true, disableRounding: true, }), }); } else if (mode === "unstake" && account.type === "Account") { fields.push({ type: "text", label: "Undelegate from", value: transaction.recipient, }); fields.push({ type: "text", label: "Amount", value: (0, formatCurrencyUnit_1.formatCurrencyUnit)((0, helpers_1.getAccountCurrency)(account).units[0], transaction.amount, { showCode: true, disableRounding: true, }), }); } else if (mode === "withdraw" && account.type === "Account") { fields.push({ type: "text", label: "Amount", value: (0, formatCurrencyUnit_1.formatCurrencyUnit)((0, helpers_1.getAccountCurrency)(account).units[0], transaction.amount, { showCode: true, disableRounding: true, }), }); } return fields; } exports.default = getDeviceTransactionConfig; //# sourceMappingURL=deviceTransactionConfig.js.map