@rabbitio/ui-kit 1.0.0-beta.14 → 1.0.0-beta.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,6 @@
1
- import React, { useState, useRef, useEffect } from 'react';
1
+ import React, { useState, useRef, useEffect, useCallback } from 'react';
2
2
  import { BigNumber } from 'bignumber.js';
3
3
  import axios from 'axios';
4
- import EventBusInstance from 'eventbusjs';
5
4
 
6
5
  function createCommonjsModule(fn) {
7
6
  var module = { exports: {} };
@@ -1432,6 +1431,166 @@ AssetIcon.defaultProps = {
1432
1431
  small: false
1433
1432
  };
1434
1433
 
1434
+ class LogsStorage {
1435
+ static saveLog(log) {
1436
+ this._inMemoryStorage.push(log);
1437
+ }
1438
+ static getInMemoryLogs() {
1439
+ return this._inMemoryStorage;
1440
+ }
1441
+ static getAllLogs() {
1442
+ let storedLogs = "";
1443
+ if (typeof window !== "undefined") {
1444
+ storedLogs = localStorage.getItem(this._logsStorageId);
1445
+ }
1446
+ return `${storedLogs}\n${this._inMemoryStorage.join("\n")}`;
1447
+ }
1448
+
1449
+ /**
1450
+ * @param logger {Logger}
1451
+ */
1452
+ static saveToTheDisk(logger) {
1453
+ try {
1454
+ const MAX_LOCAL_STORAGE_VOLUME_BYTES = 5 * 1024 * 1024;
1455
+ const MAX_LOGS_STORAGE_BYTES = MAX_LOCAL_STORAGE_VOLUME_BYTES * 0.65;
1456
+ if (typeof window !== "undefined") {
1457
+ const existingLogs = localStorage.getItem(this._logsStorageId);
1458
+ const logsString = `${existingLogs}\n${this._inMemoryStorage.join("\n")}`;
1459
+ const lettersCountToRemove = logsString.length - Math.round(MAX_LOGS_STORAGE_BYTES / 2);
1460
+ if (lettersCountToRemove > 0) {
1461
+ localStorage.setItem(this._logsStorageId, logsString.slice(lettersCountToRemove, logsString.length));
1462
+ } else {
1463
+ localStorage.setItem(this._logsStorageId, logsString);
1464
+ }
1465
+ this._inMemoryStorage = [];
1466
+ }
1467
+ } catch (e) {
1468
+ logger == null || logger.logError(e, "saveToTheDisk", "Failed to save logs to disk");
1469
+ }
1470
+ }
1471
+ static removeAllClientLogs() {
1472
+ if (typeof window !== "undefined") {
1473
+ if (localStorage.getItem("doNotRemoveClientLogsWhenSignedOut") !== "true") {
1474
+ localStorage.removeItem(this._logsStorageId);
1475
+ }
1476
+ }
1477
+ this._inMemoryStorage = [];
1478
+ }
1479
+ static setDoNotRemoveClientLogsWhenSignedOut(value) {
1480
+ if (typeof window !== "undefined") {
1481
+ localStorage.setItem("doNotRemoveClientLogsWhenSignedOut", value);
1482
+ }
1483
+ }
1484
+ }
1485
+ LogsStorage._inMemoryStorage = [];
1486
+ LogsStorage._logsStorageId = "clietnLogs_j203fj2D0n-d1";
1487
+
1488
+ /**
1489
+ * Stringify given object by use of JSON.stringify but handles circular structures and "response", "request" properties
1490
+ * to avoid stringing redundant data when printing errors containing request/response objects.
1491
+ *
1492
+ * @param object - object to be stringed
1493
+ * @param indent - custom indentation
1494
+ * @return {string} - stringed object
1495
+ */
1496
+ function safeStringify(object, indent = 2) {
1497
+ let cache = [];
1498
+ if (typeof object === "string" || typeof object === "function" || typeof object === "number" || typeof object === "undefined" || typeof object === "boolean") {
1499
+ return String(object);
1500
+ }
1501
+ const retVal = JSON.stringify(object, (key, value) => {
1502
+ if (key.toLowerCase().includes("request")) {
1503
+ return JSON.stringify({
1504
+ body: value == null ? void 0 : value.body,
1505
+ query: value == null ? void 0 : value.query,
1506
+ headers: value == null ? void 0 : value.headers
1507
+ });
1508
+ }
1509
+ if (key.toLowerCase().includes("response")) {
1510
+ return JSON.stringify({
1511
+ statusText: value == null ? void 0 : value.statusText,
1512
+ status: value == null ? void 0 : value.status,
1513
+ data: value == null ? void 0 : value.data,
1514
+ headers: value == null ? void 0 : value.headers
1515
+ });
1516
+ }
1517
+ return typeof value === "object" && value !== null ? cache.includes(value) ? "duplicated reference" // Duplicated references were found, discarding this key
1518
+ : cache.push(value) && value // Store value in our collection
1519
+ : value;
1520
+ }, indent);
1521
+ cache = null;
1522
+ return retVal;
1523
+ }
1524
+
1525
+ class Logger {
1526
+ /**
1527
+ * Logs to client logs storage.
1528
+ *
1529
+ * WARNING! this method should ce used carefully for critical logging as we have the restriction for storing logs
1530
+ * on client side as we store them inside the local storage. Please see details inside storage.js
1531
+ * @param logString {string} log string
1532
+ * @param source {string} source of the log entry
1533
+ */
1534
+ static log(logString, source) {
1535
+ const timestamp = new Date().toISOString();
1536
+ LogsStorage.saveLog(`${timestamp}|${source}:${logString}`);
1537
+ }
1538
+ static logError(e, settingFunction, additionalMessage = "", onlyToConsole = false) {
1539
+ var _e$errorDescription, _e$howToFix;
1540
+ let message = `\nFunction call ${settingFunction != null ? settingFunction : ""} failed. Error message: ${e == null ? void 0 : e.message}. ${additionalMessage} `;
1541
+ message += `${(_e$errorDescription = e == null ? void 0 : e.errorDescription) != null ? _e$errorDescription : ""}${(_e$howToFix = e == null ? void 0 : e.howToFix) != null ? _e$howToFix : ""}` + ((e == null ? void 0 : e.httpStatus) === 403 ? "Authentication has expired or was lost. " : "");
1542
+ if (e != null && e.response) {
1543
+ try {
1544
+ const responseData = safeStringify({
1545
+ response: e.response
1546
+ });
1547
+ responseData && (message += `\n${responseData}. `);
1548
+ } catch (e) {}
1549
+ }
1550
+ const finalErrorText = message + ". " + safeStringify(e);
1551
+ // eslint-disable-next-line no-console
1552
+ console.error(finalErrorText);
1553
+ if (!onlyToConsole) {
1554
+ this.log(finalErrorText, "logError");
1555
+ }
1556
+ }
1557
+ }
1558
+
1559
+ function useCallHandlingErrors() {
1560
+ const [, setState] = useState();
1561
+ return useCallback(async (functionToBeCalled, event) => {
1562
+ try {
1563
+ await functionToBeCalled(event);
1564
+ } catch (error) {
1565
+ Logger.logError(error, (functionToBeCalled == null ? void 0 : functionToBeCalled.name) || "errorBoundaryTrigger", "Caught by ErrorBoundary");
1566
+ // Triggering ErrorBoundary
1567
+ setState(() => {
1568
+ throw error;
1569
+ });
1570
+ }
1571
+ }, []);
1572
+ }
1573
+
1574
+ /**
1575
+ * Adds reference to standard state variable. It is helpful to be able to use state variable value inside
1576
+ * event handlers and other callbacks without the need to call setState(prev => { value = prev; return prev; }).
1577
+ *
1578
+ * @param initialValue {any} to be passed to useState
1579
+ * @return {[React.Ref, function]} reference to state variable and its setter
1580
+ */
1581
+ function useReferredState(initialValue) {
1582
+ const [state, setState] = React.useState(initialValue);
1583
+ const reference = React.useRef(state);
1584
+ const setReferredState = value => {
1585
+ if (value && {}.toString.call(value) === "[object Function]") {
1586
+ value = value(reference.current);
1587
+ }
1588
+ reference.current = value;
1589
+ setState(value);
1590
+ };
1591
+ return [reference, setReferredState];
1592
+ }
1593
+
1435
1594
  /**
1436
1595
  * This function improves the passed error object (its message) by adding the passed function name
1437
1596
  * and additional message to it.
@@ -1958,131 +2117,6 @@ class Coin {
1958
2117
  }
1959
2118
  }
1960
2119
 
1961
- class LogsStorage {
1962
- static saveLog(log) {
1963
- this._inMemoryStorage.push(log);
1964
- }
1965
- static getInMemoryLogs() {
1966
- return this._inMemoryStorage;
1967
- }
1968
- static getAllLogs() {
1969
- let storedLogs = "";
1970
- if (typeof window !== "undefined") {
1971
- storedLogs = localStorage.getItem(this._logsStorageId);
1972
- }
1973
- return `${storedLogs}\n${this._inMemoryStorage.join("\n")}`;
1974
- }
1975
-
1976
- /**
1977
- * @param logger {Logger}
1978
- */
1979
- static saveToTheDisk(logger) {
1980
- try {
1981
- const MAX_LOCAL_STORAGE_VOLUME_BYTES = 5 * 1024 * 1024;
1982
- const MAX_LOGS_STORAGE_BYTES = MAX_LOCAL_STORAGE_VOLUME_BYTES * 0.65;
1983
- if (typeof window !== "undefined") {
1984
- const existingLogs = localStorage.getItem(this._logsStorageId);
1985
- const logsString = `${existingLogs}\n${this._inMemoryStorage.join("\n")}`;
1986
- const lettersCountToRemove = logsString.length - Math.round(MAX_LOGS_STORAGE_BYTES / 2);
1987
- if (lettersCountToRemove > 0) {
1988
- localStorage.setItem(this._logsStorageId, logsString.slice(lettersCountToRemove, logsString.length));
1989
- } else {
1990
- localStorage.setItem(this._logsStorageId, logsString);
1991
- }
1992
- this._inMemoryStorage = [];
1993
- }
1994
- } catch (e) {
1995
- logger == null || logger.logError(e, "saveToTheDisk", "Failed to save logs to disk");
1996
- }
1997
- }
1998
- static removeAllClientLogs() {
1999
- if (typeof window !== "undefined") {
2000
- if (localStorage.getItem("doNotRemoveClientLogsWhenSignedOut") !== "true") {
2001
- localStorage.removeItem(this._logsStorageId);
2002
- }
2003
- }
2004
- this._inMemoryStorage = [];
2005
- }
2006
- static setDoNotRemoveClientLogsWhenSignedOut(value) {
2007
- if (typeof window !== "undefined") {
2008
- localStorage.setItem("doNotRemoveClientLogsWhenSignedOut", value);
2009
- }
2010
- }
2011
- }
2012
- LogsStorage._inMemoryStorage = [];
2013
- LogsStorage._logsStorageId = "clietnLogs_j203fj2D0n-d1";
2014
-
2015
- /**
2016
- * Stringify given object by use of JSON.stringify but handles circular structures and "response", "request" properties
2017
- * to avoid stringing redundant data when printing errors containing request/response objects.
2018
- *
2019
- * @param object - object to be stringed
2020
- * @param indent - custom indentation
2021
- * @return {string} - stringed object
2022
- */
2023
- function safeStringify(object, indent = 2) {
2024
- let cache = [];
2025
- if (typeof object === "string" || typeof object === "function" || typeof object === "number" || typeof object === "undefined" || typeof object === "boolean") {
2026
- return String(object);
2027
- }
2028
- const retVal = JSON.stringify(object, (key, value) => {
2029
- if (key.toLowerCase().includes("request")) {
2030
- return JSON.stringify({
2031
- body: value == null ? void 0 : value.body,
2032
- query: value == null ? void 0 : value.query,
2033
- headers: value == null ? void 0 : value.headers
2034
- });
2035
- }
2036
- if (key.toLowerCase().includes("response")) {
2037
- return JSON.stringify({
2038
- statusText: value == null ? void 0 : value.statusText,
2039
- status: value == null ? void 0 : value.status,
2040
- data: value == null ? void 0 : value.data,
2041
- headers: value == null ? void 0 : value.headers
2042
- });
2043
- }
2044
- return typeof value === "object" && value !== null ? cache.includes(value) ? "duplicated reference" // Duplicated references were found, discarding this key
2045
- : cache.push(value) && value // Store value in our collection
2046
- : value;
2047
- }, indent);
2048
- cache = null;
2049
- return retVal;
2050
- }
2051
-
2052
- class Logger {
2053
- /**
2054
- * Logs to client logs storage.
2055
- *
2056
- * WARNING! this method should ce used carefully for critical logging as we have the restriction for storing logs
2057
- * on client side as we store them inside the local storage. Please see details inside storage.js
2058
- * @param logString {string} log string
2059
- * @param source {string} source of the log entry
2060
- */
2061
- static log(logString, source) {
2062
- const timestamp = new Date().toISOString();
2063
- LogsStorage.saveLog(`${timestamp}|${source}:${logString}`);
2064
- }
2065
- static logError(e, settingFunction, additionalMessage = "", onlyToConsole = false) {
2066
- var _e$errorDescription, _e$howToFix;
2067
- let message = `\nFunction call ${settingFunction != null ? settingFunction : ""} failed. Error message: ${e == null ? void 0 : e.message}. ${additionalMessage} `;
2068
- message += `${(_e$errorDescription = e == null ? void 0 : e.errorDescription) != null ? _e$errorDescription : ""}${(_e$howToFix = e == null ? void 0 : e.howToFix) != null ? _e$howToFix : ""}` + ((e == null ? void 0 : e.httpStatus) === 403 ? "Authentication has expired or was lost. " : "");
2069
- if (e != null && e.response) {
2070
- try {
2071
- const responseData = safeStringify({
2072
- response: e.response
2073
- });
2074
- responseData && (message += `\n${responseData}. `);
2075
- } catch (e) {}
2076
- }
2077
- const finalErrorText = message + ". " + safeStringify(e);
2078
- // eslint-disable-next-line no-console
2079
- console.error(finalErrorText);
2080
- if (!onlyToConsole) {
2081
- this.log(finalErrorText, "logError");
2082
- }
2083
- }
2084
- }
2085
-
2086
2120
  /**
2087
2121
  * TODO: [tests, critical] Ued by payments logic
2088
2122
  *
@@ -2413,7 +2447,7 @@ class ExistingSwapWithFiatData extends ExistingSwap {
2413
2447
  }
2414
2448
  }
2415
2449
 
2416
- class PublicSwapCreationInfo {
2450
+ class BaseSwapCreationInfo {
2417
2451
  /**
2418
2452
  * @param fromCoin {Coin}
2419
2453
  * @param toCoin {Coin}
@@ -3205,10 +3239,11 @@ class SwapUtils {
3205
3239
  }
3206
3240
  }
3207
3241
 
3208
- const API_KEYS_PROXY_URL = `${window.location.protocol + "//" + window.location.host}/api/v1/proxy`;
3209
- const cache = new Cache(EventBusInstance);
3210
3242
  class PublicSwapService {
3211
- static async initialize() {
3243
+ constructor(API_KEYS_PROXY_URL, cache) {
3244
+ this._swapProvider = new SwapspaceSwapProvider(API_KEYS_PROXY_URL, cache, () => null, false);
3245
+ }
3246
+ async initialize() {
3212
3247
  try {
3213
3248
  await this._swapProvider.initialize();
3214
3249
  SwapUtils.safeHandleRequestsLimitExceeding();
@@ -3216,7 +3251,7 @@ class PublicSwapService {
3216
3251
  Logger.logError(e, "PublicSwapService.initialize");
3217
3252
  }
3218
3253
  }
3219
- static async getCurrenciesListForPublicSwap(currencyThatShouldNotBeFirst = null) {
3254
+ async getCurrenciesListForPublicSwap(currencyThatShouldNotBeFirst = null) {
3220
3255
  const loggerSource = "getCurrenciesListForPublicSwap";
3221
3256
  try {
3222
3257
  var _result$coins;
@@ -3261,7 +3296,7 @@ class PublicSwapService {
3261
3296
  * reason: string
3262
3297
  * }>}
3263
3298
  */
3264
- static async getInitialPublicSwapData(fromCoin, toCoin) {
3299
+ async getInitialPublicSwapData(fromCoin, toCoin) {
3265
3300
  try {
3266
3301
  const result = await SwapUtils.getInitialSwapData(this._swapProvider, fromCoin, toCoin);
3267
3302
  if (!result.result) {
@@ -3301,10 +3336,10 @@ class PublicSwapService {
3301
3336
  * fiatMax: (number|null)
3302
3337
  * }|{
3303
3338
  * result: true,
3304
- * swapCreationInfo: PublicSwapCreationInfo
3339
+ * swapCreationInfo: BaseSwapCreationInfo
3305
3340
  * }>}
3306
3341
  */
3307
- static async getPublicSwapDetails(fromCoin, toCoin, fromAmountCoins) {
3342
+ async getPublicSwapDetails(fromCoin, toCoin, fromAmountCoins) {
3308
3343
  const loggerSource = "getPublicSwapDetails";
3309
3344
  try {
3310
3345
  var _await$this$_swapProv, _await$this$_swapProv2, _result$swapCreationI, _result$swapCreationI2;
@@ -3349,7 +3384,7 @@ class PublicSwapService {
3349
3384
  const toAmountCoins = AmountUtils.trim(fromAmountBigNumber.times(details.rate), fromCoin.digits);
3350
3385
  const result = {
3351
3386
  result: true,
3352
- swapCreationInfo: new PublicSwapCreationInfo(fromCoin, toCoin, fromAmountCoins, toAmountCoins, details.rate, details.rawSwapData, min, fiatMin, max, fiatMax, details.durationMinutesRange)
3387
+ swapCreationInfo: new BaseSwapCreationInfo(fromCoin, toCoin, fromAmountCoins, toAmountCoins, details.rate, details.rawSwapData, min, fiatMin, max, fiatMax, details.durationMinutesRange)
3353
3388
  };
3354
3389
  Logger.log(`Result: ${safeStringify({
3355
3390
  result: result.result,
@@ -3370,7 +3405,7 @@ class PublicSwapService {
3370
3405
  * @param fromCoin {Coin}
3371
3406
  * @param toCoin {Coin}
3372
3407
  * @param fromAmount {string}
3373
- * @param swapCreationInfo {PublicSwapCreationInfo}
3408
+ * @param swapCreationInfo {BaseSwapCreationInfo}
3374
3409
  * @param toAddress {string}
3375
3410
  * @param refundAddress {string}
3376
3411
  * @return {Promise<{
@@ -3392,11 +3427,11 @@ class PublicSwapService {
3392
3427
  * reason: string
3393
3428
  * }>}
3394
3429
  */
3395
- static async createPublicSwap(fromCoin, toCoin, fromAmount, swapCreationInfo, toAddress, refundAddress, clientIp) {
3430
+ async createPublicSwap(fromCoin, toCoin, fromAmount, swapCreationInfo, toAddress, refundAddress, clientIp) {
3396
3431
  const loggerSource = "createPublicSwap";
3397
3432
  try {
3398
3433
  var _swapCreationInfo$fro, _swapCreationInfo$toC;
3399
- if (!(fromCoin instanceof Coin) || !(toCoin instanceof Coin) || typeof fromAmount !== "string" || typeof toAddress !== "string" || typeof refundAddress !== "string" || !(swapCreationInfo instanceof PublicSwapCreationInfo)) {
3434
+ if (!(fromCoin instanceof Coin) || !(toCoin instanceof Coin) || typeof fromAmount !== "string" || typeof toAddress !== "string" || typeof refundAddress !== "string" || !(swapCreationInfo instanceof BaseSwapCreationInfo)) {
3400
3435
  throw new Error(`Wrong input: ${fromCoin.ticker} ${toCoin.ticker} ${fromAmount} ${swapCreationInfo}`);
3401
3436
  }
3402
3437
  Logger.log(`Start: ${fromAmount} ${fromCoin.ticker} -> ${toCoin.ticker}. Details: ${safeStringify(_extends({}, swapCreationInfo, {
@@ -3482,7 +3517,7 @@ class PublicSwapService {
3482
3517
  * }>}
3483
3518
  * error reason is one of PUBLIC_SWAPS_COMMON_ERRORS
3484
3519
  */
3485
- static async getPublicExistingSwapDetailsAndStatus(swapIds) {
3520
+ async getPublicExistingSwapDetailsAndStatus(swapIds) {
3486
3521
  const loggerSource = "getPublicExistingSwapDetailsAndStatus";
3487
3522
  try {
3488
3523
  const result = await SwapUtils.getExistingSwapsDetailsWithFiatAmounts(this._swapProvider, swapIds);
@@ -3513,7 +3548,7 @@ class PublicSwapService {
3513
3548
  * reason: string
3514
3549
  * }>}
3515
3550
  */
3516
- static async getPublicSwapsHistory() {
3551
+ async getPublicSwapsHistory() {
3517
3552
  try {
3518
3553
  const swapIds = this._getPublicSwapIdsSavedLocally();
3519
3554
  if (swapIds.length) {
@@ -3532,7 +3567,7 @@ class PublicSwapService {
3532
3567
  * @param swapId {string}
3533
3568
  * @private
3534
3569
  */
3535
- static _savePublicSwapIdLocally(swapId) {
3570
+ _savePublicSwapIdLocally(swapId) {
3536
3571
  if (typeof window !== "undefined") {
3537
3572
  try {
3538
3573
  const saved = localStorage.getItem("publicSwapIds");
@@ -3549,7 +3584,7 @@ class PublicSwapService {
3549
3584
  * @private
3550
3585
  * @return {string[]}
3551
3586
  */
3552
- static _getPublicSwapIdsSavedLocally() {
3587
+ _getPublicSwapIdsSavedLocally() {
3553
3588
  if (typeof window !== "undefined") {
3554
3589
  try {
3555
3590
  const saved = localStorage.getItem("publicSwapIds");
@@ -3564,7 +3599,7 @@ class PublicSwapService {
3564
3599
  * @param coinOrTicker {Coin|string}
3565
3600
  * @return {string} icon URL (ready to use)
3566
3601
  */
3567
- static getAssetIconUrl(coinOrTicker) {
3602
+ getAssetIconUrl(coinOrTicker) {
3568
3603
  return this._swapProvider.getIconUrl(coinOrTicker);
3569
3604
  }
3570
3605
 
@@ -3572,7 +3607,7 @@ class PublicSwapService {
3572
3607
  * @param ticker {string}
3573
3608
  * @return {Coin|null}
3574
3609
  */
3575
- static getCoinByTickerIfPresent(ticker) {
3610
+ getCoinByTickerIfPresent(ticker) {
3576
3611
  return this._swapProvider.getCoinByTickerIfPresent(ticker);
3577
3612
  }
3578
3613
 
@@ -3581,7 +3616,7 @@ class PublicSwapService {
3581
3616
  * @param asset {Coin}
3582
3617
  * @return {Promise<string|null>}
3583
3618
  */
3584
- static async getAssetToUsdtRate(asset) {
3619
+ async getAssetToUsdtRate(asset) {
3585
3620
  try {
3586
3621
  var _result$rate;
3587
3622
  const result = await this._swapProvider.getCoinToUSDTRate(asset);
@@ -3596,54 +3631,15 @@ class PublicSwapService {
3596
3631
  * @param address {string}
3597
3632
  * @return {boolean}
3598
3633
  */
3599
- static isAddressValidForAsset(asset, address) {
3634
+ isAddressValidForAsset(asset, address) {
3600
3635
  try {
3601
3636
  return this._swapProvider.isAddressValidForAsset(asset, address);
3602
3637
  } catch (e) {
3603
3638
  improveAndRethrow(e, "isAddressValidForAsset");
3604
3639
  }
3605
3640
  }
3606
-
3607
- // TODO: [dev] Remove if we don't need this inside the public swap steps
3608
- // /**
3609
- // * TODO: [feature, moderate] add other fiat currencies support. task_id=5490e21b8b9c4f89a2247b28db3c9e0a
3610
- // * @param asset {Coin}
3611
- // * @param amount {string}
3612
- // * @return {Promise<string|null>}
3613
- // */
3614
- // static async convertSingleCoinAmountToUsdtOrNull(asset, amount) {
3615
- // try {
3616
- // const result = await this._swapProvider.getCoinToUSDTRate(asset);
3617
- // if (result?.rate != null) {
3618
- // const decimals = FiatCurrenciesService.getCurrencyDecimalCountByCode("USD");
3619
- // return BigNumber(amount).div(result?.rate).toFixed(decimals);
3620
- // }
3621
- // return null;
3622
- // } catch (e) {
3623
- // improveAndRethrow(e, "convertSingleCoinAmountToUsdtOrNull");
3624
- // }
3625
- // }
3626
- //
3627
- // /**
3628
- // * TODO: [feature, moderate] add other fiat currencies support. task_id=5490e21b8b9c4f89a2247b28db3c9e0a
3629
- // * @param asset {Coin}
3630
- // * @param amount {string}
3631
- // * @return {Promise<string|null>}
3632
- // */
3633
- // static async convertSingleUsdtAmountToCoinOrNull(asset, amount) {
3634
- // try {
3635
- // const result = await this._swapProvider.getCoinToUSDTRate(asset);
3636
- // if (result?.rate != null) {
3637
- // return BigNumber(amount).times(result?.rate).toFixed(asset.digits);
3638
- // }
3639
- // return null;
3640
- // } catch (e) {
3641
- // improveAndRethrow(e, "convertSingleUsdtAmountToCoinOrNull");
3642
- // }
3643
- // }
3644
3641
  }
3645
3642
  PublicSwapService.PUBLIC_SWAP_CREATED_EVENT = "publicSwapCreatedEvent";
3646
- PublicSwapService._swapProvider = new SwapspaceSwapProvider(API_KEYS_PROXY_URL, cache, () => null, false);
3647
3643
  PublicSwapService.PUBLIC_SWAPS_COMMON_ERRORS = {
3648
3644
  REQUESTS_LIMIT_EXCEEDED: "requestsLimitExceeded"
3649
3645
  };
@@ -3654,5 +3650,5 @@ PublicSwapService.PUBLIC_SWAP_DETAILS_FAIL_REASONS = {
3654
3650
  };
3655
3651
  PublicSwapService._fiatDecimalsCount = FiatCurrenciesService.getCurrencyDecimalCountByCode("USD");
3656
3652
 
3657
- export { AmountUtils, AssetIcon, Blockchain, Button, Cache, Coin, EmailsApi, ExistingSwap, ExistingSwapWithFiatData, FiatCurrenciesService, LoadingDots, Logger, LogsStorage, Protocol, PublicSwapCreationInfo, PublicSwapService, SupportChat, SwapProvider, SwapUtils, SwapspaceSwapProvider, improveAndRethrow, safeStringify };
3653
+ export { AmountUtils, AssetIcon, BaseSwapCreationInfo, Blockchain, Button, Cache, Coin, EmailsApi, ExistingSwap, ExistingSwapWithFiatData, FiatCurrenciesService, LoadingDots, Logger, LogsStorage, Protocol, PublicSwapService, SupportChat, SwapProvider, SwapUtils, SwapspaceSwapProvider, improveAndRethrow, safeStringify, useCallHandlingErrors, useReferredState };
3658
3654
  //# sourceMappingURL=index.modern.js.map