@rango-dev/widget-embedded 0.19.0 → 0.19.1-next.1
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 +0 -4
- package/dist/QueueManager.d.ts +5 -2
- package/dist/QueueManager.d.ts.map +1 -1
- package/dist/components/AppRouter.d.ts +0 -2
- package/dist/components/AppRouter.d.ts.map +1 -1
- package/dist/components/AppRoutes.d.ts +1 -6
- 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 +1 -3
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +690 -61
- 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 +1 -3
- 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 +1 -4
- 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/LoadingSwapDetails.d.ts.map +1 -1
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts +1727 -0
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts.map +1 -1
- package/dist/components/NoResult/NoResult.d.ts +4 -0
- package/dist/components/NoResult/NoResult.d.ts.map +1 -0
- package/dist/components/NoResult/NoResult.helpers.d.ts +4 -0
- package/dist/components/NoResult/NoResult.helpers.d.ts.map +1 -0
- package/dist/components/{NoRoutes/NoRoutes.styles.d.ts → NoResult/NoResult.styles.d.ts} +1 -1
- package/dist/components/{NoRoutes/NoRoutes.styles.d.ts.map → NoResult/NoResult.styles.d.ts.map} +1 -1
- package/dist/components/{NoRoutes/NoRoutes.types.d.ts → NoResult/NoResult.types.d.ts} +3 -3
- package/dist/components/NoResult/NoResult.types.d.ts.map +1 -0
- package/dist/components/NoResult/index.d.ts +2 -0
- package/dist/components/NoResult/index.d.ts.map +1 -0
- package/dist/components/NotificationContent/NotificationContent.d.ts.map +1 -1
- package/dist/components/Quote/Quote.d.ts +4 -0
- package/dist/components/Quote/Quote.d.ts.map +1 -0
- package/dist/components/Quote/Quote.styles.d.ts +2217 -0
- package/dist/components/Quote/Quote.styles.d.ts.map +1 -0
- package/dist/components/Quote/Quote.types.d.ts +21 -0
- package/dist/components/Quote/Quote.types.d.ts.map +1 -0
- package/dist/components/Quote/QuoteSummary.d.ts +11 -0
- package/dist/components/Quote/QuoteSummary.d.ts.map +1 -0
- package/dist/components/Quote/QuoteSummary.styles.d.ts +315 -0
- package/dist/components/Quote/QuoteSummary.styles.d.ts.map +1 -0
- package/dist/components/Quote/index.d.ts +3 -0
- package/dist/components/Quote/index.d.ts.map +1 -0
- package/dist/components/QuoteSkeleton/QuoteSkeleton.d.ts +4 -0
- package/dist/components/QuoteSkeleton/QuoteSkeleton.d.ts.map +1 -0
- package/dist/components/QuoteSkeleton/QuoteSkeleton.styles.d.ts +633 -0
- package/dist/components/QuoteSkeleton/QuoteSkeleton.styles.d.ts.map +1 -0
- package/dist/components/QuoteSkeleton/QuoteSkeleton.types.d.ts +6 -0
- package/dist/components/QuoteSkeleton/QuoteSkeleton.types.d.ts.map +1 -0
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.d.ts +4 -0
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.d.ts.map +1 -0
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.styles.d.ts +1571 -0
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.styles.d.ts.map +1 -0
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.types.d.ts +6 -0
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.types.d.ts.map +1 -0
- package/dist/components/QuoteSkeleton/StepSkeleton.d.ts +4 -0
- package/dist/components/QuoteSkeleton/StepSkeleton.d.ts.map +1 -0
- package/dist/components/QuoteSkeleton/StepSkeleton.styles.d.ts +786 -0
- package/dist/components/QuoteSkeleton/StepSkeleton.styles.d.ts.map +1 -0
- package/dist/components/QuoteSkeleton/StepSkeleton.types.d.ts +4 -0
- package/dist/components/QuoteSkeleton/StepSkeleton.types.d.ts.map +1 -0
- package/dist/components/QuoteSkeleton/index.d.ts +4 -0
- package/dist/components/QuoteSkeleton/index.d.ts.map +1 -0
- package/dist/components/QuoteWarningsAndErrors/HighValueLossWarningModal.d.ts +11 -0
- package/dist/components/QuoteWarningsAndErrors/HighValueLossWarningModal.d.ts.map +1 -0
- package/dist/components/QuoteWarningsAndErrors/QuoteErrorsModalItem.d.ts +4 -0
- package/dist/components/QuoteWarningsAndErrors/QuoteErrorsModalItem.d.ts.map +1 -0
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.d.ts +4 -0
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.d.ts.map +1 -0
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts +9 -0
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts.map +1 -0
- package/dist/components/{RouteErrors/RouteErrors.styles.d.ts → QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts} +1 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts.map +1 -0
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts +23 -0
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts.map +1 -0
- package/dist/components/QuoteWarningsAndErrors/SlippageWariningModal.d.ts +11 -0
- package/dist/components/QuoteWarningsAndErrors/SlippageWariningModal.d.ts.map +1 -0
- package/dist/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.d.ts +11 -0
- package/dist/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.d.ts.map +1 -0
- package/dist/components/QuoteWarningsAndErrors/index.d.ts +2 -0
- package/dist/components/QuoteWarningsAndErrors/index.d.ts.map +1 -0
- package/dist/components/Slippage/Slippage.d.ts.map +1 -1
- package/dist/components/Slippage/Slippage.styles.d.ts +158 -0
- 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 +628 -0
- 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 +157 -0
- 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 +1100 -1
- package/dist/components/TokenList/TokenList.styles.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.types.d.ts +4 -9
- package/dist/components/TokenList/TokenList.types.d.ts.map +1 -1
- package/dist/components/TokenList/index.d.ts +0 -1
- package/dist/components/TokenList/index.d.ts.map +1 -1
- package/dist/components/UpdateUrl.d.ts +1 -6
- 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 +1 -0
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/constants/messages.d.ts +1 -1
- package/dist/constants/navigationRoutes.d.ts +1 -2
- package/dist/constants/navigationRoutes.d.ts.map +1 -1
- package/dist/constants/searchParams.d.ts +2 -1
- 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/containers/App/App.d.ts +3 -0
- package/dist/containers/App/App.d.ts.map +1 -0
- package/dist/containers/App/App.styles.d.ts +158 -0
- package/dist/containers/App/App.styles.d.ts.map +1 -0
- package/dist/containers/App/index.d.ts +2 -0
- package/dist/containers/App/index.d.ts.map +1 -0
- package/dist/containers/QuoteInfo/QuoteInfo.d.ts +4 -0
- package/dist/containers/QuoteInfo/QuoteInfo.d.ts.map +1 -0
- package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts +788 -0
- package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts.map +1 -0
- package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts +20 -0
- package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts.map +1 -0
- package/dist/containers/QuoteInfo/index.d.ts +2 -0
- package/dist/containers/QuoteInfo/index.d.ts.map +1 -0
- package/dist/containers/Wallets/Wallets.d.ts +6 -0
- package/dist/containers/Wallets/Wallets.d.ts.map +1 -0
- package/dist/containers/Wallets/Wallets.types.d.ts +11 -0
- package/dist/containers/Wallets/Wallets.types.d.ts.map +1 -0
- package/dist/containers/Wallets/index.d.ts +2 -0
- package/dist/containers/Wallets/index.d.ts.map +1 -0
- package/dist/containers/Widget/Widget.d.ts +5 -0
- package/dist/containers/Widget/Widget.d.ts.map +1 -0
- package/dist/containers/Widget/Widget.types.d.ts +5 -0
- package/dist/containers/Widget/Widget.types.d.ts.map +1 -0
- package/dist/containers/Widget/index.d.ts +3 -0
- package/dist/containers/Widget/index.d.ts.map +1 -0
- package/dist/containers/WidgetInfo/WidgetInfo.d.ts +6 -0
- package/dist/containers/WidgetInfo/WidgetInfo.d.ts.map +1 -0
- package/dist/containers/WidgetInfo/WidgetInfo.helpers.d.ts +20 -0
- package/dist/containers/WidgetInfo/WidgetInfo.helpers.d.ts.map +1 -0
- package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts +21 -0
- package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts.map +1 -0
- package/dist/containers/WidgetInfo/index.d.ts +2 -0
- package/dist/containers/WidgetInfo/index.d.ts.map +1 -0
- package/dist/containers/WidgetProvider/WidgetProvider.d.ts +5 -0
- package/dist/containers/WidgetProvider/WidgetProvider.d.ts.map +1 -0
- package/dist/containers/WidgetProvider/WidgetProvider.types.d.ts +7 -0
- package/dist/containers/WidgetProvider/WidgetProvider.types.d.ts.map +1 -0
- package/dist/containers/WidgetProvider/index.d.ts +2 -0
- package/dist/containers/WidgetProvider/index.d.ts.map +1 -0
- package/dist/hooks/useConfirmSwap/index.d.ts +2 -0
- package/dist/hooks/useConfirmSwap/index.d.ts.map +1 -0
- package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts +3 -0
- package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts.map +1 -0
- package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts +19 -0
- package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts.map +1 -0
- package/dist/hooks/{useConfirmSwap.d.ts → useConfirmSwap/useConfirmSwap.types.d.ts} +5 -7
- package/dist/hooks/useConfirmSwap/useConfirmSwap.types.d.ts.map +1 -0
- package/dist/hooks/{useFetchBestRoute.d.ts → useFetchQuote.d.ts} +3 -3
- package/dist/hooks/useFetchQuote.d.ts.map +1 -0
- package/dist/hooks/useForceAutoConnect.d.ts +2 -0
- package/dist/hooks/useForceAutoConnect.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 +1 -3
- 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 +5 -7
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.d.ts.map +1 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.d.ts +1 -0
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.d.ts.map +1 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.types.d.ts +5 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.types.d.ts.map +1 -1
- package/dist/hooks/useSwapInput.d.ts +4 -2
- package/dist/hooks/useSwapInput.d.ts.map +1 -1
- package/dist/hooks/useSyncStoresWithConfig.d.ts +1 -2
- 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 +21 -8
- 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 +1 -6
- 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 +1 -2
- 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 +1 -6
- 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 +1 -8
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/store/AppStore.d.ts +47 -0
- package/dist/store/AppStore.d.ts.map +1 -0
- package/dist/store/app.d.ts +41 -22
- package/dist/store/app.d.ts.map +1 -1
- package/dist/store/notification.d.ts +4 -3
- package/dist/store/notification.d.ts.map +1 -1
- package/dist/store/quote.d.ts +89 -0
- package/dist/store/quote.d.ts.map +1 -0
- package/dist/store/slices/config.d.ts +3 -2
- package/dist/store/slices/config.d.ts.map +1 -1
- package/dist/store/slices/data.d.ts +5 -2
- package/dist/store/slices/data.d.ts.map +1 -1
- package/dist/store/slices/settings.d.ts +39 -0
- package/dist/store/slices/settings.d.ts.map +1 -0
- package/dist/store/ui.d.ts +2 -1
- package/dist/store/ui.d.ts.map +1 -1
- package/dist/store/wallets.d.ts +14 -9
- package/dist/store/wallets.d.ts.map +1 -1
- package/dist/types/config.d.ts +41 -8
- 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/quote.d.ts +82 -0
- package/dist/types/quote.d.ts.map +1 -0
- package/dist/types/swap.d.ts +4 -14
- package/dist/types/swap.d.ts.map +1 -1
- package/dist/types/wallets.d.ts +15 -1
- package/dist/types/wallets.d.ts.map +1 -1
- package/dist/utils/colors.d.ts.map +1 -1
- package/dist/utils/configs.d.ts +1 -0
- package/dist/utils/configs.d.ts.map +1 -1
- package/dist/utils/meta.d.ts +2 -1
- 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/quote.d.ts +32 -0
- package/dist/utils/quote.d.ts.map +1 -0
- package/dist/utils/settings.d.ts +6 -2
- package/dist/utils/settings.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +35 -24
- 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 +9 -10
- package/dist/utils/wallets.d.ts.map +1 -1
- package/package.json +12 -10
- package/src/QueueManager.tsx +18 -17
- package/src/components/AppRouter.tsx +8 -32
- package/src/components/AppRoutes.tsx +57 -69
- 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 +26 -17
- package/src/components/ConfirmWalletsModal/ConfirmWallets.helpers.ts +2 -64
- package/src/components/ConfirmWalletsModal/ConfirmWallets.styles.ts +29 -10
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +43 -47
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.types.ts +1 -3
- package/src/components/ConfirmWalletsModal/WalletList.tsx +9 -8
- package/src/components/ConfirmWalletsModal/WalletList.type.ts +1 -4
- package/src/components/HeaderButtons/HomeButtons.tsx +28 -18
- package/src/components/Layout/Layout.styles.ts +2 -0
- package/src/components/Layout/Layout.tsx +20 -7
- package/src/components/Layout/Layout.types.ts +2 -2
- package/src/components/LoadingSwapDetails/LoadingSwapDetails.styles.ts +65 -61
- package/src/components/LoadingSwapDetails/LoadingSwapDetails.tsx +28 -34
- package/src/components/{NoRoutes/NoRoutes.helper.ts → NoResult/NoResult.helpers.ts} +23 -16
- package/src/components/{NoRoutes/NoRoutes.styles.ts → NoResult/NoResult.styles.ts} +2 -0
- package/src/components/{NoRoutes/NoRoutes.tsx → NoResult/NoResult.tsx} +12 -17
- package/src/components/{NoRoutes/NoRoutes.types.ts → NoResult/NoResult.types.ts} +3 -2
- package/src/components/NoResult/index.ts +1 -0
- package/src/components/NotificationContent/NotificationContent.tsx +5 -3
- package/src/components/Quote/Quote.styles.ts +250 -0
- package/src/components/Quote/Quote.tsx +414 -0
- package/src/components/Quote/Quote.types.ts +15 -0
- package/src/components/Quote/QuoteSummary.styles.ts +16 -0
- package/src/components/Quote/QuoteSummary.tsx +46 -0
- package/src/components/Quote/index.ts +2 -0
- package/src/components/QuoteSkeleton/QuoteSkeleton.styles.ts +42 -0
- package/src/components/QuoteSkeleton/QuoteSkeleton.tsx +30 -0
- package/src/components/QuoteSkeleton/QuoteSkeleton.types.ts +5 -0
- package/src/components/QuoteSkeleton/QuoteSummarySkeleton.styles.ts +57 -0
- package/src/components/QuoteSkeleton/QuoteSummarySkeleton.tsx +76 -0
- package/src/components/QuoteSkeleton/QuoteSummarySkeleton.types.ts +6 -0
- package/src/components/QuoteSkeleton/StepSkeleton.styles.ts +33 -0
- package/src/components/QuoteSkeleton/StepSkeleton.tsx +44 -0
- package/src/components/QuoteSkeleton/StepSkeleton.types.ts +1 -0
- package/src/components/QuoteSkeleton/index.ts +3 -0
- package/src/components/QuoteWarningsAndErrors/HighValueLossWarningModal.tsx +107 -0
- package/src/components/{RouteErrors/RouteErrorsModalItem.tsx → QuoteWarningsAndErrors/QuoteErrorsModalItem.tsx} +4 -4
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.ts +74 -0
- package/src/components/{RouteErrors/RouteErrors.styles.ts → QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.ts} +8 -1
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.tsx +103 -0
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.ts +25 -0
- package/src/components/QuoteWarningsAndErrors/SlippageWariningModal.tsx +77 -0
- package/src/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.tsx +38 -0
- package/src/components/QuoteWarningsAndErrors/index.ts +1 -0
- package/src/components/Slippage/Slippage.styles.ts +15 -5
- package/src/components/Slippage/Slippage.tsx +11 -10
- package/src/components/SwapDetails/SwapDetails.Placeholder.tsx +5 -8
- package/src/components/SwapDetails/SwapDetails.helpers.tsx +1 -1
- package/src/components/SwapDetails/SwapDetails.styles.ts +36 -33
- package/src/components/SwapDetails/SwapDetails.tsx +41 -56
- package/src/components/SwapDetailsAlerts/SwapDetailsAlerts.Warning.tsx +1 -1
- package/src/components/SwapDetailsModal/SwapDetailsCompleteModal.tsx +4 -3
- package/src/components/SwapDetailsModal/SwapDetailsModal.Cancel.tsx +2 -2
- package/src/components/SwapDetailsModal/SwapDetailsModal.WalletState.tsx +14 -8
- 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 +10 -1
- package/src/components/SwapsGroup/SwapsGroup.tsx +3 -5
- package/src/components/SwitchFromAndTo.tsx +2 -2
- package/src/components/TokenList/TokenList.helpers.ts +2 -2
- package/src/components/TokenList/TokenList.styles.ts +74 -38
- package/src/components/TokenList/TokenList.tsx +35 -26
- package/src/components/TokenList/TokenList.types.ts +4 -10
- package/src/components/TokenList/index.ts +0 -1
- package/src/components/UpdateUrl.tsx +35 -30
- package/src/components/WidgetEvents.tsx +4 -2
- package/src/constants/errors.ts +17 -15
- package/src/constants/index.ts +1 -0
- package/src/constants/messages.ts +1 -1
- package/src/constants/navigationRoutes.ts +7 -8
- package/src/constants/searchParams.ts +1 -0
- package/src/constants/warnings.ts +7 -7
- package/src/containers/App/App.styles.ts +18 -0
- package/src/containers/App/App.tsx +52 -0
- package/src/containers/App/index.ts +1 -0
- package/src/containers/QuoteInfo/QuoteInfo.styles.ts +31 -0
- package/src/containers/QuoteInfo/QuoteInfo.tsx +99 -0
- package/src/containers/QuoteInfo/QuoteInfo.types.ts +20 -0
- package/src/containers/QuoteInfo/index.ts +1 -0
- package/src/{Wallets.tsx → containers/Wallets/Wallets.tsx} +48 -34
- package/src/containers/Wallets/Wallets.types.ts +12 -0
- package/src/containers/Wallets/index.ts +1 -0
- package/src/containers/Widget/Widget.tsx +19 -0
- package/src/containers/Widget/Widget.types.ts +5 -0
- package/src/containers/Widget/index.ts +2 -0
- package/src/containers/WidgetInfo/WidgetInfo.helpers.ts +64 -0
- package/src/containers/WidgetInfo/WidgetInfo.tsx +62 -0
- package/src/containers/WidgetInfo/WidgetInfo.types.ts +21 -0
- package/src/containers/WidgetInfo/index.ts +1 -0
- package/src/containers/WidgetProvider/WidgetProvider.tsx +28 -0
- package/src/containers/WidgetProvider/WidgetProvider.types.ts +7 -0
- package/src/containers/WidgetProvider/index.ts +1 -0
- package/src/hooks/useConfirmSwap/index.ts +1 -0
- package/src/hooks/useConfirmSwap/useConfirmSwap.helpers.ts +172 -0
- package/src/hooks/useConfirmSwap/useConfirmSwap.ts +137 -0
- package/src/hooks/useConfirmSwap/useConfirmSwap.types.ts +19 -0
- package/src/hooks/{useFetchBestRoute.ts → useFetchQuote.ts} +3 -3
- package/src/hooks/useForceAutoConnect.ts +27 -0
- package/src/hooks/useLanguage.ts +4 -5
- package/src/hooks/useNavigateBack.ts +3 -52
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.constants.ts +1 -1
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.ts +37 -7
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.ts +60 -0
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.test.ts +78 -3
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.ts +15 -6
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.types.ts +6 -1
- package/src/hooks/useSwapInput.ts +141 -48
- package/src/hooks/useSyncStoresWithConfig.ts +40 -24
- package/src/hooks/useTheme.ts +4 -5
- package/src/hooks/useWalletList.ts +3 -5
- package/src/index.ts +50 -5
- package/src/pages/ConfirmSwapPage.tsx +117 -266
- package/src/pages/HistoryPage.tsx +2 -7
- package/src/pages/Home.tsx +88 -303
- package/src/pages/LanguagePage.tsx +0 -5
- package/src/pages/LiquiditySourcePage.tsx +24 -37
- package/src/pages/SelectBlockchainPage.tsx +31 -24
- package/src/pages/SelectSwapItemsPage.tsx +18 -31
- package/src/pages/SettingsPage.tsx +32 -27
- package/src/pages/SwapDetailsPage.tsx +6 -7
- package/src/pages/ThemePage.tsx +2 -7
- package/src/pages/WalletsPage.tsx +9 -19
- package/src/services/httpService.ts +1 -1
- package/src/store/AppStore.tsx +41 -0
- package/src/store/app.ts +44 -6
- package/src/store/{bestRoute.ts → quote.ts} +71 -64
- package/src/store/slices/config.ts +26 -15
- package/src/store/slices/data.ts +74 -35
- package/src/store/slices/settings.ts +168 -0
- package/src/store/wallets.ts +68 -37
- package/src/types/config.ts +53 -8
- package/src/types/index.ts +1 -1
- package/src/types/quote.ts +107 -0
- package/src/types/swap.ts +4 -13
- package/src/types/wallets.ts +18 -1
- package/src/utils/colors.ts +2 -1
- package/src/utils/configs.ts +2 -1
- package/src/utils/date.ts +1 -1
- package/src/utils/meta.ts +8 -1
- package/src/utils/numbers.ts +1 -1
- package/src/utils/providers.ts +8 -5
- package/src/utils/queue.ts +2 -2
- package/src/utils/quote.ts +338 -0
- package/src/utils/settings.ts +17 -10
- package/src/utils/swap.ts +154 -120
- package/src/utils/time.ts +1 -1
- package/src/utils/wallets.ts +156 -161
- package/dist/Wallets.d.ts +0 -17
- package/dist/Wallets.d.ts.map +0 -1
- package/dist/Widget.d.ts +0 -9
- package/dist/Widget.d.ts.map +0 -1
- package/dist/components/LoadingSwapDetails/LoadingSwapDetailStep.d.ts +0 -4
- package/dist/components/LoadingSwapDetails/LoadingSwapDetailStep.d.ts.map +0 -1
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.types.d.ts +0 -4
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.types.d.ts.map +0 -1
- package/dist/components/NoRoutes/NoRoutes.d.ts +0 -4
- package/dist/components/NoRoutes/NoRoutes.d.ts.map +0 -1
- package/dist/components/NoRoutes/NoRoutes.helper.d.ts +0 -3
- package/dist/components/NoRoutes/NoRoutes.helper.d.ts.map +0 -1
- package/dist/components/NoRoutes/NoRoutes.types.d.ts.map +0 -1
- package/dist/components/NoRoutes/index.d.ts +0 -2
- package/dist/components/NoRoutes/index.d.ts.map +0 -1
- package/dist/components/RouteErrors/RouteErrors.d.ts +0 -4
- package/dist/components/RouteErrors/RouteErrors.d.ts.map +0 -1
- package/dist/components/RouteErrors/RouteErrors.styles.d.ts.map +0 -1
- package/dist/components/RouteErrors/RouteErrors.types.d.ts +0 -24
- package/dist/components/RouteErrors/RouteErrors.types.d.ts.map +0 -1
- package/dist/components/RouteErrors/RouteErrorsModal.d.ts +0 -4
- package/dist/components/RouteErrors/RouteErrorsModal.d.ts.map +0 -1
- package/dist/components/RouteErrors/RouteErrorsModalItem.d.ts +0 -4
- package/dist/components/RouteErrors/RouteErrorsModalItem.d.ts.map +0 -1
- package/dist/components/RouteErrors/index.d.ts +0 -2
- package/dist/components/RouteErrors/index.d.ts.map +0 -1
- package/dist/hooks/useConfirmSwap.d.ts.map +0 -1
- package/dist/hooks/useFetchBestRoute.d.ts.map +0 -1
- package/dist/store/bestRoute.d.ts +0 -77
- package/dist/store/bestRoute.d.ts.map +0 -1
- package/dist/store/meta.d.ts +0 -23
- package/dist/store/meta.d.ts.map +0 -1
- package/dist/store/settings.d.ts +0 -81
- package/dist/store/settings.d.ts.map +0 -1
- package/dist/types/routing.d.ts +0 -65
- package/dist/types/routing.d.ts.map +0 -1
- package/dist/utils/routing.d.ts +0 -28
- package/dist/utils/routing.d.ts.map +0 -1
- package/src/Widget.tsx +0 -119
- package/src/components/LoadingSwapDetails/LoadingSwapDetailStep.tsx +0 -41
- package/src/components/LoadingSwapDetails/LoadingSwapDetails.types.ts +0 -3
- package/src/components/NoRoutes/index.ts +0 -1
- package/src/components/RouteErrors/RouteErrors.tsx +0 -79
- package/src/components/RouteErrors/RouteErrors.types.ts +0 -29
- package/src/components/RouteErrors/RouteErrorsModal.tsx +0 -129
- package/src/components/RouteErrors/index.ts +0 -1
- package/src/hooks/useConfirmSwap.ts +0 -303
- package/src/store/meta.ts +0 -39
- package/src/store/settings.ts +0 -158
- package/src/types/routing.ts +0 -77
- package/src/utils/routing.ts +0 -321
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import type { TokenWithBalance } from '../components/TokenList';
|
|
2
1
|
import type { Wallet } from '../types';
|
|
3
|
-
import type {
|
|
4
|
-
|
|
2
|
+
import type {
|
|
3
|
+
BestRouteResponse,
|
|
4
|
+
BlockchainMeta,
|
|
5
|
+
MetaResponse,
|
|
6
|
+
Token,
|
|
7
|
+
} from 'rango-sdk';
|
|
8
|
+
import type { PendingSwap } from 'rango-types';
|
|
5
9
|
|
|
6
10
|
import BigNumber from 'bignumber.js';
|
|
7
11
|
import { create } from 'zustand';
|
|
@@ -9,53 +13,58 @@ import { subscribeWithSelector } from 'zustand/middleware';
|
|
|
9
13
|
|
|
10
14
|
import { ZERO } from '../constants/numbers';
|
|
11
15
|
import { isPositiveNumber } from '../utils/numbers';
|
|
12
|
-
import {
|
|
13
|
-
createRetryRoute,
|
|
14
|
-
getBestRouteToTokenUsdPrice,
|
|
15
|
-
} from '../utils/routing';
|
|
16
|
+
import { createRetryQuote, getQuoteToTokenUsdPrice } from '../utils/quote';
|
|
16
17
|
import { calcOutputUsdValue } from '../utils/swap';
|
|
17
18
|
|
|
18
|
-
import { useMetaStore } from './meta';
|
|
19
19
|
import createSelectors from './selectors';
|
|
20
20
|
|
|
21
|
-
const getUsdValue = (
|
|
21
|
+
export const getUsdValue = (
|
|
22
|
+
token: Token | null,
|
|
23
|
+
amount: string
|
|
24
|
+
): BigNumber | null =>
|
|
22
25
|
token?.usdPrice
|
|
23
26
|
? new BigNumber(amount || ZERO).multipliedBy(token?.usdPrice || 0)
|
|
24
27
|
: null;
|
|
25
28
|
|
|
26
|
-
export
|
|
29
|
+
export type Meta = Pick<MetaResponse, 'blockchains' | 'tokens'>;
|
|
30
|
+
|
|
31
|
+
export type SetTokenParams = { token: Token; meta: Meta } | { token: null };
|
|
32
|
+
|
|
33
|
+
export interface QuoteState {
|
|
27
34
|
fromBlockchain: BlockchainMeta | null;
|
|
28
35
|
toBlockchain: BlockchainMeta | null;
|
|
29
36
|
inputAmount: string;
|
|
30
37
|
inputUsdValue: BigNumber | null;
|
|
31
38
|
outputAmount: BigNumber | null;
|
|
32
39
|
outputUsdValue: BigNumber | null;
|
|
33
|
-
fromToken:
|
|
34
|
-
toToken:
|
|
35
|
-
|
|
40
|
+
fromToken: Token | null;
|
|
41
|
+
toToken: Token | null;
|
|
42
|
+
quoteWalletsConfirmed: boolean;
|
|
36
43
|
selectedWallets: Wallet[];
|
|
37
|
-
|
|
44
|
+
quoteWarningsConfirmed: boolean;
|
|
45
|
+
resetQuote: () => void;
|
|
38
46
|
resetToBlockchain: () => void;
|
|
39
47
|
resetFromBlockchain: () => void;
|
|
40
48
|
setFromBlockchain: (chain: BlockchainMeta | null) => void;
|
|
41
49
|
setToBlockchain: (chian: BlockchainMeta | null) => void;
|
|
42
50
|
|
|
43
|
-
setFromToken: (
|
|
44
|
-
setToToken: (
|
|
51
|
+
setFromToken: (params: SetTokenParams) => void;
|
|
52
|
+
setToToken: (params: SetTokenParams) => void;
|
|
45
53
|
setInputAmount: (amount: string) => void;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
retry: (pendingSwap: PendingSwap) => void;
|
|
54
|
+
quote: BestRouteResponse | null;
|
|
55
|
+
setQuote: (quote: BestRouteResponse | null) => void;
|
|
56
|
+
retry: (pendingSwap: PendingSwap, meta: Meta) => void;
|
|
49
57
|
switchFromAndTo: () => void;
|
|
50
|
-
|
|
58
|
+
setQuoteWalletConfirmed: (flag: boolean) => void;
|
|
51
59
|
setSelectedWallets: (wallets: Wallet[]) => void;
|
|
52
60
|
customDestination: string;
|
|
53
61
|
setCustomDestination: (address: string) => void;
|
|
54
|
-
|
|
62
|
+
resetQuoteWallets: () => void;
|
|
63
|
+
setQuoteWarningsConfirmed: (flag: boolean) => void;
|
|
55
64
|
}
|
|
56
65
|
|
|
57
|
-
export const
|
|
58
|
-
create<
|
|
66
|
+
export const useQuoteStore = createSelectors(
|
|
67
|
+
create<QuoteState>()(
|
|
59
68
|
subscribeWithSelector((set) => ({
|
|
60
69
|
fromBlockchain: null,
|
|
61
70
|
fromToken: null,
|
|
@@ -65,37 +74,38 @@ export const useBestRouteStore = createSelectors(
|
|
|
65
74
|
outputUsdValue: new BigNumber(0),
|
|
66
75
|
toBlockchain: null,
|
|
67
76
|
toToken: null,
|
|
68
|
-
|
|
69
|
-
|
|
77
|
+
quote: null,
|
|
78
|
+
quoteWalletsConfirmed: false,
|
|
70
79
|
selectedWallets: [],
|
|
71
80
|
customDestination: '',
|
|
72
|
-
|
|
81
|
+
quoteWarningsConfirmed: false,
|
|
82
|
+
setQuote: (quote) =>
|
|
73
83
|
set((state) => {
|
|
74
84
|
let outputAmount: BigNumber | null = null;
|
|
75
85
|
let outputUsdValue: BigNumber = ZERO;
|
|
76
86
|
if (!isPositiveNumber(state.inputAmount)) {
|
|
77
87
|
return {};
|
|
78
88
|
}
|
|
79
|
-
if (!!
|
|
80
|
-
outputAmount = !!
|
|
81
|
-
? new BigNumber(
|
|
89
|
+
if (!!quote) {
|
|
90
|
+
outputAmount = !!quote.result?.outputAmount
|
|
91
|
+
? new BigNumber(quote.result?.outputAmount)
|
|
82
92
|
: null;
|
|
83
93
|
outputUsdValue = calcOutputUsdValue(
|
|
84
|
-
|
|
85
|
-
|
|
94
|
+
quote.result?.outputAmount,
|
|
95
|
+
getQuoteToTokenUsdPrice(quote) || state.toToken?.usdPrice
|
|
86
96
|
);
|
|
87
97
|
}
|
|
88
98
|
return {
|
|
89
|
-
|
|
90
|
-
...(!!
|
|
99
|
+
quote: quote,
|
|
100
|
+
...(!!quote && {
|
|
91
101
|
outputAmount,
|
|
92
102
|
outputUsdValue,
|
|
93
103
|
}),
|
|
94
104
|
};
|
|
95
105
|
}),
|
|
96
|
-
|
|
106
|
+
resetQuote: () =>
|
|
97
107
|
set(() => ({
|
|
98
|
-
|
|
108
|
+
quote: null,
|
|
99
109
|
outputAmount: null,
|
|
100
110
|
outputUsdValue: new BigNumber(0),
|
|
101
111
|
})),
|
|
@@ -108,7 +118,7 @@ export const useBestRouteStore = createSelectors(
|
|
|
108
118
|
return {
|
|
109
119
|
fromBlockchain: chain,
|
|
110
120
|
...(state.fromToken && {
|
|
111
|
-
|
|
121
|
+
quote: null,
|
|
112
122
|
fromToken: null,
|
|
113
123
|
outputAmount: null,
|
|
114
124
|
outputUsdValue: null,
|
|
@@ -116,18 +126,17 @@ export const useBestRouteStore = createSelectors(
|
|
|
116
126
|
};
|
|
117
127
|
});
|
|
118
128
|
},
|
|
119
|
-
setFromToken: (
|
|
120
|
-
const { blockchains } = useMetaStore.getState().meta;
|
|
129
|
+
setFromToken: (params) => {
|
|
121
130
|
return set((state) => ({
|
|
122
|
-
fromToken: token,
|
|
123
|
-
...(token && {
|
|
131
|
+
fromToken: params.token,
|
|
132
|
+
...(params.token && {
|
|
124
133
|
fromBlockchain:
|
|
125
|
-
blockchains.find(
|
|
126
|
-
(blockchain) => blockchain.name === token.blockchain
|
|
134
|
+
params.meta.blockchains.find(
|
|
135
|
+
(blockchain) => blockchain.name === params.token.blockchain
|
|
127
136
|
) ?? null,
|
|
128
137
|
}),
|
|
129
138
|
...(!!state.inputAmount && {
|
|
130
|
-
inputUsdValue: getUsdValue(token, state.inputAmount),
|
|
139
|
+
inputUsdValue: getUsdValue(params.token, state.inputAmount),
|
|
131
140
|
}),
|
|
132
141
|
}));
|
|
133
142
|
},
|
|
@@ -140,7 +149,7 @@ export const useBestRouteStore = createSelectors(
|
|
|
140
149
|
return {
|
|
141
150
|
toBlockchain: chain,
|
|
142
151
|
...(state.toToken && {
|
|
143
|
-
|
|
152
|
+
quote: null,
|
|
144
153
|
toToken: null,
|
|
145
154
|
outputAmount: null,
|
|
146
155
|
outputUsdValue: null,
|
|
@@ -148,14 +157,13 @@ export const useBestRouteStore = createSelectors(
|
|
|
148
157
|
};
|
|
149
158
|
});
|
|
150
159
|
},
|
|
151
|
-
setToToken: (
|
|
152
|
-
const { blockchains } = useMetaStore.getState().meta;
|
|
160
|
+
setToToken: (params) => {
|
|
153
161
|
return set(() => ({
|
|
154
|
-
toToken: token,
|
|
155
|
-
...(token && {
|
|
162
|
+
toToken: params.token,
|
|
163
|
+
...(params.token && {
|
|
156
164
|
toBlockchain:
|
|
157
|
-
blockchains.find(
|
|
158
|
-
(blockchain) => blockchain.name === token.blockchain
|
|
165
|
+
params.meta.blockchains.find(
|
|
166
|
+
(blockchain) => blockchain.name === params.token.blockchain
|
|
159
167
|
) ?? null,
|
|
160
168
|
}),
|
|
161
169
|
}));
|
|
@@ -166,24 +174,22 @@ export const useBestRouteStore = createSelectors(
|
|
|
166
174
|
...(!amount && {
|
|
167
175
|
outputAmount: new BigNumber(0),
|
|
168
176
|
outputUsdValue: new BigNumber(0),
|
|
169
|
-
|
|
177
|
+
quote: null,
|
|
170
178
|
}),
|
|
171
179
|
...(!!state.fromToken && {
|
|
172
180
|
inputUsdValue: getUsdValue(state.fromToken, amount),
|
|
173
181
|
}),
|
|
174
182
|
}));
|
|
175
183
|
},
|
|
176
|
-
retry: (pendingSwap) => {
|
|
177
|
-
const { tokens, blockchains } =
|
|
178
|
-
|
|
184
|
+
retry: (pendingSwap, meta) => {
|
|
185
|
+
const { tokens, blockchains } = meta;
|
|
179
186
|
const {
|
|
180
187
|
fromBlockchain,
|
|
181
188
|
fromToken,
|
|
182
189
|
toBlockchain,
|
|
183
190
|
toToken,
|
|
184
191
|
inputAmount,
|
|
185
|
-
} =
|
|
186
|
-
|
|
192
|
+
} = createRetryQuote(pendingSwap, blockchains, tokens);
|
|
187
193
|
set({
|
|
188
194
|
fromBlockchain,
|
|
189
195
|
fromToken,
|
|
@@ -193,7 +199,7 @@ export const useBestRouteStore = createSelectors(
|
|
|
193
199
|
outputUsdValue: new BigNumber(0),
|
|
194
200
|
toBlockchain,
|
|
195
201
|
toToken,
|
|
196
|
-
|
|
202
|
+
quote: null,
|
|
197
203
|
});
|
|
198
204
|
},
|
|
199
205
|
switchFromAndTo: () =>
|
|
@@ -208,14 +214,13 @@ export const useBestRouteStore = createSelectors(
|
|
|
208
214
|
state.outputAmount?.toString() || ''
|
|
209
215
|
),
|
|
210
216
|
})),
|
|
211
|
-
|
|
212
217
|
resetFromBlockchain: () =>
|
|
213
218
|
set(() => ({
|
|
214
219
|
fromToken: null,
|
|
215
220
|
fromBlockchain: null,
|
|
216
221
|
outputAmount: null,
|
|
217
222
|
outputUsdValue: null,
|
|
218
|
-
|
|
223
|
+
quote: null,
|
|
219
224
|
})),
|
|
220
225
|
resetToBlockchain: () =>
|
|
221
226
|
set(() => ({
|
|
@@ -223,20 +228,22 @@ export const useBestRouteStore = createSelectors(
|
|
|
223
228
|
toBlockchain: null,
|
|
224
229
|
outputAmount: null,
|
|
225
230
|
outputUsdValue: null,
|
|
226
|
-
|
|
231
|
+
quote: null,
|
|
227
232
|
})),
|
|
228
|
-
|
|
233
|
+
setQuoteWalletConfirmed: (flag) =>
|
|
229
234
|
set({
|
|
230
|
-
|
|
235
|
+
quoteWalletsConfirmed: flag,
|
|
231
236
|
}),
|
|
232
237
|
setSelectedWallets: (wallets) => set({ selectedWallets: wallets }),
|
|
233
238
|
setCustomDestination: (address) => set({ customDestination: address }),
|
|
234
|
-
|
|
239
|
+
resetQuoteWallets: () =>
|
|
235
240
|
set({
|
|
236
|
-
|
|
241
|
+
quoteWalletsConfirmed: false,
|
|
237
242
|
selectedWallets: [],
|
|
238
243
|
customDestination: '',
|
|
239
244
|
}),
|
|
245
|
+
setQuoteWarningsConfirmed: (flag) =>
|
|
246
|
+
set({ quoteWarningsConfirmed: flag }),
|
|
240
247
|
}))
|
|
241
248
|
)
|
|
242
249
|
);
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import type { WidgetConfig } from '../../types';
|
|
2
|
-
import type {
|
|
2
|
+
import type { StateCreatorWithInitialData } from '../app';
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
export const DEFAULT_CONFIG: WidgetConfig = {
|
|
5
|
+
apiKey: '',
|
|
6
|
+
multiWallets: true,
|
|
7
|
+
enableNewLiquiditySources: true,
|
|
8
|
+
customDestination: true,
|
|
9
|
+
};
|
|
5
10
|
|
|
6
11
|
export type ConfigSlice = {
|
|
7
12
|
config: WidgetConfig;
|
|
@@ -9,18 +14,24 @@ export type ConfigSlice = {
|
|
|
9
14
|
updateConfig: (config: WidgetConfig) => void;
|
|
10
15
|
};
|
|
11
16
|
|
|
12
|
-
export const createConfigSlice:
|
|
13
|
-
|
|
17
|
+
export const createConfigSlice: StateCreatorWithInitialData<
|
|
18
|
+
WidgetConfig,
|
|
19
|
+
ConfigSlice,
|
|
20
|
+
ConfigSlice
|
|
21
|
+
> = (initialData, set, get) => {
|
|
22
|
+
return {
|
|
23
|
+
config: { ...DEFAULT_CONFIG, ...initialData },
|
|
14
24
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
25
|
+
// Actions
|
|
26
|
+
updateConfig: (nextConfig: WidgetConfig) => {
|
|
27
|
+
const currentConfig = get().config;
|
|
18
28
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
29
|
+
set({
|
|
30
|
+
config: {
|
|
31
|
+
...currentConfig,
|
|
32
|
+
...nextConfig,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
};
|
package/src/store/slices/data.ts
CHANGED
|
@@ -6,6 +6,7 @@ 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';
|
|
9
10
|
import { tokensAreEqual } from '../../utils/wallets';
|
|
10
11
|
|
|
11
12
|
type BlockchainOptions = {
|
|
@@ -13,21 +14,22 @@ type BlockchainOptions = {
|
|
|
13
14
|
};
|
|
14
15
|
|
|
15
16
|
type TokenOptions = {
|
|
16
|
-
type
|
|
17
|
+
type: 'source' | 'destination';
|
|
17
18
|
// filter by an specific blockchain
|
|
18
19
|
blockchain?: string;
|
|
19
20
|
searchFor?: string;
|
|
20
21
|
};
|
|
21
|
-
|
|
22
|
+
export type FetchStatus = 'loading' | 'success' | 'failed';
|
|
22
23
|
export interface DataSlice {
|
|
23
24
|
_blockchains: BlockchainMeta[];
|
|
24
25
|
_tokens: Token[];
|
|
25
26
|
_popularTokens: Token[];
|
|
26
27
|
_swappers: SwapperMeta[];
|
|
27
|
-
|
|
28
|
+
fetchStatus: FetchStatus;
|
|
28
29
|
blockchains: (options?: BlockchainOptions) => BlockchainMeta[];
|
|
29
30
|
tokens: (options?: TokenOptions) => Token[];
|
|
30
|
-
|
|
31
|
+
swappers: () => SwapperMeta[];
|
|
32
|
+
isTokenPinned: (token: Token, type: 'source' | 'destination') => boolean;
|
|
31
33
|
|
|
32
34
|
fetch: () => Promise<void>;
|
|
33
35
|
}
|
|
@@ -43,7 +45,7 @@ export const createDataSlice: StateCreator<
|
|
|
43
45
|
_tokens: [],
|
|
44
46
|
_popularTokens: [],
|
|
45
47
|
_swappers: [],
|
|
46
|
-
|
|
48
|
+
fetchStatus: 'loading',
|
|
47
49
|
// Selectors
|
|
48
50
|
blockchains: (options) => {
|
|
49
51
|
const blockchainsFromState = get()._blockchains;
|
|
@@ -129,10 +131,10 @@ export const createDataSlice: StateCreator<
|
|
|
129
131
|
})
|
|
130
132
|
.sort((a, b) => {
|
|
131
133
|
// Check pinned tokens
|
|
132
|
-
if (get().isTokenPinned(a)) {
|
|
134
|
+
if (get().isTokenPinned(a, options.type)) {
|
|
133
135
|
return -1;
|
|
134
136
|
}
|
|
135
|
-
if (get().isTokenPinned(b)) {
|
|
137
|
+
if (get().isTokenPinned(b, options.type)) {
|
|
136
138
|
return 1;
|
|
137
139
|
}
|
|
138
140
|
|
|
@@ -157,47 +159,84 @@ export const createDataSlice: StateCreator<
|
|
|
157
159
|
|
|
158
160
|
return list;
|
|
159
161
|
},
|
|
160
|
-
isTokenPinned: (token) => {
|
|
161
|
-
const
|
|
162
|
+
isTokenPinned: (token, type) => {
|
|
163
|
+
const pinnedTokens =
|
|
164
|
+
type === 'source'
|
|
165
|
+
? get().config.from?.pinnedTokens
|
|
166
|
+
: get().config.to?.pinnedTokens;
|
|
167
|
+
const pinned = !!pinnedTokens?.some((pinnedToken) =>
|
|
162
168
|
tokensAreEqual(pinnedToken, token)
|
|
163
169
|
);
|
|
164
170
|
return pinned;
|
|
165
171
|
},
|
|
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
|
+
});
|
|
166
195
|
|
|
196
|
+
const sortedSwappers = swappers.sort(sortLiquiditySourcesByGroupTitle);
|
|
197
|
+
|
|
198
|
+
return sortedSwappers;
|
|
199
|
+
},
|
|
167
200
|
// Actions
|
|
168
201
|
fetch: async () => {
|
|
169
|
-
|
|
202
|
+
try {
|
|
203
|
+
const response = await sdk().getAllMetadata();
|
|
170
204
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
205
|
+
set({ fetchStatus: 'success' });
|
|
206
|
+
const blockchains: BlockchainMeta[] = [];
|
|
207
|
+
const tokens: Token[] = [];
|
|
208
|
+
const popularTokens: Token[] = response.popularTokens;
|
|
209
|
+
const swappers: SwapperMeta[] = response.swappers;
|
|
175
210
|
|
|
176
|
-
|
|
211
|
+
const blockchainsWithAtLeastOneToken = new Set();
|
|
177
212
|
|
|
178
|
-
|
|
179
|
-
|
|
213
|
+
response.tokens.forEach((token) => {
|
|
214
|
+
blockchainsWithAtLeastOneToken.add(token.blockchain);
|
|
180
215
|
|
|
181
|
-
|
|
182
|
-
|
|
216
|
+
tokens.push(token);
|
|
217
|
+
});
|
|
183
218
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
219
|
+
response.blockchains.forEach((blockchain) => {
|
|
220
|
+
if (
|
|
221
|
+
blockchain.enabled &&
|
|
222
|
+
blockchainsWithAtLeastOneToken.has(blockchain.name)
|
|
223
|
+
) {
|
|
224
|
+
blockchains.push(blockchain);
|
|
225
|
+
}
|
|
226
|
+
});
|
|
192
227
|
|
|
193
|
-
|
|
194
|
-
|
|
228
|
+
// Sort
|
|
229
|
+
blockchains.sort((a, b) => a.sort - b.sort);
|
|
195
230
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
231
|
+
set({
|
|
232
|
+
_blockchains: blockchains,
|
|
233
|
+
_tokens: tokens,
|
|
234
|
+
_popularTokens: popularTokens,
|
|
235
|
+
_swappers: swappers,
|
|
236
|
+
});
|
|
237
|
+
} catch (error) {
|
|
238
|
+
set({ fetchStatus: 'failed' });
|
|
239
|
+
throw error;
|
|
240
|
+
}
|
|
202
241
|
},
|
|
203
242
|
});
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import type { ConfigSlice } from './config';
|
|
2
|
+
import type { WidgetConfig } from '../../types';
|
|
3
|
+
import type { SwapperMeta } from 'rango-sdk';
|
|
4
|
+
import type { StateCreator } from 'zustand';
|
|
5
|
+
|
|
6
|
+
import { type Language } from '@rango-dev/ui';
|
|
7
|
+
|
|
8
|
+
import { BLOCKCHAIN_LIST_SIZE } from '../../constants/configs';
|
|
9
|
+
import { DEFAULT_LANGUAGE } from '../../constants/languages';
|
|
10
|
+
import { DEFAULT_SLIPPAGE } from '../../constants/swapSettings';
|
|
11
|
+
import { removeDuplicateFrom } from '../../utils/common';
|
|
12
|
+
import { isFeatureHidden } from '../../utils/settings';
|
|
13
|
+
|
|
14
|
+
export type ThemeMode = 'auto' | 'dark' | 'light';
|
|
15
|
+
|
|
16
|
+
export interface SettingsSlice {
|
|
17
|
+
theme: ThemeMode;
|
|
18
|
+
language: Language;
|
|
19
|
+
disabledLiquiditySources: string[];
|
|
20
|
+
/** Keeping a history of blockchains that user has selected (in Swap process) */
|
|
21
|
+
preferredBlockchains: string[];
|
|
22
|
+
slippage: number;
|
|
23
|
+
customSlippage: number | null;
|
|
24
|
+
infiniteApprove: boolean;
|
|
25
|
+
affiliateRef: string | null;
|
|
26
|
+
affiliatePercent: number | null;
|
|
27
|
+
affiliateWallets: { [key: string]: string } | null;
|
|
28
|
+
|
|
29
|
+
setSlippage: (slippage: number) => void;
|
|
30
|
+
setCustomSlippage: (customSlippage: number | null) => void;
|
|
31
|
+
toggleInfiniteApprove: () => void;
|
|
32
|
+
toggleLiquiditySource: (name: string) => void;
|
|
33
|
+
setTheme: (theme: ThemeMode) => void;
|
|
34
|
+
setLanguage: (language: Language) => void;
|
|
35
|
+
toggleAllLiquiditySources: (
|
|
36
|
+
swappers: SwapperMeta[],
|
|
37
|
+
shouldReset?: boolean
|
|
38
|
+
) => void;
|
|
39
|
+
setAffiliateRef: (affiliateRef: string | null) => void;
|
|
40
|
+
setAffiliatePercent: (affiliatePercent: number | null) => void;
|
|
41
|
+
setAffiliateWallets: (
|
|
42
|
+
affiliateWallets: { [key: string]: string } | null
|
|
43
|
+
) => void;
|
|
44
|
+
addPreferredBlockchain: (blockchain: string) => void;
|
|
45
|
+
updateSettings: (config: WidgetConfig) => void;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const createSettingsSlice: StateCreator<
|
|
49
|
+
SettingsSlice & ConfigSlice,
|
|
50
|
+
[],
|
|
51
|
+
[],
|
|
52
|
+
SettingsSlice
|
|
53
|
+
> = (set, get) => ({
|
|
54
|
+
disabledLiquiditySources: [],
|
|
55
|
+
theme: 'auto',
|
|
56
|
+
language: DEFAULT_LANGUAGE,
|
|
57
|
+
preferredBlockchains: [],
|
|
58
|
+
slippage: DEFAULT_SLIPPAGE,
|
|
59
|
+
customSlippage: null,
|
|
60
|
+
infiniteApprove: false,
|
|
61
|
+
affiliateRef: null,
|
|
62
|
+
affiliatePercent: null,
|
|
63
|
+
affiliateWallets: null,
|
|
64
|
+
|
|
65
|
+
addPreferredBlockchain: (blockchain) => {
|
|
66
|
+
const currentPreferredBlockchains = get().preferredBlockchains;
|
|
67
|
+
|
|
68
|
+
const noNeedToDoAnything = currentPreferredBlockchains.find(
|
|
69
|
+
(preferredBlockchain, index) => {
|
|
70
|
+
const isSameBlockchain = preferredBlockchain === blockchain;
|
|
71
|
+
const isInVisibleList = index <= BLOCKCHAIN_LIST_SIZE - 1;
|
|
72
|
+
|
|
73
|
+
return isSameBlockchain && isInVisibleList;
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
if (noNeedToDoAnything) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const nextPreferredBlockchains: string[] =
|
|
82
|
+
currentPreferredBlockchains.filter((preferredBlockchain) => {
|
|
83
|
+
const isSameBlockchain = preferredBlockchain === blockchain;
|
|
84
|
+
|
|
85
|
+
return !isSameBlockchain;
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
set(() => ({
|
|
89
|
+
preferredBlockchains: [blockchain, ...nextPreferredBlockchains],
|
|
90
|
+
}));
|
|
91
|
+
},
|
|
92
|
+
setSlippage: (slippage) =>
|
|
93
|
+
set(() => ({
|
|
94
|
+
slippage: slippage,
|
|
95
|
+
})),
|
|
96
|
+
setCustomSlippage: (customSlippage) =>
|
|
97
|
+
set(() => ({
|
|
98
|
+
customSlippage: customSlippage,
|
|
99
|
+
})),
|
|
100
|
+
setAffiliateRef: (affiliateRef) =>
|
|
101
|
+
set(() => ({
|
|
102
|
+
affiliateRef,
|
|
103
|
+
})),
|
|
104
|
+
setAffiliatePercent: (affiliatePercent) =>
|
|
105
|
+
set(() => ({
|
|
106
|
+
affiliatePercent,
|
|
107
|
+
})),
|
|
108
|
+
|
|
109
|
+
setAffiliateWallets: (affiliateWallets) =>
|
|
110
|
+
set(() => ({
|
|
111
|
+
affiliateWallets,
|
|
112
|
+
})),
|
|
113
|
+
toggleAllLiquiditySources: (swappers, shouldReset) =>
|
|
114
|
+
set((state) => {
|
|
115
|
+
if (shouldReset) {
|
|
116
|
+
return { disabledLiquiditySources: [] };
|
|
117
|
+
}
|
|
118
|
+
const swappersGroup = removeDuplicateFrom(
|
|
119
|
+
swappers.map((swapper) => swapper.swapperGroup)
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
if (swappersGroup.length === state.disabledLiquiditySources.length) {
|
|
123
|
+
return { disabledLiquiditySources: [] };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return {
|
|
127
|
+
disabledLiquiditySources: swappersGroup,
|
|
128
|
+
};
|
|
129
|
+
}),
|
|
130
|
+
toggleInfiniteApprove: () =>
|
|
131
|
+
set((state) => ({
|
|
132
|
+
infiniteApprove: !state.infiniteApprove,
|
|
133
|
+
})),
|
|
134
|
+
toggleLiquiditySource: (name) =>
|
|
135
|
+
set((state) => {
|
|
136
|
+
if (state.disabledLiquiditySources.includes(name)) {
|
|
137
|
+
return {
|
|
138
|
+
disabledLiquiditySources: state.disabledLiquiditySources.filter(
|
|
139
|
+
(liquiditySource) => liquiditySource != name
|
|
140
|
+
),
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
disabledLiquiditySources: state.disabledLiquiditySources.concat(name),
|
|
145
|
+
};
|
|
146
|
+
}),
|
|
147
|
+
setTheme: (theme) =>
|
|
148
|
+
set(() => ({
|
|
149
|
+
theme,
|
|
150
|
+
})),
|
|
151
|
+
setLanguage: (language) =>
|
|
152
|
+
set(() => ({
|
|
153
|
+
language,
|
|
154
|
+
})),
|
|
155
|
+
updateSettings: (nextConfig: WidgetConfig) => {
|
|
156
|
+
const { features } = nextConfig;
|
|
157
|
+
|
|
158
|
+
const isThemeHidden = isFeatureHidden('theme', features);
|
|
159
|
+
const isLanguageHidden = isFeatureHidden('language', features);
|
|
160
|
+
const isLiquidityHidden = isFeatureHidden('liquiditySource', features);
|
|
161
|
+
|
|
162
|
+
set({
|
|
163
|
+
...(isThemeHidden && { theme: 'auto' }),
|
|
164
|
+
...(isLanguageHidden && { language: DEFAULT_LANGUAGE }),
|
|
165
|
+
...(isLiquidityHidden && { disabledLiquiditySources: [] }),
|
|
166
|
+
});
|
|
167
|
+
},
|
|
168
|
+
});
|