@rabbitio/ui-kit 1.0.0-beta.12 → 1.0.0-beta.121
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/.env.example +1 -0
- package/.gitlab-ci.yml +29 -0
- package/.husky/commit-msg +19 -0
- package/.husky/pre-push +1 -0
- package/README.md +14 -4
- package/coverage/base.css +224 -0
- package/coverage/block-navigation.js +87 -0
- package/coverage/clover.xml +19749 -0
- package/coverage/coverage-final.json +122 -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 +151 -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 +172 -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 +253 -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 +391 -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 +1234 -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 +211 -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 +388 -0
- package/coverage/rabbit-ui-kit/src/robust-api-caller/cacheAndConcurrentRequestsResolver.js.html +1660 -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/changeHeroSwapProvider.js.html +2800 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/changeNowSwapProvider.js.html +2644 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/exolixSwapProvider.js.html +1942 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/goexmeSwapProvider.js.html +2389 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/index.html +236 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/letsExchangeSwapProvider.js.html +1666 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/retriableErrorsUtils.js.html +274 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/swapProvider.js.html +1888 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/swapspaceSwapProvider.js.html +1981 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/utils.js.html +163 -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 +337 -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 +1654 -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 +706 -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 +199 -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 +733 -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 +433 -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 +241 -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 +427 -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 +4375 -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 +166 -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 +176 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/utils/inputValueProviders.js.html +235 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/utils/searchCoins.js.html +259 -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 +15089 -1593
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +2352 -8493
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +11801 -1298
- package/dist/index.modern.js.map +1 -1
- package/dist/index.module.js +15003 -1594
- package/dist/index.module.js.map +1 -1
- package/dist/index.umd.js +15081 -1596
- 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 +22 -0
- package/src/common-apis/adapters/analyticsAdapters/metrikaAdapter.js +29 -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 +56 -0
- package/src/common-apis/external-apis/emailAPI.js +16 -0
- package/src/common-apis/external-apis/ipAddressProviders.js +102 -0
- package/src/common-apis/globalConstants.jsx +3 -0
- package/src/{common → common-apis}/models/coin.js +98 -7
- package/src/{common → common-apis/services}/fiatCurrenciesService.js +4 -12
- package/src/common-apis/tests/integration/external-apis/ipAddressProviders/getClientIpAddress.test.js +18 -0
- package/src/common-apis/tests/units/utils/amountUtils/composeRateText.test.js +152 -0
- package/src/{common → common-apis/utils}/amountUtils.js +100 -140
- package/src/{common → common-apis}/utils/cache.js +15 -41
- package/src/{common → common-apis/utils}/errorUtils.js +15 -0
- package/src/{common → common-apis}/utils/logging/logger.js +7 -13
- package/src/common-apis/utils/postponeExecution.js +11 -0
- package/src/common-apis/utils/rabbitTicker.js +24 -0
- package/src/index.js +91 -14
- package/src/robust-api-caller/cacheAndConcurrentRequestsResolver.js +525 -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/changeHeroSwapProvider.js +905 -0
- package/src/swaps-lib/external-apis/changeNowSwapProvider.js +853 -0
- package/src/swaps-lib/external-apis/exolixSwapProvider.js +619 -0
- package/src/swaps-lib/external-apis/goexmeSwapProvider.js +768 -0
- package/src/swaps-lib/external-apis/letsExchangeSwapProvider.js +527 -0
- package/src/swaps-lib/external-apis/retriableErrorsUtils.js +63 -0
- package/src/swaps-lib/external-apis/swapProvider.js +457 -25
- package/src/swaps-lib/external-apis/swapspaceSwapProvider.js +320 -486
- package/src/swaps-lib/external-apis/utils.js +26 -0
- package/src/swaps-lib/models/baseSwapCreationInfo.js +78 -0
- package/src/swaps-lib/models/existingSwap.js +101 -16
- 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 +84 -0
- package/src/swaps-lib/services/publicSwapService.js +523 -0
- package/src/swaps-lib/test/external-apis/changeHeroSwapProvider/_fetchSupportedCurrenciesIfNeeded.test.js +155 -0
- package/src/swaps-lib/test/external-apis/changeHeroSwapProvider/createSwap.test.js +702 -0
- package/src/swaps-lib/test/external-apis/changeHeroSwapProvider/getExistingSwapsDetailsAndStatus.test.js +501 -0
- package/src/swaps-lib/test/external-apis/changeHeroSwapProvider/getSwapInfo.test.js +425 -0
- package/src/swaps-lib/test/external-apis/changeNowSwapProvider/_fetchSupportedCurrenciesIfNeeded.test.js +83 -0
- package/src/swaps-lib/test/external-apis/changeNowSwapProvider/_providerHelpers.test.js +54 -0
- package/src/swaps-lib/test/external-apis/changeNowSwapProvider/_validateAddressWithProvider.test.js +49 -0
- package/src/swaps-lib/test/external-apis/changeNowSwapProvider/createSwap.test.js +938 -0
- package/src/swaps-lib/test/external-apis/changeNowSwapProvider/getExistingSwapsDetailsAndStatus.test.js +353 -0
- package/src/swaps-lib/test/external-apis/changeNowSwapProvider/getSwapInfo.test.js +342 -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 +1081 -0
- package/src/swaps-lib/test/external-apis/exolixSwapProvider/getSwapInfo.test.js +611 -0
- package/src/swaps-lib/test/external-apis/goexmeSwapProvider/_convertCurrencyMeta.test.js +95 -0
- package/src/swaps-lib/test/external-apis/goexmeSwapProvider/_fetchSupportedCurrenciesIfNeeded.test.js +75 -0
- package/src/swaps-lib/test/external-apis/goexmeSwapProvider/createSwap.test.js +225 -0
- package/src/swaps-lib/test/external-apis/goexmeSwapProvider/getExistingSwapsDetailsAndStatus.test.js +175 -0
- package/src/swaps-lib/test/external-apis/goexmeSwapProvider/getSwapInfo.test.js +177 -0
- package/src/swaps-lib/test/external-apis/goexmeSwapProvider/helpers.test.js +26 -0
- package/src/swaps-lib/test/external-apis/goexmeSwapProvider/integration/PairSupport.int.test.js +69 -0
- package/src/swaps-lib/test/external-apis/goexmeSwapProvider/integration/_fetchSupportedCurrenciesIfNeeded.int.test.js +307 -0
- package/src/swaps-lib/test/external-apis/goexmeSwapProvider/integration/createSwap.int.test.js +335 -0
- package/src/swaps-lib/test/external-apis/goexmeSwapProvider/integration/getSwapInfo.int.test.js +154 -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 +1359 -0
- package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/getExistingSwapsDetailsAndStatus.test.js +136 -0
- package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/getSwapInfo.test.js +1743 -0
- package/src/swaps-lib/test/utils/swapUtils/isIpBannedProviderError.test.js +150 -0
- package/src/swaps-lib/test/utils/swapUtils/safeHandleRequestsLimitExceeding.test.js +80 -0
- package/src/swaps-lib/utils/swapUtils.js +207 -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/{components → ui-kit/components}/atoms/AssetIcon/AssetIcon.jsx +16 -14
- 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 +38 -0
- package/src/ui-kit/components/atoms/QrCode/qr-code.module.scss +8 -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 +26 -45
- 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 +116 -0
- package/src/ui-kit/components/atoms/buttons/LinkButton/link-button.module.scss +53 -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 +52 -0
- package/src/ui-kit/components/molecules/ColoredNotice/colored-notice.module.scss +36 -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 +114 -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 +382 -0
- package/src/ui-kit/components/organisms/Dialog/dialog.module.scss +226 -0
- package/src/ui-kit/components/organisms/SwapForm/SwapForm.jsx +1430 -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 +27 -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/searchCoins.js +58 -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/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/src/{common → common-apis}/models/blockchain.js +0 -0
- /package/src/{common → common-apis}/models/protocol.js +0 -0
- /package/src/{common → common-apis}/utils/logging/logsStorage.js +0 -0
- /package/src/{common → common-apis}/utils/safeStringify.js +0 -0
- /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,342 @@
|
|
|
1
|
+
import sinon from "sinon";
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
import should from "should";
|
|
4
|
+
import { describe, it, beforeEach, afterEach } from "vitest";
|
|
5
|
+
|
|
6
|
+
import { ChangeNowSwapProvider } from "../../../external-apis/changeNowSwapProvider.js";
|
|
7
|
+
import { Cache } from "../../../../common-apis/utils/cache.js";
|
|
8
|
+
import { Coin } from "../../../../common-apis/models/coin.js";
|
|
9
|
+
|
|
10
|
+
describe("src/swaps-lib/external-apis/changeNowSwapProvider.js", function () {
|
|
11
|
+
describe("getSwapInfo", function () {
|
|
12
|
+
let provider;
|
|
13
|
+
let axiosGetStub;
|
|
14
|
+
let fetchCoinsStub;
|
|
15
|
+
let fromCoin;
|
|
16
|
+
let toCoin;
|
|
17
|
+
|
|
18
|
+
function buildCoin(ticker, digits = 8) {
|
|
19
|
+
return new Coin(
|
|
20
|
+
ticker,
|
|
21
|
+
ticker,
|
|
22
|
+
ticker,
|
|
23
|
+
digits,
|
|
24
|
+
null,
|
|
25
|
+
"",
|
|
26
|
+
null,
|
|
27
|
+
null,
|
|
28
|
+
1,
|
|
29
|
+
null,
|
|
30
|
+
[],
|
|
31
|
+
60000,
|
|
32
|
+
null,
|
|
33
|
+
null,
|
|
34
|
+
null,
|
|
35
|
+
false
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
beforeEach(function () {
|
|
40
|
+
provider = new ChangeNowSwapProvider(null, new Cache());
|
|
41
|
+
axiosGetStub = sinon.stub(axios, "get");
|
|
42
|
+
fetchCoinsStub = sinon.stub(provider, "_fetchSupportedCurrenciesIfNeeded").resolves();
|
|
43
|
+
fromCoin = buildCoin("BTC", 8);
|
|
44
|
+
toCoin = buildCoin("ETH", 8);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
afterEach(function () {
|
|
48
|
+
sinon.restore();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("Should throw on invalid input parameters", async function () {
|
|
52
|
+
const invalidCoin = { ticker: "BTC" };
|
|
53
|
+
|
|
54
|
+
let thrown1;
|
|
55
|
+
try {
|
|
56
|
+
await provider.getSwapInfo(invalidCoin, toCoin, "1");
|
|
57
|
+
} catch (e) {
|
|
58
|
+
thrown1 = e;
|
|
59
|
+
}
|
|
60
|
+
should.exist(thrown1);
|
|
61
|
+
(thrown1.message || "").toLowerCase().includes("invalid swap parameters").should.be.true();
|
|
62
|
+
|
|
63
|
+
let thrown2;
|
|
64
|
+
try {
|
|
65
|
+
await provider.getSwapInfo(fromCoin, toCoin, "0");
|
|
66
|
+
} catch (e) {
|
|
67
|
+
thrown2 = e;
|
|
68
|
+
}
|
|
69
|
+
should.exist(thrown2);
|
|
70
|
+
(thrown2.message || "").toLowerCase().includes("invalid swap parameters").should.be.true();
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("Should return NOT_SUPPORTED when either coin is unsupported", async function () {
|
|
74
|
+
provider._supportedCoins = [];
|
|
75
|
+
const result = await provider.getSwapInfo(fromCoin, toCoin, "1");
|
|
76
|
+
result.result.should.be.false();
|
|
77
|
+
result.reason.should.equal(provider.constructor.NO_SWAPS_REASONS.NOT_SUPPORTED);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it("Should return TOO_LOW when the requested amount is below provider minimum", async function () {
|
|
81
|
+
provider._supportedCoins = [
|
|
82
|
+
{ coin: fromCoin, code: "BTC", network: null, deposit: true, withdrawal: true, isAvailable: true },
|
|
83
|
+
{ coin: toCoin, code: "ETH", network: null, deposit: true, withdrawal: true, isAvailable: true },
|
|
84
|
+
];
|
|
85
|
+
axiosGetStub.onCall(0).resolves({ status: 200, data: { minAmount: "10", maxAmount: "100" } });
|
|
86
|
+
axiosGetStub.onCall(1).resolves({ status: 200, data: {} });
|
|
87
|
+
|
|
88
|
+
const result = await provider.getSwapInfo(fromCoin, toCoin, "5");
|
|
89
|
+
|
|
90
|
+
result.result.should.be.false();
|
|
91
|
+
result.reason.should.equal(provider.constructor.NO_SWAPS_REASONS.TOO_LOW);
|
|
92
|
+
result.smallestMin.should.equal("10");
|
|
93
|
+
result.greatestMax.should.equal("100");
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it("Should return TOO_HIGH when the requested amount is above provider maximum", async function () {
|
|
97
|
+
provider._supportedCoins = [
|
|
98
|
+
{ coin: fromCoin, code: "BTC", network: null, deposit: true, withdrawal: true, isAvailable: true },
|
|
99
|
+
{ coin: toCoin, code: "ETH", network: null, deposit: true, withdrawal: true, isAvailable: true },
|
|
100
|
+
];
|
|
101
|
+
axiosGetStub.onCall(0).resolves({ status: 200, data: { minAmount: "1", maxAmount: "10" } });
|
|
102
|
+
axiosGetStub.onCall(1).resolves({ status: 200, data: {} });
|
|
103
|
+
const result = await provider.getSwapInfo(fromCoin, toCoin, "20");
|
|
104
|
+
result.result.should.be.false();
|
|
105
|
+
result.reason.should.equal(provider.constructor.NO_SWAPS_REASONS.TOO_HIGH);
|
|
106
|
+
result.smallestMin.should.equal("1");
|
|
107
|
+
result.greatestMax.should.equal("10");
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it("Should return correct estimation and rate for a successful floating rate swap", async function () {
|
|
111
|
+
provider._supportedCoins = [
|
|
112
|
+
{ coin: fromCoin, code: "BTC", network: null, deposit: true, withdrawal: true, isAvailable: true },
|
|
113
|
+
{ coin: toCoin, code: "ETH", network: null, deposit: true, withdrawal: true, isAvailable: true },
|
|
114
|
+
];
|
|
115
|
+
axiosGetStub.onCall(0).resolves({ status: 200, data: {} });
|
|
116
|
+
axiosGetStub.onCall(1).resolves({
|
|
117
|
+
status: 200,
|
|
118
|
+
data: { fromAmount: "5", toAmount: "10", rateId: "id1", transactionSpeedForecast: "30" },
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
const res = await provider.getSwapInfo(fromCoin, toCoin, "5", false);
|
|
122
|
+
res.result.should.be.true();
|
|
123
|
+
res.rate.should.equal("2");
|
|
124
|
+
should(res.min).be.null();
|
|
125
|
+
should(res.smallestMin).be.null();
|
|
126
|
+
should(res.greatestMax).be.null();
|
|
127
|
+
res.durationMinutesRange.should.equal("30");
|
|
128
|
+
res.fixed.should.be.false();
|
|
129
|
+
res.rawSwapData.fromAmount.should.equal("5");
|
|
130
|
+
res.rawSwapData.toAmount.should.equal("10");
|
|
131
|
+
res.rawSwapData.rate.should.equal("2");
|
|
132
|
+
res.rawSwapData.rateId.should.equal("id1");
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it("Should include fixed rate flow when fixed = true and use provided rateId", async function () {
|
|
136
|
+
provider._supportedCoins = [
|
|
137
|
+
{ coin: fromCoin, code: "BTC", network: null, deposit: true, withdrawal: true, isAvailable: true },
|
|
138
|
+
{ coin: toCoin, code: "ETH", network: null, deposit: true, withdrawal: true, isAvailable: true },
|
|
139
|
+
];
|
|
140
|
+
axiosGetStub.onCall(0).resolves({ status: 200, data: {} });
|
|
141
|
+
axiosGetStub.onCall(1).resolves({
|
|
142
|
+
status: 200,
|
|
143
|
+
data: { fromAmount: "5", toAmount: "7.5", rateId: "fixed123", transactionSpeedForecast: "15" },
|
|
144
|
+
});
|
|
145
|
+
const result = await provider.getSwapInfo(fromCoin, toCoin, "5", true);
|
|
146
|
+
result.fixed.should.be.true();
|
|
147
|
+
result.rate.should.equal("1.5");
|
|
148
|
+
result.rawSwapData.rateId.should.equal("fixed123");
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it("Should throw when estimation response is not 200", async function () {
|
|
152
|
+
provider._supportedCoins = [
|
|
153
|
+
{ coin: fromCoin, code: "BTC", network: null, deposit: true, withdrawal: true, isAvailable: true },
|
|
154
|
+
{ coin: toCoin, code: "ETH", network: null, deposit: true, withdrawal: true, isAvailable: true },
|
|
155
|
+
];
|
|
156
|
+
axiosGetStub.onCall(0).resolves({ status: 200, data: {} });
|
|
157
|
+
axiosGetStub.onCall(1).resolves({ status: 400, data: "error" });
|
|
158
|
+
|
|
159
|
+
let thrown;
|
|
160
|
+
try {
|
|
161
|
+
await provider.getSwapInfo(fromCoin, toCoin, "5");
|
|
162
|
+
} catch (e) {
|
|
163
|
+
thrown = e;
|
|
164
|
+
}
|
|
165
|
+
should.exist(thrown);
|
|
166
|
+
(thrown.message || "").toLowerCase().includes("unexpected estimate response").should.be.true();
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it("Should return NOT_SUPPORTED when deposit or withdrawal unavailable or coin disabled", async function () {
|
|
170
|
+
provider._supportedCoins = [
|
|
171
|
+
{ coin: fromCoin, code: "BTC", network: null, deposit: false, withdrawal: true, isAvailable: true },
|
|
172
|
+
{ coin: toCoin, code: "ETH", network: null, deposit: true, withdrawal: true, isAvailable: true },
|
|
173
|
+
];
|
|
174
|
+
let res = await provider.getSwapInfo(fromCoin, toCoin, "1");
|
|
175
|
+
res.result.should.be.false();
|
|
176
|
+
res.reason.should.equal(provider.constructor.NO_SWAPS_REASONS.NOT_SUPPORTED);
|
|
177
|
+
provider._supportedCoins = [
|
|
178
|
+
{ coin: fromCoin, code: "BTC", network: null, deposit: true, withdrawal: true, isAvailable: true },
|
|
179
|
+
{ coin: toCoin, code: "ETH", network: null, deposit: true, withdrawal: false, isAvailable: true },
|
|
180
|
+
];
|
|
181
|
+
res = await provider.getSwapInfo(fromCoin, toCoin, "1");
|
|
182
|
+
res.result.should.be.false();
|
|
183
|
+
res.reason.should.equal(provider.constructor.NO_SWAPS_REASONS.NOT_SUPPORTED);
|
|
184
|
+
provider._supportedCoins = [
|
|
185
|
+
{ coin: fromCoin, code: "BTC", network: null, deposit: true, withdrawal: true, isAvailable: false },
|
|
186
|
+
{ coin: toCoin, code: "ETH", network: null, deposit: true, withdrawal: true, isAvailable: true },
|
|
187
|
+
];
|
|
188
|
+
res = await provider.getSwapInfo(fromCoin, toCoin, "1");
|
|
189
|
+
res.result.should.be.false();
|
|
190
|
+
res.reason.should.equal(provider.constructor.NO_SWAPS_REASONS.NOT_SUPPORTED);
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
it("Should include fixed-rate flow parameter only when fixed is true", async function () {
|
|
194
|
+
provider._supportedCoins = [
|
|
195
|
+
{ coin: fromCoin, code: "BTC", network: "btc", deposit: true, withdrawal: true, isAvailable: true },
|
|
196
|
+
{ coin: toCoin, code: "ETH", network: "eth", deposit: true, withdrawal: true, isAvailable: true },
|
|
197
|
+
];
|
|
198
|
+
axiosGetStub.withArgs(sinon.match(/\/exchange\/range/)).resolves({ status: 200, data: {} });
|
|
199
|
+
axiosGetStub.withArgs(sinon.match(/\/exchange\/estimated-amount/)).resolves({
|
|
200
|
+
status: 200,
|
|
201
|
+
data: { fromAmount: "1", toAmount: "2" },
|
|
202
|
+
});
|
|
203
|
+
await provider.getSwapInfo(fromCoin, toCoin, "1", true);
|
|
204
|
+
let call = axiosGetStub.getCalls().find(c => c.args[0].includes("/exchange/estimated-amount"));
|
|
205
|
+
call.args[1].params.flow.should.equal("fixed-rate");
|
|
206
|
+
axiosGetStub.resetHistory();
|
|
207
|
+
await provider.getSwapInfo(fromCoin, toCoin, "1", false);
|
|
208
|
+
call = axiosGetStub.getCalls().find(c => c.args[0].includes("/exchange/estimated-amount"));
|
|
209
|
+
call.args[1].params.flow.should.equal("standard");
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
it("Should send toAmount when amountIsToReceive is true", async function () {
|
|
213
|
+
provider._supportedCoins = [
|
|
214
|
+
{ coin: fromCoin, code: "BTC", network: "btc", deposit: true, withdrawal: true, isAvailable: true },
|
|
215
|
+
{ coin: toCoin, code: "ETH", network: "eth", deposit: true, withdrawal: true, isAvailable: true },
|
|
216
|
+
];
|
|
217
|
+
axiosGetStub.withArgs(sinon.match(/\/exchange\/range/)).resolves({ status: 200, data: {} });
|
|
218
|
+
axiosGetStub.withArgs(sinon.match(/\/exchange\/estimated-amount/)).resolves({
|
|
219
|
+
status: 200,
|
|
220
|
+
data: { fromAmount: "2", toAmount: "4" },
|
|
221
|
+
});
|
|
222
|
+
const amountWanted = "4";
|
|
223
|
+
await provider.getSwapInfo(fromCoin, toCoin, amountWanted, false, null, true);
|
|
224
|
+
let call = axiosGetStub.getCalls().find(c => c.args[0].includes("/exchange/estimated-amount"));
|
|
225
|
+
should(call.args[1].params.fromAmount).be.undefined();
|
|
226
|
+
call.args[1].params.toAmount.should.equal(amountWanted);
|
|
227
|
+
const res = await provider.getSwapInfo(fromCoin, toCoin, amountWanted, false, null, true);
|
|
228
|
+
res.result.should.be.true();
|
|
229
|
+
res.rawSwapData.fromAmount.should.equal("2");
|
|
230
|
+
res.rawSwapData.toAmount.should.equal("4");
|
|
231
|
+
res.rate.should.equal("2");
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
it("Should compute rate when fromAmount or toAmount missing in estimation", async function () {
|
|
235
|
+
provider._supportedCoins = [
|
|
236
|
+
{ coin: fromCoin, code: "BTC", network: null, deposit: true, withdrawal: true, isAvailable: true },
|
|
237
|
+
{ coin: toCoin, code: "ETH", network: null, deposit: true, withdrawal: true, isAvailable: true },
|
|
238
|
+
];
|
|
239
|
+
axiosGetStub.onCall(0).resolves({ status: 200, data: {} });
|
|
240
|
+
axiosGetStub.onCall(1).resolves({ status: 200, data: { toAmount: "15" } });
|
|
241
|
+
const res = await provider.getSwapInfo(fromCoin, toCoin, "5");
|
|
242
|
+
res.rawSwapData.fromAmount.should.equal("5");
|
|
243
|
+
res.rawSwapData.toAmount.should.equal("15");
|
|
244
|
+
res.rate.should.equal("3");
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
it("Should ignore invalid range response and still proceed", async function () {
|
|
248
|
+
provider._supportedCoins = [
|
|
249
|
+
{ coin: fromCoin, code: "BTC", network: null, deposit: true, withdrawal: true, isAvailable: true },
|
|
250
|
+
{ coin: toCoin, code: "ETH", network: null, deposit: true, withdrawal: true, isAvailable: true },
|
|
251
|
+
];
|
|
252
|
+
axiosGetStub.onCall(0).resolves({ status: 200, data: "unexpected" });
|
|
253
|
+
axiosGetStub.onCall(1).resolves({ status: 200, data: { fromAmount: "2", toAmount: "4" } });
|
|
254
|
+
const res = await provider.getSwapInfo(fromCoin, toCoin, "2");
|
|
255
|
+
res.result.should.be.true();
|
|
256
|
+
should(res.min).be.null();
|
|
257
|
+
res.rate.should.equal("2");
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
it("Should include fromNetwork and toNetwork params in both range and estimation requests", async function () {
|
|
261
|
+
provider._supportedCoins = [
|
|
262
|
+
{
|
|
263
|
+
coin: fromCoin,
|
|
264
|
+
code: fromCoin.ticker,
|
|
265
|
+
network: "btc",
|
|
266
|
+
deposit: true,
|
|
267
|
+
withdrawal: true,
|
|
268
|
+
isAvailable: true,
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
coin: toCoin,
|
|
272
|
+
code: toCoin.ticker,
|
|
273
|
+
network: "eth",
|
|
274
|
+
deposit: true,
|
|
275
|
+
withdrawal: true,
|
|
276
|
+
isAvailable: true,
|
|
277
|
+
},
|
|
278
|
+
];
|
|
279
|
+
axiosGetStub.withArgs(sinon.match(/\/exchange\/range/)).resolves({ status: 200, data: {} });
|
|
280
|
+
axiosGetStub.withArgs(sinon.match(/\/exchange\/estimated-amount/)).resolves({
|
|
281
|
+
status: 200,
|
|
282
|
+
data: { fromAmount: "1", toAmount: "2" },
|
|
283
|
+
});
|
|
284
|
+
await provider.getSwapInfo(fromCoin, toCoin, "1");
|
|
285
|
+
const rangeCall = axiosGetStub.getCalls().find(c => c.args[0].includes("/exchange/range"));
|
|
286
|
+
rangeCall.args[1].params.fromNetwork.should.equal("btc");
|
|
287
|
+
rangeCall.args[1].params.toNetwork.should.equal("eth");
|
|
288
|
+
const estCall = axiosGetStub.getCalls().find(c => c.args[0].includes("/exchange/estimated-amount"));
|
|
289
|
+
estCall.args[1].params.fromNetwork.should.equal("btc");
|
|
290
|
+
estCall.args[1].params.toNetwork.should.equal("eth");
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
it("Should propagate Axios rejection (non-429) as an exception", async function () {
|
|
294
|
+
provider._supportedCoins = [
|
|
295
|
+
{ coin: fromCoin, code: "BTC", network: null, deposit: true, withdrawal: true, isAvailable: true },
|
|
296
|
+
{ coin: toCoin, code: "ETH", network: null, deposit: true, withdrawal: true, isAvailable: true },
|
|
297
|
+
];
|
|
298
|
+
axiosGetStub.rejects(new Error("network down"));
|
|
299
|
+
|
|
300
|
+
let thrown;
|
|
301
|
+
try {
|
|
302
|
+
await provider.getSwapInfo(fromCoin, toCoin, "1");
|
|
303
|
+
} catch (e) {
|
|
304
|
+
thrown = e;
|
|
305
|
+
}
|
|
306
|
+
should.exist(thrown);
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
it("Should throw when estimation returns 200 with non-object data", async function () {
|
|
310
|
+
provider._supportedCoins = [
|
|
311
|
+
{ coin: fromCoin, code: "BTC", network: null, deposit: true, withdrawal: true, isAvailable: true },
|
|
312
|
+
{ coin: toCoin, code: "ETH", network: null, deposit: true, withdrawal: true, isAvailable: true },
|
|
313
|
+
];
|
|
314
|
+
axiosGetStub.onCall(0).resolves({ status: 200, data: {} });
|
|
315
|
+
axiosGetStub.onCall(1).resolves({ status: 200, data: "invalid" });
|
|
316
|
+
|
|
317
|
+
let thrown;
|
|
318
|
+
try {
|
|
319
|
+
await provider.getSwapInfo(fromCoin, toCoin, "5");
|
|
320
|
+
} catch (e) {
|
|
321
|
+
thrown = e;
|
|
322
|
+
}
|
|
323
|
+
should.exist(thrown);
|
|
324
|
+
(thrown.message || "").toLowerCase().includes("unexpected estimate response").should.be.true();
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
it("Should include min and max in success response when provider returns them", async function () {
|
|
328
|
+
provider._supportedCoins = [
|
|
329
|
+
{ coin: fromCoin, code: "BTC", network: null, deposit: true, withdrawal: true, isAvailable: true },
|
|
330
|
+
{ coin: toCoin, code: "ETH", network: null, deposit: true, withdrawal: true, isAvailable: true },
|
|
331
|
+
];
|
|
332
|
+
axiosGetStub.onCall(0).resolves({ status: 200, data: { minAmount: "1", maxAmount: "20" } });
|
|
333
|
+
axiosGetStub.onCall(1).resolves({ status: 200, data: { fromAmount: "5", toAmount: "10" } });
|
|
334
|
+
const res = await provider.getSwapInfo(fromCoin, toCoin, "5");
|
|
335
|
+
res.result.should.be.true();
|
|
336
|
+
res.min.should.equal("1");
|
|
337
|
+
res.max.should.equal("20");
|
|
338
|
+
res.smallestMin.should.equal("1");
|
|
339
|
+
res.greatestMax.should.equal("20");
|
|
340
|
+
});
|
|
341
|
+
});
|
|
342
|
+
});
|
|
@@ -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
|
+
});
|