@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
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import type { ConfirmSwapFetchResult } from './useConfirmSwap.types';
|
|
2
|
+
import type { ConfirmSwapWarnings, Wallet } from '../../types';
|
|
3
|
+
import type { BestRouteResponse, BlockchainMeta, Token } from 'rango-sdk';
|
|
4
|
+
|
|
5
|
+
import { errorMessages } from '../../constants/errors';
|
|
6
|
+
import { QuoteErrorType, QuoteUpdateType } from '../../types';
|
|
7
|
+
import { numberToString } from '../../utils/numbers';
|
|
8
|
+
import {
|
|
9
|
+
generateQuoteWarnings,
|
|
10
|
+
getPriceImpact,
|
|
11
|
+
isNumberOfSwapsChanged,
|
|
12
|
+
isQuoteChanged,
|
|
13
|
+
isQuoteInternalCoinsUpdated,
|
|
14
|
+
isQuoteSwappersUpdated,
|
|
15
|
+
} from '../../utils/quote';
|
|
16
|
+
import {
|
|
17
|
+
checkSlippageErrors,
|
|
18
|
+
generateBalanceWarnings,
|
|
19
|
+
getLimitErrorMessage,
|
|
20
|
+
getMinRequiredSlippage,
|
|
21
|
+
getQuoteOutputAmount,
|
|
22
|
+
hasLimitError,
|
|
23
|
+
isOutputAmountChangedALot,
|
|
24
|
+
} from '../../utils/swap';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* A request can be successful but in body of the response, it can be some case which is considered as failed.
|
|
28
|
+
*/
|
|
29
|
+
export function throwErrorIfResponseIsNotValid(response: BestRouteResponse) {
|
|
30
|
+
if (!response.result) {
|
|
31
|
+
throw new Error(errorMessages().noResultError.title, {
|
|
32
|
+
cause: {
|
|
33
|
+
type: QuoteErrorType.NO_RESULT,
|
|
34
|
+
diagnosisMessage: response.diagnosisMessages?.[0],
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
const limitError = hasLimitError(response);
|
|
39
|
+
if (limitError) {
|
|
40
|
+
const { swap, recommendation, fromAmountRangeError } =
|
|
41
|
+
getLimitErrorMessage(response);
|
|
42
|
+
|
|
43
|
+
throw new Error('bridge limit error', {
|
|
44
|
+
cause: {
|
|
45
|
+
type: QuoteErrorType.BRIDGE_LIMIT,
|
|
46
|
+
swap: swap,
|
|
47
|
+
recommendation,
|
|
48
|
+
fromAmountRangeError,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const recommendedSlippages = checkSlippageErrors(response);
|
|
54
|
+
|
|
55
|
+
if (recommendedSlippages) {
|
|
56
|
+
const minRequiredSlippage = getMinRequiredSlippage(response);
|
|
57
|
+
throw new Error('', {
|
|
58
|
+
cause: {
|
|
59
|
+
type: QuoteErrorType.INSUFFICIENT_SLIPPAGE,
|
|
60
|
+
recommendedSlippages,
|
|
61
|
+
minRequiredSlippage,
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return response;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function generateWarnings(
|
|
70
|
+
previousQuote: BestRouteResponse | undefined,
|
|
71
|
+
currentQuote: BestRouteResponse,
|
|
72
|
+
params: {
|
|
73
|
+
fromToken: Token;
|
|
74
|
+
toToken: Token;
|
|
75
|
+
meta: { blockchains: BlockchainMeta[]; tokens: Token[] };
|
|
76
|
+
selectedWallets: Wallet[];
|
|
77
|
+
userSlippage: number;
|
|
78
|
+
}
|
|
79
|
+
): ConfirmSwapWarnings {
|
|
80
|
+
let quoteChanged = false;
|
|
81
|
+
if (previousQuote) {
|
|
82
|
+
quoteChanged = isQuoteChanged(previousQuote, currentQuote);
|
|
83
|
+
}
|
|
84
|
+
const output: ConfirmSwapWarnings = {
|
|
85
|
+
quote: null,
|
|
86
|
+
quoteUpdate: null,
|
|
87
|
+
balance: null,
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const quoteWarning = generateQuoteWarnings(currentQuote, {
|
|
91
|
+
fromToken: params.fromToken,
|
|
92
|
+
toToken: params.toToken,
|
|
93
|
+
tokens: params.meta.tokens,
|
|
94
|
+
userSlippage: params.userSlippage,
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
if (quoteWarning) {
|
|
98
|
+
output.quote = quoteWarning;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (previousQuote && quoteChanged) {
|
|
102
|
+
if (isOutputAmountChangedALot(previousQuote, currentQuote)) {
|
|
103
|
+
output.quoteUpdate = {
|
|
104
|
+
type: QuoteUpdateType.QUOTE_AND_OUTPUT_AMOUNT_UPDATED,
|
|
105
|
+
newOutputAmount: numberToString(getQuoteOutputAmount(currentQuote)),
|
|
106
|
+
percentageChange: numberToString(
|
|
107
|
+
getPriceImpact(
|
|
108
|
+
getQuoteOutputAmount(previousQuote) ?? '',
|
|
109
|
+
getQuoteOutputAmount(currentQuote) ?? ''
|
|
110
|
+
),
|
|
111
|
+
null,
|
|
112
|
+
2
|
|
113
|
+
),
|
|
114
|
+
};
|
|
115
|
+
} else if (isNumberOfSwapsChanged(previousQuote, currentQuote)) {
|
|
116
|
+
output.quoteUpdate = {
|
|
117
|
+
type: QuoteUpdateType.QUOTE_UPDATED,
|
|
118
|
+
};
|
|
119
|
+
} else if (isQuoteSwappersUpdated(previousQuote, currentQuote)) {
|
|
120
|
+
output.quoteUpdate = {
|
|
121
|
+
type: QuoteUpdateType.QUOTE_SWAPPERS_UPDATED,
|
|
122
|
+
};
|
|
123
|
+
} else if (isQuoteInternalCoinsUpdated(previousQuote, currentQuote)) {
|
|
124
|
+
output.quoteUpdate = {
|
|
125
|
+
type: QuoteUpdateType.QUOTE_COINS_UPDATED,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const balanceWarnings = generateBalanceWarnings(
|
|
131
|
+
currentQuote,
|
|
132
|
+
params.selectedWallets,
|
|
133
|
+
params.meta.blockchains
|
|
134
|
+
);
|
|
135
|
+
const enoughBalance = balanceWarnings.length === 0;
|
|
136
|
+
|
|
137
|
+
if (!enoughBalance) {
|
|
138
|
+
output.balance = {
|
|
139
|
+
messages: balanceWarnings,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return output;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export function handleQuoteErrors(error: any): ConfirmSwapFetchResult {
|
|
147
|
+
if (error?.code === 'ERR_CANCELED') {
|
|
148
|
+
return {
|
|
149
|
+
swap: null,
|
|
150
|
+
error: {
|
|
151
|
+
type: QuoteErrorType.REQUEST_CANCELED,
|
|
152
|
+
},
|
|
153
|
+
warnings: null,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (error.cause) {
|
|
158
|
+
return {
|
|
159
|
+
swap: null,
|
|
160
|
+
error: error.cause,
|
|
161
|
+
warnings: null,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return {
|
|
166
|
+
swap: null,
|
|
167
|
+
error: {
|
|
168
|
+
type: QuoteErrorType.REQUEST_FAILED,
|
|
169
|
+
},
|
|
170
|
+
warnings: null,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import type { ConfirmSwap, Params } from './useConfirmSwap.types';
|
|
2
|
+
import type { PendingSwapSettings } from '../../types';
|
|
3
|
+
import type { BestRouteResponse } from 'rango-sdk';
|
|
4
|
+
|
|
5
|
+
import { calculatePendingSwap } from '@rango-dev/queue-manager-rango-preset';
|
|
6
|
+
import { useEffect } from 'react';
|
|
7
|
+
|
|
8
|
+
import { useAppStore } from '../../store/AppStore';
|
|
9
|
+
import { useQuoteStore } from '../../store/quote';
|
|
10
|
+
import { useWalletsStore } from '../../store/wallets';
|
|
11
|
+
import { isFeatureEnabled } from '../../utils/settings';
|
|
12
|
+
import { createQuoteRequestBody, getWalletsForNewSwap } from '../../utils/swap';
|
|
13
|
+
import { useFetchQuote } from '../useFetchQuote';
|
|
14
|
+
|
|
15
|
+
import {
|
|
16
|
+
generateWarnings,
|
|
17
|
+
handleQuoteErrors,
|
|
18
|
+
throwErrorIfResponseIsNotValid,
|
|
19
|
+
} from './useConfirmSwap.helpers';
|
|
20
|
+
|
|
21
|
+
export function useConfirmSwap(): ConfirmSwap {
|
|
22
|
+
const {
|
|
23
|
+
fromToken,
|
|
24
|
+
toToken,
|
|
25
|
+
inputAmount,
|
|
26
|
+
setQuote,
|
|
27
|
+
quote: initialQuote,
|
|
28
|
+
customDestination: customDestinationFromStore,
|
|
29
|
+
setQuoteWarningsConfirmed,
|
|
30
|
+
} = useQuoteStore();
|
|
31
|
+
|
|
32
|
+
const {
|
|
33
|
+
slippage,
|
|
34
|
+
customSlippage,
|
|
35
|
+
affiliatePercent,
|
|
36
|
+
affiliateRef,
|
|
37
|
+
affiliateWallets,
|
|
38
|
+
disabledLiquiditySources,
|
|
39
|
+
} = useAppStore();
|
|
40
|
+
const { connectedWallets } = useWalletsStore();
|
|
41
|
+
const blockchains = useAppStore().blockchains();
|
|
42
|
+
const tokens = useAppStore().tokens();
|
|
43
|
+
const { features } = useAppStore().config;
|
|
44
|
+
const { enableNewLiquiditySources } = useAppStore().config;
|
|
45
|
+
|
|
46
|
+
const userSlippage = customSlippage || slippage;
|
|
47
|
+
|
|
48
|
+
const { fetch: fetchQuote, cancelFetch, loading } = useFetchQuote();
|
|
49
|
+
|
|
50
|
+
useEffect(() => cancelFetch, []);
|
|
51
|
+
|
|
52
|
+
const fetch: ConfirmSwap['fetch'] = async (params: Params) => {
|
|
53
|
+
const selectedWallets = params.selectedWallets;
|
|
54
|
+
const customDestination =
|
|
55
|
+
params?.customDestination ?? customDestinationFromStore;
|
|
56
|
+
|
|
57
|
+
if (!fromToken || !toToken || !inputAmount) {
|
|
58
|
+
return {
|
|
59
|
+
quote: null,
|
|
60
|
+
swap: null,
|
|
61
|
+
error: null,
|
|
62
|
+
warnings: null,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const requestBody = createQuoteRequestBody({
|
|
67
|
+
fromToken,
|
|
68
|
+
toToken,
|
|
69
|
+
inputAmount,
|
|
70
|
+
wallets: connectedWallets,
|
|
71
|
+
selectedWallets,
|
|
72
|
+
excludeLiquiditySources: enableNewLiquiditySources,
|
|
73
|
+
disabledLiquiditySources,
|
|
74
|
+
slippage: userSlippage,
|
|
75
|
+
affiliateRef,
|
|
76
|
+
affiliatePercent,
|
|
77
|
+
affiliateWallets,
|
|
78
|
+
initialQuote: initialQuote ?? undefined,
|
|
79
|
+
destination: customDestination,
|
|
80
|
+
});
|
|
81
|
+
if (isFeatureEnabled('experimentalRoute', features)) {
|
|
82
|
+
requestBody.experimental = true;
|
|
83
|
+
}
|
|
84
|
+
let currentQuote: BestRouteResponse;
|
|
85
|
+
try {
|
|
86
|
+
currentQuote = await fetchQuote(requestBody).then((response) =>
|
|
87
|
+
throwErrorIfResponseIsNotValid(response)
|
|
88
|
+
);
|
|
89
|
+
setQuote(currentQuote);
|
|
90
|
+
} catch (error: any) {
|
|
91
|
+
const confirmSwapResult = handleQuoteErrors(error);
|
|
92
|
+
return confirmSwapResult;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const swapSettings: PendingSwapSettings = {
|
|
96
|
+
slippage: userSlippage.toString(),
|
|
97
|
+
disabledSwappersGroups: disabledLiquiditySources,
|
|
98
|
+
};
|
|
99
|
+
const swap = calculatePendingSwap(
|
|
100
|
+
inputAmount.toString(),
|
|
101
|
+
currentQuote,
|
|
102
|
+
getWalletsForNewSwap(selectedWallets),
|
|
103
|
+
swapSettings,
|
|
104
|
+
false,
|
|
105
|
+
{ blockchains, tokens }
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
const confirmSwapWarnings = generateWarnings(
|
|
109
|
+
initialQuote ?? undefined,
|
|
110
|
+
currentQuote,
|
|
111
|
+
{
|
|
112
|
+
fromToken,
|
|
113
|
+
toToken,
|
|
114
|
+
meta: { blockchains, tokens },
|
|
115
|
+
selectedWallets,
|
|
116
|
+
userSlippage,
|
|
117
|
+
}
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
if (confirmSwapWarnings.quoteUpdate) {
|
|
121
|
+
setQuoteWarningsConfirmed(false);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return {
|
|
125
|
+
quote: currentQuote,
|
|
126
|
+
swap,
|
|
127
|
+
error: null,
|
|
128
|
+
warnings: confirmSwapWarnings,
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
return {
|
|
133
|
+
loading,
|
|
134
|
+
fetch,
|
|
135
|
+
cancelFetch,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ConfirmSwapWarnings, QuoteError, Wallet } from '../../types';
|
|
2
|
+
import type { PendingSwap } from 'rango-types';
|
|
3
|
+
|
|
4
|
+
export type ConfirmSwapFetchResult = {
|
|
5
|
+
swap: PendingSwap | null;
|
|
6
|
+
error: QuoteError | null;
|
|
7
|
+
warnings: ConfirmSwapWarnings | null;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type ConfirmSwap = {
|
|
11
|
+
loading: boolean;
|
|
12
|
+
fetch: (params: Params) => Promise<ConfirmSwapFetchResult>;
|
|
13
|
+
cancelFetch: () => void;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type Params = {
|
|
17
|
+
selectedWallets: Wallet[];
|
|
18
|
+
customDestination?: string;
|
|
19
|
+
};
|
|
@@ -4,18 +4,18 @@ import { useRef, useState } from 'react';
|
|
|
4
4
|
|
|
5
5
|
import { httpService } from '../services/httpService';
|
|
6
6
|
|
|
7
|
-
interface
|
|
7
|
+
interface UseFetchQuote {
|
|
8
8
|
fetch: (requestBody: BestRouteRequest) => Promise<BestRouteResponse>;
|
|
9
9
|
cancelFetch: () => void;
|
|
10
10
|
loading: boolean;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export function
|
|
13
|
+
export function useFetchQuote(): UseFetchQuote {
|
|
14
14
|
const [loading, setLoading] = useState(false);
|
|
15
15
|
const abortController = useRef<AbortController | null>(null);
|
|
16
16
|
const cancel = () => abortController.current?.abort();
|
|
17
17
|
|
|
18
|
-
const fetch:
|
|
18
|
+
const fetch: UseFetchQuote['fetch'] = async (requestBody) => {
|
|
19
19
|
cancel();
|
|
20
20
|
abortController.current = new AbortController();
|
|
21
21
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useWallets } from '@rango-dev/wallets-react';
|
|
2
|
+
import { useEffect, useRef } from 'react';
|
|
3
|
+
|
|
4
|
+
import { SearchParams } from '../constants/searchParams';
|
|
5
|
+
import { useAppStore } from '../store/AppStore';
|
|
6
|
+
|
|
7
|
+
export function useForceAutoConnect(): void {
|
|
8
|
+
const { connect, state } = useWallets();
|
|
9
|
+
const initiated = useRef<{ [key: string]: boolean }>({});
|
|
10
|
+
const { fetchStatus } = useAppStore();
|
|
11
|
+
const walletType =
|
|
12
|
+
new URLSearchParams(location.search).get(SearchParams.AUTO_CONNECT) || '';
|
|
13
|
+
const walletState = state(walletType);
|
|
14
|
+
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
const shouldTryConnect =
|
|
17
|
+
fetchStatus === 'success' &&
|
|
18
|
+
walletType &&
|
|
19
|
+
walletState.installed &&
|
|
20
|
+
!walletState.connecting &&
|
|
21
|
+
!walletState.connected;
|
|
22
|
+
if (shouldTryConnect && !initiated.current[walletType]) {
|
|
23
|
+
initiated.current[walletType] = true;
|
|
24
|
+
void connect(walletType);
|
|
25
|
+
}
|
|
26
|
+
}, [walletState, fetchStatus]);
|
|
27
|
+
}
|
package/src/hooks/useLanguage.ts
CHANGED
|
@@ -3,18 +3,17 @@ import type { LanguageItem } from '../constants/languages';
|
|
|
3
3
|
import { type Language } from '@rango-dev/ui';
|
|
4
4
|
|
|
5
5
|
import { DEFAULT_LANGUAGE, LANGUAGES } from '../constants/languages';
|
|
6
|
-
import {
|
|
6
|
+
import { useAppStore } from '../store/AppStore';
|
|
7
7
|
|
|
8
8
|
interface UseLanguage {
|
|
9
9
|
languages: LanguageItem[];
|
|
10
10
|
defaultLanguage: Language;
|
|
11
11
|
activeLanguage: Language;
|
|
12
|
-
changeLanguage: (language
|
|
12
|
+
changeLanguage: (language?: Language) => void;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export function useLanguage(): UseLanguage {
|
|
16
|
-
const language =
|
|
17
|
-
const setLanguage = useSettingsStore.use.setLanguage();
|
|
16
|
+
const { setLanguage, language } = useAppStore();
|
|
18
17
|
const languages = LANGUAGES;
|
|
19
18
|
const defaultLanguage = DEFAULT_LANGUAGE;
|
|
20
19
|
|
|
@@ -22,6 +21,6 @@ export function useLanguage(): UseLanguage {
|
|
|
22
21
|
activeLanguage: language,
|
|
23
22
|
languages,
|
|
24
23
|
defaultLanguage,
|
|
25
|
-
changeLanguage: setLanguage,
|
|
24
|
+
changeLanguage: (language) => setLanguage(language || DEFAULT_LANGUAGE),
|
|
26
25
|
};
|
|
27
26
|
}
|
|
@@ -1,55 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useNavigate } from 'react-router-dom';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
import { useBestRouteStore } from '../store/bestRoute';
|
|
5
|
-
|
|
6
|
-
export function useNavigateBack() {
|
|
7
|
-
const isRouterInContext = useInRouterContext();
|
|
3
|
+
export function useNavigateBack(): () => void {
|
|
8
4
|
const navigate = useNavigate();
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
navigationRoutes;
|
|
12
|
-
|
|
13
|
-
const navigateBackFrom = (currentRoute: string) => {
|
|
14
|
-
if (currentRoute === navigationRoutes.swapDetails) {
|
|
15
|
-
return navigate('/' + navigationRoutes.swaps, { replace: true });
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if (
|
|
19
|
-
!isRouterInContext ||
|
|
20
|
-
(window.history.state && window.history.state.idx > 0)
|
|
21
|
-
) {
|
|
22
|
-
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
23
|
-
navigate(-1);
|
|
24
|
-
} else {
|
|
25
|
-
if (
|
|
26
|
-
[navigationRoutes.settings, navigationRoutes.wallets].includes(
|
|
27
|
-
currentRoute
|
|
28
|
-
) &&
|
|
29
|
-
routeWalletsConfirmed
|
|
30
|
-
) {
|
|
31
|
-
return navigate('/' + navigationRoutes.confirmSwap, { replace: true });
|
|
32
|
-
}
|
|
33
|
-
if (
|
|
34
|
-
[
|
|
35
|
-
navigationRoutes.fromSwap,
|
|
36
|
-
navigationRoutes.toSwap,
|
|
37
|
-
navigationRoutes.settings,
|
|
38
|
-
navigationRoutes.wallets,
|
|
39
|
-
navigationRoutes.swaps,
|
|
40
|
-
navigationRoutes.confirmSwap,
|
|
41
|
-
].includes(currentRoute)
|
|
42
|
-
) {
|
|
43
|
-
navigate(navigationRoutes.home, { replace: true });
|
|
44
|
-
} else if (currentRoute === navigationRoutes.fromBlockchain) {
|
|
45
|
-
navigate('/' + navigationRoutes.fromSwap, { replace: true });
|
|
46
|
-
} else if (currentRoute === navigationRoutes.toBlockchain) {
|
|
47
|
-
navigate('/' + navigationRoutes.fromSwap, { replace: true });
|
|
48
|
-
} else if (currentRoute === navigationRoutes.liquiditySources) {
|
|
49
|
-
navigate('/' + navigationRoutes.settings, { replace: true });
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
return { navigateBackFrom };
|
|
5
|
+
return () => navigate(-1);
|
|
55
6
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const
|
|
1
|
+
export const MOST_USED_BLOCKCHAINS = ['ETH', 'COSMOS', 'OSMOSIS'];
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
PrepareListOptions,
|
|
3
|
+
PrepareOutput,
|
|
4
|
+
} from './usePrepareBlockchainList.types';
|
|
2
5
|
import type { BlockchainMeta } from 'rango-sdk';
|
|
3
6
|
|
|
4
|
-
import {
|
|
7
|
+
import { MOST_USED_BLOCKCHAINS } from './usePrepareBlockchainList.constants';
|
|
5
8
|
|
|
6
9
|
export function prepare(
|
|
7
10
|
blockchains: BlockchainMeta[],
|
|
8
11
|
preferredBlockchains: string[],
|
|
9
12
|
options?: PrepareListOptions
|
|
10
|
-
) {
|
|
13
|
+
): PrepareOutput {
|
|
11
14
|
/*
|
|
12
15
|
* TODO:
|
|
13
16
|
* We copying the `blockchains` which can causes performance penalties but we should because we are mutating the original object.
|
|
@@ -25,17 +28,37 @@ export function prepare(
|
|
|
25
28
|
let preferredBlockchainsWithoutMainList = preferredBlockchains;
|
|
26
29
|
|
|
27
30
|
if (preferredBlockchains.length <= options.limit) {
|
|
28
|
-
|
|
29
|
-
*
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* if we want to show 10 items (aka `options.limit`)
|
|
34
|
+
* and have these items as our preferred list: [x,y,z]
|
|
35
|
+
* and these as our main list: [A, B, C, D, E, F, G, H, I, J]
|
|
36
|
+
* the final list will be like this: [...preferred, ...mainList].
|
|
37
|
+
*
|
|
38
|
+
* Since we have a limit (e.g. 10) on our list (preferred + mainList),
|
|
39
|
+
* we only should check those items from main list that will be in final list.
|
|
40
|
+
*
|
|
41
|
+
* finalListWithoutLimit = [x,y,z, A, B, C, D, E, F, G, H, I, J]
|
|
42
|
+
* finalListWithLimit = [x,y,z, A, B, C, D, E, F, G]
|
|
43
|
+
*
|
|
44
|
+
* As you can see, [H, I, J] will not be in our list.
|
|
45
|
+
*
|
|
46
|
+
* The following code only check preffred blockchain
|
|
47
|
+
* shouldn't be in first 7 of 10 items in main list. (Since, the last 3 items will not be in the final list and we should check those.)
|
|
30
48
|
*/
|
|
31
|
-
|
|
49
|
+
const howManyItemsShouldBeCheckedFromMainList =
|
|
50
|
+
options.limit - preferredBlockchains.length;
|
|
51
|
+
|
|
52
|
+
for (let i = 0; i <= howManyItemsShouldBeCheckedFromMainList; i++) {
|
|
32
53
|
const blockchain = list[i];
|
|
54
|
+
|
|
33
55
|
preferredBlockchainsWithoutMainList =
|
|
34
56
|
preferredBlockchainsWithoutMainList.filter((preferredBlockchain) => {
|
|
35
57
|
return blockchain.name !== preferredBlockchain;
|
|
36
58
|
});
|
|
37
59
|
}
|
|
38
60
|
}
|
|
61
|
+
|
|
39
62
|
list.sort(
|
|
40
63
|
generateSortByPreferredBlockchainsFor(preferredBlockchainsWithoutMainList)
|
|
41
64
|
);
|
|
@@ -57,7 +80,7 @@ export function sortByMostUsedBlockchains(
|
|
|
57
80
|
a: BlockchainMeta,
|
|
58
81
|
b: BlockchainMeta
|
|
59
82
|
) {
|
|
60
|
-
const mostUsed =
|
|
83
|
+
const mostUsed = MOST_USED_BLOCKCHAINS;
|
|
61
84
|
const aIndexInMostUsed = mostUsed.findIndex((token) => token === a.name);
|
|
62
85
|
const bIndexInMostUsed = mostUsed.findIndex((token) => token === b.name);
|
|
63
86
|
const aIsMostUsed = aIndexInMostUsed > -1;
|
|
@@ -106,3 +129,10 @@ export function generateSortByPreferredBlockchainsFor(
|
|
|
106
129
|
return 0;
|
|
107
130
|
};
|
|
108
131
|
}
|
|
132
|
+
|
|
133
|
+
export function isInVisibleList(
|
|
134
|
+
blockchain: string,
|
|
135
|
+
prepareOutput: PrepareOutput
|
|
136
|
+
): boolean {
|
|
137
|
+
return !!prepareOutput.list.find((item) => item.name === blockchain);
|
|
138
|
+
}
|
|
@@ -2,6 +2,66 @@ import type { BlockchainMeta } from 'rango-sdk';
|
|
|
2
2
|
|
|
3
3
|
import { TransactionType } from 'rango-sdk';
|
|
4
4
|
|
|
5
|
+
export const sampleDefaultBlockchainNames = [
|
|
6
|
+
'ETH',
|
|
7
|
+
'COSMOS',
|
|
8
|
+
'OSMOSIS',
|
|
9
|
+
'BSC',
|
|
10
|
+
'ARBITRUM',
|
|
11
|
+
'POLYGON',
|
|
12
|
+
'ZKSYNC',
|
|
13
|
+
'STARKNET',
|
|
14
|
+
'OPTIMISM',
|
|
15
|
+
'AVAX_CCHAIN',
|
|
16
|
+
'POLYGONZK',
|
|
17
|
+
'LINEA',
|
|
18
|
+
'TRON',
|
|
19
|
+
'BTC',
|
|
20
|
+
'NEUTRON',
|
|
21
|
+
'NOBLE',
|
|
22
|
+
'SOLANA',
|
|
23
|
+
'CRONOS',
|
|
24
|
+
'BNB',
|
|
25
|
+
'AURORA',
|
|
26
|
+
'MAYA',
|
|
27
|
+
'THOR',
|
|
28
|
+
'BOBA',
|
|
29
|
+
'MOONBEAM',
|
|
30
|
+
'MOONRIVER',
|
|
31
|
+
'OKC',
|
|
32
|
+
'BOBA_AVALANCHE',
|
|
33
|
+
'LTC',
|
|
34
|
+
'BCH',
|
|
35
|
+
'HECO',
|
|
36
|
+
'STARGAZE',
|
|
37
|
+
'CRYPTO_ORG',
|
|
38
|
+
'CHIHUAHUA',
|
|
39
|
+
'BANDCHAIN',
|
|
40
|
+
'COMDEX',
|
|
41
|
+
'REGEN',
|
|
42
|
+
'IRIS',
|
|
43
|
+
'EMONEY',
|
|
44
|
+
'JUNO',
|
|
45
|
+
'STRIDE',
|
|
46
|
+
'MARS',
|
|
47
|
+
'TERRA',
|
|
48
|
+
'BITSONG',
|
|
49
|
+
'AKASH',
|
|
50
|
+
'KI',
|
|
51
|
+
'PERSISTENCE',
|
|
52
|
+
'MEDIBLOC',
|
|
53
|
+
'KUJIRA',
|
|
54
|
+
'SENTINEL',
|
|
55
|
+
'INJECTIVE',
|
|
56
|
+
'SECRET',
|
|
57
|
+
'KONSTELLATION',
|
|
58
|
+
'STARNAME',
|
|
59
|
+
'BITCANNA',
|
|
60
|
+
'UMEE',
|
|
61
|
+
'DESMOS',
|
|
62
|
+
'LUMNETWORK',
|
|
63
|
+
];
|
|
64
|
+
|
|
5
65
|
export const sampleBlockchains: BlockchainMeta[] = [
|
|
6
66
|
{
|
|
7
67
|
name: 'ETH',
|