UNPKG

rubic-sdk

Version:
73 lines 2.71 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ChangellyApiService = void 0; const injector_1 = require("../../../../../../core/injector/injector"); const cross_chain_deposit_statuses_1 = require("../../common/cross-chain-transfer-trade/models/cross-chain-deposit-statuses"); class ChangellyApiService { static fetchTokenList() { return injector_1.Injector.httpClient.post(`${ChangellyApiService.endpoint}?method=getCurrenciesFull`, { params: {} }, { headers: { apiKey: ChangellyApiService.xApiKey } }); } static getFixedRateEstimation(params) { return injector_1.Injector.httpClient.post(`${ChangellyApiService.endpoint}?method=getFixRateForAmount`, { params }, { headers: { apiKey: ChangellyApiService.xApiKey } }); } static createExchange(params) { return injector_1.Injector.httpClient.post(`${ChangellyApiService.endpoint}?method=createFixTransaction`, { params }, { headers: { apiKey: ChangellyApiService.xApiKey } }); } static async getTxStatus(id) { const { result } = await injector_1.Injector.httpClient.post(`${ChangellyApiService.endpoint}?method=getTransactions`, { params: { id } }, { headers: { apiKey: ChangellyApiService.xApiKey } }); const txData = result[0]; if (txData.status === 'overdue' || txData.status === 'failed') { return { status: cross_chain_deposit_statuses_1.CROSS_CHAIN_DEPOSIT_STATUS.FAILED, dstHash: null }; } if (txData.status === 'new' || txData.status === 'waiting') { return { status: cross_chain_deposit_statuses_1.CROSS_CHAIN_DEPOSIT_STATUS.WAITING, dstHash: null }; } if (txData.status === 'refunded' || txData.status === 'finished') { return { status: cross_chain_deposit_statuses_1.CROSS_CHAIN_DEPOSIT_STATUS.FINISHED, dstHash: txData.payoutHash }; } const depositData = { status: txData.status, dstHash: null }; return depositData; } } exports.ChangellyApiService = ChangellyApiService; ChangellyApiService.xApiKey = 'sndfje3u4b3fnNSDNFUSDNVSunw345842hrnfd3b4nt4'; ChangellyApiService.endpoint = 'https://x-api.rubic.exchange/changelly'; //# sourceMappingURL=changelly-api-service.js.map