import { getAlpacaApi } from "./alpaca";
import { transactionToIntent } from "./utils";
import BigNumber from "bignumber.js";
function bnEq(a, b) {
    return !a && !b ? true : !a || !b ? false : a.eq(b);
}
export function genericPrepareTransaction(network, kind) {
    return async (account, transaction) => {
        const fees = await getAlpacaApi(network, kind).estimateFees(transactionToIntent(account, transaction));
        const bnFee = BigNumber(fees.value.toString());
        if (!bnEq(transaction.fees, bnFee)) {
            return { ...transaction, fees: bnFee };
        }
        return transaction;
    };
}
//# sourceMappingURL=prepareTransaction.js.map