import BigNumber from "bignumber.js";
import { getAlpacaApi } from "./alpaca";
// => alpaca validateIntent
export function genericGetTransactionStatus(network, kind) {
    return async (account, transaction) => {
        const { freshAddress, balance, currency } = account;
        const alpacaApi = getAlpacaApi(network, kind);
        const { errors, warnings } = await alpacaApi.validateIntent({
            currencyName: currency.name,
            address: freshAddress,
            balance: BigInt(balance.toString()),
            currencyUnit: currency.units[0],
        }, {
            type: "PAYMENT",
            recipient: transaction.recipient,
            amount: BigInt(transaction.amount?.toString() ?? "0"),
            fee: BigInt(transaction.fees?.toString() ?? "0"),
        });
        const estimatedFees = transaction.fees || new BigNumber(0);
        return Promise.resolve({
            errors,
            warnings,
            estimatedFees,
            amount: transaction.amount,
            totalSpent: transaction.amount.plus(transaction.fees),
        });
    };
}
//# sourceMappingURL=getTransactionStatus.js.map