@rabbitio/ui-kit 1.0.0-beta.87 → 1.0.0-beta.89
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/coverage/clover.xml +1882 -1481
- package/coverage/coverage-final.json +32 -31
- package/coverage/index.html +90 -75
- package/coverage/rabbit-ui-kit/index.html +1 -1
- package/coverage/rabbit-ui-kit/index.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/common-apis/adapters/analyticsAdapters/googleAnalyticsAdapter.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/common-apis/adapters/analyticsAdapters/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/common-apis/adapters/analyticsAdapters/metrikaAdapter.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/common-apis/adapters/analyticsAdapters/mixpanelAdapter.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/common-apis/adapters/axiosAdapter.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/common-apis/adapters/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/common-apis/adapters/qrUtils.js.html +2 -2
- package/coverage/rabbit-ui-kit/src/common-apis/external-apis/apiGroups.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/common-apis/{utils → external-apis}/emailAPI.js.html +4 -4
- package/coverage/rabbit-ui-kit/src/common-apis/external-apis/index.html +24 -9
- package/coverage/rabbit-ui-kit/src/common-apis/external-apis/ipAddressProviders.js.html +2 -2
- package/coverage/rabbit-ui-kit/src/common-apis/globalConstants.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/common-apis/index.html +10 -55
- package/coverage/rabbit-ui-kit/src/common-apis/models/blockchain.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/common-apis/models/coin.js.html +381 -96
- package/coverage/rabbit-ui-kit/src/common-apis/models/index.html +17 -17
- package/coverage/rabbit-ui-kit/src/common-apis/models/protocol.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/common-apis/{fiatCurrenciesService.js.html → services/fiatCurrenciesService.js.html} +10 -10
- package/coverage/rabbit-ui-kit/src/common-apis/services/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/common-apis/{amountUtils.js.html → utils/amountUtils.js.html} +11 -11
- package/coverage/rabbit-ui-kit/src/common-apis/utils/cache.js.html +2 -2
- package/coverage/rabbit-ui-kit/src/common-apis/{errorUtils.js.html → utils/errorUtils.js.html} +12 -12
- package/coverage/rabbit-ui-kit/src/common-apis/utils/index.html +49 -19
- package/coverage/rabbit-ui-kit/src/common-apis/utils/logging/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/common-apis/utils/logging/logger.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/common-apis/utils/logging/logsStorage.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/common-apis/utils/postponeExecution.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/common-apis/utils/rabbitTicker.js.html +157 -0
- package/coverage/rabbit-ui-kit/src/common-apis/utils/safeStringify.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/index.html +5 -5
- package/coverage/rabbit-ui-kit/src/index.js.html +21 -9
- package/coverage/rabbit-ui-kit/src/robust-api-caller/cacheAndConcurrentRequestsResolver.js.html +2 -2
- package/coverage/rabbit-ui-kit/src/robust-api-caller/cachedRobustExternalApiCallerService.js.html +2 -2
- package/coverage/rabbit-ui-kit/src/robust-api-caller/cancelProcessing.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/robust-api-caller/concurrentCalculationsMetadataHolder.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/robust-api-caller/externalApiProvider.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/robust-api-caller/externalServicesStatsCollector.js.html +2 -2
- package/coverage/rabbit-ui-kit/src/robust-api-caller/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/robust-api-caller/robustExternalAPICallerService.js.html +2 -2
- package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/index.html +28 -28
- package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/letsExchangeSwapProvider.js.html +100 -31
- package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/swapProvider.js.html +418 -208
- package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/swapspaceSwapProvider.js.html +127 -40
- package/coverage/rabbit-ui-kit/src/swaps-lib/models/baseSwapCreationInfo.js.html +85 -4
- package/coverage/rabbit-ui-kit/src/swaps-lib/models/existingSwap.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/swaps-lib/models/existingSwapWithFiatData.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/swaps-lib/models/index.html +25 -25
- package/coverage/rabbit-ui-kit/src/swaps-lib/models/partner.js.html +76 -13
- package/coverage/rabbit-ui-kit/src/swaps-lib/models/swapProviderCoinInfo.js.html +147 -9
- package/coverage/rabbit-ui-kit/src/swaps-lib/services/index.html +5 -5
- package/coverage/rabbit-ui-kit/src/swaps-lib/services/publicSwapService.js.html +158 -23
- package/coverage/rabbit-ui-kit/src/swaps-lib/utils/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/swaps-lib/utils/swapUtils.js.html +5 -5
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/arrowIcon.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/arrowTosca.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/arrowWhite.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/darkRectangle.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/determinedError.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/failedValidationIcon.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/infoIcon.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/messageIcon.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/noticeQuestionIcon.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/successfulValidationIcon.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/supportDialogImage.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/walletIcon.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/AssetIcon/AssetIcon.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/AssetIcon/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/AssetSelection/AssetSelection.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/AssetSelection/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/BackgroundTitle/BackgroundTitle.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/BackgroundTitle/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/InformationMessage/InformationMessage.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/InformationMessage/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Input/Input.jsx.html +2 -2
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Input/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/LoadingDots/LoadingDots.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/LoadingDots/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/NoticeIcon/NoticeIcon.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/NoticeIcon/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/QrCode/QrCode.jsx.html +2 -2
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/QrCode/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/RateSelector/RateSelector.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/RateSelector/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/SupportChat/SupportChat.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/SupportChat/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Textarea/Textarea.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Textarea/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/TitleBox/TitleBox.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/TitleBox/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Tooltip/Tooltip.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Tooltip/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/TwoLinesOfText/LinesOfText.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/TwoLinesOfText/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Validation/Validation.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Validation/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/Button/Button.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/Button/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/Close/Close.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/Close/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/LinkButton/LinkButton.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/LinkButton/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/RadioButtonWithText/RadioButtonWithText.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/RadioButtonWithText/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/AmountInput/AmountInput.jsx.html +3 -3
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/AmountInput/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/CoinPicker/CoinPicker.jsx.html +3 -3
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/CoinPicker/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/ColoredNotice/ColoredNotice.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/ColoredNotice/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/LineWithIconLink/LineWithIconLink.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/LineWithIconLink/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/LogoCarousel/LogoCarousel.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/LogoCarousel/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/SearchableCoinsList/SearchableCoinsList.jsx.html +6 -6
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/SearchableCoinsList/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/TitledLineWithIconLink/TitledLineWithIconLink.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/TitledLineWithIconLink/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/CoinPickerDialogStep/CoinPickerDialogStep.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/CoinPickerDialogStep/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/Dialog/Dialog.jsx.html +2 -2
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/Dialog/DialogButtons/DialogButtons.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/Dialog/DialogButtons/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/Dialog/DialogStep/DialogStep.jsx.html +2 -2
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/Dialog/DialogStep/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/Dialog/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/SwapForm/SwapForm.jsx.html +40 -7
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/SwapForm/index.html +5 -5
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/WaitlistSubscription/WaitlistSubscription.jsx.html +2 -2
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/WaitlistSubscription/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/templates/DeterminedErrorDialogStep/DeterminedErrorDialogStep.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/templates/DeterminedErrorDialogStep/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/hooks/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/hooks/useCallHandlingErrors.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/hooks/useIsHydrated.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/hooks/useReferredState.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/utils/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/utils/inputValueProviders.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/utils/textUtils.js.html +2 -2
- package/coverage/rabbit-ui-kit/src/ui-kit/utils/uiUtils.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/utils/urlQueryUtils.js.html +1 -1
- package/coverage/rabbit-ui-kit/stories/atoms/BackgroundTitle.stories.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/stories/atoms/LinesOfText.stories.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/stories/atoms/LoadingDots.stories.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/stories/atoms/QrCode.stories.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/stories/atoms/RateSelector.stories.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/stories/atoms/Validation.stories.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/stories/atoms/buttons/Button.stories.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/stories/atoms/buttons/Close.stories.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/stories/atoms/buttons/LinkButton.stories.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/stories/atoms/buttons/index.html +1 -1
- package/coverage/rabbit-ui-kit/stories/atoms/index.html +1 -1
- package/coverage/rabbit-ui-kit/stories/molecules/AmountInput.stories.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/stories/molecules/CoinPicker.stories.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/stories/molecules/ColoredNotice.stories.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/stories/molecules/LineWithIconLink.stories.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/stories/molecules/LogoCarousel.stories.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/stories/molecules/TitledLineWithIconLink.stories.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/stories/molecules/index.html +1 -1
- package/coverage/rabbit-ui-kit/stories/organisms/Dialog/Dialog.stories.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/stories/organisms/Dialog/DialogButtons/DialogButtons.stories.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/stories/organisms/Dialog/DialogButtons/index.html +1 -1
- package/coverage/rabbit-ui-kit/stories/organisms/Dialog/DialogStep/DialogStep.stories.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/stories/organisms/Dialog/DialogStep/index.html +1 -1
- package/coverage/rabbit-ui-kit/stories/organisms/Dialog/index.html +1 -1
- package/coverage/rabbit-ui-kit/stories/organisms/WaitlistSubscription.stories.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/stories/organisms/index.html +1 -1
- package/coverage/rabbit-ui-kit/stories/stubs/coins.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/stories/stubs/exampleContent.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/stories/stubs/index.html +1 -1
- package/coverage/rabbit-ui-kit/stories/templates/DeterminedErrorDialogStep.stories.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/stories/templates/index.html +1 -1
- package/dist/index.cjs +1547 -1178
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +751 -421
- package/dist/index.modern.js.map +1 -1
- package/dist/index.module.js +1543 -1179
- package/dist/index.module.js.map +1 -1
- package/dist/index.umd.js +1547 -1178
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/common-apis/adapters/qrUtils.js +1 -1
- package/src/common-apis/{utils → external-apis}/emailAPI.js +1 -1
- package/src/common-apis/external-apis/ipAddressProviders.js +1 -1
- package/src/common-apis/models/coin.js +96 -1
- package/src/common-apis/tests/{amountUtils → units/utils/amountUtils}/composeRateText.test.js +1 -1
- package/src/common-apis/{amountUtils.js → utils/amountUtils.js} +1 -1
- package/src/common-apis/utils/cache.js +1 -1
- package/src/common-apis/{errorUtils.js → utils/errorUtils.js} +2 -2
- package/src/common-apis/utils/rabbitTicker.js +24 -0
- package/src/index.js +9 -5
- package/src/robust-api-caller/cacheAndConcurrentRequestsResolver.js +1 -1
- package/src/robust-api-caller/cachedRobustExternalApiCallerService.js +1 -1
- package/src/robust-api-caller/externalServicesStatsCollector.js +1 -1
- package/src/robust-api-caller/robustExternalAPICallerService.js +1 -1
- package/src/swaps-lib/external-apis/letsExchangeSwapProvider.js +50 -27
- package/src/swaps-lib/external-apis/swapProvider.js +84 -14
- package/src/swaps-lib/external-apis/swapspaceSwapProvider.js +54 -25
- package/src/swaps-lib/models/baseSwapCreationInfo.js +27 -0
- package/src/swaps-lib/models/partner.js +22 -1
- package/src/swaps-lib/models/swapProviderCoinInfo.js +46 -0
- package/src/swaps-lib/services/publicSwapService.js +64 -19
- package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/_fetchSupportedCurrenciesIfNeeded.test.js +0 -3
- package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/getSwapInfo.test.js +9 -2
- package/src/swaps-lib/test/utils/swapUtils/safeHandleRequestsLimitExceeding.test.js +1 -1
- package/src/swaps-lib/utils/swapUtils.js +4 -4
- package/src/ui-kit/components/atoms/Input/Input.jsx +1 -1
- package/src/ui-kit/components/atoms/QrCode/QrCode.jsx +1 -1
- package/src/ui-kit/components/molecules/AmountInput/AmountInput.jsx +2 -2
- package/src/ui-kit/components/molecules/CoinPicker/CoinPicker.jsx +2 -2
- package/src/ui-kit/components/molecules/SearchableCoinsList/SearchableCoinsList.jsx +5 -5
- package/src/ui-kit/components/organisms/Dialog/Dialog.jsx +1 -1
- package/src/ui-kit/components/organisms/Dialog/DialogStep/DialogStep.jsx +1 -1
- package/src/ui-kit/components/organisms/SwapForm/SwapForm.jsx +14 -3
- package/src/ui-kit/components/organisms/WaitlistSubscription/WaitlistSubscription.jsx +1 -1
- package/src/ui-kit/utils/textUtils.js +1 -1
- /package/src/common-apis/{fiatCurrenciesService.js → services/fiatCurrenciesService.js} +0 -0
package/dist/index.umd.js
CHANGED
|
@@ -4790,6 +4790,7 @@
|
|
|
4790
4790
|
* @param {string} ticker - Ticker symbol of the asset.
|
|
4791
4791
|
* @param {string} address - Address to be validated
|
|
4792
4792
|
* @param {boolean} isFixed - Is swap rate mode = fixed
|
|
4793
|
+
* @param {function} setValidationContent - Function setting validation message text
|
|
4793
4794
|
* @return {Promise<boolean>}
|
|
4794
4795
|
*/
|
|
4795
4796
|
|
|
@@ -5442,7 +5443,7 @@
|
|
|
5442
5443
|
};
|
|
5443
5444
|
if (!receivingAssetTicker) return;
|
|
5444
5445
|
var _temp = recipientAddress.current === "";
|
|
5445
|
-
return _temp ? _temp2(false) : Promise.resolve(validateAddressByTicker(receivingAssetTicker, recipientAddress.current, isFixedRate.current)).then(_temp2);
|
|
5446
|
+
return _temp ? _temp2(false) : Promise.resolve(validateAddressByTicker(receivingAssetTicker, recipientAddress.current, isFixedRate.current, setValidationContent)).then(_temp2);
|
|
5446
5447
|
} catch (e) {
|
|
5447
5448
|
Promise.reject(e);
|
|
5448
5449
|
}
|
|
@@ -5457,7 +5458,7 @@
|
|
|
5457
5458
|
};
|
|
5458
5459
|
if (!sendingAssetTicker || !isRefundAddressRequired) return;
|
|
5459
5460
|
var _temp3 = refundAddress.current === "";
|
|
5460
|
-
return _temp3 ? _temp4(false) : Promise.resolve(validateAddressByTicker(sendingAssetTicker, refundAddress.current, isFixedRate.current)).then(_temp4);
|
|
5461
|
+
return _temp3 ? _temp4(false) : Promise.resolve(validateAddressByTicker(sendingAssetTicker, refundAddress.current, isFixedRate.current, setValidationContent)).then(_temp4);
|
|
5461
5462
|
} catch (e) {
|
|
5462
5463
|
Promise.reject(e);
|
|
5463
5464
|
}
|
|
@@ -6572,160 +6573,12 @@
|
|
|
6572
6573
|
var FALLBACK_ASSET_ICON_URL = "https://rabbit.io/asset-icons/fallback.svg";
|
|
6573
6574
|
var DEFAULT_CRYPTO_DECIMAL_COUNT = 8;
|
|
6574
6575
|
|
|
6575
|
-
/**
|
|
6576
|
-
* The model for cryptocurrency coins.
|
|
6577
|
-
*
|
|
6578
|
-
* WARNING: this class should not be instantiated directly. Use only predefined singleton Coin (or descendants) instances.
|
|
6579
|
-
*/
|
|
6580
|
-
var Coin = /*#__PURE__*/function () {
|
|
6581
|
-
/**
|
|
6582
|
-
* Creates new coin
|
|
6583
|
-
*
|
|
6584
|
-
* @param latinName {string} the coin name in latin symbols like "Bitcoin"
|
|
6585
|
-
* @param ticker {string} the coin symbol/ticker/code like 'BTC'. Always upper case. A unique coin identifier
|
|
6586
|
-
* @param tickerPrintable {string} ticker but in printable format. Useful for tokens based on external blockchains
|
|
6587
|
-
* like ERC20 or TRC20. It is not friendly to display USDTERC20 or BUSDTRC20 - more neat options are just
|
|
6588
|
-
* USDT and BUSD. Note that you should always care about user's understanding of what coin he/she is working
|
|
6589
|
-
* with as printable ticker for USDTERC20 and USDTTRC20 are the same.
|
|
6590
|
-
* @param digitsCountAfterComma {number} count of digits after the comma. E.g. 8 for bitcoin
|
|
6591
|
-
* @param maxValue {number|null} max possible value for cryptocurrency. Null means that the currency has no max possible value
|
|
6592
|
-
* @param atomName {string} name of the coin's atomic value. Like 'satoshi' for bitcoin
|
|
6593
|
-
* @param mainnet {Network} main network for this coin
|
|
6594
|
-
* @param testnet {Network} test network for this coin
|
|
6595
|
-
* @param minConfirmations {number} min confirmations count to treat the coin's transaction confirmed
|
|
6596
|
-
* @param payableEntityStringForFeeRate {string|null} the payable fee entity like byte for bitcoin or gas for ether if present
|
|
6597
|
-
* @param feeOptionsTimeStringsSortedDesc {string[]} array of 4 strings for fee options when sending coins. Should be sorted from the highest time to the smallest
|
|
6598
|
-
* @param feeRatesExpirationTimeMs {number} number of milliseconds to treat the fee rates as expired
|
|
6599
|
-
* @param blockchain {Blockchain} blockchain object
|
|
6600
|
-
* @param [protocol] {Protocol|null} token/coin protocol if relevant
|
|
6601
|
-
* @param [tokenAddress] {string|null} address of contract of this token (if the coin is token)
|
|
6602
|
-
* @param [doesUseLowerCaseAddresses] {boolean} flag to clarify whether we can use lower case addresses to ensure more robust comparisons
|
|
6603
|
-
* @param [doesUseOutputs=false] {boolean} true if this coin uses inputs/outputs concept and false if it uses just balances
|
|
6604
|
-
*/
|
|
6605
|
-
function Coin(latinName, ticker, tickerPrintable, digitsCountAfterComma, maxValue, atomName, mainnet, testnet, minConfirmations, payableEntityStringForFeeRate, feeOptionsTimeStringsSortedDesc, feeRatesExpirationTimeMs, blockchain, protocol, tokenAddress, doesUseLowerCaseAddresses, doesUseOutputs) {
|
|
6606
|
-
if (protocol === void 0) {
|
|
6607
|
-
protocol = null;
|
|
6608
|
-
}
|
|
6609
|
-
if (tokenAddress === void 0) {
|
|
6610
|
-
tokenAddress = null;
|
|
6611
|
-
}
|
|
6612
|
-
if (doesUseLowerCaseAddresses === void 0) {
|
|
6613
|
-
doesUseLowerCaseAddresses = true;
|
|
6614
|
-
}
|
|
6615
|
-
if (doesUseOutputs === void 0) {
|
|
6616
|
-
doesUseOutputs = false;
|
|
6617
|
-
}
|
|
6618
|
-
this.latinName = latinName;
|
|
6619
|
-
this.ticker = ticker;
|
|
6620
|
-
this.tickerPrintable = tickerPrintable;
|
|
6621
|
-
this.digits = digitsCountAfterComma;
|
|
6622
|
-
this.maxValue = maxValue;
|
|
6623
|
-
this.atomName = atomName;
|
|
6624
|
-
this.mainnet = mainnet;
|
|
6625
|
-
this.testnet = testnet;
|
|
6626
|
-
this.minConfirmations = minConfirmations;
|
|
6627
|
-
this.payableEntityStringForFeeRate = payableEntityStringForFeeRate;
|
|
6628
|
-
this.feeOptionsTimeStringsSortedDesc = feeOptionsTimeStringsSortedDesc;
|
|
6629
|
-
this.feeRatesExpirationTimeMs = feeRatesExpirationTimeMs;
|
|
6630
|
-
this.protocol = protocol;
|
|
6631
|
-
this.blockchain = blockchain;
|
|
6632
|
-
// TODO: [bug, critical] use testnet property for testnet contract address as it blocks the app work in testnets
|
|
6633
|
-
this.tokenAddress = tokenAddress;
|
|
6634
|
-
this.feeCoin = this;
|
|
6635
|
-
this._significantDigits = 8;
|
|
6636
|
-
this.doesUseLowerCaseAddresses = doesUseLowerCaseAddresses;
|
|
6637
|
-
this.doesUseOutputs = doesUseOutputs;
|
|
6638
|
-
}
|
|
6639
|
-
|
|
6640
|
-
/**
|
|
6641
|
-
* Sets fee coin
|
|
6642
|
-
*
|
|
6643
|
-
* @param feeCoin {Coin} some tokens use another coin to charge transaction fee as they work on top of some external
|
|
6644
|
-
* blockchain. So pass here the coin the token uses for fee charging. Like for ERC20 token the fee coin is ETH.
|
|
6645
|
-
* By default, the creating coin will be set as a value for this field.
|
|
6646
|
-
*/
|
|
6647
|
-
var _proto = Coin.prototype;
|
|
6648
|
-
_proto.setFeeCoin = function setFeeCoin(feeCoin) {
|
|
6649
|
-
this.feeCoin = feeCoin;
|
|
6650
|
-
}
|
|
6651
|
-
|
|
6652
|
-
/**
|
|
6653
|
-
* Checks whether this coin uses another coin (blockchain) to charge fee for transactions (means works on base of
|
|
6654
|
-
* some external blockchain).
|
|
6655
|
-
*
|
|
6656
|
-
* @return {boolean} true if this coin uses external blockchain to perform transactions and charge fee
|
|
6657
|
-
*/;
|
|
6658
|
-
_proto.doesUseDifferentCoinFee = function doesUseDifferentCoinFee() {
|
|
6659
|
-
return this.feeCoin !== this;
|
|
6660
|
-
}
|
|
6661
|
-
|
|
6662
|
-
/**
|
|
6663
|
-
* Converts the given atoms string/number to string representing the same amount in coin itself - floating point number
|
|
6664
|
-
*
|
|
6665
|
-
* @param atoms {string} atoms positive integer amount
|
|
6666
|
-
* @return {string} coin amount floating point number as a string
|
|
6667
|
-
*/;
|
|
6668
|
-
_proto.atomsToCoinAmount = function atomsToCoinAmount(atoms) {
|
|
6669
|
-
throw new Error("Not implemented in base Coin");
|
|
6670
|
-
}
|
|
6671
|
-
|
|
6672
|
-
/**
|
|
6673
|
-
* Converts the given coins amount string/number to string representing the same amount in coin atoms - integer number
|
|
6674
|
-
*
|
|
6675
|
-
* @param coinsAmount {string} coins positive floating point amount
|
|
6676
|
-
* @return {string} coin atoms amount integer number as a string
|
|
6677
|
-
*/;
|
|
6678
|
-
_proto.coinAmountToAtoms = function coinAmountToAtoms(coinsAmount) {
|
|
6679
|
-
throw new Error("Not implemented in base Coin");
|
|
6680
|
-
}
|
|
6681
|
-
|
|
6682
|
-
/**
|
|
6683
|
-
* Composes URL to view the tx with given id in the external blockchain explorer
|
|
6684
|
-
*
|
|
6685
|
-
* @param txId {string} id of transaction
|
|
6686
|
-
* @return {string} URL string
|
|
6687
|
-
*/;
|
|
6688
|
-
_proto.composeUrlToTransactionExplorer = function composeUrlToTransactionExplorer(txId) {
|
|
6689
|
-
throw new Error("Not implemented in base Coin");
|
|
6690
|
-
}
|
|
6691
|
-
|
|
6692
|
-
/**
|
|
6693
|
-
* Most of the cryptocurrencies has specific fee rate or fee price metric. This value usually has specific measure
|
|
6694
|
-
* like satoshi/byte or gWei/gas. This function adds the described denomination string to the given amount
|
|
6695
|
-
* as a suffix and returns the result string ready to be show to a user.
|
|
6696
|
-
*
|
|
6697
|
-
* @param coinAtomsString {string} coin atoms positive integer amount
|
|
6698
|
-
* @return {string} string of coin amount and fee rate units
|
|
6699
|
-
*/;
|
|
6700
|
-
_proto.coinAtomsFeeRateToCommonlyUsedAmountFormatWithDenominationString = function coinAtomsFeeRateToCommonlyUsedAmountFormatWithDenominationString(coinAtomsString) {
|
|
6701
|
-
throw new Error("Not implemented in base Coin");
|
|
6702
|
-
}
|
|
6703
|
-
|
|
6704
|
-
/**
|
|
6705
|
-
* Check whether this coin support transaction prioritisation during the sending process.
|
|
6706
|
-
*
|
|
6707
|
-
* @return {boolean} true if support transaction prioritisation and false otherwise
|
|
6708
|
-
*/;
|
|
6709
|
-
_proto.doesSupportTransactionPrioritisation = function doesSupportTransactionPrioritisation() {
|
|
6710
|
-
return Array.isArray(this.feeOptionsTimeStringsSortedDesc);
|
|
6711
|
-
};
|
|
6712
|
-
_proto.tickerAndProtocol = function tickerAndProtocol() {
|
|
6713
|
-
try {
|
|
6714
|
-
var _ref;
|
|
6715
|
-
return "" + this.tickerPrintable + (this.protocol ? (_ref = " " + this.protocol.protocol) != null ? _ref : "" : "");
|
|
6716
|
-
} catch (e) {
|
|
6717
|
-
improveAndRethrow(e, "tickerAndProtocol");
|
|
6718
|
-
}
|
|
6719
|
-
};
|
|
6720
|
-
return Coin;
|
|
6721
|
-
}();
|
|
6722
|
-
|
|
6723
6576
|
/**
|
|
6724
6577
|
* A component that displays a list of coins that can be searched and filtered.
|
|
6725
6578
|
*
|
|
6726
6579
|
* @param {Object} props - The properties object.
|
|
6727
|
-
* @param {
|
|
6728
|
-
* @param {Array<{
|
|
6580
|
+
* @param {{ ticker:string, tickerPrintable: string, latinName: string }[]} props.coinsList - The list of all available coins.
|
|
6581
|
+
* @param {Array<{ ticker: string, component: React.Component }>} props.coinsBundle - The bundle of coin components to be displayed.
|
|
6729
6582
|
* @param {string} props.searchQuery - The search query to filter coins.
|
|
6730
6583
|
* @param {boolean} props.partialLoadingEnabled - Determines if partial loading is enabled.
|
|
6731
6584
|
* @param {number} props.partialLoadingIncrement - The increment of coins to load when loading more.
|
|
@@ -6825,7 +6678,7 @@
|
|
|
6825
6678
|
}, [coinsList, searchQuery]);
|
|
6826
6679
|
return displayedCoins.map(function (coin) {
|
|
6827
6680
|
return coinsBundle.find(function (bundleItem) {
|
|
6828
|
-
return bundleItem.
|
|
6681
|
+
return bundleItem.ticker === coin.ticker;
|
|
6829
6682
|
}).component;
|
|
6830
6683
|
}).map(function (Item) {
|
|
6831
6684
|
return /*#__PURE__*/React__default["default"].createElement(Item, null);
|
|
@@ -7160,7 +7013,7 @@
|
|
|
7160
7013
|
coinsList: coins,
|
|
7161
7014
|
coinsBundle: coins == null ? void 0 : coins.map(function (coin, index) {
|
|
7162
7015
|
return {
|
|
7163
|
-
|
|
7016
|
+
ticker: coin.ticker,
|
|
7164
7017
|
component: function component() {
|
|
7165
7018
|
var _coinsContent$find$su, _coinsContent$find;
|
|
7166
7019
|
var _coinToIconPaths = coinToIconPaths(coin),
|
|
@@ -7377,115 +7230,247 @@
|
|
|
7377
7230
|
onButtonClick: function onButtonClick() {}
|
|
7378
7231
|
};
|
|
7379
7232
|
|
|
7380
|
-
|
|
7381
|
-
|
|
7382
|
-
|
|
7383
|
-
|
|
7384
|
-
|
|
7385
|
-
|
|
7386
|
-
|
|
7387
|
-
|
|
7388
|
-
|
|
7389
|
-
"clip-rule": "evenodd",
|
|
7390
|
-
d: "M65 130C100.899 130 130 100.899 130 65C130 29.1015 100.899 0 65 0C29.1015 0 0 29.1015 0 65C0 100.899 29.1015 130 65 130Z",
|
|
7391
|
-
fill: "#2294F0"
|
|
7392
|
-
}), /*#__PURE__*/React__default["default"].createElement("mask", {
|
|
7393
|
-
id: "mask0",
|
|
7394
|
-
style: {
|
|
7395
|
-
maskType: "alpha"
|
|
7396
|
-
},
|
|
7397
|
-
maskUnits: "userSpaceOnUse",
|
|
7398
|
-
x: "0",
|
|
7399
|
-
y: "0",
|
|
7400
|
-
width: "130",
|
|
7401
|
-
height: "130"
|
|
7402
|
-
}, /*#__PURE__*/React__default["default"].createElement("path", {
|
|
7403
|
-
"fill-rule": "evenodd",
|
|
7404
|
-
"clip-rule": "evenodd",
|
|
7405
|
-
d: "M65 130C100.899 130 130 100.899 130 65C130 29.1015 100.899 0 65 0C29.1015 0 0 29.1015 0 65C0 100.899 29.1015 130 65 130Z",
|
|
7406
|
-
fill: "white"
|
|
7407
|
-
})), /*#__PURE__*/React__default["default"].createElement("g", {
|
|
7408
|
-
mask: "url(#mask0)"
|
|
7409
|
-
}, /*#__PURE__*/React__default["default"].createElement("rect", {
|
|
7410
|
-
opacity: "0.3",
|
|
7411
|
-
x: "3.25",
|
|
7412
|
-
y: "150.776",
|
|
7413
|
-
width: "227.136",
|
|
7414
|
-
height: "25.2373",
|
|
7415
|
-
transform: "rotate(-45 3.25 150.776)",
|
|
7416
|
-
fill: "white"
|
|
7417
|
-
}), /*#__PURE__*/React__default["default"].createElement("rect", {
|
|
7418
|
-
opacity: "0.3",
|
|
7419
|
-
x: "-48.4546",
|
|
7420
|
-
y: "126.52",
|
|
7421
|
-
width: "227.136",
|
|
7422
|
-
height: "25.2373",
|
|
7423
|
-
transform: "rotate(-45 -48.4546 126.52)",
|
|
7424
|
-
fill: "white"
|
|
7425
|
-
}), /*#__PURE__*/React__default["default"].createElement("rect", {
|
|
7426
|
-
x: "27.75",
|
|
7427
|
-
y: "29.5",
|
|
7428
|
-
width: "74.5",
|
|
7429
|
-
height: "81.5",
|
|
7430
|
-
rx: "12",
|
|
7431
|
-
fill: "white"
|
|
7432
|
-
}), /*#__PURE__*/React__default["default"].createElement("path", {
|
|
7433
|
-
d: "M27.75 41.5C27.75 34.8726 33.1226 29.5 39.75 29.5H90.25C96.8774 29.5 102.25 34.8726 102.25 41.5V118C102.25 124.627 96.8774 130 90.25 130H39.75C33.1226 130 27.75 124.627 27.75 118V41.5Z",
|
|
7434
|
-
fill: "white"
|
|
7435
|
-
}), /*#__PURE__*/React__default["default"].createElement("path", {
|
|
7436
|
-
"fill-rule": "evenodd",
|
|
7437
|
-
"clip-rule": "evenodd",
|
|
7438
|
-
d: "M51.5 63.5C58.1274 63.5 63.5 58.1274 63.5 51.5C63.5 44.8726 58.1274 39.5 51.5 39.5C44.8726 39.5 39.5 44.8726 39.5 51.5C39.5 58.1274 44.8726 63.5 51.5 63.5Z",
|
|
7439
|
-
fill: "#2294F0"
|
|
7440
|
-
}), /*#__PURE__*/React__default["default"].createElement("path", {
|
|
7441
|
-
d: "M50.072 49.088H52.03V54.5H50.072V49.088ZM52.074 46.382V48.153H50.028V46.382H52.074Z",
|
|
7442
|
-
fill: "white"
|
|
7443
|
-
}), /*#__PURE__*/React__default["default"].createElement("path", {
|
|
7444
|
-
opacity: "0.2",
|
|
7445
|
-
d: "M41 74.5H63",
|
|
7446
|
-
stroke: "#2294F0",
|
|
7447
|
-
"stroke-width": "4",
|
|
7448
|
-
"stroke-linecap": "round",
|
|
7449
|
-
"stroke-linejoin": "round"
|
|
7450
|
-
}), /*#__PURE__*/React__default["default"].createElement("path", {
|
|
7451
|
-
opacity: "0.2",
|
|
7452
|
-
d: "M41 84.6157H84.1426",
|
|
7453
|
-
stroke: "#2294F0",
|
|
7454
|
-
"stroke-width": "4",
|
|
7455
|
-
"stroke-linecap": "round",
|
|
7456
|
-
"stroke-linejoin": "round"
|
|
7457
|
-
}), /*#__PURE__*/React__default["default"].createElement("path", {
|
|
7458
|
-
opacity: "0.2",
|
|
7459
|
-
d: "M41 94.7314H84.1426",
|
|
7460
|
-
stroke: "#2294F0",
|
|
7461
|
-
"stroke-width": "4",
|
|
7462
|
-
"stroke-linecap": "round",
|
|
7463
|
-
"stroke-linejoin": "round"
|
|
7464
|
-
}), /*#__PURE__*/React__default["default"].createElement("path", {
|
|
7465
|
-
opacity: "0.2",
|
|
7466
|
-
d: "M41 104.731H84.1426",
|
|
7467
|
-
stroke: "#2294F0",
|
|
7468
|
-
"stroke-width": "4",
|
|
7469
|
-
"stroke-linecap": "round",
|
|
7470
|
-
"stroke-linejoin": "round"
|
|
7471
|
-
})));
|
|
7472
|
-
});
|
|
7233
|
+
/**
|
|
7234
|
+
* The model for cryptocurrency coins.
|
|
7235
|
+
*
|
|
7236
|
+
* WARNING: this class should not be instantiated directly. Use only predefined singleton Coin (or descendants) instances.
|
|
7237
|
+
*/
|
|
7238
|
+
var Coin = /*#__PURE__*/function () {
|
|
7239
|
+
/**
|
|
7240
|
+
* @type {string}
|
|
7241
|
+
*/
|
|
7473
7242
|
|
|
7474
|
-
|
|
7475
|
-
|
|
7476
|
-
|
|
7477
|
-
|
|
7478
|
-
|
|
7479
|
-
|
|
7480
|
-
|
|
7243
|
+
/**
|
|
7244
|
+
* @type {string}
|
|
7245
|
+
*/
|
|
7246
|
+
|
|
7247
|
+
/**
|
|
7248
|
+
* @type {string}
|
|
7249
|
+
*/
|
|
7250
|
+
|
|
7251
|
+
/**
|
|
7252
|
+
* @type {number}
|
|
7253
|
+
*/
|
|
7254
|
+
|
|
7255
|
+
/**
|
|
7256
|
+
* @type {number|null}
|
|
7257
|
+
*/
|
|
7258
|
+
|
|
7259
|
+
/**
|
|
7260
|
+
* @type {string}
|
|
7261
|
+
*/
|
|
7262
|
+
|
|
7263
|
+
/**
|
|
7264
|
+
* @type {Network}
|
|
7265
|
+
*/
|
|
7266
|
+
|
|
7267
|
+
/**
|
|
7268
|
+
* @type {Network}
|
|
7269
|
+
*/
|
|
7270
|
+
|
|
7271
|
+
/**
|
|
7272
|
+
* @type {number}
|
|
7273
|
+
*/
|
|
7274
|
+
|
|
7275
|
+
/**
|
|
7276
|
+
* @type {string|null}
|
|
7277
|
+
*/
|
|
7278
|
+
|
|
7279
|
+
/**
|
|
7280
|
+
* @type {string[]}
|
|
7281
|
+
*/
|
|
7282
|
+
|
|
7283
|
+
/**
|
|
7284
|
+
* @type {number}
|
|
7285
|
+
*/
|
|
7286
|
+
|
|
7287
|
+
/**
|
|
7288
|
+
* @type {Blockchain}
|
|
7289
|
+
*/
|
|
7290
|
+
|
|
7291
|
+
/**
|
|
7292
|
+
* @type {Protocol|null}
|
|
7293
|
+
*/
|
|
7294
|
+
|
|
7295
|
+
/**
|
|
7296
|
+
* @type {string|null}
|
|
7297
|
+
*/
|
|
7298
|
+
|
|
7299
|
+
/**
|
|
7300
|
+
* @type {boolean}
|
|
7301
|
+
*/
|
|
7302
|
+
|
|
7303
|
+
/**
|
|
7304
|
+
* @type {boolean}
|
|
7305
|
+
*/
|
|
7306
|
+
|
|
7307
|
+
/**
|
|
7308
|
+
* @type {Coin}
|
|
7309
|
+
*/
|
|
7310
|
+
|
|
7311
|
+
/**
|
|
7312
|
+
* @type {number}
|
|
7313
|
+
*/
|
|
7314
|
+
|
|
7315
|
+
/**
|
|
7316
|
+
* Creates new coin
|
|
7317
|
+
*
|
|
7318
|
+
* @param latinName {string} the coin name in latin symbols like "Bitcoin"
|
|
7319
|
+
* @param ticker {string} the coin symbol/ticker/code like 'BTC'. Always upper case. A unique coin identifier
|
|
7320
|
+
* @param tickerPrintable {string} ticker but in printable format. Useful for tokens based on external blockchains
|
|
7321
|
+
* like ERC20 or TRC20. It is not friendly to display USDTERC20 or BUSDTRC20 - more neat options are just
|
|
7322
|
+
* USDT and BUSD. Note that you should always care about user's understanding of what coin he/she is working
|
|
7323
|
+
* with as printable ticker for USDTERC20 and USDTTRC20 are the same.
|
|
7324
|
+
* @param digitsCountAfterComma {number} count of digits after the comma. E.g. 8 for bitcoin
|
|
7325
|
+
* @param maxValue {number|null} max possible value for cryptocurrency. Null means that the currency has no max possible value
|
|
7326
|
+
* @param atomName {string} name of the coin's atomic value. Like 'satoshi' for bitcoin
|
|
7327
|
+
* @param mainnet {Network} main network for this coin
|
|
7328
|
+
* @param testnet {Network} test network for this coin
|
|
7329
|
+
* @param minConfirmations {number} min confirmations count to treat the coin's transaction confirmed
|
|
7330
|
+
* @param payableEntityStringForFeeRate {string|null} the payable fee entity like byte for bitcoin or gas for ether if present
|
|
7331
|
+
* @param feeOptionsTimeStringsSortedDesc {string[]} array of 4 strings for fee options when sending coins. Should be sorted from the highest time to the smallest
|
|
7332
|
+
* @param feeRatesExpirationTimeMs {number} number of milliseconds to treat the fee rates as expired
|
|
7333
|
+
* @param blockchain {Blockchain} blockchain object
|
|
7334
|
+
* @param [protocol] {Protocol|null} token/coin protocol if relevant
|
|
7335
|
+
* @param [tokenAddress] {string|null} address of contract of this token (if the coin is token)
|
|
7336
|
+
* @param [doesUseLowerCaseAddresses] {boolean} flag to clarify whether we can use lower case addresses to ensure more robust comparisons
|
|
7337
|
+
* @param [doesUseOutputs=false] {boolean} true if this coin uses inputs/outputs concept and false if it uses just balances
|
|
7338
|
+
*/
|
|
7339
|
+
function Coin(latinName, ticker, tickerPrintable, digitsCountAfterComma, maxValue, atomName, mainnet, testnet, minConfirmations, payableEntityStringForFeeRate, feeOptionsTimeStringsSortedDesc, feeRatesExpirationTimeMs, blockchain, protocol, tokenAddress, doesUseLowerCaseAddresses, doesUseOutputs) {
|
|
7340
|
+
if (protocol === void 0) {
|
|
7341
|
+
protocol = null;
|
|
7342
|
+
}
|
|
7343
|
+
if (tokenAddress === void 0) {
|
|
7344
|
+
tokenAddress = null;
|
|
7345
|
+
}
|
|
7346
|
+
if (doesUseLowerCaseAddresses === void 0) {
|
|
7347
|
+
doesUseLowerCaseAddresses = true;
|
|
7348
|
+
}
|
|
7349
|
+
if (doesUseOutputs === void 0) {
|
|
7350
|
+
doesUseOutputs = false;
|
|
7351
|
+
}
|
|
7352
|
+
this.latinName = latinName;
|
|
7353
|
+
this.ticker = ticker;
|
|
7354
|
+
this.tickerPrintable = tickerPrintable;
|
|
7355
|
+
this.digits = digitsCountAfterComma;
|
|
7356
|
+
this.maxValue = maxValue;
|
|
7357
|
+
this.atomName = atomName;
|
|
7358
|
+
this.mainnet = mainnet;
|
|
7359
|
+
this.testnet = testnet;
|
|
7360
|
+
this.minConfirmations = minConfirmations;
|
|
7361
|
+
this.payableEntityStringForFeeRate = payableEntityStringForFeeRate;
|
|
7362
|
+
this.feeOptionsTimeStringsSortedDesc = feeOptionsTimeStringsSortedDesc;
|
|
7363
|
+
this.feeRatesExpirationTimeMs = feeRatesExpirationTimeMs;
|
|
7364
|
+
this.protocol = protocol;
|
|
7365
|
+
this.blockchain = blockchain;
|
|
7366
|
+
// TODO: [bug, critical] use testnet property for testnet contract address as it blocks the app work in testnets
|
|
7367
|
+
this.tokenAddress = tokenAddress;
|
|
7368
|
+
this.feeCoin = this;
|
|
7369
|
+
this._significantDigits = 8;
|
|
7370
|
+
this.doesUseLowerCaseAddresses = doesUseLowerCaseAddresses;
|
|
7371
|
+
this.doesUseOutputs = doesUseOutputs;
|
|
7372
|
+
}
|
|
7373
|
+
|
|
7374
|
+
/**
|
|
7375
|
+
* Sets fee coin
|
|
7376
|
+
*
|
|
7377
|
+
* @param feeCoin {Coin} some tokens use another coin to charge transaction fee as they work on top of some external
|
|
7378
|
+
* blockchain. So pass here the coin the token uses for fee charging. Like for ERC20 token the fee coin is ETH.
|
|
7379
|
+
* By default, the creating coin will be set as a value for this field.
|
|
7380
|
+
*/
|
|
7381
|
+
var _proto = Coin.prototype;
|
|
7382
|
+
_proto.setFeeCoin = function setFeeCoin(feeCoin) {
|
|
7383
|
+
this.feeCoin = feeCoin;
|
|
7384
|
+
}
|
|
7385
|
+
|
|
7386
|
+
/**
|
|
7387
|
+
* Checks whether this coin uses another coin (blockchain) to charge fee for transactions (means works on base of
|
|
7388
|
+
* some external blockchain).
|
|
7389
|
+
*
|
|
7390
|
+
* @return {boolean} true if this coin uses external blockchain to perform transactions and charge fee
|
|
7391
|
+
*/;
|
|
7392
|
+
_proto.doesUseDifferentCoinFee = function doesUseDifferentCoinFee() {
|
|
7393
|
+
return this.feeCoin !== this;
|
|
7394
|
+
}
|
|
7395
|
+
|
|
7396
|
+
/**
|
|
7397
|
+
* Converts the given atoms string/number to string representing the same amount in coin itself - floating point number
|
|
7398
|
+
*
|
|
7399
|
+
* @param atoms {string} atoms positive integer amount
|
|
7400
|
+
* @return {string} coin amount floating point number as a string
|
|
7401
|
+
*/;
|
|
7402
|
+
_proto.atomsToCoinAmount = function atomsToCoinAmount(atoms) {
|
|
7403
|
+
throw new Error("Not implemented in base Coin");
|
|
7404
|
+
}
|
|
7405
|
+
|
|
7406
|
+
/**
|
|
7407
|
+
* Converts the given coins amount string/number to string representing the same amount in coin atoms - integer number
|
|
7408
|
+
*
|
|
7409
|
+
* @param coinsAmount {string} coins positive floating point amount
|
|
7410
|
+
* @return {string} coin atoms amount integer number as a string
|
|
7411
|
+
*/;
|
|
7412
|
+
_proto.coinAmountToAtoms = function coinAmountToAtoms(coinsAmount) {
|
|
7413
|
+
throw new Error("Not implemented in base Coin");
|
|
7414
|
+
}
|
|
7415
|
+
|
|
7416
|
+
/**
|
|
7417
|
+
* Composes URL to view the tx with given id in the external blockchain explorer
|
|
7418
|
+
*
|
|
7419
|
+
* @param txId {string} id of transaction
|
|
7420
|
+
* @return {string} URL string
|
|
7421
|
+
*/;
|
|
7422
|
+
_proto.composeUrlToTransactionExplorer = function composeUrlToTransactionExplorer(txId) {
|
|
7423
|
+
throw new Error("Not implemented in base Coin");
|
|
7424
|
+
}
|
|
7425
|
+
|
|
7426
|
+
/**
|
|
7427
|
+
* Most of the cryptocurrencies has specific fee rate or fee price metric. This value usually has specific measure
|
|
7428
|
+
* like satoshi/byte or gWei/gas. This function adds the described denomination string to the given amount
|
|
7429
|
+
* as a suffix and returns the result string ready to be show to a user.
|
|
7430
|
+
*
|
|
7431
|
+
* @param coinAtomsString {string} coin atoms positive integer amount
|
|
7432
|
+
* @return {string} string of coin amount and fee rate units
|
|
7433
|
+
*/;
|
|
7434
|
+
_proto.coinAtomsFeeRateToCommonlyUsedAmountFormatWithDenominationString = function coinAtomsFeeRateToCommonlyUsedAmountFormatWithDenominationString(coinAtomsString) {
|
|
7435
|
+
throw new Error("Not implemented in base Coin");
|
|
7436
|
+
}
|
|
7437
|
+
|
|
7438
|
+
/**
|
|
7439
|
+
* Check whether this coin support transaction prioritisation during the sending process.
|
|
7440
|
+
*
|
|
7441
|
+
* @return {boolean} true if support transaction prioritisation and false otherwise
|
|
7442
|
+
*/;
|
|
7443
|
+
_proto.doesSupportTransactionPrioritisation = function doesSupportTransactionPrioritisation() {
|
|
7444
|
+
return Array.isArray(this.feeOptionsTimeStringsSortedDesc);
|
|
7445
|
+
};
|
|
7446
|
+
_proto.tickerAndProtocol = function tickerAndProtocol() {
|
|
7447
|
+
try {
|
|
7448
|
+
var _ref;
|
|
7449
|
+
return "" + this.tickerPrintable + (this.protocol ? (_ref = " " + this.protocol.protocol) != null ? _ref : "" : "");
|
|
7450
|
+
} catch (e) {
|
|
7451
|
+
improveAndRethrow(e, "tickerAndProtocol");
|
|
7452
|
+
}
|
|
7453
|
+
};
|
|
7454
|
+
return Coin;
|
|
7455
|
+
}();
|
|
7456
|
+
|
|
7457
|
+
var messageIcon = (function () {
|
|
7458
|
+
return /*#__PURE__*/React__default["default"].createElement("svg", {
|
|
7459
|
+
width: "130",
|
|
7460
|
+
height: "130",
|
|
7461
|
+
viewBox: "0 0 130 130",
|
|
7462
|
+
fill: "none",
|
|
7463
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
7481
7464
|
}, /*#__PURE__*/React__default["default"].createElement("path", {
|
|
7482
7465
|
"fill-rule": "evenodd",
|
|
7483
7466
|
"clip-rule": "evenodd",
|
|
7484
7467
|
d: "M65 130C100.899 130 130 100.899 130 65C130 29.1015 100.899 0 65 0C29.1015 0 0 29.1015 0 65C0 100.899 29.1015 130 65 130Z",
|
|
7485
|
-
fill: "#
|
|
7468
|
+
fill: "#2294F0"
|
|
7486
7469
|
}), /*#__PURE__*/React__default["default"].createElement("mask", {
|
|
7487
7470
|
id: "mask0",
|
|
7488
|
-
|
|
7471
|
+
style: {
|
|
7472
|
+
maskType: "alpha"
|
|
7473
|
+
},
|
|
7489
7474
|
maskUnits: "userSpaceOnUse",
|
|
7490
7475
|
x: "0",
|
|
7491
7476
|
y: "0",
|
|
@@ -7508,38 +7493,130 @@
|
|
|
7508
7493
|
fill: "white"
|
|
7509
7494
|
}), /*#__PURE__*/React__default["default"].createElement("rect", {
|
|
7510
7495
|
opacity: "0.3",
|
|
7511
|
-
x: "-48.
|
|
7496
|
+
x: "-48.4546",
|
|
7512
7497
|
y: "126.52",
|
|
7513
7498
|
width: "227.136",
|
|
7514
7499
|
height: "25.2373",
|
|
7515
|
-
transform: "rotate(-45 -48.
|
|
7500
|
+
transform: "rotate(-45 -48.4546 126.52)",
|
|
7501
|
+
fill: "white"
|
|
7502
|
+
}), /*#__PURE__*/React__default["default"].createElement("rect", {
|
|
7503
|
+
x: "27.75",
|
|
7504
|
+
y: "29.5",
|
|
7505
|
+
width: "74.5",
|
|
7506
|
+
height: "81.5",
|
|
7507
|
+
rx: "12",
|
|
7516
7508
|
fill: "white"
|
|
7517
7509
|
}), /*#__PURE__*/React__default["default"].createElement("path", {
|
|
7518
|
-
d: "
|
|
7519
|
-
fill: "
|
|
7510
|
+
d: "M27.75 41.5C27.75 34.8726 33.1226 29.5 39.75 29.5H90.25C96.8774 29.5 102.25 34.8726 102.25 41.5V118C102.25 124.627 96.8774 130 90.25 130H39.75C33.1226 130 27.75 124.627 27.75 118V41.5Z",
|
|
7511
|
+
fill: "white"
|
|
7520
7512
|
}), /*#__PURE__*/React__default["default"].createElement("path", {
|
|
7521
|
-
|
|
7513
|
+
"fill-rule": "evenodd",
|
|
7514
|
+
"clip-rule": "evenodd",
|
|
7515
|
+
d: "M51.5 63.5C58.1274 63.5 63.5 58.1274 63.5 51.5C63.5 44.8726 58.1274 39.5 51.5 39.5C44.8726 39.5 39.5 44.8726 39.5 51.5C39.5 58.1274 44.8726 63.5 51.5 63.5Z",
|
|
7516
|
+
fill: "#2294F0"
|
|
7517
|
+
}), /*#__PURE__*/React__default["default"].createElement("path", {
|
|
7518
|
+
d: "M50.072 49.088H52.03V54.5H50.072V49.088ZM52.074 46.382V48.153H50.028V46.382H52.074Z",
|
|
7522
7519
|
fill: "white"
|
|
7523
7520
|
}), /*#__PURE__*/React__default["default"].createElement("path", {
|
|
7524
|
-
opacity: "0.
|
|
7525
|
-
d: "
|
|
7526
|
-
|
|
7521
|
+
opacity: "0.2",
|
|
7522
|
+
d: "M41 74.5H63",
|
|
7523
|
+
stroke: "#2294F0",
|
|
7524
|
+
"stroke-width": "4",
|
|
7525
|
+
"stroke-linecap": "round",
|
|
7526
|
+
"stroke-linejoin": "round"
|
|
7527
7527
|
}), /*#__PURE__*/React__default["default"].createElement("path", {
|
|
7528
|
-
|
|
7529
|
-
|
|
7530
|
-
|
|
7528
|
+
opacity: "0.2",
|
|
7529
|
+
d: "M41 84.6157H84.1426",
|
|
7530
|
+
stroke: "#2294F0",
|
|
7531
|
+
"stroke-width": "4",
|
|
7531
7532
|
"stroke-linecap": "round",
|
|
7532
7533
|
"stroke-linejoin": "round"
|
|
7533
7534
|
}), /*#__PURE__*/React__default["default"].createElement("path", {
|
|
7534
|
-
|
|
7535
|
-
|
|
7536
|
-
|
|
7537
|
-
|
|
7538
|
-
|
|
7539
|
-
|
|
7540
|
-
|
|
7541
|
-
|
|
7542
|
-
|
|
7535
|
+
opacity: "0.2",
|
|
7536
|
+
d: "M41 94.7314H84.1426",
|
|
7537
|
+
stroke: "#2294F0",
|
|
7538
|
+
"stroke-width": "4",
|
|
7539
|
+
"stroke-linecap": "round",
|
|
7540
|
+
"stroke-linejoin": "round"
|
|
7541
|
+
}), /*#__PURE__*/React__default["default"].createElement("path", {
|
|
7542
|
+
opacity: "0.2",
|
|
7543
|
+
d: "M41 104.731H84.1426",
|
|
7544
|
+
stroke: "#2294F0",
|
|
7545
|
+
"stroke-width": "4",
|
|
7546
|
+
"stroke-linecap": "round",
|
|
7547
|
+
"stroke-linejoin": "round"
|
|
7548
|
+
})));
|
|
7549
|
+
});
|
|
7550
|
+
|
|
7551
|
+
var supportDialogImage = (function () {
|
|
7552
|
+
return /*#__PURE__*/React__default["default"].createElement("svg", {
|
|
7553
|
+
width: "130",
|
|
7554
|
+
height: "130",
|
|
7555
|
+
viewBox: "0 0 130 130",
|
|
7556
|
+
fill: "none",
|
|
7557
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
7558
|
+
}, /*#__PURE__*/React__default["default"].createElement("path", {
|
|
7559
|
+
"fill-rule": "evenodd",
|
|
7560
|
+
"clip-rule": "evenodd",
|
|
7561
|
+
d: "M65 130C100.899 130 130 100.899 130 65C130 29.1015 100.899 0 65 0C29.1015 0 0 29.1015 0 65C0 100.899 29.1015 130 65 130Z",
|
|
7562
|
+
fill: "#AFEBC3"
|
|
7563
|
+
}), /*#__PURE__*/React__default["default"].createElement("mask", {
|
|
7564
|
+
id: "mask0",
|
|
7565
|
+
"mask-type": "alpha",
|
|
7566
|
+
maskUnits: "userSpaceOnUse",
|
|
7567
|
+
x: "0",
|
|
7568
|
+
y: "0",
|
|
7569
|
+
width: "130",
|
|
7570
|
+
height: "130"
|
|
7571
|
+
}, /*#__PURE__*/React__default["default"].createElement("path", {
|
|
7572
|
+
"fill-rule": "evenodd",
|
|
7573
|
+
"clip-rule": "evenodd",
|
|
7574
|
+
d: "M65 130C100.899 130 130 100.899 130 65C130 29.1015 100.899 0 65 0C29.1015 0 0 29.1015 0 65C0 100.899 29.1015 130 65 130Z",
|
|
7575
|
+
fill: "white"
|
|
7576
|
+
})), /*#__PURE__*/React__default["default"].createElement("g", {
|
|
7577
|
+
mask: "url(#mask0)"
|
|
7578
|
+
}, /*#__PURE__*/React__default["default"].createElement("rect", {
|
|
7579
|
+
opacity: "0.3",
|
|
7580
|
+
x: "3.25",
|
|
7581
|
+
y: "150.776",
|
|
7582
|
+
width: "227.136",
|
|
7583
|
+
height: "25.2373",
|
|
7584
|
+
transform: "rotate(-45 3.25 150.776)",
|
|
7585
|
+
fill: "white"
|
|
7586
|
+
}), /*#__PURE__*/React__default["default"].createElement("rect", {
|
|
7587
|
+
opacity: "0.3",
|
|
7588
|
+
x: "-48.4545",
|
|
7589
|
+
y: "126.52",
|
|
7590
|
+
width: "227.136",
|
|
7591
|
+
height: "25.2373",
|
|
7592
|
+
transform: "rotate(-45 -48.4545 126.52)",
|
|
7593
|
+
fill: "white"
|
|
7594
|
+
}), /*#__PURE__*/React__default["default"].createElement("path", {
|
|
7595
|
+
d: "M9.69092 69.153C9.69092 66.0864 11.2523 63.2309 13.8339 61.576L55.8257 34.6583C61.4168 31.0742 68.5832 31.0742 74.1743 34.6583L116.166 61.576C118.748 63.2309 120.309 66.0864 120.309 69.153V126.495C120.309 131.466 116.28 135.495 111.309 135.495H18.6909C13.7204 135.495 9.69092 131.466 9.69092 126.495V69.153Z",
|
|
7596
|
+
fill: "#14A957"
|
|
7597
|
+
}), /*#__PURE__*/React__default["default"].createElement("path", {
|
|
7598
|
+
d: "M30.9045 51.8818H97.9136V117.118H30.9045V51.8818Z",
|
|
7599
|
+
fill: "white"
|
|
7600
|
+
}), /*#__PURE__*/React__default["default"].createElement("path", {
|
|
7601
|
+
opacity: "0.1",
|
|
7602
|
+
d: "M63.8182 107.167C76.8722 107.167 87.4545 96.5849 87.4545 83.5308C87.4545 70.4768 76.8722 59.8945 63.8182 59.8945C50.7642 59.8945 40.1818 70.4768 40.1818 83.5308C40.1818 96.5849 50.7642 107.167 63.8182 107.167Z",
|
|
7603
|
+
fill: "#24BE6A"
|
|
7604
|
+
}), /*#__PURE__*/React__default["default"].createElement("path", {
|
|
7605
|
+
d: "M58.2093 83.4849L63.0246 88.3002L71.3036 79.047",
|
|
7606
|
+
stroke: "#24BE6A",
|
|
7607
|
+
"stroke-width": "3.76358",
|
|
7608
|
+
"stroke-linecap": "round",
|
|
7609
|
+
"stroke-linejoin": "round"
|
|
7610
|
+
}), /*#__PURE__*/React__default["default"].createElement("path", {
|
|
7611
|
+
d: "M9.69092 70.2531C9.69092 68.672 11.4391 67.7161 12.7703 68.5694L65 102.05L117.23 68.5694C118.561 67.7161 120.309 68.672 120.309 70.2531V128.859C120.309 133.83 116.28 137.859 111.309 137.859H18.6909C13.7204 137.859 9.69092 133.83 9.69092 128.859V70.2531Z",
|
|
7612
|
+
fill: "#24BE6A"
|
|
7613
|
+
})));
|
|
7614
|
+
});
|
|
7615
|
+
|
|
7616
|
+
/**
|
|
7617
|
+
* Saves a user's subscription to receive notifications about a specific coin.
|
|
7618
|
+
* This function sends an email to subscribe the user to notifications for the specified coin.
|
|
7619
|
+
*
|
|
7543
7620
|
* @function
|
|
7544
7621
|
* @name saveSubscription
|
|
7545
7622
|
* @param {Coin} coin - The coin object containing information about the coin, including its ticker symbol.
|
|
@@ -7848,6 +7925,27 @@
|
|
|
7848
7925
|
return (getQueryParameterValues(name) || [])[0];
|
|
7849
7926
|
}
|
|
7850
7927
|
|
|
7928
|
+
/**
|
|
7929
|
+
* Major point of rabbit ticker format definition.
|
|
7930
|
+
* Our asset ticker format is just stick standard (printable) ticker with protocol code.
|
|
7931
|
+
* If protocol code is the same as asset ticker than it is not added.
|
|
7932
|
+
* Examples:
|
|
7933
|
+
* SHIBERC20 - shiba inu on ethereum,
|
|
7934
|
+
* TON - Ton coin on ton blockchain,
|
|
7935
|
+
* BTC - Bitcoin in BTC mainnet,
|
|
7936
|
+
* NOTTON - Notcoin in Ton blockchain
|
|
7937
|
+
*
|
|
7938
|
+
* @param standardPrintableTicker {string}
|
|
7939
|
+
* @param protocolOrNetworkCode {string}
|
|
7940
|
+
* @return {string}
|
|
7941
|
+
*/
|
|
7942
|
+
function toRabbitTicker(standardPrintableTicker, protocolOrNetworkCode) {
|
|
7943
|
+
if (typeof standardPrintableTicker !== "string" || typeof protocolOrNetworkCode !== "string" && protocolOrNetworkCode != null) throw new Error("Wrong ticker/protocol passed: " + standardPrintableTicker + ", " + protocolOrNetworkCode);
|
|
7944
|
+
var upperTicker = standardPrintableTicker.toUpperCase();
|
|
7945
|
+
var upperCode = (protocolOrNetworkCode != null ? protocolOrNetworkCode : "").toUpperCase();
|
|
7946
|
+
return "" + upperTicker + (upperCode === upperTicker ? "" : upperCode);
|
|
7947
|
+
}
|
|
7948
|
+
|
|
7851
7949
|
var Blockchain =
|
|
7852
7950
|
/**
|
|
7853
7951
|
* @param name {string} latin printable name of blockchain
|
|
@@ -10455,7 +10553,32 @@
|
|
|
10455
10553
|
return ExistingSwapWithFiatData;
|
|
10456
10554
|
}(ExistingSwap);
|
|
10457
10555
|
|
|
10458
|
-
var BaseSwapCreationInfo =
|
|
10556
|
+
var BaseSwapCreationInfo = /** @type {Coin} */
|
|
10557
|
+
|
|
10558
|
+
/** @type {Coin} */
|
|
10559
|
+
|
|
10560
|
+
/** @type {string} */
|
|
10561
|
+
|
|
10562
|
+
/** @type {string} */
|
|
10563
|
+
|
|
10564
|
+
/** @type {string} */
|
|
10565
|
+
|
|
10566
|
+
/** @type {Object} */
|
|
10567
|
+
|
|
10568
|
+
/** @type {string} */
|
|
10569
|
+
|
|
10570
|
+
/** @type {number} */
|
|
10571
|
+
|
|
10572
|
+
/** @type {string} */
|
|
10573
|
+
|
|
10574
|
+
/** @type {number} */
|
|
10575
|
+
|
|
10576
|
+
/** @type {string} */
|
|
10577
|
+
|
|
10578
|
+
/** @type {boolean} */
|
|
10579
|
+
|
|
10580
|
+
/** @type {boolean} */
|
|
10581
|
+
|
|
10459
10582
|
/**
|
|
10460
10583
|
* @param fromCoin {Coin}
|
|
10461
10584
|
* @param toCoin {Coin}
|
|
@@ -10497,7 +10620,42 @@
|
|
|
10497
10620
|
* 3. protocol should be null for coins major for their blockchains like BTC, ETH
|
|
10498
10621
|
* 4. isPopular should be a number - the higher -> the more popular
|
|
10499
10622
|
*/
|
|
10500
|
-
var SwapProviderCoinInfo =
|
|
10623
|
+
var SwapProviderCoinInfo = /** @type {Coin} */
|
|
10624
|
+
|
|
10625
|
+
/** @type {string} */
|
|
10626
|
+
|
|
10627
|
+
/** @type {string} */
|
|
10628
|
+
|
|
10629
|
+
/** @type {boolean} */
|
|
10630
|
+
|
|
10631
|
+
/** @type {string|null} */
|
|
10632
|
+
|
|
10633
|
+
/** @type {number} */
|
|
10634
|
+
|
|
10635
|
+
/** @type {string} */
|
|
10636
|
+
|
|
10637
|
+
/** @type {boolean} */
|
|
10638
|
+
|
|
10639
|
+
/** @type {boolean} */
|
|
10640
|
+
|
|
10641
|
+
/** @type {string|null} */
|
|
10642
|
+
|
|
10643
|
+
/** @type {boolean} */
|
|
10644
|
+
|
|
10645
|
+
/**
|
|
10646
|
+
* @param {string} coin - The name of the coin.
|
|
10647
|
+
* @param {string} code - The ticker code for the coin, e.g., USDTERC20.
|
|
10648
|
+
* @param {string} network - The network on which the coin operates.
|
|
10649
|
+
* @param {boolean} hasExtraId - Whether the coin requires an extra ID for transactions.
|
|
10650
|
+
* @param {string|null} extraIdName - The name of the extra ID, if applicable.
|
|
10651
|
+
* @param {number} popularity - A number indicating the popularity of the coin.
|
|
10652
|
+
* @param {string} [iconURL=FALLBACK_ASSET_ICON_URL] - The URL of the coin's icon. Falls back to a default value if not provided.
|
|
10653
|
+
* @param {boolean} [deposit=false] - Indicates whether deposits are supported. Defaults to `false`.
|
|
10654
|
+
* @param {boolean} [withdrawal=false] - Indicates whether withdrawals are supported. Defaults to `false`.
|
|
10655
|
+
* @param {string|null} [validationRegexp=null] - A regular expression for validating addresses, if applicable.
|
|
10656
|
+
* @param {boolean} [isAvailable=true] - Whether the coin is available for transactions. Defaults to `true`.
|
|
10657
|
+
*/
|
|
10658
|
+
function SwapProviderCoinInfo(coin, code, network, hasExtraId, extraIdName, popularity, iconURL, deposit, withdrawal, validationRegexp, isAvailable) {
|
|
10501
10659
|
this.coin = coin;
|
|
10502
10660
|
this.code = code;
|
|
10503
10661
|
this.network = network;
|
|
@@ -10526,7 +10684,23 @@
|
|
|
10526
10684
|
// "https://hamsterkombat.io/images/icons/hamster-coin.png"
|
|
10527
10685
|
true, true, "^(EQ|UQ)[A-Za-z0-9-_]{46}$", false)];
|
|
10528
10686
|
var SwapProvider = /*#__PURE__*/function () {
|
|
10529
|
-
|
|
10687
|
+
/** @type {string} */
|
|
10688
|
+
|
|
10689
|
+
/** @type {SwapProviderCoinInfo[]} */
|
|
10690
|
+
|
|
10691
|
+
/** @type {number} */
|
|
10692
|
+
|
|
10693
|
+
/** @type {number} */
|
|
10694
|
+
|
|
10695
|
+
/** @type {boolean} */
|
|
10696
|
+
|
|
10697
|
+
/** @type {function} */
|
|
10698
|
+
|
|
10699
|
+
/** @type {Cache} */
|
|
10700
|
+
|
|
10701
|
+
/** @type {boolean} */
|
|
10702
|
+
|
|
10703
|
+
function SwapProvider(id, cache, customCoinBuilder, useRestrictedCoinsSet) {
|
|
10530
10704
|
if (customCoinBuilder === void 0) {
|
|
10531
10705
|
customCoinBuilder = function customCoinBuilder(coin, network) {
|
|
10532
10706
|
return null;
|
|
@@ -10535,7 +10709,9 @@
|
|
|
10535
10709
|
if (useRestrictedCoinsSet === void 0) {
|
|
10536
10710
|
useRestrictedCoinsSet = true;
|
|
10537
10711
|
}
|
|
10712
|
+
this.id = id;
|
|
10538
10713
|
this._supportedCoins = [];
|
|
10714
|
+
this._supportedCoinsLastUpdateTimestamp = 0;
|
|
10539
10715
|
this._maxRateDigits = 20;
|
|
10540
10716
|
this.useRestrictedCoinsSet = useRestrictedCoinsSet;
|
|
10541
10717
|
this._customCoinBuilder = customCoinBuilder;
|
|
@@ -10544,8 +10720,24 @@
|
|
|
10544
10720
|
}
|
|
10545
10721
|
var _proto = SwapProvider.prototype;
|
|
10546
10722
|
/**
|
|
10547
|
-
*
|
|
10723
|
+
* Returns provider-specific identifiers exactly the way they defined in the provider API.
|
|
10724
|
+
* Usually providers have 2 identifiers - ticker/code/coin id and network/protocol.
|
|
10725
|
+
* So by default we return this set based in the coin info instance.
|
|
10726
|
+
* Should be redefined for dedicated providers if their ids logic differ.
|
|
10727
|
+
*
|
|
10728
|
+
* @param info {SwapProviderCoinInfo}
|
|
10729
|
+
* @return {{code: string, network: string|null}} null network means the coin is the major for its network like BTC and ETH
|
|
10548
10730
|
*/
|
|
10731
|
+
_proto.getIdsByCoinInfo = function getIdsByCoinInfo(info) {
|
|
10732
|
+
return {
|
|
10733
|
+
code: info.code,
|
|
10734
|
+
network: info.network
|
|
10735
|
+
};
|
|
10736
|
+
}
|
|
10737
|
+
|
|
10738
|
+
/**
|
|
10739
|
+
* @return {Promise<void>}
|
|
10740
|
+
*/;
|
|
10549
10741
|
_proto.initialize = function initialize() {
|
|
10550
10742
|
try {
|
|
10551
10743
|
var _this = this;
|
|
@@ -10592,6 +10784,10 @@
|
|
|
10592
10784
|
// By default, sort by the coin ticker
|
|
10593
10785
|
return i1.coin.ticker.localeCompare(i2.coin.ticker);
|
|
10594
10786
|
});
|
|
10787
|
+
};
|
|
10788
|
+
_proto._shouldCoinsListBeLoaded = function _shouldCoinsListBeLoaded() {
|
|
10789
|
+
var _this$_supportedCoins;
|
|
10790
|
+
return !((_this$_supportedCoins = this._supportedCoins) != null && _this$_supportedCoins.length) || !this._supportedCoinsLastUpdateTimestamp || this._supportedCoinsLastUpdateTimestamp + SwapProvider.COINS_EXPIRATION_TIME_MS < Date.now();
|
|
10595
10791
|
}
|
|
10596
10792
|
|
|
10597
10793
|
/**
|
|
@@ -10653,6 +10849,40 @@
|
|
|
10653
10849
|
return Promise.reject(e);
|
|
10654
10850
|
}
|
|
10655
10851
|
}
|
|
10852
|
+
/**
|
|
10853
|
+
* Retrieves all currencies supported by this swap provider with raw details.
|
|
10854
|
+
* Returns one of SwapProvider.COMMON_ERRORS in case of processable fail.
|
|
10855
|
+
*
|
|
10856
|
+
* @return {Promise<({ result: true, coinsInfo: SwapProviderCoinInfo[] }|{ result: false, reason: string })>}
|
|
10857
|
+
*/
|
|
10858
|
+
;
|
|
10859
|
+
_proto.getAllSupportedCurrenciesWithRawDetails = function getAllSupportedCurrenciesWithRawDetails() {
|
|
10860
|
+
try {
|
|
10861
|
+
var _this4 = this;
|
|
10862
|
+
var loggerSource = "getAllSupportedCurrenciesWithRawDetails";
|
|
10863
|
+
return Promise.resolve(_catch$4(function () {
|
|
10864
|
+
return Promise.resolve(_this4._fetchSupportedCurrenciesIfNeeded()).then(function () {
|
|
10865
|
+
var _this4$_supportedCoin;
|
|
10866
|
+
Logger.log("We have " + ((_this4$_supportedCoin = _this4._supportedCoins) == null ? void 0 : _this4$_supportedCoin.length) + " supported coins returning", loggerSource);
|
|
10867
|
+
return {
|
|
10868
|
+
result: true,
|
|
10869
|
+
coinsInfo: [].concat(_this4._supportedCoins)
|
|
10870
|
+
};
|
|
10871
|
+
});
|
|
10872
|
+
}, function (e) {
|
|
10873
|
+
var _e$response2;
|
|
10874
|
+
if ((e == null || (_e$response2 = e.response) == null ? void 0 : _e$response2.status) === 429) {
|
|
10875
|
+
return {
|
|
10876
|
+
result: false,
|
|
10877
|
+
reason: SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED
|
|
10878
|
+
};
|
|
10879
|
+
}
|
|
10880
|
+
improveAndRethrow(e, loggerSource);
|
|
10881
|
+
}));
|
|
10882
|
+
} catch (e) {
|
|
10883
|
+
return Promise.reject(e);
|
|
10884
|
+
}
|
|
10885
|
+
}
|
|
10656
10886
|
/**
|
|
10657
10887
|
* Retrieves all deposit currencies supported by this swap provider.
|
|
10658
10888
|
* Returns one of SwapProvider.COMMON_ERRORS in case of processable fail.
|
|
@@ -10662,15 +10892,15 @@
|
|
|
10662
10892
|
;
|
|
10663
10893
|
_proto.getDepositCurrencies = function getDepositCurrencies() {
|
|
10664
10894
|
try {
|
|
10665
|
-
var
|
|
10895
|
+
var _this5 = this;
|
|
10666
10896
|
var loggerSource = "getDepositCurrencies";
|
|
10667
10897
|
return Promise.resolve(_catch$4(function () {
|
|
10668
|
-
return Promise.resolve(
|
|
10669
|
-
var
|
|
10670
|
-
Logger.log("We have " + ((
|
|
10898
|
+
return Promise.resolve(_this5._fetchSupportedCurrenciesIfNeeded()).then(function () {
|
|
10899
|
+
var _this5$_supportedCoin;
|
|
10900
|
+
Logger.log("We have " + ((_this5$_supportedCoin = _this5._supportedCoins) == null ? void 0 : _this5$_supportedCoin.length) + " supported coins, getting depositable", loggerSource);
|
|
10671
10901
|
return {
|
|
10672
10902
|
result: true,
|
|
10673
|
-
coins:
|
|
10903
|
+
coins: _this5._supportedCoins.filter(function (item) {
|
|
10674
10904
|
return item.deposit;
|
|
10675
10905
|
}).map(function (item) {
|
|
10676
10906
|
return item.coin;
|
|
@@ -10678,8 +10908,8 @@
|
|
|
10678
10908
|
};
|
|
10679
10909
|
});
|
|
10680
10910
|
}, function (e) {
|
|
10681
|
-
var _e$
|
|
10682
|
-
if ((e == null || (_e$
|
|
10911
|
+
var _e$response3;
|
|
10912
|
+
if ((e == null || (_e$response3 = e.response) == null ? void 0 : _e$response3.status) === 429) {
|
|
10683
10913
|
return {
|
|
10684
10914
|
result: false,
|
|
10685
10915
|
reason: SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED
|
|
@@ -10704,15 +10934,15 @@
|
|
|
10704
10934
|
exceptCurrency = null;
|
|
10705
10935
|
}
|
|
10706
10936
|
try {
|
|
10707
|
-
var
|
|
10937
|
+
var _this6 = this;
|
|
10708
10938
|
var loggerSource = "getWithdrawalCurrencies";
|
|
10709
10939
|
return Promise.resolve(_catch$4(function () {
|
|
10710
|
-
return Promise.resolve(
|
|
10711
|
-
var
|
|
10712
|
-
Logger.log("We have " + ((
|
|
10940
|
+
return Promise.resolve(_this6._fetchSupportedCurrenciesIfNeeded()).then(function () {
|
|
10941
|
+
var _this6$_supportedCoin;
|
|
10942
|
+
Logger.log("We have " + ((_this6$_supportedCoin = _this6._supportedCoins) == null ? void 0 : _this6$_supportedCoin.length) + " supported coins, getting withdrawable", loggerSource);
|
|
10713
10943
|
return {
|
|
10714
10944
|
result: true,
|
|
10715
|
-
coins:
|
|
10945
|
+
coins: _this6._supportedCoins.filter(function (item) {
|
|
10716
10946
|
var _item$coin, _exceptCurrency;
|
|
10717
10947
|
return item.withdrawal && (!exceptCurrency || ((_item$coin = item.coin) == null ? void 0 : _item$coin.ticker) !== ((_exceptCurrency = exceptCurrency) == null ? void 0 : _exceptCurrency.ticker));
|
|
10718
10948
|
}).map(function (item) {
|
|
@@ -10721,8 +10951,8 @@
|
|
|
10721
10951
|
};
|
|
10722
10952
|
});
|
|
10723
10953
|
}, function (e) {
|
|
10724
|
-
var _e$
|
|
10725
|
-
if ((e == null || (_e$
|
|
10954
|
+
var _e$response4;
|
|
10955
|
+
if ((e == null || (_e$response4 = e.response) == null ? void 0 : _e$response4.status) === 429) {
|
|
10726
10956
|
return {
|
|
10727
10957
|
result: false,
|
|
10728
10958
|
reason: SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED
|
|
@@ -10744,18 +10974,18 @@
|
|
|
10744
10974
|
_proto.getIconUrl = function getIconUrl(coinOrTicker) {
|
|
10745
10975
|
var loggerSource = "getIconUrl";
|
|
10746
10976
|
try {
|
|
10747
|
-
var _this$
|
|
10977
|
+
var _this$_supportedCoins3, _this$_supportedCoins4;
|
|
10748
10978
|
var coin = coinOrTicker;
|
|
10749
10979
|
if (!(coinOrTicker instanceof Coin)) {
|
|
10750
|
-
var _this$
|
|
10751
|
-
coin = (_this$
|
|
10980
|
+
var _this$_supportedCoins2;
|
|
10981
|
+
coin = (_this$_supportedCoins2 = this._supportedCoins.find(function (i) {
|
|
10752
10982
|
return i.coin.ticker === coinOrTicker;
|
|
10753
|
-
})) == null ? void 0 : _this$
|
|
10983
|
+
})) == null ? void 0 : _this$_supportedCoins2.coin;
|
|
10754
10984
|
}
|
|
10755
|
-
return (_this$
|
|
10985
|
+
return (_this$_supportedCoins3 = (_this$_supportedCoins4 = this._supportedCoins.find(function (item) {
|
|
10756
10986
|
var _item$coin2, _coin;
|
|
10757
10987
|
return ((_item$coin2 = item.coin) == null ? void 0 : _item$coin2.ticker) === ((_coin = coin) == null ? void 0 : _coin.ticker);
|
|
10758
|
-
})) == null ? void 0 : _this$
|
|
10988
|
+
})) == null ? void 0 : _this$_supportedCoins4.iconURL) != null ? _this$_supportedCoins3 : FALLBACK_ASSET_ICON_URL;
|
|
10759
10989
|
} catch (e) {
|
|
10760
10990
|
improveAndRethrow(e, loggerSource);
|
|
10761
10991
|
}
|
|
@@ -10764,43 +10994,44 @@
|
|
|
10764
10994
|
/**
|
|
10765
10995
|
* Retrieves coin to USDT rate.
|
|
10766
10996
|
*
|
|
10767
|
-
* @param
|
|
10997
|
+
* @param coinOrTicker {Coin|string}
|
|
10768
10998
|
* @return {{result: true, rate: string}|null}
|
|
10769
10999
|
*/;
|
|
10770
|
-
_proto.getCoinToUSDTRate = function getCoinToUSDTRate(
|
|
11000
|
+
_proto.getCoinToUSDTRate = function getCoinToUSDTRate(coinOrTicker) {
|
|
10771
11001
|
try {
|
|
10772
|
-
var
|
|
11002
|
+
var _this7 = this;
|
|
10773
11003
|
var loggerSource = "getCoinToUSDTRate";
|
|
10774
11004
|
return Promise.resolve(_catch$4(function () {
|
|
10775
|
-
return
|
|
10776
|
-
var
|
|
10777
|
-
var
|
|
10778
|
-
|
|
11005
|
+
return coinOrTicker ? Promise.resolve(_this7._fetchSupportedCurrenciesIfNeeded()).then(function () {
|
|
11006
|
+
var _this7$_supportedCoin;
|
|
11007
|
+
var ticker = coinOrTicker instanceof Coin ? coinOrTicker.ticker : coinOrTicker;
|
|
11008
|
+
var coin = _this7.getCoinByTickerIfPresent(ticker);
|
|
11009
|
+
if (!coin) return null;
|
|
10779
11010
|
|
|
10780
11011
|
// Using USDT TRC20 as usually fee in this network is smaller than ERC20 and this network is widely used for USDT
|
|
10781
11012
|
// This calculation is not precise as we cannot recognize the actual fee and network fee. Just approximate.
|
|
10782
|
-
// fee is
|
|
10783
|
-
var usdtTrc20 = (
|
|
11013
|
+
// standard market fee is about 0.4% usually
|
|
11014
|
+
var usdtTrc20 = (_this7$_supportedCoin = _this7._supportedCoins.find(function (i) {
|
|
10784
11015
|
return i.coin.ticker === "USDTTRC20";
|
|
10785
|
-
})) == null ? void 0 :
|
|
11016
|
+
})) == null ? void 0 : _this7$_supportedCoin.coin;
|
|
10786
11017
|
if (!usdtTrc20) {
|
|
10787
11018
|
return null;
|
|
10788
11019
|
}
|
|
10789
|
-
var cached =
|
|
11020
|
+
var cached = _this7._cache.get("swapspace_usdt_rate_" + ticker);
|
|
10790
11021
|
if (cached != null) {
|
|
10791
11022
|
return {
|
|
10792
11023
|
result: true,
|
|
10793
11024
|
rate: cached
|
|
10794
11025
|
};
|
|
10795
11026
|
}
|
|
10796
|
-
Logger.log("Loading USDT->coin rate as not found in cache:",
|
|
10797
|
-
return Promise.resolve(
|
|
11027
|
+
Logger.log("Loading USDT->coin rate as not found in cache:", ticker);
|
|
11028
|
+
return Promise.resolve(_this7.getSwapInfo(usdtTrc20, coin, "5000", false)).then(function (result) {
|
|
10798
11029
|
if (!result.result) {
|
|
10799
11030
|
return null;
|
|
10800
11031
|
}
|
|
10801
11032
|
var standardSwapspaceFeeMultiplier = 1.004;
|
|
10802
11033
|
var rate = bignumber_js.BigNumber(1).div(bignumber_js.BigNumber(result.rate).times(standardSwapspaceFeeMultiplier)).toString();
|
|
10803
|
-
|
|
11034
|
+
_this7._cache.put("swap_usdt_rate_" + ticker, rate, 10 * 60000 // 15 minutes
|
|
10804
11035
|
);
|
|
10805
11036
|
return {
|
|
10806
11037
|
result: true,
|
|
@@ -10828,6 +11059,7 @@
|
|
|
10828
11059
|
* @param [fromCoinToUsdRate=null] pass if you want to increase the min amount returned
|
|
10829
11060
|
* by provider with some fixed "insurance" amount to cover min amount fluctuations.
|
|
10830
11061
|
* @param [amountIsToReceive=false] {boolean} whether the given amount is receiving amount. False means the amount is the sending amount.
|
|
11062
|
+
* @param [bannedPartners=[]] {string[]} list of ids of banned partners to be excluded from list, suitable only for swap aggregators
|
|
10831
11063
|
* @return {Promise<({
|
|
10832
11064
|
* result: false,
|
|
10833
11065
|
* reason: string,
|
|
@@ -10847,7 +11079,7 @@
|
|
|
10847
11079
|
* })>}
|
|
10848
11080
|
*/
|
|
10849
11081
|
;
|
|
10850
|
-
_proto.getSwapInfo = function getSwapInfo(fromCoin, toCoin, amountCoins, fixed, fromCoinToUsdRate, amountIsToReceive) {
|
|
11082
|
+
_proto.getSwapInfo = function getSwapInfo(fromCoin, toCoin, amountCoins, fixed, fromCoinToUsdRate, amountIsToReceive, bannedPartners) {
|
|
10851
11083
|
try {
|
|
10852
11084
|
throw new Error("Not implemented in base");
|
|
10853
11085
|
} catch (e) {
|
|
@@ -11006,6 +11238,7 @@
|
|
|
11006
11238
|
};
|
|
11007
11239
|
return SwapProvider;
|
|
11008
11240
|
}();
|
|
11241
|
+
SwapProvider.COINS_EXPIRATION_TIME_MS = 5 * 60 * 1000;
|
|
11009
11242
|
SwapProvider.COMMON_ERRORS = {
|
|
11010
11243
|
REQUESTS_LIMIT_EXCEEDED: "requestsLimitExceeded"
|
|
11011
11244
|
};
|
|
@@ -11031,9 +11264,36 @@
|
|
|
11031
11264
|
FAILED: "failed"
|
|
11032
11265
|
};
|
|
11033
11266
|
|
|
11034
|
-
var Partner =
|
|
11267
|
+
var Partner =
|
|
11268
|
+
/**
|
|
11269
|
+
* Rabbit id for partner.
|
|
11270
|
+
*
|
|
11271
|
+
* @type {string}
|
|
11272
|
+
* */
|
|
11273
|
+
|
|
11274
|
+
/** @type {string} */
|
|
11275
|
+
|
|
11276
|
+
/** @type {string|undefined|null} */
|
|
11277
|
+
|
|
11278
|
+
/** @type {string|null} */
|
|
11279
|
+
|
|
11280
|
+
function Partner(id, name, logoUrl, kycLevel) {
|
|
11281
|
+
var _Object$values$find;
|
|
11282
|
+
if (kycLevel === void 0) {
|
|
11283
|
+
kycLevel = null;
|
|
11284
|
+
}
|
|
11285
|
+
this.id = id;
|
|
11035
11286
|
this.name = name;
|
|
11036
11287
|
this.logoUrl = logoUrl;
|
|
11288
|
+
this.kycLevel = (_Object$values$find = Object.values(KYC_LEVELS).find(function (level) {
|
|
11289
|
+
var _kycLevel;
|
|
11290
|
+
return level === ((_kycLevel = kycLevel) != null ? _kycLevel : "").toLowerCase();
|
|
11291
|
+
})) != null ? _Object$values$find : null;
|
|
11292
|
+
};
|
|
11293
|
+
var KYC_LEVELS = {
|
|
11294
|
+
LOW: "low",
|
|
11295
|
+
MEDIUM: "medium",
|
|
11296
|
+
HIGH: "high"
|
|
11037
11297
|
};
|
|
11038
11298
|
|
|
11039
11299
|
function _catch$3(body, recover) {
|
|
@@ -11047,10 +11307,18 @@
|
|
|
11047
11307
|
}
|
|
11048
11308
|
return result;
|
|
11049
11309
|
}
|
|
11050
|
-
var BANNED_PARTNERS = ["stealthex", "changee", "coincraddle", "easybit"];
|
|
11051
11310
|
var SwapspaceSwapProvider = /*#__PURE__*/function (_SwapProvider) {
|
|
11052
11311
|
_inheritsLoose(SwapspaceSwapProvider, _SwapProvider);
|
|
11053
|
-
|
|
11312
|
+
/**
|
|
11313
|
+
* You should pass either proxy URL or the API key
|
|
11314
|
+
*
|
|
11315
|
+
* @param apiKeysProxyUrl {string|null}
|
|
11316
|
+
* @param cache {Cache}
|
|
11317
|
+
* @param [customCoinBuilder] {function}
|
|
11318
|
+
* @param [useRestrictedCoinsSet=true] {boolean}
|
|
11319
|
+
* @param [apiKey] {string|null}
|
|
11320
|
+
*/
|
|
11321
|
+
function SwapspaceSwapProvider(apiKeysProxyUrl, cache, customCoinBuilder, useRestrictedCoinsSet, apiKey) {
|
|
11054
11322
|
var _this;
|
|
11055
11323
|
if (customCoinBuilder === void 0) {
|
|
11056
11324
|
customCoinBuilder = function customCoinBuilder(coin, network) {
|
|
@@ -11060,9 +11328,15 @@
|
|
|
11060
11328
|
if (useRestrictedCoinsSet === void 0) {
|
|
11061
11329
|
useRestrictedCoinsSet = true;
|
|
11062
11330
|
}
|
|
11063
|
-
|
|
11331
|
+
if (apiKey === void 0) {
|
|
11332
|
+
apiKey = null;
|
|
11333
|
+
}
|
|
11334
|
+
_this = _SwapProvider.call(this, "swapspace", cache, customCoinBuilder, useRestrictedCoinsSet) || this;
|
|
11064
11335
|
_this._partners = [];
|
|
11065
|
-
_this._URL = apiKeysProxyUrl + "/
|
|
11336
|
+
_this._URL = apiKey ? "https://api.swapspace.co" : apiKeysProxyUrl + "/" + _this.id;
|
|
11337
|
+
_this._headers = apiKey ? {
|
|
11338
|
+
Authorization: apiKey
|
|
11339
|
+
} : {};
|
|
11066
11340
|
_this.isAggregator = true;
|
|
11067
11341
|
return _this;
|
|
11068
11342
|
}
|
|
@@ -11077,15 +11351,17 @@
|
|
|
11077
11351
|
var _this2 = this;
|
|
11078
11352
|
var loggerSource = "_fetchSupportedCurrenciesIfNeeded";
|
|
11079
11353
|
return Promise.resolve(_catch$3(function () {
|
|
11080
|
-
var _temp = function (
|
|
11081
|
-
if (
|
|
11082
|
-
return Promise.resolve(axios__default["default"].get(_this2._URL + "/api/v2/currencies"
|
|
11354
|
+
var _temp = function () {
|
|
11355
|
+
if (_this2._shouldCoinsListBeLoaded()) {
|
|
11356
|
+
return Promise.resolve(axios__default["default"].get(_this2._URL + "/api/v2/currencies", {
|
|
11357
|
+
headers: _this2._headers
|
|
11358
|
+
})).then(function (rawResponse) {
|
|
11083
11359
|
var _rawResponse$data, _rawResponse$data2;
|
|
11084
11360
|
Logger.log("Retrieved " + (rawResponse == null || (_rawResponse$data = rawResponse.data) == null ? void 0 : _rawResponse$data.length), loggerSource);
|
|
11085
11361
|
var allowedCoins = (_rawResponse$data2 = rawResponse == null ? void 0 : rawResponse.data) != null ? _rawResponse$data2 : [];
|
|
11086
11362
|
Logger.log("Allowed cnt " + allowedCoins.length, loggerSource);
|
|
11087
11363
|
_this2._supportedCoins = allowedCoins.map(function (item) {
|
|
11088
|
-
var coin = _this2._customCoinBuilder(item.code, item.network);
|
|
11364
|
+
var coin = _this2._customCoinBuilder != null ? _this2._customCoinBuilder(item.code, item.network) : null;
|
|
11089
11365
|
if (!coin && !_this2.useRestrictedCoinsSet) {
|
|
11090
11366
|
/** Building coin object for coin that isn't supported OOB in Rabbit.
|
|
11091
11367
|
* We are doing this way to be able to use extended coins set for swaps.
|
|
@@ -11101,7 +11377,7 @@
|
|
|
11101
11377
|
* from coin object rather than counting on having it in the coin name itself.
|
|
11102
11378
|
* This processing is needed due to poor quality of swapspace coins names. */
|
|
11103
11379
|
var name = _this2.removeProtocolNameFromCoinName(item.name, code, network);
|
|
11104
|
-
var ticker =
|
|
11380
|
+
var ticker = toRabbitTicker(code, network);
|
|
11105
11381
|
var defaultDecimalPlacesForCoinNotSupportedOOB = 8;
|
|
11106
11382
|
var defaultMinConfirmationsForCoinNotSupportedOOB = 1;
|
|
11107
11383
|
coin = new Coin(name, ticker, code, defaultDecimalPlacesForCoinNotSupportedOOB, null, "", null, null, defaultMinConfirmationsForCoinNotSupportedOOB, null, [], 60000, null,
|
|
@@ -11114,6 +11390,7 @@
|
|
|
11114
11390
|
}
|
|
11115
11391
|
return [];
|
|
11116
11392
|
}).flat();
|
|
11393
|
+
_this2._supportedCoinsLastUpdateTimestamp = Date.now();
|
|
11117
11394
|
_this2._putPopularCoinsFirst();
|
|
11118
11395
|
return Promise.resolve(_SwapProvider.prototype._fetchSupportedCurrenciesIfNeeded.call(_this2)).then(function () {});
|
|
11119
11396
|
});
|
|
@@ -11134,7 +11411,9 @@
|
|
|
11134
11411
|
return Promise.resolve(_catch$3(function () {
|
|
11135
11412
|
var _temp2 = function (_this3$_partners) {
|
|
11136
11413
|
if (((_this3$_partners = _this3._partners) == null ? void 0 : _this3$_partners.length) === 0) {
|
|
11137
|
-
return Promise.resolve(axios__default["default"].get(_this3._URL + "/api/v2/partners"
|
|
11414
|
+
return Promise.resolve(axios__default["default"].get(_this3._URL + "/api/v2/partners", {
|
|
11415
|
+
headers: _this3._headers
|
|
11416
|
+
})).then(function (rawResponse) {
|
|
11138
11417
|
var _rawResponse$data3;
|
|
11139
11418
|
Logger.log("Retrieved " + (rawResponse == null || (_rawResponse$data3 = rawResponse.data) == null ? void 0 : _rawResponse$data3.length) + " partners", loggerSource);
|
|
11140
11419
|
_this3._partners = Array.isArray(rawResponse == null ? void 0 : rawResponse.data) ? rawResponse == null ? void 0 : rawResponse.data : [];
|
|
@@ -11149,7 +11428,7 @@
|
|
|
11149
11428
|
return Promise.reject(e);
|
|
11150
11429
|
}
|
|
11151
11430
|
};
|
|
11152
|
-
_proto.getSwapInfo = function getSwapInfo(fromCoin, toCoin, amountCoins, fixed, fromCoinToUsdRate, amountIsToReceive) {
|
|
11431
|
+
_proto.getSwapInfo = function getSwapInfo(fromCoin, toCoin, amountCoins, fixed, fromCoinToUsdRate, amountIsToReceive, bannedPartners) {
|
|
11153
11432
|
if (fixed === void 0) {
|
|
11154
11433
|
fixed = false;
|
|
11155
11434
|
}
|
|
@@ -11159,6 +11438,9 @@
|
|
|
11159
11438
|
if (amountIsToReceive === void 0) {
|
|
11160
11439
|
amountIsToReceive = false;
|
|
11161
11440
|
}
|
|
11441
|
+
if (bannedPartners === void 0) {
|
|
11442
|
+
bannedPartners = [];
|
|
11443
|
+
}
|
|
11162
11444
|
try {
|
|
11163
11445
|
var _this4 = this;
|
|
11164
11446
|
var loggerSource = "getSwapInfo";
|
|
@@ -11167,148 +11449,156 @@
|
|
|
11167
11449
|
if (!(fromCoin instanceof Coin) || !(toCoin instanceof Coin) || typeof amountCoins !== "string" || bignumber_js.BigNumber(amountCoins).lt("0") || fixed !== null && typeof fixed !== "boolean") {
|
|
11168
11450
|
throw new Error("Wrong input params: " + amountCoins + " " + fromCoin.ticker + " -> " + toCoin.ticker + ", " + (fromCoin instanceof Coin) + ", " + (toCoin instanceof Coin) + ", " + typeof fixed + " " + fixed);
|
|
11169
11451
|
}
|
|
11170
|
-
|
|
11171
|
-
var
|
|
11172
|
-
|
|
11173
|
-
|
|
11174
|
-
|
|
11175
|
-
var
|
|
11176
|
-
|
|
11177
|
-
|
|
11178
|
-
return !fromCoinSwapspaceDetails || !toCoinSwapspaceDetails || !fromCoinSwapspaceDetails.deposit || !toCoinSwapspaceDetails.withdrawal || !fromCoinSwapspaceDetails.isAvailable || !toCoinSwapspaceDetails.isAvailable ? {
|
|
11179
|
-
result: false,
|
|
11180
|
-
reason: SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED
|
|
11181
|
-
} : Promise.resolve(axios__default["default"].get(_this4._URL + "/api/v2/amounts?fromCurrency=" + fromCoinSwapspaceDetails.code + "&fromNetwork=" + fromCoinSwapspaceDetails.network + "&toNetwork=" + toCoinSwapspaceDetails.network + "&toCurrency=" + toCoinSwapspaceDetails.code + "&amount=" + amountCoins + "&estimated=false")).then(function (response) {
|
|
11182
|
-
var _response$data, _exchangesSupportingT;
|
|
11183
|
-
var _exit;
|
|
11184
|
-
function _temp4(_result2) {
|
|
11185
|
-
if (_exit) return _result2;
|
|
11186
|
-
var result = {
|
|
11187
|
-
result: false,
|
|
11188
|
-
reason: smallestMin && bignumber_js.BigNumber(amountCoins).lt(smallestMin) ? SwapProvider.NO_SWAPS_REASONS.TOO_LOW : greatestMax && bignumber_js.BigNumber(amountCoins).gt(greatestMax) ? SwapProvider.NO_SWAPS_REASONS.TOO_HIGH : SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED,
|
|
11189
|
-
smallestMin: smallestMin,
|
|
11190
|
-
greatestMax: greatestMax
|
|
11191
|
-
};
|
|
11192
|
-
Logger.log("Returning result " + safeStringify(result), loggerSource);
|
|
11193
|
-
return result;
|
|
11194
|
-
}
|
|
11195
|
-
Logger.log("Retrieved " + (response == null || (_response$data = response.data) == null ? void 0 : _response$data.length) + " options", loggerSource);
|
|
11196
|
-
var options = Array.isArray(response.data) ? response.data : [];
|
|
11197
|
-
// TODO: [feature, high] remove if possible over-engineering about toAmount = 0 options treating as supported but not available. task_id=404ae30d9a7743238af3cc0d3bae9239
|
|
11198
|
-
var exchangesSupportingThePairDespiteFixedOrFloating = options.filter(function (exchange) {
|
|
11199
|
-
return (exchange == null ? void 0 : exchange.exists) && !BANNED_PARTNERS.find(function (bannedPartner) {
|
|
11200
|
-
return bannedPartner === (exchange == null ? void 0 : exchange.partner);
|
|
11201
|
-
}) && ((exchange == null ? void 0 : exchange.fixed) === false || (exchange == null ? void 0 : exchange.fixed) === true) && typeof exchange.toAmount === "number" && (typeof exchange.min === "number" && typeof exchange.max === "number" || exchange.toAmount > 0) && (exchange.min === 0 || exchange.max === 0 || exchange.max > exchange.min);
|
|
11452
|
+
return Promise.resolve(_this4._fetchSupportedCurrenciesIfNeeded()).then(function () {
|
|
11453
|
+
var fromCoinSwapspaceDetails = _this4._supportedCoins.find(function (i) {
|
|
11454
|
+
var _i$coin;
|
|
11455
|
+
return ((_i$coin = i.coin) == null ? void 0 : _i$coin.ticker) === (fromCoin == null ? void 0 : fromCoin.ticker);
|
|
11456
|
+
});
|
|
11457
|
+
var toCoinSwapspaceDetails = _this4._supportedCoins.find(function (i) {
|
|
11458
|
+
var _i$coin2;
|
|
11459
|
+
return ((_i$coin2 = i.coin) == null ? void 0 : _i$coin2.ticker) === (toCoin == null ? void 0 : toCoin.ticker);
|
|
11202
11460
|
});
|
|
11203
|
-
|
|
11204
|
-
|
|
11205
|
-
|
|
11206
|
-
|
|
11461
|
+
return !fromCoinSwapspaceDetails || !toCoinSwapspaceDetails || !fromCoinSwapspaceDetails.deposit || !toCoinSwapspaceDetails.withdrawal || !fromCoinSwapspaceDetails.isAvailable || !toCoinSwapspaceDetails.isAvailable ? {
|
|
11462
|
+
result: false,
|
|
11463
|
+
reason: SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED
|
|
11464
|
+
} : Promise.resolve(axios__default["default"].get(_this4._URL + "/api/v2/amounts?fromCurrency=" + fromCoinSwapspaceDetails.code + "&fromNetwork=" + fromCoinSwapspaceDetails.network + "&toNetwork=" + toCoinSwapspaceDetails.network + "&toCurrency=" + toCoinSwapspaceDetails.code + "&amount=" + amountCoins + "&estimated=false", {
|
|
11465
|
+
headers: _this4._headers
|
|
11466
|
+
})).then(function (response) {
|
|
11467
|
+
var _response$data, _exchangesSupportingT;
|
|
11468
|
+
var _exit;
|
|
11469
|
+
function _temp4(_result) {
|
|
11470
|
+
if (_exit) return _result;
|
|
11471
|
+
var result = {
|
|
11472
|
+
result: false,
|
|
11473
|
+
reason: smallestMin && bignumber_js.BigNumber(amountCoins).lt(smallestMin) ? SwapProvider.NO_SWAPS_REASONS.TOO_LOW : greatestMax && bignumber_js.BigNumber(amountCoins).gt(greatestMax) ? SwapProvider.NO_SWAPS_REASONS.TOO_HIGH : SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED,
|
|
11474
|
+
smallestMin: smallestMin,
|
|
11475
|
+
greatestMax: greatestMax
|
|
11476
|
+
};
|
|
11477
|
+
Logger.log("Returning result " + safeStringify(result), loggerSource);
|
|
11478
|
+
return result;
|
|
11479
|
+
}
|
|
11480
|
+
Logger.log("Retrieved " + (response == null || (_response$data = response.data) == null ? void 0 : _response$data.length) + " options", loggerSource);
|
|
11481
|
+
var options = Array.isArray(response.data) ? response.data : [];
|
|
11482
|
+
// TODO: [feature, high] remove if possible over-engineering about toAmount = 0 options treating as supported but not available. task_id=404ae30d9a7743238af3cc0d3bae9239
|
|
11483
|
+
var exchangesSupportingThePairDespiteFixedOrFloating = options.filter(function (exchange) {
|
|
11484
|
+
return (exchange == null ? void 0 : exchange.exists) && !bannedPartners.find(function (bannedPartner) {
|
|
11485
|
+
return bannedPartner === (exchange == null ? void 0 : exchange.partner);
|
|
11486
|
+
}) && ((exchange == null ? void 0 : exchange.fixed) === false || (exchange == null ? void 0 : exchange.fixed) === true) && typeof exchange.toAmount === "number" && (typeof exchange.min === "number" && typeof exchange.max === "number" || exchange.toAmount > 0) && (exchange.min === 0 || exchange.max === 0 || exchange.max > exchange.min);
|
|
11207
11487
|
});
|
|
11208
|
-
|
|
11209
|
-
|
|
11210
|
-
|
|
11211
|
-
|
|
11488
|
+
var exchangesSupportingThePair = exchangesSupportingThePairDespiteFixedOrFloating;
|
|
11489
|
+
if (fixed != null) {
|
|
11490
|
+
exchangesSupportingThePair = exchangesSupportingThePairDespiteFixedOrFloating.filter(function (option) {
|
|
11491
|
+
return option.fixed === fixed;
|
|
11492
|
+
});
|
|
11493
|
+
}
|
|
11494
|
+
Logger.log(((_exchangesSupportingT = exchangesSupportingThePair) == null ? void 0 : _exchangesSupportingT.length) + " of them have exist=true", loggerSource);
|
|
11495
|
+
if (exchangesSupportingThePair.length === 0) {
|
|
11496
|
+
if (exchangesSupportingThePairDespiteFixedOrFloating.length > 0 && fixed !== null) {
|
|
11497
|
+
return {
|
|
11498
|
+
result: false,
|
|
11499
|
+
reason: fixed ? SwapProvider.NO_SWAPS_REASONS.NO_FIXED_BUT_HAVE_FLOATING : SwapProvider.NO_SWAPS_REASONS.NO_FLOATING_BUT_HAVE_FIXED
|
|
11500
|
+
};
|
|
11501
|
+
}
|
|
11212
11502
|
return {
|
|
11213
11503
|
result: false,
|
|
11214
|
-
reason:
|
|
11504
|
+
reason: SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED
|
|
11215
11505
|
};
|
|
11216
11506
|
}
|
|
11217
|
-
|
|
11218
|
-
|
|
11219
|
-
|
|
11220
|
-
|
|
11221
|
-
|
|
11222
|
-
|
|
11223
|
-
|
|
11224
|
-
|
|
11225
|
-
|
|
11226
|
-
|
|
11227
|
-
|
|
11228
|
-
|
|
11229
|
-
|
|
11230
|
-
}) == null) {
|
|
11231
|
-
smallestMin = exchangesSupportingThePair.reduce(function (prev, cur) {
|
|
11232
|
-
if (typeof cur.min === "number" && (prev === null || bignumber_js.BigNumber(cur.min).lt(prev))) return bignumber_js.BigNumber(cur.min);
|
|
11233
|
-
return prev;
|
|
11234
|
-
}, null);
|
|
11235
|
-
}
|
|
11236
|
-
var greatestMax = null;
|
|
11237
|
-
if (exchangesSupportingThePair.find(function (ex) {
|
|
11238
|
-
return bignumber_js.BigNumber(ex.max).isZero();
|
|
11239
|
-
}) == null) {
|
|
11240
|
-
greatestMax = exchangesSupportingThePair.reduce(function (prev, cur) {
|
|
11241
|
-
if (typeof cur.max === "number" && (prev === null || bignumber_js.BigNumber(cur.max).gt(prev))) return bignumber_js.BigNumber(cur.max);
|
|
11242
|
-
return prev;
|
|
11243
|
-
}, null);
|
|
11244
|
-
}
|
|
11245
|
-
var extraCoinsToFitMinMax = "0";
|
|
11246
|
-
if (typeof fromCoinToUsdRate === "string" && bignumber_js.BigNumber(fromCoinToUsdRate).gt("0")) {
|
|
11247
|
-
var extraUsdToFitMinMax = bignumber_js.BigNumber("1"); // We correct the limits as the exact limit can fluctuate and cause failed swap creation
|
|
11248
|
-
extraCoinsToFitMinMax = AmountUtils.trim(extraUsdToFitMinMax.div(fromCoinToUsdRate), fromCoin.digits);
|
|
11249
|
-
}
|
|
11250
|
-
if (smallestMin instanceof bignumber_js.BigNumber) {
|
|
11251
|
-
smallestMin = AmountUtils.trim(smallestMin.plus(extraCoinsToFitMinMax), fromCoin.digits);
|
|
11252
|
-
}
|
|
11253
|
-
if (greatestMax instanceof bignumber_js.BigNumber) {
|
|
11254
|
-
if (greatestMax > extraCoinsToFitMinMax) {
|
|
11255
|
-
greatestMax = AmountUtils.trim(greatestMax.minus(extraCoinsToFitMinMax), fromCoin.digits);
|
|
11256
|
-
} else {
|
|
11257
|
-
greatestMax = "0";
|
|
11507
|
+
var availableExchanges = exchangesSupportingThePair.filter(function (exchange) {
|
|
11508
|
+
return typeof (exchange == null ? void 0 : exchange.toAmount) === "number" && exchange.toAmount > 0;
|
|
11509
|
+
});
|
|
11510
|
+
Logger.log("Available (having amountTo): " + safeStringify(availableExchanges), loggerSource);
|
|
11511
|
+
// min=0 or max=0 means there is no limit for the partner
|
|
11512
|
+
var smallestMin = null;
|
|
11513
|
+
if (exchangesSupportingThePair.find(function (ex) {
|
|
11514
|
+
return bignumber_js.BigNumber(ex.min).isZero();
|
|
11515
|
+
}) == null) {
|
|
11516
|
+
smallestMin = exchangesSupportingThePair.reduce(function (prev, cur) {
|
|
11517
|
+
if (typeof cur.min === "number" && (prev === null || bignumber_js.BigNumber(cur.min).lt(prev))) return bignumber_js.BigNumber(cur.min);
|
|
11518
|
+
return prev;
|
|
11519
|
+
}, null);
|
|
11258
11520
|
}
|
|
11259
|
-
|
|
11260
|
-
|
|
11261
|
-
|
|
11262
|
-
|
|
11263
|
-
|
|
11264
|
-
|
|
11265
|
-
|
|
11266
|
-
|
|
11267
|
-
|
|
11268
|
-
|
|
11269
|
-
|
|
11270
|
-
|
|
11271
|
-
|
|
11272
|
-
|
|
11273
|
-
|
|
11274
|
-
|
|
11275
|
-
|
|
11276
|
-
|
|
11521
|
+
var greatestMax = null;
|
|
11522
|
+
if (exchangesSupportingThePair.find(function (ex) {
|
|
11523
|
+
return bignumber_js.BigNumber(ex.max).isZero();
|
|
11524
|
+
}) == null) {
|
|
11525
|
+
greatestMax = exchangesSupportingThePair.reduce(function (prev, cur) {
|
|
11526
|
+
if (typeof cur.max === "number" && (prev === null || bignumber_js.BigNumber(cur.max).gt(prev))) return bignumber_js.BigNumber(cur.max);
|
|
11527
|
+
return prev;
|
|
11528
|
+
}, null);
|
|
11529
|
+
}
|
|
11530
|
+
var extraCoinsToFitMinMax = "0";
|
|
11531
|
+
if (typeof fromCoinToUsdRate === "string" && bignumber_js.BigNumber(fromCoinToUsdRate).gt("0")) {
|
|
11532
|
+
var extraUsdToFitMinMax = bignumber_js.BigNumber("1"); // We correct the limits as the exact limit can fluctuate and cause failed swap creation
|
|
11533
|
+
extraCoinsToFitMinMax = AmountUtils.trim(extraUsdToFitMinMax.div(fromCoinToUsdRate), fromCoin.digits);
|
|
11534
|
+
}
|
|
11535
|
+
if (smallestMin instanceof bignumber_js.BigNumber) {
|
|
11536
|
+
smallestMin = AmountUtils.trim(smallestMin.plus(extraCoinsToFitMinMax), fromCoin.digits);
|
|
11537
|
+
}
|
|
11538
|
+
if (greatestMax instanceof bignumber_js.BigNumber) {
|
|
11539
|
+
if (greatestMax > extraCoinsToFitMinMax) {
|
|
11540
|
+
greatestMax = AmountUtils.trim(greatestMax.minus(extraCoinsToFitMinMax), fromCoin.digits);
|
|
11541
|
+
} else {
|
|
11542
|
+
greatestMax = "0";
|
|
11277
11543
|
}
|
|
11278
|
-
var rate = bestOpt.toAmount && bestOpt.fromAmount ? bignumber_js.BigNumber(bestOpt.toAmount).div(bestOpt.fromAmount) : null;
|
|
11279
|
-
return Promise.resolve(_this4._fetchPartnersListIfNeeded()).then(function () {
|
|
11280
|
-
var _bestOpt$duration;
|
|
11281
|
-
var partner = _this4._partners.find(function (p) {
|
|
11282
|
-
var _bestOpt$partner;
|
|
11283
|
-
return (bestOpt == null || (_bestOpt$partner = bestOpt.partner) == null ? void 0 : _bestOpt$partner.toLowerCase()) === p.path.toLowerCase();
|
|
11284
|
-
});
|
|
11285
|
-
var isRefundAddressRequired = partner == null ? true : bestOpt.fixed ? partner.reqFixedRefund : partner.reqFloatRefund;
|
|
11286
|
-
var _result$min$max$small = {
|
|
11287
|
-
result: true,
|
|
11288
|
-
min: min,
|
|
11289
|
-
max: max,
|
|
11290
|
-
smallestMin: smallestMin,
|
|
11291
|
-
greatestMax: greatestMax,
|
|
11292
|
-
rate: rate != null ? AmountUtils.trim(rate, _this4._maxRateDigits) : null,
|
|
11293
|
-
durationMinutesRange: (_bestOpt$duration = bestOpt.duration) != null ? _bestOpt$duration : null,
|
|
11294
|
-
fixed: bestOpt.fixed,
|
|
11295
|
-
rawSwapData: bestOpt,
|
|
11296
|
-
isRefundAddressRequired: !!isRefundAddressRequired
|
|
11297
|
-
};
|
|
11298
|
-
_exit = 1;
|
|
11299
|
-
return _result$min$max$small;
|
|
11300
|
-
});
|
|
11301
11544
|
}
|
|
11302
|
-
|
|
11303
|
-
|
|
11304
|
-
|
|
11305
|
-
|
|
11306
|
-
|
|
11307
|
-
|
|
11308
|
-
|
|
11309
|
-
|
|
11310
|
-
|
|
11311
|
-
|
|
11545
|
+
var _temp3 = function () {
|
|
11546
|
+
if (availableExchanges.length) {
|
|
11547
|
+
var sorted = availableExchanges.sort(function (op1, op2) {
|
|
11548
|
+
return op2.toAmount - op1.toAmount;
|
|
11549
|
+
});
|
|
11550
|
+
var bestOpt = sorted[0];
|
|
11551
|
+
Logger.log("Returning first option after sorting: " + safeStringify(bestOpt), loggerSource);
|
|
11552
|
+
var max = null;
|
|
11553
|
+
var min = null;
|
|
11554
|
+
if (extraCoinsToFitMinMax != null) {
|
|
11555
|
+
if (typeof bestOpt.max === "number" && bestOpt.max !== 0) {
|
|
11556
|
+
max = bignumber_js.BigNumber(bestOpt.max).minus(extraCoinsToFitMinMax);
|
|
11557
|
+
max = AmountUtils.trim(max.lt(0) ? "0" : max, fromCoin.digits);
|
|
11558
|
+
}
|
|
11559
|
+
if (typeof bestOpt.min === "number" && bestOpt.min !== 0) {
|
|
11560
|
+
min = AmountUtils.trim(bignumber_js.BigNumber(bestOpt.min).plus(extraCoinsToFitMinMax), fromCoin.digits);
|
|
11561
|
+
}
|
|
11562
|
+
}
|
|
11563
|
+
var rate = bestOpt.toAmount && bestOpt.fromAmount ? bignumber_js.BigNumber(bestOpt.toAmount).div(bestOpt.fromAmount) : null;
|
|
11564
|
+
return Promise.resolve(_this4._fetchPartnersListIfNeeded()).then(function () {
|
|
11565
|
+
var _bestOpt$duration;
|
|
11566
|
+
var partner = _this4._partners.find(function (p) {
|
|
11567
|
+
var _bestOpt$partner;
|
|
11568
|
+
return (bestOpt == null || (_bestOpt$partner = bestOpt.partner) == null ? void 0 : _bestOpt$partner.toLowerCase()) === p.path.toLowerCase();
|
|
11569
|
+
});
|
|
11570
|
+
var isRefundAddressRequired = partner == null ? true : bestOpt.fixed ? partner.reqFixedRefund : partner.reqFloatRefund;
|
|
11571
|
+
var _result$min$max$small = {
|
|
11572
|
+
result: true,
|
|
11573
|
+
min: min,
|
|
11574
|
+
max: max,
|
|
11575
|
+
smallestMin: smallestMin,
|
|
11576
|
+
greatestMax: greatestMax,
|
|
11577
|
+
rate: rate != null ? AmountUtils.trim(rate, _this4._maxRateDigits) : null,
|
|
11578
|
+
durationMinutesRange: (_bestOpt$duration = bestOpt.duration) != null ? _bestOpt$duration : null,
|
|
11579
|
+
fixed: bestOpt.fixed,
|
|
11580
|
+
rawSwapData: bestOpt,
|
|
11581
|
+
isRefundAddressRequired: !!isRefundAddressRequired
|
|
11582
|
+
};
|
|
11583
|
+
_exit = 1;
|
|
11584
|
+
return _result$min$max$small;
|
|
11585
|
+
});
|
|
11586
|
+
}
|
|
11587
|
+
}();
|
|
11588
|
+
return _temp3 && _temp3.then ? _temp3.then(_temp4) : _temp4(_temp3);
|
|
11589
|
+
});
|
|
11590
|
+
});
|
|
11591
|
+
/* Here we use not documented parameter 'estimated=false'. This parameter controls whether we want to use
|
|
11592
|
+
* cached rate values stored in swapspace cache. Their support says they store at most for 30 sec.
|
|
11593
|
+
* But we are better off using the most actual rates.
|
|
11594
|
+
*/
|
|
11595
|
+
}, function (e) {
|
|
11596
|
+
var _e$response;
|
|
11597
|
+
if ((e == null || (_e$response = e.response) == null ? void 0 : _e$response.status) === 429) {
|
|
11598
|
+
return {
|
|
11599
|
+
result: false,
|
|
11600
|
+
reason: SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED
|
|
11601
|
+
};
|
|
11312
11602
|
}
|
|
11313
11603
|
Logger.log("Internal swapspace/rabbit error when getting swap options " + safeStringify(e), loggerSource);
|
|
11314
11604
|
improveAndRethrow(e, loggerSource);
|
|
@@ -11340,13 +11630,13 @@
|
|
|
11340
11630
|
) {
|
|
11341
11631
|
throw new Error("Invalid raw swap data: " + safeStringify(rawSwapData));
|
|
11342
11632
|
}
|
|
11343
|
-
var _this5$_supportedCoin = _this5._supportedCoins.reduce(function (prev, coinData) {
|
|
11344
|
-
return [coinData.coin.ticker === fromCoin.ticker ? coinData.hasExtraId : prev[0], coinData.coin.ticker === toCoin.ticker ? coinData.hasExtraId : prev[1]];
|
|
11345
|
-
}, [false, false]),
|
|
11346
|
-
fromCurrencyHasExtraId = _this5$_supportedCoin[0],
|
|
11347
|
-
toCurrencyHasExtraId = _this5$_supportedCoin[1];
|
|
11348
11633
|
return Promise.resolve(_this5._fetchSupportedCurrenciesIfNeeded()).then(function () {
|
|
11349
11634
|
var _toCurrencyExtraId, _refundExtraId;
|
|
11635
|
+
var _this5$_supportedCoin = _this5._supportedCoins.reduce(function (prev, coinData) {
|
|
11636
|
+
return [coinData.coin.ticker === fromCoin.ticker ? coinData.hasExtraId : prev[0], coinData.coin.ticker === toCoin.ticker ? coinData.hasExtraId : prev[1]];
|
|
11637
|
+
}, [false, false]),
|
|
11638
|
+
fromCurrencyHasExtraId = _this5$_supportedCoin[0],
|
|
11639
|
+
toCurrencyHasExtraId = _this5$_supportedCoin[1];
|
|
11350
11640
|
var requestData = {
|
|
11351
11641
|
partner: partner,
|
|
11352
11642
|
fromCurrency: rawSwapData == null ? void 0 : rawSwapData.fromCurrency,
|
|
@@ -11364,7 +11654,9 @@
|
|
|
11364
11654
|
refund: refundAddress
|
|
11365
11655
|
};
|
|
11366
11656
|
Logger.log("Sending create request: " + safeStringify(requestData), loggerSource);
|
|
11367
|
-
return Promise.resolve(axios__default["default"].post(_this5._URL + "/api/v2/exchange", requestData
|
|
11657
|
+
return Promise.resolve(axios__default["default"].post(_this5._URL + "/api/v2/exchange", requestData, {
|
|
11658
|
+
headers: _this5._headers
|
|
11659
|
+
})).then(function (response) {
|
|
11368
11660
|
var result = response.data;
|
|
11369
11661
|
Logger.log("Creation result " + safeStringify(result), loggerSource);
|
|
11370
11662
|
if (result != null && result.id) {
|
|
@@ -11469,7 +11761,9 @@
|
|
|
11469
11761
|
var getNotFailingOn404 = function getNotFailingOn404(swapId) {
|
|
11470
11762
|
try {
|
|
11471
11763
|
return Promise.resolve(_catch$3(function () {
|
|
11472
|
-
return Promise.resolve(axios__default["default"].get(_this6._URL + "/api/v2/exchange/" + swapId
|
|
11764
|
+
return Promise.resolve(axios__default["default"].get(_this6._URL + "/api/v2/exchange/" + swapId, {
|
|
11765
|
+
headers: _this6._headers
|
|
11766
|
+
}));
|
|
11473
11767
|
}, function (error) {
|
|
11474
11768
|
var _error$response;
|
|
11475
11769
|
if ((error == null || (_error$response = error.response) == null ? void 0 : _error$response.status) === 404) return [];
|
|
@@ -11542,15 +11836,11 @@
|
|
|
11542
11836
|
var _this7 = this;
|
|
11543
11837
|
return Promise.resolve(_catch$3(function () {
|
|
11544
11838
|
return Promise.resolve(_this7._fetchPartnersListIfNeeded()).then(function () {
|
|
11545
|
-
var swapspacePartners = _this7._partners.
|
|
11546
|
-
return !BANNED_PARTNERS.find(function (banned) {
|
|
11547
|
-
return banned === p.path;
|
|
11548
|
-
});
|
|
11549
|
-
}).map(function (p) {
|
|
11839
|
+
var swapspacePartners = _this7._partners.map(function (p) {
|
|
11550
11840
|
var _p$image;
|
|
11551
|
-
return new Partner(p.name, p != null && (_p$image = p.image) != null && _p$image["default"] ? "https://storage.swapspace.co" + p.image["default"] : null);
|
|
11841
|
+
return new Partner(p.path, p.name, p != null && (_p$image = p.image) != null && _p$image["default"] ? "https://storage.swapspace.co" + p.image["default"] : null, p.kycLevel);
|
|
11552
11842
|
});
|
|
11553
|
-
var swapspaceItself = new Partner("Swapspace", "https://storage.swapspace.co/static/logo-vertical-black.svg");
|
|
11843
|
+
var swapspaceItself = new Partner("swapspace", "Swapspace", "https://storage.swapspace.co/static/logo-vertical-black.svg", KYC_LEVELS.LOW);
|
|
11554
11844
|
return [swapspaceItself].concat(swapspacePartners);
|
|
11555
11845
|
});
|
|
11556
11846
|
}, function (e) {
|
|
@@ -11574,354 +11864,440 @@
|
|
|
11574
11864
|
}
|
|
11575
11865
|
return result;
|
|
11576
11866
|
}
|
|
11577
|
-
var
|
|
11578
|
-
|
|
11579
|
-
|
|
11580
|
-
|
|
11581
|
-
|
|
11582
|
-
|
|
11583
|
-
|
|
11584
|
-
|
|
11585
|
-
value = value.v;
|
|
11586
|
-
} else {
|
|
11587
|
-
value.o = _settle.bind(null, pact, state);
|
|
11588
|
-
return;
|
|
11589
|
-
}
|
|
11867
|
+
var LetsExchangeSwapProvider = /*#__PURE__*/function (_SwapProvider) {
|
|
11868
|
+
_inheritsLoose(LetsExchangeSwapProvider, _SwapProvider);
|
|
11869
|
+
function LetsExchangeSwapProvider(apiKeysProxyUrl, cache, customCoinBuilder, useRestrictedCoinsSet, apiKey) {
|
|
11870
|
+
var _this;
|
|
11871
|
+
if (customCoinBuilder === void 0) {
|
|
11872
|
+
customCoinBuilder = function customCoinBuilder(coin, network) {
|
|
11873
|
+
return null;
|
|
11874
|
+
};
|
|
11590
11875
|
}
|
|
11591
|
-
if (
|
|
11592
|
-
|
|
11593
|
-
return;
|
|
11876
|
+
if (useRestrictedCoinsSet === void 0) {
|
|
11877
|
+
useRestrictedCoinsSet = true;
|
|
11594
11878
|
}
|
|
11595
|
-
|
|
11596
|
-
|
|
11597
|
-
var observer = pact.o;
|
|
11598
|
-
if (observer) {
|
|
11599
|
-
observer(pact);
|
|
11879
|
+
if (apiKey === void 0) {
|
|
11880
|
+
apiKey = null;
|
|
11600
11881
|
}
|
|
11882
|
+
_this = _SwapProvider.call(this, "letsexchange", cache, customCoinBuilder, useRestrictedCoinsSet) || this;
|
|
11883
|
+
_this._partners = [];
|
|
11884
|
+
_this._URL = apiKey ? "https://api.letsexchange.io/api" : apiKeysProxyUrl + "/" + _this.id;
|
|
11885
|
+
_this.isAggregator = false;
|
|
11886
|
+
_this._headers = apiKey ? {
|
|
11887
|
+
Authorization: "Bearer " + apiKey,
|
|
11888
|
+
"Content-Type": "application/json",
|
|
11889
|
+
Accept: "application/json"
|
|
11890
|
+
} : {};
|
|
11891
|
+
return _this;
|
|
11601
11892
|
}
|
|
11602
|
-
|
|
11603
|
-
|
|
11604
|
-
|
|
11605
|
-
_Pact.prototype.then = function (onFulfilled, onRejected) {
|
|
11606
|
-
var result = new _Pact();
|
|
11607
|
-
var state = this.s;
|
|
11608
|
-
if (state) {
|
|
11609
|
-
var callback = state & 1 ? onFulfilled : onRejected;
|
|
11610
|
-
if (callback) {
|
|
11611
|
-
try {
|
|
11612
|
-
_settle(result, 1, callback(this.v));
|
|
11613
|
-
} catch (e) {
|
|
11614
|
-
_settle(result, 2, e);
|
|
11615
|
-
}
|
|
11616
|
-
return result;
|
|
11617
|
-
} else {
|
|
11618
|
-
return this;
|
|
11619
|
-
}
|
|
11620
|
-
}
|
|
11621
|
-
this.o = function (_this) {
|
|
11622
|
-
try {
|
|
11623
|
-
var value = _this.v;
|
|
11624
|
-
if (_this.s & 1) {
|
|
11625
|
-
_settle(result, 1, onFulfilled ? onFulfilled(value) : value);
|
|
11626
|
-
} else if (onRejected) {
|
|
11627
|
-
_settle(result, 1, onRejected(value));
|
|
11628
|
-
} else {
|
|
11629
|
-
_settle(result, 2, value);
|
|
11630
|
-
}
|
|
11631
|
-
} catch (e) {
|
|
11632
|
-
_settle(result, 2, e);
|
|
11633
|
-
}
|
|
11634
|
-
};
|
|
11635
|
-
return result;
|
|
11893
|
+
var _proto = LetsExchangeSwapProvider.prototype;
|
|
11894
|
+
_proto.getSwapCreationInfoTtlMs = function getSwapCreationInfoTtlMs() {
|
|
11895
|
+
return 110000;
|
|
11636
11896
|
};
|
|
11637
|
-
|
|
11638
|
-
}();
|
|
11639
|
-
function _isSettledPact(thenable) {
|
|
11640
|
-
return thenable instanceof _Pact && thenable.s & 1;
|
|
11641
|
-
}
|
|
11642
|
-
function _forTo(array, body, check) {
|
|
11643
|
-
var i = -1,
|
|
11644
|
-
pact,
|
|
11645
|
-
reject;
|
|
11646
|
-
function _cycle(result) {
|
|
11897
|
+
_proto._fetchSupportedCurrenciesIfNeeded = function _fetchSupportedCurrenciesIfNeeded() {
|
|
11647
11898
|
try {
|
|
11648
|
-
|
|
11649
|
-
|
|
11650
|
-
|
|
11651
|
-
|
|
11652
|
-
|
|
11653
|
-
|
|
11654
|
-
|
|
11655
|
-
|
|
11899
|
+
var _this2 = this;
|
|
11900
|
+
var loggerSource = "_fetchSupportedCurrenciesIfNeeded";
|
|
11901
|
+
return Promise.resolve(_catch$2(function () {
|
|
11902
|
+
var _temp = function () {
|
|
11903
|
+
if (_this2._shouldCoinsListBeLoaded()) {
|
|
11904
|
+
return Promise.resolve(axios__default["default"].get(_this2._URL + "/v2/coins", {
|
|
11905
|
+
headers: _this2._headers
|
|
11906
|
+
})).then(function (rawResponse) {
|
|
11907
|
+
var _rawResponse$data, _rawResponse$data2;
|
|
11908
|
+
Logger.log("Retrieved " + (rawResponse == null || (_rawResponse$data = rawResponse.data) == null ? void 0 : _rawResponse$data.length), loggerSource);
|
|
11909
|
+
var allowedCoins = (_rawResponse$data2 = rawResponse == null ? void 0 : rawResponse.data) != null ? _rawResponse$data2 : [];
|
|
11910
|
+
Logger.log("Allowed cnt " + allowedCoins.length, loggerSource);
|
|
11911
|
+
_this2._supportedCoins = allowedCoins.map(function (item) {
|
|
11912
|
+
var code = item.code.toUpperCase();
|
|
11913
|
+
if (!Array.isArray(item.networks)) return [];
|
|
11914
|
+
return item.networks.map(function (networkDetails) {
|
|
11915
|
+
var network = networkDetails.code.toUpperCase();
|
|
11916
|
+
var coin = _this2._customCoinBuilder != null ? _this2._customCoinBuilder(code, network) : null;
|
|
11917
|
+
if (!coin && !_this2.useRestrictedCoinsSet) {
|
|
11918
|
+
var name = _this2.removeProtocolNameFromCoinName(item.name, code, network);
|
|
11919
|
+
var ticker = toRabbitTicker(code, network);
|
|
11920
|
+
var defaultDecimalPlacesForCoinNotSupportedOOB = DEFAULT_CRYPTO_DECIMAL_COUNT;
|
|
11921
|
+
var defaultMinConfirmationsForCoinNotSupportedOOB = 1;
|
|
11922
|
+
coin = new Coin(name, ticker, code, defaultDecimalPlacesForCoinNotSupportedOOB, null, "", null, null, defaultMinConfirmationsForCoinNotSupportedOOB, null, [], 60000, null, code !== network ? new Protocol(network) : null, item.contract_address || null, false);
|
|
11923
|
+
}
|
|
11924
|
+
if (coin) {
|
|
11925
|
+
var _networkDetails$extra, _networkDetails$valid;
|
|
11926
|
+
return new SwapProviderCoinInfo(coin, item.code, networkDetails.code, !!networkDetails.has_extra, (_networkDetails$extra = networkDetails.extra_name) != null ? _networkDetails$extra : null, item.rating || 0, item.icon ? item.icon : FALLBACK_ASSET_ICON_URL, true,
|
|
11927
|
+
// Letsexchange provide no such details
|
|
11928
|
+
true, // Letsexchange provide no such details
|
|
11929
|
+
(_networkDetails$valid = networkDetails.validation_address_regex) != null ? _networkDetails$valid : null, (typeof item.is_active !== "number" || item.is_active === 1) && (typeof item.disabled !== "number" || item.disabled === 0) && (typeof networkDetails.is_active !== "number" || networkDetails.is_active === 1));
|
|
11930
|
+
}
|
|
11931
|
+
return [];
|
|
11932
|
+
});
|
|
11933
|
+
}).flat();
|
|
11934
|
+
_this2._supportedCoinsLastUpdateTimestamp = Date.now();
|
|
11935
|
+
_this2._putPopularCoinsFirst();
|
|
11936
|
+
return Promise.resolve(_SwapProvider.prototype._fetchSupportedCurrenciesIfNeeded.call(_this2)).then(function () {});
|
|
11937
|
+
});
|
|
11656
11938
|
}
|
|
11657
|
-
}
|
|
11658
|
-
|
|
11659
|
-
|
|
11660
|
-
|
|
11661
|
-
}
|
|
11662
|
-
pact = result;
|
|
11663
|
-
}
|
|
11939
|
+
}();
|
|
11940
|
+
if (_temp && _temp.then) return _temp.then(function () {});
|
|
11941
|
+
}, function (e) {
|
|
11942
|
+
improveAndRethrow(e, loggerSource);
|
|
11943
|
+
}));
|
|
11664
11944
|
} catch (e) {
|
|
11665
|
-
|
|
11945
|
+
return Promise.reject(e);
|
|
11666
11946
|
}
|
|
11667
|
-
}
|
|
11668
|
-
|
|
11669
|
-
|
|
11670
|
-
|
|
11671
|
-
|
|
11672
|
-
|
|
11673
|
-
|
|
11674
|
-
|
|
11675
|
-
|
|
11676
|
-
|
|
11677
|
-
|
|
11678
|
-
|
|
11679
|
-
|
|
11680
|
-
|
|
11681
|
-
|
|
11682
|
-
|
|
11683
|
-
}
|
|
11684
|
-
}
|
|
11685
|
-
}
|
|
11686
|
-
if (pact) {
|
|
11687
|
-
_settle(pact, 1, result);
|
|
11688
|
-
} else {
|
|
11689
|
-
pact = result;
|
|
11947
|
+
};
|
|
11948
|
+
_proto.getSwapInfo = function getSwapInfo(fromCoin, toCoin, amountCoins, fixed, fromCoinToUsdRate, amountIsToReceive) {
|
|
11949
|
+
if (fixed === void 0) {
|
|
11950
|
+
fixed = false;
|
|
11951
|
+
}
|
|
11952
|
+
if (amountIsToReceive === void 0) {
|
|
11953
|
+
amountIsToReceive = false;
|
|
11954
|
+
}
|
|
11955
|
+
try {
|
|
11956
|
+
var _this3 = this;
|
|
11957
|
+
var loggerSource = "getSwapInfo";
|
|
11958
|
+
var min = null;
|
|
11959
|
+
var max = null;
|
|
11960
|
+
return Promise.resolve(_catch$2(function () {
|
|
11961
|
+
if (!(fromCoin instanceof Coin) || !(toCoin instanceof Coin) || typeof amountCoins !== "string" || bignumber_js.BigNumber(amountCoins).lt("0") || fixed !== null && typeof fixed !== "boolean" || amountIsToReceive && !fixed) {
|
|
11962
|
+
throw new Error("Wrong input params: " + amountCoins + " " + fromCoin.ticker + " -> " + toCoin.ticker + ", " + (fromCoin instanceof Coin) + ", " + (toCoin instanceof Coin) + ", " + typeof fixed + " " + fixed + ", " + amountIsToReceive);
|
|
11690
11963
|
}
|
|
11691
|
-
|
|
11692
|
-
|
|
11693
|
-
|
|
11694
|
-
|
|
11695
|
-
|
|
11696
|
-
|
|
11697
|
-
|
|
11698
|
-
|
|
11699
|
-
|
|
11700
|
-
|
|
11701
|
-
|
|
11702
|
-
|
|
11703
|
-
|
|
11704
|
-
|
|
11964
|
+
return Promise.resolve(_this3._fetchSupportedCurrenciesIfNeeded()).then(function () {
|
|
11965
|
+
var fromCoinDetails = _this3._supportedCoins.find(function (i) {
|
|
11966
|
+
var _i$coin;
|
|
11967
|
+
return ((_i$coin = i.coin) == null ? void 0 : _i$coin.ticker) === (fromCoin == null ? void 0 : fromCoin.ticker);
|
|
11968
|
+
});
|
|
11969
|
+
var toCoinDetails = _this3._supportedCoins.find(function (i) {
|
|
11970
|
+
var _i$coin2;
|
|
11971
|
+
return ((_i$coin2 = i.coin) == null ? void 0 : _i$coin2.ticker) === (toCoin == null ? void 0 : toCoin.ticker);
|
|
11972
|
+
});
|
|
11973
|
+
if (!fromCoinDetails || !toCoinDetails || !fromCoinDetails.deposit || !fromCoinDetails.isAvailable || !toCoinDetails.withdrawal || !toCoinDetails.isAvailable) {
|
|
11974
|
+
return {
|
|
11975
|
+
result: false,
|
|
11976
|
+
reason: SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED
|
|
11977
|
+
};
|
|
11705
11978
|
}
|
|
11706
|
-
|
|
11707
|
-
|
|
11708
|
-
|
|
11709
|
-
|
|
11710
|
-
|
|
11711
|
-
|
|
11979
|
+
var pathAndQuery = "/v1/info" + (amountIsToReceive ? "-revert" : "?float=" + !fixed);
|
|
11980
|
+
return Promise.resolve(axios__default["default"].post("" + _this3._URL + pathAndQuery, {
|
|
11981
|
+
from: fromCoinDetails.code,
|
|
11982
|
+
to: toCoinDetails.code,
|
|
11983
|
+
network_from: fromCoinDetails.network,
|
|
11984
|
+
network_to: toCoinDetails.network,
|
|
11985
|
+
amount: amountCoins,
|
|
11986
|
+
affiliate_id: LetsExchangeSwapProvider.AFFILIATE_ID
|
|
11987
|
+
}, {
|
|
11988
|
+
headers: _this3._headers
|
|
11989
|
+
})).then(function (response) {
|
|
11990
|
+
Logger.log("Retrieved " + (response == null ? void 0 : response.data), loggerSource);
|
|
11991
|
+
var data = response.data;
|
|
11992
|
+
|
|
11993
|
+
// TODO: [dev] add SwapProvider.NO_SWAPS_REASONS.NO_FIXED_BUT_HAVE_FLOATING - request alternative rate. task_id=
|
|
11994
|
+
|
|
11995
|
+
// TODO: [feature, low] implement extra coins to fit min/max if there are frequent errors due to min/max exceeding
|
|
11996
|
+
// let extraCoinsToFitMinMax = "0";
|
|
11997
|
+
// if (typeof fromCoinToUsdRate === "string" && BigNumber(fromCoinToUsdRate).gt("0")) {
|
|
11998
|
+
// const extraUsdToFitMinMax = BigNumber("1"); // We correct the limits as the exact limit can fluctuate and cause failed swap creation
|
|
11999
|
+
// extraCoinsToFitMinMax = AmountUtils.trim(extraUsdToFitMinMax.div(fromCoinToUsdRate), fromCoin.digits);
|
|
12000
|
+
// }
|
|
12001
|
+
if (data != null && data.min_amount) {
|
|
12002
|
+
min = AmountUtils.trim(data == null ? void 0 : data.min_amount, amountIsToReceive ? toCoin.digits : fromCoin.digits);
|
|
12003
|
+
}
|
|
12004
|
+
if (data != null && data.max_amount) {
|
|
12005
|
+
max = AmountUtils.trim(data == null ? void 0 : data.max_amount, amountIsToReceive ? toCoin.digits : fromCoin.digits);
|
|
12006
|
+
}
|
|
12007
|
+
if (data.success === false && data.error) {
|
|
12008
|
+
// TODO: [dev] waiting for response from letsexchange about their not-documented responses
|
|
12009
|
+
// {
|
|
12010
|
+
// "success": false,
|
|
12011
|
+
// "error": "Internal error"
|
|
12012
|
+
// }
|
|
12013
|
+
throw new Error("Failed to estimate swap letsexchange");
|
|
12014
|
+
}
|
|
12015
|
+
if (bignumber_js.BigNumber(data.rate).eq("0") || bignumber_js.BigNumber(data.amount).eq("0")) {
|
|
12016
|
+
// TODO actualize according to letsexchage clarification - decide, can we count on min/max abcense? task_id=76512110797f4eab8b37f1bb789825cb
|
|
12017
|
+
// amount: "0", rate: "0", rate_id: ""
|
|
12018
|
+
var reason = SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED;
|
|
12019
|
+
if (min && bignumber_js.BigNumber(amountCoins).lt(min)) {
|
|
12020
|
+
reason = SwapProvider.NO_SWAPS_REASONS.TOO_LOW;
|
|
12021
|
+
} else if (max && bignumber_js.BigNumber(amountCoins).gt(max)) {
|
|
12022
|
+
reason = SwapProvider.NO_SWAPS_REASONS.TOO_HIGH;
|
|
12023
|
+
} else if (!amountIsToReceive) {
|
|
12024
|
+
// If we are not requesting receiving amount (it cannot be floating-rate)
|
|
12025
|
+
// todo [feature, moderate] request alternative rate. task_id=31884db5392f49738c20a86115c90e1f
|
|
12026
|
+
// const alternativeRate = 1;
|
|
12027
|
+
// const alternativeRateAvailable = alternativeRate;
|
|
12028
|
+
// if (alternativeRateAvailable) {
|
|
12029
|
+
// reason = fixed
|
|
12030
|
+
// ? SwapProvider.NO_SWAPS_REASONS.NO_FIXED_BUT_HAVE_FLOATING
|
|
12031
|
+
// : SwapProvider.NO_SWAPS_REASONS.NO_FLOATING_BUT_HAVE_FIXED;
|
|
12032
|
+
// }
|
|
12033
|
+
}
|
|
12034
|
+
return {
|
|
12035
|
+
result: false,
|
|
12036
|
+
reason: reason,
|
|
12037
|
+
smallestMin: min,
|
|
12038
|
+
greatestMax: max
|
|
12039
|
+
};
|
|
12040
|
+
}
|
|
12041
|
+
var rate = amountIsToReceive ? bignumber_js.BigNumber(amountCoins).div(data.amount) : bignumber_js.BigNumber(data.amount).div(amountCoins);
|
|
12042
|
+
return {
|
|
12043
|
+
result: true,
|
|
12044
|
+
min: min,
|
|
12045
|
+
max: max,
|
|
12046
|
+
smallestMin: min,
|
|
12047
|
+
greatestMax: max,
|
|
12048
|
+
rate: AmountUtils.trim(rate, _this3._maxRateDigits),
|
|
12049
|
+
durationMinutesRange: null,
|
|
12050
|
+
fixed: fixed,
|
|
12051
|
+
rawSwapData: data,
|
|
12052
|
+
isRefundAddressRequired: false
|
|
12053
|
+
};
|
|
12054
|
+
});
|
|
11712
12055
|
});
|
|
11713
|
-
}
|
|
11714
|
-
|
|
11715
|
-
|
|
11716
|
-
|
|
11717
|
-
|
|
11718
|
-
|
|
11719
|
-
|
|
11720
|
-
|
|
11721
|
-
|
|
11722
|
-
|
|
11723
|
-
|
|
11724
|
-
|
|
11725
|
-
|
|
11726
|
-
|
|
11727
|
-
|
|
11728
|
-
|
|
11729
|
-
|
|
11730
|
-
|
|
11731
|
-
|
|
11732
|
-
|
|
11733
|
-
|
|
11734
|
-
* Retrieves min and max limits for swapping giving currencies.
|
|
11735
|
-
* Returns also conversion rate if possible with predefined amount logic.
|
|
11736
|
-
* Rate is how many "to" coins does 1 "from" coin contain.
|
|
11737
|
-
*
|
|
11738
|
-
* In case of errors returns one of reasons
|
|
11739
|
-
* - SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED
|
|
11740
|
-
* - one of SwapProvider.COMMON_ERRORS.*
|
|
11741
|
-
*
|
|
11742
|
-
* @param swapProvider {SwapProvider}
|
|
11743
|
-
* @param fromCoin {Coin} enabled coin (to swap amount from)
|
|
11744
|
-
* @param toCoin {Coin}
|
|
11745
|
-
* @param coinToCurrentFiatRate {string|null}
|
|
11746
|
-
* @param fiatCurrencyDecimals {number|null}
|
|
11747
|
-
* @return {Promise<{
|
|
11748
|
-
* result: true,
|
|
11749
|
-
* min: string,
|
|
11750
|
-
* fiatMin: (number|null),
|
|
11751
|
-
* max: string,
|
|
11752
|
-
* fiatMax: (number|null),
|
|
11753
|
-
* rate: (string|null),
|
|
11754
|
-
* }|{
|
|
11755
|
-
* result: false,
|
|
11756
|
-
* reason: string
|
|
11757
|
-
* }>}
|
|
11758
|
-
*/
|
|
11759
|
-
SwapUtils.getInitialSwapData = function getInitialSwapData(swapProvider, fromCoin, toCoin, coinToCurrentFiatRate, fiatCurrencyDecimals) {
|
|
11760
|
-
if (coinToCurrentFiatRate === void 0) {
|
|
11761
|
-
coinToCurrentFiatRate = null;
|
|
12056
|
+
}, function (e) {
|
|
12057
|
+
var _e$response, _e$response2;
|
|
12058
|
+
if ((e == null || (_e$response = e.response) == null ? void 0 : _e$response.status) === 404) {
|
|
12059
|
+
return {
|
|
12060
|
+
result: false,
|
|
12061
|
+
reason: SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED,
|
|
12062
|
+
smallestMin: min,
|
|
12063
|
+
greatestMax: max
|
|
12064
|
+
};
|
|
12065
|
+
}
|
|
12066
|
+
if ((e == null || (_e$response2 = e.response) == null ? void 0 : _e$response2.status) === 429) {
|
|
12067
|
+
return {
|
|
12068
|
+
result: false,
|
|
12069
|
+
reason: SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED
|
|
12070
|
+
};
|
|
12071
|
+
}
|
|
12072
|
+
Logger.log("Internal error when getting swap options " + safeStringify(e), loggerSource);
|
|
12073
|
+
improveAndRethrow(e, loggerSource);
|
|
12074
|
+
}));
|
|
12075
|
+
} catch (e) {
|
|
12076
|
+
return Promise.reject(e);
|
|
11762
12077
|
}
|
|
11763
|
-
|
|
11764
|
-
|
|
12078
|
+
};
|
|
12079
|
+
_proto.createSwap = function createSwap(fromCoin, toCoin, amount, toAddress, refundAddress, rawSwapData, clientIpAddress, fixed, toCurrencyExtraId, refundExtraId, amountIsToReceive) {
|
|
12080
|
+
if (toCurrencyExtraId === void 0) {
|
|
12081
|
+
toCurrencyExtraId = "";
|
|
12082
|
+
}
|
|
12083
|
+
if (refundExtraId === void 0) {
|
|
12084
|
+
refundExtraId = "";
|
|
12085
|
+
}
|
|
12086
|
+
if (amountIsToReceive === void 0) {
|
|
12087
|
+
amountIsToReceive = false;
|
|
11765
12088
|
}
|
|
11766
12089
|
try {
|
|
11767
|
-
var
|
|
12090
|
+
var _this4 = this;
|
|
12091
|
+
var loggerSource = "createSwap";
|
|
11768
12092
|
return Promise.resolve(_catch$2(function () {
|
|
11769
|
-
|
|
11770
|
-
|
|
11771
|
-
|
|
11772
|
-
|
|
11773
|
-
|
|
11774
|
-
|
|
11775
|
-
|
|
11776
|
-
|
|
11777
|
-
|
|
11778
|
-
|
|
11779
|
-
|
|
11780
|
-
|
|
11781
|
-
|
|
11782
|
-
|
|
11783
|
-
|
|
11784
|
-
|
|
11785
|
-
|
|
11786
|
-
|
|
11787
|
-
|
|
11788
|
-
|
|
11789
|
-
|
|
11790
|
-
|
|
11791
|
-
|
|
11792
|
-
|
|
11793
|
-
|
|
11794
|
-
|
|
11795
|
-
|
|
11796
|
-
|
|
11797
|
-
|
|
11798
|
-
|
|
11799
|
-
|
|
12093
|
+
if (!(fromCoin instanceof Coin) || !(toCoin instanceof Coin) || typeof amount !== "string" || typeof toAddress !== "string" || typeof refundAddress !== "string" || typeof clientIpAddress != "string" || typeof fixed != "boolean") {
|
|
12094
|
+
throw new Error("Invalid input: " + fromCoin + " " + toCoin + " " + amount + " " + toAddress + " " + refundAddress + " " + fixed);
|
|
12095
|
+
}
|
|
12096
|
+
if (typeof rawSwapData !== "object" || fixed && !rawSwapData.rate_id) {
|
|
12097
|
+
throw new Error("Invalid raw swap data: " + safeStringify(rawSwapData));
|
|
12098
|
+
}
|
|
12099
|
+
return Promise.resolve(_this4._fetchSupportedCurrenciesIfNeeded()).then(function () {
|
|
12100
|
+
var fromCoinDetails = _this4._supportedCoins.find(function (i) {
|
|
12101
|
+
var _i$coin3;
|
|
12102
|
+
return ((_i$coin3 = i.coin) == null ? void 0 : _i$coin3.ticker) === (fromCoin == null ? void 0 : fromCoin.ticker);
|
|
12103
|
+
});
|
|
12104
|
+
var toCoinDetails = _this4._supportedCoins.find(function (i) {
|
|
12105
|
+
var _i$coin4;
|
|
12106
|
+
return ((_i$coin4 = i.coin) == null ? void 0 : _i$coin4.ticker) === (toCoin == null ? void 0 : toCoin.ticker);
|
|
12107
|
+
});
|
|
12108
|
+
if (!fromCoinDetails || !toCoinDetails) {
|
|
12109
|
+
throw new Error("Failed to find coin details for: " + fromCoin.ticker + " -> " + toCoin.ticker);
|
|
12110
|
+
}
|
|
12111
|
+
var requestBody = {
|
|
12112
|
+
coin_from: fromCoinDetails.code,
|
|
12113
|
+
network_from: fromCoinDetails.network,
|
|
12114
|
+
coin_to: toCoinDetails.code,
|
|
12115
|
+
network_to: toCoinDetails.network,
|
|
12116
|
+
withdrawal: toAddress,
|
|
12117
|
+
withdrawal_extra_id: toCurrencyExtraId,
|
|
12118
|
+
"return": refundAddress,
|
|
12119
|
+
return_extra_id: refundExtraId,
|
|
12120
|
+
affiliate_id: LetsExchangeSwapProvider.AFFILIATE_ID
|
|
12121
|
+
};
|
|
12122
|
+
if (amountIsToReceive) {
|
|
12123
|
+
requestBody.withdrawal_amount = amount;
|
|
12124
|
+
} else {
|
|
12125
|
+
requestBody.deposit_amount = amount;
|
|
12126
|
+
}
|
|
12127
|
+
if (fixed) {
|
|
12128
|
+
requestBody.rate_id = rawSwapData.rate_id;
|
|
12129
|
+
}
|
|
12130
|
+
return Promise.resolve(axios__default["default"].post(_this4._URL + "/v1/transaction" + (amountIsToReceive ? "-revert" : "?float=" + !fixed), requestBody, {
|
|
12131
|
+
headers: _this4._headers
|
|
12132
|
+
})).then(function (response) {
|
|
12133
|
+
var result = response.data;
|
|
12134
|
+
Logger.log("Creation result " + safeStringify(result), loggerSource);
|
|
12135
|
+
if (result != null && result.transaction_id) {
|
|
12136
|
+
var _result$rate, _result$deposit_extra;
|
|
12137
|
+
var rate = bignumber_js.BigNumber((_result$rate = result.rate) != null ? _result$rate : 0).isZero() ? bignumber_js.BigNumber(result.withdrawal_amount).div(result.deposit_amount) : bignumber_js.BigNumber(result.rate);
|
|
12138
|
+
return {
|
|
12139
|
+
result: true,
|
|
12140
|
+
swapId: result.transaction_id,
|
|
12141
|
+
fromCoin: fromCoin,
|
|
12142
|
+
fromAmount: AmountUtils.trim(result.deposit_amount, fromCoin.digits),
|
|
12143
|
+
fromAddress: result.deposit,
|
|
12144
|
+
toCoin: toCoin,
|
|
12145
|
+
toAmount: AmountUtils.trim(result.withdrawal_amount, toCoin.digits),
|
|
12146
|
+
toAddress: result.withdrawal,
|
|
12147
|
+
fromCurrencyExtraId: (_result$deposit_extra = result.deposit_extra_id) != null ? _result$deposit_extra : "",
|
|
12148
|
+
rate: AmountUtils.trim(rate, _this4._maxRateDigits),
|
|
12149
|
+
fixed: !result.is_float
|
|
12150
|
+
};
|
|
11800
12151
|
}
|
|
11801
|
-
var
|
|
11802
|
-
|
|
11803
|
-
|
|
11804
|
-
fiatMin: fiatMin,
|
|
11805
|
-
max: details == null ? void 0 : details.greatestMax,
|
|
11806
|
-
fiatMax: fiatMax,
|
|
11807
|
-
rate: AmountUtils.trim(details.rate, 30)
|
|
11808
|
-
};
|
|
11809
|
-
Logger.log("Returning: " + safeStringify(result), loggerSource);
|
|
11810
|
-
return result;
|
|
12152
|
+
var errorMessage = "Swap creation succeeded but the response is wrong: " + safeStringify(response);
|
|
12153
|
+
Logger.log(errorMessage, loggerSource);
|
|
12154
|
+
throw new Error(errorMessage);
|
|
11811
12155
|
});
|
|
11812
12156
|
});
|
|
11813
12157
|
}, function (e) {
|
|
11814
|
-
|
|
12158
|
+
var _e$response3, _e$response4;
|
|
12159
|
+
Logger.logError(e, loggerSource, "Failed to create swap. Error is: " + safeStringify(e));
|
|
12160
|
+
var composeFailResult = function composeFailResult(reason) {
|
|
12161
|
+
return {
|
|
12162
|
+
result: false,
|
|
12163
|
+
reason: reason
|
|
12164
|
+
};
|
|
12165
|
+
};
|
|
12166
|
+
var status = e == null || (_e$response3 = e.response) == null ? void 0 : _e$response3.status;
|
|
12167
|
+
var data = e == null || (_e$response4 = e.response) == null ? void 0 : _e$response4.data;
|
|
12168
|
+
if (status === 429) {
|
|
12169
|
+
Logger.log("Returning fail - RPS limit exceeded " + data, loggerSource);
|
|
12170
|
+
return composeFailResult(SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED);
|
|
12171
|
+
}
|
|
12172
|
+
// TODO: [feature, low] add custom errors handling - waiting for response from letsexchange. task_id=00d2e435f6df4fb99af912135bd9ee27
|
|
12173
|
+
// 422 - missing params
|
|
12174
|
+
Logger.log("Internal error for swap: " + safeStringify(e), loggerSource);
|
|
11815
12175
|
improveAndRethrow(e, loggerSource);
|
|
11816
12176
|
}));
|
|
11817
12177
|
} catch (e) {
|
|
11818
12178
|
return Promise.reject(e);
|
|
11819
12179
|
}
|
|
11820
12180
|
};
|
|
11821
|
-
|
|
11822
|
-
(function () {
|
|
11823
|
-
try {
|
|
11824
|
-
var _temp = _catch$2(function () {
|
|
11825
|
-
return Promise.resolve(EmailsApi.sendEmail("AUTOMATIC EMAIL - SWAPSPACE REQUESTS LIMIT EXCEEDED", "Requests limit exceeded. Urgently ask swaps provider support for limit increasing")).then(function () {});
|
|
11826
|
-
}, function (e) {
|
|
11827
|
-
Logger.log("Failed to handle limit exceeding " + safeStringify(e), "_safeHandleRequestsLimitExceeding");
|
|
11828
|
-
});
|
|
11829
|
-
return _temp && _temp.then ? _temp.then(function () {}) : void 0;
|
|
11830
|
-
} catch (e) {
|
|
11831
|
-
Promise.reject(e);
|
|
11832
|
-
}
|
|
11833
|
-
})();
|
|
11834
|
-
}
|
|
11835
|
-
|
|
11836
|
-
/**
|
|
11837
|
-
* If some swap is not found by id then there is no item in return list.
|
|
11838
|
-
*
|
|
11839
|
-
* @param swapProviders {SwapProvider[]} - Array of swap providers
|
|
11840
|
-
* @param swapIds {string[]} - Array of swap IDs
|
|
11841
|
-
* @return {Promise<{
|
|
11842
|
-
* result: true,
|
|
11843
|
-
* swaps: ExistingSwapWithFiatData[]
|
|
11844
|
-
* }|{
|
|
11845
|
-
* result: false,
|
|
11846
|
-
* reason: string
|
|
11847
|
-
* }>}
|
|
11848
|
-
*/;
|
|
11849
|
-
SwapUtils.getExistingSwapsDetailsWithFiatAmounts = function getExistingSwapsDetailsWithFiatAmounts(swapProviders, swapIds) {
|
|
12181
|
+
_proto.getExistingSwapsDetailsAndStatus = function getExistingSwapsDetailsAndStatus(swapIds) {
|
|
11850
12182
|
try {
|
|
12183
|
+
var _this5 = this;
|
|
12184
|
+
var loggerSource = "getExistingSwapsDetailsAndStatus";
|
|
11851
12185
|
return Promise.resolve(_catch$2(function () {
|
|
11852
|
-
|
|
11853
|
-
|
|
11854
|
-
|
|
11855
|
-
|
|
11856
|
-
|
|
11857
|
-
|
|
11858
|
-
|
|
11859
|
-
|
|
11860
|
-
|
|
11861
|
-
|
|
11862
|
-
|
|
12186
|
+
if (swapIds.find(function (id) {
|
|
12187
|
+
return typeof id !== "string";
|
|
12188
|
+
})) {
|
|
12189
|
+
throw new Error("Swap id is not string: " + safeStringify(swapIds));
|
|
12190
|
+
}
|
|
12191
|
+
return Promise.resolve(axios__default["default"].get(_this5._URL + "/v1/transactions-list?ids[]=" + swapIds.join("&ids[]="), {
|
|
12192
|
+
headers: _this5._headers
|
|
12193
|
+
})).then(function (response) {
|
|
12194
|
+
Logger.log("All swaps RAW: " + safeStringify(response.data), loggerSource);
|
|
12195
|
+
var swaps = response.data.map(function (swap, index) {
|
|
12196
|
+
var _this5$_supportedCoin, _this5$_supportedCoin2, _swap$deposit_extra_i, _swap$withdrawal_extr, _swap$return_extra_id;
|
|
12197
|
+
var fromCoin = (_this5$_supportedCoin = _this5._supportedCoins.find(function (i) {
|
|
12198
|
+
return i.code === swap.coin_from && i.network === swap.coin_from_network;
|
|
12199
|
+
})) == null ? void 0 : _this5$_supportedCoin.coin;
|
|
12200
|
+
var toCoin = (_this5$_supportedCoin2 = _this5._supportedCoins.find(function (i) {
|
|
12201
|
+
return i.code === swap.coin_to && i.network === swap.coin_to_network;
|
|
12202
|
+
})) == null ? void 0 : _this5$_supportedCoin2.coin;
|
|
12203
|
+
if (!fromCoin || !toCoin) {
|
|
12204
|
+
return []; // We skip swaps with not supported coins for now
|
|
12205
|
+
}
|
|
12206
|
+
var toUtcTimestamp = function toUtcTimestamp(timeStr) {
|
|
12207
|
+
return Date.parse(timeStr.match(/.+[Zz]$/) ? timeStr : timeStr + "Z");
|
|
11863
12208
|
};
|
|
11864
|
-
|
|
12209
|
+
var expiresAt = swap.expired_at ? swap.expired_at * 1000 : null;
|
|
12210
|
+
var createdAt = swap.created_at ? toUtcTimestamp("" + swap.created_at) : null;
|
|
12211
|
+
var isExpiredByTime = expiresAt && expiresAt < Date.now();
|
|
12212
|
+
var status = _this5._mapLetsExchangeStatusToRabbitStatus(swap.status, isExpiredByTime);
|
|
12213
|
+
var toDigits = status === SwapProvider.SWAP_STATUSES.REFUNDED ? fromCoin.digits : toCoin.digits;
|
|
12214
|
+
var deposit = swap.real_deposit_amount && swap.real_deposit_amount !== "" ? swap.real_deposit_amount : swap.deposit_amount;
|
|
12215
|
+
var withdrawal = swap.real_withdrawal_amount && swap.real_withdrawal_amount !== "" ? swap.real_withdrawal_amount : swap.withdrawal_amount;
|
|
12216
|
+
var rate = bignumber_js.BigNumber(withdrawal).div(deposit).toFixed(_this5._maxRateDigits); // We don't use their rate as it excludes their fee
|
|
12217
|
+
return new ExistingSwap(swapIds[index], status, createdAt, expiresAt, swap.confirmations, rate, swap.is_float != null ? !swap.is_float : false, swap["return"], swap.deposit, fromCoin, AmountUtils.trim(deposit, fromCoin.digits), swap.hash_in, swap.hash_in ? "" + swap.coin_from_explorer_url + swap.hash_in : null, toCoin, AmountUtils.trim(withdrawal, toDigits), swap.hash_out, swap.hash_out ? "" + swap.coin_to_explorer_url + swap.hash_out : null, swap.withdrawal, "letsexchange", (_swap$deposit_extra_i = swap.deposit_extra_id) != null ? _swap$deposit_extra_i : null, (_swap$withdrawal_extr = swap.withdrawal_extra_id) != null ? _swap$withdrawal_extr : null, (_swap$return_extra_id = swap.return_extra_id) != null ? _swap$return_extra_id : null);
|
|
12218
|
+
}).flat();
|
|
12219
|
+
Logger.log("Swap details result " + safeStringify(swaps), loggerSource);
|
|
11865
12220
|
return {
|
|
11866
12221
|
result: true,
|
|
11867
|
-
swaps:
|
|
12222
|
+
swaps: swaps
|
|
12223
|
+
};
|
|
12224
|
+
});
|
|
12225
|
+
}, function (e) {
|
|
12226
|
+
var _e$response5, _e$response6;
|
|
12227
|
+
Logger.logError(e, loggerSource, "Failed to get swap details. Error is: " + safeStringify(e));
|
|
12228
|
+
var composeFailResult = function composeFailResult(reason) {
|
|
12229
|
+
return {
|
|
12230
|
+
result: false,
|
|
12231
|
+
reason: reason
|
|
11868
12232
|
};
|
|
12233
|
+
};
|
|
12234
|
+
var status = e == null || (_e$response5 = e.response) == null ? void 0 : _e$response5.status;
|
|
12235
|
+
var data = e == null || (_e$response6 = e.response) == null ? void 0 : _e$response6.data;
|
|
12236
|
+
if (status === 429) {
|
|
12237
|
+
Logger.log("Returning fail - RPS limit exceeded " + data, loggerSource);
|
|
12238
|
+
return composeFailResult(SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED);
|
|
11869
12239
|
}
|
|
11870
|
-
|
|
11871
|
-
var remainingSwapIds = new Set(swapIds);
|
|
11872
|
-
var failResults = [];
|
|
11873
|
-
var _temp7 = _forOf(swapProviders, function (provider) {
|
|
11874
|
-
return Promise.resolve(provider.getExistingSwapsDetailsAndStatus([].concat(remainingSwapIds))).then(function (result) {
|
|
11875
|
-
var _temp6 = function () {
|
|
11876
|
-
if (result.result) {
|
|
11877
|
-
var _temp5 = function _temp5() {
|
|
11878
|
-
allSwaps = allSwaps.concat(_extendedSwaps);
|
|
11879
|
-
|
|
11880
|
-
// Stop if we have retrieved all swaps
|
|
11881
|
-
if (allSwaps.length >= swapIds.length) {
|
|
11882
|
-
_interrupt = 1;
|
|
11883
|
-
}
|
|
11884
|
-
};
|
|
11885
|
-
var _extendedSwaps = [];
|
|
11886
|
-
var _temp4 = _forOf(result.swaps, function (swap) {
|
|
11887
|
-
function _temp3() {
|
|
11888
|
-
remainingSwapIds["delete"](swap.id);
|
|
11889
|
-
}
|
|
11890
|
-
var _temp2 = function () {
|
|
11891
|
-
if (swap.status === SwapProvider.SWAP_STATUSES.REFUNDED) {
|
|
11892
|
-
return Promise.resolve(provider.getCoinToUSDTRate(swap.fromCoin)).then(function (rate) {
|
|
11893
|
-
_extendedSwaps.push(ExistingSwapWithFiatData.fromExistingSwap(swap, (rate == null ? void 0 : rate.rate) != null ? bignumber_js.BigNumber(swap.fromAmount).times(rate.rate).toNumber() : null, (rate == null ? void 0 : rate.rate) != null ? bignumber_js.BigNumber(swap.toAmount).times(rate.rate).toNumber() : null, "USD", FiatCurrenciesService.getCurrencyDecimalCountByCode("USD")));
|
|
11894
|
-
});
|
|
11895
|
-
} else {
|
|
11896
|
-
return Promise.resolve(Promise.all([provider.getCoinToUSDTRate(swap.fromCoin), provider.getCoinToUSDTRate(swap.toCoin)])).then(function (_ref) {
|
|
11897
|
-
var fromCoinFiatRate = _ref[0],
|
|
11898
|
-
toCoinFiatRate = _ref[1];
|
|
11899
|
-
_extendedSwaps.push(ExistingSwapWithFiatData.fromExistingSwap(swap, (fromCoinFiatRate == null ? void 0 : fromCoinFiatRate.rate) != null ? bignumber_js.BigNumber(swap.fromAmount).times(fromCoinFiatRate.rate).toNumber() : null, (toCoinFiatRate == null ? void 0 : toCoinFiatRate.rate) != null ? bignumber_js.BigNumber(swap.toAmount).times(toCoinFiatRate.rate).toNumber() : null, "USD", FiatCurrenciesService.getCurrencyDecimalCountByCode("USD")));
|
|
11900
|
-
});
|
|
11901
|
-
}
|
|
11902
|
-
}();
|
|
11903
|
-
return _temp2 && _temp2.then ? _temp2.then(_temp3) : _temp3(_temp2);
|
|
11904
|
-
});
|
|
11905
|
-
return _temp4 && _temp4.then ? _temp4.then(_temp5) : _temp5(_temp4);
|
|
11906
|
-
} else {
|
|
11907
|
-
failResults.push(result);
|
|
11908
|
-
}
|
|
11909
|
-
}();
|
|
11910
|
-
if (_temp6 && _temp6.then) return _temp6.then(function () {});
|
|
11911
|
-
});
|
|
11912
|
-
}, function () {
|
|
11913
|
-
return _interrupt;
|
|
11914
|
-
});
|
|
11915
|
-
return _temp7 && _temp7.then ? _temp7.then(_temp8) : _temp8(_temp7);
|
|
11916
|
-
}, function (e) {
|
|
11917
|
-
improveAndRethrow(e, "getExistingSwapsDetailsWithFiatAmounts");
|
|
12240
|
+
improveAndRethrow(e, loggerSource);
|
|
11918
12241
|
}));
|
|
11919
12242
|
} catch (e) {
|
|
11920
12243
|
return Promise.reject(e);
|
|
11921
12244
|
}
|
|
11922
12245
|
};
|
|
11923
|
-
|
|
11924
|
-
|
|
12246
|
+
_proto._mapLetsExchangeStatusToRabbitStatus = function _mapLetsExchangeStatusToRabbitStatus(status, isExpiredByTime) {
|
|
12247
|
+
/**
|
|
12248
|
+
* Lets exchange statuses description
|
|
12249
|
+
* wait - The exchange has just been created and it’s waiting for coins to reach the deposit wallet
|
|
12250
|
+
* confirmation - The transaction appears in mempool and now it is waiting for necessary network confirmations to start.
|
|
12251
|
+
* confirmed - The user’s payment is confirmed, the exchange process is about to start.
|
|
12252
|
+
* exchanging - The exchange process is running.
|
|
12253
|
+
* sending - Funds are being sent to the recipient`s address.
|
|
12254
|
+
* sending_confirmation - The outgoing transaction is waiting for network confirmations.
|
|
12255
|
+
* success - The exchange is completed and the funds are successfully sent to the recipient’s address.
|
|
12256
|
+
* aml_check_failed - The deposit was marked as risky by AML check service.
|
|
12257
|
+
* overdue - The deposit receiving time for this transaction has expired.
|
|
12258
|
+
* error - The transaction has failed. In most cases, the amount that was sent differs from the amount that was specified when creating the transaction.
|
|
12259
|
+
* refund - The exchange failed and the coins were refunded to the user's wallet.
|
|
12260
|
+
*/
|
|
12261
|
+
switch (status) {
|
|
12262
|
+
case "wait":
|
|
12263
|
+
if (isExpiredByTime) {
|
|
12264
|
+
return SwapProvider.SWAP_STATUSES.EXPIRED;
|
|
12265
|
+
}
|
|
12266
|
+
return SwapProvider.SWAP_STATUSES.WAITING_FOR_PAYMENT;
|
|
12267
|
+
case "confirmation":
|
|
12268
|
+
return SwapProvider.SWAP_STATUSES.CONFIRMING;
|
|
12269
|
+
case "confirmed":
|
|
12270
|
+
return SwapProvider.SWAP_STATUSES.PAYMENT_RECEIVED;
|
|
12271
|
+
case "exchanging":
|
|
12272
|
+
return SwapProvider.SWAP_STATUSES.EXCHANGING;
|
|
12273
|
+
case "sending":
|
|
12274
|
+
return SwapProvider.SWAP_STATUSES.EXCHANGING;
|
|
12275
|
+
case "sending_confirmation":
|
|
12276
|
+
return SwapProvider.SWAP_STATUSES.EXCHANGING;
|
|
12277
|
+
case "success":
|
|
12278
|
+
return SwapProvider.SWAP_STATUSES.COMPLETED;
|
|
12279
|
+
case "refund":
|
|
12280
|
+
return SwapProvider.SWAP_STATUSES.REFUNDED;
|
|
12281
|
+
case "overdue":
|
|
12282
|
+
return SwapProvider.SWAP_STATUSES.EXPIRED;
|
|
12283
|
+
case "aml_check_failed":
|
|
12284
|
+
return SwapProvider.SWAP_STATUSES.EXCHANGING;
|
|
12285
|
+
case "error":
|
|
12286
|
+
return SwapProvider.SWAP_STATUSES.FAILED;
|
|
12287
|
+
default:
|
|
12288
|
+
throw new Error("Unknown LetsExchange status: " + status);
|
|
12289
|
+
}
|
|
12290
|
+
};
|
|
12291
|
+
_proto.getPartnersList = function getPartnersList() {
|
|
12292
|
+
try {
|
|
12293
|
+
return Promise.resolve([new Partner("letsexchange", "LetsExchange", "https://letsexchange.notion.site/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F02e45813-b375-49d8-b2b0-092ce1847fff%2F55ebbc3c-4ee6-4fa7-847b-f673e82594f3%2Flets-logo-basic__on-light.svg?table=block&id=bec5952a-2f9c-47fb-8cc0-86e1391a7f60&spaceId=02e45813-b375-49d8-b2b0-092ce1847fff&userId=&cache=v2", null)]);
|
|
12294
|
+
} catch (e) {
|
|
12295
|
+
return Promise.reject(e);
|
|
12296
|
+
}
|
|
12297
|
+
};
|
|
12298
|
+
return LetsExchangeSwapProvider;
|
|
12299
|
+
}(SwapProvider);
|
|
12300
|
+
LetsExchangeSwapProvider.AFFILIATE_ID = "0zbj9hf7xg7jgdgv";
|
|
11925
12301
|
|
|
11926
12302
|
function _catch$1(body, recover) {
|
|
11927
12303
|
try {
|
|
@@ -11934,422 +12310,354 @@
|
|
|
11934
12310
|
}
|
|
11935
12311
|
return result;
|
|
11936
12312
|
}
|
|
11937
|
-
var
|
|
11938
|
-
|
|
11939
|
-
|
|
11940
|
-
|
|
11941
|
-
|
|
11942
|
-
|
|
11943
|
-
|
|
11944
|
-
|
|
12313
|
+
var _iteratorSymbol = typeof Symbol !== "undefined" ? Symbol.iterator || (Symbol.iterator = Symbol("Symbol.iterator")) : "@@iterator";
|
|
12314
|
+
function _settle(pact, state, value) {
|
|
12315
|
+
if (!pact.s) {
|
|
12316
|
+
if (value instanceof _Pact) {
|
|
12317
|
+
if (value.s) {
|
|
12318
|
+
if (state & 1) {
|
|
12319
|
+
state = value.s;
|
|
12320
|
+
}
|
|
12321
|
+
value = value.v;
|
|
12322
|
+
} else {
|
|
12323
|
+
value.o = _settle.bind(null, pact, state);
|
|
12324
|
+
return;
|
|
12325
|
+
}
|
|
11945
12326
|
}
|
|
11946
|
-
if (
|
|
11947
|
-
|
|
12327
|
+
if (value && value.then) {
|
|
12328
|
+
value.then(_settle.bind(null, pact, state), _settle.bind(null, pact, 2));
|
|
12329
|
+
return;
|
|
12330
|
+
}
|
|
12331
|
+
pact.s = state;
|
|
12332
|
+
pact.v = value;
|
|
12333
|
+
var observer = pact.o;
|
|
12334
|
+
if (observer) {
|
|
12335
|
+
observer(pact);
|
|
11948
12336
|
}
|
|
11949
|
-
_this = _SwapProvider.call(this, cache, customCoinBuilder, useRestrictedCoinsSet) || this;
|
|
11950
|
-
_this._partners = [];
|
|
11951
|
-
_this._URL = apiKeysProxyUrl + "/letsexchange";
|
|
11952
|
-
_this.isAggregator = false;
|
|
11953
|
-
_this.COINS_EXPIRATION_TIME_MS = 5 * 60 * 1000;
|
|
11954
|
-
_this.coinsLastUpdateTimestamp = null;
|
|
11955
|
-
return _this;
|
|
11956
12337
|
}
|
|
11957
|
-
|
|
11958
|
-
|
|
11959
|
-
|
|
12338
|
+
}
|
|
12339
|
+
var _Pact = /*#__PURE__*/function () {
|
|
12340
|
+
function _Pact() {}
|
|
12341
|
+
_Pact.prototype.then = function (onFulfilled, onRejected) {
|
|
12342
|
+
var result = new _Pact();
|
|
12343
|
+
var state = this.s;
|
|
12344
|
+
if (state) {
|
|
12345
|
+
var callback = state & 1 ? onFulfilled : onRejected;
|
|
12346
|
+
if (callback) {
|
|
12347
|
+
try {
|
|
12348
|
+
_settle(result, 1, callback(this.v));
|
|
12349
|
+
} catch (e) {
|
|
12350
|
+
_settle(result, 2, e);
|
|
12351
|
+
}
|
|
12352
|
+
return result;
|
|
12353
|
+
} else {
|
|
12354
|
+
return this;
|
|
12355
|
+
}
|
|
12356
|
+
}
|
|
12357
|
+
this.o = function (_this) {
|
|
12358
|
+
try {
|
|
12359
|
+
var value = _this.v;
|
|
12360
|
+
if (_this.s & 1) {
|
|
12361
|
+
_settle(result, 1, onFulfilled ? onFulfilled(value) : value);
|
|
12362
|
+
} else if (onRejected) {
|
|
12363
|
+
_settle(result, 1, onRejected(value));
|
|
12364
|
+
} else {
|
|
12365
|
+
_settle(result, 2, value);
|
|
12366
|
+
}
|
|
12367
|
+
} catch (e) {
|
|
12368
|
+
_settle(result, 2, e);
|
|
12369
|
+
}
|
|
12370
|
+
};
|
|
12371
|
+
return result;
|
|
11960
12372
|
};
|
|
11961
|
-
|
|
12373
|
+
return _Pact;
|
|
12374
|
+
}();
|
|
12375
|
+
function _isSettledPact(thenable) {
|
|
12376
|
+
return thenable instanceof _Pact && thenable.s & 1;
|
|
12377
|
+
}
|
|
12378
|
+
function _forTo(array, body, check) {
|
|
12379
|
+
var i = -1,
|
|
12380
|
+
pact,
|
|
12381
|
+
reject;
|
|
12382
|
+
function _cycle(result) {
|
|
11962
12383
|
try {
|
|
11963
|
-
|
|
11964
|
-
|
|
11965
|
-
|
|
11966
|
-
|
|
11967
|
-
|
|
11968
|
-
|
|
11969
|
-
|
|
11970
|
-
|
|
11971
|
-
var allowedCoins = (_rawResponse$data2 = rawResponse == null ? void 0 : rawResponse.data) != null ? _rawResponse$data2 : [];
|
|
11972
|
-
Logger.log("Allowed cnt " + allowedCoins.length, loggerSource);
|
|
11973
|
-
_this2._supportedCoins = allowedCoins.map(function (item) {
|
|
11974
|
-
var code = item.code.toUpperCase();
|
|
11975
|
-
if (!Array.isArray(item.networks)) return [];
|
|
11976
|
-
return item.networks.map(function (networkDetails) {
|
|
11977
|
-
var network = networkDetails.code.toUpperCase();
|
|
11978
|
-
var coin = _this2._customCoinBuilder(code, network);
|
|
11979
|
-
if (!coin && !_this2.useRestrictedCoinsSet) {
|
|
11980
|
-
var name = _this2.removeProtocolNameFromCoinName(item.name, code, network);
|
|
11981
|
-
var ticker = "" + code + (code === network ? "" : network);
|
|
11982
|
-
var defaultDecimalPlacesForCoinNotSupportedOOB = DEFAULT_CRYPTO_DECIMAL_COUNT;
|
|
11983
|
-
var defaultMinConfirmationsForCoinNotSupportedOOB = 1;
|
|
11984
|
-
coin = new Coin(name, ticker, code, defaultDecimalPlacesForCoinNotSupportedOOB, null, "", null, null, defaultMinConfirmationsForCoinNotSupportedOOB, null, [], 60000, null, code !== network ? new Protocol(network) : null, item.contract_address || null, false);
|
|
11985
|
-
}
|
|
11986
|
-
if (coin) {
|
|
11987
|
-
var _networkDetails$extra, _networkDetails$valid;
|
|
11988
|
-
return new SwapProviderCoinInfo(coin, item.code, networkDetails.code, !!networkDetails.has_extra, (_networkDetails$extra = networkDetails.extra_name) != null ? _networkDetails$extra : null, item.rating || 0, item.icon ? item.icon : FALLBACK_ASSET_ICON_URL, true,
|
|
11989
|
-
// Letsexchange provide no such details
|
|
11990
|
-
true, // Letsexchange provide no such details
|
|
11991
|
-
(_networkDetails$valid = networkDetails.validation_address_regex) != null ? _networkDetails$valid : null, (typeof item.is_active !== "number" || item.is_active === 1) && (typeof item.disabled !== "number" || item.disabled === 0) && (typeof networkDetails.is_active !== "number" || networkDetails.is_active === 1));
|
|
11992
|
-
}
|
|
11993
|
-
return [];
|
|
11994
|
-
});
|
|
11995
|
-
}).flat();
|
|
11996
|
-
_this2.coinsLastUpdateTimestamp = Date.now();
|
|
11997
|
-
_this2._putPopularCoinsFirst();
|
|
11998
|
-
return Promise.resolve(_SwapProvider.prototype._fetchSupportedCurrenciesIfNeeded.call(_this2)).then(function () {});
|
|
11999
|
-
});
|
|
12384
|
+
while (++i < array.length && (!check || !check())) {
|
|
12385
|
+
result = body(i);
|
|
12386
|
+
if (result && result.then) {
|
|
12387
|
+
if (_isSettledPact(result)) {
|
|
12388
|
+
result = result.v;
|
|
12389
|
+
} else {
|
|
12390
|
+
result.then(_cycle, reject || (reject = _settle.bind(null, pact = new _Pact(), 2)));
|
|
12391
|
+
return;
|
|
12000
12392
|
}
|
|
12001
|
-
}
|
|
12002
|
-
|
|
12003
|
-
|
|
12004
|
-
|
|
12005
|
-
}
|
|
12393
|
+
}
|
|
12394
|
+
}
|
|
12395
|
+
if (pact) {
|
|
12396
|
+
_settle(pact, 1, result);
|
|
12397
|
+
} else {
|
|
12398
|
+
pact = result;
|
|
12399
|
+
}
|
|
12006
12400
|
} catch (e) {
|
|
12007
|
-
|
|
12008
|
-
}
|
|
12009
|
-
};
|
|
12010
|
-
_proto.getSwapInfo = function getSwapInfo(fromCoin, toCoin, amountCoins, fixed, fromCoinToUsdRate, amountIsToReceive) {
|
|
12011
|
-
if (fixed === void 0) {
|
|
12012
|
-
fixed = false;
|
|
12013
|
-
}
|
|
12014
|
-
if (amountIsToReceive === void 0) {
|
|
12015
|
-
amountIsToReceive = false;
|
|
12401
|
+
_settle(pact || (pact = new _Pact()), 2, e);
|
|
12016
12402
|
}
|
|
12017
|
-
|
|
12018
|
-
|
|
12019
|
-
|
|
12020
|
-
|
|
12021
|
-
|
|
12022
|
-
|
|
12023
|
-
|
|
12024
|
-
|
|
12025
|
-
|
|
12026
|
-
|
|
12027
|
-
|
|
12028
|
-
|
|
12029
|
-
|
|
12030
|
-
|
|
12031
|
-
|
|
12032
|
-
|
|
12033
|
-
});
|
|
12034
|
-
if (!fromCoinDetails || !toCoinDetails || !fromCoinDetails.deposit || !fromCoinDetails.isAvailable || !toCoinDetails.withdrawal || !toCoinDetails.isAvailable) {
|
|
12035
|
-
return {
|
|
12036
|
-
result: false,
|
|
12037
|
-
reason: SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED
|
|
12038
|
-
};
|
|
12039
|
-
}
|
|
12040
|
-
var pathAndQuery = "/v1/info" + (amountIsToReceive ? "-revert" : "?float=" + !fixed);
|
|
12041
|
-
return Promise.resolve(axios__default["default"].post("" + _this3._URL + pathAndQuery, {
|
|
12042
|
-
from: fromCoinDetails.code,
|
|
12043
|
-
to: toCoinDetails.code,
|
|
12044
|
-
network_from: fromCoinDetails.network,
|
|
12045
|
-
network_to: toCoinDetails.network,
|
|
12046
|
-
amount: amountCoins,
|
|
12047
|
-
affiliate_id: LetsExchangeSwapProvider.AFFILIATE_ID
|
|
12048
|
-
})).then(function (response) {
|
|
12049
|
-
Logger.log("Retrieved " + (response == null ? void 0 : response.data), loggerSource);
|
|
12050
|
-
var data = response.data;
|
|
12051
|
-
|
|
12052
|
-
// TODO: [dev] add SwapProvider.NO_SWAPS_REASONS.NO_FIXED_BUT_HAVE_FLOATING - request alternative rate. task_id=
|
|
12053
|
-
|
|
12054
|
-
// TODO: [feature, low] implement extra coins to fit min/max if there are frequent errors due to min/max exceeding
|
|
12055
|
-
// let extraCoinsToFitMinMax = "0";
|
|
12056
|
-
// if (typeof fromCoinToUsdRate === "string" && BigNumber(fromCoinToUsdRate).gt("0")) {
|
|
12057
|
-
// const extraUsdToFitMinMax = BigNumber("1"); // We correct the limits as the exact limit can fluctuate and cause failed swap creation
|
|
12058
|
-
// extraCoinsToFitMinMax = AmountUtils.trim(extraUsdToFitMinMax.div(fromCoinToUsdRate), fromCoin.digits);
|
|
12059
|
-
// }
|
|
12060
|
-
if (data != null && data.min_amount) {
|
|
12061
|
-
min = AmountUtils.trim(data == null ? void 0 : data.min_amount, amountIsToReceive ? toCoin.digits : fromCoin.digits);
|
|
12062
|
-
}
|
|
12063
|
-
if (data != null && data.max_amount) {
|
|
12064
|
-
max = AmountUtils.trim(data == null ? void 0 : data.max_amount, amountIsToReceive ? toCoin.digits : fromCoin.digits);
|
|
12065
|
-
}
|
|
12066
|
-
if (data.success === false && data.error) {
|
|
12067
|
-
// TODO: [dev] waiting for response from letsexchange about their not-documented responses
|
|
12068
|
-
// {
|
|
12069
|
-
// "success": false,
|
|
12070
|
-
// "error": "Internal error"
|
|
12071
|
-
// }
|
|
12072
|
-
throw new Error("Failed to estimate swap letsexchange");
|
|
12073
|
-
}
|
|
12074
|
-
if (bignumber_js.BigNumber(data.rate).eq("0") || bignumber_js.BigNumber(data.amount).eq("0")) {
|
|
12075
|
-
// TODO actualize according to letsexchage clarification - decide, can we count on min/max abcense? task_id=76512110797f4eab8b37f1bb789825cb
|
|
12076
|
-
// amount: "0", rate: "0", rate_id: ""
|
|
12077
|
-
var reason = SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED;
|
|
12078
|
-
if (min && bignumber_js.BigNumber(amountCoins).lt(min)) {
|
|
12079
|
-
reason = SwapProvider.NO_SWAPS_REASONS.TOO_LOW;
|
|
12080
|
-
} else if (max && bignumber_js.BigNumber(amountCoins).gt(max)) {
|
|
12081
|
-
reason = SwapProvider.NO_SWAPS_REASONS.TOO_HIGH;
|
|
12082
|
-
} else if (!amountIsToReceive) {
|
|
12083
|
-
// If we are not requesting receiving amount (it cannot be floating-rate)
|
|
12084
|
-
// todo [feature, moderate] request alternative rate. task_id=31884db5392f49738c20a86115c90e1f
|
|
12085
|
-
// const alternativeRate = 1;
|
|
12086
|
-
// const alternativeRateAvailable = alternativeRate;
|
|
12087
|
-
// if (alternativeRateAvailable) {
|
|
12088
|
-
// reason = fixed
|
|
12089
|
-
// ? SwapProvider.NO_SWAPS_REASONS.NO_FIXED_BUT_HAVE_FLOATING
|
|
12090
|
-
// : SwapProvider.NO_SWAPS_REASONS.NO_FLOATING_BUT_HAVE_FIXED;
|
|
12091
|
-
// }
|
|
12403
|
+
}
|
|
12404
|
+
_cycle();
|
|
12405
|
+
return pact;
|
|
12406
|
+
}
|
|
12407
|
+
function _forOf(target, body, check) {
|
|
12408
|
+
if (typeof target[_iteratorSymbol] === "function") {
|
|
12409
|
+
var _cycle = function _cycle(result) {
|
|
12410
|
+
try {
|
|
12411
|
+
while (!(step = iterator.next()).done && (!check || !check())) {
|
|
12412
|
+
result = body(step.value);
|
|
12413
|
+
if (result && result.then) {
|
|
12414
|
+
if (_isSettledPact(result)) {
|
|
12415
|
+
result = result.v;
|
|
12416
|
+
} else {
|
|
12417
|
+
result.then(_cycle, reject || (reject = _settle.bind(null, pact = new _Pact(), 2)));
|
|
12418
|
+
return;
|
|
12092
12419
|
}
|
|
12093
|
-
return {
|
|
12094
|
-
result: false,
|
|
12095
|
-
reason: reason,
|
|
12096
|
-
smallestMin: min,
|
|
12097
|
-
greatestMax: max
|
|
12098
|
-
};
|
|
12099
12420
|
}
|
|
12100
|
-
var rate = amountIsToReceive ? bignumber_js.BigNumber(amountCoins).div(data.amount) : bignumber_js.BigNumber(data.amount).div(amountCoins);
|
|
12101
|
-
return {
|
|
12102
|
-
result: true,
|
|
12103
|
-
min: min,
|
|
12104
|
-
max: max,
|
|
12105
|
-
smallestMin: min,
|
|
12106
|
-
greatestMax: max,
|
|
12107
|
-
rate: AmountUtils.trim(rate, _this3._maxRateDigits),
|
|
12108
|
-
durationMinutesRange: null,
|
|
12109
|
-
fixed: fixed,
|
|
12110
|
-
rawSwapData: data,
|
|
12111
|
-
isRefundAddressRequired: false
|
|
12112
|
-
};
|
|
12113
|
-
});
|
|
12114
|
-
}, function (e) {
|
|
12115
|
-
var _e$response, _e$response2;
|
|
12116
|
-
if ((e == null || (_e$response = e.response) == null ? void 0 : _e$response.status) === 404) {
|
|
12117
|
-
return {
|
|
12118
|
-
result: false,
|
|
12119
|
-
reason: SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED,
|
|
12120
|
-
smallestMin: min,
|
|
12121
|
-
greatestMax: max
|
|
12122
|
-
};
|
|
12123
12421
|
}
|
|
12124
|
-
if (
|
|
12125
|
-
|
|
12126
|
-
|
|
12127
|
-
|
|
12128
|
-
};
|
|
12422
|
+
if (pact) {
|
|
12423
|
+
_settle(pact, 1, result);
|
|
12424
|
+
} else {
|
|
12425
|
+
pact = result;
|
|
12129
12426
|
}
|
|
12130
|
-
|
|
12131
|
-
|
|
12132
|
-
}
|
|
12133
|
-
}
|
|
12134
|
-
|
|
12135
|
-
|
|
12136
|
-
|
|
12137
|
-
|
|
12138
|
-
|
|
12139
|
-
|
|
12427
|
+
} catch (e) {
|
|
12428
|
+
_settle(pact || (pact = new _Pact()), 2, e);
|
|
12429
|
+
}
|
|
12430
|
+
};
|
|
12431
|
+
var iterator = target[_iteratorSymbol](),
|
|
12432
|
+
step,
|
|
12433
|
+
pact,
|
|
12434
|
+
reject;
|
|
12435
|
+
_cycle();
|
|
12436
|
+
if (iterator["return"]) {
|
|
12437
|
+
var _fixup = function _fixup(value) {
|
|
12438
|
+
try {
|
|
12439
|
+
if (!step.done) {
|
|
12440
|
+
iterator["return"]();
|
|
12441
|
+
}
|
|
12442
|
+
} catch (e) {}
|
|
12443
|
+
return value;
|
|
12444
|
+
};
|
|
12445
|
+
if (pact && pact.then) {
|
|
12446
|
+
return pact.then(_fixup, function (e) {
|
|
12447
|
+
throw _fixup(e);
|
|
12448
|
+
});
|
|
12449
|
+
}
|
|
12450
|
+
_fixup();
|
|
12140
12451
|
}
|
|
12141
|
-
|
|
12142
|
-
|
|
12452
|
+
return pact;
|
|
12453
|
+
}
|
|
12454
|
+
// No support for Symbol.iterator
|
|
12455
|
+
if (!("length" in target)) {
|
|
12456
|
+
throw new TypeError("Object is not iterable");
|
|
12457
|
+
}
|
|
12458
|
+
// Handle live collections properly
|
|
12459
|
+
var values = [];
|
|
12460
|
+
for (var i = 0; i < target.length; i++) {
|
|
12461
|
+
values.push(target[i]);
|
|
12462
|
+
}
|
|
12463
|
+
return _forTo(values, function (i) {
|
|
12464
|
+
return body(values[i]);
|
|
12465
|
+
}, check);
|
|
12466
|
+
}
|
|
12467
|
+
var SwapUtils = /*#__PURE__*/function () {
|
|
12468
|
+
function SwapUtils() {}
|
|
12469
|
+
/**
|
|
12470
|
+
* Retrieves min and max limits for swapping giving currencies.
|
|
12471
|
+
* Returns also conversion rate if possible with predefined amount logic.
|
|
12472
|
+
* Rate is how many "to" coins does 1 "from" coin contain.
|
|
12473
|
+
*
|
|
12474
|
+
* In case of errors returns one of reasons
|
|
12475
|
+
* - SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED
|
|
12476
|
+
* - one of SwapProvider.COMMON_ERRORS.*
|
|
12477
|
+
*
|
|
12478
|
+
* @param swapProvider {SwapProvider}
|
|
12479
|
+
* @param fromCoin {Coin} enabled coin (to swap amount from)
|
|
12480
|
+
* @param toCoin {Coin}
|
|
12481
|
+
* @param coinToCurrentFiatRate {string|null}
|
|
12482
|
+
* @param fiatCurrencyDecimals {number|null}
|
|
12483
|
+
* @return {Promise<{
|
|
12484
|
+
* result: true,
|
|
12485
|
+
* min: string,
|
|
12486
|
+
* fiatMin: (number|null),
|
|
12487
|
+
* max: string,
|
|
12488
|
+
* fiatMax: (number|null),
|
|
12489
|
+
* rate: (string|null),
|
|
12490
|
+
* }|{
|
|
12491
|
+
* result: false,
|
|
12492
|
+
* reason: string
|
|
12493
|
+
* }>}
|
|
12494
|
+
*/
|
|
12495
|
+
SwapUtils.getInitialSwapData = function getInitialSwapData(swapProvider, fromCoin, toCoin, coinToCurrentFiatRate, fiatCurrencyDecimals) {
|
|
12496
|
+
if (coinToCurrentFiatRate === void 0) {
|
|
12497
|
+
coinToCurrentFiatRate = null;
|
|
12143
12498
|
}
|
|
12144
|
-
if (
|
|
12145
|
-
|
|
12499
|
+
if (fiatCurrencyDecimals === void 0) {
|
|
12500
|
+
fiatCurrencyDecimals = null;
|
|
12146
12501
|
}
|
|
12147
12502
|
try {
|
|
12148
|
-
var
|
|
12149
|
-
var loggerSource = "createSwap";
|
|
12503
|
+
var loggerSource = "getInitialSwapData";
|
|
12150
12504
|
return Promise.resolve(_catch$1(function () {
|
|
12151
|
-
|
|
12152
|
-
|
|
12153
|
-
|
|
12154
|
-
|
|
12155
|
-
|
|
12156
|
-
|
|
12157
|
-
|
|
12158
|
-
|
|
12159
|
-
return ((
|
|
12160
|
-
|
|
12161
|
-
|
|
12162
|
-
|
|
12163
|
-
|
|
12164
|
-
|
|
12165
|
-
|
|
12166
|
-
|
|
12167
|
-
|
|
12168
|
-
|
|
12169
|
-
|
|
12170
|
-
|
|
12171
|
-
|
|
12172
|
-
|
|
12173
|
-
|
|
12174
|
-
|
|
12175
|
-
|
|
12176
|
-
|
|
12177
|
-
|
|
12178
|
-
|
|
12179
|
-
|
|
12180
|
-
|
|
12181
|
-
|
|
12182
|
-
|
|
12183
|
-
|
|
12184
|
-
if (fixed) {
|
|
12185
|
-
requestBody.rate_id = rawSwapData.rate_id;
|
|
12186
|
-
}
|
|
12187
|
-
return Promise.resolve(axios__default["default"].post(_this4._URL + "/v1/transaction" + (amountIsToReceive ? "-revert" : "?float=" + !fixed), requestBody)).then(function (response) {
|
|
12188
|
-
var result = response.data;
|
|
12189
|
-
Logger.log("Creation result " + safeStringify(result), loggerSource);
|
|
12190
|
-
if (result != null && result.transaction_id) {
|
|
12191
|
-
var _result$rate, _result$deposit_extra;
|
|
12192
|
-
var rate = bignumber_js.BigNumber((_result$rate = result.rate) != null ? _result$rate : 0).isZero() ? bignumber_js.BigNumber(result.withdrawal_amount).div(result.deposit_amount) : bignumber_js.BigNumber(result.rate);
|
|
12193
|
-
return {
|
|
12505
|
+
/* We use some amount here that should fit at least some of the limits of the swap providers.
|
|
12506
|
+
* So we are going to get some rate to be used as the default for the on-flight calculations before we get
|
|
12507
|
+
* the exact rate (that should be retrieved by getSwapCreationInfo method) for a specific amount.
|
|
12508
|
+
*/
|
|
12509
|
+
var defaultAmountUsd = bignumber_js.BigNumber("300");
|
|
12510
|
+
return Promise.resolve(swapProvider.getCoinToUSDTRate(fromCoin)).then(function (coinUsdRate) {
|
|
12511
|
+
var coinAmountForDefaultUsdAmount = AmountUtils.trim(coinUsdRate != null && coinUsdRate.result ? defaultAmountUsd.div(coinUsdRate == null ? void 0 : coinUsdRate.rate) : defaultAmountUsd, fromCoin.digits);
|
|
12512
|
+
Logger.log("Init: " + coinAmountForDefaultUsdAmount + " " + fromCoin.ticker + "->" + toCoin.ticker, loggerSource);
|
|
12513
|
+
return Promise.resolve(swapProvider.getSwapInfo(fromCoin, toCoin, coinAmountForDefaultUsdAmount)).then(function (details) {
|
|
12514
|
+
var _coinToCurrentFiatRat, _fiatCurrencyDecimals;
|
|
12515
|
+
if (!details) {
|
|
12516
|
+
throw new Error("The details are empty: " + safeStringify(details));
|
|
12517
|
+
}
|
|
12518
|
+
if (!details.result) {
|
|
12519
|
+
Logger.log("Failed with reason: " + details.reason + ". " + fromCoin.ticker + "->" + toCoin.ticker, loggerSource);
|
|
12520
|
+
if ((details == null ? void 0 : details.reason) === SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED || (details == null ? void 0 : details.reason) === SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED) {
|
|
12521
|
+
return {
|
|
12522
|
+
result: false,
|
|
12523
|
+
reason: details.reason
|
|
12524
|
+
};
|
|
12525
|
+
} else {
|
|
12526
|
+
throw new Error("Unhandled error case: " + (details == null ? void 0 : details.reason));
|
|
12527
|
+
}
|
|
12528
|
+
}
|
|
12529
|
+
var fiatMin = null;
|
|
12530
|
+
var fiatMax = null;
|
|
12531
|
+
var fiatRate = (_coinToCurrentFiatRat = coinToCurrentFiatRate) != null ? _coinToCurrentFiatRat : coinUsdRate == null ? void 0 : coinUsdRate.rate;
|
|
12532
|
+
var fiatDecimals = (_fiatCurrencyDecimals = fiatCurrencyDecimals) != null ? _fiatCurrencyDecimals : FiatCurrenciesService.getCurrencyDecimalCountByCode("USD");
|
|
12533
|
+
if (fiatRate != null) {
|
|
12534
|
+
fiatMin = bignumber_js.BigNumber(details == null ? void 0 : details.smallestMin).times(fiatRate).toFixed(fiatDecimals);
|
|
12535
|
+
fiatMax = bignumber_js.BigNumber(details == null ? void 0 : details.greatestMax).times(fiatRate).toFixed(fiatDecimals);
|
|
12536
|
+
}
|
|
12537
|
+
var result = {
|
|
12194
12538
|
result: true,
|
|
12195
|
-
|
|
12196
|
-
|
|
12197
|
-
|
|
12198
|
-
|
|
12199
|
-
|
|
12200
|
-
toAmount: AmountUtils.trim(result.withdrawal_amount, toCoin.digits),
|
|
12201
|
-
toAddress: result.withdrawal,
|
|
12202
|
-
fromCurrencyExtraId: (_result$deposit_extra = result.deposit_extra_id) != null ? _result$deposit_extra : "",
|
|
12203
|
-
rate: AmountUtils.trim(rate, _this4._maxRateDigits),
|
|
12204
|
-
fixed: !result.is_float
|
|
12539
|
+
min: details == null ? void 0 : details.smallestMin,
|
|
12540
|
+
fiatMin: fiatMin,
|
|
12541
|
+
max: details == null ? void 0 : details.greatestMax,
|
|
12542
|
+
fiatMax: fiatMax,
|
|
12543
|
+
rate: AmountUtils.trim(details.rate, 30)
|
|
12205
12544
|
};
|
|
12206
|
-
|
|
12207
|
-
|
|
12208
|
-
|
|
12209
|
-
throw new Error(errorMessage);
|
|
12545
|
+
Logger.log("Returning: " + safeStringify(result), loggerSource);
|
|
12546
|
+
return result;
|
|
12547
|
+
});
|
|
12210
12548
|
});
|
|
12211
12549
|
}, function (e) {
|
|
12212
|
-
|
|
12213
|
-
Logger.logError(e, loggerSource, "Failed to create swap. Error is: " + safeStringify(e));
|
|
12214
|
-
var composeFailResult = function composeFailResult(reason) {
|
|
12215
|
-
return {
|
|
12216
|
-
result: false,
|
|
12217
|
-
reason: reason
|
|
12218
|
-
};
|
|
12219
|
-
};
|
|
12220
|
-
var status = e == null || (_e$response3 = e.response) == null ? void 0 : _e$response3.status;
|
|
12221
|
-
var data = e == null || (_e$response4 = e.response) == null ? void 0 : _e$response4.data;
|
|
12222
|
-
if (status === 429) {
|
|
12223
|
-
Logger.log("Returning fail - RPS limit exceeded " + data, loggerSource);
|
|
12224
|
-
return composeFailResult(SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED);
|
|
12225
|
-
}
|
|
12226
|
-
// TODO: [feature, low] add custom errors handling - waiting for response from letsexchange. task_id=00d2e435f6df4fb99af912135bd9ee27
|
|
12227
|
-
// 422 - missing params
|
|
12228
|
-
Logger.log("Internal error for swap: " + safeStringify(e), loggerSource);
|
|
12550
|
+
Logger.logError(e, loggerSource, "Failed to init swap: " + safeStringify(e));
|
|
12229
12551
|
improveAndRethrow(e, loggerSource);
|
|
12230
12552
|
}));
|
|
12231
12553
|
} catch (e) {
|
|
12232
12554
|
return Promise.reject(e);
|
|
12233
12555
|
}
|
|
12234
12556
|
};
|
|
12235
|
-
|
|
12557
|
+
SwapUtils.safeHandleRequestsLimitExceeding = function safeHandleRequestsLimitExceeding() {
|
|
12558
|
+
(function () {
|
|
12559
|
+
try {
|
|
12560
|
+
var _temp = _catch$1(function () {
|
|
12561
|
+
return Promise.resolve(EmailsApi.sendEmail("AUTOMATIC EMAIL - SWAPSPACE REQUESTS LIMIT EXCEEDED", "Requests limit exceeded. Urgently ask swaps provider support for limit increasing")).then(function () {});
|
|
12562
|
+
}, function (e) {
|
|
12563
|
+
Logger.log("Failed to handle limit exceeding " + safeStringify(e), "_safeHandleRequestsLimitExceeding");
|
|
12564
|
+
});
|
|
12565
|
+
return _temp && _temp.then ? _temp.then(function () {}) : void 0;
|
|
12566
|
+
} catch (e) {
|
|
12567
|
+
Promise.reject(e);
|
|
12568
|
+
}
|
|
12569
|
+
})();
|
|
12570
|
+
}
|
|
12571
|
+
|
|
12572
|
+
/**
|
|
12573
|
+
* If some swap is not found by id then there is no item in return list.
|
|
12574
|
+
*
|
|
12575
|
+
* @param swapProviders {SwapProvider[]} - Array of swap providers
|
|
12576
|
+
* @param swapIds {string[]} - Array of swap IDs
|
|
12577
|
+
* @return {Promise<{
|
|
12578
|
+
* result: true,
|
|
12579
|
+
* swaps: ExistingSwapWithFiatData[]
|
|
12580
|
+
* }|{
|
|
12581
|
+
* result: false,
|
|
12582
|
+
* reason: string
|
|
12583
|
+
* }>}
|
|
12584
|
+
*/;
|
|
12585
|
+
SwapUtils.getExistingSwapsDetailsWithFiatAmounts = function getExistingSwapsDetailsWithFiatAmounts(swapProviders, swapIds) {
|
|
12236
12586
|
try {
|
|
12237
|
-
var _this5 = this;
|
|
12238
|
-
var loggerSource = "getExistingSwapsDetailsAndStatus";
|
|
12239
12587
|
return Promise.resolve(_catch$1(function () {
|
|
12240
|
-
|
|
12241
|
-
|
|
12242
|
-
|
|
12243
|
-
|
|
12244
|
-
|
|
12245
|
-
|
|
12246
|
-
|
|
12247
|
-
|
|
12248
|
-
|
|
12249
|
-
|
|
12250
|
-
|
|
12251
|
-
})) == null ? void 0 : _this5$_supportedCoin.coin;
|
|
12252
|
-
var toCoin = (_this5$_supportedCoin2 = _this5._supportedCoins.find(function (i) {
|
|
12253
|
-
return i.code === swap.coin_to && i.network === swap.coin_to_network;
|
|
12254
|
-
})) == null ? void 0 : _this5$_supportedCoin2.coin;
|
|
12255
|
-
if (!fromCoin || !toCoin) {
|
|
12256
|
-
return []; // We skip swaps with not supported coins for now
|
|
12257
|
-
}
|
|
12258
|
-
var toUtcTimestamp = function toUtcTimestamp(timeStr) {
|
|
12259
|
-
return Date.parse(timeStr.match(/.+[Zz]$/) ? timeStr : timeStr + "Z");
|
|
12588
|
+
var _interrupt;
|
|
12589
|
+
function _temp8() {
|
|
12590
|
+
if (swapIds.length > 0 && allSwaps.length === 0 && failResults.length > 0) {
|
|
12591
|
+
var failReasons = failResults.map(function (r) {
|
|
12592
|
+
return r.reason;
|
|
12593
|
+
});
|
|
12594
|
+
return {
|
|
12595
|
+
result: false,
|
|
12596
|
+
reason: failReasons.find(function (r) {
|
|
12597
|
+
return r !== SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED;
|
|
12598
|
+
}) ? failReasons.join("\n") : SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED
|
|
12260
12599
|
};
|
|
12261
|
-
|
|
12262
|
-
var createdAt = swap.created_at ? toUtcTimestamp("" + swap.created_at) : null;
|
|
12263
|
-
var isExpiredByTime = expiresAt && expiresAt < Date.now();
|
|
12264
|
-
var status = _this5._mapLetsExchangeStatusToRabbitStatus(swap.status, isExpiredByTime);
|
|
12265
|
-
var toDigits = status === SwapProvider.SWAP_STATUSES.REFUNDED ? fromCoin.digits : toCoin.digits;
|
|
12266
|
-
var deposit = swap.real_deposit_amount && swap.real_deposit_amount !== "" ? swap.real_deposit_amount : swap.deposit_amount;
|
|
12267
|
-
var withdrawal = swap.real_withdrawal_amount && swap.real_withdrawal_amount !== "" ? swap.real_withdrawal_amount : swap.withdrawal_amount;
|
|
12268
|
-
var rate = bignumber_js.BigNumber(withdrawal).div(deposit).toFixed(_this5._maxRateDigits); // We don't use their rate as it excludes their fee
|
|
12269
|
-
return new ExistingSwap(swapIds[index], status, createdAt, expiresAt, swap.confirmations, rate, swap.is_float != null ? !swap.is_float : false, swap["return"], swap.deposit, fromCoin, AmountUtils.trim(deposit, fromCoin.digits), swap.hash_in, swap.hash_in ? "" + swap.coin_from_explorer_url + swap.hash_in : null, toCoin, AmountUtils.trim(withdrawal, toDigits), swap.hash_out, swap.hash_out ? "" + swap.coin_to_explorer_url + swap.hash_out : null, swap.withdrawal, "letsexchange", (_swap$deposit_extra_i = swap.deposit_extra_id) != null ? _swap$deposit_extra_i : null, (_swap$withdrawal_extr = swap.withdrawal_extra_id) != null ? _swap$withdrawal_extr : null, (_swap$return_extra_id = swap.return_extra_id) != null ? _swap$return_extra_id : null);
|
|
12270
|
-
}).flat();
|
|
12271
|
-
Logger.log("Swap details result " + safeStringify(swaps), loggerSource);
|
|
12600
|
+
}
|
|
12272
12601
|
return {
|
|
12273
12602
|
result: true,
|
|
12274
|
-
swaps:
|
|
12603
|
+
swaps: allSwaps
|
|
12275
12604
|
};
|
|
12605
|
+
}
|
|
12606
|
+
var allSwaps = [];
|
|
12607
|
+
var remainingSwapIds = new Set(swapIds);
|
|
12608
|
+
var failResults = [];
|
|
12609
|
+
var _temp7 = _forOf(swapProviders, function (provider) {
|
|
12610
|
+
return Promise.resolve(provider.getExistingSwapsDetailsAndStatus([].concat(remainingSwapIds))).then(function (result) {
|
|
12611
|
+
var _temp6 = function () {
|
|
12612
|
+
if (result.result) {
|
|
12613
|
+
var _temp5 = function _temp5() {
|
|
12614
|
+
allSwaps = allSwaps.concat(_extendedSwaps);
|
|
12615
|
+
|
|
12616
|
+
// Stop if we have retrieved all swaps
|
|
12617
|
+
if (allSwaps.length >= swapIds.length) {
|
|
12618
|
+
_interrupt = 1;
|
|
12619
|
+
}
|
|
12620
|
+
};
|
|
12621
|
+
var _extendedSwaps = [];
|
|
12622
|
+
var _temp4 = _forOf(result.swaps, function (swap) {
|
|
12623
|
+
function _temp3() {
|
|
12624
|
+
remainingSwapIds["delete"](swap.id);
|
|
12625
|
+
}
|
|
12626
|
+
var _temp2 = function () {
|
|
12627
|
+
if (swap.status === SwapProvider.SWAP_STATUSES.REFUNDED) {
|
|
12628
|
+
return Promise.resolve(provider.getCoinToUSDTRate(swap.fromCoin)).then(function (rate) {
|
|
12629
|
+
_extendedSwaps.push(ExistingSwapWithFiatData.fromExistingSwap(swap, (rate == null ? void 0 : rate.rate) != null ? bignumber_js.BigNumber(swap.fromAmount).times(rate.rate).toNumber() : null, (rate == null ? void 0 : rate.rate) != null ? bignumber_js.BigNumber(swap.toAmount).times(rate.rate).toNumber() : null, "USD", FiatCurrenciesService.getCurrencyDecimalCountByCode("USD")));
|
|
12630
|
+
});
|
|
12631
|
+
} else {
|
|
12632
|
+
return Promise.resolve(Promise.all([provider.getCoinToUSDTRate(swap.fromCoin), provider.getCoinToUSDTRate(swap.toCoin)])).then(function (_ref) {
|
|
12633
|
+
var fromCoinFiatRate = _ref[0],
|
|
12634
|
+
toCoinFiatRate = _ref[1];
|
|
12635
|
+
_extendedSwaps.push(ExistingSwapWithFiatData.fromExistingSwap(swap, (fromCoinFiatRate == null ? void 0 : fromCoinFiatRate.rate) != null ? bignumber_js.BigNumber(swap.fromAmount).times(fromCoinFiatRate.rate).toNumber() : null, (toCoinFiatRate == null ? void 0 : toCoinFiatRate.rate) != null ? bignumber_js.BigNumber(swap.toAmount).times(toCoinFiatRate.rate).toNumber() : null, "USD", FiatCurrenciesService.getCurrencyDecimalCountByCode("USD")));
|
|
12636
|
+
});
|
|
12637
|
+
}
|
|
12638
|
+
}();
|
|
12639
|
+
return _temp2 && _temp2.then ? _temp2.then(_temp3) : _temp3(_temp2);
|
|
12640
|
+
});
|
|
12641
|
+
return _temp4 && _temp4.then ? _temp4.then(_temp5) : _temp5(_temp4);
|
|
12642
|
+
} else {
|
|
12643
|
+
failResults.push(result);
|
|
12644
|
+
}
|
|
12645
|
+
}();
|
|
12646
|
+
if (_temp6 && _temp6.then) return _temp6.then(function () {});
|
|
12647
|
+
});
|
|
12648
|
+
}, function () {
|
|
12649
|
+
return _interrupt;
|
|
12276
12650
|
});
|
|
12651
|
+
return _temp7 && _temp7.then ? _temp7.then(_temp8) : _temp8(_temp7);
|
|
12277
12652
|
}, function (e) {
|
|
12278
|
-
|
|
12279
|
-
Logger.logError(e, loggerSource, "Failed to get swap details. Error is: " + safeStringify(e));
|
|
12280
|
-
var composeFailResult = function composeFailResult(reason) {
|
|
12281
|
-
return {
|
|
12282
|
-
result: false,
|
|
12283
|
-
reason: reason
|
|
12284
|
-
};
|
|
12285
|
-
};
|
|
12286
|
-
var status = e == null || (_e$response5 = e.response) == null ? void 0 : _e$response5.status;
|
|
12287
|
-
var data = e == null || (_e$response6 = e.response) == null ? void 0 : _e$response6.data;
|
|
12288
|
-
if (status === 429) {
|
|
12289
|
-
Logger.log("Returning fail - RPS limit exceeded " + data, loggerSource);
|
|
12290
|
-
return composeFailResult(SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED);
|
|
12291
|
-
}
|
|
12292
|
-
improveAndRethrow(e, loggerSource);
|
|
12653
|
+
improveAndRethrow(e, "getExistingSwapsDetailsWithFiatAmounts");
|
|
12293
12654
|
}));
|
|
12294
12655
|
} catch (e) {
|
|
12295
12656
|
return Promise.reject(e);
|
|
12296
12657
|
}
|
|
12297
12658
|
};
|
|
12298
|
-
|
|
12299
|
-
|
|
12300
|
-
* Lets exchange statuses description
|
|
12301
|
-
* wait - The exchange has just been created and it’s waiting for coins to reach the deposit wallet
|
|
12302
|
-
* confirmation - The transaction appears in mempool and now it is waiting for necessary network confirmations to start.
|
|
12303
|
-
* confirmed - The user’s payment is confirmed, the exchange process is about to start.
|
|
12304
|
-
* exchanging - The exchange process is running.
|
|
12305
|
-
* sending - Funds are being sent to the recipient`s address.
|
|
12306
|
-
* sending_confirmation - The outgoing transaction is waiting for network confirmations.
|
|
12307
|
-
* success - The exchange is completed and the funds are successfully sent to the recipient’s address.
|
|
12308
|
-
* aml_check_failed - The deposit was marked as risky by AML check service.
|
|
12309
|
-
* overdue - The deposit receiving time for this transaction has expired.
|
|
12310
|
-
* error - The transaction has failed. In most cases, the amount that was sent differs from the amount that was specified when creating the transaction.
|
|
12311
|
-
* refund - The exchange failed and the coins were refunded to the user's wallet.
|
|
12312
|
-
*/
|
|
12313
|
-
switch (status) {
|
|
12314
|
-
case "wait":
|
|
12315
|
-
if (isExpiredByTime) {
|
|
12316
|
-
return SwapProvider.SWAP_STATUSES.EXPIRED;
|
|
12317
|
-
}
|
|
12318
|
-
return SwapProvider.SWAP_STATUSES.WAITING_FOR_PAYMENT;
|
|
12319
|
-
case "confirmation":
|
|
12320
|
-
return SwapProvider.SWAP_STATUSES.CONFIRMING;
|
|
12321
|
-
case "confirmed":
|
|
12322
|
-
return SwapProvider.SWAP_STATUSES.PAYMENT_RECEIVED;
|
|
12323
|
-
case "exchanging":
|
|
12324
|
-
return SwapProvider.SWAP_STATUSES.EXCHANGING;
|
|
12325
|
-
case "sending":
|
|
12326
|
-
return SwapProvider.SWAP_STATUSES.EXCHANGING;
|
|
12327
|
-
case "sending_confirmation":
|
|
12328
|
-
return SwapProvider.SWAP_STATUSES.EXCHANGING;
|
|
12329
|
-
case "success":
|
|
12330
|
-
return SwapProvider.SWAP_STATUSES.COMPLETED;
|
|
12331
|
-
case "refund":
|
|
12332
|
-
return SwapProvider.SWAP_STATUSES.REFUNDED;
|
|
12333
|
-
case "overdue":
|
|
12334
|
-
return SwapProvider.SWAP_STATUSES.EXPIRED;
|
|
12335
|
-
case "aml_check_failed":
|
|
12336
|
-
return SwapProvider.SWAP_STATUSES.EXCHANGING;
|
|
12337
|
-
case "error":
|
|
12338
|
-
return SwapProvider.SWAP_STATUSES.FAILED;
|
|
12339
|
-
default:
|
|
12340
|
-
throw new Error("Unknown LetsExchange status: " + status);
|
|
12341
|
-
}
|
|
12342
|
-
};
|
|
12343
|
-
_proto.getPartnersList = function getPartnersList() {
|
|
12344
|
-
try {
|
|
12345
|
-
return Promise.resolve([new Partner("LetsExchange", "https://letsexchange.notion.site/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F02e45813-b375-49d8-b2b0-092ce1847fff%2F55ebbc3c-4ee6-4fa7-847b-f673e82594f3%2Flets-logo-basic__on-light.svg?table=block&id=bec5952a-2f9c-47fb-8cc0-86e1391a7f60&spaceId=02e45813-b375-49d8-b2b0-092ce1847fff&userId=&cache=v2")]);
|
|
12346
|
-
} catch (e) {
|
|
12347
|
-
return Promise.reject(e);
|
|
12348
|
-
}
|
|
12349
|
-
};
|
|
12350
|
-
return LetsExchangeSwapProvider;
|
|
12351
|
-
}(SwapProvider);
|
|
12352
|
-
LetsExchangeSwapProvider.AFFILIATE_ID = "0zbj9hf7xg7jgdgv";
|
|
12659
|
+
return SwapUtils;
|
|
12660
|
+
}();
|
|
12353
12661
|
|
|
12354
12662
|
function _catch(body, recover) {
|
|
12355
12663
|
try {
|
|
@@ -12363,13 +12671,33 @@
|
|
|
12363
12671
|
return result;
|
|
12364
12672
|
}
|
|
12365
12673
|
var PublicSwapService = /*#__PURE__*/function () {
|
|
12366
|
-
|
|
12367
|
-
|
|
12368
|
-
|
|
12369
|
-
|
|
12370
|
-
|
|
12371
|
-
|
|
12372
|
-
|
|
12674
|
+
/**
|
|
12675
|
+
* TODO: [feature, critical] implement more adequate providers list&initiation logic. task_id=6a6b0fbbee8a413690c49b1e4ee289cb
|
|
12676
|
+
*
|
|
12677
|
+
* @param apiKeysProxyUrl {string|null}
|
|
12678
|
+
* @param cache {Cache}
|
|
12679
|
+
* @param providers {SwapProvider[]|null}
|
|
12680
|
+
*/
|
|
12681
|
+
function PublicSwapService(apiKeysProxyUrl, cache, providers) {
|
|
12682
|
+
var _providers;
|
|
12683
|
+
if (providers === void 0) {
|
|
12684
|
+
providers = null;
|
|
12685
|
+
}
|
|
12686
|
+
if (apiKeysProxyUrl) {
|
|
12687
|
+
this._swapProvider = new SwapspaceSwapProvider(apiKeysProxyUrl, cache, function () {
|
|
12688
|
+
return null;
|
|
12689
|
+
}, false);
|
|
12690
|
+
this._fixedSwapProvider = new LetsExchangeSwapProvider(apiKeysProxyUrl, cache, function () {
|
|
12691
|
+
return null;
|
|
12692
|
+
}, false);
|
|
12693
|
+
} else if ((_providers = providers) != null && _providers.length) {
|
|
12694
|
+
this._swapProvider = providers.find(function (p) {
|
|
12695
|
+
return p.id === "swapspace";
|
|
12696
|
+
});
|
|
12697
|
+
this._fixedSwapProvider = providers.find(function (p) {
|
|
12698
|
+
return p.id === "letsexchange";
|
|
12699
|
+
});
|
|
12700
|
+
}
|
|
12373
12701
|
}
|
|
12374
12702
|
var _proto = PublicSwapService.prototype;
|
|
12375
12703
|
_proto.initialize = function initialize() {
|
|
@@ -12548,13 +12876,14 @@
|
|
|
12548
12876
|
/**
|
|
12549
12877
|
* Retrieves swap details that can be used to create swap.
|
|
12550
12878
|
*
|
|
12551
|
-
* @param
|
|
12552
|
-
* @param
|
|
12879
|
+
* @param fromCoinOrTicker {Coin|string}
|
|
12880
|
+
* @param toCoinOrTicker {Coin|string}
|
|
12553
12881
|
* @param amountCoins {string}
|
|
12554
12882
|
* @param [fixed=false] {boolean|null} null means fixed or float doesn't matter
|
|
12555
12883
|
* @param [withoutFiat=false] {boolean} pass true if you don't need the fiat equivalent - this will diminish requests count
|
|
12556
12884
|
* @param [amountIsToReceive=false] {boolean} whether the given amount is receiving amount.
|
|
12557
12885
|
* False means the amount is the sending amount.
|
|
12886
|
+
* @param bannedPartners {string[]} array of banned swap partners (providers) ids
|
|
12558
12887
|
* @return {Promise<{
|
|
12559
12888
|
* result: false,
|
|
12560
12889
|
* reason: string,
|
|
@@ -12569,7 +12898,7 @@
|
|
|
12569
12898
|
* }>}
|
|
12570
12899
|
*/
|
|
12571
12900
|
;
|
|
12572
|
-
_proto.getPublicSwapDetails = function getPublicSwapDetails(
|
|
12901
|
+
_proto.getPublicSwapDetails = function getPublicSwapDetails(fromCoinOrTicker, toCoinOrTicker, amountCoins, fixed, withoutFiat, amountIsToReceive, bannedPartners) {
|
|
12573
12902
|
if (fixed === void 0) {
|
|
12574
12903
|
fixed = false;
|
|
12575
12904
|
}
|
|
@@ -12579,14 +12908,18 @@
|
|
|
12579
12908
|
if (amountIsToReceive === void 0) {
|
|
12580
12909
|
amountIsToReceive = false;
|
|
12581
12910
|
}
|
|
12911
|
+
if (bannedPartners === void 0) {
|
|
12912
|
+
bannedPartners = [];
|
|
12913
|
+
}
|
|
12582
12914
|
try {
|
|
12583
12915
|
var _this7 = this;
|
|
12584
12916
|
var loggerSource = "getPublicSwapDetails";
|
|
12585
12917
|
return Promise.resolve(_catch(function () {
|
|
12586
|
-
function _temp2(
|
|
12587
|
-
var
|
|
12588
|
-
var coinUsdtRate = withoutFiat ?
|
|
12589
|
-
|
|
12918
|
+
function _temp2(_operatingPartner$get) {
|
|
12919
|
+
var _operatingPartner$get2;
|
|
12920
|
+
var coinUsdtRate = withoutFiat ? _operatingPartner$get : (_operatingPartner$get2 = _operatingPartner$get == null ? void 0 : _operatingPartner$get.rate) != null ? _operatingPartner$get2 : null;
|
|
12921
|
+
// TODO: [feature, high] implement base logic for provider selection based on the list of allowed providers - call estimation for all allowed and select the best option. task_id=6a6b0fbbee8a413690c49b1e4ee289cb
|
|
12922
|
+
return Promise.resolve(operatingPartner.getSwapInfo(fromCoin, toCoin, amountCoins, fixed, coinUsdtRate, amountIsToReceive, bannedPartners)).then(function (details) {
|
|
12590
12923
|
var _result$swapCreationI, _result$swapCreationI2;
|
|
12591
12924
|
// eslint-disable-next-line no-console
|
|
12592
12925
|
console.log("getSwapInfo result: ", details);
|
|
@@ -12651,7 +12984,27 @@
|
|
|
12651
12984
|
if (amountIsToReceive && !fixed) {
|
|
12652
12985
|
throw new Error("Estimating allowed only for fixed rate.");
|
|
12653
12986
|
}
|
|
12654
|
-
|
|
12987
|
+
var fromCoin = fromCoinOrTicker;
|
|
12988
|
+
if (typeof fromCoin === "string") {
|
|
12989
|
+
fromCoin = _this7.getCoinByTickerIfPresent(fromCoin);
|
|
12990
|
+
}
|
|
12991
|
+
var toCoin = toCoinOrTicker;
|
|
12992
|
+
if (typeof toCoin === "string") {
|
|
12993
|
+
toCoin = _this7.getCoinByTickerIfPresent(toCoin);
|
|
12994
|
+
}
|
|
12995
|
+
var operatingPartner = fixed ? _this7._fixedSwapProvider : _this7._swapProvider;
|
|
12996
|
+
var isPartnerBanned = !!bannedPartners.find(function (banned) {
|
|
12997
|
+
return banned === operatingPartner.id;
|
|
12998
|
+
});
|
|
12999
|
+
return !fromCoin || !toCoin || isPartnerBanned ? {
|
|
13000
|
+
result: false,
|
|
13001
|
+
reason: PublicSwapService.PUBLIC_SWAP_DETAILS_FAIL_REASONS.PAIR_NOT_SUPPORTED,
|
|
13002
|
+
min: null,
|
|
13003
|
+
max: null,
|
|
13004
|
+
fiatMin: null,
|
|
13005
|
+
fiatMax: null,
|
|
13006
|
+
rate: undefined
|
|
13007
|
+
} : withoutFiat ? _temp2(null) : Promise.resolve(operatingPartner.getCoinToUSDTRate(amountIsToReceive ? toCoin : fromCoin)).then(_temp2);
|
|
12655
13008
|
}, function (e) {
|
|
12656
13009
|
improveAndRethrow(e, loggerSource);
|
|
12657
13010
|
}));
|
|
@@ -13051,7 +13404,12 @@
|
|
|
13051
13404
|
} catch (e) {
|
|
13052
13405
|
improveAndRethrow(e, "getExtraIdNameIfPresentForAsset");
|
|
13053
13406
|
}
|
|
13054
|
-
}
|
|
13407
|
+
}
|
|
13408
|
+
|
|
13409
|
+
/**
|
|
13410
|
+
* Retrieves flat partners list across all supported providers (including aggregators)
|
|
13411
|
+
* @return {Promise<Partner[]>}
|
|
13412
|
+
*/;
|
|
13055
13413
|
_proto.getPartnersList = function getPartnersList() {
|
|
13056
13414
|
try {
|
|
13057
13415
|
var _temp17 = function _temp17(_result15) {
|
|
@@ -13067,10 +13425,16 @@
|
|
|
13067
13425
|
allPartners = _Promise$all;
|
|
13068
13426
|
allPartners = allPartners.flat().flat();
|
|
13069
13427
|
var _allPartners$reduce = allPartners.reduce(function (prev, cur) {
|
|
13070
|
-
|
|
13428
|
+
var alreadyAdded = prev.find(function (partner) {
|
|
13071
13429
|
return partner.name.toLowerCase() === cur.name.toLowerCase();
|
|
13072
|
-
})
|
|
13430
|
+
});
|
|
13431
|
+
if (!alreadyAdded) {
|
|
13073
13432
|
prev.push(cur);
|
|
13433
|
+
} else {
|
|
13434
|
+
var _cur$logoUrl, _cur$kycLevel;
|
|
13435
|
+
// Attempting to fill missing data if there are the same partner from different providers
|
|
13436
|
+
alreadyAdded.logoUrl = (_cur$logoUrl = cur.logoUrl) != null ? _cur$logoUrl : alreadyAdded.logoUrl;
|
|
13437
|
+
alreadyAdded.kycLevel = (_cur$kycLevel = cur.kycLevel) != null ? _cur$kycLevel : alreadyAdded.kycLevel;
|
|
13074
13438
|
}
|
|
13075
13439
|
return prev;
|
|
13076
13440
|
}, []);
|
|
@@ -13144,6 +13508,8 @@
|
|
|
13144
13508
|
exports.Input = Input;
|
|
13145
13509
|
exports.InputValuesProviders = InputValuesProviders;
|
|
13146
13510
|
exports.IpAddressProvider = IpAddressProvider;
|
|
13511
|
+
exports.KYC_LEVELS = KYC_LEVELS;
|
|
13512
|
+
exports.LetsExchangeSwapProvider = LetsExchangeSwapProvider;
|
|
13147
13513
|
exports.LineWithIconLink = LineWithIconLink;
|
|
13148
13514
|
exports.LinesOfText = LinesOfText;
|
|
13149
13515
|
exports.LinkButton = LinkButton;
|
|
@@ -13154,6 +13520,7 @@
|
|
|
13154
13520
|
exports.MetrikaAdapter = MetrikaAdapter;
|
|
13155
13521
|
exports.MixpanelAdapter = MixpanelAdapter;
|
|
13156
13522
|
exports.NoticeIcon = NoticeIcon;
|
|
13523
|
+
exports.Partner = Partner;
|
|
13157
13524
|
exports.Protocol = Protocol;
|
|
13158
13525
|
exports.PublicSwapService = PublicSwapService;
|
|
13159
13526
|
exports.QrCode = QrCode;
|
|
@@ -13163,6 +13530,7 @@
|
|
|
13163
13530
|
exports.SupportChat = SupportChat;
|
|
13164
13531
|
exports.SwapForm = SwapForm;
|
|
13165
13532
|
exports.SwapProvider = SwapProvider;
|
|
13533
|
+
exports.SwapProviderCoinInfo = SwapProviderCoinInfo;
|
|
13166
13534
|
exports.SwapUtils = SwapUtils;
|
|
13167
13535
|
exports.SwapspaceSwapProvider = SwapspaceSwapProvider;
|
|
13168
13536
|
exports.TOOLTIP_POSITIONS = TOOLTIP_POSITIONS;
|
|
@@ -13182,6 +13550,7 @@
|
|
|
13182
13550
|
exports.removeQueryParameterAndValues = removeQueryParameterAndValues;
|
|
13183
13551
|
exports.safeStringify = safeStringify;
|
|
13184
13552
|
exports.saveQueryParameterAndValues = saveQueryParameterAndValues;
|
|
13553
|
+
exports.toRabbitTicker = toRabbitTicker;
|
|
13185
13554
|
exports.useCallHandlingErrors = useCallHandlingErrors;
|
|
13186
13555
|
exports.useIsHydrated = useIsHydrated;
|
|
13187
13556
|
exports.useReferredState = useReferredState;
|