@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,511 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import { BigNumber } from "bignumber.js";
|
|
3
|
+
import { AmountUtils } from "../../common-apis/utils/amountUtils.js";
|
|
4
|
+
import { improveAndRethrow } from "../../common-apis/utils/errorUtils.js";
|
|
5
|
+
import { SwapProvider } from "./swapProvider.js";
|
|
6
|
+
import { ExistingSwap } from "../models/existingSwap.js";
|
|
7
|
+
import { Coin } from "../../common-apis/models/coin.js";
|
|
8
|
+
import { Protocol } from "../../common-apis/models/protocol.js";
|
|
9
|
+
import { safeStringify } from "../../common-apis/utils/safeStringify.js";
|
|
10
|
+
import { Logger } from "../../common-apis/utils/logging/logger.js";
|
|
11
|
+
import { DEFAULT_CRYPTO_DECIMAL_COUNT, FALLBACK_ASSET_ICON_URL } from "../../common-apis/globalConstants.jsx";
|
|
12
|
+
import { SwapProviderCoinInfo } from "../models/swapProviderCoinInfo.js";
|
|
13
|
+
import { Partner } from "../models/partner.js";
|
|
14
|
+
import { toRabbitTicker } from "../../common-apis/utils/rabbitTicker.js";
|
|
15
|
+
|
|
16
|
+
export class LetsExchangeSwapProvider extends SwapProvider {
|
|
17
|
+
constructor(
|
|
18
|
+
apiKeysProxyUrl,
|
|
19
|
+
cache,
|
|
20
|
+
customCoinBuilder = (coin, network) => null,
|
|
21
|
+
useRestrictedCoinsSet = true,
|
|
22
|
+
apiKey = null
|
|
23
|
+
) {
|
|
24
|
+
super("letsexchange", cache, customCoinBuilder, useRestrictedCoinsSet, false, true);
|
|
25
|
+
this._partners = [];
|
|
26
|
+
this._URL = apiKey ? `https://api.letsexchange.io/api` : `${apiKeysProxyUrl}/${this.id}`;
|
|
27
|
+
this._headers = apiKey
|
|
28
|
+
? {
|
|
29
|
+
Authorization: `Bearer ${apiKey}`,
|
|
30
|
+
"Content-Type": "application/json",
|
|
31
|
+
Accept: "application/json",
|
|
32
|
+
}
|
|
33
|
+
: {};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
static AFFILIATE_ID = "0zbj9hf7xg7jgdgv";
|
|
37
|
+
|
|
38
|
+
getSwapCreationInfoTtlMs() {
|
|
39
|
+
return 110000;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async _fetchSupportedCurrenciesIfNeeded() {
|
|
43
|
+
const loggerSource = "_fetchSupportedCurrenciesIfNeeded";
|
|
44
|
+
try {
|
|
45
|
+
if (this._shouldCoinsListBeLoaded()) {
|
|
46
|
+
const rawResponse = await axios.get(`${this._URL}/v2/coins`, { headers: this._headers });
|
|
47
|
+
Logger.log(`Retrieved ${rawResponse?.data?.length}`, loggerSource);
|
|
48
|
+
let allowedCoins = rawResponse?.data ?? [];
|
|
49
|
+
Logger.log(`Allowed cnt ${allowedCoins.length}`, loggerSource);
|
|
50
|
+
|
|
51
|
+
this._supportedCoins = allowedCoins
|
|
52
|
+
.map(item => {
|
|
53
|
+
const code = item.code.toUpperCase();
|
|
54
|
+
|
|
55
|
+
if (!Array.isArray(item.networks)) return [];
|
|
56
|
+
|
|
57
|
+
return item.networks.map(networkDetails => {
|
|
58
|
+
const network = networkDetails.code.toUpperCase();
|
|
59
|
+
let coin = this._customCoinBuilder != null ? this._customCoinBuilder(code, network) : null;
|
|
60
|
+
if (!coin && !this.useRestrictedCoinsSet) {
|
|
61
|
+
let name = this.removeProtocolNameFromCoinName(item.name, code, network);
|
|
62
|
+
const ticker = toRabbitTicker(code, network);
|
|
63
|
+
const defaultDecimalPlacesForCoinNotSupportedOOB = DEFAULT_CRYPTO_DECIMAL_COUNT;
|
|
64
|
+
const defaultMinConfirmationsForCoinNotSupportedOOB = 1;
|
|
65
|
+
coin = new Coin(
|
|
66
|
+
name,
|
|
67
|
+
ticker,
|
|
68
|
+
code,
|
|
69
|
+
defaultDecimalPlacesForCoinNotSupportedOOB,
|
|
70
|
+
null,
|
|
71
|
+
"",
|
|
72
|
+
null,
|
|
73
|
+
null,
|
|
74
|
+
defaultMinConfirmationsForCoinNotSupportedOOB,
|
|
75
|
+
null,
|
|
76
|
+
[],
|
|
77
|
+
60000,
|
|
78
|
+
null,
|
|
79
|
+
code !== network ? new Protocol(network) : null,
|
|
80
|
+
item.contract_address || null,
|
|
81
|
+
false
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
if (coin) {
|
|
85
|
+
return new SwapProviderCoinInfo(
|
|
86
|
+
coin,
|
|
87
|
+
item.code,
|
|
88
|
+
networkDetails.code,
|
|
89
|
+
!!networkDetails.has_extra,
|
|
90
|
+
networkDetails.extra_name ?? null,
|
|
91
|
+
item.rating || 0,
|
|
92
|
+
item.icon ? item.icon : FALLBACK_ASSET_ICON_URL,
|
|
93
|
+
true, // Letsexchange provide no such details
|
|
94
|
+
true, // Letsexchange provide no such details
|
|
95
|
+
networkDetails.validation_address_regex ?? null,
|
|
96
|
+
(typeof item.is_active !== "number" || item.is_active === 1) &&
|
|
97
|
+
(typeof item.disabled !== "number" || item.disabled === 0) &&
|
|
98
|
+
(typeof networkDetails.is_active !== "number" || networkDetails.is_active === 1)
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
return [];
|
|
102
|
+
});
|
|
103
|
+
})
|
|
104
|
+
.flat();
|
|
105
|
+
this._supportedCoinsLastUpdateTimestamp = Date.now();
|
|
106
|
+
this._putPopularCoinsFirst();
|
|
107
|
+
await super._fetchSupportedCurrenciesIfNeeded();
|
|
108
|
+
}
|
|
109
|
+
} catch (e) {
|
|
110
|
+
improveAndRethrow(e, loggerSource);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
async getSwapInfo(
|
|
115
|
+
fromCoin,
|
|
116
|
+
toCoin,
|
|
117
|
+
amountCoins,
|
|
118
|
+
fixed = false,
|
|
119
|
+
fromCoinToUsdRate = null,
|
|
120
|
+
amountIsToReceive = false,
|
|
121
|
+
bannedPartners = []
|
|
122
|
+
) {
|
|
123
|
+
const loggerSource = "getSwapInfo";
|
|
124
|
+
let min = null;
|
|
125
|
+
let max = null;
|
|
126
|
+
try {
|
|
127
|
+
if (
|
|
128
|
+
!(fromCoin instanceof Coin) ||
|
|
129
|
+
!(toCoin instanceof Coin) ||
|
|
130
|
+
typeof amountCoins !== "string" ||
|
|
131
|
+
BigNumber(amountCoins).lt("0") ||
|
|
132
|
+
(fixed !== null && typeof fixed !== "boolean") ||
|
|
133
|
+
(amountIsToReceive && !fixed)
|
|
134
|
+
) {
|
|
135
|
+
throw new Error(
|
|
136
|
+
`Wrong input params: ${amountCoins} ${fromCoin.ticker} -> ${toCoin.ticker}, ${
|
|
137
|
+
fromCoin instanceof Coin
|
|
138
|
+
}, ${toCoin instanceof Coin}, ${typeof fixed} ${fixed}, ${amountIsToReceive}`
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
await this._fetchSupportedCurrenciesIfNeeded();
|
|
143
|
+
|
|
144
|
+
const fromCoinDetails = this._supportedCoins.find(i => i.coin?.ticker === fromCoin?.ticker);
|
|
145
|
+
const toCoinDetails = this._supportedCoins.find(i => i.coin?.ticker === toCoin?.ticker);
|
|
146
|
+
if (
|
|
147
|
+
!fromCoinDetails ||
|
|
148
|
+
!toCoinDetails ||
|
|
149
|
+
!fromCoinDetails.deposit ||
|
|
150
|
+
!fromCoinDetails.isAvailable ||
|
|
151
|
+
!toCoinDetails.withdrawal ||
|
|
152
|
+
!toCoinDetails.isAvailable
|
|
153
|
+
) {
|
|
154
|
+
return {
|
|
155
|
+
result: false,
|
|
156
|
+
reason: SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const pathAndQuery = `/v1/info${amountIsToReceive ? "-revert" : `?float=${!fixed}`}`;
|
|
161
|
+
const response = await axios.post(
|
|
162
|
+
`${this._URL}${pathAndQuery}`,
|
|
163
|
+
{
|
|
164
|
+
from: fromCoinDetails.code,
|
|
165
|
+
to: toCoinDetails.code,
|
|
166
|
+
network_from: fromCoinDetails.network,
|
|
167
|
+
network_to: toCoinDetails.network,
|
|
168
|
+
amount: amountCoins,
|
|
169
|
+
affiliate_id: LetsExchangeSwapProvider.AFFILIATE_ID,
|
|
170
|
+
},
|
|
171
|
+
{ headers: this._headers }
|
|
172
|
+
);
|
|
173
|
+
Logger.log(`Retrieved ${response?.data}`, loggerSource);
|
|
174
|
+
const data = response.data;
|
|
175
|
+
|
|
176
|
+
// TODO: [dev] add SwapProvider.NO_SWAPS_REASONS.NO_FIXED_BUT_HAVE_FLOATING - request alternative rate. task_id=
|
|
177
|
+
|
|
178
|
+
// TODO: [feature, low] implement extra coins to fit min/max if there are frequent errors due to min/max exceeding
|
|
179
|
+
// let extraCoinsToFitMinMax = "0";
|
|
180
|
+
// if (typeof fromCoinToUsdRate === "string" && BigNumber(fromCoinToUsdRate).gt("0")) {
|
|
181
|
+
// const extraUsdToFitMinMax = BigNumber("1"); // We correct the limits as the exact limit can fluctuate and cause failed swap creation
|
|
182
|
+
// extraCoinsToFitMinMax = AmountUtils.trim(extraUsdToFitMinMax.div(fromCoinToUsdRate), fromCoin.digits);
|
|
183
|
+
// }
|
|
184
|
+
if (data?.min_amount) {
|
|
185
|
+
min = AmountUtils.trim(data?.min_amount, amountIsToReceive ? toCoin.digits : fromCoin.digits);
|
|
186
|
+
}
|
|
187
|
+
if (data?.max_amount) {
|
|
188
|
+
max = AmountUtils.trim(data?.max_amount, amountIsToReceive ? toCoin.digits : fromCoin.digits);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (data.success === false && data.error) {
|
|
192
|
+
// TODO: [dev] waiting for response from letsexchange about their not-documented responses
|
|
193
|
+
// {
|
|
194
|
+
// "success": false,
|
|
195
|
+
// "error": "Internal error"
|
|
196
|
+
// }
|
|
197
|
+
throw new Error("Failed to estimate swap letsexchange");
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (BigNumber(data.rate).eq("0") || BigNumber(data.amount).eq("0")) {
|
|
201
|
+
// TODO actualize according to letsexchage clarification - decide, can we count on min/max abcense? task_id=76512110797f4eab8b37f1bb789825cb
|
|
202
|
+
// amount: "0", rate: "0", rate_id: ""
|
|
203
|
+
let reason = SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED;
|
|
204
|
+
if (min && BigNumber(amountCoins).lt(min)) {
|
|
205
|
+
reason = SwapProvider.NO_SWAPS_REASONS.TOO_LOW;
|
|
206
|
+
} else if (max && BigNumber(amountCoins).gt(max)) {
|
|
207
|
+
reason = SwapProvider.NO_SWAPS_REASONS.TOO_HIGH;
|
|
208
|
+
} else if (!amountIsToReceive) {
|
|
209
|
+
// If we are not requesting receiving amount (it cannot be floating-rate)
|
|
210
|
+
// todo [feature, moderate] request alternative rate. task_id=31884db5392f49738c20a86115c90e1f
|
|
211
|
+
// const alternativeRate = 1;
|
|
212
|
+
// const alternativeRateAvailable = alternativeRate;
|
|
213
|
+
// if (alternativeRateAvailable) {
|
|
214
|
+
// reason = fixed
|
|
215
|
+
// ? SwapProvider.NO_SWAPS_REASONS.NO_FIXED_BUT_HAVE_FLOATING
|
|
216
|
+
// : SwapProvider.NO_SWAPS_REASONS.NO_FLOATING_BUT_HAVE_FIXED;
|
|
217
|
+
// }
|
|
218
|
+
}
|
|
219
|
+
return {
|
|
220
|
+
result: false,
|
|
221
|
+
reason: reason,
|
|
222
|
+
smallestMin: min,
|
|
223
|
+
greatestMax: max,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
const rate = amountIsToReceive
|
|
227
|
+
? BigNumber(amountCoins).div(data.amount)
|
|
228
|
+
: BigNumber(data.amount).div(amountCoins);
|
|
229
|
+
return {
|
|
230
|
+
result: true,
|
|
231
|
+
min: min,
|
|
232
|
+
max: max,
|
|
233
|
+
smallestMin: min,
|
|
234
|
+
greatestMax: max,
|
|
235
|
+
rate: AmountUtils.trim(rate, this._maxRateDigits),
|
|
236
|
+
durationMinutesRange: null,
|
|
237
|
+
fixed: fixed,
|
|
238
|
+
rawSwapData: data,
|
|
239
|
+
isRefundAddressRequired: false,
|
|
240
|
+
};
|
|
241
|
+
} catch (e) {
|
|
242
|
+
if (e?.response?.status === 404) {
|
|
243
|
+
return {
|
|
244
|
+
result: false,
|
|
245
|
+
reason: SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED,
|
|
246
|
+
smallestMin: min,
|
|
247
|
+
greatestMax: max,
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
if (e?.response?.status === 429) {
|
|
251
|
+
return {
|
|
252
|
+
result: false,
|
|
253
|
+
reason: SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED,
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
Logger.log(`Internal error when getting swap options ${safeStringify(e)}`, loggerSource);
|
|
258
|
+
improveAndRethrow(e, loggerSource);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
async createSwap(
|
|
263
|
+
fromCoin,
|
|
264
|
+
toCoin,
|
|
265
|
+
amount,
|
|
266
|
+
toAddress,
|
|
267
|
+
refundAddress,
|
|
268
|
+
proprietarySwapEstimationData,
|
|
269
|
+
clientIpAddress,
|
|
270
|
+
fixed,
|
|
271
|
+
toCurrencyExtraId = "",
|
|
272
|
+
refundExtraId = "",
|
|
273
|
+
amountIsToReceive = false
|
|
274
|
+
) {
|
|
275
|
+
const loggerSource = "createSwap";
|
|
276
|
+
try {
|
|
277
|
+
if (
|
|
278
|
+
!(fromCoin instanceof Coin) ||
|
|
279
|
+
!(toCoin instanceof Coin) ||
|
|
280
|
+
typeof amount !== "string" ||
|
|
281
|
+
typeof toAddress !== "string" ||
|
|
282
|
+
typeof refundAddress !== "string" ||
|
|
283
|
+
typeof clientIpAddress != "string" ||
|
|
284
|
+
typeof fixed != "boolean"
|
|
285
|
+
) {
|
|
286
|
+
throw new Error(
|
|
287
|
+
`Invalid input: ${fromCoin} ${toCoin} ${amount} ${toAddress} ${refundAddress} ${fixed}`
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
if (
|
|
291
|
+
typeof proprietarySwapEstimationData !== "object" ||
|
|
292
|
+
(fixed && !proprietarySwapEstimationData.rate_id)
|
|
293
|
+
) {
|
|
294
|
+
throw new Error(`Invalid raw swap data: ${safeStringify(proprietarySwapEstimationData)}`);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
await this._fetchSupportedCurrenciesIfNeeded();
|
|
298
|
+
|
|
299
|
+
const fromCoinDetails = this._supportedCoins.find(i => i.coin?.ticker === fromCoin?.ticker);
|
|
300
|
+
const toCoinDetails = this._supportedCoins.find(i => i.coin?.ticker === toCoin?.ticker);
|
|
301
|
+
if (!fromCoinDetails || !toCoinDetails) {
|
|
302
|
+
throw new Error("Failed to find coin details for: " + fromCoin.ticker + " -> " + toCoin.ticker);
|
|
303
|
+
}
|
|
304
|
+
const requestBody = {
|
|
305
|
+
coin_from: fromCoinDetails.code,
|
|
306
|
+
network_from: fromCoinDetails.network,
|
|
307
|
+
coin_to: toCoinDetails.code,
|
|
308
|
+
network_to: toCoinDetails.network,
|
|
309
|
+
withdrawal: toAddress,
|
|
310
|
+
withdrawal_extra_id: toCurrencyExtraId,
|
|
311
|
+
return: refundAddress,
|
|
312
|
+
return_extra_id: refundExtraId,
|
|
313
|
+
affiliate_id: LetsExchangeSwapProvider.AFFILIATE_ID,
|
|
314
|
+
};
|
|
315
|
+
if (amountIsToReceive) {
|
|
316
|
+
requestBody.withdrawal_amount = amount;
|
|
317
|
+
} else {
|
|
318
|
+
requestBody.deposit_amount = amount;
|
|
319
|
+
}
|
|
320
|
+
if (fixed) {
|
|
321
|
+
requestBody.rate_id = proprietarySwapEstimationData.rate_id;
|
|
322
|
+
}
|
|
323
|
+
const response = await axios.post(
|
|
324
|
+
`${this._URL}/v1/transaction${amountIsToReceive ? "-revert" : `?float=${!fixed}`}`,
|
|
325
|
+
requestBody,
|
|
326
|
+
{ headers: this._headers }
|
|
327
|
+
);
|
|
328
|
+
const result = response.data;
|
|
329
|
+
Logger.log(`Creation result ${safeStringify(result)}`, loggerSource);
|
|
330
|
+
|
|
331
|
+
if (result?.transaction_id) {
|
|
332
|
+
const rate = BigNumber(result.rate ?? 0).isZero()
|
|
333
|
+
? BigNumber(result.withdrawal_amount).div(result.deposit_amount)
|
|
334
|
+
: BigNumber(result.rate);
|
|
335
|
+
|
|
336
|
+
return {
|
|
337
|
+
result: true,
|
|
338
|
+
swapId: result.transaction_id,
|
|
339
|
+
fromCoin: fromCoin,
|
|
340
|
+
fromAmount: AmountUtils.trim(result.deposit_amount, fromCoin.digits),
|
|
341
|
+
fromAddress: result.deposit,
|
|
342
|
+
toCoin: toCoin,
|
|
343
|
+
toAmount: AmountUtils.trim(result.withdrawal_amount, toCoin.digits),
|
|
344
|
+
toAddress: result.withdrawal,
|
|
345
|
+
fromCurrencyExtraId: result.deposit_extra_id ?? "",
|
|
346
|
+
rate: AmountUtils.trim(rate, this._maxRateDigits),
|
|
347
|
+
fixed: !result.is_float,
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
const errorMessage = `Swap creation succeeded but the response is wrong: ${safeStringify(response)}`;
|
|
352
|
+
Logger.log(errorMessage, loggerSource);
|
|
353
|
+
throw new Error(errorMessage);
|
|
354
|
+
} catch (e) {
|
|
355
|
+
Logger.logError(e, loggerSource, `Failed to create swap. Error is: ${safeStringify(e)}`);
|
|
356
|
+
const composeFailResult = reason => ({
|
|
357
|
+
result: false,
|
|
358
|
+
reason: reason,
|
|
359
|
+
});
|
|
360
|
+
const status = e?.response?.status;
|
|
361
|
+
const data = e?.response?.data;
|
|
362
|
+
if (status === 429) {
|
|
363
|
+
Logger.log(`Returning fail - RPS limit exceeded ${data}`, loggerSource);
|
|
364
|
+
return composeFailResult(SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED);
|
|
365
|
+
}
|
|
366
|
+
// TODO: [feature, low] add custom errors handling - waiting for response from letsexchange. task_id=00d2e435f6df4fb99af912135bd9ee27
|
|
367
|
+
// 422 - missing params
|
|
368
|
+
Logger.log(`Internal error for swap: ${safeStringify(e)}`, loggerSource);
|
|
369
|
+
improveAndRethrow(e, loggerSource);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
async getExistingSwapsDetailsAndStatus(swapIds) {
|
|
374
|
+
const loggerSource = "getExistingSwapsDetailsAndStatus";
|
|
375
|
+
try {
|
|
376
|
+
if (swapIds.find(id => typeof id !== "string")) {
|
|
377
|
+
throw new Error("Swap id is not string: " + safeStringify(swapIds) + " " + this.id);
|
|
378
|
+
}
|
|
379
|
+
const response = await axios.get(`${this._URL}/v1/transactions-list?ids[]=${swapIds.join("&ids[]=")}`, {
|
|
380
|
+
headers: this._headers,
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
Logger.log("All swaps RAW: " + safeStringify(response.data), loggerSource);
|
|
384
|
+
const swaps = response.data
|
|
385
|
+
.map((swap, index) => {
|
|
386
|
+
const fromCoin = this._supportedCoins.find(
|
|
387
|
+
i => i.code === swap.coin_from && i.network === swap.coin_from_network
|
|
388
|
+
)?.coin;
|
|
389
|
+
const toCoin = this._supportedCoins.find(
|
|
390
|
+
i => i.code === swap.coin_to && i.network === swap.coin_to_network
|
|
391
|
+
)?.coin;
|
|
392
|
+
if (!fromCoin || !toCoin) {
|
|
393
|
+
return []; // We skip swaps with not supported coins for now
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
const toUtcTimestamp = timeStr => Date.parse(timeStr.match(/.+[Zz]$/) ? timeStr : `${timeStr}Z`);
|
|
397
|
+
const expiresAt = swap.expired_at ? swap.expired_at * 1000 : null;
|
|
398
|
+
const createdAt = swap.created_at ? toUtcTimestamp(`${swap.created_at}`) : null;
|
|
399
|
+
const isExpiredByTime = expiresAt && expiresAt < Date.now();
|
|
400
|
+
const status = this._mapLetsExchangeStatusToRabbitStatus(swap.status, isExpiredByTime);
|
|
401
|
+
const toDigits = status === SwapProvider.SWAP_STATUSES.REFUNDED ? fromCoin.digits : toCoin.digits;
|
|
402
|
+
const deposit =
|
|
403
|
+
swap.real_deposit_amount && swap.real_deposit_amount !== ""
|
|
404
|
+
? swap.real_deposit_amount
|
|
405
|
+
: swap.deposit_amount;
|
|
406
|
+
const withdrawal =
|
|
407
|
+
swap.real_withdrawal_amount && swap.real_withdrawal_amount !== ""
|
|
408
|
+
? swap.real_withdrawal_amount
|
|
409
|
+
: swap.withdrawal_amount;
|
|
410
|
+
const rate = BigNumber(withdrawal).div(deposit).toFixed(this._maxRateDigits); // We don't use their rate as it excludes their fee
|
|
411
|
+
return new ExistingSwap(
|
|
412
|
+
swapIds[index],
|
|
413
|
+
status,
|
|
414
|
+
createdAt,
|
|
415
|
+
expiresAt,
|
|
416
|
+
swap.confirmations,
|
|
417
|
+
rate,
|
|
418
|
+
swap.is_float != null ? !swap.is_float : false,
|
|
419
|
+
swap.return,
|
|
420
|
+
swap.deposit,
|
|
421
|
+
fromCoin,
|
|
422
|
+
AmountUtils.trim(deposit, fromCoin.digits),
|
|
423
|
+
swap.hash_in,
|
|
424
|
+
swap.hash_in ? `${swap.coin_from_explorer_url}${swap.hash_in}` : null,
|
|
425
|
+
toCoin,
|
|
426
|
+
AmountUtils.trim(withdrawal, toDigits),
|
|
427
|
+
swap.hash_out,
|
|
428
|
+
swap.hash_out ? `${swap.coin_to_explorer_url}${swap.hash_out}` : null,
|
|
429
|
+
swap.withdrawal,
|
|
430
|
+
"letsexchange",
|
|
431
|
+
swap.deposit_extra_id ?? null,
|
|
432
|
+
swap.withdrawal_extra_id ?? null,
|
|
433
|
+
swap.return_extra_id ?? null
|
|
434
|
+
);
|
|
435
|
+
})
|
|
436
|
+
.flat();
|
|
437
|
+
Logger.log(`Swap details result ${safeStringify(swaps)}`, loggerSource);
|
|
438
|
+
return { result: true, swaps: swaps };
|
|
439
|
+
} catch (e) {
|
|
440
|
+
Logger.logError(e, loggerSource, `Failed to get swap details. Error is: ${safeStringify(e)}`);
|
|
441
|
+
const composeFailResult = reason => ({
|
|
442
|
+
result: false,
|
|
443
|
+
reason: reason,
|
|
444
|
+
});
|
|
445
|
+
const status = e?.response?.status;
|
|
446
|
+
const data = e?.response?.data;
|
|
447
|
+
if (status === 429) {
|
|
448
|
+
Logger.log(`Returning fail - RPS limit exceeded ${data}`, loggerSource);
|
|
449
|
+
return composeFailResult(SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED);
|
|
450
|
+
}
|
|
451
|
+
improveAndRethrow(e, loggerSource);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
_mapLetsExchangeStatusToRabbitStatus(status, isExpiredByTime) {
|
|
456
|
+
/**
|
|
457
|
+
* Lets exchange statuses description
|
|
458
|
+
* wait - The exchange has just been created and it’s waiting for coins to reach the deposit wallet
|
|
459
|
+
* confirmation - The transaction appears in mempool and now it is waiting for necessary network confirmations to start.
|
|
460
|
+
* confirmed - The user’s payment is confirmed, the exchange process is about to start.
|
|
461
|
+
* exchanging - The exchange process is running.
|
|
462
|
+
* sending - Funds are being sent to the recipient`s address.
|
|
463
|
+
* sending_confirmation - The outgoing transaction is waiting for network confirmations.
|
|
464
|
+
* success - The exchange is completed and the funds are successfully sent to the recipient’s address.
|
|
465
|
+
* aml_check_failed - The deposit was marked as risky by AML check service.
|
|
466
|
+
* overdue - The deposit receiving time for this transaction has expired.
|
|
467
|
+
* error - The transaction has failed. In most cases, the amount that was sent differs from the amount that was specified when creating the transaction.
|
|
468
|
+
* refund - The exchange failed and the coins were refunded to the user's wallet.
|
|
469
|
+
*/
|
|
470
|
+
switch (status) {
|
|
471
|
+
case "wait":
|
|
472
|
+
if (isExpiredByTime) {
|
|
473
|
+
return SwapProvider.SWAP_STATUSES.EXPIRED;
|
|
474
|
+
}
|
|
475
|
+
return SwapProvider.SWAP_STATUSES.WAITING_FOR_PAYMENT;
|
|
476
|
+
case "confirmation":
|
|
477
|
+
return SwapProvider.SWAP_STATUSES.CONFIRMING;
|
|
478
|
+
case "confirmed":
|
|
479
|
+
return SwapProvider.SWAP_STATUSES.PAYMENT_RECEIVED;
|
|
480
|
+
case "exchanging":
|
|
481
|
+
return SwapProvider.SWAP_STATUSES.EXCHANGING;
|
|
482
|
+
case "sending":
|
|
483
|
+
return SwapProvider.SWAP_STATUSES.EXCHANGING;
|
|
484
|
+
case "sending_confirmation":
|
|
485
|
+
return SwapProvider.SWAP_STATUSES.EXCHANGING;
|
|
486
|
+
case "success":
|
|
487
|
+
return SwapProvider.SWAP_STATUSES.COMPLETED;
|
|
488
|
+
case "refund":
|
|
489
|
+
return SwapProvider.SWAP_STATUSES.REFUNDED;
|
|
490
|
+
case "overdue":
|
|
491
|
+
return SwapProvider.SWAP_STATUSES.EXPIRED;
|
|
492
|
+
case "aml_check_failed":
|
|
493
|
+
return SwapProvider.SWAP_STATUSES.EXCHANGING;
|
|
494
|
+
case "error":
|
|
495
|
+
return SwapProvider.SWAP_STATUSES.FAILED;
|
|
496
|
+
default:
|
|
497
|
+
throw new Error(`Unknown LetsExchange status: ${status}`);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
async getPartnersList() {
|
|
502
|
+
return [
|
|
503
|
+
new Partner(
|
|
504
|
+
"letsexchange",
|
|
505
|
+
"LetsExchange",
|
|
506
|
+
"https://letsexchange.notion.site/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F02e45813-b375-49d8-b2b0-092ce1847fff%2F55ebbc3c-4ee6-4fa7-847b-f673e82594f3%2Flets-logo-basic__on-light.svg?table=block&id=bec5952a-2f9c-47fb-8cc0-86e1391a7f60&spaceId=02e45813-b375-49d8-b2b0-092ce1847fff&userId=&cache=v2",
|
|
507
|
+
null
|
|
508
|
+
),
|
|
509
|
+
];
|
|
510
|
+
}
|
|
511
|
+
}
|