@rango-dev/widget-embedded 0.12.1-next.9 → 0.13.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 +55 -0
- package/dist/Widget.d.ts.map +1 -1
- package/dist/components/AppRouter.d.ts +5 -2
- package/dist/components/AppRouter.d.ts.map +1 -1
- package/dist/components/AppRoutes.d.ts.map +1 -1
- package/dist/components/BlockchainList/BlockchainList.d.ts.map +1 -1
- package/dist/components/BlockchainList/BlockchainList.helpers.d.ts.map +1 -1
- package/dist/components/BlockchainList/BlockchainList.styles.d.ts +14 -4
- package/dist/components/BlockchainList/BlockchainList.styles.d.ts.map +1 -1
- package/dist/components/BlockchainsSection/BlockchainsSection.d.ts.map +1 -1
- package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts +6 -1
- package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +94 -17
- 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/WalletList.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/WalletList.styles.d.ts +18 -3
- package/dist/components/ConfirmWalletsModal/WalletList.styles.d.ts.map +1 -1
- package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts +25 -284
- package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts.map +1 -1
- package/dist/components/HeaderButtons/HeaderButtons.types.d.ts +1 -0
- package/dist/components/HeaderButtons/HeaderButtons.types.d.ts.map +1 -1
- package/dist/components/HeaderButtons/HomeButtons.d.ts.map +1 -1
- package/dist/components/HeaderButtons/UnreadNotificationsBadge.d.ts.map +1 -1
- package/dist/components/HeaderButtons/WalletButton.d.ts.map +1 -1
- package/dist/components/Layout/Layout.d.ts.map +1 -1
- package/dist/components/Layout/Layout.styles.d.ts +18 -3
- package/dist/components/Layout/Layout.styles.d.ts.map +1 -1
- package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.d.ts +6 -1
- package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.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 +3 -0
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.d.ts.map +1 -0
- package/dist/components/{SelectableCategoryList/SelectableCategoryList.styles.d.ts → LoadingSwapDetails/LoadingSwapDetails.styles.d.ts} +21 -6
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts.map +1 -0
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.types.d.ts +4 -0
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.types.d.ts.map +1 -0
- package/dist/components/LoadingSwapDetails/index.d.ts +2 -0
- package/dist/components/LoadingSwapDetails/index.d.ts.map +1 -0
- package/dist/components/NoRoutes/NoRoutes.helper.d.ts.map +1 -1
- package/dist/components/NoRoutes/NoRoutes.styles.d.ts +18 -3
- package/dist/components/NoRoutes/NoRoutes.styles.d.ts.map +1 -1
- package/dist/components/NotificationContent/NotificationContent.d.ts.map +1 -1
- package/dist/components/NotificationContent/NotificationContent.styles.d.ts +24 -4
- package/dist/components/NotificationContent/NotificationContent.styles.d.ts.map +1 -1
- package/dist/components/RouteErrors/RouteErrors.d.ts.map +1 -1
- package/dist/components/RouteErrors/RouteErrors.styles.d.ts +24 -4
- package/dist/components/RouteErrors/RouteErrors.styles.d.ts.map +1 -1
- package/dist/components/RouteErrors/RouteErrors.types.d.ts +3 -1
- package/dist/components/RouteErrors/RouteErrors.types.d.ts.map +1 -1
- package/dist/components/RouteErrors/RouteErrorsModal.d.ts.map +1 -1
- package/dist/components/SearchInput/SearchInput.styles.d.ts +6 -1
- package/dist/components/SearchInput/SearchInput.styles.d.ts.map +1 -1
- package/dist/components/SettingsContainer/SettingsContainer.style.d.ts +23 -151
- package/dist/components/SettingsContainer/SettingsContainer.style.d.ts.map +1 -1
- package/dist/components/SettingsContainer/index.d.ts +1 -1
- package/dist/components/SettingsContainer/index.d.ts.map +1 -1
- package/dist/components/Slippage/Slippage.d.ts.map +1 -1
- package/dist/components/Slippage/Slippage.styles.d.ts +24 -4
- 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 +2 -9
- package/dist/components/SwapDetails/SwapDetails.helpers.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.styles.d.ts +35 -153
- package/dist/components/SwapDetails/SwapDetails.styles.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.types.d.ts +1 -1
- package/dist/components/SwapDetails/SwapDetails.types.d.ts.map +1 -1
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.styles.d.ts +6 -1
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.styles.d.ts.map +1 -1
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.types.d.ts +2 -1
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.types.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.WalletState.d.ts +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.WalletState.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.styles.d.ts +6 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.styles.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts +2 -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 +24 -4
- package/dist/components/SwapsGroup/SwapsGroup.styles.d.ts.map +1 -1
- package/dist/components/SwitchFromAndTo.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.helpers.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.styles.d.ts +207 -9
- package/dist/components/TokenList/TokenList.styles.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.types.d.ts +1 -1
- package/dist/components/TokenList/TokenList.types.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/WalletModal/WalletModalContent.styles.d.ts +24 -4
- package/dist/components/WalletModal/WalletModalContent.styles.d.ts.map +1 -1
- package/dist/components/WidgetEvents.d.ts.map +1 -1
- package/dist/constants/errors.d.ts +2 -2
- package/dist/constants/routing.d.ts +12 -2
- package/dist/constants/routing.d.ts.map +1 -1
- package/dist/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/globalStyles.d.ts +1 -1
- package/dist/globalStyles.d.ts.map +1 -1
- package/dist/hooks/useNavigateBack.d.ts.map +1 -1
- package/dist/hooks/usePrepareBlockchainList.d.ts +18 -0
- package/dist/hooks/usePrepareBlockchainList.d.ts.map +1 -0
- package/dist/hooks/useSwapInput.d.ts.map +1 -1
- package/dist/hooks/useSyncStoresWithConfig.d.ts +3 -0
- package/dist/hooks/useSyncStoresWithConfig.d.ts.map +1 -0
- package/dist/hooks/useTheme.d.ts +3 -6
- package/dist/hooks/useTheme.d.ts.map +1 -1
- package/dist/hooks/useWalletProviders.d.ts +3 -3
- package/dist/hooks/useWalletProviders.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
- package/dist/pages/Home.d.ts.map +1 -1
- package/dist/pages/LiquiditySourcePage.d.ts.map +1 -1
- package/dist/pages/SelectBlockchainPage.d.ts +1 -2
- package/dist/pages/SelectBlockchainPage.d.ts.map +1 -1
- package/dist/pages/SelectSwapItemsPage.d.ts +1 -5
- package/dist/pages/SelectSwapItemsPage.d.ts.map +1 -1
- package/dist/pages/SettingsPage.d.ts.map +1 -1
- package/dist/pages/SwapDetailsPage.d.ts.map +1 -1
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/services/httpService.d.ts +0 -1
- package/dist/services/httpService.d.ts.map +1 -1
- package/dist/store/app.d.ts +26 -0
- package/dist/store/app.d.ts.map +1 -0
- package/dist/store/bestRoute.d.ts +4 -8
- package/dist/store/bestRoute.d.ts.map +1 -1
- package/dist/store/meta.d.ts +0 -2
- package/dist/store/meta.d.ts.map +1 -1
- package/dist/store/slices/config.d.ts +8 -0
- package/dist/store/slices/config.d.ts.map +1 -0
- package/dist/store/slices/data.d.ts +26 -0
- package/dist/store/slices/data.d.ts.map +1 -0
- package/dist/store/wallets.d.ts.map +1 -1
- package/dist/types/config.d.ts +3 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/utils/common.d.ts +1 -0
- package/dist/utils/common.d.ts.map +1 -1
- package/dist/utils/configs.d.ts +5 -0
- package/dist/utils/configs.d.ts.map +1 -1
- package/dist/utils/meta.d.ts +1 -0
- package/dist/utils/meta.d.ts.map +1 -1
- package/dist/utils/numbers.d.ts +3 -1
- package/dist/utils/numbers.d.ts.map +1 -1
- package/dist/utils/routing.d.ts +6 -3
- package/dist/utils/routing.d.ts.map +1 -1
- package/dist/utils/settings.d.ts +1 -0
- package/dist/utils/settings.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +1 -1
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/utils/time.d.ts +2 -2
- package/dist/utils/time.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +1 -1
- package/dist/utils/wallets.d.ts.map +1 -1
- package/package.json +8 -8
- package/readme.md +3 -1
- package/src/Widget.tsx +22 -3
- package/src/components/AppRouter.tsx +38 -7
- package/src/components/AppRoutes.tsx +4 -28
- package/src/components/BlockchainList/BlockchainList.helpers.ts +1 -1
- package/src/components/BlockchainList/BlockchainList.styles.ts +6 -5
- package/src/components/BlockchainList/BlockchainList.tsx +6 -9
- package/src/components/BlockchainsSection/BlockchainsSection.tsx +29 -42
- package/src/components/ConfirmWalletsModal/ConfirmWallets.helpers.ts +33 -7
- package/src/components/ConfirmWalletsModal/ConfirmWallets.styles.ts +48 -7
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +59 -16
- package/src/components/ConfirmWalletsModal/WalletList.tsx +66 -22
- package/src/components/HeaderButtons/HeaderButtons.styles.ts +2 -2
- package/src/components/HeaderButtons/HeaderButtons.types.ts +1 -0
- package/src/components/HeaderButtons/HomeButtons.tsx +18 -5
- package/src/components/HeaderButtons/UnreadNotificationsBadge.tsx +1 -2
- package/src/components/HeaderButtons/WalletButton.tsx +4 -1
- package/src/components/Layout/Layout.styles.ts +5 -3
- package/src/components/Layout/Layout.tsx +5 -20
- package/src/components/LoadingSwapDetails/LoadingSwapDetailStep.tsx +41 -0
- package/src/components/LoadingSwapDetails/LoadingSwapDetails.styles.ts +78 -0
- package/src/components/LoadingSwapDetails/LoadingSwapDetails.tsx +53 -0
- package/src/components/LoadingSwapDetails/LoadingSwapDetails.types.ts +3 -0
- package/src/components/LoadingSwapDetails/index.ts +1 -0
- package/src/components/NoRoutes/NoRoutes.helper.ts +4 -2
- package/src/components/NotificationContent/NotificationContent.tsx +3 -7
- package/src/components/RouteErrors/RouteErrors.styles.ts +2 -1
- package/src/components/RouteErrors/RouteErrors.tsx +37 -26
- package/src/components/RouteErrors/RouteErrors.types.ts +3 -1
- package/src/components/RouteErrors/RouteErrorsModal.tsx +42 -14
- package/src/components/SettingsContainer/SettingsContainer.style.ts +2 -7
- package/src/components/SettingsContainer/index.ts +0 -1
- package/src/components/Slippage/Slippage.tsx +6 -2
- package/src/components/Slippage/SlippageTooltipContent.tsx +1 -1
- package/src/components/SwapDetails/SwapDetails.Placeholder.tsx +52 -16
- package/src/components/SwapDetails/SwapDetails.helpers.tsx +19 -33
- package/src/components/SwapDetails/SwapDetails.styles.ts +10 -14
- package/src/components/SwapDetails/SwapDetails.tsx +143 -101
- package/src/components/SwapDetails/SwapDetails.types.ts +1 -1
- package/src/components/SwapDetailsAlerts/SwapDetailsAlerts.types.ts +5 -4
- package/src/components/SwapDetailsModal/SwapDetailsModal.WalletState.tsx +6 -7
- package/src/components/SwapDetailsModal/SwapDetailsModal.tsx +3 -0
- package/src/components/SwapDetailsModal/SwapDetailsModal.types.ts +2 -1
- package/src/components/SwapsGroup/SwapsGroup.tsx +3 -2
- package/src/components/SwitchFromAndTo.tsx +1 -35
- package/src/components/TokenList/TokenList.helpers.ts +6 -8
- package/src/components/TokenList/TokenList.styles.ts +7 -1
- package/src/components/TokenList/TokenList.tsx +29 -23
- package/src/components/TokenList/TokenList.types.ts +1 -1
- package/src/components/UpdateUrl.tsx +7 -1
- package/src/components/WidgetEvents.tsx +9 -3
- package/src/constants/errors.ts +2 -2
- package/src/constants/routing.ts +17 -2
- package/src/constants.ts +1 -0
- package/src/globalStyles.ts +1 -4
- package/src/hooks/useFetchBestRoute.ts +2 -2
- package/src/hooks/useNavigateBack.ts +10 -0
- package/src/hooks/usePrepareBlockchainList.ts +125 -0
- package/src/hooks/useSwapInput.ts +17 -3
- package/src/hooks/useSyncStoresWithConfig.ts +102 -0
- package/src/hooks/useTheme.ts +37 -75
- package/src/hooks/useWalletProviders.ts +7 -7
- package/src/pages/ConfirmSwapPage.tsx +65 -36
- package/src/pages/HistoryPage.tsx +2 -2
- package/src/pages/Home.tsx +114 -50
- package/src/pages/LanguagePage.tsx +1 -1
- package/src/pages/LiquiditySourcePage.tsx +22 -18
- package/src/pages/SelectBlockchainPage.tsx +19 -20
- package/src/pages/SelectSwapItemsPage.tsx +66 -88
- package/src/pages/SettingsPage.tsx +42 -15
- package/src/pages/SwapDetailsPage.tsx +9 -2
- package/src/pages/ThemePage.tsx +1 -1
- package/src/pages/WalletsPage.tsx +11 -5
- package/src/services/httpService.ts +4 -5
- package/src/store/app.ts +15 -0
- package/src/store/bestRoute.ts +45 -71
- package/src/store/meta.ts +11 -29
- package/src/store/slices/config.ts +26 -0
- package/src/store/slices/data.ts +203 -0
- package/src/store/wallets.ts +0 -27
- package/src/types/config.ts +3 -0
- package/src/utils/common.ts +3 -0
- package/src/utils/configs.ts +8 -2
- package/src/utils/meta.ts +7 -0
- package/src/utils/numbers.ts +3 -2
- package/src/utils/routing.ts +76 -14
- package/src/utils/settings.ts +15 -0
- package/src/utils/swap.ts +82 -26
- package/src/utils/time.ts +69 -36
- package/src/utils/wallets.ts +49 -29
- package/dist/components/BlockchainsChip/BlockchainsChip.d.ts +0 -5
- package/dist/components/BlockchainsChip/BlockchainsChip.d.ts.map +0 -1
- package/dist/components/BlockchainsChip/BlockchainsChip.styles.d.ts +0 -151
- package/dist/components/BlockchainsChip/BlockchainsChip.styles.d.ts.map +0 -1
- package/dist/components/BlockchainsChip/BlockchainsChip.types.d.ts +0 -6
- package/dist/components/BlockchainsChip/BlockchainsChip.types.d.ts.map +0 -1
- package/dist/components/BlockchainsChip/index.d.ts +0 -2
- package/dist/components/BlockchainsChip/index.d.ts.map +0 -1
- package/dist/components/BlockchainsSection/BlockchainSection.helpers.d.ts +0 -3
- package/dist/components/BlockchainsSection/BlockchainSection.helpers.d.ts.map +0 -1
- package/dist/components/SelectableCategoryList/SelectableCategoryList.d.ts +0 -4
- package/dist/components/SelectableCategoryList/SelectableCategoryList.d.ts.map +0 -1
- package/dist/components/SelectableCategoryList/SelectableCategoryList.helpers.d.ts +0 -4
- package/dist/components/SelectableCategoryList/SelectableCategoryList.helpers.d.ts.map +0 -1
- package/dist/components/SelectableCategoryList/SelectableCategoryList.styles.d.ts.map +0 -1
- package/dist/components/SelectableCategoryList/SelectableCategoryList.types.d.ts +0 -12
- package/dist/components/SelectableCategoryList/SelectableCategoryList.types.d.ts.map +0 -1
- package/dist/components/SelectableCategoryList/index.d.ts +0 -2
- package/dist/components/SelectableCategoryList/index.d.ts.map +0 -1
- package/src/components/BlockchainsChip/BlockchainsChip.styles.ts +0 -30
- package/src/components/BlockchainsChip/BlockchainsChip.tsx +0 -15
- package/src/components/BlockchainsChip/BlockchainsChip.types.ts +0 -4
- package/src/components/BlockchainsChip/index.ts +0 -1
- package/src/components/BlockchainsSection/BlockchainSection.helpers.ts +0 -20
- package/src/components/SelectableCategoryList/SelectableCategoryList.helpers.ts +0 -20
- package/src/components/SelectableCategoryList/SelectableCategoryList.styles.ts +0 -21
- package/src/components/SelectableCategoryList/SelectableCategoryList.tsx +0 -79
- package/src/components/SelectableCategoryList/SelectableCategoryList.types.ts +0 -12
- package/src/components/SelectableCategoryList/index.ts +0 -1
package/src/hooks/useTheme.ts
CHANGED
|
@@ -1,87 +1,53 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import type { WidgetTheme } from '../types';
|
|
2
|
+
|
|
3
|
+
import { createTheme, darkTheme, lightTheme } from '@rango-dev/ui';
|
|
4
|
+
import { useEffect, useState } from 'react';
|
|
5
|
+
|
|
3
6
|
import { useMetaStore } from '../store/meta';
|
|
4
7
|
import { useSettingsStore } from '../store/settings';
|
|
5
|
-
import {
|
|
6
|
-
|
|
8
|
+
import {
|
|
9
|
+
DEFAULT_PRIMARY_RADIUS,
|
|
10
|
+
DEFAULT_SECONDARY_RADIUS,
|
|
11
|
+
} from '../utils/configs';
|
|
7
12
|
|
|
8
13
|
export function useTheme({
|
|
9
14
|
// colors,
|
|
10
15
|
fontFamily = 'Roboto',
|
|
11
|
-
|
|
16
|
+
borderRadius = DEFAULT_PRIMARY_RADIUS,
|
|
17
|
+
secondaryBorderRadius = DEFAULT_SECONDARY_RADIUS,
|
|
12
18
|
mode = 'auto',
|
|
13
19
|
}: WidgetTheme) {
|
|
14
20
|
const theme = useSettingsStore.use.theme();
|
|
15
21
|
const fetchMeta = useMetaStore.use.fetchMeta();
|
|
16
22
|
const setTheme = useSettingsStore.use.setTheme();
|
|
17
|
-
// const light = themeColors?.light;
|
|
18
|
-
// const dark = themeColors?.dark;
|
|
19
|
-
// const neutral = light?.neutral || '#fafafa';
|
|
20
|
-
// const background = light?.background || '#fff';
|
|
21
|
-
// const foreground = light?.foreground || '#000';
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
// };
|
|
24
|
+
const customTheme = createTheme({
|
|
25
|
+
radii: {
|
|
26
|
+
primary: `${borderRadius}px`,
|
|
27
|
+
secondary: `${secondaryBorderRadius}px`,
|
|
28
|
+
},
|
|
29
|
+
fonts: {
|
|
30
|
+
widget: fontFamily,
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
// ...generateRangeColors('primary', 'light', light?.primary || '#5FA425'),
|
|
37
|
-
// ...generateRangeColors('error', 'light', light?.error || '#FF0000'),
|
|
38
|
-
// ...generateRangeColors('warning', 'light', light?.warning || '#F5A623'),
|
|
39
|
-
// ...generateRangeColors('success', 'light', light?.success || '#0070F3'),
|
|
40
|
-
// ...generateRangeColors('neutral', 'light', neutral),
|
|
41
|
-
// background,
|
|
42
|
-
// foreground,
|
|
43
|
-
// };
|
|
34
|
+
const lightClassName = `${customTheme.className} ${lightTheme.className}`;
|
|
35
|
+
const darkClassName = `${customTheme.className} ${darkTheme.className}`;
|
|
44
36
|
|
|
45
|
-
// const customLightTheme = createTheme({
|
|
46
|
-
// colors: lightColors,
|
|
47
|
-
// radii: {
|
|
48
|
-
// xs: `${borderRadius}px`,
|
|
49
|
-
// },
|
|
50
|
-
// shadows: {
|
|
51
|
-
// s: `0px 3px 5px 3px ${light?.neutral || '#f0f2f5'} ,0px 6px 10px 3px ${
|
|
52
|
-
// light?.neutral || '#f0f2f5'
|
|
53
|
-
// }, 0px 1px 18px 3px ${light?.neutral || '#f0f2f5'}`,
|
|
54
|
-
// },
|
|
55
|
-
// });
|
|
56
|
-
|
|
57
|
-
// const customDarkTheme = createTheme({
|
|
58
|
-
// colors: {
|
|
59
|
-
// ...lightColors,
|
|
60
|
-
// ...generateRangeColors('neutral', 'dark', '#111111'),
|
|
61
|
-
// foreground: background,
|
|
62
|
-
// background: foreground,
|
|
63
|
-
// surface: '#000',
|
|
64
|
-
// ...JSON.parse(JSON.stringify(darkColors)),
|
|
65
|
-
// },
|
|
66
|
-
// radii: {
|
|
67
|
-
// xs: `${borderRadius}px`,
|
|
68
|
-
// },
|
|
69
|
-
// shadows: {
|
|
70
|
-
// s: `0px 3px 5px 3px ${dark?.neutral || '#222'}, 0px 6px 10px 3px ${
|
|
71
|
-
// dark?.neutral || '#222'
|
|
72
|
-
// }, 0px 1px 18px 3px ${dark?.neutral || '#222'}`,
|
|
73
|
-
// },
|
|
74
|
-
// });
|
|
75
37
|
const [OSTheme, setOSTheme] = useState('light');
|
|
76
38
|
|
|
77
39
|
useEffect(() => {
|
|
78
|
-
|
|
40
|
+
const fetchData = async () => {
|
|
79
41
|
await fetchMeta();
|
|
80
|
-
}
|
|
42
|
+
};
|
|
43
|
+
void fetchData();
|
|
81
44
|
|
|
82
45
|
const switchTheme = (event: MediaQueryListEvent) => {
|
|
83
|
-
if (event.matches)
|
|
84
|
-
|
|
46
|
+
if (event.matches) {
|
|
47
|
+
setOSTheme('dark');
|
|
48
|
+
} else {
|
|
49
|
+
setOSTheme('light');
|
|
50
|
+
}
|
|
85
51
|
};
|
|
86
52
|
|
|
87
53
|
if (
|
|
@@ -101,20 +67,16 @@ export function useTheme({
|
|
|
101
67
|
};
|
|
102
68
|
}, []);
|
|
103
69
|
useEffect(() => {
|
|
104
|
-
if (mode !== 'auto')
|
|
70
|
+
if (mode !== 'auto') {
|
|
71
|
+
setTheme(mode);
|
|
72
|
+
}
|
|
105
73
|
}, [mode]);
|
|
106
|
-
const prevFont = usePrevious(fontFamily);
|
|
107
|
-
|
|
108
|
-
useLayoutEffect(() => {
|
|
109
|
-
const { classList } = document.body;
|
|
110
|
-
|
|
111
|
-
if (prevFont) classList.remove(`font_${prevFont.replace(/ /g, '')}`);
|
|
112
|
-
classList.add(`font_${fontFamily.replace(/ /g, '')}`);
|
|
113
|
-
}, [fontFamily]);
|
|
114
74
|
|
|
115
75
|
const getActiveTheme = () => {
|
|
116
|
-
if (theme === 'auto')
|
|
117
|
-
|
|
76
|
+
if (theme === 'auto') {
|
|
77
|
+
return OSTheme === 'dark' ? darkClassName : lightClassName;
|
|
78
|
+
}
|
|
79
|
+
return theme === 'dark' ? darkClassName : lightClassName;
|
|
118
80
|
};
|
|
119
81
|
|
|
120
82
|
return { activeTheme: getActiveTheme() };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { WidgetConfig } from '../types';
|
|
2
|
+
import type { ProvidersOptions } from '../utils/providers';
|
|
3
|
+
import type { ProviderInterface } from '@rango-dev/wallets-react';
|
|
4
|
+
|
|
2
5
|
import { useEffect } from 'react';
|
|
6
|
+
|
|
3
7
|
import { useWalletsStore } from '../store/wallets';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
matchAndGenerateProviders,
|
|
7
|
-
ProvidersOptions,
|
|
8
|
-
} from '../utils/providers';
|
|
8
|
+
import { matchAndGenerateProviders } from '../utils/providers';
|
|
9
9
|
|
|
10
10
|
export function useWalletProviders(
|
|
11
11
|
providers: WidgetConfig['wallets'],
|
|
@@ -22,7 +22,7 @@ export function useWalletProviders(
|
|
|
22
22
|
generateProviders = matchAndGenerateProviders(providers, {
|
|
23
23
|
walletConnectProjectId: options?.walletConnectProjectId,
|
|
24
24
|
});
|
|
25
|
-
}, [providers]);
|
|
25
|
+
}, [providers?.length]);
|
|
26
26
|
|
|
27
27
|
return {
|
|
28
28
|
providers: generateProviders,
|
|
@@ -4,7 +4,6 @@ import type {
|
|
|
4
4
|
ConfirmSwapFetchResult,
|
|
5
5
|
} from '../hooks/useConfirmSwap';
|
|
6
6
|
import type { WidgetConfig } from '../types';
|
|
7
|
-
import type { PriceImpactWarningLevel } from '@rango-dev/ui/dist/widget/ui/src/components/PriceImpact/PriceImpact.types';
|
|
8
7
|
|
|
9
8
|
import { i18n } from '@lingui/core';
|
|
10
9
|
import { useManager } from '@rango-dev/queue-manager-react';
|
|
@@ -38,7 +37,16 @@ import { Layout } from '../components/Layout';
|
|
|
38
37
|
import { NoRoutes } from '../components/NoRoutes';
|
|
39
38
|
import { getConfirmSwapErrorMessage } from '../constants/errors';
|
|
40
39
|
import { navigationRoutes } from '../constants/navigationRoutes';
|
|
41
|
-
import {
|
|
40
|
+
import {
|
|
41
|
+
GAS_FEE_MAX_DECIMALS,
|
|
42
|
+
GAS_FEE_MIN_DECIMALS,
|
|
43
|
+
PERCENTAGE_CHANGE_MAX_DECIMALS,
|
|
44
|
+
PERCENTAGE_CHANGE_MIN_DECIMALS,
|
|
45
|
+
TOKEN_AMOUNT_MAX_DECIMALS,
|
|
46
|
+
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
47
|
+
USD_VALUE_MAX_DECIMALS,
|
|
48
|
+
USD_VALUE_MIN_DECIMALS,
|
|
49
|
+
} from '../constants/routing';
|
|
42
50
|
import { getRouteWarningMessage } from '../constants/warnings';
|
|
43
51
|
import { useConfirmSwap } from '../hooks/useConfirmSwap';
|
|
44
52
|
import { useBestRouteStore } from '../store/bestRoute';
|
|
@@ -51,11 +59,13 @@ import {
|
|
|
51
59
|
RouteWarningType,
|
|
52
60
|
SlippageWarningType,
|
|
53
61
|
} from '../types';
|
|
62
|
+
import { getContainer } from '../utils/common';
|
|
54
63
|
import {
|
|
55
64
|
numberToString,
|
|
56
65
|
secondsToString,
|
|
57
66
|
totalArrivalTime,
|
|
58
67
|
} from '../utils/numbers';
|
|
68
|
+
import { getPriceImpactLevel } from '../utils/routing';
|
|
59
69
|
import { getPercentageChange, getTotalFeeInUsd } from '../utils/swap';
|
|
60
70
|
|
|
61
71
|
const Container = styled('div', {
|
|
@@ -117,7 +127,10 @@ export function ConfirmSwapPage(props: PropTypes) {
|
|
|
117
127
|
const showWalletsOnInit = !routeWalletsConfirmed;
|
|
118
128
|
const [showWallets, setShowWallets] = useState(false);
|
|
119
129
|
const setSelectedSwap = useUiStore.use.setSelectedSwap();
|
|
120
|
-
const {
|
|
130
|
+
const {
|
|
131
|
+
meta: { tokens, blockchains },
|
|
132
|
+
loadingStatus: loadingMetaStatus,
|
|
133
|
+
} = useMetaStore();
|
|
121
134
|
const slippage = useSettingsStore.use.slippage();
|
|
122
135
|
const customSlippage = useSettingsStore.use.customSlippage();
|
|
123
136
|
const { manager } = useManager();
|
|
@@ -133,6 +146,8 @@ export function ConfirmSwapPage(props: PropTypes) {
|
|
|
133
146
|
error: null,
|
|
134
147
|
warnings: null,
|
|
135
148
|
});
|
|
149
|
+
const showSkeleton =
|
|
150
|
+
fetchingConfirmationRoute || loadingMetaStatus === 'loading';
|
|
136
151
|
const showNoRouteFound =
|
|
137
152
|
!fetchingConfirmationRoute &&
|
|
138
153
|
confirmSwapResult.error &&
|
|
@@ -152,15 +167,11 @@ export function ConfirmSwapPage(props: PropTypes) {
|
|
|
152
167
|
inputUsdValue?.toNumber() ?? 0,
|
|
153
168
|
outputUsdValue?.toNumber() ?? 0
|
|
154
169
|
),
|
|
155
|
-
|
|
156
|
-
|
|
170
|
+
PERCENTAGE_CHANGE_MIN_DECIMALS,
|
|
171
|
+
PERCENTAGE_CHANGE_MAX_DECIMALS
|
|
157
172
|
);
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
warningLevel = 'high';
|
|
161
|
-
} else if (parseFloat(percentageChange) >= LOW_PRICE_IMPACT) {
|
|
162
|
-
warningLevel = 'low';
|
|
163
|
-
}
|
|
173
|
+
|
|
174
|
+
const warningLevel = getPriceImpactLevel(parseFloat(percentageChange));
|
|
164
175
|
|
|
165
176
|
const onConfirmSwap: ConfirmSwap['fetch'] = async ({
|
|
166
177
|
selectedWallets,
|
|
@@ -240,12 +251,6 @@ export function ConfirmSwapPage(props: PropTypes) {
|
|
|
240
251
|
}
|
|
241
252
|
}, []);
|
|
242
253
|
|
|
243
|
-
useEffect(() => {
|
|
244
|
-
if (!showWallets && !routeWalletsConfirmed) {
|
|
245
|
-
navigate(navigationRoutes.home, { replace: true });
|
|
246
|
-
}
|
|
247
|
-
}, [showWallets, routeWalletsConfirmed]);
|
|
248
|
-
|
|
249
254
|
useEffect(() => {
|
|
250
255
|
const routeChanged =
|
|
251
256
|
confirmSwapResult.warnings?.route?.type &&
|
|
@@ -309,11 +314,14 @@ export function ConfirmSwapPage(props: PropTypes) {
|
|
|
309
314
|
return (
|
|
310
315
|
<Layout
|
|
311
316
|
header={{
|
|
312
|
-
title: 'Confirm Swap',
|
|
317
|
+
title: i18n.t('Confirm Swap'),
|
|
313
318
|
onBack: navigate.bind(null, -1),
|
|
314
319
|
hasConnectWallet: true,
|
|
315
320
|
suffix: (
|
|
316
|
-
<Tooltip
|
|
321
|
+
<Tooltip
|
|
322
|
+
container={getContainer()}
|
|
323
|
+
side="bottom"
|
|
324
|
+
content={i18n.t('Settings')}>
|
|
317
325
|
<HeaderButton
|
|
318
326
|
size="small"
|
|
319
327
|
variant="ghost"
|
|
@@ -334,7 +342,7 @@ export function ConfirmSwapPage(props: PropTypes) {
|
|
|
334
342
|
loading={fetchingConfirmationRoute}
|
|
335
343
|
disabled={!!confirmSwapResult.error}
|
|
336
344
|
onClick={onStartConfirmSwap}>
|
|
337
|
-
Start Swap
|
|
345
|
+
{i18n.t('Start Swap')}
|
|
338
346
|
</Button>
|
|
339
347
|
</div>
|
|
340
348
|
<IconButton
|
|
@@ -356,7 +364,7 @@ export function ConfirmSwapPage(props: PropTypes) {
|
|
|
356
364
|
variant="ghost"
|
|
357
365
|
onClick={() => navigate('/' + navigationRoutes.settings)}>
|
|
358
366
|
<Typography variant="label" size="medium" color="$neutral900">
|
|
359
|
-
Change settings
|
|
367
|
+
{i18n.t('Change settings')}
|
|
360
368
|
</Typography>
|
|
361
369
|
</Button>
|
|
362
370
|
}
|
|
@@ -368,8 +376,8 @@ export function ConfirmSwapPage(props: PropTypes) {
|
|
|
368
376
|
title={
|
|
369
377
|
confirmSwapResult.warnings.slippage.type ===
|
|
370
378
|
SlippageWarningType.HIGH_SLIPPAGE
|
|
371
|
-
? 'High slippage'
|
|
372
|
-
: 'Low slippage'
|
|
379
|
+
? i18n.t('High slippage')
|
|
380
|
+
: i18n.t('Low slippage')
|
|
373
381
|
}
|
|
374
382
|
description={
|
|
375
383
|
confirmSwapResult.warnings.slippage.type ===
|
|
@@ -403,7 +411,7 @@ export function ConfirmSwapPage(props: PropTypes) {
|
|
|
403
411
|
variant="contained"
|
|
404
412
|
fullWidth
|
|
405
413
|
onClick={onConfirm}>
|
|
406
|
-
Confirm anyway
|
|
414
|
+
{i18n.t('Confirm anyway')}
|
|
407
415
|
</Button>
|
|
408
416
|
</MessageBox>
|
|
409
417
|
)}
|
|
@@ -411,7 +419,7 @@ export function ConfirmSwapPage(props: PropTypes) {
|
|
|
411
419
|
{showWallets && (
|
|
412
420
|
<ConfirmWalletsModal
|
|
413
421
|
open={showWallets}
|
|
414
|
-
onClose={setShowWallets
|
|
422
|
+
onClose={() => setShowWallets(false)}
|
|
415
423
|
onCancel={cancelFetch}
|
|
416
424
|
loading={fetchingConfirmationRoute}
|
|
417
425
|
onCheckBalance={onConfirmSwap}
|
|
@@ -422,7 +430,7 @@ export function ConfirmSwapPage(props: PropTypes) {
|
|
|
422
430
|
<Container>
|
|
423
431
|
<div className="description">
|
|
424
432
|
<Typography variant="title" size="small">
|
|
425
|
-
You get
|
|
433
|
+
{i18n.t('You get')}
|
|
426
434
|
</Typography>
|
|
427
435
|
<Button
|
|
428
436
|
style={{ padding: '0' }}
|
|
@@ -450,23 +458,44 @@ export function ConfirmSwapPage(props: PropTypes) {
|
|
|
450
458
|
<Divider size={12} />
|
|
451
459
|
</>
|
|
452
460
|
)}
|
|
453
|
-
{
|
|
454
|
-
<BestRouteSkeleton type="swap-preview" expanded />
|
|
455
|
-
)}
|
|
461
|
+
{showSkeleton && <BestRouteSkeleton type="swap-preview" expanded />}
|
|
456
462
|
{showBestRoute && (
|
|
457
463
|
<BestRoute
|
|
458
464
|
expanded={true}
|
|
459
|
-
|
|
465
|
+
tooltipContainer={getContainer()}
|
|
466
|
+
steps={formatBestRoute(bestRoute, blockchains) ?? []}
|
|
460
467
|
input={{
|
|
461
|
-
value: numberToString(
|
|
462
|
-
|
|
468
|
+
value: numberToString(
|
|
469
|
+
inputAmount,
|
|
470
|
+
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
471
|
+
TOKEN_AMOUNT_MAX_DECIMALS
|
|
472
|
+
),
|
|
473
|
+
usdValue: numberToString(
|
|
474
|
+
inputUsdValue,
|
|
475
|
+
USD_VALUE_MIN_DECIMALS,
|
|
476
|
+
USD_VALUE_MAX_DECIMALS
|
|
477
|
+
),
|
|
463
478
|
}}
|
|
464
479
|
output={{
|
|
465
|
-
value: numberToString(
|
|
466
|
-
|
|
480
|
+
value: numberToString(
|
|
481
|
+
outputAmount,
|
|
482
|
+
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
483
|
+
TOKEN_AMOUNT_MAX_DECIMALS
|
|
484
|
+
),
|
|
485
|
+
usdValue: numberToString(
|
|
486
|
+
outputUsdValue,
|
|
487
|
+
USD_VALUE_MIN_DECIMALS,
|
|
488
|
+
USD_VALUE_MAX_DECIMALS
|
|
489
|
+
),
|
|
467
490
|
}}
|
|
468
|
-
totalFee={numberToString(
|
|
469
|
-
|
|
491
|
+
totalFee={numberToString(
|
|
492
|
+
totalFeeInUsd,
|
|
493
|
+
GAS_FEE_MIN_DECIMALS,
|
|
494
|
+
GAS_FEE_MAX_DECIMALS
|
|
495
|
+
)}
|
|
496
|
+
totalTime={secondsToString(
|
|
497
|
+
totalArrivalTime(bestRoute.result?.swaps)
|
|
498
|
+
)}
|
|
470
499
|
recommended={true}
|
|
471
500
|
type="swap-preview"
|
|
472
501
|
percentageChange={percentageChange}
|
|
@@ -78,7 +78,7 @@ export function HistoryPage() {
|
|
|
78
78
|
return (
|
|
79
79
|
<Layout
|
|
80
80
|
header={{
|
|
81
|
-
onBack: navigateBackFrom.bind(null,
|
|
81
|
+
onBack: navigateBackFrom.bind(null, navigationRoutes.swaps),
|
|
82
82
|
title: i18n.t('History'),
|
|
83
83
|
}}>
|
|
84
84
|
<Container>
|
|
@@ -86,7 +86,7 @@ export function HistoryPage() {
|
|
|
86
86
|
setValue={setSearchedFor}
|
|
87
87
|
fullWidth
|
|
88
88
|
variant="contained"
|
|
89
|
-
placeholder=
|
|
89
|
+
placeholder={i18n.t('Search Transaction')}
|
|
90
90
|
autoFocus
|
|
91
91
|
onChange={searchHandler}
|
|
92
92
|
value={searchedFor}
|