@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
44 lines • 1.55 kB
JavaScript
import { getEnv } from "@ledgerhq/live-env";
import { postSwapAccepted, postSwapCancelled } from "./index";
export const setBroadcastTransaction = ({ result, provider, sourceCurrencyId, targetCurrencyId, hardwareWalletType, swapType, swapAppVersion, fromAccountAddress, toAccountAddress, fromAmount, flags, }) => {
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,
flags,
});
}
else {
postSwapAccepted({
provider,
swapId,
transactionId: typeof operation === "string" ? operation : operation.hash,
sourceCurrencyId,
targetCurrencyId,
hardwareWalletType,
swapType,
swapAppVersion,
fromAccountAddress,
toAccountAddress,
fromAmount,
flags,
});
}
};
//# sourceMappingURL=setBroadcastTransaction.js.map