"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setBroadcastTransaction = void 0;
const live_env_1 = require("@ledgerhq/live-env");
const index_1 = require("./index");
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 ((0, live_env_1.getEnv)("DISABLE_TRANSACTION_BROADCAST")) {
        (0, index_1.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 {
        (0, index_1.postSwapAccepted)({
            provider,
            swapId,
            transactionId: typeof operation === "string" ? operation : operation.hash,
            sourceCurrencyId,
            targetCurrencyId,
            hardwareWalletType,
            swapType,
            swapAppVersion,
            fromAccountAddress,
            toAccountAddress,
            fromAmount,
        });
    }
};
exports.setBroadcastTransaction = setBroadcastTransaction;
//# sourceMappingURL=setBroadcastTransaction.js.map