@rango-dev/widget-embedded 0.18.0 → 0.19.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 +1 -113
- package/dist/QueueManager.d.ts +2 -5
- package/dist/QueueManager.d.ts.map +1 -1
- package/dist/Wallets.d.ts +17 -0
- package/dist/Wallets.d.ts.map +1 -0
- package/dist/Widget.d.ts +9 -0
- package/dist/Widget.d.ts.map +1 -0
- package/dist/components/AppRouter.d.ts +2 -0
- package/dist/components/AppRouter.d.ts.map +1 -1
- package/dist/components/AppRoutes.d.ts +6 -1
- 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 +3 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +62 -691
- 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 +3 -1
- 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 +4 -1
- 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/LoadingSwapDetailStep.d.ts +4 -0
- package/dist/components/LoadingSwapDetails/LoadingSwapDetailStep.d.ts.map +1 -0
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.d.ts.map +1 -1
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts +0 -1727
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts.map +1 -1
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.types.d.ts +4 -0
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.types.d.ts.map +1 -0
- package/dist/components/NoRoutes/NoRoutes.d.ts +4 -0
- package/dist/components/NoRoutes/NoRoutes.d.ts.map +1 -0
- package/dist/components/NoRoutes/NoRoutes.helper.d.ts +3 -0
- package/dist/components/NoRoutes/NoRoutes.helper.d.ts.map +1 -0
- package/dist/components/{NoResult/NoResult.styles.d.ts → NoRoutes/NoRoutes.styles.d.ts} +1 -1
- package/dist/components/{NoResult/NoResult.styles.d.ts.map → NoRoutes/NoRoutes.styles.d.ts.map} +1 -1
- package/dist/components/{NoResult/NoResult.types.d.ts → NoRoutes/NoRoutes.types.d.ts} +3 -3
- package/dist/components/NoRoutes/NoRoutes.types.d.ts.map +1 -0
- package/dist/components/NoRoutes/index.d.ts +2 -0
- package/dist/components/NoRoutes/index.d.ts.map +1 -0
- package/dist/components/NotificationContent/NotificationContent.d.ts.map +1 -1
- package/dist/components/RouteErrors/RouteErrors.d.ts +4 -0
- package/dist/components/RouteErrors/RouteErrors.d.ts.map +1 -0
- package/dist/components/{QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts → RouteErrors/RouteErrors.styles.d.ts} +1 -1
- package/dist/components/RouteErrors/RouteErrors.styles.d.ts.map +1 -0
- package/dist/components/RouteErrors/RouteErrors.types.d.ts +24 -0
- package/dist/components/RouteErrors/RouteErrors.types.d.ts.map +1 -0
- package/dist/components/RouteErrors/RouteErrorsModal.d.ts +4 -0
- package/dist/components/RouteErrors/RouteErrorsModal.d.ts.map +1 -0
- package/dist/components/RouteErrors/RouteErrorsModalItem.d.ts +4 -0
- package/dist/components/RouteErrors/RouteErrorsModalItem.d.ts.map +1 -0
- package/dist/components/RouteErrors/index.d.ts +2 -0
- package/dist/components/RouteErrors/index.d.ts.map +1 -0
- package/dist/components/Slippage/Slippage.d.ts.map +1 -1
- package/dist/components/Slippage/Slippage.styles.d.ts +0 -158
- 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 +0 -628
- 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 +0 -157
- 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 +1 -1100
- package/dist/components/TokenList/TokenList.styles.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.types.d.ts +9 -4
- package/dist/components/TokenList/TokenList.types.d.ts.map +1 -1
- package/dist/components/TokenList/index.d.ts +1 -0
- package/dist/components/TokenList/index.d.ts.map +1 -1
- package/dist/components/UpdateUrl.d.ts +6 -1
- 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 +0 -1
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/constants/messages.d.ts +1 -1
- package/dist/constants/navigationRoutes.d.ts +2 -1
- package/dist/constants/navigationRoutes.d.ts.map +1 -1
- package/dist/constants/searchParams.d.ts +1 -2
- 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/hooks/{useConfirmSwap/useConfirmSwap.types.d.ts → useConfirmSwap.d.ts} +7 -5
- package/dist/hooks/useConfirmSwap.d.ts.map +1 -0
- package/dist/hooks/{useFetchQuote.d.ts → useFetchBestRoute.d.ts} +3 -3
- package/dist/hooks/useFetchBestRoute.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 +3 -1
- 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 +7 -5
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.d.ts.map +1 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.d.ts +0 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.d.ts.map +1 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.types.d.ts +1 -5
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.types.d.ts.map +1 -1
- package/dist/hooks/useSwapInput.d.ts +2 -4
- package/dist/hooks/useSwapInput.d.ts.map +1 -1
- package/dist/hooks/useSyncStoresWithConfig.d.ts +2 -1
- 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 +8 -20
- 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 +6 -1
- 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 +2 -1
- 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 +6 -1
- 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 +8 -1
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/store/app.d.ts +22 -41
- package/dist/store/app.d.ts.map +1 -1
- package/dist/store/bestRoute.d.ts +77 -0
- package/dist/store/bestRoute.d.ts.map +1 -0
- package/dist/store/meta.d.ts +23 -0
- package/dist/store/meta.d.ts.map +1 -0
- package/dist/store/notification.d.ts +3 -4
- package/dist/store/notification.d.ts.map +1 -1
- package/dist/store/settings.d.ts +81 -0
- package/dist/store/settings.d.ts.map +1 -0
- package/dist/store/slices/config.d.ts +2 -3
- package/dist/store/slices/config.d.ts.map +1 -1
- package/dist/store/slices/data.d.ts +2 -5
- package/dist/store/slices/data.d.ts.map +1 -1
- package/dist/store/ui.d.ts +1 -2
- package/dist/store/ui.d.ts.map +1 -1
- package/dist/store/wallets.d.ts +9 -14
- package/dist/store/wallets.d.ts.map +1 -1
- package/dist/types/config.d.ts +8 -41
- 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/routing.d.ts +65 -0
- package/dist/types/routing.d.ts.map +1 -0
- package/dist/types/swap.d.ts +14 -4
- package/dist/types/swap.d.ts.map +1 -1
- package/dist/types/wallets.d.ts +1 -15
- package/dist/types/wallets.d.ts.map +1 -1
- package/dist/utils/colors.d.ts.map +1 -1
- package/dist/utils/configs.d.ts +0 -1
- package/dist/utils/configs.d.ts.map +1 -1
- package/dist/utils/meta.d.ts +1 -2
- 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/routing.d.ts +28 -0
- package/dist/utils/routing.d.ts.map +1 -0
- package/dist/utils/settings.d.ts +2 -6
- package/dist/utils/settings.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +24 -35
- 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 +10 -9
- package/dist/utils/wallets.d.ts.map +1 -1
- package/package.json +10 -12
- package/src/QueueManager.tsx +17 -18
- package/src/{containers/Wallets/Wallets.tsx → Wallets.tsx} +34 -48
- package/src/Widget.tsx +119 -0
- package/src/components/AppRouter.tsx +32 -8
- package/src/components/AppRoutes.tsx +69 -57
- 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 +17 -26
- package/src/components/ConfirmWalletsModal/ConfirmWallets.helpers.ts +64 -2
- package/src/components/ConfirmWalletsModal/ConfirmWallets.styles.ts +10 -29
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +47 -43
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.types.ts +3 -1
- package/src/components/ConfirmWalletsModal/WalletList.tsx +8 -9
- package/src/components/ConfirmWalletsModal/WalletList.type.ts +4 -1
- package/src/components/HeaderButtons/HomeButtons.tsx +18 -28
- package/src/components/Layout/Layout.styles.ts +0 -2
- package/src/components/Layout/Layout.tsx +7 -20
- package/src/components/Layout/Layout.types.ts +2 -2
- package/src/components/LoadingSwapDetails/LoadingSwapDetailStep.tsx +41 -0
- package/src/components/LoadingSwapDetails/LoadingSwapDetails.styles.ts +61 -65
- package/src/components/LoadingSwapDetails/LoadingSwapDetails.tsx +34 -28
- package/src/components/LoadingSwapDetails/LoadingSwapDetails.types.ts +3 -0
- package/src/components/{NoResult/NoResult.helpers.ts → NoRoutes/NoRoutes.helper.ts} +16 -23
- package/src/components/{NoResult/NoResult.styles.ts → NoRoutes/NoRoutes.styles.ts} +0 -2
- package/src/components/{NoResult/NoResult.tsx → NoRoutes/NoRoutes.tsx} +17 -12
- package/src/components/{NoResult/NoResult.types.ts → NoRoutes/NoRoutes.types.ts} +2 -3
- package/src/components/NoRoutes/index.ts +1 -0
- package/src/components/NotificationContent/NotificationContent.tsx +3 -5
- package/src/components/{QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.ts → RouteErrors/RouteErrors.styles.ts} +1 -8
- package/src/components/RouteErrors/RouteErrors.tsx +79 -0
- package/src/components/RouteErrors/RouteErrors.types.ts +29 -0
- package/src/components/RouteErrors/RouteErrorsModal.tsx +129 -0
- package/src/components/{QuoteWarningsAndErrors/QuoteErrorsModalItem.tsx → RouteErrors/RouteErrorsModalItem.tsx} +4 -4
- package/src/components/RouteErrors/index.ts +1 -0
- package/src/components/Slippage/Slippage.styles.ts +5 -15
- package/src/components/Slippage/Slippage.tsx +10 -11
- package/src/components/SwapDetails/SwapDetails.Placeholder.tsx +8 -5
- package/src/components/SwapDetails/SwapDetails.helpers.tsx +1 -1
- package/src/components/SwapDetails/SwapDetails.styles.ts +33 -36
- package/src/components/SwapDetails/SwapDetails.tsx +56 -41
- package/src/components/SwapDetailsAlerts/SwapDetailsAlerts.Warning.tsx +1 -1
- package/src/components/SwapDetailsModal/SwapDetailsCompleteModal.tsx +3 -4
- package/src/components/SwapDetailsModal/SwapDetailsModal.Cancel.tsx +2 -2
- package/src/components/SwapDetailsModal/SwapDetailsModal.WalletState.tsx +8 -14
- 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 +1 -10
- package/src/components/SwapsGroup/SwapsGroup.tsx +5 -3
- package/src/components/SwitchFromAndTo.tsx +2 -2
- package/src/components/TokenList/TokenList.helpers.ts +2 -2
- package/src/components/TokenList/TokenList.styles.ts +38 -74
- package/src/components/TokenList/TokenList.tsx +26 -35
- package/src/components/TokenList/TokenList.types.ts +10 -4
- package/src/components/TokenList/index.ts +1 -0
- package/src/components/UpdateUrl.tsx +30 -35
- package/src/components/WidgetEvents.tsx +2 -4
- package/src/constants/errors.ts +15 -17
- package/src/constants/index.ts +0 -1
- package/src/constants/messages.ts +1 -1
- package/src/constants/navigationRoutes.ts +8 -7
- package/src/constants/searchParams.ts +0 -1
- package/src/constants/warnings.ts +7 -7
- package/src/hooks/useConfirmSwap.ts +303 -0
- package/src/hooks/{useFetchQuote.ts → useFetchBestRoute.ts} +3 -3
- package/src/hooks/useLanguage.ts +5 -4
- package/src/hooks/useNavigateBack.ts +52 -3
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.constants.ts +1 -1
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.ts +7 -37
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.ts +0 -60
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.test.ts +3 -78
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.ts +6 -15
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.types.ts +1 -6
- package/src/hooks/useSwapInput.ts +48 -141
- package/src/hooks/useSyncStoresWithConfig.ts +24 -40
- package/src/hooks/useTheme.ts +5 -4
- package/src/hooks/useWalletList.ts +5 -3
- package/src/index.ts +5 -53
- package/src/pages/ConfirmSwapPage.tsx +266 -117
- package/src/pages/HistoryPage.tsx +7 -2
- package/src/pages/Home.tsx +303 -88
- package/src/pages/LanguagePage.tsx +5 -0
- package/src/pages/LiquiditySourcePage.tsx +37 -24
- package/src/pages/SelectBlockchainPage.tsx +24 -31
- package/src/pages/SelectSwapItemsPage.tsx +31 -18
- package/src/pages/SettingsPage.tsx +27 -32
- package/src/pages/SwapDetailsPage.tsx +7 -6
- package/src/pages/ThemePage.tsx +7 -2
- package/src/pages/WalletsPage.tsx +19 -9
- package/src/services/httpService.ts +1 -1
- package/src/store/app.ts +6 -44
- package/src/store/{quote.ts → bestRoute.ts} +64 -71
- package/src/store/meta.ts +39 -0
- package/src/store/settings.ts +158 -0
- package/src/store/slices/config.ts +15 -26
- package/src/store/slices/data.ts +35 -74
- package/src/store/wallets.ts +37 -68
- package/src/types/config.ts +8 -53
- package/src/types/index.ts +1 -1
- package/src/types/routing.ts +77 -0
- package/src/types/swap.ts +13 -4
- package/src/types/wallets.ts +1 -18
- package/src/utils/colors.ts +1 -2
- package/src/utils/configs.ts +1 -2
- package/src/utils/date.ts +1 -1
- package/src/utils/meta.ts +1 -8
- package/src/utils/numbers.ts +1 -1
- package/src/utils/providers.ts +5 -8
- package/src/utils/queue.ts +2 -2
- package/src/utils/routing.ts +321 -0
- package/src/utils/settings.ts +10 -17
- package/src/utils/swap.ts +120 -154
- package/src/utils/time.ts +1 -1
- package/src/utils/wallets.ts +161 -156
- package/dist/components/NoResult/NoResult.d.ts +0 -4
- package/dist/components/NoResult/NoResult.d.ts.map +0 -1
- package/dist/components/NoResult/NoResult.helpers.d.ts +0 -4
- package/dist/components/NoResult/NoResult.helpers.d.ts.map +0 -1
- package/dist/components/NoResult/NoResult.types.d.ts.map +0 -1
- package/dist/components/NoResult/index.d.ts +0 -2
- package/dist/components/NoResult/index.d.ts.map +0 -1
- package/dist/components/Quote/Quote.d.ts +0 -4
- package/dist/components/Quote/Quote.d.ts.map +0 -1
- package/dist/components/Quote/Quote.styles.d.ts +0 -2217
- package/dist/components/Quote/Quote.styles.d.ts.map +0 -1
- package/dist/components/Quote/Quote.types.d.ts +0 -21
- package/dist/components/Quote/Quote.types.d.ts.map +0 -1
- package/dist/components/Quote/QuoteSummary.d.ts +0 -11
- package/dist/components/Quote/QuoteSummary.d.ts.map +0 -1
- package/dist/components/Quote/QuoteSummary.styles.d.ts +0 -315
- package/dist/components/Quote/QuoteSummary.styles.d.ts.map +0 -1
- package/dist/components/Quote/index.d.ts +0 -3
- package/dist/components/Quote/index.d.ts.map +0 -1
- package/dist/components/QuoteSkeleton/QuoteSkeleton.d.ts +0 -4
- package/dist/components/QuoteSkeleton/QuoteSkeleton.d.ts.map +0 -1
- package/dist/components/QuoteSkeleton/QuoteSkeleton.styles.d.ts +0 -633
- package/dist/components/QuoteSkeleton/QuoteSkeleton.styles.d.ts.map +0 -1
- package/dist/components/QuoteSkeleton/QuoteSkeleton.types.d.ts +0 -6
- package/dist/components/QuoteSkeleton/QuoteSkeleton.types.d.ts.map +0 -1
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.d.ts +0 -4
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.d.ts.map +0 -1
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.styles.d.ts +0 -1571
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.styles.d.ts.map +0 -1
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.types.d.ts +0 -6
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.types.d.ts.map +0 -1
- package/dist/components/QuoteSkeleton/StepSkeleton.d.ts +0 -4
- package/dist/components/QuoteSkeleton/StepSkeleton.d.ts.map +0 -1
- package/dist/components/QuoteSkeleton/StepSkeleton.styles.d.ts +0 -786
- package/dist/components/QuoteSkeleton/StepSkeleton.styles.d.ts.map +0 -1
- package/dist/components/QuoteSkeleton/StepSkeleton.types.d.ts +0 -4
- package/dist/components/QuoteSkeleton/StepSkeleton.types.d.ts.map +0 -1
- package/dist/components/QuoteSkeleton/index.d.ts +0 -4
- package/dist/components/QuoteSkeleton/index.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/HighValueLossWarningModal.d.ts +0 -11
- package/dist/components/QuoteWarningsAndErrors/HighValueLossWarningModal.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteErrorsModalItem.d.ts +0 -4
- package/dist/components/QuoteWarningsAndErrors/QuoteErrorsModalItem.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.d.ts +0 -4
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts +0 -9
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts +0 -23
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/SlippageWariningModal.d.ts +0 -11
- package/dist/components/QuoteWarningsAndErrors/SlippageWariningModal.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.d.ts +0 -11
- package/dist/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/index.d.ts +0 -2
- package/dist/components/QuoteWarningsAndErrors/index.d.ts.map +0 -1
- package/dist/containers/App/App.d.ts +0 -3
- package/dist/containers/App/App.d.ts.map +0 -1
- package/dist/containers/App/App.styles.d.ts +0 -158
- package/dist/containers/App/App.styles.d.ts.map +0 -1
- package/dist/containers/App/index.d.ts +0 -2
- package/dist/containers/App/index.d.ts.map +0 -1
- package/dist/containers/QuoteInfo/QuoteInfo.d.ts +0 -4
- package/dist/containers/QuoteInfo/QuoteInfo.d.ts.map +0 -1
- package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts +0 -788
- package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts.map +0 -1
- package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts +0 -20
- package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts.map +0 -1
- package/dist/containers/QuoteInfo/index.d.ts +0 -2
- package/dist/containers/QuoteInfo/index.d.ts.map +0 -1
- package/dist/containers/Wallets/Wallets.d.ts +0 -6
- package/dist/containers/Wallets/Wallets.d.ts.map +0 -1
- package/dist/containers/Wallets/Wallets.types.d.ts +0 -11
- package/dist/containers/Wallets/Wallets.types.d.ts.map +0 -1
- package/dist/containers/Wallets/index.d.ts +0 -2
- package/dist/containers/Wallets/index.d.ts.map +0 -1
- package/dist/containers/Widget/Widget.d.ts +0 -5
- package/dist/containers/Widget/Widget.d.ts.map +0 -1
- package/dist/containers/Widget/Widget.types.d.ts +0 -5
- package/dist/containers/Widget/Widget.types.d.ts.map +0 -1
- package/dist/containers/Widget/index.d.ts +0 -3
- package/dist/containers/Widget/index.d.ts.map +0 -1
- package/dist/containers/WidgetInfo/WidgetInfo.d.ts +0 -6
- package/dist/containers/WidgetInfo/WidgetInfo.d.ts.map +0 -1
- package/dist/containers/WidgetInfo/WidgetInfo.helpers.d.ts +0 -20
- package/dist/containers/WidgetInfo/WidgetInfo.helpers.d.ts.map +0 -1
- package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts +0 -21
- package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts.map +0 -1
- package/dist/containers/WidgetInfo/index.d.ts +0 -2
- package/dist/containers/WidgetInfo/index.d.ts.map +0 -1
- package/dist/containers/WidgetProvider/WidgetProvider.d.ts +0 -5
- package/dist/containers/WidgetProvider/WidgetProvider.d.ts.map +0 -1
- package/dist/containers/WidgetProvider/WidgetProvider.types.d.ts +0 -7
- package/dist/containers/WidgetProvider/WidgetProvider.types.d.ts.map +0 -1
- package/dist/containers/WidgetProvider/index.d.ts +0 -2
- package/dist/containers/WidgetProvider/index.d.ts.map +0 -1
- package/dist/hooks/useConfirmSwap/index.d.ts +0 -2
- package/dist/hooks/useConfirmSwap/index.d.ts.map +0 -1
- package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts +0 -3
- package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts.map +0 -1
- package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts +0 -19
- package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts.map +0 -1
- package/dist/hooks/useConfirmSwap/useConfirmSwap.types.d.ts.map +0 -1
- package/dist/hooks/useFetchQuote.d.ts.map +0 -1
- package/dist/hooks/useForceAutoConnect.d.ts +0 -2
- package/dist/hooks/useForceAutoConnect.d.ts.map +0 -1
- package/dist/store/AppStore.d.ts +0 -47
- package/dist/store/AppStore.d.ts.map +0 -1
- package/dist/store/quote.d.ts +0 -89
- package/dist/store/quote.d.ts.map +0 -1
- package/dist/store/slices/settings.d.ts +0 -39
- package/dist/store/slices/settings.d.ts.map +0 -1
- package/dist/types/quote.d.ts +0 -82
- package/dist/types/quote.d.ts.map +0 -1
- package/dist/utils/quote.d.ts +0 -32
- package/dist/utils/quote.d.ts.map +0 -1
- package/src/components/NoResult/index.ts +0 -1
- package/src/components/Quote/Quote.styles.ts +0 -249
- package/src/components/Quote/Quote.tsx +0 -414
- package/src/components/Quote/Quote.types.ts +0 -15
- package/src/components/Quote/QuoteSummary.styles.ts +0 -16
- package/src/components/Quote/QuoteSummary.tsx +0 -46
- package/src/components/Quote/index.ts +0 -2
- package/src/components/QuoteSkeleton/QuoteSkeleton.styles.ts +0 -42
- package/src/components/QuoteSkeleton/QuoteSkeleton.tsx +0 -30
- package/src/components/QuoteSkeleton/QuoteSkeleton.types.ts +0 -5
- package/src/components/QuoteSkeleton/QuoteSummarySkeleton.styles.ts +0 -57
- package/src/components/QuoteSkeleton/QuoteSummarySkeleton.tsx +0 -76
- package/src/components/QuoteSkeleton/QuoteSummarySkeleton.types.ts +0 -6
- package/src/components/QuoteSkeleton/StepSkeleton.styles.ts +0 -33
- package/src/components/QuoteSkeleton/StepSkeleton.tsx +0 -44
- package/src/components/QuoteSkeleton/StepSkeleton.types.ts +0 -1
- package/src/components/QuoteSkeleton/index.ts +0 -3
- package/src/components/QuoteWarningsAndErrors/HighValueLossWarningModal.tsx +0 -107
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.ts +0 -74
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.tsx +0 -103
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.ts +0 -25
- package/src/components/QuoteWarningsAndErrors/SlippageWariningModal.tsx +0 -77
- package/src/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.tsx +0 -38
- package/src/components/QuoteWarningsAndErrors/index.ts +0 -1
- package/src/containers/App/App.styles.ts +0 -18
- package/src/containers/App/App.tsx +0 -52
- package/src/containers/App/index.ts +0 -1
- package/src/containers/QuoteInfo/QuoteInfo.styles.ts +0 -31
- package/src/containers/QuoteInfo/QuoteInfo.tsx +0 -99
- package/src/containers/QuoteInfo/QuoteInfo.types.ts +0 -20
- package/src/containers/QuoteInfo/index.ts +0 -1
- package/src/containers/Wallets/Wallets.types.ts +0 -12
- package/src/containers/Wallets/index.ts +0 -1
- package/src/containers/Widget/Widget.tsx +0 -19
- package/src/containers/Widget/Widget.types.ts +0 -5
- package/src/containers/Widget/index.ts +0 -2
- package/src/containers/WidgetInfo/WidgetInfo.helpers.ts +0 -64
- package/src/containers/WidgetInfo/WidgetInfo.tsx +0 -62
- package/src/containers/WidgetInfo/WidgetInfo.types.ts +0 -21
- package/src/containers/WidgetInfo/index.ts +0 -1
- package/src/containers/WidgetProvider/WidgetProvider.tsx +0 -28
- package/src/containers/WidgetProvider/WidgetProvider.types.ts +0 -7
- package/src/containers/WidgetProvider/index.ts +0 -1
- package/src/hooks/useConfirmSwap/index.ts +0 -1
- package/src/hooks/useConfirmSwap/useConfirmSwap.helpers.ts +0 -172
- package/src/hooks/useConfirmSwap/useConfirmSwap.ts +0 -137
- package/src/hooks/useConfirmSwap/useConfirmSwap.types.ts +0 -19
- package/src/hooks/useForceAutoConnect.ts +0 -27
- package/src/store/AppStore.tsx +0 -41
- package/src/store/slices/settings.ts +0 -168
- package/src/types/quote.ts +0 -107
- package/src/utils/quote.ts +0 -338
|
@@ -2,66 +2,6 @@ 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
|
-
|
|
65
5
|
export const sampleBlockchains: BlockchainMeta[] = [
|
|
66
6
|
{
|
|
67
7
|
name: 'ETH',
|
|
@@ -2,7 +2,7 @@ import type { BlockchainMeta } from 'rango-sdk';
|
|
|
2
2
|
|
|
3
3
|
import { beforeEach, describe, expect, it } from 'vitest';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { MOST_USED_BLOCKChAINS } from './usePrepareBlockchainList.constants';
|
|
6
6
|
import {
|
|
7
7
|
generateSortByPreferredBlockchainsFor,
|
|
8
8
|
prepare,
|
|
@@ -20,8 +20,8 @@ describe('usePrepareBlockchainList', () => {
|
|
|
20
20
|
it('should sort blockchains by most used ones.', () => {
|
|
21
21
|
const sortedBlockchainsList = sample.sort(sortByMostUsedBlockchains);
|
|
22
22
|
|
|
23
|
-
const mostUsedCount =
|
|
24
|
-
const expected =
|
|
23
|
+
const mostUsedCount = MOST_USED_BLOCKChAINS.length;
|
|
24
|
+
const expected = MOST_USED_BLOCKChAINS;
|
|
25
25
|
const received = sortedBlockchainsList
|
|
26
26
|
.map((blockchain) => blockchain.name)
|
|
27
27
|
.slice(0, mostUsedCount);
|
|
@@ -270,79 +270,4 @@ describe('usePrepareBlockchainList', () => {
|
|
|
270
270
|
...received.more.map((blockchain) => blockchain.name),
|
|
271
271
|
]);
|
|
272
272
|
});
|
|
273
|
-
|
|
274
|
-
it.only('Last item of the main list should be moved to front if it selected again.', () => {
|
|
275
|
-
const listLimit = 10;
|
|
276
|
-
const preferredBlockchains = ['AVAX_CCHAIN', 'BTC'];
|
|
277
|
-
const expected = [
|
|
278
|
-
'AVAX_CCHAIN',
|
|
279
|
-
'BTC',
|
|
280
|
-
'ETH',
|
|
281
|
-
'COSMOS',
|
|
282
|
-
'OSMOSIS',
|
|
283
|
-
'BSC',
|
|
284
|
-
'ARBITRUM',
|
|
285
|
-
'POLYGON',
|
|
286
|
-
'ZKSYNC',
|
|
287
|
-
'STARKNET',
|
|
288
|
-
'OPTIMISM',
|
|
289
|
-
'POLYGONZK',
|
|
290
|
-
'LINEA',
|
|
291
|
-
'TRON',
|
|
292
|
-
'NEUTRON',
|
|
293
|
-
'NOBLE',
|
|
294
|
-
'SOLANA',
|
|
295
|
-
'CRONOS',
|
|
296
|
-
'BNB',
|
|
297
|
-
'AURORA',
|
|
298
|
-
'MAYA',
|
|
299
|
-
'THOR',
|
|
300
|
-
'BOBA',
|
|
301
|
-
'MOONBEAM',
|
|
302
|
-
'MOONRIVER',
|
|
303
|
-
'OKC',
|
|
304
|
-
'BOBA_AVALANCHE',
|
|
305
|
-
'LTC',
|
|
306
|
-
'BCH',
|
|
307
|
-
'HECO',
|
|
308
|
-
'STARGAZE',
|
|
309
|
-
'CRYPTO_ORG',
|
|
310
|
-
'CHIHUAHUA',
|
|
311
|
-
'BANDCHAIN',
|
|
312
|
-
'COMDEX',
|
|
313
|
-
'REGEN',
|
|
314
|
-
'IRIS',
|
|
315
|
-
'EMONEY',
|
|
316
|
-
'JUNO',
|
|
317
|
-
'STRIDE',
|
|
318
|
-
'MARS',
|
|
319
|
-
'TERRA',
|
|
320
|
-
'BITSONG',
|
|
321
|
-
'AKASH',
|
|
322
|
-
'KI',
|
|
323
|
-
'PERSISTENCE',
|
|
324
|
-
'MEDIBLOC',
|
|
325
|
-
'KUJIRA',
|
|
326
|
-
'SENTINEL',
|
|
327
|
-
'INJECTIVE',
|
|
328
|
-
'SECRET',
|
|
329
|
-
'KONSTELLATION',
|
|
330
|
-
'STARNAME',
|
|
331
|
-
'BITCANNA',
|
|
332
|
-
'UMEE',
|
|
333
|
-
'DESMOS',
|
|
334
|
-
'LUMNETWORK',
|
|
335
|
-
];
|
|
336
|
-
|
|
337
|
-
const output = prepare(sample, preferredBlockchains, {
|
|
338
|
-
limit: listLimit,
|
|
339
|
-
});
|
|
340
|
-
|
|
341
|
-
const received = [
|
|
342
|
-
...output.list.map((blockchain) => blockchain.name),
|
|
343
|
-
...output.more.map((blockchain) => blockchain.name),
|
|
344
|
-
];
|
|
345
|
-
|
|
346
|
-
expect(expected).toEqual(received);
|
|
347
|
-
});
|
|
348
273
|
});
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
PrepareListOptions,
|
|
3
|
-
|
|
3
|
+
PrepareListOutput,
|
|
4
4
|
} from './usePrepareBlockchainList.types';
|
|
5
5
|
import type { BlockchainMeta } from 'rango-sdk';
|
|
6
6
|
|
|
7
7
|
import { useEffect } from 'react';
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import { useSettingsStore } from '../../store/settings';
|
|
10
10
|
|
|
11
|
-
import {
|
|
11
|
+
import { prepare } from './usePrepareBlockchainList.helpers';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
*
|
|
@@ -19,21 +19,12 @@ import { isInVisibleList, prepare } from './usePrepareBlockchainList.helpers';
|
|
|
19
19
|
export function usePrepareBlockchainList(
|
|
20
20
|
blockchains: BlockchainMeta[],
|
|
21
21
|
options?: PrepareListOptions
|
|
22
|
-
):
|
|
23
|
-
const { preferredBlockchains, addPreferredBlockchain } =
|
|
22
|
+
): PrepareListOutput {
|
|
23
|
+
const { preferredBlockchains, addPreferredBlockchain } = useSettingsStore();
|
|
24
24
|
|
|
25
25
|
useEffect(() => {
|
|
26
26
|
if (options?.selected) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* We only add a new blockchain to preferred when it's not in the main list
|
|
31
|
-
* In this way we can guarantee we will be able to regenerate the same list always.
|
|
32
|
-
* And also it helps us to avoid jumping for the last item of the main list (e.g. tenth item of our list).
|
|
33
|
-
*/
|
|
34
|
-
if (!isInVisibleList(options.selected, output)) {
|
|
35
|
-
addPreferredBlockchain(options?.selected);
|
|
36
|
-
}
|
|
27
|
+
addPreferredBlockchain(options?.selected);
|
|
37
28
|
}
|
|
38
29
|
}, [options?.selected]);
|
|
39
30
|
|
|
@@ -5,13 +5,8 @@ export interface PrepareListOptions {
|
|
|
5
5
|
selected?: string;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
export interface
|
|
8
|
+
export interface PrepareListOutput {
|
|
9
9
|
list: BlockchainMeta[];
|
|
10
10
|
more: BlockchainMeta[];
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface UsePrepareList {
|
|
14
|
-
list: PrepareOutput['list'];
|
|
15
|
-
more: PrepareOutput['more'];
|
|
16
11
|
history: string[];
|
|
17
12
|
}
|
|
@@ -1,56 +1,37 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { Token } from 'rango-sdk';
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
2
|
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import { useAppStore } from '../store/AppStore';
|
|
7
|
-
import { useQuoteStore } from '../store/quote';
|
|
8
|
-
import { QuoteErrorType } from '../types';
|
|
3
|
+
import { useBestRouteStore } from '../store/bestRoute';
|
|
4
|
+
import { useSettingsStore } from '../store/settings';
|
|
9
5
|
import { debounce } from '../utils/common';
|
|
10
6
|
import { isPositiveNumber } from '../utils/numbers';
|
|
11
|
-
import {
|
|
12
|
-
import { isFeatureEnabled } from '../utils/settings';
|
|
13
|
-
import { createQuoteRequestBody } from '../utils/swap';
|
|
7
|
+
import { createBestRouteRequestBody } from '../utils/swap';
|
|
14
8
|
import { tokensAreEqual } from '../utils/wallets';
|
|
15
9
|
|
|
16
|
-
import {
|
|
17
|
-
handleQuoteErrors,
|
|
18
|
-
throwErrorIfResponseIsNotValid,
|
|
19
|
-
} from './useConfirmSwap/useConfirmSwap.helpers';
|
|
20
|
-
import { useFetchQuote } from './useFetchQuote';
|
|
10
|
+
import { useFetchBestRoute } from './useFetchBestRoute';
|
|
21
11
|
|
|
22
12
|
const DEBOUNCE_DELAY = 600;
|
|
23
|
-
const FIRST_INDEX = 0;
|
|
24
|
-
|
|
25
|
-
type FetchQuoteParams = Omit<
|
|
26
|
-
Parameters<typeof createQuoteRequestBody>[typeof FIRST_INDEX],
|
|
27
|
-
'fromToken' | 'toToken'
|
|
28
|
-
> & { fromToken: Token | null; toToken: Token | null };
|
|
29
13
|
|
|
30
14
|
type UseSwapInput = {
|
|
31
15
|
fetch: () => void;
|
|
32
16
|
loading: boolean;
|
|
33
|
-
error:
|
|
34
|
-
warning: QuoteWarning | null;
|
|
17
|
+
error: string;
|
|
35
18
|
};
|
|
36
19
|
|
|
37
20
|
/**
|
|
38
|
-
* a hook for fetching
|
|
21
|
+
* a hook for fetching best route based on from and to input values
|
|
39
22
|
* we use this hook in home page
|
|
40
23
|
*/
|
|
41
24
|
export function useSwapInput(): UseSwapInput {
|
|
42
|
-
const { fetch:
|
|
43
|
-
const
|
|
44
|
-
useAppStore().config;
|
|
45
|
-
const tokens = useAppStore().tokens();
|
|
25
|
+
const { fetch: fetchBestRoute, cancelFetch } = useFetchBestRoute();
|
|
26
|
+
const [loading, setLoading] = useState(false);
|
|
46
27
|
const {
|
|
47
28
|
fromToken,
|
|
48
29
|
toToken,
|
|
49
30
|
inputAmount,
|
|
50
31
|
inputUsdValue,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
} =
|
|
32
|
+
resetRoute,
|
|
33
|
+
setRoute,
|
|
34
|
+
} = useBestRouteStore();
|
|
54
35
|
const {
|
|
55
36
|
slippage,
|
|
56
37
|
customSlippage,
|
|
@@ -58,10 +39,9 @@ export function useSwapInput(): UseSwapInput {
|
|
|
58
39
|
affiliateRef,
|
|
59
40
|
affiliateWallets,
|
|
60
41
|
disabledLiquiditySources,
|
|
61
|
-
} =
|
|
62
|
-
const [
|
|
63
|
-
const
|
|
64
|
-
const [warning, setWarning] = useState<QuoteWarning | null>(null);
|
|
42
|
+
} = useSettingsStore();
|
|
43
|
+
const [error, setError] = useState('');
|
|
44
|
+
const prevDisabledLiquiditySources = useRef(disabledLiquiditySources);
|
|
65
45
|
const userSlippage = customSlippage ?? slippage;
|
|
66
46
|
const hasTokensValue = !fromToken || !toToken;
|
|
67
47
|
const shouldSkipRequest =
|
|
@@ -69,141 +49,68 @@ export function useSwapInput(): UseSwapInput {
|
|
|
69
49
|
tokensAreEqual(fromToken, toToken) ||
|
|
70
50
|
!isPositiveNumber(inputAmount);
|
|
71
51
|
|
|
72
|
-
const
|
|
73
|
-
setLoading(loading);
|
|
74
|
-
setError(null);
|
|
75
|
-
setWarning(null);
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
const fetch = (params: FetchQuoteParams) => {
|
|
79
|
-
const {
|
|
80
|
-
fromToken,
|
|
81
|
-
toToken,
|
|
82
|
-
inputAmount,
|
|
83
|
-
liquiditySources,
|
|
84
|
-
excludeLiquiditySources,
|
|
85
|
-
disabledLiquiditySources,
|
|
86
|
-
slippage,
|
|
87
|
-
affiliateRef,
|
|
88
|
-
affiliatePercent,
|
|
89
|
-
affiliateWallets,
|
|
90
|
-
} = params;
|
|
52
|
+
const fetch: UseSwapInput['fetch'] = () => {
|
|
91
53
|
if (!loading) {
|
|
92
|
-
|
|
54
|
+
setLoading(true);
|
|
93
55
|
}
|
|
94
|
-
if (!shouldSkipRequest
|
|
95
|
-
|
|
96
|
-
const requestBody =
|
|
56
|
+
if (!shouldSkipRequest) {
|
|
57
|
+
resetRoute();
|
|
58
|
+
const requestBody = createBestRouteRequestBody({
|
|
97
59
|
fromToken,
|
|
98
60
|
toToken,
|
|
99
61
|
inputAmount,
|
|
100
|
-
liquiditySources,
|
|
101
|
-
excludeLiquiditySources,
|
|
102
62
|
disabledLiquiditySources,
|
|
103
|
-
slippage,
|
|
63
|
+
slippage: userSlippage,
|
|
104
64
|
affiliateRef,
|
|
105
65
|
affiliatePercent,
|
|
106
66
|
affiliateWallets,
|
|
107
67
|
});
|
|
108
|
-
|
|
109
|
-
requestBody.experimental = true;
|
|
110
|
-
}
|
|
111
|
-
fetchQuote(requestBody)
|
|
68
|
+
fetchBestRoute(requestBody)
|
|
112
69
|
.then((res) => {
|
|
113
70
|
setLoading(false);
|
|
114
|
-
|
|
115
|
-
throwErrorIfResponseIsNotValid(res);
|
|
116
|
-
const quoteWarning = generateQuoteWarnings(res, {
|
|
117
|
-
fromToken,
|
|
118
|
-
toToken,
|
|
119
|
-
userSlippage,
|
|
120
|
-
tokens,
|
|
121
|
-
});
|
|
122
|
-
setWarning(quoteWarning);
|
|
71
|
+
setRoute(res);
|
|
123
72
|
})
|
|
124
73
|
.catch((error) => {
|
|
125
|
-
|
|
126
|
-
if (
|
|
127
|
-
|
|
128
|
-
quoteError?.type === QuoteErrorType.REQUEST_FAILED
|
|
129
|
-
) {
|
|
130
|
-
resetQuote();
|
|
131
|
-
}
|
|
132
|
-
if (quoteError?.type !== QuoteErrorType.REQUEST_CANCELED) {
|
|
133
|
-
setError(quoteError);
|
|
74
|
+
resetRoute();
|
|
75
|
+
if (error?.code !== 'ERR_CANCELED') {
|
|
76
|
+
setError(error.message);
|
|
134
77
|
setLoading(false);
|
|
135
78
|
}
|
|
136
79
|
});
|
|
137
80
|
}
|
|
138
81
|
};
|
|
139
82
|
|
|
140
|
-
const debouncedFetch =
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}, DEBOUNCE_DELAY),
|
|
146
|
-
[shouldSkipRequest]
|
|
147
|
-
);
|
|
83
|
+
const debouncedFetch = debounce(() => {
|
|
84
|
+
if (!shouldSkipRequest) {
|
|
85
|
+
fetch();
|
|
86
|
+
}
|
|
87
|
+
}, DEBOUNCE_DELAY);
|
|
148
88
|
|
|
149
89
|
useEffect(() => {
|
|
150
90
|
if (!isPositiveNumber(inputAmount) || inputUsdValue?.eq(0)) {
|
|
151
|
-
|
|
91
|
+
setLoading(false);
|
|
152
92
|
cancelFetch();
|
|
153
93
|
return;
|
|
154
94
|
}
|
|
155
95
|
if (shouldSkipRequest) {
|
|
156
96
|
return;
|
|
157
97
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
debouncedFetch(
|
|
161
|
-
inputAmount,
|
|
162
|
-
fromToken,
|
|
163
|
-
toToken,
|
|
164
|
-
liquiditySources,
|
|
165
|
-
excludeLiquiditySources: enableNewLiquiditySources,
|
|
166
|
-
disabledLiquiditySources,
|
|
167
|
-
slippage: userSlippage,
|
|
168
|
-
affiliateRef,
|
|
169
|
-
affiliatePercent,
|
|
170
|
-
affiliateWallets,
|
|
171
|
-
});
|
|
98
|
+
resetRoute();
|
|
99
|
+
setLoading(true);
|
|
100
|
+
debouncedFetch();
|
|
172
101
|
return cancelFetch;
|
|
173
|
-
}, [
|
|
174
|
-
inputAmount,
|
|
175
|
-
fromToken?.symbol,
|
|
176
|
-
fromToken?.address,
|
|
177
|
-
fromToken?.blockchain,
|
|
178
|
-
toToken?.symbol,
|
|
179
|
-
toToken?.address,
|
|
180
|
-
toToken?.blockchain,
|
|
181
|
-
shouldSkipRequest,
|
|
182
|
-
liquiditySources?.length,
|
|
183
|
-
enableNewLiquiditySources,
|
|
184
|
-
disabledLiquiditySources.length,
|
|
185
|
-
userSlippage,
|
|
186
|
-
affiliateRef,
|
|
187
|
-
affiliatePercent,
|
|
188
|
-
JSON.stringify(affiliateWallets),
|
|
189
|
-
]);
|
|
102
|
+
}, [inputAmount, shouldSkipRequest]);
|
|
190
103
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
affiliateWallets,
|
|
204
|
-
}),
|
|
205
|
-
loading,
|
|
206
|
-
error,
|
|
207
|
-
warning,
|
|
208
|
-
};
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
const disabledLiquiditySourceReset =
|
|
106
|
+
!!prevDisabledLiquiditySources.current.length &&
|
|
107
|
+
!disabledLiquiditySources.length;
|
|
108
|
+
if (!shouldSkipRequest && disabledLiquiditySourceReset) {
|
|
109
|
+
fetch();
|
|
110
|
+
}
|
|
111
|
+
prevDisabledLiquiditySources.current = disabledLiquiditySources;
|
|
112
|
+
return cancelFetch;
|
|
113
|
+
}, [disabledLiquiditySources.length]);
|
|
114
|
+
|
|
115
|
+
return { fetch, loading, error };
|
|
209
116
|
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
import type { WidgetConfig } from '../types';
|
|
1
2
|
import type { Asset } from 'rango-sdk';
|
|
2
3
|
|
|
3
|
-
import { useEffect,
|
|
4
|
+
import { useEffect, useMemo, useRef } from 'react';
|
|
4
5
|
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
6
|
+
import { useBestRouteStore } from '../store/bestRoute';
|
|
7
|
+
import { useMetaStore } from '../store/meta';
|
|
8
|
+
import { useSettingsStore } from '../store/settings';
|
|
7
9
|
import { tokensAreEqual } from '../utils/wallets';
|
|
8
10
|
|
|
9
|
-
export function useSyncStoresWithConfig() {
|
|
11
|
+
export function useSyncStoresWithConfig(config: WidgetConfig | undefined) {
|
|
10
12
|
const {
|
|
11
13
|
setInputAmount,
|
|
12
14
|
setToToken,
|
|
@@ -17,15 +19,15 @@ export function useSyncStoresWithConfig() {
|
|
|
17
19
|
toToken,
|
|
18
20
|
fromBlockchain,
|
|
19
21
|
toBlockchain,
|
|
20
|
-
} =
|
|
22
|
+
} = useBestRouteStore();
|
|
21
23
|
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
const {
|
|
25
|
+
meta: { tokens, blockchains },
|
|
26
|
+
loadingStatus: loadingMetaStatus,
|
|
27
|
+
} = useMetaStore();
|
|
26
28
|
|
|
27
29
|
const { setAffiliateRef, setAffiliatePercent, setAffiliateWallets } =
|
|
28
|
-
|
|
30
|
+
useSettingsStore();
|
|
29
31
|
|
|
30
32
|
const fromTokensConfig = useMemo(
|
|
31
33
|
() => config?.from?.tokens,
|
|
@@ -52,15 +54,8 @@ export function useSyncStoresWithConfig() {
|
|
|
52
54
|
setInputAmount(config?.amount?.toString() || '');
|
|
53
55
|
}, [config?.amount]);
|
|
54
56
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
* If default values exist in widget config or search parameters exist in URL.
|
|
58
|
-
* The logic for updating quote store exists in two useEffect in two locations, and they run in order.If default tokens for quote exist in widget config and also exist in URL, widget config values take precedence over URL values, and URL search parameters don’t affect the widget.
|
|
59
|
-
* Using useLayoutEffect causes widget config values to apply first.
|
|
60
|
-
* We may consider replacing this with a better solution in the future.
|
|
61
|
-
*/
|
|
62
|
-
useLayoutEffect(() => {
|
|
63
|
-
if (fetchMetaStatus === 'success') {
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
if (loadingMetaStatus === 'success') {
|
|
64
59
|
const chain = blockchains.find(
|
|
65
60
|
(chain) => chain.name === config?.from?.blockchain
|
|
66
61
|
);
|
|
@@ -72,10 +67,8 @@ export function useSyncStoresWithConfig() {
|
|
|
72
67
|
setFromBlockchain(chain ?? null);
|
|
73
68
|
}
|
|
74
69
|
|
|
75
|
-
if (token) {
|
|
76
|
-
setFromToken(
|
|
77
|
-
} else if (!token && prevConfigFromToken.current) {
|
|
78
|
-
setFromToken({ token: null });
|
|
70
|
+
if (token || (!token && prevConfigFromToken.current)) {
|
|
71
|
+
setFromToken(token ?? null);
|
|
79
72
|
}
|
|
80
73
|
|
|
81
74
|
prevConfigFromBlockchain.current = config?.from?.blockchain;
|
|
@@ -86,13 +79,13 @@ export function useSyncStoresWithConfig() {
|
|
|
86
79
|
config?.from?.token?.address,
|
|
87
80
|
config?.from?.token?.blockchain,
|
|
88
81
|
config?.from?.blockchain,
|
|
89
|
-
|
|
82
|
+
loadingMetaStatus,
|
|
90
83
|
]);
|
|
91
84
|
|
|
92
85
|
useEffect(() => {
|
|
93
86
|
if (fromToken && fromTokensConfig) {
|
|
94
87
|
if (!fromTokensConfig.some((token) => tokensAreEqual(token, fromToken))) {
|
|
95
|
-
setFromToken(
|
|
88
|
+
setFromToken(null);
|
|
96
89
|
}
|
|
97
90
|
}
|
|
98
91
|
|
|
@@ -106,7 +99,7 @@ export function useSyncStoresWithConfig() {
|
|
|
106
99
|
useEffect(() => {
|
|
107
100
|
if (toToken && toTokensConfig) {
|
|
108
101
|
if (!toTokensConfig.some((token) => tokensAreEqual(token, toToken))) {
|
|
109
|
-
setToToken(
|
|
102
|
+
setToToken(null);
|
|
110
103
|
}
|
|
111
104
|
}
|
|
112
105
|
|
|
@@ -117,15 +110,8 @@ export function useSyncStoresWithConfig() {
|
|
|
117
110
|
}
|
|
118
111
|
}, [toTokensConfig, toBlockchainsConfig]);
|
|
119
112
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
* If default values exist in widget config or search parameters exist in URL.
|
|
123
|
-
* The logic for updating quote store exists in two useEffect in two locations, and they run in order.If default tokens for quote exist in widget config and also exist in URL, widget config values take precedence over URL values, and URL search parameters don’t affect the widget.
|
|
124
|
-
* Using useLayoutEffect causes widget config values to apply first.
|
|
125
|
-
* We may consider replacing this with a better solution in the future.
|
|
126
|
-
*/
|
|
127
|
-
useLayoutEffect(() => {
|
|
128
|
-
if (fetchMetaStatus === 'success') {
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
if (loadingMetaStatus === 'success') {
|
|
129
115
|
const chain = blockchains.find(
|
|
130
116
|
(chain) => chain.name === config?.to?.blockchain
|
|
131
117
|
);
|
|
@@ -137,10 +123,8 @@ export function useSyncStoresWithConfig() {
|
|
|
137
123
|
setToBlockchain(chain ?? null);
|
|
138
124
|
}
|
|
139
125
|
|
|
140
|
-
if (token) {
|
|
141
|
-
setToToken(
|
|
142
|
-
} else if (!token && prevConfigToToken.current) {
|
|
143
|
-
setToToken({ token: null });
|
|
126
|
+
if (token || (!token && prevConfigToToken.current)) {
|
|
127
|
+
setToToken(token ?? null);
|
|
144
128
|
}
|
|
145
129
|
|
|
146
130
|
prevConfigToBlockchain.current = config?.to?.blockchain;
|
|
@@ -151,7 +135,7 @@ export function useSyncStoresWithConfig() {
|
|
|
151
135
|
config?.to?.token?.address,
|
|
152
136
|
config?.to?.token?.blockchain,
|
|
153
137
|
config?.to?.blockchain,
|
|
154
|
-
|
|
138
|
+
loadingMetaStatus,
|
|
155
139
|
]);
|
|
156
140
|
|
|
157
141
|
useEffect(() => {
|
package/src/hooks/useTheme.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-magic-numbers */
|
|
2
|
+
import type { WidgetTheme } from '../types';
|
|
3
|
+
|
|
2
4
|
import {
|
|
3
5
|
createTheme,
|
|
4
6
|
darkTheme as defaultDarkTheme,
|
|
@@ -6,8 +8,7 @@ import {
|
|
|
6
8
|
} from '@rango-dev/ui';
|
|
7
9
|
import { useEffect, useState } from 'react';
|
|
8
10
|
|
|
9
|
-
import {
|
|
10
|
-
import { type WidgetTheme } from '../types';
|
|
11
|
+
import { useSettingsStore } from '../store/settings';
|
|
11
12
|
import {
|
|
12
13
|
DEFAULT_FONT_FAMILY,
|
|
13
14
|
DEFAULT_PRIMARY_RADIUS,
|
|
@@ -25,8 +26,8 @@ export function useTheme(props: WidgetTheme) {
|
|
|
25
26
|
} = props;
|
|
26
27
|
|
|
27
28
|
const [OSTheme, setOSTheme] = useState('light');
|
|
28
|
-
|
|
29
|
-
const
|
|
29
|
+
const theme = useSettingsStore.use.theme();
|
|
30
|
+
const setTheme = useSettingsStore.use.setTheme();
|
|
30
31
|
|
|
31
32
|
const { dark, light } = customizedThemeTokens(colors);
|
|
32
33
|
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from '@rango-dev/wallets-shared';
|
|
11
11
|
import { useEffect, useState } from 'react';
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import { useMetaStore } from '../store/meta';
|
|
14
14
|
import { useWalletsStore } from '../store/wallets';
|
|
15
15
|
import { configWalletsToWalletName } from '../utils/providers';
|
|
16
16
|
import {
|
|
@@ -37,7 +37,9 @@ export function useWalletList(params: Params) {
|
|
|
37
37
|
const { config, chain, onBeforeConnect, onConnect } = params;
|
|
38
38
|
const { state, disconnect, getWalletInfo, connect } = useWallets();
|
|
39
39
|
const { connectedWallets } = useWalletsStore();
|
|
40
|
-
const blockchains =
|
|
40
|
+
const { blockchains } = useMetaStore().meta;
|
|
41
|
+
const multiWallets =
|
|
42
|
+
typeof config?.multiWallets === 'undefined' ? true : config.multiWallets;
|
|
41
43
|
|
|
42
44
|
/** It can be what has been set by widget config or as a fallback we use all the supported wallets by our library */
|
|
43
45
|
const listAvailableWalletTypes =
|
|
@@ -74,7 +76,7 @@ export function useWalletList(params: Params) {
|
|
|
74
76
|
const atLeastOneWalletIsConnected = !!wallets.find(
|
|
75
77
|
(w) => w.state === WalletState.CONNECTED
|
|
76
78
|
);
|
|
77
|
-
if (!
|
|
79
|
+
if (!multiWallets && atLeastOneWalletIsConnected) {
|
|
78
80
|
return;
|
|
79
81
|
}
|
|
80
82
|
onBeforeConnect?.(type);
|