@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
|
@@ -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,8 +12,7 @@ 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
18
|
const element = (0, react_router_dom_1.useRoutes)([
|
|
@@ -22,7 +21,7 @@ const SwapRoutesExpanded = () => {
|
|
|
22
21
|
element: null,
|
|
23
22
|
},
|
|
24
23
|
]);
|
|
25
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
24
|
+
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
25
|
};
|
|
27
26
|
exports.SwapRoutesExpanded = SwapRoutesExpanded;
|
|
28
27
|
const SwapRoutesExpandedElement = () => {
|
|
@@ -33,7 +32,6 @@ const SwapRoutesExpandedElement = () => {
|
|
|
33
32
|
const { isValid, isValidating } = (0, react_hook_form_1.useFormState)();
|
|
34
33
|
const { routes, isLoading, isFetching, isFetched, dataUpdatedAt, refetchTime, refetch, } = (0, hooks_1.useSwapRoutes)();
|
|
35
34
|
const currentRoute = routes?.[0];
|
|
36
|
-
(0, useSetRecommendedRoute_1.useSetRecommendedRoute)(currentRoute, isFetching);
|
|
37
35
|
const handleRouteClick = (route) => {
|
|
38
36
|
if (isValid && !isValidating) {
|
|
39
37
|
setExecutableRoute(route);
|
|
@@ -44,6 +42,6 @@ const SwapRoutesExpandedElement = () => {
|
|
|
44
42
|
};
|
|
45
43
|
const expanded = Boolean(currentRoute || isLoading || isFetching || isFetched);
|
|
46
44
|
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)(
|
|
45
|
+
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
46
|
};
|
|
49
47
|
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,
|
|
@@ -4,6 +4,7 @@ exports.TextFitter = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const styles_1 = require("@mui/material/styles");
|
|
6
6
|
const react_1 = require("react");
|
|
7
|
+
const react_intersection_observer_1 = require("react-intersection-observer");
|
|
7
8
|
const initialState = {
|
|
8
9
|
x: 0,
|
|
9
10
|
y: 0,
|
|
@@ -14,7 +15,13 @@ const TextFitter = ({ children, width = '100%', height, maxHeight, preserveAspec
|
|
|
14
15
|
const theme = (0, styles_1.useTheme)();
|
|
15
16
|
const textRef = (0, react_1.useRef)(null);
|
|
16
17
|
const [viewBox, setViewBox] = (0, react_1.useState)(initialState);
|
|
17
|
-
|
|
18
|
+
const [ref] = (0, react_intersection_observer_1.useInView)({
|
|
19
|
+
onChange(inView) {
|
|
20
|
+
if (inView) {
|
|
21
|
+
calculateBox();
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
});
|
|
18
25
|
const calculateBox = (0, react_1.useCallback)(() => {
|
|
19
26
|
if (!textRef.current) {
|
|
20
27
|
return;
|
|
@@ -28,7 +35,6 @@ const TextFitter = ({ children, width = '100%', height, maxHeight, preserveAspec
|
|
|
28
35
|
box.height -= box.height * cropBottom;
|
|
29
36
|
}
|
|
30
37
|
setViewBox(box);
|
|
31
|
-
// setTextRect(textRef.current.getBoundingClientRect());
|
|
32
38
|
onFit?.();
|
|
33
39
|
}, [cropBottom, cropTop, onFit]);
|
|
34
40
|
(0, react_1.useLayoutEffect)(() => {
|
|
@@ -47,6 +53,6 @@ const TextFitter = ({ children, width = '100%', height, maxHeight, preserveAspec
|
|
|
47
53
|
// ? maxHeight
|
|
48
54
|
// : height
|
|
49
55
|
// }
|
|
50
|
-
preserveAspectRatio: preserveAspectRatio, fill: theme.palette.text.primary, children: (0, jsx_runtime_1.jsx)("text", { x: 0, y: 0, style: textStyle, ref: textRef, children: children }) }));
|
|
56
|
+
preserveAspectRatio: preserveAspectRatio, fill: theme.palette.text.primary, ref: ref, children: (0, jsx_runtime_1.jsx)("text", { x: 0, y: 0, style: textStyle, ref: textRef, children: children }) }));
|
|
51
57
|
};
|
|
52
58
|
exports.TextFitter = TextFitter;
|
|
@@ -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/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.0";
|
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;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useGasRefuel = void 0;
|
|
4
|
+
const big_js_1 = require("big.js");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
7
|
+
const _1 = require(".");
|
|
8
|
+
const providers_1 = require("../providers");
|
|
9
|
+
const useGasRecommendation_1 = require("./useGasRecommendation");
|
|
10
|
+
const useTokenBalance_1 = require("./useTokenBalance");
|
|
11
|
+
const useGasRefuel = () => {
|
|
12
|
+
const { getChainById } = (0, _1.useChains)();
|
|
13
|
+
const [fromChainId, fromTokenAddress, toChainId, toTokenAddress, toAddress] = (0, react_hook_form_1.useWatch)({
|
|
14
|
+
name: [
|
|
15
|
+
providers_1.SwapFormKey.FromChain,
|
|
16
|
+
providers_1.SwapFormKey.FromToken,
|
|
17
|
+
providers_1.SwapFormKey.ToChain,
|
|
18
|
+
providers_1.SwapFormKey.ToToken,
|
|
19
|
+
providers_1.SwapFormKey.ToAddress,
|
|
20
|
+
],
|
|
21
|
+
});
|
|
22
|
+
const toChain = getChainById(toChainId);
|
|
23
|
+
const { token: nativeToken } = (0, useTokenBalance_1.useTokenBalance)(toChainId && toChain?.nativeToken, toAddress);
|
|
24
|
+
const { data: gasRecommendation, isLoading } = (0, useGasRecommendation_1.useGasRecommendation)(toChainId, fromChainId, fromTokenAddress);
|
|
25
|
+
const enabled = (0, react_1.useMemo)(() => {
|
|
26
|
+
if (
|
|
27
|
+
// We don't allow same chain refuel.
|
|
28
|
+
// If a user runs out of gas, he can't send a source chain transaction.
|
|
29
|
+
fromChainId === toChainId ||
|
|
30
|
+
// We don't want to apply auto refuel when swapping to native tokens
|
|
31
|
+
toChain?.nativeToken.address === toTokenAddress ||
|
|
32
|
+
!gasRecommendation?.available ||
|
|
33
|
+
!gasRecommendation.recommended ||
|
|
34
|
+
!nativeToken) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
const tokenBalance = (0, big_js_1.default)(nativeToken.amount ?? 0);
|
|
38
|
+
// check if the user balance < 50% of the recommended amount
|
|
39
|
+
const recommendedAmount = (0, big_js_1.default)(gasRecommendation.recommended.amount)
|
|
40
|
+
.div(10 ** gasRecommendation.recommended.token.decimals)
|
|
41
|
+
.div(2);
|
|
42
|
+
const insufficientGas = tokenBalance.lt(recommendedAmount);
|
|
43
|
+
return insufficientGas;
|
|
44
|
+
}, [
|
|
45
|
+
fromChainId,
|
|
46
|
+
gasRecommendation?.available,
|
|
47
|
+
gasRecommendation?.recommended,
|
|
48
|
+
nativeToken,
|
|
49
|
+
toChain?.nativeToken.address,
|
|
50
|
+
toChainId,
|
|
51
|
+
toTokenAddress,
|
|
52
|
+
]);
|
|
53
|
+
return {
|
|
54
|
+
enabled: enabled,
|
|
55
|
+
availble: gasRecommendation?.available,
|
|
56
|
+
isLoading: isLoading,
|
|
57
|
+
chain: toChain,
|
|
58
|
+
gasRecommendation,
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
exports.useGasRefuel = useGasRefuel;
|
|
@@ -9,7 +9,6 @@ export interface GasSufficiency {
|
|
|
9
9
|
chain?: EVMChain;
|
|
10
10
|
}
|
|
11
11
|
export declare const useGasSufficiency: (route?: Route) => {
|
|
12
|
-
insufficientGas: GasSufficiency[] |
|
|
13
|
-
|
|
14
|
-
isLoading: boolean;
|
|
12
|
+
insufficientGas: GasSufficiency[] | undefined;
|
|
13
|
+
isInitialLoading: boolean;
|
|
15
14
|
};
|
|
@@ -5,16 +5,14 @@ const react_query_1 = require("@tanstack/react-query");
|
|
|
5
5
|
const big_js_1 = require("big.js");
|
|
6
6
|
const _1 = require(".");
|
|
7
7
|
const providers_1 = require("../providers");
|
|
8
|
-
const stores_1 = require("../stores");
|
|
9
|
-
const useTokenBalance_1 = require("./useTokenBalance");
|
|
10
8
|
const refetchInterval = 30000;
|
|
11
9
|
const useGasSufficiency = (route) => {
|
|
12
|
-
const { account } = (0, providers_1.useWallet)();
|
|
10
|
+
const { account, provider } = (0, providers_1.useWallet)();
|
|
13
11
|
const { getChainById } = (0, _1.useChains)();
|
|
14
|
-
const
|
|
15
|
-
const { data: insufficientGas, isInitialLoading
|
|
12
|
+
const getTokenBalancesWithRetry = (0, _1.useGetTokenBalancesWithRetry)(provider);
|
|
13
|
+
const { data: insufficientGas, isInitialLoading } = (0, react_query_1.useQuery)(['gas-sufficiency-check', account.address, route?.id], async () => {
|
|
16
14
|
if (!account.address || !route) {
|
|
17
|
-
return
|
|
15
|
+
return;
|
|
18
16
|
}
|
|
19
17
|
const gasCosts = route.steps
|
|
20
18
|
.filter((step) => !step.execution || step.execution.status !== 'DONE')
|
|
@@ -42,7 +40,7 @@ const useGasSufficiency = (route) => {
|
|
|
42
40
|
}
|
|
43
41
|
const tokenBalances = await getTokenBalancesWithRetry(account.address, Object.values(gasCosts).map((item) => item.token));
|
|
44
42
|
if (!tokenBalances?.length) {
|
|
45
|
-
return
|
|
43
|
+
return;
|
|
46
44
|
}
|
|
47
45
|
[route.fromChainId, route.toChainId].forEach((chainId) => {
|
|
48
46
|
if (gasCosts[chainId]) {
|
|
@@ -71,38 +69,9 @@ const useGasSufficiency = (route) => {
|
|
|
71
69
|
staleTime: refetchInterval,
|
|
72
70
|
cacheTime: refetchInterval,
|
|
73
71
|
});
|
|
74
|
-
const { data: insufficientFunds, isInitialLoading: insufficientFundsLoading, } = (0, react_query_1.useQuery)(['funds-sufficiency-check', account.address, route?.id], async () => {
|
|
75
|
-
if (!account.address || !fromToken || !route || (0, stores_1.isRouteDone)(route)) {
|
|
76
|
-
return null;
|
|
77
|
-
}
|
|
78
|
-
let currentTokenBalance = (0, big_js_1.default)(fromToken?.amount ?? 0);
|
|
79
|
-
const currentAction = route.steps.filter((step) => !step.execution || step.execution.status !== 'DONE')[0]?.action;
|
|
80
|
-
if (fromToken.chainId === currentAction.fromToken.chainId &&
|
|
81
|
-
fromToken.address === currentAction.fromToken.address &&
|
|
82
|
-
currentTokenBalance.gt(0)) {
|
|
83
|
-
const insufficientFunds = (0, big_js_1.default)(route.fromAmount)
|
|
84
|
-
.div(10 ** route.fromToken.decimals)
|
|
85
|
-
.gt(currentTokenBalance);
|
|
86
|
-
return insufficientFunds;
|
|
87
|
-
}
|
|
88
|
-
const tokenBalances = await getTokenBalancesWithRetry(account.address, [
|
|
89
|
-
currentAction.fromToken,
|
|
90
|
-
]);
|
|
91
|
-
currentTokenBalance = (0, big_js_1.default)(tokenBalances?.[0]?.amount ?? 0);
|
|
92
|
-
const insufficientFunds = (0, big_js_1.default)(currentAction.fromAmount)
|
|
93
|
-
.div(10 ** currentAction.fromToken.decimals)
|
|
94
|
-
.gt(currentTokenBalance);
|
|
95
|
-
return insufficientFunds;
|
|
96
|
-
}, {
|
|
97
|
-
enabled: Boolean(account.address && route && fromToken),
|
|
98
|
-
refetchInterval,
|
|
99
|
-
staleTime: refetchInterval,
|
|
100
|
-
cacheTime: refetchInterval,
|
|
101
|
-
});
|
|
102
72
|
return {
|
|
103
73
|
insufficientGas,
|
|
104
|
-
|
|
105
|
-
isLoading: insufficientGasLoading || insufficientFundsLoading,
|
|
74
|
+
isInitialLoading,
|
|
106
75
|
};
|
|
107
76
|
};
|
|
108
77
|
exports.useGasSufficiency = useGasSufficiency;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Provider } from '@ethersproject/providers';
|
|
2
|
+
import type { Token, TokenAmount } from '@lifi/sdk';
|
|
3
|
+
export declare const useGetTokenBalancesWithRetry: (provider?: Provider) => (accountAddress: string, tokens: Token[], depth?: number) => Promise<TokenAmount[] | undefined>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useGetTokenBalancesWithRetry = void 0;
|
|
4
|
+
const address_1 = require("@ethersproject/address");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const providers_1 = require("../providers");
|
|
7
|
+
const useGetTokenBalancesWithRetry = (provider) => {
|
|
8
|
+
const lifi = (0, providers_1.useLiFi)();
|
|
9
|
+
const getTokenBalancesWithRetry = (0, react_1.useCallback)(async (accountAddress, tokens, depth = 0) => {
|
|
10
|
+
try {
|
|
11
|
+
const walletAddress = (0, address_1.isAddress)(accountAddress)
|
|
12
|
+
? accountAddress
|
|
13
|
+
: await provider?.resolveName(accountAddress);
|
|
14
|
+
const tokenBalances = await lifi.getTokenBalances(walletAddress, tokens);
|
|
15
|
+
if (!tokenBalances.every((token) => token.blockNumber)) {
|
|
16
|
+
if (depth > 10) {
|
|
17
|
+
console.warn('Token balance backoff depth exceeded.');
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
await new Promise((resolve) => {
|
|
21
|
+
setTimeout(resolve, 1.5 ** depth * 100);
|
|
22
|
+
});
|
|
23
|
+
return getTokenBalancesWithRetry(accountAddress, tokens, depth + 1);
|
|
24
|
+
}
|
|
25
|
+
return tokenBalances;
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
//
|
|
29
|
+
}
|
|
30
|
+
}, [lifi, provider]);
|
|
31
|
+
return getTokenBalancesWithRetry;
|
|
32
|
+
};
|
|
33
|
+
exports.useGetTokenBalancesWithRetry = useGetTokenBalancesWithRetry;
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import type { Route, RoutesResponse } from '@lifi/sdk';
|
|
2
|
-
|
|
2
|
+
interface SwapRoutesProps {
|
|
3
|
+
onSettled?: (data?: RoutesResponse) => void;
|
|
4
|
+
insurableRoute?: Route;
|
|
5
|
+
}
|
|
6
|
+
export declare const useSwapRoutes: ({ onSettled, insurableRoute, }?: SwapRoutesProps) => {
|
|
3
7
|
routes: Route[] | undefined;
|
|
4
8
|
isLoading: boolean;
|
|
5
9
|
isFetching: boolean;
|
|
6
10
|
isFetched: boolean;
|
|
7
11
|
dataUpdatedAt: number;
|
|
8
12
|
refetchTime: number;
|
|
9
|
-
refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<RoutesResponse,
|
|
13
|
+
refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<RoutesResponse, unknown>>;
|
|
10
14
|
};
|
|
15
|
+
export {};
|