@rabbitio/ui-kit 1.0.0-beta.9 → 1.0.0-beta.91
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitlab-ci.yml +29 -0
- package/.husky/commit-msg +19 -0
- package/.husky/pre-push +1 -0
- package/CHANGELOG.md +0 -0
- package/README.md +27 -18
- package/coverage/base.css +224 -0
- package/coverage/block-navigation.js +87 -0
- package/coverage/clover.xml +16765 -0
- package/coverage/coverage-final.json +116 -0
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +1001 -0
- package/coverage/prettify.css +1 -0
- package/coverage/prettify.js +2 -0
- package/coverage/rabbit-ui-kit/index.html +116 -0
- package/coverage/rabbit-ui-kit/index.js.html +88 -0
- package/coverage/rabbit-ui-kit/src/common-apis/adapters/analyticsAdapters/googleAnalyticsAdapter.js.html +148 -0
- package/coverage/rabbit-ui-kit/src/common-apis/adapters/analyticsAdapters/index.html +146 -0
- package/coverage/rabbit-ui-kit/src/common-apis/adapters/analyticsAdapters/metrikaAdapter.js.html +169 -0
- package/coverage/rabbit-ui-kit/src/common-apis/adapters/analyticsAdapters/mixpanelAdapter.js.html +199 -0
- package/coverage/rabbit-ui-kit/src/common-apis/adapters/axiosAdapter.js.html +190 -0
- package/coverage/rabbit-ui-kit/src/common-apis/adapters/index.html +131 -0
- package/coverage/rabbit-ui-kit/src/common-apis/adapters/qrUtils.js.html +139 -0
- package/coverage/rabbit-ui-kit/src/common-apis/external-apis/apiGroups.js.html +250 -0
- package/coverage/rabbit-ui-kit/src/common-apis/external-apis/emailAPI.js.html +133 -0
- package/coverage/rabbit-ui-kit/src/common-apis/external-apis/index.html +146 -0
- package/coverage/rabbit-ui-kit/src/common-apis/external-apis/ipAddressProviders.js.html +352 -0
- package/coverage/rabbit-ui-kit/src/common-apis/globalConstants.jsx.html +94 -0
- package/coverage/rabbit-ui-kit/src/common-apis/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/common-apis/models/blockchain.js.html +115 -0
- package/coverage/rabbit-ui-kit/src/common-apis/models/coin.js.html +829 -0
- package/coverage/rabbit-ui-kit/src/common-apis/models/index.html +146 -0
- package/coverage/rabbit-ui-kit/src/common-apis/models/protocol.js.html +100 -0
- package/coverage/rabbit-ui-kit/src/common-apis/services/fiatCurrenciesService.js.html +544 -0
- package/coverage/rabbit-ui-kit/src/common-apis/services/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/common-apis/utils/amountUtils.js.html +1162 -0
- package/coverage/rabbit-ui-kit/src/common-apis/utils/cache.js.html +811 -0
- package/coverage/rabbit-ui-kit/src/common-apis/utils/errorUtils.js.html +211 -0
- package/coverage/rabbit-ui-kit/src/common-apis/utils/index.html +191 -0
- package/coverage/rabbit-ui-kit/src/common-apis/utils/logging/index.html +131 -0
- package/coverage/rabbit-ui-kit/src/common-apis/utils/logging/logger.js.html +208 -0
- package/coverage/rabbit-ui-kit/src/common-apis/utils/logging/logsStorage.js.html +268 -0
- package/coverage/rabbit-ui-kit/src/common-apis/utils/postponeExecution.js.html +118 -0
- package/coverage/rabbit-ui-kit/src/common-apis/utils/rabbitTicker.js.html +157 -0
- package/coverage/rabbit-ui-kit/src/common-apis/utils/safeStringify.js.html +235 -0
- package/coverage/rabbit-ui-kit/src/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/index.js.html +376 -0
- package/coverage/rabbit-ui-kit/src/robust-api-caller/cacheAndConcurrentRequestsResolver.js.html +1570 -0
- package/coverage/rabbit-ui-kit/src/robust-api-caller/cachedRobustExternalApiCallerService.js.html +526 -0
- package/coverage/rabbit-ui-kit/src/robust-api-caller/cancelProcessing.js.html +172 -0
- package/coverage/rabbit-ui-kit/src/robust-api-caller/concurrentCalculationsMetadataHolder.js.html +310 -0
- package/coverage/rabbit-ui-kit/src/robust-api-caller/externalApiProvider.js.html +553 -0
- package/coverage/rabbit-ui-kit/src/robust-api-caller/externalServicesStatsCollector.js.html +319 -0
- package/coverage/rabbit-ui-kit/src/robust-api-caller/index.html +206 -0
- package/coverage/rabbit-ui-kit/src/robust-api-caller/robustExternalAPICallerService.js.html +997 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/exolixSwapProvider.js.html +1825 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/index.html +161 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/letsExchangeSwapProvider.js.html +1618 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/swapProvider.js.html +1819 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/swapspaceSwapProvider.js.html +1861 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/models/baseSwapCreationInfo.js.html +319 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/models/existingSwap.js.html +514 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/models/existingSwapWithFiatData.js.html +529 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/models/index.html +176 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/models/partner.js.html +166 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/models/swapProviderCoinInfo.js.html +331 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/services/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/services/publicSwapService.js.html +1555 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/utils/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/utils/swapUtils.js.html +670 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/arrowIcon.jsx.html +124 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/arrowTosca.jsx.html +127 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/arrowWhite.jsx.html +127 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/darkRectangle.jsx.html +106 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/determinedError.jsx.html +439 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/failedValidationIcon.jsx.html +202 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/index.html +281 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/infoIcon.jsx.html +133 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/messageIcon.jsx.html +346 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/noticeQuestionIcon.jsx.html +247 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/successfulValidationIcon.jsx.html +163 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/supportDialogImage.jsx.html +268 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/walletIcon.jsx.html +151 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/AssetIcon/AssetIcon.jsx.html +256 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/AssetIcon/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/AssetSelection/AssetSelection.jsx.html +289 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/AssetSelection/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/BackgroundTitle/BackgroundTitle.jsx.html +187 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/BackgroundTitle/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/InformationMessage/InformationMessage.jsx.html +238 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/InformationMessage/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Input/Input.jsx.html +634 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Input/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/LoadingDots/LoadingDots.jsx.html +196 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/LoadingDots/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/NoticeIcon/NoticeIcon.jsx.html +277 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/NoticeIcon/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/QrCode/QrCode.jsx.html +217 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/QrCode/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/RateSelector/RateSelector.jsx.html +175 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/RateSelector/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/SupportChat/SupportChat.jsx.html +217 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/SupportChat/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Textarea/Textarea.jsx.html +529 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Textarea/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/TitleBox/TitleBox.jsx.html +508 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/TitleBox/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Tooltip/Tooltip.jsx.html +316 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Tooltip/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/TwoLinesOfText/LinesOfText.jsx.html +313 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/TwoLinesOfText/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Validation/Validation.jsx.html +202 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Validation/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/Button/Button.jsx.html +712 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/Button/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/Close/Close.jsx.html +259 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/Close/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/LinkButton/LinkButton.jsx.html +421 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/LinkButton/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/RadioButtonWithText/RadioButtonWithText.jsx.html +415 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/RadioButtonWithText/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/AmountInput/AmountInput.jsx.html +1429 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/AmountInput/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/CoinPicker/CoinPicker.jsx.html +1474 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/CoinPicker/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/ColoredNotice/ColoredNotice.jsx.html +211 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/ColoredNotice/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/LineWithIconLink/LineWithIconLink.jsx.html +190 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/LineWithIconLink/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/LogoCarousel/LogoCarousel.jsx.html +307 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/LogoCarousel/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/SearchableCoinsList/SearchableCoinsList.jsx.html +496 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/SearchableCoinsList/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/TitledLineWithIconLink/TitledLineWithIconLink.jsx.html +181 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/TitledLineWithIconLink/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/CoinPickerDialogStep/CoinPickerDialogStep.jsx.html +283 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/CoinPickerDialogStep/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/Dialog/Dialog.jsx.html +1567 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/Dialog/DialogButtons/DialogButtons.jsx.html +481 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/Dialog/DialogButtons/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/Dialog/DialogStep/DialogStep.jsx.html +1747 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/Dialog/DialogStep/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/Dialog/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/SwapForm/SwapForm.jsx.html +4207 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/SwapForm/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/WaitlistSubscription/WaitlistSubscription.jsx.html +559 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/WaitlistSubscription/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/templates/DeterminedErrorDialogStep/DeterminedErrorDialogStep.jsx.html +316 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/templates/DeterminedErrorDialogStep/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/hooks/index.html +146 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/hooks/useCallHandlingErrors.js.html +151 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/hooks/useIsHydrated.js.html +121 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/hooks/useReferredState.js.html +157 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/utils/index.html +161 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/utils/inputValueProviders.js.html +235 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/utils/textUtils.js.html +139 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/utils/uiUtils.js.html +121 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/utils/urlQueryUtils.js.html +271 -0
- package/coverage/rabbit-ui-kit/stories/atoms/BackgroundTitle.stories.jsx.html +202 -0
- package/coverage/rabbit-ui-kit/stories/atoms/LinesOfText.stories.jsx.html +283 -0
- package/coverage/rabbit-ui-kit/stories/atoms/LoadingDots.stories.jsx.html +226 -0
- package/coverage/rabbit-ui-kit/stories/atoms/QrCode.stories.jsx.html +175 -0
- package/coverage/rabbit-ui-kit/stories/atoms/RateSelector.stories.jsx.html +136 -0
- package/coverage/rabbit-ui-kit/stories/atoms/Validation.stories.jsx.html +178 -0
- package/coverage/rabbit-ui-kit/stories/atoms/buttons/Button.stories.jsx.html +883 -0
- package/coverage/rabbit-ui-kit/stories/atoms/buttons/Close.stories.jsx.html +211 -0
- package/coverage/rabbit-ui-kit/stories/atoms/buttons/LinkButton.stories.jsx.html +301 -0
- package/coverage/rabbit-ui-kit/stories/atoms/buttons/index.html +146 -0
- package/coverage/rabbit-ui-kit/stories/atoms/index.html +191 -0
- package/coverage/rabbit-ui-kit/stories/molecules/AmountInput.stories.jsx.html +289 -0
- package/coverage/rabbit-ui-kit/stories/molecules/CoinPicker.stories.jsx.html +322 -0
- package/coverage/rabbit-ui-kit/stories/molecules/ColoredNotice.stories.jsx.html +178 -0
- package/coverage/rabbit-ui-kit/stories/molecules/LineWithIconLink.stories.jsx.html +154 -0
- package/coverage/rabbit-ui-kit/stories/molecules/LogoCarousel.stories.jsx.html +235 -0
- package/coverage/rabbit-ui-kit/stories/molecules/TitledLineWithIconLink.stories.jsx.html +160 -0
- package/coverage/rabbit-ui-kit/stories/molecules/index.html +191 -0
- package/coverage/rabbit-ui-kit/stories/organisms/Dialog/Dialog.stories.jsx.html +523 -0
- package/coverage/rabbit-ui-kit/stories/organisms/Dialog/DialogButtons/DialogButtons.stories.jsx.html +328 -0
- package/coverage/rabbit-ui-kit/stories/organisms/Dialog/DialogButtons/index.html +116 -0
- package/coverage/rabbit-ui-kit/stories/organisms/Dialog/DialogStep/DialogStep.stories.jsx.html +337 -0
- package/coverage/rabbit-ui-kit/stories/organisms/Dialog/DialogStep/index.html +116 -0
- package/coverage/rabbit-ui-kit/stories/organisms/Dialog/index.html +116 -0
- package/coverage/rabbit-ui-kit/stories/organisms/WaitlistSubscription.stories.jsx.html +151 -0
- package/coverage/rabbit-ui-kit/stories/organisms/index.html +116 -0
- package/coverage/rabbit-ui-kit/stories/stubs/coins.jsx.html +6880 -0
- package/coverage/rabbit-ui-kit/stories/stubs/exampleContent.jsx.html +145 -0
- package/coverage/rabbit-ui-kit/stories/stubs/index.html +131 -0
- package/coverage/rabbit-ui-kit/stories/templates/DeterminedErrorDialogStep.stories.jsx.html +190 -0
- package/coverage/rabbit-ui-kit/stories/templates/index.html +116 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +196 -0
- package/dist/global.css +197 -0
- package/dist/global.css.map +1 -0
- package/dist/index.cjs +12451 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +2339 -8491
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +9597 -26
- package/dist/index.modern.js.map +1 -1
- package/dist/index.module.js +12357 -27
- package/dist/index.module.js.map +1 -1
- package/dist/index.umd.js +12442 -29
- package/dist/index.umd.js.map +1 -1
- package/package.json +35 -9
- package/raw +1000 -0
- package/src/common-apis/adapters/analyticsAdapters/googleAnalyticsAdapter.js +21 -0
- package/src/common-apis/adapters/analyticsAdapters/metrikaAdapter.js +28 -0
- package/src/common-apis/adapters/analyticsAdapters/mixpanelAdapter.js +38 -0
- package/src/common-apis/adapters/axiosAdapter.js +35 -0
- package/src/common-apis/adapters/qrUtils.js +18 -0
- package/src/common-apis/external-apis/apiGroups.js +55 -0
- package/src/common-apis/external-apis/emailAPI.js +16 -0
- package/src/common-apis/external-apis/ipAddressProviders.js +89 -0
- package/src/common-apis/globalConstants.jsx +3 -0
- package/src/common-apis/models/blockchain.js +10 -0
- package/src/common-apis/models/coin.js +248 -0
- package/src/common-apis/models/protocol.js +5 -0
- package/src/{common → common-apis/services}/fiatCurrenciesService.js +4 -12
- package/src/common-apis/tests/integration/external-apis/ipAddressProviders/getClientIpAddress.test.js +12 -0
- package/src/common-apis/tests/units/utils/amountUtils/composeRateText.test.js +152 -0
- package/src/{common → common-apis/utils}/amountUtils.js +72 -136
- package/src/common-apis/utils/cache.js +242 -0
- package/src/{common → common-apis/utils}/errorUtils.js +15 -0
- package/src/common-apis/utils/logging/logger.js +41 -0
- package/src/common-apis/utils/logging/logsStorage.js +61 -0
- package/src/common-apis/utils/postponeExecution.js +11 -0
- package/src/common-apis/utils/rabbitTicker.js +24 -0
- package/src/common-apis/utils/safeStringify.js +50 -0
- package/src/index.js +96 -9
- package/src/robust-api-caller/cacheAndConcurrentRequestsResolver.js +495 -0
- package/src/robust-api-caller/cachedRobustExternalApiCallerService.js +147 -0
- package/src/robust-api-caller/cancelProcessing.js +29 -0
- package/src/robust-api-caller/concurrentCalculationsMetadataHolder.js +75 -0
- package/src/robust-api-caller/externalApiProvider.js +156 -0
- package/src/robust-api-caller/externalServicesStatsCollector.js +78 -0
- package/src/robust-api-caller/robustExternalAPICallerService.js +304 -0
- package/src/robust-api-caller/tests/robustExternalAPICallerService/robustExternalAPICallerService/callExternalAPI/_performCallAttempt.test.js +533 -0
- package/src/robust-api-caller/tests/robustExternalAPICallerService/robustExternalAPICallerService/callExternalAPI/callExternalAPI.test.js +532 -0
- package/src/robust-api-caller/tests/robustExternalAPICallerService/robustExternalAPICallerService/constructor.test.js +19 -0
- package/src/swaps-lib/external-apis/exolixSwapProvider.js +580 -0
- package/src/swaps-lib/external-apis/letsExchangeSwapProvider.js +511 -0
- package/src/swaps-lib/external-apis/swapProvider.js +578 -0
- package/src/swaps-lib/external-apis/swapspaceSwapProvider.js +592 -0
- package/src/swaps-lib/models/baseSwapCreationInfo.js +78 -0
- package/src/swaps-lib/models/existingSwap.js +143 -0
- package/src/swaps-lib/models/existingSwapWithFiatData.js +148 -0
- package/src/swaps-lib/models/partner.js +27 -0
- package/src/swaps-lib/models/swapProviderCoinInfo.js +82 -0
- package/src/swaps-lib/services/publicSwapService.js +490 -0
- package/src/swaps-lib/test/external-apis/exolixSwapProvider/_fetchSupportedCurrenciesIfNeeded.test.js +34 -0
- package/src/swaps-lib/test/external-apis/exolixSwapProvider/createSwap.test.js +1043 -0
- package/src/swaps-lib/test/external-apis/exolixSwapProvider/getSwapInfo.test.js +611 -0
- package/src/swaps-lib/test/external-apis/swapProvider/getAllSupportedCurrencies.test.js +63 -0
- package/src/swaps-lib/test/external-apis/swapProvider/getDepositCurrencies.test.js +73 -0
- package/src/swaps-lib/test/external-apis/swapProvider/getWithdrawalCurrencies.test.js +102 -0
- package/src/swaps-lib/test/external-apis/swapProvider/removeProtocolNameFromCoinName.test.js +152 -0
- package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/_fetchSupportedCurrenciesIfNeeded.test.js +536 -0
- package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/createSwap.test.js +1214 -0
- package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/getSwapInfo.test.js +1707 -0
- package/src/swaps-lib/test/utils/swapUtils/safeHandleRequestsLimitExceeding.test.js +80 -0
- package/src/swaps-lib/utils/swapUtils.js +195 -0
- package/{styles → src/ui-kit/assets/styles}/_functions.scss +5 -0
- package/{styles → src/ui-kit/assets/styles}/_mixins.scss +2 -2
- package/{styles → src/ui-kit/assets/styles}/_placeholder.scss +3 -3
- package/{styles → src/ui-kit/assets/styles}/_variables.scss +17 -15
- package/src/ui-kit/assets/styles/fonts/NunitoSans-Bold.ttf +0 -0
- package/src/ui-kit/assets/styles/fonts/NunitoSans-ExtraBold.ttf +0 -0
- package/src/ui-kit/assets/styles/fonts/NunitoSans-Light.ttf +0 -0
- package/src/ui-kit/assets/styles/fonts/NunitoSans-Regular.ttf +0 -0
- package/src/ui-kit/assets/styles/fonts/NunitoSans-SemiBold.ttf +0 -0
- package/src/ui-kit/assets/styles/global.scss +171 -0
- package/src/ui-kit/assets/styles/index.scss +10 -0
- package/src/ui-kit/assets/wrappedImages/arrowIcon.jsx +13 -0
- package/src/ui-kit/assets/wrappedImages/arrowTosca.jsx +14 -0
- package/src/ui-kit/assets/wrappedImages/arrowWhite.jsx +14 -0
- package/src/ui-kit/assets/wrappedImages/darkRectangle.jsx +7 -0
- package/src/ui-kit/assets/wrappedImages/determinedError.jsx +118 -0
- package/src/ui-kit/assets/wrappedImages/failedValidationIcon.jsx +39 -0
- package/src/ui-kit/assets/wrappedImages/infoIcon.jsx +16 -0
- package/src/ui-kit/assets/wrappedImages/messageIcon.jsx +87 -0
- package/src/ui-kit/assets/wrappedImages/noticeQuestionIcon.jsx +54 -0
- package/src/ui-kit/assets/wrappedImages/successfulValidationIcon.jsx +26 -0
- package/src/ui-kit/assets/wrappedImages/supportDialogImage.jsx +61 -0
- package/src/ui-kit/assets/wrappedImages/walletIcon.jsx +22 -0
- package/src/ui-kit/components/atoms/AssetIcon/AssetIcon.jsx +57 -0
- package/src/{components → ui-kit/components}/atoms/AssetIcon/asset-icon.module.scss +1 -1
- package/src/ui-kit/components/atoms/AssetSelection/AssetSelection.jsx +68 -0
- package/src/ui-kit/components/atoms/AssetSelection/asset-selection.module.scss +56 -0
- package/src/ui-kit/components/atoms/BackgroundTitle/BackgroundTitle.jsx +34 -0
- package/src/ui-kit/components/atoms/BackgroundTitle/background-title.module.scss +52 -0
- package/src/ui-kit/components/atoms/InformationMessage/InformationMessage.jsx +51 -0
- package/src/ui-kit/components/atoms/InformationMessage/information-message.module.scss +38 -0
- package/src/ui-kit/components/atoms/Input/Input.jsx +183 -0
- package/src/ui-kit/components/atoms/Input/input.module.scss +107 -0
- package/src/{components → ui-kit/components}/atoms/LoadingDots/LoadingDots.jsx +8 -28
- package/src/{components → ui-kit/components}/atoms/LoadingDots/LoadingDots.module.scss +3 -2
- package/src/ui-kit/components/atoms/NoticeIcon/NoticeIcon.jsx +64 -0
- package/src/ui-kit/components/atoms/NoticeIcon/notice-icon.module.scss +14 -0
- package/src/ui-kit/components/atoms/QrCode/QrCode.jsx +44 -0
- package/src/ui-kit/components/atoms/QrCode/qr-code.module.scss +15 -0
- package/src/ui-kit/components/atoms/RateSelector/RateSelector.jsx +30 -0
- package/src/ui-kit/components/atoms/RateSelector/rate-selector.module.scss +47 -0
- package/src/{components → ui-kit/components}/atoms/SupportChat/SupportChat.jsx +5 -1
- package/src/ui-kit/components/atoms/Textarea/Textarea.jsx +148 -0
- package/src/ui-kit/components/atoms/Textarea/textarea.module.scss +71 -0
- package/src/ui-kit/components/atoms/TitleBox/TitleBox.jsx +141 -0
- package/src/ui-kit/components/atoms/TitleBox/title-box.module.scss +32 -0
- package/src/ui-kit/components/atoms/Tooltip/Tooltip.jsx +77 -0
- package/src/ui-kit/components/atoms/Tooltip/tooltip.module.scss +237 -0
- package/src/ui-kit/components/atoms/TwoLinesOfText/LinesOfText.jsx +76 -0
- package/src/ui-kit/components/atoms/TwoLinesOfText/lines-of-text.module.scss +65 -0
- package/src/ui-kit/components/atoms/Validation/Validation.jsx +39 -0
- package/src/ui-kit/components/atoms/Validation/validation.module.scss +19 -0
- package/src/{components → ui-kit/components}/atoms/buttons/Button/Button.jsx +24 -50
- package/src/{components → ui-kit/components}/atoms/buttons/Button/Button.module.scss +1 -1
- package/src/ui-kit/components/atoms/buttons/Close/Close.jsx +58 -0
- package/src/ui-kit/components/atoms/buttons/Close/close.module.scss +75 -0
- package/src/ui-kit/components/atoms/buttons/LinkButton/LinkButton.jsx +112 -0
- package/src/ui-kit/components/atoms/buttons/LinkButton/link-button.module.scss +49 -0
- package/src/ui-kit/components/atoms/buttons/RadioButtonWithText/RadioButtonWithText.jsx +110 -0
- package/src/ui-kit/components/atoms/buttons/RadioButtonWithText/radio-button-with-text.module.scss +86 -0
- package/src/ui-kit/components/molecules/AmountInput/AmountInput.jsx +448 -0
- package/src/ui-kit/components/molecules/AmountInput/amount-input.module.scss +233 -0
- package/src/ui-kit/components/molecules/CoinPicker/CoinPicker.jsx +463 -0
- package/src/ui-kit/components/molecules/CoinPicker/coin-picker.module.scss +207 -0
- package/src/ui-kit/components/molecules/ColoredNotice/ColoredNotice.jsx +42 -0
- package/src/ui-kit/components/molecules/ColoredNotice/colored-notice.module.scss +20 -0
- package/src/ui-kit/components/molecules/LineWithIconLink/LineWithIconLink.jsx +35 -0
- package/src/ui-kit/components/molecules/LineWithIconLink/line-with-icon-link.module.scss +25 -0
- package/src/ui-kit/components/molecules/LogoCarousel/LogoCarousel.jsx +74 -0
- package/src/ui-kit/components/molecules/LogoCarousel/logo-carousel.module.scss +106 -0
- package/src/ui-kit/components/molecules/SearchableCoinsList/SearchableCoinsList.jsx +137 -0
- package/src/ui-kit/components/molecules/TitledLineWithIconLink/TitledLineWithIconLink.jsx +32 -0
- package/src/ui-kit/components/organisms/CoinPickerDialogStep/CoinPickerDialogStep.jsx +66 -0
- package/src/ui-kit/components/organisms/Dialog/Dialog.jsx +494 -0
- package/src/ui-kit/components/organisms/Dialog/DialogButtons/DialogButtons.jsx +132 -0
- package/src/ui-kit/components/organisms/Dialog/DialogButtons/dialog-buttons.module.scss +25 -0
- package/src/ui-kit/components/organisms/Dialog/DialogStep/DialogStep.jsx +554 -0
- package/src/ui-kit/components/organisms/Dialog/DialogStep/dialog-step.module.scss +381 -0
- package/src/ui-kit/components/organisms/Dialog/dialog.module.scss +226 -0
- package/src/ui-kit/components/organisms/SwapForm/SwapForm.jsx +1374 -0
- package/src/ui-kit/components/organisms/SwapForm/swap-form.module.scss +134 -0
- package/src/ui-kit/components/organisms/WaitlistSubscription/WaitlistSubscription.jsx +158 -0
- package/src/ui-kit/components/templates/DeterminedErrorDialogStep/DeterminedErrorDialogStep.jsx +77 -0
- package/src/ui-kit/hooks/useCallHandlingErrors.js +22 -0
- package/src/ui-kit/hooks/useIsHydrated.js +12 -0
- package/src/ui-kit/hooks/useReferredState.js +24 -0
- package/src/ui-kit/tests/utils/inputValueProviders/provideFormatOfFloatValueByInputString.test.js +146 -0
- package/src/ui-kit/tests/utils/urlQueryUtils/getQueryParameterValues.test.js +65 -0
- package/src/ui-kit/tests/utils/urlQueryUtils/saveQueryParameterAndValues.test.js +104 -0
- package/src/ui-kit/utils/inputValueProviders.js +50 -0
- package/src/ui-kit/utils/textUtils.js +18 -0
- package/src/ui-kit/utils/uiUtils.js +12 -0
- package/src/ui-kit/utils/urlQueryUtils.js +62 -0
- package/stories/font.scss +40 -0
- package/stories/stubs/coins.jsx +2266 -0
- package/stories/stubs/exampleContent.jsx +20 -0
- package/src/components/atoms/AssetIcon/AssetIcon.jsx +0 -55
- package/styles/_global-classes.scss +0 -433
- package/styles/fonts/NunitoSans-Bold.ttf +0 -0
- package/styles/fonts/NunitoSans-ExtraBold.ttf +0 -0
- package/styles/fonts/NunitoSans-Light.ttf +0 -0
- package/styles/fonts/NunitoSans-Regular.ttf +0 -0
- package/styles/fonts/NunitoSans-SemiBold.ttf +0 -0
- package/styles/global-styles-index.scss +0 -74
- package/styles/index.scss +0 -33
- /package/{styles → src/ui-kit/assets/styles}/colors/_light-colors.scss +0 -0
- /package/{styles → src/ui-kit/assets/styles}/colors/_solid-colors.scss +0 -0
- /package/{styles → src/ui-kit/assets/styles}/size/_margin-size.scss +0 -0
- /package/{styles → src/ui-kit/assets/styles}/size/_padding-size.scss +0 -0
|
@@ -0,0 +1,580 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import BigNumber from "bignumber.js";
|
|
3
|
+
|
|
4
|
+
import { improveAndRethrow } from "../../common-apis/utils/errorUtils";
|
|
5
|
+
import { DEFAULT_CRYPTO_DECIMAL_COUNT, FALLBACK_ASSET_ICON_URL } from "../../common-apis/globalConstants";
|
|
6
|
+
import { Logger } from "../../common-apis/utils/logging/logger";
|
|
7
|
+
import { Coin } from "../../common-apis/models/coin";
|
|
8
|
+
import { Protocol } from "../../common-apis/models/protocol";
|
|
9
|
+
import { safeStringify } from "../../common-apis/utils/safeStringify";
|
|
10
|
+
import { AmountUtils } from "../../common-apis/utils/amountUtils";
|
|
11
|
+
import { toRabbitTicker } from "../../common-apis/utils/rabbitTicker";
|
|
12
|
+
|
|
13
|
+
import { SwapProvider } from "./swapProvider";
|
|
14
|
+
import { ExistingSwap } from "../models/existingSwap";
|
|
15
|
+
import { Partner } from "../models/partner";
|
|
16
|
+
import { SwapProviderCoinInfo } from "../models/swapProviderCoinInfo";
|
|
17
|
+
|
|
18
|
+
export class ExolixSwapProvider extends SwapProvider {
|
|
19
|
+
constructor(
|
|
20
|
+
apiKeysProxyUrl,
|
|
21
|
+
cache,
|
|
22
|
+
customCoinBuilder = (coin, network) => null,
|
|
23
|
+
useRestrictedCoinsSet = true,
|
|
24
|
+
apiKey = ""
|
|
25
|
+
) {
|
|
26
|
+
super("exolix", cache, customCoinBuilder, useRestrictedCoinsSet, false, true);
|
|
27
|
+
this._partners = [];
|
|
28
|
+
this._URL = apiKey ? "https://exolix.com/api/v2" : `${apiKeysProxyUrl}/${this.id}`;
|
|
29
|
+
this.COINS_EXPIRATION_TIME_MS = 5 * 60 * 1000;
|
|
30
|
+
this.coinsLastUpdateTimestamp = null;
|
|
31
|
+
this.headers = apiKey ? { Authorization: "Bearer " + apiKey } : {};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
axiosGetPreset = {
|
|
35
|
+
headers: this.headers,
|
|
36
|
+
validateStatus: responseCode => [200, 201, 404].find(code => code === responseCode),
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
getSwapCreationInfoTtlMs() {
|
|
40
|
+
return 110000;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async _fetchSupportedCurrenciesIfNeeded() {
|
|
44
|
+
const loggerSource = "_fetchSupportedCurrenciesIfNeeded";
|
|
45
|
+
const pageSize = 100;
|
|
46
|
+
try {
|
|
47
|
+
if (this._shouldCoinsListBeLoaded()) {
|
|
48
|
+
let page = 1;
|
|
49
|
+
let allCoins = [];
|
|
50
|
+
|
|
51
|
+
while (true) {
|
|
52
|
+
const responseRaw = await axios.get(this._URL + "/currencies", {
|
|
53
|
+
...this.axiosGetPreset,
|
|
54
|
+
params: { withNetworks: true, page: page, size: pageSize },
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const response = responseRaw?.data;
|
|
58
|
+
|
|
59
|
+
// Validating the response
|
|
60
|
+
if (
|
|
61
|
+
responseRaw.status !== 200 ||
|
|
62
|
+
!response ||
|
|
63
|
+
typeof response?.data !== "object" ||
|
|
64
|
+
typeof response?.count !== "number" ||
|
|
65
|
+
response?.count < 1 ||
|
|
66
|
+
response?.count > 1000 ||
|
|
67
|
+
typeof response?.errors === "object"
|
|
68
|
+
) {
|
|
69
|
+
const errorMessages = response?.errors
|
|
70
|
+
? ". Errors - " +
|
|
71
|
+
Object.keys(response?.errors)
|
|
72
|
+
.map(errorCode => errorCode + ": " + response?.errors[errorCode])
|
|
73
|
+
.join(", ")
|
|
74
|
+
: "";
|
|
75
|
+
throw new Error("Failed to load the currencies list for Exolix" + errorMessages);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
allCoins.push(...response.data);
|
|
79
|
+
|
|
80
|
+
if (page >= Math.floor(response.count / pageSize)) break;
|
|
81
|
+
page++;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
this._supportedCoins = allCoins
|
|
85
|
+
.map(item => {
|
|
86
|
+
const code = item.code.toUpperCase();
|
|
87
|
+
|
|
88
|
+
if (!Array.isArray(item.networks)) return [];
|
|
89
|
+
|
|
90
|
+
return item.networks.map(networkDetails => {
|
|
91
|
+
const network = networkDetails.network;
|
|
92
|
+
const networkShortAdaptive =
|
|
93
|
+
networkDetails.shortName === "" || !networkDetails?.shortName
|
|
94
|
+
? networkDetails.network
|
|
95
|
+
: networkDetails.shortName;
|
|
96
|
+
let coin =
|
|
97
|
+
this._customCoinBuilder != null
|
|
98
|
+
? this._customCoinBuilder(code, code !== network ? networkShortAdaptive : "")
|
|
99
|
+
: null;
|
|
100
|
+
if (!coin && !this.useRestrictedCoinsSet) {
|
|
101
|
+
const name = item.name;
|
|
102
|
+
const ticker = toRabbitTicker(code, code === network ? "" : networkShortAdaptive);
|
|
103
|
+
const defaultDecimalPlacesForCoinNotSupportedOOB = DEFAULT_CRYPTO_DECIMAL_COUNT;
|
|
104
|
+
const defaultMinConfirmationsForCoinNotSupportedOOB = 1;
|
|
105
|
+
coin = new Coin(
|
|
106
|
+
name,
|
|
107
|
+
ticker,
|
|
108
|
+
code,
|
|
109
|
+
defaultDecimalPlacesForCoinNotSupportedOOB,
|
|
110
|
+
null,
|
|
111
|
+
"",
|
|
112
|
+
null,
|
|
113
|
+
null,
|
|
114
|
+
defaultMinConfirmationsForCoinNotSupportedOOB,
|
|
115
|
+
null,
|
|
116
|
+
[],
|
|
117
|
+
60000,
|
|
118
|
+
null,
|
|
119
|
+
code !== network ? new Protocol(networkShortAdaptive) : null,
|
|
120
|
+
null,
|
|
121
|
+
false
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
if (coin) {
|
|
125
|
+
return new SwapProviderCoinInfo(
|
|
126
|
+
coin,
|
|
127
|
+
item.code,
|
|
128
|
+
network,
|
|
129
|
+
!!networkDetails.memoNeeded,
|
|
130
|
+
networkDetails.memoName ?? null,
|
|
131
|
+
0,
|
|
132
|
+
item.icon ? item.icon : FALLBACK_ASSET_ICON_URL,
|
|
133
|
+
true,
|
|
134
|
+
true,
|
|
135
|
+
networkDetails.addressRegex ?? null,
|
|
136
|
+
true
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
return [];
|
|
140
|
+
});
|
|
141
|
+
})
|
|
142
|
+
.flat();
|
|
143
|
+
this._supportedCoinsLastUpdateTimestamp = Date.now();
|
|
144
|
+
this._putPopularCoinsFirst();
|
|
145
|
+
await super._fetchSupportedCurrenciesIfNeeded();
|
|
146
|
+
}
|
|
147
|
+
} catch (e) {
|
|
148
|
+
improveAndRethrow(e, loggerSource);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
async getSwapInfo(
|
|
153
|
+
fromCoin,
|
|
154
|
+
toCoin,
|
|
155
|
+
amountCoins,
|
|
156
|
+
fixed = false,
|
|
157
|
+
fromCoinToUsdRate = null,
|
|
158
|
+
amountIsToReceive = false,
|
|
159
|
+
bannedPartners = []
|
|
160
|
+
) {
|
|
161
|
+
const loggerSource = "getSwapInfo";
|
|
162
|
+
|
|
163
|
+
const validateAndProcessLimits = (
|
|
164
|
+
fromAmount,
|
|
165
|
+
toAmount,
|
|
166
|
+
fromCoin,
|
|
167
|
+
toCoin,
|
|
168
|
+
amountCoins,
|
|
169
|
+
amountIsToReceive,
|
|
170
|
+
minAmount,
|
|
171
|
+
maxAmount,
|
|
172
|
+
rate,
|
|
173
|
+
status
|
|
174
|
+
) => {
|
|
175
|
+
let min;
|
|
176
|
+
let max;
|
|
177
|
+
let returnObject;
|
|
178
|
+
|
|
179
|
+
if (typeof minAmount === "number" && minAmount > 0)
|
|
180
|
+
min = AmountUtils.trim(minAmount, amountIsToReceive ? toCoin.digits : fromCoin.digits);
|
|
181
|
+
if (typeof maxAmount === "number" && maxAmount > 0)
|
|
182
|
+
max = AmountUtils.trim(maxAmount, amountIsToReceive ? toCoin.digits : fromCoin.digits);
|
|
183
|
+
|
|
184
|
+
if (
|
|
185
|
+
status !== 200 ||
|
|
186
|
+
typeof fromAmount !== "number" ||
|
|
187
|
+
typeof toAmount !== "number" ||
|
|
188
|
+
typeof minAmount !== "number" ||
|
|
189
|
+
typeof maxAmount !== "number" ||
|
|
190
|
+
BigNumber(rate).lte("0") ||
|
|
191
|
+
BigNumber(fromAmount).lte("0") ||
|
|
192
|
+
BigNumber(toAmount).lte("0")
|
|
193
|
+
) {
|
|
194
|
+
let reason = SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED;
|
|
195
|
+
|
|
196
|
+
if (min && BigNumber(amountCoins).lt(min)) {
|
|
197
|
+
reason = SwapProvider.NO_SWAPS_REASONS.TOO_LOW;
|
|
198
|
+
} else if (max && BigNumber(amountCoins).gt(max)) {
|
|
199
|
+
reason = SwapProvider.NO_SWAPS_REASONS.TOO_HIGH;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
Logger.log(
|
|
203
|
+
`Inconsistent exolix data forces us to return NOT_SUPPORTED ${status} ${fromAmount} ${toAmount} ${maxAmount} ${minAmount} ${rate}`
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
returnObject = {
|
|
207
|
+
result: false,
|
|
208
|
+
reason: reason,
|
|
209
|
+
smallestMin: min,
|
|
210
|
+
greatestMax: max,
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return [returnObject, min, max];
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
try {
|
|
218
|
+
if (
|
|
219
|
+
!(fromCoin instanceof Coin) ||
|
|
220
|
+
!(toCoin instanceof Coin) ||
|
|
221
|
+
typeof amountCoins !== "string" ||
|
|
222
|
+
BigNumber(amountCoins).lt("0") ||
|
|
223
|
+
(fixed !== null && typeof fixed !== "boolean")
|
|
224
|
+
) {
|
|
225
|
+
throw new Error(
|
|
226
|
+
`Wrong input params: ${amountCoins} ${fromCoin.ticker} -> ${toCoin.ticker}, ${
|
|
227
|
+
fromCoin instanceof Coin
|
|
228
|
+
}, ${toCoin instanceof Coin}, ${typeof fixed} ${fixed}, ${amountIsToReceive}`
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
const fromCoinDetails = this._supportedCoins.find(i => i.coin?.ticker === fromCoin?.ticker);
|
|
232
|
+
const toCoinDetails = this._supportedCoins.find(i => i.coin?.ticker === toCoin?.ticker);
|
|
233
|
+
if (
|
|
234
|
+
!fromCoinDetails ||
|
|
235
|
+
!toCoinDetails ||
|
|
236
|
+
!fromCoinDetails.deposit ||
|
|
237
|
+
!fromCoinDetails.isAvailable ||
|
|
238
|
+
!toCoinDetails.withdrawal ||
|
|
239
|
+
!toCoinDetails.isAvailable
|
|
240
|
+
) {
|
|
241
|
+
return {
|
|
242
|
+
result: false,
|
|
243
|
+
reason: SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED,
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const response = await axios.get(this._URL + "/rate", {
|
|
248
|
+
...this.axiosGetPreset,
|
|
249
|
+
params: {
|
|
250
|
+
coinFrom: fromCoinDetails.code,
|
|
251
|
+
networkFrom: fromCoinDetails.network,
|
|
252
|
+
coinTo: toCoinDetails.code,
|
|
253
|
+
networkTo: toCoinDetails.network,
|
|
254
|
+
amount: amountIsToReceive ? undefined : amountCoins,
|
|
255
|
+
withdrawalAmount: amountIsToReceive ? amountCoins : undefined,
|
|
256
|
+
rateType: fixed ? "fixed" : "float",
|
|
257
|
+
},
|
|
258
|
+
});
|
|
259
|
+
Logger.log(`Retrieved ${response?.data}`, loggerSource);
|
|
260
|
+
if (typeof response?.data !== "object") {
|
|
261
|
+
Logger.log(`Swap response didn't include the data object ${safeStringify(e)}`, loggerSource);
|
|
262
|
+
return { result: false, reason: SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED };
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
const data = response?.data;
|
|
266
|
+
const [returnObject, min, max] = validateAndProcessLimits(
|
|
267
|
+
data?.fromAmount,
|
|
268
|
+
data?.toAmount,
|
|
269
|
+
fromCoin,
|
|
270
|
+
toCoin,
|
|
271
|
+
amountCoins,
|
|
272
|
+
amountIsToReceive,
|
|
273
|
+
data?.minAmount,
|
|
274
|
+
data?.maxAmount,
|
|
275
|
+
data?.rate,
|
|
276
|
+
response?.status
|
|
277
|
+
);
|
|
278
|
+
if (returnObject) return returnObject;
|
|
279
|
+
|
|
280
|
+
if (min && max & BigNumber(max).lt(min)) {
|
|
281
|
+
Logger.log(
|
|
282
|
+
`Exolix swap info failed, max limit is below the min one. ${safeStringify(response)}`,
|
|
283
|
+
loggerSource
|
|
284
|
+
);
|
|
285
|
+
return { result: false, reason: SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED };
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
const rate = amountIsToReceive
|
|
289
|
+
? BigNumber(amountCoins).div(data.fromAmount)
|
|
290
|
+
: BigNumber(data.toAmount).div(amountCoins);
|
|
291
|
+
|
|
292
|
+
return {
|
|
293
|
+
result: true,
|
|
294
|
+
min: min ?? null,
|
|
295
|
+
max: max ?? null,
|
|
296
|
+
smallestMin: min ?? null,
|
|
297
|
+
greatestMax: max ?? null,
|
|
298
|
+
rate: AmountUtils.trim(rate, this._maxRateDigits),
|
|
299
|
+
durationMinutesRange: null,
|
|
300
|
+
fixed: fixed,
|
|
301
|
+
rawSwapData: data,
|
|
302
|
+
isRefundAddressRequired: false,
|
|
303
|
+
};
|
|
304
|
+
} catch (e) {
|
|
305
|
+
const status = e?.response?.status;
|
|
306
|
+
const data = e?.response?.data;
|
|
307
|
+
if (status === 429) {
|
|
308
|
+
return {
|
|
309
|
+
result: false,
|
|
310
|
+
reason: SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED,
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
const [returnObject, min, max] = validateAndProcessLimits(
|
|
315
|
+
data?.fromAmount,
|
|
316
|
+
data?.toAmount,
|
|
317
|
+
fromCoin,
|
|
318
|
+
toCoin,
|
|
319
|
+
amountCoins,
|
|
320
|
+
amountIsToReceive,
|
|
321
|
+
data?.minAmount,
|
|
322
|
+
data?.maxAmount,
|
|
323
|
+
data?.rate,
|
|
324
|
+
e?.response?.status
|
|
325
|
+
);
|
|
326
|
+
if (returnObject) return returnObject;
|
|
327
|
+
|
|
328
|
+
if (e?.response?.status === 400 || e?.response?.data?.error || e?.response?.data?.errors) {
|
|
329
|
+
const errorMessages = e?.response?.data?.errors
|
|
330
|
+
? ". Errors - " +
|
|
331
|
+
Object.keys(e?.response?.data?.errors)
|
|
332
|
+
.map(errorCode => errorCode + ": " + e?.response?.data?.errors[errorCode])
|
|
333
|
+
.join(", ")
|
|
334
|
+
: "";
|
|
335
|
+
Logger.log(
|
|
336
|
+
"Failed to estimate swap for Exolix (" +
|
|
337
|
+
e?.response?.status +
|
|
338
|
+
")" +
|
|
339
|
+
errorMessages +
|
|
340
|
+
` ${safeStringify(e)}`,
|
|
341
|
+
loggerSource
|
|
342
|
+
);
|
|
343
|
+
} else {
|
|
344
|
+
Logger.log(`Internal error when getting swap options ${safeStringify(e)}`, loggerSource);
|
|
345
|
+
}
|
|
346
|
+
improveAndRethrow(e, loggerSource);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
async createSwap(
|
|
351
|
+
fromCoin,
|
|
352
|
+
toCoin,
|
|
353
|
+
amount,
|
|
354
|
+
toAddress,
|
|
355
|
+
refundAddress,
|
|
356
|
+
proprietarySwapEstimationData,
|
|
357
|
+
clientIpAddress,
|
|
358
|
+
fixed,
|
|
359
|
+
toCurrencyExtraId = "",
|
|
360
|
+
refundExtraId = "",
|
|
361
|
+
amountIsToReceive = false
|
|
362
|
+
) {
|
|
363
|
+
const loggerSource = "createSwap";
|
|
364
|
+
|
|
365
|
+
try {
|
|
366
|
+
if (
|
|
367
|
+
!(fromCoin instanceof Coin) ||
|
|
368
|
+
!(toCoin instanceof Coin) ||
|
|
369
|
+
typeof amount !== "string" ||
|
|
370
|
+
typeof toAddress !== "string" ||
|
|
371
|
+
typeof refundAddress !== "string" ||
|
|
372
|
+
typeof fixed != "boolean"
|
|
373
|
+
) {
|
|
374
|
+
throw new Error(
|
|
375
|
+
`Invalid input: ${fromCoin} ${toCoin} ${amount} ${toAddress} ${refundAddress} ${fixed}`
|
|
376
|
+
);
|
|
377
|
+
}
|
|
378
|
+
await this._fetchSupportedCurrenciesIfNeeded();
|
|
379
|
+
const fromCoinExtended = this._supportedCoins.find(item => item.coin.ticker == fromCoin.ticker);
|
|
380
|
+
const toCoinExtended = this._supportedCoins.find(item => item.coin.ticker == toCoin.ticker);
|
|
381
|
+
if (!fromCoinExtended || !toCoinExtended) {
|
|
382
|
+
throw new Error("Failed to find coin details for: " + fromCoin.ticker + " -> " + toCoin.ticker);
|
|
383
|
+
}
|
|
384
|
+
const fromCurrencyHasExtraId = fromCoinExtended.hasExtraId;
|
|
385
|
+
const toCurrencyHasExtraId = toCoinExtended.hasExtraId;
|
|
386
|
+
const requestData = {
|
|
387
|
+
coinFrom: fromCoinExtended.code,
|
|
388
|
+
networkFrom: fromCoinExtended.network,
|
|
389
|
+
coinTo: toCoinExtended.code,
|
|
390
|
+
networkTo: toCoinExtended.network,
|
|
391
|
+
amount: amountIsToReceive ? undefined : amount,
|
|
392
|
+
withdrawalAmount: amountIsToReceive ? amount : undefined,
|
|
393
|
+
withdrawalAddress: toAddress,
|
|
394
|
+
withdrawalExtraId: toCurrencyHasExtraId ? toCurrencyExtraId ?? "" : "",
|
|
395
|
+
refundAddress: refundAddress,
|
|
396
|
+
refundExtraId: fromCurrencyHasExtraId ? refundExtraId ?? "" : "",
|
|
397
|
+
rateType: fixed ? "fixed" : "float",
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
Logger.log(`Sending create request: ${safeStringify(requestData)}`, loggerSource);
|
|
401
|
+
const response = await axios.post(this._URL + "/transactions", requestData, this.axiosGetPreset);
|
|
402
|
+
const result = response?.data;
|
|
403
|
+
Logger.log(`Creation result ${safeStringify(result)}`, loggerSource);
|
|
404
|
+
|
|
405
|
+
if (
|
|
406
|
+
!result?.id ||
|
|
407
|
+
typeof result?.id !== "string" ||
|
|
408
|
+
typeof result?.amount !== "number" ||
|
|
409
|
+
typeof result?.amountTo !== "number" ||
|
|
410
|
+
typeof result?.depositAddress !== "string" ||
|
|
411
|
+
typeof result?.withdrawalAddress !== "string" ||
|
|
412
|
+
!(result?.rateType === "fixed" || result?.rateType === "float")
|
|
413
|
+
) {
|
|
414
|
+
let errorMessage;
|
|
415
|
+
errorMessage = result?.id
|
|
416
|
+
? "Swap was created but the data was incorrect: " + safeStringify(response)
|
|
417
|
+
: "Swap creation failed, API response: " + safeStringify(response);
|
|
418
|
+
|
|
419
|
+
Logger.log(errorMessage, loggerSource);
|
|
420
|
+
throw new Error(errorMessage);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
let rate;
|
|
424
|
+
if (typeof rate !== "number" || BigNumber(result?.rate).isZero()) {
|
|
425
|
+
rate = BigNumber(result?.amountTo).div(result?.amount);
|
|
426
|
+
} else {
|
|
427
|
+
rate = BigNumber(result?.rate);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
return {
|
|
431
|
+
result: true,
|
|
432
|
+
swapId: result?.id,
|
|
433
|
+
fromCoin: fromCoin,
|
|
434
|
+
fromAmount: AmountUtils.trim(result?.amount, fromCoin.digits),
|
|
435
|
+
fromAddress: result?.depositAddress,
|
|
436
|
+
toCoin: toCoin,
|
|
437
|
+
toAmount: AmountUtils.trim(result?.amountTo, toCoin.digits),
|
|
438
|
+
toAddress: result?.withdrawalAddress,
|
|
439
|
+
fromCurrencyExtraId: result?.withdrawalExtraId ?? "",
|
|
440
|
+
rate: AmountUtils.trim(rate, this._maxRateDigits),
|
|
441
|
+
fixed: result?.rateType === "fixed",
|
|
442
|
+
};
|
|
443
|
+
} catch (e) {
|
|
444
|
+
const composeFailResult = reason => ({
|
|
445
|
+
result: false,
|
|
446
|
+
reason: reason,
|
|
447
|
+
});
|
|
448
|
+
if (
|
|
449
|
+
e?.response?.status === 400 ||
|
|
450
|
+
e?.response?.data?.message?.includes("Amount to exchange is higher") ||
|
|
451
|
+
e?.response?.data?.message?.includes("Amount to exchange is below")
|
|
452
|
+
) {
|
|
453
|
+
return composeFailResult(SwapProvider.CREATION_FAIL_REASONS.RETRIABLE_FAIL);
|
|
454
|
+
}
|
|
455
|
+
if (e?.response?.status === 422 && e?.response?.data.error === "Such exchange pair is not available") {
|
|
456
|
+
Logger.log(`Unable to create a swap with a not available currency ${e?.response?.data}`, loggerSource);
|
|
457
|
+
return composeFailResult(SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED);
|
|
458
|
+
}
|
|
459
|
+
if (e?.response?.status === 429) {
|
|
460
|
+
Logger.log(`Returning fail - RPS limit exceeded ${e?.response?.data}`, loggerSource);
|
|
461
|
+
return composeFailResult(SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED);
|
|
462
|
+
}
|
|
463
|
+
Logger.log(`Internal error for swap: ${safeStringify(e)}`, loggerSource);
|
|
464
|
+
improveAndRethrow(e, loggerSource);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
async getExistingSwapsDetailsAndStatus(swapIds) {
|
|
469
|
+
const loggerSource = "getExistingSwapsDetailsAndStatus";
|
|
470
|
+
try {
|
|
471
|
+
if (swapIds.find(id => typeof id !== "string")) {
|
|
472
|
+
throw new Error("Swap id is not string: " + safeStringify(swapIds));
|
|
473
|
+
}
|
|
474
|
+
const getSwap = async swapId => {
|
|
475
|
+
try {
|
|
476
|
+
return await axios.get(this._URL + "/transactions/" + swapId, this.axiosGetPreset);
|
|
477
|
+
} catch (error) {
|
|
478
|
+
if (error?.response?.status === 404) return [];
|
|
479
|
+
throw error;
|
|
480
|
+
}
|
|
481
|
+
};
|
|
482
|
+
const responses = await Promise.all(swapIds.map(swapId => getSwap(swapId)));
|
|
483
|
+
const fetchedSwaps = responses.flat();
|
|
484
|
+
Logger.log("All swaps RAW: " + JSON.stringify(fetchedSwaps.map(r => r.data)), loggerSource);
|
|
485
|
+
|
|
486
|
+
const swaps = fetchedSwaps
|
|
487
|
+
.map(r => r.data)
|
|
488
|
+
.map((swap, index) => {
|
|
489
|
+
const fromCoin = this._supportedCoins.find(
|
|
490
|
+
i => i.code === swap.coinFrom.coinCode && i.network === swap.coinFrom.network
|
|
491
|
+
)?.coin;
|
|
492
|
+
const toCoin = this._supportedCoins.find(
|
|
493
|
+
i => i.code === swap.coinTo.coinCode && i.network === swap.coinTo.network
|
|
494
|
+
)?.coin;
|
|
495
|
+
if (!fromCoin || !toCoin) {
|
|
496
|
+
return []; // We skip swaps with not supported coins for now
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
const toUtcTimestamp = timeStr => Date.parse(timeStr.match(/.+[Zz]$/) ? timeStr : `${timeStr}Z`);
|
|
500
|
+
const createdAt = toUtcTimestamp(swap.createdAt);
|
|
501
|
+
const expiresAt = createdAt + 25 * 60 * 1000; // Hack with hard-coded 25 minutes
|
|
502
|
+
const isExpiredByTime = expiresAt < Date.now();
|
|
503
|
+
const status = this._mapExolixStatusToRabbitStatus(swap.status, isExpiredByTime);
|
|
504
|
+
const toDigits = status === SwapProvider.SWAP_STATUSES.REFUNDED ? fromCoin.digits : toCoin.digits;
|
|
505
|
+
return new ExistingSwap(
|
|
506
|
+
swapIds[index],
|
|
507
|
+
status,
|
|
508
|
+
createdAt,
|
|
509
|
+
expiresAt,
|
|
510
|
+
-1,
|
|
511
|
+
AmountUtils.trim(swap.rate, this._maxRateDigits),
|
|
512
|
+
swap?.rateType === "fixed",
|
|
513
|
+
swap.refundAddress,
|
|
514
|
+
swap.depositAddress,
|
|
515
|
+
fromCoin,
|
|
516
|
+
AmountUtils.trim(swap.amount, fromCoin.digits),
|
|
517
|
+
swap.hashIn.hash,
|
|
518
|
+
swap.hashIn.link,
|
|
519
|
+
toCoin,
|
|
520
|
+
AmountUtils.trim(swap.amountTo, toDigits),
|
|
521
|
+
swap.hashOut.hash,
|
|
522
|
+
swap.hashOut.link,
|
|
523
|
+
swap.withdrawalAddress,
|
|
524
|
+
this.id,
|
|
525
|
+
swap.depositExtraId ?? null,
|
|
526
|
+
swap.withdrawalExtraId ?? null,
|
|
527
|
+
swap.refundExtraId ?? null
|
|
528
|
+
);
|
|
529
|
+
})
|
|
530
|
+
.flat();
|
|
531
|
+
Logger.log(`Swap details result ${safeStringify(swaps)}`, loggerSource);
|
|
532
|
+
return { result: true, swaps: swaps };
|
|
533
|
+
} catch (e) {
|
|
534
|
+
Logger.logError(e, loggerSource, `Failed to get swap details. Error is: ${safeStringify(e)}`);
|
|
535
|
+
const composeFailResult = reason => ({
|
|
536
|
+
result: false,
|
|
537
|
+
reason: reason,
|
|
538
|
+
});
|
|
539
|
+
const status = e?.response?.status;
|
|
540
|
+
const data = e?.response?.data;
|
|
541
|
+
if (status === 429) {
|
|
542
|
+
Logger.log(`Returning fail - RPS limit exceeded ${data}`, loggerSource);
|
|
543
|
+
return composeFailResult(SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED);
|
|
544
|
+
}
|
|
545
|
+
improveAndRethrow(e, loggerSource);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
_mapExolixStatusToRabbitStatus(status, isExpiredByTime) {
|
|
550
|
+
switch (status) {
|
|
551
|
+
case "wait":
|
|
552
|
+
if (isExpiredByTime) {
|
|
553
|
+
return SwapProvider.SWAP_STATUSES.EXPIRED;
|
|
554
|
+
}
|
|
555
|
+
return SwapProvider.SWAP_STATUSES.WAITING_FOR_PAYMENT;
|
|
556
|
+
case "confirmation":
|
|
557
|
+
return SwapProvider.SWAP_STATUSES.CONFIRMING;
|
|
558
|
+
case "confirmed":
|
|
559
|
+
return SwapProvider.SWAP_STATUSES.PAYMENT_RECEIVED;
|
|
560
|
+
case "exchanging":
|
|
561
|
+
return SwapProvider.SWAP_STATUSES.EXCHANGING;
|
|
562
|
+
case "sending":
|
|
563
|
+
return SwapProvider.SWAP_STATUSES.EXCHANGING;
|
|
564
|
+
case "success":
|
|
565
|
+
return SwapProvider.SWAP_STATUSES.COMPLETED;
|
|
566
|
+
case "overdue":
|
|
567
|
+
return SwapProvider.SWAP_STATUSES.EXPIRED;
|
|
568
|
+
case "refunded":
|
|
569
|
+
return SwapProvider.SWAP_STATUSES.REFUNDED;
|
|
570
|
+
default:
|
|
571
|
+
throw new Error(`Unknown Exolix status: ${status}`);
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
async getPartnersList() {
|
|
576
|
+
return [
|
|
577
|
+
new Partner(this.id, "Exolix", "https://storage.swapspace.co/static/9WRkfc_QCUUmOBTcvgC9p57l9.svg", null),
|
|
578
|
+
];
|
|
579
|
+
}
|
|
580
|
+
}
|