@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.
package/dist/index.cjs CHANGED
@@ -3870,16 +3870,39 @@ var PublicSwapService = /*#__PURE__*/function () {
3870
3870
  return Promise.reject(e);
3871
3871
  }
3872
3872
  };
3873
- _proto.getCurrenciesListForPublicSwap = function getCurrenciesListForPublicSwap(currencyThatShouldNotBeFirst) {
3874
- if (currencyThatShouldNotBeFirst === void 0) {
3875
- currencyThatShouldNotBeFirst = null;
3876
- }
3873
+ _proto.getDepositCurrenciesListForPublicSwap = function getDepositCurrenciesListForPublicSwap() {
3877
3874
  try {
3878
3875
  var _this2 = this;
3876
+ return Promise.resolve(_catch(function () {
3877
+ return Promise.resolve(_this2._getCurrenciesListForPublicSwap(false));
3878
+ }, function (e) {
3879
+ improveAndRethrow(e, "getDepositCurrenciesListForPublicSwap");
3880
+ }));
3881
+ } catch (e) {
3882
+ return Promise.reject(e);
3883
+ }
3884
+ };
3885
+ _proto.getWithdrawCurrenciesListForPublicSwap = function getWithdrawCurrenciesListForPublicSwap() {
3886
+ try {
3887
+ var _this3 = this;
3888
+ return Promise.resolve(_catch(function () {
3889
+ return Promise.resolve(_this3._getCurrenciesListForPublicSwap(true));
3890
+ }, function (e) {
3891
+ improveAndRethrow(e, "getWithdrawCurrenciesListForPublicSwap");
3892
+ }));
3893
+ } catch (e) {
3894
+ return Promise.reject(e);
3895
+ }
3896
+ };
3897
+ _proto._getCurrenciesListForPublicSwap = function _getCurrenciesListForPublicSwap(withdraw) {
3898
+ if (withdraw === void 0) {
3899
+ withdraw = false;
3900
+ }
3901
+ try {
3902
+ var _this4 = this;
3879
3903
  var loggerSource = "getCurrenciesListForPublicSwap";
3880
3904
  return Promise.resolve(_catch(function () {
3881
- // TODO: [dev] this is temporary hack, change it to use dedicated lists inside UI and also here
3882
- return Promise.resolve(currencyThatShouldNotBeFirst ? _this2._swapProvider.getWithdrawalCurrencies(currencyThatShouldNotBeFirst) : _this2._swapProvider.getDepositCurrencies()).then(function (result) {
3905
+ return Promise.resolve(withdraw ? _this4._swapProvider.getWithdrawalCurrencies() : _this4._swapProvider.getDepositCurrencies()).then(function (result) {
3883
3906
  var _result$coins;
3884
3907
  if (result.reason === SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED) {
3885
3908
  SwapUtils.safeHandleRequestsLimitExceeding();
@@ -3926,9 +3949,9 @@ var PublicSwapService = /*#__PURE__*/function () {
3926
3949
  ;
3927
3950
  _proto.getInitialPublicSwapData = function getInitialPublicSwapData(fromCoin, toCoin) {
3928
3951
  try {
3929
- var _this3 = this;
3952
+ var _this5 = this;
3930
3953
  return Promise.resolve(_catch(function () {
3931
- return Promise.resolve(SwapUtils.getInitialSwapData(_this3._swapProvider, fromCoin, toCoin)).then(function (result) {
3954
+ return Promise.resolve(SwapUtils.getInitialSwapData(_this5._swapProvider, fromCoin, toCoin)).then(function (result) {
3932
3955
  if (!result.result) {
3933
3956
  if (result.reason === SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED) {
3934
3957
  SwapUtils.safeHandleRequestsLimitExceeding();
@@ -3975,13 +3998,13 @@ var PublicSwapService = /*#__PURE__*/function () {
3975
3998
  ;
3976
3999
  _proto.getPublicSwapDetails = function getPublicSwapDetails(fromCoin, toCoin, fromAmountCoins) {
3977
4000
  try {
3978
- var _this4 = this;
4001
+ var _this6 = this;
3979
4002
  var loggerSource = "getPublicSwapDetails";
3980
4003
  return Promise.resolve(_catch(function () {
3981
- return Promise.resolve(_this4._swapProvider.getCoinToUSDTRate(fromCoin)).then(function (_this4$_swapProvider$) {
3982
- var _this4$_swapProvider$2;
3983
- var coinUsdtRate = (_this4$_swapProvider$2 = _this4$_swapProvider$ == null ? void 0 : _this4$_swapProvider$.rate) != null ? _this4$_swapProvider$2 : null;
3984
- return Promise.resolve(_this4._swapProvider.getSwapInfo(fromCoin, toCoin, fromAmountCoins, coinUsdtRate)).then(function (details) {
4004
+ return Promise.resolve(_this6._swapProvider.getCoinToUSDTRate(fromCoin)).then(function (_this6$_swapProvider$) {
4005
+ var _this6$_swapProvider$2;
4006
+ var coinUsdtRate = (_this6$_swapProvider$2 = _this6$_swapProvider$ == null ? void 0 : _this6$_swapProvider$.rate) != null ? _this6$_swapProvider$2 : null;
4007
+ return Promise.resolve(_this6._swapProvider.getSwapInfo(fromCoin, toCoin, fromAmountCoins, coinUsdtRate)).then(function (details) {
3985
4008
  var _result$swapCreationI, _result$swapCreationI2;
3986
4009
  var min = details.result ? details.min : details.smallestMin;
3987
4010
  var max = details.result ? details.max : details.greatestMax;
@@ -4073,7 +4096,7 @@ var PublicSwapService = /*#__PURE__*/function () {
4073
4096
  ;
4074
4097
  _proto.createPublicSwap = function createPublicSwap(fromCoin, toCoin, fromAmount, swapCreationInfo, toAddress, refundAddress, clientIp) {
4075
4098
  try {
4076
- var _this5 = this;
4099
+ var _this7 = this;
4077
4100
  var loggerSource = "createPublicSwap";
4078
4101
  return Promise.resolve(_catch(function () {
4079
4102
  var _swapCreationInfo$fro, _swapCreationInfo$toC;
@@ -4084,10 +4107,10 @@ var PublicSwapService = /*#__PURE__*/function () {
4084
4107
  fromCoin: swapCreationInfo == null || (_swapCreationInfo$fro = swapCreationInfo.fromCoin) == null ? void 0 : _swapCreationInfo$fro.ticker,
4085
4108
  toCoin: swapCreationInfo == null || (_swapCreationInfo$toC = swapCreationInfo.toCoin) == null ? void 0 : _swapCreationInfo$toC.ticker
4086
4109
  })), loggerSource);
4087
- return Promise.resolve(_this5._swapProvider.createSwap(fromCoin, toCoin, fromAmount, toAddress, refundAddress, swapCreationInfo.rawSwapData, clientIp)).then(function (result) {
4110
+ return Promise.resolve(_this7._swapProvider.createSwap(fromCoin, toCoin, fromAmount, toAddress, refundAddress, swapCreationInfo.rawSwapData, clientIp)).then(function (result) {
4088
4111
  var _exit;
4089
- function _temp5(_result5) {
4090
- if (_exit) return _result5;
4112
+ function _temp5(_result7) {
4113
+ if (_exit) return _result7;
4091
4114
  throw new Error("Unexpected result from provider " + safeStringify(result));
4092
4115
  }
4093
4116
  Logger.log("Created:" + safeStringify(_extends({}, result, {
@@ -4129,7 +4152,7 @@ var PublicSwapService = /*#__PURE__*/function () {
4129
4152
  durationMinutesRange: swapCreationInfo.durationMinutesRange,
4130
4153
  address: result.fromAddress // CRITICAL: this is the address to send coins to swaps provider
4131
4154
  };
4132
- _this5._savePublicSwapIdLocally(result.swapId);
4155
+ _this7._savePublicSwapIdLocally(result.swapId);
4133
4156
  Logger.log("Returning: " + safeStringify(_extends({}, toReturn, {
4134
4157
  fromCoin: fromCoin == null ? void 0 : fromCoin.ticker,
4135
4158
  toCoin: toCoin == null ? void 0 : toCoin.ticker
@@ -4140,12 +4163,12 @@ var PublicSwapService = /*#__PURE__*/function () {
4140
4163
  var _fromAmountFiat = null,
4141
4164
  _toAmountFiat = null;
4142
4165
  var _temp2 = _catch(function () {
4143
- return Promise.resolve(_this5._swapProvider.getCoinToUSDTRate(fromCoin)).then(function (_this5$_swapProvider$) {
4144
- var _this5$_swapProvider$3;
4145
- var fromCoinUsdtRate = (_this5$_swapProvider$3 = _this5$_swapProvider$ == null ? void 0 : _this5$_swapProvider$.rate) != null ? _this5$_swapProvider$3 : null;
4146
- return Promise.resolve(_this5._swapProvider.getCoinToUSDTRate(fromCoin)).then(function (_this5$_swapProvider$2) {
4147
- var _this5$_swapProvider$4;
4148
- var toCoinUsdtRate = (_this5$_swapProvider$4 = _this5$_swapProvider$2 == null ? void 0 : _this5$_swapProvider$2.rate) != null ? _this5$_swapProvider$4 : null;
4166
+ return Promise.resolve(_this7._swapProvider.getCoinToUSDTRate(fromCoin)).then(function (_this7$_swapProvider$) {
4167
+ var _this7$_swapProvider$3;
4168
+ var fromCoinUsdtRate = (_this7$_swapProvider$3 = _this7$_swapProvider$ == null ? void 0 : _this7$_swapProvider$.rate) != null ? _this7$_swapProvider$3 : null;
4169
+ return Promise.resolve(_this7._swapProvider.getCoinToUSDTRate(fromCoin)).then(function (_this7$_swapProvider$2) {
4170
+ var _this7$_swapProvider$4;
4171
+ var toCoinUsdtRate = (_this7$_swapProvider$4 = _this7$_swapProvider$2 == null ? void 0 : _this7$_swapProvider$2.rate) != null ? _this7$_swapProvider$4 : null;
4149
4172
  if (fromCoinUsdtRate != null && result.fromAmount != null) {
4150
4173
  _fromAmountFiat = bignumber_js.BigNumber(result.fromAmount).times(fromCoinUsdtRate).toFixed(PublicSwapService._fiatDecimalsCount);
4151
4174
  }
@@ -4185,10 +4208,10 @@ var PublicSwapService = /*#__PURE__*/function () {
4185
4208
  ;
4186
4209
  _proto.getPublicExistingSwapDetailsAndStatus = function getPublicExistingSwapDetailsAndStatus(swapIds) {
4187
4210
  try {
4188
- var _this6 = this;
4211
+ var _this8 = this;
4189
4212
  var loggerSource = "getPublicExistingSwapDetailsAndStatus";
4190
4213
  return Promise.resolve(_catch(function () {
4191
- return Promise.resolve(SwapUtils.getExistingSwapsDetailsWithFiatAmounts(_this6._swapProvider, swapIds)).then(function (result) {
4214
+ return Promise.resolve(SwapUtils.getExistingSwapsDetailsWithFiatAmounts(_this8._swapProvider, swapIds)).then(function (result) {
4192
4215
  if (!(result != null && result.result)) {
4193
4216
  if (result.reason === SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED) {
4194
4217
  SwapUtils.safeHandleRequestsLimitExceeding();
@@ -4223,20 +4246,20 @@ var PublicSwapService = /*#__PURE__*/function () {
4223
4246
  _proto.getPublicSwapsHistory = function getPublicSwapsHistory() {
4224
4247
  try {
4225
4248
  var _exit2;
4226
- var _this7 = this;
4249
+ var _this9 = this;
4227
4250
  return Promise.resolve(_catch(function () {
4228
- function _temp7(_result7) {
4229
- return _exit2 ? _result7 : {
4251
+ function _temp7(_result9) {
4252
+ return _exit2 ? _result9 : {
4230
4253
  result: true,
4231
4254
  swaps: []
4232
4255
  };
4233
4256
  }
4234
- var swapIds = _this7._getPublicSwapIdsSavedLocally();
4257
+ var swapIds = _this9._getPublicSwapIdsSavedLocally();
4235
4258
  var _temp6 = function () {
4236
4259
  if (swapIds.length) {
4237
- return Promise.resolve(_this7.getPublicExistingSwapDetailsAndStatus(swapIds)).then(function (_await$_this7$getPubl) {
4260
+ return Promise.resolve(_this9.getPublicExistingSwapDetailsAndStatus(swapIds)).then(function (_await$_this9$getPubl) {
4238
4261
  _exit2 = 1;
4239
- return _await$_this7$getPubl;
4262
+ return _await$_this9$getPubl;
4240
4263
  });
4241
4264
  }
4242
4265
  }();
@@ -4304,9 +4327,9 @@ var PublicSwapService = /*#__PURE__*/function () {
4304
4327
  */;
4305
4328
  _proto.getAssetToUsdtRate = function getAssetToUsdtRate(asset) {
4306
4329
  try {
4307
- var _this8 = this;
4330
+ var _this10 = this;
4308
4331
  return Promise.resolve(_catch(function () {
4309
- return Promise.resolve(_this8._swapProvider.getCoinToUSDTRate(asset)).then(function (result) {
4332
+ return Promise.resolve(_this10._swapProvider.getCoinToUSDTRate(asset)).then(function (result) {
4310
4333
  var _result$rate;
4311
4334
  return (_result$rate = result == null ? void 0 : result.rate) != null ? _result$rate : null;
4312
4335
  });