UNPKG

@yoroi/exchange

Version:

The Exchange package of Yoroi SDK

69 lines 1.64 kB
import { Exchange } from '@yoroi/types'; import { freeze } from 'immer'; import { encryptusApiGetBaseUrl } from './encryptus/api'; import { banxaApiGetBaseUrl } from './banxa/api'; const initialDeps = freeze({ banxaApi: { getBaseUrl: banxaApiGetBaseUrl }, encryptusApi: { getBaseUrl: encryptusApiGetBaseUrl } }, true); export const exchangeApiMaker = function (_ref) { let { isProduction, partner } = _ref; let { banxaApi, encryptusApi } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : initialDeps; const getProviders = async () => Promise.resolve(providers); const getBaseUrl = (providerId, fetcherConfig) => { switch (providerId) { case 'banxa': return banxaApi.getBaseUrl({ isProduction, partner })(); case 'encryptus': return encryptusApi.getBaseUrl({ isProduction })(fetcherConfig); default: return Promise.reject(new Exchange.Errors.ProviderNotFound(`Unknown provider: ${providerId}`)); } }; return freeze({ getBaseUrl, getProviders }, true); }; export const providers = freeze({ banxa: { id: 'banxa', name: 'Banxa', logo: 'banxa', supportedOrders: { buy: { fee: 2, min: 100000000 } }, supportUrl: 'https://support.banxa.com/' }, encryptus: { id: 'encryptus', name: 'Encryptus', logo: 'encryptus', supportedOrders: { sell: { fee: 2.5, min: 1000000 } }, supportUrl: 'https://support.encryptus.com/' } }, true); //# sourceMappingURL=api.js.map