@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
|
@@ -1,172 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,137 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
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/store/AppStore.tsx
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { WidgetConfig } from '../types';
|
|
2
|
-
import type { PropsWithChildren } from 'react';
|
|
3
|
-
|
|
4
|
-
import React, { createContext, useContext, useEffect, useRef } from 'react';
|
|
5
|
-
|
|
6
|
-
import { createAppStore } from './app';
|
|
7
|
-
|
|
8
|
-
type AppStore = ReturnType<typeof createAppStore>;
|
|
9
|
-
type AppStoreProviderProps = PropsWithChildren<{ config?: WidgetConfig }>;
|
|
10
|
-
|
|
11
|
-
export const AppStoreContext = createContext<AppStore | null>(null);
|
|
12
|
-
|
|
13
|
-
export function useAppStore() {
|
|
14
|
-
const store = useContext(AppStoreContext);
|
|
15
|
-
|
|
16
|
-
useEffect(() => {
|
|
17
|
-
if (store && !store.persist.hasHydrated()) {
|
|
18
|
-
void store.persist.rehydrate();
|
|
19
|
-
}
|
|
20
|
-
}, []);
|
|
21
|
-
|
|
22
|
-
if (!store) {
|
|
23
|
-
throw new Error('Missing AppStoreContext.Provider in the tree');
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return store();
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function AppStoreProvider(props: AppStoreProviderProps) {
|
|
30
|
-
const appStoreRef = useRef<AppStore>();
|
|
31
|
-
|
|
32
|
-
if (!appStoreRef.current) {
|
|
33
|
-
appStoreRef.current = createAppStore(props.config);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return (
|
|
37
|
-
<AppStoreContext.Provider value={appStoreRef.current}>
|
|
38
|
-
{props.children}
|
|
39
|
-
</AppStoreContext.Provider>
|
|
40
|
-
);
|
|
41
|
-
}
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import type { ConfigSlice } from './config';
|
|
2
|
-
import type { WidgetConfig } from '../../types';
|
|
3
|
-
import type { SwapperMeta } from 'rango-sdk';
|
|
4
|
-
import type { StateCreator } from 'zustand';
|
|
5
|
-
|
|
6
|
-
import { type Language } from '@rango-dev/ui';
|
|
7
|
-
|
|
8
|
-
import { BLOCKCHAIN_LIST_SIZE } from '../../constants/configs';
|
|
9
|
-
import { DEFAULT_LANGUAGE } from '../../constants/languages';
|
|
10
|
-
import { DEFAULT_SLIPPAGE } from '../../constants/swapSettings';
|
|
11
|
-
import { removeDuplicateFrom } from '../../utils/common';
|
|
12
|
-
import { isFeatureHidden } from '../../utils/settings';
|
|
13
|
-
|
|
14
|
-
export type ThemeMode = 'auto' | 'dark' | 'light';
|
|
15
|
-
|
|
16
|
-
export interface SettingsSlice {
|
|
17
|
-
theme: ThemeMode;
|
|
18
|
-
language: Language;
|
|
19
|
-
disabledLiquiditySources: string[];
|
|
20
|
-
/** Keeping a history of blockchains that user has selected (in Swap process) */
|
|
21
|
-
preferredBlockchains: string[];
|
|
22
|
-
slippage: number;
|
|
23
|
-
customSlippage: number | null;
|
|
24
|
-
infiniteApprove: boolean;
|
|
25
|
-
affiliateRef: string | null;
|
|
26
|
-
affiliatePercent: number | null;
|
|
27
|
-
affiliateWallets: { [key: string]: string } | null;
|
|
28
|
-
|
|
29
|
-
setSlippage: (slippage: number) => void;
|
|
30
|
-
setCustomSlippage: (customSlippage: number | null) => void;
|
|
31
|
-
toggleInfiniteApprove: () => void;
|
|
32
|
-
toggleLiquiditySource: (name: string) => void;
|
|
33
|
-
setTheme: (theme: ThemeMode) => void;
|
|
34
|
-
setLanguage: (language: Language) => void;
|
|
35
|
-
toggleAllLiquiditySources: (
|
|
36
|
-
swappers: SwapperMeta[],
|
|
37
|
-
shouldReset?: boolean
|
|
38
|
-
) => void;
|
|
39
|
-
setAffiliateRef: (affiliateRef: string | null) => void;
|
|
40
|
-
setAffiliatePercent: (affiliatePercent: number | null) => void;
|
|
41
|
-
setAffiliateWallets: (
|
|
42
|
-
affiliateWallets: { [key: string]: string } | null
|
|
43
|
-
) => void;
|
|
44
|
-
addPreferredBlockchain: (blockchain: string) => void;
|
|
45
|
-
updateSettings: (config: WidgetConfig) => void;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export const createSettingsSlice: StateCreator<
|
|
49
|
-
SettingsSlice & ConfigSlice,
|
|
50
|
-
[],
|
|
51
|
-
[],
|
|
52
|
-
SettingsSlice
|
|
53
|
-
> = (set, get) => ({
|
|
54
|
-
disabledLiquiditySources: [],
|
|
55
|
-
theme: 'auto',
|
|
56
|
-
language: DEFAULT_LANGUAGE,
|
|
57
|
-
preferredBlockchains: [],
|
|
58
|
-
slippage: DEFAULT_SLIPPAGE,
|
|
59
|
-
customSlippage: null,
|
|
60
|
-
infiniteApprove: false,
|
|
61
|
-
affiliateRef: null,
|
|
62
|
-
affiliatePercent: null,
|
|
63
|
-
affiliateWallets: null,
|
|
64
|
-
|
|
65
|
-
addPreferredBlockchain: (blockchain) => {
|
|
66
|
-
const currentPreferredBlockchains = get().preferredBlockchains;
|
|
67
|
-
|
|
68
|
-
const noNeedToDoAnything = currentPreferredBlockchains.find(
|
|
69
|
-
(preferredBlockchain, index) => {
|
|
70
|
-
const isSameBlockchain = preferredBlockchain === blockchain;
|
|
71
|
-
const isInVisibleList = index <= BLOCKCHAIN_LIST_SIZE - 1;
|
|
72
|
-
|
|
73
|
-
return isSameBlockchain && isInVisibleList;
|
|
74
|
-
}
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
if (noNeedToDoAnything) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const nextPreferredBlockchains: string[] =
|
|
82
|
-
currentPreferredBlockchains.filter((preferredBlockchain) => {
|
|
83
|
-
const isSameBlockchain = preferredBlockchain === blockchain;
|
|
84
|
-
|
|
85
|
-
return !isSameBlockchain;
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
set(() => ({
|
|
89
|
-
preferredBlockchains: [blockchain, ...nextPreferredBlockchains],
|
|
90
|
-
}));
|
|
91
|
-
},
|
|
92
|
-
setSlippage: (slippage) =>
|
|
93
|
-
set(() => ({
|
|
94
|
-
slippage: slippage,
|
|
95
|
-
})),
|
|
96
|
-
setCustomSlippage: (customSlippage) =>
|
|
97
|
-
set(() => ({
|
|
98
|
-
customSlippage: customSlippage,
|
|
99
|
-
})),
|
|
100
|
-
setAffiliateRef: (affiliateRef) =>
|
|
101
|
-
set(() => ({
|
|
102
|
-
affiliateRef,
|
|
103
|
-
})),
|
|
104
|
-
setAffiliatePercent: (affiliatePercent) =>
|
|
105
|
-
set(() => ({
|
|
106
|
-
affiliatePercent,
|
|
107
|
-
})),
|
|
108
|
-
|
|
109
|
-
setAffiliateWallets: (affiliateWallets) =>
|
|
110
|
-
set(() => ({
|
|
111
|
-
affiliateWallets,
|
|
112
|
-
})),
|
|
113
|
-
toggleAllLiquiditySources: (swappers, shouldReset) =>
|
|
114
|
-
set((state) => {
|
|
115
|
-
if (shouldReset) {
|
|
116
|
-
return { disabledLiquiditySources: [] };
|
|
117
|
-
}
|
|
118
|
-
const swappersGroup = removeDuplicateFrom(
|
|
119
|
-
swappers.map((swapper) => swapper.swapperGroup)
|
|
120
|
-
);
|
|
121
|
-
|
|
122
|
-
if (swappersGroup.length === state.disabledLiquiditySources.length) {
|
|
123
|
-
return { disabledLiquiditySources: [] };
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return {
|
|
127
|
-
disabledLiquiditySources: swappersGroup,
|
|
128
|
-
};
|
|
129
|
-
}),
|
|
130
|
-
toggleInfiniteApprove: () =>
|
|
131
|
-
set((state) => ({
|
|
132
|
-
infiniteApprove: !state.infiniteApprove,
|
|
133
|
-
})),
|
|
134
|
-
toggleLiquiditySource: (name) =>
|
|
135
|
-
set((state) => {
|
|
136
|
-
if (state.disabledLiquiditySources.includes(name)) {
|
|
137
|
-
return {
|
|
138
|
-
disabledLiquiditySources: state.disabledLiquiditySources.filter(
|
|
139
|
-
(liquiditySource) => liquiditySource != name
|
|
140
|
-
),
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
return {
|
|
144
|
-
disabledLiquiditySources: state.disabledLiquiditySources.concat(name),
|
|
145
|
-
};
|
|
146
|
-
}),
|
|
147
|
-
setTheme: (theme) =>
|
|
148
|
-
set(() => ({
|
|
149
|
-
theme,
|
|
150
|
-
})),
|
|
151
|
-
setLanguage: (language) =>
|
|
152
|
-
set(() => ({
|
|
153
|
-
language,
|
|
154
|
-
})),
|
|
155
|
-
updateSettings: (nextConfig: WidgetConfig) => {
|
|
156
|
-
const { features } = nextConfig;
|
|
157
|
-
|
|
158
|
-
const isThemeHidden = isFeatureHidden('theme', features);
|
|
159
|
-
const isLanguageHidden = isFeatureHidden('language', features);
|
|
160
|
-
const isLiquidityHidden = isFeatureHidden('liquiditySource', features);
|
|
161
|
-
|
|
162
|
-
set({
|
|
163
|
-
...(isThemeHidden && { theme: 'auto' }),
|
|
164
|
-
...(isLanguageHidden && { language: DEFAULT_LANGUAGE }),
|
|
165
|
-
...(isLiquidityHidden && { disabledLiquiditySources: [] }),
|
|
166
|
-
});
|
|
167
|
-
},
|
|
168
|
-
});
|
package/src/types/quote.ts
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/prefer-enum-initializers */
|
|
2
|
-
|
|
3
|
-
import type { PriceImpactWarningLevel } from '@rango-dev/ui';
|
|
4
|
-
import type BigNumber from 'bignumber.js';
|
|
5
|
-
import type { SwapResult } from 'rango-sdk';
|
|
6
|
-
|
|
7
|
-
export enum QuoteErrorType {
|
|
8
|
-
NO_RESULT,
|
|
9
|
-
REQUEST_FAILED,
|
|
10
|
-
REQUEST_CANCELED,
|
|
11
|
-
BRIDGE_LIMIT,
|
|
12
|
-
INSUFFICIENT_SLIPPAGE,
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export type NoResultError = {
|
|
16
|
-
type: QuoteErrorType.NO_RESULT;
|
|
17
|
-
diagnosisMessage?: string;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export type BridgeLimitError = {
|
|
21
|
-
type: QuoteErrorType.BRIDGE_LIMIT;
|
|
22
|
-
swap: SwapResult;
|
|
23
|
-
recommendation: string;
|
|
24
|
-
fromAmountRangeError: string;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export type InsufficientSlippageError = {
|
|
28
|
-
type: QuoteErrorType.INSUFFICIENT_SLIPPAGE;
|
|
29
|
-
recommendedSlippages: RecommendedSlippages | null;
|
|
30
|
-
minRequiredSlippage: string | null;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export type QuoteRequestFailed = { type: QuoteErrorType.REQUEST_FAILED };
|
|
34
|
-
export type QuoteRequestCanceled = { type: QuoteErrorType.REQUEST_CANCELED };
|
|
35
|
-
|
|
36
|
-
export type QuoteError =
|
|
37
|
-
| NoResultError
|
|
38
|
-
| BridgeLimitError
|
|
39
|
-
| InsufficientSlippageError
|
|
40
|
-
| QuoteRequestFailed
|
|
41
|
-
| QuoteRequestCanceled;
|
|
42
|
-
|
|
43
|
-
export enum QuoteWarningType {
|
|
44
|
-
HIGH_VALUE_LOSS,
|
|
45
|
-
UNKNOWN_PRICE,
|
|
46
|
-
INSUFFICIENT_SLIPPAGE,
|
|
47
|
-
HIGH_SLIPPAGE,
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export enum QuoteUpdateType {
|
|
51
|
-
QUOTE_UPDATED,
|
|
52
|
-
QUOTE_SWAPPERS_UPDATED,
|
|
53
|
-
QUOTE_COINS_UPDATED,
|
|
54
|
-
QUOTE_AND_OUTPUT_AMOUNT_UPDATED,
|
|
55
|
-
QUOTE_UPDATED_WITH_HIGH_VALUE_LOSS,
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export type QuoteUpdateWarning =
|
|
59
|
-
| {
|
|
60
|
-
type: QuoteUpdateType.QUOTE_AND_OUTPUT_AMOUNT_UPDATED;
|
|
61
|
-
newOutputAmount: string;
|
|
62
|
-
percentageChange: string;
|
|
63
|
-
}
|
|
64
|
-
| {
|
|
65
|
-
type: Exclude<
|
|
66
|
-
QuoteUpdateType,
|
|
67
|
-
QuoteUpdateType.QUOTE_AND_OUTPUT_AMOUNT_UPDATED
|
|
68
|
-
>;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
export type RecommendedSlippages = Map<number, string>;
|
|
72
|
-
|
|
73
|
-
export type InsufficientSlippageWarning = {
|
|
74
|
-
type: QuoteWarningType.INSUFFICIENT_SLIPPAGE;
|
|
75
|
-
recommendedSlippages: RecommendedSlippages | null;
|
|
76
|
-
minRequiredSlippage: string | null;
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export type HighSlippageWarning = {
|
|
80
|
-
type: QuoteWarningType.HIGH_SLIPPAGE;
|
|
81
|
-
slippage: string | null;
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export type HighValueLossWarning = {
|
|
85
|
-
type: QuoteWarningType.HIGH_VALUE_LOSS;
|
|
86
|
-
warningLevel: PriceImpactWarningLevel;
|
|
87
|
-
inputUsdValue: BigNumber;
|
|
88
|
-
outputUsdValue: BigNumber;
|
|
89
|
-
totalFee: BigNumber;
|
|
90
|
-
priceImpact: number;
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
export type UnknownPriceWarning = {
|
|
94
|
-
type: QuoteWarningType.UNKNOWN_PRICE;
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
export type QuoteWarning =
|
|
98
|
-
| HighValueLossWarning
|
|
99
|
-
| InsufficientSlippageWarning
|
|
100
|
-
| HighSlippageWarning
|
|
101
|
-
| UnknownPriceWarning;
|
|
102
|
-
|
|
103
|
-
export type ConfirmSwapWarnings = {
|
|
104
|
-
quote: QuoteWarning | null;
|
|
105
|
-
quoteUpdate: QuoteUpdateWarning | null;
|
|
106
|
-
balance: { messages: string[] } | null;
|
|
107
|
-
};
|