@bluefin-exchange/bluefin7k-aggregator-sdk
Version:
36 lines (35 loc) • 1.21 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.executeBluefinTx = exports.sponsorBluefinX = void 0;
const apiEndpoints_1 = require("../../../constants/apiEndpoints");
const request = async (path, body) => {
const res = await fetch(`${apiEndpoints_1.API_ENDPOINTS.MAIN}/${path}`, {
method: "POST",
body: JSON.stringify(body),
headers: {
"Content-Type": "application/json",
},
});
return res.json();
};
const sponsorBluefinX = async (body) => {
return await request("bluefinx/sponsor", body);
};
exports.sponsorBluefinX = sponsorBluefinX;
/**
* Request BluefinX for signing sponsored tx and execute it
*
* @Warning
* User must use this function to execute BluefinX tx, otherwise the tx will be rejected by BluefinX contract
* @param tx - BluefinX tx which is generated by `buildTx`
* @param signature - user signature after signing the transaction
* @returns `SwapResponse`
*/
const executeBluefinTx = async (tx, signature) => {
return await request("bluefinx/swap", {
quoteId: tx.quoteId,
txBytes: tx.txBytes,
signature,
});
};
exports.executeBluefinTx = executeBluefinTx;
;