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