@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
|
@@ -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,10 @@
|
|
|
1
|
-
import type { EVMChain,
|
|
1
|
+
import type { EVMChain, LifiStep, Process } from '@lifi/sdk';
|
|
2
2
|
import type { TFunction } from 'i18next';
|
|
3
|
-
export declare const useProcessMessage: (step?:
|
|
3
|
+
export declare const useProcessMessage: (step?: LifiStep, process?: Process) => {
|
|
4
4
|
title?: string | undefined;
|
|
5
5
|
message?: string | undefined;
|
|
6
6
|
};
|
|
7
|
-
export declare function getProcessMessage(t: TFunction, getChainById: (chainId: number) => EVMChain | undefined, step:
|
|
7
|
+
export declare function getProcessMessage(t: TFunction, getChainById: (chainId: number) => EVMChain | undefined, step: LifiStep, process: Process): {
|
|
8
8
|
title?: string;
|
|
9
9
|
message?: string;
|
|
10
10
|
};
|
|
@@ -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 {};
|
|
@@ -11,14 +11,15 @@ const _1 = require(".");
|
|
|
11
11
|
const providers_1 = require("../providers");
|
|
12
12
|
const stores_1 = require("../stores");
|
|
13
13
|
const refetchTime = 60000;
|
|
14
|
-
const useSwapRoutes = () => {
|
|
14
|
+
const useSwapRoutes = ({ onSettled, insurableRoute, } = {}) => {
|
|
15
15
|
const lifi = (0, providers_1.useLiFi)();
|
|
16
|
-
const { variant, sdkConfig } = (0, providers_1.useWidgetConfig)();
|
|
16
|
+
const { variant, sdkConfig, insurance } = (0, providers_1.useWidgetConfig)();
|
|
17
17
|
const { account, provider } = (0, providers_1.useWallet)();
|
|
18
18
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
19
|
-
const { slippage, enabledBridges, enabledExchanges, routePriority } = (0, stores_1.useSettings)([
|
|
19
|
+
const { slippage, enabledBridges, enabledAutoRefuel, enabledExchanges, routePriority, } = (0, stores_1.useSettings)([
|
|
20
20
|
'slippage',
|
|
21
21
|
'routePriority',
|
|
22
|
+
'enabledAutoRefuel',
|
|
22
23
|
'enabledBridges',
|
|
23
24
|
'enabledExchanges',
|
|
24
25
|
]);
|
|
@@ -38,6 +39,7 @@ const useSwapRoutes = () => {
|
|
|
38
39
|
});
|
|
39
40
|
const { token: fromToken } = (0, _1.useToken)(fromChainId, fromTokenAddress);
|
|
40
41
|
const { token: toToken } = (0, _1.useToken)(toChainId, toTokenAddress);
|
|
42
|
+
const { enabled: enabledRefuel, gasRecommendation } = (0, _1.useGasRefuel)();
|
|
41
43
|
const hasAmount = (!isNaN(fromTokenAmount) && Number(fromTokenAmount) > 0) ||
|
|
42
44
|
(!isNaN(toTokenAmount) && Number(toTokenAmount) > 0);
|
|
43
45
|
const contractCallQuoteEnabled = variant === 'nft'
|
|
@@ -69,12 +71,12 @@ const useSwapRoutes = () => {
|
|
|
69
71
|
routePriority,
|
|
70
72
|
variant,
|
|
71
73
|
sdkConfig?.defaultRouteOptions?.allowSwitchChain,
|
|
74
|
+
enabledRefuel && enabledAutoRefuel,
|
|
75
|
+
gasRecommendation?.fromAmount,
|
|
76
|
+
insurance,
|
|
77
|
+
insurableRoute?.id,
|
|
72
78
|
];
|
|
73
|
-
const
|
|
74
|
-
const refetchInterval = previousDataUpdatedAt
|
|
75
|
-
? Math.min(Math.abs(refetchTime - (Date.now() - previousDataUpdatedAt)), refetchTime)
|
|
76
|
-
: refetchTime;
|
|
77
|
-
const { data, isLoading, isFetching, isFetched, dataUpdatedAt, refetch } = (0, react_query_1.useQuery)(queryKey, async ({ queryKey: [_, fromAddress, fromChainId, fromTokenAddress, fromTokenAmount, toAddress, toChainId, toTokenAddress, toTokenAmount, toContractAddress, toContractCallData, toContractGasLimit, slippage, enabledBridges, enabledExchanges, routePriority, variant, allowSwitchChain,], signal, }) => {
|
|
79
|
+
const { data, isLoading, isFetching, isFetched, dataUpdatedAt, refetch } = (0, react_query_1.useQuery)(queryKey, async ({ queryKey: [_, fromAddress, fromChainId, fromTokenAddress, fromTokenAmount, toAddress, toChainId, toTokenAddress, toTokenAmount, toContractAddress, toContractCallData, toContractGasLimit, slippage, enabledBridges, enabledExchanges, routePriority, variant, allowSwitchChain, enabledRefuel, gasRecommendationFromAmount, insurance, insurableRouteId,], signal, }) => {
|
|
78
80
|
let toWalletAddress;
|
|
79
81
|
try {
|
|
80
82
|
toWalletAddress =
|
|
@@ -120,9 +122,20 @@ const useSwapRoutes = () => {
|
|
|
120
122
|
toAddress: toAddress,
|
|
121
123
|
gasCostUSD: contractCallQuote.estimate.gasCosts?.[0].amountUSD,
|
|
122
124
|
steps: [contractCallQuote],
|
|
125
|
+
insurance: { state: 'NOT_INSURABLE', feeAmountUsd: '0' },
|
|
123
126
|
};
|
|
124
127
|
return { routes: [route] };
|
|
125
128
|
}
|
|
129
|
+
const allowedBridges = insurableRoute
|
|
130
|
+
? insurableRoute.steps.flatMap((step) => step.includedSteps
|
|
131
|
+
.filter((includedStep) => includedStep.type === 'cross')
|
|
132
|
+
.map((includedStep) => includedStep.toolDetails.key))
|
|
133
|
+
: enabledBridges;
|
|
134
|
+
const allowedExchanges = insurableRoute
|
|
135
|
+
? insurableRoute.steps.flatMap((step) => step.includedSteps
|
|
136
|
+
.filter((includedStep) => includedStep.type === 'swap')
|
|
137
|
+
.map((includedStep) => includedStep.toolDetails.key))
|
|
138
|
+
: enabledExchanges;
|
|
126
139
|
return lifi.getRoutes({
|
|
127
140
|
fromChainId,
|
|
128
141
|
fromAmount,
|
|
@@ -131,23 +144,29 @@ const useSwapRoutes = () => {
|
|
|
131
144
|
toTokenAddress,
|
|
132
145
|
fromAddress,
|
|
133
146
|
toAddress: toWalletAddress,
|
|
147
|
+
fromAmountForGas: enabledRefuel && gasRecommendationFromAmount
|
|
148
|
+
? gasRecommendationFromAmount
|
|
149
|
+
: undefined,
|
|
134
150
|
options: {
|
|
135
151
|
slippage: formattedSlippage,
|
|
136
152
|
bridges: {
|
|
137
|
-
allow:
|
|
153
|
+
allow: allowedBridges,
|
|
138
154
|
},
|
|
139
155
|
exchanges: {
|
|
140
|
-
allow:
|
|
156
|
+
allow: allowedExchanges,
|
|
141
157
|
},
|
|
142
158
|
order: routePriority,
|
|
143
159
|
allowSwitchChain: variant === 'refuel' ? false : allowSwitchChain,
|
|
160
|
+
insurance: insurance ? Boolean(insurableRoute) : undefined,
|
|
144
161
|
},
|
|
145
162
|
}, { signal });
|
|
146
163
|
}, {
|
|
147
164
|
enabled: isEnabled,
|
|
148
|
-
refetchInterval,
|
|
149
165
|
staleTime: refetchTime,
|
|
150
166
|
cacheTime: refetchTime,
|
|
167
|
+
refetchInterval(data, query) {
|
|
168
|
+
return Math.min(Math.abs(refetchTime - (Date.now() - query.state.dataUpdatedAt)), refetchTime);
|
|
169
|
+
},
|
|
151
170
|
retry(failureCount, error) {
|
|
152
171
|
if (error?.code === sdk_1.LifiErrorCode.NotFound) {
|
|
153
172
|
return false;
|
|
@@ -173,6 +192,7 @@ const useSwapRoutes = () => {
|
|
|
173
192
|
});
|
|
174
193
|
}
|
|
175
194
|
},
|
|
195
|
+
onSettled,
|
|
176
196
|
});
|
|
177
197
|
return {
|
|
178
198
|
routes: data?.routes,
|
|
@@ -6,8 +6,10 @@ const useTokenBalances_1 = require("./useTokenBalances");
|
|
|
6
6
|
const useTokenAddressBalance = (chainId, tokenAddress) => {
|
|
7
7
|
const { tokens, tokensWithBalance, isBalanceLoading, refetch } = (0, useTokenBalances_1.useTokenBalances)(chainId);
|
|
8
8
|
const token = (0, react_1.useMemo)(() => {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
if (tokenAddress && chainId) {
|
|
10
|
+
const token = (tokensWithBalance ?? tokens)?.find((token) => token.address === tokenAddress && token.chainId === chainId);
|
|
11
|
+
return token;
|
|
12
|
+
}
|
|
11
13
|
}, [chainId, tokenAddress, tokens, tokensWithBalance]);
|
|
12
14
|
return {
|
|
13
15
|
token,
|
|
@@ -5,31 +5,13 @@ const react_query_1 = require("@tanstack/react-query");
|
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const providers_1 = require("../providers");
|
|
7
7
|
const utils_1 = require("../utils");
|
|
8
|
+
const useGetTokenBalancesWithRetry_1 = require("./useGetTokenBalancesWithRetry");
|
|
8
9
|
const defaultRefetchInterval = 30000;
|
|
9
10
|
const useTokenBalance = (token, accountAddress) => {
|
|
10
|
-
const
|
|
11
|
-
const { account } = (0, providers_1.useWallet)();
|
|
11
|
+
const { account, provider } = (0, providers_1.useWallet)();
|
|
12
12
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
13
|
-
const walletAddress = accountAddress
|
|
14
|
-
const getTokenBalancesWithRetry = (0,
|
|
15
|
-
try {
|
|
16
|
-
const tokenBalances = await lifi.getTokenBalances(accountAddress, tokens);
|
|
17
|
-
if (!tokenBalances.every((token) => token.blockNumber)) {
|
|
18
|
-
if (depth > 10) {
|
|
19
|
-
console.warn('Token balance backoff depth exceeded.');
|
|
20
|
-
return undefined;
|
|
21
|
-
}
|
|
22
|
-
await new Promise((resolve) => {
|
|
23
|
-
setTimeout(resolve, 1.5 ** depth * 100);
|
|
24
|
-
});
|
|
25
|
-
return getTokenBalancesWithRetry(accountAddress, tokens, depth + 1);
|
|
26
|
-
}
|
|
27
|
-
return tokenBalances;
|
|
28
|
-
}
|
|
29
|
-
catch (error) {
|
|
30
|
-
//
|
|
31
|
-
}
|
|
32
|
-
}, [lifi]);
|
|
13
|
+
const walletAddress = accountAddress || account.address;
|
|
14
|
+
const getTokenBalancesWithRetry = (0, useGetTokenBalancesWithRetry_1.useGetTokenBalancesWithRetry)(provider);
|
|
33
15
|
const tokenBalanceQueryKey = (0, react_1.useMemo)(() => ['token-balance', walletAddress, token?.chainId, token?.address], [token?.address, token?.chainId, walletAddress]);
|
|
34
16
|
const { data, isLoading, refetch } = (0, react_query_1.useQuery)(tokenBalanceQueryKey, async ({ queryKey: [, accountAddress] }) => {
|
|
35
17
|
const cachedToken = queryClient
|
|
@@ -2,7 +2,7 @@ import type { Token } from '../types';
|
|
|
2
2
|
export declare const useTokenBalances: (selectedChainId?: number) => {
|
|
3
3
|
tokens: Token[];
|
|
4
4
|
tokensWithBalance: Token[] | undefined;
|
|
5
|
-
featuredTokens: import("@lifi/types").Token[];
|
|
5
|
+
featuredTokens: import("@lifi/types").Token[] | undefined;
|
|
6
6
|
isLoading: boolean;
|
|
7
7
|
isBalanceLoading: boolean;
|
|
8
8
|
refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<Token[], unknown>>;
|
|
@@ -13,9 +13,9 @@ const useTokenSearch = (chainId, tokenQuery, enabled) => {
|
|
|
13
13
|
if (token) {
|
|
14
14
|
queryClient.setQueriesData(['tokens'], (data) => {
|
|
15
15
|
if (data &&
|
|
16
|
-
!data.tokens[chainId]
|
|
16
|
+
!data.tokens[chainId]?.some((t) => t.address === token.address)) {
|
|
17
17
|
const clonedData = { ...data };
|
|
18
|
-
clonedData.tokens[chainId]
|
|
18
|
+
clonedData.tokens[chainId]?.push(token);
|
|
19
19
|
return clonedData;
|
|
20
20
|
}
|
|
21
21
|
});
|
package/cjs/hooks/useTokens.js
CHANGED
|
@@ -11,14 +11,14 @@ const useTokens = (selectedChainId) => {
|
|
|
11
11
|
const { data, isLoading, dataUpdatedAt } = (0, react_query_1.useQuery)(['tokens'], () => lifi.getTokens());
|
|
12
12
|
const { getChainById, isLoading: isSupportedChainsLoading } = (0, useChains_1.useChains)();
|
|
13
13
|
const featuredTokens = (0, useFeaturedTokens_1.useFeaturedTokens)(selectedChainId);
|
|
14
|
-
const { tokens: configTokens, chains: configChains
|
|
14
|
+
const { tokens: configTokens, chains: configChains } = (0, providers_1.useWidgetConfig)();
|
|
15
15
|
const tokens = (0, react_1.useMemo)(() => {
|
|
16
16
|
if (isSupportedChainsLoading) {
|
|
17
17
|
return [];
|
|
18
18
|
}
|
|
19
19
|
const chainAllowed = selectedChainId &&
|
|
20
20
|
getChainById(selectedChainId) &&
|
|
21
|
-
(0, providers_1.isItemAllowed)(selectedChainId, configChains
|
|
21
|
+
(0, providers_1.isItemAllowed)(selectedChainId, configChains);
|
|
22
22
|
if (!chainAllowed) {
|
|
23
23
|
return [];
|
|
24
24
|
}
|
|
@@ -47,7 +47,6 @@ const useTokens = (selectedChainId) => {
|
|
|
47
47
|
selectedChainId,
|
|
48
48
|
getChainById,
|
|
49
49
|
configChains,
|
|
50
|
-
disabledChains,
|
|
51
50
|
configTokens?.allow,
|
|
52
51
|
configTokens?.deny,
|
|
53
52
|
featuredTokens,
|
package/cjs/i18n/en.json
CHANGED
|
@@ -106,12 +106,14 @@
|
|
|
106
106
|
"inProgress": "in progress",
|
|
107
107
|
"info": {
|
|
108
108
|
"message": {
|
|
109
|
+
"autoRefuel": "You're low on {{chainName}} gas. By continuing, you'll get enough gas to complete the swap.",
|
|
109
110
|
"emptyActiveSwaps": "Swaps in progress will appear here. Once completed, find them in swap history.",
|
|
110
111
|
"emptySwapHistory": "Swap history is only stored locally and will be deleted if you clear your browser data.",
|
|
111
112
|
"emptyTokenList": "We couldn't find tokens on {{chainName}} chain or you don't have any. Please try search again or choose another chain.",
|
|
112
113
|
"routeNotFound": "Try another token combination."
|
|
113
114
|
},
|
|
114
115
|
"title": {
|
|
116
|
+
"autoRefuel": "Get gas",
|
|
115
117
|
"emptyActiveSwaps": "No active swaps",
|
|
116
118
|
"emptySwapHistory": "No recent swaps",
|
|
117
119
|
"routeNotFound": "No routes available"
|
|
@@ -154,6 +156,7 @@
|
|
|
154
156
|
"quotedAmount": "Quoted amount",
|
|
155
157
|
"rateChange": "Rate change",
|
|
156
158
|
"receiving": "Receiving",
|
|
159
|
+
"refuelStepDetails": "Get gas via {{tool}}",
|
|
157
160
|
"routes": "You get",
|
|
158
161
|
"selectChain": "Chain",
|
|
159
162
|
"selectChainAndToken": "Select chain and token",
|
|
@@ -162,6 +165,7 @@
|
|
|
162
165
|
"sendToWallet": "Send to a different wallet",
|
|
163
166
|
"sentToAddress": "Sent to {{address}}",
|
|
164
167
|
"stepBridge": "Bridge",
|
|
168
|
+
"stepDetails": "{{tool}} via LI.FI",
|
|
165
169
|
"stepSwap": "Swap",
|
|
166
170
|
"stepSwapAndBridge": "Swap and bridge",
|
|
167
171
|
"success": {
|
|
@@ -180,11 +184,13 @@
|
|
|
180
184
|
"swapStepDetails": "Swap on {{chain}} via {{tool}}",
|
|
181
185
|
"swapping": "Swapping",
|
|
182
186
|
"tags": {
|
|
183
|
-
"
|
|
184
|
-
"
|
|
185
|
-
"
|
|
186
|
-
"
|
|
187
|
-
"
|
|
187
|
+
"cheapest": "Cheap",
|
|
188
|
+
"fastest": "Fast",
|
|
189
|
+
"insurable": "Insurable",
|
|
190
|
+
"insurance": "Insurance",
|
|
191
|
+
"insured": "Insured",
|
|
192
|
+
"recommended": "Recommended",
|
|
193
|
+
"safest": "Safe"
|
|
188
194
|
},
|
|
189
195
|
"to": "To",
|
|
190
196
|
"tokenOnChain": "{{tokenSymbol}} on {{chainName}}",
|
|
@@ -197,8 +203,8 @@
|
|
|
197
203
|
"deleteActiveSwaps": "Active swaps are only stored locally and can't be recovered if you delete them.",
|
|
198
204
|
"deleteSwapHistory": "Swap history is only stored locally and can't be recovered if you delete it.",
|
|
199
205
|
"highValueLoss": "The value of the received tokens is significantly lower than the swapped tokens and transaction cost.",
|
|
200
|
-
"insufficientFunds": "You don't have enough funds to
|
|
201
|
-
"insufficientGas": "You need to add at least:",
|
|
206
|
+
"insufficientFunds": "You don't have enough funds to complete the swap.",
|
|
207
|
+
"insufficientGas": "You don't have enough gas to complete the swap. You need to add at least:",
|
|
202
208
|
"rateChanged": "The exchange rate has changed. By continuing the swap, you'll accept the new rate.",
|
|
203
209
|
"resetSettings": "This will reset your route priority, slippage, gas price, enabled bridges and exchanges."
|
|
204
210
|
},
|
|
@@ -214,6 +220,7 @@
|
|
|
214
220
|
}
|
|
215
221
|
},
|
|
216
222
|
"tooltip": {
|
|
223
|
+
"additionalProviderFee": "Additional bridges, DEXs, and service fees.",
|
|
217
224
|
"estimatedNetworkFee": "Estimated network fee.",
|
|
218
225
|
"estimatedTime": "Estimated swap execution time in minutes.",
|
|
219
226
|
"notFound": {
|
package/cjs/i18n/it.json
CHANGED
|
@@ -106,12 +106,14 @@
|
|
|
106
106
|
"inProgress": "in corso",
|
|
107
107
|
"info": {
|
|
108
108
|
"message": {
|
|
109
|
+
"autoRefuel": "Livello basso di gas su {{chainName}}. Continuando avrai abbastanza gas per completare lo scambio.",
|
|
109
110
|
"emptyActiveSwaps": "Gli scambi in corso verranno visualizzati qui. Una volta completati, saranno presenti nella cronologia di scambi.",
|
|
110
111
|
"emptySwapHistory": "La cronologia di scambi viene memorizzata solo localmente e verrà cancellata se si cancellano i dati del browser.",
|
|
111
112
|
"emptyTokenList": "Non siamo riusciti a trovare token sulla chain {{chainName}} o non ne hai. Riprova o scegli un'altra chain.",
|
|
112
113
|
"routeNotFound": "Prova un'altra combinazione di token."
|
|
113
114
|
},
|
|
114
115
|
"title": {
|
|
116
|
+
"autoRefuel": "Ottieni gas",
|
|
115
117
|
"emptyActiveSwaps": "Nessuno scambio attivo",
|
|
116
118
|
"emptySwapHistory": "Nessuno scambio recente",
|
|
117
119
|
"routeNotFound": "Nessuna rotta disponibile"
|
|
@@ -154,6 +156,7 @@
|
|
|
154
156
|
"quotedAmount": "Totale quotato",
|
|
155
157
|
"rateChange": "Tasso di scambio",
|
|
156
158
|
"receiving": "In ricezione",
|
|
159
|
+
"refuelStepDetails": "Ottieni gas tramite {{tool}}",
|
|
157
160
|
"routes": "Ottieni",
|
|
158
161
|
"selectChain": "Chain",
|
|
159
162
|
"selectChainAndToken": "Selezionare la chain ed il token",
|
|
@@ -162,6 +165,7 @@
|
|
|
162
165
|
"sendToWallet": "Invia ad un altro portafoglio",
|
|
163
166
|
"sentToAddress": "Inviati a {{address}}",
|
|
164
167
|
"stepBridge": "Bridge",
|
|
168
|
+
"stepDetails": "{{tool}} tramite LI.FI",
|
|
165
169
|
"stepSwap": "Scambio",
|
|
166
170
|
"stepSwapAndBridge": "Scambia e bridge",
|
|
167
171
|
"success": {
|
|
@@ -197,8 +201,8 @@
|
|
|
197
201
|
"deleteActiveSwaps": "Gli scambi attivi vengono memorizzati solo localmente e non possono essere recuperati se vengono cancellati.",
|
|
198
202
|
"deleteSwapHistory": "La cronologia degli scambi viene memorizzata solo localmente e, se cancellata, non può essere recuperata.",
|
|
199
203
|
"highValueLoss": "Il valore dei token ricevuti è significativamente inferiore ai token scambiati più il costo della transazione.",
|
|
200
|
-
"insufficientFunds": "Non hai abbastanza fondi per
|
|
201
|
-
"insufficientGas": "
|
|
204
|
+
"insufficientFunds": "Non hai abbastanza fondi per completare lo scambio.",
|
|
205
|
+
"insufficientGas": "Non hai abbastanza gas per completare lo scambio. Devi aggiungere almeno:",
|
|
202
206
|
"rateChanged": "Il tasso di scambio è cambiato. Se procedi, confermi di accettare il nuovo tasso.",
|
|
203
207
|
"resetSettings": "Questo porterà al ripristino della priorità di route, slittamento di prezzo, prezzo del gas, bridge abilitati ed exchanges."
|
|
204
208
|
},
|