@lifi/widget 1.15.1 → 1.17.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 +21 -0
- package/AppProvider.d.ts +0 -4
- package/AppProvider.js +2 -10
- package/README.md +1 -1
- package/cjs/App.js +21 -0
- package/cjs/AppProvider.d.ts +0 -4
- package/cjs/AppProvider.js +3 -12
- package/cjs/components/ActiveSwaps/ActiveSwapItem.d.ts +5 -0
- package/cjs/components/ActiveSwaps/ActiveSwapItem.js +45 -0
- package/cjs/components/{SwapsInProgress/SwapsInProgress.d.ts → ActiveSwaps/ActiveSwaps.d.ts} +1 -1
- package/cjs/components/ActiveSwaps/ActiveSwaps.js +30 -0
- package/cjs/components/ActiveSwaps/ActiveSwaps.style.d.ts +78 -0
- package/cjs/components/ActiveSwaps/ActiveSwaps.style.js +40 -0
- package/cjs/components/ActiveSwaps/index.d.ts +2 -0
- package/cjs/components/ActiveSwaps/index.js +18 -0
- package/cjs/components/AppContainer.js +2 -2
- package/cjs/components/Card/Card.d.ts +7 -4
- package/cjs/components/Card/Card.js +38 -28
- package/cjs/{pages/SelectTokenPage → components/ChainSelect}/ChainSelect.d.ts +0 -0
- package/cjs/components/ChainSelect/ChainSelect.js +35 -0
- package/cjs/components/{SwapsInProgress/SwapsInProgress.style.d.ts → ChainSelect/ChainSelect.style.d.ts} +10 -19
- package/cjs/components/ChainSelect/ChainSelect.style.js +19 -0
- package/cjs/components/ChainSelect/index.d.ts +2 -0
- package/cjs/components/ChainSelect/index.js +18 -0
- package/cjs/components/ChainSelect/useChainSelect.d.ts +8 -0
- package/cjs/components/ChainSelect/useChainSelect.js +33 -0
- package/cjs/components/GasSufficiencyMessage/GasSufficiencyMessage.js +3 -3
- package/cjs/components/Header/Header.js +1 -9
- package/cjs/components/Header/NavigationHeader.js +6 -11
- package/cjs/components/Header/useHeaderActionStore.d.ts +0 -2
- package/cjs/components/Header/useHeaderActionStore.js +1 -5
- package/cjs/components/PoweredBy/PoweredBy.style.d.ts +1 -1
- package/cjs/components/PoweredBy/PoweredBy.style.js +1 -0
- package/cjs/components/SelectChainAndToken.js +5 -5
- package/cjs/components/SendToWallet/SendToWallet.js +6 -6
- package/cjs/components/Step/CircularProgress.js +1 -1
- package/cjs/components/Step/CircularProgress.style.js +1 -1
- package/cjs/components/Step/StepProcess.js +1 -5
- package/cjs/components/Step/StepProcess.style.d.ts +1 -1
- package/cjs/components/Step/StepTimer.d.ts +1 -0
- package/cjs/components/Step/StepTimer.js +6 -6
- package/cjs/components/SwapButton/SwapButton.js +5 -32
- package/cjs/components/SwapButton/types.d.ts +2 -2
- package/cjs/components/SwapRouteCard/SwapRouteCard.js +1 -1
- package/cjs/components/TokenAvatar/TokenAvatar.style.js +0 -3
- package/cjs/components/TokenList/TokenList.js +7 -3
- package/cjs/components/TokenList/TokenList.style.js +4 -3
- package/cjs/components/TokenList/TokenListItem.js +1 -1
- package/cjs/components/TokenList/TokenNotFound.d.ts +2 -1
- package/cjs/components/TokenList/TokenNotFound.js +12 -2
- package/cjs/components/TokenList/types.d.ts +2 -2
- package/cjs/config/theme.js +24 -23
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/hooks/index.d.ts +2 -0
- package/cjs/hooks/index.js +2 -0
- package/cjs/hooks/useChains.d.ts +1 -97
- package/cjs/hooks/useChains.js +26 -20
- package/cjs/hooks/useFeaturedTokens.d.ts +1 -1
- package/cjs/hooks/useFeaturedTokens.js +6 -3
- package/cjs/hooks/useGasSufficiency.d.ts +1 -1
- package/cjs/hooks/useGasSufficiency.js +36 -28
- package/cjs/hooks/useInitializer.js +6 -0
- package/cjs/{components/Step/utils.d.ts → hooks/useProcessMessage.d.ts} +4 -0
- package/cjs/{components/Step/utils.js → hooks/useProcessMessage.js} +16 -10
- package/cjs/hooks/useRouteExecution.d.ts +1 -1
- package/cjs/hooks/useRouteExecution.js +26 -35
- package/cjs/hooks/useSwapRoutes.js +10 -11
- package/cjs/hooks/useToken.d.ts +0 -1
- package/cjs/hooks/useToken.js +1 -2
- package/cjs/hooks/useTokenBalances.d.ts +1 -2
- package/cjs/hooks/useTokenBalances.js +5 -6
- package/cjs/hooks/useTokenSearch.js +3 -2
- package/cjs/hooks/useTokens.d.ts +1 -2
- package/cjs/hooks/useTokens.js +32 -9
- package/cjs/hooks/useTools.js +11 -5
- package/cjs/hooks/useWidgetEvents.d.ts +3 -0
- package/cjs/hooks/useWidgetEvents.js +13 -0
- package/cjs/i18n/en/translation.json +14 -10
- package/cjs/i18n/index.d.ts +11 -7
- package/cjs/index.d.ts +1 -0
- package/cjs/index.js +3 -1
- package/cjs/pages/ActiveSwapsPage/ActiveSwapsEmpty.d.ts +2 -0
- package/cjs/pages/ActiveSwapsPage/ActiveSwapsEmpty.js +18 -0
- package/cjs/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +2 -0
- package/cjs/pages/ActiveSwapsPage/ActiveSwapsPage.js +21 -0
- package/cjs/pages/ActiveSwapsPage/index.d.ts +1 -0
- package/cjs/{components/SwapsInProgress → pages/ActiveSwapsPage}/index.js +1 -1
- package/cjs/pages/MainPage/MainPage.js +2 -3
- package/cjs/pages/MainPage/MainSwapButton.js +3 -1
- package/cjs/pages/MainPage/SwapRoutes.js +4 -1
- package/cjs/pages/SelectChainPage/SelectChainPage.d.ts +3 -0
- package/cjs/pages/SelectChainPage/SelectChainPage.js +33 -0
- package/cjs/pages/SelectChainPage/SelectChainPage.style.d.ts +21 -0
- package/cjs/pages/SelectChainPage/SelectChainPage.style.js +20 -0
- package/cjs/pages/SelectChainPage/index.d.ts +1 -0
- package/cjs/pages/SelectChainPage/index.js +17 -0
- package/cjs/pages/SelectTokenPage/SelectTokenPage.d.ts +2 -4
- package/cjs/pages/SelectTokenPage/SelectTokenPage.js +2 -2
- package/cjs/pages/SelectWalletPage/SelectWalletPage.js +4 -4
- package/cjs/pages/SelectWalletPage/SelectWalletPage.style.d.ts +2 -27
- package/cjs/pages/SelectWalletPage/SelectWalletPage.style.js +4 -14
- package/cjs/pages/SettingsPage/AdvancedPreferences.js +1 -1
- package/cjs/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +1 -1
- package/cjs/pages/SettingsPage/EnabledBridgesSelect.js +3 -6
- package/cjs/pages/SettingsPage/EnabledExchangesSelect.js +3 -5
- package/cjs/pages/SettingsPage/GasPriceSelect.js +1 -1
- package/cjs/pages/SettingsPage/RoutePrioritySelect.js +6 -2
- package/cjs/pages/SettingsPage/ShowDestinationWallet.js +1 -1
- package/cjs/pages/SettingsPage/SlippageInput.js +1 -1
- package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +3 -4
- package/cjs/pages/SwapHistoryPage/SwapHistoryPage.js +2 -3
- package/cjs/pages/SwapPage/StatusBottomSheet.js +25 -36
- package/cjs/pages/SwapPage/SwapPage.js +16 -3
- package/cjs/pages/SwapRoutesPage/SwapRoutesPage.js +4 -3
- package/cjs/providers/SDKProvider/SDKProvider.d.ts +4 -0
- package/cjs/providers/SDKProvider/SDKProvider.js +27 -0
- package/cjs/providers/SDKProvider/index.d.ts +1 -0
- package/cjs/providers/SDKProvider/index.js +17 -0
- package/cjs/providers/SwapFormProvider/SwapFormProvider.js +4 -30
- package/cjs/providers/SwapFormProvider/types.d.ts +5 -5
- package/cjs/providers/TelemetryProvider/TelemetryProvider.d.ts +4 -0
- package/cjs/providers/TelemetryProvider/TelemetryProvider.js +11 -0
- package/cjs/providers/TelemetryProvider/index.d.ts +1 -0
- package/cjs/providers/TelemetryProvider/index.js +17 -0
- package/cjs/providers/WalletProvider/WalletProvider.d.ts +1 -4
- package/cjs/providers/WalletProvider/WalletProvider.js +59 -1
- package/cjs/providers/WidgetProvider/WidgetProvider.js +1 -16
- package/cjs/providers/WidgetProvider/index.d.ts +1 -0
- package/cjs/providers/WidgetProvider/index.js +1 -0
- package/cjs/providers/WidgetProvider/utils.d.ts +4 -0
- package/cjs/providers/WidgetProvider/utils.js +13 -0
- package/cjs/providers/index.d.ts +2 -0
- package/cjs/providers/index.js +2 -0
- package/cjs/stores/chains/index.d.ts +3 -0
- package/cjs/stores/chains/index.js +19 -0
- package/cjs/stores/chains/types.d.ts +8 -0
- package/cjs/stores/chains/types.js +2 -0
- package/cjs/stores/chains/useChainOrder.d.ts +1 -0
- package/cjs/stores/chains/useChainOrder.js +12 -0
- package/cjs/stores/chains/useChainOrderStore.d.ts +19 -0
- package/cjs/stores/chains/useChainOrderStore.js +45 -0
- package/cjs/stores/route/index.d.ts +2 -1
- package/cjs/stores/route/index.js +2 -1
- package/cjs/stores/route/useExecutingRoutesIds.d.ts +1 -0
- package/cjs/stores/route/useExecutingRoutesIds.js +20 -0
- package/cjs/stores/route/useRouteStore.js +5 -4
- package/cjs/stores/route/utils.d.ts +4 -0
- package/cjs/stores/route/utils.js +21 -0
- package/cjs/stores/settings/index.d.ts +0 -1
- package/cjs/stores/settings/index.js +0 -1
- package/cjs/stores/settings/useAppearance.js +3 -1
- package/cjs/stores/settings/useSettingsStore.js +5 -2
- package/cjs/types/events.d.ts +5 -0
- package/cjs/types/events.js +9 -0
- package/cjs/types/index.d.ts +1 -0
- package/cjs/types/index.js +1 -0
- package/cjs/types/widget.d.ts +31 -23
- package/cjs/utils/colors.d.ts +1 -1
- package/cjs/utils/navigationRoutes.d.ts +5 -0
- package/cjs/utils/navigationRoutes.js +31 -4
- package/components/ActiveSwaps/ActiveSwapItem.d.ts +5 -0
- package/components/ActiveSwaps/ActiveSwapItem.js +41 -0
- package/components/{SwapsInProgress/SwapsInProgress.d.ts → ActiveSwaps/ActiveSwaps.d.ts} +1 -1
- package/components/ActiveSwaps/ActiveSwaps.js +26 -0
- package/components/ActiveSwaps/ActiveSwaps.style.d.ts +78 -0
- package/components/ActiveSwaps/ActiveSwaps.style.js +37 -0
- package/components/ActiveSwaps/index.d.ts +2 -0
- package/components/ActiveSwaps/index.js +2 -0
- package/components/AppContainer.js +1 -1
- package/components/Card/Card.d.ts +7 -4
- package/components/Card/Card.js +39 -29
- package/{pages/SelectTokenPage → components/ChainSelect}/ChainSelect.d.ts +0 -0
- package/components/ChainSelect/ChainSelect.js +31 -0
- package/components/{SwapsInProgress/SwapsInProgress.style.d.ts → ChainSelect/ChainSelect.style.d.ts} +10 -19
- package/components/ChainSelect/ChainSelect.style.js +16 -0
- package/components/ChainSelect/index.d.ts +2 -0
- package/components/ChainSelect/index.js +2 -0
- package/components/ChainSelect/useChainSelect.d.ts +8 -0
- package/components/ChainSelect/useChainSelect.js +29 -0
- package/components/GasSufficiencyMessage/GasSufficiencyMessage.js +3 -3
- package/components/Header/Header.js +1 -9
- package/components/Header/NavigationHeader.js +6 -11
- package/components/Header/useHeaderActionStore.d.ts +0 -2
- package/components/Header/useHeaderActionStore.js +0 -3
- package/components/PoweredBy/PoweredBy.style.d.ts +1 -1
- package/components/PoweredBy/PoweredBy.style.js +1 -0
- package/components/SelectChainAndToken.js +1 -1
- package/components/SendToWallet/SendToWallet.js +6 -6
- package/components/Step/CircularProgress.js +3 -3
- package/components/Step/CircularProgress.style.js +1 -1
- package/components/Step/StepProcess.js +2 -6
- package/components/Step/StepProcess.style.d.ts +1 -1
- package/components/Step/StepTimer.d.ts +1 -0
- package/components/Step/StepTimer.js +6 -6
- package/components/SwapButton/SwapButton.js +7 -34
- package/components/SwapButton/types.d.ts +2 -2
- package/components/SwapRouteCard/SwapRouteCard.js +1 -1
- package/components/TokenAvatar/TokenAvatar.style.js +0 -3
- package/components/TokenList/TokenList.js +7 -3
- package/components/TokenList/TokenList.style.js +4 -3
- package/components/TokenList/TokenListItem.js +1 -1
- package/components/TokenList/TokenNotFound.d.ts +2 -1
- package/components/TokenList/TokenNotFound.js +12 -2
- package/components/TokenList/types.d.ts +2 -2
- package/config/theme.js +24 -23
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/index.d.ts +2 -0
- package/hooks/index.js +2 -0
- package/hooks/useChains.d.ts +1 -97
- package/hooks/useChains.js +26 -20
- package/hooks/useFeaturedTokens.d.ts +1 -1
- package/hooks/useFeaturedTokens.js +6 -3
- package/hooks/useGasSufficiency.d.ts +1 -1
- package/hooks/useGasSufficiency.js +32 -24
- package/hooks/useInitializer.js +6 -0
- package/{components/Step/utils.d.ts → hooks/useProcessMessage.d.ts} +4 -0
- package/{pages/SwapPage/utils.js → hooks/useProcessMessage.js} +15 -10
- package/hooks/useRouteExecution.d.ts +1 -1
- package/hooks/useRouteExecution.js +26 -35
- package/hooks/useSwapRoutes.js +3 -4
- package/hooks/useToken.d.ts +0 -1
- package/hooks/useToken.js +1 -2
- package/hooks/useTokenBalances.d.ts +1 -2
- package/hooks/useTokenBalances.js +4 -5
- package/hooks/useTokenSearch.js +3 -2
- package/hooks/useTokens.d.ts +1 -2
- package/hooks/useTokens.js +32 -9
- package/hooks/useTools.js +11 -5
- package/hooks/useWidgetEvents.d.ts +3 -0
- package/hooks/useWidgetEvents.js +6 -0
- package/i18n/en/translation.json +14 -10
- package/i18n/index.d.ts +11 -7
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +15 -14
- package/pages/ActiveSwapsPage/ActiveSwapsEmpty.d.ts +2 -0
- package/pages/ActiveSwapsPage/ActiveSwapsEmpty.js +14 -0
- package/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +2 -0
- package/pages/ActiveSwapsPage/ActiveSwapsPage.js +17 -0
- package/pages/ActiveSwapsPage/index.d.ts +1 -0
- package/pages/ActiveSwapsPage/index.js +1 -0
- package/pages/MainPage/MainPage.js +2 -3
- package/pages/MainPage/MainSwapButton.js +3 -1
- package/pages/MainPage/SwapRoutes.js +4 -1
- package/pages/SelectChainPage/SelectChainPage.d.ts +3 -0
- package/pages/SelectChainPage/SelectChainPage.js +29 -0
- package/pages/SelectChainPage/SelectChainPage.style.d.ts +21 -0
- package/pages/SelectChainPage/SelectChainPage.style.js +17 -0
- package/pages/SelectChainPage/index.d.ts +1 -0
- package/pages/SelectChainPage/index.js +1 -0
- package/pages/SelectTokenPage/SelectTokenPage.d.ts +2 -4
- package/pages/SelectTokenPage/SelectTokenPage.js +2 -2
- package/pages/SelectWalletPage/SelectWalletPage.js +5 -5
- package/pages/SelectWalletPage/SelectWalletPage.style.d.ts +2 -27
- package/pages/SelectWalletPage/SelectWalletPage.style.js +4 -14
- package/pages/SettingsPage/AdvancedPreferences.js +2 -2
- package/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +1 -1
- package/pages/SettingsPage/EnabledBridgesSelect.js +4 -7
- package/pages/SettingsPage/EnabledExchangesSelect.js +4 -6
- package/pages/SettingsPage/GasPriceSelect.js +2 -2
- package/pages/SettingsPage/RoutePrioritySelect.js +7 -3
- package/pages/SettingsPage/ShowDestinationWallet.js +2 -2
- package/pages/SettingsPage/SlippageInput.js +2 -2
- package/pages/SwapDetailsPage/SwapDetailsPage.js +4 -5
- package/pages/SwapHistoryPage/SwapHistoryPage.js +3 -4
- package/pages/SwapPage/StatusBottomSheet.js +27 -38
- package/pages/SwapPage/SwapPage.js +16 -3
- package/pages/SwapRoutesPage/SwapRoutesPage.js +5 -4
- package/providers/SDKProvider/SDKProvider.d.ts +4 -0
- package/providers/SDKProvider/SDKProvider.js +19 -0
- package/providers/SDKProvider/index.d.ts +1 -0
- package/providers/SDKProvider/index.js +1 -0
- package/providers/SwapFormProvider/SwapFormProvider.js +4 -30
- package/providers/SwapFormProvider/types.d.ts +5 -5
- package/providers/TelemetryProvider/TelemetryProvider.d.ts +4 -0
- package/providers/TelemetryProvider/TelemetryProvider.js +7 -0
- package/providers/TelemetryProvider/index.d.ts +1 -0
- package/providers/TelemetryProvider/index.js +1 -0
- package/providers/WalletProvider/WalletProvider.d.ts +1 -4
- package/providers/WalletProvider/WalletProvider.js +59 -1
- package/providers/WidgetProvider/WidgetProvider.js +3 -18
- package/providers/WidgetProvider/index.d.ts +1 -0
- package/providers/WidgetProvider/index.js +1 -0
- package/providers/WidgetProvider/utils.d.ts +4 -0
- package/providers/WidgetProvider/utils.js +9 -0
- package/providers/index.d.ts +2 -0
- package/providers/index.js +2 -0
- package/stores/chains/index.d.ts +3 -0
- package/stores/chains/index.js +3 -0
- package/stores/chains/types.d.ts +8 -0
- package/stores/chains/types.js +1 -0
- package/stores/chains/useChainOrder.d.ts +1 -0
- package/stores/chains/useChainOrder.js +5 -0
- package/stores/chains/useChainOrderStore.d.ts +19 -0
- package/stores/chains/useChainOrderStore.js +39 -0
- package/stores/route/index.d.ts +2 -1
- package/stores/route/index.js +2 -1
- package/stores/route/useExecutingRoutesIds.d.ts +1 -0
- package/stores/route/useExecutingRoutesIds.js +13 -0
- package/stores/route/useRouteStore.js +5 -4
- package/stores/route/utils.d.ts +4 -0
- package/stores/route/utils.js +15 -0
- package/stores/settings/index.d.ts +0 -1
- package/stores/settings/index.js +0 -1
- package/stores/settings/useAppearance.js +3 -1
- package/stores/settings/useSettingsStore.js +5 -2
- package/tsconfig.cjs.tsbuildinfo +1 -1
- package/types/events.d.ts +5 -0
- package/types/events.js +6 -0
- package/types/index.d.ts +1 -0
- package/types/index.js +1 -0
- package/types/widget.d.ts +31 -23
- package/utils/colors.d.ts +1 -1
- package/utils/navigationRoutes.d.ts +5 -0
- package/utils/navigationRoutes.js +30 -3
- package/cjs/components/SwapButton/SwapButton.style.d.ts +0 -65
- package/cjs/components/SwapButton/SwapButton.style.js +0 -15
- package/cjs/components/SwapsInProgress/SwapsInProgress.js +0 -29
- package/cjs/components/SwapsInProgress/SwapsInProgress.style.js +0 -17
- package/cjs/components/SwapsInProgress/index.d.ts +0 -1
- package/cjs/config/lifi.d.ts +0 -4
- package/cjs/config/lifi.js +0 -14
- package/cjs/pages/SelectTokenPage/ChainSelect.js +0 -31
- package/cjs/pages/SwapPage/utils.d.ts +0 -6
- package/cjs/pages/SwapPage/utils.js +0 -93
- package/cjs/stores/route/useExecutingRoutes.d.ts +0 -2
- package/cjs/stores/route/useExecutingRoutes.js +0 -13
- package/cjs/stores/settings/useSetSettings.d.ts +0 -5
- package/cjs/stores/settings/useSetSettings.js +0 -12
- package/components/Step/utils.js +0 -89
- package/components/SwapButton/SwapButton.style.d.ts +0 -65
- package/components/SwapButton/SwapButton.style.js +0 -12
- package/components/SwapsInProgress/SwapsInProgress.js +0 -25
- package/components/SwapsInProgress/SwapsInProgress.style.js +0 -14
- package/components/SwapsInProgress/index.d.ts +0 -1
- package/components/SwapsInProgress/index.js +0 -1
- package/config/lifi.d.ts +0 -4
- package/config/lifi.js +0 -7
- package/pages/SelectTokenPage/ChainSelect.js +0 -27
- package/pages/SwapPage/utils.d.ts +0 -6
- package/stores/route/useExecutingRoutes.d.ts +0 -2
- package/stores/route/useExecutingRoutes.js +0 -6
- package/stores/settings/useSetSettings.d.ts +0 -5
- package/stores/settings/useSetSettings.js +0 -5
|
@@ -4,9 +4,17 @@ exports.TokenNotFound = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const icons_material_1 = require("@mui/icons-material");
|
|
6
6
|
const material_1 = require("@mui/material");
|
|
7
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
7
8
|
const react_i18next_1 = require("react-i18next");
|
|
8
|
-
const
|
|
9
|
+
const hooks_1 = require("../../hooks");
|
|
10
|
+
const providers_1 = require("../../providers");
|
|
11
|
+
const TokenNotFound = ({ formType }) => {
|
|
12
|
+
var _a;
|
|
9
13
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
14
|
+
const [selectedChainId] = (0, react_hook_form_1.useWatch)({
|
|
15
|
+
name: [providers_1.SwapFormKeyHelper.getChainKey(formType)],
|
|
16
|
+
});
|
|
17
|
+
const { getChainById } = (0, hooks_1.useChains)();
|
|
10
18
|
return ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ sx: {
|
|
11
19
|
display: 'flex',
|
|
12
20
|
justifyContent: 'center',
|
|
@@ -14,6 +22,8 @@ const TokenNotFound = () => {
|
|
|
14
22
|
flexDirection: 'column',
|
|
15
23
|
flex: 1,
|
|
16
24
|
padding: 3,
|
|
17
|
-
} }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: 48, lineHeight: 1 }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.SearchOff, { fontSize: "inherit" }) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: 14, color: "text.secondary", textAlign: "center", mt: 2, px: 2 }, { children: t('swap.
|
|
25
|
+
} }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: 48, lineHeight: 1 }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.SearchOff, { fontSize: "inherit" }) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: 14, color: "text.secondary", textAlign: "center", mt: 2, px: 2 }, { children: t('swap.info.message.emptyTokenList', {
|
|
26
|
+
chainName: (_a = getChainById(selectedChainId)) === null || _a === void 0 ? void 0 : _a.name,
|
|
27
|
+
}) }))] })));
|
|
18
28
|
};
|
|
19
29
|
exports.TokenNotFound = TokenNotFound;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { TokenAmount } from '@lifi/sdk';
|
|
2
2
|
import type { MutableRefObject } from 'react';
|
|
3
|
-
import type {
|
|
3
|
+
import type { SwapFormType } from '../../providers';
|
|
4
4
|
import type { Token } from '../../types';
|
|
5
5
|
export interface TokenListProps {
|
|
6
|
-
formType:
|
|
6
|
+
formType: SwapFormType;
|
|
7
7
|
height: number;
|
|
8
8
|
onClick?(): void;
|
|
9
9
|
}
|
package/cjs/config/theme.js
CHANGED
|
@@ -88,7 +88,29 @@ const createTheme = (mode, theme = {}) => {
|
|
|
88
88
|
defaultProps: {
|
|
89
89
|
disableElevation: true,
|
|
90
90
|
},
|
|
91
|
-
styleOverrides: Object.assign(
|
|
91
|
+
styleOverrides: Object.assign({ root: {
|
|
92
|
+
borderRadius: (_v = (_u = theme.shape) === null || _u === void 0 ? void 0 : _u.borderRadiusSecondary) !== null && _v !== void 0 ? _v : shape.borderRadiusSecondary,
|
|
93
|
+
textTransform: 'none',
|
|
94
|
+
fontSize: '1rem',
|
|
95
|
+
'&.Mui-disabled, &.Mui-disabled:hover': {
|
|
96
|
+
color: mode === 'light'
|
|
97
|
+
? 'rgb(0 0 0 / 70%)'
|
|
98
|
+
: 'rgb(255 255 255 / 70%)',
|
|
99
|
+
cursor: 'not-allowed',
|
|
100
|
+
pointerEvents: 'auto',
|
|
101
|
+
},
|
|
102
|
+
}, contained: {
|
|
103
|
+
'&:hover': {
|
|
104
|
+
color: (0, styles_1.getContrastRatio)(colors_1.common.white, primaryMainColor) >= 3
|
|
105
|
+
? colors_1.common.white
|
|
106
|
+
: colors_1.common.black,
|
|
107
|
+
},
|
|
108
|
+
}, sizeMedium: {
|
|
109
|
+
padding: '10px 16px',
|
|
110
|
+
[`.${DialogActions_1.dialogActionsClasses.root} &`]: {
|
|
111
|
+
padding: '6px 12px',
|
|
112
|
+
},
|
|
113
|
+
} }, (mode === 'dark'
|
|
92
114
|
? {
|
|
93
115
|
outlined: {
|
|
94
116
|
color: primaryLightColor,
|
|
@@ -106,28 +128,7 @@ const createTheme = (mode, theme = {}) => {
|
|
|
106
128
|
},
|
|
107
129
|
},
|
|
108
130
|
}
|
|
109
|
-
: {})),
|
|
110
|
-
borderRadius: (_v = (_u = theme.shape) === null || _u === void 0 ? void 0 : _u.borderRadiusSecondary) !== null && _v !== void 0 ? _v : shape.borderRadiusSecondary,
|
|
111
|
-
textTransform: 'none',
|
|
112
|
-
fontSize: '1rem',
|
|
113
|
-
padding: '10px 16px',
|
|
114
|
-
[`.${DialogActions_1.dialogActionsClasses.root} &`]: {
|
|
115
|
-
padding: '6px 12px',
|
|
116
|
-
},
|
|
117
|
-
'&.Mui-disabled, &.Mui-disabled:hover': {
|
|
118
|
-
color: mode === 'light'
|
|
119
|
-
? 'rgb(0 0 0 / 70%)'
|
|
120
|
-
: 'rgb(255 255 255 / 70%)',
|
|
121
|
-
cursor: 'not-allowed',
|
|
122
|
-
pointerEvents: 'auto',
|
|
123
|
-
},
|
|
124
|
-
}, contained: {
|
|
125
|
-
'&:hover': {
|
|
126
|
-
color: (0, styles_1.getContrastRatio)(colors_1.common.white, primaryMainColor) >= 3
|
|
127
|
-
? colors_1.common.white
|
|
128
|
-
: colors_1.common.black,
|
|
129
|
-
},
|
|
130
|
-
} }),
|
|
131
|
+
: {})),
|
|
131
132
|
},
|
|
132
133
|
MuiIconButton: {
|
|
133
134
|
styleOverrides: {
|
package/cjs/config/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/widget";
|
|
2
|
-
export declare const version = "1.
|
|
2
|
+
export declare const version = "1.17.0";
|
package/cjs/config/version.js
CHANGED
package/cjs/hooks/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export * from './useFeaturedTokens';
|
|
|
6
6
|
export * from './useGasSufficiency';
|
|
7
7
|
export * from './useInitializer';
|
|
8
8
|
export * from './useNavigateBack';
|
|
9
|
+
export * from './useProcessMessage';
|
|
9
10
|
export * from './useRouteExecution';
|
|
10
11
|
export * from './useScrollableContainer';
|
|
11
12
|
export * from './useSwapRoutes';
|
|
@@ -16,3 +17,4 @@ export * from './useTokenBalances';
|
|
|
16
17
|
export * from './useTokens';
|
|
17
18
|
export * from './useTokenSearch';
|
|
18
19
|
export * from './useTools';
|
|
20
|
+
export * from './useWidgetEvents';
|
package/cjs/hooks/index.js
CHANGED
|
@@ -22,6 +22,7 @@ __exportStar(require("./useFeaturedTokens"), exports);
|
|
|
22
22
|
__exportStar(require("./useGasSufficiency"), exports);
|
|
23
23
|
__exportStar(require("./useInitializer"), exports);
|
|
24
24
|
__exportStar(require("./useNavigateBack"), exports);
|
|
25
|
+
__exportStar(require("./useProcessMessage"), exports);
|
|
25
26
|
__exportStar(require("./useRouteExecution"), exports);
|
|
26
27
|
__exportStar(require("./useScrollableContainer"), exports);
|
|
27
28
|
__exportStar(require("./useSwapRoutes"), exports);
|
|
@@ -32,3 +33,4 @@ __exportStar(require("./useTokenBalances"), exports);
|
|
|
32
33
|
__exportStar(require("./useTokens"), exports);
|
|
33
34
|
__exportStar(require("./useTokenSearch"), exports);
|
|
34
35
|
__exportStar(require("./useTools"), exports);
|
|
36
|
+
__exportStar(require("./useWidgetEvents"), exports);
|
package/cjs/hooks/useChains.d.ts
CHANGED
|
@@ -1,101 +1,5 @@
|
|
|
1
1
|
export declare const useChains: () => {
|
|
2
|
-
error: unknown;
|
|
3
|
-
isError: true;
|
|
4
|
-
isLoading: false;
|
|
5
|
-
isLoadingError: false;
|
|
6
|
-
isRefetchError: true;
|
|
7
|
-
isSuccess: false;
|
|
8
|
-
status: "error";
|
|
9
|
-
dataUpdatedAt: number;
|
|
10
|
-
errorUpdatedAt: number;
|
|
11
|
-
failureCount: number;
|
|
12
|
-
errorUpdateCount: number;
|
|
13
|
-
isFetched: boolean;
|
|
14
|
-
isFetchedAfterMount: boolean;
|
|
15
|
-
isFetching: boolean;
|
|
16
|
-
isPaused: boolean;
|
|
17
|
-
isPlaceholderData: boolean;
|
|
18
|
-
isPreviousData: boolean;
|
|
19
|
-
isRefetching: boolean;
|
|
20
|
-
isStale: boolean;
|
|
21
|
-
refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@lifi/types").EVMChain[], unknown>>;
|
|
22
|
-
remove: () => void;
|
|
23
|
-
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
24
|
-
chains: import("@lifi/types").EVMChain[] | undefined;
|
|
25
|
-
getChainById: (chainId: number) => import("@lifi/types").EVMChain | undefined;
|
|
26
|
-
} | {
|
|
27
|
-
error: null;
|
|
28
|
-
isError: false;
|
|
29
|
-
isLoading: false;
|
|
30
|
-
isLoadingError: false;
|
|
31
|
-
isRefetchError: false;
|
|
32
|
-
isSuccess: true;
|
|
33
|
-
status: "success";
|
|
34
|
-
dataUpdatedAt: number;
|
|
35
|
-
errorUpdatedAt: number;
|
|
36
|
-
failureCount: number;
|
|
37
|
-
errorUpdateCount: number;
|
|
38
|
-
isFetched: boolean;
|
|
39
|
-
isFetchedAfterMount: boolean;
|
|
40
|
-
isFetching: boolean;
|
|
41
|
-
isPaused: boolean;
|
|
42
|
-
isPlaceholderData: boolean;
|
|
43
|
-
isPreviousData: boolean;
|
|
44
|
-
isRefetching: boolean;
|
|
45
|
-
isStale: boolean;
|
|
46
|
-
refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@lifi/types").EVMChain[], unknown>>;
|
|
47
|
-
remove: () => void;
|
|
48
|
-
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
49
|
-
chains: import("@lifi/types").EVMChain[] | undefined;
|
|
50
|
-
getChainById: (chainId: number) => import("@lifi/types").EVMChain | undefined;
|
|
51
|
-
} | {
|
|
52
|
-
error: unknown;
|
|
53
|
-
isError: true;
|
|
54
|
-
isLoading: false;
|
|
55
|
-
isLoadingError: true;
|
|
56
|
-
isRefetchError: false;
|
|
57
|
-
isSuccess: false;
|
|
58
|
-
status: "error";
|
|
59
|
-
dataUpdatedAt: number;
|
|
60
|
-
errorUpdatedAt: number;
|
|
61
|
-
failureCount: number;
|
|
62
|
-
errorUpdateCount: number;
|
|
63
|
-
isFetched: boolean;
|
|
64
|
-
isFetchedAfterMount: boolean;
|
|
65
|
-
isFetching: boolean;
|
|
66
|
-
isPaused: boolean;
|
|
67
|
-
isPlaceholderData: boolean;
|
|
68
|
-
isPreviousData: boolean;
|
|
69
|
-
isRefetching: boolean;
|
|
70
|
-
isStale: boolean;
|
|
71
|
-
refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@lifi/types").EVMChain[], unknown>>;
|
|
72
|
-
remove: () => void;
|
|
73
|
-
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
74
|
-
chains: import("@lifi/types").EVMChain[] | undefined;
|
|
75
|
-
getChainById: (chainId: number) => import("@lifi/types").EVMChain | undefined;
|
|
76
|
-
} | {
|
|
77
|
-
error: null;
|
|
78
|
-
isError: false;
|
|
79
|
-
isLoading: true;
|
|
80
|
-
isLoadingError: false;
|
|
81
|
-
isRefetchError: false;
|
|
82
|
-
isSuccess: false;
|
|
83
|
-
status: "loading";
|
|
84
|
-
dataUpdatedAt: number;
|
|
85
|
-
errorUpdatedAt: number;
|
|
86
|
-
failureCount: number;
|
|
87
|
-
errorUpdateCount: number;
|
|
88
|
-
isFetched: boolean;
|
|
89
|
-
isFetchedAfterMount: boolean;
|
|
90
|
-
isFetching: boolean;
|
|
91
|
-
isPaused: boolean;
|
|
92
|
-
isPlaceholderData: boolean;
|
|
93
|
-
isPreviousData: boolean;
|
|
94
|
-
isRefetching: boolean;
|
|
95
|
-
isStale: boolean;
|
|
96
|
-
refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@lifi/types").EVMChain[], unknown>>;
|
|
97
|
-
remove: () => void;
|
|
98
|
-
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
99
2
|
chains: import("@lifi/types").EVMChain[] | undefined;
|
|
100
3
|
getChainById: (chainId: number) => import("@lifi/types").EVMChain | undefined;
|
|
4
|
+
isLoading: boolean;
|
|
101
5
|
};
|
package/cjs/hooks/useChains.js
CHANGED
|
@@ -8,36 +8,42 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
-
var t = {};
|
|
13
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
-
t[p] = s[p];
|
|
15
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
-
t[p[i]] = s[p[i]];
|
|
19
|
-
}
|
|
20
|
-
return t;
|
|
21
|
-
};
|
|
22
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
12
|
exports.useChains = void 0;
|
|
24
13
|
const react_query_1 = require("@tanstack/react-query");
|
|
25
14
|
const react_1 = require("react");
|
|
26
|
-
const
|
|
27
|
-
const
|
|
15
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
16
|
+
const providers_1 = require("../providers");
|
|
17
|
+
const chains_1 = require("../stores/chains");
|
|
28
18
|
const useChains = () => {
|
|
29
|
-
const { disabledChains } = (0,
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
19
|
+
const { disabledChains, chains } = (0, providers_1.useWidgetConfig)();
|
|
20
|
+
const lifi = (0, providers_1.useLiFi)();
|
|
21
|
+
const { getValues, setValue } = (0, react_hook_form_1.useFormContext)();
|
|
22
|
+
const { data, isLoading } = (0, react_query_1.useQuery)(['chains'], () => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
+
const availableChains = yield lifi.getChains();
|
|
24
|
+
const filteredChains = availableChains.filter((chain) => (0, providers_1.isItemAllowed)(chain.id, chains, disabledChains));
|
|
25
|
+
const chainOrder = chains_1.useChainOrderStore
|
|
26
|
+
.getState()
|
|
27
|
+
.initializeChains(filteredChains.map((chain) => chain.id));
|
|
28
|
+
const [fromChainValue, toChainValue] = getValues([
|
|
29
|
+
providers_1.SwapFormKey.FromChain,
|
|
30
|
+
providers_1.SwapFormKey.ToChain,
|
|
31
|
+
]);
|
|
32
|
+
if (!fromChainValue) {
|
|
33
|
+
setValue(providers_1.SwapFormKey.FromChain, chainOrder[0]);
|
|
34
|
+
}
|
|
35
|
+
if (!toChainValue) {
|
|
36
|
+
setValue(providers_1.SwapFormKey.ToChain, chainOrder[0]);
|
|
37
|
+
}
|
|
38
|
+
return { availableChains, filteredChains };
|
|
39
|
+
}));
|
|
34
40
|
const getChainById = (0, react_1.useCallback)((chainId) => {
|
|
35
|
-
const chain = data === null || data === void 0 ? void 0 : data.find((chain) => chain.id === chainId);
|
|
41
|
+
const chain = data === null || data === void 0 ? void 0 : data.availableChains.find((chain) => chain.id === chainId);
|
|
36
42
|
// if (!chain) {
|
|
37
43
|
// throw new Error('Chain not found or chainId is invalid.');
|
|
38
44
|
// }
|
|
39
45
|
return chain;
|
|
40
46
|
}, [data]);
|
|
41
|
-
return
|
|
47
|
+
return { chains: data === null || data === void 0 ? void 0 : data.filteredChains, getChainById, isLoading };
|
|
42
48
|
};
|
|
43
49
|
exports.useChains = useChains;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useFeaturedTokens: (selectedChainId
|
|
1
|
+
export declare const useFeaturedTokens: (selectedChainId?: number) => import("@lifi/types").Token[];
|
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useFeaturedTokens = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
-
const
|
|
5
|
+
const providers_1 = require("../providers");
|
|
6
6
|
const useFeaturedTokens = (selectedChainId) => {
|
|
7
|
-
const { featuredTokens } = (0,
|
|
8
|
-
return (0, react_1.useMemo)(() =>
|
|
7
|
+
const { featuredTokens, tokens } = (0, providers_1.useWidgetConfig)();
|
|
8
|
+
return (0, react_1.useMemo)(() => {
|
|
9
|
+
var _a;
|
|
10
|
+
return [...((_a = tokens === null || tokens === void 0 ? void 0 : tokens.featured) !== null && _a !== void 0 ? _a : []), ...(featuredTokens !== null && featuredTokens !== void 0 ? featuredTokens : [])].filter((token) => token.chainId === selectedChainId);
|
|
11
|
+
}, [featuredTokens, selectedChainId, tokens === null || tokens === void 0 ? void 0 : tokens.featured]);
|
|
9
12
|
};
|
|
10
13
|
exports.useFeaturedTokens = useFeaturedTokens;
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
13
|
};
|
|
@@ -8,35 +17,27 @@ const big_js_1 = __importDefault(require("big.js"));
|
|
|
8
17
|
const react_1 = require("react");
|
|
9
18
|
const react_hook_form_1 = require("react-hook-form");
|
|
10
19
|
const _1 = require(".");
|
|
11
|
-
const
|
|
12
|
-
const WalletProvider_1 = require("../providers/WalletProvider");
|
|
20
|
+
const providers_1 = require("../providers");
|
|
13
21
|
const useTokenBalances_1 = require("./useTokenBalances");
|
|
14
22
|
const useGasSufficiency = (route) => {
|
|
15
|
-
const
|
|
23
|
+
const lifi = (0, providers_1.useLiFi)();
|
|
24
|
+
const { account } = (0, providers_1.useWallet)();
|
|
16
25
|
const [fromChainId, toChainId, fromToken] = (0, react_hook_form_1.useWatch)({
|
|
17
26
|
name: [
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
27
|
+
providers_1.SwapFormKeyHelper.getChainKey('from'),
|
|
28
|
+
providers_1.SwapFormKeyHelper.getChainKey('to'),
|
|
29
|
+
providers_1.SwapFormKey.FromToken,
|
|
21
30
|
],
|
|
22
31
|
});
|
|
23
|
-
const fromAmount = (0, _1.useDebouncedWatch)(
|
|
32
|
+
const fromAmount = (0, _1.useDebouncedWatch)(providers_1.SwapFormKey.FromAmount, 250);
|
|
24
33
|
const { getChainById } = (0, _1.useChains)();
|
|
25
34
|
const { tokensWithBalance: fromChainTokenBalances } = (0, useTokenBalances_1.useTokenBalances)(fromChainId);
|
|
26
|
-
const
|
|
27
|
-
const
|
|
35
|
+
const [insufficientGas, setInsufficientGas] = (0, react_1.useState)();
|
|
36
|
+
const checkInsufficientGas = (0, react_1.useCallback)(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
37
|
var _a;
|
|
29
|
-
if (!account.isActive ||
|
|
30
|
-
|
|
31
|
-
!fromAmount ||
|
|
32
|
-
!fromChainTokenBalances ||
|
|
33
|
-
!toChainTokenBalances) {
|
|
34
|
-
return [];
|
|
38
|
+
if (!account.isActive || !route || !fromAmount) {
|
|
39
|
+
return;
|
|
35
40
|
}
|
|
36
|
-
const tokenBalancesByChain = {
|
|
37
|
-
[fromChainId]: fromChainTokenBalances,
|
|
38
|
-
[toChainId]: toChainTokenBalances,
|
|
39
|
-
};
|
|
40
41
|
const gasCosts = route.steps.reduce((groupedGasCosts, step) => {
|
|
41
42
|
if (step.estimate.gasCosts) {
|
|
42
43
|
const { token } = step.estimate.gasCosts[0];
|
|
@@ -61,30 +62,34 @@ const useGasSufficiency = (route) => {
|
|
|
61
62
|
route.fromToken.address === gasCosts[fromChainId].token.address) {
|
|
62
63
|
gasCosts[fromChainId].tokenAmount = (_a = gasCosts[fromChainId]) === null || _a === void 0 ? void 0 : _a.gasAmount.plus((0, big_js_1.default)(fromAmount));
|
|
63
64
|
}
|
|
65
|
+
const tokenBalances = yield lifi.getTokenBalances(account.address, Object.values(gasCosts).map((item) => item.token));
|
|
66
|
+
if (!(tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.length)) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
64
69
|
[fromChainId, toChainId].forEach((chainId) => {
|
|
65
|
-
var _a, _b, _c, _d, _e, _f
|
|
70
|
+
var _a, _b, _c, _d, _e, _f;
|
|
66
71
|
if (gasCosts[chainId]) {
|
|
67
|
-
const gasTokenBalance = (0, big_js_1.default)((
|
|
72
|
+
const gasTokenBalance = (0, big_js_1.default)((_b = (_a = tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.find((t) => t.address === gasCosts[chainId].token.address)) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : 0);
|
|
68
73
|
const insufficientFromChainGas = gasTokenBalance.lte(0) ||
|
|
69
|
-
gasTokenBalance.lt((
|
|
70
|
-
gasTokenBalance.lt((
|
|
74
|
+
gasTokenBalance.lt((_c = gasCosts[chainId].gasAmount) !== null && _c !== void 0 ? _c : (0, big_js_1.default)(0)) ||
|
|
75
|
+
gasTokenBalance.lt((_d = gasCosts[chainId].tokenAmount) !== null && _d !== void 0 ? _d : (0, big_js_1.default)(0));
|
|
71
76
|
const insufficientFromChainGasAmount = insufficientFromChainGas
|
|
72
|
-
? (
|
|
77
|
+
? (_f = (_e = gasCosts[chainId].tokenAmount) === null || _e === void 0 ? void 0 : _e.minus(gasTokenBalance)) !== null && _f !== void 0 ? _f : gasCosts[chainId].gasAmount.minus(gasTokenBalance)
|
|
73
78
|
: undefined;
|
|
74
79
|
gasCosts[chainId] = Object.assign(Object.assign({}, gasCosts[chainId]), { insufficient: insufficientFromChainGas, insufficientAmount: insufficientFromChainGasAmount });
|
|
75
80
|
}
|
|
76
81
|
});
|
|
77
82
|
const gasCostResult = Object.values(gasCosts).filter((gasCost) => gasCost.insufficient);
|
|
78
|
-
|
|
79
|
-
}, [
|
|
83
|
+
setInsufficientGas(gasCostResult);
|
|
84
|
+
}), [
|
|
85
|
+
account.address,
|
|
80
86
|
account.isActive,
|
|
81
87
|
fromAmount,
|
|
82
88
|
fromChainId,
|
|
83
|
-
fromChainTokenBalances,
|
|
84
89
|
getChainById,
|
|
90
|
+
lifi,
|
|
85
91
|
route,
|
|
86
92
|
toChainId,
|
|
87
|
-
toChainTokenBalances,
|
|
88
93
|
]);
|
|
89
94
|
const insufficientFunds = (0, react_1.useMemo)(() => {
|
|
90
95
|
var _a, _b;
|
|
@@ -97,6 +102,9 @@ const useGasSufficiency = (route) => {
|
|
|
97
102
|
const balance = (0, big_js_1.default)((_b = (_a = fromChainTokenBalances === null || fromChainTokenBalances === void 0 ? void 0 : fromChainTokenBalances.find((t) => t.address === fromToken)) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : 0);
|
|
98
103
|
return (0, big_js_1.default)(fromAmount).gt(balance);
|
|
99
104
|
}, [account.isActive, fromAmount, fromChainTokenBalances, fromToken]);
|
|
105
|
+
(0, react_1.useEffect)(() => {
|
|
106
|
+
checkInsufficientGas();
|
|
107
|
+
}, [checkInsufficientGas]);
|
|
100
108
|
return {
|
|
101
109
|
insufficientGas,
|
|
102
110
|
insufficientFunds,
|
|
@@ -2,8 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useInitializer = void 0;
|
|
4
4
|
/* eslint-disable no-underscore-dangle */
|
|
5
|
+
const sdk_1 = require("@lifi/sdk");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const version_1 = require("../config/version");
|
|
5
8
|
const useTools_1 = require("./useTools");
|
|
6
9
|
const useInitializer = () => {
|
|
7
10
|
(0, useTools_1.useTools)();
|
|
11
|
+
(0, react_1.useEffect)(() => {
|
|
12
|
+
(0, sdk_1.checkPackageUpdates)(version_1.name, version_1.version);
|
|
13
|
+
}, []);
|
|
8
14
|
};
|
|
9
15
|
exports.useInitializer = useInitializer;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { EVMChain, Process, Step } from '@lifi/sdk';
|
|
2
2
|
import type { TFunction } from 'react-i18next';
|
|
3
|
+
export declare const useProcessMessage: (step?: Step, process?: Process) => {
|
|
4
|
+
title?: string | undefined;
|
|
5
|
+
message?: string | undefined;
|
|
6
|
+
};
|
|
3
7
|
export declare function getProcessMessage(t: TFunction<'translation', undefined>, getChainById: (chainId: number) => EVMChain | undefined, step: Step, process: Process): {
|
|
4
8
|
title?: string;
|
|
5
9
|
message?: string;
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getProcessMessage = void 0;
|
|
3
|
+
exports.getProcessMessage = exports.useProcessMessage = void 0;
|
|
4
4
|
const sdk_1 = require("@lifi/sdk");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
},
|
|
5
|
+
const react_i18next_1 = require("react-i18next");
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
|
+
const useChains_1 = require("./useChains");
|
|
8
|
+
const useProcessMessage = (step, process) => {
|
|
9
|
+
const { t } = (0, react_i18next_1.useTranslation)();
|
|
10
|
+
const { getChainById } = (0, useChains_1.useChains)();
|
|
11
|
+
if (!step || !process) {
|
|
12
|
+
return {};
|
|
13
|
+
}
|
|
14
|
+
return getProcessMessage(t, getChainById, step, process);
|
|
10
15
|
};
|
|
16
|
+
exports.useProcessMessage = useProcessMessage;
|
|
11
17
|
const processMessages = {
|
|
12
18
|
TOKEN_ALLOWANCE: {
|
|
13
19
|
STARTED: (t) => t(`swap.process.tokenAllowance.started`),
|
|
@@ -15,7 +21,7 @@ const processMessages = {
|
|
|
15
21
|
DONE: (t) => t(`swap.process.tokenAllowance.done`),
|
|
16
22
|
},
|
|
17
23
|
SWITCH_CHAIN: {
|
|
18
|
-
|
|
24
|
+
ACTION_REQUIRED: (t) => t(`swap.process.switchChain.actionRequired`),
|
|
19
25
|
DONE: (t) => t(`swap.process.switchChain.done`),
|
|
20
26
|
},
|
|
21
27
|
SWAP: {
|
|
@@ -70,9 +76,9 @@ function getProcessMessage(t, getChainById, step, process) {
|
|
|
70
76
|
title = t(`swap.error.title.slippageTooLarge`);
|
|
71
77
|
message = t(`swap.error.message.slippageTooLarge`);
|
|
72
78
|
break;
|
|
73
|
-
case sdk_1.
|
|
74
|
-
title = t(`swap.error.title.
|
|
75
|
-
message = t(`swap.error.message.
|
|
79
|
+
case sdk_1.LifiErrorCode.TransactionRejected:
|
|
80
|
+
title = t(`swap.error.title.transactionRejected`);
|
|
81
|
+
message = t(`swap.error.message.transactionRejected`, {
|
|
76
82
|
amount: (0, utils_1.formatTokenAmount)(step.action.fromAmount, step.action.fromToken.decimals),
|
|
77
83
|
tokenSymbol: step.action.fromToken.symbol,
|
|
78
84
|
chainName: (_b = (_a = getChainById(step.action.fromChainId)) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : '',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Route } from '@lifi/sdk';
|
|
2
|
-
export declare const useRouteExecution: (routeId: string) => {
|
|
2
|
+
export declare const useRouteExecution: (routeId: string, executeInBackground?: boolean) => {
|
|
3
3
|
executeRoute: () => void;
|
|
4
4
|
restartRoute: () => void;
|
|
5
5
|
deleteRoute: () => void;
|