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

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.
@@ -3864,16 +3864,39 @@ var PublicSwapService = /*#__PURE__*/function () {
3864
3864
  return Promise.reject(e);
3865
3865
  }
3866
3866
  };
3867
- _proto.getCurrenciesListForPublicSwap = function getCurrenciesListForPublicSwap(currencyThatShouldNotBeFirst) {
3868
- if (currencyThatShouldNotBeFirst === void 0) {
3869
- currencyThatShouldNotBeFirst = null;
3870
- }
3867
+ _proto.getDepositCurrenciesListForPublicSwap = function getDepositCurrenciesListForPublicSwap() {
3871
3868
  try {
3872
3869
  var _this2 = this;
3870
+ return Promise.resolve(_catch(function () {
3871
+ return Promise.resolve(_this2._getCurrenciesListForPublicSwap(false));
3872
+ }, function (e) {
3873
+ improveAndRethrow(e, "getDepositCurrenciesListForPublicSwap");
3874
+ }));
3875
+ } catch (e) {
3876
+ return Promise.reject(e);
3877
+ }
3878
+ };
3879
+ _proto.getWithdrawCurrenciesListForPublicSwap = function getWithdrawCurrenciesListForPublicSwap() {
3880
+ try {
3881
+ var _this3 = this;
3882
+ return Promise.resolve(_catch(function () {
3883
+ return Promise.resolve(_this3._getCurrenciesListForPublicSwap(true));
3884
+ }, function (e) {
3885
+ improveAndRethrow(e, "getWithdrawCurrenciesListForPublicSwap");
3886
+ }));
3887
+ } catch (e) {
3888
+ return Promise.reject(e);
3889
+ }
3890
+ };
3891
+ _proto._getCurrenciesListForPublicSwap = function _getCurrenciesListForPublicSwap(withdraw) {
3892
+ if (withdraw === void 0) {
3893
+ withdraw = false;
3894
+ }
3895
+ try {
3896
+ var _this4 = this;
3873
3897
  var loggerSource = "getCurrenciesListForPublicSwap";
3874
3898
  return Promise.resolve(_catch(function () {
3875
- // TODO: [dev] this is temporary hack, change it to use dedicated lists inside UI and also here
3876
- return Promise.resolve(currencyThatShouldNotBeFirst ? _this2._swapProvider.getWithdrawalCurrencies(currencyThatShouldNotBeFirst) : _this2._swapProvider.getDepositCurrencies()).then(function (result) {
3899
+ return Promise.resolve(withdraw ? _this4._swapProvider.getWithdrawalCurrencies() : _this4._swapProvider.getDepositCurrencies()).then(function (result) {
3877
3900
  var _result$coins;
3878
3901
  if (result.reason === SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED) {
3879
3902
  SwapUtils.safeHandleRequestsLimitExceeding();
@@ -3920,9 +3943,9 @@ var PublicSwapService = /*#__PURE__*/function () {
3920
3943
  ;
3921
3944
  _proto.getInitialPublicSwapData = function getInitialPublicSwapData(fromCoin, toCoin) {
3922
3945
  try {
3923
- var _this3 = this;
3946
+ var _this5 = this;
3924
3947
  return Promise.resolve(_catch(function () {
3925
- return Promise.resolve(SwapUtils.getInitialSwapData(_this3._swapProvider, fromCoin, toCoin)).then(function (result) {
3948
+ return Promise.resolve(SwapUtils.getInitialSwapData(_this5._swapProvider, fromCoin, toCoin)).then(function (result) {
3926
3949
  if (!result.result) {
3927
3950
  if (result.reason === SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED) {
3928
3951
  SwapUtils.safeHandleRequestsLimitExceeding();
@@ -3969,13 +3992,13 @@ var PublicSwapService = /*#__PURE__*/function () {
3969
3992
  ;
3970
3993
  _proto.getPublicSwapDetails = function getPublicSwapDetails(fromCoin, toCoin, fromAmountCoins) {
3971
3994
  try {
3972
- var _this4 = this;
3995
+ var _this6 = this;
3973
3996
  var loggerSource = "getPublicSwapDetails";
3974
3997
  return Promise.resolve(_catch(function () {
3975
- return Promise.resolve(_this4._swapProvider.getCoinToUSDTRate(fromCoin)).then(function (_this4$_swapProvider$) {
3976
- var _this4$_swapProvider$2;
3977
- var coinUsdtRate = (_this4$_swapProvider$2 = _this4$_swapProvider$ == null ? void 0 : _this4$_swapProvider$.rate) != null ? _this4$_swapProvider$2 : null;
3978
- return Promise.resolve(_this4._swapProvider.getSwapInfo(fromCoin, toCoin, fromAmountCoins, coinUsdtRate)).then(function (details) {
3998
+ return Promise.resolve(_this6._swapProvider.getCoinToUSDTRate(fromCoin)).then(function (_this6$_swapProvider$) {
3999
+ var _this6$_swapProvider$2;
4000
+ var coinUsdtRate = (_this6$_swapProvider$2 = _this6$_swapProvider$ == null ? void 0 : _this6$_swapProvider$.rate) != null ? _this6$_swapProvider$2 : null;
4001
+ return Promise.resolve(_this6._swapProvider.getSwapInfo(fromCoin, toCoin, fromAmountCoins, coinUsdtRate)).then(function (details) {
3979
4002
  var _result$swapCreationI, _result$swapCreationI2;
3980
4003
  var min = details.result ? details.min : details.smallestMin;
3981
4004
  var max = details.result ? details.max : details.greatestMax;
@@ -4067,7 +4090,7 @@ var PublicSwapService = /*#__PURE__*/function () {
4067
4090
  ;
4068
4091
  _proto.createPublicSwap = function createPublicSwap(fromCoin, toCoin, fromAmount, swapCreationInfo, toAddress, refundAddress, clientIp) {
4069
4092
  try {
4070
- var _this5 = this;
4093
+ var _this7 = this;
4071
4094
  var loggerSource = "createPublicSwap";
4072
4095
  return Promise.resolve(_catch(function () {
4073
4096
  var _swapCreationInfo$fro, _swapCreationInfo$toC;
@@ -4078,10 +4101,10 @@ var PublicSwapService = /*#__PURE__*/function () {
4078
4101
  fromCoin: swapCreationInfo == null || (_swapCreationInfo$fro = swapCreationInfo.fromCoin) == null ? void 0 : _swapCreationInfo$fro.ticker,
4079
4102
  toCoin: swapCreationInfo == null || (_swapCreationInfo$toC = swapCreationInfo.toCoin) == null ? void 0 : _swapCreationInfo$toC.ticker
4080
4103
  })), loggerSource);
4081
- return Promise.resolve(_this5._swapProvider.createSwap(fromCoin, toCoin, fromAmount, toAddress, refundAddress, swapCreationInfo.rawSwapData, clientIp)).then(function (result) {
4104
+ return Promise.resolve(_this7._swapProvider.createSwap(fromCoin, toCoin, fromAmount, toAddress, refundAddress, swapCreationInfo.rawSwapData, clientIp)).then(function (result) {
4082
4105
  var _exit;
4083
- function _temp5(_result5) {
4084
- if (_exit) return _result5;
4106
+ function _temp5(_result7) {
4107
+ if (_exit) return _result7;
4085
4108
  throw new Error("Unexpected result from provider " + safeStringify(result));
4086
4109
  }
4087
4110
  Logger.log("Created:" + safeStringify(_extends({}, result, {
@@ -4123,7 +4146,7 @@ var PublicSwapService = /*#__PURE__*/function () {
4123
4146
  durationMinutesRange: swapCreationInfo.durationMinutesRange,
4124
4147
  address: result.fromAddress // CRITICAL: this is the address to send coins to swaps provider
4125
4148
  };
4126
- _this5._savePublicSwapIdLocally(result.swapId);
4149
+ _this7._savePublicSwapIdLocally(result.swapId);
4127
4150
  Logger.log("Returning: " + safeStringify(_extends({}, toReturn, {
4128
4151
  fromCoin: fromCoin == null ? void 0 : fromCoin.ticker,
4129
4152
  toCoin: toCoin == null ? void 0 : toCoin.ticker
@@ -4134,12 +4157,12 @@ var PublicSwapService = /*#__PURE__*/function () {
4134
4157
  var _fromAmountFiat = null,
4135
4158
  _toAmountFiat = null;
4136
4159
  var _temp2 = _catch(function () {
4137
- return Promise.resolve(_this5._swapProvider.getCoinToUSDTRate(fromCoin)).then(function (_this5$_swapProvider$) {
4138
- var _this5$_swapProvider$3;
4139
- var fromCoinUsdtRate = (_this5$_swapProvider$3 = _this5$_swapProvider$ == null ? void 0 : _this5$_swapProvider$.rate) != null ? _this5$_swapProvider$3 : null;
4140
- return Promise.resolve(_this5._swapProvider.getCoinToUSDTRate(fromCoin)).then(function (_this5$_swapProvider$2) {
4141
- var _this5$_swapProvider$4;
4142
- var toCoinUsdtRate = (_this5$_swapProvider$4 = _this5$_swapProvider$2 == null ? void 0 : _this5$_swapProvider$2.rate) != null ? _this5$_swapProvider$4 : null;
4160
+ return Promise.resolve(_this7._swapProvider.getCoinToUSDTRate(fromCoin)).then(function (_this7$_swapProvider$) {
4161
+ var _this7$_swapProvider$3;
4162
+ var fromCoinUsdtRate = (_this7$_swapProvider$3 = _this7$_swapProvider$ == null ? void 0 : _this7$_swapProvider$.rate) != null ? _this7$_swapProvider$3 : null;
4163
+ return Promise.resolve(_this7._swapProvider.getCoinToUSDTRate(fromCoin)).then(function (_this7$_swapProvider$2) {
4164
+ var _this7$_swapProvider$4;
4165
+ var toCoinUsdtRate = (_this7$_swapProvider$4 = _this7$_swapProvider$2 == null ? void 0 : _this7$_swapProvider$2.rate) != null ? _this7$_swapProvider$4 : null;
4143
4166
  if (fromCoinUsdtRate != null && result.fromAmount != null) {
4144
4167
  _fromAmountFiat = BigNumber(result.fromAmount).times(fromCoinUsdtRate).toFixed(PublicSwapService._fiatDecimalsCount);
4145
4168
  }
@@ -4179,10 +4202,10 @@ var PublicSwapService = /*#__PURE__*/function () {
4179
4202
  ;
4180
4203
  _proto.getPublicExistingSwapDetailsAndStatus = function getPublicExistingSwapDetailsAndStatus(swapIds) {
4181
4204
  try {
4182
- var _this6 = this;
4205
+ var _this8 = this;
4183
4206
  var loggerSource = "getPublicExistingSwapDetailsAndStatus";
4184
4207
  return Promise.resolve(_catch(function () {
4185
- return Promise.resolve(SwapUtils.getExistingSwapsDetailsWithFiatAmounts(_this6._swapProvider, swapIds)).then(function (result) {
4208
+ return Promise.resolve(SwapUtils.getExistingSwapsDetailsWithFiatAmounts(_this8._swapProvider, swapIds)).then(function (result) {
4186
4209
  if (!(result != null && result.result)) {
4187
4210
  if (result.reason === SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED) {
4188
4211
  SwapUtils.safeHandleRequestsLimitExceeding();
@@ -4217,20 +4240,20 @@ var PublicSwapService = /*#__PURE__*/function () {
4217
4240
  _proto.getPublicSwapsHistory = function getPublicSwapsHistory() {
4218
4241
  try {
4219
4242
  var _exit2;
4220
- var _this7 = this;
4243
+ var _this9 = this;
4221
4244
  return Promise.resolve(_catch(function () {
4222
- function _temp7(_result7) {
4223
- return _exit2 ? _result7 : {
4245
+ function _temp7(_result9) {
4246
+ return _exit2 ? _result9 : {
4224
4247
  result: true,
4225
4248
  swaps: []
4226
4249
  };
4227
4250
  }
4228
- var swapIds = _this7._getPublicSwapIdsSavedLocally();
4251
+ var swapIds = _this9._getPublicSwapIdsSavedLocally();
4229
4252
  var _temp6 = function () {
4230
4253
  if (swapIds.length) {
4231
- return Promise.resolve(_this7.getPublicExistingSwapDetailsAndStatus(swapIds)).then(function (_await$_this7$getPubl) {
4254
+ return Promise.resolve(_this9.getPublicExistingSwapDetailsAndStatus(swapIds)).then(function (_await$_this9$getPubl) {
4232
4255
  _exit2 = 1;
4233
- return _await$_this7$getPubl;
4256
+ return _await$_this9$getPubl;
4234
4257
  });
4235
4258
  }
4236
4259
  }();
@@ -4298,9 +4321,9 @@ var PublicSwapService = /*#__PURE__*/function () {
4298
4321
  */;
4299
4322
  _proto.getAssetToUsdtRate = function getAssetToUsdtRate(asset) {
4300
4323
  try {
4301
- var _this8 = this;
4324
+ var _this10 = this;
4302
4325
  return Promise.resolve(_catch(function () {
4303
- return Promise.resolve(_this8._swapProvider.getCoinToUSDTRate(asset)).then(function (result) {
4326
+ return Promise.resolve(_this10._swapProvider.getCoinToUSDTRate(asset)).then(function (result) {
4304
4327
  var _result$rate;
4305
4328
  return (_result$rate = result == null ? void 0 : result.rate) != null ? _result$rate : null;
4306
4329
  });