import { getEnv } from "@ledgerhq/live-env";
import { postSwapAccepted, postSwapCancelled } from "./index";
export const setBroadcastTransaction = ({ result, provider, sourceCurrencyId, targetCurrencyId, hardwareWalletType, swapType, swapAppVersion, fromAccountAddress, toAccountAddress, fromAmount, }) => {
    const { operation, swapId } = result;
    /**
     * If transaction broadcast are disabled, consider the swap as cancelled
     * since the partner will never receive the funds
     */
    if (getEnv("DISABLE_TRANSACTION_BROADCAST")) {
        postSwapCancelled({
            provider,
            swapId,
            swapStep: "SIGN_COIN_TRANSACTION",
            statusCode: "DISABLE_TRANSACTION_BROADCAST",
            errorMessage: "DISABLE_TRANSACTION_BROADCAST",
            sourceCurrencyId,
            targetCurrencyId,
            hardwareWalletType,
            swapType: swapType,
            swapAppVersion,
            fromAccountAddress,
            toAccountAddress,
            fromAmount,
        });
    }
    else {
        postSwapAccepted({
            provider,
            swapId,
            transactionId: typeof operation === "string" ? operation : operation.hash,
            sourceCurrencyId,
            targetCurrencyId,
            hardwareWalletType,
            swapType,
            swapAppVersion,
            fromAccountAddress,
            toAccountAddress,
            fromAmount,
        });
    }
};
//# sourceMappingURL=setBroadcastTransaction.js.map