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

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,6 +1,7 @@
1
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';
4
5
 
5
6
  function createCommonjsModule(fn) {
6
7
  var module = { exports: {} };
@@ -1604,7 +1605,7 @@ var Logger = /*#__PURE__*/function () {
1604
1605
  }
1605
1606
  var finalErrorText = message + ". " + safeStringify(e);
1606
1607
  // eslint-disable-next-line no-console
1607
- console.error(finalErrorText);
1608
+ console.error(finalErrorText, e);
1608
1609
  if (!onlyToConsole) {
1609
1610
  this.log(finalErrorText, "logError");
1610
1611
  }
@@ -3369,7 +3370,7 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
3369
3370
  });
3370
3371
  }, function (e) {
3371
3372
  var _e$response4, _e$response5;
3372
- Logger.log("Failed to create swap. Error is: " + safeStringify(e), loggerSource);
3373
+ Logger.logError(e, loggerSource, "Failed to create swap. Error is: " + safeStringify(e));
3373
3374
  var composeFailResult = function composeFailResult(reason) {
3374
3375
  return {
3375
3376
  result: false,
@@ -3478,7 +3479,7 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
3478
3479
  });
3479
3480
  }, function (e) {
3480
3481
  var _e$response6, _e$response7;
3481
- Logger.log("Failed to get swap details. Error is: " + safeStringify(e), loggerSource);
3482
+ Logger.logError(e, loggerSource, "Failed to get swap details. Error is: " + safeStringify(e));
3482
3483
  var composeFailResult = function composeFailResult(reason) {
3483
3484
  return {
3484
3485
  result: false,
@@ -3754,7 +3755,7 @@ var SwapUtils = /*#__PURE__*/function () {
3754
3755
  });
3755
3756
  });
3756
3757
  }, function (e) {
3757
- Logger.log("Failed to init swap: " + safeStringify(e), loggerSource);
3758
+ Logger.logError(e, loggerSource, "Failed to init swap: " + safeStringify(e));
3758
3759
  improveAndRethrow(e, loggerSource);
3759
3760
  }));
3760
3761
  } catch (e) {
@@ -3854,9 +3855,7 @@ var PublicSwapService = /*#__PURE__*/function () {
3854
3855
  try {
3855
3856
  var _this = this;
3856
3857
  var _temp = _catch(function () {
3857
- return Promise.resolve(_this._swapProvider.initialize()).then(function () {
3858
- SwapUtils.safeHandleRequestsLimitExceeding();
3859
- });
3858
+ return Promise.resolve(_this._swapProvider.initialize()).then(function () {});
3860
3859
  }, function (e) {
3861
3860
  Logger.logError(e, "PublicSwapService.initialize");
3862
3861
  });
@@ -3880,7 +3879,7 @@ var PublicSwapService = /*#__PURE__*/function () {
3880
3879
  SwapUtils.safeHandleRequestsLimitExceeding();
3881
3880
  return {
3882
3881
  result: false,
3883
- reason: _this2.PUBLIC_SWAPS_COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED
3882
+ reason: PublicSwapService.PUBLIC_SWAPS_COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED
3884
3883
  };
3885
3884
  }
3886
3885
  Logger.log("Retrieved " + (result == null || (_result$coins = result.coins) == null ? void 0 : _result$coins.length) + " supported currencies for swap", loggerSource);
@@ -3929,13 +3928,13 @@ var PublicSwapService = /*#__PURE__*/function () {
3929
3928
  SwapUtils.safeHandleRequestsLimitExceeding();
3930
3929
  return {
3931
3930
  result: false,
3932
- reason: _this3.PUBLIC_SWAPS_COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED
3931
+ reason: PublicSwapService.PUBLIC_SWAPS_COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED
3933
3932
  };
3934
3933
  }
3935
3934
  if (result.reason === SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED) {
3936
3935
  return {
3937
3936
  result: false,
3938
- reason: _this3.PUBLIC_SWAP_DETAILS_FAIL_REASONS.PAIR_NOT_SUPPORTED
3937
+ reason: PublicSwapService.PUBLIC_SWAP_DETAILS_FAIL_REASONS.PAIR_NOT_SUPPORTED
3939
3938
  };
3940
3939
  }
3941
3940
  }
@@ -3984,10 +3983,10 @@ var PublicSwapService = /*#__PURE__*/function () {
3984
3983
  fiatMax = null;
3985
3984
  if (coinUsdtRate != null) {
3986
3985
  if (min != null) {
3987
- fiatMin = BigNumber(min).times(coinUsdtRate).toFixed(_this4._fiatDecimalsCount);
3986
+ fiatMin = BigNumber(min).times(coinUsdtRate).toFixed(PublicSwapService._fiatDecimalsCount);
3988
3987
  }
3989
3988
  if (max != null) {
3990
- fiatMax = BigNumber(max).times(coinUsdtRate).toFixed(_this4._fiatDecimalsCount);
3989
+ fiatMax = BigNumber(max).times(coinUsdtRate).toFixed(PublicSwapService._fiatDecimalsCount);
3991
3990
  }
3992
3991
  }
3993
3992
  var composeFailResult = function composeFailResult(reason) {
@@ -4003,16 +4002,16 @@ var PublicSwapService = /*#__PURE__*/function () {
4003
4002
  };
4004
4003
  };
4005
4004
  if (!details.result) {
4006
- if ((details == null ? void 0 : details.reason) === SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED) return composeFailResult(_this4.PUBLIC_SWAP_DETAILS_FAIL_REASONS.PAIR_NOT_SUPPORTED);else if ((details == null ? void 0 : details.reason) === SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED) {
4005
+ if ((details == null ? void 0 : details.reason) === SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED) return composeFailResult(PublicSwapService.PUBLIC_SWAP_DETAILS_FAIL_REASONS.PAIR_NOT_SUPPORTED);else if ((details == null ? void 0 : details.reason) === SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED) {
4007
4006
  SwapUtils.safeHandleRequestsLimitExceeding();
4008
- return composeFailResult(_this4.PUBLIC_SWAPS_COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED);
4007
+ return composeFailResult(PublicSwapService.PUBLIC_SWAPS_COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED);
4009
4008
  }
4010
4009
  }
4011
4010
  var fromAmountBigNumber = BigNumber(fromAmountCoins);
4012
4011
  if (typeof min === "string" && fromAmountBigNumber.lt(min)) {
4013
- return composeFailResult(_this4.PUBLIC_SWAP_DETAILS_FAIL_REASONS.AMOUNT_LESS_THAN_MIN_SWAPPABLE);
4012
+ return composeFailResult(PublicSwapService.PUBLIC_SWAP_DETAILS_FAIL_REASONS.AMOUNT_LESS_THAN_MIN_SWAPPABLE);
4014
4013
  } else if (typeof max === "string" && fromAmountBigNumber.gt(max)) {
4015
- return composeFailResult(_this4.PUBLIC_SWAP_DETAILS_FAIL_REASONS.AMOUNT_HIGHER_THAN_MAX_SWAPPABLE);
4014
+ return composeFailResult(PublicSwapService.PUBLIC_SWAP_DETAILS_FAIL_REASONS.AMOUNT_HIGHER_THAN_MAX_SWAPPABLE);
4016
4015
  }
4017
4016
  var toAmountCoins = AmountUtils.trim(fromAmountBigNumber.times(details.rate), fromCoin.digits);
4018
4017
  var result = {
@@ -4045,6 +4044,7 @@ var PublicSwapService = /*#__PURE__*/function () {
4045
4044
  * @param swapCreationInfo {BaseSwapCreationInfo}
4046
4045
  * @param toAddress {string}
4047
4046
  * @param refundAddress {string}
4047
+ * @param clientIp {string}
4048
4048
  * @return {Promise<{
4049
4049
  * result: true,
4050
4050
  * fiatCurrencyCode: string,
@@ -4093,21 +4093,21 @@ var PublicSwapService = /*#__PURE__*/function () {
4093
4093
  SwapUtils.safeHandleRequestsLimitExceeding();
4094
4094
  return {
4095
4095
  result: false,
4096
- reason: _this5.PUBLIC_SWAPS_COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED
4096
+ reason: PublicSwapService.PUBLIC_SWAPS_COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED
4097
4097
  };
4098
4098
  }
4099
4099
  if ((result == null ? void 0 : result.reason) === SwapProvider.CREATION_FAIL_REASONS.RETRIABLE_FAIL) {
4100
4100
  // TODO: [feature, high] implement retrying if one partner fail and we have another partners task_id=a07e367e488f4a4899613ac9056fa359
4101
4101
  // return {
4102
4102
  // result: false,
4103
- // reason: this.SWAP_CREATION_FAIL_REASONS.RETRIABLE_FAIL,
4103
+ // reason: PublicSwapService.SWAP_CREATION_FAIL_REASONS.RETRIABLE_FAIL,
4104
4104
  // };
4105
4105
  }
4106
4106
  }
4107
4107
  var _temp4 = function () {
4108
4108
  if (result.result && result != null && result.swapId) {
4109
4109
  var _temp3 = function _temp3() {
4110
- EventBusInstance.dispatch(_this5.PUBLIC_SWAP_CREATED_EVENT, null, fromCoin.ticker, toCoin.ticker, _fromAmountFiat);
4110
+ EventBusInstance.dispatch(PublicSwapService.PUBLIC_SWAP_CREATED_EVENT, null, fromCoin.ticker, toCoin.ticker, _fromAmountFiat);
4111
4111
  var toReturn = {
4112
4112
  result: true,
4113
4113
  swapId: result.swapId,
@@ -4118,7 +4118,7 @@ var PublicSwapService = /*#__PURE__*/function () {
4118
4118
  fromAmountFiat: _fromAmountFiat,
4119
4119
  toAmountFiat: _toAmountFiat,
4120
4120
  fiatCurrencyCode: "USD",
4121
- fiatCurrencyDecimals: _this5._fiatDecimalsCount,
4121
+ fiatCurrencyDecimals: PublicSwapService._fiatDecimalsCount,
4122
4122
  rate: result.rate,
4123
4123
  durationMinutesRange: swapCreationInfo.durationMinutesRange,
4124
4124
  address: result.fromAddress // CRITICAL: this is the address to send coins to swaps provider
@@ -4141,10 +4141,10 @@ var PublicSwapService = /*#__PURE__*/function () {
4141
4141
  var _this5$_swapProvider$4;
4142
4142
  var toCoinUsdtRate = (_this5$_swapProvider$4 = _this5$_swapProvider$2 == null ? void 0 : _this5$_swapProvider$2.rate) != null ? _this5$_swapProvider$4 : null;
4143
4143
  if (fromCoinUsdtRate != null && result.fromAmount != null) {
4144
- _fromAmountFiat = BigNumber(result.fromAmount).times(fromCoinUsdtRate).toFixed(_this5._fiatDecimalsCount);
4144
+ _fromAmountFiat = BigNumber(result.fromAmount).times(fromCoinUsdtRate).toFixed(PublicSwapService._fiatDecimalsCount);
4145
4145
  }
4146
4146
  if (toCoinUsdtRate != null && result.toAmount != null) {
4147
- _toAmountFiat = BigNumber(result.toAmount).times(toCoinUsdtRate).toFixed(_this5._fiatDecimalsCount);
4147
+ _toAmountFiat = BigNumber(result.toAmount).times(toCoinUsdtRate).toFixed(PublicSwapService._fiatDecimalsCount);
4148
4148
  }
4149
4149
  });
4150
4150
  });
@@ -4188,7 +4188,7 @@ var PublicSwapService = /*#__PURE__*/function () {
4188
4188
  SwapUtils.safeHandleRequestsLimitExceeding();
4189
4189
  return {
4190
4190
  result: false,
4191
- reason: _this6.PUBLIC_SWAPS_COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED
4191
+ reason: PublicSwapService.PUBLIC_SWAPS_COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED
4192
4192
  };
4193
4193
  }
4194
4194
  throw new Error("Unknown reason: " + (result == null ? void 0 : result.reason));