@rango-dev/widget-embedded 0.19.0 → 0.19.1-next.0
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/CHANGELOG.md +0 -4
- package/dist/QueueManager.d.ts +5 -2
- package/dist/QueueManager.d.ts.map +1 -1
- package/dist/components/AppRouter.d.ts +0 -2
- package/dist/components/AppRouter.d.ts.map +1 -1
- package/dist/components/AppRoutes.d.ts +1 -6
- package/dist/components/AppRoutes.d.ts.map +1 -1
- package/dist/components/BlockchainsSection/BlockchainsSection.d.ts.map +1 -1
- package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts +1 -1
- package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts +1 -3
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +690 -61
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.types.d.ts +1 -3
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.types.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/WalletList.type.d.ts +1 -4
- package/dist/components/ConfirmWalletsModal/WalletList.type.d.ts.map +1 -1
- package/dist/components/HeaderButtons/HomeButtons.d.ts.map +1 -1
- package/dist/components/Layout/Layout.d.ts.map +1 -1
- package/dist/components/Layout/Layout.styles.d.ts.map +1 -1
- package/dist/components/Layout/Layout.types.d.ts +2 -2
- package/dist/components/Layout/Layout.types.d.ts.map +1 -1
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.d.ts.map +1 -1
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts +1727 -0
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts.map +1 -1
- package/dist/components/NoResult/NoResult.d.ts +4 -0
- package/dist/components/NoResult/NoResult.d.ts.map +1 -0
- package/dist/components/NoResult/NoResult.helpers.d.ts +4 -0
- package/dist/components/NoResult/NoResult.helpers.d.ts.map +1 -0
- package/dist/components/{NoRoutes/NoRoutes.styles.d.ts → NoResult/NoResult.styles.d.ts} +1 -1
- package/dist/components/{NoRoutes/NoRoutes.styles.d.ts.map → NoResult/NoResult.styles.d.ts.map} +1 -1
- package/dist/components/{NoRoutes/NoRoutes.types.d.ts → NoResult/NoResult.types.d.ts} +3 -3
- package/dist/components/NoResult/NoResult.types.d.ts.map +1 -0
- package/dist/components/NoResult/index.d.ts +2 -0
- package/dist/components/NoResult/index.d.ts.map +1 -0
- package/dist/components/NotificationContent/NotificationContent.d.ts.map +1 -1
- package/dist/components/Quote/Quote.d.ts +4 -0
- package/dist/components/Quote/Quote.d.ts.map +1 -0
- package/dist/components/Quote/Quote.styles.d.ts +2217 -0
- package/dist/components/Quote/Quote.styles.d.ts.map +1 -0
- package/dist/components/Quote/Quote.types.d.ts +21 -0
- package/dist/components/Quote/Quote.types.d.ts.map +1 -0
- package/dist/components/Quote/QuoteSummary.d.ts +11 -0
- package/dist/components/Quote/QuoteSummary.d.ts.map +1 -0
- package/dist/components/Quote/QuoteSummary.styles.d.ts +315 -0
- package/dist/components/Quote/QuoteSummary.styles.d.ts.map +1 -0
- package/dist/components/Quote/index.d.ts +3 -0
- package/dist/components/Quote/index.d.ts.map +1 -0
- package/dist/components/QuoteSkeleton/QuoteSkeleton.d.ts +4 -0
- package/dist/components/QuoteSkeleton/QuoteSkeleton.d.ts.map +1 -0
- package/dist/components/QuoteSkeleton/QuoteSkeleton.styles.d.ts +633 -0
- package/dist/components/QuoteSkeleton/QuoteSkeleton.styles.d.ts.map +1 -0
- package/dist/components/QuoteSkeleton/QuoteSkeleton.types.d.ts +6 -0
- package/dist/components/QuoteSkeleton/QuoteSkeleton.types.d.ts.map +1 -0
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.d.ts +4 -0
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.d.ts.map +1 -0
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.styles.d.ts +1571 -0
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.styles.d.ts.map +1 -0
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.types.d.ts +6 -0
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.types.d.ts.map +1 -0
- package/dist/components/QuoteSkeleton/StepSkeleton.d.ts +4 -0
- package/dist/components/QuoteSkeleton/StepSkeleton.d.ts.map +1 -0
- package/dist/components/QuoteSkeleton/StepSkeleton.styles.d.ts +786 -0
- package/dist/components/QuoteSkeleton/StepSkeleton.styles.d.ts.map +1 -0
- package/dist/components/QuoteSkeleton/StepSkeleton.types.d.ts +4 -0
- package/dist/components/QuoteSkeleton/StepSkeleton.types.d.ts.map +1 -0
- package/dist/components/QuoteSkeleton/index.d.ts +4 -0
- package/dist/components/QuoteSkeleton/index.d.ts.map +1 -0
- package/dist/components/QuoteWarningsAndErrors/HighValueLossWarningModal.d.ts +11 -0
- package/dist/components/QuoteWarningsAndErrors/HighValueLossWarningModal.d.ts.map +1 -0
- package/dist/components/QuoteWarningsAndErrors/QuoteErrorsModalItem.d.ts +4 -0
- package/dist/components/QuoteWarningsAndErrors/QuoteErrorsModalItem.d.ts.map +1 -0
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.d.ts +4 -0
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.d.ts.map +1 -0
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts +9 -0
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts.map +1 -0
- package/dist/components/{RouteErrors/RouteErrors.styles.d.ts → QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts} +1 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts.map +1 -0
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts +23 -0
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts.map +1 -0
- package/dist/components/QuoteWarningsAndErrors/SlippageWariningModal.d.ts +11 -0
- package/dist/components/QuoteWarningsAndErrors/SlippageWariningModal.d.ts.map +1 -0
- package/dist/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.d.ts +11 -0
- package/dist/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.d.ts.map +1 -0
- package/dist/components/QuoteWarningsAndErrors/index.d.ts +2 -0
- package/dist/components/QuoteWarningsAndErrors/index.d.ts.map +1 -0
- package/dist/components/Slippage/Slippage.d.ts.map +1 -1
- package/dist/components/Slippage/Slippage.styles.d.ts +158 -0
- package/dist/components/Slippage/Slippage.styles.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.Placeholder.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.helpers.d.ts +1 -1
- package/dist/components/SwapDetails/SwapDetails.helpers.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.styles.d.ts +628 -0
- package/dist/components/SwapDetails/SwapDetails.styles.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsCompleteModal.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.WalletState.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.helpers.d.ts +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.helpers.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts.map +1 -1
- package/dist/components/SwapsGroup/SwapsGroup.d.ts.map +1 -1
- package/dist/components/SwapsGroup/SwapsGroup.styles.d.ts +157 -0
- package/dist/components/SwapsGroup/SwapsGroup.styles.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.helpers.d.ts +2 -2
- package/dist/components/TokenList/TokenList.helpers.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.styles.d.ts +1100 -1
- package/dist/components/TokenList/TokenList.styles.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.types.d.ts +4 -9
- package/dist/components/TokenList/TokenList.types.d.ts.map +1 -1
- package/dist/components/TokenList/index.d.ts +0 -1
- package/dist/components/TokenList/index.d.ts.map +1 -1
- package/dist/components/UpdateUrl.d.ts +1 -6
- package/dist/components/UpdateUrl.d.ts.map +1 -1
- package/dist/components/WidgetEvents.d.ts.map +1 -1
- package/dist/constants/errors.d.ts +4 -4
- package/dist/constants/errors.d.ts.map +1 -1
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/constants/messages.d.ts +1 -1
- package/dist/constants/navigationRoutes.d.ts +1 -2
- package/dist/constants/navigationRoutes.d.ts.map +1 -1
- package/dist/constants/searchParams.d.ts +2 -1
- package/dist/constants/searchParams.d.ts.map +1 -1
- package/dist/constants/warnings.d.ts +2 -2
- package/dist/constants/warnings.d.ts.map +1 -1
- package/dist/containers/App/App.d.ts +3 -0
- package/dist/containers/App/App.d.ts.map +1 -0
- package/dist/containers/App/App.styles.d.ts +158 -0
- package/dist/containers/App/App.styles.d.ts.map +1 -0
- package/dist/containers/App/index.d.ts +2 -0
- package/dist/containers/App/index.d.ts.map +1 -0
- package/dist/containers/QuoteInfo/QuoteInfo.d.ts +4 -0
- package/dist/containers/QuoteInfo/QuoteInfo.d.ts.map +1 -0
- package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts +788 -0
- package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts.map +1 -0
- package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts +20 -0
- package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts.map +1 -0
- package/dist/containers/QuoteInfo/index.d.ts +2 -0
- package/dist/containers/QuoteInfo/index.d.ts.map +1 -0
- package/dist/containers/Wallets/Wallets.d.ts +6 -0
- package/dist/containers/Wallets/Wallets.d.ts.map +1 -0
- package/dist/containers/Wallets/Wallets.types.d.ts +11 -0
- package/dist/containers/Wallets/Wallets.types.d.ts.map +1 -0
- package/dist/containers/Wallets/index.d.ts +2 -0
- package/dist/containers/Wallets/index.d.ts.map +1 -0
- package/dist/containers/Widget/Widget.d.ts +5 -0
- package/dist/containers/Widget/Widget.d.ts.map +1 -0
- package/dist/containers/Widget/Widget.types.d.ts +5 -0
- package/dist/containers/Widget/Widget.types.d.ts.map +1 -0
- package/dist/containers/Widget/index.d.ts +3 -0
- package/dist/containers/Widget/index.d.ts.map +1 -0
- package/dist/containers/WidgetInfo/WidgetInfo.d.ts +6 -0
- package/dist/containers/WidgetInfo/WidgetInfo.d.ts.map +1 -0
- package/dist/containers/WidgetInfo/WidgetInfo.helpers.d.ts +20 -0
- package/dist/containers/WidgetInfo/WidgetInfo.helpers.d.ts.map +1 -0
- package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts +21 -0
- package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts.map +1 -0
- package/dist/containers/WidgetInfo/index.d.ts +2 -0
- package/dist/containers/WidgetInfo/index.d.ts.map +1 -0
- package/dist/containers/WidgetProvider/WidgetProvider.d.ts +5 -0
- package/dist/containers/WidgetProvider/WidgetProvider.d.ts.map +1 -0
- package/dist/containers/WidgetProvider/WidgetProvider.types.d.ts +7 -0
- package/dist/containers/WidgetProvider/WidgetProvider.types.d.ts.map +1 -0
- package/dist/containers/WidgetProvider/index.d.ts +2 -0
- package/dist/containers/WidgetProvider/index.d.ts.map +1 -0
- package/dist/hooks/useConfirmSwap/index.d.ts +2 -0
- package/dist/hooks/useConfirmSwap/index.d.ts.map +1 -0
- package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts +3 -0
- package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts.map +1 -0
- package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts +19 -0
- package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts.map +1 -0
- package/dist/hooks/{useConfirmSwap.d.ts → useConfirmSwap/useConfirmSwap.types.d.ts} +5 -7
- package/dist/hooks/useConfirmSwap/useConfirmSwap.types.d.ts.map +1 -0
- package/dist/hooks/{useFetchBestRoute.d.ts → useFetchQuote.d.ts} +3 -3
- package/dist/hooks/useFetchQuote.d.ts.map +1 -0
- package/dist/hooks/useForceAutoConnect.d.ts +2 -0
- package/dist/hooks/useForceAutoConnect.d.ts.map +1 -0
- package/dist/hooks/useLanguage.d.ts +1 -1
- package/dist/hooks/useLanguage.d.ts.map +1 -1
- package/dist/hooks/useNavigateBack.d.ts +1 -3
- package/dist/hooks/useNavigateBack.d.ts.map +1 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.constants.d.ts +1 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.d.ts +2 -2
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.d.ts.map +1 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.d.ts +5 -7
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.d.ts.map +1 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.d.ts +1 -0
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.d.ts.map +1 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.types.d.ts +5 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.types.d.ts.map +1 -1
- package/dist/hooks/useSwapInput.d.ts +4 -2
- package/dist/hooks/useSwapInput.d.ts.map +1 -1
- package/dist/hooks/useSyncStoresWithConfig.d.ts +1 -2
- package/dist/hooks/useSyncStoresWithConfig.d.ts.map +1 -1
- package/dist/hooks/useTheme.d.ts +1 -1
- package/dist/hooks/useTheme.d.ts.map +1 -1
- package/dist/hooks/useWalletList.d.ts.map +1 -1
- package/dist/index.d.ts +20 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/dist/pages/ConfirmSwapPage.d.ts +1 -6
- package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
- package/dist/pages/HistoryPage.d.ts.map +1 -1
- package/dist/pages/Home.d.ts.map +1 -1
- package/dist/pages/LanguagePage.d.ts.map +1 -1
- package/dist/pages/LiquiditySourcePage.d.ts +1 -2
- package/dist/pages/LiquiditySourcePage.d.ts.map +1 -1
- package/dist/pages/SelectBlockchainPage.d.ts.map +1 -1
- package/dist/pages/SelectSwapItemsPage.d.ts.map +1 -1
- package/dist/pages/SettingsPage.d.ts +1 -6
- package/dist/pages/SettingsPage.d.ts.map +1 -1
- package/dist/pages/SwapDetailsPage.d.ts.map +1 -1
- package/dist/pages/ThemePage.d.ts.map +1 -1
- package/dist/pages/WalletsPage.d.ts +1 -8
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/store/AppStore.d.ts +47 -0
- package/dist/store/AppStore.d.ts.map +1 -0
- package/dist/store/app.d.ts +41 -22
- package/dist/store/app.d.ts.map +1 -1
- package/dist/store/notification.d.ts +4 -3
- package/dist/store/notification.d.ts.map +1 -1
- package/dist/store/quote.d.ts +89 -0
- package/dist/store/quote.d.ts.map +1 -0
- package/dist/store/slices/config.d.ts +3 -2
- package/dist/store/slices/config.d.ts.map +1 -1
- package/dist/store/slices/data.d.ts +5 -2
- package/dist/store/slices/data.d.ts.map +1 -1
- package/dist/store/slices/settings.d.ts +39 -0
- package/dist/store/slices/settings.d.ts.map +1 -0
- package/dist/store/ui.d.ts +2 -1
- package/dist/store/ui.d.ts.map +1 -1
- package/dist/store/wallets.d.ts +14 -9
- package/dist/store/wallets.d.ts.map +1 -1
- package/dist/types/config.d.ts +41 -8
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/quote.d.ts +82 -0
- package/dist/types/quote.d.ts.map +1 -0
- package/dist/types/swap.d.ts +4 -14
- package/dist/types/swap.d.ts.map +1 -1
- package/dist/types/wallets.d.ts +15 -1
- package/dist/types/wallets.d.ts.map +1 -1
- package/dist/utils/colors.d.ts.map +1 -1
- package/dist/utils/configs.d.ts +1 -0
- package/dist/utils/configs.d.ts.map +1 -1
- package/dist/utils/meta.d.ts +2 -1
- package/dist/utils/meta.d.ts.map +1 -1
- package/dist/utils/numbers.d.ts +1 -1
- package/dist/utils/numbers.d.ts.map +1 -1
- package/dist/utils/providers.d.ts +2 -2
- package/dist/utils/providers.d.ts.map +1 -1
- package/dist/utils/queue.d.ts +2 -2
- package/dist/utils/queue.d.ts.map +1 -1
- package/dist/utils/quote.d.ts +32 -0
- package/dist/utils/quote.d.ts.map +1 -0
- package/dist/utils/settings.d.ts +6 -2
- package/dist/utils/settings.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +35 -24
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/utils/time.d.ts +1 -1
- package/dist/utils/time.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +9 -10
- package/dist/utils/wallets.d.ts.map +1 -1
- package/package.json +13 -11
- package/src/QueueManager.tsx +18 -17
- package/src/components/AppRouter.tsx +8 -32
- package/src/components/AppRoutes.tsx +57 -69
- package/src/components/BlockchainList/BlockchainList.styles.ts +2 -2
- package/src/components/BlockchainList/BlockchainList.tsx +4 -4
- package/src/components/BlockchainsSection/BlockchainsSection.styles.ts +1 -1
- package/src/components/BlockchainsSection/BlockchainsSection.tsx +26 -17
- package/src/components/ConfirmWalletsModal/ConfirmWallets.helpers.ts +2 -64
- package/src/components/ConfirmWalletsModal/ConfirmWallets.styles.ts +29 -10
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +43 -47
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.types.ts +1 -3
- package/src/components/ConfirmWalletsModal/WalletList.tsx +9 -8
- package/src/components/ConfirmWalletsModal/WalletList.type.ts +1 -4
- package/src/components/HeaderButtons/HomeButtons.tsx +28 -18
- package/src/components/Layout/Layout.styles.ts +2 -0
- package/src/components/Layout/Layout.tsx +20 -7
- package/src/components/Layout/Layout.types.ts +2 -2
- package/src/components/LoadingSwapDetails/LoadingSwapDetails.styles.ts +65 -61
- package/src/components/LoadingSwapDetails/LoadingSwapDetails.tsx +28 -34
- package/src/components/{NoRoutes/NoRoutes.helper.ts → NoResult/NoResult.helpers.ts} +23 -16
- package/src/components/{NoRoutes/NoRoutes.styles.ts → NoResult/NoResult.styles.ts} +2 -0
- package/src/components/{NoRoutes/NoRoutes.tsx → NoResult/NoResult.tsx} +12 -17
- package/src/components/{NoRoutes/NoRoutes.types.ts → NoResult/NoResult.types.ts} +3 -2
- package/src/components/NoResult/index.ts +1 -0
- package/src/components/NotificationContent/NotificationContent.tsx +5 -3
- package/src/components/Quote/Quote.styles.ts +249 -0
- package/src/components/Quote/Quote.tsx +414 -0
- package/src/components/Quote/Quote.types.ts +15 -0
- package/src/components/Quote/QuoteSummary.styles.ts +16 -0
- package/src/components/Quote/QuoteSummary.tsx +46 -0
- package/src/components/Quote/index.ts +2 -0
- package/src/components/QuoteSkeleton/QuoteSkeleton.styles.ts +42 -0
- package/src/components/QuoteSkeleton/QuoteSkeleton.tsx +30 -0
- package/src/components/QuoteSkeleton/QuoteSkeleton.types.ts +5 -0
- package/src/components/QuoteSkeleton/QuoteSummarySkeleton.styles.ts +57 -0
- package/src/components/QuoteSkeleton/QuoteSummarySkeleton.tsx +76 -0
- package/src/components/QuoteSkeleton/QuoteSummarySkeleton.types.ts +6 -0
- package/src/components/QuoteSkeleton/StepSkeleton.styles.ts +33 -0
- package/src/components/QuoteSkeleton/StepSkeleton.tsx +44 -0
- package/src/components/QuoteSkeleton/StepSkeleton.types.ts +1 -0
- package/src/components/QuoteSkeleton/index.ts +3 -0
- package/src/components/QuoteWarningsAndErrors/HighValueLossWarningModal.tsx +107 -0
- package/src/components/{RouteErrors/RouteErrorsModalItem.tsx → QuoteWarningsAndErrors/QuoteErrorsModalItem.tsx} +4 -4
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.ts +74 -0
- package/src/components/{RouteErrors/RouteErrors.styles.ts → QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.ts} +8 -1
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.tsx +103 -0
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.ts +25 -0
- package/src/components/QuoteWarningsAndErrors/SlippageWariningModal.tsx +77 -0
- package/src/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.tsx +38 -0
- package/src/components/QuoteWarningsAndErrors/index.ts +1 -0
- package/src/components/Slippage/Slippage.styles.ts +15 -5
- package/src/components/Slippage/Slippage.tsx +11 -10
- package/src/components/SwapDetails/SwapDetails.Placeholder.tsx +5 -8
- package/src/components/SwapDetails/SwapDetails.helpers.tsx +1 -1
- package/src/components/SwapDetails/SwapDetails.styles.ts +36 -33
- package/src/components/SwapDetails/SwapDetails.tsx +41 -56
- package/src/components/SwapDetailsAlerts/SwapDetailsAlerts.Warning.tsx +1 -1
- package/src/components/SwapDetailsModal/SwapDetailsCompleteModal.tsx +4 -3
- package/src/components/SwapDetailsModal/SwapDetailsModal.Cancel.tsx +2 -2
- package/src/components/SwapDetailsModal/SwapDetailsModal.WalletState.tsx +14 -8
- package/src/components/SwapDetailsModal/SwapDetailsModal.helpers.tsx +1 -1
- package/src/components/SwapDetailsModal/SwapDetailsModal.tsx +1 -1
- package/src/components/SwapDetailsModal/SwapDetailsModal.types.ts +1 -1
- package/src/components/SwapsGroup/SwapsGroup.styles.ts +10 -1
- package/src/components/SwapsGroup/SwapsGroup.tsx +3 -5
- package/src/components/SwitchFromAndTo.tsx +2 -2
- package/src/components/TokenList/TokenList.helpers.ts +2 -2
- package/src/components/TokenList/TokenList.styles.ts +74 -38
- package/src/components/TokenList/TokenList.tsx +35 -26
- package/src/components/TokenList/TokenList.types.ts +4 -10
- package/src/components/TokenList/index.ts +0 -1
- package/src/components/UpdateUrl.tsx +35 -30
- package/src/components/WidgetEvents.tsx +4 -2
- package/src/constants/errors.ts +17 -15
- package/src/constants/index.ts +1 -0
- package/src/constants/messages.ts +1 -1
- package/src/constants/navigationRoutes.ts +7 -8
- package/src/constants/searchParams.ts +1 -0
- package/src/constants/warnings.ts +7 -7
- package/src/containers/App/App.styles.ts +18 -0
- package/src/containers/App/App.tsx +52 -0
- package/src/containers/App/index.ts +1 -0
- package/src/containers/QuoteInfo/QuoteInfo.styles.ts +31 -0
- package/src/containers/QuoteInfo/QuoteInfo.tsx +99 -0
- package/src/containers/QuoteInfo/QuoteInfo.types.ts +20 -0
- package/src/containers/QuoteInfo/index.ts +1 -0
- package/src/{Wallets.tsx → containers/Wallets/Wallets.tsx} +48 -34
- package/src/containers/Wallets/Wallets.types.ts +12 -0
- package/src/containers/Wallets/index.ts +1 -0
- package/src/containers/Widget/Widget.tsx +19 -0
- package/src/containers/Widget/Widget.types.ts +5 -0
- package/src/containers/Widget/index.ts +2 -0
- package/src/containers/WidgetInfo/WidgetInfo.helpers.ts +64 -0
- package/src/containers/WidgetInfo/WidgetInfo.tsx +62 -0
- package/src/containers/WidgetInfo/WidgetInfo.types.ts +21 -0
- package/src/containers/WidgetInfo/index.ts +1 -0
- package/src/containers/WidgetProvider/WidgetProvider.tsx +28 -0
- package/src/containers/WidgetProvider/WidgetProvider.types.ts +7 -0
- package/src/containers/WidgetProvider/index.ts +1 -0
- package/src/hooks/useConfirmSwap/index.ts +1 -0
- package/src/hooks/useConfirmSwap/useConfirmSwap.helpers.ts +172 -0
- package/src/hooks/useConfirmSwap/useConfirmSwap.ts +137 -0
- package/src/hooks/useConfirmSwap/useConfirmSwap.types.ts +19 -0
- package/src/hooks/{useFetchBestRoute.ts → useFetchQuote.ts} +3 -3
- package/src/hooks/useForceAutoConnect.ts +27 -0
- package/src/hooks/useLanguage.ts +4 -5
- package/src/hooks/useNavigateBack.ts +3 -52
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.constants.ts +1 -1
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.ts +37 -7
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.ts +60 -0
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.test.ts +78 -3
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.ts +15 -6
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.types.ts +6 -1
- package/src/hooks/useSwapInput.ts +141 -48
- package/src/hooks/useSyncStoresWithConfig.ts +40 -24
- package/src/hooks/useTheme.ts +4 -5
- package/src/hooks/useWalletList.ts +3 -5
- package/src/index.ts +53 -5
- package/src/pages/ConfirmSwapPage.tsx +117 -266
- package/src/pages/HistoryPage.tsx +2 -7
- package/src/pages/Home.tsx +88 -303
- package/src/pages/LanguagePage.tsx +0 -5
- package/src/pages/LiquiditySourcePage.tsx +24 -37
- package/src/pages/SelectBlockchainPage.tsx +31 -24
- package/src/pages/SelectSwapItemsPage.tsx +18 -31
- package/src/pages/SettingsPage.tsx +32 -27
- package/src/pages/SwapDetailsPage.tsx +6 -7
- package/src/pages/ThemePage.tsx +2 -7
- package/src/pages/WalletsPage.tsx +9 -19
- package/src/services/httpService.ts +1 -1
- package/src/store/AppStore.tsx +41 -0
- package/src/store/app.ts +44 -6
- package/src/store/{bestRoute.ts → quote.ts} +71 -64
- package/src/store/slices/config.ts +26 -15
- package/src/store/slices/data.ts +74 -35
- package/src/store/slices/settings.ts +168 -0
- package/src/store/wallets.ts +68 -37
- package/src/types/config.ts +53 -8
- package/src/types/index.ts +1 -1
- package/src/types/quote.ts +107 -0
- package/src/types/swap.ts +4 -13
- package/src/types/wallets.ts +18 -1
- package/src/utils/colors.ts +2 -1
- package/src/utils/configs.ts +2 -1
- package/src/utils/date.ts +1 -1
- package/src/utils/meta.ts +8 -1
- package/src/utils/numbers.ts +1 -1
- package/src/utils/providers.ts +8 -5
- package/src/utils/queue.ts +2 -2
- package/src/utils/quote.ts +338 -0
- package/src/utils/settings.ts +17 -10
- package/src/utils/swap.ts +154 -120
- package/src/utils/time.ts +1 -1
- package/src/utils/wallets.ts +156 -161
- package/dist/Wallets.d.ts +0 -17
- package/dist/Wallets.d.ts.map +0 -1
- package/dist/Widget.d.ts +0 -9
- package/dist/Widget.d.ts.map +0 -1
- package/dist/components/LoadingSwapDetails/LoadingSwapDetailStep.d.ts +0 -4
- package/dist/components/LoadingSwapDetails/LoadingSwapDetailStep.d.ts.map +0 -1
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.types.d.ts +0 -4
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.types.d.ts.map +0 -1
- package/dist/components/NoRoutes/NoRoutes.d.ts +0 -4
- package/dist/components/NoRoutes/NoRoutes.d.ts.map +0 -1
- package/dist/components/NoRoutes/NoRoutes.helper.d.ts +0 -3
- package/dist/components/NoRoutes/NoRoutes.helper.d.ts.map +0 -1
- package/dist/components/NoRoutes/NoRoutes.types.d.ts.map +0 -1
- package/dist/components/NoRoutes/index.d.ts +0 -2
- package/dist/components/NoRoutes/index.d.ts.map +0 -1
- package/dist/components/RouteErrors/RouteErrors.d.ts +0 -4
- package/dist/components/RouteErrors/RouteErrors.d.ts.map +0 -1
- package/dist/components/RouteErrors/RouteErrors.styles.d.ts.map +0 -1
- package/dist/components/RouteErrors/RouteErrors.types.d.ts +0 -24
- package/dist/components/RouteErrors/RouteErrors.types.d.ts.map +0 -1
- package/dist/components/RouteErrors/RouteErrorsModal.d.ts +0 -4
- package/dist/components/RouteErrors/RouteErrorsModal.d.ts.map +0 -1
- package/dist/components/RouteErrors/RouteErrorsModalItem.d.ts +0 -4
- package/dist/components/RouteErrors/RouteErrorsModalItem.d.ts.map +0 -1
- package/dist/components/RouteErrors/index.d.ts +0 -2
- package/dist/components/RouteErrors/index.d.ts.map +0 -1
- package/dist/hooks/useConfirmSwap.d.ts.map +0 -1
- package/dist/hooks/useFetchBestRoute.d.ts.map +0 -1
- package/dist/store/bestRoute.d.ts +0 -77
- package/dist/store/bestRoute.d.ts.map +0 -1
- package/dist/store/meta.d.ts +0 -23
- package/dist/store/meta.d.ts.map +0 -1
- package/dist/store/settings.d.ts +0 -81
- package/dist/store/settings.d.ts.map +0 -1
- package/dist/types/routing.d.ts +0 -65
- package/dist/types/routing.d.ts.map +0 -1
- package/dist/utils/routing.d.ts +0 -28
- package/dist/utils/routing.d.ts.map +0 -1
- package/src/Widget.tsx +0 -119
- package/src/components/LoadingSwapDetails/LoadingSwapDetailStep.tsx +0 -41
- package/src/components/LoadingSwapDetails/LoadingSwapDetails.types.ts +0 -3
- package/src/components/NoRoutes/index.ts +0 -1
- package/src/components/RouteErrors/RouteErrors.tsx +0 -79
- package/src/components/RouteErrors/RouteErrors.types.ts +0 -29
- package/src/components/RouteErrors/RouteErrorsModal.tsx +0 -129
- package/src/components/RouteErrors/index.ts +0 -1
- package/src/hooks/useConfirmSwap.ts +0 -303
- package/src/store/meta.ts +0 -39
- package/src/store/settings.ts +0 -158
- package/src/types/routing.ts +0 -77
- package/src/utils/routing.ts +0 -321
|
@@ -1,303 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-magic-numbers */
|
|
2
|
-
import type {
|
|
3
|
-
ConfirmSwapError,
|
|
4
|
-
ConfirmSwapWarnings,
|
|
5
|
-
PendingSwapSettings,
|
|
6
|
-
Wallet,
|
|
7
|
-
} from '../types';
|
|
8
|
-
import type { PendingSwap } from '@rango-dev/queue-manager-rango-preset';
|
|
9
|
-
import type { BestRouteResponse } from 'rango-sdk';
|
|
10
|
-
|
|
11
|
-
import { calculatePendingSwap } from '@rango-dev/queue-manager-rango-preset';
|
|
12
|
-
import BigNumber from 'bignumber.js';
|
|
13
|
-
import { useEffect } from 'react';
|
|
14
|
-
|
|
15
|
-
import { errorMessages } from '../constants/errors';
|
|
16
|
-
import { HIGH_SLIPPAGE } from '../constants/swapSettings';
|
|
17
|
-
import { useBestRouteStore } from '../store/bestRoute';
|
|
18
|
-
import { useMetaStore } from '../store/meta';
|
|
19
|
-
import { useSettingsStore } from '../store/settings';
|
|
20
|
-
import { useWalletsStore } from '../store/wallets';
|
|
21
|
-
import {
|
|
22
|
-
ConfirmSwapErrorTypes,
|
|
23
|
-
RouteWarningType,
|
|
24
|
-
SlippageWarningType,
|
|
25
|
-
} from '../types';
|
|
26
|
-
import { numberToString } from '../utils/numbers';
|
|
27
|
-
import {
|
|
28
|
-
isNumberOfSwapsChanged,
|
|
29
|
-
isRouteChanged,
|
|
30
|
-
isRouteInternalCoinsUpdated,
|
|
31
|
-
isRouteSwappersUpdated,
|
|
32
|
-
} from '../utils/routing';
|
|
33
|
-
import {
|
|
34
|
-
createBestRouteRequestBody,
|
|
35
|
-
getBalanceWarnings,
|
|
36
|
-
getMinRequiredSlippage,
|
|
37
|
-
getOutputRatio,
|
|
38
|
-
getPercentageChange,
|
|
39
|
-
getRouteOutputAmount,
|
|
40
|
-
getWalletsForNewSwap,
|
|
41
|
-
hasProperSlippage,
|
|
42
|
-
isOutputAmountChangedALot,
|
|
43
|
-
outputRatioHasWarning,
|
|
44
|
-
} from '../utils/swap';
|
|
45
|
-
|
|
46
|
-
import { useFetchBestRoute } from './useFetchBestRoute';
|
|
47
|
-
|
|
48
|
-
export type ConfirmSwapFetchResult = {
|
|
49
|
-
swap: PendingSwap | null;
|
|
50
|
-
error: ConfirmSwapError | null;
|
|
51
|
-
warnings: ConfirmSwapWarnings | null;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export type ConfirmSwap = {
|
|
55
|
-
loading: boolean;
|
|
56
|
-
fetch: (params: Params) => Promise<ConfirmSwapFetchResult>;
|
|
57
|
-
cancelFetch: () => void;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
type Params = {
|
|
61
|
-
selectedWallets: Wallet[];
|
|
62
|
-
customDestination?: string;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* A request can be successful but in body of the response, it can be some case which is considered as failed.
|
|
67
|
-
*/
|
|
68
|
-
function throwErrorIfResponseIsNotValid(
|
|
69
|
-
response: BestRouteResponse,
|
|
70
|
-
params: { inputUsdValue: BigNumber | null; outputUsdValue: number | null }
|
|
71
|
-
) {
|
|
72
|
-
if (!response.result) {
|
|
73
|
-
throw new Error(errorMessages().noRoutesError.title, {
|
|
74
|
-
cause: {
|
|
75
|
-
type: ConfirmSwapErrorTypes.NO_ROUTE,
|
|
76
|
-
diagnosisMessage: response.diagnosisMessages?.[0],
|
|
77
|
-
},
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const newRouteOutputUsdValue = new BigNumber(
|
|
82
|
-
response.result?.outputAmount || '0'
|
|
83
|
-
).multipliedBy(params.outputUsdValue || 0);
|
|
84
|
-
|
|
85
|
-
const outputRatio = getOutputRatio(
|
|
86
|
-
params.inputUsdValue,
|
|
87
|
-
newRouteOutputUsdValue
|
|
88
|
-
);
|
|
89
|
-
const highValueLoss = outputRatioHasWarning(
|
|
90
|
-
params.inputUsdValue,
|
|
91
|
-
outputRatio
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
if (highValueLoss) {
|
|
95
|
-
throw new Error('High value loss for route', {
|
|
96
|
-
cause: {
|
|
97
|
-
type: ConfirmSwapErrorTypes.ROUTE_UPDATED_WITH_HIGH_VALUE_LOSS,
|
|
98
|
-
},
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return response;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function generateWarnings(
|
|
106
|
-
previousRoute: BestRouteResponse,
|
|
107
|
-
currentRoute: BestRouteResponse,
|
|
108
|
-
params: {
|
|
109
|
-
selectedWallets: Wallet[];
|
|
110
|
-
userSlippage: number;
|
|
111
|
-
}
|
|
112
|
-
): ConfirmSwapWarnings {
|
|
113
|
-
const routeChanged = isRouteChanged(previousRoute, currentRoute);
|
|
114
|
-
const output: ConfirmSwapWarnings = {
|
|
115
|
-
balance: null,
|
|
116
|
-
route: null,
|
|
117
|
-
slippage: null,
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
if (routeChanged) {
|
|
121
|
-
if (isOutputAmountChangedALot(previousRoute, currentRoute)) {
|
|
122
|
-
output.route = {
|
|
123
|
-
type: RouteWarningType.ROUTE_AND_OUTPUT_AMOUNT_UPDATED,
|
|
124
|
-
newOutputAmount: numberToString(getRouteOutputAmount(currentRoute)),
|
|
125
|
-
percentageChange: numberToString(
|
|
126
|
-
getPercentageChange(
|
|
127
|
-
getRouteOutputAmount(previousRoute),
|
|
128
|
-
getRouteOutputAmount(currentRoute)
|
|
129
|
-
),
|
|
130
|
-
null,
|
|
131
|
-
2
|
|
132
|
-
),
|
|
133
|
-
};
|
|
134
|
-
} else if (isNumberOfSwapsChanged(previousRoute, currentRoute)) {
|
|
135
|
-
output.route = {
|
|
136
|
-
type: RouteWarningType.ROUTE_UPDATED,
|
|
137
|
-
};
|
|
138
|
-
} else if (isRouteSwappersUpdated(previousRoute, currentRoute)) {
|
|
139
|
-
output.route = {
|
|
140
|
-
type: RouteWarningType.ROUTE_SWAPPERS_UPDATED,
|
|
141
|
-
};
|
|
142
|
-
} else if (isRouteInternalCoinsUpdated(previousRoute, currentRoute)) {
|
|
143
|
-
output.route = {
|
|
144
|
-
type: RouteWarningType.ROUTE_COINS_UPDATED,
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
const balanceWarnings = getBalanceWarnings(
|
|
150
|
-
currentRoute,
|
|
151
|
-
params.selectedWallets
|
|
152
|
-
);
|
|
153
|
-
const enoughBalance = balanceWarnings.length === 0;
|
|
154
|
-
|
|
155
|
-
if (!enoughBalance) {
|
|
156
|
-
output.balance = {
|
|
157
|
-
messages: balanceWarnings,
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
const minRequiredSlippage = getMinRequiredSlippage(previousRoute);
|
|
162
|
-
const highSlippage = params.userSlippage > HIGH_SLIPPAGE;
|
|
163
|
-
|
|
164
|
-
if (!hasProperSlippage(params.userSlippage.toString(), minRequiredSlippage)) {
|
|
165
|
-
output.slippage = {
|
|
166
|
-
type: SlippageWarningType.INSUFFICIENT_SLIPPAGE,
|
|
167
|
-
slippage: minRequiredSlippage,
|
|
168
|
-
};
|
|
169
|
-
} else if (highSlippage) {
|
|
170
|
-
output.slippage = {
|
|
171
|
-
type: SlippageWarningType.HIGH_SLIPPAGE,
|
|
172
|
-
slippage: params.userSlippage.toString(),
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
return output;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
export function useConfirmSwap(): ConfirmSwap {
|
|
180
|
-
const {
|
|
181
|
-
fromToken,
|
|
182
|
-
toToken,
|
|
183
|
-
inputAmount,
|
|
184
|
-
inputUsdValue,
|
|
185
|
-
setRoute,
|
|
186
|
-
bestRoute: initialRoute,
|
|
187
|
-
customDestination: customDestinationFromStore,
|
|
188
|
-
} = useBestRouteStore();
|
|
189
|
-
|
|
190
|
-
const {
|
|
191
|
-
slippage,
|
|
192
|
-
customSlippage,
|
|
193
|
-
affiliatePercent,
|
|
194
|
-
affiliateRef,
|
|
195
|
-
affiliateWallets,
|
|
196
|
-
disabledLiquiditySources,
|
|
197
|
-
} = useSettingsStore();
|
|
198
|
-
const { connectedWallets } = useWalletsStore();
|
|
199
|
-
|
|
200
|
-
const { meta } = useMetaStore();
|
|
201
|
-
|
|
202
|
-
const userSlippage = customSlippage || slippage;
|
|
203
|
-
|
|
204
|
-
const { fetch: fetchBestRoute, cancelFetch, loading } = useFetchBestRoute();
|
|
205
|
-
|
|
206
|
-
useEffect(() => cancelFetch, []);
|
|
207
|
-
|
|
208
|
-
const fetch: ConfirmSwap['fetch'] = async (params: Params) => {
|
|
209
|
-
const selectedWallets = params.selectedWallets;
|
|
210
|
-
const customDestination =
|
|
211
|
-
params?.customDestination ?? customDestinationFromStore;
|
|
212
|
-
|
|
213
|
-
if (!fromToken || !toToken || !inputAmount || !initialRoute) {
|
|
214
|
-
return {
|
|
215
|
-
route: null,
|
|
216
|
-
swap: null,
|
|
217
|
-
error: null,
|
|
218
|
-
warnings: null,
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
const requestBody = createBestRouteRequestBody({
|
|
223
|
-
fromToken,
|
|
224
|
-
toToken,
|
|
225
|
-
inputAmount,
|
|
226
|
-
wallets: connectedWallets,
|
|
227
|
-
selectedWallets,
|
|
228
|
-
disabledLiquiditySources,
|
|
229
|
-
slippage: userSlippage,
|
|
230
|
-
affiliateRef,
|
|
231
|
-
affiliatePercent,
|
|
232
|
-
affiliateWallets,
|
|
233
|
-
initialRoute,
|
|
234
|
-
destination: customDestination,
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
let currentRoute: BestRouteResponse;
|
|
238
|
-
try {
|
|
239
|
-
currentRoute = await fetchBestRoute(requestBody).then((response) =>
|
|
240
|
-
throwErrorIfResponseIsNotValid(response, {
|
|
241
|
-
outputUsdValue: toToken.usdPrice,
|
|
242
|
-
inputUsdValue,
|
|
243
|
-
})
|
|
244
|
-
);
|
|
245
|
-
setRoute(currentRoute);
|
|
246
|
-
} catch (error: any) {
|
|
247
|
-
if (error?.code === 'ERR_CANCELED') {
|
|
248
|
-
return {
|
|
249
|
-
swap: null,
|
|
250
|
-
error: {
|
|
251
|
-
type: ConfirmSwapErrorTypes.REQUEST_CANCELED,
|
|
252
|
-
},
|
|
253
|
-
warnings: null,
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
if (error.cause) {
|
|
258
|
-
return {
|
|
259
|
-
swap: null,
|
|
260
|
-
error: error.cause,
|
|
261
|
-
warnings: null,
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
return {
|
|
266
|
-
swap: null,
|
|
267
|
-
error: {
|
|
268
|
-
type: ConfirmSwapErrorTypes.REQUEST_FAILED,
|
|
269
|
-
},
|
|
270
|
-
warnings: null,
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
const swapSettings: PendingSwapSettings = {
|
|
275
|
-
slippage: userSlippage.toString(),
|
|
276
|
-
disabledSwappersGroups: disabledLiquiditySources,
|
|
277
|
-
};
|
|
278
|
-
const swap = calculatePendingSwap(
|
|
279
|
-
inputAmount.toString(),
|
|
280
|
-
currentRoute,
|
|
281
|
-
getWalletsForNewSwap(selectedWallets),
|
|
282
|
-
swapSettings,
|
|
283
|
-
false,
|
|
284
|
-
meta
|
|
285
|
-
);
|
|
286
|
-
|
|
287
|
-
return {
|
|
288
|
-
route: currentRoute,
|
|
289
|
-
swap,
|
|
290
|
-
error: null,
|
|
291
|
-
warnings: generateWarnings(initialRoute, currentRoute, {
|
|
292
|
-
selectedWallets,
|
|
293
|
-
userSlippage,
|
|
294
|
-
}),
|
|
295
|
-
};
|
|
296
|
-
};
|
|
297
|
-
|
|
298
|
-
return {
|
|
299
|
-
loading,
|
|
300
|
-
fetch,
|
|
301
|
-
cancelFetch,
|
|
302
|
-
};
|
|
303
|
-
}
|
package/src/store/meta.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { TokenWithBalance } from '../components/TokenList';
|
|
2
|
-
import type { MetaResponse } from 'rango-sdk';
|
|
3
|
-
|
|
4
|
-
import { create } from 'zustand';
|
|
5
|
-
|
|
6
|
-
import { useAppStore } from './app';
|
|
7
|
-
import createSelectors from './selectors';
|
|
8
|
-
|
|
9
|
-
export type LoadingStatus = 'loading' | 'success' | 'failed';
|
|
10
|
-
|
|
11
|
-
export interface MetaState {
|
|
12
|
-
meta: MetaResponse & { tokens: TokenWithBalance[] };
|
|
13
|
-
loadingStatus: LoadingStatus;
|
|
14
|
-
fetchMeta: () => Promise<void>;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const useMetaStore = createSelectors(
|
|
18
|
-
create<MetaState>()((set) => ({
|
|
19
|
-
meta: { blockchains: [], popularTokens: [], swappers: [], tokens: [] },
|
|
20
|
-
loadingStatus: 'loading',
|
|
21
|
-
fetchMeta: async () => {
|
|
22
|
-
try {
|
|
23
|
-
await useAppStore.getState().fetch();
|
|
24
|
-
|
|
25
|
-
const state = useAppStore.getState();
|
|
26
|
-
const response: MetaResponse = {
|
|
27
|
-
blockchains: state.blockchains(),
|
|
28
|
-
tokens: state.tokens(),
|
|
29
|
-
popularTokens: state._popularTokens,
|
|
30
|
-
swappers: state._swappers,
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
set({ meta: response, loadingStatus: 'success' });
|
|
34
|
-
} catch (error) {
|
|
35
|
-
set({ loadingStatus: 'failed' });
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
}))
|
|
39
|
-
);
|
package/src/store/settings.ts
DELETED
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { type Language } from '@rango-dev/ui';
|
|
2
|
-
import { create } from 'zustand';
|
|
3
|
-
import { persist, subscribeWithSelector } from 'zustand/middleware';
|
|
4
|
-
|
|
5
|
-
import { BLOCKCHAIN_LIST_SIZE } from '../constants/configs';
|
|
6
|
-
import { DEFAULT_LANGUAGE } from '../constants/languages';
|
|
7
|
-
import { DEFAULT_SLIPPAGE } from '../constants/swapSettings';
|
|
8
|
-
import { removeDuplicateFrom } from '../utils/common';
|
|
9
|
-
|
|
10
|
-
import { useMetaStore } from './meta';
|
|
11
|
-
import createSelectors from './selectors';
|
|
12
|
-
|
|
13
|
-
export type ThemeMode = 'auto' | 'dark' | 'light';
|
|
14
|
-
|
|
15
|
-
export interface SettingsState {
|
|
16
|
-
/** Keeping a history of blockchains that user has selected (in Swap process) */
|
|
17
|
-
preferredBlockchains: string[];
|
|
18
|
-
slippage: number;
|
|
19
|
-
customSlippage: number | null;
|
|
20
|
-
infiniteApprove: boolean;
|
|
21
|
-
disabledLiquiditySources: string[];
|
|
22
|
-
theme: ThemeMode;
|
|
23
|
-
language: Language;
|
|
24
|
-
affiliateRef: string | null;
|
|
25
|
-
affiliatePercent: number | null;
|
|
26
|
-
affiliateWallets: { [key: string]: string } | null;
|
|
27
|
-
|
|
28
|
-
setSlippage: (slippage: number) => void;
|
|
29
|
-
setCustomSlippage: (customSlippage: number | null) => void;
|
|
30
|
-
toggleInfiniteApprove: () => void;
|
|
31
|
-
toggleLiquiditySource: (name: string) => void;
|
|
32
|
-
setTheme: (theme: ThemeMode) => void;
|
|
33
|
-
setLanguage: (language: Language) => void;
|
|
34
|
-
toggleAllLiquiditySources: (shouldReset?: boolean) => void;
|
|
35
|
-
setAffiliateRef: (affiliateRef: string | null) => void;
|
|
36
|
-
setAffiliatePercent: (affiliatePercent: number | null) => void;
|
|
37
|
-
setAffiliateWallets: (
|
|
38
|
-
affiliateWallets: { [key: string]: string } | null
|
|
39
|
-
) => void;
|
|
40
|
-
addPreferredBlockchain: (blockchain: string) => void;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export const useSettingsStore = createSelectors(
|
|
44
|
-
create<SettingsState>()(
|
|
45
|
-
persist(
|
|
46
|
-
subscribeWithSelector((set, get) => ({
|
|
47
|
-
preferredBlockchains: [],
|
|
48
|
-
slippage: DEFAULT_SLIPPAGE,
|
|
49
|
-
customSlippage: null,
|
|
50
|
-
infiniteApprove: false,
|
|
51
|
-
affiliateRef: null,
|
|
52
|
-
affiliatePercent: null,
|
|
53
|
-
affiliateWallets: null,
|
|
54
|
-
disabledLiquiditySources: [],
|
|
55
|
-
theme: 'auto',
|
|
56
|
-
language: DEFAULT_LANGUAGE,
|
|
57
|
-
addPreferredBlockchain: (blockchain) => {
|
|
58
|
-
const currentPreferredBlockchains = get().preferredBlockchains;
|
|
59
|
-
|
|
60
|
-
const noNeedToDoAnything = currentPreferredBlockchains.find(
|
|
61
|
-
(preferredBlockchain, index) => {
|
|
62
|
-
const isSameBlockchain = preferredBlockchain === blockchain;
|
|
63
|
-
const isInVisibleList = index <= BLOCKCHAIN_LIST_SIZE - 1;
|
|
64
|
-
|
|
65
|
-
return isSameBlockchain && isInVisibleList;
|
|
66
|
-
}
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
if (noNeedToDoAnything) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const nextPreferredBlockchains: string[] =
|
|
74
|
-
currentPreferredBlockchains.filter((preferredBlockchain) => {
|
|
75
|
-
const isSameBlockchain = preferredBlockchain === blockchain;
|
|
76
|
-
|
|
77
|
-
return !isSameBlockchain;
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
set(() => ({
|
|
81
|
-
preferredBlockchains: [blockchain, ...nextPreferredBlockchains],
|
|
82
|
-
}));
|
|
83
|
-
},
|
|
84
|
-
setSlippage: (slippage) =>
|
|
85
|
-
set(() => ({
|
|
86
|
-
slippage: slippage,
|
|
87
|
-
})),
|
|
88
|
-
setCustomSlippage: (customSlippage) =>
|
|
89
|
-
set(() => ({
|
|
90
|
-
customSlippage: customSlippage,
|
|
91
|
-
})),
|
|
92
|
-
setAffiliateRef: (affiliateRef) =>
|
|
93
|
-
set(() => ({
|
|
94
|
-
affiliateRef,
|
|
95
|
-
})),
|
|
96
|
-
setAffiliatePercent: (affiliatePercent) =>
|
|
97
|
-
set(() => ({
|
|
98
|
-
affiliatePercent,
|
|
99
|
-
})),
|
|
100
|
-
|
|
101
|
-
setAffiliateWallets: (affiliateWallets) =>
|
|
102
|
-
set(() => ({
|
|
103
|
-
affiliateWallets,
|
|
104
|
-
})),
|
|
105
|
-
toggleAllLiquiditySources: (shouldReset?: boolean) =>
|
|
106
|
-
set((state) => {
|
|
107
|
-
if (shouldReset) {
|
|
108
|
-
return { disabledLiquiditySources: [] };
|
|
109
|
-
}
|
|
110
|
-
const { swappers } = useMetaStore.getState().meta;
|
|
111
|
-
const swappersGroup = removeDuplicateFrom(
|
|
112
|
-
swappers.map((swapper) => swapper.swapperGroup)
|
|
113
|
-
);
|
|
114
|
-
|
|
115
|
-
if (
|
|
116
|
-
swappersGroup.length === state.disabledLiquiditySources.length
|
|
117
|
-
) {
|
|
118
|
-
return { disabledLiquiditySources: [] };
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return {
|
|
122
|
-
disabledLiquiditySources: swappersGroup,
|
|
123
|
-
};
|
|
124
|
-
}),
|
|
125
|
-
toggleInfiniteApprove: () =>
|
|
126
|
-
set((state) => ({
|
|
127
|
-
infiniteApprove: !state.infiniteApprove,
|
|
128
|
-
})),
|
|
129
|
-
toggleLiquiditySource: (name) =>
|
|
130
|
-
set((state) => {
|
|
131
|
-
if (state.disabledLiquiditySources.includes(name)) {
|
|
132
|
-
return {
|
|
133
|
-
disabledLiquiditySources: state.disabledLiquiditySources.filter(
|
|
134
|
-
(liquiditySource) => liquiditySource != name
|
|
135
|
-
),
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
return {
|
|
139
|
-
disabledLiquiditySources:
|
|
140
|
-
state.disabledLiquiditySources.concat(name),
|
|
141
|
-
};
|
|
142
|
-
}),
|
|
143
|
-
setTheme: (theme) =>
|
|
144
|
-
set(() => ({
|
|
145
|
-
theme,
|
|
146
|
-
})),
|
|
147
|
-
setLanguage: (language) =>
|
|
148
|
-
set(() => ({
|
|
149
|
-
language,
|
|
150
|
-
})),
|
|
151
|
-
})),
|
|
152
|
-
{
|
|
153
|
-
name: 'user-settings',
|
|
154
|
-
skipHydration: true,
|
|
155
|
-
}
|
|
156
|
-
)
|
|
157
|
-
)
|
|
158
|
-
);
|
package/src/types/routing.ts
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/prefer-enum-initializers */
|
|
2
|
-
import type { RouteState } from '../store/bestRoute';
|
|
3
|
-
import type { SettingsState } from '../store/settings';
|
|
4
|
-
|
|
5
|
-
interface BestRouteStoreParams {
|
|
6
|
-
fromBlockchain?: RouteState['fromBlockchain'];
|
|
7
|
-
toBlockchain?: RouteState['toBlockchain'];
|
|
8
|
-
fromToken?: RouteState['fromToken'];
|
|
9
|
-
toToken?: RouteState['toToken'];
|
|
10
|
-
inputAmount?: RouteState['inputAmount'];
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
interface SettingsStoreParams {
|
|
14
|
-
slippage?: SettingsState['slippage'];
|
|
15
|
-
customSlippage?: SettingsState['customSlippage'];
|
|
16
|
-
disabledLiquiditySources?: SettingsState['disabledLiquiditySources'];
|
|
17
|
-
infiniteApprove?: SettingsState['infiniteApprove'];
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export type BestRouteEqualityParams =
|
|
21
|
-
| {
|
|
22
|
-
store: 'bestRoute';
|
|
23
|
-
prevState: BestRouteStoreParams;
|
|
24
|
-
currentState: BestRouteStoreParams;
|
|
25
|
-
}
|
|
26
|
-
| {
|
|
27
|
-
store: 'settings';
|
|
28
|
-
prevState: SettingsStoreParams;
|
|
29
|
-
currentState: SettingsStoreParams;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export enum ConfirmSwapErrorTypes {
|
|
33
|
-
NO_ROUTE,
|
|
34
|
-
ROUTE_UPDATED_WITH_HIGH_VALUE_LOSS,
|
|
35
|
-
REQUEST_FAILED,
|
|
36
|
-
REQUEST_CANCELED,
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export type ConfirmSwapError =
|
|
40
|
-
| {
|
|
41
|
-
type: ConfirmSwapErrorTypes.NO_ROUTE;
|
|
42
|
-
diagnosisMessage?: string;
|
|
43
|
-
}
|
|
44
|
-
| {
|
|
45
|
-
type: Exclude<ConfirmSwapErrorTypes, ConfirmSwapErrorTypes.NO_ROUTE>;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export enum RouteWarningType {
|
|
49
|
-
ROUTE_UPDATED,
|
|
50
|
-
ROUTE_SWAPPERS_UPDATED,
|
|
51
|
-
ROUTE_COINS_UPDATED,
|
|
52
|
-
ROUTE_AND_OUTPUT_AMOUNT_UPDATED,
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export type RouteWarning =
|
|
56
|
-
| {
|
|
57
|
-
type: RouteWarningType.ROUTE_AND_OUTPUT_AMOUNT_UPDATED;
|
|
58
|
-
newOutputAmount: string;
|
|
59
|
-
percentageChange: string;
|
|
60
|
-
}
|
|
61
|
-
| {
|
|
62
|
-
type: Exclude<
|
|
63
|
-
RouteWarningType,
|
|
64
|
-
RouteWarningType.ROUTE_AND_OUTPUT_AMOUNT_UPDATED
|
|
65
|
-
>;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export enum SlippageWarningType {
|
|
69
|
-
INSUFFICIENT_SLIPPAGE,
|
|
70
|
-
HIGH_SLIPPAGE,
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export type ConfirmSwapWarnings = {
|
|
74
|
-
route: RouteWarning | null;
|
|
75
|
-
balance: { messages: string[] } | null;
|
|
76
|
-
slippage: { type: SlippageWarningType; slippage: string | null } | null;
|
|
77
|
-
};
|