@rango-dev/widget-embedded 0.17.1-next.2 → 0.17.1-next.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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/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 +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/Layout/Layout.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/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 +1588 -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/QuoteSkeleton.d.ts +4 -0
- package/dist/components/Quote/QuoteSkeleton.d.ts.map +1 -0
- package/dist/components/Quote/QuoteSkeleton.styles.d.ts +319 -0
- package/dist/components/Quote/QuoteSkeleton.styles.d.ts.map +1 -0
- package/dist/components/Quote/QuoteSkeleton.types.d.ts +6 -0
- package/dist/components/Quote/QuoteSkeleton.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 +158 -0
- package/dist/components/Quote/QuoteSummary.styles.d.ts.map +1 -0
- package/dist/components/Quote/index.d.ts +4 -0
- package/dist/components/Quote/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/SwapDetails/SwapDetails.Placeholder.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsCompleteModal.d.ts.map +1 -1
- package/dist/components/SwapsGroup/SwapsGroup.d.ts.map +1 -1
- 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.styles.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.types.d.ts +14 -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/useWalletList.d.ts.map +1 -1
- package/dist/index.d.ts +13 -5
- 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 +11 -0
- package/dist/store/AppStore.d.ts.map +1 -0
- package/dist/store/app.d.ts +5 -23
- package/dist/store/app.d.ts.map +1 -1
- package/dist/store/{bestRoute.d.ts → quote.d.ts} +39 -27
- package/dist/store/quote.d.ts.map +1 -0
- package/dist/store/settings.d.ts +3 -2
- package/dist/store/settings.d.ts.map +1 -1
- 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 +3 -0
- package/dist/store/slices/data.d.ts.map +1 -1
- package/dist/store/wallets.d.ts +5 -4
- package/dist/store/wallets.d.ts.map +1 -1
- package/dist/types/config.d.ts +19 -5
- 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 +3 -13
- package/dist/types/swap.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/{routing.d.ts → quote.d.ts} +16 -12
- package/dist/utils/quote.d.ts.map +1 -0
- package/dist/utils/settings.d.ts +3 -2
- package/dist/utils/settings.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +34 -23
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +2 -2
- package/dist/utils/wallets.d.ts.map +1 -1
- package/package.json +6 -6
- 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.tsx +4 -4
- package/src/components/BlockchainsSection/BlockchainsSection.tsx +7 -7
- package/src/components/ConfirmWalletsModal/ConfirmWallets.helpers.ts +2 -64
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +39 -45
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.types.ts +1 -3
- package/src/components/ConfirmWalletsModal/WalletList.tsx +6 -5
- package/src/components/ConfirmWalletsModal/WalletList.type.ts +1 -4
- package/src/components/Layout/Layout.tsx +10 -7
- package/src/components/Layout/Layout.types.ts +2 -2
- package/src/components/LoadingSwapDetails/LoadingSwapDetails.styles.ts +3 -3
- package/src/components/LoadingSwapDetails/LoadingSwapDetails.tsx +6 -6
- 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} +10 -12
- 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 +239 -0
- package/src/components/Quote/Quote.tsx +413 -0
- package/src/components/Quote/Quote.types.ts +15 -0
- package/src/components/Quote/QuoteSkeleton.styles.ts +110 -0
- package/src/components/Quote/QuoteSkeleton.tsx +108 -0
- package/src/components/Quote/QuoteSkeleton.types.ts +5 -0
- package/src/components/Quote/QuoteSummary.styles.ts +15 -0
- package/src/components/Quote/QuoteSummary.tsx +46 -0
- package/src/components/Quote/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/SwapDetails/SwapDetails.Placeholder.tsx +0 -4
- package/src/components/SwapDetails/SwapDetails.tsx +17 -24
- package/src/components/SwapDetailsModal/SwapDetailsCompleteModal.tsx +4 -3
- package/src/components/SwapDetailsModal/SwapDetailsModal.Cancel.tsx +2 -2
- package/src/components/SwapsGroup/SwapsGroup.styles.ts +8 -1
- package/src/components/SwapsGroup/SwapsGroup.tsx +0 -2
- package/src/components/SwitchFromAndTo.tsx +2 -2
- package/src/components/TokenList/TokenList.styles.ts +14 -2
- package/src/components/TokenList/TokenList.tsx +6 -7
- package/src/components/UpdateUrl.tsx +36 -29
- 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 +55 -0
- package/src/containers/App/index.ts +1 -0
- package/src/containers/QuoteInfo/QuoteInfo.styles.ts +31 -0
- package/src/containers/QuoteInfo/QuoteInfo.tsx +98 -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} +40 -32
- 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.tsx +47 -0
- package/src/containers/WidgetInfo/WidgetInfo.types.ts +14 -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 +2 -2
- 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 +13 -4
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.types.ts +6 -1
- package/src/hooks/useSwapInput.ts +139 -46
- package/src/hooks/useSyncStoresWithConfig.ts +22 -19
- package/src/hooks/useWalletList.ts +3 -5
- package/src/index.ts +14 -3
- package/src/pages/ConfirmSwapPage.tsx +95 -248
- package/src/pages/HistoryPage.tsx +1 -5
- package/src/pages/Home.tsx +75 -270
- package/src/pages/LanguagePage.tsx +0 -5
- package/src/pages/LiquiditySourcePage.tsx +22 -35
- package/src/pages/SelectBlockchainPage.tsx +31 -24
- package/src/pages/SelectSwapItemsPage.tsx +9 -23
- package/src/pages/SettingsPage.tsx +8 -15
- package/src/pages/SwapDetailsPage.tsx +6 -7
- package/src/pages/ThemePage.tsx +0 -4
- package/src/pages/WalletsPage.tsx +4 -15
- package/src/services/httpService.ts +1 -1
- package/src/store/AppStore.tsx +35 -0
- package/src/store/app.ts +18 -6
- package/src/store/{bestRoute.ts → quote.ts} +68 -60
- package/src/store/settings.ts +7 -4
- package/src/store/slices/config.ts +25 -15
- package/src/store/slices/data.ts +64 -29
- package/src/store/wallets.ts +12 -8
- package/src/types/config.ts +20 -5
- package/src/types/index.ts +1 -1
- package/src/types/quote.ts +107 -0
- package/src/types/swap.ts +3 -12
- package/src/utils/colors.ts +2 -1
- package/src/utils/configs.ts +2 -1
- package/src/utils/meta.ts +8 -1
- package/src/utils/numbers.ts +1 -1
- package/src/utils/quote.ts +338 -0
- package/src/utils/settings.ts +8 -7
- package/src/utils/swap.ts +153 -116
- package/src/utils/wallets.ts +29 -17
- 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/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.map +0 -1
- package/dist/store/meta.d.ts +0 -23
- package/dist/store/meta.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.map +0 -1
- package/src/Widget.tsx +0 -119
- 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/types/routing.ts +0 -77
- package/src/utils/routing.ts +0 -321
package/src/constants/errors.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { QuoteError } from '../types';
|
|
2
2
|
|
|
3
3
|
import { i18n } from '@lingui/core';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { QuoteErrorType } from '../types';
|
|
6
6
|
|
|
7
7
|
export const errorMessages = () => {
|
|
8
8
|
return {
|
|
@@ -10,18 +10,22 @@ export const errorMessages = () => {
|
|
|
10
10
|
liquiditySourcesError: {
|
|
11
11
|
title: i18n.t('Please reset your liquidity sources.'),
|
|
12
12
|
description: i18n.t(
|
|
13
|
-
'You have limited the liquidity sources and this might result in Rango finding no routes. Please consider resetting your liquidity sources'
|
|
13
|
+
'You have limited the liquidity sources and this might result in Rango finding no routes. Please consider resetting your liquidity sources.'
|
|
14
14
|
),
|
|
15
15
|
},
|
|
16
|
-
|
|
17
|
-
title: i18n.t('No Routes Found'),
|
|
16
|
+
noResultError: {
|
|
17
|
+
title: i18n.t('No Routes Found.'),
|
|
18
18
|
description: i18n.t(
|
|
19
19
|
"Reasons why Rango couldn't find a route: low liquidity on token, very low input amount or no routes available for the selected input/output token combination."
|
|
20
20
|
),
|
|
21
21
|
},
|
|
22
22
|
bridgeLimitErrors: {
|
|
23
|
-
increaseAmount: i18n.t(
|
|
24
|
-
|
|
23
|
+
increaseAmount: i18n.t(
|
|
24
|
+
'Bridge Limit Error: Please increase your amount.'
|
|
25
|
+
),
|
|
26
|
+
decreaseAmount: i18n.t(
|
|
27
|
+
'Bridge Limit Error: Please decrease your amount.'
|
|
28
|
+
),
|
|
25
29
|
},
|
|
26
30
|
highValueLossError: {
|
|
27
31
|
impactTitle: i18n.t('High Price Impact'),
|
|
@@ -29,9 +33,9 @@ export const errorMessages = () => {
|
|
|
29
33
|
description: i18n.t(
|
|
30
34
|
'The price impact is significantly higher than the allowed amount. If you are sure, continue, otherwise, change the swap.'
|
|
31
35
|
),
|
|
32
|
-
confirmMessage: i18n.t('Confirm
|
|
36
|
+
confirmMessage: i18n.t('Confirm high price impact'),
|
|
33
37
|
},
|
|
34
|
-
|
|
38
|
+
quoteUpdatedWithHighValueLoss: {
|
|
35
39
|
title: i18n.t(
|
|
36
40
|
'Route updated and price impact is too high, try again later!'
|
|
37
41
|
),
|
|
@@ -47,14 +51,12 @@ export const errorMessages = () => {
|
|
|
47
51
|
};
|
|
48
52
|
};
|
|
49
53
|
|
|
50
|
-
export function
|
|
54
|
+
export function getQuoteErrorMessage(error: QuoteError) {
|
|
51
55
|
switch (error.type) {
|
|
52
|
-
case
|
|
53
|
-
return error.diagnosisMessage ?? errorMessages().
|
|
54
|
-
case
|
|
56
|
+
case QuoteErrorType.NO_RESULT:
|
|
57
|
+
return error.diagnosisMessage ?? errorMessages().noResultError.title;
|
|
58
|
+
case QuoteErrorType.REQUEST_FAILED:
|
|
55
59
|
return errorMessages().genericServerError;
|
|
56
|
-
case ConfirmSwapErrorTypes.ROUTE_UPDATED_WITH_HIGH_VALUE_LOSS:
|
|
57
|
-
return errorMessages().routeUpdatedWithHighValueLoss.title;
|
|
58
60
|
default:
|
|
59
61
|
return '';
|
|
60
62
|
}
|
package/src/constants/index.ts
CHANGED
|
@@ -5,6 +5,6 @@ export const swapButtonTitles = () => {
|
|
|
5
5
|
connectWallet: i18n.t('Connect Wallet'),
|
|
6
6
|
swap: i18n.t('Swap'),
|
|
7
7
|
swapAnyway: i18n.t('Swap anyway'),
|
|
8
|
-
|
|
8
|
+
ethWarning: i18n.t('The route goes through Ethereum. Continue?'),
|
|
9
9
|
};
|
|
10
10
|
};
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
export const navigationRoutes = {
|
|
2
2
|
home: '/',
|
|
3
3
|
fromSwap: 'from-swap',
|
|
4
|
-
fromBlockchain: '/from-swap/blockchains',
|
|
5
|
-
toBlockchain: '/to-swap/blockchains',
|
|
6
4
|
toSwap: 'to-swap',
|
|
5
|
+
blockchains: 'blockchains',
|
|
7
6
|
settings: 'settings',
|
|
8
|
-
liquiditySources: '
|
|
9
|
-
themes: '
|
|
10
|
-
bridges: '
|
|
11
|
-
exchanges: '
|
|
12
|
-
languages: '
|
|
7
|
+
liquiditySources: 'liquidity-sources',
|
|
8
|
+
themes: 'themes',
|
|
9
|
+
bridges: 'bridges',
|
|
10
|
+
exchanges: 'exchanges',
|
|
11
|
+
languages: 'languages',
|
|
13
12
|
swaps: 'swaps',
|
|
14
13
|
wallets: 'wallets',
|
|
15
14
|
confirmSwap: 'confirm-swap',
|
|
16
|
-
swapDetails: '
|
|
15
|
+
swapDetails: ':requestId',
|
|
17
16
|
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { QuoteUpdateWarning } from '../types';
|
|
2
2
|
|
|
3
3
|
import { i18n } from '@lingui/core';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { QuoteUpdateType } from '../types';
|
|
6
6
|
|
|
7
|
-
export function
|
|
7
|
+
export function getQuoteUpdateWarningMessage(warning: QuoteUpdateWarning) {
|
|
8
8
|
switch (warning.type) {
|
|
9
|
-
case
|
|
9
|
+
case QuoteUpdateType.QUOTE_UPDATED:
|
|
10
10
|
return i18n.t('Route has been updated.');
|
|
11
|
-
case
|
|
11
|
+
case QuoteUpdateType.QUOTE_AND_OUTPUT_AMOUNT_UPDATED:
|
|
12
12
|
return i18n.t(
|
|
13
13
|
'Output amount changed to {newOutputAmount} ({percentageChange}% change).',
|
|
14
14
|
{
|
|
@@ -16,9 +16,9 @@ export function getRouteWarningMessage(warning: RouteWarning) {
|
|
|
16
16
|
percentageChange: warning.percentageChange,
|
|
17
17
|
}
|
|
18
18
|
);
|
|
19
|
-
case
|
|
19
|
+
case QuoteUpdateType.QUOTE_SWAPPERS_UPDATED:
|
|
20
20
|
return i18n.t('Route swappers has been updated.');
|
|
21
|
-
case
|
|
21
|
+
case QuoteUpdateType.QUOTE_COINS_UPDATED:
|
|
22
22
|
return i18n.t('Route internal coins has been updated.');
|
|
23
23
|
default:
|
|
24
24
|
return '';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { styled } from '@rango-dev/ui';
|
|
2
|
+
|
|
3
|
+
export const MainContainer = styled('div', {
|
|
4
|
+
width: '100%',
|
|
5
|
+
display: 'flex',
|
|
6
|
+
justifyContent: 'center',
|
|
7
|
+
alignItems: 'center',
|
|
8
|
+
fontFamily: '$widget',
|
|
9
|
+
boxSizing: 'border-box',
|
|
10
|
+
'& *, *::before, *::after': {
|
|
11
|
+
boxSizing: 'inherit',
|
|
12
|
+
listStyleType: 'none',
|
|
13
|
+
},
|
|
14
|
+
'& *:focus-visible': {
|
|
15
|
+
outlineColor: '$info500',
|
|
16
|
+
transition: 'none',
|
|
17
|
+
},
|
|
18
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { WalletType } from '@rango-dev/wallets-shared';
|
|
2
|
+
|
|
3
|
+
import { I18nManager } from '@rango-dev/ui';
|
|
4
|
+
import React, { useContext, useEffect, useState } from 'react';
|
|
5
|
+
|
|
6
|
+
import { AppRouter } from '../../components/AppRouter';
|
|
7
|
+
import { AppRoutes } from '../../components/AppRoutes';
|
|
8
|
+
import { WidgetEvents } from '../../components/WidgetEvents';
|
|
9
|
+
import { globalFont } from '../../globalStyles';
|
|
10
|
+
import { useLanguage } from '../../hooks/useLanguage';
|
|
11
|
+
import { useTheme } from '../../hooks/useTheme';
|
|
12
|
+
import { useAppStore } from '../../store/AppStore';
|
|
13
|
+
import { useNotificationStore } from '../../store/notification';
|
|
14
|
+
import { useSettingsStore } from '../../store/settings';
|
|
15
|
+
import { WidgetContext } from '../Wallets';
|
|
16
|
+
|
|
17
|
+
import { MainContainer } from './App.styles';
|
|
18
|
+
|
|
19
|
+
export function Main() {
|
|
20
|
+
globalFont();
|
|
21
|
+
|
|
22
|
+
const { fetch: fetchMeta, config } = useAppStore();
|
|
23
|
+
const { activeTheme } = useTheme(config?.theme || {});
|
|
24
|
+
const { activeLanguage, changeLanguage } = useLanguage();
|
|
25
|
+
const [lastConnectedWalletWithNetwork, setLastConnectedWalletWithNetwork] =
|
|
26
|
+
useState<string>('');
|
|
27
|
+
const [disconnectedWallet, setDisconnectedWallet] = useState<WalletType>();
|
|
28
|
+
const widgetContext = useContext(WidgetContext);
|
|
29
|
+
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
void fetchMeta().catch();
|
|
32
|
+
void useSettingsStore.persist.rehydrate();
|
|
33
|
+
void useNotificationStore.persist.rehydrate();
|
|
34
|
+
widgetContext.onConnectWallet(setLastConnectedWalletWithNetwork);
|
|
35
|
+
}, []);
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
changeLanguage(config?.language);
|
|
38
|
+
}, [config?.language]);
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<I18nManager language={activeLanguage}>
|
|
42
|
+
<MainContainer id="swap-container" className={activeTheme()}>
|
|
43
|
+
<WidgetEvents />
|
|
44
|
+
<AppRouter
|
|
45
|
+
lastConnectedWallet={lastConnectedWalletWithNetwork}
|
|
46
|
+
disconnectedWallet={disconnectedWallet}
|
|
47
|
+
clearDisconnectedWallet={() => {
|
|
48
|
+
setDisconnectedWallet(undefined);
|
|
49
|
+
}}>
|
|
50
|
+
<AppRoutes />
|
|
51
|
+
</AppRouter>
|
|
52
|
+
</MainContainer>
|
|
53
|
+
</I18nManager>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Main } from './App';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { styled } from '@rango-dev/ui';
|
|
2
|
+
|
|
3
|
+
export const PositionTopAlerts = styled('div', {
|
|
4
|
+
paddingBottom: '$10',
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
export const QuoteContainer = styled('div', {
|
|
8
|
+
width: '100%',
|
|
9
|
+
'& .position-top__skeleton': {
|
|
10
|
+
paddingTop: '$10',
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export const SkeletonContainer = styled('div', {
|
|
15
|
+
variants: {
|
|
16
|
+
paddingTop: {
|
|
17
|
+
true: {
|
|
18
|
+
paddingTop: '$10',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export const FooterStepAlarm = styled('div', {
|
|
25
|
+
paddingBottom: '$15',
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export const FooterAlert = styled('div', {
|
|
29
|
+
width: '100%',
|
|
30
|
+
display: 'flex',
|
|
31
|
+
});
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { PropTypes } from './QuoteInfo.types';
|
|
2
|
+
|
|
3
|
+
import { Divider } from '@rango-dev/ui';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
|
|
6
|
+
import { Quote, QuoteSkeleton } from '../../components/Quote';
|
|
7
|
+
import { QuoteWarningsAndErrors } from '../../components/QuoteWarningsAndErrors';
|
|
8
|
+
import { useQuoteStore } from '../../store/quote';
|
|
9
|
+
import { QuoteErrorType } from '../../types';
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
PositionTopAlerts,
|
|
13
|
+
QuoteContainer,
|
|
14
|
+
SkeletonContainer,
|
|
15
|
+
} from './QuoteInfo.styles';
|
|
16
|
+
|
|
17
|
+
export function QuoteInfo(props: PropTypes) {
|
|
18
|
+
const {
|
|
19
|
+
quote,
|
|
20
|
+
type,
|
|
21
|
+
loading,
|
|
22
|
+
error,
|
|
23
|
+
warning,
|
|
24
|
+
refetchQuote,
|
|
25
|
+
showWarningModal,
|
|
26
|
+
onOpenWarningModal,
|
|
27
|
+
onCloseWarningModal,
|
|
28
|
+
onConfirmWarningModal,
|
|
29
|
+
onChangeSettings,
|
|
30
|
+
expanded = false,
|
|
31
|
+
alertPosition = 'bottom',
|
|
32
|
+
} = props;
|
|
33
|
+
const { inputAmount, inputUsdValue, outputUsdValue, outputAmount } =
|
|
34
|
+
useQuoteStore();
|
|
35
|
+
|
|
36
|
+
const noResult =
|
|
37
|
+
error &&
|
|
38
|
+
(error.type === QuoteErrorType.NO_RESULT ||
|
|
39
|
+
error.type === QuoteErrorType.REQUEST_FAILED);
|
|
40
|
+
|
|
41
|
+
const showQuote = !noResult && quote && quote.result && !loading;
|
|
42
|
+
|
|
43
|
+
const quoteWarningsAndErrors = (warning || error) && (
|
|
44
|
+
<QuoteWarningsAndErrors
|
|
45
|
+
warning={warning}
|
|
46
|
+
error={error}
|
|
47
|
+
loading={loading}
|
|
48
|
+
refetchQuote={refetchQuote}
|
|
49
|
+
showWarningModal={showWarningModal}
|
|
50
|
+
onOpenWarningModal={onOpenWarningModal}
|
|
51
|
+
onCloseWarningModal={onCloseWarningModal}
|
|
52
|
+
onConfirmWarningModal={onConfirmWarningModal}
|
|
53
|
+
onChangeSettings={onChangeSettings}
|
|
54
|
+
/>
|
|
55
|
+
);
|
|
56
|
+
return (
|
|
57
|
+
<>
|
|
58
|
+
{loading && (
|
|
59
|
+
<QuoteContainer>
|
|
60
|
+
<SkeletonContainer paddingTop={alertPosition === 'top'}>
|
|
61
|
+
<QuoteSkeleton type={type} expanded={expanded} />
|
|
62
|
+
</SkeletonContainer>
|
|
63
|
+
</QuoteContainer>
|
|
64
|
+
)}
|
|
65
|
+
|
|
66
|
+
{alertPosition === 'top' && (
|
|
67
|
+
<PositionTopAlerts>{quoteWarningsAndErrors}</PositionTopAlerts>
|
|
68
|
+
)}
|
|
69
|
+
{showQuote ? (
|
|
70
|
+
<QuoteContainer>
|
|
71
|
+
<Quote
|
|
72
|
+
quote={quote}
|
|
73
|
+
error={error}
|
|
74
|
+
warning={warning}
|
|
75
|
+
type={type}
|
|
76
|
+
expanded={expanded}
|
|
77
|
+
recommended={true}
|
|
78
|
+
input={{
|
|
79
|
+
value: inputAmount,
|
|
80
|
+
usdValue: inputUsdValue?.toString() ?? '',
|
|
81
|
+
}}
|
|
82
|
+
output={{
|
|
83
|
+
value: outputAmount?.toString() ?? '',
|
|
84
|
+
usdValue: outputUsdValue?.toString() ?? '',
|
|
85
|
+
}}
|
|
86
|
+
/>
|
|
87
|
+
</QuoteContainer>
|
|
88
|
+
) : null}
|
|
89
|
+
|
|
90
|
+
{alertPosition === 'bottom' && (
|
|
91
|
+
<>
|
|
92
|
+
{!warning && !error && <Divider size={16} />}
|
|
93
|
+
{quoteWarningsAndErrors}
|
|
94
|
+
</>
|
|
95
|
+
)}
|
|
96
|
+
</>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { QuoteProps } from '../../components/Quote/Quote.types';
|
|
2
|
+
import type { QuoteError, QuoteWarning } from '../../types';
|
|
3
|
+
import type { BestRouteResponse } from 'rango-sdk';
|
|
4
|
+
|
|
5
|
+
export type PropTypes = {
|
|
6
|
+
quote: BestRouteResponse | null;
|
|
7
|
+
type: QuoteProps['type'];
|
|
8
|
+
loading: boolean;
|
|
9
|
+
error: QuoteError | null;
|
|
10
|
+
warning: QuoteWarning | null;
|
|
11
|
+
autoScrollOnExpanding?: boolean;
|
|
12
|
+
expanded?: boolean;
|
|
13
|
+
alertPosition?: 'top' | 'bottom';
|
|
14
|
+
refetchQuote: () => void;
|
|
15
|
+
showWarningModal: boolean;
|
|
16
|
+
onOpenWarningModal: () => void;
|
|
17
|
+
onCloseWarningModal: () => void;
|
|
18
|
+
onConfirmWarningModal: () => void;
|
|
19
|
+
onChangeSettings: () => void;
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { QuoteInfo } from './QuoteInfo';
|
|
@@ -1,25 +1,24 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type {
|
|
2
|
+
OnConnectHandler,
|
|
3
|
+
PropTypes,
|
|
4
|
+
WidgetContextInterface,
|
|
5
|
+
} from './Wallets.types';
|
|
6
|
+
import type { ProvidersOptions } from '../../utils/providers';
|
|
3
7
|
import type { EventHandler } from '@rango-dev/wallets-react';
|
|
4
8
|
import type { Network } from '@rango-dev/wallets-shared';
|
|
5
9
|
import type { PropsWithChildren } from 'react';
|
|
6
10
|
|
|
7
11
|
import { Events, Provider } from '@rango-dev/wallets-react';
|
|
8
12
|
import { isEvmBlockchain } from 'rango-sdk';
|
|
9
|
-
import React, { createContext, useRef } from 'react';
|
|
13
|
+
import React, { createContext, useEffect, useRef } from 'react';
|
|
10
14
|
|
|
11
|
-
import { useWalletProviders } from '
|
|
12
|
-
import {
|
|
13
|
-
import { useWalletsStore } from '
|
|
15
|
+
import { useWalletProviders } from '../../hooks/useWalletProviders';
|
|
16
|
+
import { AppStoreProvider, useAppStore } from '../../store/AppStore';
|
|
17
|
+
import { useWalletsStore } from '../../store/wallets';
|
|
14
18
|
import {
|
|
15
19
|
prepareAccountsForWalletStore,
|
|
16
20
|
walletAndSupportedChainsNames,
|
|
17
|
-
} from '
|
|
18
|
-
|
|
19
|
-
type OnConnectHandler = (key: string) => void;
|
|
20
|
-
interface WidgetContextInterface {
|
|
21
|
-
onConnectWallet(handler: OnConnectHandler): void;
|
|
22
|
-
}
|
|
21
|
+
} from '../../utils/wallets';
|
|
23
22
|
|
|
24
23
|
export const WidgetContext = createContext<WidgetContextInterface>({
|
|
25
24
|
onConnectWallet: () => {
|
|
@@ -27,41 +26,41 @@ export const WidgetContext = createContext<WidgetContextInterface>({
|
|
|
27
26
|
},
|
|
28
27
|
});
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const {
|
|
38
|
-
const { providers } = useWalletProviders(props.providers, props?.options);
|
|
29
|
+
function Main(props: PropsWithChildren<PropTypes>) {
|
|
30
|
+
const updateConfig = useAppStore().updateConfig;
|
|
31
|
+
const blockchains = useAppStore().blockchains();
|
|
32
|
+
const tokens = useAppStore().tokens();
|
|
33
|
+
const walletOptions: ProvidersOptions = {
|
|
34
|
+
walletConnectProjectId: props.config?.walletConnectProjectId,
|
|
35
|
+
};
|
|
36
|
+
const { providers } = useWalletProviders(props.config.wallets, walletOptions);
|
|
39
37
|
const disconnectWallet = useWalletsStore.use.disconnectWallet();
|
|
40
38
|
const connectWallet = useWalletsStore.use.connectWallet();
|
|
41
39
|
const onConnectWalletHandler = useRef<OnConnectHandler>();
|
|
42
40
|
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (props.config) {
|
|
43
|
+
updateConfig(props.config);
|
|
44
|
+
}
|
|
45
|
+
}, [props.config]);
|
|
46
|
+
|
|
43
47
|
const evmBasedChainNames = blockchains
|
|
44
48
|
.filter(isEvmBlockchain)
|
|
45
49
|
.map((chain) => chain.name);
|
|
46
50
|
|
|
47
|
-
const onUpdateState: EventHandler = (
|
|
48
|
-
type,
|
|
49
|
-
event,
|
|
50
|
-
value,
|
|
51
|
-
state,
|
|
52
|
-
supportedBlockchains
|
|
53
|
-
) => {
|
|
51
|
+
const onUpdateState: EventHandler = (type, event, value, state, meta) => {
|
|
54
52
|
if (event === Events.ACCOUNTS) {
|
|
55
53
|
if (value) {
|
|
56
54
|
const supportedChainNames: Network[] | null =
|
|
57
|
-
walletAndSupportedChainsNames(supportedBlockchains);
|
|
55
|
+
walletAndSupportedChainsNames(meta.supportedBlockchains);
|
|
58
56
|
const data = prepareAccountsForWalletStore(
|
|
59
57
|
type,
|
|
60
58
|
value,
|
|
61
59
|
evmBasedChainNames,
|
|
62
|
-
supportedChainNames
|
|
60
|
+
supportedChainNames,
|
|
61
|
+
meta.isContractWallet
|
|
63
62
|
);
|
|
64
|
-
connectWallet(data);
|
|
63
|
+
connectWallet(data, tokens);
|
|
65
64
|
} else {
|
|
66
65
|
disconnectWallet(type);
|
|
67
66
|
}
|
|
@@ -91,7 +90,7 @@ export function WidgetWallets(
|
|
|
91
90
|
|
|
92
91
|
// propagate updates for Dapps using external wallets
|
|
93
92
|
if (props.onUpdateState) {
|
|
94
|
-
props.onUpdateState(type, event, value, state,
|
|
93
|
+
props.onUpdateState(type, event, value, state, meta);
|
|
95
94
|
}
|
|
96
95
|
};
|
|
97
96
|
return (
|
|
@@ -112,3 +111,12 @@ export function WidgetWallets(
|
|
|
112
111
|
</WidgetContext.Provider>
|
|
113
112
|
);
|
|
114
113
|
}
|
|
114
|
+
|
|
115
|
+
export function WidgetWallets(props: PropsWithChildren<PropTypes>) {
|
|
116
|
+
const { config, ...otherProps } = props;
|
|
117
|
+
return (
|
|
118
|
+
<AppStoreProvider config={config}>
|
|
119
|
+
<Main {...otherProps} config={config} />
|
|
120
|
+
</AppStoreProvider>
|
|
121
|
+
);
|
|
122
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { WidgetConfig } from '../../types';
|
|
2
|
+
import type { EventHandler } from '@rango-dev/wallets-react';
|
|
3
|
+
|
|
4
|
+
export type OnConnectHandler = (key: string) => void;
|
|
5
|
+
export interface WidgetContextInterface {
|
|
6
|
+
onConnectWallet(handler: OnConnectHandler): void;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface PropTypes {
|
|
10
|
+
onUpdateState?: EventHandler;
|
|
11
|
+
config: WidgetConfig;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { WidgetWallets, WidgetContext } from './Wallets';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { WidgetProps } from './Widget.types';
|
|
2
|
+
import type { PropsWithChildren } from 'react';
|
|
3
|
+
|
|
4
|
+
import React from 'react';
|
|
5
|
+
|
|
6
|
+
import { DEFAULT_CONFIG } from '../../store/slices/config';
|
|
7
|
+
import { Main } from '../App';
|
|
8
|
+
import { WidgetProvider } from '../WidgetProvider';
|
|
9
|
+
|
|
10
|
+
export function Widget(props: PropsWithChildren<WidgetProps>) {
|
|
11
|
+
if (!props.config?.externalWallets) {
|
|
12
|
+
return (
|
|
13
|
+
<WidgetProvider config={props.config ?? DEFAULT_CONFIG}>
|
|
14
|
+
<Main />
|
|
15
|
+
</WidgetProvider>
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
return <Main />;
|
|
19
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { WidgetInfoContextInterface } from './WidgetInfo.types';
|
|
2
|
+
|
|
3
|
+
import { useManager } from '@rango-dev/queue-manager-react';
|
|
4
|
+
import React, { createContext, useContext } from 'react';
|
|
5
|
+
|
|
6
|
+
import { useWalletsStore } from '../../store/wallets';
|
|
7
|
+
import { getPendingSwaps } from '../../utils/queue';
|
|
8
|
+
import { calculateWalletUsdValue } from '../../utils/wallets';
|
|
9
|
+
|
|
10
|
+
export const WidgetInfoContext = createContext<
|
|
11
|
+
WidgetInfoContextInterface | undefined
|
|
12
|
+
>(undefined);
|
|
13
|
+
|
|
14
|
+
export function WidgetInfo(props: React.PropsWithChildren) {
|
|
15
|
+
const { manager } = useManager();
|
|
16
|
+
const swaps = getPendingSwaps(manager);
|
|
17
|
+
const details = useWalletsStore.use.connectedWallets();
|
|
18
|
+
const isLoading = useWalletsStore.use.loading();
|
|
19
|
+
const totalBalance = calculateWalletUsdValue(details);
|
|
20
|
+
const refetch = useWalletsStore.use.getWalletsDetails();
|
|
21
|
+
// eslint-disable-next-line react/jsx-no-constructed-context-values
|
|
22
|
+
const value = {
|
|
23
|
+
swaps,
|
|
24
|
+
wallets: {
|
|
25
|
+
isLoading,
|
|
26
|
+
details,
|
|
27
|
+
totalBalance,
|
|
28
|
+
refetch,
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<WidgetInfoContext.Provider value={value}>
|
|
34
|
+
{props.children}
|
|
35
|
+
</WidgetInfoContext.Provider>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function useWidget(): WidgetInfoContextInterface {
|
|
40
|
+
const context = useContext(WidgetInfoContext);
|
|
41
|
+
if (!context) {
|
|
42
|
+
throw new Error(
|
|
43
|
+
'useWidget can only be used within the WidgetProvider component'
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
return context;
|
|
47
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ConnectedWallet } from '../../store/wallets';
|
|
2
|
+
import type { Wallet } from '../../types';
|
|
3
|
+
import type { PendingSwapWithQueueID } from '@rango-dev/queue-manager-rango-preset';
|
|
4
|
+
import type { Token } from 'rango-sdk';
|
|
5
|
+
|
|
6
|
+
export interface WidgetInfoContextInterface {
|
|
7
|
+
swaps: PendingSwapWithQueueID[];
|
|
8
|
+
wallets: {
|
|
9
|
+
details: ConnectedWallet[];
|
|
10
|
+
totalBalance: string;
|
|
11
|
+
isLoading: boolean;
|
|
12
|
+
refetch: (accounts: Wallet[], tokens: Token[]) => void;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { WidgetInfo, useWidget } from './WidgetInfo';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { PropTypes } from './WidgetProvider.types';
|
|
2
|
+
import type { PropsWithChildren } from 'react';
|
|
3
|
+
|
|
4
|
+
import React, { useMemo } from 'react';
|
|
5
|
+
|
|
6
|
+
import { DEFAULT_BASE_URL, RANGO_PUBLIC_API_KEY } from '../../constants';
|
|
7
|
+
import QueueManager from '../../QueueManager';
|
|
8
|
+
import { initConfig } from '../../utils/configs';
|
|
9
|
+
import { WidgetWallets } from '../Wallets';
|
|
10
|
+
import { WidgetInfo } from '../WidgetInfo';
|
|
11
|
+
|
|
12
|
+
export function WidgetProvider(props: PropsWithChildren<PropTypes>) {
|
|
13
|
+
const { onUpdateState, config } = props;
|
|
14
|
+
|
|
15
|
+
useMemo(() => {
|
|
16
|
+
initConfig({
|
|
17
|
+
API_KEY: config?.apiKey || RANGO_PUBLIC_API_KEY,
|
|
18
|
+
BASE_URL: config?.apiUrl || DEFAULT_BASE_URL,
|
|
19
|
+
});
|
|
20
|
+
}, [config]);
|
|
21
|
+
return (
|
|
22
|
+
<WidgetWallets config={config} onUpdateState={onUpdateState}>
|
|
23
|
+
<QueueManager apiKey={config.apiKey}>
|
|
24
|
+
<WidgetInfo>{props.children}</WidgetInfo>
|
|
25
|
+
</QueueManager>
|
|
26
|
+
</WidgetWallets>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { WidgetProvider } from './WidgetProvider';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useConfirmSwap } from './useConfirmSwap';
|