@lifi/widget 1.32.7 → 2.0.0-alpha.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/App.js +3 -3
- package/AppDrawer.js +4 -3
- package/AppDrawer.style.d.ts +5 -5
- package/cjs/App.js +3 -3
- package/cjs/AppDrawer.js +4 -3
- package/cjs/AppDrawer.style.d.ts +5 -5
- package/cjs/components/ActiveSwaps/ActiveSwaps.style.d.ts +3 -3
- package/cjs/components/Card/CardIconButton.d.ts +29 -0
- package/cjs/components/Card/CardIconButton.js +17 -0
- package/cjs/components/Card/CardLabel.d.ts +26 -0
- package/cjs/components/Card/CardLabel.js +45 -0
- package/cjs/components/Card/CardTitle.d.ts +2 -2
- package/cjs/components/Card/index.d.ts +2 -0
- package/cjs/components/Card/index.js +2 -0
- package/cjs/components/GasMessage/FundsSufficiencyMessage.d.ts +1 -0
- package/cjs/components/GasMessage/FundsSufficiencyMessage.js +16 -0
- package/cjs/components/{GasSufficiencyMessage/GasSufficiencyMessage.d.ts → GasMessage/GasMessage.d.ts} +4 -2
- package/cjs/components/GasMessage/GasMessage.js +19 -0
- package/cjs/components/GasMessage/GasMessage.style.d.ts +34 -0
- package/cjs/components/GasMessage/GasMessage.style.js +48 -0
- package/cjs/components/GasMessage/GasRefuelMessage.d.ts +3 -0
- package/cjs/components/GasMessage/GasRefuelMessage.js +26 -0
- package/cjs/components/GasMessage/GasSufficiencyMessage.d.ts +7 -0
- package/cjs/components/GasMessage/GasSufficiencyMessage.js +21 -0
- package/cjs/components/GasMessage/index.d.ts +2 -0
- package/cjs/components/GasMessage/index.js +18 -0
- package/cjs/components/Header/Header.style.d.ts +5 -5
- package/cjs/components/Header/NavigationHeader.js +4 -4
- package/cjs/components/Header/WalletHeader.js +5 -5
- package/cjs/components/Insurance/Insurance.d.ts +3 -0
- package/cjs/components/Insurance/Insurance.js +11 -0
- package/cjs/components/Insurance/InsuranceCard.d.ts +3 -0
- package/cjs/components/Insurance/InsuranceCard.js +20 -0
- package/cjs/components/Insurance/InsuranceCollapsed.d.ts +3 -0
- package/cjs/components/Insurance/InsuranceCollapsed.js +32 -0
- package/cjs/components/Insurance/index.d.ts +1 -0
- package/cjs/components/{GasSufficiencyMessage → Insurance}/index.js +1 -1
- package/cjs/components/Insurance/types.d.ts +14 -0
- package/cjs/components/Insurance/types.js +2 -0
- package/cjs/components/NFT/NFT.style.d.ts +1 -1
- package/cjs/components/PoweredBy/PoweredBy.style.d.ts +1 -1
- package/cjs/components/ReverseTokensButton/ReverseTokensButton.style.d.ts +2 -2
- package/cjs/components/SendToWallet/SendToWallet.js +31 -25
- package/cjs/components/SendToWallet/SendToWallet.style.d.ts +2 -2
- package/cjs/components/SendToWallet/SendToWalletButton.js +3 -3
- package/cjs/components/SmallAvatar.d.ts +2 -2
- package/cjs/components/Step/CircularProgress.style.d.ts +1 -1
- package/cjs/components/Step/DestinationWalletAddress.js +2 -2
- package/cjs/components/Step/GasStepProcess.js +2 -2
- package/cjs/components/Step/Step.js +7 -5
- package/cjs/components/Step/StepList.d.ts +1 -1
- package/cjs/components/Step/StepProcess.style.d.ts +3 -3
- package/cjs/components/StepActions/StepActions.d.ts +5 -0
- package/cjs/components/StepActions/StepActions.js +55 -17
- package/cjs/components/StepActions/StepActions.style.d.ts +1 -1
- package/cjs/components/SwapButton/SwapButton.js +2 -2
- package/cjs/components/SwapButton/types.d.ts +1 -2
- package/cjs/components/SwapInput/SwapInput.style.d.ts +2 -2
- package/cjs/components/SwapInput/SwapInputAdornment.style.d.ts +3 -3
- package/cjs/components/SwapInput/SwapInputEndAdornment.js +18 -1
- package/cjs/components/SwapRouteCard/SwapRouteCard.d.ts +1 -2
- package/cjs/components/SwapRouteCard/SwapRouteCard.js +10 -26
- package/cjs/components/SwapRouteCard/SwapRouteCard.style.d.ts +4 -36
- package/cjs/components/SwapRouteCard/SwapRouteCard.style.js +7 -38
- package/cjs/components/SwapRouteCard/SwapRouteCardEssentials.d.ts +3 -0
- package/cjs/components/SwapRouteCard/SwapRouteCardEssentials.js +27 -0
- package/cjs/components/SwapRouteCard/SwapRouteCardSkeleton.js +5 -5
- package/cjs/components/SwapRouteCard/types.d.ts +2 -2
- package/cjs/components/SwapRouteCard/utils.d.ts +5 -0
- package/cjs/components/SwapRouteCard/utils.js +32 -2
- package/cjs/components/SwapRoutes/SwapRoutes.js +3 -12
- package/cjs/components/SwapRoutes/SwapRoutesExpanded.js +3 -5
- package/cjs/components/SwapRoutes/{SwapRoutes.style.d.ts → SwapRoutesExpanded.style.d.ts} +0 -9
- package/cjs/components/SwapRoutes/{SwapRoutes.style.js → SwapRoutesExpanded.style.js} +1 -12
- package/cjs/components/Switch.js +4 -4
- package/cjs/components/TextFitter/TextFitter.js +9 -3
- package/cjs/components/Token/Token.style.d.ts +2 -2
- package/cjs/config/theme.js +1 -1
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/hooks/index.d.ts +4 -0
- package/cjs/hooks/index.js +4 -0
- package/cjs/hooks/useChains.js +2 -2
- package/cjs/hooks/useFeaturedTokens.d.ts +1 -1
- package/cjs/hooks/useFeaturedTokens.js +2 -2
- package/cjs/hooks/useFundsSufficiency.d.ts +5 -0
- package/cjs/hooks/useFundsSufficiency.js +73 -0
- package/cjs/hooks/useGasRecommendation.d.ts +2 -0
- package/cjs/hooks/useGasRecommendation.js +23 -0
- package/cjs/hooks/useGasRefuel.d.ts +7 -0
- package/cjs/hooks/useGasRefuel.js +61 -0
- package/cjs/hooks/useGasSufficiency.d.ts +2 -3
- package/cjs/hooks/useGasSufficiency.js +6 -37
- package/cjs/hooks/useGetTokenBalancesWithRetry.d.ts +3 -0
- package/cjs/hooks/useGetTokenBalancesWithRetry.js +33 -0
- package/cjs/hooks/useSwapRoutes.d.ts +7 -2
- package/cjs/hooks/useSwapRoutes.js +31 -11
- package/cjs/hooks/useTokenAddressBalance.js +4 -2
- package/cjs/hooks/useTokenBalance.js +4 -22
- package/cjs/hooks/useTokenBalances.d.ts +1 -1
- package/cjs/hooks/useTokenSearch.js +2 -2
- package/cjs/hooks/useTokens.js +2 -3
- package/cjs/i18n/en.json +14 -7
- package/cjs/i18n/it.json +6 -2
- package/cjs/i18n/pt.json +234 -0
- package/cjs/i18n/uk.json +5 -1
- package/cjs/icons/InsuraceLogo.d.ts +2 -0
- package/cjs/icons/InsuraceLogo.js +11 -0
- package/cjs/icons/index.d.ts +1 -0
- package/cjs/icons/index.js +1 -0
- package/cjs/index.d.ts +0 -6
- package/cjs/index.js +1 -6
- package/cjs/pages/MainPage/MainGasMessage.d.ts +3 -0
- package/cjs/pages/MainPage/MainGasMessage.js +12 -0
- package/cjs/pages/MainPage/MainPage.js +3 -2
- package/cjs/pages/MainPage/MainSwapButton.js +1 -1
- package/cjs/pages/SettingsPage/ColorSchemeButtonGroup.js +2 -2
- package/cjs/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +2 -2
- package/cjs/pages/SettingsPage/ResetSettingsButton.js +3 -1
- package/cjs/pages/SettingsPage/RoutePrioritySelect.js +1 -1
- package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +4 -3
- package/cjs/pages/SwapPage/ExchangeRateBottomSheet.d.ts +1 -2
- package/cjs/pages/SwapPage/ExchangeRateBottomSheet.js +1 -14
- package/cjs/pages/SwapPage/StartSwapButton.d.ts +3 -2
- package/cjs/pages/SwapPage/StartSwapButton.js +14 -4
- package/cjs/pages/SwapPage/SwapPage.js +18 -7
- package/cjs/pages/SwapPage/types.d.ts +9 -0
- package/cjs/pages/SwapPage/types.js +2 -0
- package/cjs/pages/SwapRoutesPage/SwapRoutesPage.js +1 -1
- package/cjs/providers/SDKProvider/SDKProvider.d.ts +2 -2
- package/cjs/providers/SDKProvider/SDKProvider.js +2 -1
- package/cjs/providers/SwapFormProvider/FormUpdater.js +2 -3
- package/cjs/providers/WidgetProvider/WidgetProvider.js +17 -4
- package/cjs/providers/WidgetProvider/utils.d.ts +1 -1
- package/cjs/providers/WidgetProvider/utils.js +2 -4
- package/cjs/stores/StoreProvider.js +1 -1
- package/cjs/stores/routes/createRouteExecutionStore.js +3 -2
- package/cjs/stores/routes/index.d.ts +0 -1
- package/cjs/stores/routes/index.js +0 -1
- package/cjs/stores/routes/types.d.ts +1 -5
- package/cjs/stores/routes/useSetExecutableRoute.d.ts +1 -1
- package/cjs/stores/settings/types.d.ts +3 -2
- package/cjs/stores/settings/useSettingsStore.js +3 -1
- package/cjs/types/widget.d.ts +5 -10
- package/cjs/utils/format.js +4 -1
- package/components/ActiveSwaps/ActiveSwaps.style.d.ts +3 -3
- package/components/Card/CardIconButton.d.ts +29 -0
- package/components/Card/CardIconButton.js +14 -0
- package/components/Card/CardLabel.d.ts +26 -0
- package/components/Card/CardLabel.js +42 -0
- package/components/Card/CardTitle.d.ts +2 -2
- package/components/Card/index.d.ts +2 -0
- package/components/Card/index.js +2 -0
- package/components/GasMessage/FundsSufficiencyMessage.d.ts +1 -0
- package/components/GasMessage/FundsSufficiencyMessage.js +12 -0
- package/components/{GasSufficiencyMessage/GasSufficiencyMessage.d.ts → GasMessage/GasMessage.d.ts} +4 -2
- package/components/GasMessage/GasMessage.js +15 -0
- package/components/GasMessage/GasMessage.style.d.ts +34 -0
- package/components/GasMessage/GasMessage.style.js +45 -0
- package/components/GasMessage/GasRefuelMessage.d.ts +3 -0
- package/components/GasMessage/GasRefuelMessage.js +22 -0
- package/components/GasMessage/GasSufficiencyMessage.d.ts +7 -0
- package/components/GasMessage/GasSufficiencyMessage.js +17 -0
- package/components/GasMessage/index.d.ts +2 -0
- package/components/GasMessage/index.js +2 -0
- package/components/Header/Header.style.d.ts +5 -5
- package/components/Header/NavigationHeader.js +4 -4
- package/components/Header/WalletHeader.js +6 -6
- package/components/Insurance/Insurance.d.ts +3 -0
- package/components/Insurance/Insurance.js +7 -0
- package/components/Insurance/InsuranceCard.d.ts +3 -0
- package/components/Insurance/InsuranceCard.js +16 -0
- package/components/Insurance/InsuranceCollapsed.d.ts +3 -0
- package/components/Insurance/InsuranceCollapsed.js +28 -0
- package/components/Insurance/index.d.ts +1 -0
- package/components/Insurance/index.js +1 -0
- package/components/Insurance/types.d.ts +14 -0
- package/components/Insurance/types.js +1 -0
- package/components/NFT/NFT.style.d.ts +1 -1
- package/components/PoweredBy/PoweredBy.style.d.ts +1 -1
- package/components/ReverseTokensButton/ReverseTokensButton.style.d.ts +2 -2
- package/components/SendToWallet/SendToWallet.js +34 -28
- package/components/SendToWallet/SendToWallet.style.d.ts +2 -2
- package/components/SendToWallet/SendToWalletButton.js +4 -4
- package/components/SmallAvatar.d.ts +2 -2
- package/components/Step/CircularProgress.style.d.ts +1 -1
- package/components/Step/DestinationWalletAddress.js +2 -2
- package/components/Step/GasStepProcess.js +2 -2
- package/components/Step/Step.js +7 -5
- package/components/Step/StepList.d.ts +1 -1
- package/components/Step/StepProcess.style.d.ts +3 -3
- package/components/StepActions/StepActions.d.ts +5 -0
- package/components/StepActions/StepActions.js +52 -16
- package/components/StepActions/StepActions.style.d.ts +1 -1
- package/components/SwapButton/SwapButton.js +2 -2
- package/components/SwapButton/types.d.ts +1 -2
- package/components/SwapInput/SwapInput.style.d.ts +2 -2
- package/components/SwapInput/SwapInputAdornment.style.d.ts +3 -3
- package/components/SwapInput/SwapInputEndAdornment.js +19 -2
- package/components/SwapRouteCard/SwapRouteCard.d.ts +1 -2
- package/components/SwapRouteCard/SwapRouteCard.js +11 -26
- package/components/SwapRouteCard/SwapRouteCard.style.d.ts +4 -36
- package/components/SwapRouteCard/SwapRouteCard.style.js +7 -38
- package/components/SwapRouteCard/SwapRouteCardEssentials.d.ts +3 -0
- package/components/SwapRouteCard/SwapRouteCardEssentials.js +23 -0
- package/components/SwapRouteCard/SwapRouteCardSkeleton.js +5 -5
- package/components/SwapRouteCard/types.d.ts +2 -2
- package/components/SwapRouteCard/utils.d.ts +5 -0
- package/components/SwapRouteCard/utils.js +30 -1
- package/components/SwapRoutes/SwapRoutes.js +5 -14
- package/components/SwapRoutes/SwapRoutesExpanded.js +2 -4
- package/components/SwapRoutes/{SwapRoutes.style.d.ts → SwapRoutesExpanded.style.d.ts} +0 -9
- package/components/SwapRoutes/{SwapRoutes.style.js → SwapRoutesExpanded.style.js} +1 -12
- package/components/Switch.js +5 -5
- package/components/TextFitter/TextFitter.js +9 -3
- package/components/Token/Token.style.d.ts +2 -2
- package/config/theme.js +1 -1
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/index.d.ts +4 -0
- package/hooks/index.js +4 -0
- package/hooks/useChains.js +2 -2
- package/hooks/useFeaturedTokens.d.ts +1 -1
- package/hooks/useFeaturedTokens.js +2 -2
- package/hooks/useFundsSufficiency.d.ts +5 -0
- package/hooks/useFundsSufficiency.js +69 -0
- package/hooks/useGasRecommendation.d.ts +2 -0
- package/hooks/useGasRecommendation.js +19 -0
- package/hooks/useGasRefuel.d.ts +7 -0
- package/hooks/useGasRefuel.js +57 -0
- package/hooks/useGasSufficiency.d.ts +2 -3
- package/hooks/useGasSufficiency.js +7 -38
- package/hooks/useGetTokenBalancesWithRetry.d.ts +3 -0
- package/hooks/useGetTokenBalancesWithRetry.js +29 -0
- package/hooks/useSwapRoutes.d.ts +7 -2
- package/hooks/useSwapRoutes.js +32 -12
- package/hooks/useTokenAddressBalance.js +4 -2
- package/hooks/useTokenBalance.js +5 -23
- package/hooks/useTokenBalances.d.ts +1 -1
- package/hooks/useTokenSearch.js +2 -2
- package/hooks/useTokens.js +2 -3
- package/i18n/en.json +14 -7
- package/i18n/it.json +6 -2
- package/i18n/pt.json +234 -0
- package/i18n/uk.json +5 -1
- package/icons/InsuraceLogo.d.ts +2 -0
- package/icons/InsuraceLogo.js +7 -0
- package/icons/index.d.ts +1 -0
- package/icons/index.js +1 -0
- package/index.d.ts +0 -6
- package/index.js +0 -5
- package/package.json +12 -11
- package/pages/ActiveSwapsPage/ActiveSwapsPage.js +2 -2
- package/pages/MainPage/MainGasMessage.d.ts +3 -0
- package/pages/MainPage/MainGasMessage.js +8 -0
- package/pages/MainPage/MainPage.js +3 -2
- package/pages/MainPage/MainSwapButton.js +1 -1
- package/pages/SettingsPage/ColorSchemeButtonGroup.js +2 -2
- package/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +2 -2
- package/pages/SettingsPage/ResetSettingsButton.js +3 -1
- package/pages/SettingsPage/RoutePrioritySelect.js +1 -1
- package/pages/SwapDetailsPage/SwapDetailsPage.js +5 -4
- package/pages/SwapHistoryPage/SwapHistoryPage.js +2 -2
- package/pages/SwapPage/ExchangeRateBottomSheet.d.ts +1 -2
- package/pages/SwapPage/ExchangeRateBottomSheet.js +0 -12
- package/pages/SwapPage/StartSwapButton.d.ts +3 -2
- package/pages/SwapPage/StartSwapButton.js +13 -4
- package/pages/SwapPage/SwapPage.js +21 -10
- package/pages/SwapPage/types.d.ts +9 -0
- package/pages/SwapPage/types.js +1 -0
- package/pages/SwapRoutesPage/SwapRoutesPage.js +1 -1
- package/providers/SDKProvider/SDKProvider.d.ts +2 -2
- package/providers/SDKProvider/SDKProvider.js +3 -2
- package/providers/SwapFormProvider/FormUpdater.js +2 -3
- package/providers/WidgetProvider/WidgetProvider.js +17 -4
- package/providers/WidgetProvider/utils.d.ts +1 -1
- package/providers/WidgetProvider/utils.js +2 -4
- package/stores/StoreProvider.js +2 -2
- package/stores/routes/createRouteExecutionStore.js +3 -2
- package/stores/routes/index.d.ts +0 -1
- package/stores/routes/index.js +0 -1
- package/stores/routes/types.d.ts +1 -5
- package/stores/routes/useSetExecutableRoute.d.ts +1 -1
- package/stores/settings/types.d.ts +3 -2
- package/stores/settings/useSettingsStore.js +3 -1
- package/tsconfig.cjs.tsbuildinfo +1 -1
- package/types/widget.d.ts +5 -10
- package/utils/format.js +4 -1
- package/cjs/components/GasSufficiencyMessage/GasSufficiencyMessage.js +0 -31
- package/cjs/components/GasSufficiencyMessage/GasSufficiencyMessage.style.d.ts +0 -9
- package/cjs/components/GasSufficiencyMessage/GasSufficiencyMessage.style.js +0 -14
- package/cjs/components/GasSufficiencyMessage/index.d.ts +0 -1
- package/cjs/components/SwapRoutes/useSetRecommendedRoute.d.ts +0 -2
- package/cjs/components/SwapRoutes/useSetRecommendedRoute.js +0 -13
- package/cjs/config/env.d.ts +0 -3
- package/cjs/config/env.js +0 -6
- package/cjs/stores/routes/useRecommendedRouteStore.d.ts +0 -10
- package/cjs/stores/routes/useRecommendedRouteStore.js +0 -39
- package/components/GasSufficiencyMessage/GasSufficiencyMessage.js +0 -27
- package/components/GasSufficiencyMessage/GasSufficiencyMessage.style.d.ts +0 -9
- package/components/GasSufficiencyMessage/GasSufficiencyMessage.style.js +0 -11
- package/components/GasSufficiencyMessage/index.d.ts +0 -1
- package/components/GasSufficiencyMessage/index.js +0 -1
- package/components/SwapRoutes/useSetRecommendedRoute.d.ts +0 -2
- package/components/SwapRoutes/useSetRecommendedRoute.js +0 -9
- package/config/env.d.ts +0 -3
- package/config/env.js +0 -3
- package/stores/routes/useRecommendedRouteStore.d.ts +0 -10
- package/stores/routes/useRecommendedRouteStore.js +0 -32
|
@@ -1,26 +1,20 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import AccessTimeIcon from '@mui/icons-material/AccessTime';
|
|
3
|
-
import EvStationOutlinedIcon from '@mui/icons-material/EvStationOutlined';
|
|
4
2
|
import ExpandLessIcon from '@mui/icons-material/ExpandLess';
|
|
5
3
|
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
|
6
|
-
import
|
|
7
|
-
import { Box, Collapse
|
|
4
|
+
import VerifiedUserIcon from '@mui/icons-material/VerifiedUser';
|
|
5
|
+
import { Box, Collapse } from '@mui/material';
|
|
8
6
|
import { useState } from 'react';
|
|
9
7
|
import { useTranslation } from 'react-i18next';
|
|
10
8
|
import { useWidgetConfig } from '../../providers';
|
|
11
|
-
import { Card } from '../Card';
|
|
9
|
+
import { Card, CardIconButton, CardLabel, CardLabelTypography } from '../Card';
|
|
12
10
|
import { StepActions } from '../StepActions';
|
|
13
11
|
import { Token } from '../Token';
|
|
14
|
-
import {
|
|
15
|
-
import { getGasCostsBreakdown } from './utils';
|
|
12
|
+
import { SwapRouteCardEssentials } from './SwapRouteCardEssentials';
|
|
16
13
|
export const SwapRouteCard = ({ route, active, variant = 'default', expanded, ...other }) => {
|
|
17
14
|
const { t } = useTranslation();
|
|
18
|
-
const { variant: widgetVariant
|
|
19
|
-
const [cardExpanded, setCardExpanded] = useState(
|
|
20
|
-
const
|
|
21
|
-
const label = route.tags?.length
|
|
22
|
-
? t(`swap.tags.${route.tags[0]}`)
|
|
23
|
-
: alternativeTag;
|
|
15
|
+
const { variant: widgetVariant } = useWidgetConfig();
|
|
16
|
+
const [cardExpanded, setCardExpanded] = useState(expanded);
|
|
17
|
+
const insurable = route.insurance?.state === 'INSURABLE';
|
|
24
18
|
const handleExpand = (e) => {
|
|
25
19
|
e.stopPropagation();
|
|
26
20
|
setCardExpanded((expanded) => !expanded);
|
|
@@ -28,17 +22,8 @@ export const SwapRouteCard = ({ route, active, variant = 'default', expanded, ..
|
|
|
28
22
|
const token = widgetVariant === 'nft'
|
|
29
23
|
? { ...route.fromToken, amount: route.fromAmount }
|
|
30
24
|
: { ...route.toToken, amount: route.toAmount };
|
|
31
|
-
const cardContent = (_jsxs(Box, { flex: 1, children: [widgetVariant !== 'refuel' &&
|
|
32
|
-
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const { t } = useTranslation();
|
|
36
|
-
const executionTimeMinutes = Math.ceil(route.steps
|
|
37
|
-
.map((step) => step.estimate.executionDuration)
|
|
38
|
-
.reduce((duration, x) => duration + x, 0) / 60);
|
|
39
|
-
const gasCostUSD = parseFloat(route.gasCostUSD ?? '') || 0.01;
|
|
40
|
-
const gasCosts = getGasCostsBreakdown(route);
|
|
41
|
-
return (_jsxs(Box, { display: "flex", justifyContent: dense ? 'space-between' : 'flex-end', flex: 1, pl: dense ? 0 : 2, mt: dense ? 2 : 0, children: [_jsx(Tooltip, { title: _jsxs(Box, { component: "span", children: [t(`tooltip.estimatedNetworkFee`), gasCosts.map((gas) => (_jsxs(Typography, { fontSize: 11, children: [gas.amount?.toFixed(6), " ", gas.token.symbol, " (", t(`format.currency`, { value: gas.amountUSD }), ")"] }, `${gas.token.address}${gas.token.symbol}`)))] }), placement: "top", enterDelay: 400, arrow: true, children: _jsxs(Box, { display: "flex", alignItems: "center", mr: dense ? 0 : 2, children: [_jsx(Typography, { lineHeight: 0, mr: 0.5, color: "grey.500", children: _jsx(EvStationOutlinedIcon, { fontSize: dense ? 'medium' : 'small' }) }), _jsx(Typography, { fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1, children: t(`format.currency`, { value: gasCostUSD }) })] }) }), _jsx(Tooltip, { title: t(`tooltip.estimatedTime`), placement: "top", enterDelay: 400, arrow: true, children: _jsxs(Box, { display: "flex", alignItems: "center", mr: dense ? 0 : 2, children: [_jsx(Typography, { lineHeight: 0, mr: 0.5, color: "grey.500", children: _jsx(AccessTimeIcon, { fontSize: dense ? 'medium' : 'small' }) }), _jsx(Typography, { fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1, children: t('swap.estimatedTime', {
|
|
42
|
-
value: executionTimeMinutes,
|
|
43
|
-
}) })] }) }), !dense ? (_jsx(Tooltip, { title: t(`tooltip.numberOfSteps`), placement: "top", enterDelay: 400, arrow: true, children: _jsxs(Box, { display: "flex", alignItems: "center", children: [_jsx(Typography, { lineHeight: 0, mr: 0.5, color: "grey.500", children: _jsx(LayersOutlinedIcon, { fontSize: dense ? 'medium' : 'small' }) }), _jsx(Typography, { fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1, children: route.steps.length })] }) })) : null] }));
|
|
25
|
+
const cardContent = (_jsxs(Box, { flex: 1, children: [widgetVariant !== 'refuel' && (insurable || route.tags?.length) ? (_jsxs(Box, { display: "flex", alignItems: "center", mb: 2, children: [insurable ? (_jsxs(CardLabel, { type: route.tags?.length && !cardExpanded
|
|
26
|
+
? 'insurance-icon'
|
|
27
|
+
: 'insurance', children: [_jsx(VerifiedUserIcon, { fontSize: "inherit" }), cardExpanded || !route.tags?.length ? (_jsx(CardLabelTypography, { type: "icon", children: t(`swap.tags.insurable`) })) : null] })) : null, route.tags?.length ? (_jsx(CardLabel, { type: active ? 'active' : undefined, children: _jsx(CardLabelTypography, { children: t(`swap.tags.${route.tags[0].toLowerCase()}`) }) })) : null] })) : null, _jsxs(Box, { display: "flex", justifyContent: "space-between", alignItems: "start", children: [_jsx(Token, { token: token, step: !cardExpanded ? route.steps[0] : undefined }), !expanded ? (_jsx(CardIconButton, { onClick: handleExpand, size: "small", children: cardExpanded ? _jsx(ExpandLessIcon, {}) : _jsx(ExpandMoreIcon, {}) })) : null] }), _jsx(Collapse, { timeout: 225, in: cardExpanded, mountOnEnter: true, unmountOnExit: true, children: route.steps.map((step) => (_jsx(StepActions, { step: step, mt: 2 }, step.id))) }), _jsx(SwapRouteCardEssentials, { route: route })] }));
|
|
28
|
+
return widgetVariant === 'refuel' || variant === 'cardless' ? (cardContent) : (_jsx(Card, { variant: active ? 'selected' : 'default', selectionColor: "secondary", indented: true, ...other, children: cardContent }));
|
|
44
29
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const IconTypography: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
|
|
3
3
|
align?: "center" | "left" | "right" | "inherit" | "justify" | undefined;
|
|
4
4
|
children?: import("react").ReactNode;
|
|
5
5
|
classes?: Partial<import("@mui/material").TypographyClasses> | undefined;
|
|
@@ -7,40 +7,8 @@ export declare const Label: import("@emotion/styled").StyledComponent<import("@m
|
|
|
7
7
|
noWrap?: boolean | undefined;
|
|
8
8
|
paragraph?: boolean | undefined;
|
|
9
9
|
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
10
|
-
variant?: "
|
|
11
|
-
variantMapping?: Partial<Record<"
|
|
10
|
+
variant?: import("@mui/types").OverridableStringUnion<"inherit" | import("@mui/material").TypographyVariant, import("@mui/material").TypographyPropsVariantOverrides> | undefined;
|
|
11
|
+
variantMapping?: Partial<Record<import("@mui/types").OverridableStringUnion<"inherit" | import("@mui/material").TypographyVariant, import("@mui/material").TypographyPropsVariantOverrides>, string>> | undefined;
|
|
12
12
|
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
|
|
13
13
|
ref?: ((instance: HTMLSpanElement | null) => void) | import("react").RefObject<HTMLSpanElement> | null | undefined;
|
|
14
|
-
}, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "variant" | ("p" | "color" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint") | "align" | "gutterBottom" | "noWrap" | "paragraph" | "variantMapping"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme
|
|
15
|
-
active?: boolean | undefined;
|
|
16
|
-
}, {}, {}>;
|
|
17
|
-
export declare const IconButton: import("@emotion/styled").StyledComponent<{
|
|
18
|
-
children?: import("react").ReactNode;
|
|
19
|
-
classes?: Partial<import("@mui/material").IconButtonClasses> | undefined;
|
|
20
|
-
color?: "inherit" | "default" | "success" | "warning" | "error" | "primary" | "secondary" | "info" | undefined;
|
|
21
|
-
disabled?: boolean | undefined;
|
|
22
|
-
disableFocusRipple?: boolean | undefined;
|
|
23
|
-
edge?: false | "end" | "start" | undefined;
|
|
24
|
-
size?: "small" | "medium" | "large" | undefined;
|
|
25
|
-
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
26
|
-
} & Omit<{
|
|
27
|
-
action?: import("react").Ref<import("@mui/material").ButtonBaseActions> | undefined;
|
|
28
|
-
centerRipple?: boolean | undefined;
|
|
29
|
-
children?: import("react").ReactNode;
|
|
30
|
-
classes?: Partial<import("@mui/material").ButtonBaseClasses> | undefined;
|
|
31
|
-
disabled?: boolean | undefined;
|
|
32
|
-
disableRipple?: boolean | undefined;
|
|
33
|
-
disableTouchRipple?: boolean | undefined;
|
|
34
|
-
focusRipple?: boolean | undefined;
|
|
35
|
-
focusVisibleClassName?: string | undefined;
|
|
36
|
-
LinkComponent?: import("react").ElementType<any> | undefined;
|
|
37
|
-
onFocusVisible?: import("react").FocusEventHandler<any> | undefined;
|
|
38
|
-
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
39
|
-
tabIndex?: number | undefined;
|
|
40
|
-
TouchRippleProps?: Partial<import("@mui/material/ButtonBase/TouchRipple").TouchRippleProps> | undefined;
|
|
41
|
-
touchRippleRef?: import("react").Ref<import("@mui/material/ButtonBase/TouchRipple").TouchRippleActions> | undefined;
|
|
42
|
-
}, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
|
43
|
-
ref?: ((instance: HTMLButtonElement | null) => void) | import("react").RefObject<HTMLButtonElement> | null | undefined;
|
|
44
|
-
}, keyof import("@mui/material/OverridableComponent").CommonProps | "tabIndex" | "color" | "children" | "action" | "centerRipple" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "TouchRippleProps" | "touchRippleRef" | "disableFocusRipple" | "size" | "edge"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
|
|
45
|
-
active?: boolean | undefined;
|
|
46
|
-
}, {}, {}>;
|
|
14
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "variant" | ("p" | "color" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint") | "align" | "gutterBottom" | "noWrap" | "paragraph" | "variantMapping"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
@@ -1,40 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Typography } from '@mui/material';
|
|
2
2
|
import { alpha, styled } from '@mui/material/styles';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
borderColor: active
|
|
10
|
-
? theme.palette.secondary.main
|
|
11
|
-
: theme.palette.mode === 'light'
|
|
12
|
-
? theme.palette.grey[300]
|
|
13
|
-
: theme.palette.grey[800],
|
|
14
|
-
borderRadius: theme.shape.borderRadiusSecondary,
|
|
15
|
-
color: active
|
|
16
|
-
? getContrastTextColor(theme, theme.palette.secondary.main)
|
|
17
|
-
: theme.palette.text.secondary,
|
|
18
|
-
padding: theme.spacing(0.75),
|
|
19
|
-
fontSize: 12,
|
|
20
|
-
lineHeight: 1,
|
|
21
|
-
fontWeight: '600',
|
|
22
|
-
height: 24,
|
|
23
|
-
letterSpacing: '0.05rem',
|
|
24
|
-
textTransform: 'uppercase',
|
|
25
|
-
display: 'inline-flex',
|
|
26
|
-
userSelect: 'none',
|
|
3
|
+
export const IconTypography = styled(Typography)(({ theme }) => ({
|
|
4
|
+
color: theme.palette.mode === 'light'
|
|
5
|
+
? alpha(theme.palette.common.black, 0.24)
|
|
6
|
+
: alpha(theme.palette.common.white, 0.32),
|
|
7
|
+
lineHeight: 0,
|
|
8
|
+
marginRight: theme.spacing(0.5),
|
|
27
9
|
}));
|
|
28
|
-
export const IconButton = styled(MuiIconButton, {
|
|
29
|
-
shouldForwardProp: (prop) => prop !== 'active',
|
|
30
|
-
})(({ theme, active }) => {
|
|
31
|
-
const backgroundColor = theme.palette.mode === 'light'
|
|
32
|
-
? theme.palette.common.black
|
|
33
|
-
: theme.palette.common.white;
|
|
34
|
-
return {
|
|
35
|
-
backgroundColor: alpha(backgroundColor, 0.04),
|
|
36
|
-
'&:hover': {
|
|
37
|
-
backgroundColor: alpha(backgroundColor, 0.08),
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import AccessTimeIcon from '@mui/icons-material/AccessTimeFilled';
|
|
3
|
+
import EvStationIcon from '@mui/icons-material/EvStation';
|
|
4
|
+
import LayersIcon from '@mui/icons-material/Layers';
|
|
5
|
+
import MonetizationOnIcon from '@mui/icons-material/MonetizationOn';
|
|
6
|
+
import { Box, Tooltip, Typography } from '@mui/material';
|
|
7
|
+
import { useTranslation } from 'react-i18next';
|
|
8
|
+
import { IconTypography } from './SwapRouteCard.style';
|
|
9
|
+
import { getFeeCostsBreakdown, getGasCostsBreakdown } from './utils';
|
|
10
|
+
export const SwapRouteCardEssentials = ({ route, dense }) => {
|
|
11
|
+
const { t } = useTranslation();
|
|
12
|
+
const executionTimeMinutes = Math.ceil(route.steps
|
|
13
|
+
.map((step) => step.estimate.executionDuration)
|
|
14
|
+
.reduce((duration, x) => duration + x, 0) / 60);
|
|
15
|
+
const gasCostUSD = parseFloat(route.gasCostUSD ?? '') || 0.01;
|
|
16
|
+
const gasCosts = getGasCostsBreakdown(route);
|
|
17
|
+
const feeCosts = getFeeCostsBreakdown(route, false);
|
|
18
|
+
return (_jsxs(Box, { display: "flex", justifyContent: 'space-between', flex: 1, mt: 2, children: [_jsx(Tooltip, { title: _jsxs(Box, { component: "span", children: [t(`tooltip.estimatedNetworkFee`), gasCosts.map((gas, index) => (_jsxs(Typography, { fontSize: 11, children: [gas.amount?.toFixed(9), " ", gas.token.symbol, " (", t(`format.currency`, { value: gas.amountUSD }), ")"] }, `${gas.token.address}${index}`)))] }), placement: "top", enterDelay: 400, arrow: true, children: _jsxs(Box, { display: "flex", alignItems: "center", mr: dense ? 0 : 2, children: [_jsx(IconTypography, { children: _jsx(EvStationIcon, { fontSize: "small" }) }), _jsx(Typography, { fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1, children: t(`format.currency`, { value: gasCostUSD }) })] }) }), _jsx(Tooltip, { title: _jsxs(Box, { component: "span", children: [t(`tooltip.additionalProviderFee`), feeCosts.map((fee, index) => (_jsxs(Typography, { fontSize: 11, children: [fee.amount?.toFixed(9), " ", fee.token.symbol, " (", t(`format.currency`, { value: fee.amountUSD }), ")"] }, `${fee.token.address}${index}`)))] }), placement: "top", enterDelay: 400, arrow: true, children: _jsxs(Box, { display: "flex", alignItems: "center", mr: dense ? 0 : 2, children: [_jsx(IconTypography, { children: _jsx(MonetizationOnIcon, { fontSize: "small" }) }), _jsx(Typography, { fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1, children: t(`format.currency`, {
|
|
19
|
+
value: feeCosts.reduce((sum, feeCost) => sum + feeCost.amountUSD, 0),
|
|
20
|
+
}) })] }) }), _jsx(Tooltip, { title: t(`tooltip.estimatedTime`), placement: "top", enterDelay: 400, arrow: true, children: _jsxs(Box, { display: "flex", alignItems: "center", mr: dense ? 0 : 2, children: [_jsx(IconTypography, { children: _jsx(AccessTimeIcon, { fontSize: "small" }) }), _jsx(Typography, { fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1, children: t('swap.estimatedTime', {
|
|
21
|
+
value: executionTimeMinutes,
|
|
22
|
+
}) })] }) }), _jsx(Tooltip, { title: t(`tooltip.numberOfSteps`), placement: "top", enterDelay: 400, arrow: true, children: _jsxs(Box, { display: "flex", alignItems: "center", children: [_jsx(IconTypography, { children: _jsx(LayersIcon, { fontSize: "small" }) }), _jsx(Typography, { fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1, children: route.steps.length })] }) })] }));
|
|
23
|
+
};
|
|
@@ -3,9 +3,9 @@ import { Box, Skeleton } from '@mui/material';
|
|
|
3
3
|
import { useWidgetConfig } from '../../providers';
|
|
4
4
|
import { Card } from '../Card';
|
|
5
5
|
export const SwapRouteCardSkeleton = ({ variant, ...other }) => {
|
|
6
|
-
const { variant: widgetVariant
|
|
7
|
-
const cardContent = (_jsxs(Box, { flex: 1, children: [widgetVariant !== 'refuel'
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return widgetVariant === 'refuel' ? (cardContent) : (_jsx(Card, { indented: true, ...other, children: cardContent }));
|
|
6
|
+
const { variant: widgetVariant } = useWidgetConfig();
|
|
7
|
+
const cardContent = (_jsxs(Box, { flex: 1, children: [widgetVariant !== 'refuel' ? (_jsx(Box, { display: "flex", alignItems: "center", mb: 2, children: _jsx(Skeleton, { variant: "rectangular", width: 112, height: 24, sx: (theme) => ({
|
|
8
|
+
borderRadius: `${theme.shape.borderRadius}px`,
|
|
9
|
+
}) }) })) : null, _jsxs(Box, { children: [_jsxs(Box, { display: "flex", alignItems: "center", children: [_jsx(Box, { mr: 2, children: _jsx(Skeleton, { variant: "circular", width: 32, height: 32 }) }), _jsx(Skeleton, { variant: "text", width: 96, height: 32 })] }), _jsxs(Box, { ml: 6, display: "flex", alignItems: "center", children: [_jsx(Skeleton, { variant: "text", width: 102, height: 16 }), _jsx(Skeleton, { variant: "text", width: 72, height: 16, sx: { marginLeft: 1 } })] })] }), _jsxs(Box, { mt: 2, display: "flex", justifyContent: "space-between", children: [_jsx(Skeleton, { variant: "text", width: 64, height: 20 }), _jsx(Skeleton, { variant: "text", width: 64, height: 20 }), _jsx(Skeleton, { variant: "text", width: 48, height: 20 }), _jsx(Skeleton, { variant: "text", width: 32, height: 20 })] })] }));
|
|
10
|
+
return widgetVariant === 'refuel' || variant === 'cardless' ? (cardContent) : (_jsx(Card, { indented: true, ...other, children: cardContent }));
|
|
11
11
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Route } from '@lifi/sdk';
|
|
2
2
|
export interface SwapRouteCardProps {
|
|
3
3
|
route: Route;
|
|
4
|
-
variant?: 'default' | '
|
|
4
|
+
variant?: 'default' | 'cardless';
|
|
5
5
|
active?: boolean;
|
|
6
6
|
expanded?: boolean;
|
|
7
7
|
}
|
|
@@ -10,5 +10,5 @@ export interface SwapRouteCardEssentialsProps {
|
|
|
10
10
|
dense?: boolean;
|
|
11
11
|
}
|
|
12
12
|
export interface SwapRouteCardSkeletonProps {
|
|
13
|
-
variant?: 'default' | '
|
|
13
|
+
variant?: 'default' | 'cardless';
|
|
14
14
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Big from 'big.js';
|
|
2
2
|
export const getGasCostsBreakdown = (route) => {
|
|
3
3
|
return Object.values(route.steps.reduce((groupedGasCosts, step) => {
|
|
4
|
-
if (step.estimate.gasCosts) {
|
|
4
|
+
if (step.estimate.gasCosts?.length) {
|
|
5
5
|
const { token } = step.estimate.gasCosts[0];
|
|
6
6
|
const gasCostAmount = step.estimate.gasCosts
|
|
7
7
|
.reduce((amount, gasCost) => amount.plus(Big(gasCost.amount || 0)), Big(0))
|
|
@@ -24,3 +24,32 @@ export const getGasCostsBreakdown = (route) => {
|
|
|
24
24
|
return groupedGasCosts;
|
|
25
25
|
}, {}));
|
|
26
26
|
};
|
|
27
|
+
export const getFeeCostsBreakdown = (route, included) => {
|
|
28
|
+
return Object.values(route.steps.reduce((groupedFeeCosts, step) => {
|
|
29
|
+
let feeCosts = step.estimate.feeCosts;
|
|
30
|
+
if (typeof included === 'boolean') {
|
|
31
|
+
feeCosts = feeCosts?.filter((feeCost) => feeCost.included === included);
|
|
32
|
+
}
|
|
33
|
+
if (feeCosts?.length) {
|
|
34
|
+
const { token } = feeCosts[0];
|
|
35
|
+
const feeCostAmount = feeCosts
|
|
36
|
+
.reduce((amount, feeCost) => amount.plus(Big(feeCost.amount || 0)), Big(0))
|
|
37
|
+
.div(10 ** token.decimals);
|
|
38
|
+
const feeCostAmountUSD = feeCosts.reduce((amount, feeCost) => amount + parseFloat(feeCost.amountUSD || '0'), 0);
|
|
39
|
+
const groupedFeeCost = groupedFeeCosts[token.chainId];
|
|
40
|
+
const amount = groupedFeeCost
|
|
41
|
+
? groupedFeeCost.amount.plus(feeCostAmount)
|
|
42
|
+
: feeCostAmount;
|
|
43
|
+
const amountUSD = groupedFeeCost
|
|
44
|
+
? groupedFeeCost.amountUSD + feeCostAmountUSD
|
|
45
|
+
: feeCostAmountUSD;
|
|
46
|
+
groupedFeeCosts[token.chainId] = {
|
|
47
|
+
amount,
|
|
48
|
+
amountUSD,
|
|
49
|
+
token,
|
|
50
|
+
};
|
|
51
|
+
return groupedFeeCosts;
|
|
52
|
+
}
|
|
53
|
+
return groupedFeeCosts;
|
|
54
|
+
}, {}));
|
|
55
|
+
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { jsx as _jsx,
|
|
2
|
-
import
|
|
3
|
-
import { Box, IconButton } from '@mui/material';
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Button, Collapse } from '@mui/material';
|
|
4
3
|
import { useFormState } from 'react-hook-form';
|
|
5
4
|
import { useTranslation } from 'react-i18next';
|
|
6
5
|
import { useNavigate } from 'react-router-dom';
|
|
@@ -10,16 +9,13 @@ import { SwapRouteCard, SwapRouteCardSkeleton, SwapRouteNotFoundCard, } from '..
|
|
|
10
9
|
import { useSwapRoutes } from '../../hooks';
|
|
11
10
|
import { useWidgetConfig } from '../../providers';
|
|
12
11
|
import { navigationRoutes } from '../../utils';
|
|
13
|
-
import { Stack } from './SwapRoutes.style';
|
|
14
|
-
import { useSetRecommendedRoute } from './useSetRecommendedRoute';
|
|
15
12
|
export const SwapRoutes = (props) => {
|
|
16
13
|
const { t } = useTranslation();
|
|
17
|
-
const { variant, useRecommendedRoute } = useWidgetConfig();
|
|
18
14
|
const navigate = useNavigate();
|
|
15
|
+
const { variant, useRecommendedRoute } = useWidgetConfig();
|
|
19
16
|
const { isValid, isValidating } = useFormState();
|
|
20
17
|
const { routes, isLoading, isFetching, isFetched, dataUpdatedAt, refetchTime, refetch, } = useSwapRoutes();
|
|
21
18
|
const currentRoute = routes?.[0];
|
|
22
|
-
useSetRecommendedRoute(currentRoute, isFetching);
|
|
23
19
|
if (!currentRoute && !isLoading && !isFetching && !isFetched) {
|
|
24
20
|
return null;
|
|
25
21
|
}
|
|
@@ -28,15 +24,10 @@ export const SwapRoutes = (props) => {
|
|
|
28
24
|
};
|
|
29
25
|
const routeNotFound = !currentRoute && !isLoading && !isFetching;
|
|
30
26
|
const onlyRecommendedRoute = variant === 'refuel' || useRecommendedRoute;
|
|
27
|
+
const showAll = !onlyRecommendedRoute && !routeNotFound && (routes?.length ?? 0) > 1;
|
|
31
28
|
return (_jsxs(Card, { ...props, children: [_jsx(CardTitle, { children: t('swap.routes') }), _jsx(ProgressToNextUpdate, { updatedAt: dataUpdatedAt || new Date().getTime(), timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: {
|
|
32
29
|
position: 'absolute',
|
|
33
30
|
top: 8,
|
|
34
31
|
right: 8,
|
|
35
|
-
} }), _jsxs(Box, {
|
|
36
|
-
borderRightWidth: !onlyRecommendedRoute &&
|
|
37
|
-
!routeNotFound &&
|
|
38
|
-
(isFetching || (routes && routes.length > 1))
|
|
39
|
-
? 1
|
|
40
|
-
: 0,
|
|
41
|
-
}, children: isLoading ? (_jsxs(_Fragment, { children: [_jsx(SwapRouteCardSkeleton, { minWidth: !onlyRecommendedRoute ? '80%' : '100%', variant: "dense" }), !onlyRecommendedRoute ? (_jsx(SwapRouteCardSkeleton, { minWidth: "80%", variant: "dense" })) : null] })) : !currentRoute ? (_jsx(SwapRouteNotFoundCard, {})) : (_jsxs(_Fragment, { children: [_jsx(SwapRouteCard, { minWidth: !onlyRecommendedRoute && routes.length > 1 ? '80%' : '100%', route: currentRoute, variant: "dense", active: true }), !onlyRecommendedRoute && routes.length > 1 ? (_jsx(SwapRouteCard, { minWidth: "80%", route: routes[1], variant: "dense", pointerEvents: "none" })) : null] })) }), _jsx(Box, { sx: { display: 'flex', alignItems: 'center' }, children: !onlyRecommendedRoute && !routeNotFound ? (_jsx(Box, { py: 1, pr: 1, children: _jsx(IconButton, { onClick: handleCardClick, size: "medium", disabled: isValidating || !isValid, children: _jsx(KeyboardArrowRightIcon, {}) }) })) : null })] })] }));
|
|
32
|
+
} }), _jsxs(Box, { p: 2, children: [isLoading ? (_jsx(SwapRouteCardSkeleton, { variant: "cardless" })) : !currentRoute ? (_jsx(SwapRouteNotFoundCard, {})) : (_jsx(SwapRouteCard, { route: currentRoute, variant: "cardless", active: true })), _jsx(Collapse, { timeout: 225, in: showAll, unmountOnExit: true, mountOnEnter: true, appear: true, children: _jsx(Box, { mt: 2, children: _jsx(Button, { onClick: handleCardClick, disabled: isValidating || !isValid, fullWidth: true, children: t('button.showAll') }) }) })] })] }));
|
|
42
33
|
};
|
|
@@ -9,8 +9,7 @@ import { useSetExecutableRoute } from '../../stores';
|
|
|
9
9
|
import { navigationRoutes } from '../../utils';
|
|
10
10
|
import { ProgressToNextUpdate } from '../ProgressToNextUpdate';
|
|
11
11
|
import { SwapRouteCard, SwapRouteCardSkeleton, SwapRouteNotFoundCard, } from '../SwapRouteCard';
|
|
12
|
-
import { CollapseContainer, Container, Header, ScrollableContainer, } from './
|
|
13
|
-
import { useSetRecommendedRoute } from './useSetRecommendedRoute';
|
|
12
|
+
import { CollapseContainer, Container, Header, ScrollableContainer, } from './SwapRoutesExpanded.style';
|
|
14
13
|
const timeout = { enter: 225, exit: 225, appear: 0 };
|
|
15
14
|
export const SwapRoutesExpanded = () => {
|
|
16
15
|
const element = useRoutes([
|
|
@@ -29,7 +28,6 @@ export const SwapRoutesExpandedElement = () => {
|
|
|
29
28
|
const { isValid, isValidating } = useFormState();
|
|
30
29
|
const { routes, isLoading, isFetching, isFetched, dataUpdatedAt, refetchTime, refetch, } = useSwapRoutes();
|
|
31
30
|
const currentRoute = routes?.[0];
|
|
32
|
-
useSetRecommendedRoute(currentRoute, isFetching);
|
|
33
31
|
const handleRouteClick = (route) => {
|
|
34
32
|
if (isValid && !isValidating) {
|
|
35
33
|
setExecutableRoute(route);
|
|
@@ -40,5 +38,5 @@ export const SwapRoutesExpandedElement = () => {
|
|
|
40
38
|
};
|
|
41
39
|
const expanded = Boolean(currentRoute || isLoading || isFetching || isFetched);
|
|
42
40
|
const routeNotFound = !currentRoute && !isLoading && !isFetching && expanded;
|
|
43
|
-
return (_jsx(Collapse, { timeout: timeout.enter, in: expanded, orientation: "horizontal", children: _jsx(Grow, { timeout: timeout.enter, in: expanded, mountOnEnter: true, unmountOnExit: true, children: _jsx(Container, { sx: containerStyle, enableColorScheme: true, children: _jsxs(ScrollableContainer, { children: [_jsxs(Header, { children: [_jsx(Typography, { fontSize: 18, fontWeight: "700", flex: 1, noWrap: true, children: t('swap.routes') }), _jsx(ProgressToNextUpdate, { updatedAt: dataUpdatedAt || new Date().getTime(), timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: { marginRight: -1 } })] }), _jsx(Stack, { direction: "column", spacing: 2, flex: 1, paddingX: 3, paddingBottom: 3, children: routeNotFound ? (_jsx(SwapRouteNotFoundCard, {})) : isLoading ? (Array.from({ length: 3 }).map((_, index) => (_jsx(SwapRouteCardSkeleton, {
|
|
41
|
+
return (_jsx(Collapse, { timeout: timeout.enter, in: expanded, orientation: "horizontal", children: _jsx(Grow, { timeout: timeout.enter, in: expanded, mountOnEnter: true, unmountOnExit: true, children: _jsx(Container, { sx: containerStyle, enableColorScheme: true, children: _jsxs(ScrollableContainer, { children: [_jsxs(Header, { children: [_jsx(Typography, { fontSize: 18, fontWeight: "700", flex: 1, noWrap: true, children: t('swap.routes') }), _jsx(ProgressToNextUpdate, { updatedAt: dataUpdatedAt || new Date().getTime(), timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: { marginRight: -1 } })] }), _jsx(Stack, { direction: "column", spacing: 2, flex: 1, paddingX: 3, paddingBottom: 3, children: routeNotFound ? (_jsx(SwapRouteNotFoundCard, {})) : isLoading || (isFetching && !routes?.length) ? (Array.from({ length: 3 }).map((_, index) => (_jsx(SwapRouteCardSkeleton, {}, index)))) : (routes?.map((route, index) => (_jsx(SwapRouteCard, { route: route, onClick: () => handleRouteClick(route), active: index === 0, expanded: routes?.length <= 2 }, route.id)))) })] }) }) }) }));
|
|
44
42
|
};
|
|
@@ -31,12 +31,3 @@ export declare const Header: import("@emotion/styled").StyledComponent<import("@
|
|
|
31
31
|
} & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
32
32
|
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
33
33
|
}, "children" | "sx" | "ref" | ("p" | "color" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint") | "component"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
34
|
-
export declare const Stack: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
|
|
35
|
-
children?: import("react").ReactNode;
|
|
36
|
-
direction?: import("@mui/system").ResponsiveStyleValue<"column" | "column-reverse" | "row" | "row-reverse"> | undefined;
|
|
37
|
-
spacing?: import("@mui/system").ResponsiveStyleValue<string | number> | undefined;
|
|
38
|
-
divider?: import("react").ReactNode;
|
|
39
|
-
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
40
|
-
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
41
|
-
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
42
|
-
}, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "direction" | ("p" | "color" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint") | "divider" | "spacing"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Box, ScopedCssBaseline
|
|
1
|
+
import { Box, ScopedCssBaseline } from '@mui/material';
|
|
2
2
|
import { alpha, styled } from '@mui/material/styles';
|
|
3
3
|
import { maxHeight } from '../AppContainer';
|
|
4
4
|
export const CollapseContainer = styled(Box)(({ theme }) => ({
|
|
@@ -32,14 +32,3 @@ export const Header = styled(Box)(({ theme }) => ({
|
|
|
32
32
|
top: 0,
|
|
33
33
|
zIndex: 1200,
|
|
34
34
|
}));
|
|
35
|
-
export const Stack = styled(MuiStack)(({ theme }) => ({
|
|
36
|
-
alignItems: 'stretch',
|
|
37
|
-
display: 'flex',
|
|
38
|
-
flex: 1,
|
|
39
|
-
flexWrap: 'nowrap',
|
|
40
|
-
overflow: 'hidden',
|
|
41
|
-
borderRight: `solid ${theme.palette.mode === 'light'
|
|
42
|
-
? theme.palette.grey[300]
|
|
43
|
-
: theme.palette.grey[800]}`,
|
|
44
|
-
width: 'calc(100% - 48px)',
|
|
45
|
-
}));
|
package/components/Switch.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Switch as MuiSwitch } from '@mui/material';
|
|
2
|
-
import { styled } from '@mui/material/styles';
|
|
2
|
+
import { alpha, styled } from '@mui/material/styles';
|
|
3
3
|
import { switchClasses } from '@mui/material/Switch';
|
|
4
4
|
export const Switch = styled(MuiSwitch)(({ theme }) => ({
|
|
5
5
|
width: 42,
|
|
@@ -28,8 +28,8 @@ export const Switch = styled(MuiSwitch)(({ theme }) => ({
|
|
|
28
28
|
},
|
|
29
29
|
[`&.${switchClasses.disabled} .${switchClasses.thumb}`]: {
|
|
30
30
|
color: theme.palette.mode === 'light'
|
|
31
|
-
? theme.palette.
|
|
32
|
-
: theme.palette.
|
|
31
|
+
? alpha(theme.palette.common.black, 0.12)
|
|
32
|
+
: alpha(theme.palette.common.white, 0.12),
|
|
33
33
|
},
|
|
34
34
|
[`&.${switchClasses.disabled} + .${switchClasses.track}`]: {
|
|
35
35
|
opacity: theme.palette.mode === 'light' ? 0.7 : 0.3,
|
|
@@ -43,8 +43,8 @@ export const Switch = styled(MuiSwitch)(({ theme }) => ({
|
|
|
43
43
|
[`.${switchClasses.track}`]: {
|
|
44
44
|
borderRadius: 24 / 2,
|
|
45
45
|
backgroundColor: theme.palette.mode === 'light'
|
|
46
|
-
? theme.palette.
|
|
47
|
-
: theme.palette.
|
|
46
|
+
? alpha(theme.palette.common.black, 0.16)
|
|
47
|
+
: alpha(theme.palette.common.white, 0.16),
|
|
48
48
|
opacity: 1,
|
|
49
49
|
transition: theme.transitions.create(['background-color'], {
|
|
50
50
|
duration: theme.transitions.duration.standard,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useTheme } from '@mui/material/styles';
|
|
3
3
|
import { useCallback, useLayoutEffect, useRef, useState } from 'react';
|
|
4
|
+
import { useInView } from 'react-intersection-observer';
|
|
4
5
|
const initialState = {
|
|
5
6
|
x: 0,
|
|
6
7
|
y: 0,
|
|
@@ -11,7 +12,13 @@ export const TextFitter = ({ children, width = '100%', height, maxHeight, preser
|
|
|
11
12
|
const theme = useTheme();
|
|
12
13
|
const textRef = useRef(null);
|
|
13
14
|
const [viewBox, setViewBox] = useState(initialState);
|
|
14
|
-
|
|
15
|
+
const [ref] = useInView({
|
|
16
|
+
onChange(inView) {
|
|
17
|
+
if (inView) {
|
|
18
|
+
calculateBox();
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
});
|
|
15
22
|
const calculateBox = useCallback(() => {
|
|
16
23
|
if (!textRef.current) {
|
|
17
24
|
return;
|
|
@@ -25,7 +32,6 @@ export const TextFitter = ({ children, width = '100%', height, maxHeight, preser
|
|
|
25
32
|
box.height -= box.height * cropBottom;
|
|
26
33
|
}
|
|
27
34
|
setViewBox(box);
|
|
28
|
-
// setTextRect(textRef.current.getBoundingClientRect());
|
|
29
35
|
onFit?.();
|
|
30
36
|
}, [cropBottom, cropTop, onFit]);
|
|
31
37
|
useLayoutEffect(() => {
|
|
@@ -44,5 +50,5 @@ export const TextFitter = ({ children, width = '100%', height, maxHeight, preser
|
|
|
44
50
|
// ? maxHeight
|
|
45
51
|
// : height
|
|
46
52
|
// }
|
|
47
|
-
preserveAspectRatio: preserveAspectRatio, fill: theme.palette.text.primary, children: _jsx("text", { x: 0, y: 0, style: textStyle, ref: textRef, children: children }) }));
|
|
53
|
+
preserveAspectRatio: preserveAspectRatio, fill: theme.palette.text.primary, ref: ref, children: _jsx("text", { x: 0, y: 0, style: textStyle, ref: textRef, children: children }) }));
|
|
48
54
|
};
|
|
@@ -17,8 +17,8 @@ export declare const TextSecondary: import("@emotion/styled").StyledComponent<im
|
|
|
17
17
|
noWrap?: boolean | undefined;
|
|
18
18
|
paragraph?: boolean | undefined;
|
|
19
19
|
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
20
|
-
variant?: "
|
|
21
|
-
variantMapping?: Partial<Record<"
|
|
20
|
+
variant?: import("@mui/types").OverridableStringUnion<"inherit" | import("@mui/material").TypographyVariant, import("@mui/material").TypographyPropsVariantOverrides> | undefined;
|
|
21
|
+
variantMapping?: Partial<Record<import("@mui/types").OverridableStringUnion<"inherit" | import("@mui/material").TypographyVariant, import("@mui/material").TypographyPropsVariantOverrides>, string>> | undefined;
|
|
22
22
|
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
|
|
23
23
|
ref?: ((instance: HTMLSpanElement | null) => void) | import("react").RefObject<HTMLSpanElement> | null | undefined;
|
|
24
24
|
}, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "variant" | ("p" | "color" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint") | "align" | "gutterBottom" | "noWrap" | "paragraph" | "variantMapping"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
|
package/config/theme.js
CHANGED
package/config/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/widget";
|
|
2
|
-
export declare const version = "
|
|
2
|
+
export declare const version = "2.0.0-alpha.0";
|
package/config/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/widget';
|
|
2
|
-
export const version = '
|
|
2
|
+
export const version = '2.0.0-alpha.0';
|
package/hooks/index.d.ts
CHANGED
|
@@ -5,7 +5,11 @@ export * from './useDebouncedWatch';
|
|
|
5
5
|
export * from './useDefaultElementId';
|
|
6
6
|
export * from './useExpandableVariant';
|
|
7
7
|
export * from './useFeaturedTokens';
|
|
8
|
+
export * from './useFundsSufficiency';
|
|
9
|
+
export * from './useGasRecommendation';
|
|
10
|
+
export * from './useGasRefuel';
|
|
8
11
|
export * from './useGasSufficiency';
|
|
12
|
+
export * from './useGetTokenBalancesWithRetry';
|
|
9
13
|
export * from './useInitializer';
|
|
10
14
|
export * from './useNavigateBack';
|
|
11
15
|
export * from './useProcessMessage';
|
package/hooks/index.js
CHANGED
|
@@ -5,7 +5,11 @@ export * from './useDebouncedWatch';
|
|
|
5
5
|
export * from './useDefaultElementId';
|
|
6
6
|
export * from './useExpandableVariant';
|
|
7
7
|
export * from './useFeaturedTokens';
|
|
8
|
+
export * from './useFundsSufficiency';
|
|
9
|
+
export * from './useGasRecommendation';
|
|
10
|
+
export * from './useGasRefuel';
|
|
8
11
|
export * from './useGasSufficiency';
|
|
12
|
+
export * from './useGetTokenBalancesWithRetry';
|
|
9
13
|
export * from './useInitializer';
|
|
10
14
|
export * from './useNavigateBack';
|
|
11
15
|
export * from './useProcessMessage';
|
package/hooks/useChains.js
CHANGED
|
@@ -4,13 +4,13 @@ import { useFormContext } from 'react-hook-form';
|
|
|
4
4
|
import { isItemAllowed, SwapFormKey, useLiFi, useWidgetConfig, } from '../providers';
|
|
5
5
|
import { useChainOrderStore } from '../stores';
|
|
6
6
|
export const useChains = () => {
|
|
7
|
-
const {
|
|
7
|
+
const { chains } = useWidgetConfig();
|
|
8
8
|
const lifi = useLiFi();
|
|
9
9
|
const { getValues, setValue } = useFormContext();
|
|
10
10
|
const initializeChains = useChainOrderStore((state) => state.initializeChains);
|
|
11
11
|
const { data, isLoading } = useQuery(['chains'], async () => {
|
|
12
12
|
const availableChains = await lifi.getChains();
|
|
13
|
-
const filteredChains = availableChains.filter((chain) => isItemAllowed(chain.id, chains
|
|
13
|
+
const filteredChains = availableChains.filter((chain) => isItemAllowed(chain.id, chains));
|
|
14
14
|
const chainOrder = initializeChains(filteredChains.map((chain) => chain.id));
|
|
15
15
|
const [fromChainValue, toChainValue] = getValues([
|
|
16
16
|
SwapFormKey.FromChain,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useFeaturedTokens: (selectedChainId?: number) => import("@lifi/types").Token[];
|
|
1
|
+
export declare const useFeaturedTokens: (selectedChainId?: number) => import("@lifi/types").Token[] | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import { useWidgetConfig } from '../providers';
|
|
3
3
|
export const useFeaturedTokens = (selectedChainId) => {
|
|
4
|
-
const {
|
|
5
|
-
return useMemo(() =>
|
|
4
|
+
const { tokens } = useWidgetConfig();
|
|
5
|
+
return useMemo(() => tokens?.featured?.filter((token) => token.chainId === selectedChainId), [selectedChainId, tokens?.featured]);
|
|
6
6
|
};
|