@rango-dev/widget-embedded 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -113
- package/dist/QueueManager.d.ts +2 -5
- package/dist/QueueManager.d.ts.map +1 -1
- package/dist/Wallets.d.ts +17 -0
- package/dist/Wallets.d.ts.map +1 -0
- package/dist/Widget.d.ts +9 -0
- package/dist/Widget.d.ts.map +1 -0
- package/dist/components/AppRouter.d.ts +2 -0
- package/dist/components/AppRouter.d.ts.map +1 -1
- package/dist/components/AppRoutes.d.ts +6 -1
- package/dist/components/AppRoutes.d.ts.map +1 -1
- package/dist/components/BlockchainsSection/BlockchainsSection.d.ts.map +1 -1
- package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts +1 -1
- package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts +3 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +62 -691
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.types.d.ts +3 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.types.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/WalletList.type.d.ts +4 -1
- package/dist/components/ConfirmWalletsModal/WalletList.type.d.ts.map +1 -1
- package/dist/components/HeaderButtons/HomeButtons.d.ts.map +1 -1
- package/dist/components/Layout/Layout.d.ts.map +1 -1
- package/dist/components/Layout/Layout.styles.d.ts.map +1 -1
- package/dist/components/Layout/Layout.types.d.ts +2 -2
- package/dist/components/Layout/Layout.types.d.ts.map +1 -1
- package/dist/components/LoadingSwapDetails/LoadingSwapDetailStep.d.ts +4 -0
- package/dist/components/LoadingSwapDetails/LoadingSwapDetailStep.d.ts.map +1 -0
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.d.ts.map +1 -1
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts +0 -1727
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts.map +1 -1
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.types.d.ts +4 -0
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.types.d.ts.map +1 -0
- package/dist/components/NoRoutes/NoRoutes.d.ts +4 -0
- package/dist/components/NoRoutes/NoRoutes.d.ts.map +1 -0
- package/dist/components/NoRoutes/NoRoutes.helper.d.ts +3 -0
- package/dist/components/NoRoutes/NoRoutes.helper.d.ts.map +1 -0
- package/dist/components/{NoResult/NoResult.styles.d.ts → NoRoutes/NoRoutes.styles.d.ts} +1 -1
- package/dist/components/{NoResult/NoResult.styles.d.ts.map → NoRoutes/NoRoutes.styles.d.ts.map} +1 -1
- package/dist/components/{NoResult/NoResult.types.d.ts → NoRoutes/NoRoutes.types.d.ts} +3 -3
- package/dist/components/NoRoutes/NoRoutes.types.d.ts.map +1 -0
- package/dist/components/NoRoutes/index.d.ts +2 -0
- package/dist/components/NoRoutes/index.d.ts.map +1 -0
- package/dist/components/NotificationContent/NotificationContent.d.ts.map +1 -1
- package/dist/components/RouteErrors/RouteErrors.d.ts +4 -0
- package/dist/components/RouteErrors/RouteErrors.d.ts.map +1 -0
- package/dist/components/{QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts → RouteErrors/RouteErrors.styles.d.ts} +1 -1
- package/dist/components/RouteErrors/RouteErrors.styles.d.ts.map +1 -0
- package/dist/components/RouteErrors/RouteErrors.types.d.ts +24 -0
- package/dist/components/RouteErrors/RouteErrors.types.d.ts.map +1 -0
- package/dist/components/RouteErrors/RouteErrorsModal.d.ts +4 -0
- package/dist/components/RouteErrors/RouteErrorsModal.d.ts.map +1 -0
- package/dist/components/RouteErrors/RouteErrorsModalItem.d.ts +4 -0
- package/dist/components/RouteErrors/RouteErrorsModalItem.d.ts.map +1 -0
- package/dist/components/RouteErrors/index.d.ts +2 -0
- package/dist/components/RouteErrors/index.d.ts.map +1 -0
- package/dist/components/Slippage/Slippage.d.ts.map +1 -1
- package/dist/components/Slippage/Slippage.styles.d.ts +0 -158
- package/dist/components/Slippage/Slippage.styles.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.Placeholder.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.helpers.d.ts +1 -1
- package/dist/components/SwapDetails/SwapDetails.helpers.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.styles.d.ts +0 -628
- package/dist/components/SwapDetails/SwapDetails.styles.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsCompleteModal.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.WalletState.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.helpers.d.ts +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.helpers.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts.map +1 -1
- package/dist/components/SwapsGroup/SwapsGroup.d.ts.map +1 -1
- package/dist/components/SwapsGroup/SwapsGroup.styles.d.ts +0 -157
- package/dist/components/SwapsGroup/SwapsGroup.styles.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.helpers.d.ts +2 -2
- package/dist/components/TokenList/TokenList.helpers.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.styles.d.ts +1 -1100
- package/dist/components/TokenList/TokenList.styles.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.types.d.ts +9 -4
- package/dist/components/TokenList/TokenList.types.d.ts.map +1 -1
- package/dist/components/TokenList/index.d.ts +1 -0
- package/dist/components/TokenList/index.d.ts.map +1 -1
- package/dist/components/UpdateUrl.d.ts +6 -1
- package/dist/components/UpdateUrl.d.ts.map +1 -1
- package/dist/components/WidgetEvents.d.ts.map +1 -1
- package/dist/constants/errors.d.ts +4 -4
- package/dist/constants/errors.d.ts.map +1 -1
- package/dist/constants/index.d.ts +0 -1
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/constants/messages.d.ts +1 -1
- package/dist/constants/navigationRoutes.d.ts +2 -1
- package/dist/constants/navigationRoutes.d.ts.map +1 -1
- package/dist/constants/searchParams.d.ts +1 -2
- package/dist/constants/searchParams.d.ts.map +1 -1
- package/dist/constants/warnings.d.ts +2 -2
- package/dist/constants/warnings.d.ts.map +1 -1
- package/dist/hooks/{useConfirmSwap/useConfirmSwap.types.d.ts → useConfirmSwap.d.ts} +7 -5
- package/dist/hooks/useConfirmSwap.d.ts.map +1 -0
- package/dist/hooks/{useFetchQuote.d.ts → useFetchBestRoute.d.ts} +3 -3
- package/dist/hooks/useFetchBestRoute.d.ts.map +1 -0
- package/dist/hooks/useLanguage.d.ts +1 -1
- package/dist/hooks/useLanguage.d.ts.map +1 -1
- package/dist/hooks/useNavigateBack.d.ts +3 -1
- package/dist/hooks/useNavigateBack.d.ts.map +1 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.constants.d.ts +1 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.d.ts +2 -2
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.d.ts.map +1 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.d.ts +7 -5
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.d.ts.map +1 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.d.ts +0 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.d.ts.map +1 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.types.d.ts +1 -5
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.types.d.ts.map +1 -1
- package/dist/hooks/useSwapInput.d.ts +2 -4
- package/dist/hooks/useSwapInput.d.ts.map +1 -1
- package/dist/hooks/useSyncStoresWithConfig.d.ts +2 -1
- package/dist/hooks/useSyncStoresWithConfig.d.ts.map +1 -1
- package/dist/hooks/useTheme.d.ts +1 -1
- package/dist/hooks/useTheme.d.ts.map +1 -1
- package/dist/hooks/useWalletList.d.ts.map +1 -1
- package/dist/index.d.ts +8 -20
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/dist/pages/ConfirmSwapPage.d.ts +6 -1
- package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
- package/dist/pages/HistoryPage.d.ts.map +1 -1
- package/dist/pages/Home.d.ts.map +1 -1
- package/dist/pages/LanguagePage.d.ts.map +1 -1
- package/dist/pages/LiquiditySourcePage.d.ts +2 -1
- package/dist/pages/LiquiditySourcePage.d.ts.map +1 -1
- package/dist/pages/SelectBlockchainPage.d.ts.map +1 -1
- package/dist/pages/SelectSwapItemsPage.d.ts.map +1 -1
- package/dist/pages/SettingsPage.d.ts +6 -1
- package/dist/pages/SettingsPage.d.ts.map +1 -1
- package/dist/pages/SwapDetailsPage.d.ts.map +1 -1
- package/dist/pages/ThemePage.d.ts.map +1 -1
- package/dist/pages/WalletsPage.d.ts +8 -1
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/store/app.d.ts +22 -41
- package/dist/store/app.d.ts.map +1 -1
- package/dist/store/bestRoute.d.ts +77 -0
- package/dist/store/bestRoute.d.ts.map +1 -0
- package/dist/store/meta.d.ts +23 -0
- package/dist/store/meta.d.ts.map +1 -0
- package/dist/store/notification.d.ts +3 -4
- package/dist/store/notification.d.ts.map +1 -1
- package/dist/store/settings.d.ts +81 -0
- package/dist/store/settings.d.ts.map +1 -0
- package/dist/store/slices/config.d.ts +2 -3
- package/dist/store/slices/config.d.ts.map +1 -1
- package/dist/store/slices/data.d.ts +2 -5
- package/dist/store/slices/data.d.ts.map +1 -1
- package/dist/store/ui.d.ts +1 -2
- package/dist/store/ui.d.ts.map +1 -1
- package/dist/store/wallets.d.ts +9 -14
- package/dist/store/wallets.d.ts.map +1 -1
- package/dist/types/config.d.ts +8 -41
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/routing.d.ts +65 -0
- package/dist/types/routing.d.ts.map +1 -0
- package/dist/types/swap.d.ts +14 -4
- package/dist/types/swap.d.ts.map +1 -1
- package/dist/types/wallets.d.ts +1 -15
- package/dist/types/wallets.d.ts.map +1 -1
- package/dist/utils/colors.d.ts.map +1 -1
- package/dist/utils/configs.d.ts +0 -1
- package/dist/utils/configs.d.ts.map +1 -1
- package/dist/utils/meta.d.ts +1 -2
- package/dist/utils/meta.d.ts.map +1 -1
- package/dist/utils/numbers.d.ts +1 -1
- package/dist/utils/numbers.d.ts.map +1 -1
- package/dist/utils/providers.d.ts +2 -2
- package/dist/utils/providers.d.ts.map +1 -1
- package/dist/utils/queue.d.ts +2 -2
- package/dist/utils/queue.d.ts.map +1 -1
- package/dist/utils/routing.d.ts +28 -0
- package/dist/utils/routing.d.ts.map +1 -0
- package/dist/utils/settings.d.ts +2 -6
- package/dist/utils/settings.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +24 -35
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/utils/time.d.ts +1 -1
- package/dist/utils/time.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +10 -9
- package/dist/utils/wallets.d.ts.map +1 -1
- package/package.json +10 -12
- package/src/QueueManager.tsx +17 -18
- package/src/{containers/Wallets/Wallets.tsx → Wallets.tsx} +34 -48
- package/src/Widget.tsx +119 -0
- package/src/components/AppRouter.tsx +32 -8
- package/src/components/AppRoutes.tsx +69 -57
- package/src/components/BlockchainList/BlockchainList.styles.ts +2 -2
- package/src/components/BlockchainList/BlockchainList.tsx +4 -4
- package/src/components/BlockchainsSection/BlockchainsSection.styles.ts +1 -1
- package/src/components/BlockchainsSection/BlockchainsSection.tsx +17 -26
- package/src/components/ConfirmWalletsModal/ConfirmWallets.helpers.ts +64 -2
- package/src/components/ConfirmWalletsModal/ConfirmWallets.styles.ts +10 -29
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +47 -43
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.types.ts +3 -1
- package/src/components/ConfirmWalletsModal/WalletList.tsx +8 -9
- package/src/components/ConfirmWalletsModal/WalletList.type.ts +4 -1
- package/src/components/HeaderButtons/HomeButtons.tsx +18 -28
- package/src/components/Layout/Layout.styles.ts +0 -2
- package/src/components/Layout/Layout.tsx +7 -20
- package/src/components/Layout/Layout.types.ts +2 -2
- package/src/components/LoadingSwapDetails/LoadingSwapDetailStep.tsx +41 -0
- package/src/components/LoadingSwapDetails/LoadingSwapDetails.styles.ts +61 -65
- package/src/components/LoadingSwapDetails/LoadingSwapDetails.tsx +34 -28
- package/src/components/LoadingSwapDetails/LoadingSwapDetails.types.ts +3 -0
- package/src/components/{NoResult/NoResult.helpers.ts → NoRoutes/NoRoutes.helper.ts} +16 -23
- package/src/components/{NoResult/NoResult.styles.ts → NoRoutes/NoRoutes.styles.ts} +0 -2
- package/src/components/{NoResult/NoResult.tsx → NoRoutes/NoRoutes.tsx} +17 -12
- package/src/components/{NoResult/NoResult.types.ts → NoRoutes/NoRoutes.types.ts} +2 -3
- package/src/components/NoRoutes/index.ts +1 -0
- package/src/components/NotificationContent/NotificationContent.tsx +3 -5
- package/src/components/{QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.ts → RouteErrors/RouteErrors.styles.ts} +1 -8
- package/src/components/RouteErrors/RouteErrors.tsx +79 -0
- package/src/components/RouteErrors/RouteErrors.types.ts +29 -0
- package/src/components/RouteErrors/RouteErrorsModal.tsx +129 -0
- package/src/components/{QuoteWarningsAndErrors/QuoteErrorsModalItem.tsx → RouteErrors/RouteErrorsModalItem.tsx} +4 -4
- package/src/components/RouteErrors/index.ts +1 -0
- package/src/components/Slippage/Slippage.styles.ts +5 -15
- package/src/components/Slippage/Slippage.tsx +10 -11
- package/src/components/SwapDetails/SwapDetails.Placeholder.tsx +8 -5
- package/src/components/SwapDetails/SwapDetails.helpers.tsx +1 -1
- package/src/components/SwapDetails/SwapDetails.styles.ts +33 -36
- package/src/components/SwapDetails/SwapDetails.tsx +56 -41
- package/src/components/SwapDetailsAlerts/SwapDetailsAlerts.Warning.tsx +1 -1
- package/src/components/SwapDetailsModal/SwapDetailsCompleteModal.tsx +3 -4
- package/src/components/SwapDetailsModal/SwapDetailsModal.Cancel.tsx +2 -2
- package/src/components/SwapDetailsModal/SwapDetailsModal.WalletState.tsx +8 -14
- package/src/components/SwapDetailsModal/SwapDetailsModal.helpers.tsx +1 -1
- package/src/components/SwapDetailsModal/SwapDetailsModal.tsx +1 -1
- package/src/components/SwapDetailsModal/SwapDetailsModal.types.ts +1 -1
- package/src/components/SwapsGroup/SwapsGroup.styles.ts +1 -10
- package/src/components/SwapsGroup/SwapsGroup.tsx +5 -3
- package/src/components/SwitchFromAndTo.tsx +2 -2
- package/src/components/TokenList/TokenList.helpers.ts +2 -2
- package/src/components/TokenList/TokenList.styles.ts +38 -74
- package/src/components/TokenList/TokenList.tsx +26 -35
- package/src/components/TokenList/TokenList.types.ts +10 -4
- package/src/components/TokenList/index.ts +1 -0
- package/src/components/UpdateUrl.tsx +30 -35
- package/src/components/WidgetEvents.tsx +2 -4
- package/src/constants/errors.ts +15 -17
- package/src/constants/index.ts +0 -1
- package/src/constants/messages.ts +1 -1
- package/src/constants/navigationRoutes.ts +8 -7
- package/src/constants/searchParams.ts +0 -1
- package/src/constants/warnings.ts +7 -7
- package/src/hooks/useConfirmSwap.ts +303 -0
- package/src/hooks/{useFetchQuote.ts → useFetchBestRoute.ts} +3 -3
- package/src/hooks/useLanguage.ts +5 -4
- package/src/hooks/useNavigateBack.ts +52 -3
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.constants.ts +1 -1
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.ts +7 -37
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.ts +0 -60
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.test.ts +3 -78
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.ts +6 -15
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.types.ts +1 -6
- package/src/hooks/useSwapInput.ts +48 -141
- package/src/hooks/useSyncStoresWithConfig.ts +24 -40
- package/src/hooks/useTheme.ts +5 -4
- package/src/hooks/useWalletList.ts +5 -3
- package/src/index.ts +5 -53
- package/src/pages/ConfirmSwapPage.tsx +266 -117
- package/src/pages/HistoryPage.tsx +7 -2
- package/src/pages/Home.tsx +303 -88
- package/src/pages/LanguagePage.tsx +5 -0
- package/src/pages/LiquiditySourcePage.tsx +37 -24
- package/src/pages/SelectBlockchainPage.tsx +24 -31
- package/src/pages/SelectSwapItemsPage.tsx +31 -18
- package/src/pages/SettingsPage.tsx +27 -32
- package/src/pages/SwapDetailsPage.tsx +7 -6
- package/src/pages/ThemePage.tsx +7 -2
- package/src/pages/WalletsPage.tsx +19 -9
- package/src/services/httpService.ts +1 -1
- package/src/store/app.ts +6 -44
- package/src/store/{quote.ts → bestRoute.ts} +64 -71
- package/src/store/meta.ts +39 -0
- package/src/store/settings.ts +158 -0
- package/src/store/slices/config.ts +15 -26
- package/src/store/slices/data.ts +35 -74
- package/src/store/wallets.ts +37 -68
- package/src/types/config.ts +8 -53
- package/src/types/index.ts +1 -1
- package/src/types/routing.ts +77 -0
- package/src/types/swap.ts +13 -4
- package/src/types/wallets.ts +1 -18
- package/src/utils/colors.ts +1 -2
- package/src/utils/configs.ts +1 -2
- package/src/utils/date.ts +1 -1
- package/src/utils/meta.ts +1 -8
- package/src/utils/numbers.ts +1 -1
- package/src/utils/providers.ts +5 -8
- package/src/utils/queue.ts +2 -2
- package/src/utils/routing.ts +321 -0
- package/src/utils/settings.ts +10 -17
- package/src/utils/swap.ts +120 -154
- package/src/utils/time.ts +1 -1
- package/src/utils/wallets.ts +161 -156
- package/dist/components/NoResult/NoResult.d.ts +0 -4
- package/dist/components/NoResult/NoResult.d.ts.map +0 -1
- package/dist/components/NoResult/NoResult.helpers.d.ts +0 -4
- package/dist/components/NoResult/NoResult.helpers.d.ts.map +0 -1
- package/dist/components/NoResult/NoResult.types.d.ts.map +0 -1
- package/dist/components/NoResult/index.d.ts +0 -2
- package/dist/components/NoResult/index.d.ts.map +0 -1
- package/dist/components/Quote/Quote.d.ts +0 -4
- package/dist/components/Quote/Quote.d.ts.map +0 -1
- package/dist/components/Quote/Quote.styles.d.ts +0 -2217
- package/dist/components/Quote/Quote.styles.d.ts.map +0 -1
- package/dist/components/Quote/Quote.types.d.ts +0 -21
- package/dist/components/Quote/Quote.types.d.ts.map +0 -1
- package/dist/components/Quote/QuoteSummary.d.ts +0 -11
- package/dist/components/Quote/QuoteSummary.d.ts.map +0 -1
- package/dist/components/Quote/QuoteSummary.styles.d.ts +0 -315
- package/dist/components/Quote/QuoteSummary.styles.d.ts.map +0 -1
- package/dist/components/Quote/index.d.ts +0 -3
- package/dist/components/Quote/index.d.ts.map +0 -1
- package/dist/components/QuoteSkeleton/QuoteSkeleton.d.ts +0 -4
- package/dist/components/QuoteSkeleton/QuoteSkeleton.d.ts.map +0 -1
- package/dist/components/QuoteSkeleton/QuoteSkeleton.styles.d.ts +0 -633
- package/dist/components/QuoteSkeleton/QuoteSkeleton.styles.d.ts.map +0 -1
- package/dist/components/QuoteSkeleton/QuoteSkeleton.types.d.ts +0 -6
- package/dist/components/QuoteSkeleton/QuoteSkeleton.types.d.ts.map +0 -1
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.d.ts +0 -4
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.d.ts.map +0 -1
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.styles.d.ts +0 -1571
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.styles.d.ts.map +0 -1
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.types.d.ts +0 -6
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.types.d.ts.map +0 -1
- package/dist/components/QuoteSkeleton/StepSkeleton.d.ts +0 -4
- package/dist/components/QuoteSkeleton/StepSkeleton.d.ts.map +0 -1
- package/dist/components/QuoteSkeleton/StepSkeleton.styles.d.ts +0 -786
- package/dist/components/QuoteSkeleton/StepSkeleton.styles.d.ts.map +0 -1
- package/dist/components/QuoteSkeleton/StepSkeleton.types.d.ts +0 -4
- package/dist/components/QuoteSkeleton/StepSkeleton.types.d.ts.map +0 -1
- package/dist/components/QuoteSkeleton/index.d.ts +0 -4
- package/dist/components/QuoteSkeleton/index.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/HighValueLossWarningModal.d.ts +0 -11
- package/dist/components/QuoteWarningsAndErrors/HighValueLossWarningModal.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteErrorsModalItem.d.ts +0 -4
- package/dist/components/QuoteWarningsAndErrors/QuoteErrorsModalItem.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.d.ts +0 -4
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts +0 -9
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts +0 -23
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/SlippageWariningModal.d.ts +0 -11
- package/dist/components/QuoteWarningsAndErrors/SlippageWariningModal.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.d.ts +0 -11
- package/dist/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/index.d.ts +0 -2
- package/dist/components/QuoteWarningsAndErrors/index.d.ts.map +0 -1
- package/dist/containers/App/App.d.ts +0 -3
- package/dist/containers/App/App.d.ts.map +0 -1
- package/dist/containers/App/App.styles.d.ts +0 -158
- package/dist/containers/App/App.styles.d.ts.map +0 -1
- package/dist/containers/App/index.d.ts +0 -2
- package/dist/containers/App/index.d.ts.map +0 -1
- package/dist/containers/QuoteInfo/QuoteInfo.d.ts +0 -4
- package/dist/containers/QuoteInfo/QuoteInfo.d.ts.map +0 -1
- package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts +0 -788
- package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts.map +0 -1
- package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts +0 -20
- package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts.map +0 -1
- package/dist/containers/QuoteInfo/index.d.ts +0 -2
- package/dist/containers/QuoteInfo/index.d.ts.map +0 -1
- package/dist/containers/Wallets/Wallets.d.ts +0 -6
- package/dist/containers/Wallets/Wallets.d.ts.map +0 -1
- package/dist/containers/Wallets/Wallets.types.d.ts +0 -11
- package/dist/containers/Wallets/Wallets.types.d.ts.map +0 -1
- package/dist/containers/Wallets/index.d.ts +0 -2
- package/dist/containers/Wallets/index.d.ts.map +0 -1
- package/dist/containers/Widget/Widget.d.ts +0 -5
- package/dist/containers/Widget/Widget.d.ts.map +0 -1
- package/dist/containers/Widget/Widget.types.d.ts +0 -5
- package/dist/containers/Widget/Widget.types.d.ts.map +0 -1
- package/dist/containers/Widget/index.d.ts +0 -3
- package/dist/containers/Widget/index.d.ts.map +0 -1
- package/dist/containers/WidgetInfo/WidgetInfo.d.ts +0 -6
- package/dist/containers/WidgetInfo/WidgetInfo.d.ts.map +0 -1
- package/dist/containers/WidgetInfo/WidgetInfo.helpers.d.ts +0 -20
- package/dist/containers/WidgetInfo/WidgetInfo.helpers.d.ts.map +0 -1
- package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts +0 -21
- package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts.map +0 -1
- package/dist/containers/WidgetInfo/index.d.ts +0 -2
- package/dist/containers/WidgetInfo/index.d.ts.map +0 -1
- package/dist/containers/WidgetProvider/WidgetProvider.d.ts +0 -5
- package/dist/containers/WidgetProvider/WidgetProvider.d.ts.map +0 -1
- package/dist/containers/WidgetProvider/WidgetProvider.types.d.ts +0 -7
- package/dist/containers/WidgetProvider/WidgetProvider.types.d.ts.map +0 -1
- package/dist/containers/WidgetProvider/index.d.ts +0 -2
- package/dist/containers/WidgetProvider/index.d.ts.map +0 -1
- package/dist/hooks/useConfirmSwap/index.d.ts +0 -2
- package/dist/hooks/useConfirmSwap/index.d.ts.map +0 -1
- package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts +0 -3
- package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts.map +0 -1
- package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts +0 -19
- package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts.map +0 -1
- package/dist/hooks/useConfirmSwap/useConfirmSwap.types.d.ts.map +0 -1
- package/dist/hooks/useFetchQuote.d.ts.map +0 -1
- package/dist/hooks/useForceAutoConnect.d.ts +0 -2
- package/dist/hooks/useForceAutoConnect.d.ts.map +0 -1
- package/dist/store/AppStore.d.ts +0 -47
- package/dist/store/AppStore.d.ts.map +0 -1
- package/dist/store/quote.d.ts +0 -89
- package/dist/store/quote.d.ts.map +0 -1
- package/dist/store/slices/settings.d.ts +0 -39
- package/dist/store/slices/settings.d.ts.map +0 -1
- package/dist/types/quote.d.ts +0 -82
- package/dist/types/quote.d.ts.map +0 -1
- package/dist/utils/quote.d.ts +0 -32
- package/dist/utils/quote.d.ts.map +0 -1
- package/src/components/NoResult/index.ts +0 -1
- package/src/components/Quote/Quote.styles.ts +0 -249
- package/src/components/Quote/Quote.tsx +0 -414
- package/src/components/Quote/Quote.types.ts +0 -15
- package/src/components/Quote/QuoteSummary.styles.ts +0 -16
- package/src/components/Quote/QuoteSummary.tsx +0 -46
- package/src/components/Quote/index.ts +0 -2
- package/src/components/QuoteSkeleton/QuoteSkeleton.styles.ts +0 -42
- package/src/components/QuoteSkeleton/QuoteSkeleton.tsx +0 -30
- package/src/components/QuoteSkeleton/QuoteSkeleton.types.ts +0 -5
- package/src/components/QuoteSkeleton/QuoteSummarySkeleton.styles.ts +0 -57
- package/src/components/QuoteSkeleton/QuoteSummarySkeleton.tsx +0 -76
- package/src/components/QuoteSkeleton/QuoteSummarySkeleton.types.ts +0 -6
- package/src/components/QuoteSkeleton/StepSkeleton.styles.ts +0 -33
- package/src/components/QuoteSkeleton/StepSkeleton.tsx +0 -44
- package/src/components/QuoteSkeleton/StepSkeleton.types.ts +0 -1
- package/src/components/QuoteSkeleton/index.ts +0 -3
- package/src/components/QuoteWarningsAndErrors/HighValueLossWarningModal.tsx +0 -107
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.ts +0 -74
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.tsx +0 -103
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.ts +0 -25
- package/src/components/QuoteWarningsAndErrors/SlippageWariningModal.tsx +0 -77
- package/src/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.tsx +0 -38
- package/src/components/QuoteWarningsAndErrors/index.ts +0 -1
- package/src/containers/App/App.styles.ts +0 -18
- package/src/containers/App/App.tsx +0 -52
- package/src/containers/App/index.ts +0 -1
- package/src/containers/QuoteInfo/QuoteInfo.styles.ts +0 -31
- package/src/containers/QuoteInfo/QuoteInfo.tsx +0 -99
- package/src/containers/QuoteInfo/QuoteInfo.types.ts +0 -20
- package/src/containers/QuoteInfo/index.ts +0 -1
- package/src/containers/Wallets/Wallets.types.ts +0 -12
- package/src/containers/Wallets/index.ts +0 -1
- package/src/containers/Widget/Widget.tsx +0 -19
- package/src/containers/Widget/Widget.types.ts +0 -5
- package/src/containers/Widget/index.ts +0 -2
- package/src/containers/WidgetInfo/WidgetInfo.helpers.ts +0 -64
- package/src/containers/WidgetInfo/WidgetInfo.tsx +0 -62
- package/src/containers/WidgetInfo/WidgetInfo.types.ts +0 -21
- package/src/containers/WidgetInfo/index.ts +0 -1
- package/src/containers/WidgetProvider/WidgetProvider.tsx +0 -28
- package/src/containers/WidgetProvider/WidgetProvider.types.ts +0 -7
- package/src/containers/WidgetProvider/index.ts +0 -1
- package/src/hooks/useConfirmSwap/index.ts +0 -1
- package/src/hooks/useConfirmSwap/useConfirmSwap.helpers.ts +0 -172
- package/src/hooks/useConfirmSwap/useConfirmSwap.ts +0 -137
- package/src/hooks/useConfirmSwap/useConfirmSwap.types.ts +0 -19
- package/src/hooks/useForceAutoConnect.ts +0 -27
- package/src/store/AppStore.tsx +0 -41
- package/src/store/slices/settings.ts +0 -168
- package/src/types/quote.ts +0 -107
- package/src/utils/quote.ts +0 -338
package/package.json
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/widget-embedded",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"source": "./src/index.ts",
|
|
7
6
|
"main": "dist/index.js",
|
|
8
7
|
"typings": "dist/index.d.ts",
|
|
9
8
|
"files": [
|
|
@@ -13,7 +12,6 @@
|
|
|
13
12
|
"browserslist": "> 0.5%, last 2 versions, not dead",
|
|
14
13
|
"scripts": {
|
|
15
14
|
"build": "node ../../scripts/build/command.mjs --path widget/embedded",
|
|
16
|
-
"ts-check": "tsc --declaration --emitDeclarationOnly -p ./tsconfig.json",
|
|
17
15
|
"clean": "rimraf dist",
|
|
18
16
|
"format": "prettier --write '{.,src}/**/*.{ts,tsx}'",
|
|
19
17
|
"lint": "eslint \"**/*.{ts,tsx}\" --ignore-path ../../.eslintignore"
|
|
@@ -21,20 +19,20 @@
|
|
|
21
19
|
"dependencies": {
|
|
22
20
|
"@lingui/core": "4.2.1",
|
|
23
21
|
"@lingui/react": "4.2.1",
|
|
24
|
-
"@rango-dev/provider-all": "^0.
|
|
25
|
-
"@rango-dev/queue-manager-core": "^0.
|
|
26
|
-
"@rango-dev/queue-manager-rango-preset": "^0.
|
|
27
|
-
"@rango-dev/queue-manager-react": "^0.
|
|
28
|
-
"@rango-dev/ui": "^0.
|
|
29
|
-
"@rango-dev/wallets-react": "^0.
|
|
30
|
-
"@rango-dev/wallets-shared": "^0.
|
|
22
|
+
"@rango-dev/provider-all": "^0.24.0",
|
|
23
|
+
"@rango-dev/queue-manager-core": "^0.23.0",
|
|
24
|
+
"@rango-dev/queue-manager-rango-preset": "^0.24.0",
|
|
25
|
+
"@rango-dev/queue-manager-react": "^0.23.0",
|
|
26
|
+
"@rango-dev/ui": "^0.24.0",
|
|
27
|
+
"@rango-dev/wallets-react": "^0.10.0",
|
|
28
|
+
"@rango-dev/wallets-shared": "^0.23.0",
|
|
31
29
|
"bignumber.js": "^9.1.1",
|
|
32
30
|
"copy-to-clipboard": "^3.3.3",
|
|
33
31
|
"dayjs": "^1.11.7",
|
|
34
32
|
"immer": "^9.0.19",
|
|
35
33
|
"mitt": "^3.0.0",
|
|
36
|
-
"rango-sdk": "^0.1.
|
|
37
|
-
"rango-types": "^0.1.
|
|
34
|
+
"rango-sdk": "^0.1.35",
|
|
35
|
+
"rango-types": "^0.1.46",
|
|
38
36
|
"react-i18next": "^12.2.0",
|
|
39
37
|
"react-router-dom": "^6.8.0",
|
|
40
38
|
"values.js": "2.1.1",
|
package/src/QueueManager.tsx
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import type { PropsWithChildren } from 'react';
|
|
4
|
-
|
|
1
|
+
import React, { PropsWithChildren, useMemo } from 'react';
|
|
2
|
+
import { Provider as ManagerProvider } from '@rango-dev/queue-manager-react';
|
|
5
3
|
import {
|
|
6
|
-
checkWaitingForNetworkChange,
|
|
7
4
|
makeQueueDefinition,
|
|
5
|
+
SwapQueueContext,
|
|
6
|
+
checkWaitingForNetworkChange,
|
|
8
7
|
} from '@rango-dev/queue-manager-rango-preset';
|
|
9
|
-
import { Provider as ManagerProvider } from '@rango-dev/queue-manager-react';
|
|
10
8
|
import { useWallets } from '@rango-dev/wallets-react';
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
import {
|
|
10
|
+
convertEvmBlockchainMetaToEvmChainInfo,
|
|
11
|
+
Network,
|
|
12
|
+
WalletType,
|
|
13
|
+
} from '@rango-dev/wallets-shared';
|
|
14
|
+
import { useMetaStore } from './store/meta';
|
|
16
15
|
import { useWalletsStore } from './store/wallets';
|
|
17
|
-
import { getConfig } from './utils/configs';
|
|
18
16
|
import { walletAndSupportedChainsNames } from './utils/wallets';
|
|
17
|
+
import { getConfig } from './utils/configs';
|
|
18
|
+
import { isEvmBlockchain } from 'rango-types';
|
|
19
19
|
|
|
20
|
-
function QueueManager(props: PropsWithChildren
|
|
20
|
+
function QueueManager(props: PropsWithChildren) {
|
|
21
21
|
const {
|
|
22
22
|
providers,
|
|
23
23
|
getSigners,
|
|
@@ -29,12 +29,11 @@ function QueueManager(props: PropsWithChildren<{ apiKey?: string }>) {
|
|
|
29
29
|
|
|
30
30
|
const swapQueueDef = useMemo(() => {
|
|
31
31
|
return makeQueueDefinition({
|
|
32
|
-
API_KEY:
|
|
33
|
-
BASE_URL: getConfig('BASE_URL'),
|
|
32
|
+
API_KEY: getConfig('API_KEY'),
|
|
34
33
|
});
|
|
35
|
-
}, [
|
|
34
|
+
}, []);
|
|
36
35
|
|
|
37
|
-
const blockchains =
|
|
36
|
+
const { blockchains } = useMetaStore.use.meta();
|
|
38
37
|
const connectedWallets = useWalletsStore.use.connectedWallets();
|
|
39
38
|
|
|
40
39
|
const wallets = {
|
|
@@ -44,7 +43,7 @@ function QueueManager(props: PropsWithChildren<{ apiKey?: string }>) {
|
|
|
44
43
|
})),
|
|
45
44
|
};
|
|
46
45
|
|
|
47
|
-
const switchNetwork =
|
|
46
|
+
const switchNetwork = (wallet: WalletType, network: Network) => {
|
|
48
47
|
if (!canSwitchNetworkTo(wallet, network)) {
|
|
49
48
|
return undefined;
|
|
50
49
|
}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
PropTypes,
|
|
4
|
-
WidgetContextInterface,
|
|
5
|
-
} from './Wallets.types';
|
|
6
|
-
import type { ProvidersOptions } from '../../utils/providers';
|
|
1
|
+
import type { WidgetConfig } from './types';
|
|
2
|
+
import type { ProvidersOptions } from './utils/providers';
|
|
7
3
|
import type { EventHandler } from '@rango-dev/wallets-react';
|
|
8
4
|
import type { Network } from '@rango-dev/wallets-shared';
|
|
9
5
|
import type { PropsWithChildren } from 'react';
|
|
10
6
|
|
|
11
7
|
import { Events, Provider } from '@rango-dev/wallets-react';
|
|
12
8
|
import { isEvmBlockchain } from 'rango-sdk';
|
|
13
|
-
import React, { createContext,
|
|
9
|
+
import React, { createContext, useRef } from 'react';
|
|
14
10
|
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import { useWalletsStore } from '../../store/wallets';
|
|
11
|
+
import { useWalletProviders } from './hooks/useWalletProviders';
|
|
12
|
+
import { useMetaStore } from './store/meta';
|
|
13
|
+
import { useWalletsStore } from './store/wallets';
|
|
19
14
|
import {
|
|
20
15
|
prepareAccountsForWalletStore,
|
|
21
16
|
walletAndSupportedChainsNames,
|
|
22
|
-
} from '
|
|
17
|
+
} from './utils/wallets';
|
|
18
|
+
|
|
19
|
+
type OnConnectHandler = (key: string) => void;
|
|
20
|
+
interface WidgetContextInterface {
|
|
21
|
+
onConnectWallet(handler: OnConnectHandler): void;
|
|
22
|
+
}
|
|
23
23
|
|
|
24
24
|
export const WidgetContext = createContext<WidgetContextInterface>({
|
|
25
25
|
onConnectWallet: () => {
|
|
@@ -27,46 +27,41 @@ export const WidgetContext = createContext<WidgetContextInterface>({
|
|
|
27
27
|
},
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const {
|
|
38
|
-
const {
|
|
30
|
+
export function WidgetWallets(
|
|
31
|
+
props: PropsWithChildren<{
|
|
32
|
+
providers: WidgetConfig['wallets'];
|
|
33
|
+
options?: ProvidersOptions;
|
|
34
|
+
onUpdateState?: EventHandler;
|
|
35
|
+
}>
|
|
36
|
+
) {
|
|
37
|
+
const { blockchains } = useMetaStore.use.meta();
|
|
38
|
+
const { providers } = useWalletProviders(props.providers, props?.options);
|
|
39
|
+
const disconnectWallet = useWalletsStore.use.disconnectWallet();
|
|
40
|
+
const connectWallet = useWalletsStore.use.connectWallet();
|
|
39
41
|
const onConnectWalletHandler = useRef<OnConnectHandler>();
|
|
40
|
-
useSyncStoresWithConfig();
|
|
41
|
-
|
|
42
|
-
useEffect(() => {
|
|
43
|
-
void fetchMeta().catch(console.log);
|
|
44
|
-
}, []);
|
|
45
|
-
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
if (props.config) {
|
|
48
|
-
updateConfig(props.config);
|
|
49
|
-
updateSettings(props.config);
|
|
50
|
-
}
|
|
51
|
-
}, [props.config]);
|
|
52
42
|
|
|
53
43
|
const evmBasedChainNames = blockchains
|
|
54
44
|
.filter(isEvmBlockchain)
|
|
55
45
|
.map((chain) => chain.name);
|
|
56
46
|
|
|
57
|
-
const onUpdateState: EventHandler = (
|
|
47
|
+
const onUpdateState: EventHandler = (
|
|
48
|
+
type,
|
|
49
|
+
event,
|
|
50
|
+
value,
|
|
51
|
+
state,
|
|
52
|
+
supportedBlockchains
|
|
53
|
+
) => {
|
|
58
54
|
if (event === Events.ACCOUNTS) {
|
|
59
55
|
if (value) {
|
|
60
56
|
const supportedChainNames: Network[] | null =
|
|
61
|
-
walletAndSupportedChainsNames(
|
|
57
|
+
walletAndSupportedChainsNames(supportedBlockchains);
|
|
62
58
|
const data = prepareAccountsForWalletStore(
|
|
63
59
|
type,
|
|
64
60
|
value,
|
|
65
61
|
evmBasedChainNames,
|
|
66
|
-
supportedChainNames
|
|
67
|
-
meta.isContractWallet
|
|
62
|
+
supportedChainNames
|
|
68
63
|
);
|
|
69
|
-
connectWallet(data
|
|
64
|
+
connectWallet(data);
|
|
70
65
|
} else {
|
|
71
66
|
disconnectWallet(type);
|
|
72
67
|
}
|
|
@@ -96,7 +91,7 @@ function Main(props: PropsWithChildren<PropTypes>) {
|
|
|
96
91
|
|
|
97
92
|
// propagate updates for Dapps using external wallets
|
|
98
93
|
if (props.onUpdateState) {
|
|
99
|
-
props.onUpdateState(type, event, value, state,
|
|
94
|
+
props.onUpdateState(type, event, value, state, supportedBlockchains);
|
|
100
95
|
}
|
|
101
96
|
};
|
|
102
97
|
return (
|
|
@@ -117,12 +112,3 @@ function Main(props: PropsWithChildren<PropTypes>) {
|
|
|
117
112
|
</WidgetContext.Provider>
|
|
118
113
|
);
|
|
119
114
|
}
|
|
120
|
-
|
|
121
|
-
export function WidgetWallets(props: PropsWithChildren<PropTypes>) {
|
|
122
|
-
const { config, ...otherProps } = props;
|
|
123
|
-
return (
|
|
124
|
-
<AppStoreProvider config={config}>
|
|
125
|
-
<Main {...otherProps} config={config} />
|
|
126
|
-
</AppStoreProvider>
|
|
127
|
-
);
|
|
128
|
-
}
|
package/src/Widget.tsx
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type { WidgetConfig } from './types';
|
|
2
|
+
import type { WalletType } from '@rango-dev/wallets-shared';
|
|
3
|
+
import type { PropsWithChildren } from 'react';
|
|
4
|
+
|
|
5
|
+
import { I18nManager, styled } from '@rango-dev/ui';
|
|
6
|
+
import React, { useContext, useEffect, useMemo, useState } from 'react';
|
|
7
|
+
|
|
8
|
+
import { AppRouter } from './components/AppRouter';
|
|
9
|
+
import { AppRoutes } from './components/AppRoutes';
|
|
10
|
+
import { WidgetEvents } from './components/WidgetEvents';
|
|
11
|
+
import { globalFont } from './globalStyles';
|
|
12
|
+
import { useLanguage } from './hooks/useLanguage';
|
|
13
|
+
import { useTheme } from './hooks/useTheme';
|
|
14
|
+
import QueueManager from './QueueManager';
|
|
15
|
+
import { useAppStore } from './store/app';
|
|
16
|
+
import { useMetaStore } from './store/meta';
|
|
17
|
+
import { useNotificationStore } from './store/notification';
|
|
18
|
+
import { useSettingsStore } from './store/settings';
|
|
19
|
+
import { initConfig } from './utils/configs';
|
|
20
|
+
import { WidgetContext, WidgetWallets } from './Wallets';
|
|
21
|
+
|
|
22
|
+
const MainContainer = styled('div', {
|
|
23
|
+
width: '100%',
|
|
24
|
+
display: 'flex',
|
|
25
|
+
justifyContent: 'center',
|
|
26
|
+
alignItems: 'center',
|
|
27
|
+
fontFamily: '$widget',
|
|
28
|
+
boxSizing: 'border-box',
|
|
29
|
+
'& *, *::before, *::after': {
|
|
30
|
+
boxSizing: 'inherit',
|
|
31
|
+
listStyleType: 'none',
|
|
32
|
+
},
|
|
33
|
+
'& *:focus-visible': {
|
|
34
|
+
outlineColor: '$info500',
|
|
35
|
+
transition: 'none',
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export type WidgetProps = {
|
|
40
|
+
config?: WidgetConfig;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export function Main(props: PropsWithChildren<WidgetProps>) {
|
|
44
|
+
const { config } = props;
|
|
45
|
+
globalFont();
|
|
46
|
+
|
|
47
|
+
const { activeTheme } = useTheme(config?.theme || {});
|
|
48
|
+
const { activeLanguage, changeLanguage } = useLanguage();
|
|
49
|
+
|
|
50
|
+
const [lastConnectedWalletWithNetwork, setLastConnectedWalletWithNetwork] =
|
|
51
|
+
useState<string>('');
|
|
52
|
+
const [disconnectedWallet, setDisconnectedWallet] = useState<WalletType>();
|
|
53
|
+
const widgetContext = useContext(WidgetContext);
|
|
54
|
+
const fetchMeta = useMetaStore.use.fetchMeta();
|
|
55
|
+
|
|
56
|
+
useMemo(() => {
|
|
57
|
+
if (config?.apiKey) {
|
|
58
|
+
initConfig({
|
|
59
|
+
API_KEY: config?.apiKey,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}, [config]);
|
|
63
|
+
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
void fetchMeta();
|
|
66
|
+
void useSettingsStore.persist.rehydrate();
|
|
67
|
+
void useNotificationStore.persist.rehydrate();
|
|
68
|
+
widgetContext.onConnectWallet(setLastConnectedWalletWithNetwork);
|
|
69
|
+
}, []);
|
|
70
|
+
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
if (config?.language) {
|
|
73
|
+
changeLanguage(config.language);
|
|
74
|
+
}
|
|
75
|
+
}, [config?.language]);
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<I18nManager language={activeLanguage}>
|
|
79
|
+
<MainContainer id="swap-container" className={activeTheme()}>
|
|
80
|
+
<QueueManager>
|
|
81
|
+
<WidgetEvents />
|
|
82
|
+
<AppRouter
|
|
83
|
+
config={config}
|
|
84
|
+
lastConnectedWallet={lastConnectedWalletWithNetwork}
|
|
85
|
+
disconnectedWallet={disconnectedWallet}
|
|
86
|
+
clearDisconnectedWallet={() => {
|
|
87
|
+
setDisconnectedWallet(undefined);
|
|
88
|
+
}}>
|
|
89
|
+
<AppRoutes config={config} />
|
|
90
|
+
</AppRouter>
|
|
91
|
+
</QueueManager>
|
|
92
|
+
</MainContainer>
|
|
93
|
+
</I18nManager>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function Widget(props: PropsWithChildren<WidgetProps>) {
|
|
98
|
+
const { updateConfig, config } = useAppStore();
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
if (props.config) {
|
|
101
|
+
updateConfig(props.config);
|
|
102
|
+
}
|
|
103
|
+
}, [props.config]);
|
|
104
|
+
|
|
105
|
+
if (!props.config?.externalWallets) {
|
|
106
|
+
return (
|
|
107
|
+
<WidgetWallets
|
|
108
|
+
providers={config?.wallets}
|
|
109
|
+
options={{
|
|
110
|
+
walletConnectProjectId:
|
|
111
|
+
config?.walletConnectProjectId ||
|
|
112
|
+
props.config?.walletConnectProjectId,
|
|
113
|
+
}}>
|
|
114
|
+
<Main {...props} />
|
|
115
|
+
</WidgetWallets>
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
return <Main {...props} />;
|
|
119
|
+
}
|
|
@@ -1,17 +1,42 @@
|
|
|
1
|
+
import type { WidgetConfig } from '../types';
|
|
1
2
|
import type { WalletType } from '@rango-dev/wallets-shared';
|
|
2
3
|
import type { PropsWithChildren } from 'react';
|
|
3
4
|
|
|
4
5
|
import { useQueueManager } from '@rango-dev/queue-manager-rango-preset';
|
|
5
6
|
import { useWallets } from '@rango-dev/wallets-react';
|
|
6
7
|
import { isEvmBlockchain } from 'rango-types';
|
|
7
|
-
import React, {
|
|
8
|
+
import React, { useEffect, useRef } from 'react';
|
|
8
9
|
import { MemoryRouter, useInRouterContext } from 'react-router';
|
|
10
|
+
import { useLocation, useNavigate } from 'react-router-dom';
|
|
9
11
|
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
+
import { navigationRoutes } from '../constants/navigationRoutes';
|
|
13
|
+
import { Home } from '../pages/Home';
|
|
14
|
+
import { useMetaStore } from '../store/meta';
|
|
12
15
|
|
|
13
16
|
import { UpdateUrl } from './UpdateUrl';
|
|
14
17
|
|
|
18
|
+
function Route(props: PropsWithChildren) {
|
|
19
|
+
const location = useLocation();
|
|
20
|
+
const navigate = useNavigate();
|
|
21
|
+
const firstRender = useRef(true);
|
|
22
|
+
const paths = location.pathname.split('/');
|
|
23
|
+
const pathMatched = paths[paths.length - 1] === navigationRoutes.confirmSwap;
|
|
24
|
+
const shouldRedirectToMainPage = pathMatched && firstRender.current;
|
|
25
|
+
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (shouldRedirectToMainPage) {
|
|
28
|
+
navigate('.');
|
|
29
|
+
}
|
|
30
|
+
firstRender.current = false;
|
|
31
|
+
}, []);
|
|
32
|
+
|
|
33
|
+
if (shouldRedirectToMainPage) {
|
|
34
|
+
return <Home />;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return <> {props.children}</>;
|
|
38
|
+
}
|
|
39
|
+
|
|
15
40
|
export function AppRouter({
|
|
16
41
|
children,
|
|
17
42
|
...props
|
|
@@ -19,14 +44,13 @@ export function AppRouter({
|
|
|
19
44
|
lastConnectedWallet: string;
|
|
20
45
|
disconnectedWallet: WalletType | undefined;
|
|
21
46
|
clearDisconnectedWallet: () => void;
|
|
47
|
+
config: WidgetConfig | undefined;
|
|
22
48
|
}) {
|
|
23
49
|
const isRouterInContext = useInRouterContext();
|
|
24
|
-
const Router = isRouterInContext ?
|
|
25
|
-
const blockchains =
|
|
50
|
+
const Router = isRouterInContext ? Route : MemoryRouter;
|
|
51
|
+
const { blockchains } = useMetaStore.use.meta();
|
|
26
52
|
const { canSwitchNetworkTo } = useWallets();
|
|
27
53
|
|
|
28
|
-
useForceAutoConnect();
|
|
29
|
-
|
|
30
54
|
const evmChains = blockchains.filter(isEvmBlockchain);
|
|
31
55
|
|
|
32
56
|
useQueueManager({
|
|
@@ -40,7 +64,7 @@ export function AppRouter({
|
|
|
40
64
|
return (
|
|
41
65
|
<>
|
|
42
66
|
<Router>{children}</Router>
|
|
43
|
-
{isRouterInContext && <UpdateUrl />}
|
|
67
|
+
{isRouterInContext && <UpdateUrl config={props.config} />}
|
|
44
68
|
</>
|
|
45
69
|
);
|
|
46
70
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { WidgetConfig } from '../types';
|
|
2
|
+
|
|
1
3
|
import React from 'react';
|
|
2
4
|
import { useRoutes } from 'react-router-dom';
|
|
3
5
|
|
|
@@ -14,7 +16,15 @@ import { SwapDetailsPage } from '../pages/SwapDetailsPage';
|
|
|
14
16
|
import { ThemePage } from '../pages/ThemePage';
|
|
15
17
|
import { WalletsPage } from '../pages/WalletsPage';
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
const getAbsolutePath = (path: string) => path.replace('/', '');
|
|
20
|
+
|
|
21
|
+
interface PropTypes {
|
|
22
|
+
config?: WidgetConfig;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function AppRoutes(props: PropTypes) {
|
|
26
|
+
const { config } = props;
|
|
27
|
+
|
|
18
28
|
return useRoutes([
|
|
19
29
|
{
|
|
20
30
|
path: navigationRoutes.home,
|
|
@@ -22,75 +32,77 @@ export function AppRoutes() {
|
|
|
22
32
|
},
|
|
23
33
|
{
|
|
24
34
|
path: navigationRoutes.fromSwap,
|
|
25
|
-
|
|
26
|
-
{
|
|
27
|
-
index: true,
|
|
28
|
-
element: <SelectSwapItemsPage type="source" />,
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
path: navigationRoutes.blockchains,
|
|
32
|
-
element: <SelectBlockchainPage type="source" />,
|
|
33
|
-
},
|
|
34
|
-
],
|
|
35
|
+
element: <SelectSwapItemsPage type="source" />,
|
|
35
36
|
},
|
|
36
37
|
{
|
|
37
38
|
path: navigationRoutes.toSwap,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
],
|
|
39
|
+
element: <SelectSwapItemsPage type="destination" />,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
path: navigationRoutes.fromBlockchain,
|
|
43
|
+
element: <SelectBlockchainPage type="source" />,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
path: navigationRoutes.toBlockchain,
|
|
47
|
+
element: <SelectBlockchainPage type="destination" />,
|
|
48
48
|
},
|
|
49
49
|
{
|
|
50
50
|
path: navigationRoutes.settings,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
51
|
+
element: (
|
|
52
|
+
<SettingsPage
|
|
53
|
+
singleTheme={config?.theme?.singleTheme}
|
|
54
|
+
supportedSwappers={config?.liquiditySources}
|
|
55
|
+
/>
|
|
56
|
+
),
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
path: navigationRoutes.themes,
|
|
60
|
+
element: <ThemePage />,
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
path: navigationRoutes.languages,
|
|
64
|
+
element: <LanguagePage />,
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
path: navigationRoutes.exchanges,
|
|
68
|
+
element: (
|
|
69
|
+
<LiquiditySourcePage
|
|
70
|
+
sourceType="Exchanges"
|
|
71
|
+
supportedSwappers={config?.liquiditySources}
|
|
72
|
+
/>
|
|
73
|
+
),
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
path: navigationRoutes.bridges,
|
|
77
|
+
element: (
|
|
78
|
+
<LiquiditySourcePage
|
|
79
|
+
sourceType="Bridges"
|
|
80
|
+
supportedSwappers={config?.liquiditySources}
|
|
81
|
+
/>
|
|
82
|
+
),
|
|
73
83
|
},
|
|
84
|
+
{ path: navigationRoutes.swaps, element: <HistoryPage /> },
|
|
74
85
|
{
|
|
75
|
-
path: navigationRoutes.
|
|
76
|
-
|
|
77
|
-
{
|
|
78
|
-
index: true,
|
|
79
|
-
element: <HistoryPage />,
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
path: navigationRoutes.swapDetails,
|
|
83
|
-
element: <SwapDetailsPage />,
|
|
84
|
-
},
|
|
85
|
-
],
|
|
86
|
+
path: navigationRoutes.swapDetails,
|
|
87
|
+
element: <SwapDetailsPage />,
|
|
86
88
|
},
|
|
87
89
|
{
|
|
88
90
|
path: navigationRoutes.wallets,
|
|
89
|
-
element:
|
|
91
|
+
element: (
|
|
92
|
+
<WalletsPage
|
|
93
|
+
supportedWallets={config?.wallets}
|
|
94
|
+
multiWallets={
|
|
95
|
+
typeof config?.multiWallets === 'undefined'
|
|
96
|
+
? true
|
|
97
|
+
: config.multiWallets
|
|
98
|
+
}
|
|
99
|
+
config={config}
|
|
100
|
+
/>
|
|
101
|
+
),
|
|
90
102
|
},
|
|
91
103
|
{
|
|
92
|
-
path: navigationRoutes.confirmSwap,
|
|
93
|
-
element: <ConfirmSwapPage />,
|
|
104
|
+
path: getAbsolutePath(navigationRoutes.confirmSwap),
|
|
105
|
+
element: <ConfirmSwapPage config={config} />,
|
|
94
106
|
},
|
|
95
107
|
]);
|
|
96
108
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { styled } from '@rango-dev/ui';
|
|
2
2
|
|
|
3
3
|
export const Container = styled('div', {
|
|
4
4
|
display: 'flex',
|
|
@@ -12,7 +12,7 @@ export const List = styled('ul', {
|
|
|
12
12
|
listStyle: 'none',
|
|
13
13
|
overflowY: 'auto',
|
|
14
14
|
paddingRight: '$5',
|
|
15
|
-
|
|
15
|
+
'.image-container': {
|
|
16
16
|
borderRadius: '$xm',
|
|
17
17
|
overflow: 'hidden',
|
|
18
18
|
},
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from '@rango-dev/ui';
|
|
12
12
|
import React, { useEffect, useState } from 'react';
|
|
13
13
|
|
|
14
|
-
import {
|
|
14
|
+
import { useMetaStore } from '../../store/meta';
|
|
15
15
|
|
|
16
16
|
import { filterBlockchains } from './BlockchainList.helpers';
|
|
17
17
|
import { Container, List } from './BlockchainList.styles';
|
|
@@ -20,7 +20,7 @@ import { LoadingBlockchainList } from './LoadingBlockchainList';
|
|
|
20
20
|
export function BlockchainList(props: PropTypes) {
|
|
21
21
|
const { list, searchedFor, onChange, blockchainCategory } = props;
|
|
22
22
|
const [blockchains, setBlockchains] = useState<BlockchainMeta[]>(list);
|
|
23
|
-
const
|
|
23
|
+
const loadingStatus = useMetaStore.use.loadingStatus();
|
|
24
24
|
|
|
25
25
|
useEffect(() => {
|
|
26
26
|
setBlockchains([
|
|
@@ -66,8 +66,8 @@ export function BlockchainList(props: PropTypes) {
|
|
|
66
66
|
{i18n.t('Select Blockchain')}
|
|
67
67
|
</Typography>
|
|
68
68
|
<Divider size={4} />
|
|
69
|
-
{
|
|
70
|
-
{
|
|
69
|
+
{loadingStatus === 'loading' && <LoadingBlockchainList />}
|
|
70
|
+
{loadingStatus === 'success' && renderList()}
|
|
71
71
|
</Container>
|
|
72
72
|
);
|
|
73
73
|
}
|