@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
package/src/store/slices/data.ts
CHANGED
|
@@ -6,7 +6,6 @@ import type { StateCreator } from 'zustand';
|
|
|
6
6
|
|
|
7
7
|
import { httpService as sdk } from '../../services/httpService';
|
|
8
8
|
import { containsText } from '../../utils/common';
|
|
9
|
-
import { sortLiquiditySourcesByGroupTitle } from '../../utils/settings';
|
|
10
9
|
import { tokensAreEqual } from '../../utils/wallets';
|
|
11
10
|
|
|
12
11
|
type BlockchainOptions = {
|
|
@@ -14,22 +13,21 @@ type BlockchainOptions = {
|
|
|
14
13
|
};
|
|
15
14
|
|
|
16
15
|
type TokenOptions = {
|
|
17
|
-
type
|
|
16
|
+
type?: 'source' | 'destination';
|
|
18
17
|
// filter by an specific blockchain
|
|
19
18
|
blockchain?: string;
|
|
20
19
|
searchFor?: string;
|
|
21
20
|
};
|
|
22
|
-
|
|
21
|
+
|
|
23
22
|
export interface DataSlice {
|
|
24
23
|
_blockchains: BlockchainMeta[];
|
|
25
24
|
_tokens: Token[];
|
|
26
25
|
_popularTokens: Token[];
|
|
27
26
|
_swappers: SwapperMeta[];
|
|
28
|
-
|
|
27
|
+
|
|
29
28
|
blockchains: (options?: BlockchainOptions) => BlockchainMeta[];
|
|
30
29
|
tokens: (options?: TokenOptions) => Token[];
|
|
31
|
-
|
|
32
|
-
isTokenPinned: (token: Token, type: 'source' | 'destination') => boolean;
|
|
30
|
+
isTokenPinned: (token: Token) => boolean;
|
|
33
31
|
|
|
34
32
|
fetch: () => Promise<void>;
|
|
35
33
|
}
|
|
@@ -45,7 +43,7 @@ export const createDataSlice: StateCreator<
|
|
|
45
43
|
_tokens: [],
|
|
46
44
|
_popularTokens: [],
|
|
47
45
|
_swappers: [],
|
|
48
|
-
|
|
46
|
+
|
|
49
47
|
// Selectors
|
|
50
48
|
blockchains: (options) => {
|
|
51
49
|
const blockchainsFromState = get()._blockchains;
|
|
@@ -131,10 +129,10 @@ export const createDataSlice: StateCreator<
|
|
|
131
129
|
})
|
|
132
130
|
.sort((a, b) => {
|
|
133
131
|
// Check pinned tokens
|
|
134
|
-
if (get().isTokenPinned(a
|
|
132
|
+
if (get().isTokenPinned(a)) {
|
|
135
133
|
return -1;
|
|
136
134
|
}
|
|
137
|
-
if (get().isTokenPinned(b
|
|
135
|
+
if (get().isTokenPinned(b)) {
|
|
138
136
|
return 1;
|
|
139
137
|
}
|
|
140
138
|
|
|
@@ -159,84 +157,47 @@ export const createDataSlice: StateCreator<
|
|
|
159
157
|
|
|
160
158
|
return list;
|
|
161
159
|
},
|
|
162
|
-
isTokenPinned: (token
|
|
163
|
-
const pinnedTokens
|
|
164
|
-
type === 'source'
|
|
165
|
-
? get().config.from?.pinnedTokens
|
|
166
|
-
: get().config.to?.pinnedTokens;
|
|
167
|
-
const pinned = !!pinnedTokens?.some((pinnedToken) =>
|
|
160
|
+
isTokenPinned: (token) => {
|
|
161
|
+
const pinned = !!get().config.pinnedTokens?.some((pinnedToken) =>
|
|
168
162
|
tokensAreEqual(pinnedToken, token)
|
|
169
163
|
);
|
|
170
164
|
return pinned;
|
|
171
165
|
},
|
|
172
|
-
swappers: () => {
|
|
173
|
-
const {
|
|
174
|
-
config: { enableNewLiquiditySources, liquiditySources },
|
|
175
|
-
} = get();
|
|
176
|
-
|
|
177
|
-
/*
|
|
178
|
-
* If the enableNewLiquiditySources flag is set to true, we return all swappers that are not included in the config.
|
|
179
|
-
* Otherwise, we return all swappers that are included in the config.
|
|
180
|
-
*/
|
|
181
|
-
const swappers = get()._swappers.filter((swapper) => {
|
|
182
|
-
const swapperGroupIncludedInLiquiditySources = liquiditySources?.includes(
|
|
183
|
-
swapper.swapperGroup
|
|
184
|
-
);
|
|
185
|
-
|
|
186
|
-
const shouldExcludeLiquiditySources =
|
|
187
|
-
enableNewLiquiditySources ||
|
|
188
|
-
!liquiditySources ||
|
|
189
|
-
liquiditySources.length === 0;
|
|
190
|
-
|
|
191
|
-
return shouldExcludeLiquiditySources
|
|
192
|
-
? !swapperGroupIncludedInLiquiditySources
|
|
193
|
-
: swapperGroupIncludedInLiquiditySources;
|
|
194
|
-
});
|
|
195
166
|
|
|
196
|
-
const sortedSwappers = swappers.sort(sortLiquiditySourcesByGroupTitle);
|
|
197
|
-
|
|
198
|
-
return sortedSwappers;
|
|
199
|
-
},
|
|
200
167
|
// Actions
|
|
201
168
|
fetch: async () => {
|
|
202
|
-
|
|
203
|
-
const response = await sdk().getAllMetadata();
|
|
169
|
+
const response = await sdk().getAllMetadata();
|
|
204
170
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
const swappers: SwapperMeta[] = response.swappers;
|
|
171
|
+
const blockchains: BlockchainMeta[] = [];
|
|
172
|
+
const tokens: Token[] = [];
|
|
173
|
+
const popularTokens: Token[] = response.popularTokens;
|
|
174
|
+
const swappers: SwapperMeta[] = response.swappers;
|
|
210
175
|
|
|
211
|
-
|
|
176
|
+
const blockchainsWithAtLeastOneToken = new Set();
|
|
212
177
|
|
|
213
|
-
|
|
214
|
-
|
|
178
|
+
response.tokens.forEach((token) => {
|
|
179
|
+
blockchainsWithAtLeastOneToken.add(token.blockchain);
|
|
215
180
|
|
|
216
|
-
|
|
217
|
-
|
|
181
|
+
tokens.push(token);
|
|
182
|
+
});
|
|
218
183
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
184
|
+
response.blockchains.forEach((blockchain) => {
|
|
185
|
+
if (
|
|
186
|
+
blockchain.enabled &&
|
|
187
|
+
blockchainsWithAtLeastOneToken.has(blockchain.name)
|
|
188
|
+
) {
|
|
189
|
+
blockchains.push(blockchain);
|
|
190
|
+
}
|
|
191
|
+
});
|
|
227
192
|
|
|
228
|
-
|
|
229
|
-
|
|
193
|
+
// Sort
|
|
194
|
+
blockchains.sort((a, b) => a.sort - b.sort);
|
|
230
195
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
} catch (error) {
|
|
238
|
-
set({ fetchStatus: 'failed' });
|
|
239
|
-
throw error;
|
|
240
|
-
}
|
|
196
|
+
set({
|
|
197
|
+
_blockchains: blockchains,
|
|
198
|
+
_tokens: tokens,
|
|
199
|
+
_popularTokens: popularTokens,
|
|
200
|
+
_swappers: swappers,
|
|
201
|
+
});
|
|
241
202
|
},
|
|
242
203
|
});
|
package/src/store/wallets.ts
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Wallet } from '../types';
|
|
2
2
|
import type { WalletType } from '@rango-dev/wallets-shared';
|
|
3
|
-
import type { Token } from 'rango-sdk';
|
|
4
3
|
|
|
5
4
|
import { create } from 'zustand';
|
|
6
5
|
import { subscribeWithSelector } from 'zustand/middleware';
|
|
7
6
|
|
|
8
7
|
import { httpService } from '../services/httpService';
|
|
9
8
|
import {
|
|
10
|
-
createTokenHash,
|
|
11
9
|
isAccountAndWalletMatched,
|
|
12
10
|
makeBalanceFor,
|
|
13
|
-
makeTokensBalance,
|
|
14
11
|
resetConnectedWalletState,
|
|
15
12
|
} from '../utils/wallets';
|
|
16
13
|
|
|
14
|
+
import { useMetaStore } from './meta';
|
|
17
15
|
import createSelectors from './selectors';
|
|
18
16
|
|
|
19
17
|
export type TokenBalance = {
|
|
@@ -35,31 +33,25 @@ export interface ConnectedWallet extends Wallet {
|
|
|
35
33
|
loading: boolean;
|
|
36
34
|
error: boolean;
|
|
37
35
|
}
|
|
36
|
+
|
|
38
37
|
interface WalletsStore {
|
|
39
38
|
connectedWallets: ConnectedWallet[];
|
|
40
|
-
balances: TokensBalance;
|
|
41
39
|
customDestination: string;
|
|
42
40
|
loading: boolean;
|
|
43
|
-
connectWallet: (accounts: Wallet[]
|
|
41
|
+
connectWallet: (accounts: Wallet[]) => void;
|
|
44
42
|
disconnectWallet: (walletType: WalletType) => void;
|
|
45
43
|
selectWallets: (wallets: { walletType: string; chain: string }[]) => void;
|
|
46
44
|
clearConnectedWallet: () => void;
|
|
47
|
-
getWalletsDetails: (
|
|
48
|
-
accounts: Wallet[],
|
|
49
|
-
tokens: Token[],
|
|
50
|
-
shouldRetry?: boolean
|
|
51
|
-
) => void;
|
|
52
|
-
getBalanceFor: (token: Token) => Balance | null;
|
|
45
|
+
getWalletsDetails: (accounts: Wallet[], shouldRetry?: boolean) => void;
|
|
53
46
|
}
|
|
54
47
|
|
|
55
48
|
export const useWalletsStore = createSelectors(
|
|
56
49
|
create<WalletsStore>()(
|
|
57
50
|
subscribeWithSelector((set, get) => ({
|
|
58
51
|
connectedWallets: [],
|
|
59
|
-
balances: {},
|
|
60
52
|
customDestination: '',
|
|
61
53
|
loading: false,
|
|
62
|
-
connectWallet: (accounts
|
|
54
|
+
connectWallet: (accounts) => {
|
|
63
55
|
const getWalletsDetails = get().getWalletsDetails;
|
|
64
56
|
set((state) => ({
|
|
65
57
|
loading: true,
|
|
@@ -85,7 +77,7 @@ export const useWalletsStore = createSelectors(
|
|
|
85
77
|
})
|
|
86
78
|
),
|
|
87
79
|
}));
|
|
88
|
-
getWalletsDetails(accounts
|
|
80
|
+
getWalletsDetails(accounts);
|
|
89
81
|
},
|
|
90
82
|
disconnectWallet: (walletType) => {
|
|
91
83
|
set((state) => {
|
|
@@ -96,27 +88,21 @@ export const useWalletsStore = createSelectors(
|
|
|
96
88
|
connectedWallet.walletType !== walletType
|
|
97
89
|
)
|
|
98
90
|
.map((selectedWallet) => selectedWallet.chain);
|
|
99
|
-
|
|
100
|
-
const connectedWallets = state.connectedWallets
|
|
101
|
-
.filter(
|
|
102
|
-
(connectedWallet) => connectedWallet.walletType !== walletType
|
|
103
|
-
)
|
|
104
|
-
.map((connectedWallet) => {
|
|
105
|
-
const anyWalletSelectedForBlockchain = selectedWallets.includes(
|
|
106
|
-
connectedWallet.chain
|
|
107
|
-
);
|
|
108
|
-
if (anyWalletSelectedForBlockchain) {
|
|
109
|
-
return connectedWallet;
|
|
110
|
-
}
|
|
111
|
-
selectedWallets.push(connectedWallet.chain);
|
|
112
|
-
return { ...connectedWallet, selected: true };
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
const balances = makeTokensBalance(connectedWallets);
|
|
116
|
-
|
|
117
91
|
return {
|
|
118
|
-
|
|
119
|
-
|
|
92
|
+
connectedWallets: state.connectedWallets
|
|
93
|
+
.filter(
|
|
94
|
+
(connectedWallet) => connectedWallet.walletType !== walletType
|
|
95
|
+
)
|
|
96
|
+
.map((connectedWallet) => {
|
|
97
|
+
const anyWalletSelectedForBlockchain = selectedWallets.includes(
|
|
98
|
+
connectedWallet.chain
|
|
99
|
+
);
|
|
100
|
+
if (anyWalletSelectedForBlockchain) {
|
|
101
|
+
return connectedWallet;
|
|
102
|
+
}
|
|
103
|
+
selectedWallets.push(connectedWallet.chain);
|
|
104
|
+
return { ...connectedWallet, selected: true };
|
|
105
|
+
}),
|
|
120
106
|
};
|
|
121
107
|
});
|
|
122
108
|
},
|
|
@@ -149,8 +135,9 @@ export const useWalletsStore = createSelectors(
|
|
|
149
135
|
connectedWallets: [],
|
|
150
136
|
selectedWallets: [],
|
|
151
137
|
})),
|
|
152
|
-
getWalletsDetails: async (accounts,
|
|
138
|
+
getWalletsDetails: async (accounts, shouldRetry = true) => {
|
|
153
139
|
const getWalletsDetails = get().getWalletsDetails;
|
|
140
|
+
const { tokens } = useMetaStore.getState().meta;
|
|
154
141
|
set((state) => ({
|
|
155
142
|
loading: true,
|
|
156
143
|
connectedWallets: state.connectedWallets.map((wallet) => {
|
|
@@ -169,8 +156,9 @@ export const useWalletsStore = createSelectors(
|
|
|
169
156
|
const response = await httpService().getWalletsDetails(data);
|
|
170
157
|
const retrievedBalance = response.wallets;
|
|
171
158
|
if (retrievedBalance) {
|
|
172
|
-
set((state) => {
|
|
173
|
-
|
|
159
|
+
set((state) => ({
|
|
160
|
+
loading: false,
|
|
161
|
+
connectedWallets: state.connectedWallets.map(
|
|
174
162
|
(connectedWallet) => {
|
|
175
163
|
const matchedAccount = accounts.find((account) =>
|
|
176
164
|
isAccountAndWalletMatched(account, connectedWallet)
|
|
@@ -185,7 +173,7 @@ export const useWalletsStore = createSelectors(
|
|
|
185
173
|
matchedAccount &&
|
|
186
174
|
shouldRetry
|
|
187
175
|
) {
|
|
188
|
-
getWalletsDetails([matchedAccount],
|
|
176
|
+
getWalletsDetails([matchedAccount], false);
|
|
189
177
|
}
|
|
190
178
|
return matchedAccount && retrievedBalanceAccount
|
|
191
179
|
? {
|
|
@@ -195,49 +183,30 @@ export const useWalletsStore = createSelectors(
|
|
|
195
183
|
retrievedBalanceAccount,
|
|
196
184
|
tokens
|
|
197
185
|
),
|
|
198
|
-
loading: false,
|
|
199
186
|
}
|
|
200
187
|
: connectedWallet;
|
|
201
188
|
}
|
|
202
|
-
)
|
|
203
|
-
|
|
204
|
-
const balances = makeTokensBalance(connectedWallets);
|
|
205
|
-
|
|
206
|
-
return {
|
|
207
|
-
loading: false,
|
|
208
|
-
balances,
|
|
209
|
-
connectedWallets,
|
|
210
|
-
};
|
|
211
|
-
});
|
|
189
|
+
),
|
|
190
|
+
}));
|
|
212
191
|
} else {
|
|
213
192
|
throw new Error('Wallet not found');
|
|
214
193
|
}
|
|
215
194
|
} catch (error) {
|
|
216
|
-
set((state) => {
|
|
217
|
-
|
|
195
|
+
set((state) => ({
|
|
196
|
+
loading: false,
|
|
197
|
+
connectedWallets: state.connectedWallets.map((balance) => {
|
|
218
198
|
return accounts.find((account) =>
|
|
219
199
|
isAccountAndWalletMatched(account, balance)
|
|
220
200
|
)
|
|
221
201
|
? resetConnectedWalletState(balance)
|
|
222
202
|
: balance;
|
|
223
|
-
})
|
|
224
|
-
|
|
225
|
-
const balances = makeTokensBalance(connectedWallets);
|
|
226
|
-
|
|
227
|
-
return {
|
|
228
|
-
loading: false,
|
|
229
|
-
balances,
|
|
230
|
-
connectedWallets,
|
|
231
|
-
};
|
|
232
|
-
});
|
|
203
|
+
}),
|
|
204
|
+
}));
|
|
233
205
|
}
|
|
234
206
|
},
|
|
235
|
-
getBalanceFor: (token) => {
|
|
236
|
-
const { balances } = get();
|
|
237
|
-
const tokenHash = createTokenHash(token);
|
|
238
|
-
const balance = balances[tokenHash];
|
|
239
|
-
return balance ?? null;
|
|
240
|
-
},
|
|
241
207
|
}))
|
|
242
208
|
)
|
|
243
209
|
);
|
|
210
|
+
|
|
211
|
+
export const fetchingBalanceSelector = (state: WalletsStore) =>
|
|
212
|
+
!!state.connectedWallets.find((wallet) => wallet.loading);
|
package/src/types/config.ts
CHANGED
|
@@ -61,7 +61,7 @@ export type WidgetTheme = {
|
|
|
61
61
|
* @property {{ [key: string]: string }} wallets - If you want to change the default affiliate wallet
|
|
62
62
|
* addresses, you can provide new values here. (Map of route blockchains to affiliate address)
|
|
63
63
|
*/
|
|
64
|
-
export type
|
|
64
|
+
export type WidgeAffiliate = {
|
|
65
65
|
ref?: string;
|
|
66
66
|
percent?: number;
|
|
67
67
|
wallets?: { [key: string]: string };
|
|
@@ -77,58 +77,21 @@ export type WidgetAffiliate = {
|
|
|
77
77
|
* blockchains. e.g. ['BSC','ETHEREUM']
|
|
78
78
|
* @property {Asset[]} tokens - The `tokens` property is an optional array of `Asset` objects that
|
|
79
79
|
* you could use that to limit tokens to some limited ones.
|
|
80
|
-
* @property {Asset} pinnedTokens - The `pinnedTokens` property is an optional array of `Asset` objects that
|
|
81
|
-
* you could use to pin tokens of your choice to the top of the token list.
|
|
82
80
|
*/
|
|
83
81
|
export type BlockchainAndTokenConfig = {
|
|
84
82
|
blockchain?: string;
|
|
85
83
|
token?: Asset;
|
|
86
84
|
blockchains?: string[];
|
|
87
85
|
tokens?: Asset[];
|
|
88
|
-
pinnedTokens?: Asset[];
|
|
89
86
|
};
|
|
90
87
|
|
|
91
|
-
/**
|
|
92
|
-
* `Features`
|
|
93
|
-
*
|
|
94
|
-
* @property {'visible' | 'hidden'} [theme]
|
|
95
|
-
* - The visibility state for the theme feature. Optional property.
|
|
96
|
-
*
|
|
97
|
-
* @property {'visible' | 'hidden'} [language]
|
|
98
|
-
* - The visibility state for the language feature. Optional property.
|
|
99
|
-
*
|
|
100
|
-
* @property {'disabled' | 'enabled'} [experimentalRoute]
|
|
101
|
-
* - The enablement state for the experimental route feature. Optional property.
|
|
102
|
-
*
|
|
103
|
-
* @property {'visible' | 'hidden'} [connectWalletButton]
|
|
104
|
-
* - The visibility state for the connect wallet button feature. Optional property.
|
|
105
|
-
*
|
|
106
|
-
* @property {'visible' | 'hidden'} [notification]
|
|
107
|
-
* - The visibility state for the notification feature. Optional property.
|
|
108
|
-
*
|
|
109
|
-
* @property {'visible' | 'hidden'} [liquiditySource]
|
|
110
|
-
* - The visibility state for the liquiditySource feature. Optional property.
|
|
111
|
-
*/
|
|
112
|
-
export type Features = Partial<
|
|
113
|
-
Record<
|
|
114
|
-
| 'theme'
|
|
115
|
-
| 'language'
|
|
116
|
-
| 'connectWalletButton'
|
|
117
|
-
| 'notification'
|
|
118
|
-
| 'liquiditySource',
|
|
119
|
-
'visible' | 'hidden'
|
|
120
|
-
>
|
|
121
|
-
> &
|
|
122
|
-
Partial<Record<'experimentalRoute', 'disabled' | 'enabled'>>;
|
|
123
|
-
|
|
124
88
|
/**
|
|
125
89
|
* The type WidgetConfig defines the configuration options for a widget, including API key, affiliate
|
|
126
90
|
* reference, amount, blockchain and token configurations, liquidity sources, wallet types, language,
|
|
127
91
|
* and theme.
|
|
128
92
|
*
|
|
129
93
|
* @property {string} apiKey - The API key used to communicate with Rango API
|
|
130
|
-
* @property {
|
|
131
|
-
* @property {WidgetAffiliate} affiliate - If you want to charge users fee per transaction, you should
|
|
94
|
+
* @property {WidgeAffiliate} affiliate - If you want to charge users fee per transaction, you should
|
|
132
95
|
* pass `WidgetAffiliate` including affiliateRef, affiliatePercent, and affiliateWallets.
|
|
133
96
|
* @property {number} amount - The default input amount.
|
|
134
97
|
* @property {BlockchainAndTokenConfig} from - The `from` property is an optional property of type
|
|
@@ -156,23 +119,15 @@ export type Features = Partial<
|
|
|
156
119
|
* that defines the various properties of the theme, such as colors, fonts, and others.
|
|
157
120
|
* @property {boolean} externalWallets
|
|
158
121
|
* If `externalWallets` is `true`, you should add `WidgetWallets` to your app.
|
|
159
|
-
* @property {
|
|
122
|
+
* @property {Asset} pinnedTokens - The `pinnedTokens` property is an optional array of `Asset` objects that
|
|
123
|
+
* you could use to pin tokens of your choice to the top of the token list.
|
|
124
|
+
* @property {boolean} includeNewLiquiditySources - The `includeNewLiquiditySources` property is a boolean value that when you
|
|
160
125
|
* set it to true, whenever a new liquidity source is added, it will be added to your list as well.
|
|
161
|
-
* @property {Features} features - An optional object for configuring the visibility or enablement of various features.
|
|
162
|
-
* Keys include:
|
|
163
|
-
* - 'notification': Visibility state for the notification icon.
|
|
164
|
-
* - 'theme': Visibility state for the theme.
|
|
165
|
-
* - 'liquiditySource': Visibility state for liquidity source.
|
|
166
|
-
* - 'connectWalletButton': Visibility state for the wallet connect icon.
|
|
167
|
-
* - 'language': Visibility state for the language.
|
|
168
|
-
* - 'experimentalRoute': Enablement state for the experimental route.
|
|
169
126
|
*/
|
|
170
|
-
|
|
171
127
|
export type WidgetConfig = {
|
|
172
128
|
apiKey: string;
|
|
173
|
-
apiUrl?: string;
|
|
174
129
|
walletConnectProjectId?: string;
|
|
175
|
-
affiliate?:
|
|
130
|
+
affiliate?: WidgeAffiliate;
|
|
176
131
|
amount?: number;
|
|
177
132
|
from?: BlockchainAndTokenConfig;
|
|
178
133
|
to?: BlockchainAndTokenConfig;
|
|
@@ -183,6 +138,6 @@ export type WidgetConfig = {
|
|
|
183
138
|
language?: Language;
|
|
184
139
|
theme?: WidgetTheme;
|
|
185
140
|
externalWallets?: boolean;
|
|
186
|
-
|
|
187
|
-
|
|
141
|
+
pinnedTokens?: Asset[];
|
|
142
|
+
includeNewLiquiditySources?: boolean;
|
|
188
143
|
};
|
package/src/types/index.ts
CHANGED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/prefer-enum-initializers */
|
|
2
|
+
import type { RouteState } from '../store/bestRoute';
|
|
3
|
+
import type { SettingsState } from '../store/settings';
|
|
4
|
+
|
|
5
|
+
interface BestRouteStoreParams {
|
|
6
|
+
fromBlockchain?: RouteState['fromBlockchain'];
|
|
7
|
+
toBlockchain?: RouteState['toBlockchain'];
|
|
8
|
+
fromToken?: RouteState['fromToken'];
|
|
9
|
+
toToken?: RouteState['toToken'];
|
|
10
|
+
inputAmount?: RouteState['inputAmount'];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface SettingsStoreParams {
|
|
14
|
+
slippage?: SettingsState['slippage'];
|
|
15
|
+
customSlippage?: SettingsState['customSlippage'];
|
|
16
|
+
disabledLiquiditySources?: SettingsState['disabledLiquiditySources'];
|
|
17
|
+
infiniteApprove?: SettingsState['infiniteApprove'];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type BestRouteEqualityParams =
|
|
21
|
+
| {
|
|
22
|
+
store: 'bestRoute';
|
|
23
|
+
prevState: BestRouteStoreParams;
|
|
24
|
+
currentState: BestRouteStoreParams;
|
|
25
|
+
}
|
|
26
|
+
| {
|
|
27
|
+
store: 'settings';
|
|
28
|
+
prevState: SettingsStoreParams;
|
|
29
|
+
currentState: SettingsStoreParams;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export enum ConfirmSwapErrorTypes {
|
|
33
|
+
NO_ROUTE,
|
|
34
|
+
ROUTE_UPDATED_WITH_HIGH_VALUE_LOSS,
|
|
35
|
+
REQUEST_FAILED,
|
|
36
|
+
REQUEST_CANCELED,
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export type ConfirmSwapError =
|
|
40
|
+
| {
|
|
41
|
+
type: ConfirmSwapErrorTypes.NO_ROUTE;
|
|
42
|
+
diagnosisMessage?: string;
|
|
43
|
+
}
|
|
44
|
+
| {
|
|
45
|
+
type: Exclude<ConfirmSwapErrorTypes, ConfirmSwapErrorTypes.NO_ROUTE>;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export enum RouteWarningType {
|
|
49
|
+
ROUTE_UPDATED,
|
|
50
|
+
ROUTE_SWAPPERS_UPDATED,
|
|
51
|
+
ROUTE_COINS_UPDATED,
|
|
52
|
+
ROUTE_AND_OUTPUT_AMOUNT_UPDATED,
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export type RouteWarning =
|
|
56
|
+
| {
|
|
57
|
+
type: RouteWarningType.ROUTE_AND_OUTPUT_AMOUNT_UPDATED;
|
|
58
|
+
newOutputAmount: string;
|
|
59
|
+
percentageChange: string;
|
|
60
|
+
}
|
|
61
|
+
| {
|
|
62
|
+
type: Exclude<
|
|
63
|
+
RouteWarningType,
|
|
64
|
+
RouteWarningType.ROUTE_AND_OUTPUT_AMOUNT_UPDATED
|
|
65
|
+
>;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export enum SlippageWarningType {
|
|
69
|
+
INSUFFICIENT_SLIPPAGE,
|
|
70
|
+
HIGH_SLIPPAGE,
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export type ConfirmSwapWarnings = {
|
|
74
|
+
route: RouteWarning | null;
|
|
75
|
+
balance: { messages: string[] } | null;
|
|
76
|
+
slippage: { type: SlippageWarningType; slippage: string | null } | null;
|
|
77
|
+
};
|
package/src/types/swap.ts
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
|
-
import type { SwapSavedSettings } from 'rango-types';
|
|
1
|
+
import type { SwapSavedSettings } from 'rango-types/lib';
|
|
2
2
|
|
|
3
3
|
export type PendingSwapSettings = Omit<
|
|
4
4
|
SwapSavedSettings,
|
|
5
5
|
'disabledSwappersIds'
|
|
6
6
|
>;
|
|
7
7
|
|
|
8
|
-
export
|
|
9
|
-
|
|
8
|
+
export enum ButtonState {
|
|
9
|
+
WAITFORCONNECTING = 'waitForConnecting',
|
|
10
|
+
SWAP = 'swap',
|
|
11
|
+
NEEDTOCONFIRM = 'needToConfirm',
|
|
12
|
+
WARNING = 'warning',
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type SwapButtonState = (
|
|
16
|
+
| { disabled: true }
|
|
17
|
+
| { disabled: false; hasWarning?: boolean }
|
|
18
|
+
) & {
|
|
10
19
|
title: string;
|
|
11
|
-
|
|
20
|
+
state: ButtonState;
|
|
12
21
|
};
|
|
13
22
|
|
|
14
23
|
export type ConvertedToken = {
|
package/src/types/wallets.ts
CHANGED
|
@@ -1,24 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { WalletType } from '@rango-dev/wallets-shared';
|
|
2
2
|
|
|
3
3
|
export interface Wallet {
|
|
4
4
|
chain: string;
|
|
5
5
|
address: string;
|
|
6
6
|
walletType: WalletType;
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
export type Balance = {
|
|
10
|
-
amount: string;
|
|
11
|
-
decimals: number;
|
|
12
|
-
usdValue: string;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
type Blockchain = string;
|
|
16
|
-
type TokenSymbol = string;
|
|
17
|
-
type Address = string;
|
|
18
|
-
|
|
19
|
-
/** `blockchain-symbol-Address` */
|
|
20
|
-
export type TokenHash = `${Blockchain}-${TokenSymbol}-${Address}`;
|
|
21
|
-
|
|
22
|
-
export type TokensBalance = {
|
|
23
|
-
[key: TokenHash]: Balance;
|
|
24
|
-
};
|
package/src/utils/colors.ts
CHANGED
|
@@ -31,7 +31,7 @@ export const generateRangeColors = (name: string, color: string) => {
|
|
|
31
31
|
const NUMBER_OF_COLORS = 10;
|
|
32
32
|
const HALF_NUMBER_OF_COLORS = 5;
|
|
33
33
|
const COLOR_SUFFIX = 100;
|
|
34
|
-
const AMT =
|
|
34
|
+
const AMT = 32;
|
|
35
35
|
|
|
36
36
|
let colors = { [name]: color };
|
|
37
37
|
for (let i = 1; i < NUMBER_OF_COLORS; i++) {
|
|
@@ -60,7 +60,6 @@ export const generateRangeColors = (name: string, color: string) => {
|
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
|
|
64
63
|
return colors;
|
|
65
64
|
};
|
|
66
65
|
export const generateColors = (
|
package/src/utils/configs.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { RANGO_PUBLIC_API_KEY } from '../constants';
|
|
|
2
2
|
|
|
3
3
|
export interface Configs {
|
|
4
4
|
API_KEY: string;
|
|
5
|
-
BASE_URL?: string;
|
|
6
5
|
}
|
|
7
6
|
|
|
8
7
|
let configs: Configs = {
|
|
@@ -10,7 +9,7 @@ let configs: Configs = {
|
|
|
10
9
|
};
|
|
11
10
|
|
|
12
11
|
export function getConfig(name: keyof Configs) {
|
|
13
|
-
return configs[name]
|
|
12
|
+
return configs[name];
|
|
14
13
|
}
|
|
15
14
|
|
|
16
15
|
export function setConfig(name: keyof Configs, value: any) {
|
package/src/utils/date.ts
CHANGED
package/src/utils/meta.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Asset, BlockchainMeta,
|
|
1
|
+
import type { Asset, BlockchainMeta, Token } from 'rango-sdk';
|
|
2
2
|
|
|
3
3
|
import { tokensAreEqual } from './wallets';
|
|
4
4
|
|
|
@@ -17,13 +17,6 @@ export function getBlockchainShortNameFor(
|
|
|
17
17
|
?.shortName;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
export function getSwapperDisplayName(
|
|
21
|
-
swapperId: string,
|
|
22
|
-
swappers: SwapperMeta[]
|
|
23
|
-
) {
|
|
24
|
-
return swappers.find((swapper) => swapper.id === swapperId)?.swapperGroup;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
20
|
export function findToken(t: Asset, tokens: Token[]) {
|
|
28
21
|
return tokens.find((token) => tokensAreEqual(token, t)) ?? null;
|
|
29
22
|
}
|
package/src/utils/numbers.ts
CHANGED
|
@@ -16,7 +16,7 @@ export const secondsToString = (s: number): string => {
|
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
export const numberToString = (
|
|
19
|
-
number: BigNumber | string |
|
|
19
|
+
number: BigNumber | string | null | undefined,
|
|
20
20
|
minDecimals: number | null = null,
|
|
21
21
|
maxDecimals: number | null = null
|
|
22
22
|
): string => {
|