UNPKG

@ledgerhq/coin-ton

Version:
21 lines 1.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const jsHelpers_1 = require("@ledgerhq/coin-framework/bridge/jsHelpers"); const api_1 = require("./bridge/bridgeHelpers/api"); const utils_1 = require("./utils"); const prepareTransaction = async (account, transaction) => { const accountInfo = await (0, api_1.fetchAccountInfo)(account.freshAddress); const subAccount = (0, utils_1.findSubAccountById)(account, transaction.subAccountId ?? ""); const simpleTx = (0, utils_1.buildTonTransaction)(transaction, accountInfo.seqno, account); const fees = await (0, utils_1.getTonEstimatedFees)(account, accountInfo.status === "uninit", simpleTx); let amount; if (transaction.useAllAmount) { amount = subAccount ? subAccount.spendableBalance : account.spendableBalance.minus(fees); } else { amount = transaction.amount; } return (0, jsHelpers_1.updateTransaction)(transaction, { fees, amount }); }; exports.default = prepareTransaction; //# sourceMappingURL=prepareTransaction.js.map