@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,11 +1,7 @@
|
|
|
1
|
+
import type { TokenWithBalance } from '../components/TokenList';
|
|
1
2
|
import type { Wallet } from '../types';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
BlockchainMeta,
|
|
5
|
-
MetaResponse,
|
|
6
|
-
Token,
|
|
7
|
-
} from 'rango-sdk';
|
|
8
|
-
import type { PendingSwap } from 'rango-types';
|
|
3
|
+
import type { PendingSwap } from '@rango-dev/queue-manager-rango-preset/dist/shared';
|
|
4
|
+
import type { BestRouteResponse, BlockchainMeta, Token } from 'rango-sdk';
|
|
9
5
|
|
|
10
6
|
import BigNumber from 'bignumber.js';
|
|
11
7
|
import { create } from 'zustand';
|
|
@@ -13,58 +9,53 @@ import { subscribeWithSelector } from 'zustand/middleware';
|
|
|
13
9
|
|
|
14
10
|
import { ZERO } from '../constants/numbers';
|
|
15
11
|
import { isPositiveNumber } from '../utils/numbers';
|
|
16
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
createRetryRoute,
|
|
14
|
+
getBestRouteToTokenUsdPrice,
|
|
15
|
+
} from '../utils/routing';
|
|
17
16
|
import { calcOutputUsdValue } from '../utils/swap';
|
|
18
17
|
|
|
18
|
+
import { useMetaStore } from './meta';
|
|
19
19
|
import createSelectors from './selectors';
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
token: Token | null,
|
|
23
|
-
amount: string
|
|
24
|
-
): BigNumber | null =>
|
|
21
|
+
const getUsdValue = (token: Token | null, amount: string): BigNumber | null =>
|
|
25
22
|
token?.usdPrice
|
|
26
23
|
? new BigNumber(amount || ZERO).multipliedBy(token?.usdPrice || 0)
|
|
27
24
|
: null;
|
|
28
25
|
|
|
29
|
-
export
|
|
30
|
-
|
|
31
|
-
export type SetTokenParams = { token: Token; meta: Meta } | { token: null };
|
|
32
|
-
|
|
33
|
-
export interface QuoteState {
|
|
26
|
+
export interface RouteState {
|
|
34
27
|
fromBlockchain: BlockchainMeta | null;
|
|
35
28
|
toBlockchain: BlockchainMeta | null;
|
|
36
29
|
inputAmount: string;
|
|
37
30
|
inputUsdValue: BigNumber | null;
|
|
38
31
|
outputAmount: BigNumber | null;
|
|
39
32
|
outputUsdValue: BigNumber | null;
|
|
40
|
-
fromToken:
|
|
41
|
-
toToken:
|
|
42
|
-
|
|
33
|
+
fromToken: TokenWithBalance | null;
|
|
34
|
+
toToken: TokenWithBalance | null;
|
|
35
|
+
routeWalletsConfirmed: boolean;
|
|
43
36
|
selectedWallets: Wallet[];
|
|
44
|
-
|
|
45
|
-
resetQuote: () => void;
|
|
37
|
+
resetRoute: () => void;
|
|
46
38
|
resetToBlockchain: () => void;
|
|
47
39
|
resetFromBlockchain: () => void;
|
|
48
40
|
setFromBlockchain: (chain: BlockchainMeta | null) => void;
|
|
49
41
|
setToBlockchain: (chian: BlockchainMeta | null) => void;
|
|
50
42
|
|
|
51
|
-
setFromToken: (
|
|
52
|
-
setToToken: (
|
|
43
|
+
setFromToken: (token: Token | null) => void;
|
|
44
|
+
setToToken: (token: Token | null) => void;
|
|
53
45
|
setInputAmount: (amount: string) => void;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
retry: (pendingSwap: PendingSwap
|
|
46
|
+
bestRoute: BestRouteResponse | null;
|
|
47
|
+
setRoute: (bestRoute: BestRouteResponse | null) => void;
|
|
48
|
+
retry: (pendingSwap: PendingSwap) => void;
|
|
57
49
|
switchFromAndTo: () => void;
|
|
58
|
-
|
|
50
|
+
setRouteWalletConfirmed: (flag: boolean) => void;
|
|
59
51
|
setSelectedWallets: (wallets: Wallet[]) => void;
|
|
60
52
|
customDestination: string;
|
|
61
53
|
setCustomDestination: (address: string) => void;
|
|
62
|
-
|
|
63
|
-
setQuoteWarningsConfirmed: (flag: boolean) => void;
|
|
54
|
+
resetRouteWallets: () => void;
|
|
64
55
|
}
|
|
65
56
|
|
|
66
|
-
export const
|
|
67
|
-
create<
|
|
57
|
+
export const useBestRouteStore = createSelectors(
|
|
58
|
+
create<RouteState>()(
|
|
68
59
|
subscribeWithSelector((set) => ({
|
|
69
60
|
fromBlockchain: null,
|
|
70
61
|
fromToken: null,
|
|
@@ -74,38 +65,37 @@ export const useQuoteStore = createSelectors(
|
|
|
74
65
|
outputUsdValue: new BigNumber(0),
|
|
75
66
|
toBlockchain: null,
|
|
76
67
|
toToken: null,
|
|
77
|
-
|
|
78
|
-
|
|
68
|
+
bestRoute: null,
|
|
69
|
+
routeWalletsConfirmed: false,
|
|
79
70
|
selectedWallets: [],
|
|
80
71
|
customDestination: '',
|
|
81
|
-
|
|
82
|
-
setQuote: (quote) =>
|
|
72
|
+
setRoute: (bestRoute) =>
|
|
83
73
|
set((state) => {
|
|
84
74
|
let outputAmount: BigNumber | null = null;
|
|
85
75
|
let outputUsdValue: BigNumber = ZERO;
|
|
86
76
|
if (!isPositiveNumber(state.inputAmount)) {
|
|
87
77
|
return {};
|
|
88
78
|
}
|
|
89
|
-
if (!!
|
|
90
|
-
outputAmount = !!
|
|
91
|
-
? new BigNumber(
|
|
79
|
+
if (!!bestRoute) {
|
|
80
|
+
outputAmount = !!bestRoute.result?.outputAmount
|
|
81
|
+
? new BigNumber(bestRoute.result?.outputAmount)
|
|
92
82
|
: null;
|
|
93
83
|
outputUsdValue = calcOutputUsdValue(
|
|
94
|
-
|
|
95
|
-
|
|
84
|
+
bestRoute.result?.outputAmount,
|
|
85
|
+
getBestRouteToTokenUsdPrice(bestRoute) || state.toToken?.usdPrice
|
|
96
86
|
);
|
|
97
87
|
}
|
|
98
88
|
return {
|
|
99
|
-
|
|
100
|
-
...(!!
|
|
89
|
+
bestRoute,
|
|
90
|
+
...(!!bestRoute && {
|
|
101
91
|
outputAmount,
|
|
102
92
|
outputUsdValue,
|
|
103
93
|
}),
|
|
104
94
|
};
|
|
105
95
|
}),
|
|
106
|
-
|
|
96
|
+
resetRoute: () =>
|
|
107
97
|
set(() => ({
|
|
108
|
-
|
|
98
|
+
bestRoute: null,
|
|
109
99
|
outputAmount: null,
|
|
110
100
|
outputUsdValue: new BigNumber(0),
|
|
111
101
|
})),
|
|
@@ -118,7 +108,7 @@ export const useQuoteStore = createSelectors(
|
|
|
118
108
|
return {
|
|
119
109
|
fromBlockchain: chain,
|
|
120
110
|
...(state.fromToken && {
|
|
121
|
-
|
|
111
|
+
bestRoute: null,
|
|
122
112
|
fromToken: null,
|
|
123
113
|
outputAmount: null,
|
|
124
114
|
outputUsdValue: null,
|
|
@@ -126,17 +116,18 @@ export const useQuoteStore = createSelectors(
|
|
|
126
116
|
};
|
|
127
117
|
});
|
|
128
118
|
},
|
|
129
|
-
setFromToken: (
|
|
119
|
+
setFromToken: (token) => {
|
|
120
|
+
const { blockchains } = useMetaStore.getState().meta;
|
|
130
121
|
return set((state) => ({
|
|
131
|
-
fromToken:
|
|
132
|
-
...(
|
|
122
|
+
fromToken: token,
|
|
123
|
+
...(token && {
|
|
133
124
|
fromBlockchain:
|
|
134
|
-
|
|
135
|
-
(blockchain) => blockchain.name ===
|
|
125
|
+
blockchains.find(
|
|
126
|
+
(blockchain) => blockchain.name === token.blockchain
|
|
136
127
|
) ?? null,
|
|
137
128
|
}),
|
|
138
129
|
...(!!state.inputAmount && {
|
|
139
|
-
inputUsdValue: getUsdValue(
|
|
130
|
+
inputUsdValue: getUsdValue(token, state.inputAmount),
|
|
140
131
|
}),
|
|
141
132
|
}));
|
|
142
133
|
},
|
|
@@ -149,7 +140,7 @@ export const useQuoteStore = createSelectors(
|
|
|
149
140
|
return {
|
|
150
141
|
toBlockchain: chain,
|
|
151
142
|
...(state.toToken && {
|
|
152
|
-
|
|
143
|
+
bestRoute: null,
|
|
153
144
|
toToken: null,
|
|
154
145
|
outputAmount: null,
|
|
155
146
|
outputUsdValue: null,
|
|
@@ -157,13 +148,14 @@ export const useQuoteStore = createSelectors(
|
|
|
157
148
|
};
|
|
158
149
|
});
|
|
159
150
|
},
|
|
160
|
-
setToToken: (
|
|
151
|
+
setToToken: (token) => {
|
|
152
|
+
const { blockchains } = useMetaStore.getState().meta;
|
|
161
153
|
return set(() => ({
|
|
162
|
-
toToken:
|
|
163
|
-
...(
|
|
154
|
+
toToken: token,
|
|
155
|
+
...(token && {
|
|
164
156
|
toBlockchain:
|
|
165
|
-
|
|
166
|
-
(blockchain) => blockchain.name ===
|
|
157
|
+
blockchains.find(
|
|
158
|
+
(blockchain) => blockchain.name === token.blockchain
|
|
167
159
|
) ?? null,
|
|
168
160
|
}),
|
|
169
161
|
}));
|
|
@@ -174,22 +166,24 @@ export const useQuoteStore = createSelectors(
|
|
|
174
166
|
...(!amount && {
|
|
175
167
|
outputAmount: new BigNumber(0),
|
|
176
168
|
outputUsdValue: new BigNumber(0),
|
|
177
|
-
|
|
169
|
+
bestRoute: null,
|
|
178
170
|
}),
|
|
179
171
|
...(!!state.fromToken && {
|
|
180
172
|
inputUsdValue: getUsdValue(state.fromToken, amount),
|
|
181
173
|
}),
|
|
182
174
|
}));
|
|
183
175
|
},
|
|
184
|
-
retry: (pendingSwap
|
|
185
|
-
const { tokens, blockchains } = meta;
|
|
176
|
+
retry: (pendingSwap) => {
|
|
177
|
+
const { tokens, blockchains } = useMetaStore.getState().meta;
|
|
178
|
+
|
|
186
179
|
const {
|
|
187
180
|
fromBlockchain,
|
|
188
181
|
fromToken,
|
|
189
182
|
toBlockchain,
|
|
190
183
|
toToken,
|
|
191
184
|
inputAmount,
|
|
192
|
-
} =
|
|
185
|
+
} = createRetryRoute(pendingSwap, blockchains, tokens);
|
|
186
|
+
|
|
193
187
|
set({
|
|
194
188
|
fromBlockchain,
|
|
195
189
|
fromToken,
|
|
@@ -199,7 +193,7 @@ export const useQuoteStore = createSelectors(
|
|
|
199
193
|
outputUsdValue: new BigNumber(0),
|
|
200
194
|
toBlockchain,
|
|
201
195
|
toToken,
|
|
202
|
-
|
|
196
|
+
bestRoute: null,
|
|
203
197
|
});
|
|
204
198
|
},
|
|
205
199
|
switchFromAndTo: () =>
|
|
@@ -214,13 +208,14 @@ export const useQuoteStore = createSelectors(
|
|
|
214
208
|
state.outputAmount?.toString() || ''
|
|
215
209
|
),
|
|
216
210
|
})),
|
|
211
|
+
|
|
217
212
|
resetFromBlockchain: () =>
|
|
218
213
|
set(() => ({
|
|
219
214
|
fromToken: null,
|
|
220
215
|
fromBlockchain: null,
|
|
221
216
|
outputAmount: null,
|
|
222
217
|
outputUsdValue: null,
|
|
223
|
-
|
|
218
|
+
bestRoute: null,
|
|
224
219
|
})),
|
|
225
220
|
resetToBlockchain: () =>
|
|
226
221
|
set(() => ({
|
|
@@ -228,22 +223,20 @@ export const useQuoteStore = createSelectors(
|
|
|
228
223
|
toBlockchain: null,
|
|
229
224
|
outputAmount: null,
|
|
230
225
|
outputUsdValue: null,
|
|
231
|
-
|
|
226
|
+
bestRoute: null,
|
|
232
227
|
})),
|
|
233
|
-
|
|
228
|
+
setRouteWalletConfirmed: (flag) =>
|
|
234
229
|
set({
|
|
235
|
-
|
|
230
|
+
routeWalletsConfirmed: flag,
|
|
236
231
|
}),
|
|
237
232
|
setSelectedWallets: (wallets) => set({ selectedWallets: wallets }),
|
|
238
233
|
setCustomDestination: (address) => set({ customDestination: address }),
|
|
239
|
-
|
|
234
|
+
resetRouteWallets: () =>
|
|
240
235
|
set({
|
|
241
|
-
|
|
236
|
+
routeWalletsConfirmed: false,
|
|
242
237
|
selectedWallets: [],
|
|
243
238
|
customDestination: '',
|
|
244
239
|
}),
|
|
245
|
-
setQuoteWarningsConfirmed: (flag) =>
|
|
246
|
-
set({ quoteWarningsConfirmed: flag }),
|
|
247
240
|
}))
|
|
248
241
|
)
|
|
249
242
|
);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { TokenWithBalance } from '../components/TokenList';
|
|
2
|
+
import type { MetaResponse } from 'rango-sdk';
|
|
3
|
+
|
|
4
|
+
import { create } from 'zustand';
|
|
5
|
+
|
|
6
|
+
import { useAppStore } from './app';
|
|
7
|
+
import createSelectors from './selectors';
|
|
8
|
+
|
|
9
|
+
export type LoadingStatus = 'loading' | 'success' | 'failed';
|
|
10
|
+
|
|
11
|
+
export interface MetaState {
|
|
12
|
+
meta: MetaResponse & { tokens: TokenWithBalance[] };
|
|
13
|
+
loadingStatus: LoadingStatus;
|
|
14
|
+
fetchMeta: () => Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const useMetaStore = createSelectors(
|
|
18
|
+
create<MetaState>()((set) => ({
|
|
19
|
+
meta: { blockchains: [], popularTokens: [], swappers: [], tokens: [] },
|
|
20
|
+
loadingStatus: 'loading',
|
|
21
|
+
fetchMeta: async () => {
|
|
22
|
+
try {
|
|
23
|
+
await useAppStore.getState().fetch();
|
|
24
|
+
|
|
25
|
+
const state = useAppStore.getState();
|
|
26
|
+
const response: MetaResponse = {
|
|
27
|
+
blockchains: state.blockchains(),
|
|
28
|
+
tokens: state.tokens(),
|
|
29
|
+
popularTokens: state._popularTokens,
|
|
30
|
+
swappers: state._swappers,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
set({ meta: response, loadingStatus: 'success' });
|
|
34
|
+
} catch (error) {
|
|
35
|
+
set({ loadingStatus: 'failed' });
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
}))
|
|
39
|
+
);
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { type Language } from '@rango-dev/ui';
|
|
2
|
+
import { create } from 'zustand';
|
|
3
|
+
import { persist, subscribeWithSelector } from 'zustand/middleware';
|
|
4
|
+
|
|
5
|
+
import { BLOCKCHAIN_LIST_SIZE } from '../constants/configs';
|
|
6
|
+
import { DEFAULT_LANGUAGE } from '../constants/languages';
|
|
7
|
+
import { DEFAULT_SLIPPAGE } from '../constants/swapSettings';
|
|
8
|
+
import { removeDuplicateFrom } from '../utils/common';
|
|
9
|
+
|
|
10
|
+
import { useMetaStore } from './meta';
|
|
11
|
+
import createSelectors from './selectors';
|
|
12
|
+
|
|
13
|
+
export type ThemeMode = 'auto' | 'dark' | 'light';
|
|
14
|
+
|
|
15
|
+
export interface SettingsState {
|
|
16
|
+
/** Keeping a history of blockchains that user has selected (in Swap process) */
|
|
17
|
+
preferredBlockchains: string[];
|
|
18
|
+
slippage: number;
|
|
19
|
+
customSlippage: number | null;
|
|
20
|
+
infiniteApprove: boolean;
|
|
21
|
+
disabledLiquiditySources: string[];
|
|
22
|
+
theme: ThemeMode;
|
|
23
|
+
language: Language;
|
|
24
|
+
affiliateRef: string | null;
|
|
25
|
+
affiliatePercent: number | null;
|
|
26
|
+
affiliateWallets: { [key: string]: string } | null;
|
|
27
|
+
|
|
28
|
+
setSlippage: (slippage: number) => void;
|
|
29
|
+
setCustomSlippage: (customSlippage: number | null) => void;
|
|
30
|
+
toggleInfiniteApprove: () => void;
|
|
31
|
+
toggleLiquiditySource: (name: string) => void;
|
|
32
|
+
setTheme: (theme: ThemeMode) => void;
|
|
33
|
+
setLanguage: (language: Language) => void;
|
|
34
|
+
toggleAllLiquiditySources: (shouldReset?: boolean) => void;
|
|
35
|
+
setAffiliateRef: (affiliateRef: string | null) => void;
|
|
36
|
+
setAffiliatePercent: (affiliatePercent: number | null) => void;
|
|
37
|
+
setAffiliateWallets: (
|
|
38
|
+
affiliateWallets: { [key: string]: string } | null
|
|
39
|
+
) => void;
|
|
40
|
+
addPreferredBlockchain: (blockchain: string) => void;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const useSettingsStore = createSelectors(
|
|
44
|
+
create<SettingsState>()(
|
|
45
|
+
persist(
|
|
46
|
+
subscribeWithSelector((set, get) => ({
|
|
47
|
+
preferredBlockchains: [],
|
|
48
|
+
slippage: DEFAULT_SLIPPAGE,
|
|
49
|
+
customSlippage: null,
|
|
50
|
+
infiniteApprove: false,
|
|
51
|
+
affiliateRef: null,
|
|
52
|
+
affiliatePercent: null,
|
|
53
|
+
affiliateWallets: null,
|
|
54
|
+
disabledLiquiditySources: [],
|
|
55
|
+
theme: 'auto',
|
|
56
|
+
language: DEFAULT_LANGUAGE,
|
|
57
|
+
addPreferredBlockchain: (blockchain) => {
|
|
58
|
+
const currentPreferredBlockchains = get().preferredBlockchains;
|
|
59
|
+
|
|
60
|
+
const noNeedToDoAnything = currentPreferredBlockchains.find(
|
|
61
|
+
(preferredBlockchain, index) => {
|
|
62
|
+
const isSameBlockchain = preferredBlockchain === blockchain;
|
|
63
|
+
const isInVisibleList = index <= BLOCKCHAIN_LIST_SIZE - 1;
|
|
64
|
+
|
|
65
|
+
return isSameBlockchain && isInVisibleList;
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
if (noNeedToDoAnything) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const nextPreferredBlockchains: string[] =
|
|
74
|
+
currentPreferredBlockchains.filter((preferredBlockchain) => {
|
|
75
|
+
const isSameBlockchain = preferredBlockchain === blockchain;
|
|
76
|
+
|
|
77
|
+
return !isSameBlockchain;
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
set(() => ({
|
|
81
|
+
preferredBlockchains: [blockchain, ...nextPreferredBlockchains],
|
|
82
|
+
}));
|
|
83
|
+
},
|
|
84
|
+
setSlippage: (slippage) =>
|
|
85
|
+
set(() => ({
|
|
86
|
+
slippage: slippage,
|
|
87
|
+
})),
|
|
88
|
+
setCustomSlippage: (customSlippage) =>
|
|
89
|
+
set(() => ({
|
|
90
|
+
customSlippage: customSlippage,
|
|
91
|
+
})),
|
|
92
|
+
setAffiliateRef: (affiliateRef) =>
|
|
93
|
+
set(() => ({
|
|
94
|
+
affiliateRef,
|
|
95
|
+
})),
|
|
96
|
+
setAffiliatePercent: (affiliatePercent) =>
|
|
97
|
+
set(() => ({
|
|
98
|
+
affiliatePercent,
|
|
99
|
+
})),
|
|
100
|
+
|
|
101
|
+
setAffiliateWallets: (affiliateWallets) =>
|
|
102
|
+
set(() => ({
|
|
103
|
+
affiliateWallets,
|
|
104
|
+
})),
|
|
105
|
+
toggleAllLiquiditySources: (shouldReset?: boolean) =>
|
|
106
|
+
set((state) => {
|
|
107
|
+
if (shouldReset) {
|
|
108
|
+
return { disabledLiquiditySources: [] };
|
|
109
|
+
}
|
|
110
|
+
const { swappers } = useMetaStore.getState().meta;
|
|
111
|
+
const swappersGroup = removeDuplicateFrom(
|
|
112
|
+
swappers.map((swapper) => swapper.swapperGroup)
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
if (
|
|
116
|
+
swappersGroup.length === state.disabledLiquiditySources.length
|
|
117
|
+
) {
|
|
118
|
+
return { disabledLiquiditySources: [] };
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return {
|
|
122
|
+
disabledLiquiditySources: swappersGroup,
|
|
123
|
+
};
|
|
124
|
+
}),
|
|
125
|
+
toggleInfiniteApprove: () =>
|
|
126
|
+
set((state) => ({
|
|
127
|
+
infiniteApprove: !state.infiniteApprove,
|
|
128
|
+
})),
|
|
129
|
+
toggleLiquiditySource: (name) =>
|
|
130
|
+
set((state) => {
|
|
131
|
+
if (state.disabledLiquiditySources.includes(name)) {
|
|
132
|
+
return {
|
|
133
|
+
disabledLiquiditySources: state.disabledLiquiditySources.filter(
|
|
134
|
+
(liquiditySource) => liquiditySource != name
|
|
135
|
+
),
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
disabledLiquiditySources:
|
|
140
|
+
state.disabledLiquiditySources.concat(name),
|
|
141
|
+
};
|
|
142
|
+
}),
|
|
143
|
+
setTheme: (theme) =>
|
|
144
|
+
set(() => ({
|
|
145
|
+
theme,
|
|
146
|
+
})),
|
|
147
|
+
setLanguage: (language) =>
|
|
148
|
+
set(() => ({
|
|
149
|
+
language,
|
|
150
|
+
})),
|
|
151
|
+
})),
|
|
152
|
+
{
|
|
153
|
+
name: 'user-settings',
|
|
154
|
+
skipHydration: true,
|
|
155
|
+
}
|
|
156
|
+
)
|
|
157
|
+
)
|
|
158
|
+
);
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import type { WidgetConfig } from '../../types';
|
|
2
|
-
import type {
|
|
2
|
+
import type { StateCreator } from 'zustand';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
apiKey: '',
|
|
6
|
-
multiWallets: true,
|
|
7
|
-
enableNewLiquiditySources: true,
|
|
8
|
-
customDestination: true,
|
|
9
|
-
};
|
|
4
|
+
const initConfig: WidgetConfig = { apiKey: '' };
|
|
10
5
|
|
|
11
6
|
export type ConfigSlice = {
|
|
12
7
|
config: WidgetConfig;
|
|
@@ -14,24 +9,18 @@ export type ConfigSlice = {
|
|
|
14
9
|
updateConfig: (config: WidgetConfig) => void;
|
|
15
10
|
};
|
|
16
11
|
|
|
17
|
-
export const createConfigSlice:
|
|
18
|
-
|
|
19
|
-
ConfigSlice,
|
|
20
|
-
ConfigSlice
|
|
21
|
-
> = (initialData, set, get) => {
|
|
22
|
-
return {
|
|
23
|
-
config: { ...DEFAULT_CONFIG, ...initialData },
|
|
12
|
+
export const createConfigSlice: StateCreator<ConfigSlice> = (set, get) => ({
|
|
13
|
+
config: initConfig,
|
|
24
14
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
15
|
+
// Actions
|
|
16
|
+
updateConfig: (nextConfig: WidgetConfig) => {
|
|
17
|
+
const currentConfig = get().config;
|
|
28
18
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
};
|
|
19
|
+
set({
|
|
20
|
+
config: {
|
|
21
|
+
...currentConfig,
|
|
22
|
+
...nextConfig,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
});
|