@ledgerhq/coin-icon
Version:
Ledger Icon Coin integration
29 lines • 1.23 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.estimateMaxSpendable = void 0;
const index_1 = require("@ledgerhq/coin-framework/account/index");
const createTransaction_1 = require("./createTransaction");
const getFeesForTransaction_1 = __importDefault(require("./getFeesForTransaction"));
const logic_1 = require("./logic");
/**
* Returns the maximum possible amount for transaction
*
* @param {Object} param - the account, parentAccount and transaction
*/
const estimateMaxSpendable = async ({ account, parentAccount, transaction, }) => {
const acc = (0, index_1.getMainAccount)(account, parentAccount);
const tx = { ...(0, createTransaction_1.createTransaction)(), ...transaction, useAllAmount: true };
const fees = await (0, getFeesForTransaction_1.default)({
account: acc,
transaction: tx,
});
return (0, logic_1.calculateAmount)({
account: acc,
transaction: { ...tx, fees },
});
};
exports.estimateMaxSpendable = estimateMaxSpendable;
//# sourceMappingURL=estimateMaxSpendable.js.map