@rabbitio/ui-kit 1.0.0-beta.9 → 1.0.0-beta.91
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/.gitlab-ci.yml +29 -0
- package/.husky/commit-msg +19 -0
- package/.husky/pre-push +1 -0
- package/CHANGELOG.md +0 -0
- package/README.md +27 -18
- package/coverage/base.css +224 -0
- package/coverage/block-navigation.js +87 -0
- package/coverage/clover.xml +16765 -0
- package/coverage/coverage-final.json +116 -0
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +1001 -0
- package/coverage/prettify.css +1 -0
- package/coverage/prettify.js +2 -0
- package/coverage/rabbit-ui-kit/index.html +116 -0
- package/coverage/rabbit-ui-kit/index.js.html +88 -0
- package/coverage/rabbit-ui-kit/src/common-apis/adapters/analyticsAdapters/googleAnalyticsAdapter.js.html +148 -0
- package/coverage/rabbit-ui-kit/src/common-apis/adapters/analyticsAdapters/index.html +146 -0
- package/coverage/rabbit-ui-kit/src/common-apis/adapters/analyticsAdapters/metrikaAdapter.js.html +169 -0
- package/coverage/rabbit-ui-kit/src/common-apis/adapters/analyticsAdapters/mixpanelAdapter.js.html +199 -0
- package/coverage/rabbit-ui-kit/src/common-apis/adapters/axiosAdapter.js.html +190 -0
- package/coverage/rabbit-ui-kit/src/common-apis/adapters/index.html +131 -0
- package/coverage/rabbit-ui-kit/src/common-apis/adapters/qrUtils.js.html +139 -0
- package/coverage/rabbit-ui-kit/src/common-apis/external-apis/apiGroups.js.html +250 -0
- package/coverage/rabbit-ui-kit/src/common-apis/external-apis/emailAPI.js.html +133 -0
- package/coverage/rabbit-ui-kit/src/common-apis/external-apis/index.html +146 -0
- package/coverage/rabbit-ui-kit/src/common-apis/external-apis/ipAddressProviders.js.html +352 -0
- package/coverage/rabbit-ui-kit/src/common-apis/globalConstants.jsx.html +94 -0
- package/coverage/rabbit-ui-kit/src/common-apis/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/common-apis/models/blockchain.js.html +115 -0
- package/coverage/rabbit-ui-kit/src/common-apis/models/coin.js.html +829 -0
- package/coverage/rabbit-ui-kit/src/common-apis/models/index.html +146 -0
- package/coverage/rabbit-ui-kit/src/common-apis/models/protocol.js.html +100 -0
- package/coverage/rabbit-ui-kit/src/common-apis/services/fiatCurrenciesService.js.html +544 -0
- package/coverage/rabbit-ui-kit/src/common-apis/services/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/common-apis/utils/amountUtils.js.html +1162 -0
- package/coverage/rabbit-ui-kit/src/common-apis/utils/cache.js.html +811 -0
- package/coverage/rabbit-ui-kit/src/common-apis/utils/errorUtils.js.html +211 -0
- package/coverage/rabbit-ui-kit/src/common-apis/utils/index.html +191 -0
- package/coverage/rabbit-ui-kit/src/common-apis/utils/logging/index.html +131 -0
- package/coverage/rabbit-ui-kit/src/common-apis/utils/logging/logger.js.html +208 -0
- package/coverage/rabbit-ui-kit/src/common-apis/utils/logging/logsStorage.js.html +268 -0
- package/coverage/rabbit-ui-kit/src/common-apis/utils/postponeExecution.js.html +118 -0
- package/coverage/rabbit-ui-kit/src/common-apis/utils/rabbitTicker.js.html +157 -0
- package/coverage/rabbit-ui-kit/src/common-apis/utils/safeStringify.js.html +235 -0
- package/coverage/rabbit-ui-kit/src/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/index.js.html +376 -0
- package/coverage/rabbit-ui-kit/src/robust-api-caller/cacheAndConcurrentRequestsResolver.js.html +1570 -0
- package/coverage/rabbit-ui-kit/src/robust-api-caller/cachedRobustExternalApiCallerService.js.html +526 -0
- package/coverage/rabbit-ui-kit/src/robust-api-caller/cancelProcessing.js.html +172 -0
- package/coverage/rabbit-ui-kit/src/robust-api-caller/concurrentCalculationsMetadataHolder.js.html +310 -0
- package/coverage/rabbit-ui-kit/src/robust-api-caller/externalApiProvider.js.html +553 -0
- package/coverage/rabbit-ui-kit/src/robust-api-caller/externalServicesStatsCollector.js.html +319 -0
- package/coverage/rabbit-ui-kit/src/robust-api-caller/index.html +206 -0
- package/coverage/rabbit-ui-kit/src/robust-api-caller/robustExternalAPICallerService.js.html +997 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/exolixSwapProvider.js.html +1825 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/index.html +161 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/letsExchangeSwapProvider.js.html +1618 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/swapProvider.js.html +1819 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/swapspaceSwapProvider.js.html +1861 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/models/baseSwapCreationInfo.js.html +319 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/models/existingSwap.js.html +514 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/models/existingSwapWithFiatData.js.html +529 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/models/index.html +176 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/models/partner.js.html +166 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/models/swapProviderCoinInfo.js.html +331 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/services/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/services/publicSwapService.js.html +1555 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/utils/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/utils/swapUtils.js.html +670 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/arrowIcon.jsx.html +124 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/arrowTosca.jsx.html +127 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/arrowWhite.jsx.html +127 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/darkRectangle.jsx.html +106 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/determinedError.jsx.html +439 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/failedValidationIcon.jsx.html +202 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/index.html +281 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/infoIcon.jsx.html +133 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/messageIcon.jsx.html +346 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/noticeQuestionIcon.jsx.html +247 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/successfulValidationIcon.jsx.html +163 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/supportDialogImage.jsx.html +268 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/walletIcon.jsx.html +151 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/AssetIcon/AssetIcon.jsx.html +256 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/AssetIcon/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/AssetSelection/AssetSelection.jsx.html +289 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/AssetSelection/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/BackgroundTitle/BackgroundTitle.jsx.html +187 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/BackgroundTitle/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/InformationMessage/InformationMessage.jsx.html +238 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/InformationMessage/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Input/Input.jsx.html +634 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Input/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/LoadingDots/LoadingDots.jsx.html +196 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/LoadingDots/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/NoticeIcon/NoticeIcon.jsx.html +277 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/NoticeIcon/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/QrCode/QrCode.jsx.html +217 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/QrCode/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/RateSelector/RateSelector.jsx.html +175 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/RateSelector/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/SupportChat/SupportChat.jsx.html +217 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/SupportChat/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Textarea/Textarea.jsx.html +529 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Textarea/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/TitleBox/TitleBox.jsx.html +508 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/TitleBox/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Tooltip/Tooltip.jsx.html +316 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Tooltip/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/TwoLinesOfText/LinesOfText.jsx.html +313 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/TwoLinesOfText/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Validation/Validation.jsx.html +202 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Validation/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/Button/Button.jsx.html +712 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/Button/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/Close/Close.jsx.html +259 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/Close/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/LinkButton/LinkButton.jsx.html +421 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/LinkButton/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/RadioButtonWithText/RadioButtonWithText.jsx.html +415 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/RadioButtonWithText/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/AmountInput/AmountInput.jsx.html +1429 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/AmountInput/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/CoinPicker/CoinPicker.jsx.html +1474 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/CoinPicker/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/ColoredNotice/ColoredNotice.jsx.html +211 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/ColoredNotice/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/LineWithIconLink/LineWithIconLink.jsx.html +190 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/LineWithIconLink/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/LogoCarousel/LogoCarousel.jsx.html +307 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/LogoCarousel/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/SearchableCoinsList/SearchableCoinsList.jsx.html +496 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/SearchableCoinsList/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/TitledLineWithIconLink/TitledLineWithIconLink.jsx.html +181 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/TitledLineWithIconLink/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/CoinPickerDialogStep/CoinPickerDialogStep.jsx.html +283 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/CoinPickerDialogStep/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/Dialog/Dialog.jsx.html +1567 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/Dialog/DialogButtons/DialogButtons.jsx.html +481 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/Dialog/DialogButtons/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/Dialog/DialogStep/DialogStep.jsx.html +1747 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/Dialog/DialogStep/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/Dialog/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/SwapForm/SwapForm.jsx.html +4207 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/SwapForm/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/WaitlistSubscription/WaitlistSubscription.jsx.html +559 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/WaitlistSubscription/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/templates/DeterminedErrorDialogStep/DeterminedErrorDialogStep.jsx.html +316 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/templates/DeterminedErrorDialogStep/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/hooks/index.html +146 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/hooks/useCallHandlingErrors.js.html +151 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/hooks/useIsHydrated.js.html +121 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/hooks/useReferredState.js.html +157 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/utils/index.html +161 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/utils/inputValueProviders.js.html +235 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/utils/textUtils.js.html +139 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/utils/uiUtils.js.html +121 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/utils/urlQueryUtils.js.html +271 -0
- package/coverage/rabbit-ui-kit/stories/atoms/BackgroundTitle.stories.jsx.html +202 -0
- package/coverage/rabbit-ui-kit/stories/atoms/LinesOfText.stories.jsx.html +283 -0
- package/coverage/rabbit-ui-kit/stories/atoms/LoadingDots.stories.jsx.html +226 -0
- package/coverage/rabbit-ui-kit/stories/atoms/QrCode.stories.jsx.html +175 -0
- package/coverage/rabbit-ui-kit/stories/atoms/RateSelector.stories.jsx.html +136 -0
- package/coverage/rabbit-ui-kit/stories/atoms/Validation.stories.jsx.html +178 -0
- package/coverage/rabbit-ui-kit/stories/atoms/buttons/Button.stories.jsx.html +883 -0
- package/coverage/rabbit-ui-kit/stories/atoms/buttons/Close.stories.jsx.html +211 -0
- package/coverage/rabbit-ui-kit/stories/atoms/buttons/LinkButton.stories.jsx.html +301 -0
- package/coverage/rabbit-ui-kit/stories/atoms/buttons/index.html +146 -0
- package/coverage/rabbit-ui-kit/stories/atoms/index.html +191 -0
- package/coverage/rabbit-ui-kit/stories/molecules/AmountInput.stories.jsx.html +289 -0
- package/coverage/rabbit-ui-kit/stories/molecules/CoinPicker.stories.jsx.html +322 -0
- package/coverage/rabbit-ui-kit/stories/molecules/ColoredNotice.stories.jsx.html +178 -0
- package/coverage/rabbit-ui-kit/stories/molecules/LineWithIconLink.stories.jsx.html +154 -0
- package/coverage/rabbit-ui-kit/stories/molecules/LogoCarousel.stories.jsx.html +235 -0
- package/coverage/rabbit-ui-kit/stories/molecules/TitledLineWithIconLink.stories.jsx.html +160 -0
- package/coverage/rabbit-ui-kit/stories/molecules/index.html +191 -0
- package/coverage/rabbit-ui-kit/stories/organisms/Dialog/Dialog.stories.jsx.html +523 -0
- package/coverage/rabbit-ui-kit/stories/organisms/Dialog/DialogButtons/DialogButtons.stories.jsx.html +328 -0
- package/coverage/rabbit-ui-kit/stories/organisms/Dialog/DialogButtons/index.html +116 -0
- package/coverage/rabbit-ui-kit/stories/organisms/Dialog/DialogStep/DialogStep.stories.jsx.html +337 -0
- package/coverage/rabbit-ui-kit/stories/organisms/Dialog/DialogStep/index.html +116 -0
- package/coverage/rabbit-ui-kit/stories/organisms/Dialog/index.html +116 -0
- package/coverage/rabbit-ui-kit/stories/organisms/WaitlistSubscription.stories.jsx.html +151 -0
- package/coverage/rabbit-ui-kit/stories/organisms/index.html +116 -0
- package/coverage/rabbit-ui-kit/stories/stubs/coins.jsx.html +6880 -0
- package/coverage/rabbit-ui-kit/stories/stubs/exampleContent.jsx.html +145 -0
- package/coverage/rabbit-ui-kit/stories/stubs/index.html +131 -0
- package/coverage/rabbit-ui-kit/stories/templates/DeterminedErrorDialogStep.stories.jsx.html +190 -0
- package/coverage/rabbit-ui-kit/stories/templates/index.html +116 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +196 -0
- package/dist/global.css +197 -0
- package/dist/global.css.map +1 -0
- package/dist/index.cjs +12451 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +2339 -8491
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +9597 -26
- package/dist/index.modern.js.map +1 -1
- package/dist/index.module.js +12357 -27
- package/dist/index.module.js.map +1 -1
- package/dist/index.umd.js +12442 -29
- package/dist/index.umd.js.map +1 -1
- package/package.json +35 -9
- package/raw +1000 -0
- package/src/common-apis/adapters/analyticsAdapters/googleAnalyticsAdapter.js +21 -0
- package/src/common-apis/adapters/analyticsAdapters/metrikaAdapter.js +28 -0
- package/src/common-apis/adapters/analyticsAdapters/mixpanelAdapter.js +38 -0
- package/src/common-apis/adapters/axiosAdapter.js +35 -0
- package/src/common-apis/adapters/qrUtils.js +18 -0
- package/src/common-apis/external-apis/apiGroups.js +55 -0
- package/src/common-apis/external-apis/emailAPI.js +16 -0
- package/src/common-apis/external-apis/ipAddressProviders.js +89 -0
- package/src/common-apis/globalConstants.jsx +3 -0
- package/src/common-apis/models/blockchain.js +10 -0
- package/src/common-apis/models/coin.js +248 -0
- package/src/common-apis/models/protocol.js +5 -0
- package/src/{common → common-apis/services}/fiatCurrenciesService.js +4 -12
- package/src/common-apis/tests/integration/external-apis/ipAddressProviders/getClientIpAddress.test.js +12 -0
- package/src/common-apis/tests/units/utils/amountUtils/composeRateText.test.js +152 -0
- package/src/{common → common-apis/utils}/amountUtils.js +72 -136
- package/src/common-apis/utils/cache.js +242 -0
- package/src/{common → common-apis/utils}/errorUtils.js +15 -0
- package/src/common-apis/utils/logging/logger.js +41 -0
- package/src/common-apis/utils/logging/logsStorage.js +61 -0
- package/src/common-apis/utils/postponeExecution.js +11 -0
- package/src/common-apis/utils/rabbitTicker.js +24 -0
- package/src/common-apis/utils/safeStringify.js +50 -0
- package/src/index.js +96 -9
- package/src/robust-api-caller/cacheAndConcurrentRequestsResolver.js +495 -0
- package/src/robust-api-caller/cachedRobustExternalApiCallerService.js +147 -0
- package/src/robust-api-caller/cancelProcessing.js +29 -0
- package/src/robust-api-caller/concurrentCalculationsMetadataHolder.js +75 -0
- package/src/robust-api-caller/externalApiProvider.js +156 -0
- package/src/robust-api-caller/externalServicesStatsCollector.js +78 -0
- package/src/robust-api-caller/robustExternalAPICallerService.js +304 -0
- package/src/robust-api-caller/tests/robustExternalAPICallerService/robustExternalAPICallerService/callExternalAPI/_performCallAttempt.test.js +533 -0
- package/src/robust-api-caller/tests/robustExternalAPICallerService/robustExternalAPICallerService/callExternalAPI/callExternalAPI.test.js +532 -0
- package/src/robust-api-caller/tests/robustExternalAPICallerService/robustExternalAPICallerService/constructor.test.js +19 -0
- package/src/swaps-lib/external-apis/exolixSwapProvider.js +580 -0
- package/src/swaps-lib/external-apis/letsExchangeSwapProvider.js +511 -0
- package/src/swaps-lib/external-apis/swapProvider.js +578 -0
- package/src/swaps-lib/external-apis/swapspaceSwapProvider.js +592 -0
- package/src/swaps-lib/models/baseSwapCreationInfo.js +78 -0
- package/src/swaps-lib/models/existingSwap.js +143 -0
- package/src/swaps-lib/models/existingSwapWithFiatData.js +148 -0
- package/src/swaps-lib/models/partner.js +27 -0
- package/src/swaps-lib/models/swapProviderCoinInfo.js +82 -0
- package/src/swaps-lib/services/publicSwapService.js +490 -0
- 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/swapProvider/getAllSupportedCurrencies.test.js +63 -0
- package/src/swaps-lib/test/external-apis/swapProvider/getDepositCurrencies.test.js +73 -0
- package/src/swaps-lib/test/external-apis/swapProvider/getWithdrawalCurrencies.test.js +102 -0
- package/src/swaps-lib/test/external-apis/swapProvider/removeProtocolNameFromCoinName.test.js +152 -0
- package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/_fetchSupportedCurrenciesIfNeeded.test.js +536 -0
- package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/createSwap.test.js +1214 -0
- package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/getSwapInfo.test.js +1707 -0
- package/src/swaps-lib/test/utils/swapUtils/safeHandleRequestsLimitExceeding.test.js +80 -0
- package/src/swaps-lib/utils/swapUtils.js +195 -0
- package/{styles → src/ui-kit/assets/styles}/_functions.scss +5 -0
- package/{styles → src/ui-kit/assets/styles}/_mixins.scss +2 -2
- package/{styles → src/ui-kit/assets/styles}/_placeholder.scss +3 -3
- package/{styles → src/ui-kit/assets/styles}/_variables.scss +17 -15
- package/src/ui-kit/assets/styles/fonts/NunitoSans-Bold.ttf +0 -0
- package/src/ui-kit/assets/styles/fonts/NunitoSans-ExtraBold.ttf +0 -0
- package/src/ui-kit/assets/styles/fonts/NunitoSans-Light.ttf +0 -0
- package/src/ui-kit/assets/styles/fonts/NunitoSans-Regular.ttf +0 -0
- package/src/ui-kit/assets/styles/fonts/NunitoSans-SemiBold.ttf +0 -0
- package/src/ui-kit/assets/styles/global.scss +171 -0
- package/src/ui-kit/assets/styles/index.scss +10 -0
- package/src/ui-kit/assets/wrappedImages/arrowIcon.jsx +13 -0
- package/src/ui-kit/assets/wrappedImages/arrowTosca.jsx +14 -0
- package/src/ui-kit/assets/wrappedImages/arrowWhite.jsx +14 -0
- package/src/ui-kit/assets/wrappedImages/darkRectangle.jsx +7 -0
- package/src/ui-kit/assets/wrappedImages/determinedError.jsx +118 -0
- package/src/ui-kit/assets/wrappedImages/failedValidationIcon.jsx +39 -0
- package/src/ui-kit/assets/wrappedImages/infoIcon.jsx +16 -0
- package/src/ui-kit/assets/wrappedImages/messageIcon.jsx +87 -0
- package/src/ui-kit/assets/wrappedImages/noticeQuestionIcon.jsx +54 -0
- package/src/ui-kit/assets/wrappedImages/successfulValidationIcon.jsx +26 -0
- package/src/ui-kit/assets/wrappedImages/supportDialogImage.jsx +61 -0
- package/src/ui-kit/assets/wrappedImages/walletIcon.jsx +22 -0
- package/src/ui-kit/components/atoms/AssetIcon/AssetIcon.jsx +57 -0
- package/src/{components → ui-kit/components}/atoms/AssetIcon/asset-icon.module.scss +1 -1
- package/src/ui-kit/components/atoms/AssetSelection/AssetSelection.jsx +68 -0
- package/src/ui-kit/components/atoms/AssetSelection/asset-selection.module.scss +56 -0
- package/src/ui-kit/components/atoms/BackgroundTitle/BackgroundTitle.jsx +34 -0
- package/src/ui-kit/components/atoms/BackgroundTitle/background-title.module.scss +52 -0
- package/src/ui-kit/components/atoms/InformationMessage/InformationMessage.jsx +51 -0
- package/src/ui-kit/components/atoms/InformationMessage/information-message.module.scss +38 -0
- package/src/ui-kit/components/atoms/Input/Input.jsx +183 -0
- package/src/ui-kit/components/atoms/Input/input.module.scss +107 -0
- package/src/{components → ui-kit/components}/atoms/LoadingDots/LoadingDots.jsx +8 -28
- package/src/{components → ui-kit/components}/atoms/LoadingDots/LoadingDots.module.scss +3 -2
- package/src/ui-kit/components/atoms/NoticeIcon/NoticeIcon.jsx +64 -0
- package/src/ui-kit/components/atoms/NoticeIcon/notice-icon.module.scss +14 -0
- package/src/ui-kit/components/atoms/QrCode/QrCode.jsx +44 -0
- package/src/ui-kit/components/atoms/QrCode/qr-code.module.scss +15 -0
- package/src/ui-kit/components/atoms/RateSelector/RateSelector.jsx +30 -0
- package/src/ui-kit/components/atoms/RateSelector/rate-selector.module.scss +47 -0
- package/src/{components → ui-kit/components}/atoms/SupportChat/SupportChat.jsx +5 -1
- package/src/ui-kit/components/atoms/Textarea/Textarea.jsx +148 -0
- package/src/ui-kit/components/atoms/Textarea/textarea.module.scss +71 -0
- package/src/ui-kit/components/atoms/TitleBox/TitleBox.jsx +141 -0
- package/src/ui-kit/components/atoms/TitleBox/title-box.module.scss +32 -0
- package/src/ui-kit/components/atoms/Tooltip/Tooltip.jsx +77 -0
- package/src/ui-kit/components/atoms/Tooltip/tooltip.module.scss +237 -0
- package/src/ui-kit/components/atoms/TwoLinesOfText/LinesOfText.jsx +76 -0
- package/src/ui-kit/components/atoms/TwoLinesOfText/lines-of-text.module.scss +65 -0
- package/src/ui-kit/components/atoms/Validation/Validation.jsx +39 -0
- package/src/ui-kit/components/atoms/Validation/validation.module.scss +19 -0
- package/src/{components → ui-kit/components}/atoms/buttons/Button/Button.jsx +24 -50
- package/src/{components → ui-kit/components}/atoms/buttons/Button/Button.module.scss +1 -1
- package/src/ui-kit/components/atoms/buttons/Close/Close.jsx +58 -0
- package/src/ui-kit/components/atoms/buttons/Close/close.module.scss +75 -0
- package/src/ui-kit/components/atoms/buttons/LinkButton/LinkButton.jsx +112 -0
- package/src/ui-kit/components/atoms/buttons/LinkButton/link-button.module.scss +49 -0
- package/src/ui-kit/components/atoms/buttons/RadioButtonWithText/RadioButtonWithText.jsx +110 -0
- package/src/ui-kit/components/atoms/buttons/RadioButtonWithText/radio-button-with-text.module.scss +86 -0
- package/src/ui-kit/components/molecules/AmountInput/AmountInput.jsx +448 -0
- package/src/ui-kit/components/molecules/AmountInput/amount-input.module.scss +233 -0
- package/src/ui-kit/components/molecules/CoinPicker/CoinPicker.jsx +463 -0
- package/src/ui-kit/components/molecules/CoinPicker/coin-picker.module.scss +207 -0
- package/src/ui-kit/components/molecules/ColoredNotice/ColoredNotice.jsx +42 -0
- package/src/ui-kit/components/molecules/ColoredNotice/colored-notice.module.scss +20 -0
- package/src/ui-kit/components/molecules/LineWithIconLink/LineWithIconLink.jsx +35 -0
- package/src/ui-kit/components/molecules/LineWithIconLink/line-with-icon-link.module.scss +25 -0
- package/src/ui-kit/components/molecules/LogoCarousel/LogoCarousel.jsx +74 -0
- package/src/ui-kit/components/molecules/LogoCarousel/logo-carousel.module.scss +106 -0
- package/src/ui-kit/components/molecules/SearchableCoinsList/SearchableCoinsList.jsx +137 -0
- package/src/ui-kit/components/molecules/TitledLineWithIconLink/TitledLineWithIconLink.jsx +32 -0
- package/src/ui-kit/components/organisms/CoinPickerDialogStep/CoinPickerDialogStep.jsx +66 -0
- package/src/ui-kit/components/organisms/Dialog/Dialog.jsx +494 -0
- package/src/ui-kit/components/organisms/Dialog/DialogButtons/DialogButtons.jsx +132 -0
- package/src/ui-kit/components/organisms/Dialog/DialogButtons/dialog-buttons.module.scss +25 -0
- package/src/ui-kit/components/organisms/Dialog/DialogStep/DialogStep.jsx +554 -0
- package/src/ui-kit/components/organisms/Dialog/DialogStep/dialog-step.module.scss +381 -0
- package/src/ui-kit/components/organisms/Dialog/dialog.module.scss +226 -0
- package/src/ui-kit/components/organisms/SwapForm/SwapForm.jsx +1374 -0
- package/src/ui-kit/components/organisms/SwapForm/swap-form.module.scss +134 -0
- package/src/ui-kit/components/organisms/WaitlistSubscription/WaitlistSubscription.jsx +158 -0
- package/src/ui-kit/components/templates/DeterminedErrorDialogStep/DeterminedErrorDialogStep.jsx +77 -0
- package/src/ui-kit/hooks/useCallHandlingErrors.js +22 -0
- package/src/ui-kit/hooks/useIsHydrated.js +12 -0
- package/src/ui-kit/hooks/useReferredState.js +24 -0
- package/src/ui-kit/tests/utils/inputValueProviders/provideFormatOfFloatValueByInputString.test.js +146 -0
- package/src/ui-kit/tests/utils/urlQueryUtils/getQueryParameterValues.test.js +65 -0
- package/src/ui-kit/tests/utils/urlQueryUtils/saveQueryParameterAndValues.test.js +104 -0
- package/src/ui-kit/utils/inputValueProviders.js +50 -0
- package/src/ui-kit/utils/textUtils.js +18 -0
- package/src/ui-kit/utils/uiUtils.js +12 -0
- package/src/ui-kit/utils/urlQueryUtils.js +62 -0
- package/stories/font.scss +40 -0
- package/stories/stubs/coins.jsx +2266 -0
- package/stories/stubs/exampleContent.jsx +20 -0
- package/src/components/atoms/AssetIcon/AssetIcon.jsx +0 -55
- package/styles/_global-classes.scss +0 -433
- package/styles/fonts/NunitoSans-Bold.ttf +0 -0
- package/styles/fonts/NunitoSans-ExtraBold.ttf +0 -0
- package/styles/fonts/NunitoSans-Light.ttf +0 -0
- package/styles/fonts/NunitoSans-Regular.ttf +0 -0
- package/styles/fonts/NunitoSans-SemiBold.ttf +0 -0
- package/styles/global-styles-index.scss +0 -74
- package/styles/index.scss +0 -33
- /package/{styles → src/ui-kit/assets/styles}/colors/_light-colors.scss +0 -0
- /package/{styles → src/ui-kit/assets/styles}/colors/_solid-colors.scss +0 -0
- /package/{styles → src/ui-kit/assets/styles}/size/_margin-size.scss +0 -0
- /package/{styles → src/ui-kit/assets/styles}/size/_padding-size.scss +0 -0
|
@@ -0,0 +1,490 @@
|
|
|
1
|
+
import { BigNumber } from "bignumber.js";
|
|
2
|
+
|
|
3
|
+
import { FiatCurrenciesService } from "../../common-apis/services/fiatCurrenciesService.js";
|
|
4
|
+
import { improveAndRethrow } from "../../common-apis/utils/errorUtils.js";
|
|
5
|
+
import { safeStringify } from "../../common-apis/utils/safeStringify.js";
|
|
6
|
+
import { Logger } from "../../common-apis/utils/logging/logger.js";
|
|
7
|
+
import { Coin } from "../../common-apis/models/coin.js";
|
|
8
|
+
import { AmountUtils } from "../../common-apis/utils/amountUtils.js";
|
|
9
|
+
import { BaseSwapCreationInfo } from "../models/baseSwapCreationInfo.js";
|
|
10
|
+
import { SwapUtils } from "../utils/swapUtils.js";
|
|
11
|
+
import { SwapspaceSwapProvider } from "../external-apis/swapspaceSwapProvider.js";
|
|
12
|
+
import { SwapProvider } from "../external-apis/swapProvider.js";
|
|
13
|
+
import { LetsExchangeSwapProvider } from "../external-apis/letsExchangeSwapProvider.js";
|
|
14
|
+
import { GoogleAnalyticsAdapter } from "../../common-apis/adapters/analyticsAdapters/googleAnalyticsAdapter.js";
|
|
15
|
+
|
|
16
|
+
export class PublicSwapService {
|
|
17
|
+
static PUBLIC_SWAP_CREATED_ANALYTICS_EVENT = "public_swap_created_event";
|
|
18
|
+
static PUBLIC_SWAP_SUCCEED_ANALYTICS_EVENT = "public_swap_succeed_event";
|
|
19
|
+
|
|
20
|
+
static PUBLIC_SWAPS_COMMON_ERRORS = {
|
|
21
|
+
REQUESTS_LIMIT_EXCEEDED: "requestsLimitExceeded",
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
static PUBLIC_SWAP_DETAILS_FAIL_REASONS = {
|
|
25
|
+
AMOUNT_LESS_THAN_MIN_SWAPPABLE: "amountLessThanMinSwappable",
|
|
26
|
+
AMOUNT_HIGHER_THAN_MAX_SWAPPABLE: "amountHigherThanMaxSwappable",
|
|
27
|
+
PAIR_NOT_SUPPORTED: "pairNotSupported",
|
|
28
|
+
NO_FIXED_BUT_HAVE_FLOATING_PUBLIC_SWAP_OPTION: "noFixedButHaveFloatingPublicSwapOption",
|
|
29
|
+
NO_FLOATING_BUT_HAVE_FIXED_PUBLIC_SWAP_OPTION: "noFloatingButHaveFixedPublicSwapOption",
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
static _fiatDecimalsCount = FiatCurrenciesService.getCurrencyDecimalCountByCode("USD");
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* TODO: [feature, critical] implement more adequate providers list&initiation logic. task_id=6a6b0fbbee8a413690c49b1e4ee289cb
|
|
36
|
+
*
|
|
37
|
+
* @param apiKeysProxyUrl {string|null}
|
|
38
|
+
* @param cache {Cache}
|
|
39
|
+
* @param providers {SwapProvider[]|null}
|
|
40
|
+
*/
|
|
41
|
+
constructor(apiKeysProxyUrl, cache, providers = null) {
|
|
42
|
+
if (apiKeysProxyUrl) {
|
|
43
|
+
this._swapProvider = new SwapspaceSwapProvider(apiKeysProxyUrl, cache, () => null, false);
|
|
44
|
+
this._fixedSwapProvider = new LetsExchangeSwapProvider(apiKeysProxyUrl, cache, () => null, false);
|
|
45
|
+
} else if (providers?.length) {
|
|
46
|
+
this._swapProvider = providers.find(p => p.id === "swapspace");
|
|
47
|
+
this._fixedSwapProvider = providers.find(p => p.id === "letsexchange");
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async initialize() {
|
|
52
|
+
try {
|
|
53
|
+
await Promise.all([this._swapProvider.initialize(), this._fixedSwapProvider.initialize()]);
|
|
54
|
+
} catch (e) {
|
|
55
|
+
Logger.logError(e, "PublicSwapService.initialize");
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Retrieves swap details that can be used to create swap.
|
|
61
|
+
*
|
|
62
|
+
* @param provider {SwapProvider}
|
|
63
|
+
* @param fromCoinOrTicker {Coin|string}
|
|
64
|
+
* @param toCoinOrTicker {Coin|string}
|
|
65
|
+
* @param amountCoins {string}
|
|
66
|
+
* @param [fixed=false] {boolean|null} null means fixed or float doesn't matter
|
|
67
|
+
* @param [coinUsdtRate=null] {number|null} rate of amount coin to USDT
|
|
68
|
+
* @param [amountIsToReceive=false] {boolean} whether the given amount is receiving amount.
|
|
69
|
+
* False means the amount is the sending amount.
|
|
70
|
+
* @param bannedPartners {string[]} array of banned swap partners (providers) ids (rabbit ids)
|
|
71
|
+
* @return {Promise<{
|
|
72
|
+
* result: false,
|
|
73
|
+
* reason: string,
|
|
74
|
+
* min: (string|null),
|
|
75
|
+
* max: (string|null),
|
|
76
|
+
* rate: (string|undefined),
|
|
77
|
+
* fiatMin: (number|null),
|
|
78
|
+
* fiatMax: (number|null)
|
|
79
|
+
* }|{
|
|
80
|
+
* result: true,
|
|
81
|
+
* swapCreationInfo: BaseSwapCreationInfo
|
|
82
|
+
* }>}
|
|
83
|
+
*/
|
|
84
|
+
async getPublicSwapDetails(
|
|
85
|
+
provider,
|
|
86
|
+
fromCoinOrTicker,
|
|
87
|
+
toCoinOrTicker,
|
|
88
|
+
amountCoins,
|
|
89
|
+
fixed = false,
|
|
90
|
+
coinUsdtRate = null,
|
|
91
|
+
amountIsToReceive = false,
|
|
92
|
+
bannedPartners = []
|
|
93
|
+
) {
|
|
94
|
+
const loggerSource = "getPublicSwapDetails";
|
|
95
|
+
try {
|
|
96
|
+
if (amountIsToReceive && !fixed) {
|
|
97
|
+
throw new Error("Estimating allowed only for fixed rate.");
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
let fromCoin = fromCoinOrTicker;
|
|
101
|
+
if (typeof fromCoin === "string") {
|
|
102
|
+
fromCoin = this.getCoinByTickerIfPresent(fromCoin);
|
|
103
|
+
}
|
|
104
|
+
let toCoin = toCoinOrTicker;
|
|
105
|
+
if (typeof toCoin === "string") {
|
|
106
|
+
toCoin = this.getCoinByTickerIfPresent(toCoin);
|
|
107
|
+
}
|
|
108
|
+
const isPartnerBanned = !!bannedPartners.find(banned => banned === provider.id);
|
|
109
|
+
if (!fromCoin || !toCoin || isPartnerBanned) {
|
|
110
|
+
return {
|
|
111
|
+
result: false,
|
|
112
|
+
reason: PublicSwapService.PUBLIC_SWAP_DETAILS_FAIL_REASONS.PAIR_NOT_SUPPORTED,
|
|
113
|
+
min: null,
|
|
114
|
+
max: null,
|
|
115
|
+
fiatMin: null,
|
|
116
|
+
fiatMax: null,
|
|
117
|
+
rate: undefined,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const details = await provider.getSwapInfo(
|
|
122
|
+
fromCoin,
|
|
123
|
+
toCoin,
|
|
124
|
+
amountCoins,
|
|
125
|
+
fixed,
|
|
126
|
+
coinUsdtRate,
|
|
127
|
+
amountIsToReceive,
|
|
128
|
+
bannedPartners
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
// eslint-disable-next-line no-console
|
|
132
|
+
console.log("getSwapInfo raw result: ", details, loggerSource);
|
|
133
|
+
|
|
134
|
+
const min =
|
|
135
|
+
details.smallestMin != null && BigNumber(details.smallestMin).gt("0") ? details.smallestMin : null;
|
|
136
|
+
const max =
|
|
137
|
+
details.greatestMax != null && BigNumber(details.greatestMax).gt("0") ? details.greatestMax : null;
|
|
138
|
+
let fiatMin = null,
|
|
139
|
+
fiatMax = null;
|
|
140
|
+
if (coinUsdtRate != null) {
|
|
141
|
+
if (min != null) {
|
|
142
|
+
fiatMin = BigNumber(min).times(coinUsdtRate).toFixed(PublicSwapService._fiatDecimalsCount);
|
|
143
|
+
}
|
|
144
|
+
if (max != null) {
|
|
145
|
+
fiatMax = BigNumber(max).times(coinUsdtRate).toFixed(PublicSwapService._fiatDecimalsCount);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const composeFailResult = reason => ({
|
|
150
|
+
result: false,
|
|
151
|
+
reason: reason,
|
|
152
|
+
min: min ?? null,
|
|
153
|
+
fiatMin: fiatMin,
|
|
154
|
+
max: max ?? null,
|
|
155
|
+
fiatMax: fiatMax,
|
|
156
|
+
rate: details.rate ?? null,
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
if (!details.result) {
|
|
160
|
+
if (details?.reason === SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED) {
|
|
161
|
+
return composeFailResult(PublicSwapService.PUBLIC_SWAP_DETAILS_FAIL_REASONS.PAIR_NOT_SUPPORTED);
|
|
162
|
+
} else if (details?.reason === SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED) {
|
|
163
|
+
SwapUtils.safeHandleRequestsLimitExceeding();
|
|
164
|
+
return composeFailResult(PublicSwapService.PUBLIC_SWAPS_COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED);
|
|
165
|
+
} else if (details?.reason === SwapProvider.NO_SWAPS_REASONS.NO_FLOATING_BUT_HAVE_FIXED) {
|
|
166
|
+
return composeFailResult(
|
|
167
|
+
PublicSwapService.PUBLIC_SWAP_DETAILS_FAIL_REASONS.NO_FLOATING_BUT_HAVE_FIXED_PUBLIC_SWAP_OPTION
|
|
168
|
+
);
|
|
169
|
+
} else if (details?.reason === SwapProvider.NO_SWAPS_REASONS.NO_FIXED_BUT_HAVE_FLOATING) {
|
|
170
|
+
return composeFailResult(
|
|
171
|
+
PublicSwapService.PUBLIC_SWAP_DETAILS_FAIL_REASONS.NO_FIXED_BUT_HAVE_FLOATING_PUBLIC_SWAP_OPTION
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const amountBigNumber = BigNumber(amountCoins);
|
|
177
|
+
if (typeof min === "string" && amountBigNumber.lt(min)) {
|
|
178
|
+
return composeFailResult(
|
|
179
|
+
PublicSwapService.PUBLIC_SWAP_DETAILS_FAIL_REASONS.AMOUNT_LESS_THAN_MIN_SWAPPABLE
|
|
180
|
+
);
|
|
181
|
+
} else if (typeof max === "string" && amountBigNumber.gt(max)) {
|
|
182
|
+
return composeFailResult(
|
|
183
|
+
PublicSwapService.PUBLIC_SWAP_DETAILS_FAIL_REASONS.AMOUNT_HIGHER_THAN_MAX_SWAPPABLE
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const fromAmountCoins = amountIsToReceive
|
|
188
|
+
? AmountUtils.trim(amountBigNumber.div(details.rate), fromCoin.digits)
|
|
189
|
+
: amountCoins;
|
|
190
|
+
const toAmountCoins = amountIsToReceive
|
|
191
|
+
? amountCoins
|
|
192
|
+
: AmountUtils.trim(amountBigNumber.times(details.rate), toCoin.digits);
|
|
193
|
+
const result = {
|
|
194
|
+
result: true,
|
|
195
|
+
swapCreationInfo: new BaseSwapCreationInfo(
|
|
196
|
+
fromCoin,
|
|
197
|
+
toCoin,
|
|
198
|
+
fromAmountCoins,
|
|
199
|
+
toAmountCoins,
|
|
200
|
+
details.rate,
|
|
201
|
+
details.rawSwapData,
|
|
202
|
+
min,
|
|
203
|
+
fiatMin,
|
|
204
|
+
max,
|
|
205
|
+
fiatMax,
|
|
206
|
+
details.durationMinutesRange,
|
|
207
|
+
details.fixed,
|
|
208
|
+
provider.id,
|
|
209
|
+
details.isRefundAddressRequired
|
|
210
|
+
),
|
|
211
|
+
};
|
|
212
|
+
Logger.log(
|
|
213
|
+
`Result: ${safeStringify({
|
|
214
|
+
result: result.result,
|
|
215
|
+
swapCreationInfo: {
|
|
216
|
+
...result.swapCreationInfo,
|
|
217
|
+
fromCoin: result?.swapCreationInfo?.fromCoin?.ticker,
|
|
218
|
+
toCoin: result?.swapCreationInfo?.toCoin?.ticker,
|
|
219
|
+
},
|
|
220
|
+
})}`,
|
|
221
|
+
loggerSource
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
return result;
|
|
225
|
+
} catch (e) {
|
|
226
|
+
improveAndRethrow(e, loggerSource);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Creates swap by given params.
|
|
232
|
+
*
|
|
233
|
+
* @param provider {SwapProvider}
|
|
234
|
+
* @param fromCoinTicker {string}
|
|
235
|
+
* @param toCoinTicker {string}
|
|
236
|
+
* @param amount {string}
|
|
237
|
+
* @param proprietarySwapEstimationData {Object|null}
|
|
238
|
+
* @param toAddress {string}
|
|
239
|
+
* @param refundAddress {string}
|
|
240
|
+
* @param clientIp {string}
|
|
241
|
+
* @param [toCurrencyExtraId] {string}
|
|
242
|
+
* @param [refundExtraId] {string}
|
|
243
|
+
* @param [amountIsToReceive=false] {boolean} whether the given amount is receiving amount.
|
|
244
|
+
* False means the amount is the sending amount.
|
|
245
|
+
* @param isFixed {boolean}
|
|
246
|
+
* @return {Promise<{
|
|
247
|
+
* result: true,
|
|
248
|
+
* fiatCurrencyCode: string,
|
|
249
|
+
* toCoinTicker: string,
|
|
250
|
+
* fromAmountFiat: (number|null),
|
|
251
|
+
* address: string,
|
|
252
|
+
* durationMinutesRange: string,
|
|
253
|
+
* fromAmount: string,
|
|
254
|
+
* toAmount: string,
|
|
255
|
+
* toAmountFiat: (number|null),
|
|
256
|
+
* fiatCurrencyDecimals: number,
|
|
257
|
+
* fromCoinTicker: string,
|
|
258
|
+
* rate: string,
|
|
259
|
+
* swapId: string,
|
|
260
|
+
* fromCurrencyExtraId: string,
|
|
261
|
+
* fixed: boolean
|
|
262
|
+
* }|{
|
|
263
|
+
* result: false,
|
|
264
|
+
* reason: string
|
|
265
|
+
* }>}
|
|
266
|
+
*/
|
|
267
|
+
async createPublicSwap(
|
|
268
|
+
provider,
|
|
269
|
+
fromCoinTicker,
|
|
270
|
+
toCoinTicker,
|
|
271
|
+
amount,
|
|
272
|
+
proprietarySwapEstimationData,
|
|
273
|
+
toAddress,
|
|
274
|
+
refundAddress,
|
|
275
|
+
clientIp,
|
|
276
|
+
toCurrencyExtraId,
|
|
277
|
+
refundExtraId,
|
|
278
|
+
amountIsToReceive = false,
|
|
279
|
+
isFixed = false
|
|
280
|
+
) {
|
|
281
|
+
const loggerSource = "createPublicSwap";
|
|
282
|
+
try {
|
|
283
|
+
if (
|
|
284
|
+
!(provider instanceof SwapProvider) ||
|
|
285
|
+
typeof fromCoinTicker !== "string" ||
|
|
286
|
+
typeof toCoinTicker !== "string" ||
|
|
287
|
+
typeof amount !== "string" ||
|
|
288
|
+
typeof toAddress !== "string"
|
|
289
|
+
) {
|
|
290
|
+
throw new Error(`Wrong input: ${provider} ${fromCoinTicker} ${toCoinTicker} ${amount} ${isFixed}`);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
Logger.log(
|
|
294
|
+
`Start: ${provider.id} ${amount} ${fromCoinTicker} -> ${toCoinTicker}. raw data: ${proprietarySwapEstimationData}`,
|
|
295
|
+
loggerSource
|
|
296
|
+
);
|
|
297
|
+
|
|
298
|
+
const [fromCoin, toCoin] = [fromCoinTicker, toCoinTicker].map(t => this.getCoinByTickerIfPresent(t));
|
|
299
|
+
const result = await provider.createSwap(
|
|
300
|
+
fromCoin,
|
|
301
|
+
toCoin,
|
|
302
|
+
amount,
|
|
303
|
+
toAddress,
|
|
304
|
+
refundAddress,
|
|
305
|
+
proprietarySwapEstimationData,
|
|
306
|
+
clientIp,
|
|
307
|
+
isFixed,
|
|
308
|
+
toCurrencyExtraId,
|
|
309
|
+
refundExtraId,
|
|
310
|
+
amountIsToReceive
|
|
311
|
+
);
|
|
312
|
+
Logger.log(
|
|
313
|
+
`Created:${safeStringify({ ...result, fromCoin: fromCoinTicker, toCoin: toCoinTicker })}`,
|
|
314
|
+
loggerSource
|
|
315
|
+
);
|
|
316
|
+
if (!result?.result) {
|
|
317
|
+
if (result?.reason === SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED) {
|
|
318
|
+
SwapUtils.safeHandleRequestsLimitExceeding();
|
|
319
|
+
return {
|
|
320
|
+
result: false,
|
|
321
|
+
reason: PublicSwapService.PUBLIC_SWAPS_COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED,
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
if (result?.reason === SwapProvider.CREATION_FAIL_REASONS.RETRIABLE_FAIL) {
|
|
325
|
+
// TODO: [feature, high] implement retrying if one partner fail and we have another partners task_id=a07e367e488f4a4899613ac9056fa359
|
|
326
|
+
// return {
|
|
327
|
+
// result: false,
|
|
328
|
+
// reason: PublicSwapService.SWAP_CREATION_FAIL_REASONS.RETRIABLE_FAIL,
|
|
329
|
+
// };
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
if (result.result && result?.swapId) {
|
|
333
|
+
let fromAmountFiat = null,
|
|
334
|
+
toAmountFiat = null;
|
|
335
|
+
try {
|
|
336
|
+
const fromCoinUsdtRate = (await provider.getCoinToUSDTRate(fromCoinTicker))?.rate ?? null;
|
|
337
|
+
const toCoinUsdtRate = (await provider.getCoinToUSDTRate(toCoinTicker))?.rate ?? null;
|
|
338
|
+
if (fromCoinUsdtRate != null && result.fromAmount != null) {
|
|
339
|
+
fromAmountFiat = BigNumber(result.fromAmount)
|
|
340
|
+
.times(fromCoinUsdtRate)
|
|
341
|
+
.toFixed(PublicSwapService._fiatDecimalsCount);
|
|
342
|
+
}
|
|
343
|
+
if (toCoinUsdtRate != null && result.toAmount != null) {
|
|
344
|
+
toAmountFiat = BigNumber(result.toAmount)
|
|
345
|
+
.times(toCoinUsdtRate)
|
|
346
|
+
.toFixed(PublicSwapService._fiatDecimalsCount);
|
|
347
|
+
}
|
|
348
|
+
} catch (e) {
|
|
349
|
+
Logger.logError(e, loggerSource, "Failed to calculate fiat amounts for result");
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
await GoogleAnalyticsAdapter.sendEvent(PublicSwapService.PUBLIC_SWAP_CREATED_ANALYTICS_EVENT, {
|
|
353
|
+
coin_amount: result.fromAmount,
|
|
354
|
+
usd_amount: fromAmountFiat,
|
|
355
|
+
fromCoin: fromCoinTicker,
|
|
356
|
+
toCoin: toCoinTicker,
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
const toReturn = {
|
|
360
|
+
result: true,
|
|
361
|
+
swapId: result.swapId,
|
|
362
|
+
fromCoinTicker: fromCoinTicker,
|
|
363
|
+
toCoinTicker: toCoinTicker,
|
|
364
|
+
fromAmount: result.fromAmount,
|
|
365
|
+
toAmount: result.toAmount,
|
|
366
|
+
fromAmountFiat: fromAmountFiat,
|
|
367
|
+
toAmountFiat: toAmountFiat,
|
|
368
|
+
fiatCurrencyCode: "USD",
|
|
369
|
+
fiatCurrencyDecimals: PublicSwapService._fiatDecimalsCount,
|
|
370
|
+
rate: result.rate,
|
|
371
|
+
durationMinutesRange: null, // TODO: [feature, high] add duration. task_id=3f3d73d7cf44454282222901409149b5
|
|
372
|
+
address: result.fromAddress, // CRITICAL: this is the address to send coins to swaps provider
|
|
373
|
+
fromCurrencyExtraId: result.fromCurrencyExtraId ?? "", // CRITICAL: this is the extra ID for address to send coins to swaps provider
|
|
374
|
+
fixed: result.fixed,
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
this._savePublicSwapIdLocally(result.swapId);
|
|
378
|
+
|
|
379
|
+
Logger.log(
|
|
380
|
+
`Returning: ${safeStringify({
|
|
381
|
+
...toReturn,
|
|
382
|
+
fromCoin: fromCoinTicker,
|
|
383
|
+
toCoin: toCoinTicker,
|
|
384
|
+
})}`,
|
|
385
|
+
loggerSource
|
|
386
|
+
);
|
|
387
|
+
return toReturn;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
throw new Error(`Unexpected result from provider ${safeStringify(result)}`);
|
|
391
|
+
} catch (e) {
|
|
392
|
+
improveAndRethrow(e, loggerSource);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
// TODO: [feature, moderate] move to client. task_id=de4b1ddc652b4a27a472341609fcb6e4
|
|
397
|
+
// /**
|
|
398
|
+
// * Retrieves the whole available swaps history by ids saved locally.
|
|
399
|
+
// *
|
|
400
|
+
// * @return {Promise<{
|
|
401
|
+
// * result: true,
|
|
402
|
+
// * swaps: ExistingSwapWithFiatData[]
|
|
403
|
+
// * }|{
|
|
404
|
+
// * result: false,
|
|
405
|
+
// * reason: string
|
|
406
|
+
// * }>}
|
|
407
|
+
// */
|
|
408
|
+
// async getPublicSwapsHistory() {
|
|
409
|
+
// try {
|
|
410
|
+
// const swapIds = this._getPublicSwapIdsSavedLocally();
|
|
411
|
+
// if (swapIds.length) {
|
|
412
|
+
// return await this.getPublicExistingSwapDetailsAndStatus(swapIds);
|
|
413
|
+
// }
|
|
414
|
+
// return { result: true, swaps: [] };
|
|
415
|
+
// } catch (e) {
|
|
416
|
+
// improveAndRethrow(e, "getPublicSwapsHistory");
|
|
417
|
+
// }
|
|
418
|
+
// }
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* @param swapId {string}
|
|
422
|
+
* @private
|
|
423
|
+
*/
|
|
424
|
+
_savePublicSwapIdLocally(swapId) {
|
|
425
|
+
if (typeof window !== "undefined") {
|
|
426
|
+
try {
|
|
427
|
+
const saved = localStorage.getItem("publicSwapIds");
|
|
428
|
+
const ids = typeof saved === "string" && saved.length > 0 ? saved.split(",") : [];
|
|
429
|
+
ids.push(swapId);
|
|
430
|
+
localStorage.setItem("publicSwapIds", ids.join(","));
|
|
431
|
+
} catch (e) {
|
|
432
|
+
improveAndRethrow(e, "_savePublicSwapIdLocally");
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* @private
|
|
439
|
+
* @return {string[]}
|
|
440
|
+
*/
|
|
441
|
+
_getPublicSwapIdsSavedLocally() {
|
|
442
|
+
if (typeof window !== "undefined") {
|
|
443
|
+
try {
|
|
444
|
+
const saved = localStorage.getItem("publicSwapIds");
|
|
445
|
+
return typeof saved === "string" && saved.length > 0 ? saved.split(",") : [];
|
|
446
|
+
} catch (e) {
|
|
447
|
+
improveAndRethrow(e, "_getPublicSwapIdsSavedLocally");
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* @param ticker {string}
|
|
454
|
+
* @return {Coin|null}
|
|
455
|
+
*/
|
|
456
|
+
getCoinByTickerIfPresent(ticker) {
|
|
457
|
+
return (
|
|
458
|
+
this._swapProvider.getCoinByTickerIfPresent(ticker) ??
|
|
459
|
+
this._fixedSwapProvider.getCoinByTickerIfPresent(ticker)
|
|
460
|
+
);
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* Retrieves flat partners list across all supported providers (including aggregators).
|
|
465
|
+
*
|
|
466
|
+
* @param providers {SwapProvider[]}
|
|
467
|
+
* @return {Promise<Partner[]>}
|
|
468
|
+
*/
|
|
469
|
+
async getPartnersList(providers) {
|
|
470
|
+
try {
|
|
471
|
+
let allPartners = providers.map(provider => provider.getPartnersList());
|
|
472
|
+
allPartners = await Promise.all(allPartners);
|
|
473
|
+
allPartners = allPartners.flat().flat();
|
|
474
|
+
return allPartners.reduce((prev, cur) => {
|
|
475
|
+
const alreadyAdded = prev.find(partner => partner.name.toLowerCase() === cur.name.toLowerCase());
|
|
476
|
+
if (!alreadyAdded) {
|
|
477
|
+
prev.push(cur);
|
|
478
|
+
} else {
|
|
479
|
+
// Attempting to fill missing data if there are the same partner from different providers
|
|
480
|
+
alreadyAdded.logoUrl = cur.logoUrl ?? alreadyAdded.logoUrl;
|
|
481
|
+
alreadyAdded.kycLevel = cur.kycLevel ?? alreadyAdded.kycLevel;
|
|
482
|
+
}
|
|
483
|
+
return prev;
|
|
484
|
+
}, []);
|
|
485
|
+
} catch (e) {
|
|
486
|
+
Logger.logError(e, "getPartnersList");
|
|
487
|
+
}
|
|
488
|
+
return [];
|
|
489
|
+
}
|
|
490
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import sinon from "sinon";
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
import should from "should";
|
|
4
|
+
|
|
5
|
+
import { beforeEach, afterEach, describe, it } from "vitest";
|
|
6
|
+
|
|
7
|
+
import { ExolixSwapProvider } from "../../../external-apis/exolixSwapProvider.js";
|
|
8
|
+
import { Cache } from "../../../../common-apis/utils/cache.js";
|
|
9
|
+
|
|
10
|
+
describe("exolixSwapProvider", function () {
|
|
11
|
+
describe("_fetchSupportedCurrenciesIfNeeded", function () {
|
|
12
|
+
const exolixSwapProvider = new ExolixSwapProvider("/", new Cache());
|
|
13
|
+
const anyError = new Error("Any error");
|
|
14
|
+
|
|
15
|
+
let axiosGetStub;
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
axiosGetStub = sinon.stub(axios, "get");
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
afterEach(() => {
|
|
21
|
+
axiosGetStub.restore();
|
|
22
|
+
exolixSwapProvider._supportedCoins = [];
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("Should throw an error if axios throws error", async () => {
|
|
26
|
+
axiosGetStub.resetBehavior();
|
|
27
|
+
axiosGetStub.rejects(anyError);
|
|
28
|
+
|
|
29
|
+
const swapProvider = new ExolixSwapProvider("/", new Cache());
|
|
30
|
+
|
|
31
|
+
return swapProvider._fetchSupportedCurrenciesIfNeeded().should.be.rejectedWith(anyError);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
});
|