UNPKG

@ledgerhq/coin-icon

Version:
22 lines 835 B
import { getMainAccount } from "@ledgerhq/coin-framework/account/index"; import { createTransaction } from "./createTransaction"; import getEstimatedFees from "./getFeesForTransaction"; import { calculateAmount } from "./logic"; /** * Returns the maximum possible amount for transaction * * @param {Object} param - the account, parentAccount and transaction */ export const estimateMaxSpendable = async ({ account, parentAccount, transaction, }) => { const acc = getMainAccount(account, parentAccount); const tx = { ...createTransaction(), ...transaction, useAllAmount: true }; const fees = await getEstimatedFees({ account: acc, transaction: tx, }); return calculateAmount({ account: acc, transaction: { ...tx, fees }, }); }; //# sourceMappingURL=estimateMaxSpendable.js.map