@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.
package/dist/index.cjs CHANGED
@@ -1,13 +1,11 @@
1
1
  var React = require('react');
2
2
  var bignumber_js = require('bignumber.js');
3
3
  var axios = require('axios');
4
- var EventBusInstance = require('eventbusjs');
5
4
 
6
5
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
7
6
 
8
7
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
9
8
  var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
10
- var EventBusInstance__default = /*#__PURE__*/_interopDefaultLegacy(EventBusInstance);
11
9
 
12
10
  function createCommonjsModule(fn) {
13
11
  var module = { exports: {} };
@@ -1481,6 +1479,198 @@ AssetIcon.defaultProps = {
1481
1479
  small: false
1482
1480
  };
1483
1481
 
1482
+ var LogsStorage = /*#__PURE__*/function () {
1483
+ function LogsStorage() {}
1484
+ LogsStorage.saveLog = function saveLog(log) {
1485
+ this._inMemoryStorage.push(log);
1486
+ };
1487
+ LogsStorage.getInMemoryLogs = function getInMemoryLogs() {
1488
+ return this._inMemoryStorage;
1489
+ };
1490
+ LogsStorage.getAllLogs = function getAllLogs() {
1491
+ var storedLogs = "";
1492
+ if (typeof window !== "undefined") {
1493
+ storedLogs = localStorage.getItem(this._logsStorageId);
1494
+ }
1495
+ return storedLogs + "\n" + this._inMemoryStorage.join("\n");
1496
+ }
1497
+
1498
+ /**
1499
+ * @param logger {Logger}
1500
+ */;
1501
+ LogsStorage.saveToTheDisk = function saveToTheDisk(logger) {
1502
+ try {
1503
+ var MAX_LOCAL_STORAGE_VOLUME_BYTES = 5 * 1024 * 1024;
1504
+ var MAX_LOGS_STORAGE_BYTES = MAX_LOCAL_STORAGE_VOLUME_BYTES * 0.65;
1505
+ if (typeof window !== "undefined") {
1506
+ var existingLogs = localStorage.getItem(this._logsStorageId);
1507
+ var logsString = existingLogs + "\n" + this._inMemoryStorage.join("\n");
1508
+ var lettersCountToRemove = logsString.length - Math.round(MAX_LOGS_STORAGE_BYTES / 2);
1509
+ if (lettersCountToRemove > 0) {
1510
+ localStorage.setItem(this._logsStorageId, logsString.slice(lettersCountToRemove, logsString.length));
1511
+ } else {
1512
+ localStorage.setItem(this._logsStorageId, logsString);
1513
+ }
1514
+ this._inMemoryStorage = [];
1515
+ }
1516
+ } catch (e) {
1517
+ logger == null || logger.logError(e, "saveToTheDisk", "Failed to save logs to disk");
1518
+ }
1519
+ };
1520
+ LogsStorage.removeAllClientLogs = function removeAllClientLogs() {
1521
+ if (typeof window !== "undefined") {
1522
+ if (localStorage.getItem("doNotRemoveClientLogsWhenSignedOut") !== "true") {
1523
+ localStorage.removeItem(this._logsStorageId);
1524
+ }
1525
+ }
1526
+ this._inMemoryStorage = [];
1527
+ };
1528
+ LogsStorage.setDoNotRemoveClientLogsWhenSignedOut = function setDoNotRemoveClientLogsWhenSignedOut(value) {
1529
+ if (typeof window !== "undefined") {
1530
+ localStorage.setItem("doNotRemoveClientLogsWhenSignedOut", value);
1531
+ }
1532
+ };
1533
+ return LogsStorage;
1534
+ }();
1535
+ LogsStorage._inMemoryStorage = [];
1536
+ LogsStorage._logsStorageId = "clietnLogs_j203fj2D0n-d1";
1537
+
1538
+ /**
1539
+ * Stringify given object by use of JSON.stringify but handles circular structures and "response", "request" properties
1540
+ * to avoid stringing redundant data when printing errors containing request/response objects.
1541
+ *
1542
+ * @param object - object to be stringed
1543
+ * @param indent - custom indentation
1544
+ * @return {string} - stringed object
1545
+ */
1546
+ function safeStringify(object, indent) {
1547
+ if (indent === void 0) {
1548
+ indent = 2;
1549
+ }
1550
+ var cache = [];
1551
+ if (typeof object === "string" || typeof object === "function" || typeof object === "number" || typeof object === "undefined" || typeof object === "boolean") {
1552
+ return String(object);
1553
+ }
1554
+ var retVal = JSON.stringify(object, function (key, value) {
1555
+ if (key.toLowerCase().includes("request")) {
1556
+ return JSON.stringify({
1557
+ body: value == null ? void 0 : value.body,
1558
+ query: value == null ? void 0 : value.query,
1559
+ headers: value == null ? void 0 : value.headers
1560
+ });
1561
+ }
1562
+ if (key.toLowerCase().includes("response")) {
1563
+ return JSON.stringify({
1564
+ statusText: value == null ? void 0 : value.statusText,
1565
+ status: value == null ? void 0 : value.status,
1566
+ data: value == null ? void 0 : value.data,
1567
+ headers: value == null ? void 0 : value.headers
1568
+ });
1569
+ }
1570
+ return typeof value === "object" && value !== null ? cache.includes(value) ? "duplicated reference" // Duplicated references were found, discarding this key
1571
+ : cache.push(value) && value // Store value in our collection
1572
+ : value;
1573
+ }, indent);
1574
+ cache = null;
1575
+ return retVal;
1576
+ }
1577
+
1578
+ var Logger = /*#__PURE__*/function () {
1579
+ function Logger() {}
1580
+ /**
1581
+ * Logs to client logs storage.
1582
+ *
1583
+ * WARNING! this method should ce used carefully for critical logging as we have the restriction for storing logs
1584
+ * on client side as we store them inside the local storage. Please see details inside storage.js
1585
+ * @param logString {string} log string
1586
+ * @param source {string} source of the log entry
1587
+ */
1588
+ Logger.log = function log(logString, source) {
1589
+ var timestamp = new Date().toISOString();
1590
+ LogsStorage.saveLog(timestamp + "|" + source + ":" + logString);
1591
+ };
1592
+ Logger.logError = function logError(e, settingFunction, additionalMessage, onlyToConsole) {
1593
+ var _e$errorDescription, _e$howToFix;
1594
+ if (additionalMessage === void 0) {
1595
+ additionalMessage = "";
1596
+ }
1597
+ if (onlyToConsole === void 0) {
1598
+ onlyToConsole = false;
1599
+ }
1600
+ var message = "\nFunction call " + (settingFunction != null ? settingFunction : "") + " failed. Error message: " + (e == null ? void 0 : e.message) + ". " + additionalMessage + " ";
1601
+ 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. " : "");
1602
+ if (e != null && e.response) {
1603
+ try {
1604
+ var responseData = safeStringify({
1605
+ response: e.response
1606
+ });
1607
+ responseData && (message += "\n" + responseData + ". ");
1608
+ } catch (e) {}
1609
+ }
1610
+ var finalErrorText = message + ". " + safeStringify(e);
1611
+ // eslint-disable-next-line no-console
1612
+ console.error(finalErrorText);
1613
+ if (!onlyToConsole) {
1614
+ this.log(finalErrorText, "logError");
1615
+ }
1616
+ };
1617
+ return Logger;
1618
+ }();
1619
+
1620
+ function _catch$4(body, recover) {
1621
+ try {
1622
+ var result = body();
1623
+ } catch (e) {
1624
+ return recover(e);
1625
+ }
1626
+ if (result && result.then) {
1627
+ return result.then(void 0, recover);
1628
+ }
1629
+ return result;
1630
+ }
1631
+ function useCallHandlingErrors() {
1632
+ var _useState = React.useState(),
1633
+ setState = _useState[1];
1634
+ return React.useCallback(function (functionToBeCalled, event) {
1635
+ try {
1636
+ var _temp = _catch$4(function () {
1637
+ return Promise.resolve(functionToBeCalled(event)).then(function () {});
1638
+ }, function (error) {
1639
+ Logger.logError(error, (functionToBeCalled == null ? void 0 : functionToBeCalled.name) || "errorBoundaryTrigger", "Caught by ErrorBoundary");
1640
+ // Triggering ErrorBoundary
1641
+ setState(function () {
1642
+ throw error;
1643
+ });
1644
+ });
1645
+ return Promise.resolve(_temp && _temp.then ? _temp.then(function () {}) : void 0);
1646
+ } catch (e) {
1647
+ return Promise.reject(e);
1648
+ }
1649
+ }, []);
1650
+ }
1651
+
1652
+ /**
1653
+ * Adds reference to standard state variable. It is helpful to be able to use state variable value inside
1654
+ * event handlers and other callbacks without the need to call setState(prev => { value = prev; return prev; }).
1655
+ *
1656
+ * @param initialValue {any} to be passed to useState
1657
+ * @return {[React.Ref, function]} reference to state variable and its setter
1658
+ */
1659
+ function useReferredState(initialValue) {
1660
+ var _React$useState = React__default["default"].useState(initialValue),
1661
+ state = _React$useState[0],
1662
+ setState = _React$useState[1];
1663
+ var reference = React__default["default"].useRef(state);
1664
+ var setReferredState = function setReferredState(value) {
1665
+ if (value && {}.toString.call(value) === "[object Function]") {
1666
+ value = value(reference.current);
1667
+ }
1668
+ reference.current = value;
1669
+ setState(value);
1670
+ };
1671
+ return [reference, setReferredState];
1672
+ }
1673
+
1484
1674
  /**
1485
1675
  * This function improves the passed error object (its message) by adding the passed function name
1486
1676
  * and additional message to it.
@@ -2103,144 +2293,6 @@ var Coin = /*#__PURE__*/function () {
2103
2293
  return Coin;
2104
2294
  }();
2105
2295
 
2106
- var LogsStorage = /*#__PURE__*/function () {
2107
- function LogsStorage() {}
2108
- LogsStorage.saveLog = function saveLog(log) {
2109
- this._inMemoryStorage.push(log);
2110
- };
2111
- LogsStorage.getInMemoryLogs = function getInMemoryLogs() {
2112
- return this._inMemoryStorage;
2113
- };
2114
- LogsStorage.getAllLogs = function getAllLogs() {
2115
- var storedLogs = "";
2116
- if (typeof window !== "undefined") {
2117
- storedLogs = localStorage.getItem(this._logsStorageId);
2118
- }
2119
- return storedLogs + "\n" + this._inMemoryStorage.join("\n");
2120
- }
2121
-
2122
- /**
2123
- * @param logger {Logger}
2124
- */;
2125
- LogsStorage.saveToTheDisk = function saveToTheDisk(logger) {
2126
- try {
2127
- var MAX_LOCAL_STORAGE_VOLUME_BYTES = 5 * 1024 * 1024;
2128
- var MAX_LOGS_STORAGE_BYTES = MAX_LOCAL_STORAGE_VOLUME_BYTES * 0.65;
2129
- if (typeof window !== "undefined") {
2130
- var existingLogs = localStorage.getItem(this._logsStorageId);
2131
- var logsString = existingLogs + "\n" + this._inMemoryStorage.join("\n");
2132
- var lettersCountToRemove = logsString.length - Math.round(MAX_LOGS_STORAGE_BYTES / 2);
2133
- if (lettersCountToRemove > 0) {
2134
- localStorage.setItem(this._logsStorageId, logsString.slice(lettersCountToRemove, logsString.length));
2135
- } else {
2136
- localStorage.setItem(this._logsStorageId, logsString);
2137
- }
2138
- this._inMemoryStorage = [];
2139
- }
2140
- } catch (e) {
2141
- logger == null || logger.logError(e, "saveToTheDisk", "Failed to save logs to disk");
2142
- }
2143
- };
2144
- LogsStorage.removeAllClientLogs = function removeAllClientLogs() {
2145
- if (typeof window !== "undefined") {
2146
- if (localStorage.getItem("doNotRemoveClientLogsWhenSignedOut") !== "true") {
2147
- localStorage.removeItem(this._logsStorageId);
2148
- }
2149
- }
2150
- this._inMemoryStorage = [];
2151
- };
2152
- LogsStorage.setDoNotRemoveClientLogsWhenSignedOut = function setDoNotRemoveClientLogsWhenSignedOut(value) {
2153
- if (typeof window !== "undefined") {
2154
- localStorage.setItem("doNotRemoveClientLogsWhenSignedOut", value);
2155
- }
2156
- };
2157
- return LogsStorage;
2158
- }();
2159
- LogsStorage._inMemoryStorage = [];
2160
- LogsStorage._logsStorageId = "clietnLogs_j203fj2D0n-d1";
2161
-
2162
- /**
2163
- * Stringify given object by use of JSON.stringify but handles circular structures and "response", "request" properties
2164
- * to avoid stringing redundant data when printing errors containing request/response objects.
2165
- *
2166
- * @param object - object to be stringed
2167
- * @param indent - custom indentation
2168
- * @return {string} - stringed object
2169
- */
2170
- function safeStringify(object, indent) {
2171
- if (indent === void 0) {
2172
- indent = 2;
2173
- }
2174
- var cache = [];
2175
- if (typeof object === "string" || typeof object === "function" || typeof object === "number" || typeof object === "undefined" || typeof object === "boolean") {
2176
- return String(object);
2177
- }
2178
- var retVal = JSON.stringify(object, function (key, value) {
2179
- if (key.toLowerCase().includes("request")) {
2180
- return JSON.stringify({
2181
- body: value == null ? void 0 : value.body,
2182
- query: value == null ? void 0 : value.query,
2183
- headers: value == null ? void 0 : value.headers
2184
- });
2185
- }
2186
- if (key.toLowerCase().includes("response")) {
2187
- return JSON.stringify({
2188
- statusText: value == null ? void 0 : value.statusText,
2189
- status: value == null ? void 0 : value.status,
2190
- data: value == null ? void 0 : value.data,
2191
- headers: value == null ? void 0 : value.headers
2192
- });
2193
- }
2194
- return typeof value === "object" && value !== null ? cache.includes(value) ? "duplicated reference" // Duplicated references were found, discarding this key
2195
- : cache.push(value) && value // Store value in our collection
2196
- : value;
2197
- }, indent);
2198
- cache = null;
2199
- return retVal;
2200
- }
2201
-
2202
- var Logger = /*#__PURE__*/function () {
2203
- function Logger() {}
2204
- /**
2205
- * Logs to client logs storage.
2206
- *
2207
- * WARNING! this method should ce used carefully for critical logging as we have the restriction for storing logs
2208
- * on client side as we store them inside the local storage. Please see details inside storage.js
2209
- * @param logString {string} log string
2210
- * @param source {string} source of the log entry
2211
- */
2212
- Logger.log = function log(logString, source) {
2213
- var timestamp = new Date().toISOString();
2214
- LogsStorage.saveLog(timestamp + "|" + source + ":" + logString);
2215
- };
2216
- Logger.logError = function logError(e, settingFunction, additionalMessage, onlyToConsole) {
2217
- var _e$errorDescription, _e$howToFix;
2218
- if (additionalMessage === void 0) {
2219
- additionalMessage = "";
2220
- }
2221
- if (onlyToConsole === void 0) {
2222
- onlyToConsole = false;
2223
- }
2224
- var message = "\nFunction call " + (settingFunction != null ? settingFunction : "") + " failed. Error message: " + (e == null ? void 0 : e.message) + ". " + additionalMessage + " ";
2225
- 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. " : "");
2226
- if (e != null && e.response) {
2227
- try {
2228
- var responseData = safeStringify({
2229
- response: e.response
2230
- });
2231
- responseData && (message += "\n" + responseData + ". ");
2232
- } catch (e) {}
2233
- }
2234
- var finalErrorText = message + ". " + safeStringify(e);
2235
- // eslint-disable-next-line no-console
2236
- console.error(finalErrorText);
2237
- if (!onlyToConsole) {
2238
- this.log(finalErrorText, "logError");
2239
- }
2240
- };
2241
- return Logger;
2242
- }();
2243
-
2244
2296
  /**
2245
2297
  * TODO: [tests, critical] Ued by payments logic
2246
2298
  *
@@ -2629,7 +2681,7 @@ var ExistingSwapWithFiatData = /*#__PURE__*/function (_ExistingSwap) {
2629
2681
  return ExistingSwapWithFiatData;
2630
2682
  }(ExistingSwap);
2631
2683
 
2632
- var PublicSwapCreationInfo =
2684
+ var BaseSwapCreationInfo =
2633
2685
  /**
2634
2686
  * @param fromCoin {Coin}
2635
2687
  * @param toCoin {Coin}
@@ -2643,7 +2695,7 @@ var PublicSwapCreationInfo =
2643
2695
  * @param fiatMax {number}
2644
2696
  * @param durationMinutesRange {string}
2645
2697
  */
2646
- function PublicSwapCreationInfo(fromCoin, toCoin, fromAmountCoins, toAmountCoins, rate, rawSwapData, min, fiatMin, max, fiatMax, durationMinutesRange) {
2698
+ function BaseSwapCreationInfo(fromCoin, toCoin, fromAmountCoins, toAmountCoins, rate, rawSwapData, min, fiatMin, max, fiatMax, durationMinutesRange) {
2647
2699
  this.fromCoin = fromCoin;
2648
2700
  this.toCoin = toCoin;
2649
2701
  this.fromAmountCoins = fromAmountCoins;
@@ -3796,11 +3848,14 @@ function _catch(body, recover) {
3796
3848
  }
3797
3849
  return result;
3798
3850
  }
3799
- var API_KEYS_PROXY_URL = window.location.protocol + "//" + window.location.host + "/api/v1/proxy";
3800
- var cache = new Cache(EventBusInstance__default["default"]);
3801
3851
  var PublicSwapService = /*#__PURE__*/function () {
3802
- function PublicSwapService() {}
3803
- PublicSwapService.initialize = function initialize() {
3852
+ function PublicSwapService(API_KEYS_PROXY_URL, cache) {
3853
+ this._swapProvider = new SwapspaceSwapProvider(API_KEYS_PROXY_URL, cache, function () {
3854
+ return null;
3855
+ }, false);
3856
+ }
3857
+ var _proto = PublicSwapService.prototype;
3858
+ _proto.initialize = function initialize() {
3804
3859
  try {
3805
3860
  var _this = this;
3806
3861
  var _temp = _catch(function () {
@@ -3815,7 +3870,7 @@ var PublicSwapService = /*#__PURE__*/function () {
3815
3870
  return Promise.reject(e);
3816
3871
  }
3817
3872
  };
3818
- PublicSwapService.getCurrenciesListForPublicSwap = function getCurrenciesListForPublicSwap(currencyThatShouldNotBeFirst) {
3873
+ _proto.getCurrenciesListForPublicSwap = function getCurrenciesListForPublicSwap(currencyThatShouldNotBeFirst) {
3819
3874
  if (currencyThatShouldNotBeFirst === void 0) {
3820
3875
  currencyThatShouldNotBeFirst = null;
3821
3876
  }
@@ -3869,7 +3924,7 @@ var PublicSwapService = /*#__PURE__*/function () {
3869
3924
  * }>}
3870
3925
  */
3871
3926
  ;
3872
- PublicSwapService.getInitialPublicSwapData = function getInitialPublicSwapData(fromCoin, toCoin) {
3927
+ _proto.getInitialPublicSwapData = function getInitialPublicSwapData(fromCoin, toCoin) {
3873
3928
  try {
3874
3929
  var _this3 = this;
3875
3930
  return Promise.resolve(_catch(function () {
@@ -3914,11 +3969,11 @@ var PublicSwapService = /*#__PURE__*/function () {
3914
3969
  * fiatMax: (number|null)
3915
3970
  * }|{
3916
3971
  * result: true,
3917
- * swapCreationInfo: PublicSwapCreationInfo
3972
+ * swapCreationInfo: BaseSwapCreationInfo
3918
3973
  * }>}
3919
3974
  */
3920
3975
  ;
3921
- PublicSwapService.getPublicSwapDetails = function getPublicSwapDetails(fromCoin, toCoin, fromAmountCoins) {
3976
+ _proto.getPublicSwapDetails = function getPublicSwapDetails(fromCoin, toCoin, fromAmountCoins) {
3922
3977
  try {
3923
3978
  var _this4 = this;
3924
3979
  var loggerSource = "getPublicSwapDetails";
@@ -3967,7 +4022,7 @@ var PublicSwapService = /*#__PURE__*/function () {
3967
4022
  var toAmountCoins = AmountUtils.trim(fromAmountBigNumber.times(details.rate), fromCoin.digits);
3968
4023
  var result = {
3969
4024
  result: true,
3970
- swapCreationInfo: new PublicSwapCreationInfo(fromCoin, toCoin, fromAmountCoins, toAmountCoins, details.rate, details.rawSwapData, min, fiatMin, max, fiatMax, details.durationMinutesRange)
4025
+ swapCreationInfo: new BaseSwapCreationInfo(fromCoin, toCoin, fromAmountCoins, toAmountCoins, details.rate, details.rawSwapData, min, fiatMin, max, fiatMax, details.durationMinutesRange)
3971
4026
  };
3972
4027
  Logger.log("Result: " + safeStringify({
3973
4028
  result: result.result,
@@ -3992,7 +4047,7 @@ var PublicSwapService = /*#__PURE__*/function () {
3992
4047
  * @param fromCoin {Coin}
3993
4048
  * @param toCoin {Coin}
3994
4049
  * @param fromAmount {string}
3995
- * @param swapCreationInfo {PublicSwapCreationInfo}
4050
+ * @param swapCreationInfo {BaseSwapCreationInfo}
3996
4051
  * @param toAddress {string}
3997
4052
  * @param refundAddress {string}
3998
4053
  * @return {Promise<{
@@ -4015,13 +4070,13 @@ var PublicSwapService = /*#__PURE__*/function () {
4015
4070
  * }>}
4016
4071
  */
4017
4072
  ;
4018
- PublicSwapService.createPublicSwap = function createPublicSwap(fromCoin, toCoin, fromAmount, swapCreationInfo, toAddress, refundAddress, clientIp) {
4073
+ _proto.createPublicSwap = function createPublicSwap(fromCoin, toCoin, fromAmount, swapCreationInfo, toAddress, refundAddress, clientIp) {
4019
4074
  try {
4020
4075
  var _this5 = this;
4021
4076
  var loggerSource = "createPublicSwap";
4022
4077
  return Promise.resolve(_catch(function () {
4023
4078
  var _swapCreationInfo$fro, _swapCreationInfo$toC;
4024
- if (!(fromCoin instanceof Coin) || !(toCoin instanceof Coin) || typeof fromAmount !== "string" || typeof toAddress !== "string" || typeof refundAddress !== "string" || !(swapCreationInfo instanceof PublicSwapCreationInfo)) {
4079
+ if (!(fromCoin instanceof Coin) || !(toCoin instanceof Coin) || typeof fromAmount !== "string" || typeof toAddress !== "string" || typeof refundAddress !== "string" || !(swapCreationInfo instanceof BaseSwapCreationInfo)) {
4025
4080
  throw new Error("Wrong input: " + fromCoin.ticker + " " + toCoin.ticker + " " + fromAmount + " " + swapCreationInfo);
4026
4081
  }
4027
4082
  Logger.log("Start: " + fromAmount + " " + fromCoin.ticker + " -> " + toCoin.ticker + ". Details: " + safeStringify(_extends({}, swapCreationInfo, {
@@ -4057,7 +4112,7 @@ var PublicSwapService = /*#__PURE__*/function () {
4057
4112
  var _temp4 = function () {
4058
4113
  if (result.result && result != null && result.swapId) {
4059
4114
  var _temp3 = function _temp3() {
4060
- EventBusInstance__default["default"].dispatch(_this5.PUBLIC_SWAP_CREATED_EVENT, null, fromCoin.ticker, toCoin.ticker, _fromAmountFiat);
4115
+ EventBusInstance.dispatch(_this5.PUBLIC_SWAP_CREATED_EVENT, null, fromCoin.ticker, toCoin.ticker, _fromAmountFiat);
4061
4116
  var toReturn = {
4062
4117
  result: true,
4063
4118
  swapId: result.swapId,
@@ -4127,7 +4182,7 @@ var PublicSwapService = /*#__PURE__*/function () {
4127
4182
  * error reason is one of PUBLIC_SWAPS_COMMON_ERRORS
4128
4183
  */
4129
4184
  ;
4130
- PublicSwapService.getPublicExistingSwapDetailsAndStatus = function getPublicExistingSwapDetailsAndStatus(swapIds) {
4185
+ _proto.getPublicExistingSwapDetailsAndStatus = function getPublicExistingSwapDetailsAndStatus(swapIds) {
4131
4186
  try {
4132
4187
  var _this6 = this;
4133
4188
  var loggerSource = "getPublicExistingSwapDetailsAndStatus";
@@ -4164,7 +4219,7 @@ var PublicSwapService = /*#__PURE__*/function () {
4164
4219
  * }>}
4165
4220
  */
4166
4221
  ;
4167
- PublicSwapService.getPublicSwapsHistory = function getPublicSwapsHistory() {
4222
+ _proto.getPublicSwapsHistory = function getPublicSwapsHistory() {
4168
4223
  try {
4169
4224
  var _exit2;
4170
4225
  var _this7 = this;
@@ -4197,7 +4252,7 @@ var PublicSwapService = /*#__PURE__*/function () {
4197
4252
  * @private
4198
4253
  */
4199
4254
  ;
4200
- PublicSwapService._savePublicSwapIdLocally = function _savePublicSwapIdLocally(swapId) {
4255
+ _proto._savePublicSwapIdLocally = function _savePublicSwapIdLocally(swapId) {
4201
4256
  if (typeof window !== "undefined") {
4202
4257
  try {
4203
4258
  var saved = localStorage.getItem("publicSwapIds");
@@ -4214,7 +4269,7 @@ var PublicSwapService = /*#__PURE__*/function () {
4214
4269
  * @private
4215
4270
  * @return {string[]}
4216
4271
  */;
4217
- PublicSwapService._getPublicSwapIdsSavedLocally = function _getPublicSwapIdsSavedLocally() {
4272
+ _proto._getPublicSwapIdsSavedLocally = function _getPublicSwapIdsSavedLocally() {
4218
4273
  if (typeof window !== "undefined") {
4219
4274
  try {
4220
4275
  var saved = localStorage.getItem("publicSwapIds");
@@ -4229,7 +4284,7 @@ var PublicSwapService = /*#__PURE__*/function () {
4229
4284
  * @param coinOrTicker {Coin|string}
4230
4285
  * @return {string} icon URL (ready to use)
4231
4286
  */;
4232
- PublicSwapService.getAssetIconUrl = function getAssetIconUrl(coinOrTicker) {
4287
+ _proto.getAssetIconUrl = function getAssetIconUrl(coinOrTicker) {
4233
4288
  return this._swapProvider.getIconUrl(coinOrTicker);
4234
4289
  }
4235
4290
 
@@ -4237,7 +4292,7 @@ var PublicSwapService = /*#__PURE__*/function () {
4237
4292
  * @param ticker {string}
4238
4293
  * @return {Coin|null}
4239
4294
  */;
4240
- PublicSwapService.getCoinByTickerIfPresent = function getCoinByTickerIfPresent(ticker) {
4295
+ _proto.getCoinByTickerIfPresent = function getCoinByTickerIfPresent(ticker) {
4241
4296
  return this._swapProvider.getCoinByTickerIfPresent(ticker);
4242
4297
  }
4243
4298
 
@@ -4246,7 +4301,7 @@ var PublicSwapService = /*#__PURE__*/function () {
4246
4301
  * @param asset {Coin}
4247
4302
  * @return {Promise<string|null>}
4248
4303
  */;
4249
- PublicSwapService.getAssetToUsdtRate = function getAssetToUsdtRate(asset) {
4304
+ _proto.getAssetToUsdtRate = function getAssetToUsdtRate(asset) {
4250
4305
  try {
4251
4306
  var _this8 = this;
4252
4307
  return Promise.resolve(_catch(function () {
@@ -4267,58 +4322,16 @@ var PublicSwapService = /*#__PURE__*/function () {
4267
4322
  * @return {boolean}
4268
4323
  */
4269
4324
  ;
4270
- PublicSwapService.isAddressValidForAsset = function isAddressValidForAsset(asset, address) {
4325
+ _proto.isAddressValidForAsset = function isAddressValidForAsset(asset, address) {
4271
4326
  try {
4272
4327
  return this._swapProvider.isAddressValidForAsset(asset, address);
4273
4328
  } catch (e) {
4274
4329
  improveAndRethrow(e, "isAddressValidForAsset");
4275
4330
  }
4276
- }
4277
-
4278
- // TODO: [dev] Remove if we don't need this inside the public swap steps
4279
- // /**
4280
- // * TODO: [feature, moderate] add other fiat currencies support. task_id=5490e21b8b9c4f89a2247b28db3c9e0a
4281
- // * @param asset {Coin}
4282
- // * @param amount {string}
4283
- // * @return {Promise<string|null>}
4284
- // */
4285
- // static async convertSingleCoinAmountToUsdtOrNull(asset, amount) {
4286
- // try {
4287
- // const result = await this._swapProvider.getCoinToUSDTRate(asset);
4288
- // if (result?.rate != null) {
4289
- // const decimals = FiatCurrenciesService.getCurrencyDecimalCountByCode("USD");
4290
- // return BigNumber(amount).div(result?.rate).toFixed(decimals);
4291
- // }
4292
- // return null;
4293
- // } catch (e) {
4294
- // improveAndRethrow(e, "convertSingleCoinAmountToUsdtOrNull");
4295
- // }
4296
- // }
4297
- //
4298
- // /**
4299
- // * TODO: [feature, moderate] add other fiat currencies support. task_id=5490e21b8b9c4f89a2247b28db3c9e0a
4300
- // * @param asset {Coin}
4301
- // * @param amount {string}
4302
- // * @return {Promise<string|null>}
4303
- // */
4304
- // static async convertSingleUsdtAmountToCoinOrNull(asset, amount) {
4305
- // try {
4306
- // const result = await this._swapProvider.getCoinToUSDTRate(asset);
4307
- // if (result?.rate != null) {
4308
- // return BigNumber(amount).times(result?.rate).toFixed(asset.digits);
4309
- // }
4310
- // return null;
4311
- // } catch (e) {
4312
- // improveAndRethrow(e, "convertSingleUsdtAmountToCoinOrNull");
4313
- // }
4314
- // }
4315
- ;
4331
+ };
4316
4332
  return PublicSwapService;
4317
4333
  }();
4318
4334
  PublicSwapService.PUBLIC_SWAP_CREATED_EVENT = "publicSwapCreatedEvent";
4319
- PublicSwapService._swapProvider = new SwapspaceSwapProvider(API_KEYS_PROXY_URL, cache, function () {
4320
- return null;
4321
- }, false);
4322
4335
  PublicSwapService.PUBLIC_SWAPS_COMMON_ERRORS = {
4323
4336
  REQUESTS_LIMIT_EXCEEDED: "requestsLimitExceeded"
4324
4337
  };
@@ -4331,6 +4344,7 @@ PublicSwapService._fiatDecimalsCount = FiatCurrenciesService.getCurrencyDecimalC
4331
4344
 
4332
4345
  exports.AmountUtils = AmountUtils;
4333
4346
  exports.AssetIcon = AssetIcon;
4347
+ exports.BaseSwapCreationInfo = BaseSwapCreationInfo;
4334
4348
  exports.Blockchain = Blockchain;
4335
4349
  exports.Button = Button;
4336
4350
  exports.Cache = Cache;
@@ -4343,7 +4357,6 @@ exports.LoadingDots = LoadingDots;
4343
4357
  exports.Logger = Logger;
4344
4358
  exports.LogsStorage = LogsStorage;
4345
4359
  exports.Protocol = Protocol;
4346
- exports.PublicSwapCreationInfo = PublicSwapCreationInfo;
4347
4360
  exports.PublicSwapService = PublicSwapService;
4348
4361
  exports.SupportChat = SupportChat;
4349
4362
  exports.SwapProvider = SwapProvider;
@@ -4351,4 +4364,6 @@ exports.SwapUtils = SwapUtils;
4351
4364
  exports.SwapspaceSwapProvider = SwapspaceSwapProvider;
4352
4365
  exports.improveAndRethrow = improveAndRethrow;
4353
4366
  exports.safeStringify = safeStringify;
4367
+ exports.useCallHandlingErrors = useCallHandlingErrors;
4368
+ exports.useReferredState = useReferredState;
4354
4369
  //# sourceMappingURL=index.cjs.map