@rabbitio/ui-kit 1.0.0-beta.89 → 1.0.0-beta.90
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 +7146 -2602
- package/coverage/coverage-final.json +181 -114
- package/coverage/index.html +374 -104
- package/coverage/{rabbit-ui-kit → ui-kit}/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/index.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/adapters/analyticsAdapters/googleAnalyticsAdapter.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/adapters/analyticsAdapters/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/adapters/analyticsAdapters/metrikaAdapter.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/adapters/analyticsAdapters/mixpanelAdapter.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/adapters/axiosAdapter.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/adapters/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/adapters/qrUtils.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/external-apis/apiGroups.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/external-apis/emailAPI.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/external-apis/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/external-apis/ipAddressProviders.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/globalConstants.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/models/blockchain.js.html +6 -6
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/models/coin.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/models/index.html +20 -20
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/models/protocol.js.html +16 -16
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/services/fiatCurrenciesService.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/services/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/utils/amountUtils.js.html +23 -23
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/utils/cache.js.html +8 -8
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/utils/errorUtils.js.html +15 -15
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/utils/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/utils/logging/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/utils/logging/logger.js.html +23 -23
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/utils/logging/logsStorage.js.html +5 -5
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/utils/postponeExecution.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/utils/rabbitTicker.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/utils/safeStringify.js.html +36 -36
- package/coverage/{rabbit-ui-kit → ui-kit}/src/index.html +7 -7
- package/coverage/{rabbit-ui-kit → ui-kit}/src/index.js.html +9 -6
- package/coverage/{rabbit-ui-kit → ui-kit}/src/robust-api-caller/cacheAndConcurrentRequestsResolver.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/robust-api-caller/cachedRobustExternalApiCallerService.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/robust-api-caller/cancelProcessing.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/robust-api-caller/concurrentCalculationsMetadataHolder.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/robust-api-caller/externalApiProvider.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/robust-api-caller/externalServicesStatsCollector.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/robust-api-caller/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/robust-api-caller/robustExternalAPICallerService.js.html +3 -3
- package/coverage/ui-kit/src/swaps-lib/external-apis/exolixSwapProvider.js.html +1813 -0
- package/coverage/{rabbit-ui-kit → ui-kit}/src/swaps-lib/external-apis/index.html +41 -26
- package/coverage/{rabbit-ui-kit → ui-kit}/src/swaps-lib/external-apis/letsExchangeSwapProvider.js.html +23 -14
- package/coverage/{rabbit-ui-kit → ui-kit}/src/swaps-lib/external-apis/swapProvider.js.html +296 -392
- package/coverage/{rabbit-ui-kit → ui-kit}/src/swaps-lib/external-apis/swapspaceSwapProvider.js.html +108 -138
- package/coverage/{rabbit-ui-kit → ui-kit}/src/swaps-lib/models/baseSwapCreationInfo.js.html +21 -6
- package/coverage/ui-kit/src/swaps-lib/models/existingSwap.js.html +514 -0
- package/coverage/{rabbit-ui-kit → ui-kit}/src/swaps-lib/models/existingSwapWithFiatData.js.html +147 -87
- package/coverage/{rabbit-ui-kit → ui-kit}/src/swaps-lib/models/index.html +43 -43
- package/coverage/{rabbit-ui-kit → ui-kit}/src/swaps-lib/models/partner.js.html +6 -6
- package/coverage/ui-kit/src/swaps-lib/models/swapProviderCoinInfo.js.html +331 -0
- package/coverage/{rabbit-ui-kit → ui-kit}/src/swaps-lib/services/index.html +7 -7
- package/coverage/{rabbit-ui-kit → ui-kit}/src/swaps-lib/services/publicSwapService.js.html +76 -817
- package/coverage/{rabbit-ui-kit → ui-kit}/src/swaps-lib/utils/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/swaps-lib/utils/swapUtils.js.html +4 -4
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/assets/wrappedImages/arrowIcon.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/assets/wrappedImages/arrowTosca.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/assets/wrappedImages/arrowWhite.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/assets/wrappedImages/darkRectangle.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/assets/wrappedImages/determinedError.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/assets/wrappedImages/failedValidationIcon.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/assets/wrappedImages/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/assets/wrappedImages/infoIcon.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/assets/wrappedImages/messageIcon.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/assets/wrappedImages/noticeQuestionIcon.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/assets/wrappedImages/successfulValidationIcon.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/assets/wrappedImages/supportDialogImage.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/assets/wrappedImages/walletIcon.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/AssetIcon/AssetIcon.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/AssetIcon/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/AssetSelection/AssetSelection.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/AssetSelection/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/BackgroundTitle/BackgroundTitle.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/BackgroundTitle/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/InformationMessage/InformationMessage.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/InformationMessage/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/Input/Input.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/Input/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/LoadingDots/LoadingDots.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/LoadingDots/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/NoticeIcon/NoticeIcon.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/NoticeIcon/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/QrCode/QrCode.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/QrCode/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/RateSelector/RateSelector.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/RateSelector/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/SupportChat/SupportChat.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/SupportChat/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/Textarea/Textarea.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/Textarea/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/TitleBox/TitleBox.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/TitleBox/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/Tooltip/Tooltip.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/Tooltip/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/TwoLinesOfText/LinesOfText.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/TwoLinesOfText/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/Validation/Validation.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/Validation/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/buttons/Button/Button.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/buttons/Button/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/buttons/Close/Close.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/buttons/Close/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/buttons/LinkButton/LinkButton.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/buttons/LinkButton/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/buttons/RadioButtonWithText/RadioButtonWithText.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/buttons/RadioButtonWithText/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/molecules/AmountInput/AmountInput.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/molecules/AmountInput/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/molecules/CoinPicker/CoinPicker.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/molecules/CoinPicker/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/molecules/ColoredNotice/ColoredNotice.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/molecules/ColoredNotice/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/molecules/LineWithIconLink/LineWithIconLink.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/molecules/LineWithIconLink/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/molecules/LogoCarousel/LogoCarousel.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/molecules/LogoCarousel/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/molecules/SearchableCoinsList/SearchableCoinsList.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/molecules/SearchableCoinsList/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/molecules/TitledLineWithIconLink/TitledLineWithIconLink.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/molecules/TitledLineWithIconLink/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/organisms/CoinPickerDialogStep/CoinPickerDialogStep.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/organisms/CoinPickerDialogStep/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/organisms/Dialog/Dialog.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/organisms/Dialog/DialogButtons/DialogButtons.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/organisms/Dialog/DialogButtons/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/organisms/Dialog/DialogStep/DialogStep.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/organisms/Dialog/DialogStep/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/organisms/Dialog/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/organisms/SwapForm/SwapForm.jsx.html +13 -7
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/organisms/SwapForm/index.html +7 -7
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/organisms/WaitlistSubscription/WaitlistSubscription.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/organisms/WaitlistSubscription/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/templates/DeterminedErrorDialogStep/DeterminedErrorDialogStep.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/templates/DeterminedErrorDialogStep/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/hooks/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/hooks/useCallHandlingErrors.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/hooks/useIsHydrated.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/hooks/useReferredState.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/utils/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/utils/inputValueProviders.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/utils/textUtils.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/utils/uiUtils.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/utils/urlQueryUtils.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/BackgroundTitle.stories.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/LinesOfText.stories.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/LoadingDots.stories.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/QrCode.stories.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/RateSelector.stories.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/Validation.stories.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/buttons/Button.stories.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/buttons/Close.stories.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/buttons/LinkButton.stories.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/buttons/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/molecules/AmountInput.stories.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/molecules/CoinPicker.stories.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/molecules/ColoredNotice.stories.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/molecules/LineWithIconLink.stories.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/molecules/LogoCarousel.stories.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/molecules/TitledLineWithIconLink.stories.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/molecules/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/organisms/Dialog/Dialog.stories.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/organisms/Dialog/DialogButtons/DialogButtons.stories.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/organisms/Dialog/DialogButtons/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/organisms/Dialog/DialogStep/DialogStep.stories.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/organisms/Dialog/DialogStep/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/organisms/Dialog/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/organisms/WaitlistSubscription.stories.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/organisms/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/stubs/coins.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/stubs/exampleContent.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/stubs/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/templates/DeterminedErrorDialogStep.stories.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/templates/index.html +3 -3
- package/coverage/ui-kit/storybook-static/223.063dc770.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/230.7eace282.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/242.981bebe4.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/312.6f62bbd9.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/341.57a15f57.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/374.99dab897.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/506.c6cb656d.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/547.cc28f1fd.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/586.ec70f0e7.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/595.2e40d981.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/607.3ea32459.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/609.097df435.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/797.c87cdf19.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/889.a357fd2d.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/909.28bf3d7c.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/976.b5f1a5d4.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/996.07a638d5.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/atoms-BackgroundTitle-stories.1a5386a1.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/atoms-LinesOfText-stories.b7c8f08a.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/atoms-LoadingDots-stories.5180c2f1.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/atoms-QrCode-stories.006bd0cc.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/atoms-RateSelector-stories.19c65c98.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/atoms-Validation-stories.d561b311.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/atoms-buttons-Button-stories.e8e6b930.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/atoms-buttons-Close-stories.0a902a7c.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/atoms-buttons-LinkButton-stories.10813be5.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/index.html +656 -0
- package/coverage/ui-kit/storybook-static/main.54ca9836.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/molecules-ColoredNotice-stories.7a5d624e.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/molecules-LineWithIconLink-stories.b7f70ee2.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/molecules-LogoCarousel-stories.9be2ef69.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/molecules-TitledLineWithIconLink-stories.1383fe3f.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/organisms-Dialog-Dialog-stories.4e6da717.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/organisms-Dialog-DialogButtons-DialogButtons-stories.1d1f9803.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/organisms-Dialog-DialogStep-DialogStep-stories.74896048.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/organisms-WaitlistSubscription-stories.a7c49a29.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/rabbitio/ui-kit/dist/global.css.html +118 -0
- package/coverage/ui-kit/storybook-static/rabbitio/ui-kit/dist/index.html +116 -0
- package/coverage/ui-kit/storybook-static/rabbitio/ui-kit/node_modules/@storybook/addon-backgrounds/dist/index.html +116 -0
- package/coverage/ui-kit/storybook-static/rabbitio/ui-kit/node_modules/@storybook/addon-backgrounds/dist/preview.js.html +118 -0
- package/coverage/ui-kit/storybook-static/rabbitio/ui-kit/node_modules/@storybook/components/dist/formatter-SWP5E3XI.mjs.html +118 -0
- package/coverage/ui-kit/storybook-static/rabbitio/ui-kit/node_modules/@storybook/components/dist/index.html +116 -0
- package/coverage/ui-kit/storybook-static/rabbitio/ui-kit/node_modules/buffer/index.html +116 -0
- package/coverage/ui-kit/storybook-static/rabbitio/ui-kit/node_modules/buffer/index.js.html +118 -0
- package/coverage/ui-kit/storybook-static/rabbitio/ui-kit/node_modules/markdown-to-jsx/dist/index.html +116 -0
- package/coverage/ui-kit/storybook-static/rabbitio/ui-kit/node_modules/markdown-to-jsx/dist/index.modern.js.html +118 -0
- package/coverage/ui-kit/storybook-static/runtime~main.bf0b2dcd.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/sb-addons/actions-9/index.html +116 -0
- package/coverage/ui-kit/storybook-static/sb-addons/actions-9/manager-bundle.js.html +94 -0
- package/coverage/ui-kit/storybook-static/sb-addons/essentials-backgrounds-2/index.html +116 -0
- package/coverage/ui-kit/storybook-static/sb-addons/essentials-backgrounds-2/manager-bundle.js.html +121 -0
- package/coverage/ui-kit/storybook-static/sb-addons/essentials-controls-1/index.html +116 -0
- package/coverage/ui-kit/storybook-static/sb-addons/essentials-controls-1/manager-bundle.js.html +274 -0
- package/coverage/ui-kit/storybook-static/sb-addons/essentials-measure-4/index.html +116 -0
- package/coverage/ui-kit/storybook-static/sb-addons/essentials-measure-4/manager-bundle.js.html +94 -0
- package/coverage/ui-kit/storybook-static/sb-addons/essentials-outline-5/index.html +116 -0
- package/coverage/ui-kit/storybook-static/sb-addons/essentials-outline-5/manager-bundle.js.html +94 -0
- package/coverage/ui-kit/storybook-static/sb-addons/essentials-toolbars-3/index.html +116 -0
- package/coverage/ui-kit/storybook-static/sb-addons/essentials-toolbars-3/manager-bundle.js.html +94 -0
- package/coverage/ui-kit/storybook-static/sb-addons/interactions-7/index.html +116 -0
- package/coverage/ui-kit/storybook-static/sb-addons/interactions-7/manager-bundle.js.html +121 -0
- package/coverage/ui-kit/storybook-static/sb-addons/links-0/index.html +116 -0
- package/coverage/ui-kit/storybook-static/sb-addons/links-0/manager-bundle.js.html +94 -0
- package/coverage/ui-kit/storybook-static/sb-addons/onboarding-6/index.html +116 -0
- package/coverage/ui-kit/storybook-static/sb-addons/onboarding-6/manager-bundle.js.html +1588 -0
- package/coverage/ui-kit/storybook-static/sb-addons/viewport-8/index.html +116 -0
- package/coverage/ui-kit/storybook-static/sb-addons/viewport-8/manager-bundle.js.html +94 -0
- package/coverage/ui-kit/storybook-static/sb-manager/WithTooltip-V3YHNWJZ-LVYLGZW2.js.html +88 -0
- package/coverage/ui-kit/storybook-static/sb-manager/chunk-2IXBUOFS.js.html +106 -0
- package/coverage/ui-kit/storybook-static/sb-manager/chunk-INSKDKQB.js.html +1129 -0
- package/coverage/ui-kit/storybook-static/sb-manager/chunk-NGTUFCUO.js.html +112 -0
- package/coverage/ui-kit/storybook-static/sb-manager/chunk-UUEAOBSN.js.html +1303 -0
- package/coverage/ui-kit/storybook-static/sb-manager/chunk-ZEU7PDD3.js.html +88 -0
- package/coverage/ui-kit/storybook-static/sb-manager/formatter-SWP5E3XI-7BGIK6BL.js.html +553 -0
- package/coverage/ui-kit/storybook-static/sb-manager/globals-module-info.js.html +88 -0
- package/coverage/ui-kit/storybook-static/sb-manager/globals.js.html +88 -0
- package/coverage/ui-kit/storybook-static/sb-manager/index.html +281 -0
- package/coverage/ui-kit/storybook-static/sb-manager/index.js.html +88 -0
- package/coverage/ui-kit/storybook-static/sb-manager/runtime.js.html +88 -0
- package/coverage/ui-kit/storybook-static/sb-manager/syntaxhighlighter-V7JZZA35-DXZCI2WR.js.html +88 -0
- package/coverage/ui-kit/storybook-static/sb-preview/globals.js.html +88 -0
- package/coverage/ui-kit/storybook-static/sb-preview/index.html +131 -0
- package/coverage/ui-kit/storybook-static/sb-preview/runtime.js.html +421 -0
- package/coverage/ui-kit/storybook-static/templates-DeterminedErrorDialogStep-stories.3cc14214.iframe.bundle.js.html +85 -0
- package/dist/index.cjs +1248 -904
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +577 -404
- package/dist/index.modern.js.map +1 -1
- package/dist/index.module.js +1172 -830
- package/dist/index.module.js.map +1 -1
- package/dist/index.umd.js +1249 -905
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/index.js +1 -0
- package/src/swaps-lib/external-apis/exolixSwapProvider.js +576 -0
- package/src/swaps-lib/external-apis/letsExchangeSwapProvider.js +11 -8
- package/src/swaps-lib/external-apis/swapProvider.js +16 -48
- package/src/swaps-lib/external-apis/swapspaceSwapProvider.js +15 -25
- package/src/swaps-lib/models/baseSwapCreationInfo.js +5 -0
- package/src/swaps-lib/models/existingSwap.js +92 -22
- package/src/swaps-lib/models/existingSwapWithFiatData.js +52 -32
- package/src/swaps-lib/models/swapProviderCoinInfo.js +6 -6
- package/src/swaps-lib/services/publicSwapService.js +70 -317
- package/src/swaps-lib/test/external-apis/exolixSwapProvider/_fetchSupportedCurrenciesIfNeeded.test.js +34 -0
- package/src/swaps-lib/test/external-apis/exolixSwapProvider/createSwap.test.js +1043 -0
- package/src/swaps-lib/test/external-apis/exolixSwapProvider/getSwapInfo.test.js +611 -0
- package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/createSwap.test.js +57 -92
- package/src/swaps-lib/utils/swapUtils.js +1 -1
- package/src/ui-kit/components/organisms/SwapForm/SwapForm.jsx +3 -1
- package/coverage/rabbit-ui-kit/src/swaps-lib/models/existingSwap.js.html +0 -304
- package/coverage/rabbit-ui-kit/src/swaps-lib/models/swapProviderCoinInfo.js.html +0 -331
package/dist/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('react-transition-group'), require('react-animate-height'), require('resize-observer-polyfill'), require('body-scroll-lock'), require('animated-scroll-to'), require('clipboard-copy'), require('bignumber.js'), require('react-textarea-autosize'), require('qrcode'), require('axios'), require('eventbusjs'), require('jshashes'), require('uuid')) :
|
|
3
3
|
typeof define === 'function' && define.amd ? define(['exports', 'react', 'react-transition-group', 'react-animate-height', 'resize-observer-polyfill', 'body-scroll-lock', 'animated-scroll-to', 'clipboard-copy', 'bignumber.js', 'react-textarea-autosize', 'qrcode', 'axios', 'eventbusjs', 'jshashes', 'uuid'], factory) :
|
|
4
|
-
(global = global || self, factory(global.uiKit = {}, global.react, global.reactTransitionGroup, global.reactAnimateHeight, global.resizeObserverPolyfill, global.bodyScrollLock, global.animatedScrollTo, global.clipboardCopy, global.
|
|
5
|
-
})(this, (function (exports, React, reactTransitionGroup, AnimateHeight, ResizeObserver$1, bodyScrollLock, animateScrollTo, copy,
|
|
4
|
+
(global = global || self, factory(global.uiKit = {}, global.react, global.reactTransitionGroup, global.reactAnimateHeight, global.resizeObserverPolyfill, global.bodyScrollLock, global.animatedScrollTo, global.clipboardCopy, global.BigNumber, global.reactTextareaAutosize, global.qrcode, global.axios, global.eventbusjs, global.jshashes, global.uuid));
|
|
5
|
+
})(this, (function (exports, React, reactTransitionGroup, AnimateHeight, ResizeObserver$1, bodyScrollLock, animateScrollTo, copy, BigNumber, TextareaAutosize, QRCode, axios, EventBusInstance, Hashes, uuid) {
|
|
6
6
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
7
7
|
|
|
8
8
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
var ResizeObserver__default = /*#__PURE__*/_interopDefaultLegacy(ResizeObserver$1);
|
|
11
11
|
var animateScrollTo__default = /*#__PURE__*/_interopDefaultLegacy(animateScrollTo);
|
|
12
12
|
var copy__default = /*#__PURE__*/_interopDefaultLegacy(copy);
|
|
13
|
+
var BigNumber__default = /*#__PURE__*/_interopDefaultLegacy(BigNumber);
|
|
13
14
|
var TextareaAutosize__default = /*#__PURE__*/_interopDefaultLegacy(TextareaAutosize);
|
|
14
15
|
var QRCode__default = /*#__PURE__*/_interopDefaultLegacy(QRCode);
|
|
15
16
|
var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
|
|
@@ -29,12 +30,12 @@
|
|
|
29
30
|
* This source code is licensed under the MIT license found in the
|
|
30
31
|
* LICENSE file in the root directory of this source tree.
|
|
31
32
|
*/
|
|
32
|
-
var b="function"===typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.async_mode"):60111,m=b?Symbol.for("react.concurrent_mode"):60111,n=b?Symbol.for("react.forward_ref"):60112,p=b?Symbol.for("react.suspense"):60113,q=b?
|
|
33
|
+
var b="function"===typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e$1=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.async_mode"):60111,m=b?Symbol.for("react.concurrent_mode"):60111,n=b?Symbol.for("react.forward_ref"):60112,p=b?Symbol.for("react.suspense"):60113,q=b?
|
|
33
34
|
Symbol.for("react.suspense_list"):60120,r=b?Symbol.for("react.memo"):60115,t=b?Symbol.for("react.lazy"):60116,v=b?Symbol.for("react.block"):60121,w=b?Symbol.for("react.fundamental"):60117,x=b?Symbol.for("react.responder"):60118,y=b?Symbol.for("react.scope"):60119;
|
|
34
|
-
function z(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c:switch(a=a.type,a){case l:case m:case e:case g:case f:case p:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case t:case r:case h:return a;default:return u}}case d:return u}}}function A(a){return z(a)===m}var AsyncMode=l;var ConcurrentMode=m;var ContextConsumer=k;var ContextProvider=h;var Element=c;var ForwardRef=n;var Fragment=e;var Lazy=t;var Memo=r;var Portal=d;
|
|
35
|
-
var Profiler=g;var StrictMode=f;var Suspense=p;var isAsyncMode=function(a){return A(a)||z(a)===l};var isConcurrentMode=A;var isContextConsumer=function(a){return z(a)===k};var isContextProvider=function(a){return z(a)===h};var isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===c};var isForwardRef=function(a){return z(a)===n};var isFragment=function(a){return z(a)===e};var isLazy=function(a){return z(a)===t};
|
|
35
|
+
function z(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c:switch(a=a.type,a){case l:case m:case e$1:case g:case f:case p:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case t:case r:case h:return a;default:return u}}case d:return u}}}function A(a){return z(a)===m}var AsyncMode=l;var ConcurrentMode=m;var ContextConsumer=k;var ContextProvider=h;var Element=c;var ForwardRef=n;var Fragment=e$1;var Lazy=t;var Memo=r;var Portal=d;
|
|
36
|
+
var Profiler=g;var StrictMode=f;var Suspense=p;var isAsyncMode=function(a){return A(a)||z(a)===l};var isConcurrentMode=A;var isContextConsumer=function(a){return z(a)===k};var isContextProvider=function(a){return z(a)===h};var isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===c};var isForwardRef=function(a){return z(a)===n};var isFragment=function(a){return z(a)===e$1};var isLazy=function(a){return z(a)===t};
|
|
36
37
|
var isMemo=function(a){return z(a)===r};var isPortal=function(a){return z(a)===d};var isProfiler=function(a){return z(a)===g};var isStrictMode=function(a){return z(a)===f};var isSuspense=function(a){return z(a)===p};
|
|
37
|
-
var isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===e||a===m||a===g||a===f||a===p||a===q||"object"===typeof a&&null!==a&&(a.$$typeof===t||a.$$typeof===r||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n||a.$$typeof===w||a.$$typeof===x||a.$$typeof===y||a.$$typeof===v)};var typeOf=z;
|
|
38
|
+
var isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===e$1||a===m||a===g||a===f||a===p||a===q||"object"===typeof a&&null!==a&&(a.$$typeof===t||a.$$typeof===r||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n||a.$$typeof===w||a.$$typeof===x||a.$$typeof===y||a.$$typeof===v)};var typeOf=z;
|
|
38
39
|
|
|
39
40
|
var reactIs_production_min = {
|
|
40
41
|
AsyncMode: AsyncMode,
|
|
@@ -1649,7 +1650,7 @@
|
|
|
1649
1650
|
return Logger;
|
|
1650
1651
|
}();
|
|
1651
1652
|
|
|
1652
|
-
function _catch$
|
|
1653
|
+
function _catch$h(body, recover) {
|
|
1653
1654
|
try {
|
|
1654
1655
|
var result = body();
|
|
1655
1656
|
} catch (e) {
|
|
@@ -1665,7 +1666,7 @@
|
|
|
1665
1666
|
setState = _useState[1];
|
|
1666
1667
|
return React.useCallback(function (functionToBeCalled, event) {
|
|
1667
1668
|
try {
|
|
1668
|
-
var _temp = _catch$
|
|
1669
|
+
var _temp = _catch$h(function () {
|
|
1669
1670
|
return Promise.resolve(functionToBeCalled(event)).then(function () {});
|
|
1670
1671
|
}, function (error) {
|
|
1671
1672
|
Logger.logError(error, (functionToBeCalled == null ? void 0 : functionToBeCalled.name) || "errorBoundaryTrigger", "Caught by ErrorBoundary");
|
|
@@ -3655,7 +3656,7 @@
|
|
|
3655
3656
|
}
|
|
3656
3657
|
if (maxValue != null) {
|
|
3657
3658
|
var _parts$;
|
|
3658
|
-
var maxDigitsCountBeforeTheDot =
|
|
3659
|
+
var maxDigitsCountBeforeTheDot = BigNumber.BigNumber(maxValue).toFixed(0).length;
|
|
3659
3660
|
if (((_parts$ = parts[0]) == null ? void 0 : _parts$.length) > maxDigitsCountBeforeTheDot) {
|
|
3660
3661
|
// removes redundant prefix digits
|
|
3661
3662
|
parts[0] = parts[0].substring(parts[0].length - maxDigitsCountBeforeTheDot, parts[0].length);
|
|
@@ -3751,13 +3752,13 @@
|
|
|
3751
3752
|
if (this._checkIfAmountInvalid(amount, true) || typeof currencyCode !== "string") return "NULL";
|
|
3752
3753
|
var currencySymbol = FiatCurrenciesService.getCurrencySymbolByCode(currencyCode);
|
|
3753
3754
|
var currencyDecimalCount = FiatCurrenciesService.getCurrencyDecimalCountByCode(currencyCode);
|
|
3754
|
-
var trimmedByMaxDigits =
|
|
3755
|
-
var processedAmount =
|
|
3756
|
-
if (params.collapsible && processedAmount.gte(
|
|
3755
|
+
var trimmedByMaxDigits = BigNumber.BigNumber(amount).toFixed(currencyDecimalCount, BigNumber.BigNumber.ROUND_FLOOR);
|
|
3756
|
+
var processedAmount = BigNumber.BigNumber(trimmedByMaxDigits);
|
|
3757
|
+
if (params.collapsible && processedAmount.gte(BigNumber.BigNumber("1000000"))) {
|
|
3757
3758
|
processedAmount = this._collapseToMillionsAndFormat(processedAmount, this.collapsedDecimalCount, params);
|
|
3758
3759
|
} else {
|
|
3759
3760
|
var limitResult = this._limitTotalAmountLengthIfNeeded(trimmedByMaxDigits, params);
|
|
3760
|
-
processedAmount =
|
|
3761
|
+
processedAmount = BigNumber.BigNumber(limitResult.processedAmount).toFormat(); // Adds commas to integer part
|
|
3761
3762
|
}
|
|
3762
3763
|
|
|
3763
3764
|
// Add the currency code or currency symbol, if symbol is enabled and available
|
|
@@ -3826,10 +3827,10 @@
|
|
|
3826
3827
|
var params = _extends({}, this.defaultCryptoParams, passedParams);
|
|
3827
3828
|
if (this._checkIfAmountInvalid(amount) || typeof ticker !== "string" && params.ticker) return "NULL";
|
|
3828
3829
|
var addPeriods = false;
|
|
3829
|
-
var amountBigNumber =
|
|
3830
|
-
var processedAmount = amountBigNumber.toFixed(digits,
|
|
3830
|
+
var amountBigNumber = BigNumber.BigNumber(amount);
|
|
3831
|
+
var processedAmount = amountBigNumber.toFixed(digits, BigNumber.BigNumber.ROUND_FLOOR);
|
|
3831
3832
|
processedAmount = this.removeRedundantRightZerosFromNumberString(processedAmount);
|
|
3832
|
-
var originalAmountDecimalPlaces =
|
|
3833
|
+
var originalAmountDecimalPlaces = BigNumber.BigNumber(processedAmount).decimalPlaces();
|
|
3833
3834
|
// Check decimal count and throw an error, if the amount has more decimal digits than supported by the asset
|
|
3834
3835
|
if (originalAmountDecimalPlaces > digits) {
|
|
3835
3836
|
var errorMessage = "An attempt to render a crypto value with too many digits after period was made: " + amount + ", allowed digits: " + digits + ". This is a no-op, since the logical and visually rendered values would differ, which is not acceptable for crypto amounts. Please trim the amount before rendering, using the trimCryptoAmountByCoin(amount, coin) method.";
|
|
@@ -3840,7 +3841,7 @@
|
|
|
3840
3841
|
|
|
3841
3842
|
// Shortening the value to general significant number of digits after period
|
|
3842
3843
|
if (params.trim) {
|
|
3843
|
-
processedAmount = this.removeRedundantRightZerosFromNumberString(amountBigNumber.toFixed(this.significantDecimalCount,
|
|
3844
|
+
processedAmount = this.removeRedundantRightZerosFromNumberString(amountBigNumber.toFixed(this.significantDecimalCount, BigNumber.BigNumber.ROUND_FLOOR));
|
|
3844
3845
|
addPeriods = originalAmountDecimalPlaces > this.significantDecimalCount;
|
|
3845
3846
|
}
|
|
3846
3847
|
var limitResult = this._limitTotalAmountLengthIfNeeded(processedAmount, params);
|
|
@@ -3849,11 +3850,11 @@
|
|
|
3849
3850
|
var wereMillionsCollapsed = false;
|
|
3850
3851
|
if (params.collapsible && amountBigNumber.gte("1000000")) {
|
|
3851
3852
|
// Collapse the 1M+ amounts if applicable
|
|
3852
|
-
processedAmount = this._collapseToMillionsAndFormat(
|
|
3853
|
+
processedAmount = this._collapseToMillionsAndFormat(BigNumber.BigNumber(processedAmount), this.collapsedDecimalCount, params);
|
|
3853
3854
|
wereMillionsCollapsed = true;
|
|
3854
3855
|
} else if (params.numberPartsSeparator) {
|
|
3855
3856
|
// Add separators to integer part of the amount
|
|
3856
|
-
processedAmount =
|
|
3857
|
+
processedAmount = BigNumber.BigNumber(processedAmount).toFormat();
|
|
3857
3858
|
}
|
|
3858
3859
|
|
|
3859
3860
|
// Adding periods, if the amount was shortened
|
|
@@ -3874,7 +3875,7 @@
|
|
|
3874
3875
|
if (allowNumbers === void 0) {
|
|
3875
3876
|
allowNumbers = false;
|
|
3876
3877
|
}
|
|
3877
|
-
return amount == null || amount === "" || !
|
|
3878
|
+
return amount == null || amount === "" || !BigNumber.BigNumber.isBigNumber(amount) && typeof amount !== "string" && (!allowNumbers || typeof amount !== "number");
|
|
3878
3879
|
}
|
|
3879
3880
|
|
|
3880
3881
|
/**
|
|
@@ -3890,7 +3891,7 @@
|
|
|
3890
3891
|
AmountUtils.trim = function trim(amount, digits) {
|
|
3891
3892
|
try {
|
|
3892
3893
|
if (this._checkIfAmountInvalid(amount, true)) return null;
|
|
3893
|
-
return
|
|
3894
|
+
return BigNumber.BigNumber(amount).toFixed(digits, BigNumber.BigNumber.ROUND_FLOOR);
|
|
3894
3895
|
} catch (e) {
|
|
3895
3896
|
improveAndRethrow(e, "trim", "Passed: " + amount + ", " + digits);
|
|
3896
3897
|
}
|
|
@@ -3921,10 +3922,10 @@
|
|
|
3921
3922
|
}
|
|
3922
3923
|
try {
|
|
3923
3924
|
// TODO: [feature, moderate] use local format here - take from JS locales (comma/dot etc.)
|
|
3924
|
-
var millionBigNumber =
|
|
3925
|
-
var millions = amountBigNumber.div(millionBigNumber).toFixed(decimalCount,
|
|
3925
|
+
var millionBigNumber = BigNumber.BigNumber("1000000");
|
|
3926
|
+
var millions = amountBigNumber.div(millionBigNumber).toFixed(decimalCount, BigNumber.BigNumber.ROUND_FLOOR);
|
|
3926
3927
|
var limitedResult = this._limitTotalAmountLengthIfNeeded(millions, params);
|
|
3927
|
-
var formatted =
|
|
3928
|
+
var formatted = BigNumber.BigNumber(limitedResult.processedAmount).toFormat();
|
|
3928
3929
|
return formatted + "M";
|
|
3929
3930
|
} catch (e) {
|
|
3930
3931
|
improveAndRethrow(e, "_collapseAmountAndFormat", "Passed: " + amountBigNumber.toFixed() + ", " + decimalCount);
|
|
@@ -3943,9 +3944,9 @@
|
|
|
3943
3944
|
var maxLength = params.extraSmallLength ? this.extraSmallMaxTotalLength : this.maxTotalLength;
|
|
3944
3945
|
if (amountString.length > maxLength) {
|
|
3945
3946
|
var delta = amountString.length - maxLength;
|
|
3946
|
-
var currentDecimalsCount =
|
|
3947
|
+
var currentDecimalsCount = BigNumber.BigNumber(amountString).decimalPlaces();
|
|
3947
3948
|
var newDecimalCount = currentDecimalsCount - delta;
|
|
3948
|
-
amountString =
|
|
3949
|
+
amountString = BigNumber.BigNumber(amountString).toFixed(newDecimalCount > 2 ? newDecimalCount : 2, BigNumber.BigNumber.ROUND_FLOOR);
|
|
3949
3950
|
addPeriods = currentDecimalsCount > newDecimalCount;
|
|
3950
3951
|
}
|
|
3951
3952
|
}
|
|
@@ -3982,18 +3983,18 @@
|
|
|
3982
3983
|
if (rightCurrencyDigitsAfterDots < 0) {
|
|
3983
3984
|
rightCurrencyDigitsAfterDots = this.significantDecimalCount;
|
|
3984
3985
|
}
|
|
3985
|
-
var leftNumber =
|
|
3986
|
-
var multiplier =
|
|
3986
|
+
var leftNumber = BigNumber.BigNumber("1");
|
|
3987
|
+
var multiplier = BigNumber.BigNumber("100");
|
|
3987
3988
|
var maxAttemptsToGetRate = 10;
|
|
3988
3989
|
var right = null;
|
|
3989
|
-
var rateBigNumber =
|
|
3990
|
-
if (
|
|
3991
|
-
right =
|
|
3992
|
-
} else if (rate && (
|
|
3990
|
+
var rateBigNumber = BigNumber.BigNumber(rate);
|
|
3991
|
+
if (BigNumber.BigNumber(rate).eq("0")) {
|
|
3992
|
+
right = BigNumber.BigNumber("0");
|
|
3993
|
+
} else if (rate && (BigNumber.BigNumber.isBigNumber(rate) || !Number.isNaN(+rate))) {
|
|
3993
3994
|
for (var i = 0; i < maxAttemptsToGetRate; ++i) {
|
|
3994
|
-
var rightNumberAttempt = rateBigNumber.times(leftNumber).toFixed(rightCurrencyDigitsAfterDots,
|
|
3995
|
-
if (!
|
|
3996
|
-
right =
|
|
3995
|
+
var rightNumberAttempt = rateBigNumber.times(leftNumber).toFixed(rightCurrencyDigitsAfterDots, BigNumber.BigNumber.ROUND_FLOOR);
|
|
3996
|
+
if (!BigNumber.BigNumber(rightNumberAttempt).eq(BigNumber.BigNumber("0"))) {
|
|
3997
|
+
right = BigNumber.BigNumber(rightNumberAttempt);
|
|
3997
3998
|
break;
|
|
3998
3999
|
} else {
|
|
3999
4000
|
leftNumber = leftNumber.times(multiplier);
|
|
@@ -4001,7 +4002,7 @@
|
|
|
4001
4002
|
}
|
|
4002
4003
|
}
|
|
4003
4004
|
var leftAmountString = AmountUtils.toIntegerString(leftNumber);
|
|
4004
|
-
var rightAmountString = right != null ? right.toFixed(rightCurrencyDigitsAfterDots,
|
|
4005
|
+
var rightAmountString = right != null ? right.toFixed(rightCurrencyDigitsAfterDots, BigNumber.BigNumber.ROUND_FLOOR) : null;
|
|
4005
4006
|
return leftAmountString + " " + leftTicker + " " + (strictRate ? "=" : "~") + " " + (rightAmountString != null ? rightAmountString : "?") + " " + rightTicker;
|
|
4006
4007
|
} catch (e) {
|
|
4007
4008
|
// eslint-disable-next-line no-console
|
|
@@ -4216,7 +4217,7 @@
|
|
|
4216
4217
|
setCoinAmountValue(correctedAmount);
|
|
4217
4218
|
if (handlerEnabled) handleCoinAmountChange(correctedAmount);
|
|
4218
4219
|
if (correctedAmount !== "" && cryptoAssetToFiatRate != null) {
|
|
4219
|
-
var fiatAmount =
|
|
4220
|
+
var fiatAmount = BigNumber.BigNumber(correctedAmount).times(cryptoAssetToFiatRate).toFixed(fiatCurrencyDecimals);
|
|
4220
4221
|
setFiatAmountValue(fiatAmount);
|
|
4221
4222
|
handleFiatAmountChange(fiatAmount);
|
|
4222
4223
|
} else {
|
|
@@ -4239,8 +4240,8 @@
|
|
|
4239
4240
|
var correctedFiatAmount = InputValuesProviders.provideFormatOfFloatValueByInputString(newAmountString, fiatCurrencyDecimals);
|
|
4240
4241
|
setFiatAmountValue(correctedFiatAmount);
|
|
4241
4242
|
handleFiatAmountChange(correctedFiatAmount);
|
|
4242
|
-
var coinAmount = correctedFiatAmount !== "" ?
|
|
4243
|
-
var coinsAmount =
|
|
4243
|
+
var coinAmount = correctedFiatAmount !== "" ? BigNumber.BigNumber(correctedFiatAmount).div(cryptoAssetToFiatRate).toFixed(assetDecimalPlaces) : "0";
|
|
4244
|
+
var coinsAmount = BigNumber.BigNumber(coinAmount).isZero() ? "" : coinAmount;
|
|
4244
4245
|
setCoinAmountValue(coinsAmount);
|
|
4245
4246
|
handleCoinAmountChange(coinsAmount);
|
|
4246
4247
|
} catch (e) {
|
|
@@ -4281,7 +4282,7 @@
|
|
|
4281
4282
|
// Check if input & balance highlights are needed after a change in either the asset amount or the balance
|
|
4282
4283
|
React.useEffect(function () {
|
|
4283
4284
|
if (!showBalanceValidation || (assetBalance == null ? void 0 : assetBalance.assetAmount) == null) return;
|
|
4284
|
-
var enableHighlight =
|
|
4285
|
+
var enableHighlight = BigNumber.BigNumber(coinAmountValue).gt(assetBalance == null ? void 0 : assetBalance.assetAmount);
|
|
4285
4286
|
handleBalanceValidationChange(enableHighlight);
|
|
4286
4287
|
setHighlightBalance(enableHighlight);
|
|
4287
4288
|
setHighlightInput(enableHighlight);
|
|
@@ -4848,7 +4849,7 @@
|
|
|
4848
4849
|
* @constructor
|
|
4849
4850
|
*/
|
|
4850
4851
|
|
|
4851
|
-
function _catch$
|
|
4852
|
+
function _catch$g(body, recover) {
|
|
4852
4853
|
try {
|
|
4853
4854
|
var result = body();
|
|
4854
4855
|
} catch (e) {
|
|
@@ -5113,7 +5114,7 @@
|
|
|
5113
5114
|
setIsLastEditedReceiving(false);
|
|
5114
5115
|
var receiveAmount = "";
|
|
5115
5116
|
if (amount != null && amount !== "" && swapRate != null) {
|
|
5116
|
-
receiveAmount = AmountUtils.trim(
|
|
5117
|
+
receiveAmount = AmountUtils.trim(BigNumber.BigNumber(amount).times(swapRate), receivingAssetDecimalCount);
|
|
5117
5118
|
}
|
|
5118
5119
|
setReceiveAssetAmount(receiveAmount);
|
|
5119
5120
|
setUpdateReceiveInputTo(receiveAmount);
|
|
@@ -5124,7 +5125,7 @@
|
|
|
5124
5125
|
if (isFixedRate.current) setIsLastEditedReceiving(true);
|
|
5125
5126
|
var sendAssetAmount = "";
|
|
5126
5127
|
if (amount != null && amount !== "" && swapRate != null) {
|
|
5127
|
-
sendAssetAmount = AmountUtils.trim(
|
|
5128
|
+
sendAssetAmount = AmountUtils.trim(BigNumber.BigNumber(amount).div(swapRate), sendingAssetDecimalCount);
|
|
5128
5129
|
}
|
|
5129
5130
|
setUpdateSendInputTo(sendAssetAmount);
|
|
5130
5131
|
setSendAssetAmount(sendAssetAmount);
|
|
@@ -5169,8 +5170,8 @@
|
|
|
5169
5170
|
var processMinMaxAmounts = function processMinMaxAmounts(amount) {
|
|
5170
5171
|
var _minimalAmount$curren5;
|
|
5171
5172
|
if (amount === null) return;
|
|
5172
|
-
setMaximumAmountValid(!maximumAmount.current ||
|
|
5173
|
-
setMinimalAmountValid(!minimalAmount.current ||
|
|
5173
|
+
setMaximumAmountValid(!maximumAmount.current || BigNumber.BigNumber(amount).eq("0") || BigNumber.BigNumber(amount).lte(maximumAmount.current.crypto));
|
|
5174
|
+
setMinimalAmountValid(!minimalAmount.current || BigNumber.BigNumber(amount).eq("0") || BigNumber.BigNumber(amount).gte((_minimalAmount$curren5 = minimalAmount.current) == null ? void 0 : _minimalAmount$curren5.crypto));
|
|
5174
5175
|
};
|
|
5175
5176
|
var requestDataRefresh = function requestDataRefresh(amount, immediately, isSwapAll, ignoreEmptyAmount) {
|
|
5176
5177
|
if (immediately === void 0) {
|
|
@@ -5191,7 +5192,7 @@
|
|
|
5191
5192
|
if (!amount && !ignoreEmptyAmount) {
|
|
5192
5193
|
return;
|
|
5193
5194
|
}
|
|
5194
|
-
if (
|
|
5195
|
+
if (BigNumber.BigNumber(amount).eq("0") || amount == null || amount === "") {
|
|
5195
5196
|
if (immediately) {
|
|
5196
5197
|
loadMinimalAmountAndSwapRate(true);
|
|
5197
5198
|
} else {
|
|
@@ -5247,7 +5248,7 @@
|
|
|
5247
5248
|
}
|
|
5248
5249
|
(function () {
|
|
5249
5250
|
try {
|
|
5250
|
-
return _catch$
|
|
5251
|
+
return _catch$g(function () {
|
|
5251
5252
|
var _minimalAmount$curren6, _maximumAmount$curren5, _isFixedRate$current;
|
|
5252
5253
|
var dataMemento = {
|
|
5253
5254
|
rate: swapRate,
|
|
@@ -5283,7 +5284,7 @@
|
|
|
5283
5284
|
if (response.result) {
|
|
5284
5285
|
var swapCreationInfo = response == null ? void 0 : response.swapCreationInfo;
|
|
5285
5286
|
if (isSwapAll.current) {
|
|
5286
|
-
setIsAmountZero(
|
|
5287
|
+
setIsAmountZero(BigNumber.BigNumber("0").eq(swapCreationInfo.fromAmountCoins));
|
|
5287
5288
|
}
|
|
5288
5289
|
setUpdateSendInputTo(swapCreationInfo.fromAmountCoins);
|
|
5289
5290
|
setUpdateReceiveInputTo(swapCreationInfo.toAmountCoins);
|
|
@@ -5333,7 +5334,7 @@
|
|
|
5333
5334
|
}
|
|
5334
5335
|
(function () {
|
|
5335
5336
|
try {
|
|
5336
|
-
return _catch$
|
|
5337
|
+
return _catch$g(function () {
|
|
5337
5338
|
setIsLoading(true);
|
|
5338
5339
|
setMinimalAmount(null);
|
|
5339
5340
|
setMaximumAmount(null);
|
|
@@ -5404,7 +5405,7 @@
|
|
|
5404
5405
|
React.useEffect(function () {
|
|
5405
5406
|
if (!sendingAssetTicker || !receivingAssetTicker) return;
|
|
5406
5407
|
var currentAmount = isLastEditedReceiving.current ? receiveAssetAmount.current : sendAssetAmount.current;
|
|
5407
|
-
var isCurrentAmountNotZero = currentAmount && !
|
|
5408
|
+
var isCurrentAmountNotZero = currentAmount && !BigNumber.BigNumber("0").eq(currentAmount);
|
|
5408
5409
|
if (isCurrentAmountNotZero) {
|
|
5409
5410
|
loadFullEstimation(currentAmount);
|
|
5410
5411
|
} else {
|
|
@@ -5442,6 +5443,7 @@
|
|
|
5442
5443
|
setIsRecipientAddressValid(_validateAddressByTic);
|
|
5443
5444
|
};
|
|
5444
5445
|
if (!receivingAssetTicker) return;
|
|
5446
|
+
setValidationContent("");
|
|
5445
5447
|
var _temp = recipientAddress.current === "";
|
|
5446
5448
|
return _temp ? _temp2(false) : Promise.resolve(validateAddressByTicker(receivingAssetTicker, recipientAddress.current, isFixedRate.current, setValidationContent)).then(_temp2);
|
|
5447
5449
|
} catch (e) {
|
|
@@ -5457,6 +5459,7 @@
|
|
|
5457
5459
|
setIsRefundAddressValid(_validateAddressByTic2);
|
|
5458
5460
|
};
|
|
5459
5461
|
if (!sendingAssetTicker || !isRefundAddressRequired) return;
|
|
5462
|
+
setValidationContent("");
|
|
5460
5463
|
var _temp3 = refundAddress.current === "";
|
|
5461
5464
|
return _temp3 ? _temp4(false) : Promise.resolve(validateAddressByTicker(sendingAssetTicker, refundAddress.current, isFixedRate.current, setValidationContent)).then(_temp4);
|
|
5462
5465
|
} catch (e) {
|
|
@@ -5504,9 +5507,9 @@
|
|
|
5504
5507
|
React.useEffect(function () {
|
|
5505
5508
|
if (swapRate != null && (isLastEditedReceiving.current ? receiveAssetAmount.current : sendAssetAmount.current) != null) {
|
|
5506
5509
|
if (isLastEditedReceiving.current) {
|
|
5507
|
-
setUpdateSendInputTo(AmountUtils.trim(
|
|
5510
|
+
setUpdateSendInputTo(AmountUtils.trim(BigNumber.BigNumber(receiveAssetAmount.current).div(swapRate), sendingAssetDecimalCount));
|
|
5508
5511
|
} else {
|
|
5509
|
-
setUpdateReceiveInputTo(AmountUtils.trim(
|
|
5512
|
+
setUpdateReceiveInputTo(AmountUtils.trim(BigNumber.BigNumber(sendAssetAmount.current).times(swapRate), receivingAssetDecimalCount));
|
|
5510
5513
|
}
|
|
5511
5514
|
}
|
|
5512
5515
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -5521,7 +5524,7 @@
|
|
|
5521
5524
|
var handleAmountChange = function handleAmountChange(amount) {
|
|
5522
5525
|
requestDataRefresh(amount);
|
|
5523
5526
|
processMinMaxAmounts(amount);
|
|
5524
|
-
setIsAmountZero(
|
|
5527
|
+
setIsAmountZero(BigNumber.BigNumber("0").eq(amount));
|
|
5525
5528
|
setIsSwapCalculated(false);
|
|
5526
5529
|
};
|
|
5527
5530
|
React.useEffect(function () {
|
|
@@ -5535,12 +5538,12 @@
|
|
|
5535
5538
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
5536
5539
|
className: s$b["swap-form"]
|
|
5537
5540
|
}, /*#__PURE__*/React__default["default"].createElement(TitleBox, {
|
|
5538
|
-
linkButtonClick:
|
|
5541
|
+
linkButtonClick: BigNumber.BigNumber(sendingAssetBalance == null ? void 0 : sendingAssetBalance.assetAmount).eq(0) ? null : function (resetButtonLoader) {
|
|
5539
5542
|
return handleSwapAllClick(resetButtonLoader);
|
|
5540
5543
|
},
|
|
5541
5544
|
linkText: !formHasBalance ? "" : isSwapAll.current ? translations.swapAllButtonTitles.cancel : translations.swapAllButtonTitles.enable,
|
|
5542
5545
|
linkButtonLoader: true,
|
|
5543
|
-
isLinkButtonDisabled: isLoading.current || sendingAssetTicker === receivingAssetTicker ||
|
|
5546
|
+
isLinkButtonDisabled: isLoading.current || sendingAssetTicker === receivingAssetTicker || BigNumber.BigNumber(sendingAssetBalance == null ? void 0 : sendingAssetBalance.assetAmount).eq(0)
|
|
5544
5547
|
}, displayRateSelector ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
5545
5548
|
className: s$b["swap-form-rate-selector"]
|
|
5546
5549
|
}, /*#__PURE__*/React__default["default"].createElement(RateSelector, {
|
|
@@ -5596,7 +5599,7 @@
|
|
|
5596
5599
|
assetIconProtocolSrc: receivingAssetProtocolIconSrc,
|
|
5597
5600
|
fallbackAssetIconSrc: fallBackAssetIconSrc,
|
|
5598
5601
|
disabled: isSwapAll.current || sendingAssetTicker === null || receivingAssetTicker === null,
|
|
5599
|
-
locked:
|
|
5602
|
+
locked: true,
|
|
5600
5603
|
handleCoinAmountChange: handleReceiveAssetAmountChange,
|
|
5601
5604
|
handleChangeAssetClick: handleChangeReceivingAssetClick,
|
|
5602
5605
|
updateAssetInputTo: updateReceiveInputTo,
|
|
@@ -5802,7 +5805,7 @@
|
|
|
5802
5805
|
* @return {Promise<string>} xml string of generated svg image
|
|
5803
5806
|
*/
|
|
5804
5807
|
|
|
5805
|
-
function _catch$
|
|
5808
|
+
function _catch$f(body, recover) {
|
|
5806
5809
|
try {
|
|
5807
5810
|
var result = body();
|
|
5808
5811
|
} catch (e) {
|
|
@@ -5815,7 +5818,7 @@
|
|
|
5815
5818
|
}
|
|
5816
5819
|
var generateQrAndShowInCanvas = function generateQrAndShowInCanvas(encodingString) {
|
|
5817
5820
|
try {
|
|
5818
|
-
return Promise.resolve(_catch$
|
|
5821
|
+
return Promise.resolve(_catch$f(function () {
|
|
5819
5822
|
return Promise.resolve(QRCode__default["default"].toString(encodingString, {
|
|
5820
5823
|
type: "svg"
|
|
5821
5824
|
}));
|
|
@@ -5840,7 +5843,7 @@
|
|
|
5840
5843
|
* @returns {JSX.Element} A div containing the generated QR code.
|
|
5841
5844
|
*/
|
|
5842
5845
|
|
|
5843
|
-
function _catch$
|
|
5846
|
+
function _catch$e(body, recover) {
|
|
5844
5847
|
try {
|
|
5845
5848
|
var result = body();
|
|
5846
5849
|
} catch (e) {
|
|
@@ -5859,7 +5862,7 @@
|
|
|
5859
5862
|
React.useEffect(function () {
|
|
5860
5863
|
(function () {
|
|
5861
5864
|
try {
|
|
5862
|
-
return _catch$
|
|
5865
|
+
return _catch$e(function () {
|
|
5863
5866
|
var _temp = function () {
|
|
5864
5867
|
if (address) {
|
|
5865
5868
|
return Promise.resolve(generateQrAndShowInCanvas(address)).then(function (_generateQrAndShowInC) {
|
|
@@ -6703,7 +6706,7 @@
|
|
|
6703
6706
|
setIsSearchResultEmpty: function setIsSearchResultEmpty() {}
|
|
6704
6707
|
};
|
|
6705
6708
|
|
|
6706
|
-
function _catch$
|
|
6709
|
+
function _catch$d(body, recover) {
|
|
6707
6710
|
try {
|
|
6708
6711
|
var result = body();
|
|
6709
6712
|
} catch (e) {
|
|
@@ -6894,7 +6897,7 @@
|
|
|
6894
6897
|
var loadCoinsAndSaveToState = function loadCoinsAndSaveToState() {
|
|
6895
6898
|
(function () {
|
|
6896
6899
|
try {
|
|
6897
|
-
var _temp = _catch$
|
|
6900
|
+
var _temp = _catch$d(function () {
|
|
6898
6901
|
return Promise.resolve(loadCoinsAndContent ? loadCoinsAndContent() : defaultLoadCoinsAndContent()).then(function (data) {
|
|
6899
6902
|
setCoins(data.coins);
|
|
6900
6903
|
setCoinsContent(data.content);
|
|
@@ -7636,7 +7639,7 @@
|
|
|
7636
7639
|
* @returns {JSX.Element} The WaitlistSubscription component.
|
|
7637
7640
|
*/
|
|
7638
7641
|
|
|
7639
|
-
function _catch$
|
|
7642
|
+
function _catch$c(body, recover) {
|
|
7640
7643
|
try {
|
|
7641
7644
|
var result = body();
|
|
7642
7645
|
} catch (e) {
|
|
@@ -7691,7 +7694,7 @@
|
|
|
7691
7694
|
};
|
|
7692
7695
|
var subscribe = function subscribe(resetButtonLoader) {
|
|
7693
7696
|
try {
|
|
7694
|
-
var _temp = _catch$
|
|
7697
|
+
var _temp = _catch$c(function () {
|
|
7695
7698
|
setErrorEncountered(false);
|
|
7696
7699
|
return Promise.resolve(saveSubscription(coin, inputValue)).then(function (result) {
|
|
7697
7700
|
if (result) {
|
|
@@ -8232,7 +8235,7 @@
|
|
|
8232
8235
|
return Cache;
|
|
8233
8236
|
}();
|
|
8234
8237
|
|
|
8235
|
-
function _catch$
|
|
8238
|
+
function _catch$b(body, recover) {
|
|
8236
8239
|
try {
|
|
8237
8240
|
var result = body();
|
|
8238
8241
|
} catch (e) {
|
|
@@ -8250,7 +8253,7 @@
|
|
|
8250
8253
|
return new Promise(function (resolve, reject) {
|
|
8251
8254
|
setTimeout(function () {
|
|
8252
8255
|
try {
|
|
8253
|
-
var _temp = _catch$
|
|
8256
|
+
var _temp = _catch$b(function () {
|
|
8254
8257
|
return Promise.resolve(execution()).then(function (_execution) {
|
|
8255
8258
|
resolve(_execution);
|
|
8256
8259
|
});
|
|
@@ -8334,7 +8337,7 @@
|
|
|
8334
8337
|
return AxiosAdapter;
|
|
8335
8338
|
}();
|
|
8336
8339
|
|
|
8337
|
-
function _catch$
|
|
8340
|
+
function _catch$a(body, recover) {
|
|
8338
8341
|
try {
|
|
8339
8342
|
var result = body();
|
|
8340
8343
|
} catch (e) {
|
|
@@ -8350,7 +8353,7 @@
|
|
|
8350
8353
|
EmailsApi.sendEmail = function sendEmail(subject, body) {
|
|
8351
8354
|
try {
|
|
8352
8355
|
var _this = this;
|
|
8353
|
-
var _temp = _catch$
|
|
8356
|
+
var _temp = _catch$a(function () {
|
|
8354
8357
|
var url = window.location.protocol + "//" + window.location.host + "/api/v1/" + _this.serverEndpointEntity;
|
|
8355
8358
|
return Promise.resolve(axios__default["default"].post(url, {
|
|
8356
8359
|
subject: subject,
|
|
@@ -8768,7 +8771,7 @@
|
|
|
8768
8771
|
* improve the reliability of a data retrieval.
|
|
8769
8772
|
*/
|
|
8770
8773
|
|
|
8771
|
-
function _catch$
|
|
8774
|
+
function _catch$9(body, recover) {
|
|
8772
8775
|
try {
|
|
8773
8776
|
var result = body();
|
|
8774
8777
|
} catch (e) {
|
|
@@ -8779,21 +8782,21 @@
|
|
|
8779
8782
|
}
|
|
8780
8783
|
return result;
|
|
8781
8784
|
}
|
|
8782
|
-
function _settle$
|
|
8785
|
+
function _settle$3(pact, state, value) {
|
|
8783
8786
|
if (!pact.s) {
|
|
8784
|
-
if (value instanceof _Pact$
|
|
8787
|
+
if (value instanceof _Pact$3) {
|
|
8785
8788
|
if (value.s) {
|
|
8786
8789
|
if (state & 1) {
|
|
8787
8790
|
state = value.s;
|
|
8788
8791
|
}
|
|
8789
8792
|
value = value.v;
|
|
8790
8793
|
} else {
|
|
8791
|
-
value.o = _settle$
|
|
8794
|
+
value.o = _settle$3.bind(null, pact, state);
|
|
8792
8795
|
return;
|
|
8793
8796
|
}
|
|
8794
8797
|
}
|
|
8795
8798
|
if (value && value.then) {
|
|
8796
|
-
value.then(_settle$
|
|
8799
|
+
value.then(_settle$3.bind(null, pact, state), _settle$3.bind(null, pact, 2));
|
|
8797
8800
|
return;
|
|
8798
8801
|
}
|
|
8799
8802
|
pact.s = state;
|
|
@@ -8804,7 +8807,7 @@
|
|
|
8804
8807
|
}
|
|
8805
8808
|
}
|
|
8806
8809
|
}
|
|
8807
|
-
var _Pact$
|
|
8810
|
+
var _Pact$3 = /*#__PURE__*/function () {
|
|
8808
8811
|
function _Pact() {}
|
|
8809
8812
|
_Pact.prototype.then = function (onFulfilled, onRejected) {
|
|
8810
8813
|
var result = new _Pact();
|
|
@@ -8813,9 +8816,9 @@
|
|
|
8813
8816
|
var callback = state & 1 ? onFulfilled : onRejected;
|
|
8814
8817
|
if (callback) {
|
|
8815
8818
|
try {
|
|
8816
|
-
_settle$
|
|
8819
|
+
_settle$3(result, 1, callback(this.v));
|
|
8817
8820
|
} catch (e) {
|
|
8818
|
-
_settle$
|
|
8821
|
+
_settle$3(result, 2, e);
|
|
8819
8822
|
}
|
|
8820
8823
|
return result;
|
|
8821
8824
|
} else {
|
|
@@ -8826,28 +8829,28 @@
|
|
|
8826
8829
|
try {
|
|
8827
8830
|
var value = _this.v;
|
|
8828
8831
|
if (_this.s & 1) {
|
|
8829
|
-
_settle$
|
|
8832
|
+
_settle$3(result, 1, onFulfilled ? onFulfilled(value) : value);
|
|
8830
8833
|
} else if (onRejected) {
|
|
8831
|
-
_settle$
|
|
8834
|
+
_settle$3(result, 1, onRejected(value));
|
|
8832
8835
|
} else {
|
|
8833
|
-
_settle$
|
|
8836
|
+
_settle$3(result, 2, value);
|
|
8834
8837
|
}
|
|
8835
8838
|
} catch (e) {
|
|
8836
|
-
_settle$
|
|
8839
|
+
_settle$3(result, 2, e);
|
|
8837
8840
|
}
|
|
8838
8841
|
};
|
|
8839
8842
|
return result;
|
|
8840
8843
|
};
|
|
8841
8844
|
return _Pact;
|
|
8842
8845
|
}();
|
|
8843
|
-
function _isSettledPact$
|
|
8844
|
-
return thenable instanceof _Pact$
|
|
8846
|
+
function _isSettledPact$3(thenable) {
|
|
8847
|
+
return thenable instanceof _Pact$3 && thenable.s & 1;
|
|
8845
8848
|
}
|
|
8846
|
-
function _for$
|
|
8849
|
+
function _for$2(test, update, body) {
|
|
8847
8850
|
var stage;
|
|
8848
8851
|
for (;;) {
|
|
8849
8852
|
var shouldContinue = test();
|
|
8850
|
-
if (_isSettledPact$
|
|
8853
|
+
if (_isSettledPact$3(shouldContinue)) {
|
|
8851
8854
|
shouldContinue = shouldContinue.v;
|
|
8852
8855
|
}
|
|
8853
8856
|
if (!shouldContinue) {
|
|
@@ -8859,7 +8862,7 @@
|
|
|
8859
8862
|
}
|
|
8860
8863
|
var result = body();
|
|
8861
8864
|
if (result && result.then) {
|
|
8862
|
-
if (_isSettledPact$
|
|
8865
|
+
if (_isSettledPact$3(result)) {
|
|
8863
8866
|
result = result.s;
|
|
8864
8867
|
} else {
|
|
8865
8868
|
stage = 1;
|
|
@@ -8868,14 +8871,14 @@
|
|
|
8868
8871
|
}
|
|
8869
8872
|
if (update) {
|
|
8870
8873
|
var updateValue = update();
|
|
8871
|
-
if (updateValue && updateValue.then && !_isSettledPact$
|
|
8874
|
+
if (updateValue && updateValue.then && !_isSettledPact$3(updateValue)) {
|
|
8872
8875
|
stage = 2;
|
|
8873
8876
|
break;
|
|
8874
8877
|
}
|
|
8875
8878
|
}
|
|
8876
8879
|
}
|
|
8877
|
-
var pact = new _Pact$
|
|
8878
|
-
var reject = _settle$
|
|
8880
|
+
var pact = new _Pact$3();
|
|
8881
|
+
var reject = _settle$3.bind(null, pact, 2);
|
|
8879
8882
|
(stage === 0 ? shouldContinue.then(_resumeAfterTest) : stage === 1 ? result.then(_resumeAfterBody) : updateValue.then(_resumeAfterUpdate)).then(void 0, reject);
|
|
8880
8883
|
return pact;
|
|
8881
8884
|
function _resumeAfterBody(value) {
|
|
@@ -8883,14 +8886,14 @@
|
|
|
8883
8886
|
do {
|
|
8884
8887
|
if (update) {
|
|
8885
8888
|
updateValue = update();
|
|
8886
|
-
if (updateValue && updateValue.then && !_isSettledPact$
|
|
8889
|
+
if (updateValue && updateValue.then && !_isSettledPact$3(updateValue)) {
|
|
8887
8890
|
updateValue.then(_resumeAfterUpdate).then(void 0, reject);
|
|
8888
8891
|
return;
|
|
8889
8892
|
}
|
|
8890
8893
|
}
|
|
8891
8894
|
shouldContinue = test();
|
|
8892
|
-
if (!shouldContinue || _isSettledPact$
|
|
8893
|
-
_settle$
|
|
8895
|
+
if (!shouldContinue || _isSettledPact$3(shouldContinue) && !shouldContinue.v) {
|
|
8896
|
+
_settle$3(pact, 1, result);
|
|
8894
8897
|
return;
|
|
8895
8898
|
}
|
|
8896
8899
|
if (shouldContinue.then) {
|
|
@@ -8898,7 +8901,7 @@
|
|
|
8898
8901
|
return;
|
|
8899
8902
|
}
|
|
8900
8903
|
result = body();
|
|
8901
|
-
if (_isSettledPact$
|
|
8904
|
+
if (_isSettledPact$3(result)) {
|
|
8902
8905
|
result = result.v;
|
|
8903
8906
|
}
|
|
8904
8907
|
} while (!result || !result.then);
|
|
@@ -8913,7 +8916,7 @@
|
|
|
8913
8916
|
_resumeAfterBody(result);
|
|
8914
8917
|
}
|
|
8915
8918
|
} else {
|
|
8916
|
-
_settle$
|
|
8919
|
+
_settle$3(pact, 1, result);
|
|
8917
8920
|
}
|
|
8918
8921
|
}
|
|
8919
8922
|
function _resumeAfterUpdate() {
|
|
@@ -8924,7 +8927,7 @@
|
|
|
8924
8927
|
_resumeAfterTest(shouldContinue);
|
|
8925
8928
|
}
|
|
8926
8929
|
} else {
|
|
8927
|
-
_settle$
|
|
8930
|
+
_settle$3(pact, 1, result);
|
|
8928
8931
|
}
|
|
8929
8932
|
}
|
|
8930
8933
|
}
|
|
@@ -8944,7 +8947,7 @@
|
|
|
8944
8947
|
do {
|
|
8945
8948
|
var result = body();
|
|
8946
8949
|
if (result && result.then) {
|
|
8947
|
-
if (_isSettledPact$
|
|
8950
|
+
if (_isSettledPact$3(result)) {
|
|
8948
8951
|
result = result.v;
|
|
8949
8952
|
} else {
|
|
8950
8953
|
awaitBody = true;
|
|
@@ -8952,22 +8955,22 @@
|
|
|
8952
8955
|
}
|
|
8953
8956
|
}
|
|
8954
8957
|
var shouldContinue = test();
|
|
8955
|
-
if (_isSettledPact$
|
|
8958
|
+
if (_isSettledPact$3(shouldContinue)) {
|
|
8956
8959
|
shouldContinue = shouldContinue.v;
|
|
8957
8960
|
}
|
|
8958
8961
|
if (!shouldContinue) {
|
|
8959
8962
|
return result;
|
|
8960
8963
|
}
|
|
8961
8964
|
} while (!shouldContinue.then);
|
|
8962
|
-
var pact = new _Pact$
|
|
8963
|
-
var reject = _settle$
|
|
8965
|
+
var pact = new _Pact$3();
|
|
8966
|
+
var reject = _settle$3.bind(null, pact, 2);
|
|
8964
8967
|
(awaitBody ? result.then(_resumeAfterBody) : shouldContinue.then(_resumeAfterTest)).then(void 0, reject);
|
|
8965
8968
|
return pact;
|
|
8966
8969
|
function _resumeAfterBody(value) {
|
|
8967
8970
|
result = value;
|
|
8968
8971
|
for (;;) {
|
|
8969
8972
|
shouldContinue = test();
|
|
8970
|
-
if (_isSettledPact$
|
|
8973
|
+
if (_isSettledPact$3(shouldContinue)) {
|
|
8971
8974
|
shouldContinue = shouldContinue.v;
|
|
8972
8975
|
}
|
|
8973
8976
|
if (!shouldContinue) {
|
|
@@ -8979,7 +8982,7 @@
|
|
|
8979
8982
|
}
|
|
8980
8983
|
result = body();
|
|
8981
8984
|
if (result && result.then) {
|
|
8982
|
-
if (_isSettledPact$
|
|
8985
|
+
if (_isSettledPact$3(result)) {
|
|
8983
8986
|
result = result.v;
|
|
8984
8987
|
} else {
|
|
8985
8988
|
result.then(_resumeAfterBody).then(void 0, reject);
|
|
@@ -8987,14 +8990,14 @@
|
|
|
8987
8990
|
}
|
|
8988
8991
|
}
|
|
8989
8992
|
}
|
|
8990
|
-
_settle$
|
|
8993
|
+
_settle$3(pact, 1, result);
|
|
8991
8994
|
}
|
|
8992
8995
|
function _resumeAfterTest(shouldContinue) {
|
|
8993
8996
|
if (shouldContinue) {
|
|
8994
8997
|
do {
|
|
8995
8998
|
result = body();
|
|
8996
8999
|
if (result && result.then) {
|
|
8997
|
-
if (_isSettledPact$
|
|
9000
|
+
if (_isSettledPact$3(result)) {
|
|
8998
9001
|
result = result.v;
|
|
8999
9002
|
} else {
|
|
9000
9003
|
result.then(_resumeAfterBody).then(void 0, reject);
|
|
@@ -9002,17 +9005,17 @@
|
|
|
9002
9005
|
}
|
|
9003
9006
|
}
|
|
9004
9007
|
shouldContinue = test();
|
|
9005
|
-
if (_isSettledPact$
|
|
9008
|
+
if (_isSettledPact$3(shouldContinue)) {
|
|
9006
9009
|
shouldContinue = shouldContinue.v;
|
|
9007
9010
|
}
|
|
9008
9011
|
if (!shouldContinue) {
|
|
9009
|
-
_settle$
|
|
9012
|
+
_settle$3(pact, 1, result);
|
|
9010
9013
|
return;
|
|
9011
9014
|
}
|
|
9012
9015
|
} while (!shouldContinue.then);
|
|
9013
9016
|
shouldContinue.then(_resumeAfterTest).then(void 0, reject);
|
|
9014
9017
|
} else {
|
|
9015
|
-
_settle$
|
|
9018
|
+
_settle$3(pact, 1, result);
|
|
9016
9019
|
}
|
|
9017
9020
|
}
|
|
9018
9021
|
}
|
|
@@ -9025,21 +9028,21 @@
|
|
|
9025
9028
|
while (++i < array.length && (!check || !check())) {
|
|
9026
9029
|
result = body(i);
|
|
9027
9030
|
if (result && result.then) {
|
|
9028
|
-
if (_isSettledPact$
|
|
9031
|
+
if (_isSettledPact$3(result)) {
|
|
9029
9032
|
result = result.v;
|
|
9030
9033
|
} else {
|
|
9031
|
-
result.then(_cycle, reject || (reject = _settle$
|
|
9034
|
+
result.then(_cycle, reject || (reject = _settle$3.bind(null, pact = new _Pact$3(), 2)));
|
|
9032
9035
|
return;
|
|
9033
9036
|
}
|
|
9034
9037
|
}
|
|
9035
9038
|
}
|
|
9036
9039
|
if (pact) {
|
|
9037
|
-
_settle$
|
|
9040
|
+
_settle$3(pact, 1, result);
|
|
9038
9041
|
} else {
|
|
9039
9042
|
pact = result;
|
|
9040
9043
|
}
|
|
9041
9044
|
} catch (e) {
|
|
9042
|
-
_settle$
|
|
9045
|
+
_settle$3(pact || (pact = new _Pact$3()), 2, e);
|
|
9043
9046
|
}
|
|
9044
9047
|
}
|
|
9045
9048
|
_cycle();
|
|
@@ -9107,7 +9110,7 @@
|
|
|
9107
9110
|
var result;
|
|
9108
9111
|
var calculationUuid = concurrentCalculationsMetadataHolder.startCalculation(_this.bio);
|
|
9109
9112
|
return Promise.resolve(_finallyRethrows$1(function () {
|
|
9110
|
-
return _catch$
|
|
9113
|
+
return _catch$9(function () {
|
|
9111
9114
|
function _temp5() {
|
|
9112
9115
|
var _result2, _result3;
|
|
9113
9116
|
if (((_result2 = result) == null ? void 0 : _result2.data) == null) {
|
|
@@ -9122,7 +9125,7 @@
|
|
|
9122
9125
|
return (_result3 = result) == null ? void 0 : _result3.data;
|
|
9123
9126
|
}
|
|
9124
9127
|
var i = 0;
|
|
9125
|
-
var _temp4 = _for$
|
|
9128
|
+
var _temp4 = _for$2(function () {
|
|
9126
9129
|
var _result4, _result5;
|
|
9127
9130
|
return (i < attemptsCount || !!((_result4 = result) != null && _result4.shouldBeForceRetried)) && ((_result5 = result) == null ? void 0 : _result5.data) == null;
|
|
9128
9131
|
}, function () {
|
|
@@ -9135,7 +9138,7 @@
|
|
|
9135
9138
|
*/
|
|
9136
9139
|
var rpsFactor = result ? result.rpsFactor : RobustExternalAPICallerService.defaultRPSFactor;
|
|
9137
9140
|
result = null;
|
|
9138
|
-
var _temp3 = _catch$
|
|
9141
|
+
var _temp3 = _catch$9(function () {
|
|
9139
9142
|
function _temp2() {
|
|
9140
9143
|
var _result$errors;
|
|
9141
9144
|
if ((_result$errors = result.errors) != null && _result$errors.length) {
|
|
@@ -9159,7 +9162,7 @@
|
|
|
9159
9162
|
return Promise.resolve(new Promise(function (resolve, reject) {
|
|
9160
9163
|
setTimeout(function () {
|
|
9161
9164
|
try {
|
|
9162
|
-
var _temp6 = _catch$
|
|
9165
|
+
var _temp6 = _catch$9(function () {
|
|
9163
9166
|
return Promise.resolve(_this._performCallAttempt(parametersValues, timeoutMS, cancelToken, rpsFactor, doNotFailForNowData)).then(function (_this$_performCallAtt2) {
|
|
9164
9167
|
resolve(_this$_performCallAtt2);
|
|
9165
9168
|
});
|
|
@@ -9215,7 +9218,7 @@
|
|
|
9215
9218
|
providerIndex = 0,
|
|
9216
9219
|
countOfRequestsDeclinedByRps = 0,
|
|
9217
9220
|
errors = [];
|
|
9218
|
-
var _temp14 = _for$
|
|
9221
|
+
var _temp14 = _for$2(function () {
|
|
9219
9222
|
return !data && providerIndex < providers.length;
|
|
9220
9223
|
}, void 0, function () {
|
|
9221
9224
|
var provider = providers[providerIndex];
|
|
@@ -9229,7 +9232,7 @@
|
|
|
9229
9232
|
return;
|
|
9230
9233
|
}
|
|
9231
9234
|
var _temp13 = _finallyRethrows$1(function () {
|
|
9232
|
-
return _catch$
|
|
9235
|
+
return _catch$9(function () {
|
|
9233
9236
|
var _provider$specificHea;
|
|
9234
9237
|
function _temp12() {
|
|
9235
9238
|
if (iterationsData.length) {
|
|
@@ -9407,21 +9410,21 @@
|
|
|
9407
9410
|
* TODO: [tests, critical++] add unit tests - massively used logic and can produce sophisticated concurrency bugs
|
|
9408
9411
|
*/
|
|
9409
9412
|
|
|
9410
|
-
function _settle$
|
|
9413
|
+
function _settle$2(pact, state, value) {
|
|
9411
9414
|
if (!pact.s) {
|
|
9412
|
-
if (value instanceof _Pact$
|
|
9415
|
+
if (value instanceof _Pact$2) {
|
|
9413
9416
|
if (value.s) {
|
|
9414
9417
|
if (state & 1) {
|
|
9415
9418
|
state = value.s;
|
|
9416
9419
|
}
|
|
9417
9420
|
value = value.v;
|
|
9418
9421
|
} else {
|
|
9419
|
-
value.o = _settle$
|
|
9422
|
+
value.o = _settle$2.bind(null, pact, state);
|
|
9420
9423
|
return;
|
|
9421
9424
|
}
|
|
9422
9425
|
}
|
|
9423
9426
|
if (value && value.then) {
|
|
9424
|
-
value.then(_settle$
|
|
9427
|
+
value.then(_settle$2.bind(null, pact, state), _settle$2.bind(null, pact, 2));
|
|
9425
9428
|
return;
|
|
9426
9429
|
}
|
|
9427
9430
|
pact.s = state;
|
|
@@ -9437,7 +9440,7 @@
|
|
|
9437
9440
|
* Util class to control access to a resource when it can be called in parallel for the same result.
|
|
9438
9441
|
* (E.g. getting today coins-fiat rates from some API).
|
|
9439
9442
|
*/
|
|
9440
|
-
var _Pact$
|
|
9443
|
+
var _Pact$2 = /*#__PURE__*/function () {
|
|
9441
9444
|
function _Pact() {}
|
|
9442
9445
|
_Pact.prototype.then = function (onFulfilled, onRejected) {
|
|
9443
9446
|
var result = new _Pact();
|
|
@@ -9446,9 +9449,9 @@
|
|
|
9446
9449
|
var callback = state & 1 ? onFulfilled : onRejected;
|
|
9447
9450
|
if (callback) {
|
|
9448
9451
|
try {
|
|
9449
|
-
_settle$
|
|
9452
|
+
_settle$2(result, 1, callback(this.v));
|
|
9450
9453
|
} catch (e) {
|
|
9451
|
-
_settle$
|
|
9454
|
+
_settle$2(result, 2, e);
|
|
9452
9455
|
}
|
|
9453
9456
|
return result;
|
|
9454
9457
|
} else {
|
|
@@ -9459,28 +9462,28 @@
|
|
|
9459
9462
|
try {
|
|
9460
9463
|
var value = _this.v;
|
|
9461
9464
|
if (_this.s & 1) {
|
|
9462
|
-
_settle$
|
|
9465
|
+
_settle$2(result, 1, onFulfilled ? onFulfilled(value) : value);
|
|
9463
9466
|
} else if (onRejected) {
|
|
9464
|
-
_settle$
|
|
9467
|
+
_settle$2(result, 1, onRejected(value));
|
|
9465
9468
|
} else {
|
|
9466
|
-
_settle$
|
|
9469
|
+
_settle$2(result, 2, value);
|
|
9467
9470
|
}
|
|
9468
9471
|
} catch (e) {
|
|
9469
|
-
_settle$
|
|
9472
|
+
_settle$2(result, 2, e);
|
|
9470
9473
|
}
|
|
9471
9474
|
};
|
|
9472
9475
|
return result;
|
|
9473
9476
|
};
|
|
9474
9477
|
return _Pact;
|
|
9475
9478
|
}();
|
|
9476
|
-
function _isSettledPact$
|
|
9477
|
-
return thenable instanceof _Pact$
|
|
9479
|
+
function _isSettledPact$2(thenable) {
|
|
9480
|
+
return thenable instanceof _Pact$2 && thenable.s & 1;
|
|
9478
9481
|
}
|
|
9479
|
-
function _for(test, update, body) {
|
|
9482
|
+
function _for$1(test, update, body) {
|
|
9480
9483
|
var stage;
|
|
9481
9484
|
for (;;) {
|
|
9482
9485
|
var shouldContinue = test();
|
|
9483
|
-
if (_isSettledPact$
|
|
9486
|
+
if (_isSettledPact$2(shouldContinue)) {
|
|
9484
9487
|
shouldContinue = shouldContinue.v;
|
|
9485
9488
|
}
|
|
9486
9489
|
if (!shouldContinue) {
|
|
@@ -9492,7 +9495,7 @@
|
|
|
9492
9495
|
}
|
|
9493
9496
|
var result = body();
|
|
9494
9497
|
if (result && result.then) {
|
|
9495
|
-
if (_isSettledPact$
|
|
9498
|
+
if (_isSettledPact$2(result)) {
|
|
9496
9499
|
result = result.s;
|
|
9497
9500
|
} else {
|
|
9498
9501
|
stage = 1;
|
|
@@ -9501,14 +9504,14 @@
|
|
|
9501
9504
|
}
|
|
9502
9505
|
if (update) {
|
|
9503
9506
|
var updateValue = update();
|
|
9504
|
-
if (updateValue && updateValue.then && !_isSettledPact$
|
|
9507
|
+
if (updateValue && updateValue.then && !_isSettledPact$2(updateValue)) {
|
|
9505
9508
|
stage = 2;
|
|
9506
9509
|
break;
|
|
9507
9510
|
}
|
|
9508
9511
|
}
|
|
9509
9512
|
}
|
|
9510
|
-
var pact = new _Pact$
|
|
9511
|
-
var reject = _settle$
|
|
9513
|
+
var pact = new _Pact$2();
|
|
9514
|
+
var reject = _settle$2.bind(null, pact, 2);
|
|
9512
9515
|
(stage === 0 ? shouldContinue.then(_resumeAfterTest) : stage === 1 ? result.then(_resumeAfterBody) : updateValue.then(_resumeAfterUpdate)).then(void 0, reject);
|
|
9513
9516
|
return pact;
|
|
9514
9517
|
function _resumeAfterBody(value) {
|
|
@@ -9516,14 +9519,14 @@
|
|
|
9516
9519
|
do {
|
|
9517
9520
|
if (update) {
|
|
9518
9521
|
updateValue = update();
|
|
9519
|
-
if (updateValue && updateValue.then && !_isSettledPact$
|
|
9522
|
+
if (updateValue && updateValue.then && !_isSettledPact$2(updateValue)) {
|
|
9520
9523
|
updateValue.then(_resumeAfterUpdate).then(void 0, reject);
|
|
9521
9524
|
return;
|
|
9522
9525
|
}
|
|
9523
9526
|
}
|
|
9524
9527
|
shouldContinue = test();
|
|
9525
|
-
if (!shouldContinue || _isSettledPact$
|
|
9526
|
-
_settle$
|
|
9528
|
+
if (!shouldContinue || _isSettledPact$2(shouldContinue) && !shouldContinue.v) {
|
|
9529
|
+
_settle$2(pact, 1, result);
|
|
9527
9530
|
return;
|
|
9528
9531
|
}
|
|
9529
9532
|
if (shouldContinue.then) {
|
|
@@ -9531,7 +9534,7 @@
|
|
|
9531
9534
|
return;
|
|
9532
9535
|
}
|
|
9533
9536
|
result = body();
|
|
9534
|
-
if (_isSettledPact$
|
|
9537
|
+
if (_isSettledPact$2(result)) {
|
|
9535
9538
|
result = result.v;
|
|
9536
9539
|
}
|
|
9537
9540
|
} while (!result || !result.then);
|
|
@@ -9546,7 +9549,7 @@
|
|
|
9546
9549
|
_resumeAfterBody(result);
|
|
9547
9550
|
}
|
|
9548
9551
|
} else {
|
|
9549
|
-
_settle$
|
|
9552
|
+
_settle$2(pact, 1, result);
|
|
9550
9553
|
}
|
|
9551
9554
|
}
|
|
9552
9555
|
function _resumeAfterUpdate() {
|
|
@@ -9557,11 +9560,11 @@
|
|
|
9557
9560
|
_resumeAfterTest(shouldContinue);
|
|
9558
9561
|
}
|
|
9559
9562
|
} else {
|
|
9560
|
-
_settle$
|
|
9563
|
+
_settle$2(pact, 1, result);
|
|
9561
9564
|
}
|
|
9562
9565
|
}
|
|
9563
9566
|
}
|
|
9564
|
-
function _catch$
|
|
9567
|
+
function _catch$8(body, recover) {
|
|
9565
9568
|
try {
|
|
9566
9569
|
var result = body();
|
|
9567
9570
|
} catch (e) {
|
|
@@ -9640,7 +9643,7 @@
|
|
|
9640
9643
|
_proto.getCachedOrWaitForCachedOrAcquireLock = function getCachedOrWaitForCachedOrAcquireLock(cacheId) {
|
|
9641
9644
|
try {
|
|
9642
9645
|
var _this = this;
|
|
9643
|
-
return Promise.resolve(_catch$
|
|
9646
|
+
return Promise.resolve(_catch$8(function () {
|
|
9644
9647
|
function _temp2() {
|
|
9645
9648
|
var _cached, _cached2;
|
|
9646
9649
|
return calculationId ? {
|
|
@@ -9671,7 +9674,7 @@
|
|
|
9671
9674
|
var isRetrievedCacheExpired = true;
|
|
9672
9675
|
var isWaitingForActiveCalculationSucceeded;
|
|
9673
9676
|
var weStillHaveSomeTimeToProceedExecution = true;
|
|
9674
|
-
var _temp = _for(function () {
|
|
9677
|
+
var _temp = _for$1(function () {
|
|
9675
9678
|
return calculationId == null && cached == null && !!isRetrievedCacheExpired && !!weStillHaveSomeTimeToProceedExecution;
|
|
9676
9679
|
}, void 0, function () {
|
|
9677
9680
|
return Promise.resolve(_this._requestsManager.startCalculationOrWaitForActiveToFinish(cacheId)).then(function (result) {
|
|
@@ -9719,7 +9722,7 @@
|
|
|
9719
9722
|
_proto.acquireLock = function acquireLock(cacheId) {
|
|
9720
9723
|
try {
|
|
9721
9724
|
var _this2 = this;
|
|
9722
|
-
return Promise.resolve(_catch$
|
|
9725
|
+
return Promise.resolve(_catch$8(function () {
|
|
9723
9726
|
return Promise.resolve(_this2._requestsManager.acquireLock(cacheId));
|
|
9724
9727
|
}, function (e) {
|
|
9725
9728
|
improveAndRethrow(e, "acquireLock");
|
|
@@ -9889,7 +9892,7 @@
|
|
|
9889
9892
|
try {
|
|
9890
9893
|
var _exit;
|
|
9891
9894
|
var _this3 = this;
|
|
9892
|
-
var _temp3 = _catch$
|
|
9895
|
+
var _temp3 = _catch$8(function () {
|
|
9893
9896
|
var activeCalculationIdForHash = _this3._activeCalculationsIds.get(requestHash);
|
|
9894
9897
|
if (activeCalculationIdForHash == null) {
|
|
9895
9898
|
var id = uuid.v4();
|
|
@@ -9923,7 +9926,7 @@
|
|
|
9923
9926
|
_proto2.acquireLock = function acquireLock(requestHash) {
|
|
9924
9927
|
try {
|
|
9925
9928
|
var _this4 = this;
|
|
9926
|
-
return Promise.resolve(_catch$
|
|
9929
|
+
return Promise.resolve(_catch$8(function () {
|
|
9927
9930
|
var _this4$_nextCalculati;
|
|
9928
9931
|
var activeId = _this4._activeCalculationsIds.get(requestHash);
|
|
9929
9932
|
var nextId = uuid.v4();
|
|
@@ -10074,7 +10077,7 @@
|
|
|
10074
10077
|
* TODO: [tests, critical] Massively used logic
|
|
10075
10078
|
*/
|
|
10076
10079
|
|
|
10077
|
-
function _catch$
|
|
10080
|
+
function _catch$7(body, recover) {
|
|
10078
10081
|
try {
|
|
10079
10082
|
var result = body();
|
|
10080
10083
|
} catch (e) {
|
|
@@ -10171,7 +10174,7 @@
|
|
|
10171
10174
|
var cacheId;
|
|
10172
10175
|
var result;
|
|
10173
10176
|
return Promise.resolve(_finallyRethrows(function () {
|
|
10174
|
-
return _catch$
|
|
10177
|
+
return _catch$7(function () {
|
|
10175
10178
|
cacheId = _this._calculateCacheId(parametersValues, customHashFunctionForParams);
|
|
10176
10179
|
return Promise.resolve(_this._cahceAndRequestsResolver.getCachedOrWaitForCachedOrAcquireLock(cacheId)).then(function (_this$_cahceAndReques) {
|
|
10177
10180
|
var _result2, _result4;
|
|
@@ -10240,7 +10243,7 @@
|
|
|
10240
10243
|
return CachedRobustExternalApiCallerService;
|
|
10241
10244
|
}();
|
|
10242
10245
|
|
|
10243
|
-
function _catch$
|
|
10246
|
+
function _catch$6(body, recover) {
|
|
10244
10247
|
try {
|
|
10245
10248
|
var result = body();
|
|
10246
10249
|
} catch (e) {
|
|
@@ -10324,7 +10327,7 @@
|
|
|
10324
10327
|
IpAddressProvider.getClientIpAddress = function getClientIpAddress() {
|
|
10325
10328
|
try {
|
|
10326
10329
|
var _this = this;
|
|
10327
|
-
return Promise.resolve(_catch$
|
|
10330
|
+
return Promise.resolve(_catch$6(function () {
|
|
10328
10331
|
return Promise.resolve(_this.externalIPAddressAPICaller.callExternalAPICached([], 7000));
|
|
10329
10332
|
}, function (e) {
|
|
10330
10333
|
improveAndRethrow(e, "getClientIpAddress");
|
|
@@ -10447,30 +10450,77 @@
|
|
|
10447
10450
|
return CancelProcessing;
|
|
10448
10451
|
}();
|
|
10449
10452
|
|
|
10450
|
-
var ExistingSwap =
|
|
10451
10453
|
/**
|
|
10452
|
-
*
|
|
10453
|
-
|
|
10454
|
-
|
|
10455
|
-
|
|
10456
|
-
|
|
10457
|
-
|
|
10458
|
-
|
|
10459
|
-
|
|
10460
|
-
|
|
10461
|
-
|
|
10462
|
-
|
|
10463
|
-
|
|
10464
|
-
|
|
10465
|
-
|
|
10466
|
-
|
|
10467
|
-
|
|
10468
|
-
|
|
10469
|
-
|
|
10470
|
-
|
|
10471
|
-
|
|
10472
|
-
|
|
10473
|
-
|
|
10454
|
+
* Represents an existing swap.
|
|
10455
|
+
*/
|
|
10456
|
+
var ExistingSwap = /** @type {string} The ID of the swap. */
|
|
10457
|
+
|
|
10458
|
+
/** @type {SwapProvider.SWAP_STATUSES} The status of the swap. */
|
|
10459
|
+
|
|
10460
|
+
/** @type {number} The timestamp when the swap was created. */
|
|
10461
|
+
|
|
10462
|
+
/** @type {number} The timestamp when the swap expires. */
|
|
10463
|
+
|
|
10464
|
+
/** @type {number|null} The number of confirmations the swap has received, or null if not applicable. */
|
|
10465
|
+
|
|
10466
|
+
/** @type {string} The exchange rate for the swap. */
|
|
10467
|
+
|
|
10468
|
+
/** @type {boolean} Whether the rate is fixed. */
|
|
10469
|
+
|
|
10470
|
+
/** @type {string|null} The refund address in case the swap fails, or null if not applicable. */
|
|
10471
|
+
|
|
10472
|
+
/** @type {string} The address to send the payment to. */
|
|
10473
|
+
|
|
10474
|
+
/** @type {Coin} The coin from which the swap is made. */
|
|
10475
|
+
|
|
10476
|
+
/** @type {string} The amount of the fromCoin being swapped. */
|
|
10477
|
+
|
|
10478
|
+
/** @type {string|null} The transaction ID for the fromCoin, or null if not applicable. */
|
|
10479
|
+
|
|
10480
|
+
/** @type {string|null} The link to view the fromCoin transaction, or null if not applicable. */
|
|
10481
|
+
|
|
10482
|
+
/** @type {Coin} The coin to which the swap is made. */
|
|
10483
|
+
|
|
10484
|
+
/** @type {string} The amount of the toCoin received. */
|
|
10485
|
+
|
|
10486
|
+
/** @type {string|null} The transaction ID for the toCoin, or null if not applicable. */
|
|
10487
|
+
|
|
10488
|
+
/** @type {string|null} The link to view the toCoin transaction, or null if not applicable. */
|
|
10489
|
+
|
|
10490
|
+
/** @type {string} The address to send the swapped toCoin to. */
|
|
10491
|
+
|
|
10492
|
+
/** @type {string|null} The partner associated with the swap, or null if not applicable. */
|
|
10493
|
+
|
|
10494
|
+
/** @type {string|null} Extra identifier for the fromCoin, or null if not applicable. */
|
|
10495
|
+
|
|
10496
|
+
/** @type {string|null} Extra identifier for the toCoin, or null if not applicable. */
|
|
10497
|
+
|
|
10498
|
+
/** @type {string|null} Extra identifier for refund, or null if not applicable. */
|
|
10499
|
+
|
|
10500
|
+
/**
|
|
10501
|
+
* @constructor
|
|
10502
|
+
* @param {string} swapId - The ID of the swap.
|
|
10503
|
+
* @param {SwapProvider.SWAP_STATUSES} status - The status of the swap.
|
|
10504
|
+
* @param {number} createdAt - The timestamp when the swap was created.
|
|
10505
|
+
* @param {number} expiresAt - The timestamp when the swap expires.
|
|
10506
|
+
* @param {number|null} confirmations - The number of confirmations the swap has received, or null.
|
|
10507
|
+
* @param {string} rate - The exchange rate for the swap.
|
|
10508
|
+
* @param {boolean} fixed - Indicates if the rate is fixed.
|
|
10509
|
+
* @param {string|null} refundAddress - The address to refund to in case of failure, or null.
|
|
10510
|
+
* @param {string} payToAddress - The address to send the funds to.
|
|
10511
|
+
* @param {Coin} fromCoin - The coin that is being swapped from.
|
|
10512
|
+
* @param {string} fromAmount - The amount of the coin being swapped from.
|
|
10513
|
+
* @param {string|null} fromTransactionId - The transaction ID for the fromCoin, or null.
|
|
10514
|
+
* @param {string|null} fromTransactionLink - The link to view the fromCoin transaction, or null.
|
|
10515
|
+
* @param {Coin} toCoin - The coin that is being swapped to.
|
|
10516
|
+
* @param {string} toAmount - The amount of the coin being swapped to.
|
|
10517
|
+
* @param {string|null} toTransactionId - The transaction ID for the toCoin, or null.
|
|
10518
|
+
* @param {string|null} toTransactionLink - The link to view the toCoin transaction, or null.
|
|
10519
|
+
* @param {string} toAddress - The address to send the swapped coin to.
|
|
10520
|
+
* @param {string|null} partner - The partner associated with the swap, or null.
|
|
10521
|
+
* @param {string|null} fromExtraId - Any extra ID related to the fromCoin, or null.
|
|
10522
|
+
* @param {string|null} toExtraId - Any extra ID related to the toCoin, or null.
|
|
10523
|
+
* @param {string|null} refundExtraId - Any extra ID related to the refund, or null.
|
|
10474
10524
|
*/
|
|
10475
10525
|
function ExistingSwap(swapId, status, createdAt, expiresAt, confirmations, rate, fixed, refundAddress, payToAddress, fromCoin, fromAmount, fromTransactionId, fromTransactionLink, toCoin, toAmount, toTransactionId, toTransactionLink, toAddress,
|
|
10476
10526
|
// TODO: [refactoring, moderate] toAddress is not quite clear. How about recipientAddress? task_id=0815a111c99543b78d374217eadbde4f
|
|
@@ -10499,35 +10549,49 @@
|
|
|
10499
10549
|
this.refundExtraId = refundExtraId;
|
|
10500
10550
|
};
|
|
10501
10551
|
|
|
10552
|
+
/**
|
|
10553
|
+
* @class ExistingSwapWithFiatData
|
|
10554
|
+
* @extends {ExistingSwap}
|
|
10555
|
+
* @description Represents a swap with additional fiat currency data.
|
|
10556
|
+
*/
|
|
10502
10557
|
var ExistingSwapWithFiatData = /*#__PURE__*/function (_ExistingSwap) {
|
|
10503
10558
|
_inheritsLoose(ExistingSwapWithFiatData, _ExistingSwap);
|
|
10559
|
+
/** @type {number|null} The fiat equivalent of the fromAmount. */
|
|
10560
|
+
|
|
10561
|
+
/** @type {number|null} The fiat equivalent of the toAmount. */
|
|
10562
|
+
|
|
10563
|
+
/** @type {string} The fiat currency code (e.g., USD, EUR). */
|
|
10564
|
+
|
|
10565
|
+
/** @type {number} The number of decimals for the fiat currency. */
|
|
10566
|
+
|
|
10504
10567
|
/**
|
|
10505
|
-
* @
|
|
10506
|
-
* @param
|
|
10507
|
-
* @param
|
|
10508
|
-
* @param
|
|
10509
|
-
* @param
|
|
10510
|
-
* @param
|
|
10511
|
-
* @param
|
|
10512
|
-
* @param
|
|
10513
|
-
* @param
|
|
10514
|
-
* @param
|
|
10515
|
-
* @param
|
|
10516
|
-
* @param
|
|
10517
|
-
* @param
|
|
10518
|
-
* @param
|
|
10519
|
-
* @param
|
|
10520
|
-
* @param
|
|
10521
|
-
* @param
|
|
10522
|
-
* @param
|
|
10523
|
-
* @param
|
|
10524
|
-
* @param
|
|
10525
|
-
* @param
|
|
10526
|
-
* @param
|
|
10527
|
-
* @param
|
|
10528
|
-
* @param
|
|
10529
|
-
* @param
|
|
10530
|
-
* @param
|
|
10568
|
+
* @constructor
|
|
10569
|
+
* @param {string} swapId - The ID of the swap.
|
|
10570
|
+
* @param {SwapProvider.SWAP_STATUSES} status - The status of the swap.
|
|
10571
|
+
* @param {number} createdAt - The timestamp when the swap was created.
|
|
10572
|
+
* @param {number} expiresAt - The timestamp when the swap expires.
|
|
10573
|
+
* @param {number|null} confirmations - The number of confirmations the swap has received.
|
|
10574
|
+
* @param {string} rate - The exchange rate for the swap.
|
|
10575
|
+
* @param {boolean} fixed - Indicates if the rate is fixed.
|
|
10576
|
+
* @param {string|null} refundAddress - The address to refund to in case of failure.
|
|
10577
|
+
* @param {string} payToAddress - The address to send the funds to.
|
|
10578
|
+
* @param {Coin} fromCoin - The coin that is being swapped from.
|
|
10579
|
+
* @param {string} fromAmount - The amount of the coin being swapped from.
|
|
10580
|
+
* @param {string|null} fromTransactionId - The transaction ID for the fromCoin.
|
|
10581
|
+
* @param {string|null} fromTransactionLink - The link to view the fromCoin transaction.
|
|
10582
|
+
* @param {Coin} toCoin - The coin that is being swapped to.
|
|
10583
|
+
* @param {string} toAmount - The amount of the coin being swapped to.
|
|
10584
|
+
* @param {string|null} toTransactionId - The transaction ID for the toCoin.
|
|
10585
|
+
* @param {string|null} toTransactionLink - The link to view the toCoin transaction.
|
|
10586
|
+
* @param {string} toAddress - The address to send the swapped coin to.
|
|
10587
|
+
* @param {string|null} partner - The partner id associated with the swap.
|
|
10588
|
+
* @param {string|null} fromExtraId - Any extra ID related to the fromCoin.
|
|
10589
|
+
* @param {string|null} toExtraId - Any extra ID related to the toCoin.
|
|
10590
|
+
* @param {string|null} refundExtraId - Any extra ID related to the refund.
|
|
10591
|
+
* @param {number|null} fromAmountFiat - The fiat equivalent of the fromAmount.
|
|
10592
|
+
* @param {number|null} toAmountFiat - The fiat equivalent of the toAmount.
|
|
10593
|
+
* @param {string} fiatCurrencyCode - The fiat currency code (e.g., USD, EUR).
|
|
10594
|
+
* @param {number} fiatCurrencyDecimals - The number of decimals for the fiat currency.
|
|
10531
10595
|
*/
|
|
10532
10596
|
function ExistingSwapWithFiatData(swapId, status, createdAt, expiresAt, confirmations, rate, fixed, refundAddress, payToAddress, fromCoin, fromAmount, fromTransactionId, fromTransactionLink, toCoin, toAmount, toTransactionId, toTransactionLink, toAddress, partner, fromExtraId, toExtraId, refundExtraId, fromAmountFiat, toAmountFiat, fiatCurrencyCode, fiatCurrencyDecimals) {
|
|
10533
10597
|
var _this;
|
|
@@ -10540,12 +10604,14 @@
|
|
|
10540
10604
|
}
|
|
10541
10605
|
|
|
10542
10606
|
/**
|
|
10543
|
-
*
|
|
10544
|
-
* @
|
|
10545
|
-
* @param
|
|
10546
|
-
* @param
|
|
10547
|
-
* @param
|
|
10548
|
-
* @
|
|
10607
|
+
* Creates an instance of ExistingSwapWithFiatData from an ExistingSwap.
|
|
10608
|
+
* @static
|
|
10609
|
+
* @param {ExistingSwap} existingSwap - The existing swap data.
|
|
10610
|
+
* @param {number|null} fromAmountFiat - The fiat equivalent of the fromAmount.
|
|
10611
|
+
* @param {number|null} toAmountFiat - The fiat equivalent of the toAmount.
|
|
10612
|
+
* @param {string} fiatCurrencyCode - The fiat currency code (e.g., USD, EUR).
|
|
10613
|
+
* @param {number} fiatCurrencyDecimals - The number of decimals for the fiat currency.
|
|
10614
|
+
* @returns {ExistingSwapWithFiatData} A new instance of ExistingSwapWithFiatData.
|
|
10549
10615
|
*/
|
|
10550
10616
|
ExistingSwapWithFiatData.fromExistingSwap = function fromExistingSwap(existingSwap, fromAmountFiat, toAmountFiat, fiatCurrencyCode, fiatCurrencyDecimals) {
|
|
10551
10617
|
return new ExistingSwapWithFiatData(existingSwap.swapId, existingSwap.status, existingSwap.createdAt, existingSwap.expiresAt, existingSwap.confirmations, existingSwap.rate, existingSwap.fixed, existingSwap.refundAddress, existingSwap.payToAddress, existingSwap.fromCoin, existingSwap.fromAmount, existingSwap.fromTransactionId, existingSwap.fromTransactionLink, existingSwap.toCoin, existingSwap.toAmount, existingSwap.toTransactionId, existingSwap.toTransactionLink, existingSwap.toAddress, existingSwap.partner, existingSwap.fromExtraId, existingSwap.toExtraId, existingSwap.refundExtraId, fromAmountFiat, toAmountFiat, fiatCurrencyCode, fiatCurrencyDecimals);
|
|
@@ -10577,6 +10643,8 @@
|
|
|
10577
10643
|
|
|
10578
10644
|
/** @type {boolean} */
|
|
10579
10645
|
|
|
10646
|
+
/** @type {string|null} */
|
|
10647
|
+
|
|
10580
10648
|
/** @type {boolean} */
|
|
10581
10649
|
|
|
10582
10650
|
/**
|
|
@@ -10592,9 +10660,13 @@
|
|
|
10592
10660
|
* @param fiatMax {number}
|
|
10593
10661
|
* @param durationMinutesRange {string}
|
|
10594
10662
|
* @param fixed {boolean}
|
|
10663
|
+
* @param partner {string|null} rabbit partner id
|
|
10595
10664
|
* @param [isRefundAddressRequired=false] {boolean}
|
|
10596
10665
|
*/
|
|
10597
|
-
function BaseSwapCreationInfo(fromCoin, toCoin, fromAmountCoins, toAmountCoins, rate, rawSwapData, min, fiatMin, max, fiatMax, durationMinutesRange, fixed, isRefundAddressRequired) {
|
|
10666
|
+
function BaseSwapCreationInfo(fromCoin, toCoin, fromAmountCoins, toAmountCoins, rate, rawSwapData, min, fiatMin, max, fiatMax, durationMinutesRange, fixed, partner, isRefundAddressRequired) {
|
|
10667
|
+
if (partner === void 0) {
|
|
10668
|
+
partner = null;
|
|
10669
|
+
}
|
|
10598
10670
|
if (isRefundAddressRequired === void 0) {
|
|
10599
10671
|
isRefundAddressRequired = false;
|
|
10600
10672
|
}
|
|
@@ -10610,12 +10682,13 @@
|
|
|
10610
10682
|
this.fiatMax = fiatMax;
|
|
10611
10683
|
this.durationMinutesRange = durationMinutesRange;
|
|
10612
10684
|
this.fixed = fixed;
|
|
10685
|
+
this.partner = partner;
|
|
10613
10686
|
this.isRefundAddressRequired = isRefundAddressRequired;
|
|
10614
10687
|
};
|
|
10615
10688
|
|
|
10616
10689
|
/**
|
|
10617
|
-
*
|
|
10618
|
-
* 1. ticker should be
|
|
10690
|
+
* construction rules:
|
|
10691
|
+
* 1. Coin class ticker should be built using toRabbitTicker function
|
|
10619
10692
|
* 2. name should not contain (PROTOCOL_CODE) or just PROTOCOL_CODe
|
|
10620
10693
|
* 3. protocol should be null for coins major for their blockchains like BTC, ETH
|
|
10621
10694
|
* 4. isPopular should be a number - the higher -> the more popular
|
|
@@ -10643,13 +10716,13 @@
|
|
|
10643
10716
|
/** @type {boolean} */
|
|
10644
10717
|
|
|
10645
10718
|
/**
|
|
10646
|
-
* @param {
|
|
10647
|
-
* @param {string} code - The ticker code
|
|
10648
|
-
* @param {string} network - The network
|
|
10719
|
+
* @param {Coin} coin
|
|
10720
|
+
* @param {string} code - The ticker code raw as in the provider
|
|
10721
|
+
* @param {string} network - The network raw as in the provider
|
|
10649
10722
|
* @param {boolean} hasExtraId - Whether the coin requires an extra ID for transactions.
|
|
10650
10723
|
* @param {string|null} extraIdName - The name of the extra ID, if applicable.
|
|
10651
10724
|
* @param {number} popularity - A number indicating the popularity of the coin.
|
|
10652
|
-
* @param {string}
|
|
10725
|
+
* @param {string} iconURL - The URL of the coin's icon.
|
|
10653
10726
|
* @param {boolean} [deposit=false] - Indicates whether deposits are supported. Defaults to `false`.
|
|
10654
10727
|
* @param {boolean} [withdrawal=false] - Indicates whether withdrawals are supported. Defaults to `false`.
|
|
10655
10728
|
* @param {string|null} [validationRegexp=null] - A regular expression for validating addresses, if applicable.
|
|
@@ -10669,7 +10742,9 @@
|
|
|
10669
10742
|
this.isAvailable = isAvailable != null ? isAvailable : true;
|
|
10670
10743
|
};
|
|
10671
10744
|
|
|
10672
|
-
|
|
10745
|
+
// TODO: [refactoring, moderate] extract structure of _supportedCoins into model class
|
|
10746
|
+
|
|
10747
|
+
function _catch$5(body, recover) {
|
|
10673
10748
|
try {
|
|
10674
10749
|
var result = body();
|
|
10675
10750
|
} catch (e) {
|
|
@@ -10679,10 +10754,7 @@
|
|
|
10679
10754
|
return result.then(void 0, recover);
|
|
10680
10755
|
}
|
|
10681
10756
|
return result;
|
|
10682
|
-
}
|
|
10683
|
-
var PRE_LISTED_COINS = [new SwapProviderCoinInfo(new Coin("Hamster Kombat", "HMSTRTON", "HMSTR", 18, null, "", null, null, 1, null, [], 60000, null, new Protocol("TON"), null, false), "HMSTR", "TON", true, "MEMO", 100, "https://rabbit.io/asset-icons/HMSTR.png",
|
|
10684
|
-
// "https://hamsterkombat.io/images/icons/hamster-coin.png"
|
|
10685
|
-
true, true, "^(EQ|UQ)[A-Za-z0-9-_]{46}$", false)];
|
|
10757
|
+
}
|
|
10686
10758
|
var SwapProvider = /*#__PURE__*/function () {
|
|
10687
10759
|
/** @type {string} */
|
|
10688
10760
|
|
|
@@ -10700,7 +10772,9 @@
|
|
|
10700
10772
|
|
|
10701
10773
|
/** @type {boolean} */
|
|
10702
10774
|
|
|
10703
|
-
|
|
10775
|
+
/** @type {boolean} */
|
|
10776
|
+
|
|
10777
|
+
function SwapProvider(id, cache, customCoinBuilder, useRestrictedCoinsSet, isAggregator, isReceiveAmountEstimationSupported) {
|
|
10704
10778
|
if (customCoinBuilder === void 0) {
|
|
10705
10779
|
customCoinBuilder = function customCoinBuilder(coin, network) {
|
|
10706
10780
|
return null;
|
|
@@ -10709,6 +10783,12 @@
|
|
|
10709
10783
|
if (useRestrictedCoinsSet === void 0) {
|
|
10710
10784
|
useRestrictedCoinsSet = true;
|
|
10711
10785
|
}
|
|
10786
|
+
if (isAggregator === void 0) {
|
|
10787
|
+
isAggregator = false;
|
|
10788
|
+
}
|
|
10789
|
+
if (isReceiveAmountEstimationSupported === void 0) {
|
|
10790
|
+
isReceiveAmountEstimationSupported = false;
|
|
10791
|
+
}
|
|
10712
10792
|
this.id = id;
|
|
10713
10793
|
this._supportedCoins = [];
|
|
10714
10794
|
this._supportedCoinsLastUpdateTimestamp = 0;
|
|
@@ -10716,7 +10796,8 @@
|
|
|
10716
10796
|
this.useRestrictedCoinsSet = useRestrictedCoinsSet;
|
|
10717
10797
|
this._customCoinBuilder = customCoinBuilder;
|
|
10718
10798
|
this._cache = cache;
|
|
10719
|
-
this.isAggregator =
|
|
10799
|
+
this.isAggregator = isAggregator;
|
|
10800
|
+
this.isReceiveAmountEstimationSupported = isReceiveAmountEstimationSupported;
|
|
10720
10801
|
}
|
|
10721
10802
|
var _proto = SwapProvider.prototype;
|
|
10722
10803
|
/**
|
|
@@ -10797,21 +10878,7 @@
|
|
|
10797
10878
|
* @private
|
|
10798
10879
|
*/;
|
|
10799
10880
|
_proto._fetchSupportedCurrenciesIfNeeded = function _fetchSupportedCurrenciesIfNeeded() {
|
|
10800
|
-
|
|
10801
|
-
var _this2 = this;
|
|
10802
|
-
if (!_this2.useRestrictedCoinsSet) {
|
|
10803
|
-
PRE_LISTED_COINS.forEach(function (preListedCoin) {
|
|
10804
|
-
if (!_this2._supportedCoins.find(function (existingCoin) {
|
|
10805
|
-
return preListedCoin.coin.ticker === existingCoin.coin.ticker;
|
|
10806
|
-
})) {
|
|
10807
|
-
_this2._supportedCoins.push(preListedCoin);
|
|
10808
|
-
}
|
|
10809
|
-
});
|
|
10810
|
-
}
|
|
10811
|
-
return Promise.resolve();
|
|
10812
|
-
} catch (e) {
|
|
10813
|
-
return Promise.reject(e);
|
|
10814
|
-
}
|
|
10881
|
+
return Promise.resolve();
|
|
10815
10882
|
}
|
|
10816
10883
|
/**
|
|
10817
10884
|
* Retrieves all currencies supported by this swap provider.
|
|
@@ -10822,15 +10889,15 @@
|
|
|
10822
10889
|
;
|
|
10823
10890
|
_proto.getAllSupportedCurrencies = function getAllSupportedCurrencies() {
|
|
10824
10891
|
try {
|
|
10825
|
-
var
|
|
10892
|
+
var _this2 = this;
|
|
10826
10893
|
var loggerSource = "getAllSupportedCurrencies";
|
|
10827
|
-
return Promise.resolve(_catch$
|
|
10828
|
-
return Promise.resolve(
|
|
10829
|
-
var
|
|
10830
|
-
Logger.log("We have " + ((
|
|
10894
|
+
return Promise.resolve(_catch$5(function () {
|
|
10895
|
+
return Promise.resolve(_this2._fetchSupportedCurrenciesIfNeeded()).then(function () {
|
|
10896
|
+
var _this2$_supportedCoin;
|
|
10897
|
+
Logger.log("We have " + ((_this2$_supportedCoin = _this2._supportedCoins) == null ? void 0 : _this2$_supportedCoin.length) + " supported coins returning", loggerSource);
|
|
10831
10898
|
return {
|
|
10832
10899
|
result: true,
|
|
10833
|
-
coins:
|
|
10900
|
+
coins: _this2._supportedCoins.map(function (item) {
|
|
10834
10901
|
return item.coin;
|
|
10835
10902
|
})
|
|
10836
10903
|
};
|
|
@@ -10858,15 +10925,15 @@
|
|
|
10858
10925
|
;
|
|
10859
10926
|
_proto.getAllSupportedCurrenciesWithRawDetails = function getAllSupportedCurrenciesWithRawDetails() {
|
|
10860
10927
|
try {
|
|
10861
|
-
var
|
|
10928
|
+
var _this3 = this;
|
|
10862
10929
|
var loggerSource = "getAllSupportedCurrenciesWithRawDetails";
|
|
10863
|
-
return Promise.resolve(_catch$
|
|
10864
|
-
return Promise.resolve(
|
|
10865
|
-
var
|
|
10866
|
-
Logger.log("We have " + ((
|
|
10930
|
+
return Promise.resolve(_catch$5(function () {
|
|
10931
|
+
return Promise.resolve(_this3._fetchSupportedCurrenciesIfNeeded()).then(function () {
|
|
10932
|
+
var _this3$_supportedCoin;
|
|
10933
|
+
Logger.log("We have " + ((_this3$_supportedCoin = _this3._supportedCoins) == null ? void 0 : _this3$_supportedCoin.length) + " supported coins returning", loggerSource);
|
|
10867
10934
|
return {
|
|
10868
10935
|
result: true,
|
|
10869
|
-
coinsInfo: [].concat(
|
|
10936
|
+
coinsInfo: [].concat(_this3._supportedCoins)
|
|
10870
10937
|
};
|
|
10871
10938
|
});
|
|
10872
10939
|
}, function (e) {
|
|
@@ -10892,15 +10959,15 @@
|
|
|
10892
10959
|
;
|
|
10893
10960
|
_proto.getDepositCurrencies = function getDepositCurrencies() {
|
|
10894
10961
|
try {
|
|
10895
|
-
var
|
|
10962
|
+
var _this4 = this;
|
|
10896
10963
|
var loggerSource = "getDepositCurrencies";
|
|
10897
|
-
return Promise.resolve(_catch$
|
|
10898
|
-
return Promise.resolve(
|
|
10899
|
-
var
|
|
10900
|
-
Logger.log("We have " + ((
|
|
10964
|
+
return Promise.resolve(_catch$5(function () {
|
|
10965
|
+
return Promise.resolve(_this4._fetchSupportedCurrenciesIfNeeded()).then(function () {
|
|
10966
|
+
var _this4$_supportedCoin;
|
|
10967
|
+
Logger.log("We have " + ((_this4$_supportedCoin = _this4._supportedCoins) == null ? void 0 : _this4$_supportedCoin.length) + " supported coins, getting depositable", loggerSource);
|
|
10901
10968
|
return {
|
|
10902
10969
|
result: true,
|
|
10903
|
-
coins:
|
|
10970
|
+
coins: _this4._supportedCoins.filter(function (item) {
|
|
10904
10971
|
return item.deposit;
|
|
10905
10972
|
}).map(function (item) {
|
|
10906
10973
|
return item.coin;
|
|
@@ -10934,15 +11001,15 @@
|
|
|
10934
11001
|
exceptCurrency = null;
|
|
10935
11002
|
}
|
|
10936
11003
|
try {
|
|
10937
|
-
var
|
|
11004
|
+
var _this5 = this;
|
|
10938
11005
|
var loggerSource = "getWithdrawalCurrencies";
|
|
10939
|
-
return Promise.resolve(_catch$
|
|
10940
|
-
return Promise.resolve(
|
|
10941
|
-
var
|
|
10942
|
-
Logger.log("We have " + ((
|
|
11006
|
+
return Promise.resolve(_catch$5(function () {
|
|
11007
|
+
return Promise.resolve(_this5._fetchSupportedCurrenciesIfNeeded()).then(function () {
|
|
11008
|
+
var _this5$_supportedCoin;
|
|
11009
|
+
Logger.log("We have " + ((_this5$_supportedCoin = _this5._supportedCoins) == null ? void 0 : _this5$_supportedCoin.length) + " supported coins, getting withdrawable", loggerSource);
|
|
10943
11010
|
return {
|
|
10944
11011
|
result: true,
|
|
10945
|
-
coins:
|
|
11012
|
+
coins: _this5._supportedCoins.filter(function (item) {
|
|
10946
11013
|
var _item$coin, _exceptCurrency;
|
|
10947
11014
|
return item.withdrawal && (!exceptCurrency || ((_item$coin = item.coin) == null ? void 0 : _item$coin.ticker) !== ((_exceptCurrency = exceptCurrency) == null ? void 0 : _exceptCurrency.ticker));
|
|
10948
11015
|
}).map(function (item) {
|
|
@@ -10999,25 +11066,25 @@
|
|
|
10999
11066
|
*/;
|
|
11000
11067
|
_proto.getCoinToUSDTRate = function getCoinToUSDTRate(coinOrTicker) {
|
|
11001
11068
|
try {
|
|
11002
|
-
var
|
|
11069
|
+
var _this6 = this;
|
|
11003
11070
|
var loggerSource = "getCoinToUSDTRate";
|
|
11004
|
-
return Promise.resolve(_catch$
|
|
11005
|
-
return coinOrTicker ? Promise.resolve(
|
|
11006
|
-
var
|
|
11071
|
+
return Promise.resolve(_catch$5(function () {
|
|
11072
|
+
return coinOrTicker ? Promise.resolve(_this6._fetchSupportedCurrenciesIfNeeded()).then(function () {
|
|
11073
|
+
var _this6$_supportedCoin;
|
|
11007
11074
|
var ticker = coinOrTicker instanceof Coin ? coinOrTicker.ticker : coinOrTicker;
|
|
11008
|
-
var coin =
|
|
11075
|
+
var coin = _this6.getCoinByTickerIfPresent(ticker);
|
|
11009
11076
|
if (!coin) return null;
|
|
11010
11077
|
|
|
11011
11078
|
// Using USDT TRC20 as usually fee in this network is smaller than ERC20 and this network is widely used for USDT
|
|
11012
11079
|
// This calculation is not precise as we cannot recognize the actual fee and network fee. Just approximate.
|
|
11013
11080
|
// standard market fee is about 0.4% usually
|
|
11014
|
-
var usdtTrc20 = (
|
|
11081
|
+
var usdtTrc20 = (_this6$_supportedCoin = _this6._supportedCoins.find(function (i) {
|
|
11015
11082
|
return i.coin.ticker === "USDTTRC20";
|
|
11016
|
-
})) == null ? void 0 :
|
|
11083
|
+
})) == null ? void 0 : _this6$_supportedCoin.coin;
|
|
11017
11084
|
if (!usdtTrc20) {
|
|
11018
11085
|
return null;
|
|
11019
11086
|
}
|
|
11020
|
-
var cached =
|
|
11087
|
+
var cached = _this6._cache.get("swapspace_usdt_rate_" + ticker);
|
|
11021
11088
|
if (cached != null) {
|
|
11022
11089
|
return {
|
|
11023
11090
|
result: true,
|
|
@@ -11025,13 +11092,13 @@
|
|
|
11025
11092
|
};
|
|
11026
11093
|
}
|
|
11027
11094
|
Logger.log("Loading USDT->coin rate as not found in cache:", ticker);
|
|
11028
|
-
return Promise.resolve(
|
|
11095
|
+
return Promise.resolve(_this6.getSwapInfo(usdtTrc20, coin, "5000", false)).then(function (result) {
|
|
11029
11096
|
if (!result.result) {
|
|
11030
11097
|
return null;
|
|
11031
11098
|
}
|
|
11032
11099
|
var standardSwapspaceFeeMultiplier = 1.004;
|
|
11033
|
-
var rate =
|
|
11034
|
-
|
|
11100
|
+
var rate = BigNumber.BigNumber(1).div(BigNumber.BigNumber(result.rate).times(standardSwapspaceFeeMultiplier)).toString();
|
|
11101
|
+
_this6._cache.put("swap_usdt_rate_" + ticker, rate, 10 * 60000 // 15 minutes
|
|
11035
11102
|
);
|
|
11036
11103
|
return {
|
|
11037
11104
|
result: true,
|
|
@@ -11094,7 +11161,7 @@
|
|
|
11094
11161
|
* @param amount {string}
|
|
11095
11162
|
* @param toAddress {string}
|
|
11096
11163
|
* @param refundAddress {string}
|
|
11097
|
-
* @param
|
|
11164
|
+
* @param proprietarySwapEstimationData {Object|null}
|
|
11098
11165
|
* @param clientIpAddress {string}
|
|
11099
11166
|
* @param fixed {boolean}
|
|
11100
11167
|
* @param [toCurrencyExtraId=""] {string} optional extra ID
|
|
@@ -11119,7 +11186,7 @@
|
|
|
11119
11186
|
* })>}
|
|
11120
11187
|
*/
|
|
11121
11188
|
;
|
|
11122
|
-
_proto.createSwap = function createSwap(fromCoin, toCoin, amount, toAddress, refundAddress,
|
|
11189
|
+
_proto.createSwap = function createSwap(fromCoin, toCoin, amount, toAddress, refundAddress, proprietarySwapEstimationData, clientIpAddress, fixed, toCurrencyExtraId, refundExtraId, amountIsToReceive) {
|
|
11123
11190
|
try {
|
|
11124
11191
|
throw new Error("Not implemented in base");
|
|
11125
11192
|
} catch (e) {
|
|
@@ -11296,7 +11363,7 @@
|
|
|
11296
11363
|
HIGH: "high"
|
|
11297
11364
|
};
|
|
11298
11365
|
|
|
11299
|
-
function _catch$
|
|
11366
|
+
function _catch$4(body, recover) {
|
|
11300
11367
|
try {
|
|
11301
11368
|
var result = body();
|
|
11302
11369
|
} catch (e) {
|
|
@@ -11331,13 +11398,12 @@
|
|
|
11331
11398
|
if (apiKey === void 0) {
|
|
11332
11399
|
apiKey = null;
|
|
11333
11400
|
}
|
|
11334
|
-
_this = _SwapProvider.call(this, "swapspace", cache, customCoinBuilder, useRestrictedCoinsSet) || this;
|
|
11401
|
+
_this = _SwapProvider.call(this, "swapspace", cache, customCoinBuilder, useRestrictedCoinsSet, true, false) || this;
|
|
11335
11402
|
_this._partners = [];
|
|
11336
11403
|
_this._URL = apiKey ? "https://api.swapspace.co" : apiKeysProxyUrl + "/" + _this.id;
|
|
11337
11404
|
_this._headers = apiKey ? {
|
|
11338
11405
|
Authorization: apiKey
|
|
11339
11406
|
} : {};
|
|
11340
|
-
_this.isAggregator = true;
|
|
11341
11407
|
return _this;
|
|
11342
11408
|
}
|
|
11343
11409
|
var _proto = SwapspaceSwapProvider.prototype;
|
|
@@ -11350,7 +11416,7 @@
|
|
|
11350
11416
|
try {
|
|
11351
11417
|
var _this2 = this;
|
|
11352
11418
|
var loggerSource = "_fetchSupportedCurrenciesIfNeeded";
|
|
11353
|
-
return Promise.resolve(_catch$
|
|
11419
|
+
return Promise.resolve(_catch$4(function () {
|
|
11354
11420
|
var _temp = function () {
|
|
11355
11421
|
if (_this2._shouldCoinsListBeLoaded()) {
|
|
11356
11422
|
return Promise.resolve(axios__default["default"].get(_this2._URL + "/api/v2/currencies", {
|
|
@@ -11408,7 +11474,7 @@
|
|
|
11408
11474
|
try {
|
|
11409
11475
|
var _this3 = this;
|
|
11410
11476
|
var loggerSource = "_fetchPartnersListIfNeeded";
|
|
11411
|
-
return Promise.resolve(_catch$
|
|
11477
|
+
return Promise.resolve(_catch$4(function () {
|
|
11412
11478
|
var _temp2 = function (_this3$_partners) {
|
|
11413
11479
|
if (((_this3$_partners = _this3._partners) == null ? void 0 : _this3$_partners.length) === 0) {
|
|
11414
11480
|
return Promise.resolve(axios__default["default"].get(_this3._URL + "/api/v2/partners", {
|
|
@@ -11444,9 +11510,9 @@
|
|
|
11444
11510
|
try {
|
|
11445
11511
|
var _this4 = this;
|
|
11446
11512
|
var loggerSource = "getSwapInfo";
|
|
11447
|
-
return Promise.resolve(_catch$
|
|
11513
|
+
return Promise.resolve(_catch$4(function () {
|
|
11448
11514
|
if (amountIsToReceive) throw new Error("Swapspace doesn't support exchanging to get the exact receiving amount");
|
|
11449
|
-
if (!(fromCoin instanceof Coin) || !(toCoin instanceof Coin) || typeof amountCoins !== "string" ||
|
|
11515
|
+
if (!(fromCoin instanceof Coin) || !(toCoin instanceof Coin) || typeof amountCoins !== "string" || BigNumber.BigNumber(amountCoins).lt("0") || fixed !== null && typeof fixed !== "boolean") {
|
|
11450
11516
|
throw new Error("Wrong input params: " + amountCoins + " " + fromCoin.ticker + " -> " + toCoin.ticker + ", " + (fromCoin instanceof Coin) + ", " + (toCoin instanceof Coin) + ", " + typeof fixed + " " + fixed);
|
|
11451
11517
|
}
|
|
11452
11518
|
return Promise.resolve(_this4._fetchSupportedCurrenciesIfNeeded()).then(function () {
|
|
@@ -11470,7 +11536,7 @@
|
|
|
11470
11536
|
if (_exit) return _result;
|
|
11471
11537
|
var result = {
|
|
11472
11538
|
result: false,
|
|
11473
|
-
reason: smallestMin &&
|
|
11539
|
+
reason: smallestMin && BigNumber.BigNumber(amountCoins).lt(smallestMin) ? SwapProvider.NO_SWAPS_REASONS.TOO_LOW : greatestMax && BigNumber.BigNumber(amountCoins).gt(greatestMax) ? SwapProvider.NO_SWAPS_REASONS.TOO_HIGH : SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED,
|
|
11474
11540
|
smallestMin: smallestMin,
|
|
11475
11541
|
greatestMax: greatestMax
|
|
11476
11542
|
};
|
|
@@ -11511,31 +11577,31 @@
|
|
|
11511
11577
|
// min=0 or max=0 means there is no limit for the partner
|
|
11512
11578
|
var smallestMin = null;
|
|
11513
11579
|
if (exchangesSupportingThePair.find(function (ex) {
|
|
11514
|
-
return
|
|
11580
|
+
return BigNumber.BigNumber(ex.min).isZero();
|
|
11515
11581
|
}) == null) {
|
|
11516
11582
|
smallestMin = exchangesSupportingThePair.reduce(function (prev, cur) {
|
|
11517
|
-
if (typeof cur.min === "number" && (prev === null ||
|
|
11583
|
+
if (typeof cur.min === "number" && (prev === null || BigNumber.BigNumber(cur.min).lt(prev))) return BigNumber.BigNumber(cur.min);
|
|
11518
11584
|
return prev;
|
|
11519
11585
|
}, null);
|
|
11520
11586
|
}
|
|
11521
11587
|
var greatestMax = null;
|
|
11522
11588
|
if (exchangesSupportingThePair.find(function (ex) {
|
|
11523
|
-
return
|
|
11589
|
+
return BigNumber.BigNumber(ex.max).isZero();
|
|
11524
11590
|
}) == null) {
|
|
11525
11591
|
greatestMax = exchangesSupportingThePair.reduce(function (prev, cur) {
|
|
11526
|
-
if (typeof cur.max === "number" && (prev === null ||
|
|
11592
|
+
if (typeof cur.max === "number" && (prev === null || BigNumber.BigNumber(cur.max).gt(prev))) return BigNumber.BigNumber(cur.max);
|
|
11527
11593
|
return prev;
|
|
11528
11594
|
}, null);
|
|
11529
11595
|
}
|
|
11530
11596
|
var extraCoinsToFitMinMax = "0";
|
|
11531
|
-
if (typeof fromCoinToUsdRate === "string" &&
|
|
11532
|
-
var extraUsdToFitMinMax =
|
|
11597
|
+
if (typeof fromCoinToUsdRate === "string" && BigNumber.BigNumber(fromCoinToUsdRate).gt("0")) {
|
|
11598
|
+
var extraUsdToFitMinMax = BigNumber.BigNumber("1"); // We correct the limits as the exact limit can fluctuate and cause failed swap creation
|
|
11533
11599
|
extraCoinsToFitMinMax = AmountUtils.trim(extraUsdToFitMinMax.div(fromCoinToUsdRate), fromCoin.digits);
|
|
11534
11600
|
}
|
|
11535
|
-
if (smallestMin instanceof
|
|
11601
|
+
if (smallestMin instanceof BigNumber.BigNumber) {
|
|
11536
11602
|
smallestMin = AmountUtils.trim(smallestMin.plus(extraCoinsToFitMinMax), fromCoin.digits);
|
|
11537
11603
|
}
|
|
11538
|
-
if (greatestMax instanceof
|
|
11604
|
+
if (greatestMax instanceof BigNumber.BigNumber) {
|
|
11539
11605
|
if (greatestMax > extraCoinsToFitMinMax) {
|
|
11540
11606
|
greatestMax = AmountUtils.trim(greatestMax.minus(extraCoinsToFitMinMax), fromCoin.digits);
|
|
11541
11607
|
} else {
|
|
@@ -11553,14 +11619,14 @@
|
|
|
11553
11619
|
var min = null;
|
|
11554
11620
|
if (extraCoinsToFitMinMax != null) {
|
|
11555
11621
|
if (typeof bestOpt.max === "number" && bestOpt.max !== 0) {
|
|
11556
|
-
max =
|
|
11622
|
+
max = BigNumber.BigNumber(bestOpt.max).minus(extraCoinsToFitMinMax);
|
|
11557
11623
|
max = AmountUtils.trim(max.lt(0) ? "0" : max, fromCoin.digits);
|
|
11558
11624
|
}
|
|
11559
11625
|
if (typeof bestOpt.min === "number" && bestOpt.min !== 0) {
|
|
11560
|
-
min = AmountUtils.trim(
|
|
11626
|
+
min = AmountUtils.trim(BigNumber.BigNumber(bestOpt.min).plus(extraCoinsToFitMinMax), fromCoin.digits);
|
|
11561
11627
|
}
|
|
11562
11628
|
}
|
|
11563
|
-
var rate = bestOpt.toAmount && bestOpt.fromAmount ?
|
|
11629
|
+
var rate = bestOpt.toAmount && bestOpt.fromAmount ? BigNumber.BigNumber(bestOpt.toAmount).div(bestOpt.fromAmount) : null;
|
|
11564
11630
|
return Promise.resolve(_this4._fetchPartnersListIfNeeded()).then(function () {
|
|
11565
11631
|
var _bestOpt$duration;
|
|
11566
11632
|
var partner = _this4._partners.find(function (p) {
|
|
@@ -11607,7 +11673,7 @@
|
|
|
11607
11673
|
return Promise.reject(e);
|
|
11608
11674
|
}
|
|
11609
11675
|
};
|
|
11610
|
-
_proto.createSwap = function createSwap(fromCoin, toCoin, amount, toAddress, refundAddress,
|
|
11676
|
+
_proto.createSwap = function createSwap(fromCoin, toCoin, amount, toAddress, refundAddress, proprietarySwapEstimationData, clientIpAddress, fixed, toCurrencyExtraId, refundExtraId, amountIsToReceive) {
|
|
11611
11677
|
if (toCurrencyExtraId === void 0) {
|
|
11612
11678
|
toCurrencyExtraId = "";
|
|
11613
11679
|
}
|
|
@@ -11620,36 +11686,40 @@
|
|
|
11620
11686
|
try {
|
|
11621
11687
|
var _this5 = this;
|
|
11622
11688
|
var loggerSource = "createSwap";
|
|
11623
|
-
var partner =
|
|
11624
|
-
return Promise.resolve(_catch$
|
|
11689
|
+
var partner = proprietarySwapEstimationData == null ? void 0 : proprietarySwapEstimationData.partner;
|
|
11690
|
+
return Promise.resolve(_catch$4(function () {
|
|
11625
11691
|
if (amountIsToReceive) throw new Error("Swapspace doesn't support exchanging to get the exact receiving amount");
|
|
11626
11692
|
if (!(fromCoin instanceof Coin) || !(toCoin instanceof Coin) || typeof amount !== "string" || typeof toAddress !== "string" || typeof refundAddress !== "string" || typeof clientIpAddress != "string" || typeof fixed != "boolean" || clientIpAddress.length === 0) {
|
|
11627
11693
|
throw new Error("Invalid input: " + fromCoin + " " + toCoin + " " + amount + " " + toAddress + " " + refundAddress + " " + (clientIpAddress == null ? void 0 : clientIpAddress.length) + " " + fixed);
|
|
11628
11694
|
}
|
|
11629
|
-
|
|
11630
|
-
) {
|
|
11631
|
-
throw new Error("Invalid raw swap data: " + safeStringify(
|
|
11695
|
+
var rateId = proprietarySwapEstimationData == null ? void 0 : proprietarySwapEstimationData.id;
|
|
11696
|
+
if (typeof partner !== "string" || typeof rateId !== "string") {
|
|
11697
|
+
throw new Error("Invalid raw swap data: " + safeStringify(proprietarySwapEstimationData));
|
|
11632
11698
|
}
|
|
11633
11699
|
return Promise.resolve(_this5._fetchSupportedCurrenciesIfNeeded()).then(function () {
|
|
11634
11700
|
var _toCurrencyExtraId, _refundExtraId;
|
|
11635
|
-
var
|
|
11636
|
-
return
|
|
11637
|
-
|
|
11638
|
-
|
|
11639
|
-
|
|
11701
|
+
var _map = [fromCoin.ticker, toCoin.ticker].map(function (t) {
|
|
11702
|
+
return _this5._supportedCoins.find(function (coinData) {
|
|
11703
|
+
return coinData.coin.ticker === t;
|
|
11704
|
+
});
|
|
11705
|
+
}),
|
|
11706
|
+
fromCoinData = _map[0],
|
|
11707
|
+
toCoinData = _map[1];
|
|
11708
|
+
var fromCurrencyHasExtraId = !!fromCoinData.hasExtraId,
|
|
11709
|
+
toCurrencyHasExtraId = !!toCoinData.hasExtraId;
|
|
11640
11710
|
var requestData = {
|
|
11641
11711
|
partner: partner,
|
|
11642
|
-
fromCurrency:
|
|
11643
|
-
fromNetwork:
|
|
11644
|
-
toCurrency:
|
|
11645
|
-
toNetwork:
|
|
11712
|
+
fromCurrency: fromCoinData.code,
|
|
11713
|
+
fromNetwork: fromCoinData.network,
|
|
11714
|
+
toCurrency: toCoinData.code,
|
|
11715
|
+
toNetwork: toCoinData.network,
|
|
11646
11716
|
address: toAddress,
|
|
11647
11717
|
amount: amount,
|
|
11648
11718
|
fixed: fixed,
|
|
11649
11719
|
extraId: toCurrencyHasExtraId ? (_toCurrencyExtraId = toCurrencyExtraId) != null ? _toCurrencyExtraId : "" : "",
|
|
11650
11720
|
// This param is not documented. But the refund is usually manual so this is not critical.
|
|
11651
11721
|
refundExtraId: fromCurrencyHasExtraId ? (_refundExtraId = refundExtraId) != null ? _refundExtraId : "" : "",
|
|
11652
|
-
rateId:
|
|
11722
|
+
rateId: rateId,
|
|
11653
11723
|
userIp: clientIpAddress,
|
|
11654
11724
|
refund: refundAddress
|
|
11655
11725
|
};
|
|
@@ -11665,11 +11735,11 @@
|
|
|
11665
11735
|
/* We use the returned rate preferably but if the retrieved
|
|
11666
11736
|
* rate 0/null/undefined we calculate it manually */
|
|
11667
11737
|
var rate = result.rate;
|
|
11668
|
-
if (typeof rate !== "number" ||
|
|
11738
|
+
if (typeof rate !== "number" || BigNumber.BigNumber(rate).isZero()) {
|
|
11669
11739
|
var _result$to3, _result$from3;
|
|
11670
|
-
rate =
|
|
11740
|
+
rate = BigNumber.BigNumber(result == null || (_result$to3 = result.to) == null ? void 0 : _result$to3.amount).div(result == null || (_result$from3 = result.from) == null ? void 0 : _result$from3.amount);
|
|
11671
11741
|
} else {
|
|
11672
|
-
rate =
|
|
11742
|
+
rate = BigNumber.BigNumber(rate);
|
|
11673
11743
|
}
|
|
11674
11744
|
return {
|
|
11675
11745
|
result: true,
|
|
@@ -11752,15 +11822,15 @@
|
|
|
11752
11822
|
try {
|
|
11753
11823
|
var _this6 = this;
|
|
11754
11824
|
var loggerSource = "getExistingSwapsDetailsAndStatus";
|
|
11755
|
-
return Promise.resolve(_catch$
|
|
11825
|
+
return Promise.resolve(_catch$4(function () {
|
|
11756
11826
|
if (swapIds.find(function (id) {
|
|
11757
11827
|
return typeof id !== "string";
|
|
11758
11828
|
})) {
|
|
11759
|
-
throw new Error("Swap id is not string: " + safeStringify(swapIds));
|
|
11829
|
+
throw new Error("Swap id is not string: " + safeStringify(swapIds) + " " + _this6.id);
|
|
11760
11830
|
}
|
|
11761
11831
|
var getNotFailingOn404 = function getNotFailingOn404(swapId) {
|
|
11762
11832
|
try {
|
|
11763
|
-
return Promise.resolve(_catch$
|
|
11833
|
+
return Promise.resolve(_catch$4(function () {
|
|
11764
11834
|
return Promise.resolve(axios__default["default"].get(_this6._URL + "/api/v2/exchange/" + swapId, {
|
|
11765
11835
|
headers: _this6._headers
|
|
11766
11836
|
}));
|
|
@@ -11834,7 +11904,7 @@
|
|
|
11834
11904
|
_proto.getPartnersList = function getPartnersList() {
|
|
11835
11905
|
try {
|
|
11836
11906
|
var _this7 = this;
|
|
11837
|
-
return Promise.resolve(_catch$
|
|
11907
|
+
return Promise.resolve(_catch$4(function () {
|
|
11838
11908
|
return Promise.resolve(_this7._fetchPartnersListIfNeeded()).then(function () {
|
|
11839
11909
|
var swapspacePartners = _this7._partners.map(function (p) {
|
|
11840
11910
|
var _p$image;
|
|
@@ -11853,7 +11923,7 @@
|
|
|
11853
11923
|
return SwapspaceSwapProvider;
|
|
11854
11924
|
}(SwapProvider);
|
|
11855
11925
|
|
|
11856
|
-
function _catch$
|
|
11926
|
+
function _catch$3(body, recover) {
|
|
11857
11927
|
try {
|
|
11858
11928
|
var result = body();
|
|
11859
11929
|
} catch (e) {
|
|
@@ -11879,10 +11949,9 @@
|
|
|
11879
11949
|
if (apiKey === void 0) {
|
|
11880
11950
|
apiKey = null;
|
|
11881
11951
|
}
|
|
11882
|
-
_this = _SwapProvider.call(this, "letsexchange", cache, customCoinBuilder, useRestrictedCoinsSet) || this;
|
|
11952
|
+
_this = _SwapProvider.call(this, "letsexchange", cache, customCoinBuilder, useRestrictedCoinsSet, false, true) || this;
|
|
11883
11953
|
_this._partners = [];
|
|
11884
11954
|
_this._URL = apiKey ? "https://api.letsexchange.io/api" : apiKeysProxyUrl + "/" + _this.id;
|
|
11885
|
-
_this.isAggregator = false;
|
|
11886
11955
|
_this._headers = apiKey ? {
|
|
11887
11956
|
Authorization: "Bearer " + apiKey,
|
|
11888
11957
|
"Content-Type": "application/json",
|
|
@@ -11898,7 +11967,7 @@
|
|
|
11898
11967
|
try {
|
|
11899
11968
|
var _this2 = this;
|
|
11900
11969
|
var loggerSource = "_fetchSupportedCurrenciesIfNeeded";
|
|
11901
|
-
return Promise.resolve(_catch$
|
|
11970
|
+
return Promise.resolve(_catch$3(function () {
|
|
11902
11971
|
var _temp = function () {
|
|
11903
11972
|
if (_this2._shouldCoinsListBeLoaded()) {
|
|
11904
11973
|
return Promise.resolve(axios__default["default"].get(_this2._URL + "/v2/coins", {
|
|
@@ -11945,7 +12014,7 @@
|
|
|
11945
12014
|
return Promise.reject(e);
|
|
11946
12015
|
}
|
|
11947
12016
|
};
|
|
11948
|
-
_proto.getSwapInfo = function getSwapInfo(fromCoin, toCoin, amountCoins, fixed, fromCoinToUsdRate, amountIsToReceive) {
|
|
12017
|
+
_proto.getSwapInfo = function getSwapInfo(fromCoin, toCoin, amountCoins, fixed, fromCoinToUsdRate, amountIsToReceive, bannedPartners) {
|
|
11949
12018
|
if (fixed === void 0) {
|
|
11950
12019
|
fixed = false;
|
|
11951
12020
|
}
|
|
@@ -11957,8 +12026,8 @@
|
|
|
11957
12026
|
var loggerSource = "getSwapInfo";
|
|
11958
12027
|
var min = null;
|
|
11959
12028
|
var max = null;
|
|
11960
|
-
return Promise.resolve(_catch$
|
|
11961
|
-
if (!(fromCoin instanceof Coin) || !(toCoin instanceof Coin) || typeof amountCoins !== "string" ||
|
|
12029
|
+
return Promise.resolve(_catch$3(function () {
|
|
12030
|
+
if (!(fromCoin instanceof Coin) || !(toCoin instanceof Coin) || typeof amountCoins !== "string" || BigNumber.BigNumber(amountCoins).lt("0") || fixed !== null && typeof fixed !== "boolean" || amountIsToReceive && !fixed) {
|
|
11962
12031
|
throw new Error("Wrong input params: " + amountCoins + " " + fromCoin.ticker + " -> " + toCoin.ticker + ", " + (fromCoin instanceof Coin) + ", " + (toCoin instanceof Coin) + ", " + typeof fixed + " " + fixed + ", " + amountIsToReceive);
|
|
11963
12032
|
}
|
|
11964
12033
|
return Promise.resolve(_this3._fetchSupportedCurrenciesIfNeeded()).then(function () {
|
|
@@ -12012,13 +12081,13 @@
|
|
|
12012
12081
|
// }
|
|
12013
12082
|
throw new Error("Failed to estimate swap letsexchange");
|
|
12014
12083
|
}
|
|
12015
|
-
if (
|
|
12084
|
+
if (BigNumber.BigNumber(data.rate).eq("0") || BigNumber.BigNumber(data.amount).eq("0")) {
|
|
12016
12085
|
// TODO actualize according to letsexchage clarification - decide, can we count on min/max abcense? task_id=76512110797f4eab8b37f1bb789825cb
|
|
12017
12086
|
// amount: "0", rate: "0", rate_id: ""
|
|
12018
12087
|
var reason = SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED;
|
|
12019
|
-
if (min &&
|
|
12088
|
+
if (min && BigNumber.BigNumber(amountCoins).lt(min)) {
|
|
12020
12089
|
reason = SwapProvider.NO_SWAPS_REASONS.TOO_LOW;
|
|
12021
|
-
} else if (max &&
|
|
12090
|
+
} else if (max && BigNumber.BigNumber(amountCoins).gt(max)) {
|
|
12022
12091
|
reason = SwapProvider.NO_SWAPS_REASONS.TOO_HIGH;
|
|
12023
12092
|
} else if (!amountIsToReceive) {
|
|
12024
12093
|
// If we are not requesting receiving amount (it cannot be floating-rate)
|
|
@@ -12038,7 +12107,7 @@
|
|
|
12038
12107
|
greatestMax: max
|
|
12039
12108
|
};
|
|
12040
12109
|
}
|
|
12041
|
-
var rate = amountIsToReceive ?
|
|
12110
|
+
var rate = amountIsToReceive ? BigNumber.BigNumber(amountCoins).div(data.amount) : BigNumber.BigNumber(data.amount).div(amountCoins);
|
|
12042
12111
|
return {
|
|
12043
12112
|
result: true,
|
|
12044
12113
|
min: min,
|
|
@@ -12076,7 +12145,7 @@
|
|
|
12076
12145
|
return Promise.reject(e);
|
|
12077
12146
|
}
|
|
12078
12147
|
};
|
|
12079
|
-
_proto.createSwap = function createSwap(fromCoin, toCoin, amount, toAddress, refundAddress,
|
|
12148
|
+
_proto.createSwap = function createSwap(fromCoin, toCoin, amount, toAddress, refundAddress, proprietarySwapEstimationData, clientIpAddress, fixed, toCurrencyExtraId, refundExtraId, amountIsToReceive) {
|
|
12080
12149
|
if (toCurrencyExtraId === void 0) {
|
|
12081
12150
|
toCurrencyExtraId = "";
|
|
12082
12151
|
}
|
|
@@ -12089,12 +12158,12 @@
|
|
|
12089
12158
|
try {
|
|
12090
12159
|
var _this4 = this;
|
|
12091
12160
|
var loggerSource = "createSwap";
|
|
12092
|
-
return Promise.resolve(_catch$
|
|
12161
|
+
return Promise.resolve(_catch$3(function () {
|
|
12093
12162
|
if (!(fromCoin instanceof Coin) || !(toCoin instanceof Coin) || typeof amount !== "string" || typeof toAddress !== "string" || typeof refundAddress !== "string" || typeof clientIpAddress != "string" || typeof fixed != "boolean") {
|
|
12094
12163
|
throw new Error("Invalid input: " + fromCoin + " " + toCoin + " " + amount + " " + toAddress + " " + refundAddress + " " + fixed);
|
|
12095
12164
|
}
|
|
12096
|
-
if (typeof
|
|
12097
|
-
throw new Error("Invalid raw swap data: " + safeStringify(
|
|
12165
|
+
if (typeof proprietarySwapEstimationData !== "object" || fixed && !proprietarySwapEstimationData.rate_id) {
|
|
12166
|
+
throw new Error("Invalid raw swap data: " + safeStringify(proprietarySwapEstimationData));
|
|
12098
12167
|
}
|
|
12099
12168
|
return Promise.resolve(_this4._fetchSupportedCurrenciesIfNeeded()).then(function () {
|
|
12100
12169
|
var fromCoinDetails = _this4._supportedCoins.find(function (i) {
|
|
@@ -12125,7 +12194,7 @@
|
|
|
12125
12194
|
requestBody.deposit_amount = amount;
|
|
12126
12195
|
}
|
|
12127
12196
|
if (fixed) {
|
|
12128
|
-
requestBody.rate_id =
|
|
12197
|
+
requestBody.rate_id = proprietarySwapEstimationData.rate_id;
|
|
12129
12198
|
}
|
|
12130
12199
|
return Promise.resolve(axios__default["default"].post(_this4._URL + "/v1/transaction" + (amountIsToReceive ? "-revert" : "?float=" + !fixed), requestBody, {
|
|
12131
12200
|
headers: _this4._headers
|
|
@@ -12134,7 +12203,7 @@
|
|
|
12134
12203
|
Logger.log("Creation result " + safeStringify(result), loggerSource);
|
|
12135
12204
|
if (result != null && result.transaction_id) {
|
|
12136
12205
|
var _result$rate, _result$deposit_extra;
|
|
12137
|
-
var rate =
|
|
12206
|
+
var rate = BigNumber.BigNumber((_result$rate = result.rate) != null ? _result$rate : 0).isZero() ? BigNumber.BigNumber(result.withdrawal_amount).div(result.deposit_amount) : BigNumber.BigNumber(result.rate);
|
|
12138
12207
|
return {
|
|
12139
12208
|
result: true,
|
|
12140
12209
|
swapId: result.transaction_id,
|
|
@@ -12182,11 +12251,11 @@
|
|
|
12182
12251
|
try {
|
|
12183
12252
|
var _this5 = this;
|
|
12184
12253
|
var loggerSource = "getExistingSwapsDetailsAndStatus";
|
|
12185
|
-
return Promise.resolve(_catch$
|
|
12254
|
+
return Promise.resolve(_catch$3(function () {
|
|
12186
12255
|
if (swapIds.find(function (id) {
|
|
12187
12256
|
return typeof id !== "string";
|
|
12188
12257
|
})) {
|
|
12189
|
-
throw new Error("Swap id is not string: " + safeStringify(swapIds));
|
|
12258
|
+
throw new Error("Swap id is not string: " + safeStringify(swapIds) + " " + _this5.id);
|
|
12190
12259
|
}
|
|
12191
12260
|
return Promise.resolve(axios__default["default"].get(_this5._URL + "/v1/transactions-list?ids[]=" + swapIds.join("&ids[]="), {
|
|
12192
12261
|
headers: _this5._headers
|
|
@@ -12213,7 +12282,7 @@
|
|
|
12213
12282
|
var toDigits = status === SwapProvider.SWAP_STATUSES.REFUNDED ? fromCoin.digits : toCoin.digits;
|
|
12214
12283
|
var deposit = swap.real_deposit_amount && swap.real_deposit_amount !== "" ? swap.real_deposit_amount : swap.deposit_amount;
|
|
12215
12284
|
var withdrawal = swap.real_withdrawal_amount && swap.real_withdrawal_amount !== "" ? swap.real_withdrawal_amount : swap.withdrawal_amount;
|
|
12216
|
-
var rate =
|
|
12285
|
+
var rate = BigNumber.BigNumber(withdrawal).div(deposit).toFixed(_this5._maxRateDigits); // We don't use their rate as it excludes their fee
|
|
12217
12286
|
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
12287
|
}).flat();
|
|
12219
12288
|
Logger.log("Swap details result " + safeStringify(swaps), loggerSource);
|
|
@@ -12299,38 +12368,652 @@
|
|
|
12299
12368
|
}(SwapProvider);
|
|
12300
12369
|
LetsExchangeSwapProvider.AFFILIATE_ID = "0zbj9hf7xg7jgdgv";
|
|
12301
12370
|
|
|
12302
|
-
function
|
|
12303
|
-
try {
|
|
12304
|
-
var result = body();
|
|
12305
|
-
} catch (e) {
|
|
12306
|
-
return recover(e);
|
|
12307
|
-
}
|
|
12308
|
-
if (result && result.then) {
|
|
12309
|
-
return result.then(void 0, recover);
|
|
12310
|
-
}
|
|
12311
|
-
return result;
|
|
12312
|
-
}
|
|
12313
|
-
var _iteratorSymbol = typeof Symbol !== "undefined" ? Symbol.iterator || (Symbol.iterator = Symbol("Symbol.iterator")) : "@@iterator";
|
|
12314
|
-
function _settle(pact, state, value) {
|
|
12371
|
+
function _settle$1(pact, state, value) {
|
|
12315
12372
|
if (!pact.s) {
|
|
12316
|
-
if (value instanceof _Pact) {
|
|
12373
|
+
if (value instanceof _Pact$1) {
|
|
12317
12374
|
if (value.s) {
|
|
12318
12375
|
if (state & 1) {
|
|
12319
12376
|
state = value.s;
|
|
12320
12377
|
}
|
|
12321
12378
|
value = value.v;
|
|
12322
12379
|
} else {
|
|
12323
|
-
value.o = _settle.bind(null, pact, state);
|
|
12380
|
+
value.o = _settle$1.bind(null, pact, state);
|
|
12324
12381
|
return;
|
|
12325
12382
|
}
|
|
12326
12383
|
}
|
|
12327
12384
|
if (value && value.then) {
|
|
12328
|
-
value.then(_settle.bind(null, pact, state), _settle.bind(null, pact, 2));
|
|
12385
|
+
value.then(_settle$1.bind(null, pact, state), _settle$1.bind(null, pact, 2));
|
|
12329
12386
|
return;
|
|
12330
12387
|
}
|
|
12331
12388
|
pact.s = state;
|
|
12332
12389
|
pact.v = value;
|
|
12333
|
-
|
|
12390
|
+
const observer = pact.o;
|
|
12391
|
+
if (observer) {
|
|
12392
|
+
observer(pact);
|
|
12393
|
+
}
|
|
12394
|
+
}
|
|
12395
|
+
}
|
|
12396
|
+
var _Pact$1 = /*#__PURE__*/function () {
|
|
12397
|
+
function _Pact() {}
|
|
12398
|
+
_Pact.prototype.then = function (onFulfilled, onRejected) {
|
|
12399
|
+
var result = new _Pact();
|
|
12400
|
+
var state = this.s;
|
|
12401
|
+
if (state) {
|
|
12402
|
+
var callback = state & 1 ? onFulfilled : onRejected;
|
|
12403
|
+
if (callback) {
|
|
12404
|
+
try {
|
|
12405
|
+
_settle$1(result, 1, callback(this.v));
|
|
12406
|
+
} catch (e) {
|
|
12407
|
+
_settle$1(result, 2, e);
|
|
12408
|
+
}
|
|
12409
|
+
return result;
|
|
12410
|
+
} else {
|
|
12411
|
+
return this;
|
|
12412
|
+
}
|
|
12413
|
+
}
|
|
12414
|
+
this.o = function (_this) {
|
|
12415
|
+
try {
|
|
12416
|
+
var value = _this.v;
|
|
12417
|
+
if (_this.s & 1) {
|
|
12418
|
+
_settle$1(result, 1, onFulfilled ? onFulfilled(value) : value);
|
|
12419
|
+
} else if (onRejected) {
|
|
12420
|
+
_settle$1(result, 1, onRejected(value));
|
|
12421
|
+
} else {
|
|
12422
|
+
_settle$1(result, 2, value);
|
|
12423
|
+
}
|
|
12424
|
+
} catch (e) {
|
|
12425
|
+
_settle$1(result, 2, e);
|
|
12426
|
+
}
|
|
12427
|
+
};
|
|
12428
|
+
return result;
|
|
12429
|
+
};
|
|
12430
|
+
return _Pact;
|
|
12431
|
+
}();
|
|
12432
|
+
function _isSettledPact$1(thenable) {
|
|
12433
|
+
return thenable instanceof _Pact$1 && thenable.s & 1;
|
|
12434
|
+
}
|
|
12435
|
+
function _for(test, update, body) {
|
|
12436
|
+
var stage;
|
|
12437
|
+
for (;;) {
|
|
12438
|
+
var shouldContinue = test();
|
|
12439
|
+
if (_isSettledPact$1(shouldContinue)) {
|
|
12440
|
+
shouldContinue = shouldContinue.v;
|
|
12441
|
+
}
|
|
12442
|
+
if (!shouldContinue) {
|
|
12443
|
+
return result;
|
|
12444
|
+
}
|
|
12445
|
+
if (shouldContinue.then) {
|
|
12446
|
+
stage = 0;
|
|
12447
|
+
break;
|
|
12448
|
+
}
|
|
12449
|
+
var result = body();
|
|
12450
|
+
if (result && result.then) {
|
|
12451
|
+
if (_isSettledPact$1(result)) {
|
|
12452
|
+
result = result.s;
|
|
12453
|
+
} else {
|
|
12454
|
+
stage = 1;
|
|
12455
|
+
break;
|
|
12456
|
+
}
|
|
12457
|
+
}
|
|
12458
|
+
if (update) {
|
|
12459
|
+
var updateValue = update();
|
|
12460
|
+
if (updateValue && updateValue.then && !_isSettledPact$1(updateValue)) {
|
|
12461
|
+
stage = 2;
|
|
12462
|
+
break;
|
|
12463
|
+
}
|
|
12464
|
+
}
|
|
12465
|
+
}
|
|
12466
|
+
var pact = new _Pact$1();
|
|
12467
|
+
var reject = _settle$1.bind(null, pact, 2);
|
|
12468
|
+
(stage === 0 ? shouldContinue.then(_resumeAfterTest) : stage === 1 ? result.then(_resumeAfterBody) : updateValue.then(_resumeAfterUpdate)).then(void 0, reject);
|
|
12469
|
+
return pact;
|
|
12470
|
+
function _resumeAfterBody(value) {
|
|
12471
|
+
result = value;
|
|
12472
|
+
do {
|
|
12473
|
+
if (update) {
|
|
12474
|
+
updateValue = update();
|
|
12475
|
+
if (updateValue && updateValue.then && !_isSettledPact$1(updateValue)) {
|
|
12476
|
+
updateValue.then(_resumeAfterUpdate).then(void 0, reject);
|
|
12477
|
+
return;
|
|
12478
|
+
}
|
|
12479
|
+
}
|
|
12480
|
+
shouldContinue = test();
|
|
12481
|
+
if (!shouldContinue || _isSettledPact$1(shouldContinue) && !shouldContinue.v) {
|
|
12482
|
+
_settle$1(pact, 1, result);
|
|
12483
|
+
return;
|
|
12484
|
+
}
|
|
12485
|
+
if (shouldContinue.then) {
|
|
12486
|
+
shouldContinue.then(_resumeAfterTest).then(void 0, reject);
|
|
12487
|
+
return;
|
|
12488
|
+
}
|
|
12489
|
+
result = body();
|
|
12490
|
+
if (_isSettledPact$1(result)) {
|
|
12491
|
+
result = result.v;
|
|
12492
|
+
}
|
|
12493
|
+
} while (!result || !result.then);
|
|
12494
|
+
result.then(_resumeAfterBody).then(void 0, reject);
|
|
12495
|
+
}
|
|
12496
|
+
function _resumeAfterTest(shouldContinue) {
|
|
12497
|
+
if (shouldContinue) {
|
|
12498
|
+
result = body();
|
|
12499
|
+
if (result && result.then) {
|
|
12500
|
+
result.then(_resumeAfterBody).then(void 0, reject);
|
|
12501
|
+
} else {
|
|
12502
|
+
_resumeAfterBody(result);
|
|
12503
|
+
}
|
|
12504
|
+
} else {
|
|
12505
|
+
_settle$1(pact, 1, result);
|
|
12506
|
+
}
|
|
12507
|
+
}
|
|
12508
|
+
function _resumeAfterUpdate() {
|
|
12509
|
+
if (shouldContinue = test()) {
|
|
12510
|
+
if (shouldContinue.then) {
|
|
12511
|
+
shouldContinue.then(_resumeAfterTest).then(void 0, reject);
|
|
12512
|
+
} else {
|
|
12513
|
+
_resumeAfterTest(shouldContinue);
|
|
12514
|
+
}
|
|
12515
|
+
} else {
|
|
12516
|
+
_settle$1(pact, 1, result);
|
|
12517
|
+
}
|
|
12518
|
+
}
|
|
12519
|
+
}
|
|
12520
|
+
function _catch$2(body, recover) {
|
|
12521
|
+
try {
|
|
12522
|
+
var result = body();
|
|
12523
|
+
} catch (e) {
|
|
12524
|
+
return recover(e);
|
|
12525
|
+
}
|
|
12526
|
+
if (result && result.then) {
|
|
12527
|
+
return result.then(void 0, recover);
|
|
12528
|
+
}
|
|
12529
|
+
return result;
|
|
12530
|
+
}
|
|
12531
|
+
var ExolixSwapProvider = /*#__PURE__*/function (_SwapProvider) {
|
|
12532
|
+
_inheritsLoose(ExolixSwapProvider, _SwapProvider);
|
|
12533
|
+
function ExolixSwapProvider(apiKeysProxyUrl, cache, customCoinBuilder, useRestrictedCoinsSet, apiKey) {
|
|
12534
|
+
var _this;
|
|
12535
|
+
if (customCoinBuilder === void 0) {
|
|
12536
|
+
customCoinBuilder = function customCoinBuilder(coin, network) {
|
|
12537
|
+
return null;
|
|
12538
|
+
};
|
|
12539
|
+
}
|
|
12540
|
+
if (useRestrictedCoinsSet === void 0) {
|
|
12541
|
+
useRestrictedCoinsSet = true;
|
|
12542
|
+
}
|
|
12543
|
+
if (apiKey === void 0) {
|
|
12544
|
+
apiKey = "";
|
|
12545
|
+
}
|
|
12546
|
+
_this = _SwapProvider.call(this, "exolix", cache, customCoinBuilder, useRestrictedCoinsSet, false, true) || this;
|
|
12547
|
+
_this.axiosGetPreset = {
|
|
12548
|
+
headers: _this.headers,
|
|
12549
|
+
validateStatus: function validateStatus(responseCode) {
|
|
12550
|
+
return [200, 201, 404].find(function (code) {
|
|
12551
|
+
return code === responseCode;
|
|
12552
|
+
});
|
|
12553
|
+
}
|
|
12554
|
+
};
|
|
12555
|
+
_this._partners = [];
|
|
12556
|
+
_this._URL = apiKey ? "https://exolix.com/api/v2" : apiKeysProxyUrl + "/" + _this.id;
|
|
12557
|
+
_this.COINS_EXPIRATION_TIME_MS = 5 * 60 * 1000;
|
|
12558
|
+
_this.coinsLastUpdateTimestamp = null;
|
|
12559
|
+
_this.headers = apiKey ? {
|
|
12560
|
+
Authorization: "Bearer " + apiKey
|
|
12561
|
+
} : {};
|
|
12562
|
+
return _this;
|
|
12563
|
+
}
|
|
12564
|
+
var _proto = ExolixSwapProvider.prototype;
|
|
12565
|
+
_proto.getSwapCreationInfoTtlMs = function getSwapCreationInfoTtlMs() {
|
|
12566
|
+
return 110000;
|
|
12567
|
+
};
|
|
12568
|
+
_proto._fetchSupportedCurrenciesIfNeeded = function _fetchSupportedCurrenciesIfNeeded() {
|
|
12569
|
+
try {
|
|
12570
|
+
var _exit;
|
|
12571
|
+
var _this2 = this;
|
|
12572
|
+
var loggerSource = "_fetchSupportedCurrenciesIfNeeded";
|
|
12573
|
+
var pageSize = 100;
|
|
12574
|
+
return Promise.resolve(_catch$2(function () {
|
|
12575
|
+
if (_this2._shouldCoinsListBeLoaded()) {
|
|
12576
|
+
var _temp2 = function _temp2(_result) {
|
|
12577
|
+
if (_exit) return _result;
|
|
12578
|
+
_this2._supportedCoins = _allCoins.map(function (item) {
|
|
12579
|
+
var code = item.code.toUpperCase();
|
|
12580
|
+
if (!Array.isArray(item.networks)) return [];
|
|
12581
|
+
return item.networks.map(function (networkDetails) {
|
|
12582
|
+
var network = networkDetails.network;
|
|
12583
|
+
var networkShortAdaptive = networkDetails.shortName === "" || !(networkDetails != null && networkDetails.shortName) ? networkDetails.network : networkDetails.shortName;
|
|
12584
|
+
var coin = _this2._customCoinBuilder != null ? _this2._customCoinBuilder(code, code !== network ? networkShortAdaptive : "") : null;
|
|
12585
|
+
if (!coin && !_this2.useRestrictedCoinsSet) {
|
|
12586
|
+
var name = item.name;
|
|
12587
|
+
var ticker = toRabbitTicker(code, code === network ? "" : networkShortAdaptive);
|
|
12588
|
+
var defaultDecimalPlacesForCoinNotSupportedOOB = DEFAULT_CRYPTO_DECIMAL_COUNT;
|
|
12589
|
+
var defaultMinConfirmationsForCoinNotSupportedOOB = 1;
|
|
12590
|
+
coin = new Coin(name, ticker, code, defaultDecimalPlacesForCoinNotSupportedOOB, null, "", null, null, defaultMinConfirmationsForCoinNotSupportedOOB, null, [], 60000, null, code !== network ? new Protocol(networkShortAdaptive) : null, null, false);
|
|
12591
|
+
}
|
|
12592
|
+
if (coin) {
|
|
12593
|
+
var _networkDetails$memoN, _networkDetails$addre;
|
|
12594
|
+
return new SwapProviderCoinInfo(coin, item.code, network, !!networkDetails.memoNeeded, (_networkDetails$memoN = networkDetails.memoName) != null ? _networkDetails$memoN : null, 0, item.icon ? item.icon : FALLBACK_ASSET_ICON_URL, true, true, (_networkDetails$addre = networkDetails.addressRegex) != null ? _networkDetails$addre : null, true);
|
|
12595
|
+
}
|
|
12596
|
+
return [];
|
|
12597
|
+
});
|
|
12598
|
+
}).flat();
|
|
12599
|
+
_this2._supportedCoinsLastUpdateTimestamp = Date.now();
|
|
12600
|
+
_this2._putPopularCoinsFirst();
|
|
12601
|
+
return Promise.resolve(_SwapProvider.prototype._fetchSupportedCurrenciesIfNeeded.call(_this2)).then(function () {});
|
|
12602
|
+
};
|
|
12603
|
+
var _interrupt;
|
|
12604
|
+
var page = 1;
|
|
12605
|
+
var _allCoins = [];
|
|
12606
|
+
var _temp = _for(function () {
|
|
12607
|
+
return !(_interrupt || _exit);
|
|
12608
|
+
}, void 0, function () {
|
|
12609
|
+
return Promise.resolve(axios__default["default"].get(_this2._URL + "/currencies", _extends({}, _this2.axiosGetPreset, {
|
|
12610
|
+
params: {
|
|
12611
|
+
withNetworks: true,
|
|
12612
|
+
page: page,
|
|
12613
|
+
size: pageSize
|
|
12614
|
+
}
|
|
12615
|
+
}))).then(function (responseRaw) {
|
|
12616
|
+
var response = responseRaw == null ? void 0 : responseRaw.data;
|
|
12617
|
+
|
|
12618
|
+
// Validating the response
|
|
12619
|
+
if (responseRaw.status !== 200 || !response || typeof (response == null ? void 0 : response.data) !== "object" || typeof (response == null ? void 0 : response.count) !== "number" || (response == null ? void 0 : response.count) < 1 || (response == null ? void 0 : response.count) > 1000 || typeof (response == null ? void 0 : response.errors) === "object") {
|
|
12620
|
+
var errorMessages = response != null && response.errors ? ". Errors - " + Object.keys(response == null ? void 0 : response.errors).map(function (errorCode) {
|
|
12621
|
+
return errorCode + ": " + (response == null ? void 0 : response.errors[errorCode]);
|
|
12622
|
+
}).join(", ") : "";
|
|
12623
|
+
throw new Error("Failed to load the currencies list for Exolix" + errorMessages);
|
|
12624
|
+
}
|
|
12625
|
+
_allCoins.push.apply(_allCoins, response.data);
|
|
12626
|
+
if (page >= Math.floor(response.count / pageSize)) {
|
|
12627
|
+
_interrupt = 1;
|
|
12628
|
+
return;
|
|
12629
|
+
}
|
|
12630
|
+
page++;
|
|
12631
|
+
});
|
|
12632
|
+
});
|
|
12633
|
+
return _temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp);
|
|
12634
|
+
}
|
|
12635
|
+
}, function (e) {
|
|
12636
|
+
improveAndRethrow(e, loggerSource);
|
|
12637
|
+
}));
|
|
12638
|
+
} catch (e) {
|
|
12639
|
+
return Promise.reject(e);
|
|
12640
|
+
}
|
|
12641
|
+
};
|
|
12642
|
+
_proto.getSwapInfo = function getSwapInfo(fromCoin, toCoin, amountCoins, fixed, fromCoinToUsdRate, amountIsToReceive, bannedPartners) {
|
|
12643
|
+
if (fixed === void 0) {
|
|
12644
|
+
fixed = false;
|
|
12645
|
+
}
|
|
12646
|
+
if (amountIsToReceive === void 0) {
|
|
12647
|
+
amountIsToReceive = false;
|
|
12648
|
+
}
|
|
12649
|
+
try {
|
|
12650
|
+
var _this3 = this;
|
|
12651
|
+
var loggerSource = "getSwapInfo";
|
|
12652
|
+
var validateAndProcessLimits = function validateAndProcessLimits(fromAmount, toAmount, fromCoin, toCoin, amountCoins, amountIsToReceive, minAmount, maxAmount, rate, status) {
|
|
12653
|
+
var min;
|
|
12654
|
+
var max;
|
|
12655
|
+
var returnObject;
|
|
12656
|
+
if (typeof minAmount === "number" && minAmount > 0) min = AmountUtils.trim(minAmount, amountIsToReceive ? toCoin.digits : fromCoin.digits);
|
|
12657
|
+
if (typeof maxAmount === "number" && maxAmount > 0) max = AmountUtils.trim(maxAmount, amountIsToReceive ? toCoin.digits : fromCoin.digits);
|
|
12658
|
+
if (status !== 200 || typeof fromAmount !== "number" || typeof toAmount !== "number" || typeof minAmount !== "number" || typeof maxAmount !== "number" || BigNumber__default["default"](rate).lte("0") || BigNumber__default["default"](fromAmount).lte("0") || BigNumber__default["default"](toAmount).lte("0")) {
|
|
12659
|
+
var reason = SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED;
|
|
12660
|
+
if (min && BigNumber__default["default"](amountCoins).lt(min)) {
|
|
12661
|
+
reason = SwapProvider.NO_SWAPS_REASONS.TOO_LOW;
|
|
12662
|
+
} else if (max && BigNumber__default["default"](amountCoins).gt(max)) {
|
|
12663
|
+
reason = SwapProvider.NO_SWAPS_REASONS.TOO_HIGH;
|
|
12664
|
+
}
|
|
12665
|
+
returnObject = {
|
|
12666
|
+
result: false,
|
|
12667
|
+
reason: reason,
|
|
12668
|
+
smallestMin: min,
|
|
12669
|
+
greatestMax: max
|
|
12670
|
+
};
|
|
12671
|
+
}
|
|
12672
|
+
return [returnObject, min, max];
|
|
12673
|
+
};
|
|
12674
|
+
return Promise.resolve(_catch$2(function () {
|
|
12675
|
+
if (!(fromCoin instanceof Coin) || !(toCoin instanceof Coin) || typeof amountCoins !== "string" || BigNumber__default["default"](amountCoins).lt("0") || fixed !== null && typeof fixed !== "boolean") {
|
|
12676
|
+
throw new Error("Wrong input params: " + amountCoins + " " + fromCoin.ticker + " -> " + toCoin.ticker + ", " + (fromCoin instanceof Coin) + ", " + (toCoin instanceof Coin) + ", " + typeof fixed + " " + fixed + ", " + amountIsToReceive);
|
|
12677
|
+
}
|
|
12678
|
+
var fromCoinDetails = _this3._supportedCoins.find(function (i) {
|
|
12679
|
+
var _i$coin;
|
|
12680
|
+
return ((_i$coin = i.coin) == null ? void 0 : _i$coin.ticker) === (fromCoin == null ? void 0 : fromCoin.ticker);
|
|
12681
|
+
});
|
|
12682
|
+
var toCoinDetails = _this3._supportedCoins.find(function (i) {
|
|
12683
|
+
var _i$coin2;
|
|
12684
|
+
return ((_i$coin2 = i.coin) == null ? void 0 : _i$coin2.ticker) === (toCoin == null ? void 0 : toCoin.ticker);
|
|
12685
|
+
});
|
|
12686
|
+
return !fromCoinDetails || !toCoinDetails || !fromCoinDetails.deposit || !fromCoinDetails.isAvailable || !toCoinDetails.withdrawal || !toCoinDetails.isAvailable ? {
|
|
12687
|
+
result: false,
|
|
12688
|
+
reason: SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED
|
|
12689
|
+
} : Promise.resolve(axios__default["default"].get(_this3._URL + "/rate", _extends({}, _this3.axiosGetPreset, {
|
|
12690
|
+
params: {
|
|
12691
|
+
coinFrom: fromCoinDetails.code,
|
|
12692
|
+
networkFrom: fromCoinDetails.network,
|
|
12693
|
+
coinTo: toCoinDetails.code,
|
|
12694
|
+
networkTo: toCoinDetails.network,
|
|
12695
|
+
amount: amountIsToReceive ? undefined : amountCoins,
|
|
12696
|
+
withdrawalAmount: amountIsToReceive ? amountCoins : undefined,
|
|
12697
|
+
rateType: fixed ? "fixed" : "float"
|
|
12698
|
+
}
|
|
12699
|
+
}))).then(function (response) {
|
|
12700
|
+
Logger.log("Retrieved " + (response == null ? void 0 : response.data), loggerSource);
|
|
12701
|
+
if (typeof (response == null ? void 0 : response.data) !== "object") {
|
|
12702
|
+
Logger.log("Swap response didn't include the data object " + safeStringify(e), loggerSource);
|
|
12703
|
+
return {
|
|
12704
|
+
result: false,
|
|
12705
|
+
reason: SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED
|
|
12706
|
+
};
|
|
12707
|
+
}
|
|
12708
|
+
var data = response == null ? void 0 : response.data;
|
|
12709
|
+
var _validateAndProcessLi = validateAndProcessLimits(data == null ? void 0 : data.fromAmount, data == null ? void 0 : data.toAmount, fromCoin, toCoin, amountCoins, amountIsToReceive, data == null ? void 0 : data.minAmount, data == null ? void 0 : data.maxAmount, data == null ? void 0 : data.rate, response == null ? void 0 : response.status),
|
|
12710
|
+
returnObject = _validateAndProcessLi[0],
|
|
12711
|
+
min = _validateAndProcessLi[1],
|
|
12712
|
+
max = _validateAndProcessLi[2];
|
|
12713
|
+
if (returnObject) return returnObject;
|
|
12714
|
+
if (min && max & BigNumber__default["default"](max).lt(min)) {
|
|
12715
|
+
Logger.log("Exolix swap info failed, max limit is below the min one. " + safeStringify(response), loggerSource);
|
|
12716
|
+
return {
|
|
12717
|
+
result: false,
|
|
12718
|
+
reason: SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED
|
|
12719
|
+
};
|
|
12720
|
+
}
|
|
12721
|
+
var rate = amountIsToReceive ? BigNumber__default["default"](amountCoins).div(data.fromAmount) : BigNumber__default["default"](data.toAmount).div(amountCoins);
|
|
12722
|
+
return {
|
|
12723
|
+
result: true,
|
|
12724
|
+
min: min != null ? min : null,
|
|
12725
|
+
max: max != null ? max : null,
|
|
12726
|
+
smallestMin: min != null ? min : null,
|
|
12727
|
+
greatestMax: max != null ? max : null,
|
|
12728
|
+
rate: AmountUtils.trim(rate, _this3._maxRateDigits),
|
|
12729
|
+
durationMinutesRange: null,
|
|
12730
|
+
fixed: fixed,
|
|
12731
|
+
rawSwapData: data,
|
|
12732
|
+
isRefundAddressRequired: false
|
|
12733
|
+
};
|
|
12734
|
+
});
|
|
12735
|
+
}, function (e) {
|
|
12736
|
+
var _e$response, _e$response2, _e$response3, _e$response4, _e$response5, _e$response6;
|
|
12737
|
+
var status = e == null || (_e$response = e.response) == null ? void 0 : _e$response.status;
|
|
12738
|
+
var data = e == null || (_e$response2 = e.response) == null ? void 0 : _e$response2.data;
|
|
12739
|
+
if (status === 429) {
|
|
12740
|
+
return {
|
|
12741
|
+
result: false,
|
|
12742
|
+
reason: SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED
|
|
12743
|
+
};
|
|
12744
|
+
}
|
|
12745
|
+
var _validateAndProcessLi2 = validateAndProcessLimits(data == null ? void 0 : data.fromAmount, data == null ? void 0 : data.toAmount, fromCoin, toCoin, amountCoins, amountIsToReceive, data == null ? void 0 : data.minAmount, data == null ? void 0 : data.maxAmount, data == null ? void 0 : data.rate, e == null || (_e$response3 = e.response) == null ? void 0 : _e$response3.status),
|
|
12746
|
+
returnObject = _validateAndProcessLi2[0],
|
|
12747
|
+
min = _validateAndProcessLi2[1],
|
|
12748
|
+
max = _validateAndProcessLi2[2];
|
|
12749
|
+
if (returnObject) return returnObject;
|
|
12750
|
+
if ((e == null || (_e$response4 = e.response) == null ? void 0 : _e$response4.status) === 400 || e != null && (_e$response5 = e.response) != null && (_e$response5 = _e$response5.data) != null && _e$response5.error || e != null && (_e$response6 = e.response) != null && (_e$response6 = _e$response6.data) != null && _e$response6.errors) {
|
|
12751
|
+
var _e$response7, _e$response8, _e$response10;
|
|
12752
|
+
var errorMessages = e != null && (_e$response7 = e.response) != null && (_e$response7 = _e$response7.data) != null && _e$response7.errors ? ". Errors - " + Object.keys(e == null || (_e$response8 = e.response) == null || (_e$response8 = _e$response8.data) == null ? void 0 : _e$response8.errors).map(function (errorCode) {
|
|
12753
|
+
var _e$response9;
|
|
12754
|
+
return errorCode + ": " + (e == null || (_e$response9 = e.response) == null || (_e$response9 = _e$response9.data) == null ? void 0 : _e$response9.errors[errorCode]);
|
|
12755
|
+
}).join(", ") : "";
|
|
12756
|
+
Logger.log("Failed to estimate swap for Exolix (" + (e == null || (_e$response10 = e.response) == null ? void 0 : _e$response10.status) + ")" + errorMessages + (" " + safeStringify(e)), loggerSource);
|
|
12757
|
+
} else {
|
|
12758
|
+
Logger.log("Internal error when getting swap options " + safeStringify(e), loggerSource);
|
|
12759
|
+
}
|
|
12760
|
+
improveAndRethrow(e, loggerSource);
|
|
12761
|
+
}));
|
|
12762
|
+
} catch (e) {
|
|
12763
|
+
return Promise.reject(e);
|
|
12764
|
+
}
|
|
12765
|
+
};
|
|
12766
|
+
_proto.createSwap = function createSwap(fromCoin, toCoin, amount, toAddress, refundAddress, proprietarySwapEstimationData, clientIpAddress, fixed, toCurrencyExtraId, refundExtraId, amountIsToReceive) {
|
|
12767
|
+
if (toCurrencyExtraId === void 0) {
|
|
12768
|
+
toCurrencyExtraId = "";
|
|
12769
|
+
}
|
|
12770
|
+
if (refundExtraId === void 0) {
|
|
12771
|
+
refundExtraId = "";
|
|
12772
|
+
}
|
|
12773
|
+
if (amountIsToReceive === void 0) {
|
|
12774
|
+
amountIsToReceive = false;
|
|
12775
|
+
}
|
|
12776
|
+
try {
|
|
12777
|
+
var _this4 = this;
|
|
12778
|
+
var loggerSource = "createSwap";
|
|
12779
|
+
return Promise.resolve(_catch$2(function () {
|
|
12780
|
+
if (!(fromCoin instanceof Coin) || !(toCoin instanceof Coin) || typeof amount !== "string" || typeof toAddress !== "string" || typeof refundAddress !== "string" || typeof fixed != "boolean") {
|
|
12781
|
+
throw new Error("Invalid input: " + fromCoin + " " + toCoin + " " + amount + " " + toAddress + " " + refundAddress + " " + fixed);
|
|
12782
|
+
}
|
|
12783
|
+
return Promise.resolve(_this4._fetchSupportedCurrenciesIfNeeded()).then(function () {
|
|
12784
|
+
var _toCurrencyExtraId, _refundExtraId;
|
|
12785
|
+
var fromCoinExtended = _this4._supportedCoins.find(function (item) {
|
|
12786
|
+
return item.coin.ticker == fromCoin.ticker;
|
|
12787
|
+
});
|
|
12788
|
+
var toCoinExtended = _this4._supportedCoins.find(function (item) {
|
|
12789
|
+
return item.coin.ticker == toCoin.ticker;
|
|
12790
|
+
});
|
|
12791
|
+
if (!fromCoinExtended || !toCoinExtended) {
|
|
12792
|
+
throw new Error("Failed to find coin details for: " + fromCoin.ticker + " -> " + toCoin.ticker);
|
|
12793
|
+
}
|
|
12794
|
+
var fromCurrencyHasExtraId = fromCoinExtended.hasExtraId;
|
|
12795
|
+
var toCurrencyHasExtraId = toCoinExtended.hasExtraId;
|
|
12796
|
+
var requestData = {
|
|
12797
|
+
coinFrom: fromCoinExtended.code,
|
|
12798
|
+
networkFrom: fromCoinExtended.network,
|
|
12799
|
+
coinTo: toCoinExtended.code,
|
|
12800
|
+
networkTo: toCoinExtended.network,
|
|
12801
|
+
amount: amountIsToReceive ? undefined : amount,
|
|
12802
|
+
withdrawalAmount: amountIsToReceive ? amount : undefined,
|
|
12803
|
+
withdrawalAddress: toAddress,
|
|
12804
|
+
withdrawalExtraId: toCurrencyHasExtraId ? (_toCurrencyExtraId = toCurrencyExtraId) != null ? _toCurrencyExtraId : "" : "",
|
|
12805
|
+
refundAddress: refundAddress,
|
|
12806
|
+
refundExtraId: fromCurrencyHasExtraId ? (_refundExtraId = refundExtraId) != null ? _refundExtraId : "" : "",
|
|
12807
|
+
rateType: fixed ? "fixed" : "float"
|
|
12808
|
+
};
|
|
12809
|
+
Logger.log("Sending create request: " + safeStringify(requestData), loggerSource);
|
|
12810
|
+
return Promise.resolve(axios__default["default"].post(_this4._URL + "/transactions", requestData, _this4.axiosGetPreset)).then(function (response) {
|
|
12811
|
+
var _result$withdrawalExt;
|
|
12812
|
+
var result = response == null ? void 0 : response.data;
|
|
12813
|
+
Logger.log("Creation result " + safeStringify(result), loggerSource);
|
|
12814
|
+
if (!(result != null && result.id) || typeof (result == null ? void 0 : result.id) !== "string" || typeof (result == null ? void 0 : result.amount) !== "number" || typeof (result == null ? void 0 : result.amountTo) !== "number" || typeof (result == null ? void 0 : result.depositAddress) !== "string" || typeof (result == null ? void 0 : result.withdrawalAddress) !== "string" || !((result == null ? void 0 : result.rateType) === "fixed" || (result == null ? void 0 : result.rateType) === "float")) {
|
|
12815
|
+
var errorMessage;
|
|
12816
|
+
errorMessage = result != null && result.id ? "Swap was created but the data was incorrect: " + safeStringify(response) : "Swap creation failed, API response: " + safeStringify(response);
|
|
12817
|
+
Logger.log(errorMessage, loggerSource);
|
|
12818
|
+
throw new Error(errorMessage);
|
|
12819
|
+
}
|
|
12820
|
+
var rate;
|
|
12821
|
+
if (typeof rate !== "number" || BigNumber__default["default"](result == null ? void 0 : result.rate).isZero()) {
|
|
12822
|
+
rate = BigNumber__default["default"](result == null ? void 0 : result.amountTo).div(result == null ? void 0 : result.amount);
|
|
12823
|
+
} else {
|
|
12824
|
+
rate = BigNumber__default["default"](result == null ? void 0 : result.rate);
|
|
12825
|
+
}
|
|
12826
|
+
return {
|
|
12827
|
+
result: true,
|
|
12828
|
+
swapId: result == null ? void 0 : result.id,
|
|
12829
|
+
fromCoin: fromCoin,
|
|
12830
|
+
fromAmount: AmountUtils.trim(result == null ? void 0 : result.amount, fromCoin.digits),
|
|
12831
|
+
fromAddress: result == null ? void 0 : result.depositAddress,
|
|
12832
|
+
toCoin: toCoin,
|
|
12833
|
+
toAmount: AmountUtils.trim(result == null ? void 0 : result.amountTo, toCoin.digits),
|
|
12834
|
+
toAddress: result == null ? void 0 : result.withdrawalAddress,
|
|
12835
|
+
fromCurrencyExtraId: (_result$withdrawalExt = result == null ? void 0 : result.withdrawalExtraId) != null ? _result$withdrawalExt : "",
|
|
12836
|
+
rate: AmountUtils.trim(rate, _this4._maxRateDigits),
|
|
12837
|
+
fixed: (result == null ? void 0 : result.rateType) === "fixed"
|
|
12838
|
+
};
|
|
12839
|
+
});
|
|
12840
|
+
});
|
|
12841
|
+
}, function (e) {
|
|
12842
|
+
var _e$response11, _e$response12, _e$response13, _e$response14, _e$response15, _e$response17;
|
|
12843
|
+
var composeFailResult = function composeFailResult(reason) {
|
|
12844
|
+
return {
|
|
12845
|
+
result: false,
|
|
12846
|
+
reason: reason
|
|
12847
|
+
};
|
|
12848
|
+
};
|
|
12849
|
+
if ((e == null || (_e$response11 = e.response) == null ? void 0 : _e$response11.status) === 400 || e != null && (_e$response12 = e.response) != null && (_e$response12 = _e$response12.data) != null && (_e$response12 = _e$response12.message) != null && _e$response12.includes("Amount to exchange is higher") || e != null && (_e$response13 = e.response) != null && (_e$response13 = _e$response13.data) != null && (_e$response13 = _e$response13.message) != null && _e$response13.includes("Amount to exchange is below")) {
|
|
12850
|
+
return composeFailResult(SwapProvider.CREATION_FAIL_REASONS.RETRIABLE_FAIL);
|
|
12851
|
+
}
|
|
12852
|
+
if ((e == null || (_e$response14 = e.response) == null ? void 0 : _e$response14.status) === 422 && (e == null || (_e$response15 = e.response) == null ? void 0 : _e$response15.data.error) === "Such exchange pair is not available") {
|
|
12853
|
+
var _e$response16;
|
|
12854
|
+
Logger.log("Unable to create a swap with a not available currency " + (e == null || (_e$response16 = e.response) == null ? void 0 : _e$response16.data), loggerSource);
|
|
12855
|
+
return composeFailResult(SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED);
|
|
12856
|
+
}
|
|
12857
|
+
if ((e == null || (_e$response17 = e.response) == null ? void 0 : _e$response17.status) === 429) {
|
|
12858
|
+
var _e$response18;
|
|
12859
|
+
Logger.log("Returning fail - RPS limit exceeded " + (e == null || (_e$response18 = e.response) == null ? void 0 : _e$response18.data), loggerSource);
|
|
12860
|
+
return composeFailResult(SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED);
|
|
12861
|
+
}
|
|
12862
|
+
Logger.log("Internal error for swap: " + safeStringify(e), loggerSource);
|
|
12863
|
+
improveAndRethrow(e, loggerSource);
|
|
12864
|
+
}));
|
|
12865
|
+
} catch (e) {
|
|
12866
|
+
return Promise.reject(e);
|
|
12867
|
+
}
|
|
12868
|
+
};
|
|
12869
|
+
_proto.getExistingSwapsDetailsAndStatus = function getExistingSwapsDetailsAndStatus(swapIds) {
|
|
12870
|
+
try {
|
|
12871
|
+
var _this5 = this;
|
|
12872
|
+
var loggerSource = "getExistingSwapsDetailsAndStatus";
|
|
12873
|
+
return Promise.resolve(_catch$2(function () {
|
|
12874
|
+
if (swapIds.find(function (id) {
|
|
12875
|
+
return typeof id !== "string";
|
|
12876
|
+
})) {
|
|
12877
|
+
throw new Error("Swap id is not string: " + safeStringify(swapIds));
|
|
12878
|
+
}
|
|
12879
|
+
var getSwap = function getSwap(swapId) {
|
|
12880
|
+
try {
|
|
12881
|
+
return Promise.resolve(_catch$2(function () {
|
|
12882
|
+
return Promise.resolve(axios__default["default"].get(_this5._URL + "/transactions/" + swapId, _this5.axiosGetPreset));
|
|
12883
|
+
}, function (error) {
|
|
12884
|
+
var _error$response;
|
|
12885
|
+
if ((error == null || (_error$response = error.response) == null ? void 0 : _error$response.status) === 404) return [];
|
|
12886
|
+
throw error;
|
|
12887
|
+
}));
|
|
12888
|
+
} catch (e) {
|
|
12889
|
+
return Promise.reject(e);
|
|
12890
|
+
}
|
|
12891
|
+
};
|
|
12892
|
+
return Promise.resolve(Promise.all(swapIds.map(function (swapId) {
|
|
12893
|
+
return getSwap(swapId);
|
|
12894
|
+
}))).then(function (responses) {
|
|
12895
|
+
var fetchedSwaps = responses.flat();
|
|
12896
|
+
Logger.log("All swaps RAW: " + JSON.stringify(fetchedSwaps.map(function (r) {
|
|
12897
|
+
return r.data;
|
|
12898
|
+
})), loggerSource);
|
|
12899
|
+
var swaps = fetchedSwaps.map(function (r) {
|
|
12900
|
+
return r.data;
|
|
12901
|
+
}).map(function (swap, index) {
|
|
12902
|
+
var _this5$_supportedCoin, _this5$_supportedCoin2, _swap$depositExtraId, _swap$withdrawalExtra, _swap$refundExtraId;
|
|
12903
|
+
var fromCoin = (_this5$_supportedCoin = _this5._supportedCoins.find(function (i) {
|
|
12904
|
+
return i.code === swap.coinFrom.coinCode && i.network === swap.coinFrom.network;
|
|
12905
|
+
})) == null ? void 0 : _this5$_supportedCoin.coin;
|
|
12906
|
+
var toCoin = (_this5$_supportedCoin2 = _this5._supportedCoins.find(function (i) {
|
|
12907
|
+
return i.code === swap.coinTo.coinCode && i.network === swap.coinTo.network;
|
|
12908
|
+
})) == null ? void 0 : _this5$_supportedCoin2.coin;
|
|
12909
|
+
if (!fromCoin || !toCoin) {
|
|
12910
|
+
return []; // We skip swaps with not supported coins for now
|
|
12911
|
+
}
|
|
12912
|
+
var toUtcTimestamp = function toUtcTimestamp(timeStr) {
|
|
12913
|
+
return Date.parse(timeStr.match(/.+[Zz]$/) ? timeStr : timeStr + "Z");
|
|
12914
|
+
};
|
|
12915
|
+
var createdAt = toUtcTimestamp(swap.createdAt);
|
|
12916
|
+
var expiresAt = createdAt + 25 * 60 * 1000; // Hack with hard-coded 25 minutes
|
|
12917
|
+
var isExpiredByTime = expiresAt < Date.now();
|
|
12918
|
+
var status = _this5._mapExolixStatusToRabbitStatus(swap.status, isExpiredByTime);
|
|
12919
|
+
var toDigits = status === SwapProvider.SWAP_STATUSES.REFUNDED ? fromCoin.digits : toCoin.digits;
|
|
12920
|
+
return new ExistingSwap(swapIds[index], status, createdAt, expiresAt, -1, AmountUtils.trim(swap.rate, _this5._maxRateDigits), (swap == null ? void 0 : swap.rateType) === "fixed", swap.refundAddress, swap.depositAddress, fromCoin, AmountUtils.trim(swap.amount, fromCoin.digits), swap.hashIn.hash, swap.hashIn.link, toCoin, AmountUtils.trim(swap.amountTo, toDigits), swap.hashOut.hash, swap.hashOut.link, swap.withdrawalAddress, _this5.id, (_swap$depositExtraId = swap.depositExtraId) != null ? _swap$depositExtraId : null, (_swap$withdrawalExtra = swap.withdrawalExtraId) != null ? _swap$withdrawalExtra : null, (_swap$refundExtraId = swap.refundExtraId) != null ? _swap$refundExtraId : null);
|
|
12921
|
+
}).flat();
|
|
12922
|
+
Logger.log("Swap details result " + safeStringify(swaps), loggerSource);
|
|
12923
|
+
return {
|
|
12924
|
+
result: true,
|
|
12925
|
+
swaps: swaps
|
|
12926
|
+
};
|
|
12927
|
+
});
|
|
12928
|
+
}, function (e) {
|
|
12929
|
+
var _e$response19, _e$response20;
|
|
12930
|
+
Logger.logError(e, loggerSource, "Failed to get swap details. Error is: " + safeStringify(e));
|
|
12931
|
+
var composeFailResult = function composeFailResult(reason) {
|
|
12932
|
+
return {
|
|
12933
|
+
result: false,
|
|
12934
|
+
reason: reason
|
|
12935
|
+
};
|
|
12936
|
+
};
|
|
12937
|
+
var status = e == null || (_e$response19 = e.response) == null ? void 0 : _e$response19.status;
|
|
12938
|
+
var data = e == null || (_e$response20 = e.response) == null ? void 0 : _e$response20.data;
|
|
12939
|
+
if (status === 429) {
|
|
12940
|
+
Logger.log("Returning fail - RPS limit exceeded " + data, loggerSource);
|
|
12941
|
+
return composeFailResult(SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED);
|
|
12942
|
+
}
|
|
12943
|
+
improveAndRethrow(e, loggerSource);
|
|
12944
|
+
}));
|
|
12945
|
+
} catch (e) {
|
|
12946
|
+
return Promise.reject(e);
|
|
12947
|
+
}
|
|
12948
|
+
};
|
|
12949
|
+
_proto._mapExolixStatusToRabbitStatus = function _mapExolixStatusToRabbitStatus(status, isExpiredByTime) {
|
|
12950
|
+
switch (status) {
|
|
12951
|
+
case "wait":
|
|
12952
|
+
if (isExpiredByTime) {
|
|
12953
|
+
return SwapProvider.SWAP_STATUSES.EXPIRED;
|
|
12954
|
+
}
|
|
12955
|
+
return SwapProvider.SWAP_STATUSES.WAITING_FOR_PAYMENT;
|
|
12956
|
+
case "confirmation":
|
|
12957
|
+
return SwapProvider.SWAP_STATUSES.CONFIRMING;
|
|
12958
|
+
case "confirmed":
|
|
12959
|
+
return SwapProvider.SWAP_STATUSES.PAYMENT_RECEIVED;
|
|
12960
|
+
case "exchanging":
|
|
12961
|
+
return SwapProvider.SWAP_STATUSES.EXCHANGING;
|
|
12962
|
+
case "sending":
|
|
12963
|
+
return SwapProvider.SWAP_STATUSES.EXCHANGING;
|
|
12964
|
+
case "success":
|
|
12965
|
+
return SwapProvider.SWAP_STATUSES.COMPLETED;
|
|
12966
|
+
case "overdue":
|
|
12967
|
+
return SwapProvider.SWAP_STATUSES.EXPIRED;
|
|
12968
|
+
case "refunded":
|
|
12969
|
+
return SwapProvider.SWAP_STATUSES.REFUNDED;
|
|
12970
|
+
default:
|
|
12971
|
+
throw new Error("Unknown Exolix status: " + status);
|
|
12972
|
+
}
|
|
12973
|
+
};
|
|
12974
|
+
_proto.getPartnersList = function getPartnersList() {
|
|
12975
|
+
try {
|
|
12976
|
+
var _this6 = this;
|
|
12977
|
+
return Promise.resolve([new Partner(_this6.id, "Exolix", "https://storage.swapspace.co/static/9WRkfc_QCUUmOBTcvgC9p57l9.svg", null)]);
|
|
12978
|
+
} catch (e) {
|
|
12979
|
+
return Promise.reject(e);
|
|
12980
|
+
}
|
|
12981
|
+
};
|
|
12982
|
+
return ExolixSwapProvider;
|
|
12983
|
+
}(SwapProvider);
|
|
12984
|
+
|
|
12985
|
+
function _catch$1(body, recover) {
|
|
12986
|
+
try {
|
|
12987
|
+
var result = body();
|
|
12988
|
+
} catch (e) {
|
|
12989
|
+
return recover(e);
|
|
12990
|
+
}
|
|
12991
|
+
if (result && result.then) {
|
|
12992
|
+
return result.then(void 0, recover);
|
|
12993
|
+
}
|
|
12994
|
+
return result;
|
|
12995
|
+
}
|
|
12996
|
+
var _iteratorSymbol = typeof Symbol !== "undefined" ? Symbol.iterator || (Symbol.iterator = Symbol("Symbol.iterator")) : "@@iterator";
|
|
12997
|
+
function _settle(pact, state, value) {
|
|
12998
|
+
if (!pact.s) {
|
|
12999
|
+
if (value instanceof _Pact) {
|
|
13000
|
+
if (value.s) {
|
|
13001
|
+
if (state & 1) {
|
|
13002
|
+
state = value.s;
|
|
13003
|
+
}
|
|
13004
|
+
value = value.v;
|
|
13005
|
+
} else {
|
|
13006
|
+
value.o = _settle.bind(null, pact, state);
|
|
13007
|
+
return;
|
|
13008
|
+
}
|
|
13009
|
+
}
|
|
13010
|
+
if (value && value.then) {
|
|
13011
|
+
value.then(_settle.bind(null, pact, state), _settle.bind(null, pact, 2));
|
|
13012
|
+
return;
|
|
13013
|
+
}
|
|
13014
|
+
pact.s = state;
|
|
13015
|
+
pact.v = value;
|
|
13016
|
+
var observer = pact.o;
|
|
12334
13017
|
if (observer) {
|
|
12335
13018
|
observer(pact);
|
|
12336
13019
|
}
|
|
@@ -12506,7 +13189,7 @@
|
|
|
12506
13189
|
* So we are going to get some rate to be used as the default for the on-flight calculations before we get
|
|
12507
13190
|
* the exact rate (that should be retrieved by getSwapCreationInfo method) for a specific amount.
|
|
12508
13191
|
*/
|
|
12509
|
-
var defaultAmountUsd =
|
|
13192
|
+
var defaultAmountUsd = BigNumber.BigNumber("300");
|
|
12510
13193
|
return Promise.resolve(swapProvider.getCoinToUSDTRate(fromCoin)).then(function (coinUsdRate) {
|
|
12511
13194
|
var coinAmountForDefaultUsdAmount = AmountUtils.trim(coinUsdRate != null && coinUsdRate.result ? defaultAmountUsd.div(coinUsdRate == null ? void 0 : coinUsdRate.rate) : defaultAmountUsd, fromCoin.digits);
|
|
12512
13195
|
Logger.log("Init: " + coinAmountForDefaultUsdAmount + " " + fromCoin.ticker + "->" + toCoin.ticker, loggerSource);
|
|
@@ -12531,8 +13214,8 @@
|
|
|
12531
13214
|
var fiatRate = (_coinToCurrentFiatRat = coinToCurrentFiatRate) != null ? _coinToCurrentFiatRat : coinUsdRate == null ? void 0 : coinUsdRate.rate;
|
|
12532
13215
|
var fiatDecimals = (_fiatCurrencyDecimals = fiatCurrencyDecimals) != null ? _fiatCurrencyDecimals : FiatCurrenciesService.getCurrencyDecimalCountByCode("USD");
|
|
12533
13216
|
if (fiatRate != null) {
|
|
12534
|
-
fiatMin =
|
|
12535
|
-
fiatMax =
|
|
13217
|
+
fiatMin = BigNumber.BigNumber(details == null ? void 0 : details.smallestMin).times(fiatRate).toFixed(fiatDecimals);
|
|
13218
|
+
fiatMax = BigNumber.BigNumber(details == null ? void 0 : details.greatestMax).times(fiatRate).toFixed(fiatDecimals);
|
|
12536
13219
|
}
|
|
12537
13220
|
var result = {
|
|
12538
13221
|
result: true,
|
|
@@ -12607,7 +13290,7 @@
|
|
|
12607
13290
|
var remainingSwapIds = new Set(swapIds);
|
|
12608
13291
|
var failResults = [];
|
|
12609
13292
|
var _temp7 = _forOf(swapProviders, function (provider) {
|
|
12610
|
-
return Promise.resolve(provider.getExistingSwapsDetailsAndStatus(
|
|
13293
|
+
return Promise.resolve(provider.getExistingSwapsDetailsAndStatus(Array.from(remainingSwapIds))).then(function (result) {
|
|
12611
13294
|
var _temp6 = function () {
|
|
12612
13295
|
if (result.result) {
|
|
12613
13296
|
var _temp5 = function _temp5() {
|
|
@@ -12626,249 +13309,89 @@
|
|
|
12626
13309
|
var _temp2 = function () {
|
|
12627
13310
|
if (swap.status === SwapProvider.SWAP_STATUSES.REFUNDED) {
|
|
12628
13311
|
return Promise.resolve(provider.getCoinToUSDTRate(swap.fromCoin)).then(function (rate) {
|
|
12629
|
-
_extendedSwaps.push(ExistingSwapWithFiatData.fromExistingSwap(swap, (rate == null ? void 0 : rate.rate) != null ?
|
|
13312
|
+
_extendedSwaps.push(ExistingSwapWithFiatData.fromExistingSwap(swap, (rate == null ? void 0 : rate.rate) != null ? BigNumber.BigNumber(swap.fromAmount).times(rate.rate).toNumber() : null, (rate == null ? void 0 : rate.rate) != null ? BigNumber.BigNumber(swap.toAmount).times(rate.rate).toNumber() : null, "USD", FiatCurrenciesService.getCurrencyDecimalCountByCode("USD")));
|
|
12630
13313
|
});
|
|
12631
13314
|
} else {
|
|
12632
13315
|
return Promise.resolve(Promise.all([provider.getCoinToUSDTRate(swap.fromCoin), provider.getCoinToUSDTRate(swap.toCoin)])).then(function (_ref) {
|
|
12633
13316
|
var fromCoinFiatRate = _ref[0],
|
|
12634
13317
|
toCoinFiatRate = _ref[1];
|
|
12635
|
-
_extendedSwaps.push(ExistingSwapWithFiatData.fromExistingSwap(swap, (fromCoinFiatRate == null ? void 0 : fromCoinFiatRate.rate) != null ?
|
|
13318
|
+
_extendedSwaps.push(ExistingSwapWithFiatData.fromExistingSwap(swap, (fromCoinFiatRate == null ? void 0 : fromCoinFiatRate.rate) != null ? BigNumber.BigNumber(swap.fromAmount).times(fromCoinFiatRate.rate).toNumber() : null, (toCoinFiatRate == null ? void 0 : toCoinFiatRate.rate) != null ? BigNumber.BigNumber(swap.toAmount).times(toCoinFiatRate.rate).toNumber() : null, "USD", FiatCurrenciesService.getCurrencyDecimalCountByCode("USD")));
|
|
12636
13319
|
});
|
|
12637
13320
|
}
|
|
12638
13321
|
}();
|
|
12639
13322
|
return _temp2 && _temp2.then ? _temp2.then(_temp3) : _temp3(_temp2);
|
|
12640
13323
|
});
|
|
12641
13324
|
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;
|
|
12650
|
-
});
|
|
12651
|
-
return _temp7 && _temp7.then ? _temp7.then(_temp8) : _temp8(_temp7);
|
|
12652
|
-
}, function (e) {
|
|
12653
|
-
improveAndRethrow(e, "getExistingSwapsDetailsWithFiatAmounts");
|
|
12654
|
-
}));
|
|
12655
|
-
} catch (e) {
|
|
12656
|
-
return Promise.reject(e);
|
|
12657
|
-
}
|
|
12658
|
-
};
|
|
12659
|
-
return SwapUtils;
|
|
12660
|
-
}();
|
|
12661
|
-
|
|
12662
|
-
function _catch(body, recover) {
|
|
12663
|
-
try {
|
|
12664
|
-
var result = body();
|
|
12665
|
-
} catch (e) {
|
|
12666
|
-
return recover(e);
|
|
12667
|
-
}
|
|
12668
|
-
if (result && result.then) {
|
|
12669
|
-
return result.then(void 0, recover);
|
|
12670
|
-
}
|
|
12671
|
-
return result;
|
|
12672
|
-
}
|
|
12673
|
-
var PublicSwapService = /*#__PURE__*/function () {
|
|
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
|
-
}
|
|
12701
|
-
}
|
|
12702
|
-
var _proto = PublicSwapService.prototype;
|
|
12703
|
-
_proto.initialize = function initialize() {
|
|
12704
|
-
try {
|
|
12705
|
-
var _this = this;
|
|
12706
|
-
var _temp = _catch(function () {
|
|
12707
|
-
return Promise.resolve(Promise.all([_this._swapProvider.initialize(), _this._fixedSwapProvider.initialize()])).then(function () {});
|
|
12708
|
-
}, function (e) {
|
|
12709
|
-
Logger.logError(e, "PublicSwapService.initialize");
|
|
12710
|
-
});
|
|
12711
|
-
return Promise.resolve(_temp && _temp.then ? _temp.then(function () {}) : void 0);
|
|
12712
|
-
} catch (e) {
|
|
12713
|
-
return Promise.reject(e);
|
|
12714
|
-
}
|
|
12715
|
-
}
|
|
12716
|
-
/**
|
|
12717
|
-
* Gets all currencies across all partners. Useful for sitemap or supported currencies count/list.
|
|
12718
|
-
*
|
|
12719
|
-
* @return {Promise<{result: boolean, coins: Coin[]}|{result: boolean, reason: string}>}
|
|
12720
|
-
*/
|
|
12721
|
-
;
|
|
12722
|
-
_proto.getAllSupportedCurrenciesListForPublicSwap = function getAllSupportedCurrenciesListForPublicSwap() {
|
|
12723
|
-
try {
|
|
12724
|
-
var _this2 = this;
|
|
12725
|
-
var loggerSource = "getAllSupportedCurrenciesListForPublicSwap";
|
|
12726
|
-
return Promise.resolve(_catch(function () {
|
|
12727
|
-
return Promise.resolve(_this2.initialize()).then(function () {
|
|
12728
|
-
return Promise.resolve(Promise.all([_this2._fixedSwapProvider.getAllSupportedCurrencies(), _this2._swapProvider.getAllSupportedCurrencies()])).then(function (result) {
|
|
12729
|
-
var _result$0$coins, _result$1$coins, _result$coins;
|
|
12730
|
-
var allCoins = [].concat((_result$0$coins = result[0].coins) != null ? _result$0$coins : []);
|
|
12731
|
-
((_result$1$coins = result[1].coins) != null ? _result$1$coins : []).forEach(function (c) {
|
|
12732
|
-
if (!allCoins.find(function (existingCoin) {
|
|
12733
|
-
return existingCoin.ticker === c.ticker;
|
|
12734
|
-
})) {
|
|
12735
|
-
allCoins.push(c);
|
|
12736
|
-
}
|
|
12737
|
-
});
|
|
12738
|
-
if (result[0].reason === SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED || result[1].reason === SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED) {
|
|
12739
|
-
SwapUtils.safeHandleRequestsLimitExceeding();
|
|
12740
|
-
// TODO: [dev] improve this during the whitebit integration. task_id=20e7e41211b540d081bf98f392a34b2c
|
|
12741
|
-
// return {
|
|
12742
|
-
// result: false,
|
|
12743
|
-
// reason: PublicSwapService.PUBLIC_SWAPS_COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED,
|
|
12744
|
-
// };
|
|
12745
|
-
} else if (result[0].reason || result[1].reason) {
|
|
12746
|
-
console.log("Failed to get all supported coins", result[0].reason, result[1].reason);
|
|
12747
|
-
}
|
|
12748
|
-
Logger.log("Retrieved " + (result == null || (_result$coins = result.coins) == null ? void 0 : _result$coins.length) + " supported currencies for swap", loggerSource);
|
|
12749
|
-
return {
|
|
12750
|
-
result: true,
|
|
12751
|
-
coins: allCoins
|
|
12752
|
-
};
|
|
12753
|
-
});
|
|
12754
|
-
});
|
|
12755
|
-
}, function (e) {
|
|
12756
|
-
improveAndRethrow(e, "getAllSupportedCurrenciesListForPublicSwap");
|
|
12757
|
-
}));
|
|
12758
|
-
} catch (e) {
|
|
12759
|
-
return Promise.reject(e);
|
|
12760
|
-
}
|
|
12761
|
-
};
|
|
12762
|
-
_proto.getDepositCurrenciesListForPublicSwap = function getDepositCurrenciesListForPublicSwap(fixed) {
|
|
12763
|
-
if (fixed === void 0) {
|
|
12764
|
-
fixed = false;
|
|
12765
|
-
}
|
|
12766
|
-
try {
|
|
12767
|
-
var _this3 = this;
|
|
12768
|
-
return Promise.resolve(_catch(function () {
|
|
12769
|
-
return Promise.resolve(_this3._getCurrenciesListForPublicSwap(false, fixed));
|
|
12770
|
-
}, function (e) {
|
|
12771
|
-
improveAndRethrow(e, "getDepositCurrenciesListForPublicSwap");
|
|
12772
|
-
}));
|
|
12773
|
-
} catch (e) {
|
|
12774
|
-
return Promise.reject(e);
|
|
12775
|
-
}
|
|
12776
|
-
};
|
|
12777
|
-
_proto.getWithdrawCurrenciesListForPublicSwap = function getWithdrawCurrenciesListForPublicSwap(fixed) {
|
|
12778
|
-
if (fixed === void 0) {
|
|
12779
|
-
fixed = false;
|
|
12780
|
-
}
|
|
12781
|
-
try {
|
|
12782
|
-
var _this4 = this;
|
|
12783
|
-
return Promise.resolve(_catch(function () {
|
|
12784
|
-
return Promise.resolve(_this4._getCurrenciesListForPublicSwap(true, fixed));
|
|
12785
|
-
}, function (e) {
|
|
12786
|
-
improveAndRethrow(e, "getWithdrawCurrenciesListForPublicSwap");
|
|
12787
|
-
}));
|
|
12788
|
-
} catch (e) {
|
|
12789
|
-
return Promise.reject(e);
|
|
12790
|
-
}
|
|
12791
|
-
};
|
|
12792
|
-
_proto._getCurrenciesListForPublicSwap = function _getCurrenciesListForPublicSwap(withdraw, fixed) {
|
|
12793
|
-
if (withdraw === void 0) {
|
|
12794
|
-
withdraw = false;
|
|
12795
|
-
}
|
|
12796
|
-
if (fixed === void 0) {
|
|
12797
|
-
fixed = false;
|
|
12798
|
-
}
|
|
12799
|
-
try {
|
|
12800
|
-
var _this5 = this;
|
|
12801
|
-
var loggerSource = "getCurrenciesListForPublicSwap";
|
|
12802
|
-
return Promise.resolve(_catch(function () {
|
|
12803
|
-
var provider = fixed ? _this5._fixedSwapProvider : _this5._swapProvider;
|
|
12804
|
-
return Promise.resolve(withdraw ? provider.getWithdrawalCurrencies() : provider.getDepositCurrencies()).then(function (result) {
|
|
12805
|
-
var _result$coins2;
|
|
12806
|
-
if (result.reason === SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED) {
|
|
12807
|
-
SwapUtils.safeHandleRequestsLimitExceeding();
|
|
12808
|
-
return {
|
|
12809
|
-
result: false,
|
|
12810
|
-
reason: PublicSwapService.PUBLIC_SWAPS_COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED
|
|
12811
|
-
};
|
|
12812
|
-
}
|
|
12813
|
-
Logger.log("Retrieved " + (result == null || (_result$coins2 = result.coins) == null ? void 0 : _result$coins2.length) + " supported currencies for swap (withdraw=" + withdraw + ")", loggerSource);
|
|
12814
|
-
return {
|
|
12815
|
-
result: true,
|
|
12816
|
-
coins: result.coins
|
|
12817
|
-
};
|
|
13325
|
+
} else {
|
|
13326
|
+
failResults.push(result);
|
|
13327
|
+
}
|
|
13328
|
+
}();
|
|
13329
|
+
if (_temp6 && _temp6.then) return _temp6.then(function () {});
|
|
13330
|
+
});
|
|
13331
|
+
}, function () {
|
|
13332
|
+
return _interrupt;
|
|
12818
13333
|
});
|
|
13334
|
+
return _temp7 && _temp7.then ? _temp7.then(_temp8) : _temp8(_temp7);
|
|
12819
13335
|
}, function (e) {
|
|
12820
|
-
improveAndRethrow(e,
|
|
13336
|
+
improveAndRethrow(e, "getExistingSwapsDetailsWithFiatAmounts");
|
|
12821
13337
|
}));
|
|
12822
13338
|
} catch (e) {
|
|
12823
13339
|
return Promise.reject(e);
|
|
12824
13340
|
}
|
|
13341
|
+
};
|
|
13342
|
+
return SwapUtils;
|
|
13343
|
+
}();
|
|
13344
|
+
|
|
13345
|
+
function _catch(body, recover) {
|
|
13346
|
+
try {
|
|
13347
|
+
var result = body();
|
|
13348
|
+
} catch (e) {
|
|
13349
|
+
return recover(e);
|
|
12825
13350
|
}
|
|
13351
|
+
if (result && result.then) {
|
|
13352
|
+
return result.then(void 0, recover);
|
|
13353
|
+
}
|
|
13354
|
+
return result;
|
|
13355
|
+
}
|
|
13356
|
+
var PublicSwapService = /*#__PURE__*/function () {
|
|
12826
13357
|
/**
|
|
12827
|
-
*
|
|
12828
|
-
*
|
|
12829
|
-
* Always FLOATING rate, FIXED is not supported - if you want to change it the default rate - all
|
|
12830
|
-
* the swaps code logic should be verified to align with this change.
|
|
13358
|
+
* TODO: [feature, critical] implement more adequate providers list&initiation logic. task_id=6a6b0fbbee8a413690c49b1e4ee289cb
|
|
12831
13359
|
*
|
|
12832
|
-
* @param
|
|
12833
|
-
* @param
|
|
12834
|
-
* @
|
|
12835
|
-
* result: true,
|
|
12836
|
-
* min: string,
|
|
12837
|
-
* fiatMin: (number|null),
|
|
12838
|
-
* max: string,
|
|
12839
|
-
* fiatMax: (number|null),
|
|
12840
|
-
* rate: (string|null)
|
|
12841
|
-
* }|{
|
|
12842
|
-
* result: false,
|
|
12843
|
-
* reason: string
|
|
12844
|
-
* }>}
|
|
13360
|
+
* @param apiKeysProxyUrl {string|null}
|
|
13361
|
+
* @param cache {Cache}
|
|
13362
|
+
* @param providers {SwapProvider[]|null}
|
|
12845
13363
|
*/
|
|
12846
|
-
|
|
12847
|
-
|
|
13364
|
+
function PublicSwapService(apiKeysProxyUrl, cache, providers) {
|
|
13365
|
+
var _providers;
|
|
13366
|
+
if (providers === void 0) {
|
|
13367
|
+
providers = null;
|
|
13368
|
+
}
|
|
13369
|
+
if (apiKeysProxyUrl) {
|
|
13370
|
+
this._swapProvider = new SwapspaceSwapProvider(apiKeysProxyUrl, cache, function () {
|
|
13371
|
+
return null;
|
|
13372
|
+
}, false);
|
|
13373
|
+
this._fixedSwapProvider = new LetsExchangeSwapProvider(apiKeysProxyUrl, cache, function () {
|
|
13374
|
+
return null;
|
|
13375
|
+
}, false);
|
|
13376
|
+
} else if ((_providers = providers) != null && _providers.length) {
|
|
13377
|
+
this._swapProvider = providers.find(function (p) {
|
|
13378
|
+
return p.id === "swapspace";
|
|
13379
|
+
});
|
|
13380
|
+
this._fixedSwapProvider = providers.find(function (p) {
|
|
13381
|
+
return p.id === "letsexchange";
|
|
13382
|
+
});
|
|
13383
|
+
}
|
|
13384
|
+
}
|
|
13385
|
+
var _proto = PublicSwapService.prototype;
|
|
13386
|
+
_proto.initialize = function initialize() {
|
|
12848
13387
|
try {
|
|
12849
|
-
var
|
|
12850
|
-
|
|
12851
|
-
return Promise.resolve(
|
|
12852
|
-
if (!result.result) {
|
|
12853
|
-
if (result.reason === SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED) {
|
|
12854
|
-
SwapUtils.safeHandleRequestsLimitExceeding();
|
|
12855
|
-
return {
|
|
12856
|
-
result: false,
|
|
12857
|
-
reason: PublicSwapService.PUBLIC_SWAPS_COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED
|
|
12858
|
-
};
|
|
12859
|
-
}
|
|
12860
|
-
if (result.reason === SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED) {
|
|
12861
|
-
return {
|
|
12862
|
-
result: false,
|
|
12863
|
-
reason: PublicSwapService.PUBLIC_SWAP_DETAILS_FAIL_REASONS.PAIR_NOT_SUPPORTED
|
|
12864
|
-
};
|
|
12865
|
-
}
|
|
12866
|
-
}
|
|
12867
|
-
return result;
|
|
12868
|
-
});
|
|
13388
|
+
var _this = this;
|
|
13389
|
+
var _temp = _catch(function () {
|
|
13390
|
+
return Promise.resolve(Promise.all([_this._swapProvider.initialize(), _this._fixedSwapProvider.initialize()])).then(function () {});
|
|
12869
13391
|
}, function (e) {
|
|
12870
|
-
|
|
12871
|
-
})
|
|
13392
|
+
Logger.logError(e, "PublicSwapService.initialize");
|
|
13393
|
+
});
|
|
13394
|
+
return Promise.resolve(_temp && _temp.then ? _temp.then(function () {}) : void 0);
|
|
12872
13395
|
} catch (e) {
|
|
12873
13396
|
return Promise.reject(e);
|
|
12874
13397
|
}
|
|
@@ -12876,14 +13399,15 @@
|
|
|
12876
13399
|
/**
|
|
12877
13400
|
* Retrieves swap details that can be used to create swap.
|
|
12878
13401
|
*
|
|
13402
|
+
* @param provider {SwapProvider}
|
|
12879
13403
|
* @param fromCoinOrTicker {Coin|string}
|
|
12880
13404
|
* @param toCoinOrTicker {Coin|string}
|
|
12881
13405
|
* @param amountCoins {string}
|
|
12882
13406
|
* @param [fixed=false] {boolean|null} null means fixed or float doesn't matter
|
|
12883
|
-
* @param [
|
|
13407
|
+
* @param [coinUsdtRate=null] {number|null} rate of amount coin to USDT
|
|
12884
13408
|
* @param [amountIsToReceive=false] {boolean} whether the given amount is receiving amount.
|
|
12885
13409
|
* False means the amount is the sending amount.
|
|
12886
|
-
* @param bannedPartners {string[]} array of banned swap partners (providers) ids
|
|
13410
|
+
* @param bannedPartners {string[]} array of banned swap partners (providers) ids (rabbit ids)
|
|
12887
13411
|
* @return {Promise<{
|
|
12888
13412
|
* result: false,
|
|
12889
13413
|
* reason: string,
|
|
@@ -12898,12 +13422,12 @@
|
|
|
12898
13422
|
* }>}
|
|
12899
13423
|
*/
|
|
12900
13424
|
;
|
|
12901
|
-
_proto.getPublicSwapDetails = function getPublicSwapDetails(fromCoinOrTicker, toCoinOrTicker, amountCoins, fixed,
|
|
13425
|
+
_proto.getPublicSwapDetails = function getPublicSwapDetails(provider, fromCoinOrTicker, toCoinOrTicker, amountCoins, fixed, coinUsdtRate, amountIsToReceive, bannedPartners) {
|
|
12902
13426
|
if (fixed === void 0) {
|
|
12903
13427
|
fixed = false;
|
|
12904
13428
|
}
|
|
12905
|
-
if (
|
|
12906
|
-
|
|
13429
|
+
if (coinUsdtRate === void 0) {
|
|
13430
|
+
coinUsdtRate = null;
|
|
12907
13431
|
}
|
|
12908
13432
|
if (amountIsToReceive === void 0) {
|
|
12909
13433
|
amountIsToReceive = false;
|
|
@@ -12912,89 +13436,22 @@
|
|
|
12912
13436
|
bannedPartners = [];
|
|
12913
13437
|
}
|
|
12914
13438
|
try {
|
|
12915
|
-
var
|
|
13439
|
+
var _this2 = this;
|
|
12916
13440
|
var loggerSource = "getPublicSwapDetails";
|
|
12917
13441
|
return Promise.resolve(_catch(function () {
|
|
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) {
|
|
12923
|
-
var _result$swapCreationI, _result$swapCreationI2;
|
|
12924
|
-
// eslint-disable-next-line no-console
|
|
12925
|
-
console.log("getSwapInfo result: ", details);
|
|
12926
|
-
var min = details.smallestMin != null && bignumber_js.BigNumber(details.smallestMin).gt("0") ? details.smallestMin : null;
|
|
12927
|
-
var max = details.greatestMax != null && bignumber_js.BigNumber(details.greatestMax).gt("0") ? details.greatestMax : null;
|
|
12928
|
-
var fiatMin = null,
|
|
12929
|
-
fiatMax = null;
|
|
12930
|
-
if (coinUsdtRate != null) {
|
|
12931
|
-
if (min != null) {
|
|
12932
|
-
fiatMin = bignumber_js.BigNumber(min).times(coinUsdtRate).toFixed(PublicSwapService._fiatDecimalsCount);
|
|
12933
|
-
}
|
|
12934
|
-
if (max != null) {
|
|
12935
|
-
fiatMax = bignumber_js.BigNumber(max).times(coinUsdtRate).toFixed(PublicSwapService._fiatDecimalsCount);
|
|
12936
|
-
}
|
|
12937
|
-
}
|
|
12938
|
-
var composeFailResult = function composeFailResult(reason) {
|
|
12939
|
-
var _details$rate;
|
|
12940
|
-
return {
|
|
12941
|
-
result: false,
|
|
12942
|
-
reason: reason,
|
|
12943
|
-
min: min != null ? min : null,
|
|
12944
|
-
fiatMin: fiatMin,
|
|
12945
|
-
max: max != null ? max : null,
|
|
12946
|
-
fiatMax: fiatMax,
|
|
12947
|
-
rate: (_details$rate = details.rate) != null ? _details$rate : null
|
|
12948
|
-
};
|
|
12949
|
-
};
|
|
12950
|
-
if (!details.result) {
|
|
12951
|
-
if ((details == null ? void 0 : details.reason) === SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED) {
|
|
12952
|
-
return composeFailResult(PublicSwapService.PUBLIC_SWAP_DETAILS_FAIL_REASONS.PAIR_NOT_SUPPORTED);
|
|
12953
|
-
} else if ((details == null ? void 0 : details.reason) === SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED) {
|
|
12954
|
-
SwapUtils.safeHandleRequestsLimitExceeding();
|
|
12955
|
-
return composeFailResult(PublicSwapService.PUBLIC_SWAPS_COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED);
|
|
12956
|
-
} else if ((details == null ? void 0 : details.reason) === SwapProvider.NO_SWAPS_REASONS.NO_FLOATING_BUT_HAVE_FIXED) {
|
|
12957
|
-
return composeFailResult(PublicSwapService.PUBLIC_SWAP_DETAILS_FAIL_REASONS.NO_FLOATING_BUT_HAVE_FIXED_PUBLIC_SWAP_OPTION);
|
|
12958
|
-
} else if ((details == null ? void 0 : details.reason) === SwapProvider.NO_SWAPS_REASONS.NO_FIXED_BUT_HAVE_FLOATING) {
|
|
12959
|
-
return composeFailResult(PublicSwapService.PUBLIC_SWAP_DETAILS_FAIL_REASONS.NO_FIXED_BUT_HAVE_FLOATING_PUBLIC_SWAP_OPTION);
|
|
12960
|
-
}
|
|
12961
|
-
}
|
|
12962
|
-
var amountBigNumber = bignumber_js.BigNumber(amountCoins);
|
|
12963
|
-
if (typeof min === "string" && amountBigNumber.lt(min)) {
|
|
12964
|
-
return composeFailResult(PublicSwapService.PUBLIC_SWAP_DETAILS_FAIL_REASONS.AMOUNT_LESS_THAN_MIN_SWAPPABLE);
|
|
12965
|
-
} else if (typeof max === "string" && amountBigNumber.gt(max)) {
|
|
12966
|
-
return composeFailResult(PublicSwapService.PUBLIC_SWAP_DETAILS_FAIL_REASONS.AMOUNT_HIGHER_THAN_MAX_SWAPPABLE);
|
|
12967
|
-
}
|
|
12968
|
-
var fromAmountCoins = amountIsToReceive ? AmountUtils.trim(amountBigNumber.div(details.rate), fromCoin.digits) : amountCoins;
|
|
12969
|
-
var toAmountCoins = amountIsToReceive ? amountCoins : AmountUtils.trim(amountBigNumber.times(details.rate), toCoin.digits);
|
|
12970
|
-
var result = {
|
|
12971
|
-
result: true,
|
|
12972
|
-
swapCreationInfo: new BaseSwapCreationInfo(fromCoin, toCoin, fromAmountCoins, toAmountCoins, details.rate, details.rawSwapData, min, fiatMin, max, fiatMax, details.durationMinutesRange, details.fixed, details.isRefundAddressRequired)
|
|
12973
|
-
};
|
|
12974
|
-
Logger.log("Result: " + safeStringify({
|
|
12975
|
-
result: result.result,
|
|
12976
|
-
swapCreationInfo: _extends({}, result.swapCreationInfo, {
|
|
12977
|
-
fromCoin: result == null || (_result$swapCreationI = result.swapCreationInfo) == null || (_result$swapCreationI = _result$swapCreationI.fromCoin) == null ? void 0 : _result$swapCreationI.ticker,
|
|
12978
|
-
toCoin: result == null || (_result$swapCreationI2 = result.swapCreationInfo) == null || (_result$swapCreationI2 = _result$swapCreationI2.toCoin) == null ? void 0 : _result$swapCreationI2.ticker
|
|
12979
|
-
})
|
|
12980
|
-
}), loggerSource);
|
|
12981
|
-
return result;
|
|
12982
|
-
});
|
|
12983
|
-
}
|
|
12984
13442
|
if (amountIsToReceive && !fixed) {
|
|
12985
13443
|
throw new Error("Estimating allowed only for fixed rate.");
|
|
12986
13444
|
}
|
|
12987
13445
|
var fromCoin = fromCoinOrTicker;
|
|
12988
13446
|
if (typeof fromCoin === "string") {
|
|
12989
|
-
fromCoin =
|
|
13447
|
+
fromCoin = _this2.getCoinByTickerIfPresent(fromCoin);
|
|
12990
13448
|
}
|
|
12991
13449
|
var toCoin = toCoinOrTicker;
|
|
12992
13450
|
if (typeof toCoin === "string") {
|
|
12993
|
-
toCoin =
|
|
13451
|
+
toCoin = _this2.getCoinByTickerIfPresent(toCoin);
|
|
12994
13452
|
}
|
|
12995
|
-
var operatingPartner = fixed ? _this7._fixedSwapProvider : _this7._swapProvider;
|
|
12996
13453
|
var isPartnerBanned = !!bannedPartners.find(function (banned) {
|
|
12997
|
-
return banned ===
|
|
13454
|
+
return banned === provider.id;
|
|
12998
13455
|
});
|
|
12999
13456
|
return !fromCoin || !toCoin || isPartnerBanned ? {
|
|
13000
13457
|
result: false,
|
|
@@ -13004,7 +13461,67 @@
|
|
|
13004
13461
|
fiatMin: null,
|
|
13005
13462
|
fiatMax: null,
|
|
13006
13463
|
rate: undefined
|
|
13007
|
-
} :
|
|
13464
|
+
} : Promise.resolve(provider.getSwapInfo(fromCoin, toCoin, amountCoins, fixed, coinUsdtRate, amountIsToReceive, bannedPartners)).then(function (details) {
|
|
13465
|
+
var _result$swapCreationI, _result$swapCreationI2;
|
|
13466
|
+
// eslint-disable-next-line no-console
|
|
13467
|
+
console.log("getSwapInfo raw result: ", details, loggerSource);
|
|
13468
|
+
var min = details.smallestMin != null && BigNumber.BigNumber(details.smallestMin).gt("0") ? details.smallestMin : null;
|
|
13469
|
+
var max = details.greatestMax != null && BigNumber.BigNumber(details.greatestMax).gt("0") ? details.greatestMax : null;
|
|
13470
|
+
var fiatMin = null,
|
|
13471
|
+
fiatMax = null;
|
|
13472
|
+
if (coinUsdtRate != null) {
|
|
13473
|
+
if (min != null) {
|
|
13474
|
+
fiatMin = BigNumber.BigNumber(min).times(coinUsdtRate).toFixed(PublicSwapService._fiatDecimalsCount);
|
|
13475
|
+
}
|
|
13476
|
+
if (max != null) {
|
|
13477
|
+
fiatMax = BigNumber.BigNumber(max).times(coinUsdtRate).toFixed(PublicSwapService._fiatDecimalsCount);
|
|
13478
|
+
}
|
|
13479
|
+
}
|
|
13480
|
+
var composeFailResult = function composeFailResult(reason) {
|
|
13481
|
+
var _details$rate;
|
|
13482
|
+
return {
|
|
13483
|
+
result: false,
|
|
13484
|
+
reason: reason,
|
|
13485
|
+
min: min != null ? min : null,
|
|
13486
|
+
fiatMin: fiatMin,
|
|
13487
|
+
max: max != null ? max : null,
|
|
13488
|
+
fiatMax: fiatMax,
|
|
13489
|
+
rate: (_details$rate = details.rate) != null ? _details$rate : null
|
|
13490
|
+
};
|
|
13491
|
+
};
|
|
13492
|
+
if (!details.result) {
|
|
13493
|
+
if ((details == null ? void 0 : details.reason) === SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED) {
|
|
13494
|
+
return composeFailResult(PublicSwapService.PUBLIC_SWAP_DETAILS_FAIL_REASONS.PAIR_NOT_SUPPORTED);
|
|
13495
|
+
} else if ((details == null ? void 0 : details.reason) === SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED) {
|
|
13496
|
+
SwapUtils.safeHandleRequestsLimitExceeding();
|
|
13497
|
+
return composeFailResult(PublicSwapService.PUBLIC_SWAPS_COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED);
|
|
13498
|
+
} else if ((details == null ? void 0 : details.reason) === SwapProvider.NO_SWAPS_REASONS.NO_FLOATING_BUT_HAVE_FIXED) {
|
|
13499
|
+
return composeFailResult(PublicSwapService.PUBLIC_SWAP_DETAILS_FAIL_REASONS.NO_FLOATING_BUT_HAVE_FIXED_PUBLIC_SWAP_OPTION);
|
|
13500
|
+
} else if ((details == null ? void 0 : details.reason) === SwapProvider.NO_SWAPS_REASONS.NO_FIXED_BUT_HAVE_FLOATING) {
|
|
13501
|
+
return composeFailResult(PublicSwapService.PUBLIC_SWAP_DETAILS_FAIL_REASONS.NO_FIXED_BUT_HAVE_FLOATING_PUBLIC_SWAP_OPTION);
|
|
13502
|
+
}
|
|
13503
|
+
}
|
|
13504
|
+
var amountBigNumber = BigNumber.BigNumber(amountCoins);
|
|
13505
|
+
if (typeof min === "string" && amountBigNumber.lt(min)) {
|
|
13506
|
+
return composeFailResult(PublicSwapService.PUBLIC_SWAP_DETAILS_FAIL_REASONS.AMOUNT_LESS_THAN_MIN_SWAPPABLE);
|
|
13507
|
+
} else if (typeof max === "string" && amountBigNumber.gt(max)) {
|
|
13508
|
+
return composeFailResult(PublicSwapService.PUBLIC_SWAP_DETAILS_FAIL_REASONS.AMOUNT_HIGHER_THAN_MAX_SWAPPABLE);
|
|
13509
|
+
}
|
|
13510
|
+
var fromAmountCoins = amountIsToReceive ? AmountUtils.trim(amountBigNumber.div(details.rate), fromCoin.digits) : amountCoins;
|
|
13511
|
+
var toAmountCoins = amountIsToReceive ? amountCoins : AmountUtils.trim(amountBigNumber.times(details.rate), toCoin.digits);
|
|
13512
|
+
var result = {
|
|
13513
|
+
result: true,
|
|
13514
|
+
swapCreationInfo: new BaseSwapCreationInfo(fromCoin, toCoin, fromAmountCoins, toAmountCoins, details.rate, details.rawSwapData, min, fiatMin, max, fiatMax, details.durationMinutesRange, details.fixed, provider.id, details.isRefundAddressRequired)
|
|
13515
|
+
};
|
|
13516
|
+
Logger.log("Result: " + safeStringify({
|
|
13517
|
+
result: result.result,
|
|
13518
|
+
swapCreationInfo: _extends({}, result.swapCreationInfo, {
|
|
13519
|
+
fromCoin: result == null || (_result$swapCreationI = result.swapCreationInfo) == null || (_result$swapCreationI = _result$swapCreationI.fromCoin) == null ? void 0 : _result$swapCreationI.ticker,
|
|
13520
|
+
toCoin: result == null || (_result$swapCreationI2 = result.swapCreationInfo) == null || (_result$swapCreationI2 = _result$swapCreationI2.toCoin) == null ? void 0 : _result$swapCreationI2.ticker
|
|
13521
|
+
})
|
|
13522
|
+
}), loggerSource);
|
|
13523
|
+
return result;
|
|
13524
|
+
});
|
|
13008
13525
|
}, function (e) {
|
|
13009
13526
|
improveAndRethrow(e, loggerSource);
|
|
13010
13527
|
}));
|
|
@@ -13015,10 +13532,11 @@
|
|
|
13015
13532
|
/**
|
|
13016
13533
|
* Creates swap by given params.
|
|
13017
13534
|
*
|
|
13018
|
-
* @param
|
|
13019
|
-
* @param
|
|
13535
|
+
* @param provider {SwapProvider}
|
|
13536
|
+
* @param fromCoinTicker {string}
|
|
13537
|
+
* @param toCoinTicker {string}
|
|
13020
13538
|
* @param amount {string}
|
|
13021
|
-
* @param
|
|
13539
|
+
* @param proprietarySwapEstimationData {Object|null}
|
|
13022
13540
|
* @param toAddress {string}
|
|
13023
13541
|
* @param refundAddress {string}
|
|
13024
13542
|
* @param clientIp {string}
|
|
@@ -13026,10 +13544,11 @@
|
|
|
13026
13544
|
* @param [refundExtraId] {string}
|
|
13027
13545
|
* @param [amountIsToReceive=false] {boolean} whether the given amount is receiving amount.
|
|
13028
13546
|
* False means the amount is the sending amount.
|
|
13547
|
+
* @param isFixed {boolean}
|
|
13029
13548
|
* @return {Promise<{
|
|
13030
13549
|
* result: true,
|
|
13031
13550
|
* fiatCurrencyCode: string,
|
|
13032
|
-
*
|
|
13551
|
+
* toCoinTicker: string,
|
|
13033
13552
|
* fromAmountFiat: (number|null),
|
|
13034
13553
|
* address: string,
|
|
13035
13554
|
* durationMinutesRange: string,
|
|
@@ -13037,7 +13556,7 @@
|
|
|
13037
13556
|
* toAmount: string,
|
|
13038
13557
|
* toAmountFiat: (number|null),
|
|
13039
13558
|
* fiatCurrencyDecimals: number,
|
|
13040
|
-
*
|
|
13559
|
+
* fromCoinTicker: string,
|
|
13041
13560
|
* rate: string,
|
|
13042
13561
|
* swapId: string,
|
|
13043
13562
|
* fromCurrencyExtraId: string,
|
|
@@ -13048,31 +13567,35 @@
|
|
|
13048
13567
|
* }>}
|
|
13049
13568
|
*/
|
|
13050
13569
|
;
|
|
13051
|
-
_proto.createPublicSwap = function createPublicSwap(
|
|
13570
|
+
_proto.createPublicSwap = function createPublicSwap(provider, fromCoinTicker, toCoinTicker, amount, proprietarySwapEstimationData, toAddress, refundAddress, clientIp, toCurrencyExtraId, refundExtraId, amountIsToReceive, isFixed) {
|
|
13052
13571
|
if (amountIsToReceive === void 0) {
|
|
13053
13572
|
amountIsToReceive = false;
|
|
13054
13573
|
}
|
|
13574
|
+
if (isFixed === void 0) {
|
|
13575
|
+
isFixed = false;
|
|
13576
|
+
}
|
|
13055
13577
|
try {
|
|
13056
|
-
var
|
|
13578
|
+
var _this3 = this;
|
|
13057
13579
|
var loggerSource = "createPublicSwap";
|
|
13058
13580
|
return Promise.resolve(_catch(function () {
|
|
13059
|
-
|
|
13060
|
-
|
|
13061
|
-
throw new Error("Wrong input: " + fromCoin.ticker + " " + toCoin.ticker + " " + amount + " " + swapCreationInfo);
|
|
13581
|
+
if (!(provider instanceof SwapProvider) || typeof fromCoinTicker !== "string" || typeof toCoinTicker !== "string" || typeof amount !== "string" || typeof toAddress !== "string") {
|
|
13582
|
+
throw new Error("Wrong input: " + provider + " " + fromCoinTicker + " " + toCoinTicker + " " + amount + " " + isFixed);
|
|
13062
13583
|
}
|
|
13063
|
-
Logger.log("Start: " + amount + " " +
|
|
13064
|
-
|
|
13065
|
-
|
|
13066
|
-
|
|
13067
|
-
|
|
13584
|
+
Logger.log("Start: " + provider.id + " " + amount + " " + fromCoinTicker + " -> " + toCoinTicker + ". raw data: " + proprietarySwapEstimationData, loggerSource);
|
|
13585
|
+
var _map = [fromCoinTicker, toCoinTicker].map(function (t) {
|
|
13586
|
+
return _this3.getCoinByTickerIfPresent(t);
|
|
13587
|
+
}),
|
|
13588
|
+
fromCoin = _map[0],
|
|
13589
|
+
toCoin = _map[1];
|
|
13590
|
+
return Promise.resolve(provider.createSwap(fromCoin, toCoin, amount, toAddress, refundAddress, proprietarySwapEstimationData, clientIp, isFixed, toCurrencyExtraId, refundExtraId, amountIsToReceive)).then(function (result) {
|
|
13068
13591
|
var _exit;
|
|
13069
|
-
function
|
|
13070
|
-
if (_exit) return
|
|
13592
|
+
function _temp5(_result3) {
|
|
13593
|
+
if (_exit) return _result3;
|
|
13071
13594
|
throw new Error("Unexpected result from provider " + safeStringify(result));
|
|
13072
13595
|
}
|
|
13073
13596
|
Logger.log("Created:" + safeStringify(_extends({}, result, {
|
|
13074
|
-
fromCoin:
|
|
13075
|
-
toCoin:
|
|
13597
|
+
fromCoin: fromCoinTicker,
|
|
13598
|
+
toCoin: toCoinTicker
|
|
13076
13599
|
})), loggerSource);
|
|
13077
13600
|
if (!(result != null && result.result)) {
|
|
13078
13601
|
if ((result == null ? void 0 : result.reason) === SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED) {
|
|
@@ -13090,21 +13613,21 @@
|
|
|
13090
13613
|
// };
|
|
13091
13614
|
}
|
|
13092
13615
|
}
|
|
13093
|
-
var
|
|
13616
|
+
var _temp4 = function () {
|
|
13094
13617
|
if (result.result && result != null && result.swapId) {
|
|
13095
|
-
var
|
|
13618
|
+
var _temp3 = function _temp3() {
|
|
13096
13619
|
return Promise.resolve(GoogleAnalyticsAdapter.sendEvent(PublicSwapService.PUBLIC_SWAP_CREATED_ANALYTICS_EVENT, {
|
|
13097
13620
|
coin_amount: result.fromAmount,
|
|
13098
13621
|
usd_amount: _fromAmountFiat,
|
|
13099
|
-
fromCoin:
|
|
13100
|
-
toCoin:
|
|
13622
|
+
fromCoin: fromCoinTicker,
|
|
13623
|
+
toCoin: toCoinTicker
|
|
13101
13624
|
})).then(function () {
|
|
13102
13625
|
var _result$fromCurrencyE;
|
|
13103
13626
|
var toReturn = {
|
|
13104
13627
|
result: true,
|
|
13105
13628
|
swapId: result.swapId,
|
|
13106
|
-
|
|
13107
|
-
|
|
13629
|
+
fromCoinTicker: fromCoinTicker,
|
|
13630
|
+
toCoinTicker: toCoinTicker,
|
|
13108
13631
|
fromAmount: result.fromAmount,
|
|
13109
13632
|
toAmount: result.toAmount,
|
|
13110
13633
|
fromAmountFiat: _fromAmountFiat,
|
|
@@ -13112,17 +13635,18 @@
|
|
|
13112
13635
|
fiatCurrencyCode: "USD",
|
|
13113
13636
|
fiatCurrencyDecimals: PublicSwapService._fiatDecimalsCount,
|
|
13114
13637
|
rate: result.rate,
|
|
13115
|
-
durationMinutesRange:
|
|
13638
|
+
durationMinutesRange: null,
|
|
13639
|
+
// TODO: [feature, high] add duration. task_id=3f3d73d7cf44454282222901409149b5
|
|
13116
13640
|
address: result.fromAddress,
|
|
13117
13641
|
// CRITICAL: this is the address to send coins to swaps provider
|
|
13118
13642
|
fromCurrencyExtraId: (_result$fromCurrencyE = result.fromCurrencyExtraId) != null ? _result$fromCurrencyE : "",
|
|
13119
13643
|
// CRITICAL: this is the extra ID for address to send coins to swaps provider
|
|
13120
13644
|
fixed: result.fixed
|
|
13121
13645
|
};
|
|
13122
|
-
|
|
13646
|
+
_this3._savePublicSwapIdLocally(result.swapId);
|
|
13123
13647
|
Logger.log("Returning: " + safeStringify(_extends({}, toReturn, {
|
|
13124
|
-
fromCoin:
|
|
13125
|
-
toCoin:
|
|
13648
|
+
fromCoin: fromCoinTicker,
|
|
13649
|
+
toCoin: toCoinTicker
|
|
13126
13650
|
})), loggerSource);
|
|
13127
13651
|
_exit = 1;
|
|
13128
13652
|
return toReturn;
|
|
@@ -13130,67 +13654,28 @@
|
|
|
13130
13654
|
};
|
|
13131
13655
|
var _fromAmountFiat = null,
|
|
13132
13656
|
_toAmountFiat = null;
|
|
13133
|
-
var
|
|
13134
|
-
return Promise.resolve(
|
|
13135
|
-
var
|
|
13136
|
-
var fromCoinUsdtRate = (
|
|
13137
|
-
return Promise.resolve(
|
|
13138
|
-
var
|
|
13139
|
-
var toCoinUsdtRate = (
|
|
13657
|
+
var _temp2 = _catch(function () {
|
|
13658
|
+
return Promise.resolve(provider.getCoinToUSDTRate(fromCoinTicker)).then(function (_provider$getCoinToUS) {
|
|
13659
|
+
var _provider$getCoinToUS3;
|
|
13660
|
+
var fromCoinUsdtRate = (_provider$getCoinToUS3 = _provider$getCoinToUS == null ? void 0 : _provider$getCoinToUS.rate) != null ? _provider$getCoinToUS3 : null;
|
|
13661
|
+
return Promise.resolve(provider.getCoinToUSDTRate(toCoinTicker)).then(function (_provider$getCoinToUS2) {
|
|
13662
|
+
var _provider$getCoinToUS4;
|
|
13663
|
+
var toCoinUsdtRate = (_provider$getCoinToUS4 = _provider$getCoinToUS2 == null ? void 0 : _provider$getCoinToUS2.rate) != null ? _provider$getCoinToUS4 : null;
|
|
13140
13664
|
if (fromCoinUsdtRate != null && result.fromAmount != null) {
|
|
13141
|
-
_fromAmountFiat =
|
|
13665
|
+
_fromAmountFiat = BigNumber.BigNumber(result.fromAmount).times(fromCoinUsdtRate).toFixed(PublicSwapService._fiatDecimalsCount);
|
|
13142
13666
|
}
|
|
13143
13667
|
if (toCoinUsdtRate != null && result.toAmount != null) {
|
|
13144
|
-
_toAmountFiat =
|
|
13668
|
+
_toAmountFiat = BigNumber.BigNumber(result.toAmount).times(toCoinUsdtRate).toFixed(PublicSwapService._fiatDecimalsCount);
|
|
13145
13669
|
}
|
|
13146
13670
|
});
|
|
13147
13671
|
});
|
|
13148
13672
|
}, function (e) {
|
|
13149
13673
|
Logger.logError(e, loggerSource, "Failed to calculate fiat amounts for result");
|
|
13150
13674
|
});
|
|
13151
|
-
return
|
|
13675
|
+
return _temp2 && _temp2.then ? _temp2.then(_temp3) : _temp3(_temp2);
|
|
13152
13676
|
}
|
|
13153
13677
|
}();
|
|
13154
|
-
return
|
|
13155
|
-
});
|
|
13156
|
-
}, function (e) {
|
|
13157
|
-
improveAndRethrow(e, loggerSource);
|
|
13158
|
-
}));
|
|
13159
|
-
} catch (e) {
|
|
13160
|
-
return Promise.reject(e);
|
|
13161
|
-
}
|
|
13162
|
-
}
|
|
13163
|
-
/**
|
|
13164
|
-
* Retrieves swap details and status for existing swaps by their ids.
|
|
13165
|
-
*
|
|
13166
|
-
* @param swapIds {string[]}
|
|
13167
|
-
* @return {Promise<{
|
|
13168
|
-
* result: true,
|
|
13169
|
-
* swaps: ExistingSwapWithFiatData[]
|
|
13170
|
-
* }|{
|
|
13171
|
-
* result: false,
|
|
13172
|
-
* reason: string
|
|
13173
|
-
* }>}
|
|
13174
|
-
* error reason is one of PUBLIC_SWAPS_COMMON_ERRORS
|
|
13175
|
-
*/
|
|
13176
|
-
;
|
|
13177
|
-
_proto.getPublicExistingSwapDetailsAndStatus = function getPublicExistingSwapDetailsAndStatus(swapIds) {
|
|
13178
|
-
try {
|
|
13179
|
-
var _this9 = this;
|
|
13180
|
-
var loggerSource = "getPublicExistingSwapDetailsAndStatus";
|
|
13181
|
-
return Promise.resolve(_catch(function () {
|
|
13182
|
-
return Promise.resolve(SwapUtils.getExistingSwapsDetailsWithFiatAmounts([_this9._swapProvider, _this9._fixedSwapProvider], swapIds)).then(function (result) {
|
|
13183
|
-
if (!(result != null && result.result)) {
|
|
13184
|
-
if (result.reason === SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED) {
|
|
13185
|
-
SwapUtils.safeHandleRequestsLimitExceeding();
|
|
13186
|
-
return {
|
|
13187
|
-
result: false,
|
|
13188
|
-
reason: PublicSwapService.PUBLIC_SWAPS_COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED
|
|
13189
|
-
};
|
|
13190
|
-
}
|
|
13191
|
-
throw new Error("Unknown reason: " + (result == null ? void 0 : result.reason));
|
|
13192
|
-
}
|
|
13193
|
-
return result;
|
|
13678
|
+
return _temp4 && _temp4.then ? _temp4.then(_temp5) : _temp5(_temp4);
|
|
13194
13679
|
});
|
|
13195
13680
|
}, function (e) {
|
|
13196
13681
|
improveAndRethrow(e, loggerSource);
|
|
@@ -13198,47 +13683,29 @@
|
|
|
13198
13683
|
} catch (e) {
|
|
13199
13684
|
return Promise.reject(e);
|
|
13200
13685
|
}
|
|
13201
|
-
}
|
|
13202
|
-
/**
|
|
13203
|
-
|
|
13204
|
-
|
|
13205
|
-
|
|
13206
|
-
|
|
13207
|
-
|
|
13208
|
-
|
|
13209
|
-
|
|
13210
|
-
|
|
13211
|
-
|
|
13212
|
-
|
|
13213
|
-
|
|
13214
|
-
|
|
13215
|
-
|
|
13216
|
-
|
|
13217
|
-
|
|
13218
|
-
|
|
13219
|
-
|
|
13220
|
-
|
|
13221
|
-
|
|
13222
|
-
|
|
13223
|
-
|
|
13224
|
-
}
|
|
13225
|
-
var swapIds = _this10._getPublicSwapIdsSavedLocally();
|
|
13226
|
-
var _temp7 = function () {
|
|
13227
|
-
if (swapIds.length) {
|
|
13228
|
-
return Promise.resolve(_this10.getPublicExistingSwapDetailsAndStatus(swapIds)).then(function (_await$_this10$getPub) {
|
|
13229
|
-
_exit2 = 1;
|
|
13230
|
-
return _await$_this10$getPub;
|
|
13231
|
-
});
|
|
13232
|
-
}
|
|
13233
|
-
}();
|
|
13234
|
-
return _temp7 && _temp7.then ? _temp7.then(_temp8) : _temp8(_temp7);
|
|
13235
|
-
}, function (e) {
|
|
13236
|
-
improveAndRethrow(e, "getPublicSwapsHistory");
|
|
13237
|
-
}));
|
|
13238
|
-
} catch (e) {
|
|
13239
|
-
return Promise.reject(e);
|
|
13240
|
-
}
|
|
13241
|
-
}
|
|
13686
|
+
} // TODO: [feature, moderate] move to client. task_id=de4b1ddc652b4a27a472341609fcb6e4
|
|
13687
|
+
// /**
|
|
13688
|
+
// * Retrieves the whole available swaps history by ids saved locally.
|
|
13689
|
+
// *
|
|
13690
|
+
// * @return {Promise<{
|
|
13691
|
+
// * result: true,
|
|
13692
|
+
// * swaps: ExistingSwapWithFiatData[]
|
|
13693
|
+
// * }|{
|
|
13694
|
+
// * result: false,
|
|
13695
|
+
// * reason: string
|
|
13696
|
+
// * }>}
|
|
13697
|
+
// */
|
|
13698
|
+
// async getPublicSwapsHistory() {
|
|
13699
|
+
// try {
|
|
13700
|
+
// const swapIds = this._getPublicSwapIdsSavedLocally();
|
|
13701
|
+
// if (swapIds.length) {
|
|
13702
|
+
// return await this.getPublicExistingSwapDetailsAndStatus(swapIds);
|
|
13703
|
+
// }
|
|
13704
|
+
// return { result: true, swaps: [] };
|
|
13705
|
+
// } catch (e) {
|
|
13706
|
+
// improveAndRethrow(e, "getPublicSwapsHistory");
|
|
13707
|
+
// }
|
|
13708
|
+
// }
|
|
13242
13709
|
/**
|
|
13243
13710
|
* @param swapId {string}
|
|
13244
13711
|
* @private
|
|
@@ -13272,16 +13739,6 @@
|
|
|
13272
13739
|
}
|
|
13273
13740
|
}
|
|
13274
13741
|
|
|
13275
|
-
/**
|
|
13276
|
-
* @param coinOrTicker {Coin|string}
|
|
13277
|
-
* @param [isFixed=true] {boolean} rate type
|
|
13278
|
-
* @return {string} icon URL (ready to use)
|
|
13279
|
-
*/;
|
|
13280
|
-
_proto.getAssetIconUrl = function getAssetIconUrl(coinOrTicker, isFixed) {
|
|
13281
|
-
// TODO: [feature, high] improve this logic - currently hacked to show better icons from fixed provider. task_id=3b6b8c2a9df04a86aaff2e070424b64f
|
|
13282
|
-
return this._fixedSwapProvider.getIconUrl(coinOrTicker);
|
|
13283
|
-
}
|
|
13284
|
-
|
|
13285
13742
|
/**
|
|
13286
13743
|
* @param ticker {string}
|
|
13287
13744
|
* @return {Coin|null}
|
|
@@ -13292,133 +13749,19 @@
|
|
|
13292
13749
|
}
|
|
13293
13750
|
|
|
13294
13751
|
/**
|
|
13295
|
-
*
|
|
13296
|
-
* @param asset {Coin}
|
|
13297
|
-
* @return {Promise<string|null>}
|
|
13298
|
-
*/;
|
|
13299
|
-
_proto.getAssetToUsdtRate = function getAssetToUsdtRate(asset) {
|
|
13300
|
-
try {
|
|
13301
|
-
var _temp13 = function _temp13() {
|
|
13302
|
-
function _temp11() {
|
|
13303
|
-
var _result$rate, _result12;
|
|
13304
|
-
return (_result$rate = (_result12 = result) == null ? void 0 : _result12.rate) != null ? _result$rate : null;
|
|
13305
|
-
}
|
|
13306
|
-
var _temp10 = _catch(function () {
|
|
13307
|
-
var _temp9 = function (_result13) {
|
|
13308
|
-
if (((_result13 = result) == null ? void 0 : _result13.rate) == null) {
|
|
13309
|
-
return Promise.resolve(_this11._fixedSwapProvider.getCoinToUSDTRate(asset)).then(function (_this11$_fixedSwapPro) {
|
|
13310
|
-
result = _this11$_fixedSwapPro;
|
|
13311
|
-
});
|
|
13312
|
-
}
|
|
13313
|
-
}();
|
|
13314
|
-
if (_temp9 && _temp9.then) return _temp9.then(function () {});
|
|
13315
|
-
}, function (e) {
|
|
13316
|
-
Logger.logError(e, "getAssetToUsdtRate", "Failed via both fixed and floating providers");
|
|
13317
|
-
});
|
|
13318
|
-
return _temp10 && _temp10.then ? _temp10.then(_temp11) : _temp11(_temp10);
|
|
13319
|
-
};
|
|
13320
|
-
var _this11 = this;
|
|
13321
|
-
var result = null;
|
|
13322
|
-
var _temp12 = _catch(function () {
|
|
13323
|
-
return Promise.resolve(_this11._swapProvider.getCoinToUSDTRate(asset)).then(function (_this11$_swapProvider) {
|
|
13324
|
-
result = _this11$_swapProvider;
|
|
13325
|
-
});
|
|
13326
|
-
}, function (e) {
|
|
13327
|
-
Logger.logError(e, "getAssetToUsdtRate");
|
|
13328
|
-
});
|
|
13329
|
-
return Promise.resolve(_temp12 && _temp12.then ? _temp12.then(_temp13) : _temp13(_temp12));
|
|
13330
|
-
} catch (e) {
|
|
13331
|
-
return Promise.reject(e);
|
|
13332
|
-
}
|
|
13333
|
-
}
|
|
13334
|
-
/**
|
|
13335
|
-
* @param asset {Coin}
|
|
13336
|
-
* @param address {string}
|
|
13337
|
-
* @param [fixed=false] {boolean}
|
|
13338
|
-
* @return {boolean}
|
|
13339
|
-
*/
|
|
13340
|
-
;
|
|
13341
|
-
_proto.isAddressValidForAsset = function isAddressValidForAsset(asset, address, fixed) {
|
|
13342
|
-
if (fixed === void 0) {
|
|
13343
|
-
fixed = false;
|
|
13344
|
-
}
|
|
13345
|
-
try {
|
|
13346
|
-
return !fixed ? this._swapProvider.isAddressValidForAsset(asset, address) : this._fixedSwapProvider.isAddressValidForAsset(asset, address);
|
|
13347
|
-
} catch (e) {
|
|
13348
|
-
improveAndRethrow(e, "isAddressValidForAsset");
|
|
13349
|
-
}
|
|
13350
|
-
}
|
|
13351
|
-
|
|
13352
|
-
/**
|
|
13353
|
-
* Retrieves token by contract address.
|
|
13752
|
+
* Retrieves flat partners list across all supported providers (including aggregators).
|
|
13354
13753
|
*
|
|
13355
|
-
* @param
|
|
13356
|
-
* @param [fixed=false] {boolean}
|
|
13357
|
-
* @return {Promise<Coin|null>}
|
|
13358
|
-
*/;
|
|
13359
|
-
_proto.getTokenByContractAddress = function getTokenByContractAddress(addressString, fixed) {
|
|
13360
|
-
if (fixed === void 0) {
|
|
13361
|
-
fixed = false;
|
|
13362
|
-
}
|
|
13363
|
-
try {
|
|
13364
|
-
var _exit3;
|
|
13365
|
-
var _this12 = this;
|
|
13366
|
-
var _temp15 = _catch(function () {
|
|
13367
|
-
if (!addressString) {
|
|
13368
|
-
var _temp14 = null;
|
|
13369
|
-
_exit3 = 1;
|
|
13370
|
-
return _temp14;
|
|
13371
|
-
}
|
|
13372
|
-
var addressLowerCase = addressString.toLowerCase();
|
|
13373
|
-
return Promise.resolve((fixed ? _this12._fixedSwapProvider : _this12._swapProvider).getAllSupportedCurrencies()).then(function (allCoins) {
|
|
13374
|
-
if (allCoins.result) {
|
|
13375
|
-
var _allCoins$coins$find = allCoins.coins.find(function (coin) {
|
|
13376
|
-
return coin.tokenAddress && coin.tokenAddress.toLowerCase() === addressLowerCase;
|
|
13377
|
-
});
|
|
13378
|
-
_exit3 = 1;
|
|
13379
|
-
return _allCoins$coins$find;
|
|
13380
|
-
}
|
|
13381
|
-
});
|
|
13382
|
-
}, function (e) {
|
|
13383
|
-
Logger.logError(e, "getTokenByContractAddress");
|
|
13384
|
-
});
|
|
13385
|
-
return Promise.resolve(_temp15 && _temp15.then ? _temp15.then(function (_result14) {
|
|
13386
|
-
return _exit3 ? _result14 : null;
|
|
13387
|
-
}) : _exit3 ? _temp15 : null);
|
|
13388
|
-
} catch (e) {
|
|
13389
|
-
return Promise.reject(e);
|
|
13390
|
-
}
|
|
13391
|
-
}
|
|
13392
|
-
/**
|
|
13393
|
-
* @param asset {Coin}
|
|
13394
|
-
* @param [fixed=false] {boolean}
|
|
13395
|
-
* @return {string|null}
|
|
13396
|
-
*/
|
|
13397
|
-
;
|
|
13398
|
-
_proto.getExtraIdNameIfPresentForAsset = function getExtraIdNameIfPresentForAsset(asset, fixed) {
|
|
13399
|
-
if (fixed === void 0) {
|
|
13400
|
-
fixed = false;
|
|
13401
|
-
}
|
|
13402
|
-
try {
|
|
13403
|
-
return (fixed ? this._fixedSwapProvider : this._swapProvider).getExtraIdNameIfPresent(asset);
|
|
13404
|
-
} catch (e) {
|
|
13405
|
-
improveAndRethrow(e, "getExtraIdNameIfPresentForAsset");
|
|
13406
|
-
}
|
|
13407
|
-
}
|
|
13408
|
-
|
|
13409
|
-
/**
|
|
13410
|
-
* Retrieves flat partners list across all supported providers (including aggregators)
|
|
13754
|
+
* @param providers {SwapProvider[]}
|
|
13411
13755
|
* @return {Promise<Partner[]>}
|
|
13412
13756
|
*/;
|
|
13413
|
-
_proto.getPartnersList = function getPartnersList() {
|
|
13757
|
+
_proto.getPartnersList = function getPartnersList(providers) {
|
|
13414
13758
|
try {
|
|
13415
|
-
var
|
|
13416
|
-
return
|
|
13759
|
+
var _temp7 = function _temp7(_result4) {
|
|
13760
|
+
return _exit2 ? _result4 : [];
|
|
13417
13761
|
};
|
|
13418
|
-
var
|
|
13419
|
-
var
|
|
13420
|
-
|
|
13421
|
-
var allPartners = [_this13._swapProvider, _this13._fixedSwapProvider].map(function (provider) {
|
|
13762
|
+
var _exit2;
|
|
13763
|
+
var _temp6 = _catch(function () {
|
|
13764
|
+
var allPartners = providers.map(function (provider) {
|
|
13422
13765
|
return provider.getPartnersList();
|
|
13423
13766
|
});
|
|
13424
13767
|
return Promise.resolve(Promise.all(allPartners)).then(function (_Promise$all) {
|
|
@@ -13438,13 +13781,13 @@
|
|
|
13438
13781
|
}
|
|
13439
13782
|
return prev;
|
|
13440
13783
|
}, []);
|
|
13441
|
-
|
|
13784
|
+
_exit2 = 1;
|
|
13442
13785
|
return _allPartners$reduce;
|
|
13443
13786
|
});
|
|
13444
13787
|
}, function (e) {
|
|
13445
13788
|
Logger.logError(e, "getPartnersList");
|
|
13446
13789
|
});
|
|
13447
|
-
return Promise.resolve(
|
|
13790
|
+
return Promise.resolve(_temp6 && _temp6.then ? _temp6.then(_temp7) : _temp7(_temp6));
|
|
13448
13791
|
} catch (e) {
|
|
13449
13792
|
return Promise.reject(e);
|
|
13450
13793
|
}
|
|
@@ -13499,6 +13842,7 @@
|
|
|
13499
13842
|
exports.EmailsApi = EmailsApi;
|
|
13500
13843
|
exports.ExistingSwap = ExistingSwap;
|
|
13501
13844
|
exports.ExistingSwapWithFiatData = ExistingSwapWithFiatData;
|
|
13845
|
+
exports.ExolixSwapProvider = ExolixSwapProvider;
|
|
13502
13846
|
exports.ExternalApiProvider = ExternalApiProvider;
|
|
13503
13847
|
exports.FALLBACK_ASSET_ICON_URL = FALLBACK_ASSET_ICON_URL;
|
|
13504
13848
|
exports.FiatCurrenciesService = FiatCurrenciesService;
|