"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.retrieveSwapPayload = void 0;
const axios_1 = __importDefault(require("axios"));
const __1 = require("../..");
async function retrieveSwapPayload(data) {
    const SWAP_API_BASE = (0, __1.getSwapAPIBaseURL)();
    const swapAxiosClient = axios_1.default.create({
        baseURL: SWAP_API_BASE,
    });
    const request = {
        provider: data.provider,
        deviceTransactionId: data.deviceTransactionId,
        from: data.fromAccountCurrency,
        to: data.toNewTokenId || data.toAccountCurrency,
        address: data.toAccountAddress,
        refundAddress: data.fromAccountAddress,
        amountFrom: data.amount,
        amountFromInSmallestDenomination: data.amountInAtomicUnit.toString(),
        rateId: data.quoteId,
    };
    const res = await swapAxiosClient.post(`${SWAP_API_BASE}/swap`, request);
    return {
        binaryPayload: res.data?.binaryPayload,
        signature: res.data?.signature,
        payinAddress: res.data?.payinAddress,
        swapId: res.data?.swapId,
        payinExtraId: res.data?.payinExtraId,
        extraTransactionParameters: res.data?.extraTransactionParameters,
    };
}
exports.retrieveSwapPayload = retrieveSwapPayload;
//# sourceMappingURL=actions.js.map