@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.
package/dist/index.umd.js CHANGED
@@ -1,12 +1,13 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('bignumber.js'), require('axios')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'react', 'bignumber.js', 'axios'], factory) :
4
- (global = global || self, factory(global.uiKit = {}, global.react, global.bignumber_js, global.axios));
5
- })(this, (function (exports, React, bignumber_js, axios) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('bignumber.js'), require('axios'), require('eventbusjs')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'react', 'bignumber.js', 'axios', 'eventbusjs'], factory) :
4
+ (global = global || self, factory(global.uiKit = {}, global.react, global.bignumber_js, global.axios, global.eventbusjs));
5
+ })(this, (function (exports, React, bignumber_js, axios, EventBusInstance) {
6
6
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
7
7
 
8
8
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
9
9
  var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
10
+ var EventBusInstance__default = /*#__PURE__*/_interopDefaultLegacy(EventBusInstance);
10
11
 
11
12
  function createCommonjsModule(fn) {
12
13
  var module = { exports: {} };
@@ -1610,7 +1611,7 @@
1610
1611
  }
1611
1612
  var finalErrorText = message + ". " + safeStringify(e);
1612
1613
  // eslint-disable-next-line no-console
1613
- console.error(finalErrorText);
1614
+ console.error(finalErrorText, e);
1614
1615
  if (!onlyToConsole) {
1615
1616
  this.log(finalErrorText, "logError");
1616
1617
  }
@@ -3375,7 +3376,7 @@
3375
3376
  });
3376
3377
  }, function (e) {
3377
3378
  var _e$response4, _e$response5;
3378
- Logger.log("Failed to create swap. Error is: " + safeStringify(e), loggerSource);
3379
+ Logger.logError(e, loggerSource, "Failed to create swap. Error is: " + safeStringify(e));
3379
3380
  var composeFailResult = function composeFailResult(reason) {
3380
3381
  return {
3381
3382
  result: false,
@@ -3484,7 +3485,7 @@
3484
3485
  });
3485
3486
  }, function (e) {
3486
3487
  var _e$response6, _e$response7;
3487
- Logger.log("Failed to get swap details. Error is: " + safeStringify(e), loggerSource);
3488
+ Logger.logError(e, loggerSource, "Failed to get swap details. Error is: " + safeStringify(e));
3488
3489
  var composeFailResult = function composeFailResult(reason) {
3489
3490
  return {
3490
3491
  result: false,
@@ -3760,7 +3761,7 @@
3760
3761
  });
3761
3762
  });
3762
3763
  }, function (e) {
3763
- Logger.log("Failed to init swap: " + safeStringify(e), loggerSource);
3764
+ Logger.logError(e, loggerSource, "Failed to init swap: " + safeStringify(e));
3764
3765
  improveAndRethrow(e, loggerSource);
3765
3766
  }));
3766
3767
  } catch (e) {
@@ -3860,9 +3861,7 @@
3860
3861
  try {
3861
3862
  var _this = this;
3862
3863
  var _temp = _catch(function () {
3863
- return Promise.resolve(_this._swapProvider.initialize()).then(function () {
3864
- SwapUtils.safeHandleRequestsLimitExceeding();
3865
- });
3864
+ return Promise.resolve(_this._swapProvider.initialize()).then(function () {});
3866
3865
  }, function (e) {
3867
3866
  Logger.logError(e, "PublicSwapService.initialize");
3868
3867
  });
@@ -3886,7 +3885,7 @@
3886
3885
  SwapUtils.safeHandleRequestsLimitExceeding();
3887
3886
  return {
3888
3887
  result: false,
3889
- reason: _this2.PUBLIC_SWAPS_COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED
3888
+ reason: PublicSwapService.PUBLIC_SWAPS_COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED
3890
3889
  };
3891
3890
  }
3892
3891
  Logger.log("Retrieved " + (result == null || (_result$coins = result.coins) == null ? void 0 : _result$coins.length) + " supported currencies for swap", loggerSource);
@@ -3935,13 +3934,13 @@
3935
3934
  SwapUtils.safeHandleRequestsLimitExceeding();
3936
3935
  return {
3937
3936
  result: false,
3938
- reason: _this3.PUBLIC_SWAPS_COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED
3937
+ reason: PublicSwapService.PUBLIC_SWAPS_COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED
3939
3938
  };
3940
3939
  }
3941
3940
  if (result.reason === SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED) {
3942
3941
  return {
3943
3942
  result: false,
3944
- reason: _this3.PUBLIC_SWAP_DETAILS_FAIL_REASONS.PAIR_NOT_SUPPORTED
3943
+ reason: PublicSwapService.PUBLIC_SWAP_DETAILS_FAIL_REASONS.PAIR_NOT_SUPPORTED
3945
3944
  };
3946
3945
  }
3947
3946
  }
@@ -3990,10 +3989,10 @@
3990
3989
  fiatMax = null;
3991
3990
  if (coinUsdtRate != null) {
3992
3991
  if (min != null) {
3993
- fiatMin = bignumber_js.BigNumber(min).times(coinUsdtRate).toFixed(_this4._fiatDecimalsCount);
3992
+ fiatMin = bignumber_js.BigNumber(min).times(coinUsdtRate).toFixed(PublicSwapService._fiatDecimalsCount);
3994
3993
  }
3995
3994
  if (max != null) {
3996
- fiatMax = bignumber_js.BigNumber(max).times(coinUsdtRate).toFixed(_this4._fiatDecimalsCount);
3995
+ fiatMax = bignumber_js.BigNumber(max).times(coinUsdtRate).toFixed(PublicSwapService._fiatDecimalsCount);
3997
3996
  }
3998
3997
  }
3999
3998
  var composeFailResult = function composeFailResult(reason) {
@@ -4009,16 +4008,16 @@
4009
4008
  };
4010
4009
  };
4011
4010
  if (!details.result) {
4012
- 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) {
4011
+ 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) {
4013
4012
  SwapUtils.safeHandleRequestsLimitExceeding();
4014
- return composeFailResult(_this4.PUBLIC_SWAPS_COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED);
4013
+ return composeFailResult(PublicSwapService.PUBLIC_SWAPS_COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED);
4015
4014
  }
4016
4015
  }
4017
4016
  var fromAmountBigNumber = bignumber_js.BigNumber(fromAmountCoins);
4018
4017
  if (typeof min === "string" && fromAmountBigNumber.lt(min)) {
4019
- return composeFailResult(_this4.PUBLIC_SWAP_DETAILS_FAIL_REASONS.AMOUNT_LESS_THAN_MIN_SWAPPABLE);
4018
+ return composeFailResult(PublicSwapService.PUBLIC_SWAP_DETAILS_FAIL_REASONS.AMOUNT_LESS_THAN_MIN_SWAPPABLE);
4020
4019
  } else if (typeof max === "string" && fromAmountBigNumber.gt(max)) {
4021
- return composeFailResult(_this4.PUBLIC_SWAP_DETAILS_FAIL_REASONS.AMOUNT_HIGHER_THAN_MAX_SWAPPABLE);
4020
+ return composeFailResult(PublicSwapService.PUBLIC_SWAP_DETAILS_FAIL_REASONS.AMOUNT_HIGHER_THAN_MAX_SWAPPABLE);
4022
4021
  }
4023
4022
  var toAmountCoins = AmountUtils.trim(fromAmountBigNumber.times(details.rate), fromCoin.digits);
4024
4023
  var result = {
@@ -4051,6 +4050,7 @@
4051
4050
  * @param swapCreationInfo {BaseSwapCreationInfo}
4052
4051
  * @param toAddress {string}
4053
4052
  * @param refundAddress {string}
4053
+ * @param clientIp {string}
4054
4054
  * @return {Promise<{
4055
4055
  * result: true,
4056
4056
  * fiatCurrencyCode: string,
@@ -4099,21 +4099,21 @@
4099
4099
  SwapUtils.safeHandleRequestsLimitExceeding();
4100
4100
  return {
4101
4101
  result: false,
4102
- reason: _this5.PUBLIC_SWAPS_COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED
4102
+ reason: PublicSwapService.PUBLIC_SWAPS_COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED
4103
4103
  };
4104
4104
  }
4105
4105
  if ((result == null ? void 0 : result.reason) === SwapProvider.CREATION_FAIL_REASONS.RETRIABLE_FAIL) {
4106
4106
  // TODO: [feature, high] implement retrying if one partner fail and we have another partners task_id=a07e367e488f4a4899613ac9056fa359
4107
4107
  // return {
4108
4108
  // result: false,
4109
- // reason: this.SWAP_CREATION_FAIL_REASONS.RETRIABLE_FAIL,
4109
+ // reason: PublicSwapService.SWAP_CREATION_FAIL_REASONS.RETRIABLE_FAIL,
4110
4110
  // };
4111
4111
  }
4112
4112
  }
4113
4113
  var _temp4 = function () {
4114
4114
  if (result.result && result != null && result.swapId) {
4115
4115
  var _temp3 = function _temp3() {
4116
- EventBusInstance.dispatch(_this5.PUBLIC_SWAP_CREATED_EVENT, null, fromCoin.ticker, toCoin.ticker, _fromAmountFiat);
4116
+ EventBusInstance__default["default"].dispatch(PublicSwapService.PUBLIC_SWAP_CREATED_EVENT, null, fromCoin.ticker, toCoin.ticker, _fromAmountFiat);
4117
4117
  var toReturn = {
4118
4118
  result: true,
4119
4119
  swapId: result.swapId,
@@ -4124,7 +4124,7 @@
4124
4124
  fromAmountFiat: _fromAmountFiat,
4125
4125
  toAmountFiat: _toAmountFiat,
4126
4126
  fiatCurrencyCode: "USD",
4127
- fiatCurrencyDecimals: _this5._fiatDecimalsCount,
4127
+ fiatCurrencyDecimals: PublicSwapService._fiatDecimalsCount,
4128
4128
  rate: result.rate,
4129
4129
  durationMinutesRange: swapCreationInfo.durationMinutesRange,
4130
4130
  address: result.fromAddress // CRITICAL: this is the address to send coins to swaps provider
@@ -4147,10 +4147,10 @@
4147
4147
  var _this5$_swapProvider$4;
4148
4148
  var toCoinUsdtRate = (_this5$_swapProvider$4 = _this5$_swapProvider$2 == null ? void 0 : _this5$_swapProvider$2.rate) != null ? _this5$_swapProvider$4 : null;
4149
4149
  if (fromCoinUsdtRate != null && result.fromAmount != null) {
4150
- _fromAmountFiat = bignumber_js.BigNumber(result.fromAmount).times(fromCoinUsdtRate).toFixed(_this5._fiatDecimalsCount);
4150
+ _fromAmountFiat = bignumber_js.BigNumber(result.fromAmount).times(fromCoinUsdtRate).toFixed(PublicSwapService._fiatDecimalsCount);
4151
4151
  }
4152
4152
  if (toCoinUsdtRate != null && result.toAmount != null) {
4153
- _toAmountFiat = bignumber_js.BigNumber(result.toAmount).times(toCoinUsdtRate).toFixed(_this5._fiatDecimalsCount);
4153
+ _toAmountFiat = bignumber_js.BigNumber(result.toAmount).times(toCoinUsdtRate).toFixed(PublicSwapService._fiatDecimalsCount);
4154
4154
  }
4155
4155
  });
4156
4156
  });
@@ -4194,7 +4194,7 @@
4194
4194
  SwapUtils.safeHandleRequestsLimitExceeding();
4195
4195
  return {
4196
4196
  result: false,
4197
- reason: _this6.PUBLIC_SWAPS_COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED
4197
+ reason: PublicSwapService.PUBLIC_SWAPS_COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED
4198
4198
  };
4199
4199
  }
4200
4200
  throw new Error("Unknown reason: " + (result == null ? void 0 : result.reason));