@rango-dev/widget-embedded 0.17.1-next.1 → 0.17.1-next.11
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/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 +1429 -0
- package/dist/components/Quote/Quote.styles.d.ts.map +1 -0
- package/dist/components/Quote/Quote.types.d.ts +22 -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 +22 -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.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/messages.d.ts +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 +472 -0
- package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts.map +1 -0
- package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts +17 -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 +5 -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 +16 -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/usePrepareBlockchainList/usePrepareBlockchainList.helpers.d.ts +2 -2
- 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 +11 -4
- 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/Home.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/SettingsPage.d.ts +1 -6
- package/dist/pages/SettingsPage.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 +5 -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/utils/colors.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 +25 -22
- 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 +17 -17
- package/src/components/AppRouter.tsx +6 -5
- package/src/components/AppRoutes.tsx +6 -39
- 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 +28 -40
- 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/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} +16 -9
- 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 +3 -2
- package/src/components/Quote/Quote.styles.ts +219 -0
- package/src/components/Quote/Quote.tsx +345 -0
- package/src/components/Quote/Quote.types.ts +16 -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 +67 -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 +24 -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 +1 -1
- package/src/components/SwapDetails/SwapDetails.tsx +18 -22
- 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 -26
- package/src/components/WidgetEvents.tsx +4 -2
- package/src/constants/errors.ts +8 -10
- package/src/constants/messages.ts +1 -1
- 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 +65 -0
- package/src/containers/App/index.ts +1 -0
- package/src/containers/QuoteInfo/QuoteInfo.styles.ts +15 -0
- package/src/containers/QuoteInfo/QuoteInfo.tsx +97 -0
- package/src/containers/QuoteInfo/QuoteInfo.types.ts +17 -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 +36 -0
- package/src/containers/WidgetInfo/WidgetInfo.types.ts +5 -0
- package/src/containers/WidgetInfo/index.ts +1 -0
- package/src/containers/WidgetProvider/WidgetProvider.tsx +19 -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 +168 -0
- package/src/hooks/useConfirmSwap/useConfirmSwap.ts +136 -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/useNavigateBack.ts +3 -3
- package/src/hooks/useSwapInput.ts +58 -23
- package/src/hooks/useSyncStoresWithConfig.ts +22 -19
- package/src/hooks/useWalletList.ts +3 -5
- package/src/index.ts +12 -3
- package/src/pages/ConfirmSwapPage.tsx +58 -235
- package/src/pages/HistoryPage.tsx +1 -1
- package/src/pages/Home.tsx +58 -247
- package/src/pages/LanguagePage.tsx +1 -1
- package/src/pages/LiquiditySourcePage.tsx +23 -32
- package/src/pages/SelectBlockchainPage.tsx +6 -7
- package/src/pages/SelectSwapItemsPage.tsx +5 -5
- package/src/pages/SettingsPage.tsx +9 -13
- package/src/pages/SwapDetailsPage.tsx +3 -3
- package/src/pages/ThemePage.tsx +1 -1
- package/src/pages/WalletsPage.tsx +5 -12
- 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 +11 -8
- package/src/types/config.ts +5 -5
- package/src/types/index.ts +1 -1
- package/src/types/quote.ts +107 -0
- package/src/utils/colors.ts +2 -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 +113 -85
- 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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { styled, Typography } from '@rango-dev/ui';
|
|
1
|
+
import { darkTheme, styled, Typography } from '@rango-dev/ui';
|
|
2
2
|
|
|
3
3
|
export const Container = styled('div', {
|
|
4
4
|
display: 'flex',
|
|
@@ -40,7 +40,11 @@ export const List = styled('ul', {
|
|
|
40
40
|
'& a': {
|
|
41
41
|
fontSize: '$12',
|
|
42
42
|
lineHeight: '$16',
|
|
43
|
-
color: '$neutral600',
|
|
43
|
+
$$color: '$colors$neutral600',
|
|
44
|
+
[`.${darkTheme} &`]: {
|
|
45
|
+
$$color: '$colors$neutral700',
|
|
46
|
+
},
|
|
47
|
+
color: '$$color',
|
|
44
48
|
textDecoration: 'none',
|
|
45
49
|
},
|
|
46
50
|
},
|
|
@@ -92,6 +96,14 @@ export const TagTitle = styled(Typography, {});
|
|
|
92
96
|
|
|
93
97
|
export const BalanceContainer = styled('div', {
|
|
94
98
|
textAlign: 'right',
|
|
99
|
+
|
|
100
|
+
'.usd-value': {
|
|
101
|
+
$$color: '$colors$neutral600',
|
|
102
|
+
[`.${darkTheme} &`]: {
|
|
103
|
+
$$color: '$colors$neutral700',
|
|
104
|
+
},
|
|
105
|
+
color: '$$color',
|
|
106
|
+
},
|
|
95
107
|
});
|
|
96
108
|
|
|
97
109
|
export const End = styled('ul', {
|
|
@@ -21,8 +21,7 @@ import {
|
|
|
21
21
|
} from '@rango-dev/ui';
|
|
22
22
|
import React, { forwardRef, useEffect, useState } from 'react';
|
|
23
23
|
|
|
24
|
-
import { useAppStore } from '../../store/
|
|
25
|
-
import { useMetaStore } from '../../store/meta';
|
|
24
|
+
import { useAppStore } from '../../store/AppStore';
|
|
26
25
|
import { useWalletsStore } from '../../store/wallets';
|
|
27
26
|
import { generateRangeColors } from '../../utils/colors';
|
|
28
27
|
|
|
@@ -87,10 +86,10 @@ export function TokenList(props: PropTypes) {
|
|
|
87
86
|
const { list, searchedFor = '', onChange, selectedBlockchain } = props;
|
|
88
87
|
|
|
89
88
|
const [tokens, setTokens] = useState<TokenWithBalance[]>(list);
|
|
90
|
-
const
|
|
89
|
+
const fetchStatus = useAppStore().fetchStatus;
|
|
90
|
+
const blockchains = useAppStore().blockchains();
|
|
91
91
|
const [hasNextPage, setHasNextPage] = useState<boolean>(true);
|
|
92
92
|
const loadingWallet = useWalletsStore.use.loading();
|
|
93
|
-
const { blockchains } = useMetaStore.use.meta();
|
|
94
93
|
const { isTokenPinned } = useAppStore();
|
|
95
94
|
|
|
96
95
|
// eslint-disable-next-line react/display-name
|
|
@@ -239,7 +238,7 @@ export function TokenList(props: PropTypes) {
|
|
|
239
238
|
{token.balance?.usdValue && (
|
|
240
239
|
<Typography
|
|
241
240
|
variant="body"
|
|
242
|
-
|
|
241
|
+
className="usd-value"
|
|
243
242
|
size="xsmall">
|
|
244
243
|
{`$${token.balance?.usdValue}`}
|
|
245
244
|
</Typography>
|
|
@@ -268,8 +267,8 @@ export function TokenList(props: PropTypes) {
|
|
|
268
267
|
{i18n.t('Select Token')}
|
|
269
268
|
</Typography>
|
|
270
269
|
<Divider size={4} />
|
|
271
|
-
{
|
|
272
|
-
{
|
|
270
|
+
{fetchStatus === 'loading' && <LoadingTokenList size={PAGE_SIZE} />}
|
|
271
|
+
{fetchStatus === 'success' && <List>{renderList()}</List>}
|
|
273
272
|
</Container>
|
|
274
273
|
);
|
|
275
274
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { WidgetConfig } from '../types';
|
|
2
|
-
|
|
3
1
|
import { useEffect, useRef } from 'react';
|
|
4
2
|
import {
|
|
5
3
|
createSearchParams,
|
|
@@ -10,33 +8,32 @@ import {
|
|
|
10
8
|
import { navigationRoutes } from '../constants/navigationRoutes';
|
|
11
9
|
import { SearchParams } from '../constants/searchParams';
|
|
12
10
|
import { useSyncStoresWithConfig } from '../hooks/useSyncStoresWithConfig';
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
11
|
+
import { useAppStore } from '../store/AppStore';
|
|
12
|
+
import { useQuoteStore } from '../store/quote';
|
|
15
13
|
import { useUiStore } from '../store/ui';
|
|
16
|
-
import { searchParamsToToken } from '../utils/
|
|
17
|
-
|
|
18
|
-
type Props = { config: WidgetConfig | undefined };
|
|
14
|
+
import { searchParamsToToken } from '../utils/quote';
|
|
19
15
|
|
|
20
|
-
export function UpdateUrl(
|
|
16
|
+
export function UpdateUrl() {
|
|
21
17
|
const firstRender = useRef(true);
|
|
22
18
|
const [searchParams, setSearchParams] = useSearchParams();
|
|
23
19
|
const location = useLocation();
|
|
24
20
|
const firstRenderSearchParams = useRef(location.search);
|
|
25
21
|
const searchParamsRef = useRef<Record<string, string>>({});
|
|
26
|
-
const fromBlockchain =
|
|
27
|
-
const toBlockchain =
|
|
28
|
-
const fromToken =
|
|
29
|
-
const toToken =
|
|
30
|
-
const setFromBlockchain =
|
|
31
|
-
const setFromToken =
|
|
32
|
-
const setToBlockchain =
|
|
33
|
-
const setToToken =
|
|
34
|
-
const inputAmount =
|
|
35
|
-
const setInputAmount =
|
|
36
|
-
const
|
|
37
|
-
const
|
|
22
|
+
const fromBlockchain = useQuoteStore.use.fromBlockchain();
|
|
23
|
+
const toBlockchain = useQuoteStore.use.toBlockchain();
|
|
24
|
+
const fromToken = useQuoteStore.use.fromToken();
|
|
25
|
+
const toToken = useQuoteStore.use.toToken();
|
|
26
|
+
const setFromBlockchain = useQuoteStore.use.setFromBlockchain();
|
|
27
|
+
const setFromToken = useQuoteStore.use.setFromToken();
|
|
28
|
+
const setToBlockchain = useQuoteStore.use.setToBlockchain();
|
|
29
|
+
const setToToken = useQuoteStore.use.setToToken();
|
|
30
|
+
const inputAmount = useQuoteStore.use.inputAmount();
|
|
31
|
+
const setInputAmount = useQuoteStore.use.setInputAmount();
|
|
32
|
+
const fetchMetaStatus = useAppStore().fetchStatus;
|
|
33
|
+
const blockchains = useAppStore().blockchains();
|
|
34
|
+
const tokens = useAppStore().tokens();
|
|
38
35
|
const setSelectedSwap = useUiStore.use.setSelectedSwap();
|
|
39
|
-
useSyncStoresWithConfig(
|
|
36
|
+
useSyncStoresWithConfig();
|
|
40
37
|
|
|
41
38
|
useEffect(() => {
|
|
42
39
|
const params: Record<string, string> = {};
|
|
@@ -60,7 +57,8 @@ export function UpdateUrl(props: Props) {
|
|
|
60
57
|
toChainString = '',
|
|
61
58
|
toTokenString = '',
|
|
62
59
|
fromAmount = '';
|
|
63
|
-
|
|
60
|
+
const autoConnect = searchParamsRef.current[SearchParams.AUTO_CONNECT];
|
|
61
|
+
if (fetchMetaStatus !== 'success') {
|
|
64
62
|
fromChainString = searchParamsRef.current[SearchParams.FROM_CHAIN];
|
|
65
63
|
fromTokenString = searchParamsRef.current[SearchParams.FROM_TOKEN];
|
|
66
64
|
toChainString = searchParamsRef.current[SearchParams.TO_CHAIN];
|
|
@@ -94,6 +92,9 @@ export function UpdateUrl(props: Props) {
|
|
|
94
92
|
...(fromAmount && {
|
|
95
93
|
[SearchParams.FROM_AMOUNT]: fromAmount.toString(),
|
|
96
94
|
}),
|
|
95
|
+
...(autoConnect && {
|
|
96
|
+
[SearchParams.AUTO_CONNECT]: autoConnect,
|
|
97
|
+
}),
|
|
97
98
|
},
|
|
98
99
|
{ replace: true }
|
|
99
100
|
);
|
|
@@ -109,7 +110,7 @@ export function UpdateUrl(props: Props) {
|
|
|
109
110
|
]);
|
|
110
111
|
|
|
111
112
|
useEffect(() => {
|
|
112
|
-
if (
|
|
113
|
+
if (fetchMetaStatus === 'success') {
|
|
113
114
|
const fromChainString = searchParams.get(SearchParams.FROM_CHAIN);
|
|
114
115
|
const fromTokenString = searchParams.get(SearchParams.FROM_TOKEN);
|
|
115
116
|
const toChainString = searchParams.get(SearchParams.TO_CHAIN);
|
|
@@ -134,20 +135,29 @@ export function UpdateUrl(props: Props) {
|
|
|
134
135
|
if (!!fromBlockchain) {
|
|
135
136
|
setFromBlockchain(fromBlockchain);
|
|
136
137
|
if (!!fromToken) {
|
|
137
|
-
setFromToken(
|
|
138
|
+
setFromToken({
|
|
139
|
+
token: fromToken,
|
|
140
|
+
meta: {
|
|
141
|
+
blockchains: blockchains,
|
|
142
|
+
tokens: tokens,
|
|
143
|
+
},
|
|
144
|
+
});
|
|
138
145
|
}
|
|
139
146
|
}
|
|
140
147
|
if (!!toBlockchain) {
|
|
141
148
|
setToBlockchain(toBlockchain);
|
|
142
149
|
if (!!toToken) {
|
|
143
|
-
setToToken(
|
|
150
|
+
setToToken({
|
|
151
|
+
token: toToken,
|
|
152
|
+
meta: { blockchains: blockchains, tokens: tokens },
|
|
153
|
+
});
|
|
144
154
|
}
|
|
145
155
|
}
|
|
146
156
|
if (fromAmount) {
|
|
147
157
|
setInputAmount(fromAmount);
|
|
148
158
|
}
|
|
149
159
|
}
|
|
150
|
-
}, [
|
|
160
|
+
}, [fetchMetaStatus]);
|
|
151
161
|
|
|
152
162
|
return null;
|
|
153
163
|
}
|
|
@@ -8,11 +8,13 @@ import {
|
|
|
8
8
|
} from '@rango-dev/queue-manager-rango-preset';
|
|
9
9
|
import { useEffect } from 'react';
|
|
10
10
|
|
|
11
|
+
import { useAppStore } from '../store/AppStore';
|
|
11
12
|
import { useNotificationStore } from '../store/notification';
|
|
12
13
|
import { useWalletsStore } from '../store/wallets';
|
|
13
14
|
import { validBlockedStatuses } from '../types/notification';
|
|
14
15
|
|
|
15
16
|
export function WidgetEvents() {
|
|
17
|
+
const tokens = useAppStore().tokens();
|
|
16
18
|
const connectedWallets = useWalletsStore.use.connectedWallets();
|
|
17
19
|
const getWalletsDetails = useWalletsStore.use.getWalletsDetails();
|
|
18
20
|
const setNotification = useNotificationStore.use.setNotification();
|
|
@@ -38,8 +40,8 @@ export function WidgetEvents() {
|
|
|
38
40
|
(wallet) => wallet.chain === step?.toBlockchain
|
|
39
41
|
);
|
|
40
42
|
|
|
41
|
-
fromAccount && getWalletsDetails([fromAccount]);
|
|
42
|
-
toAccount && getWalletsDetails([toAccount]);
|
|
43
|
+
fromAccount && getWalletsDetails([fromAccount], tokens);
|
|
44
|
+
toAccount && getWalletsDetails([toAccount], tokens);
|
|
43
45
|
}
|
|
44
46
|
if (
|
|
45
47
|
(event.type === StepEventType.TX_EXECUTION_BLOCKED &&
|
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 {
|
|
@@ -13,7 +13,7 @@ export const errorMessages = () => {
|
|
|
13
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
|
-
|
|
16
|
+
noResultError: {
|
|
17
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."
|
|
@@ -31,7 +31,7 @@ export const errorMessages = () => {
|
|
|
31
31
|
),
|
|
32
32
|
confirmMessage: i18n.t('Confirm High price impact'),
|
|
33
33
|
},
|
|
34
|
-
|
|
34
|
+
quoteUpdatedWithHighValueLoss: {
|
|
35
35
|
title: i18n.t(
|
|
36
36
|
'Route updated and price impact is too high, try again later!'
|
|
37
37
|
),
|
|
@@ -47,14 +47,12 @@ export const errorMessages = () => {
|
|
|
47
47
|
};
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
export function
|
|
50
|
+
export function getQuoteErrorMessage(error: QuoteError) {
|
|
51
51
|
switch (error.type) {
|
|
52
|
-
case
|
|
53
|
-
return error.diagnosisMessage ?? errorMessages().
|
|
54
|
-
case
|
|
52
|
+
case QuoteErrorType.NO_RESULT:
|
|
53
|
+
return error.diagnosisMessage ?? errorMessages().noResultError.title;
|
|
54
|
+
case QuoteErrorType.REQUEST_FAILED:
|
|
55
55
|
return errorMessages().genericServerError;
|
|
56
|
-
case ConfirmSwapErrorTypes.ROUTE_UPDATED_WITH_HIGH_VALUE_LOSS:
|
|
57
|
-
return errorMessages().routeUpdatedWithHighValueLoss.title;
|
|
58
56
|
default:
|
|
59
57
|
return '';
|
|
60
58
|
}
|
|
@@ -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,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,65 @@
|
|
|
1
|
+
import type { WalletType } from '@rango-dev/wallets-shared';
|
|
2
|
+
|
|
3
|
+
import { I18nManager } from '@rango-dev/ui';
|
|
4
|
+
import React, { useContext, useEffect, useMemo, 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 { initConfig } from '../../utils/configs';
|
|
16
|
+
import { WidgetContext } from '../Wallets';
|
|
17
|
+
|
|
18
|
+
import { MainContainer } from './App.styles';
|
|
19
|
+
|
|
20
|
+
export function Main() {
|
|
21
|
+
globalFont();
|
|
22
|
+
|
|
23
|
+
const { fetch: fetchMeta, config } = useAppStore();
|
|
24
|
+
const { activeTheme } = useTheme(config?.theme || {});
|
|
25
|
+
const { activeLanguage, changeLanguage } = useLanguage();
|
|
26
|
+
const [lastConnectedWalletWithNetwork, setLastConnectedWalletWithNetwork] =
|
|
27
|
+
useState<string>('');
|
|
28
|
+
const [disconnectedWallet, setDisconnectedWallet] = useState<WalletType>();
|
|
29
|
+
const widgetContext = useContext(WidgetContext);
|
|
30
|
+
|
|
31
|
+
useMemo(() => {
|
|
32
|
+
if (config?.apiKey) {
|
|
33
|
+
initConfig({
|
|
34
|
+
API_KEY: config?.apiKey,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}, [config]);
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
void fetchMeta().catch();
|
|
40
|
+
void useSettingsStore.persist.rehydrate();
|
|
41
|
+
void useNotificationStore.persist.rehydrate();
|
|
42
|
+
widgetContext.onConnectWallet(setLastConnectedWalletWithNetwork);
|
|
43
|
+
}, []);
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (config?.language) {
|
|
46
|
+
changeLanguage(config.language);
|
|
47
|
+
}
|
|
48
|
+
}, [config?.language]);
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<I18nManager language={activeLanguage}>
|
|
52
|
+
<MainContainer id="swap-container" className={activeTheme()}>
|
|
53
|
+
<WidgetEvents />
|
|
54
|
+
<AppRouter
|
|
55
|
+
lastConnectedWallet={lastConnectedWalletWithNetwork}
|
|
56
|
+
disconnectedWallet={disconnectedWallet}
|
|
57
|
+
clearDisconnectedWallet={() => {
|
|
58
|
+
setDisconnectedWallet(undefined);
|
|
59
|
+
}}>
|
|
60
|
+
<AppRoutes />
|
|
61
|
+
</AppRouter>
|
|
62
|
+
</MainContainer>
|
|
63
|
+
</I18nManager>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Main } from './App';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { styled } from '@rango-dev/ui';
|
|
2
|
+
|
|
3
|
+
export const QuoteContainer = styled('div', {
|
|
4
|
+
width: '100%',
|
|
5
|
+
paddingTop: '$2',
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export const FooterStepAlarm = styled('div', {
|
|
9
|
+
paddingBottom: '$15',
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export const FooterAlert = styled('div', {
|
|
13
|
+
width: '100%',
|
|
14
|
+
display: 'flex',
|
|
15
|
+
});
|
|
@@ -0,0 +1,97 @@
|
|
|
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 {
|
|
9
|
+
TOKEN_AMOUNT_MAX_DECIMALS,
|
|
10
|
+
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
11
|
+
USD_VALUE_MAX_DECIMALS,
|
|
12
|
+
USD_VALUE_MIN_DECIMALS,
|
|
13
|
+
} from '../../constants/routing';
|
|
14
|
+
import { useQuoteStore } from '../../store/quote';
|
|
15
|
+
import { numberToString } from '../../utils/numbers';
|
|
16
|
+
|
|
17
|
+
import { QuoteContainer } from './QuoteInfo.styles';
|
|
18
|
+
|
|
19
|
+
export function QuoteInfo(props: PropTypes) {
|
|
20
|
+
const {
|
|
21
|
+
quote,
|
|
22
|
+
type,
|
|
23
|
+
loading,
|
|
24
|
+
error,
|
|
25
|
+
warning,
|
|
26
|
+
refetchQuote,
|
|
27
|
+
showWarningModal,
|
|
28
|
+
onOpenWarningModal,
|
|
29
|
+
onCloseWarningModal,
|
|
30
|
+
onConfirmWarningModal,
|
|
31
|
+
expanded = false,
|
|
32
|
+
} = props;
|
|
33
|
+
const { inputAmount, inputUsdValue, outputUsdValue, outputAmount } =
|
|
34
|
+
useQuoteStore();
|
|
35
|
+
|
|
36
|
+
const showQuote = quote && quote.result && !loading;
|
|
37
|
+
return (
|
|
38
|
+
<>
|
|
39
|
+
{loading && (
|
|
40
|
+
<QuoteContainer>
|
|
41
|
+
<QuoteSkeleton type={type} expanded={expanded} />
|
|
42
|
+
</QuoteContainer>
|
|
43
|
+
)}
|
|
44
|
+
{showQuote ? (
|
|
45
|
+
<QuoteContainer>
|
|
46
|
+
<Quote
|
|
47
|
+
quote={quote}
|
|
48
|
+
error={error}
|
|
49
|
+
warning={warning}
|
|
50
|
+
type={type}
|
|
51
|
+
expanded={expanded}
|
|
52
|
+
recommended={true}
|
|
53
|
+
input={{
|
|
54
|
+
value: numberToString(
|
|
55
|
+
inputAmount,
|
|
56
|
+
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
57
|
+
TOKEN_AMOUNT_MAX_DECIMALS
|
|
58
|
+
),
|
|
59
|
+
usdValue: numberToString(
|
|
60
|
+
inputUsdValue,
|
|
61
|
+
USD_VALUE_MIN_DECIMALS,
|
|
62
|
+
USD_VALUE_MAX_DECIMALS
|
|
63
|
+
),
|
|
64
|
+
}}
|
|
65
|
+
output={{
|
|
66
|
+
value: numberToString(
|
|
67
|
+
outputAmount,
|
|
68
|
+
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
69
|
+
TOKEN_AMOUNT_MAX_DECIMALS
|
|
70
|
+
),
|
|
71
|
+
usdValue: numberToString(
|
|
72
|
+
outputUsdValue,
|
|
73
|
+
USD_VALUE_MIN_DECIMALS,
|
|
74
|
+
USD_VALUE_MAX_DECIMALS
|
|
75
|
+
),
|
|
76
|
+
}}
|
|
77
|
+
/>
|
|
78
|
+
</QuoteContainer>
|
|
79
|
+
) : null}
|
|
80
|
+
|
|
81
|
+
{!warning && !error && <Divider size={16} />}
|
|
82
|
+
|
|
83
|
+
{(warning || error) && (
|
|
84
|
+
<QuoteWarningsAndErrors
|
|
85
|
+
warning={warning}
|
|
86
|
+
error={error}
|
|
87
|
+
loading={loading}
|
|
88
|
+
refetchQuote={refetchQuote}
|
|
89
|
+
showWarningModal={showWarningModal}
|
|
90
|
+
onOpenWarningModal={onOpenWarningModal}
|
|
91
|
+
onCloseWarningModal={onCloseWarningModal}
|
|
92
|
+
onConfirmWarningModal={onConfirmWarningModal}
|
|
93
|
+
/>
|
|
94
|
+
)}
|
|
95
|
+
</>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
expanded?: boolean;
|
|
12
|
+
refetchQuote: () => void;
|
|
13
|
+
showWarningModal: boolean;
|
|
14
|
+
onOpenWarningModal: () => void;
|
|
15
|
+
onCloseWarningModal: () => void;
|
|
16
|
+
onConfirmWarningModal: () => void;
|
|
17
|
+
};
|
|
@@ -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
|
+
}
|