@rabbitio/ui-kit 1.0.0-beta.72 → 1.0.0-beta.74
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/coverage/clover.xml +6441 -1864
- package/coverage/coverage-final.json +157 -95
- package/coverage/index.html +339 -84
- package/coverage/{rabbit-ui-kit → ui-kit}/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/index.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/adapters/axiosAdapter.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/adapters/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/adapters/qrUtils.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/amountUtils.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/errorUtils.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/external-apis/apiGroups.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/external-apis/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/external-apis/ipAddressProviders.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/fiatCurrenciesService.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/globalConstants.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/models/blockchain.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/models/coin.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/models/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/models/protocol.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/utils/cache.js.html +8 -8
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/utils/emailAPI.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/utils/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/utils/logging/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/utils/logging/logger.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/utils/logging/logsStorage.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/utils/postponeExecution.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/utils/safeStringify.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/index.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/robust-api-caller/cacheAndConcurrentRequestsResolver.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/robust-api-caller/cachedRobustExternalApiCallerService.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/robust-api-caller/cancelProcessing.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/robust-api-caller/concurrentCalculationsMetadataHolder.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/robust-api-caller/externalApiProvider.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/robust-api-caller/externalServicesStatsCollector.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/robust-api-caller/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/robust-api-caller/robustExternalAPICallerService.js.html +3 -3
- package/coverage/ui-kit/src/swaps-lib/external-apis/index.html +146 -0
- package/coverage/ui-kit/src/swaps-lib/external-apis/letsExchangeSwapProvider.js.html +1456 -0
- package/coverage/ui-kit/src/swaps-lib/external-apis/swapProvider.js.html +1390 -0
- package/coverage/{rabbit-ui-kit → ui-kit}/src/swaps-lib/external-apis/swapspaceSwapProvider.js.html +45 -585
- package/coverage/{rabbit-ui-kit → ui-kit}/src/swaps-lib/models/baseSwapCreationInfo.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/swaps-lib/models/existingSwap.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/swaps-lib/models/existingSwapWithFiatData.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/swaps-lib/models/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/swaps-lib/services/index.html +7 -7
- package/coverage/{rabbit-ui-kit → ui-kit}/src/swaps-lib/services/publicSwapService.js.html +233 -50
- package/coverage/{rabbit-ui-kit → ui-kit}/src/swaps-lib/utils/index.html +13 -13
- package/coverage/{rabbit-ui-kit → ui-kit}/src/swaps-lib/utils/swapUtils.js.html +121 -46
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/assets/wrappedImages/arrowIcon.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/assets/wrappedImages/arrowTosca.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/assets/wrappedImages/arrowWhite.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/assets/wrappedImages/darkRectangle.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/assets/wrappedImages/determinedError.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/assets/wrappedImages/failedValidationIcon.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/assets/wrappedImages/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/assets/wrappedImages/infoIcon.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/assets/wrappedImages/noticeQuestionIcon.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/assets/wrappedImages/successfulValidationIcon.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/assets/wrappedImages/walletIcon.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/AssetIcon/AssetIcon.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/AssetIcon/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/AssetSelection/AssetSelection.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/AssetSelection/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/BackgroundTitle/BackgroundTitle.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/BackgroundTitle/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/InformationMessage/InformationMessage.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/InformationMessage/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/Input/Input.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/Input/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/LoadingDots/LoadingDots.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/LoadingDots/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/NoticeIcon/NoticeIcon.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/NoticeIcon/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/QrCode/QrCode.jsx.html +52 -7
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/QrCode/index.html +7 -7
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/RateSelector/RateSelector.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/RateSelector/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/SupportChat/SupportChat.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/SupportChat/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/Textarea/Textarea.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/Textarea/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/TitleBox/TitleBox.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/TitleBox/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/Tooltip/Tooltip.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/Tooltip/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/TwoLinesOfText/LinesOfText.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/TwoLinesOfText/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/Validation/Validation.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/Validation/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/buttons/Button/Button.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/buttons/Button/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/buttons/Close/Close.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/buttons/Close/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/buttons/LinkButton/LinkButton.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/buttons/LinkButton/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/buttons/RadioButtonWithText/RadioButtonWithText.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/buttons/RadioButtonWithText/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/molecules/AmountInput/AmountInput.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/molecules/AmountInput/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/molecules/CoinPicker/CoinPicker.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/molecules/CoinPicker/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/molecules/LineWithIconLink/LineWithIconLink.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/molecules/LineWithIconLink/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/molecules/TitledLineWithIconLink/TitledLineWithIconLink.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/molecules/TitledLineWithIconLink/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/organisms/CoinPickerDialogStep/CoinPickerDialogStep.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/organisms/CoinPickerDialogStep/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/organisms/Dialog/Dialog.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/organisms/Dialog/DialogButtons/DialogButtons.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/organisms/Dialog/DialogButtons/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/organisms/Dialog/DialogStep/DialogStep.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/organisms/Dialog/DialogStep/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/organisms/Dialog/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/organisms/SwapForm/SwapForm.jsx.html +171 -39
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/organisms/SwapForm/index.html +7 -7
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/templates/DeterminedErrorDialogStep/DeterminedErrorDialogStep.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/templates/DeterminedErrorDialogStep/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/hooks/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/hooks/useCallHandlingErrors.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/hooks/useIsHydrated.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/hooks/useReferredState.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/utils/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/utils/inputValueProviders.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/utils/textUtils.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/utils/uiUtils.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/utils/urlQueryUtils.js.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/BackgroundTitle.stories.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/LinesOfText.stories.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/LoadingDots.stories.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/QrCode.stories.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/RateSelector.stories.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/Validation.stories.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/buttons/Button.stories.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/buttons/Close.stories.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/buttons/LinkButton.stories.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/buttons/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/molecules/LineWithIconLink.stories.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/molecules/TitledLineWithIconLink.stories.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/molecules/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/organisms/Dialog/Dialog.stories.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/organisms/Dialog/DialogButtons/DialogButtons.stories.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/organisms/Dialog/DialogButtons/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/organisms/Dialog/DialogStep/DialogStep.stories.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/organisms/Dialog/DialogStep/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/organisms/Dialog/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/stubs/exampleContent.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/stubs/index.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/templates/DeterminedErrorDialogStep.stories.jsx.html +3 -3
- package/coverage/{rabbit-ui-kit → ui-kit}/stories/templates/index.html +3 -3
- package/coverage/ui-kit/storybook-static/124.c2d01e5e.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/138.56b7edc4.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/312.6f62bbd9.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/341.57a15f57.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/370.73bb343e.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/595.2e40d981.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/607.3ea32459.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/609.8c79ec77.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/666.09fdc1d7.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/797.c87cdf19.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/822.4bc0ebce.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/833.08e3ebb6.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/862.bf6bfe62.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/87.0a1bfeb1.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/893.4b09f929.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/996.846a677b.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/atoms-BackgroundTitle-stories.1a5386a1.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/atoms-LinesOfText-stories.7043a48b.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/atoms-LoadingDots-stories.091245c7.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/atoms-QrCode-stories.e10363b6.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/atoms-RateSelector-stories.af208e9a.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/atoms-Validation-stories.d561b311.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/atoms-buttons-Button-stories.e8e6b930.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/atoms-buttons-Close-stories.0a902a7c.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/atoms-buttons-LinkButton-stories.ca93ab6b.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/index.html +596 -0
- package/coverage/ui-kit/storybook-static/main.41f410f2.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/molecules-LineWithIconLink-stories.9721a18c.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/molecules-TitledLineWithIconLink-stories.1383fe3f.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/organisms-Dialog-Dialog-stories.4e6da717.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/organisms-Dialog-DialogButtons-DialogButtons-stories.6f45ae6e.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/organisms-Dialog-DialogStep-DialogStep-stories.74896048.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/rabbitio/ui-kit/node_modules/@storybook/addon-backgrounds/dist/index.html +116 -0
- package/coverage/ui-kit/storybook-static/rabbitio/ui-kit/node_modules/@storybook/addon-backgrounds/dist/preview.js.html +118 -0
- package/coverage/ui-kit/storybook-static/rabbitio/ui-kit/node_modules/@storybook/components/dist/formatter-SWP5E3XI.mjs.html +118 -0
- package/coverage/ui-kit/storybook-static/rabbitio/ui-kit/node_modules/@storybook/components/dist/index.html +116 -0
- package/coverage/ui-kit/storybook-static/rabbitio/ui-kit/node_modules/buffer/index.html +116 -0
- package/coverage/ui-kit/storybook-static/rabbitio/ui-kit/node_modules/buffer/index.js.html +118 -0
- package/coverage/ui-kit/storybook-static/rabbitio/ui-kit/node_modules/markdown-to-jsx/dist/index.html +116 -0
- package/coverage/ui-kit/storybook-static/rabbitio/ui-kit/node_modules/markdown-to-jsx/dist/index.modern.js.html +118 -0
- package/coverage/ui-kit/storybook-static/runtime~main.ad918f38.iframe.bundle.js.html +85 -0
- package/coverage/ui-kit/storybook-static/sb-addons/actions-9/index.html +116 -0
- package/coverage/ui-kit/storybook-static/sb-addons/actions-9/manager-bundle.js.html +94 -0
- package/coverage/ui-kit/storybook-static/sb-addons/essentials-backgrounds-2/index.html +116 -0
- package/coverage/ui-kit/storybook-static/sb-addons/essentials-backgrounds-2/manager-bundle.js.html +121 -0
- package/coverage/ui-kit/storybook-static/sb-addons/essentials-controls-1/index.html +116 -0
- package/coverage/ui-kit/storybook-static/sb-addons/essentials-controls-1/manager-bundle.js.html +274 -0
- package/coverage/ui-kit/storybook-static/sb-addons/essentials-measure-4/index.html +116 -0
- package/coverage/ui-kit/storybook-static/sb-addons/essentials-measure-4/manager-bundle.js.html +94 -0
- package/coverage/ui-kit/storybook-static/sb-addons/essentials-outline-5/index.html +116 -0
- package/coverage/ui-kit/storybook-static/sb-addons/essentials-outline-5/manager-bundle.js.html +94 -0
- package/coverage/ui-kit/storybook-static/sb-addons/essentials-toolbars-3/index.html +116 -0
- package/coverage/ui-kit/storybook-static/sb-addons/essentials-toolbars-3/manager-bundle.js.html +94 -0
- package/coverage/ui-kit/storybook-static/sb-addons/interactions-7/index.html +116 -0
- package/coverage/ui-kit/storybook-static/sb-addons/interactions-7/manager-bundle.js.html +121 -0
- package/coverage/ui-kit/storybook-static/sb-addons/links-0/index.html +116 -0
- package/coverage/ui-kit/storybook-static/sb-addons/links-0/manager-bundle.js.html +94 -0
- package/coverage/ui-kit/storybook-static/sb-addons/onboarding-6/index.html +116 -0
- package/coverage/ui-kit/storybook-static/sb-addons/onboarding-6/manager-bundle.js.html +1588 -0
- package/coverage/ui-kit/storybook-static/sb-addons/viewport-8/index.html +116 -0
- package/coverage/ui-kit/storybook-static/sb-addons/viewport-8/manager-bundle.js.html +94 -0
- package/coverage/ui-kit/storybook-static/sb-manager/WithTooltip-V3YHNWJZ-LVYLGZW2.js.html +88 -0
- package/coverage/ui-kit/storybook-static/sb-manager/chunk-2IXBUOFS.js.html +106 -0
- package/coverage/ui-kit/storybook-static/sb-manager/chunk-INSKDKQB.js.html +1129 -0
- package/coverage/ui-kit/storybook-static/sb-manager/chunk-NGTUFCUO.js.html +112 -0
- package/coverage/ui-kit/storybook-static/sb-manager/chunk-UUEAOBSN.js.html +1303 -0
- package/coverage/ui-kit/storybook-static/sb-manager/chunk-ZEU7PDD3.js.html +88 -0
- package/coverage/ui-kit/storybook-static/sb-manager/formatter-SWP5E3XI-7BGIK6BL.js.html +553 -0
- package/coverage/ui-kit/storybook-static/sb-manager/globals-module-info.js.html +88 -0
- package/coverage/ui-kit/storybook-static/sb-manager/globals.js.html +88 -0
- package/coverage/ui-kit/storybook-static/sb-manager/index.html +281 -0
- package/coverage/ui-kit/storybook-static/sb-manager/index.js.html +88 -0
- package/coverage/ui-kit/storybook-static/sb-manager/runtime.js.html +88 -0
- package/coverage/ui-kit/storybook-static/sb-manager/syntaxhighlighter-V7JZZA35-DXZCI2WR.js.html +88 -0
- package/coverage/ui-kit/storybook-static/sb-preview/globals.js.html +88 -0
- package/coverage/ui-kit/storybook-static/sb-preview/index.html +131 -0
- package/coverage/ui-kit/storybook-static/sb-preview/runtime.js.html +421 -0
- package/coverage/ui-kit/storybook-static/templates-DeterminedErrorDialogStep-stories.3cc14214.iframe.bundle.js.html +85 -0
- package/dist/index.cjs +1201 -605
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +786 -330
- package/dist/index.modern.js.map +1 -1
- package/dist/index.module.js +1201 -605
- package/dist/index.module.js.map +1 -1
- package/dist/index.umd.js +1201 -605
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/swaps-lib/external-apis/letsExchangeSwapProvider.js +457 -0
- package/src/swaps-lib/external-apis/swapProvider.js +246 -20
- package/src/swaps-lib/external-apis/swapspaceSwapProvider.js +20 -200
- package/src/swaps-lib/services/publicSwapService.js +105 -44
- package/src/swaps-lib/test/external-apis/swapProvider/removeProtocolNameFromCoinName.test.js +142 -0
- package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/_fetchSupportedCurrenciesIfNeeded.test.js +2 -2
- package/src/swaps-lib/utils/swapUtils.js +63 -38
- package/src/ui-kit/components/atoms/QrCode/QrCode.jsx +16 -1
- package/src/ui-kit/components/organisms/SwapForm/SwapForm.jsx +77 -33
- package/src/ui-kit/components/organisms/SwapForm/swap-form.module.scss +1 -1
- package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/index.html +0 -131
- package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/swapProvider.js.html +0 -712
|
@@ -1,4 +1,20 @@
|
|
|
1
|
+
import { Logger } from "../../common-apis/utils/logging/logger.js";
|
|
2
|
+
import { improveAndRethrow } from "../../common-apis/errorUtils.js";
|
|
3
|
+
import { Coin } from "../../common-apis/models/coin.js";
|
|
4
|
+
import { FALLBACK_ASSET_ICON_URL } from "../../common-apis/globalConstants.jsx";
|
|
5
|
+
import { BigNumber } from "bignumber.js";
|
|
6
|
+
|
|
7
|
+
// TODO: [refactoring, moderate] extract structure of _supportedCoins into model class
|
|
1
8
|
export class SwapProvider {
|
|
9
|
+
constructor(cache, customCoinBuilder = (coin, network) => null, useRestrictedCoinsSet = true) {
|
|
10
|
+
this._supportedCoins = [];
|
|
11
|
+
this._maxRateDigits = 20;
|
|
12
|
+
this.useRestrictedCoinsSet = useRestrictedCoinsSet;
|
|
13
|
+
this._customCoinBuilder = customCoinBuilder;
|
|
14
|
+
this._cache = cache;
|
|
15
|
+
this.isAggregator = false;
|
|
16
|
+
}
|
|
17
|
+
|
|
2
18
|
static COMMON_ERRORS = {
|
|
3
19
|
REQUESTS_LIMIT_EXCEEDED: "requestsLimitExceeded",
|
|
4
20
|
};
|
|
@@ -16,21 +32,21 @@ export class SwapProvider {
|
|
|
16
32
|
};
|
|
17
33
|
|
|
18
34
|
static SWAP_STATUSES = {
|
|
19
|
-
WAITING_FOR_PAYMENT: "waiting_for_payment",
|
|
35
|
+
WAITING_FOR_PAYMENT: "waiting_for_payment",
|
|
20
36
|
CONFIRMING: "confirming",
|
|
21
|
-
PAYMENT_RECEIVED: "payment_received",
|
|
22
|
-
EXCHANGING: "exchanging",
|
|
23
|
-
COMPLETED: "completed",
|
|
24
|
-
REFUNDED: "refunded",
|
|
25
|
-
EXPIRED: "expired",
|
|
26
|
-
FAILED: "failed",
|
|
37
|
+
PAYMENT_RECEIVED: "payment_received",
|
|
38
|
+
EXCHANGING: "exchanging",
|
|
39
|
+
COMPLETED: "completed",
|
|
40
|
+
REFUNDED: "refunded",
|
|
41
|
+
EXPIRED: "expired",
|
|
42
|
+
FAILED: "failed",
|
|
27
43
|
};
|
|
28
44
|
|
|
29
45
|
/**
|
|
30
46
|
* @return {Promise<void>}
|
|
31
47
|
*/
|
|
32
48
|
async initialize() {
|
|
33
|
-
|
|
49
|
+
await this._fetchSupportedCurrenciesIfNeeded();
|
|
34
50
|
}
|
|
35
51
|
|
|
36
52
|
/**
|
|
@@ -40,6 +56,33 @@ export class SwapProvider {
|
|
|
40
56
|
throw new Error("Not implemented in base");
|
|
41
57
|
}
|
|
42
58
|
|
|
59
|
+
/**
|
|
60
|
+
* This method sort internal list putting popular (as provider thinks) coins to the top.
|
|
61
|
+
* This is just for users of this API if they don't care about the sorting - we just improve a list a bit this way.
|
|
62
|
+
* @private
|
|
63
|
+
*/
|
|
64
|
+
_putPopularCoinsFirst() {
|
|
65
|
+
this._supportedCoins.sort((i1, i2) => {
|
|
66
|
+
if (i1.isPopular !== i2.isPopular) return i2.isPopular - i1.isPopular;
|
|
67
|
+
return i1.coin.ticker.localeCompare(i2.coin.ticker);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Should fill _supportedCoins with array of coins.
|
|
73
|
+
* Coin construction rules:
|
|
74
|
+
* 1. ticker should be CODEPROTOCOL_CODE e.g. USDTERC20
|
|
75
|
+
* 2. name should not contain (PROTOCOL_CODE) or just PROTOCOL_CODe
|
|
76
|
+
* 3. protocol should be null for coins major for their blockchains like BTC, ETH
|
|
77
|
+
* 4. isPopular should be a number
|
|
78
|
+
*
|
|
79
|
+
* @return {Promise<void>}
|
|
80
|
+
* @private
|
|
81
|
+
*/
|
|
82
|
+
async _fetchSupportedCurrenciesIfNeeded() {
|
|
83
|
+
throw new Error("Not implemented in base - _fetchSupportedCurrenciesIfNeeded");
|
|
84
|
+
}
|
|
85
|
+
|
|
43
86
|
/**
|
|
44
87
|
* Retrieves all currencies supported by this swap provider.
|
|
45
88
|
* Returns one of SwapProvider.COMMON_ERRORS in case of processable fail.
|
|
@@ -47,7 +90,23 @@ export class SwapProvider {
|
|
|
47
90
|
* @return {Promise<({ result: true, coins: Coin[] }|{ result: false, reason: string })>}
|
|
48
91
|
*/
|
|
49
92
|
async getAllSupportedCurrencies() {
|
|
50
|
-
|
|
93
|
+
const loggerSource = "getAllSupportedCurrencies";
|
|
94
|
+
try {
|
|
95
|
+
await this._fetchSupportedCurrenciesIfNeeded();
|
|
96
|
+
Logger.log(`We have ${this._supportedCoins?.length} supported coins returning`, loggerSource);
|
|
97
|
+
return {
|
|
98
|
+
result: true,
|
|
99
|
+
coins: this._supportedCoins.map(item => item.coin),
|
|
100
|
+
};
|
|
101
|
+
} catch (e) {
|
|
102
|
+
if (e?.response?.status === 429) {
|
|
103
|
+
return {
|
|
104
|
+
result: false,
|
|
105
|
+
reason: SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
improveAndRethrow(e, loggerSource);
|
|
109
|
+
}
|
|
51
110
|
}
|
|
52
111
|
|
|
53
112
|
/**
|
|
@@ -57,7 +116,23 @@ export class SwapProvider {
|
|
|
57
116
|
* @return {Promise<({ result: true, coins: Coin[] }|{ result: false, reason: string })>}
|
|
58
117
|
*/
|
|
59
118
|
async getDepositCurrencies() {
|
|
60
|
-
|
|
119
|
+
const loggerSource = "getDepositCurrencies";
|
|
120
|
+
try {
|
|
121
|
+
await this._fetchSupportedCurrenciesIfNeeded();
|
|
122
|
+
Logger.log(`We have ${this._supportedCoins?.length} supported coins, getting depositable`, loggerSource);
|
|
123
|
+
return {
|
|
124
|
+
result: true,
|
|
125
|
+
coins: this._supportedCoins.filter(item => item.deposit).map(item => item.coin),
|
|
126
|
+
};
|
|
127
|
+
} catch (e) {
|
|
128
|
+
if (e?.response?.status === 429) {
|
|
129
|
+
return {
|
|
130
|
+
result: false,
|
|
131
|
+
reason: SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
improveAndRethrow(e, loggerSource);
|
|
135
|
+
}
|
|
61
136
|
}
|
|
62
137
|
|
|
63
138
|
/**
|
|
@@ -68,17 +143,49 @@ export class SwapProvider {
|
|
|
68
143
|
* @return {Promise<({ result: true, coins: Coin[] }|{ result: false, reason: string })>}
|
|
69
144
|
*/
|
|
70
145
|
async getWithdrawalCurrencies(exceptCurrency = null) {
|
|
71
|
-
|
|
146
|
+
const loggerSource = "getWithdrawalCurrencies";
|
|
147
|
+
try {
|
|
148
|
+
await this._fetchSupportedCurrenciesIfNeeded();
|
|
149
|
+
Logger.log(`We have ${this._supportedCoins?.length} supported coins, getting withdrawable`, loggerSource);
|
|
150
|
+
return {
|
|
151
|
+
result: true,
|
|
152
|
+
coins: this._supportedCoins
|
|
153
|
+
.filter(
|
|
154
|
+
item => item.withdrawal && (!exceptCurrency || item.coin?.ticker !== exceptCurrency?.ticker)
|
|
155
|
+
)
|
|
156
|
+
.map(item => item.coin),
|
|
157
|
+
};
|
|
158
|
+
} catch (e) {
|
|
159
|
+
if (e?.response?.status === 429) {
|
|
160
|
+
return {
|
|
161
|
+
result: false,
|
|
162
|
+
reason: SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
improveAndRethrow(e, loggerSource);
|
|
166
|
+
}
|
|
72
167
|
}
|
|
73
168
|
|
|
74
169
|
/**
|
|
75
170
|
* Retrieves URL for coin icon or fallback if not found.
|
|
76
171
|
*
|
|
77
|
-
* @param
|
|
172
|
+
* @param coinOrTicker {Coin|string} coin or rabbit-format of coin ticker
|
|
78
173
|
* @return {string}
|
|
79
174
|
*/
|
|
80
|
-
getIconUrl(
|
|
81
|
-
|
|
175
|
+
getIconUrl(coinOrTicker) {
|
|
176
|
+
const loggerSource = "getIconUrl";
|
|
177
|
+
try {
|
|
178
|
+
let coin = coinOrTicker;
|
|
179
|
+
if (!(coinOrTicker instanceof Coin)) {
|
|
180
|
+
coin = this._supportedCoins.find(i => i.coin.ticker === coinOrTicker)?.coin;
|
|
181
|
+
}
|
|
182
|
+
return (
|
|
183
|
+
this._supportedCoins.find(item => item.coin?.ticker === coin?.ticker)?.iconURL ??
|
|
184
|
+
FALLBACK_ASSET_ICON_URL
|
|
185
|
+
);
|
|
186
|
+
} catch (e) {
|
|
187
|
+
improveAndRethrow(e, loggerSource);
|
|
188
|
+
}
|
|
82
189
|
}
|
|
83
190
|
|
|
84
191
|
/**
|
|
@@ -88,7 +195,46 @@ export class SwapProvider {
|
|
|
88
195
|
* @return {{result: true, rate: string}|{result: false}}
|
|
89
196
|
*/
|
|
90
197
|
async getCoinToUSDTRate(coin) {
|
|
91
|
-
|
|
198
|
+
const loggerSource = "getCoinToUSDTRate";
|
|
199
|
+
try {
|
|
200
|
+
if (!coin) return null;
|
|
201
|
+
|
|
202
|
+
await this._fetchSupportedCurrenciesIfNeeded();
|
|
203
|
+
|
|
204
|
+
// Using USDT TRC20 as usually fee in this network is smaller than ERC20 and this network is widely used for USDT
|
|
205
|
+
const usdtTrc20 = this._supportedCoins.find(i => i.coin.ticker === "USDTTRC20")?.coin;
|
|
206
|
+
if (!usdtTrc20) {
|
|
207
|
+
return { result: false };
|
|
208
|
+
}
|
|
209
|
+
const cached = this._cache.get("swapspace_usdt_rate_" + coin.ticker);
|
|
210
|
+
if (cached != null) {
|
|
211
|
+
return {
|
|
212
|
+
result: true,
|
|
213
|
+
rate: cached,
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
Logger.log("Loading USDT->coin rate as not found in cache:", coin?.ticker);
|
|
218
|
+
const result = await this.getSwapInfo(usdtTrc20, coin, "5000", false);
|
|
219
|
+
if (!result.result) {
|
|
220
|
+
return { result: false };
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// This calculation is not precise as we cannot recognize the actual fee and network fee. Just approximate.
|
|
224
|
+
const standardSwapspaceFeeMultiplier = 1.004; // fee is usually 0.4%
|
|
225
|
+
const rate = BigNumber(1).div(BigNumber(result.rate).times(standardSwapspaceFeeMultiplier)).toString();
|
|
226
|
+
this._cache.put(
|
|
227
|
+
"swap_usdt_rate_" + coin.ticker,
|
|
228
|
+
rate,
|
|
229
|
+
15 * 60000 // 15 minutes
|
|
230
|
+
);
|
|
231
|
+
return {
|
|
232
|
+
result: true,
|
|
233
|
+
rate: rate,
|
|
234
|
+
};
|
|
235
|
+
} catch (e) {
|
|
236
|
+
improveAndRethrow(e, loggerSource);
|
|
237
|
+
}
|
|
92
238
|
}
|
|
93
239
|
|
|
94
240
|
/**
|
|
@@ -103,6 +249,7 @@ export class SwapProvider {
|
|
|
103
249
|
* @param [fixed=false] {boolean|null} null means fixed or float doesn't matter
|
|
104
250
|
* @param [fromCoinToUsdRate=null] pass if you want to increase the min amount returned
|
|
105
251
|
* by provider with some fixed "insurance" amount to cover min amount fluctuations.
|
|
252
|
+
* @param [amountIsToReceive=false] {boolean} whether the given amount is receiving amount. False means the amount is the sending amount.
|
|
106
253
|
* @return {Promise<({
|
|
107
254
|
* result: false,
|
|
108
255
|
* reason: string,
|
|
@@ -121,7 +268,14 @@ export class SwapProvider {
|
|
|
121
268
|
* [rawSwapData]: Object
|
|
122
269
|
* })>}
|
|
123
270
|
*/
|
|
124
|
-
async getSwapInfo(
|
|
271
|
+
async getSwapInfo(
|
|
272
|
+
fromCoin,
|
|
273
|
+
toCoin,
|
|
274
|
+
amountCoins,
|
|
275
|
+
fixed = false,
|
|
276
|
+
fromCoinToUsdRate = null,
|
|
277
|
+
amountIsToReceive = false
|
|
278
|
+
) {
|
|
125
279
|
throw new Error("Not implemented in base");
|
|
126
280
|
}
|
|
127
281
|
|
|
@@ -138,6 +292,7 @@ export class SwapProvider {
|
|
|
138
292
|
* @param fixed {boolean}
|
|
139
293
|
* @param [toCurrencyExtraId=""] {string} optional extra ID
|
|
140
294
|
* @param [refundExtraId=""] {string} optional extra ID for refund address
|
|
295
|
+
* @param [amountIsToReceive=false] {boolean} whether the given amount is receiving amount. False means the amount is the sending amount.
|
|
141
296
|
* @return {Promise<({
|
|
142
297
|
* result: true,
|
|
143
298
|
* swapId: string,
|
|
@@ -166,7 +321,8 @@ export class SwapProvider {
|
|
|
166
321
|
clientIpAddress,
|
|
167
322
|
fixed,
|
|
168
323
|
toCurrencyExtraId = "",
|
|
169
|
-
refundExtraId = ""
|
|
324
|
+
refundExtraId = "",
|
|
325
|
+
amountIsToReceive = false
|
|
170
326
|
) {
|
|
171
327
|
throw new Error("Not implemented in base");
|
|
172
328
|
}
|
|
@@ -187,7 +343,12 @@ export class SwapProvider {
|
|
|
187
343
|
* @return {Coin|null}
|
|
188
344
|
*/
|
|
189
345
|
getCoinByTickerIfPresent(ticker) {
|
|
190
|
-
|
|
346
|
+
try {
|
|
347
|
+
const item = this._supportedCoins.find(i => i.coin.ticker === ticker);
|
|
348
|
+
return item?.coin ?? null;
|
|
349
|
+
} catch (e) {
|
|
350
|
+
improveAndRethrow(e, "getCoinByTickerIfPresent");
|
|
351
|
+
}
|
|
191
352
|
}
|
|
192
353
|
|
|
193
354
|
/**
|
|
@@ -196,7 +357,19 @@ export class SwapProvider {
|
|
|
196
357
|
* @return {boolean}
|
|
197
358
|
*/
|
|
198
359
|
isAddressValidForAsset(asset, address) {
|
|
199
|
-
|
|
360
|
+
try {
|
|
361
|
+
const assetData = this._supportedCoins.find(i => i.coin?.ticker === asset?.ticker);
|
|
362
|
+
if (assetData) {
|
|
363
|
+
let corrected = assetData.validationRegexp.trim();
|
|
364
|
+
corrected = corrected[0] === "/" ? corrected.slice(1) : corrected;
|
|
365
|
+
corrected =
|
|
366
|
+
corrected[corrected.length - 1] === "/" ? corrected.slice(0, corrected.length - 1) : corrected;
|
|
367
|
+
return address.match(corrected) != null;
|
|
368
|
+
}
|
|
369
|
+
} catch (e) {
|
|
370
|
+
Logger.logError(e, "isAddressValidForAsset");
|
|
371
|
+
}
|
|
372
|
+
return false;
|
|
200
373
|
}
|
|
201
374
|
|
|
202
375
|
/**
|
|
@@ -204,6 +377,59 @@ export class SwapProvider {
|
|
|
204
377
|
* @return {string|null}
|
|
205
378
|
*/
|
|
206
379
|
getExtraIdNameIfPresent(asset) {
|
|
207
|
-
|
|
380
|
+
try {
|
|
381
|
+
const assetData = this._supportedCoins.find(i => i.coin?.ticker === asset?.ticker);
|
|
382
|
+
if (assetData?.hasExtraId) {
|
|
383
|
+
if (assetData?.extraIdName == null || assetData?.extraIdName === "") {
|
|
384
|
+
// We return some default name if the extraIdName is empty
|
|
385
|
+
return "ID";
|
|
386
|
+
}
|
|
387
|
+
return assetData?.extraIdName;
|
|
388
|
+
}
|
|
389
|
+
return null;
|
|
390
|
+
} catch (e) {
|
|
391
|
+
improveAndRethrow(e, "getExtraIdNameIfPresent");
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
removeProtocolNameFromCoinName(coinName, tickerPrintable, protocolName) {
|
|
396
|
+
if (coinName) {
|
|
397
|
+
const originalName = coinName;
|
|
398
|
+
if (tickerPrintable) {
|
|
399
|
+
coinName = coinName.replaceAll(new RegExp(`\\(${tickerPrintable}\\)`, "gi"), "");
|
|
400
|
+
}
|
|
401
|
+
if (protocolName) {
|
|
402
|
+
coinName = coinName
|
|
403
|
+
.replaceAll(new RegExp(`\\(${protocolName}\\)`, "gi"), "")
|
|
404
|
+
.replaceAll(new RegExp(`(?<!on) ${protocolName}$`, "gi"), "")
|
|
405
|
+
.replaceAll(new RegExp(`^${protocolName} `, "gi"), "")
|
|
406
|
+
.replaceAll(new RegExp(`(?<!on) ${protocolName} `, "gi"), " ");
|
|
407
|
+
}
|
|
408
|
+
coinName = coinName.replaceAll(/ +/g, " ").trim();
|
|
409
|
+
|
|
410
|
+
const defaultNames = [
|
|
411
|
+
"token",
|
|
412
|
+
"network",
|
|
413
|
+
"protocol",
|
|
414
|
+
"coin",
|
|
415
|
+
"mainnet",
|
|
416
|
+
"chain",
|
|
417
|
+
"project",
|
|
418
|
+
"cash",
|
|
419
|
+
"finance",
|
|
420
|
+
"wrapped",
|
|
421
|
+
"blockchain",
|
|
422
|
+
"network",
|
|
423
|
+
];
|
|
424
|
+
const lowerCoinName = coinName.toLowerCase();
|
|
425
|
+
const isBecameDefaultName = defaultNames.find(
|
|
426
|
+
defName => lowerCoinName === defName || lowerCoinName === `the ${defName}`
|
|
427
|
+
);
|
|
428
|
+
if (coinName === "" || isBecameDefaultName) {
|
|
429
|
+
// Rolling back to original name if our processing leads in empty name or one of the default words
|
|
430
|
+
coinName = originalName;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
return coinName;
|
|
208
434
|
}
|
|
209
435
|
}
|
|
@@ -15,14 +15,10 @@ export const BANNED_PARTNERS = ["stealthex", "changee", "coincraddle"];
|
|
|
15
15
|
|
|
16
16
|
export class SwapspaceSwapProvider extends SwapProvider {
|
|
17
17
|
constructor(apiKeysProxyUrl, cache, customCoinBuilder = (coin, network) => null, useRestrictedCoinsSet = true) {
|
|
18
|
-
super();
|
|
19
|
-
this._supportedCoins = [];
|
|
18
|
+
super(cache, customCoinBuilder, useRestrictedCoinsSet);
|
|
20
19
|
this._partners = [];
|
|
21
|
-
this._URL = `${apiKeysProxyUrl}`;
|
|
22
|
-
this.
|
|
23
|
-
this.useRestrictedCoinsSet = useRestrictedCoinsSet;
|
|
24
|
-
this._customCoinBuilder = customCoinBuilder;
|
|
25
|
-
this._cache = cache;
|
|
20
|
+
this._URL = `${apiKeysProxyUrl}/swapspace`;
|
|
21
|
+
this.isAggregator = true;
|
|
26
22
|
}
|
|
27
23
|
|
|
28
24
|
getSwapCreationInfoTtlMs() {
|
|
@@ -31,90 +27,6 @@ export class SwapspaceSwapProvider extends SwapProvider {
|
|
|
31
27
|
return 110000;
|
|
32
28
|
}
|
|
33
29
|
|
|
34
|
-
async getDepositCurrencies() {
|
|
35
|
-
const loggerSource = "getDepositCurrencies";
|
|
36
|
-
try {
|
|
37
|
-
await this._fetchSupportedCurrenciesIfNeeded();
|
|
38
|
-
Logger.log(`We have ${this._supportedCoins?.length} supported coins, getting depositable`, loggerSource);
|
|
39
|
-
return {
|
|
40
|
-
result: true,
|
|
41
|
-
coins: this._supportedCoins.filter(item => item.deposit).map(item => item.coin),
|
|
42
|
-
};
|
|
43
|
-
} catch (e) {
|
|
44
|
-
if (e?.response?.status === 429) {
|
|
45
|
-
return {
|
|
46
|
-
result: false,
|
|
47
|
-
reason: SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
improveAndRethrow(e, loggerSource);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
async getAllSupportedCurrencies() {
|
|
55
|
-
const loggerSource = "getAllSupportedCurrencies";
|
|
56
|
-
try {
|
|
57
|
-
await this._fetchSupportedCurrenciesIfNeeded();
|
|
58
|
-
Logger.log(`We have ${this._supportedCoins?.length} supported coins returning`, loggerSource);
|
|
59
|
-
return {
|
|
60
|
-
result: true,
|
|
61
|
-
coins: this._supportedCoins.map(item => item.coin),
|
|
62
|
-
};
|
|
63
|
-
} catch (e) {
|
|
64
|
-
if (e?.response?.status === 429) {
|
|
65
|
-
return {
|
|
66
|
-
result: false,
|
|
67
|
-
reason: SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED,
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
improveAndRethrow(e, loggerSource);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
async getWithdrawalCurrencies(exceptCurrency = null) {
|
|
75
|
-
const loggerSource = "getWithdrawalCurrencies";
|
|
76
|
-
try {
|
|
77
|
-
await this._fetchSupportedCurrenciesIfNeeded();
|
|
78
|
-
Logger.log(`We have ${this._supportedCoins?.length} supported coins, getting withdrawable`, loggerSource);
|
|
79
|
-
return {
|
|
80
|
-
result: true,
|
|
81
|
-
coins: this._supportedCoins
|
|
82
|
-
.filter(
|
|
83
|
-
item => item.withdrawal && (!exceptCurrency || item.coin?.ticker !== exceptCurrency?.ticker)
|
|
84
|
-
)
|
|
85
|
-
.map(item => item.coin),
|
|
86
|
-
};
|
|
87
|
-
} catch (e) {
|
|
88
|
-
if (e?.response?.status === 429) {
|
|
89
|
-
return {
|
|
90
|
-
result: false,
|
|
91
|
-
reason: SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED,
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
improveAndRethrow(e, loggerSource);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
async initialize() {
|
|
99
|
-
await this._fetchSupportedCurrenciesIfNeeded();
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
getIconUrl(coinOrTicker) {
|
|
103
|
-
const loggerSource = "getIconUrl";
|
|
104
|
-
try {
|
|
105
|
-
let coin = coinOrTicker;
|
|
106
|
-
if (!(coinOrTicker instanceof Coin)) {
|
|
107
|
-
coin = this._supportedCoins.find(i => i.coin.ticker === coinOrTicker)?.coin;
|
|
108
|
-
}
|
|
109
|
-
return (
|
|
110
|
-
this._supportedCoins.find(item => item.coin?.ticker === coin?.ticker)?.iconURL ??
|
|
111
|
-
FALLBACK_ASSET_ICON_URL
|
|
112
|
-
);
|
|
113
|
-
} catch (e) {
|
|
114
|
-
improveAndRethrow(e, loggerSource);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
30
|
async _fetchSupportedCurrenciesIfNeeded() {
|
|
119
31
|
const loggerSource = "_fetchSupportedCurrenciesIfNeeded";
|
|
120
32
|
try {
|
|
@@ -141,15 +53,7 @@ export class SwapspaceSwapProvider extends SwapProvider {
|
|
|
141
53
|
/** Removing ticker and protocol name from coin name as we usually use them explicitly
|
|
142
54
|
* from coin object rather than counting on having it in the coin name itself.
|
|
143
55
|
* This processing is needed due to poor quality of swapspace coins names. */
|
|
144
|
-
let name = (item.name
|
|
145
|
-
.replaceAll(`(${code})`, "")
|
|
146
|
-
.replaceAll(`(${network})`, "")
|
|
147
|
-
.replaceAll(/ +/g, " ")
|
|
148
|
-
.trim();
|
|
149
|
-
if (name === "") {
|
|
150
|
-
// Rolling back to original name if our processing leads in empty name
|
|
151
|
-
name = item.name;
|
|
152
|
-
}
|
|
56
|
+
let name = this.removeProtocolNameFromCoinName(item.name, code, network);
|
|
153
57
|
const ticker = `${code}${code === network ? "" : network}`;
|
|
154
58
|
const defaultDecimalPlacesForCoinNotSupportedOOB = 8;
|
|
155
59
|
const defaultMinConfirmationsForCoinNotSupportedOOB = 1;
|
|
@@ -179,13 +83,14 @@ export class SwapspaceSwapProvider extends SwapProvider {
|
|
|
179
83
|
network: item.network,
|
|
180
84
|
hasExtraId: item.hasExtraId,
|
|
181
85
|
extraIdName: item.extraIdName,
|
|
182
|
-
isPopular:
|
|
86
|
+
isPopular: item.popular ? 1 : 0,
|
|
183
87
|
iconURL: item.icon
|
|
184
88
|
? `https://storage.swapspace.co${item.icon}`
|
|
185
89
|
: FALLBACK_ASSET_ICON_URL,
|
|
186
90
|
deposit: item.deposit ?? false,
|
|
187
91
|
withdrawal: item.withdrawal ?? false,
|
|
188
92
|
validationRegexp: item.validationRegexp ?? null,
|
|
93
|
+
isAvailable: true,
|
|
189
94
|
};
|
|
190
95
|
}
|
|
191
96
|
|
|
@@ -212,74 +117,18 @@ export class SwapspaceSwapProvider extends SwapProvider {
|
|
|
212
117
|
}
|
|
213
118
|
}
|
|
214
119
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
if (i2.isPopular && !i1.isPopular) return 1;
|
|
224
|
-
return i1.coin.ticker > i2.coin.ticker ? 1 : i1.coin.ticker < i2.coin.ticker ? -1 : 0;
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
async getCoinToUSDTRate(coin) {
|
|
229
|
-
const loggerSource = "getCoinToUSDTRate";
|
|
230
|
-
try {
|
|
231
|
-
if (!coin) return null;
|
|
232
|
-
|
|
233
|
-
await this._fetchSupportedCurrenciesIfNeeded();
|
|
234
|
-
|
|
235
|
-
// Using USDT TRC20 as usually fee in this network is smaller than ERC20 and this network is widely used for USDT
|
|
236
|
-
const usdtTrc20 = this._supportedCoins.find(i => i.coin.ticker === "USDTTRC20")?.coin;
|
|
237
|
-
if (!usdtTrc20) {
|
|
238
|
-
return { result: false };
|
|
239
|
-
}
|
|
240
|
-
const cached = this._cache.get("swapspace_usdt_rate_" + coin.ticker);
|
|
241
|
-
if (cached != null) {
|
|
242
|
-
return {
|
|
243
|
-
result: true,
|
|
244
|
-
rate: cached,
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
Logger.log("Loading USDT->coin rate as not found in cache:", coin?.ticker);
|
|
249
|
-
const result = await this.getSwapInfo(usdtTrc20, coin, "5000", false);
|
|
250
|
-
if (!result.result) {
|
|
251
|
-
return { result: false };
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
// This calculation is not precise as we cannot recognize the actual fee and network fee. Just approximate.
|
|
255
|
-
const standardSwapspaceFeeMultiplier = 1.004; // fee is usually 0.4%
|
|
256
|
-
const rate = BigNumber(1).div(BigNumber(result.rate).times(standardSwapspaceFeeMultiplier)).toString();
|
|
257
|
-
this._cache.put(
|
|
258
|
-
"swapspace_usdt_rate_" + coin.ticker,
|
|
259
|
-
rate,
|
|
260
|
-
15 * 60000 // 15 minutes
|
|
261
|
-
);
|
|
262
|
-
return {
|
|
263
|
-
result: true,
|
|
264
|
-
rate: rate,
|
|
265
|
-
};
|
|
266
|
-
} catch (e) {
|
|
267
|
-
improveAndRethrow(e, loggerSource);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
getCoinByTickerIfPresent(ticker) {
|
|
272
|
-
try {
|
|
273
|
-
const item = this._supportedCoins.find(i => i.coin.ticker === ticker);
|
|
274
|
-
return item?.coin ?? null;
|
|
275
|
-
} catch (e) {
|
|
276
|
-
improveAndRethrow(e, "getCoinByTickerIfPresent");
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
async getSwapInfo(fromCoin, toCoin, amountCoins, fixed = false, fromCoinToUsdRate = null) {
|
|
120
|
+
async getSwapInfo(
|
|
121
|
+
fromCoin,
|
|
122
|
+
toCoin,
|
|
123
|
+
amountCoins,
|
|
124
|
+
fixed = false,
|
|
125
|
+
fromCoinToUsdRate = null,
|
|
126
|
+
amountIsToReceive = false
|
|
127
|
+
) {
|
|
281
128
|
const loggerSource = "getSwapInfo";
|
|
282
129
|
try {
|
|
130
|
+
if (amountIsToReceive)
|
|
131
|
+
throw new Error("Swapspace doesn't support exchanging to get the exact receiving amount");
|
|
283
132
|
if (
|
|
284
133
|
!(fromCoin instanceof Coin) ||
|
|
285
134
|
!(toCoin instanceof Coin) ||
|
|
@@ -454,11 +303,14 @@ export class SwapspaceSwapProvider extends SwapProvider {
|
|
|
454
303
|
clientIpAddress,
|
|
455
304
|
fixed,
|
|
456
305
|
toCurrencyExtraId = "",
|
|
457
|
-
refundExtraId = ""
|
|
306
|
+
refundExtraId = "",
|
|
307
|
+
amountIsToReceive = false
|
|
458
308
|
) {
|
|
459
309
|
const loggerSource = "createSwap";
|
|
460
310
|
const partner = rawSwapData?.partner;
|
|
461
311
|
try {
|
|
312
|
+
if (amountIsToReceive)
|
|
313
|
+
throw new Error("Swapspace doesn't support exchanging to get the exact receiving amount");
|
|
462
314
|
if (
|
|
463
315
|
!(fromCoin instanceof Coin) ||
|
|
464
316
|
!(toCoin instanceof Coin) ||
|
|
@@ -689,36 +541,4 @@ export class SwapspaceSwapProvider extends SwapProvider {
|
|
|
689
541
|
improveAndRethrow(e, loggerSource);
|
|
690
542
|
}
|
|
691
543
|
}
|
|
692
|
-
|
|
693
|
-
isAddressValidForAsset(asset, address) {
|
|
694
|
-
try {
|
|
695
|
-
const assetData = this._supportedCoins.find(i => i.coin?.ticker === asset?.ticker);
|
|
696
|
-
if (assetData) {
|
|
697
|
-
let corrected = assetData.validationRegexp.trim();
|
|
698
|
-
corrected = corrected[0] === "/" ? corrected.slice(1) : corrected;
|
|
699
|
-
corrected =
|
|
700
|
-
corrected[corrected.length - 1] === "/" ? corrected.slice(0, corrected.length - 1) : corrected;
|
|
701
|
-
return address.match(corrected) != null;
|
|
702
|
-
}
|
|
703
|
-
} catch (e) {
|
|
704
|
-
Logger.logError(e, "isAddressValidForAsset");
|
|
705
|
-
}
|
|
706
|
-
return false;
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
getExtraIdNameIfPresent(asset) {
|
|
710
|
-
try {
|
|
711
|
-
const assetData = this._supportedCoins.find(i => i.coin?.ticker === asset?.ticker);
|
|
712
|
-
if (assetData?.hasExtraId) {
|
|
713
|
-
if (assetData?.extraIdName == null || assetData?.extraIdName === "") {
|
|
714
|
-
// We return some default name if the extraIdName is empty
|
|
715
|
-
return "ID";
|
|
716
|
-
}
|
|
717
|
-
return assetData?.extraIdName;
|
|
718
|
-
}
|
|
719
|
-
return null;
|
|
720
|
-
} catch (e) {
|
|
721
|
-
improveAndRethrow(e, "getExtraIdNameIfPresent");
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
544
|
}
|