@ledgerhq/coin-multiversx
Version:
Ledger MultiversX Coin integration
60 lines • 2.03 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const bignumber_js_1 = __importDefault(require("bignumber.js"));
const currencies_1 = require("@ledgerhq/coin-framework/currencies");
const account_1 = require("@ledgerhq/coin-framework/account");
const logic_1 = require("./logic");
function getDeviceTransactionConfig({ account, transaction, status: { estimatedFees }, }) {
const fields = [];
const { subAccountId } = transaction;
const isEsdtTransfer = subAccountId !== undefined && subAccountId !== null;
if (isEsdtTransfer) {
const { token } = (0, account_1.decodeTokenAccountId)(subAccountId);
if (token) {
fields.push({
type: "text",
label: "Token",
value: token.name,
});
fields.push({
type: "amount",
label: "Value",
});
}
}
fields.push({
type: "address",
label: "Receiver",
address: transaction.recipient,
});
if (!isEsdtTransfer) {
if (!(0, logic_1.isAmountSpentFromBalance)(transaction.mode)) {
fields.push({
type: "text",
label: "Amount",
value: (0, currencies_1.formatCurrencyUnit)((0, account_1.getAccountCurrency)(account).units[0], new bignumber_js_1.default(0), {
showCode: true,
disableRounding: true,
}),
});
}
else {
fields.push({
type: "amount",
label: "Amount",
});
}
}
if (!estimatedFees.isZero()) {
fields.push({
type: "fees",
label: "Fee",
});
}
return fields;
}
exports.default = getDeviceTransactionConfig;
//# sourceMappingURL=deviceTransactionConfig.js.map