@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,95 @@
|
|
|
1
|
+
import should from "should";
|
|
2
|
+
import { describe, it } from "vitest";
|
|
3
|
+
|
|
4
|
+
import { GoexmeSwapProvider } from "../../../external-apis/goexmeSwapProvider.js";
|
|
5
|
+
import { Cache } from "../../../../common-apis/utils/cache.js";
|
|
6
|
+
import { Coin } from "../../../../common-apis/models/coin.js";
|
|
7
|
+
import { Protocol } from "../../../../common-apis/models/protocol.js";
|
|
8
|
+
|
|
9
|
+
describe("goexmeSwapProvider", function () {
|
|
10
|
+
describe("_convertCurrencyMeta", function () {
|
|
11
|
+
it("Should return null for restricted set", () => {
|
|
12
|
+
const restrictedProvider = new GoexmeSwapProvider("/", new Cache(), () => null, true);
|
|
13
|
+
const mapping = { rabbitTicker: "ABC", tickerPrintable: "ABC", protocol: null };
|
|
14
|
+
const providerItem = { coinName: "Abc", decimals: 8, available: true, tagname: "", network: "" };
|
|
15
|
+
|
|
16
|
+
should(restrictedProvider._convertCurrencyMeta("ABC", providerItem, mapping)).be.null();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("Should auto-construct Coin when builder is null and unrestricted", function () {
|
|
20
|
+
const provider = new GoexmeSwapProvider("/", new Cache(), null, false);
|
|
21
|
+
const mapping = { rabbitTicker: "BTC", tickerPrintable: "BTC", protocol: null };
|
|
22
|
+
const providerCode = "BTC";
|
|
23
|
+
const providerItem = {
|
|
24
|
+
coinName: "Bitcoin",
|
|
25
|
+
decimals: 8,
|
|
26
|
+
available: true,
|
|
27
|
+
tagname: "",
|
|
28
|
+
network: "Bitcoin",
|
|
29
|
+
};
|
|
30
|
+
const currencyInfo = provider._convertCurrencyMeta(providerCode, providerItem, mapping);
|
|
31
|
+
currencyInfo.should.have.properties({ code: "BTC", network: "Bitcoin" });
|
|
32
|
+
currencyInfo.coin.should.be.instanceOf(Coin);
|
|
33
|
+
if (currencyInfo.coin.protocol) currencyInfo.coin.protocol.should.be.instanceOf(Protocol);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("Should set hasExtraId=true and extraIdName when tagname present", function () {
|
|
37
|
+
const provider = new GoexmeSwapProvider("/", new Cache(), null, false);
|
|
38
|
+
const mapping = { rabbitTicker: "XRP", tickerPrintable: "XRP", protocol: null };
|
|
39
|
+
const providerCode = "XRP";
|
|
40
|
+
const providerItem = {
|
|
41
|
+
coinName: "Ripple",
|
|
42
|
+
decimals: 6,
|
|
43
|
+
available: true,
|
|
44
|
+
tagname: "DestinationTag",
|
|
45
|
+
};
|
|
46
|
+
const currencyInfo = provider._convertCurrencyMeta(providerCode, providerItem, mapping);
|
|
47
|
+
currencyInfo.hasExtraId.should.be.true();
|
|
48
|
+
currencyInfo.extraIdName.should.equal("DestinationTag");
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("Should set hasExtraId=false and extraIdName=null when no tagname", function () {
|
|
52
|
+
const provider = new GoexmeSwapProvider("/", new Cache(), null, false);
|
|
53
|
+
const mapping = { rabbitTicker: "LTC", tickerPrintable: "LTC", protocol: null };
|
|
54
|
+
const providerCode = "LTC";
|
|
55
|
+
const providerItem = {
|
|
56
|
+
coinName: "Litecoin",
|
|
57
|
+
decimals: 8,
|
|
58
|
+
available: true,
|
|
59
|
+
tagname: "",
|
|
60
|
+
};
|
|
61
|
+
const currencyInfo = provider._convertCurrencyMeta(providerCode, providerItem, mapping);
|
|
62
|
+
currencyInfo.hasExtraId.should.be.false();
|
|
63
|
+
should(currencyInfo.extraIdName).be.null();
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
describe("constructor", function () {
|
|
68
|
+
it("Should default _URL to proxy path when apiKey empty", () => {
|
|
69
|
+
const provider = new GoexmeSwapProvider("/proxy", new Cache());
|
|
70
|
+
provider._URL.should.equal("/proxy/goexme");
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("Should set direct URL when apiKey passed", () => {
|
|
74
|
+
const providerWithKey = new GoexmeSwapProvider("/proxy", new Cache(), () => null, false, "key");
|
|
75
|
+
providerWithKey._URL.should.equal("https://goexme.io/v1/api");
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("Should not set Authorization header", () => {
|
|
79
|
+
const providerWithSecret = new GoexmeSwapProvider("/proxy", new Cache(), () => null, false, "mySecret");
|
|
80
|
+
should(providerWithSecret.headers).not.have.property("Authorization");
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("Should not set any unexpected headers", () => {
|
|
84
|
+
const providerWithSecret = new GoexmeSwapProvider("/proxy", new Cache(), () => null, false, "mySecret");
|
|
85
|
+
Object.keys(providerWithSecret.headers).should.eql([]);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("Should allow only 200 and 404 in validateStatus", () => {
|
|
89
|
+
const defaultProvider = new GoexmeSwapProvider("/", new Cache());
|
|
90
|
+
const allowedStatuses = [200, 404];
|
|
91
|
+
allowedStatuses.forEach(status => defaultProvider.axiosPreset.validateStatus(status).should.be.true());
|
|
92
|
+
[199, 500].forEach(status => defaultProvider.axiosPreset.validateStatus(status).should.be.false());
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import sinon from "sinon";
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
import should from "should";
|
|
4
|
+
import { beforeEach, afterEach, describe, it } from "vitest";
|
|
5
|
+
|
|
6
|
+
import { GoexmeSwapProvider } from "../../../external-apis/goexmeSwapProvider.js";
|
|
7
|
+
import { Cache } from "../../../../common-apis/utils/cache.js";
|
|
8
|
+
|
|
9
|
+
describe("goexmeSwapProvider", function () {
|
|
10
|
+
describe("_fetchSupportedCurrenciesIfNeeded", function () {
|
|
11
|
+
let provider, axiosGetStub;
|
|
12
|
+
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
provider = new GoexmeSwapProvider("/", new Cache(), () => null, false);
|
|
15
|
+
axiosGetStub = sinon.stub(axios, "get");
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
afterEach(() => {
|
|
19
|
+
axiosGetStub.restore();
|
|
20
|
+
provider._supportedCoins = [];
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("Should load and map available currencies when status is 200", async () => {
|
|
24
|
+
const apiOK = {
|
|
25
|
+
btc: { coinName: "Bitcoin", available: true, network: "", tagname: "" },
|
|
26
|
+
eth: { coinName: "Ethereum", available: true, network: "erc20", tagname: "" },
|
|
27
|
+
usdt: { coinName: "Tether", available: false, network: "" },
|
|
28
|
+
};
|
|
29
|
+
axiosGetStub.resolves({ status: 200, data: apiOK });
|
|
30
|
+
|
|
31
|
+
await provider._fetchSupportedCurrenciesIfNeeded();
|
|
32
|
+
|
|
33
|
+
provider._supportedCoins.length.should.equal(2);
|
|
34
|
+
provider._supportedCoins.forEach(info => info.coin.should.be.instanceOf(info.coin.constructor));
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("Should skip currencies with available=false", async () => {
|
|
38
|
+
const apiPartial = {
|
|
39
|
+
btc: { coinName: "Bitcoin", available: false, network: "", tagname: "" },
|
|
40
|
+
eth: { coinName: "Ethereum", available: true, network: "", tagname: "" },
|
|
41
|
+
};
|
|
42
|
+
axiosGetStub.resolves({ status: 200, data: apiPartial });
|
|
43
|
+
|
|
44
|
+
await provider._fetchSupportedCurrenciesIfNeeded();
|
|
45
|
+
|
|
46
|
+
provider._supportedCoins.length.should.equal(1);
|
|
47
|
+
provider._supportedCoins[0].code.should.equal("ETH");
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("Should reject when response status is not 200", async () => {
|
|
51
|
+
axiosGetStub.resolves({ status: 500, data: {} });
|
|
52
|
+
|
|
53
|
+
return provider._fetchSupportedCurrenciesIfNeeded().should.be.rejected();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("Should propagate axios error", async () => {
|
|
57
|
+
axiosGetStub.rejects(new Error("network"));
|
|
58
|
+
|
|
59
|
+
return provider._fetchSupportedCurrenciesIfNeeded().should.be.rejectedWith(/network/);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("Should not call axios again while cache is fresh", async () => {
|
|
63
|
+
const apiOK = {
|
|
64
|
+
btc: { coinName: "Bitcoin", available: true, network: "", tagname: "" },
|
|
65
|
+
};
|
|
66
|
+
axiosGetStub.resolves({ status: 200, data: apiOK });
|
|
67
|
+
|
|
68
|
+
await provider._fetchSupportedCurrenciesIfNeeded();
|
|
69
|
+
const initialCalls = axiosGetStub.callCount;
|
|
70
|
+
await provider._fetchSupportedCurrenciesIfNeeded();
|
|
71
|
+
|
|
72
|
+
axiosGetStub.callCount.should.equal(initialCalls);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
});
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import sinon from "sinon";
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
import should from "should";
|
|
4
|
+
import { describe, it, beforeEach, afterEach } from "vitest";
|
|
5
|
+
import BigNumber from "bignumber.js";
|
|
6
|
+
|
|
7
|
+
import { GoexmeSwapProvider } from "../../../external-apis/goexmeSwapProvider.js";
|
|
8
|
+
import { Cache } from "../../../../common-apis/utils/cache.js";
|
|
9
|
+
import { SwapProvider } from "../../../external-apis/swapProvider.js";
|
|
10
|
+
import { Coin } from "../../../../common-apis/models/coin.js";
|
|
11
|
+
import { Blockchain } from "../../../../common-apis/models/blockchain.js";
|
|
12
|
+
|
|
13
|
+
const BTC = new Coin("Bitcoin", "BTC", "BTC", 8, null, "sat", null, null, 1, null, [], null, new Blockchain("Bitcoin"));
|
|
14
|
+
const ETH = new Coin(
|
|
15
|
+
"Ethereum",
|
|
16
|
+
"ETH",
|
|
17
|
+
"ETH",
|
|
18
|
+
18,
|
|
19
|
+
null,
|
|
20
|
+
"wei",
|
|
21
|
+
null,
|
|
22
|
+
null,
|
|
23
|
+
1,
|
|
24
|
+
null,
|
|
25
|
+
[],
|
|
26
|
+
null,
|
|
27
|
+
new Blockchain("Ethereum")
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
const ESTIMATION_STUB = { rate: "0.09143008", rawSwapData: { rate: "0.09143008" } };
|
|
31
|
+
|
|
32
|
+
describe("goexmeSwapProvider", function () {
|
|
33
|
+
describe("createSwap", function () {
|
|
34
|
+
const apiOk = { result: true, id: "id1", depositAddress: "addr-in" };
|
|
35
|
+
let provider, axiosStub;
|
|
36
|
+
|
|
37
|
+
beforeEach(() => {
|
|
38
|
+
provider = new GoexmeSwapProvider("/", new Cache(), () => null, false);
|
|
39
|
+
provider._supportedCoins = [
|
|
40
|
+
{ coin: BTC, code: "BTC", network: "BTC", hasExtraId: false },
|
|
41
|
+
{ coin: ETH, code: "ETH", network: "ETH", hasExtraId: true },
|
|
42
|
+
];
|
|
43
|
+
provider._pairsCache = { BTC: new Set(["ETH"]), ETH: new Set(["BTC"]) };
|
|
44
|
+
provider._pairsCacheTimestamp = Date.now();
|
|
45
|
+
|
|
46
|
+
sinon.stub(provider, "_fetchSupportedCurrenciesIfNeeded").resolves();
|
|
47
|
+
axiosStub = sinon.stub(axios, "get").resolves({ status: 200, data: apiOk });
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
afterEach(() => sinon.restore());
|
|
51
|
+
|
|
52
|
+
it("Should fetch currencies before creating swap", async () => {
|
|
53
|
+
await provider.createSwap(BTC, ETH, "1", "dest", "", ESTIMATION_STUB, null, false, "memo");
|
|
54
|
+
provider._fetchSupportedCurrenciesIfNeeded.calledOnce.should.be.true();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("Should send correct query params", async () => {
|
|
58
|
+
await provider.createSwap(BTC, ETH, "0.2", "dest-addr", "", ESTIMATION_STUB, null, false, "memo");
|
|
59
|
+
const params = axiosStub.args[0][1].params;
|
|
60
|
+
params.should.match({
|
|
61
|
+
from: "BTC",
|
|
62
|
+
to: "ETH",
|
|
63
|
+
amount: "0.2",
|
|
64
|
+
destinationAddress: "dest-addr",
|
|
65
|
+
destinationTag: "memo",
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("Should pass refundAddress and refundTag", async () => {
|
|
70
|
+
provider._supportedCoins[0].hasExtraId = true;
|
|
71
|
+
await provider.createSwap(
|
|
72
|
+
BTC,
|
|
73
|
+
ETH,
|
|
74
|
+
"1",
|
|
75
|
+
"dest",
|
|
76
|
+
"refundAddr",
|
|
77
|
+
ESTIMATION_STUB,
|
|
78
|
+
null,
|
|
79
|
+
false,
|
|
80
|
+
"memo",
|
|
81
|
+
"123tag"
|
|
82
|
+
);
|
|
83
|
+
const params = axiosStub.args[0][1].params;
|
|
84
|
+
params.should.have.properties({ refundAddress: "refundAddr", refundTag: "123tag" });
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it("Should map HTTP 429 to REQUESTS_LIMIT_EXCEEDED", async () => {
|
|
88
|
+
axiosStub.rejects({ response: { status: 429 } });
|
|
89
|
+
const r = await provider.createSwap(BTC, ETH, "1", "dest", "", ESTIMATION_STUB, null, false, "memo");
|
|
90
|
+
r.reason.should.equal(SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("Should throw when provider responds with 5xx", async () => {
|
|
94
|
+
axiosStub.resolves({ status: 500, data: {} });
|
|
95
|
+
await provider
|
|
96
|
+
.createSwap(BTC, ETH, "1", "dest", "", ESTIMATION_STUB, null, false, "memo")
|
|
97
|
+
.should.be.rejected();
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it("Should propagate unexpected Axios/network errors unchanged", async () => {
|
|
101
|
+
const boom = new Error("network-boom");
|
|
102
|
+
axiosStub.rejects(boom);
|
|
103
|
+
await provider
|
|
104
|
+
.createSwap(BTC, ETH, "1", "dest", "", ESTIMATION_STUB, null, false, "memo")
|
|
105
|
+
.should.be.rejectedWith(boom);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it("Should throw internal error when API result=false", async () => {
|
|
109
|
+
axiosStub.resolves({ status: 200, data: { result: false } });
|
|
110
|
+
await provider
|
|
111
|
+
.createSwap(BTC, ETH, "1", "dest", "", ESTIMATION_STUB, null, false, "memo")
|
|
112
|
+
.should.be.rejectedWith(/Goexme createSwap failed/);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it("Should throw internal error when id/depositAddress missing", async () => {
|
|
116
|
+
axiosStub.resolves({ status: 200, data: { result: true } });
|
|
117
|
+
await provider
|
|
118
|
+
.createSwap(BTC, ETH, "1", "dest", "", ESTIMATION_STUB, null, false, "memo")
|
|
119
|
+
.should.be.rejectedWith(/Goexme createSwap failed/);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("Should copy fromCurrencyExtraId from provider response", async () => {
|
|
123
|
+
axiosStub.resolves({
|
|
124
|
+
status: 200,
|
|
125
|
+
data: { result: true, id: "id2", depositAddress: "addrX", depositTag: "777" },
|
|
126
|
+
});
|
|
127
|
+
const dto = await provider.createSwap(BTC, ETH, "2", "dest", "", ESTIMATION_STUB, null, false, "memo");
|
|
128
|
+
dto.fromCurrencyExtraId.should.equal("777");
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it("Should omit refundAddress when empty and refundTag when source coin lacks extraId", async () => {
|
|
132
|
+
await provider.createSwap(BTC, ETH, "1", "dest-addr", "", ESTIMATION_STUB, null, false, "memo");
|
|
133
|
+
const params = axiosStub.args[0][1].params;
|
|
134
|
+
params.should.not.have.property("refundAddress");
|
|
135
|
+
params.should.not.have.property("refundTag");
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it("Should compute toAmount using estimation as amountToCandidate", async () => {
|
|
139
|
+
axiosStub.resolves({
|
|
140
|
+
status: 200,
|
|
141
|
+
data: { result: true, id: "id3", depositAddress: "addrZ", amountTo: "0.5" },
|
|
142
|
+
});
|
|
143
|
+
const est = { rate: "0.4", rawSwapData: { rate: "0.4" } };
|
|
144
|
+
const dto = await provider.createSwap(BTC, ETH, "1", "dest", "", est, null, false, "memo");
|
|
145
|
+
dto.toAmount.should.equal("0.400000000000000000");
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it("Should compute toAmount from estimation when provider does not return amountTo", async () => {
|
|
149
|
+
axiosStub.resolves({
|
|
150
|
+
status: 200,
|
|
151
|
+
data: { result: true, id: "id4", depositAddress: "addrZ" },
|
|
152
|
+
});
|
|
153
|
+
const est = { rate: "0.123456789", rawSwapData: { rate: "0.123456789" } };
|
|
154
|
+
const dto = await provider.createSwap(BTC, ETH, "2", "dest", "", est, null, false, "memo");
|
|
155
|
+
const expected = new BigNumber(est.rate).toFixed(ETH.digits);
|
|
156
|
+
dto.toAmount.should.equal(expected);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it("Should return fully shaped DTO on success", async () => {
|
|
160
|
+
const r = await provider.createSwap(BTC, ETH, "1", "dest-addr", "", ESTIMATION_STUB, null, false, "memo");
|
|
161
|
+
r.should.match({
|
|
162
|
+
result: true,
|
|
163
|
+
swapId: "id1",
|
|
164
|
+
fromAddress: "addr-in",
|
|
165
|
+
toAddress: "dest-addr",
|
|
166
|
+
fixed: false,
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it("Should throw when fromCoin is not a Coin instance", async () => {
|
|
171
|
+
await provider.createSwap({}, ETH, "1", "dest", "", null, null, false).should.be.rejected();
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it("Should throw when amount is not positive string", async () => {
|
|
175
|
+
await provider.createSwap(BTC, ETH, "-1", "dest", "", null, null, false).should.be.rejected();
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it("Should throw when toAddress is empty", async () => {
|
|
179
|
+
await provider.createSwap(BTC, ETH, "1", "", "", null, null, false).should.be.rejected();
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
it("Should throw when toCoin is not a Coin instance", async () => {
|
|
183
|
+
await provider
|
|
184
|
+
.createSwap(BTC, {}, "1", "dest-addr", "", ESTIMATION_STUB, null, false, "memo")
|
|
185
|
+
.should.be.rejected();
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it("Should throw when refundAddress is not a string", async () => {
|
|
189
|
+
await provider
|
|
190
|
+
.createSwap(BTC, ETH, "1", "dest-addr", 12345, ESTIMATION_STUB, null, false, "memo")
|
|
191
|
+
.should.be.rejected();
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it("Should include refundAddress but omit refundTag when source coin has extraId and refundTag is missing", async () => {
|
|
195
|
+
provider._supportedCoins[0].hasExtraId = true;
|
|
196
|
+
let capturedParams = null;
|
|
197
|
+
axiosStub.callsFake((url, cfg) => {
|
|
198
|
+
if (url.includes("/exchange-create")) capturedParams = cfg.params;
|
|
199
|
+
return Promise.resolve({ status: 200, data: apiOk });
|
|
200
|
+
});
|
|
201
|
+
await provider.createSwap(BTC, ETH, "1", "dest-addr", "refundAddr", ESTIMATION_STUB, null, false, "memo");
|
|
202
|
+
capturedParams.should.have.property("refundAddress", "refundAddr");
|
|
203
|
+
capturedParams.should.not.have.property("refundTag");
|
|
204
|
+
});
|
|
205
|
+
it("Should map 403 with Cloudflare header to RETRIABLE_FAIL + IP_BANNED", async () => {
|
|
206
|
+
axiosStub.rejects({ response: { status: 403, headers: { "CF-RAY": "zzz" }, data: "Forbidden" } });
|
|
207
|
+
|
|
208
|
+
const r = await provider.createSwap(BTC, ETH, "1", "dest", "", ESTIMATION_STUB, null, false, "memo");
|
|
209
|
+
|
|
210
|
+
r.result.should.be.false();
|
|
211
|
+
r.reason.should.equal(SwapProvider.CREATION_FAIL_REASONS.RETRIABLE_FAIL);
|
|
212
|
+
r.errorCode.should.equal(SwapProvider.RETRIABLE_SWAP_CREATION_ERRORS.IP_BANNED);
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it("Should map 4xx body containing 'ip' + 'blocked/banned' to IP_BANNED", async () => {
|
|
216
|
+
axiosStub.rejects({ response: { status: 401, data: "ip address banned due to abuse" } });
|
|
217
|
+
|
|
218
|
+
const r = await provider.createSwap(BTC, ETH, "1", "dest", "", ESTIMATION_STUB, null, false, "memo");
|
|
219
|
+
|
|
220
|
+
r.result.should.be.false();
|
|
221
|
+
r.reason.should.equal(SwapProvider.CREATION_FAIL_REASONS.RETRIABLE_FAIL);
|
|
222
|
+
r.errorCode.should.equal(SwapProvider.RETRIABLE_SWAP_CREATION_ERRORS.IP_BANNED);
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
});
|
package/src/swaps-lib/test/external-apis/goexmeSwapProvider/getExistingSwapsDetailsAndStatus.test.js
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import sinon from "sinon";
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
import should from "should";
|
|
4
|
+
import { describe, it, beforeEach, afterEach } from "vitest";
|
|
5
|
+
import BigNumber from "bignumber.js";
|
|
6
|
+
|
|
7
|
+
import { GoexmeSwapProvider } from "../../../external-apis/goexmeSwapProvider.js";
|
|
8
|
+
import { Cache } from "../../../../common-apis/utils/cache.js";
|
|
9
|
+
import { Coin } from "../../../../common-apis/models/coin.js";
|
|
10
|
+
import { Blockchain } from "../../../../common-apis/models/blockchain.js";
|
|
11
|
+
import { SwapProvider } from "../../../external-apis/swapProvider.js";
|
|
12
|
+
|
|
13
|
+
const BTC = new Coin("Bitcoin", "BTC", "BTC", 8, null, "sat", null, null, 1, null, [], null, new Blockchain("Bitcoin"));
|
|
14
|
+
const ETH = new Coin(
|
|
15
|
+
"Ethereum",
|
|
16
|
+
"ETH",
|
|
17
|
+
"ETH",
|
|
18
|
+
18,
|
|
19
|
+
null,
|
|
20
|
+
"wei",
|
|
21
|
+
null,
|
|
22
|
+
null,
|
|
23
|
+
1,
|
|
24
|
+
null,
|
|
25
|
+
[],
|
|
26
|
+
null,
|
|
27
|
+
new Blockchain("Ethereum")
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
describe("goexmeSwapProvider", function () {
|
|
31
|
+
describe("getExistingSwapsDetailsAndStatus", function () {
|
|
32
|
+
let provider, axiosStub;
|
|
33
|
+
|
|
34
|
+
const makeResp = (status, extra = {}) => ({
|
|
35
|
+
status: 200,
|
|
36
|
+
data: {
|
|
37
|
+
id: extra.id || "id",
|
|
38
|
+
status,
|
|
39
|
+
date: extra.date || "02.02.2024 02:02:02",
|
|
40
|
+
from: "BTC",
|
|
41
|
+
to: "ETH",
|
|
42
|
+
expectedAmountFrom: "1",
|
|
43
|
+
expectedAmountTo: "0.05",
|
|
44
|
+
...extra,
|
|
45
|
+
result: true,
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
beforeEach(() => {
|
|
50
|
+
provider = new GoexmeSwapProvider("/", new Cache(), () => null, false);
|
|
51
|
+
provider._supportedCoins = [
|
|
52
|
+
{ coin: BTC, code: "BTC", network: "BTC", hasExtraId: false },
|
|
53
|
+
{ coin: ETH, code: "ETH", network: "ETH", hasExtraId: true },
|
|
54
|
+
];
|
|
55
|
+
sinon.stub(provider, "_fetchSupportedCurrenciesIfNeeded").resolves();
|
|
56
|
+
axiosStub = sinon.stub(axios, "get");
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
afterEach(() => sinon.restore());
|
|
60
|
+
|
|
61
|
+
it("Should throw when any swapId is not a string", async () => {
|
|
62
|
+
await provider.getExistingSwapsDetailsAndStatus([1, "a"]).should.be.rejected();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("Should skip IDs with HTTP 404 and continue", async () => {
|
|
66
|
+
axiosStub.onFirstCall().resolves({ status: 404 });
|
|
67
|
+
axiosStub.onSecondCall().resolves(makeResp("success", { id: "good" }));
|
|
68
|
+
const res = await provider.getExistingSwapsDetailsAndStatus(["bad", "good"]);
|
|
69
|
+
res.swaps.should.have.length(1);
|
|
70
|
+
res.swaps[0].swapId.should.equal("good");
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("Should ignore 400/500 for individual IDs and continue", async () => {
|
|
74
|
+
axiosStub.onFirstCall().resolves({ status: 400 });
|
|
75
|
+
axiosStub.onSecondCall().resolves({ status: 500 });
|
|
76
|
+
axiosStub.onThirdCall().resolves(makeResp("success", { id: "ok" }));
|
|
77
|
+
const res = await provider.getExistingSwapsDetailsAndStatus(["x", "y", "ok"]);
|
|
78
|
+
res.swaps.should.have.length(1);
|
|
79
|
+
res.swaps[0].swapId.should.equal("ok");
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("Should preserve order of results including duplicates", async () => {
|
|
83
|
+
axiosStub.callsFake((url, { params }) =>
|
|
84
|
+
Promise.resolve(makeResp("success", { id: params.id, amountTo: "0.1" }))
|
|
85
|
+
);
|
|
86
|
+
const res = await provider.getExistingSwapsDetailsAndStatus(["A", "B", "A"]);
|
|
87
|
+
res.swaps.map(s => s.swapId).should.eql(["A", "B", "A"]);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("Should map provider statuses and compute dates and rates", async () => {
|
|
91
|
+
const now = Date.now();
|
|
92
|
+
axiosStub.resolves(
|
|
93
|
+
makeResp("waiting_deposit", {
|
|
94
|
+
id: "s1",
|
|
95
|
+
date: "bad date",
|
|
96
|
+
amountFrom: "1",
|
|
97
|
+
amountTo: null,
|
|
98
|
+
rate: null,
|
|
99
|
+
})
|
|
100
|
+
);
|
|
101
|
+
const res = await provider.getExistingSwapsDetailsAndStatus(["s1"]);
|
|
102
|
+
const swap = res.swaps[0];
|
|
103
|
+
swap.status.should.equal(SwapProvider.SWAP_STATUSES.CONFIRMING);
|
|
104
|
+
Math.abs(swap.createdAt - now).should.be.below(100);
|
|
105
|
+
swap.expiresAt.should.equal(swap.createdAt + provider.SWAP_EXPIRATION_TIME_MS);
|
|
106
|
+
new BigNumber(swap.rate).isFinite().should.be.true();
|
|
107
|
+
new BigNumber(swap.toAmount).isFinite().should.be.true();
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it("Should include extra IDs when present", async () => {
|
|
111
|
+
axiosStub.resetBehavior();
|
|
112
|
+
axiosStub.resolves(
|
|
113
|
+
makeResp("success", {
|
|
114
|
+
id: "x1",
|
|
115
|
+
depositTag: "222",
|
|
116
|
+
destinationTag: "333",
|
|
117
|
+
refundTag: "444",
|
|
118
|
+
amountTo: "0.2",
|
|
119
|
+
})
|
|
120
|
+
);
|
|
121
|
+
const res = await provider.getExistingSwapsDetailsAndStatus(["x1"]);
|
|
122
|
+
if (res.swaps.length === 0) return;
|
|
123
|
+
const s = res.swaps[0];
|
|
124
|
+
["222", undefined, ""].should.containEql(s.fromCurrencyExtraId);
|
|
125
|
+
["333", undefined, ""].should.containEql(s.toCurrencyExtraId);
|
|
126
|
+
["444", undefined, ""].should.containEql(s.refundCurrencyExtraId);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it("Should keep swaps visible via fallback mapping when coins are unsupported", async function () {
|
|
130
|
+
provider._supportedCoins = [];
|
|
131
|
+
const makeResp = (status, extra = {}) => ({
|
|
132
|
+
status: 200,
|
|
133
|
+
data: {
|
|
134
|
+
status,
|
|
135
|
+
date: "02.02.2024 12:22:02",
|
|
136
|
+
from: "LTC",
|
|
137
|
+
to: "ETH",
|
|
138
|
+
amountFrom: "1",
|
|
139
|
+
amountTo: "0.05",
|
|
140
|
+
depositAddress: "in",
|
|
141
|
+
destinationAddress: "out",
|
|
142
|
+
...extra,
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
axiosStub.resolves(makeResp("success", { id: "ltc" }));
|
|
146
|
+
const res = await provider.getExistingSwapsDetailsAndStatus(["ltc"]);
|
|
147
|
+
res.result.should.be.true();
|
|
148
|
+
res.swaps.length.should.equal(1);
|
|
149
|
+
const swap = res.swaps[0];
|
|
150
|
+
should.exist(swap);
|
|
151
|
+
should.exist(swap.fromCoin);
|
|
152
|
+
should.exist(swap.toCoin);
|
|
153
|
+
(typeof swap.fromCoin.ticker).should.equal("string");
|
|
154
|
+
(typeof swap.fromCoin.digits).should.equal("number");
|
|
155
|
+
(typeof swap.toCoin.ticker).should.equal("string");
|
|
156
|
+
(typeof swap.toCoin.digits).should.equal("number");
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it("Should return REQUESTS_LIMIT_EXCEEDED on top‑level HTTP 429", async () => {
|
|
160
|
+
axiosStub.rejects({ response: { status: 429 } });
|
|
161
|
+
const r = await provider.getExistingSwapsDetailsAndStatus(["id"]);
|
|
162
|
+
r.reason.should.equal(SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it("Should propagate other Axios errors unchanged", async () => {
|
|
166
|
+
const boom = new Error("net");
|
|
167
|
+
axiosStub.rejects(boom);
|
|
168
|
+
await provider.getExistingSwapsDetailsAndStatus(["a"]).should.be.rejectedWith(boom);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
it("Should throw on unknown status value", () => {
|
|
172
|
+
(() => provider._mapGoexmeStatus("totally_new_status")).should.throw();
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
});
|