@rango-dev/widget-embedded 0.12.1-next.6 → 0.12.1-next.8
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/dist/Wallets.d.ts +4 -3
- package/dist/Wallets.d.ts.map +1 -1
- package/dist/Widget.d.ts +3 -2
- package/dist/Widget.d.ts.map +1 -1
- package/dist/components/AppRoutes.d.ts +1 -1
- package/dist/components/AppRoutes.d.ts.map +1 -1
- package/dist/components/BlockchainList/BlockchainList.d.ts +4 -0
- package/dist/components/BlockchainList/BlockchainList.d.ts.map +1 -0
- package/dist/components/BlockchainList/BlockchainList.helpers.d.ts +4 -0
- package/dist/components/BlockchainList/BlockchainList.helpers.d.ts.map +1 -0
- package/dist/components/BlockchainList/BlockchainList.styles.d.ts +297 -0
- package/dist/components/BlockchainList/BlockchainList.styles.d.ts.map +1 -0
- package/dist/components/BlockchainList/BlockchainList.types.d.ts +8 -0
- package/dist/components/BlockchainList/BlockchainList.types.d.ts.map +1 -0
- package/dist/components/BlockchainList/LoadingBlockchainList.d.ts +3 -0
- package/dist/components/BlockchainList/LoadingBlockchainList.d.ts.map +1 -0
- package/dist/components/BlockchainList/index.d.ts +2 -0
- package/dist/components/BlockchainList/index.d.ts.map +1 -0
- package/dist/components/BlockchainsChip/BlockchainsChip.d.ts +5 -0
- package/dist/components/BlockchainsChip/BlockchainsChip.d.ts.map +1 -0
- package/dist/components/BlockchainsChip/BlockchainsChip.styles.d.ts +151 -0
- package/dist/components/BlockchainsChip/BlockchainsChip.styles.d.ts.map +1 -0
- package/dist/components/BlockchainsChip/BlockchainsChip.types.d.ts +6 -0
- package/dist/components/BlockchainsChip/BlockchainsChip.types.d.ts.map +1 -0
- package/dist/components/BlockchainsChip/index.d.ts +2 -0
- package/dist/components/BlockchainsChip/index.d.ts.map +1 -0
- package/dist/components/BlockchainsSection/BlockchainSection.helpers.d.ts +3 -0
- package/dist/components/BlockchainsSection/BlockchainSection.helpers.d.ts.map +1 -0
- package/dist/components/BlockchainsSection/BlockchainsSection.d.ts +4 -0
- package/dist/components/BlockchainsSection/BlockchainsSection.d.ts.map +1 -0
- package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts +149 -0
- package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts.map +1 -0
- package/dist/components/BlockchainsSection/BlockchainsSection.types.d.ts +9 -0
- package/dist/components/BlockchainsSection/BlockchainsSection.types.d.ts.map +1 -0
- package/dist/components/BlockchainsSection/index.d.ts +2 -0
- package/dist/components/BlockchainsSection/index.d.ts.map +1 -0
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts +6 -0
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts.map +1 -0
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +2522 -0
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts.map +1 -0
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts +4 -0
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -0
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.types.d.ts +11 -0
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.types.d.ts.map +1 -0
- package/dist/components/ConfirmWalletsModal/WalletList.d.ts +4 -0
- package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -0
- package/dist/components/ConfirmWalletsModal/WalletList.styles.d.ts +445 -0
- package/dist/components/ConfirmWalletsModal/WalletList.styles.d.ts.map +1 -0
- package/dist/components/ConfirmWalletsModal/WalletList.type.d.ts +12 -0
- package/dist/components/ConfirmWalletsModal/WalletList.type.d.ts.map +1 -0
- package/dist/components/HeaderButtons/BackButton.d.ts +5 -0
- package/dist/components/HeaderButtons/BackButton.d.ts.map +1 -0
- package/dist/components/HeaderButtons/CancelButton.d.ts +5 -0
- package/dist/components/HeaderButtons/CancelButton.d.ts.map +1 -0
- package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts +875 -0
- package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts.map +1 -0
- package/dist/components/HeaderButtons/HeaderButtons.types.d.ts +12 -0
- package/dist/components/HeaderButtons/HeaderButtons.types.d.ts.map +1 -0
- package/dist/components/HeaderButtons/HomeButtons.d.ts +4 -0
- package/dist/components/HeaderButtons/HomeButtons.d.ts.map +1 -0
- package/dist/components/HeaderButtons/UnreadNotificationsBadge.d.ts +3 -0
- package/dist/components/HeaderButtons/UnreadNotificationsBadge.d.ts.map +1 -0
- package/dist/components/HeaderButtons/WalletButton.d.ts +5 -0
- package/dist/components/HeaderButtons/WalletButton.d.ts.map +1 -0
- package/dist/components/HeaderButtons/index.d.ts +5 -0
- package/dist/components/HeaderButtons/index.d.ts.map +1 -0
- package/dist/components/Layout/Layout.d.ts +7 -0
- package/dist/components/Layout/Layout.d.ts.map +1 -0
- package/dist/components/Layout/Layout.styles.d.ts +449 -0
- package/dist/components/Layout/Layout.styles.d.ts.map +1 -0
- package/dist/components/Layout/Layout.types.d.ts +17 -0
- package/dist/components/Layout/Layout.types.d.ts.map +1 -0
- package/dist/components/Layout/index.d.ts +2 -0
- package/dist/components/Layout/index.d.ts.map +1 -0
- package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.d.ts +3 -0
- package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.d.ts.map +1 -0
- package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.d.ts +150 -0
- package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.d.ts.map +1 -0
- package/dist/components/LoadingLiquiditySourceList/index.d.ts +2 -0
- package/dist/components/LoadingLiquiditySourceList/index.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/NoRoutes/NoRoutes.styles.d.ts +445 -0
- package/dist/components/NoRoutes/NoRoutes.styles.d.ts.map +1 -0
- package/dist/components/NoRoutes/NoRoutes.types.d.ts +20 -0
- 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 +3 -0
- package/dist/components/NotificationContent/NotificationContent.d.ts.map +1 -0
- package/dist/components/NotificationContent/NotificationContent.styles.d.ts +593 -0
- package/dist/components/NotificationContent/NotificationContent.styles.d.ts.map +1 -0
- package/dist/components/NotificationContent/NotificationNotFound.d.ts +3 -0
- package/dist/components/NotificationContent/NotificationNotFound.d.ts.map +1 -0
- package/dist/components/NotificationContent/index.d.ts +2 -0
- package/dist/components/NotificationContent/index.d.ts.map +1 -0
- package/dist/components/RouteErrors/RouteErrors.d.ts +4 -0
- package/dist/components/RouteErrors/RouteErrors.d.ts.map +1 -0
- package/dist/components/RouteErrors/RouteErrors.styles.d.ts +593 -0
- package/dist/components/RouteErrors/RouteErrors.styles.d.ts.map +1 -0
- package/dist/components/RouteErrors/RouteErrors.types.d.ts +22 -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/SearchInput/SearchInput.d.ts +4 -0
- package/dist/components/SearchInput/SearchInput.d.ts.map +1 -0
- package/dist/components/SearchInput/SearchInput.styles.d.ts +149 -0
- package/dist/components/SearchInput/SearchInput.styles.d.ts.map +1 -0
- package/dist/components/SearchInput/SearchInput.types.d.ts +10 -0
- package/dist/components/SearchInput/SearchInput.types.d.ts.map +1 -0
- package/dist/components/SearchInput/index.d.ts +2 -0
- package/dist/components/SearchInput/index.d.ts.map +1 -0
- package/dist/components/SelectableCategoryList/SelectableCategoryList.d.ts +4 -0
- package/dist/components/SelectableCategoryList/SelectableCategoryList.d.ts.map +1 -0
- package/dist/components/SelectableCategoryList/SelectableCategoryList.helpers.d.ts +4 -0
- package/dist/components/SelectableCategoryList/SelectableCategoryList.helpers.d.ts.map +1 -0
- package/dist/components/SelectableCategoryList/SelectableCategoryList.styles.d.ts +445 -0
- package/dist/components/SelectableCategoryList/SelectableCategoryList.styles.d.ts.map +1 -0
- package/dist/components/SelectableCategoryList/SelectableCategoryList.types.d.ts +12 -0
- package/dist/components/SelectableCategoryList/SelectableCategoryList.types.d.ts.map +1 -0
- package/dist/components/SelectableCategoryList/index.d.ts +2 -0
- package/dist/components/SelectableCategoryList/index.d.ts.map +1 -0
- package/dist/components/SettingsContainer/SettingsContainer.style.d.ts +741 -0
- package/dist/components/SettingsContainer/SettingsContainer.style.d.ts.map +1 -0
- package/dist/components/SettingsContainer/index.d.ts +2 -0
- package/dist/components/SettingsContainer/index.d.ts.map +1 -0
- package/dist/components/Slippage/Slippage.d.ts +3 -0
- package/dist/components/Slippage/Slippage.d.ts.map +1 -0
- package/dist/components/Slippage/Slippage.styles.d.ts +593 -0
- package/dist/components/Slippage/Slippage.styles.d.ts.map +1 -0
- package/dist/components/Slippage/SlippageTooltipContent.d.ts +3 -0
- package/dist/components/Slippage/SlippageTooltipContent.d.ts.map +1 -0
- package/dist/components/Slippage/index.d.ts +2 -0
- package/dist/components/Slippage/index.d.ts.map +1 -0
- package/dist/components/SwapDetails/SwapDetails.Placeholder.d.ts +4 -0
- package/dist/components/SwapDetails/SwapDetails.Placeholder.d.ts.map +1 -0
- package/dist/components/SwapDetails/SwapDetails.d.ts +4 -0
- package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -0
- package/dist/components/SwapDetails/SwapDetails.helpers.d.ts +15 -0
- package/dist/components/SwapDetails/SwapDetails.helpers.d.ts.map +1 -0
- package/dist/components/SwapDetails/SwapDetails.styles.d.ts +1037 -0
- package/dist/components/SwapDetails/SwapDetails.styles.d.ts.map +1 -0
- package/dist/components/SwapDetails/SwapDetails.types.d.ts +12 -0
- package/dist/components/SwapDetails/SwapDetails.types.d.ts.map +1 -0
- package/dist/components/SwapDetails/index.d.ts +2 -0
- package/dist/components/SwapDetails/index.d.ts.map +1 -0
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.Failed.d.ts +4 -0
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.Failed.d.ts.map +1 -0
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.Warning.d.ts +4 -0
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.Warning.d.ts.map +1 -0
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.d.ts +4 -0
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.d.ts.map +1 -0
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.styles.d.ts +149 -0
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.styles.d.ts.map +1 -0
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.types.d.ts +20 -0
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.types.d.ts.map +1 -0
- package/dist/components/SwapDetailsAlerts/index.d.ts +3 -0
- package/dist/components/SwapDetailsAlerts/index.d.ts.map +1 -0
- package/dist/components/SwapDetailsModal/SwapDetailsCompleteModal.d.ts +4 -0
- package/dist/components/SwapDetailsModal/SwapDetailsCompleteModal.d.ts.map +1 -0
- package/dist/components/SwapDetailsModal/SwapDetailsModal.Cancel.d.ts +4 -0
- package/dist/components/SwapDetailsModal/SwapDetailsModal.Cancel.d.ts.map +1 -0
- package/dist/components/SwapDetailsModal/SwapDetailsModal.Delete.d.ts +4 -0
- package/dist/components/SwapDetailsModal/SwapDetailsModal.Delete.d.ts.map +1 -0
- package/dist/components/SwapDetailsModal/SwapDetailsModal.WalletState.d.ts +4 -0
- package/dist/components/SwapDetailsModal/SwapDetailsModal.WalletState.d.ts.map +1 -0
- package/dist/components/SwapDetailsModal/SwapDetailsModal.d.ts +4 -0
- package/dist/components/SwapDetailsModal/SwapDetailsModal.d.ts.map +1 -0
- package/dist/components/SwapDetailsModal/SwapDetailsModal.helpers.d.ts +4 -0
- package/dist/components/SwapDetailsModal/SwapDetailsModal.helpers.d.ts.map +1 -0
- package/dist/components/SwapDetailsModal/SwapDetailsModal.styles.d.ts +149 -0
- package/dist/components/SwapDetailsModal/SwapDetailsModal.styles.d.ts.map +1 -0
- package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts +45 -0
- package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts.map +1 -0
- package/dist/components/SwapDetailsModal/index.d.ts +4 -0
- package/dist/components/SwapDetailsModal/index.d.ts.map +1 -0
- package/dist/components/SwapsGroup/SwapsGroup.d.ts +4 -0
- package/dist/components/SwapsGroup/SwapsGroup.d.ts.map +1 -0
- package/dist/components/SwapsGroup/SwapsGroup.styles.d.ts +593 -0
- package/dist/components/SwapsGroup/SwapsGroup.styles.d.ts.map +1 -0
- package/dist/components/SwapsGroup/SwapsGroup.types.d.ts +12 -0
- package/dist/components/SwapsGroup/SwapsGroup.types.d.ts.map +1 -0
- package/dist/components/SwapsGroup/index.d.ts +2 -0
- package/dist/components/SwapsGroup/index.d.ts.map +1 -0
- package/dist/components/SwitchFromAndTo.d.ts +1 -1
- package/dist/components/SwitchFromAndTo.d.ts.map +1 -1
- package/dist/components/TokenList/LoadingTokenList.d.ts +4 -0
- package/dist/components/TokenList/LoadingTokenList.d.ts.map +1 -0
- package/dist/components/TokenList/TokenList.d.ts +4 -0
- package/dist/components/TokenList/TokenList.d.ts.map +1 -0
- package/dist/components/TokenList/TokenList.helpers.d.ts +3 -0
- package/dist/components/TokenList/TokenList.helpers.d.ts.map +1 -0
- package/dist/components/TokenList/TokenList.styles.d.ts +1334 -0
- package/dist/components/TokenList/TokenList.styles.d.ts.map +1 -0
- package/dist/components/TokenList/TokenList.types.d.ts +40 -0
- package/dist/components/TokenList/TokenList.types.d.ts.map +1 -0
- package/dist/components/TokenList/index.d.ts +3 -0
- package/dist/components/TokenList/index.d.ts.map +1 -0
- package/dist/components/UpdateUrl.d.ts.map +1 -1
- package/dist/components/WalletModal/WalletModal.d.ts +4 -0
- package/dist/components/WalletModal/WalletModal.d.ts.map +1 -0
- package/dist/components/WalletModal/WalletModal.types.d.ts +10 -0
- package/dist/components/WalletModal/WalletModal.types.d.ts.map +1 -0
- package/dist/components/WalletModal/WalletModalContent.d.ts +4 -0
- package/dist/components/WalletModal/WalletModalContent.d.ts.map +1 -0
- package/dist/components/WalletModal/WalletModalContent.styles.d.ts +593 -0
- package/dist/components/WalletModal/WalletModalContent.styles.d.ts.map +1 -0
- package/dist/components/WalletModal/index.d.ts +2 -0
- package/dist/components/WalletModal/index.d.ts.map +1 -0
- package/dist/components/WidgetEvents.d.ts.map +1 -1
- package/dist/constants/errors.d.ts +29 -0
- package/dist/constants/errors.d.ts.map +1 -1
- package/dist/constants/messages.d.ts +7 -0
- package/dist/constants/messages.d.ts.map +1 -0
- package/dist/constants/navigationRoutes.d.ts +8 -4
- package/dist/constants/navigationRoutes.d.ts.map +1 -1
- package/dist/constants/routing.d.ts +3 -0
- package/dist/constants/routing.d.ts.map +1 -0
- package/dist/constants/searchParams.d.ts +2 -2
- package/dist/constants/searchParams.d.ts.map +1 -1
- package/dist/constants/swapSettings.d.ts.map +1 -1
- package/dist/constants/wallets.d.ts +3 -0
- package/dist/constants/wallets.d.ts.map +1 -0
- package/dist/constants/warnings.d.ts +3 -0
- package/dist/constants/warnings.d.ts.map +1 -0
- package/dist/hooks/useConfirmSwap.d.ts +14 -6
- package/dist/hooks/useConfirmSwap.d.ts.map +1 -1
- package/dist/hooks/useFetchBestRoute.d.ts +9 -0
- package/dist/hooks/useFetchBestRoute.d.ts.map +1 -0
- package/dist/hooks/useNavigateBack.d.ts.map +1 -1
- package/dist/hooks/useSwapInput.d.ts +12 -0
- package/dist/hooks/useSwapInput.d.ts.map +1 -0
- package/dist/hooks/useTheme.d.ts +3 -26
- package/dist/hooks/useTheme.d.ts.map +1 -1
- package/dist/hooks/useWalletList.d.ts +20 -0
- package/dist/hooks/useWalletList.d.ts.map +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/dist/pages/ConfirmSwapPage.d.ts +6 -3
- 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 +3 -0
- package/dist/pages/LanguagePage.d.ts.map +1 -0
- package/dist/pages/LiquiditySourcePage.d.ts +8 -0
- package/dist/pages/LiquiditySourcePage.d.ts.map +1 -0
- package/dist/pages/SelectBlockchainPage.d.ts +8 -0
- package/dist/pages/SelectBlockchainPage.d.ts.map +1 -0
- package/dist/pages/SelectSwapItemsPage.d.ts +11 -0
- package/dist/pages/SelectSwapItemsPage.d.ts.map +1 -0
- package/dist/pages/SettingsPage.d.ts.map +1 -1
- package/dist/pages/SwapDetailsPage.d.ts.map +1 -1
- package/dist/pages/ThemePage.d.ts +3 -0
- package/dist/pages/ThemePage.d.ts.map +1 -0
- package/dist/pages/WalletsPage.d.ts +4 -2
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/store/bestRoute.d.ts +32 -19
- package/dist/store/bestRoute.d.ts.map +1 -1
- package/dist/store/meta.d.ts +10 -3
- package/dist/store/meta.d.ts.map +1 -1
- package/dist/store/notification.d.ts +38 -0
- package/dist/store/notification.d.ts.map +1 -0
- package/dist/store/settings.d.ts +2 -2
- package/dist/store/settings.d.ts.map +1 -1
- package/dist/store/ui.d.ts +0 -2
- package/dist/store/ui.d.ts.map +1 -1
- package/dist/store/wallets.d.ts +14 -12
- package/dist/store/wallets.d.ts.map +1 -1
- package/dist/types/config.d.ts +8 -6
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/notification.d.ts +22 -0
- package/dist/types/notification.d.ts.map +1 -0
- package/dist/types/routing.d.ts +30 -23
- package/dist/types/routing.d.ts.map +1 -1
- package/dist/types/swap.d.ts +8 -1
- package/dist/types/swap.d.ts.map +1 -1
- package/dist/utils/common.d.ts +5 -0
- package/dist/utils/common.d.ts.map +1 -1
- package/dist/utils/date.d.ts +1 -1
- package/dist/utils/date.d.ts.map +1 -1
- package/dist/utils/meta.d.ts +3 -0
- package/dist/utils/meta.d.ts.map +1 -0
- package/dist/utils/numbers.d.ts +2 -1
- package/dist/utils/numbers.d.ts.map +1 -1
- package/dist/utils/routing.d.ts +5 -5
- package/dist/utils/routing.d.ts.map +1 -1
- package/dist/utils/settings.d.ts +10 -0
- package/dist/utils/settings.d.ts.map +1 -0
- package/dist/utils/swap.d.ts +28 -13
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +20 -14
- package/dist/utils/wallets.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/Wallets.tsx +23 -17
- package/src/Widget.tsx +21 -27
- package/src/components/AppRoutes.tsx +54 -19
- package/src/components/BlockchainList/BlockchainList.helpers.ts +37 -0
- package/src/components/BlockchainList/BlockchainList.styles.ts +18 -0
- package/src/components/BlockchainList/BlockchainList.tsx +76 -0
- package/src/components/BlockchainList/BlockchainList.types.ts +8 -0
- package/src/components/BlockchainList/LoadingBlockchainList.tsx +20 -0
- package/src/components/BlockchainList/index.ts +1 -0
- package/src/components/BlockchainsChip/BlockchainsChip.styles.ts +30 -0
- package/src/components/BlockchainsChip/BlockchainsChip.tsx +15 -0
- package/src/components/BlockchainsChip/BlockchainsChip.types.ts +4 -0
- package/src/components/BlockchainsChip/index.ts +1 -0
- package/src/components/BlockchainsSection/BlockchainSection.helpers.ts +20 -0
- package/src/components/BlockchainsSection/BlockchainsSection.styles.ts +7 -0
- package/src/components/BlockchainsSection/BlockchainsSection.tsx +100 -0
- package/src/components/BlockchainsSection/BlockchainsSection.types.ts +9 -0
- package/src/components/BlockchainsSection/index.ts +1 -0
- package/src/components/ConfirmWalletsModal/ConfirmWallets.helpers.ts +64 -0
- package/src/components/ConfirmWalletsModal/ConfirmWallets.styles.ts +169 -0
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +451 -0
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.types.ts +11 -0
- package/src/components/ConfirmWalletsModal/WalletList.styles.ts +34 -0
- package/src/components/ConfirmWalletsModal/WalletList.tsx +250 -0
- package/src/components/ConfirmWalletsModal/WalletList.type.ts +12 -0
- package/src/components/HeaderButtons/BackButton.tsx +16 -0
- package/src/components/HeaderButtons/CancelButton.tsx +21 -0
- package/src/components/HeaderButtons/HeaderButtons.styles.ts +40 -0
- package/src/components/HeaderButtons/HeaderButtons.types.ts +11 -0
- package/src/components/HeaderButtons/HomeButtons.tsx +68 -0
- package/src/components/HeaderButtons/UnreadNotificationsBadge.tsx +21 -0
- package/src/components/HeaderButtons/WalletButton.tsx +20 -0
- package/src/components/HeaderButtons/index.ts +4 -0
- package/src/components/Layout/Layout.styles.ts +51 -0
- package/src/components/Layout/Layout.tsx +89 -0
- package/src/components/Layout/Layout.types.ts +20 -0
- package/src/components/Layout/index.ts +1 -0
- package/src/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.ts +5 -0
- package/src/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.tsx +23 -0
- package/src/components/LoadingLiquiditySourceList/index.ts +1 -0
- package/src/components/NoRoutes/NoRoutes.helper.ts +50 -0
- package/src/components/NoRoutes/NoRoutes.styles.ts +15 -0
- package/src/components/NoRoutes/NoRoutes.tsx +81 -0
- package/src/components/NoRoutes/NoRoutes.types.ts +21 -0
- package/src/components/NoRoutes/index.ts +1 -0
- package/src/components/NotificationContent/NotificationContent.styles.ts +34 -0
- package/src/components/NotificationContent/NotificationContent.tsx +112 -0
- package/src/components/NotificationContent/NotificationNotFound.tsx +17 -0
- package/src/components/NotificationContent/index.ts +1 -0
- package/src/components/RouteErrors/RouteErrors.styles.ts +27 -0
- package/src/components/RouteErrors/RouteErrors.tsx +68 -0
- package/src/components/RouteErrors/RouteErrors.types.ts +27 -0
- package/src/components/RouteErrors/RouteErrorsModal.tsx +101 -0
- package/src/components/RouteErrors/RouteErrorsModalItem.tsx +24 -0
- package/src/components/RouteErrors/index.ts +1 -0
- package/src/components/SearchInput/SearchInput.styles.ts +9 -0
- package/src/components/SearchInput/SearchInput.tsx +51 -0
- package/src/components/SearchInput/SearchInput.types.ts +10 -0
- package/src/components/SearchInput/index.ts +1 -0
- package/src/components/SelectableCategoryList/SelectableCategoryList.helpers.ts +20 -0
- package/src/components/SelectableCategoryList/SelectableCategoryList.styles.ts +21 -0
- package/src/components/SelectableCategoryList/SelectableCategoryList.tsx +79 -0
- package/src/components/SelectableCategoryList/SelectableCategoryList.types.ts +12 -0
- package/src/components/SelectableCategoryList/index.ts +1 -0
- package/src/components/SettingsContainer/SettingsContainer.style.ts +33 -0
- package/src/components/SettingsContainer/index.ts +7 -0
- package/src/components/Slippage/Slippage.styles.ts +24 -0
- package/src/components/Slippage/Slippage.tsx +90 -0
- package/src/components/Slippage/SlippageTooltipContent.tsx +23 -0
- package/src/components/Slippage/index.ts +1 -0
- package/src/components/SwapDetails/SwapDetails.Placeholder.tsx +43 -0
- package/src/components/SwapDetails/SwapDetails.helpers.tsx +102 -0
- package/src/components/SwapDetails/SwapDetails.styles.ts +76 -0
- package/src/components/SwapDetails/SwapDetails.tsx +387 -0
- package/src/components/SwapDetails/SwapDetails.types.ts +12 -0
- package/src/components/SwapDetails/index.ts +1 -0
- package/src/components/SwapDetailsAlerts/SwapDetailsAlerts.Failed.tsx +36 -0
- package/src/components/SwapDetailsAlerts/SwapDetailsAlerts.Warning.tsx +55 -0
- package/src/components/SwapDetailsAlerts/SwapDetailsAlerts.styles.ts +7 -0
- package/src/components/SwapDetailsAlerts/SwapDetailsAlerts.tsx +74 -0
- package/src/components/SwapDetailsAlerts/SwapDetailsAlerts.types.ts +28 -0
- package/src/components/SwapDetailsAlerts/index.ts +2 -0
- package/src/components/SwapDetailsModal/SwapDetailsCompleteModal.tsx +101 -0
- package/src/components/SwapDetailsModal/SwapDetailsModal.Cancel.tsx +34 -0
- package/src/components/SwapDetailsModal/SwapDetailsModal.Delete.tsx +34 -0
- package/src/components/SwapDetailsModal/SwapDetailsModal.WalletState.tsx +35 -0
- package/src/components/SwapDetailsModal/SwapDetailsModal.helpers.tsx +22 -0
- package/src/components/SwapDetailsModal/SwapDetailsModal.styles.ts +6 -0
- package/src/components/SwapDetailsModal/SwapDetailsModal.tsx +42 -0
- package/src/components/SwapDetailsModal/SwapDetailsModal.types.ts +53 -0
- package/src/components/SwapDetailsModal/index.ts +3 -0
- package/src/components/SwapsGroup/SwapsGroup.styles.ts +26 -0
- package/src/components/SwapsGroup/SwapsGroup.tsx +125 -0
- package/src/components/SwapsGroup/SwapsGroup.types.ts +13 -0
- package/src/components/SwapsGroup/index.ts +1 -0
- package/src/components/SwitchFromAndTo.tsx +24 -8
- package/src/components/TokenList/LoadingTokenList.tsx +34 -0
- package/src/components/TokenList/TokenList.helpers.ts +13 -0
- package/src/components/TokenList/TokenList.styles.ts +115 -0
- package/src/components/TokenList/TokenList.tsx +269 -0
- package/src/components/TokenList/TokenList.types.ts +47 -0
- package/src/components/TokenList/index.ts +2 -0
- package/src/components/UpdateUrl.tsx +40 -22
- package/src/components/WalletModal/WalletModal.tsx +20 -0
- package/src/components/WalletModal/WalletModal.types.ts +11 -0
- package/src/components/WalletModal/WalletModalContent.styles.ts +44 -0
- package/src/components/WalletModal/WalletModalContent.tsx +54 -0
- package/src/components/WalletModal/index.ts +1 -0
- package/src/components/WidgetEvents.tsx +30 -4
- package/src/constants/errors.ts +56 -1
- package/src/constants/messages.ts +8 -0
- package/src/constants/navigationRoutes.ts +8 -4
- package/src/constants/routing.ts +2 -0
- package/src/constants/searchParams.ts +2 -2
- package/src/constants/swapSettings.ts +5 -1
- package/src/constants/wallets.ts +3 -0
- package/src/constants/warnings.ts +26 -0
- package/src/hooks/useConfirmSwap.ts +251 -220
- package/src/hooks/useFetchBestRoute.ts +38 -0
- package/src/hooks/useNavigateBack.ts +15 -9
- package/src/hooks/useSwapInput.ts +102 -0
- package/src/hooks/useTheme.ts +59 -60
- package/src/hooks/useWalletList.ts +125 -0
- package/src/pages/ConfirmSwapPage.tsx +470 -228
- package/src/pages/HistoryPage.tsx +104 -15
- package/src/pages/Home.tsx +345 -111
- package/src/pages/LanguagePage.tsx +83 -0
- package/src/pages/LiquiditySourcePage.tsx +160 -0
- package/src/pages/SelectBlockchainPage.tsx +77 -0
- package/src/pages/SelectSwapItemsPage.tsx +153 -0
- package/src/pages/SettingsPage.tsx +144 -72
- package/src/pages/SwapDetailsPage.tsx +35 -143
- package/src/pages/ThemePage.tsx +96 -0
- package/src/pages/WalletsPage.tsx +73 -124
- package/src/store/bestRoute.ts +85 -180
- package/src/store/meta.ts +23 -3
- package/src/store/notification.ts +77 -0
- package/src/store/settings.ts +20 -13
- package/src/store/ui.ts +1 -5
- package/src/store/wallets.ts +92 -76
- package/src/types/config.ts +9 -7
- package/src/types/notification.ts +33 -0
- package/src/types/routing.ts +29 -28
- package/src/types/swap.ts +9 -1
- package/src/utils/common.ts +53 -3
- package/src/utils/date.ts +15 -18
- package/src/utils/meta.ts +9 -0
- package/src/utils/numbers.ts +63 -18
- package/src/utils/routing.ts +30 -14
- package/src/utils/settings.ts +57 -0
- package/src/utils/swap.ts +166 -95
- package/src/utils/wallets.ts +159 -110
- package/dist/components/ConfirmSwapErrors.d.ts +0 -4
- package/dist/components/ConfirmSwapErrors.d.ts.map +0 -1
- package/dist/components/ConfirmSwapWarnings.d.ts +0 -3
- package/dist/components/ConfirmSwapWarnings.d.ts.map +0 -1
- package/dist/components/Layout.d.ts +0 -7
- package/dist/components/Layout.d.ts.map +0 -1
- package/dist/pages/LiquiditySourcesPage.d.ts +0 -7
- package/dist/pages/LiquiditySourcesPage.d.ts.map +0 -1
- package/dist/pages/SelectChainPage.d.ts +0 -8
- package/dist/pages/SelectChainPage.d.ts.map +0 -1
- package/dist/pages/SelectTokenPage.d.ts +0 -15
- package/dist/pages/SelectTokenPage.d.ts.map +0 -1
- package/src/components/ConfirmSwapErrors.tsx +0 -34
- package/src/components/ConfirmSwapWarnings.tsx +0 -22
- package/src/components/Layout.tsx +0 -105
- package/src/pages/LiquiditySourcesPage.tsx +0 -63
- package/src/pages/SelectChainPage.tsx +0 -42
- package/src/pages/SelectTokenPage.tsx +0 -64
|
@@ -1,29 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
SecondaryPage,
|
|
4
|
-
styled,
|
|
5
|
-
Wallet,
|
|
6
|
-
WalletState,
|
|
7
|
-
WalletInfo,
|
|
8
|
-
} from '@rango-dev/ui';
|
|
9
|
-
import React, { useEffect, useRef, useState } from 'react';
|
|
10
|
-
import { getlistWallet, sortWalletsBasedOnState } from '../utils/wallets';
|
|
11
|
-
import {
|
|
12
|
-
WalletType,
|
|
13
|
-
WalletTypes,
|
|
14
|
-
detectMobileScreens,
|
|
15
|
-
} from '@rango-dev/wallets-shared';
|
|
16
|
-
import { useWallets } from '@rango-dev/wallets-react';
|
|
1
|
+
import type { WidgetConfig } from '../types';
|
|
2
|
+
import type { WalletType } from '@rango-dev/wallets-shared';
|
|
17
3
|
|
|
18
|
-
import { useUiStore } from '../store/ui';
|
|
19
|
-
import { useNavigateBack } from '../hooks/useNavigateBack';
|
|
20
|
-
import { navigationRoutes } from '../constants/navigationRoutes';
|
|
21
4
|
import { i18n } from '@lingui/core';
|
|
5
|
+
import { styled, Typography, Wallet, WalletState } from '@rango-dev/ui';
|
|
6
|
+
import React, { Fragment, useState } from 'react';
|
|
7
|
+
|
|
8
|
+
import { Layout } from '../components/Layout';
|
|
9
|
+
import { WalletModal } from '../components/WalletModal';
|
|
10
|
+
import { navigationRoutes } from '../constants/navigationRoutes';
|
|
11
|
+
import { useNavigateBack } from '../hooks/useNavigateBack';
|
|
12
|
+
import { useWalletList } from '../hooks/useWalletList';
|
|
22
13
|
import { useMetaStore } from '../store/meta';
|
|
23
|
-
import { Spinner } from '@rango-dev/ui';
|
|
24
|
-
import { LoadingFailedAlert } from '@rango-dev/ui';
|
|
25
|
-
import { WidgetConfig } from '../types';
|
|
26
|
-
import { configWalletsToWalletName } from '../utils/providers';
|
|
27
14
|
|
|
28
15
|
interface PropTypes {
|
|
29
16
|
supportedWallets: WidgetConfig['wallets'];
|
|
@@ -33,120 +20,82 @@ interface PropTypes {
|
|
|
33
20
|
|
|
34
21
|
const ListContainer = styled('div', {
|
|
35
22
|
display: 'grid',
|
|
36
|
-
gap: '
|
|
37
|
-
gridTemplateColumns: ' repeat(
|
|
23
|
+
gap: '$10',
|
|
24
|
+
gridTemplateColumns: ' repeat(3, minmax(0, 1fr))',
|
|
38
25
|
alignContent: 'baseline',
|
|
39
|
-
|
|
40
|
-
|
|
26
|
+
paddingTop: '$15',
|
|
27
|
+
height: '100%',
|
|
41
28
|
});
|
|
42
29
|
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
justifyContent: 'center',
|
|
46
|
-
width: '100%',
|
|
47
|
-
position: 'absolute',
|
|
48
|
-
top: '50%',
|
|
30
|
+
const Container = styled('div', {
|
|
31
|
+
textAlign: 'center',
|
|
49
32
|
});
|
|
50
33
|
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
});
|
|
34
|
+
export const TIME_TO_CLOSE_MODAL = 3_000;
|
|
35
|
+
export const TIME_TO_IGNORE_MODAL = 300;
|
|
54
36
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
export function WalletsPage({
|
|
58
|
-
supportedWallets,
|
|
59
|
-
multiWallets,
|
|
60
|
-
config,
|
|
61
|
-
}: PropTypes) {
|
|
37
|
+
export function WalletsPage({ config }: PropTypes) {
|
|
62
38
|
const { navigateBackFrom } = useNavigateBack();
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
state,
|
|
66
|
-
getWalletInfo,
|
|
67
|
-
configWalletsToWalletName(supportedWallets, {
|
|
68
|
-
walletConnectProjectId: config?.walletConnectProjectId,
|
|
69
|
-
}) || ALL_SUPPORTED_WALLETS
|
|
70
|
-
);
|
|
71
|
-
const walletsRef = useRef<WalletInfo[]>();
|
|
39
|
+
const [openModal, setOpenModal] = useState<WalletType>('');
|
|
40
|
+
let modalTimerId: ReturnType<typeof setTimeout> | null = null;
|
|
72
41
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
:
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const wallet = state(type);
|
|
84
|
-
try {
|
|
85
|
-
if (walletErrorMessage) setWalletErrorMessage('');
|
|
86
|
-
if (wallet.connected) {
|
|
87
|
-
await disconnect(type);
|
|
88
|
-
} else {
|
|
89
|
-
if (
|
|
90
|
-
!multiWallets &&
|
|
91
|
-
!!wallets.find((w) => w.state === WalletState.CONNECTED)
|
|
92
|
-
) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
await connect(type);
|
|
42
|
+
const { list, handleClick, error } = useWalletList({
|
|
43
|
+
config,
|
|
44
|
+
onBeforeConnect: (type) => {
|
|
45
|
+
modalTimerId = setTimeout(() => {
|
|
46
|
+
setOpenModal(type);
|
|
47
|
+
}, TIME_TO_IGNORE_MODAL);
|
|
48
|
+
},
|
|
49
|
+
onConnect: () => {
|
|
50
|
+
if (modalTimerId) {
|
|
51
|
+
clearTimeout(modalTimerId);
|
|
96
52
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
const connectingWallets =
|
|
103
|
-
walletsRef.current?.filter(
|
|
104
|
-
(wallet) => wallet.state === WalletState.CONNECTING
|
|
105
|
-
) || [];
|
|
106
|
-
for (const wallet of connectingWallets) {
|
|
107
|
-
disconnect(wallet.type);
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
useEffect(() => {
|
|
111
|
-
toggleConnectWalletsButton();
|
|
112
|
-
return () => {
|
|
113
|
-
disconnectConnectingWallets();
|
|
114
|
-
toggleConnectWalletsButton();
|
|
115
|
-
};
|
|
116
|
-
}, []);
|
|
53
|
+
setTimeout(() => {
|
|
54
|
+
setOpenModal('');
|
|
55
|
+
}, TIME_TO_CLOSE_MODAL);
|
|
56
|
+
},
|
|
57
|
+
});
|
|
117
58
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
59
|
+
const loadingMetaStatus = useMetaStore.use.loadingStatus();
|
|
60
|
+
const selectedWallet = list.find((wallet) => wallet.type === openModal);
|
|
61
|
+
const selectedWalletImage = selectedWallet?.image || '';
|
|
62
|
+
const selectedWalletState =
|
|
63
|
+
selectedWallet?.state || WalletState.NOT_INSTALLED;
|
|
121
64
|
|
|
122
65
|
return (
|
|
123
|
-
<
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
)}
|
|
133
|
-
{loadingMetaStatus === 'loading' && (
|
|
134
|
-
<LoaderContainer className="loader">
|
|
135
|
-
<Spinner size={24} />
|
|
136
|
-
</LoaderContainer>
|
|
137
|
-
)}
|
|
138
|
-
{loadingMetaStatus === 'failed' && <LoadingFailedAlert />}
|
|
66
|
+
<Layout
|
|
67
|
+
header={{
|
|
68
|
+
title: i18n.t('Connect Wallets'),
|
|
69
|
+
onBack: navigateBackFrom.bind(null, navigationRoutes.wallets),
|
|
70
|
+
}}>
|
|
71
|
+
<Container>
|
|
72
|
+
<Typography variant="title" size="xmedium" align="center">
|
|
73
|
+
{i18n.t('Choose a wallet to connect.')}
|
|
74
|
+
</Typography>
|
|
139
75
|
<ListContainer>
|
|
140
|
-
{
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
76
|
+
{list.map((wallet, index) => {
|
|
77
|
+
const key = `wallet-${index}-${wallet.type}`;
|
|
78
|
+
return (
|
|
79
|
+
<Fragment key={key}>
|
|
80
|
+
<Wallet
|
|
81
|
+
{...wallet}
|
|
82
|
+
onClick={(type) => {
|
|
83
|
+
void handleClick(type);
|
|
84
|
+
}}
|
|
85
|
+
isLoading={loadingMetaStatus === 'loading'}
|
|
86
|
+
/>
|
|
87
|
+
</Fragment>
|
|
88
|
+
);
|
|
89
|
+
})}
|
|
90
|
+
<WalletModal
|
|
91
|
+
open={!!openModal}
|
|
92
|
+
onClose={() => setOpenModal('')}
|
|
93
|
+
image={selectedWalletImage}
|
|
94
|
+
state={selectedWalletState}
|
|
95
|
+
error={error}
|
|
96
|
+
/>
|
|
148
97
|
</ListContainer>
|
|
149
|
-
|
|
150
|
-
</
|
|
98
|
+
</Container>
|
|
99
|
+
</Layout>
|
|
151
100
|
);
|
|
152
101
|
}
|
package/src/store/bestRoute.ts
CHANGED
|
@@ -1,28 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { TokenWithBalance } from '../components/TokenList';
|
|
2
|
+
import type { Wallet } from '../types';
|
|
3
|
+
import type { PendingSwap } from '@rango-dev/queue-manager-rango-preset/dist/shared';
|
|
4
|
+
import type { BestRouteResponse, BlockchainMeta, Token } from 'rango-sdk';
|
|
5
|
+
|
|
4
6
|
import BigNumber from 'bignumber.js';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
getBestRouteToTokenUsdPrice,
|
|
8
|
-
isRouteParametersChanged,
|
|
9
|
-
} from '../utils/routing';
|
|
10
|
-
import createSelectors from './selectors';
|
|
7
|
+
import { create } from 'zustand';
|
|
11
8
|
import { subscribeWithSelector } from 'zustand/middleware';
|
|
12
|
-
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
9
|
+
|
|
10
|
+
import { ZERO } from '../constants/numbers';
|
|
11
|
+
import { isPositiveNumber } from '../utils/numbers';
|
|
12
|
+
import { getBestRouteToTokenUsdPrice } from '../utils/routing';
|
|
13
|
+
import { calcOutputUsdValue } from '../utils/swap';
|
|
16
14
|
import {
|
|
17
15
|
getDefaultToken,
|
|
18
16
|
getSortedTokens,
|
|
19
17
|
tokensAreEqual,
|
|
20
18
|
} from '../utils/wallets';
|
|
19
|
+
|
|
20
|
+
import { useMetaStore } from './meta';
|
|
21
|
+
import createSelectors from './selectors';
|
|
21
22
|
import { useWalletsStore } from './wallets';
|
|
22
|
-
import { TokenWithBalance } from '../pages/SelectTokenPage';
|
|
23
|
-
import { PendingSwap } from '@rango-dev/queue-manager-rango-preset/dist/shared';
|
|
24
|
-
import { debounce } from '../utils/common';
|
|
25
|
-
import { isPositiveNumber } from '../utils/numbers';
|
|
26
23
|
|
|
27
24
|
const getUsdValue = (token: Token | null, amount: string): BigNumber | null =>
|
|
28
25
|
token?.usdPrice
|
|
@@ -30,54 +27,68 @@ const getUsdValue = (token: Token | null, amount: string): BigNumber | null =>
|
|
|
30
27
|
: null;
|
|
31
28
|
|
|
32
29
|
export interface RouteState {
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
fromBlockchain: BlockchainMeta | null;
|
|
31
|
+
toBlockchain: BlockchainMeta | null;
|
|
35
32
|
inputAmount: string;
|
|
36
33
|
inputUsdValue: BigNumber | null;
|
|
37
34
|
outputAmount: BigNumber | null;
|
|
38
35
|
outputUsdValue: BigNumber | null;
|
|
39
36
|
fromToken: TokenWithBalance | null;
|
|
40
37
|
toToken: TokenWithBalance | null;
|
|
41
|
-
|
|
42
|
-
error: string;
|
|
38
|
+
routeWalletsConfirmed: boolean;
|
|
43
39
|
sourceTokens: Token[];
|
|
44
40
|
destinationTokens: Token[];
|
|
41
|
+
selectedWallets: Wallet[];
|
|
45
42
|
resetRoute: () => void;
|
|
46
|
-
|
|
43
|
+
resetToBlockchain: () => void;
|
|
44
|
+
resetFromBlockchain: () => void;
|
|
45
|
+
setFromBlockchain: (
|
|
47
46
|
chain: BlockchainMeta | null,
|
|
48
47
|
setDefaultToken?: boolean
|
|
49
48
|
) => void;
|
|
50
|
-
|
|
49
|
+
setToBlockchain: (
|
|
50
|
+
chian: BlockchainMeta | null,
|
|
51
|
+
setDefaultToken?: boolean
|
|
52
|
+
) => void;
|
|
53
|
+
|
|
51
54
|
setFromToken: (token: Token | null) => void;
|
|
52
55
|
setToToken: (token: Token | null) => void;
|
|
53
56
|
setInputAmount: (amount: string) => void;
|
|
54
57
|
bestRoute: BestRouteResponse | null;
|
|
55
|
-
|
|
58
|
+
setRoute: (bestRoute: BestRouteResponse | null) => void;
|
|
56
59
|
retry: (pendingSwap: PendingSwap) => void;
|
|
57
60
|
switchFromAndTo: () => void;
|
|
61
|
+
setRouteWalletConfirmed: (flag: boolean) => void;
|
|
62
|
+
setSelectedWallets: (wallets: Wallet[]) => void;
|
|
63
|
+
customDestination: string;
|
|
64
|
+
setCustomDestination: (address: string) => void;
|
|
65
|
+
resetRouteWallets: () => void;
|
|
58
66
|
}
|
|
59
67
|
|
|
60
68
|
export const useBestRouteStore = createSelectors(
|
|
61
69
|
create<RouteState>()(
|
|
62
70
|
subscribeWithSelector((set) => ({
|
|
63
|
-
|
|
71
|
+
fromBlockchain: null,
|
|
64
72
|
fromToken: null,
|
|
65
73
|
inputAmount: '',
|
|
66
74
|
outputAmount: null,
|
|
67
75
|
inputUsdValue: new BigNumber(0),
|
|
68
76
|
outputUsdValue: new BigNumber(0),
|
|
69
|
-
|
|
77
|
+
toBlockchain: null,
|
|
70
78
|
toToken: null,
|
|
71
79
|
bestRoute: null,
|
|
72
|
-
|
|
73
|
-
error: '',
|
|
80
|
+
routeWalletsConfirmed: false,
|
|
74
81
|
sourceTokens: [],
|
|
75
82
|
destinationTokens: [],
|
|
76
|
-
|
|
83
|
+
selectedWallets: [],
|
|
84
|
+
customDestination: '',
|
|
85
|
+
setRoute: (bestRoute) =>
|
|
77
86
|
set((state) => {
|
|
78
87
|
let outputAmount: BigNumber | null = null;
|
|
79
88
|
let outputUsdValue: BigNumber = ZERO;
|
|
80
|
-
if (!isPositiveNumber(state.inputAmount))
|
|
89
|
+
if (!isPositiveNumber(state.inputAmount)) {
|
|
90
|
+
return {};
|
|
91
|
+
}
|
|
81
92
|
if (!!bestRoute) {
|
|
82
93
|
outputAmount = !!bestRoute.result?.outputAmount
|
|
83
94
|
? new BigNumber(bestRoute.result?.outputAmount)
|
|
@@ -97,15 +108,15 @@ export const useBestRouteStore = createSelectors(
|
|
|
97
108
|
}),
|
|
98
109
|
resetRoute: () =>
|
|
99
110
|
set(() => ({
|
|
100
|
-
loading: true,
|
|
101
|
-
error: '',
|
|
102
111
|
bestRoute: null,
|
|
103
112
|
outputAmount: null,
|
|
104
113
|
outputUsdValue: new BigNumber(0),
|
|
105
114
|
})),
|
|
106
|
-
|
|
115
|
+
setFromBlockchain: (chain, setDefaultToken) => {
|
|
107
116
|
set((state) => {
|
|
108
|
-
if (state.
|
|
117
|
+
if (state.fromBlockchain?.name === chain?.name) {
|
|
118
|
+
return {};
|
|
119
|
+
}
|
|
109
120
|
const tokens = useMetaStore.getState().meta.tokens;
|
|
110
121
|
const connectedWallets = useWalletsStore.getState().connectedWallets;
|
|
111
122
|
const sortedTokens = getSortedTokens(
|
|
@@ -116,7 +127,7 @@ export const useBestRouteStore = createSelectors(
|
|
|
116
127
|
);
|
|
117
128
|
const fromToken = getDefaultToken(sortedTokens, state.toToken);
|
|
118
129
|
return {
|
|
119
|
-
|
|
130
|
+
fromBlockchain: chain,
|
|
120
131
|
sourceTokens: sortedTokens,
|
|
121
132
|
...(setDefaultToken && {
|
|
122
133
|
fromToken,
|
|
@@ -134,9 +145,11 @@ export const useBestRouteStore = createSelectors(
|
|
|
134
145
|
inputUsdValue: getUsdValue(token, state.inputAmount),
|
|
135
146
|
}),
|
|
136
147
|
})),
|
|
137
|
-
|
|
148
|
+
setToBlockchain: (chain, setDefaultToken) => {
|
|
138
149
|
set((state) => {
|
|
139
|
-
if (state.
|
|
150
|
+
if (state.toBlockchain?.name === chain?.name) {
|
|
151
|
+
return {};
|
|
152
|
+
}
|
|
140
153
|
const tokens = useMetaStore.getState().meta.tokens;
|
|
141
154
|
const connectedWallets = useWalletsStore.getState().connectedWallets;
|
|
142
155
|
const sortedTokens = getSortedTokens(
|
|
@@ -147,7 +160,7 @@ export const useBestRouteStore = createSelectors(
|
|
|
147
160
|
);
|
|
148
161
|
|
|
149
162
|
return {
|
|
150
|
-
|
|
163
|
+
toBlockchain: chain,
|
|
151
164
|
destinationTokens: sortedTokens,
|
|
152
165
|
...(setDefaultToken && {
|
|
153
166
|
toToken: getDefaultToken(sortedTokens, state.fromToken),
|
|
@@ -166,7 +179,6 @@ export const useBestRouteStore = createSelectors(
|
|
|
166
179
|
outputAmount: new BigNumber(0),
|
|
167
180
|
outputUsdValue: new BigNumber(0),
|
|
168
181
|
bestRoute: null,
|
|
169
|
-
error: '',
|
|
170
182
|
}),
|
|
171
183
|
...(!!state.fromToken && {
|
|
172
184
|
inputUsdValue: getUsdValue(state.fromToken, amount),
|
|
@@ -181,15 +193,17 @@ export const useBestRouteStore = createSelectors(
|
|
|
181
193
|
? pendingSwap.steps.findIndex((s) => s.status === 'failed')
|
|
182
194
|
: null;
|
|
183
195
|
|
|
184
|
-
if (failedIndex === null || failedIndex < 0)
|
|
196
|
+
if (failedIndex === null || failedIndex < 0) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
185
199
|
|
|
186
200
|
const firstStep = pendingSwap.steps[0];
|
|
187
201
|
const lastStep = pendingSwap.steps[pendingSwap.steps.length - 1];
|
|
188
|
-
const
|
|
202
|
+
const fromBlockchain =
|
|
189
203
|
blockchains.find(
|
|
190
204
|
(blockchain) => blockchain.name === firstStep.fromBlockchain
|
|
191
205
|
) || null;
|
|
192
|
-
const
|
|
206
|
+
const toBlockchain =
|
|
193
207
|
blockchains.find(
|
|
194
208
|
(blockchain) => blockchain.name === lastStep.toBlockchain
|
|
195
209
|
) || null;
|
|
@@ -210,39 +224,37 @@ export const useBestRouteStore = createSelectors(
|
|
|
210
224
|
})
|
|
211
225
|
);
|
|
212
226
|
const sortedSourceTokens = getSortedTokens(
|
|
213
|
-
|
|
227
|
+
fromBlockchain,
|
|
214
228
|
tokens,
|
|
215
229
|
connectedWallets,
|
|
216
230
|
[]
|
|
217
231
|
);
|
|
218
232
|
const sortedDestinationTokens = getSortedTokens(
|
|
219
|
-
|
|
233
|
+
toBlockchain,
|
|
220
234
|
tokens,
|
|
221
235
|
connectedWallets,
|
|
222
236
|
[]
|
|
223
237
|
);
|
|
224
238
|
const inputAmount = pendingSwap.inputAmount;
|
|
225
239
|
set({
|
|
226
|
-
|
|
240
|
+
fromBlockchain,
|
|
227
241
|
fromToken,
|
|
228
242
|
inputAmount,
|
|
229
243
|
outputAmount: null,
|
|
230
244
|
inputUsdValue: getUsdValue(fromToken || null, inputAmount),
|
|
231
245
|
outputUsdValue: new BigNumber(0),
|
|
232
|
-
|
|
246
|
+
toBlockchain,
|
|
233
247
|
toToken,
|
|
234
248
|
bestRoute: null,
|
|
235
|
-
loading: false,
|
|
236
|
-
error: '',
|
|
237
249
|
sourceTokens: sortedSourceTokens,
|
|
238
250
|
destinationTokens: sortedDestinationTokens,
|
|
239
251
|
});
|
|
240
252
|
},
|
|
241
253
|
switchFromAndTo: () =>
|
|
242
254
|
set((state) => ({
|
|
243
|
-
|
|
255
|
+
fromBlockchain: state.toBlockchain,
|
|
244
256
|
fromToken: state.toToken,
|
|
245
|
-
|
|
257
|
+
toBlockchain: state.fromBlockchain,
|
|
246
258
|
toToken: state.fromToken,
|
|
247
259
|
sourceTokens: state.destinationTokens,
|
|
248
260
|
destinationTokens: state.sourceTokens,
|
|
@@ -252,136 +264,29 @@ export const useBestRouteStore = createSelectors(
|
|
|
252
264
|
state.outputAmount?.toString() || ''
|
|
253
265
|
),
|
|
254
266
|
})),
|
|
267
|
+
|
|
268
|
+
resetFromBlockchain: () =>
|
|
269
|
+
set(() => ({
|
|
270
|
+
fromBlockchain: null,
|
|
271
|
+
sourceTokens: [],
|
|
272
|
+
})),
|
|
273
|
+
resetToBlockchain: () =>
|
|
274
|
+
set(() => ({
|
|
275
|
+
toBlockchain: null,
|
|
276
|
+
destinationTokens: [],
|
|
277
|
+
})),
|
|
278
|
+
setRouteWalletConfirmed: (flag) =>
|
|
279
|
+
set({
|
|
280
|
+
routeWalletsConfirmed: flag,
|
|
281
|
+
}),
|
|
282
|
+
setSelectedWallets: (wallets) => set({ selectedWallets: wallets }),
|
|
283
|
+
setCustomDestination: (address) => set({ customDestination: address }),
|
|
284
|
+
resetRouteWallets: () =>
|
|
285
|
+
set({
|
|
286
|
+
routeWalletsConfirmed: false,
|
|
287
|
+
selectedWallets: [],
|
|
288
|
+
customDestination: '',
|
|
289
|
+
}),
|
|
255
290
|
}))
|
|
256
291
|
)
|
|
257
292
|
);
|
|
258
|
-
|
|
259
|
-
const bestRoute = (
|
|
260
|
-
bestRouteStore: typeof useBestRouteStore,
|
|
261
|
-
settingsStore: typeof useSettingsStore
|
|
262
|
-
) => {
|
|
263
|
-
let abortController: AbortController | null = null;
|
|
264
|
-
const fetchBestRoute = () => {
|
|
265
|
-
const { fromToken, toToken, inputAmount, resetRoute } =
|
|
266
|
-
bestRouteStore.getState();
|
|
267
|
-
const {
|
|
268
|
-
slippage,
|
|
269
|
-
customSlippage,
|
|
270
|
-
disabledLiquiditySources,
|
|
271
|
-
affiliateRef,
|
|
272
|
-
affiliatePercent,
|
|
273
|
-
affiliateWallets,
|
|
274
|
-
} = settingsStore.getState();
|
|
275
|
-
if (!fromToken || !toToken || !isPositiveNumber(inputAmount)) return;
|
|
276
|
-
abortController?.abort();
|
|
277
|
-
abortController = new AbortController();
|
|
278
|
-
const userSlippage = !!customSlippage ? customSlippage : slippage;
|
|
279
|
-
const requestBody = createBestRouteRequestBody(
|
|
280
|
-
fromToken,
|
|
281
|
-
toToken,
|
|
282
|
-
inputAmount,
|
|
283
|
-
[],
|
|
284
|
-
[],
|
|
285
|
-
disabledLiquiditySources,
|
|
286
|
-
userSlippage,
|
|
287
|
-
affiliateRef,
|
|
288
|
-
affiliatePercent,
|
|
289
|
-
affiliateWallets
|
|
290
|
-
);
|
|
291
|
-
|
|
292
|
-
if (!bestRouteStore.getState().loading) {
|
|
293
|
-
resetRoute();
|
|
294
|
-
}
|
|
295
|
-
httpService()
|
|
296
|
-
.getBestRoute(requestBody, {
|
|
297
|
-
signal: abortController.signal,
|
|
298
|
-
})
|
|
299
|
-
.then((res) => {
|
|
300
|
-
const { setBestRoute } = bestRouteStore.getState();
|
|
301
|
-
setBestRoute(res);
|
|
302
|
-
bestRouteStore.setState({ loading: false });
|
|
303
|
-
abortController = null;
|
|
304
|
-
})
|
|
305
|
-
.catch((error) => {
|
|
306
|
-
if (error.code === 'ERR_CANCELED') return;
|
|
307
|
-
bestRouteStore.setState({
|
|
308
|
-
error: error.message,
|
|
309
|
-
loading: false,
|
|
310
|
-
});
|
|
311
|
-
});
|
|
312
|
-
};
|
|
313
|
-
|
|
314
|
-
const debouncedFetchBestRoute = debounce(fetchBestRoute, 600);
|
|
315
|
-
|
|
316
|
-
const bestRouteParamsListener = () => {
|
|
317
|
-
const { fromToken, toToken, inputAmount, inputUsdValue, resetRoute } =
|
|
318
|
-
useBestRouteStore.getState();
|
|
319
|
-
if (!isPositiveNumber(inputAmount) || inputUsdValue?.eq(0))
|
|
320
|
-
return bestRouteStore.setState({ loading: false });
|
|
321
|
-
|
|
322
|
-
if (tokensAreEqual(fromToken, toToken))
|
|
323
|
-
return bestRouteStore.setState({
|
|
324
|
-
loading: false,
|
|
325
|
-
bestRoute: null,
|
|
326
|
-
outputAmount: new BigNumber(inputAmount),
|
|
327
|
-
outputUsdValue: inputUsdValue,
|
|
328
|
-
});
|
|
329
|
-
|
|
330
|
-
if (!bestRouteStore.getState().loading) resetRoute();
|
|
331
|
-
debouncedFetchBestRoute();
|
|
332
|
-
};
|
|
333
|
-
|
|
334
|
-
useBestRouteStore.subscribe(
|
|
335
|
-
(state) => ({
|
|
336
|
-
fromChain: state.fromChain,
|
|
337
|
-
fromToken: state.fromToken,
|
|
338
|
-
toChain: state.toChain,
|
|
339
|
-
toToken: state.toToken,
|
|
340
|
-
inputAmount: state.inputAmount,
|
|
341
|
-
}),
|
|
342
|
-
bestRouteParamsListener,
|
|
343
|
-
{
|
|
344
|
-
equalityFn: (prevState, currentState) => {
|
|
345
|
-
if (
|
|
346
|
-
isRouteParametersChanged({
|
|
347
|
-
store: 'bestRoute',
|
|
348
|
-
prevState,
|
|
349
|
-
currentState,
|
|
350
|
-
})
|
|
351
|
-
)
|
|
352
|
-
return false;
|
|
353
|
-
else return true;
|
|
354
|
-
},
|
|
355
|
-
}
|
|
356
|
-
);
|
|
357
|
-
|
|
358
|
-
useSettingsStore.subscribe(
|
|
359
|
-
(state) => ({
|
|
360
|
-
slippage: state.slippage,
|
|
361
|
-
customSlippage: state.customSlippage,
|
|
362
|
-
disabledLiquiditySources: state.disabledLiquiditySources,
|
|
363
|
-
infiniteApprove: state.infiniteApprove,
|
|
364
|
-
}),
|
|
365
|
-
bestRouteParamsListener,
|
|
366
|
-
{
|
|
367
|
-
equalityFn: (prevState, currentState) => {
|
|
368
|
-
if (
|
|
369
|
-
isRouteParametersChanged({
|
|
370
|
-
store: 'settings',
|
|
371
|
-
prevState,
|
|
372
|
-
currentState,
|
|
373
|
-
})
|
|
374
|
-
)
|
|
375
|
-
return false;
|
|
376
|
-
else return true;
|
|
377
|
-
},
|
|
378
|
-
}
|
|
379
|
-
);
|
|
380
|
-
|
|
381
|
-
return { fetchBestRoute };
|
|
382
|
-
};
|
|
383
|
-
|
|
384
|
-
export const { fetchBestRoute } = bestRoute(
|
|
385
|
-
useBestRouteStore,
|
|
386
|
-
useSettingsStore
|
|
387
|
-
);
|
package/src/store/meta.ts
CHANGED
|
@@ -1,21 +1,41 @@
|
|
|
1
|
+
import type { TokenWithBalance } from '../components/TokenList';
|
|
2
|
+
import type { MetaResponse } from 'rango-sdk';
|
|
3
|
+
|
|
1
4
|
import { create } from 'zustand';
|
|
2
|
-
|
|
5
|
+
|
|
3
6
|
import { httpService } from '../services/httpService';
|
|
4
|
-
import createSelectors from './selectors';
|
|
5
7
|
import { removeDuplicateFrom } from '../utils/common';
|
|
8
|
+
import { getTokensWithBalance, sortTokens } from '../utils/wallets';
|
|
9
|
+
|
|
10
|
+
import createSelectors from './selectors';
|
|
11
|
+
import { useWalletsStore } from './wallets';
|
|
6
12
|
|
|
7
13
|
export type LoadingStatus = 'loading' | 'success' | 'failed';
|
|
8
14
|
|
|
9
15
|
export interface MetaState {
|
|
10
|
-
meta: MetaResponse;
|
|
16
|
+
meta: MetaResponse & { tokens: TokenWithBalance[] };
|
|
11
17
|
loadingStatus: LoadingStatus;
|
|
12
18
|
fetchMeta: () => Promise<void>;
|
|
19
|
+
setTokensWithBalance: () => void;
|
|
13
20
|
}
|
|
14
21
|
|
|
15
22
|
export const useMetaStore = createSelectors(
|
|
16
23
|
create<MetaState>()((set) => ({
|
|
17
24
|
meta: { blockchains: [], popularTokens: [], swappers: [], tokens: [] },
|
|
18
25
|
loadingStatus: 'loading',
|
|
26
|
+
setTokensWithBalance: () => {
|
|
27
|
+
const connectedWallets = useWalletsStore.getState().connectedWallets;
|
|
28
|
+
|
|
29
|
+
set((state) => ({
|
|
30
|
+
...state,
|
|
31
|
+
meta: {
|
|
32
|
+
...state.meta,
|
|
33
|
+
tokens: sortTokens(
|
|
34
|
+
getTokensWithBalance(state.meta.tokens, connectedWallets)
|
|
35
|
+
),
|
|
36
|
+
},
|
|
37
|
+
}));
|
|
38
|
+
},
|
|
19
39
|
fetchMeta: async () => {
|
|
20
40
|
try {
|
|
21
41
|
const response = await httpService().getAllMetadata();
|