@ledgerhq/coin-icon
Version: 
Ledger Icon Coin integration
22 lines • 835 B
JavaScript
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