@rabbitio/ui-kit 1.0.0-beta.6 → 1.0.0-beta.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitlab-ci.yml +29 -0
- package/.husky/commit-msg +14 -0
- package/.husky/pre-push +1 -0
- package/CHANGELOG.md +0 -0
- package/README.md +27 -18
- package/coverage/base.css +224 -0
- package/coverage/block-navigation.js +87 -0
- package/coverage/clover.xml +17210 -0
- package/coverage/coverage-final.json +160 -0
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +1241 -0
- package/coverage/prettify.css +1 -0
- package/coverage/prettify.js +2 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +196 -0
- package/coverage/ui-kit/index.html +116 -0
- package/coverage/ui-kit/index.js.html +88 -0
- package/coverage/ui-kit/src/assets/wrappedImages/arrowIcon.jsx.html +142 -0
- package/coverage/ui-kit/src/assets/wrappedImages/arrowTosca.jsx.html +145 -0
- package/coverage/ui-kit/src/assets/wrappedImages/arrowWhite.jsx.html +145 -0
- package/coverage/ui-kit/src/assets/wrappedImages/darkRectangle.jsx.html +139 -0
- package/coverage/ui-kit/src/assets/wrappedImages/determinedError.jsx.html +472 -0
- package/coverage/ui-kit/src/assets/wrappedImages/failedValidationIcon.jsx.html +244 -0
- package/coverage/ui-kit/src/assets/wrappedImages/index.html +251 -0
- package/coverage/ui-kit/src/assets/wrappedImages/infoIcon.jsx.html +151 -0
- package/coverage/ui-kit/src/assets/wrappedImages/noticeQuestionIcon.jsx.html +265 -0
- package/coverage/ui-kit/src/assets/wrappedImages/successfulValidationIcon.jsx.html +205 -0
- package/coverage/ui-kit/src/assets/wrappedImages/walletIcon.jsx.html +199 -0
- package/coverage/ui-kit/src/common/adapters/axiosAdapter.js.html +190 -0
- package/coverage/ui-kit/src/common/adapters/index.html +131 -0
- package/coverage/ui-kit/src/common/adapters/qrUtils.js.html +139 -0
- package/coverage/ui-kit/src/common/amountUtils.js.html +1393 -0
- package/coverage/ui-kit/src/common/errorUtils.js.html +211 -0
- package/coverage/ui-kit/src/common/external-apis/apiGroups.js.html +250 -0
- package/coverage/ui-kit/src/common/external-apis/index.html +131 -0
- package/coverage/ui-kit/src/common/external-apis/ipAddressProviders.js.html +499 -0
- package/coverage/ui-kit/src/common/fiatCurrenciesService.js.html +568 -0
- package/coverage/ui-kit/src/common/index.html +146 -0
- package/coverage/ui-kit/src/common/models/blockchain.js.html +115 -0
- package/coverage/ui-kit/src/common/models/coin.js.html +556 -0
- package/coverage/ui-kit/src/common/models/index.html +146 -0
- package/coverage/ui-kit/src/common/models/protocol.js.html +100 -0
- package/coverage/ui-kit/src/common/utils/cache.js.html +889 -0
- package/coverage/ui-kit/src/common/utils/emailAPI.js.html +139 -0
- package/coverage/ui-kit/src/common/utils/index.html +161 -0
- package/coverage/ui-kit/src/common/utils/logging/index.html +131 -0
- package/coverage/ui-kit/src/common/utils/logging/logger.js.html +229 -0
- package/coverage/ui-kit/src/common/utils/logging/logsStorage.js.html +268 -0
- package/coverage/ui-kit/src/common/utils/postponeExecution.js.html +118 -0
- package/coverage/ui-kit/src/common/utils/safeStringify.js.html +235 -0
- package/coverage/ui-kit/src/components/atoms/AssetIcon/AssetIcon.jsx.html +277 -0
- package/coverage/ui-kit/src/components/atoms/AssetIcon/index.html +116 -0
- package/coverage/ui-kit/src/components/atoms/AssetSelection/AssetSelection.jsx.html +310 -0
- package/coverage/ui-kit/src/components/atoms/AssetSelection/index.html +116 -0
- package/coverage/ui-kit/src/components/atoms/BackgroundTitle/BackgroundTitle.jsx.html +217 -0
- package/coverage/ui-kit/src/components/atoms/BackgroundTitle/index.html +116 -0
- package/coverage/ui-kit/src/components/atoms/InformationMessage/InformationMessage.jsx.html +265 -0
- package/coverage/ui-kit/src/components/atoms/InformationMessage/index.html +116 -0
- package/coverage/ui-kit/src/components/atoms/Input/Input.jsx.html +679 -0
- package/coverage/ui-kit/src/components/atoms/Input/index.html +116 -0
- package/coverage/ui-kit/src/components/atoms/LoadingDots/LoadingDots.jsx.html +256 -0
- package/coverage/ui-kit/src/components/atoms/LoadingDots/index.html +116 -0
- package/coverage/ui-kit/src/components/atoms/NoticeIcon/NoticeIcon.jsx.html +298 -0
- package/coverage/ui-kit/src/components/atoms/NoticeIcon/index.html +116 -0
- package/coverage/ui-kit/src/components/atoms/QrCode/QrCode.jsx.html +187 -0
- package/coverage/ui-kit/src/components/atoms/QrCode/index.html +116 -0
- package/coverage/ui-kit/src/components/atoms/RateSelector/RateSelector.jsx.html +196 -0
- package/coverage/ui-kit/src/components/atoms/RateSelector/index.html +116 -0
- package/coverage/ui-kit/src/components/atoms/SupportChat/SupportChat.jsx.html +229 -0
- package/coverage/ui-kit/src/components/atoms/SupportChat/index.html +116 -0
- package/coverage/ui-kit/src/components/atoms/Textarea/Textarea.jsx.html +559 -0
- package/coverage/ui-kit/src/components/atoms/Textarea/index.html +116 -0
- package/coverage/ui-kit/src/components/atoms/TitleBox/TitleBox.jsx.html +577 -0
- package/coverage/ui-kit/src/components/atoms/TitleBox/index.html +116 -0
- package/coverage/ui-kit/src/components/atoms/Tooltip/Tooltip.jsx.html +295 -0
- package/coverage/ui-kit/src/components/atoms/Tooltip/index.html +116 -0
- package/coverage/ui-kit/src/components/atoms/TwoLinesOfText/LinesOfText.jsx.html +325 -0
- package/coverage/ui-kit/src/components/atoms/TwoLinesOfText/index.html +116 -0
- package/coverage/ui-kit/src/components/atoms/Validation/Validation.jsx.html +202 -0
- package/coverage/ui-kit/src/components/atoms/Validation/index.html +116 -0
- package/coverage/ui-kit/src/components/atoms/buttons/Button/Button.jsx.html +802 -0
- package/coverage/ui-kit/src/components/atoms/buttons/Button/index.html +116 -0
- package/coverage/ui-kit/src/components/atoms/buttons/Close/Close.jsx.html +262 -0
- package/coverage/ui-kit/src/components/atoms/buttons/Close/index.html +116 -0
- package/coverage/ui-kit/src/components/atoms/buttons/LinkButton/LinkButton.jsx.html +430 -0
- package/coverage/ui-kit/src/components/atoms/buttons/LinkButton/index.html +116 -0
- package/coverage/ui-kit/src/components/atoms/buttons/RadioButtonWithText/RadioButtonWithText.jsx.html +469 -0
- package/coverage/ui-kit/src/components/atoms/buttons/RadioButtonWithText/index.html +116 -0
- package/coverage/ui-kit/src/components/hooks/index.html +131 -0
- package/coverage/ui-kit/src/components/hooks/useCallHandlingErrors.js.html +163 -0
- package/coverage/ui-kit/src/components/hooks/useReferredState.js.html +157 -0
- package/coverage/ui-kit/src/components/molecules/AmountInput/AmountInput.jsx.html +1348 -0
- package/coverage/ui-kit/src/components/molecules/AmountInput/index.html +116 -0
- package/coverage/ui-kit/src/components/molecules/CoinPicker/CoinPicker.jsx.html +2011 -0
- package/coverage/ui-kit/src/components/molecules/CoinPicker/index.html +116 -0
- package/coverage/ui-kit/src/components/molecules/LineWithIconLink/LineWithIconLink.jsx.html +205 -0
- package/coverage/ui-kit/src/components/molecules/LineWithIconLink/index.html +116 -0
- package/coverage/ui-kit/src/components/molecules/TitledLineWithIconLink/TitledLineWithIconLink.jsx.html +175 -0
- package/coverage/ui-kit/src/components/molecules/TitledLineWithIconLink/index.html +116 -0
- package/coverage/ui-kit/src/components/organisms/CoinPickerDialogStep/CoinPickerDialogStep.jsx.html +283 -0
- package/coverage/ui-kit/src/components/organisms/CoinPickerDialogStep/index.html +116 -0
- package/coverage/ui-kit/src/components/organisms/Dialog/Dialog.jsx.html +1630 -0
- package/coverage/ui-kit/src/components/organisms/Dialog/DialogButtons/DialogButtons.jsx.html +451 -0
- package/coverage/ui-kit/src/components/organisms/Dialog/DialogButtons/index.html +116 -0
- package/coverage/ui-kit/src/components/organisms/Dialog/DialogStep/DialogStep.jsx.html +2146 -0
- package/coverage/ui-kit/src/components/organisms/Dialog/DialogStep/index.html +116 -0
- package/coverage/ui-kit/src/components/organisms/Dialog/index.html +116 -0
- package/coverage/ui-kit/src/components/organisms/SwapForm/SwapForm.jsx.html +3883 -0
- package/coverage/ui-kit/src/components/organisms/SwapForm/index.html +116 -0
- package/coverage/ui-kit/src/components/templates/DeterminedErrorDialogStep/DeterminedErrorDialogStep.jsx.html +316 -0
- package/coverage/ui-kit/src/components/templates/DeterminedErrorDialogStep/index.html +116 -0
- package/coverage/ui-kit/src/components/utils/index.html +161 -0
- package/coverage/ui-kit/src/components/utils/inputValueProviders.js.html +259 -0
- package/coverage/ui-kit/src/components/utils/textUtils.js.html +139 -0
- package/coverage/ui-kit/src/components/utils/uiUtils.js.html +127 -0
- package/coverage/ui-kit/src/components/utils/urlQueryUtils.js.html +346 -0
- package/coverage/ui-kit/src/constants/atoms/Close/close.jsx.html +100 -0
- package/coverage/ui-kit/src/constants/atoms/Close/index.html +116 -0
- package/coverage/ui-kit/src/constants/atoms/LinkButton/index.html +116 -0
- package/coverage/ui-kit/src/constants/atoms/LinkButton/linkButton.jsx.html +103 -0
- package/coverage/ui-kit/src/constants/atoms/Tooltip/index.html +116 -0
- package/coverage/ui-kit/src/constants/atoms/Tooltip/tooltip.jsx.html +109 -0
- package/coverage/ui-kit/src/constants/globalConstants.jsx.html +97 -0
- package/coverage/ui-kit/src/constants/index.html +116 -0
- package/coverage/ui-kit/src/constants/organisms/dialog/DialogStep/dialogStep.js.html +88 -0
- package/coverage/ui-kit/src/constants/organisms/dialog/DialogStep/index.html +116 -0
- package/coverage/ui-kit/src/constants/organisms/dialog/dialog.js.html +172 -0
- package/coverage/ui-kit/src/constants/organisms/dialog/index.html +116 -0
- package/coverage/ui-kit/src/index.html +116 -0
- package/coverage/ui-kit/src/index.js.html +367 -0
- package/coverage/ui-kit/src/robustExteranlApiCallerService/cacheAndConcurrentRequestsResolver.js.html +1762 -0
- package/coverage/ui-kit/src/robustExteranlApiCallerService/cachedRobustExternalApiCallerService.js.html +649 -0
- package/coverage/ui-kit/src/robustExteranlApiCallerService/cancelProcessing.js.html +172 -0
- package/coverage/ui-kit/src/robustExteranlApiCallerService/concurrentCalculationsMetadataHolder.js.html +394 -0
- package/coverage/ui-kit/src/robustExteranlApiCallerService/externalApiProvider.js.html +553 -0
- package/coverage/ui-kit/src/robustExteranlApiCallerService/externalServicesStatsCollector.js.html +331 -0
- package/coverage/ui-kit/src/robustExteranlApiCallerService/index.html +206 -0
- package/coverage/ui-kit/src/robustExteranlApiCallerService/robustExternalAPICallerService.js.html +1249 -0
- package/coverage/ui-kit/src/swaps-lib/external-apis/index.html +131 -0
- package/coverage/ui-kit/src/swaps-lib/external-apis/swapProvider.js.html +727 -0
- package/coverage/ui-kit/src/swaps-lib/external-apis/swapspaceSwapProvider.js.html +2899 -0
- package/coverage/ui-kit/src/swaps-lib/models/baseSwapCreationInfo.js.html +214 -0
- package/coverage/ui-kit/src/swaps-lib/models/existingSwap.js.html +304 -0
- package/coverage/ui-kit/src/swaps-lib/models/existingSwapWithFiatData.js.html +487 -0
- package/coverage/ui-kit/src/swaps-lib/models/index.html +146 -0
- package/coverage/ui-kit/src/swaps-lib/services/index.html +116 -0
- package/coverage/ui-kit/src/swaps-lib/services/publicSwapService.js.html +2191 -0
- package/coverage/ui-kit/src/swaps-lib/utils/index.html +116 -0
- package/coverage/ui-kit/src/swaps-lib/utils/swapUtils.js.html +742 -0
- package/coverage/ui-kit/stories/atoms/BackgroundTitle.stories.jsx.html +202 -0
- package/coverage/ui-kit/stories/atoms/LinesOfText.stories.jsx.html +283 -0
- package/coverage/ui-kit/stories/atoms/LoadingDots.stories.jsx.html +226 -0
- package/coverage/ui-kit/stories/atoms/QrCode.stories.jsx.html +175 -0
- package/coverage/ui-kit/stories/atoms/RateSelector.stories.jsx.html +136 -0
- package/coverage/ui-kit/stories/atoms/Validation.stories.jsx.html +178 -0
- package/coverage/ui-kit/stories/atoms/buttons/Button.stories.jsx.html +946 -0
- package/coverage/ui-kit/stories/atoms/buttons/Close.stories.jsx.html +214 -0
- package/coverage/ui-kit/stories/atoms/buttons/LinkButton.stories.jsx.html +295 -0
- package/coverage/ui-kit/stories/atoms/buttons/index.html +146 -0
- package/coverage/ui-kit/stories/atoms/index.html +191 -0
- package/coverage/ui-kit/stories/molecules/LineWithIconLink.stories.jsx.html +154 -0
- package/coverage/ui-kit/stories/molecules/TitledLineWithIconLink.stories.jsx.html +160 -0
- package/coverage/ui-kit/stories/molecules/index.html +131 -0
- package/coverage/ui-kit/stories/organisms/Dialog/Dialog.stories.jsx.html +589 -0
- package/coverage/ui-kit/stories/organisms/Dialog/DialogButtons/DialogButtons.stories.jsx.html +328 -0
- package/coverage/ui-kit/stories/organisms/Dialog/DialogButtons/index.html +116 -0
- package/coverage/ui-kit/stories/organisms/Dialog/DialogStep/DialogStep.stories.jsx.html +337 -0
- package/coverage/ui-kit/stories/organisms/Dialog/DialogStep/index.html +116 -0
- package/coverage/ui-kit/stories/organisms/Dialog/index.html +116 -0
- package/coverage/ui-kit/stories/stubs/exampleContent.jsx.html +145 -0
- package/coverage/ui-kit/stories/stubs/index.html +116 -0
- package/coverage/ui-kit/stories/templates/DeterminedErrorDialogStep.stories.jsx.html +193 -0
- package/coverage/ui-kit/stories/templates/index.html +116 -0
- package/dist/index.cjs +9963 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +71409 -1641
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +7672 -11
- package/dist/index.modern.js.map +1 -1
- package/dist/index.module.js +9883 -11
- package/dist/index.module.js.map +1 -1
- package/dist/index.umd.js +9954 -12
- package/dist/index.umd.js.map +1 -1
- package/index.js +1 -1
- package/package.json +27 -5
- package/src/assets/image/icons/arrow-tosca.svg +3 -0
- package/src/assets/wrappedImages/arrowIcon.jsx +19 -0
- package/src/assets/wrappedImages/arrowTosca.jsx +20 -0
- package/src/assets/wrappedImages/arrowWhite.jsx +20 -0
- package/src/assets/wrappedImages/darkRectangle.jsx +18 -0
- package/src/assets/wrappedImages/determinedError.jsx +129 -0
- package/src/assets/wrappedImages/failedValidationIcon.jsx +53 -0
- package/src/assets/wrappedImages/infoIcon.jsx +22 -0
- package/src/assets/wrappedImages/noticeQuestionIcon.jsx +60 -0
- package/src/assets/wrappedImages/successfulValidationIcon.jsx +40 -0
- package/src/assets/wrappedImages/walletIcon.jsx +38 -0
- package/src/common/adapters/axiosAdapter.js +35 -0
- package/src/common/adapters/qrUtils.js +18 -0
- package/src/common/amountUtils.js +436 -0
- package/src/common/errorUtils.js +42 -0
- package/src/common/external-apis/apiGroups.js +55 -0
- package/src/common/external-apis/ipAddressProviders.js +138 -0
- package/src/common/fiatCurrenciesService.js +161 -0
- package/src/common/models/blockchain.js +10 -0
- package/src/common/models/coin.js +157 -0
- package/src/common/models/protocol.js +5 -0
- package/src/common/tests/integration/external-apis/ipAddressProviders/getClientIpAddress.test.js +14 -0
- package/src/common/utils/cache.js +268 -0
- package/src/common/utils/emailAPI.js +18 -0
- package/src/common/utils/logging/logger.js +48 -0
- package/src/common/utils/logging/logsStorage.js +61 -0
- package/src/common/utils/postponeExecution.js +11 -0
- package/src/common/utils/safeStringify.js +50 -0
- package/src/components/atoms/AssetIcon/AssetIcon.jsx +64 -0
- package/src/components/atoms/AssetIcon/asset-icon.module.scss +42 -0
- package/src/components/atoms/AssetSelection/AssetSelection.jsx +75 -0
- package/src/components/atoms/AssetSelection/asset-selection.module.scss +55 -0
- package/src/components/atoms/BackgroundTitle/BackgroundTitle.jsx +44 -0
- package/src/components/atoms/BackgroundTitle/background-title.module.scss +52 -0
- package/src/components/atoms/InformationMessage/InformationMessage.jsx +60 -0
- package/src/components/atoms/InformationMessage/information-message.module.scss +36 -0
- package/src/components/atoms/Input/Input.jsx +198 -0
- package/src/components/atoms/Input/input.module.scss +107 -0
- package/{stories → src/components}/atoms/LoadingDots/LoadingDots.module.scss +1 -1
- package/src/components/atoms/NoticeIcon/NoticeIcon.jsx +71 -0
- package/src/components/atoms/NoticeIcon/notice-icon.module.scss +14 -0
- package/src/components/atoms/QrCode/QrCode.jsx +34 -0
- package/src/components/atoms/QrCode/qr-code.module.scss +9 -0
- package/src/components/atoms/RateSelector/RateSelector.jsx +37 -0
- package/src/components/atoms/RateSelector/rate-selector.module.scss +47 -0
- package/src/components/atoms/SupportChat/SupportChat.jsx +48 -0
- package/src/components/atoms/Textarea/Textarea.jsx +158 -0
- package/src/components/atoms/Textarea/textarea.module.scss +71 -0
- package/src/components/atoms/TitleBox/TitleBox.jsx +164 -0
- package/src/components/atoms/TitleBox/title-box.module.scss +30 -0
- package/src/components/atoms/Tooltip/Tooltip.jsx +70 -0
- package/src/components/atoms/Tooltip/tooltip.module.scss +237 -0
- package/src/components/atoms/TwoLinesOfText/LinesOfText.jsx +80 -0
- package/src/components/atoms/TwoLinesOfText/lines-of-text.module.scss +65 -0
- package/src/components/atoms/Validation/Validation.jsx +39 -0
- package/src/components/atoms/Validation/validation.module.scss +15 -0
- package/{stories → src/components}/atoms/buttons/Button/Button.jsx +5 -1
- package/{stories → src/components}/atoms/buttons/Button/Button.module.scss +1 -1
- package/src/components/atoms/buttons/Close/Close.jsx +59 -0
- package/src/components/atoms/buttons/Close/close.module.scss +75 -0
- package/src/components/atoms/buttons/LinkButton/LinkButton.jsx +115 -0
- package/src/components/atoms/buttons/LinkButton/link-button.module.scss +49 -0
- package/src/components/atoms/buttons/RadioButtonWithText/RadioButtonWithText.jsx +128 -0
- package/src/components/atoms/buttons/RadioButtonWithText/radio-button-with-text.module.scss +86 -0
- package/src/components/hooks/useCallHandlingErrors.js +26 -0
- package/src/components/hooks/useReferredState.js +24 -0
- package/src/components/molecules/AmountInput/AmountInput.jsx +421 -0
- package/src/components/molecules/AmountInput/amount-input.module.scss +189 -0
- package/src/components/molecules/CoinPicker/CoinPicker.jsx +642 -0
- package/src/components/molecules/CoinPicker/coin-picker.module.scss +210 -0
- package/src/components/molecules/LineWithIconLink/LineWithIconLink.jsx +40 -0
- package/src/components/molecules/LineWithIconLink/line-with-icon-link.module.scss +25 -0
- package/src/components/molecules/TitledLineWithIconLink/TitledLineWithIconLink.jsx +30 -0
- package/src/components/organisms/CoinPickerDialogStep/CoinPickerDialogStep.jsx +66 -0
- package/src/components/organisms/Dialog/Dialog.jsx +515 -0
- package/src/components/organisms/Dialog/DialogButtons/DialogButtons.jsx +122 -0
- package/src/components/organisms/Dialog/DialogButtons/dialog-buttons.module.scss +25 -0
- package/src/components/organisms/Dialog/DialogStep/DialogStep.jsx +687 -0
- package/src/components/organisms/Dialog/DialogStep/dialog-step.module.scss +383 -0
- package/src/components/organisms/Dialog/dialog.module.scss +226 -0
- package/src/components/organisms/SwapForm/SwapForm.jsx +1266 -0
- package/src/components/organisms/SwapForm/swap-form.module.scss +134 -0
- package/src/components/templates/DeterminedErrorDialogStep/DeterminedErrorDialogStep.jsx +77 -0
- package/src/components/tests/utils/inputValueProviders/provideFormatOfFloatValueByInputString.test.js +139 -0
- package/src/components/tests/utils/urlQueryUtils/getQueryParameterValues.test.js +71 -0
- package/src/components/tests/utils/urlQueryUtils/saveQueryParameterAndValues.test.js +144 -0
- package/src/components/utils/inputValueProviders.js +58 -0
- package/src/components/utils/textUtils.js +18 -0
- package/src/components/utils/uiUtils.js +14 -0
- package/src/components/utils/urlQueryUtils.js +87 -0
- package/src/constants/atoms/Close/close.jsx +5 -0
- package/src/constants/atoms/LinkButton/linkButton.jsx +6 -0
- package/src/constants/atoms/Tooltip/tooltip.jsx +8 -0
- package/src/constants/globalConstants.jsx +4 -0
- package/src/constants/organisms/dialog/DialogStep/dialogStep.js +1 -0
- package/src/constants/organisms/dialog/dialog.js +29 -0
- package/src/index.js +94 -0
- package/src/robustExteranlApiCallerService/cacheAndConcurrentRequestsResolver.js +559 -0
- package/src/robustExteranlApiCallerService/cachedRobustExternalApiCallerService.js +188 -0
- package/src/robustExteranlApiCallerService/cancelProcessing.js +29 -0
- package/src/robustExteranlApiCallerService/concurrentCalculationsMetadataHolder.js +103 -0
- package/src/robustExteranlApiCallerService/externalApiProvider.js +156 -0
- package/src/robustExteranlApiCallerService/externalServicesStatsCollector.js +82 -0
- package/src/robustExteranlApiCallerService/robustExternalAPICallerService.js +388 -0
- package/src/robustExteranlApiCallerService/tests/robustExternalAPICallerService/robustExternalAPICallerService/callExternalAPI/_performCallAttempt.test.js +787 -0
- package/src/robustExteranlApiCallerService/tests/robustExternalAPICallerService/robustExternalAPICallerService/callExternalAPI/callExternalAPI.test.js +745 -0
- package/src/robustExteranlApiCallerService/tests/robustExternalAPICallerService/robustExternalAPICallerService/constructor.test.js +31 -0
- package/src/swaps-lib/external-apis/swapProvider.js +214 -0
- package/src/swaps-lib/external-apis/swapspaceSwapProvider.js +938 -0
- package/src/swaps-lib/models/baseSwapCreationInfo.js +43 -0
- package/src/swaps-lib/models/existingSwap.js +73 -0
- package/src/swaps-lib/models/existingSwapWithFiatData.js +134 -0
- package/src/swaps-lib/services/publicSwapService.js +702 -0
- package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/_fetchSupportedCurrenciesIfNeeded.test.js +506 -0
- package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/createSwap.test.js +1311 -0
- package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/getAllSupportedCurrencies.test.js +76 -0
- package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/getDepositCurrencies.test.js +82 -0
- package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/getSwapInfo.test.js +1892 -0
- package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/getWithdrawalCurrencies.test.js +111 -0
- package/src/swaps-lib/test/utils/swapUtils/safeHandleRequestsLimitExceeding.test.js +88 -0
- package/src/swaps-lib/utils/swapUtils.js +219 -0
- package/stories/stubs/exampleContent.jsx +20 -0
- package/styles/_placeholder.scss +1 -1
- 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 +1 -1
- package/styles/index.scss +5 -3
- package/stories/index.js +0 -2
- /package/{stories → src/components}/atoms/LoadingDots/LoadingDots.jsx +0 -0
|
@@ -0,0 +1,506 @@
|
|
|
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 { SwapspaceSwapProvider } from "../../../external-apis/swapspaceSwapProvider.js";
|
|
8
|
+
import { Coin } from "../../../../common/models/coin.js";
|
|
9
|
+
import { Cache } from "../../../../common/utils/cache.js";
|
|
10
|
+
import { Protocol } from "../../../../common/models/protocol.js";
|
|
11
|
+
|
|
12
|
+
describe("swapspaceSwapProvider", function () {
|
|
13
|
+
describe("_fetchSupportedCurrenciesIfNeeded", function () {
|
|
14
|
+
const swapspaceProvider = new SwapspaceSwapProvider("/", new Cache());
|
|
15
|
+
const anyError = new Error("Any error");
|
|
16
|
+
|
|
17
|
+
let axiosGetStub;
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
axiosGetStub = sinon.stub(axios, "get");
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
afterEach(() => {
|
|
23
|
+
axiosGetStub.restore();
|
|
24
|
+
swapspaceProvider._supportedCoins = [];
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("Should throw an error if axios throws error", async () => {
|
|
28
|
+
axiosGetStub.resetBehavior();
|
|
29
|
+
axiosGetStub.rejects(anyError);
|
|
30
|
+
|
|
31
|
+
const swapProvider = new SwapspaceSwapProvider("/", new Cache());
|
|
32
|
+
|
|
33
|
+
return swapProvider
|
|
34
|
+
._fetchSupportedCurrenciesIfNeeded()
|
|
35
|
+
.should.be.rejectedWith(anyError);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("Should not call axios if there is _supportedCoins", async () => {
|
|
39
|
+
swapspaceProvider._supportedCoins = [{ coin: {}, extraId: "" }];
|
|
40
|
+
await swapspaceProvider._fetchSupportedCurrenciesIfNeeded();
|
|
41
|
+
|
|
42
|
+
axiosGetStub.callCount.should.be.equal(0);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("should make a network call if coins are not cached", async () => {
|
|
46
|
+
swapspaceProvider._supportedCoins = [];
|
|
47
|
+
const fakeResponse = { data: [] };
|
|
48
|
+
axiosGetStub.returns(Promise.resolve(fakeResponse));
|
|
49
|
+
|
|
50
|
+
await swapspaceProvider._fetchSupportedCurrenciesIfNeeded();
|
|
51
|
+
|
|
52
|
+
axiosGetStub.calledOnce.should.be.true();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("Should call _customCoinBuilder number of times equal to returned coins count", async () => {
|
|
56
|
+
const _customCoinBuilderStub = sinon.stub();
|
|
57
|
+
const someResp = {
|
|
58
|
+
data: [
|
|
59
|
+
{ code: "1", network: "n1" },
|
|
60
|
+
{ code: "2", network: "n2" },
|
|
61
|
+
{ code: "3", network: "n3" },
|
|
62
|
+
{ code: "4", network: "n4" },
|
|
63
|
+
],
|
|
64
|
+
};
|
|
65
|
+
axiosGetStub.resetBehavior();
|
|
66
|
+
axiosGetStub.resolves(someResp);
|
|
67
|
+
const p = new SwapspaceSwapProvider(
|
|
68
|
+
"/",
|
|
69
|
+
new Cache(),
|
|
70
|
+
_customCoinBuilderStub
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
await p._fetchSupportedCurrenciesIfNeeded();
|
|
74
|
+
|
|
75
|
+
_customCoinBuilderStub.callCount.should.be.equal(
|
|
76
|
+
someResp.data.length
|
|
77
|
+
);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it("Should call _customCoinBuilder with proper params", async () => {
|
|
81
|
+
const _customCoinBuilderStub = sinon.stub();
|
|
82
|
+
const someResp = {
|
|
83
|
+
data: [
|
|
84
|
+
{ code: "1", network: "n1" },
|
|
85
|
+
{ code: "2", network: "n2" },
|
|
86
|
+
{ code: "3", network: "n3" },
|
|
87
|
+
{ code: "4", network: "n4" },
|
|
88
|
+
],
|
|
89
|
+
};
|
|
90
|
+
axiosGetStub.resetBehavior();
|
|
91
|
+
axiosGetStub.resolves(someResp);
|
|
92
|
+
const p = new SwapspaceSwapProvider(
|
|
93
|
+
"/",
|
|
94
|
+
new Cache(),
|
|
95
|
+
_customCoinBuilderStub
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
await p._fetchSupportedCurrenciesIfNeeded();
|
|
99
|
+
|
|
100
|
+
_customCoinBuilderStub.args.forEach((args, i) =>
|
|
101
|
+
args.should.be.deepEqual([
|
|
102
|
+
someResp.data[i].code,
|
|
103
|
+
someResp.data[i].network,
|
|
104
|
+
])
|
|
105
|
+
);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it("Should ignore coins that _customCoinBuilder returned null for if useRestrictedCoinsSet is true", async () => {
|
|
109
|
+
const someResp = {
|
|
110
|
+
data: [
|
|
111
|
+
{ code: "1", network: "n1" },
|
|
112
|
+
{ code: "2", network: "n2" },
|
|
113
|
+
{ code: "3", network: "n3" },
|
|
114
|
+
],
|
|
115
|
+
};
|
|
116
|
+
const _customCoinBuilderStub = sinon.stub();
|
|
117
|
+
_customCoinBuilderStub.onFirstCall().returns({ ticker: "1" });
|
|
118
|
+
_customCoinBuilderStub.onSecondCall().returns(null);
|
|
119
|
+
_customCoinBuilderStub.onThirdCall().returns({ ticker: "3" });
|
|
120
|
+
|
|
121
|
+
axiosGetStub.resetBehavior();
|
|
122
|
+
axiosGetStub.resolves(someResp);
|
|
123
|
+
const p = new SwapspaceSwapProvider(
|
|
124
|
+
"/",
|
|
125
|
+
new Cache(),
|
|
126
|
+
_customCoinBuilderStub,
|
|
127
|
+
true
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
await p._fetchSupportedCurrenciesIfNeeded();
|
|
131
|
+
|
|
132
|
+
p._supportedCoins.length.should.be.equal(2);
|
|
133
|
+
(
|
|
134
|
+
p._supportedCoins.find((i) => i.coin.ticker === "1") != null
|
|
135
|
+
).should.be.true();
|
|
136
|
+
(
|
|
137
|
+
p._supportedCoins.find((i) => i.coin.ticker === "3") != null
|
|
138
|
+
).should.be.true();
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it("Should construct coins with default params if _customCoinBuilder return null for some and useRestrictedCoinsSet is false", async () => {
|
|
142
|
+
const someResp = {
|
|
143
|
+
data: [
|
|
144
|
+
{ code: "aaa", network: "n1" },
|
|
145
|
+
{
|
|
146
|
+
code: "bbb",
|
|
147
|
+
network: "n2",
|
|
148
|
+
name: "some",
|
|
149
|
+
contractAddress: "addr",
|
|
150
|
+
},
|
|
151
|
+
{ code: "ccc", network: "n3" },
|
|
152
|
+
],
|
|
153
|
+
};
|
|
154
|
+
const _customCoinBuilderStub = sinon.stub();
|
|
155
|
+
_customCoinBuilderStub.onFirstCall().returns({ ticker: "AAAN1" });
|
|
156
|
+
_customCoinBuilderStub.onSecondCall().returns(null);
|
|
157
|
+
_customCoinBuilderStub.onThirdCall().returns({ ticker: "CCCN3" });
|
|
158
|
+
|
|
159
|
+
axiosGetStub.resetBehavior();
|
|
160
|
+
axiosGetStub.resolves(someResp);
|
|
161
|
+
const p = new SwapspaceSwapProvider(
|
|
162
|
+
"/",
|
|
163
|
+
new Cache(),
|
|
164
|
+
_customCoinBuilderStub,
|
|
165
|
+
false
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
await p._fetchSupportedCurrenciesIfNeeded();
|
|
169
|
+
|
|
170
|
+
p._supportedCoins.length.should.be.equal(3);
|
|
171
|
+
|
|
172
|
+
const newCoin = p._supportedCoins.find(
|
|
173
|
+
(i) => i.coin.ticker === "BBBN2"
|
|
174
|
+
)?.coin;
|
|
175
|
+
(newCoin instanceof Coin).should.be.true();
|
|
176
|
+
newCoin.tickerPrintable.should.be.equal("BBB");
|
|
177
|
+
newCoin.latinName.should.be.equal("some");
|
|
178
|
+
newCoin.digits.should.be.equal(8);
|
|
179
|
+
(newCoin.maxValue === null).should.be.true();
|
|
180
|
+
newCoin.atomName.should.be.equal("");
|
|
181
|
+
(newCoin.mainnet === null).should.be.true();
|
|
182
|
+
(newCoin.testnet === null).should.be.true();
|
|
183
|
+
newCoin.minConfirmations.should.be.equal(1);
|
|
184
|
+
(newCoin.payableEntityStringForFeeRate === null).should.be.true();
|
|
185
|
+
newCoin.feeOptionsTimeStringsSortedDesc.should.be.deepEqual([]);
|
|
186
|
+
newCoin.feeRatesExpirationTimeMs.should.be.equal(60000);
|
|
187
|
+
newCoin.protocol.should.be.deepEqual(new Protocol("N2"));
|
|
188
|
+
(newCoin.blockchain === null).should.be.true();
|
|
189
|
+
newCoin.tokenAddress.should.be.equal("addr");
|
|
190
|
+
newCoin.feeCoin.should.be.equal(newCoin);
|
|
191
|
+
newCoin.doesUseLowerCaseAddresses.should.be.equal(false);
|
|
192
|
+
newCoin.doesUseOutputs.should.be.equal(false);
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
it("Should construct coins with null protocol and ticker===<uppercase code> if _customCoinBuilder return null for item and useRestrictedCoinsSet is false and code and network are equal for item", async () => {
|
|
196
|
+
const someResp = {
|
|
197
|
+
data: [
|
|
198
|
+
{
|
|
199
|
+
code: "bbb",
|
|
200
|
+
network: "bbb",
|
|
201
|
+
},
|
|
202
|
+
],
|
|
203
|
+
};
|
|
204
|
+
const _customCoinBuilderStub = sinon.stub();
|
|
205
|
+
_customCoinBuilderStub.onFirstCall().returns(null);
|
|
206
|
+
|
|
207
|
+
axiosGetStub.resetBehavior();
|
|
208
|
+
axiosGetStub.resolves(someResp);
|
|
209
|
+
const p = new SwapspaceSwapProvider(
|
|
210
|
+
"/",
|
|
211
|
+
new Cache(),
|
|
212
|
+
_customCoinBuilderStub,
|
|
213
|
+
false
|
|
214
|
+
);
|
|
215
|
+
|
|
216
|
+
await p._fetchSupportedCurrenciesIfNeeded();
|
|
217
|
+
|
|
218
|
+
p._supportedCoins[0].coin.ticker.should.be.equal("BBB");
|
|
219
|
+
(p._supportedCoins[0].coin.protocol === null).should.be.true();
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
it("Should construct coins ticker===<uppercasecodeProtocol> and protocol with name===<uppercasenetwork> if _customCoinBuilder return null for item and useRestrictedCoinsSet is false and code and network are nopt equal for item", async () => {
|
|
223
|
+
const someResp = {
|
|
224
|
+
data: [
|
|
225
|
+
{
|
|
226
|
+
code: "bbb",
|
|
227
|
+
network: "bbb1",
|
|
228
|
+
},
|
|
229
|
+
],
|
|
230
|
+
};
|
|
231
|
+
const _customCoinBuilderStub = sinon.stub();
|
|
232
|
+
_customCoinBuilderStub.onFirstCall().returns(null);
|
|
233
|
+
|
|
234
|
+
axiosGetStub.resetBehavior();
|
|
235
|
+
axiosGetStub.resolves(someResp);
|
|
236
|
+
const p = new SwapspaceSwapProvider(
|
|
237
|
+
"/",
|
|
238
|
+
new Cache(),
|
|
239
|
+
_customCoinBuilderStub,
|
|
240
|
+
false
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
await p._fetchSupportedCurrenciesIfNeeded();
|
|
244
|
+
|
|
245
|
+
p._supportedCoins[0].coin.ticker.should.be.equal("BBBBBB1");
|
|
246
|
+
p._supportedCoins[0].coin.protocol.should.be.deepEqual(
|
|
247
|
+
new Protocol("BBB1")
|
|
248
|
+
);
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
it("Should construct coins with tokenAddress === null if _customCoinBuilder return null for item and useRestrictedCoinsSet is false and contractAddress is nullish for item", async () => {
|
|
252
|
+
const someResp = {
|
|
253
|
+
data: [
|
|
254
|
+
{
|
|
255
|
+
code: "bbb",
|
|
256
|
+
network: "bbb1",
|
|
257
|
+
},
|
|
258
|
+
],
|
|
259
|
+
};
|
|
260
|
+
const _customCoinBuilderStub = sinon.stub();
|
|
261
|
+
_customCoinBuilderStub.onFirstCall().returns(null);
|
|
262
|
+
|
|
263
|
+
axiosGetStub.resetBehavior();
|
|
264
|
+
axiosGetStub.resolves(someResp);
|
|
265
|
+
const p = new SwapspaceSwapProvider(
|
|
266
|
+
"/",
|
|
267
|
+
new Cache(),
|
|
268
|
+
_customCoinBuilderStub,
|
|
269
|
+
false
|
|
270
|
+
);
|
|
271
|
+
|
|
272
|
+
await p._fetchSupportedCurrenciesIfNeeded();
|
|
273
|
+
|
|
274
|
+
(p._supportedCoins[0].coin.tokenAddress === null).should.be.true();
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
const setupAndExecstoreCoinDataFormatTest = async (attribute) => {
|
|
278
|
+
const someResp = {
|
|
279
|
+
data: [
|
|
280
|
+
{
|
|
281
|
+
code: "aaa",
|
|
282
|
+
network: "aaa",
|
|
283
|
+
hasExtraId: false,
|
|
284
|
+
extraIdName: "",
|
|
285
|
+
popular: false,
|
|
286
|
+
iconURL: "/aaa",
|
|
287
|
+
deposit: true,
|
|
288
|
+
withdrawal: true,
|
|
289
|
+
validationRegexp: "any",
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
code: "bbb",
|
|
293
|
+
network: "bbb1",
|
|
294
|
+
hasExtraId: false,
|
|
295
|
+
extraIdName: "",
|
|
296
|
+
iconURL: "/bbb/bbb1.svg",
|
|
297
|
+
deposit: false,
|
|
298
|
+
withdrawal: false,
|
|
299
|
+
validationRegexp: "any",
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
code: "ccc",
|
|
303
|
+
network: "n3",
|
|
304
|
+
hasExtraId: true,
|
|
305
|
+
extraIdName: "",
|
|
306
|
+
popular: false,
|
|
307
|
+
iconURL: "/1/ccc.jpg",
|
|
308
|
+
deposit: true,
|
|
309
|
+
withdrawal: false,
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
code: "ddd",
|
|
313
|
+
network: "n4",
|
|
314
|
+
hasExtraId: true,
|
|
315
|
+
extraIdName: "MEMO",
|
|
316
|
+
popular: false,
|
|
317
|
+
deposit: false,
|
|
318
|
+
withdrawal: true,
|
|
319
|
+
validationRegexp: "any",
|
|
320
|
+
},
|
|
321
|
+
],
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
const _customCoinBuilderStub = sinon.stub();
|
|
325
|
+
_customCoinBuilderStub.returns(null);
|
|
326
|
+
// _customCoinBuilderStub.onCall(1).returns({ ticker: "CCCN3" });
|
|
327
|
+
|
|
328
|
+
axiosGetStub.resetBehavior();
|
|
329
|
+
axiosGetStub.resolves(someResp);
|
|
330
|
+
const p = new SwapspaceSwapProvider(
|
|
331
|
+
"/",
|
|
332
|
+
new Cache(),
|
|
333
|
+
_customCoinBuilderStub,
|
|
334
|
+
false
|
|
335
|
+
);
|
|
336
|
+
|
|
337
|
+
await p._fetchSupportedCurrenciesIfNeeded();
|
|
338
|
+
|
|
339
|
+
return { provider: p, data: someResp.data };
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
it("Should save constructed coin as a coin list item", async () => {
|
|
343
|
+
const { provider } = await setupAndExecstoreCoinDataFormatTest();
|
|
344
|
+
|
|
345
|
+
provider._supportedCoins.forEach((i) =>
|
|
346
|
+
i.coin.should.be.instanceof(Coin)
|
|
347
|
+
);
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
it("Should save code as is", async () => {
|
|
351
|
+
const { provider, data } =
|
|
352
|
+
await setupAndExecstoreCoinDataFormatTest();
|
|
353
|
+
|
|
354
|
+
provider._supportedCoins.forEach((dataItem, i) => {
|
|
355
|
+
dataItem.code.should.be.equal(data[i].code);
|
|
356
|
+
});
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
it("Should save network as is", async () => {
|
|
360
|
+
const { provider, data } =
|
|
361
|
+
await setupAndExecstoreCoinDataFormatTest();
|
|
362
|
+
|
|
363
|
+
provider._supportedCoins.forEach((dataItem, i) => {
|
|
364
|
+
dataItem.network.should.be.equal(data[i].network);
|
|
365
|
+
});
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
it("Should save hasExtraId as is", async () => {
|
|
369
|
+
const { provider, data } =
|
|
370
|
+
await setupAndExecstoreCoinDataFormatTest();
|
|
371
|
+
|
|
372
|
+
provider._supportedCoins.forEach((dataItem, i) => {
|
|
373
|
+
dataItem.hasExtraId.should.be.equal(data[i].hasExtraId);
|
|
374
|
+
});
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
it("Should save extraIdName as is", async () => {
|
|
378
|
+
const { provider, data } =
|
|
379
|
+
await setupAndExecstoreCoinDataFormatTest();
|
|
380
|
+
|
|
381
|
+
provider._supportedCoins.forEach((dataItem, i) => {
|
|
382
|
+
dataItem.extraIdName.should.be.equal(data[i].extraIdName);
|
|
383
|
+
});
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
it("Should save popular to isPopular as boolean", async () => {
|
|
387
|
+
const { provider, data } =
|
|
388
|
+
await setupAndExecstoreCoinDataFormatTest();
|
|
389
|
+
|
|
390
|
+
provider._supportedCoins.forEach((dataItem, i) => {
|
|
391
|
+
dataItem.isPopular.should.be.equal(!!data[i].popular);
|
|
392
|
+
});
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
it("Should save icon or default URL to iconURL", async () => {
|
|
396
|
+
const { provider, data } =
|
|
397
|
+
await setupAndExecstoreCoinDataFormatTest();
|
|
398
|
+
|
|
399
|
+
provider._supportedCoins.forEach((dataItem, i) => {
|
|
400
|
+
dataItem.iconURL.should.be.equal(
|
|
401
|
+
data[i].icon
|
|
402
|
+
? `https://storage.swapspace.co${data[i].iconURL}`
|
|
403
|
+
: "https://rabbit.io/asset-icons/fallback.svg"
|
|
404
|
+
);
|
|
405
|
+
});
|
|
406
|
+
});
|
|
407
|
+
|
|
408
|
+
it("Should save deposit as is", async () => {
|
|
409
|
+
const { provider, data } =
|
|
410
|
+
await setupAndExecstoreCoinDataFormatTest();
|
|
411
|
+
|
|
412
|
+
provider._supportedCoins.forEach((dataItem, i) => {
|
|
413
|
+
dataItem.deposit.should.be.equal(data[i].deposit);
|
|
414
|
+
});
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
it("Should save withdrawal as is", async () => {
|
|
418
|
+
const { provider, data } =
|
|
419
|
+
await setupAndExecstoreCoinDataFormatTest();
|
|
420
|
+
|
|
421
|
+
provider._supportedCoins.forEach((dataItem, i) => {
|
|
422
|
+
dataItem.withdrawal.should.be.equal(data[i].withdrawal);
|
|
423
|
+
});
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
it("Should save validationRegexp or null if it is nullish", async () => {
|
|
427
|
+
const { provider, data } =
|
|
428
|
+
await setupAndExecstoreCoinDataFormatTest();
|
|
429
|
+
|
|
430
|
+
provider._supportedCoins.forEach((dataItem, i) => {
|
|
431
|
+
(
|
|
432
|
+
dataItem.validationRegexp ===
|
|
433
|
+
(data[i].validationRegexp ?? null)
|
|
434
|
+
).should.be.true();
|
|
435
|
+
});
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
it("should sort list by isPopular and alphabetically by ticker", async () => {
|
|
439
|
+
const swapspaceProvider = new SwapspaceSwapProvider(
|
|
440
|
+
"/",
|
|
441
|
+
new Cache(),
|
|
442
|
+
() => null,
|
|
443
|
+
false
|
|
444
|
+
);
|
|
445
|
+
const fakeResponse = {
|
|
446
|
+
data: [
|
|
447
|
+
{
|
|
448
|
+
network: "eth",
|
|
449
|
+
code: "eth",
|
|
450
|
+
popular: true,
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
network: "bac",
|
|
454
|
+
code: "bac",
|
|
455
|
+
popular: false,
|
|
456
|
+
},
|
|
457
|
+
{
|
|
458
|
+
network: "bbb",
|
|
459
|
+
code: "btc",
|
|
460
|
+
popular: false,
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
network: "eee",
|
|
464
|
+
code: "aaa",
|
|
465
|
+
popular: false,
|
|
466
|
+
},
|
|
467
|
+
{
|
|
468
|
+
network: "xxx",
|
|
469
|
+
code: "aaa",
|
|
470
|
+
popular: true,
|
|
471
|
+
},
|
|
472
|
+
],
|
|
473
|
+
};
|
|
474
|
+
axiosGetStub.returns(Promise.resolve(fakeResponse));
|
|
475
|
+
|
|
476
|
+
await swapspaceProvider._fetchSupportedCurrenciesIfNeeded();
|
|
477
|
+
|
|
478
|
+
swapspaceProvider._supportedCoins
|
|
479
|
+
.map((coin) => coin.coin.ticker)
|
|
480
|
+
.should.be.deepEqual([
|
|
481
|
+
"AAAXXX",
|
|
482
|
+
"ETH",
|
|
483
|
+
"AAAEEE",
|
|
484
|
+
"BAC",
|
|
485
|
+
"BTCBBB",
|
|
486
|
+
]);
|
|
487
|
+
});
|
|
488
|
+
|
|
489
|
+
it("should handle empty response data", async () => {
|
|
490
|
+
const fakeResponse = { data: null };
|
|
491
|
+
axiosGetStub.returns(Promise.resolve(fakeResponse));
|
|
492
|
+
|
|
493
|
+
await swapspaceProvider._fetchSupportedCurrenciesIfNeeded();
|
|
494
|
+
|
|
495
|
+
swapspaceProvider._supportedCoins.should.deepEqual([]);
|
|
496
|
+
});
|
|
497
|
+
|
|
498
|
+
it("should handle absence of data field in response", async () => {
|
|
499
|
+
const fakeResponse = {};
|
|
500
|
+
axiosGetStub.returns(Promise.resolve(fakeResponse));
|
|
501
|
+
|
|
502
|
+
await swapspaceProvider._fetchSupportedCurrenciesIfNeeded();
|
|
503
|
+
swapspaceProvider._supportedCoins.should.deepEqual([]);
|
|
504
|
+
});
|
|
505
|
+
});
|
|
506
|
+
});
|