@lifi/widget 1.32.8 → 2.0.0-alpha.1
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/AppProvider.js +4 -3
- package/cjs/App.js +3 -3
- package/cjs/AppDrawer.js +4 -3
- package/cjs/AppDrawer.style.d.ts +5 -5
- package/cjs/AppProvider.js +2 -1
- package/cjs/components/ActiveSwaps/ActiveSwaps.style.d.ts +5 -5
- 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 +6 -6
- 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/ListItemButton.d.ts +1 -1
- package/cjs/components/NFT/NFT.style.d.ts +1 -1
- package/cjs/components/PoweredBy/PoweredBy.style.d.ts +3 -12
- 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.d.ts +2 -2
- package/cjs/components/Step/DestinationWalletAddress.js +4 -8
- package/cjs/components/Step/GasStepProcess.d.ts +2 -2
- package/cjs/components/Step/GasStepProcess.js +3 -3
- package/cjs/components/Step/Step.d.ts +2 -2
- package/cjs/components/Step/Step.js +6 -8
- package/cjs/components/Step/StepList.d.ts +1 -1
- package/cjs/components/Step/StepProcess.d.ts +2 -2
- package/cjs/components/Step/StepProcess.js +1 -5
- package/cjs/components/Step/StepProcess.style.d.ts +3 -39
- package/cjs/components/Step/StepTimer.d.ts +2 -2
- package/cjs/components/Step/StepTimer.js +1 -1
- package/cjs/components/StepActions/StepActions.d.ts +6 -1
- package/cjs/components/StepActions/StepActions.js +54 -17
- package/cjs/components/StepActions/StepActions.style.d.ts +1 -1
- package/cjs/components/StepActions/types.d.ts +2 -2
- 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 +4 -11
- 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/Token/Token.d.ts +2 -2
- package/cjs/components/Token/Token.style.d.ts +2 -2
- package/cjs/components/TokenList/TokenList.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/useProcessMessage.d.ts +3 -3
- 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/SelectEnabledToolsPage/SelectEnabledToolsPage.style.d.ts +1 -1
- package/cjs/pages/SettingsPage/ColorSchemeButtonGroup.js +2 -2
- package/cjs/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +2 -2
- package/cjs/pages/SettingsPage/EnabledToolsButton.style.d.ts +1 -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/pages/SwapRoutesPage/SwapRoutesPage.style.d.ts +2 -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/SwapFormProvider/SwapFormProvider.js +2 -3
- package/cjs/providers/SwapFormProvider/index.d.ts +1 -0
- package/cjs/providers/SwapFormProvider/index.js +1 -0
- 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 +1 -0
- package/cjs/stores/settings/useSettingsStore.js +1 -0
- package/cjs/types/widget.d.ts +5 -10
- package/cjs/utils/format.js +4 -1
- package/components/ActiveSwaps/ActiveSwaps.style.d.ts +5 -5
- 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 +6 -6
- 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/ListItemButton.d.ts +1 -1
- package/components/NFT/NFT.style.d.ts +1 -1
- package/components/PoweredBy/PoweredBy.style.d.ts +3 -12
- 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.d.ts +2 -2
- package/components/Step/DestinationWalletAddress.js +4 -8
- package/components/Step/GasStepProcess.d.ts +2 -2
- package/components/Step/GasStepProcess.js +3 -3
- package/components/Step/Step.d.ts +2 -2
- package/components/Step/Step.js +6 -8
- package/components/Step/StepList.d.ts +1 -1
- package/components/Step/StepProcess.d.ts +2 -2
- package/components/Step/StepProcess.js +1 -5
- package/components/Step/StepProcess.style.d.ts +3 -39
- package/components/Step/StepTimer.d.ts +2 -2
- package/components/Step/StepTimer.js +1 -1
- package/components/StepActions/StepActions.d.ts +6 -1
- package/components/StepActions/StepActions.js +51 -16
- package/components/StepActions/StepActions.style.d.ts +1 -1
- package/components/StepActions/types.d.ts +2 -2
- 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 +4 -11
- 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/Token/Token.d.ts +2 -2
- package/components/Token/Token.style.d.ts +2 -2
- package/components/TokenList/TokenList.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/useProcessMessage.d.ts +3 -3
- 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 -12
- 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/SelectEnabledToolsPage/SelectEnabledToolsPage.style.d.ts +1 -1
- package/pages/SettingsPage/ColorSchemeButtonGroup.js +2 -2
- package/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +2 -2
- package/pages/SettingsPage/EnabledToolsButton.style.d.ts +1 -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/pages/SwapRoutesPage/SwapRoutesPage.style.d.ts +2 -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/SwapFormProvider/SwapFormProvider.js +2 -3
- package/providers/SwapFormProvider/index.d.ts +1 -0
- package/providers/SwapFormProvider/index.js +1 -0
- 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 +1 -0
- package/stores/settings/useSettingsStore.js +1 -0
- 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,43 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.IconTypography = void 0;
|
|
4
4
|
const material_1 = require("@mui/material");
|
|
5
5
|
const styles_1 = require("@mui/material/styles");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
borderColor: active
|
|
13
|
-
? theme.palette.secondary.main
|
|
14
|
-
: theme.palette.mode === 'light'
|
|
15
|
-
? theme.palette.grey[300]
|
|
16
|
-
: theme.palette.grey[800],
|
|
17
|
-
borderRadius: theme.shape.borderRadiusSecondary,
|
|
18
|
-
color: active
|
|
19
|
-
? (0, utils_1.getContrastTextColor)(theme, theme.palette.secondary.main)
|
|
20
|
-
: theme.palette.text.secondary,
|
|
21
|
-
padding: theme.spacing(0.75),
|
|
22
|
-
fontSize: 12,
|
|
23
|
-
lineHeight: 1,
|
|
24
|
-
fontWeight: '600',
|
|
25
|
-
height: 24,
|
|
26
|
-
letterSpacing: '0.05rem',
|
|
27
|
-
textTransform: 'uppercase',
|
|
28
|
-
display: 'inline-flex',
|
|
29
|
-
userSelect: 'none',
|
|
6
|
+
exports.IconTypography = (0, styles_1.styled)(material_1.Typography)(({ theme }) => ({
|
|
7
|
+
color: theme.palette.mode === 'light'
|
|
8
|
+
? (0, styles_1.alpha)(theme.palette.common.black, 0.24)
|
|
9
|
+
: (0, styles_1.alpha)(theme.palette.common.white, 0.32),
|
|
10
|
+
lineHeight: 0,
|
|
11
|
+
marginRight: theme.spacing(0.5),
|
|
30
12
|
}));
|
|
31
|
-
exports.IconButton = (0, styles_1.styled)(material_1.IconButton, {
|
|
32
|
-
shouldForwardProp: (prop) => prop !== 'active',
|
|
33
|
-
})(({ theme, active }) => {
|
|
34
|
-
const backgroundColor = theme.palette.mode === 'light'
|
|
35
|
-
? theme.palette.common.black
|
|
36
|
-
: theme.palette.common.white;
|
|
37
|
-
return {
|
|
38
|
-
backgroundColor: (0, styles_1.alpha)(backgroundColor, 0.04),
|
|
39
|
-
'&:hover': {
|
|
40
|
-
backgroundColor: (0, styles_1.alpha)(backgroundColor, 0.08),
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SwapRouteCardEssentials = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const AccessTimeFilled_1 = require("@mui/icons-material/AccessTimeFilled");
|
|
6
|
+
const EvStation_1 = require("@mui/icons-material/EvStation");
|
|
7
|
+
const Layers_1 = require("@mui/icons-material/Layers");
|
|
8
|
+
const MonetizationOn_1 = require("@mui/icons-material/MonetizationOn");
|
|
9
|
+
const material_1 = require("@mui/material");
|
|
10
|
+
const react_i18next_1 = require("react-i18next");
|
|
11
|
+
const SwapRouteCard_style_1 = require("./SwapRouteCard.style");
|
|
12
|
+
const utils_1 = require("./utils");
|
|
13
|
+
const SwapRouteCardEssentials = ({ route, dense }) => {
|
|
14
|
+
const { t } = (0, react_i18next_1.useTranslation)();
|
|
15
|
+
const executionTimeMinutes = Math.ceil(route.steps
|
|
16
|
+
.map((step) => step.estimate.executionDuration)
|
|
17
|
+
.reduce((duration, x) => duration + x, 0) / 60);
|
|
18
|
+
const gasCostUSD = parseFloat(route.gasCostUSD ?? '') || 0.01;
|
|
19
|
+
const gasCosts = (0, utils_1.getGasCostsBreakdown)(route);
|
|
20
|
+
const feeCosts = (0, utils_1.getFeeCostsBreakdown)(route, false);
|
|
21
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", justifyContent: 'space-between', flex: 1, mt: 2, children: [(0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: (0, jsx_runtime_1.jsxs)(material_1.Box, { component: "span", children: [t(`tooltip.estimatedNetworkFee`), gasCosts.map((gas, index) => ((0, jsx_runtime_1.jsxs)(material_1.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: (0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", alignItems: "center", mr: dense ? 0 : 2, children: [(0, jsx_runtime_1.jsx)(SwapRouteCard_style_1.IconTypography, { children: (0, jsx_runtime_1.jsx)(EvStation_1.default, { fontSize: "small" }) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1, children: t(`format.currency`, { value: gasCostUSD }) })] }) }), (0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: (0, jsx_runtime_1.jsxs)(material_1.Box, { component: "span", children: [t(`tooltip.additionalProviderFee`), feeCosts.map((fee, index) => ((0, jsx_runtime_1.jsxs)(material_1.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: (0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", alignItems: "center", mr: dense ? 0 : 2, children: [(0, jsx_runtime_1.jsx)(SwapRouteCard_style_1.IconTypography, { children: (0, jsx_runtime_1.jsx)(MonetizationOn_1.default, { fontSize: "small" }) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1, children: t(`format.currency`, {
|
|
22
|
+
value: feeCosts.reduce((sum, feeCost) => sum + feeCost.amountUSD, 0),
|
|
23
|
+
}) })] }) }), (0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: t(`tooltip.estimatedTime`), placement: "top", enterDelay: 400, arrow: true, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", alignItems: "center", mr: dense ? 0 : 2, children: [(0, jsx_runtime_1.jsx)(SwapRouteCard_style_1.IconTypography, { children: (0, jsx_runtime_1.jsx)(AccessTimeFilled_1.default, { fontSize: "small" }) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1, children: t('swap.estimatedTime', {
|
|
24
|
+
value: executionTimeMinutes,
|
|
25
|
+
}) })] }) }), (0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: t(`tooltip.numberOfSteps`), placement: "top", enterDelay: 400, arrow: true, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", alignItems: "center", children: [(0, jsx_runtime_1.jsx)(SwapRouteCard_style_1.IconTypography, { children: (0, jsx_runtime_1.jsx)(Layers_1.default, { fontSize: "small" }) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1, children: route.steps.length })] }) })] }));
|
|
26
|
+
};
|
|
27
|
+
exports.SwapRouteCardEssentials = SwapRouteCardEssentials;
|
|
@@ -6,10 +6,10 @@ const material_1 = require("@mui/material");
|
|
|
6
6
|
const providers_1 = require("../../providers");
|
|
7
7
|
const Card_1 = require("../Card");
|
|
8
8
|
const SwapRouteCardSkeleton = ({ variant, ...other }) => {
|
|
9
|
-
const { variant: widgetVariant
|
|
10
|
-
const cardContent = ((0, jsx_runtime_1.jsxs)(material_1.Box, { flex: 1, children: [widgetVariant !== 'refuel'
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return widgetVariant === 'refuel' ? (cardContent) : ((0, jsx_runtime_1.jsx)(Card_1.Card, { indented: true, ...other, children: cardContent }));
|
|
9
|
+
const { variant: widgetVariant } = (0, providers_1.useWidgetConfig)();
|
|
10
|
+
const cardContent = ((0, jsx_runtime_1.jsxs)(material_1.Box, { flex: 1, children: [widgetVariant !== 'refuel' ? ((0, jsx_runtime_1.jsx)(material_1.Box, { display: "flex", alignItems: "center", mb: 2, children: (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "rectangular", width: 112, height: 24, sx: (theme) => ({
|
|
11
|
+
borderRadius: `${theme.shape.borderRadius}px`,
|
|
12
|
+
}) }) })) : null, (0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", alignItems: "center", children: [(0, jsx_runtime_1.jsx)(material_1.Box, { mr: 2, children: (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "circular", width: 32, height: 32 }) }), (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", width: 96, height: 32 })] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { ml: 6, display: "flex", alignItems: "center", children: [(0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", width: 102, height: 16 }), (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", width: 72, height: 16, sx: { marginLeft: 1 } })] })] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { mt: 2, display: "flex", justifyContent: "space-between", children: [(0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", width: 64, height: 20 }), (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", width: 64, height: 20 }), (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", width: 48, height: 20 }), (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", width: 32, height: 20 })] })] }));
|
|
13
|
+
return widgetVariant === 'refuel' || variant === 'cardless' ? (cardContent) : ((0, jsx_runtime_1.jsx)(Card_1.Card, { indented: true, ...other, children: cardContent }));
|
|
14
14
|
};
|
|
15
15
|
exports.SwapRouteCardSkeleton = SwapRouteCardSkeleton;
|
|
@@ -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,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getGasCostsBreakdown = void 0;
|
|
3
|
+
exports.getFeeCostsBreakdown = exports.getGasCostsBreakdown = void 0;
|
|
4
4
|
const big_js_1 = require("big.js");
|
|
5
5
|
const getGasCostsBreakdown = (route) => {
|
|
6
6
|
return Object.values(route.steps.reduce((groupedGasCosts, step) => {
|
|
7
|
-
if (step.estimate.gasCosts) {
|
|
7
|
+
if (step.estimate.gasCosts?.length) {
|
|
8
8
|
const { token } = step.estimate.gasCosts[0];
|
|
9
9
|
const gasCostAmount = step.estimate.gasCosts
|
|
10
10
|
.reduce((amount, gasCost) => amount.plus((0, big_js_1.default)(gasCost.amount || 0)), (0, big_js_1.default)(0))
|
|
@@ -28,3 +28,33 @@ const getGasCostsBreakdown = (route) => {
|
|
|
28
28
|
}, {}));
|
|
29
29
|
};
|
|
30
30
|
exports.getGasCostsBreakdown = getGasCostsBreakdown;
|
|
31
|
+
const getFeeCostsBreakdown = (route, included) => {
|
|
32
|
+
return Object.values(route.steps.reduce((groupedFeeCosts, step) => {
|
|
33
|
+
let feeCosts = step.estimate.feeCosts;
|
|
34
|
+
if (typeof included === 'boolean') {
|
|
35
|
+
feeCosts = feeCosts?.filter((feeCost) => feeCost.included === included);
|
|
36
|
+
}
|
|
37
|
+
if (feeCosts?.length) {
|
|
38
|
+
const { token } = feeCosts[0];
|
|
39
|
+
const feeCostAmount = feeCosts
|
|
40
|
+
.reduce((amount, feeCost) => amount.plus((0, big_js_1.default)(feeCost.amount || 0)), (0, big_js_1.default)(0))
|
|
41
|
+
.div(10 ** token.decimals);
|
|
42
|
+
const feeCostAmountUSD = feeCosts.reduce((amount, feeCost) => amount + parseFloat(feeCost.amountUSD || '0'), 0);
|
|
43
|
+
const groupedFeeCost = groupedFeeCosts[token.chainId];
|
|
44
|
+
const amount = groupedFeeCost
|
|
45
|
+
? groupedFeeCost.amount.plus(feeCostAmount)
|
|
46
|
+
: feeCostAmount;
|
|
47
|
+
const amountUSD = groupedFeeCost
|
|
48
|
+
? groupedFeeCost.amountUSD + feeCostAmountUSD
|
|
49
|
+
: feeCostAmountUSD;
|
|
50
|
+
groupedFeeCosts[token.chainId] = {
|
|
51
|
+
amount,
|
|
52
|
+
amountUSD,
|
|
53
|
+
token,
|
|
54
|
+
};
|
|
55
|
+
return groupedFeeCosts;
|
|
56
|
+
}
|
|
57
|
+
return groupedFeeCosts;
|
|
58
|
+
}, {}));
|
|
59
|
+
};
|
|
60
|
+
exports.getFeeCostsBreakdown = getFeeCostsBreakdown;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SwapRoutes = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const KeyboardArrowRight_1 = require("@mui/icons-material/KeyboardArrowRight");
|
|
6
5
|
const material_1 = require("@mui/material");
|
|
7
6
|
const react_hook_form_1 = require("react-hook-form");
|
|
8
7
|
const react_i18next_1 = require("react-i18next");
|
|
@@ -13,16 +12,13 @@ const SwapRouteCard_1 = require("../../components/SwapRouteCard");
|
|
|
13
12
|
const hooks_1 = require("../../hooks");
|
|
14
13
|
const providers_1 = require("../../providers");
|
|
15
14
|
const utils_1 = require("../../utils");
|
|
16
|
-
const SwapRoutes_style_1 = require("./SwapRoutes.style");
|
|
17
|
-
const useSetRecommendedRoute_1 = require("./useSetRecommendedRoute");
|
|
18
15
|
const SwapRoutes = (props) => {
|
|
19
16
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
20
|
-
const { variant, useRecommendedRoute } = (0, providers_1.useWidgetConfig)();
|
|
21
17
|
const navigate = (0, react_router_dom_1.useNavigate)();
|
|
18
|
+
const { variant, useRecommendedRoute } = (0, providers_1.useWidgetConfig)();
|
|
22
19
|
const { isValid, isValidating } = (0, react_hook_form_1.useFormState)();
|
|
23
20
|
const { routes, isLoading, isFetching, isFetched, dataUpdatedAt, refetchTime, refetch, } = (0, hooks_1.useSwapRoutes)();
|
|
24
21
|
const currentRoute = routes?.[0];
|
|
25
|
-
(0, useSetRecommendedRoute_1.useSetRecommendedRoute)(currentRoute, isFetching);
|
|
26
22
|
if (!currentRoute && !isLoading && !isFetching && !isFetched) {
|
|
27
23
|
return null;
|
|
28
24
|
}
|
|
@@ -31,16 +27,11 @@ const SwapRoutes = (props) => {
|
|
|
31
27
|
};
|
|
32
28
|
const routeNotFound = !currentRoute && !isLoading && !isFetching;
|
|
33
29
|
const onlyRecommendedRoute = variant === 'refuel' || useRecommendedRoute;
|
|
30
|
+
const showAll = !onlyRecommendedRoute && !routeNotFound && (routes?.length ?? 0) > 1;
|
|
34
31
|
return ((0, jsx_runtime_1.jsxs)(Card_1.Card, { ...props, children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, { children: t('swap.routes') }), (0, jsx_runtime_1.jsx)(ProgressToNextUpdate_1.ProgressToNextUpdate, { updatedAt: dataUpdatedAt || new Date().getTime(), timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: {
|
|
35
32
|
position: 'absolute',
|
|
36
33
|
top: 8,
|
|
37
34
|
right: 8,
|
|
38
|
-
} }), (0, jsx_runtime_1.jsxs)(material_1.Box, {
|
|
39
|
-
borderRightWidth: !onlyRecommendedRoute &&
|
|
40
|
-
!routeNotFound &&
|
|
41
|
-
(isFetching || (routes && routes.length > 1))
|
|
42
|
-
? 1
|
|
43
|
-
: 0,
|
|
44
|
-
}, children: isLoading ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCardSkeleton, { minWidth: !onlyRecommendedRoute ? '80%' : '100%', variant: "dense" }), !onlyRecommendedRoute ? ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCardSkeleton, { minWidth: "80%", variant: "dense" })) : null] })) : !currentRoute ? ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteNotFoundCard, {})) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCard, { minWidth: !onlyRecommendedRoute && routes.length > 1 ? '80%' : '100%', route: currentRoute, variant: "dense", active: true }), !onlyRecommendedRoute && routes.length > 1 ? ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCard, { minWidth: "80%", route: routes[1], variant: "dense", pointerEvents: "none" })) : null] })) }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { display: 'flex', alignItems: 'center' }, children: !onlyRecommendedRoute && !routeNotFound ? ((0, jsx_runtime_1.jsx)(material_1.Box, { py: 1, pr: 1, children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { onClick: handleCardClick, size: "medium", disabled: isValidating || !isValid, children: (0, jsx_runtime_1.jsx)(KeyboardArrowRight_1.default, {}) }) })) : null })] })] }));
|
|
35
|
+
} }), (0, jsx_runtime_1.jsxs)(material_1.Box, { p: 2, children: [isLoading ? ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCardSkeleton, { variant: "cardless" })) : !currentRoute ? ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteNotFoundCard, {})) : ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCard, { route: currentRoute, variant: "cardless", active: true })), (0, jsx_runtime_1.jsx)(material_1.Collapse, { timeout: 225, in: showAll, unmountOnExit: true, mountOnEnter: true, appear: true, children: (0, jsx_runtime_1.jsx)(material_1.Box, { mt: 2, children: (0, jsx_runtime_1.jsx)(material_1.Button, { onClick: handleCardClick, disabled: isValidating || !isValid, fullWidth: true, children: t('button.showAll') }) }) })] })] }));
|
|
45
36
|
};
|
|
46
37
|
exports.SwapRoutes = SwapRoutes;
|
|
@@ -12,17 +12,11 @@ const stores_1 = require("../../stores");
|
|
|
12
12
|
const utils_1 = require("../../utils");
|
|
13
13
|
const ProgressToNextUpdate_1 = require("../ProgressToNextUpdate");
|
|
14
14
|
const SwapRouteCard_1 = require("../SwapRouteCard");
|
|
15
|
-
const
|
|
16
|
-
const useSetRecommendedRoute_1 = require("./useSetRecommendedRoute");
|
|
15
|
+
const SwapRoutesExpanded_style_1 = require("./SwapRoutesExpanded.style");
|
|
17
16
|
const timeout = { enter: 225, exit: 225, appear: 0 };
|
|
18
17
|
const SwapRoutesExpanded = () => {
|
|
19
|
-
const element = (0, react_router_dom_1.
|
|
20
|
-
|
|
21
|
-
path: '/',
|
|
22
|
-
element: null,
|
|
23
|
-
},
|
|
24
|
-
]);
|
|
25
|
-
return ((0, jsx_runtime_1.jsx)(SwapRoutes_style_1.CollapseContainer, { children: (0, jsx_runtime_1.jsx)(material_1.Collapse, { timeout: timeout, in: !!element, orientation: "horizontal", children: (0, jsx_runtime_1.jsx)(material_1.Grow, { timeout: timeout, in: !!element, mountOnEnter: true, unmountOnExit: true, children: (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(exports.SwapRoutesExpandedElement, {}) }) }) }) }));
|
|
18
|
+
const element = (0, react_router_dom_1.useMatch)('/');
|
|
19
|
+
return ((0, jsx_runtime_1.jsx)(SwapRoutesExpanded_style_1.CollapseContainer, { children: (0, jsx_runtime_1.jsx)(material_1.Collapse, { timeout: timeout, in: !!element, orientation: "horizontal", children: (0, jsx_runtime_1.jsx)(material_1.Grow, { timeout: timeout, in: !!element, mountOnEnter: true, unmountOnExit: true, children: (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(exports.SwapRoutesExpandedElement, {}) }) }) }) }));
|
|
26
20
|
};
|
|
27
21
|
exports.SwapRoutesExpanded = SwapRoutesExpanded;
|
|
28
22
|
const SwapRoutesExpandedElement = () => {
|
|
@@ -33,7 +27,6 @@ const SwapRoutesExpandedElement = () => {
|
|
|
33
27
|
const { isValid, isValidating } = (0, react_hook_form_1.useFormState)();
|
|
34
28
|
const { routes, isLoading, isFetching, isFetched, dataUpdatedAt, refetchTime, refetch, } = (0, hooks_1.useSwapRoutes)();
|
|
35
29
|
const currentRoute = routes?.[0];
|
|
36
|
-
(0, useSetRecommendedRoute_1.useSetRecommendedRoute)(currentRoute, isFetching);
|
|
37
30
|
const handleRouteClick = (route) => {
|
|
38
31
|
if (isValid && !isValidating) {
|
|
39
32
|
setExecutableRoute(route);
|
|
@@ -44,6 +37,6 @@ const SwapRoutesExpandedElement = () => {
|
|
|
44
37
|
};
|
|
45
38
|
const expanded = Boolean(currentRoute || isLoading || isFetching || isFetched);
|
|
46
39
|
const routeNotFound = !currentRoute && !isLoading && !isFetching && expanded;
|
|
47
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Collapse, { timeout: timeout.enter, in: expanded, orientation: "horizontal", children: (0, jsx_runtime_1.jsx)(material_1.Grow, { timeout: timeout.enter, in: expanded, mountOnEnter: true, unmountOnExit: true, children: (0, jsx_runtime_1.jsx)(
|
|
40
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Collapse, { timeout: timeout.enter, in: expanded, orientation: "horizontal", children: (0, jsx_runtime_1.jsx)(material_1.Grow, { timeout: timeout.enter, in: expanded, mountOnEnter: true, unmountOnExit: true, children: (0, jsx_runtime_1.jsx)(SwapRoutesExpanded_style_1.Container, { sx: containerStyle, enableColorScheme: true, children: (0, jsx_runtime_1.jsxs)(SwapRoutesExpanded_style_1.ScrollableContainer, { children: [(0, jsx_runtime_1.jsxs)(SwapRoutesExpanded_style_1.Header, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 18, fontWeight: "700", flex: 1, noWrap: true, children: t('swap.routes') }), (0, jsx_runtime_1.jsx)(ProgressToNextUpdate_1.ProgressToNextUpdate, { updatedAt: dataUpdatedAt || new Date().getTime(), timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: { marginRight: -1 } })] }), (0, jsx_runtime_1.jsx)(material_1.Stack, { direction: "column", spacing: 2, flex: 1, paddingX: 3, paddingBottom: 3, children: routeNotFound ? ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteNotFoundCard, {})) : isLoading || (isFetching && !routes?.length) ? (Array.from({ length: 3 }).map((_, index) => ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCardSkeleton, {}, index)))) : (routes?.map((route, index) => ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCard, { route: route, onClick: () => handleRouteClick(route), active: index === 0, expanded: routes?.length <= 2 }, route.id)))) })] }) }) }) }));
|
|
48
41
|
};
|
|
49
42
|
exports.SwapRoutesExpandedElement = SwapRoutesExpandedElement;
|
|
@@ -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,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.Header = exports.Container = exports.ScrollableContainer = exports.CollapseContainer = void 0;
|
|
4
4
|
const material_1 = require("@mui/material");
|
|
5
5
|
const styles_1 = require("@mui/material/styles");
|
|
6
6
|
const AppContainer_1 = require("../AppContainer");
|
|
@@ -35,14 +35,3 @@ exports.Header = (0, styles_1.styled)(material_1.Box)(({ theme }) => ({
|
|
|
35
35
|
top: 0,
|
|
36
36
|
zIndex: 1200,
|
|
37
37
|
}));
|
|
38
|
-
exports.Stack = (0, styles_1.styled)(material_1.Stack)(({ theme }) => ({
|
|
39
|
-
alignItems: 'stretch',
|
|
40
|
-
display: 'flex',
|
|
41
|
-
flex: 1,
|
|
42
|
-
flexWrap: 'nowrap',
|
|
43
|
-
overflow: 'hidden',
|
|
44
|
-
borderRight: `solid ${theme.palette.mode === 'light'
|
|
45
|
-
? theme.palette.grey[300]
|
|
46
|
-
: theme.palette.grey[800]}`,
|
|
47
|
-
width: 'calc(100% - 48px)',
|
|
48
|
-
}));
|
package/cjs/components/Switch.js
CHANGED
|
@@ -31,8 +31,8 @@ exports.Switch = (0, styles_1.styled)(material_1.Switch)(({ theme }) => ({
|
|
|
31
31
|
},
|
|
32
32
|
[`&.${Switch_1.switchClasses.disabled} .${Switch_1.switchClasses.thumb}`]: {
|
|
33
33
|
color: theme.palette.mode === 'light'
|
|
34
|
-
? theme.palette.
|
|
35
|
-
: theme.palette.
|
|
34
|
+
? (0, styles_1.alpha)(theme.palette.common.black, 0.12)
|
|
35
|
+
: (0, styles_1.alpha)(theme.palette.common.white, 0.12),
|
|
36
36
|
},
|
|
37
37
|
[`&.${Switch_1.switchClasses.disabled} + .${Switch_1.switchClasses.track}`]: {
|
|
38
38
|
opacity: theme.palette.mode === 'light' ? 0.7 : 0.3,
|
|
@@ -46,8 +46,8 @@ exports.Switch = (0, styles_1.styled)(material_1.Switch)(({ theme }) => ({
|
|
|
46
46
|
[`.${Switch_1.switchClasses.track}`]: {
|
|
47
47
|
borderRadius: 24 / 2,
|
|
48
48
|
backgroundColor: theme.palette.mode === 'light'
|
|
49
|
-
? theme.palette.
|
|
50
|
-
: theme.palette.
|
|
49
|
+
? (0, styles_1.alpha)(theme.palette.common.black, 0.16)
|
|
50
|
+
: (0, styles_1.alpha)(theme.palette.common.white, 0.16),
|
|
51
51
|
opacity: 1,
|
|
52
52
|
transition: theme.transitions.create(['background-color'], {
|
|
53
53
|
duration: theme.transitions.duration.standard,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type {
|
|
2
|
+
import type { LifiStep, TokenAmount } from '@lifi/sdk';
|
|
3
3
|
import type { BoxProps } from '@mui/material';
|
|
4
4
|
interface TokenProps {
|
|
5
5
|
token?: TokenAmount;
|
|
6
6
|
connected?: boolean;
|
|
7
|
-
step?:
|
|
7
|
+
step?: LifiStep;
|
|
8
8
|
disableDescription?: boolean;
|
|
9
9
|
isLoading?: boolean;
|
|
10
10
|
}
|
|
@@ -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> & {
|
|
@@ -17,7 +17,7 @@ export declare const ListItemButton: import("@emotion/styled").StyledComponent<i
|
|
|
17
17
|
touchRippleRef?: import("react").Ref<import("@mui/material/ButtonBase/TouchRipple").TouchRippleActions> | undefined;
|
|
18
18
|
}, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
19
19
|
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
20
|
-
}, "className" | "style" | "classes" | "tabIndex" | "children" | "action" | "centerRipple" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "TouchRippleProps" | "touchRippleRef" | "alignItems" | "
|
|
20
|
+
}, "className" | "style" | "classes" | "autoFocus" | "tabIndex" | "children" | "action" | "centerRipple" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "TouchRippleProps" | "touchRippleRef" | "alignItems" | "dense" | "divider" | "selected" | "disableGutters"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
21
21
|
export declare const ListItem: import("@emotion/styled").StyledComponent<{
|
|
22
22
|
button?: false | undefined;
|
|
23
23
|
} & import("@mui/material").ListItemBaseProps & {
|
|
@@ -35,4 +35,4 @@ export declare const ListItem: import("@emotion/styled").StyledComponent<{
|
|
|
35
35
|
} | undefined;
|
|
36
36
|
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "ref"> & {
|
|
37
37
|
ref?: ((instance: HTMLLIElement | null) => void) | import("react").RefObject<HTMLLIElement> | null | undefined;
|
|
38
|
-
}, "button" | "className" | "style" | "classes" | "
|
|
38
|
+
}, "button" | "className" | "style" | "classes" | "autoFocus" | "children" | "disabled" | "sx" | "alignItems" | "dense" | "divider" | "components" | "slotProps" | "slots" | "componentsProps" | "selected" | "disableGutters" | "ContainerComponent" | "ContainerProps" | "disablePadding" | "secondaryAction"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
package/cjs/config/theme.js
CHANGED
package/cjs/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.1";
|
package/cjs/config/version.js
CHANGED
package/cjs/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/cjs/hooks/index.js
CHANGED
|
@@ -21,7 +21,11 @@ __exportStar(require("./useDebouncedWatch"), exports);
|
|
|
21
21
|
__exportStar(require("./useDefaultElementId"), exports);
|
|
22
22
|
__exportStar(require("./useExpandableVariant"), exports);
|
|
23
23
|
__exportStar(require("./useFeaturedTokens"), exports);
|
|
24
|
+
__exportStar(require("./useFundsSufficiency"), exports);
|
|
25
|
+
__exportStar(require("./useGasRecommendation"), exports);
|
|
26
|
+
__exportStar(require("./useGasRefuel"), exports);
|
|
24
27
|
__exportStar(require("./useGasSufficiency"), exports);
|
|
28
|
+
__exportStar(require("./useGetTokenBalancesWithRetry"), exports);
|
|
25
29
|
__exportStar(require("./useInitializer"), exports);
|
|
26
30
|
__exportStar(require("./useNavigateBack"), exports);
|
|
27
31
|
__exportStar(require("./useProcessMessage"), exports);
|
package/cjs/hooks/useChains.js
CHANGED
|
@@ -7,13 +7,13 @@ const react_hook_form_1 = require("react-hook-form");
|
|
|
7
7
|
const providers_1 = require("../providers");
|
|
8
8
|
const stores_1 = require("../stores");
|
|
9
9
|
const useChains = () => {
|
|
10
|
-
const {
|
|
10
|
+
const { chains } = (0, providers_1.useWidgetConfig)();
|
|
11
11
|
const lifi = (0, providers_1.useLiFi)();
|
|
12
12
|
const { getValues, setValue } = (0, react_hook_form_1.useFormContext)();
|
|
13
13
|
const initializeChains = (0, stores_1.useChainOrderStore)((state) => state.initializeChains);
|
|
14
14
|
const { data, isLoading } = (0, react_query_1.useQuery)(['chains'], async () => {
|
|
15
15
|
const availableChains = await lifi.getChains();
|
|
16
|
-
const filteredChains = availableChains.filter((chain) => (0, providers_1.isItemAllowed)(chain.id, chains
|
|
16
|
+
const filteredChains = availableChains.filter((chain) => (0, providers_1.isItemAllowed)(chain.id, chains));
|
|
17
17
|
const chainOrder = initializeChains(filteredChains.map((chain) => chain.id));
|
|
18
18
|
const [fromChainValue, toChainValue] = getValues([
|
|
19
19
|
providers_1.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;
|
|
@@ -4,7 +4,7 @@ exports.useFeaturedTokens = void 0;
|
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const providers_1 = require("../providers");
|
|
6
6
|
const useFeaturedTokens = (selectedChainId) => {
|
|
7
|
-
const {
|
|
8
|
-
return (0, react_1.useMemo)(() =>
|
|
7
|
+
const { tokens } = (0, providers_1.useWidgetConfig)();
|
|
8
|
+
return (0, react_1.useMemo)(() => tokens?.featured?.filter((token) => token.chainId === selectedChainId), [selectedChainId, tokens?.featured]);
|
|
9
9
|
};
|
|
10
10
|
exports.useFeaturedTokens = useFeaturedTokens;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useFundsSufficiency = void 0;
|
|
4
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
5
|
+
const big_js_1 = require("big.js");
|
|
6
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
7
|
+
const providers_1 = require("../providers");
|
|
8
|
+
const stores_1 = require("../stores");
|
|
9
|
+
const useGetTokenBalancesWithRetry_1 = require("./useGetTokenBalancesWithRetry");
|
|
10
|
+
const useTokenAddressBalance_1 = require("./useTokenAddressBalance");
|
|
11
|
+
const refetchInterval = 30000;
|
|
12
|
+
const useFundsSufficiency = (route) => {
|
|
13
|
+
const { account, provider } = (0, providers_1.useWallet)();
|
|
14
|
+
const getTokenBalancesWithRetry = (0, useGetTokenBalancesWithRetry_1.useGetTokenBalancesWithRetry)(provider);
|
|
15
|
+
const [fromChainId, fromTokenAddress, fromAmount] = (0, react_hook_form_1.useWatch)({
|
|
16
|
+
name: [
|
|
17
|
+
providers_1.SwapFormKey.FromChain,
|
|
18
|
+
providers_1.SwapFormKey.FromToken,
|
|
19
|
+
providers_1.SwapFormKey.FromAmount,
|
|
20
|
+
],
|
|
21
|
+
});
|
|
22
|
+
let chainId = fromChainId;
|
|
23
|
+
let tokenAddress = fromTokenAddress;
|
|
24
|
+
if (route) {
|
|
25
|
+
chainId = route.fromToken.chainId;
|
|
26
|
+
tokenAddress = route.fromToken.address;
|
|
27
|
+
}
|
|
28
|
+
const { token, isLoading } = (0, useTokenAddressBalance_1.useTokenAddressBalance)(chainId, tokenAddress);
|
|
29
|
+
const { data: insufficientFunds, isInitialLoading } = (0, react_query_1.useQuery)([
|
|
30
|
+
'funds-sufficiency-check',
|
|
31
|
+
account.address,
|
|
32
|
+
chainId,
|
|
33
|
+
tokenAddress,
|
|
34
|
+
route?.id ?? fromAmount,
|
|
35
|
+
], async () => {
|
|
36
|
+
if (!account.address || !token) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
let currentTokenBalance = (0, big_js_1.default)(token?.amount || 0);
|
|
40
|
+
if (!route || (0, stores_1.isRouteDone)(route)) {
|
|
41
|
+
const insufficientFunds = currentTokenBalance.lt((0, big_js_1.default)(fromAmount || 0));
|
|
42
|
+
return insufficientFunds;
|
|
43
|
+
}
|
|
44
|
+
const currentAction = route.steps.filter((step) => !step.execution || step.execution.status !== 'DONE')[0]?.action;
|
|
45
|
+
if (token.chainId === currentAction.fromToken.chainId &&
|
|
46
|
+
token.address === currentAction.fromToken.address &&
|
|
47
|
+
currentTokenBalance.gt(0)) {
|
|
48
|
+
const insufficientFunds = (0, big_js_1.default)(route.fromAmount)
|
|
49
|
+
.div(10 ** route.fromToken.decimals)
|
|
50
|
+
.gt(currentTokenBalance);
|
|
51
|
+
return insufficientFunds;
|
|
52
|
+
}
|
|
53
|
+
const tokenBalances = await getTokenBalancesWithRetry(account.address, [
|
|
54
|
+
currentAction.fromToken,
|
|
55
|
+
]);
|
|
56
|
+
currentTokenBalance = (0, big_js_1.default)(tokenBalances?.[0]?.amount || 0);
|
|
57
|
+
const insufficientFunds = (0, big_js_1.default)(currentAction.fromAmount)
|
|
58
|
+
.div(10 ** currentAction.fromToken.decimals)
|
|
59
|
+
.gt(currentTokenBalance);
|
|
60
|
+
return insufficientFunds;
|
|
61
|
+
}, {
|
|
62
|
+
enabled: Boolean(account.address && token && !isLoading),
|
|
63
|
+
refetchInterval,
|
|
64
|
+
staleTime: refetchInterval,
|
|
65
|
+
cacheTime: refetchInterval,
|
|
66
|
+
keepPreviousData: true,
|
|
67
|
+
});
|
|
68
|
+
return {
|
|
69
|
+
insufficientFunds,
|
|
70
|
+
isInitialLoading,
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
exports.useFundsSufficiency = useFundsSufficiency;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useGasRecommendation = void 0;
|
|
4
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
5
|
+
const providers_1 = require("../providers");
|
|
6
|
+
const refetchInterval = 60000;
|
|
7
|
+
const useGasRecommendation = (chainId, fromChain, fromToken) => {
|
|
8
|
+
const lifi = (0, providers_1.useLiFi)();
|
|
9
|
+
return (0, react_query_1.useQuery)(['gas-recommendation', chainId, fromChain, fromToken], async ({ queryKey: [_, chainId, fromChain, fromToken] }) => {
|
|
10
|
+
const gasRecommendation = await lifi.getGasRecommendation({
|
|
11
|
+
chainId: chainId,
|
|
12
|
+
fromChain: fromChain,
|
|
13
|
+
fromToken: fromToken,
|
|
14
|
+
});
|
|
15
|
+
return gasRecommendation;
|
|
16
|
+
}, {
|
|
17
|
+
enabled: Boolean(chainId),
|
|
18
|
+
refetchInterval,
|
|
19
|
+
staleTime: refetchInterval,
|
|
20
|
+
cacheTime: refetchInterval,
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
exports.useGasRecommendation = useGasRecommendation;
|