@rabbitio/ui-kit 1.0.0-beta.23 → 1.0.0-beta.24

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.
@@ -2727,11 +2727,25 @@ var SwapProvider = /*#__PURE__*/function () {
2727
2727
  }
2728
2728
 
2729
2729
  /**
2730
- * Retrieves all deposit currencies supported by this swap provider.
2730
+ * Retrieves all currencies supported by this swap provider.
2731
2731
  * Returns one of SwapProvider.COMMON_ERRORS in case of processable fail.
2732
2732
  *
2733
2733
  * @return {Promise<({ result: true, coins: Coin[] }|{ result: false, reason: string })>}
2734
2734
  */;
2735
+ _proto.getAllSupportedCurrencies = function getAllSupportedCurrencies() {
2736
+ try {
2737
+ throw new Error("Not implemented in base");
2738
+ } catch (e) {
2739
+ return Promise.reject(e);
2740
+ }
2741
+ }
2742
+ /**
2743
+ * Retrieves all deposit currencies supported by this swap provider.
2744
+ * Returns one of SwapProvider.COMMON_ERRORS in case of processable fail.
2745
+ *
2746
+ * @return {Promise<({ result: true, coins: Coin[] }|{ result: false, reason: string })>}
2747
+ */
2748
+ ;
2735
2749
  _proto.getDepositCurrencies = function getDepositCurrencies() {
2736
2750
  try {
2737
2751
  throw new Error("Not implemented in base");
@@ -2783,6 +2797,7 @@ var SwapProvider = /*#__PURE__*/function () {
2783
2797
  * null min or max signals there is no corresponding limitation. undefined means that the limits were not retrieved.
2784
2798
  * For fail result on of SwapProvider.NO_SWAPS_REASONS or SwapProvider.COMMON_ERRORS reasons will be returned.
2785
2799
  *
2800
+ * WARNING: MUST return NOT_SUPPORTED error code for any case when pair is not available/supported (Should not throw random errors for this case)
2786
2801
  * @param fromCoin {Coin}
2787
2802
  * @param toCoin {Coin}
2788
2803
  * @param amountCoins {string}
@@ -2979,20 +2994,49 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
2979
2994
  return Promise.reject(e);
2980
2995
  }
2981
2996
  };
2997
+ _proto.getAllSupportedCurrencies = function getAllSupportedCurrencies() {
2998
+ try {
2999
+ var _this3 = this;
3000
+ var loggerSource = "getAllSupportedCurrencies";
3001
+ return Promise.resolve(_catch$2(function () {
3002
+ return Promise.resolve(_this3._fetchSupportedCurrenciesIfNeeded()).then(function () {
3003
+ var _this3$_supportedCoin;
3004
+ Logger.log("We have " + ((_this3$_supportedCoin = _this3._supportedCoins) == null ? void 0 : _this3$_supportedCoin.length) + " supported coins returning", loggerSource);
3005
+ return {
3006
+ result: true,
3007
+ coins: _this3._supportedCoins.map(function (item) {
3008
+ return item.coin;
3009
+ })
3010
+ };
3011
+ });
3012
+ }, function (e) {
3013
+ var _e$response2;
3014
+ if ((e == null || (_e$response2 = e.response) == null ? void 0 : _e$response2.status) === 429) {
3015
+ return {
3016
+ result: false,
3017
+ reason: SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED
3018
+ };
3019
+ }
3020
+ improveAndRethrow(e, loggerSource);
3021
+ }));
3022
+ } catch (e) {
3023
+ return Promise.reject(e);
3024
+ }
3025
+ };
2982
3026
  _proto.getWithdrawalCurrencies = function getWithdrawalCurrencies(exceptCurrency) {
2983
3027
  if (exceptCurrency === void 0) {
2984
3028
  exceptCurrency = null;
2985
3029
  }
2986
3030
  try {
2987
- var _this3 = this;
3031
+ var _this4 = this;
2988
3032
  var loggerSource = "getWithdrawalCurrencies";
2989
3033
  return Promise.resolve(_catch$2(function () {
2990
- return Promise.resolve(_this3._fetchSupportedCurrenciesIfNeeded()).then(function () {
2991
- var _this3$_supportedCoin;
2992
- Logger.log("We have " + ((_this3$_supportedCoin = _this3._supportedCoins) == null ? void 0 : _this3$_supportedCoin.length) + " supported coins, getting withdrawable", loggerSource);
3034
+ return Promise.resolve(_this4._fetchSupportedCurrenciesIfNeeded()).then(function () {
3035
+ var _this4$_supportedCoin;
3036
+ Logger.log("We have " + ((_this4$_supportedCoin = _this4._supportedCoins) == null ? void 0 : _this4$_supportedCoin.length) + " supported coins, getting withdrawable", loggerSource);
2993
3037
  return {
2994
3038
  result: true,
2995
- coins: _this3._supportedCoins.filter(function (item) {
3039
+ coins: _this4._supportedCoins.filter(function (item) {
2996
3040
  var _item$coin, _exceptCurrency;
2997
3041
  return item.withdrawal && (!exceptCurrency || ((_item$coin = item.coin) == null ? void 0 : _item$coin.ticker) !== ((_exceptCurrency = exceptCurrency) == null ? void 0 : _exceptCurrency.ticker));
2998
3042
  }).map(function (item) {
@@ -3001,8 +3045,8 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
3001
3045
  };
3002
3046
  });
3003
3047
  }, function (e) {
3004
- var _e$response2;
3005
- if ((e == null || (_e$response2 = e.response) == null ? void 0 : _e$response2.status) === 429) {
3048
+ var _e$response3;
3049
+ if ((e == null || (_e$response3 = e.response) == null ? void 0 : _e$response3.status) === 429) {
3006
3050
  return {
3007
3051
  result: false,
3008
3052
  reason: SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED
@@ -3016,8 +3060,8 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
3016
3060
  };
3017
3061
  _proto.initialize = function initialize() {
3018
3062
  try {
3019
- var _this4 = this;
3020
- return Promise.resolve(_this4._fetchSupportedCurrenciesIfNeeded()).then(function () {});
3063
+ var _this5 = this;
3064
+ return Promise.resolve(_this5._fetchSupportedCurrenciesIfNeeded()).then(function () {});
3021
3065
  } catch (e) {
3022
3066
  return Promise.reject(e);
3023
3067
  }
@@ -3043,17 +3087,17 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
3043
3087
  };
3044
3088
  _proto._fetchSupportedCurrenciesIfNeeded = function _fetchSupportedCurrenciesIfNeeded() {
3045
3089
  try {
3046
- var _this5 = this;
3090
+ var _this6 = this;
3047
3091
  var loggerSource = "_fetchSupportedCurrenciesIfNeeded";
3048
3092
  return Promise.resolve(_catch$2(function () {
3049
- var _temp = function (_this5$_supportedCoin) {
3050
- if (!((_this5$_supportedCoin = _this5._supportedCoins) != null && _this5$_supportedCoin.length)) {
3051
- return Promise.resolve(axios.get(_this5._URL + "/api/v2/currencies")).then(function (rawResponse) {
3093
+ var _temp = function (_this6$_supportedCoin) {
3094
+ if (!((_this6$_supportedCoin = _this6._supportedCoins) != null && _this6$_supportedCoin.length)) {
3095
+ return Promise.resolve(axios.get(_this6._URL + "/api/v2/currencies")).then(function (rawResponse) {
3052
3096
  var _rawResponse$data, _rawResponse$data2;
3053
3097
  Logger.log("Retrieved " + (rawResponse == null || (_rawResponse$data = rawResponse.data) == null ? void 0 : _rawResponse$data.length) + " currencies", loggerSource);
3054
- _this5._supportedCoins = ((_rawResponse$data2 = rawResponse == null ? void 0 : rawResponse.data) != null ? _rawResponse$data2 : []).map(function (item) {
3055
- var coin = _this5._customCoinBuilder(item.code, item.network);
3056
- if (!coin && !_this5.useRestrictedCoinsSet) {
3098
+ _this6._supportedCoins = ((_rawResponse$data2 = rawResponse == null ? void 0 : rawResponse.data) != null ? _rawResponse$data2 : []).map(function (item) {
3099
+ var coin = _this6._customCoinBuilder(item.code, item.network);
3100
+ if (!coin && !_this6.useRestrictedCoinsSet) {
3057
3101
  /** Building coin object for coin that isn't supported OOB in Rabbit.
3058
3102
  * We are doing this way to be able to use extended coins set for swaps.
3059
3103
  * These temporary built coins are only for in-swap use, and we omit some usual
@@ -3089,7 +3133,7 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
3089
3133
  }
3090
3134
  return [];
3091
3135
  }).flat();
3092
- _this5._putPopularCoinsFirst();
3136
+ _this6._putPopularCoinsFirst();
3093
3137
  });
3094
3138
  }
3095
3139
  }();
@@ -3116,21 +3160,21 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
3116
3160
  };
3117
3161
  _proto.getCoinToUSDTRate = function getCoinToUSDTRate(coin) {
3118
3162
  try {
3119
- var _this6 = this;
3163
+ var _this7 = this;
3120
3164
  var loggerSource = "getCoinToUSDTRate";
3121
3165
  return Promise.resolve(_catch$2(function () {
3122
- return coin ? Promise.resolve(_this6._fetchSupportedCurrenciesIfNeeded()).then(function () {
3123
- var _this6$_supportedCoin;
3166
+ return coin ? Promise.resolve(_this7._fetchSupportedCurrenciesIfNeeded()).then(function () {
3167
+ var _this7$_supportedCoin;
3124
3168
  // Using USDT TRC20 as usually fee in this network is smaller than ERC20 and this network is widely used for USDT
3125
- var usdtTrc20 = (_this6$_supportedCoin = _this6._supportedCoins.find(function (i) {
3169
+ var usdtTrc20 = (_this7$_supportedCoin = _this7._supportedCoins.find(function (i) {
3126
3170
  return i.coin.ticker === "USDTTRC20";
3127
- })) == null ? void 0 : _this6$_supportedCoin.coin;
3171
+ })) == null ? void 0 : _this7$_supportedCoin.coin;
3128
3172
  if (!usdtTrc20) {
3129
3173
  return {
3130
3174
  result: false
3131
3175
  };
3132
3176
  }
3133
- var cached = _this6._cache.get("swapspace_usdt_rate_" + coin.ticker);
3177
+ var cached = _this7._cache.get("swapspace_usdt_rate_" + coin.ticker);
3134
3178
  if (cached != null) {
3135
3179
  return {
3136
3180
  result: true,
@@ -3138,7 +3182,7 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
3138
3182
  };
3139
3183
  }
3140
3184
  Logger.log("Loading USDT->coin rate as not found in cache:", coin == null ? void 0 : coin.ticker);
3141
- return Promise.resolve(_this6.getSwapInfo(usdtTrc20, coin, "5000")).then(function (result) {
3185
+ return Promise.resolve(_this7.getSwapInfo(usdtTrc20, coin, "5000")).then(function (result) {
3142
3186
  if (!result.result) {
3143
3187
  return {
3144
3188
  result: false
@@ -3148,7 +3192,7 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
3148
3192
  // This calculation is not precise as we cannot recognize the actual fee and network fee. Just approximate.
3149
3193
  var standardSwapspaceFeeMultiplier = 1.002; // usually 0.2%
3150
3194
  var rate = BigNumber(1).div(BigNumber(result.rate).times(standardSwapspaceFeeMultiplier)).toString();
3151
- _this6._cache.put("swapspace_usdt_rate_" + coin.ticker, rate, 15 * 60000 // 15 minutes
3195
+ _this7._cache.put("swapspace_usdt_rate_" + coin.ticker, rate, 15 * 60000 // 15 minutes
3152
3196
  );
3153
3197
  return {
3154
3198
  result: true,
@@ -3179,17 +3223,17 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
3179
3223
  fromCoinToUsdRate = null;
3180
3224
  }
3181
3225
  try {
3182
- var _this7 = this;
3226
+ var _this8 = this;
3183
3227
  var loggerSource = "getSwapInfo";
3184
3228
  return Promise.resolve(_catch$2(function () {
3185
3229
  if (!(fromCoin instanceof Coin) || !(toCoin instanceof Coin) || typeof amountCoins !== "string" || BigNumber(amountCoins).lt("0")) {
3186
3230
  throw new Error("Wrong input params: " + amountCoins + " " + fromCoin.ticker + " -> " + toCoin.ticker + (fromCoin instanceof Coin) + (toCoin instanceof Coin));
3187
3231
  }
3188
- var fromCoinSwapspaceDetails = _this7._supportedCoins.find(function (i) {
3232
+ var fromCoinSwapspaceDetails = _this8._supportedCoins.find(function (i) {
3189
3233
  var _i$coin;
3190
3234
  return ((_i$coin = i.coin) == null ? void 0 : _i$coin.ticker) === (fromCoin == null ? void 0 : fromCoin.ticker);
3191
3235
  });
3192
- var toCoinSwapspaceDetails = _this7._supportedCoins.find(function (i) {
3236
+ var toCoinSwapspaceDetails = _this8._supportedCoins.find(function (i) {
3193
3237
  var _i$coin2;
3194
3238
  return ((_i$coin2 = i.coin) == null ? void 0 : _i$coin2.ticker) === (toCoin == null ? void 0 : toCoin.ticker);
3195
3239
  });
@@ -3199,7 +3243,7 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
3199
3243
  return !fromCoinSwapspaceDetails.deposit || !toCoinSwapspaceDetails.withdrawal ? {
3200
3244
  result: false,
3201
3245
  reason: SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED
3202
- } : Promise.resolve(axios.get(_this7._URL + "/api/v2/amounts?fromCurrency=" + fromCoinSwapspaceDetails.code + "&fromNetwork=" + fromCoinSwapspaceDetails.network + "&toNetwork=" + toCoinSwapspaceDetails.network + "&toCurrency=" + toCoinSwapspaceDetails.code + "&amount=" + amountCoins + "&float=true&estimated=false")).then(function (response) {
3246
+ } : Promise.resolve(axios.get(_this8._URL + "/api/v2/amounts?fromCurrency=" + fromCoinSwapspaceDetails.code + "&fromNetwork=" + fromCoinSwapspaceDetails.network + "&toNetwork=" + toCoinSwapspaceDetails.network + "&toCurrency=" + toCoinSwapspaceDetails.code + "&amount=" + amountCoins + "&float=true&estimated=false")).then(function (response) {
3203
3247
  var _response$data;
3204
3248
  Logger.log("Retrieved " + (response == null || (_response$data = response.data) == null ? void 0 : _response$data.length) + " options", loggerSource);
3205
3249
  var options = Array.isArray(response.data) ? response.data : [];
@@ -3278,7 +3322,7 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
3278
3322
  max: max,
3279
3323
  smallestMin: smallestMin,
3280
3324
  greatestMax: greatestMax,
3281
- rate: rate != null ? AmountUtils.trim(rate, _this7._maxRateDigits) : null,
3325
+ rate: rate != null ? AmountUtils.trim(rate, _this8._maxRateDigits) : null,
3282
3326
  durationMinutesRange: (_bestOpt$duration = bestOpt.duration) != null ? _bestOpt$duration : null,
3283
3327
  rawSwapData: bestOpt
3284
3328
  };
@@ -3293,8 +3337,8 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
3293
3337
  return result;
3294
3338
  });
3295
3339
  }, function (e) {
3296
- var _e$response3;
3297
- if ((e == null || (_e$response3 = e.response) == null ? void 0 : _e$response3.status) === 429) {
3340
+ var _e$response4;
3341
+ if ((e == null || (_e$response4 = e.response) == null ? void 0 : _e$response4.status) === 429) {
3298
3342
  return {
3299
3343
  result: false,
3300
3344
  reason: SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED
@@ -3309,7 +3353,7 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
3309
3353
  };
3310
3354
  _proto.createSwap = function createSwap(fromCoin, toCoin, amount, toAddress, refundAddress, rawSwapData, clientIpAddress) {
3311
3355
  try {
3312
- var _this8 = this;
3356
+ var _this9 = this;
3313
3357
  var loggerSource = "createSwap";
3314
3358
  var partner = rawSwapData == null ? void 0 : rawSwapData.partner;
3315
3359
  return Promise.resolve(_catch$2(function () {
@@ -3320,12 +3364,12 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
3320
3364
  ) {
3321
3365
  throw new Error("Invalid raw swap data: " + safeStringify(rawSwapData));
3322
3366
  }
3323
- return Promise.resolve(_this8._fetchSupportedCurrenciesIfNeeded()).then(function () {
3324
- var _this8$_supportedCoin, _this8$_supportedCoin2;
3325
- var toCurrencyExtraId = (_this8$_supportedCoin = (_this8$_supportedCoin2 = _this8._supportedCoins.find(function (item) {
3367
+ return Promise.resolve(_this9._fetchSupportedCurrenciesIfNeeded()).then(function () {
3368
+ var _this9$_supportedCoin, _this9$_supportedCoin2;
3369
+ var toCurrencyExtraId = (_this9$_supportedCoin = (_this9$_supportedCoin2 = _this9._supportedCoins.find(function (item) {
3326
3370
  var _item$coin4;
3327
3371
  return ((_item$coin4 = item.coin) == null ? void 0 : _item$coin4.ticker) === (toCoin == null ? void 0 : toCoin.ticker);
3328
- })) == null ? void 0 : _this8$_supportedCoin2.extraId) != null ? _this8$_supportedCoin : "";
3372
+ })) == null ? void 0 : _this9$_supportedCoin2.extraId) != null ? _this9$_supportedCoin : "";
3329
3373
  var requestData = {
3330
3374
  partner: partner,
3331
3375
  fromCurrency: rawSwapData == null ? void 0 : rawSwapData.fromCurrency,
@@ -3341,7 +3385,7 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
3341
3385
  refund: refundAddress
3342
3386
  };
3343
3387
  Logger.log("Sending create request: " + safeStringify(requestData), loggerSource);
3344
- return Promise.resolve(axios.post(_this8._URL + "/api/v2/exchange", requestData)).then(function (response) {
3388
+ return Promise.resolve(axios.post(_this9._URL + "/api/v2/exchange", requestData)).then(function (response) {
3345
3389
  var result = response.data;
3346
3390
  Logger.log("Creation result " + safeStringify(result), loggerSource);
3347
3391
  if (result != null && result.id) {
@@ -3365,7 +3409,7 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
3365
3409
  toCoin: toCoin,
3366
3410
  toAmount: AmountUtils.trim(result == null || (_result$to4 = result.to) == null ? void 0 : _result$to4.amount, toCoin.digits),
3367
3411
  toAddress: result == null || (_result$to5 = result.to) == null ? void 0 : _result$to5.address,
3368
- rate: AmountUtils.trim(rate, _this8._maxRateDigits)
3412
+ rate: AmountUtils.trim(rate, _this9._maxRateDigits)
3369
3413
  };
3370
3414
  }
3371
3415
  var errorMessage = "Swap creation succeeded but the response is wrong: " + safeStringify(response);
@@ -3374,7 +3418,7 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
3374
3418
  });
3375
3419
  });
3376
3420
  }, function (e) {
3377
- var _e$response4, _e$response5;
3421
+ var _e$response5, _e$response6;
3378
3422
  Logger.logError(e, loggerSource, "Failed to create swap. Error is: " + safeStringify(e));
3379
3423
  var composeFailResult = function composeFailResult(reason) {
3380
3424
  return {
@@ -3383,8 +3427,8 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
3383
3427
  partner: partner
3384
3428
  };
3385
3429
  };
3386
- var status = e == null || (_e$response4 = e.response) == null ? void 0 : _e$response4.status;
3387
- var data = e == null || (_e$response5 = e.response) == null ? void 0 : _e$response5.data;
3430
+ var status = e == null || (_e$response5 = e.response) == null ? void 0 : _e$response5.status;
3431
+ var data = e == null || (_e$response6 = e.response) == null ? void 0 : _e$response6.data;
3388
3432
  if (status === 429) {
3389
3433
  Logger.log("Returning fail - RPS limit exceeded " + data, loggerSource);
3390
3434
  return composeFailResult(SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED);
@@ -3433,7 +3477,7 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
3433
3477
  };
3434
3478
  _proto.getExistingSwapsDetailsAndStatus = function getExistingSwapsDetailsAndStatus(swapIds) {
3435
3479
  try {
3436
- var _this9 = this;
3480
+ var _this10 = this;
3437
3481
  var loggerSource = "getExistingSwapsDetailsAndStatus";
3438
3482
  return Promise.resolve(_catch$2(function () {
3439
3483
  if (swapIds.find(function (id) {
@@ -3444,7 +3488,7 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
3444
3488
  var getNotFailingOn404 = function getNotFailingOn404(swapId) {
3445
3489
  try {
3446
3490
  return Promise.resolve(_catch$2(function () {
3447
- return Promise.resolve(axios.get(_this9._URL + "/api/v2/exchange/" + swapId));
3491
+ return Promise.resolve(axios.get(_this10._URL + "/api/v2/exchange/" + swapId));
3448
3492
  }, function (error) {
3449
3493
  var _error$response;
3450
3494
  if ((error == null || (_error$response = error.response) == null ? void 0 : _error$response.status) === 404) return [];
@@ -3461,13 +3505,13 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
3461
3505
  var swaps = wo404.map(function (r) {
3462
3506
  return r.data;
3463
3507
  }).map(function (swap, index) {
3464
- var _this9$_supportedCoin, _this9$_supportedCoin2;
3465
- var fromCoin = (_this9$_supportedCoin = _this9._supportedCoins.find(function (i) {
3508
+ var _this10$_supportedCoi, _this10$_supportedCoi2;
3509
+ var fromCoin = (_this10$_supportedCoi = _this10._supportedCoins.find(function (i) {
3466
3510
  return i.code === swap.from.code && i.network === swap.from.network;
3467
- })) == null ? void 0 : _this9$_supportedCoin.coin;
3468
- var toCoin = (_this9$_supportedCoin2 = _this9._supportedCoins.find(function (i) {
3511
+ })) == null ? void 0 : _this10$_supportedCoi.coin;
3512
+ var toCoin = (_this10$_supportedCoi2 = _this10._supportedCoins.find(function (i) {
3469
3513
  return i.code === swap.to.code && i.network === swap.to.network;
3470
- })) == null ? void 0 : _this9$_supportedCoin2.coin;
3514
+ })) == null ? void 0 : _this10$_supportedCoi2.coin;
3471
3515
  if (!fromCoin || !toCoin) {
3472
3516
  return []; // We skip swaps with not supported coins for now
3473
3517
  }
@@ -3476,10 +3520,10 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
3476
3520
  };
3477
3521
  var expiresAt = toUtcTimestamp(swap.timestamps.expiresAt);
3478
3522
  var isExpiredByTime = expiresAt < Date.now();
3479
- var status = _this9._mapSwapspaceStatusToRabbitStatus(swap.status, isExpiredByTime);
3523
+ var status = _this10._mapSwapspaceStatusToRabbitStatus(swap.status, isExpiredByTime);
3480
3524
  var toDigits = status === SwapProvider.SWAP_STATUSES.REFUNDED ? fromCoin.digits : toCoin.digits;
3481
3525
  var addressToSendCoinsToSwapspace = swap.from.address;
3482
- return new ExistingSwap(swapIds[index], status, toUtcTimestamp(swap.timestamps.createdAt), expiresAt, swap.confirmations, AmountUtils.trim(swap.rate, _this9._maxRateDigits), swap.refundAddress, addressToSendCoinsToSwapspace, fromCoin, AmountUtils.trim(swap.from.amount, fromCoin.digits), swap.from.transactionHash, swap.blockExplorerTransactionUrl.from, toCoin, AmountUtils.trim(swap.to.amount, toDigits), swap.to.transactionHash, swap.blockExplorerTransactionUrl.to, swap.to.address, swap.partner);
3526
+ return new ExistingSwap(swapIds[index], status, toUtcTimestamp(swap.timestamps.createdAt), expiresAt, swap.confirmations, AmountUtils.trim(swap.rate, _this10._maxRateDigits), swap.refundAddress, addressToSendCoinsToSwapspace, fromCoin, AmountUtils.trim(swap.from.amount, fromCoin.digits), swap.from.transactionHash, swap.blockExplorerTransactionUrl.from, toCoin, AmountUtils.trim(swap.to.amount, toDigits), swap.to.transactionHash, swap.blockExplorerTransactionUrl.to, swap.to.address, swap.partner);
3483
3527
  }).flat();
3484
3528
  Logger.log("Swap details result " + safeStringify(swaps), loggerSource);
3485
3529
  return {
@@ -3488,7 +3532,7 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
3488
3532
  };
3489
3533
  });
3490
3534
  }, function (e) {
3491
- var _e$response6, _e$response7;
3535
+ var _e$response7, _e$response8;
3492
3536
  Logger.logError(e, loggerSource, "Failed to get swap details. Error is: " + safeStringify(e));
3493
3537
  var composeFailResult = function composeFailResult(reason) {
3494
3538
  return {
@@ -3496,8 +3540,8 @@ var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
3496
3540
  reason: reason
3497
3541
  };
3498
3542
  };
3499
- var status = e == null || (_e$response6 = e.response) == null ? void 0 : _e$response6.status;
3500
- var data = e == null || (_e$response7 = e.response) == null ? void 0 : _e$response7.data;
3543
+ var status = e == null || (_e$response7 = e.response) == null ? void 0 : _e$response7.status;
3544
+ var data = e == null || (_e$response8 = e.response) == null ? void 0 : _e$response8.data;
3501
3545
  if (status === 429) {
3502
3546
  Logger.log("Returning fail - RPS limit exceeded " + data, loggerSource);
3503
3547
  return composeFailResult(SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED);
@@ -3875,11 +3919,26 @@ var PublicSwapService = /*#__PURE__*/function () {
3875
3919
  return Promise.reject(e);
3876
3920
  }
3877
3921
  };
3878
- _proto.getDepositCurrenciesListForPublicSwap = function getDepositCurrenciesListForPublicSwap() {
3922
+ _proto.getAllSupportedCurrenciesListForPublicSwap = function getAllSupportedCurrenciesListForPublicSwap() {
3879
3923
  try {
3880
3924
  var _this2 = this;
3925
+ var loggerSource = "getAllSupportedCurrenciesListForPublicSwap";
3881
3926
  return Promise.resolve(_catch(function () {
3882
- return Promise.resolve(_this2._getCurrenciesListForPublicSwap(false));
3927
+ return Promise.resolve(_this2._swapProvider.getAllSupportedCurrencies()).then(function (result) {
3928
+ var _result$coins;
3929
+ if (result.reason === SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED) {
3930
+ SwapUtils.safeHandleRequestsLimitExceeding();
3931
+ return {
3932
+ result: false,
3933
+ reason: PublicSwapService.PUBLIC_SWAPS_COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED
3934
+ };
3935
+ }
3936
+ Logger.log("Retrieved " + (result == null || (_result$coins = result.coins) == null ? void 0 : _result$coins.length) + " supported currencies for swap", loggerSource);
3937
+ return {
3938
+ result: true,
3939
+ coins: result.coins
3940
+ };
3941
+ });
3883
3942
  }, function (e) {
3884
3943
  improveAndRethrow(e, "getDepositCurrenciesListForPublicSwap");
3885
3944
  }));
@@ -3887,11 +3946,23 @@ var PublicSwapService = /*#__PURE__*/function () {
3887
3946
  return Promise.reject(e);
3888
3947
  }
3889
3948
  };
3890
- _proto.getWithdrawCurrenciesListForPublicSwap = function getWithdrawCurrenciesListForPublicSwap() {
3949
+ _proto.getDepositCurrenciesListForPublicSwap = function getDepositCurrenciesListForPublicSwap() {
3891
3950
  try {
3892
3951
  var _this3 = this;
3893
3952
  return Promise.resolve(_catch(function () {
3894
- return Promise.resolve(_this3._getCurrenciesListForPublicSwap(true));
3953
+ return Promise.resolve(_this3._getCurrenciesListForPublicSwap(false));
3954
+ }, function (e) {
3955
+ improveAndRethrow(e, "getDepositCurrenciesListForPublicSwap");
3956
+ }));
3957
+ } catch (e) {
3958
+ return Promise.reject(e);
3959
+ }
3960
+ };
3961
+ _proto.getWithdrawCurrenciesListForPublicSwap = function getWithdrawCurrenciesListForPublicSwap() {
3962
+ try {
3963
+ var _this4 = this;
3964
+ return Promise.resolve(_catch(function () {
3965
+ return Promise.resolve(_this4._getCurrenciesListForPublicSwap(true));
3895
3966
  }, function (e) {
3896
3967
  improveAndRethrow(e, "getWithdrawCurrenciesListForPublicSwap");
3897
3968
  }));
@@ -3904,11 +3975,11 @@ var PublicSwapService = /*#__PURE__*/function () {
3904
3975
  withdraw = false;
3905
3976
  }
3906
3977
  try {
3907
- var _this4 = this;
3978
+ var _this5 = this;
3908
3979
  var loggerSource = "getCurrenciesListForPublicSwap";
3909
3980
  return Promise.resolve(_catch(function () {
3910
- return Promise.resolve(withdraw ? _this4._swapProvider.getWithdrawalCurrencies() : _this4._swapProvider.getDepositCurrencies()).then(function (result) {
3911
- var _result$coins;
3981
+ return Promise.resolve(withdraw ? _this5._swapProvider.getWithdrawalCurrencies() : _this5._swapProvider.getDepositCurrencies()).then(function (result) {
3982
+ var _result$coins2;
3912
3983
  if (result.reason === SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED) {
3913
3984
  SwapUtils.safeHandleRequestsLimitExceeding();
3914
3985
  return {
@@ -3916,12 +3987,7 @@ var PublicSwapService = /*#__PURE__*/function () {
3916
3987
  reason: PublicSwapService.PUBLIC_SWAPS_COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED
3917
3988
  };
3918
3989
  }
3919
- Logger.log("Retrieved " + (result == null || (_result$coins = result.coins) == null ? void 0 : _result$coins.length) + " supported currencies for swap", loggerSource);
3920
- if (result.coins.length > 1) {
3921
- var temp = result.coins[0];
3922
- result.coins[0] = result.coins[1];
3923
- result.coins[1] = temp;
3924
- }
3990
+ Logger.log("Retrieved " + (result == null || (_result$coins2 = result.coins) == null ? void 0 : _result$coins2.length) + " supported currencies for swap", loggerSource);
3925
3991
  return {
3926
3992
  result: true,
3927
3993
  coins: result.coins
@@ -3954,9 +4020,9 @@ var PublicSwapService = /*#__PURE__*/function () {
3954
4020
  ;
3955
4021
  _proto.getInitialPublicSwapData = function getInitialPublicSwapData(fromCoin, toCoin) {
3956
4022
  try {
3957
- var _this5 = this;
4023
+ var _this6 = this;
3958
4024
  return Promise.resolve(_catch(function () {
3959
- return Promise.resolve(SwapUtils.getInitialSwapData(_this5._swapProvider, fromCoin, toCoin)).then(function (result) {
4025
+ return Promise.resolve(SwapUtils.getInitialSwapData(_this6._swapProvider, fromCoin, toCoin)).then(function (result) {
3960
4026
  if (!result.result) {
3961
4027
  if (result.reason === SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED) {
3962
4028
  SwapUtils.safeHandleRequestsLimitExceeding();
@@ -4003,13 +4069,13 @@ var PublicSwapService = /*#__PURE__*/function () {
4003
4069
  ;
4004
4070
  _proto.getPublicSwapDetails = function getPublicSwapDetails(fromCoin, toCoin, fromAmountCoins) {
4005
4071
  try {
4006
- var _this6 = this;
4072
+ var _this7 = this;
4007
4073
  var loggerSource = "getPublicSwapDetails";
4008
4074
  return Promise.resolve(_catch(function () {
4009
- return Promise.resolve(_this6._swapProvider.getCoinToUSDTRate(fromCoin)).then(function (_this6$_swapProvider$) {
4010
- var _this6$_swapProvider$2;
4011
- var coinUsdtRate = (_this6$_swapProvider$2 = _this6$_swapProvider$ == null ? void 0 : _this6$_swapProvider$.rate) != null ? _this6$_swapProvider$2 : null;
4012
- return Promise.resolve(_this6._swapProvider.getSwapInfo(fromCoin, toCoin, fromAmountCoins, coinUsdtRate)).then(function (details) {
4075
+ return Promise.resolve(_this7._swapProvider.getCoinToUSDTRate(fromCoin)).then(function (_this7$_swapProvider$) {
4076
+ var _this7$_swapProvider$2;
4077
+ var coinUsdtRate = (_this7$_swapProvider$2 = _this7$_swapProvider$ == null ? void 0 : _this7$_swapProvider$.rate) != null ? _this7$_swapProvider$2 : null;
4078
+ return Promise.resolve(_this7._swapProvider.getSwapInfo(fromCoin, toCoin, fromAmountCoins, coinUsdtRate)).then(function (details) {
4013
4079
  var _result$swapCreationI, _result$swapCreationI2;
4014
4080
  var min = details.result ? details.min : details.smallestMin;
4015
4081
  var max = details.result ? details.max : details.greatestMax;
@@ -4101,7 +4167,7 @@ var PublicSwapService = /*#__PURE__*/function () {
4101
4167
  ;
4102
4168
  _proto.createPublicSwap = function createPublicSwap(fromCoin, toCoin, fromAmount, swapCreationInfo, toAddress, refundAddress, clientIp) {
4103
4169
  try {
4104
- var _this7 = this;
4170
+ var _this8 = this;
4105
4171
  var loggerSource = "createPublicSwap";
4106
4172
  return Promise.resolve(_catch(function () {
4107
4173
  var _swapCreationInfo$fro, _swapCreationInfo$toC;
@@ -4112,10 +4178,10 @@ var PublicSwapService = /*#__PURE__*/function () {
4112
4178
  fromCoin: swapCreationInfo == null || (_swapCreationInfo$fro = swapCreationInfo.fromCoin) == null ? void 0 : _swapCreationInfo$fro.ticker,
4113
4179
  toCoin: swapCreationInfo == null || (_swapCreationInfo$toC = swapCreationInfo.toCoin) == null ? void 0 : _swapCreationInfo$toC.ticker
4114
4180
  })), loggerSource);
4115
- return Promise.resolve(_this7._swapProvider.createSwap(fromCoin, toCoin, fromAmount, toAddress, refundAddress, swapCreationInfo.rawSwapData, clientIp)).then(function (result) {
4181
+ return Promise.resolve(_this8._swapProvider.createSwap(fromCoin, toCoin, fromAmount, toAddress, refundAddress, swapCreationInfo.rawSwapData, clientIp)).then(function (result) {
4116
4182
  var _exit;
4117
- function _temp5(_result7) {
4118
- if (_exit) return _result7;
4183
+ function _temp5(_result8) {
4184
+ if (_exit) return _result8;
4119
4185
  throw new Error("Unexpected result from provider " + safeStringify(result));
4120
4186
  }
4121
4187
  Logger.log("Created:" + safeStringify(_extends({}, result, {
@@ -4157,7 +4223,7 @@ var PublicSwapService = /*#__PURE__*/function () {
4157
4223
  durationMinutesRange: swapCreationInfo.durationMinutesRange,
4158
4224
  address: result.fromAddress // CRITICAL: this is the address to send coins to swaps provider
4159
4225
  };
4160
- _this7._savePublicSwapIdLocally(result.swapId);
4226
+ _this8._savePublicSwapIdLocally(result.swapId);
4161
4227
  Logger.log("Returning: " + safeStringify(_extends({}, toReturn, {
4162
4228
  fromCoin: fromCoin == null ? void 0 : fromCoin.ticker,
4163
4229
  toCoin: toCoin == null ? void 0 : toCoin.ticker
@@ -4168,12 +4234,12 @@ var PublicSwapService = /*#__PURE__*/function () {
4168
4234
  var _fromAmountFiat = null,
4169
4235
  _toAmountFiat = null;
4170
4236
  var _temp2 = _catch(function () {
4171
- return Promise.resolve(_this7._swapProvider.getCoinToUSDTRate(fromCoin)).then(function (_this7$_swapProvider$) {
4172
- var _this7$_swapProvider$3;
4173
- var fromCoinUsdtRate = (_this7$_swapProvider$3 = _this7$_swapProvider$ == null ? void 0 : _this7$_swapProvider$.rate) != null ? _this7$_swapProvider$3 : null;
4174
- return Promise.resolve(_this7._swapProvider.getCoinToUSDTRate(fromCoin)).then(function (_this7$_swapProvider$2) {
4175
- var _this7$_swapProvider$4;
4176
- var toCoinUsdtRate = (_this7$_swapProvider$4 = _this7$_swapProvider$2 == null ? void 0 : _this7$_swapProvider$2.rate) != null ? _this7$_swapProvider$4 : null;
4237
+ return Promise.resolve(_this8._swapProvider.getCoinToUSDTRate(fromCoin)).then(function (_this8$_swapProvider$) {
4238
+ var _this8$_swapProvider$3;
4239
+ var fromCoinUsdtRate = (_this8$_swapProvider$3 = _this8$_swapProvider$ == null ? void 0 : _this8$_swapProvider$.rate) != null ? _this8$_swapProvider$3 : null;
4240
+ return Promise.resolve(_this8._swapProvider.getCoinToUSDTRate(fromCoin)).then(function (_this8$_swapProvider$2) {
4241
+ var _this8$_swapProvider$4;
4242
+ var toCoinUsdtRate = (_this8$_swapProvider$4 = _this8$_swapProvider$2 == null ? void 0 : _this8$_swapProvider$2.rate) != null ? _this8$_swapProvider$4 : null;
4177
4243
  if (fromCoinUsdtRate != null && result.fromAmount != null) {
4178
4244
  _fromAmountFiat = BigNumber(result.fromAmount).times(fromCoinUsdtRate).toFixed(PublicSwapService._fiatDecimalsCount);
4179
4245
  }
@@ -4213,10 +4279,10 @@ var PublicSwapService = /*#__PURE__*/function () {
4213
4279
  ;
4214
4280
  _proto.getPublicExistingSwapDetailsAndStatus = function getPublicExistingSwapDetailsAndStatus(swapIds) {
4215
4281
  try {
4216
- var _this8 = this;
4282
+ var _this9 = this;
4217
4283
  var loggerSource = "getPublicExistingSwapDetailsAndStatus";
4218
4284
  return Promise.resolve(_catch(function () {
4219
- return Promise.resolve(SwapUtils.getExistingSwapsDetailsWithFiatAmounts(_this8._swapProvider, swapIds)).then(function (result) {
4285
+ return Promise.resolve(SwapUtils.getExistingSwapsDetailsWithFiatAmounts(_this9._swapProvider, swapIds)).then(function (result) {
4220
4286
  if (!(result != null && result.result)) {
4221
4287
  if (result.reason === SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED) {
4222
4288
  SwapUtils.safeHandleRequestsLimitExceeding();
@@ -4251,20 +4317,20 @@ var PublicSwapService = /*#__PURE__*/function () {
4251
4317
  _proto.getPublicSwapsHistory = function getPublicSwapsHistory() {
4252
4318
  try {
4253
4319
  var _exit2;
4254
- var _this9 = this;
4320
+ var _this10 = this;
4255
4321
  return Promise.resolve(_catch(function () {
4256
- function _temp7(_result9) {
4257
- return _exit2 ? _result9 : {
4322
+ function _temp7(_result10) {
4323
+ return _exit2 ? _result10 : {
4258
4324
  result: true,
4259
4325
  swaps: []
4260
4326
  };
4261
4327
  }
4262
- var swapIds = _this9._getPublicSwapIdsSavedLocally();
4328
+ var swapIds = _this10._getPublicSwapIdsSavedLocally();
4263
4329
  var _temp6 = function () {
4264
4330
  if (swapIds.length) {
4265
- return Promise.resolve(_this9.getPublicExistingSwapDetailsAndStatus(swapIds)).then(function (_await$_this9$getPubl) {
4331
+ return Promise.resolve(_this10.getPublicExistingSwapDetailsAndStatus(swapIds)).then(function (_await$_this10$getPub) {
4266
4332
  _exit2 = 1;
4267
- return _await$_this9$getPubl;
4333
+ return _await$_this10$getPub;
4268
4334
  });
4269
4335
  }
4270
4336
  }();
@@ -4332,9 +4398,9 @@ var PublicSwapService = /*#__PURE__*/function () {
4332
4398
  */;
4333
4399
  _proto.getAssetToUsdtRate = function getAssetToUsdtRate(asset) {
4334
4400
  try {
4335
- var _this10 = this;
4401
+ var _this11 = this;
4336
4402
  return Promise.resolve(_catch(function () {
4337
- return Promise.resolve(_this10._swapProvider.getCoinToUSDTRate(asset)).then(function (result) {
4403
+ return Promise.resolve(_this11._swapProvider.getCoinToUSDTRate(asset)).then(function (result) {
4338
4404
  var _result$rate;
4339
4405
  return (_result$rate = result == null ? void 0 : result.rate) != null ? _result$rate : null;
4340
4406
  });