@lifi/widget 1.31.1 → 1.32.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 +4 -16
- package/AppDrawer.js +13 -7
- package/AppDrawer.style.d.ts +3 -3
- package/AppDrawer.style.js +1 -1
- package/AppProvider.js +1 -1
- package/AppRoutes.js +9 -0
- package/cjs/App.js +4 -16
- package/cjs/AppDrawer.js +13 -7
- package/cjs/AppDrawer.style.d.ts +3 -3
- package/cjs/AppDrawer.style.js +1 -1
- package/cjs/AppProvider.js +1 -1
- package/cjs/AppRoutes.js +9 -0
- package/cjs/components/ActiveSwaps/ActiveSwapItem.js +9 -7
- package/cjs/components/ActiveSwaps/ActiveSwaps.js +3 -3
- package/cjs/components/ActiveSwaps/ActiveSwaps.style.d.ts +5 -5
- package/cjs/components/AppContainer.d.ts +2 -2
- package/cjs/components/AppContainer.js +1 -1
- package/cjs/components/BottomSheet/BottomSheet.d.ts +1 -1
- package/cjs/components/BottomSheet/BottomSheet.js +2 -2
- package/cjs/components/Card/Card.d.ts +2 -2
- package/cjs/components/Card/CardHeader.d.ts +1 -1
- package/cjs/components/Card/CardTitle.d.ts +1 -1
- package/cjs/components/ChainSelect/ChainSelect.d.ts +0 -1
- package/cjs/components/ChainSelect/ChainSelect.js +3 -4
- package/cjs/components/ChainSelect/ChainSelect.style.d.ts +3 -3
- package/cjs/components/ContractComponent/ContractComponent.js +1 -1
- package/cjs/components/Dialog.js +1 -1
- package/cjs/components/GasSufficiencyMessage/GasSufficiencyMessage.js +13 -28
- package/cjs/components/GasSufficiencyMessage/GasSufficiencyMessage.style.d.ts +1 -1
- package/cjs/components/Header/Header.js +1 -1
- package/cjs/components/Header/Header.style.d.ts +4 -4
- package/cjs/components/Header/NavigationHeader.js +6 -2
- package/cjs/components/Header/WalletHeader.js +12 -22
- package/cjs/{pages/SelectNativeTokenPage/SelectNativeTokenPage.style.d.ts → components/ListItemButton.d.ts} +1 -2
- package/cjs/{pages/SelectWalletPage/SelectWalletPage.style.js → components/ListItemButton.js} +2 -8
- package/cjs/components/ListItemText.d.ts +2 -0
- package/cjs/{pages/SelectNativeTokenPage/SelectNativeTokenPage.style.js → components/ListItemText.js} +1 -10
- package/cjs/components/NFT/NFT.js +2 -14
- package/cjs/components/NFT/NFT.style.d.ts +1 -1
- package/cjs/components/NotFound.js +2 -2
- package/cjs/components/PoweredBy/PoweredBy.js +2 -2
- package/cjs/components/PoweredBy/PoweredBy.style.d.ts +1 -1
- package/cjs/components/ProgressToNextUpdate/ProgressToNextUpdate.js +5 -17
- package/cjs/components/ReverseTokensButton/ReverseTokensButton.js +1 -1
- package/cjs/components/ReverseTokensButton/ReverseTokensButton.style.d.ts +2 -2
- package/cjs/components/Select.js +1 -0
- package/cjs/components/SelectChainAndToken.js +4 -4
- package/cjs/components/SelectTokenButton/SelectTokenButton.js +2 -2
- package/cjs/components/SelectTokenButton/SelectTokenButton.style.d.ts +1 -1
- package/cjs/components/SendToWallet/SendToWallet.js +9 -19
- package/cjs/components/SendToWallet/SendToWallet.style.d.ts +2 -2
- package/cjs/components/SendToWallet/SendToWalletButton.js +5 -5
- package/cjs/components/SmallAvatar.d.ts +3 -3
- package/cjs/components/Step/CircularProgress.d.ts +0 -1
- package/cjs/components/Step/CircularProgress.js +2 -2
- package/cjs/components/Step/CircularProgress.style.d.ts +1 -1
- package/cjs/components/Step/DestinationWalletAddress.js +6 -7
- package/cjs/components/Step/GasStepProcess.js +8 -8
- package/cjs/components/Step/Step.js +4 -5
- package/cjs/components/Step/StepList.d.ts +0 -1
- package/cjs/components/Step/StepList.js +8 -4
- package/cjs/components/Step/StepProcess.js +3 -3
- package/cjs/components/Step/StepProcess.style.d.ts +3 -3
- package/cjs/components/Step/StepTimer.js +4 -8
- package/cjs/components/StepActions/StepActions.js +20 -37
- package/cjs/components/StepActions/StepActions.style.d.ts +1 -1
- package/cjs/components/StepDivider/StepDivider.style.d.ts +1 -1
- package/cjs/components/SwapButton/SwapButton.js +5 -14
- package/cjs/components/SwapInput/FormPriceHelperText.js +6 -6
- package/cjs/components/SwapInput/SwapInput.js +4 -16
- package/cjs/components/SwapInput/SwapInput.style.d.ts +2 -2
- package/cjs/components/SwapInput/SwapInputAdornment.style.d.ts +2 -2
- package/cjs/components/SwapInput/SwapInputEndAdornment.d.ts +0 -1
- package/cjs/components/SwapInput/SwapInputEndAdornment.js +2 -3
- package/cjs/components/SwapRouteCard/SwapRouteCard.js +9 -25
- package/cjs/components/SwapRouteCard/SwapRouteCard.style.d.ts +3 -3
- package/cjs/components/SwapRouteCard/SwapRouteCardSkeleton.js +4 -16
- package/cjs/components/SwapRouteCard/SwapRouteNotFoundCard.js +2 -2
- package/cjs/components/SwapRouteCard/utils.js +1 -1
- package/cjs/components/SwapRoutes/SwapRoutes.js +4 -4
- package/cjs/components/SwapRoutes/SwapRoutes.style.d.ts +5 -5
- package/cjs/components/SwapRoutes/SwapRoutesExpanded.d.ts +0 -1
- package/cjs/components/SwapRoutes/SwapRoutesExpanded.js +3 -3
- package/cjs/components/TextFitter/TextFitter.js +3 -3
- package/cjs/components/Token/Token.js +19 -33
- package/cjs/components/Token/Token.style.d.ts +3 -3
- package/cjs/components/TokenAvatar/TokenAvatar.js +6 -7
- package/cjs/components/TokenAvatar/TokenAvatar.style.d.ts +2 -2
- package/cjs/components/TokenList/TokenList.js +3 -4
- package/cjs/components/TokenList/TokenList.style.d.ts +3 -3
- package/cjs/components/TokenList/TokenList.style.js +2 -6
- package/cjs/components/TokenList/TokenListItem.js +9 -9
- package/cjs/components/TokenList/TokenNotFound.js +4 -5
- package/cjs/components/TokenList/VirtualizedTokenList.js +10 -11
- package/cjs/components/TokenList/useTokenSelect.js +2 -2
- package/cjs/config/env.js +1 -1
- package/cjs/config/sentry.js +3 -12
- package/cjs/config/theme.js +44 -16
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/hooks/useChain.js +1 -1
- package/cjs/hooks/useChains.js +5 -14
- package/cjs/hooks/useContentHeight.js +1 -2
- package/cjs/hooks/useFeaturedTokens.js +1 -4
- package/cjs/hooks/useGasSufficiency.js +28 -34
- package/cjs/hooks/useProcessMessage.js +7 -11
- package/cjs/hooks/useRouteExecution.js +16 -26
- package/cjs/hooks/useSwapRoutes.js +16 -26
- package/cjs/hooks/useToken.js +2 -2
- package/cjs/hooks/useTokenAddressBalance.js +1 -2
- package/cjs/hooks/useTokenBalance.js +24 -27
- package/cjs/hooks/useTokenBalances.d.ts +1 -1
- package/cjs/hooks/useTokenBalances.js +8 -20
- package/cjs/hooks/useTokenSearch.d.ts +1 -1
- package/cjs/hooks/useTokenSearch.js +12 -21
- package/cjs/hooks/useTokens.d.ts +1 -1
- package/cjs/hooks/useTokens.js +36 -38
- package/cjs/hooks/useTools.d.ts +2 -11
- package/cjs/hooks/useTools.js +11 -21
- package/cjs/i18n/en.json +8 -8
- package/cjs/i18n/uk.json +8 -8
- package/cjs/icons/LiFiFullLogo.js +1 -1
- package/cjs/icons/LiFiLogo.js +1 -1
- package/cjs/icons/LiFiToolLogo.js +1 -1
- package/cjs/index.d.ts +1 -0
- package/cjs/index.js +2 -0
- package/cjs/pages/ActiveSwapsPage/ActiveSwapsEmpty.js +2 -2
- package/cjs/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +0 -1
- package/cjs/pages/ActiveSwapsPage/ActiveSwapsPage.js +3 -3
- package/cjs/pages/MainPage/MainPage.js +1 -1
- package/cjs/pages/MainPage/MainPage.style.d.ts +1 -1
- package/cjs/pages/MainPage/MainSwapButton.js +3 -12
- package/cjs/pages/SelectChainPage/SelectChainPage.js +6 -14
- package/cjs/pages/SelectEnabledToolsPage/SelectEnabledToolsPage.d.ts +4 -0
- package/cjs/pages/SelectEnabledToolsPage/SelectEnabledToolsPage.js +51 -0
- package/cjs/pages/SelectEnabledToolsPage/SelectEnabledToolsPage.style.d.ts +20 -0
- package/cjs/pages/SelectEnabledToolsPage/SelectEnabledToolsPage.style.js +8 -0
- package/cjs/pages/SelectEnabledToolsPage/index.d.ts +1 -0
- package/cjs/pages/SelectEnabledToolsPage/index.js +17 -0
- package/cjs/pages/SelectNativeTokenPage/SelectNativeTokenPage.js +4 -3
- package/cjs/pages/SelectTokenPage/SearchTokenInput.d.ts +0 -1
- package/cjs/pages/SelectTokenPage/SearchTokenInput.js +4 -1
- package/cjs/pages/SelectTokenPage/SelectTokenPage.js +2 -3
- package/cjs/pages/SelectWalletPage/SelectWalletPage.d.ts +0 -1
- package/cjs/pages/SelectWalletPage/SelectWalletPage.js +13 -19
- package/cjs/pages/SettingsPage/ColorSchemeButtonGroup.js +3 -3
- package/cjs/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +2 -2
- package/cjs/pages/SettingsPage/EnabledToolsButton.d.ts +4 -0
- package/cjs/pages/SettingsPage/EnabledToolsButton.js +25 -0
- package/cjs/pages/{SelectChainPage/SelectChainPage.style.d.ts → SettingsPage/EnabledToolsButton.style.d.ts} +1 -1
- package/cjs/pages/{SelectChainPage/SelectChainPage.style.js → SettingsPage/EnabledToolsButton.style.js} +7 -10
- package/cjs/pages/SettingsPage/GasPriceSelect.d.ts +0 -1
- package/cjs/pages/SettingsPage/GasPriceSelect.js +1 -1
- package/cjs/pages/SettingsPage/LanguageSelect.js +5 -6
- package/cjs/pages/SettingsPage/ResetSettingsButton.d.ts +2 -0
- package/cjs/pages/SettingsPage/ResetSettingsButton.js +27 -0
- package/cjs/pages/SettingsPage/RoutePrioritySelect.js +4 -4
- package/cjs/pages/SettingsPage/SettingsPage.d.ts +0 -1
- package/cjs/pages/SettingsPage/SettingsPage.js +3 -2
- package/cjs/pages/SettingsPage/ShowDestinationWallet.d.ts +0 -1
- package/cjs/pages/SettingsPage/ShowDestinationWallet.js +3 -3
- package/cjs/pages/SettingsPage/SlippageInput.d.ts +0 -1
- package/cjs/pages/SettingsPage/SlippageInput.js +3 -3
- package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +14 -22
- package/cjs/pages/SwapDetailsPage/SwapDetailsPage.style.d.ts +1 -1
- package/cjs/pages/SwapHistoryPage/SwapHistoryEmpty.js +2 -2
- package/cjs/pages/SwapHistoryPage/SwapHistoryItem.js +9 -7
- package/cjs/pages/SwapHistoryPage/SwapHistoryPage.js +2 -2
- package/cjs/pages/SwapPage/ExchangeRateBottomSheet.js +21 -26
- package/cjs/pages/SwapPage/StartSwapButton.js +1 -1
- package/cjs/pages/SwapPage/StatusBottomSheet.js +21 -19
- package/cjs/pages/SwapPage/StatusBottomSheet.style.d.ts +2 -2
- package/cjs/pages/SwapPage/SwapPage.js +9 -21
- package/cjs/pages/SwapPage/SwapPage.style.d.ts +1 -1
- package/cjs/pages/SwapPage/TokenValueBottomSheet.js +8 -9
- package/cjs/pages/SwapRoutesPage/SwapRoutesPage.js +3 -3
- package/cjs/pages/SwapRoutesPage/SwapRoutesPage.style.d.ts +1 -1
- package/cjs/providers/I18nProvider/I18nProvider.js +7 -8
- package/cjs/providers/SDKProvider/SDKProvider.js +15 -4
- package/cjs/providers/SwapFormProvider/SwapFormProvider.js +12 -6
- package/cjs/providers/SwapFormProvider/URLSearchParamsBuilder.js +3 -12
- package/cjs/providers/TelemetryProvider/TelemetryProvider.js +1 -1
- package/cjs/providers/ThemeProvider/ThemeProvider.js +2 -2
- package/cjs/providers/WalletProvider/WalletProvider.js +30 -39
- package/cjs/providers/WidgetProvider/WidgetProvider.js +20 -27
- package/cjs/providers/WidgetProvider/utils.js +2 -3
- package/cjs/stores/StoreProvider.js +1 -7
- package/cjs/stores/chains/index.d.ts +1 -2
- package/cjs/stores/chains/index.js +1 -2
- package/cjs/stores/chains/useChainOrder.js +2 -2
- package/cjs/stores/chains/useChainOrderStore.d.ts +3 -0
- package/cjs/stores/chains/{createChainOrderStore.js → useChainOrderStore.js} +3 -4
- package/cjs/stores/routes/RouteExecutionStore.js +2 -14
- package/cjs/stores/routes/createRouteExecutionStore.js +27 -16
- package/cjs/stores/routes/types.d.ts +1 -1
- package/cjs/stores/routes/useExecutingRoutesIds.js +2 -5
- package/cjs/stores/routes/useRecommendedRouteStore.d.ts +10 -2
- package/cjs/stores/routes/useRecommendedRouteStore.js +30 -2
- package/cjs/stores/routes/useSwapHistory.js +3 -6
- package/cjs/stores/routes/utils.js +4 -4
- package/cjs/stores/settings/index.d.ts +1 -1
- package/cjs/stores/settings/index.js +1 -1
- package/cjs/stores/settings/types.d.ts +6 -6
- package/cjs/stores/settings/useAppearance.js +2 -2
- package/cjs/stores/settings/useSettings.js +2 -2
- package/cjs/stores/settings/useSettingsStore.d.ts +6 -0
- package/cjs/stores/settings/{createSettingsStore.js → useSettingsStore.js} +48 -28
- package/cjs/utils/colors.js +1 -1
- package/cjs/utils/format.js +3 -3
- package/cjs/utils/navigationRoutes.d.ts +2 -0
- package/cjs/utils/navigationRoutes.js +6 -0
- package/components/ActiveSwaps/ActiveSwapItem.js +9 -7
- package/components/ActiveSwaps/ActiveSwaps.js +3 -3
- package/components/ActiveSwaps/ActiveSwaps.style.d.ts +5 -5
- package/components/AppContainer.d.ts +2 -2
- package/components/AppContainer.js +1 -1
- package/components/BottomSheet/BottomSheet.d.ts +1 -1
- package/components/BottomSheet/BottomSheet.js +2 -2
- package/components/Card/Card.d.ts +2 -2
- package/components/Card/CardHeader.d.ts +1 -1
- package/components/Card/CardTitle.d.ts +1 -1
- package/components/ChainSelect/ChainSelect.d.ts +0 -1
- package/components/ChainSelect/ChainSelect.js +3 -4
- package/components/ChainSelect/ChainSelect.style.d.ts +3 -3
- package/components/ContractComponent/ContractComponent.js +1 -1
- package/components/Dialog.js +1 -1
- package/components/GasSufficiencyMessage/GasSufficiencyMessage.js +13 -28
- package/components/GasSufficiencyMessage/GasSufficiencyMessage.style.d.ts +1 -1
- package/components/Header/Header.js +1 -1
- package/components/Header/Header.style.d.ts +4 -4
- package/components/Header/NavigationHeader.js +6 -2
- package/components/Header/WalletHeader.js +12 -22
- package/{pages/SelectChainPage/SelectChainPage.style.d.ts → components/ListItemButton.d.ts} +1 -2
- package/components/ListItemButton.js +11 -0
- package/components/ListItemText.d.ts +2 -0
- package/components/ListItemText.js +8 -0
- package/components/NFT/NFT.js +2 -14
- package/components/NFT/NFT.style.d.ts +1 -1
- package/components/NotFound.js +2 -2
- package/components/PoweredBy/PoweredBy.js +2 -2
- package/components/PoweredBy/PoweredBy.style.d.ts +1 -1
- package/components/ProgressToNextUpdate/ProgressToNextUpdate.js +5 -17
- package/components/ReverseTokensButton/ReverseTokensButton.js +1 -1
- package/components/ReverseTokensButton/ReverseTokensButton.style.d.ts +2 -2
- package/components/Select.js +1 -0
- package/components/SelectChainAndToken.js +4 -4
- package/components/SelectTokenButton/SelectTokenButton.js +2 -2
- package/components/SelectTokenButton/SelectTokenButton.style.d.ts +1 -1
- package/components/SendToWallet/SendToWallet.js +9 -19
- package/components/SendToWallet/SendToWallet.style.d.ts +2 -2
- package/components/SendToWallet/SendToWalletButton.js +5 -5
- package/components/SmallAvatar.d.ts +3 -3
- package/components/Step/CircularProgress.d.ts +0 -1
- package/components/Step/CircularProgress.js +2 -2
- package/components/Step/CircularProgress.style.d.ts +1 -1
- package/components/Step/DestinationWalletAddress.js +6 -7
- package/components/Step/GasStepProcess.js +8 -8
- package/components/Step/Step.js +4 -5
- package/components/Step/StepList.d.ts +0 -1
- package/components/Step/StepList.js +8 -4
- package/components/Step/StepProcess.js +3 -3
- package/components/Step/StepProcess.style.d.ts +3 -3
- package/components/Step/StepTimer.js +4 -8
- package/components/StepActions/StepActions.js +20 -37
- package/components/StepActions/StepActions.style.d.ts +1 -1
- package/components/StepDivider/StepDivider.style.d.ts +1 -1
- package/components/SwapButton/SwapButton.js +5 -14
- package/components/SwapInput/FormPriceHelperText.js +6 -6
- package/components/SwapInput/SwapInput.js +4 -16
- package/components/SwapInput/SwapInput.style.d.ts +2 -2
- package/components/SwapInput/SwapInputAdornment.style.d.ts +2 -2
- package/components/SwapInput/SwapInputEndAdornment.d.ts +0 -1
- package/components/SwapInput/SwapInputEndAdornment.js +2 -3
- package/components/SwapRouteCard/SwapRouteCard.js +9 -25
- package/components/SwapRouteCard/SwapRouteCard.style.d.ts +3 -3
- package/components/SwapRouteCard/SwapRouteCardSkeleton.js +4 -16
- package/components/SwapRouteCard/SwapRouteNotFoundCard.js +2 -2
- package/components/SwapRouteCard/utils.js +1 -1
- package/components/SwapRoutes/SwapRoutes.js +4 -4
- package/components/SwapRoutes/SwapRoutes.style.d.ts +5 -5
- package/components/SwapRoutes/SwapRoutesExpanded.d.ts +0 -1
- package/components/SwapRoutes/SwapRoutesExpanded.js +3 -3
- package/components/TextFitter/TextFitter.js +3 -3
- package/components/Token/Token.js +19 -33
- package/components/Token/Token.style.d.ts +3 -3
- package/components/TokenAvatar/TokenAvatar.js +6 -7
- package/components/TokenAvatar/TokenAvatar.style.d.ts +2 -2
- package/components/TokenList/TokenList.js +3 -4
- package/components/TokenList/TokenList.style.d.ts +3 -3
- package/components/TokenList/TokenList.style.js +3 -7
- package/components/TokenList/TokenListItem.js +9 -9
- package/components/TokenList/TokenNotFound.js +4 -5
- package/components/TokenList/VirtualizedTokenList.js +10 -11
- package/components/TokenList/useTokenSelect.js +2 -2
- package/config/env.js +1 -1
- package/config/sentry.js +3 -12
- package/config/theme.js +44 -16
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/useChain.js +1 -1
- package/hooks/useChains.js +5 -14
- package/hooks/useContentHeight.js +1 -2
- package/hooks/useFeaturedTokens.js +1 -4
- package/hooks/useGasSufficiency.js +28 -34
- package/hooks/useProcessMessage.js +7 -11
- package/hooks/useRouteExecution.js +16 -26
- package/hooks/useSwapRoutes.js +16 -26
- package/hooks/useToken.js +2 -2
- package/hooks/useTokenAddressBalance.js +1 -2
- package/hooks/useTokenBalance.js +24 -27
- package/hooks/useTokenBalances.d.ts +1 -1
- package/hooks/useTokenBalances.js +8 -20
- package/hooks/useTokenSearch.d.ts +1 -1
- package/hooks/useTokenSearch.js +12 -21
- package/hooks/useTokens.d.ts +1 -1
- package/hooks/useTokens.js +36 -38
- package/hooks/useTools.d.ts +2 -11
- package/hooks/useTools.js +12 -22
- package/i18n/en.json +8 -8
- package/i18n/uk.json +8 -8
- package/icons/LiFiFullLogo.js +1 -1
- package/icons/LiFiLogo.js +1 -1
- package/icons/LiFiToolLogo.js +1 -1
- package/index.d.ts +1 -0
- package/index.js +2 -0
- package/package.json +7 -7
- package/pages/ActiveSwapsPage/ActiveSwapsEmpty.js +2 -2
- package/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +0 -1
- package/pages/ActiveSwapsPage/ActiveSwapsPage.js +3 -3
- package/pages/MainPage/MainPage.js +1 -1
- package/pages/MainPage/MainPage.style.d.ts +1 -1
- package/pages/MainPage/MainSwapButton.js +3 -12
- package/pages/SelectChainPage/SelectChainPage.js +6 -14
- package/pages/SelectEnabledToolsPage/SelectEnabledToolsPage.d.ts +4 -0
- package/pages/SelectEnabledToolsPage/SelectEnabledToolsPage.js +47 -0
- package/pages/SelectEnabledToolsPage/SelectEnabledToolsPage.style.d.ts +20 -0
- package/pages/SelectEnabledToolsPage/SelectEnabledToolsPage.style.js +5 -0
- package/pages/SelectEnabledToolsPage/index.d.ts +1 -0
- package/pages/SelectEnabledToolsPage/index.js +1 -0
- package/pages/SelectNativeTokenPage/SelectNativeTokenPage.js +4 -3
- package/pages/SelectTokenPage/SearchTokenInput.d.ts +0 -1
- package/pages/SelectTokenPage/SearchTokenInput.js +4 -1
- package/pages/SelectTokenPage/SelectTokenPage.js +2 -3
- package/pages/SelectWalletPage/SelectWalletPage.d.ts +0 -1
- package/pages/SelectWalletPage/SelectWalletPage.js +13 -19
- package/pages/SettingsPage/ColorSchemeButtonGroup.js +3 -3
- package/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +2 -2
- package/pages/SettingsPage/EnabledToolsButton.d.ts +4 -0
- package/pages/SettingsPage/EnabledToolsButton.js +21 -0
- package/{cjs/pages/SelectWalletPage/SelectWalletPage.style.d.ts → pages/SettingsPage/EnabledToolsButton.style.d.ts} +1 -1
- package/pages/SettingsPage/EnabledToolsButton.style.js +14 -0
- package/pages/SettingsPage/GasPriceSelect.d.ts +0 -1
- package/pages/SettingsPage/GasPriceSelect.js +1 -1
- package/pages/SettingsPage/LanguageSelect.js +5 -6
- package/pages/SettingsPage/ResetSettingsButton.d.ts +2 -0
- package/pages/SettingsPage/ResetSettingsButton.js +23 -0
- package/pages/SettingsPage/RoutePrioritySelect.js +4 -4
- package/pages/SettingsPage/SettingsPage.d.ts +0 -1
- package/pages/SettingsPage/SettingsPage.js +3 -2
- package/pages/SettingsPage/ShowDestinationWallet.d.ts +0 -1
- package/pages/SettingsPage/ShowDestinationWallet.js +3 -3
- package/pages/SettingsPage/SlippageInput.d.ts +0 -1
- package/pages/SettingsPage/SlippageInput.js +3 -3
- package/pages/SwapDetailsPage/SwapDetailsPage.js +14 -22
- package/pages/SwapDetailsPage/SwapDetailsPage.style.d.ts +1 -1
- package/pages/SwapHistoryPage/SwapHistoryEmpty.js +2 -2
- package/pages/SwapHistoryPage/SwapHistoryItem.js +9 -7
- package/pages/SwapHistoryPage/SwapHistoryPage.js +2 -2
- package/pages/SwapPage/ExchangeRateBottomSheet.js +21 -26
- package/pages/SwapPage/StartSwapButton.js +1 -1
- package/pages/SwapPage/StatusBottomSheet.js +21 -19
- package/pages/SwapPage/StatusBottomSheet.style.d.ts +2 -2
- package/pages/SwapPage/SwapPage.js +9 -21
- package/pages/SwapPage/SwapPage.style.d.ts +1 -1
- package/pages/SwapPage/TokenValueBottomSheet.js +8 -9
- package/pages/SwapRoutesPage/SwapRoutesPage.js +3 -3
- package/pages/SwapRoutesPage/SwapRoutesPage.style.d.ts +1 -1
- package/providers/I18nProvider/I18nProvider.js +7 -8
- package/providers/SDKProvider/SDKProvider.js +15 -4
- package/providers/SwapFormProvider/SwapFormProvider.js +12 -6
- package/providers/SwapFormProvider/URLSearchParamsBuilder.js +3 -12
- package/providers/TelemetryProvider/TelemetryProvider.js +1 -1
- package/providers/ThemeProvider/ThemeProvider.js +2 -2
- package/providers/WalletProvider/WalletProvider.js +30 -39
- package/providers/WidgetProvider/WidgetProvider.js +22 -29
- package/providers/WidgetProvider/utils.js +2 -3
- package/stores/StoreProvider.js +2 -8
- package/stores/chains/index.d.ts +1 -2
- package/stores/chains/index.js +1 -2
- package/stores/chains/useChainOrder.js +1 -1
- package/stores/chains/useChainOrderStore.d.ts +3 -0
- package/stores/chains/{createChainOrderStore.js → useChainOrderStore.js} +2 -2
- package/stores/routes/RouteExecutionStore.js +2 -14
- package/stores/routes/createRouteExecutionStore.js +27 -16
- package/stores/routes/types.d.ts +1 -1
- package/stores/routes/useExecutingRoutesIds.js +2 -5
- package/stores/routes/useRecommendedRouteStore.d.ts +10 -2
- package/stores/routes/useRecommendedRouteStore.js +25 -1
- package/stores/routes/useSwapHistory.js +3 -6
- package/stores/routes/utils.js +4 -4
- package/stores/settings/index.d.ts +1 -1
- package/stores/settings/index.js +1 -1
- package/stores/settings/types.d.ts +6 -6
- package/stores/settings/useAppearance.js +1 -1
- package/stores/settings/useSettings.js +1 -1
- package/stores/settings/useSettingsStore.d.ts +6 -0
- package/stores/settings/{createSettingsStore.js → useSettingsStore.js} +46 -26
- package/tsconfig.cjs.tsbuildinfo +1 -1
- package/utils/colors.js +1 -1
- package/utils/format.js +3 -3
- package/utils/navigationRoutes.d.ts +2 -0
- package/utils/navigationRoutes.js +6 -0
- package/cjs/pages/SettingsPage/AdvancedPreferences.d.ts +0 -2
- package/cjs/pages/SettingsPage/AdvancedPreferences.js +0 -24
- package/cjs/pages/SettingsPage/EnabledBridgesSelect.d.ts +0 -2
- package/cjs/pages/SettingsPage/EnabledBridgesSelect.js +0 -24
- package/cjs/pages/SettingsPage/EnabledExchangesSelect.d.ts +0 -2
- package/cjs/pages/SettingsPage/EnabledExchangesSelect.js +0 -24
- package/cjs/stores/chains/ChainOrderStore.d.ts +0 -9
- package/cjs/stores/chains/ChainOrderStore.js +0 -44
- package/cjs/stores/chains/createChainOrderStore.d.ts +0 -4
- package/cjs/stores/settings/SettingsStore.d.ts +0 -11
- package/cjs/stores/settings/SettingsStore.js +0 -58
- package/cjs/stores/settings/createSettingsStore.d.ts +0 -5
- package/pages/SelectChainPage/SelectChainPage.style.js +0 -17
- package/pages/SelectNativeTokenPage/SelectNativeTokenPage.style.d.ts +0 -21
- package/pages/SelectNativeTokenPage/SelectNativeTokenPage.style.js +0 -17
- package/pages/SelectWalletPage/SelectWalletPage.style.d.ts +0 -21
- package/pages/SelectWalletPage/SelectWalletPage.style.js +0 -17
- package/pages/SettingsPage/AdvancedPreferences.d.ts +0 -2
- package/pages/SettingsPage/AdvancedPreferences.js +0 -20
- package/pages/SettingsPage/EnabledBridgesSelect.d.ts +0 -2
- package/pages/SettingsPage/EnabledBridgesSelect.js +0 -20
- package/pages/SettingsPage/EnabledExchangesSelect.d.ts +0 -2
- package/pages/SettingsPage/EnabledExchangesSelect.js +0 -20
- package/stores/chains/ChainOrderStore.d.ts +0 -9
- package/stores/chains/ChainOrderStore.js +0 -38
- package/stores/chains/createChainOrderStore.d.ts +0 -4
- package/stores/settings/SettingsStore.d.ts +0 -11
- package/stores/settings/SettingsStore.js +0 -51
- package/stores/settings/createSettingsStore.d.ts +0 -5
package/cjs/config/theme.js
CHANGED
|
@@ -45,10 +45,12 @@ const shape = {
|
|
|
45
45
|
borderRadiusSecondary: 8,
|
|
46
46
|
};
|
|
47
47
|
const createTheme = (mode, theme = {}) => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const primaryLightColor = (0, styles_1.lighten)(
|
|
51
|
-
|
|
48
|
+
const primaryMainColor = theme.palette?.primary?.main ??
|
|
49
|
+
palette.primary.main;
|
|
50
|
+
const primaryLightColor = (0, styles_1.lighten)(theme.palette?.primary?.main ??
|
|
51
|
+
palette.primary.main, 0.5);
|
|
52
|
+
const primaryDarkColor = (0, styles_1.darken)(theme.palette?.primary?.main ??
|
|
53
|
+
palette.primary.main, 0.2);
|
|
52
54
|
const contrastButtonColor = (0, styles_1.getContrastRatio)(colors_1.common.white, primaryMainColor) >= 3
|
|
53
55
|
? colors_1.common.white
|
|
54
56
|
: colors_1.common.black;
|
|
@@ -56,17 +58,33 @@ const createTheme = (mode, theme = {}) => {
|
|
|
56
58
|
? colors_1.common.white
|
|
57
59
|
: colors_1.common.black;
|
|
58
60
|
return (0, styles_1.createTheme)({
|
|
59
|
-
typography:
|
|
60
|
-
|
|
61
|
+
typography: {
|
|
62
|
+
fontFamily: 'Inter var, Inter, sans-serif',
|
|
63
|
+
...theme.typography,
|
|
64
|
+
},
|
|
65
|
+
palette: {
|
|
66
|
+
mode,
|
|
67
|
+
...palette,
|
|
68
|
+
...(mode === 'light' ? paletteLight : paletteDark),
|
|
69
|
+
...theme.palette,
|
|
70
|
+
primary: {
|
|
61
71
|
main: primaryMainColor,
|
|
62
72
|
light: primaryLightColor,
|
|
63
73
|
dark: primaryDarkColor,
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
74
|
+
},
|
|
75
|
+
secondary: {
|
|
76
|
+
main: theme.palette?.secondary?.main ??
|
|
77
|
+
palette.secondary.main,
|
|
78
|
+
light: (0, styles_1.lighten)(theme.palette?.secondary?.main ??
|
|
79
|
+
palette.secondary.main, 0.5),
|
|
80
|
+
dark: (0, styles_1.darken)(theme.palette?.secondary?.main ??
|
|
81
|
+
palette.secondary.main, 0.2),
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
shape: {
|
|
85
|
+
...shape,
|
|
86
|
+
...theme.shape,
|
|
87
|
+
},
|
|
70
88
|
breakpoints: {
|
|
71
89
|
values: {
|
|
72
90
|
xs: 0,
|
|
@@ -79,7 +97,14 @@ const createTheme = (mode, theme = {}) => {
|
|
|
79
97
|
components: {
|
|
80
98
|
MuiScopedCssBaseline: {
|
|
81
99
|
styleOverrides: {
|
|
82
|
-
root:
|
|
100
|
+
root: {
|
|
101
|
+
fontFamily: 'Inter, sans-serif',
|
|
102
|
+
...theme.typography,
|
|
103
|
+
'@supports (font-variation-settings: normal)': {
|
|
104
|
+
fontFamily: 'Inter var, sans-serif',
|
|
105
|
+
...theme.typography,
|
|
106
|
+
},
|
|
107
|
+
},
|
|
83
108
|
},
|
|
84
109
|
},
|
|
85
110
|
MuiButton: {
|
|
@@ -88,7 +113,7 @@ const createTheme = (mode, theme = {}) => {
|
|
|
88
113
|
},
|
|
89
114
|
styleOverrides: {
|
|
90
115
|
root: {
|
|
91
|
-
borderRadius:
|
|
116
|
+
borderRadius: theme.shape?.borderRadiusSecondary ?? shape.borderRadiusSecondary,
|
|
92
117
|
textTransform: 'none',
|
|
93
118
|
fontSize: '1rem',
|
|
94
119
|
[`&.Mui-disabled, &.Mui-disabled:hover`]: {
|
|
@@ -145,12 +170,15 @@ const createTheme = (mode, theme = {}) => {
|
|
|
145
170
|
},
|
|
146
171
|
},
|
|
147
172
|
},
|
|
148
|
-
MuiAvatar:
|
|
173
|
+
MuiAvatar: {
|
|
174
|
+
styleOverrides: {
|
|
149
175
|
root: {
|
|
150
176
|
height: 32,
|
|
151
177
|
width: 32,
|
|
152
178
|
},
|
|
153
|
-
}
|
|
179
|
+
},
|
|
180
|
+
...theme.components?.MuiAvatar,
|
|
181
|
+
},
|
|
154
182
|
MuiListItemAvatar: {
|
|
155
183
|
styleOverrides: {
|
|
156
184
|
root: {
|
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.32.1";
|
package/cjs/config/version.js
CHANGED
package/cjs/hooks/useChain.js
CHANGED
|
@@ -6,7 +6,7 @@ const useChains_1 = require("./useChains");
|
|
|
6
6
|
const useChain = (chainId) => {
|
|
7
7
|
const { chains, isLoading } = (0, useChains_1.useChains)();
|
|
8
8
|
const chain = (0, react_1.useMemo)(() => {
|
|
9
|
-
const chain = chains
|
|
9
|
+
const chain = chains?.find((chain) => chain.id === chainId);
|
|
10
10
|
return chain;
|
|
11
11
|
}, [chainId, chains]);
|
|
12
12
|
return {
|
package/cjs/hooks/useChains.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
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
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.useChains = void 0;
|
|
13
4
|
const react_query_1 = require("@tanstack/react-query");
|
|
@@ -20,8 +11,8 @@ const useChains = () => {
|
|
|
20
11
|
const lifi = (0, providers_1.useLiFi)();
|
|
21
12
|
const { getValues, setValue } = (0, react_hook_form_1.useFormContext)();
|
|
22
13
|
const initializeChains = (0, stores_1.useChainOrderStore)((state) => state.initializeChains);
|
|
23
|
-
const { data, isLoading } = (0, react_query_1.useQuery)(['chains'], () =>
|
|
24
|
-
const availableChains =
|
|
14
|
+
const { data, isLoading } = (0, react_query_1.useQuery)(['chains'], async () => {
|
|
15
|
+
const availableChains = await lifi.getChains();
|
|
25
16
|
const filteredChains = availableChains.filter((chain) => (0, providers_1.isItemAllowed)(chain.id, chains, disabledChains));
|
|
26
17
|
const chainOrder = initializeChains(filteredChains.map((chain) => chain.id));
|
|
27
18
|
const [fromChainValue, toChainValue] = getValues([
|
|
@@ -35,17 +26,17 @@ const useChains = () => {
|
|
|
35
26
|
setValue(providers_1.SwapFormKey.ToChain, chainOrder[0]);
|
|
36
27
|
}
|
|
37
28
|
return { availableChains, filteredChains };
|
|
38
|
-
}
|
|
29
|
+
}, {
|
|
39
30
|
refetchInterval: 180000,
|
|
40
31
|
staleTime: 180000,
|
|
41
32
|
});
|
|
42
33
|
const getChainById = (0, react_1.useCallback)((chainId) => {
|
|
43
|
-
const chain = data
|
|
34
|
+
const chain = data?.availableChains.find((chain) => chain.id === chainId);
|
|
44
35
|
// if (!chain) {
|
|
45
36
|
// throw new Error('Chain not found or chainId is invalid.');
|
|
46
37
|
// }
|
|
47
38
|
return chain;
|
|
48
39
|
}, [data]);
|
|
49
|
-
return { chains: data
|
|
40
|
+
return { chains: data?.filteredChains, getChainById, isLoading };
|
|
50
41
|
};
|
|
51
42
|
exports.useChains = useChains;
|
|
@@ -31,11 +31,10 @@ exports.useContentHeight = useContentHeight;
|
|
|
31
31
|
const useSetContentHeight = (ref) => {
|
|
32
32
|
const elementId = (0, useDefaultElementId_1.useDefaultElementId)();
|
|
33
33
|
(0, react_1.useLayoutEffect)(() => {
|
|
34
|
-
var _a;
|
|
35
34
|
const scrollableContainer = (0, useScrollableContainer_1.getScrollableContainer)(elementId);
|
|
36
35
|
if (!scrollableContainer ||
|
|
37
36
|
!ref.current ||
|
|
38
|
-
|
|
37
|
+
ref.current?.clientHeight <= scrollableContainer?.clientHeight) {
|
|
39
38
|
return;
|
|
40
39
|
}
|
|
41
40
|
scrollableContainer.style.height = `${ref.current.clientHeight}px`;
|
|
@@ -5,9 +5,6 @@ const react_1 = require("react");
|
|
|
5
5
|
const providers_1 = require("../providers");
|
|
6
6
|
const useFeaturedTokens = (selectedChainId) => {
|
|
7
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]);
|
|
8
|
+
return (0, react_1.useMemo)(() => [...(tokens?.featured ?? []), ...(featuredTokens ?? [])].filter((token) => token.chainId === selectedChainId), [featuredTokens, selectedChainId, tokens?.featured]);
|
|
12
9
|
};
|
|
13
10
|
exports.useFeaturedTokens = useFeaturedTokens;
|
|
@@ -1,13 +1,4 @@
|
|
|
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
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.useGasSufficiency = void 0;
|
|
13
4
|
const react_query_1 = require("@tanstack/react-query");
|
|
@@ -20,9 +11,8 @@ const refetchInterval = 30000;
|
|
|
20
11
|
const useGasSufficiency = (route) => {
|
|
21
12
|
const { account } = (0, providers_1.useWallet)();
|
|
22
13
|
const { getChainById } = (0, _1.useChains)();
|
|
23
|
-
const { token: fromToken, getTokenBalancesWithRetry } = (0, useTokenBalance_1.useTokenBalance)(route
|
|
24
|
-
const { data: insufficientGas, isInitialLoading: insufficientGasLoading } = (0, react_query_1.useQuery)(['gas-sufficiency-check', account.address, route
|
|
25
|
-
var _a, _b;
|
|
14
|
+
const { token: fromToken, getTokenBalancesWithRetry } = (0, useTokenBalance_1.useTokenBalance)(route?.fromToken);
|
|
15
|
+
const { data: insufficientGas, isInitialLoading: insufficientGasLoading } = (0, react_query_1.useQuery)(['gas-sufficiency-check', account.address, route?.id], async () => {
|
|
26
16
|
if (!account.address || !route) {
|
|
27
17
|
return null;
|
|
28
18
|
}
|
|
@@ -33,7 +23,7 @@ const useGasSufficiency = (route) => {
|
|
|
33
23
|
const { token } = step.estimate.gasCosts[0];
|
|
34
24
|
const gasCostAmount = step.estimate.gasCosts
|
|
35
25
|
.reduce((amount, gasCost) => amount.plus((0, big_js_1.default)(gasCost.amount || 0)), (0, big_js_1.default)(0))
|
|
36
|
-
.div(
|
|
26
|
+
.div(10 ** token.decimals);
|
|
37
27
|
const groupedGasCost = groupedGasCosts[token.chainId];
|
|
38
28
|
const gasAmount = groupedGasCost
|
|
39
29
|
? groupedGasCost.gasAmount.plus(gasCostAmount)
|
|
@@ -47,59 +37,63 @@ const useGasSufficiency = (route) => {
|
|
|
47
37
|
}
|
|
48
38
|
return groupedGasCosts;
|
|
49
39
|
}, {});
|
|
50
|
-
if (route.fromToken.address ===
|
|
51
|
-
gasCosts[route.fromChainId].tokenAmount =
|
|
40
|
+
if (route.fromToken.address === gasCosts[route.fromChainId]?.token.address) {
|
|
41
|
+
gasCosts[route.fromChainId].tokenAmount = gasCosts[route.fromChainId]?.gasAmount.plus((0, big_js_1.default)(route.fromAmount).div(10 ** route.fromToken.decimals));
|
|
52
42
|
}
|
|
53
|
-
const tokenBalances =
|
|
54
|
-
if (!
|
|
43
|
+
const tokenBalances = await getTokenBalancesWithRetry(account.address, Object.values(gasCosts).map((item) => item.token));
|
|
44
|
+
if (!tokenBalances?.length) {
|
|
55
45
|
return null;
|
|
56
46
|
}
|
|
57
47
|
[route.fromChainId, route.toChainId].forEach((chainId) => {
|
|
58
|
-
var _a, _b, _c, _d, _e, _f;
|
|
59
48
|
if (gasCosts[chainId]) {
|
|
60
|
-
const gasTokenBalance = (0, big_js_1.default)(
|
|
61
|
-
t.address === gasCosts[chainId].token.address)
|
|
49
|
+
const gasTokenBalance = (0, big_js_1.default)(tokenBalances?.find((t) => t.chainId === gasCosts[chainId].token.chainId &&
|
|
50
|
+
t.address === gasCosts[chainId].token.address)?.amount ?? 0);
|
|
62
51
|
const insufficient = gasTokenBalance.lte(0) ||
|
|
63
|
-
gasTokenBalance.lt(
|
|
64
|
-
gasTokenBalance.lt(
|
|
52
|
+
gasTokenBalance.lt(gasCosts[chainId].gasAmount ?? (0, big_js_1.default)(0)) ||
|
|
53
|
+
gasTokenBalance.lt(gasCosts[chainId].tokenAmount ?? (0, big_js_1.default)(0));
|
|
65
54
|
const insufficientAmount = insufficient
|
|
66
|
-
?
|
|
55
|
+
? gasCosts[chainId].tokenAmount?.minus(gasTokenBalance) ??
|
|
56
|
+
gasCosts[chainId].gasAmount.minus(gasTokenBalance)
|
|
67
57
|
: undefined;
|
|
68
|
-
gasCosts[chainId] =
|
|
58
|
+
gasCosts[chainId] = {
|
|
59
|
+
...gasCosts[chainId],
|
|
60
|
+
insufficient,
|
|
61
|
+
insufficientAmount: insufficientAmount?.round(5, big_js_1.default.roundUp),
|
|
62
|
+
chain: insufficient ? getChainById(chainId) : undefined,
|
|
63
|
+
};
|
|
69
64
|
}
|
|
70
65
|
});
|
|
71
66
|
const gasCostResult = Object.values(gasCosts).filter((gasCost) => gasCost.insufficient);
|
|
72
67
|
return gasCostResult;
|
|
73
|
-
}
|
|
68
|
+
}, {
|
|
74
69
|
enabled: Boolean(account.address && route),
|
|
75
70
|
refetchInterval,
|
|
76
71
|
staleTime: refetchInterval,
|
|
77
72
|
cacheTime: refetchInterval,
|
|
78
73
|
});
|
|
79
|
-
const { data: insufficientFunds, isInitialLoading: insufficientFundsLoading, } = (0, react_query_1.useQuery)(['funds-sufficiency-check', account.address, route
|
|
80
|
-
var _c, _d, _e, _f;
|
|
74
|
+
const { data: insufficientFunds, isInitialLoading: insufficientFundsLoading, } = (0, react_query_1.useQuery)(['funds-sufficiency-check', account.address, route?.id], async () => {
|
|
81
75
|
if (!account.address || !fromToken || !route || (0, stores_1.isRouteDone)(route)) {
|
|
82
76
|
return null;
|
|
83
77
|
}
|
|
84
|
-
let currentTokenBalance = (0, big_js_1.default)(
|
|
85
|
-
const currentAction =
|
|
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;
|
|
86
80
|
if (fromToken.chainId === currentAction.fromToken.chainId &&
|
|
87
81
|
fromToken.address === currentAction.fromToken.address &&
|
|
88
82
|
currentTokenBalance.gt(0)) {
|
|
89
83
|
const insufficientFunds = (0, big_js_1.default)(route.fromAmount)
|
|
90
|
-
.div(
|
|
84
|
+
.div(10 ** route.fromToken.decimals)
|
|
91
85
|
.gt(currentTokenBalance);
|
|
92
86
|
return insufficientFunds;
|
|
93
87
|
}
|
|
94
|
-
const tokenBalances =
|
|
88
|
+
const tokenBalances = await getTokenBalancesWithRetry(account.address, [
|
|
95
89
|
currentAction.fromToken,
|
|
96
90
|
]);
|
|
97
|
-
currentTokenBalance = (0, big_js_1.default)(
|
|
91
|
+
currentTokenBalance = (0, big_js_1.default)(tokenBalances?.[0]?.amount ?? 0);
|
|
98
92
|
const insufficientFunds = (0, big_js_1.default)(currentAction.fromAmount)
|
|
99
|
-
.div(
|
|
93
|
+
.div(10 ** currentAction.fromToken.decimals)
|
|
100
94
|
.gt(currentTokenBalance);
|
|
101
95
|
return insufficientFunds;
|
|
102
|
-
}
|
|
96
|
+
}, {
|
|
103
97
|
enabled: Boolean(account.address && route && fromToken),
|
|
104
98
|
refetchInterval,
|
|
105
99
|
staleTime: refetchInterval,
|
|
@@ -69,16 +69,12 @@ const processSubstatusMessages = {
|
|
|
69
69
|
NOT_FOUND: {},
|
|
70
70
|
};
|
|
71
71
|
function getProcessMessage(t, getChainById, step, process) {
|
|
72
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
73
72
|
if (process.error && process.status === 'FAILED') {
|
|
74
|
-
const getTransactionNotSentMessage = () => {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
chainName: (_b = (_a = getChainById(step.action.fromChainId)) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : '',
|
|
80
|
-
});
|
|
81
|
-
};
|
|
73
|
+
const getTransactionNotSentMessage = () => t(`swap.error.message.transactionNotSent`, {
|
|
74
|
+
amount: (0, utils_1.formatTokenAmount)(step.action.fromAmount, step.action.fromToken.decimals),
|
|
75
|
+
tokenSymbol: step.action.fromToken.symbol,
|
|
76
|
+
chainName: getChainById(step.action.fromChainId)?.name ?? '',
|
|
77
|
+
});
|
|
82
78
|
let title = '';
|
|
83
79
|
let message = '';
|
|
84
80
|
switch (process.error.code) {
|
|
@@ -119,7 +115,7 @@ function getProcessMessage(t, getChainById, step, process) {
|
|
|
119
115
|
message = t(`swap.error.message.transactionRejected`, {
|
|
120
116
|
amount: (0, utils_1.formatTokenAmount)(step.action.fromAmount, step.action.fromToken.decimals),
|
|
121
117
|
tokenSymbol: step.action.fromToken.symbol,
|
|
122
|
-
chainName:
|
|
118
|
+
chainName: getChainById(step.action.fromChainId)?.name ?? '',
|
|
123
119
|
});
|
|
124
120
|
break;
|
|
125
121
|
case sdk_1.LifiErrorCode.ProviderUnavailable:
|
|
@@ -135,7 +131,7 @@ function getProcessMessage(t, getChainById, step, process) {
|
|
|
135
131
|
}
|
|
136
132
|
return { title, message };
|
|
137
133
|
}
|
|
138
|
-
const title =
|
|
134
|
+
const title = processSubstatusMessages[process.status]?.[process.substatus]?.(t) ?? processStatusMessages[process.type]?.[process.status]?.(t);
|
|
139
135
|
return { title };
|
|
140
136
|
}
|
|
141
137
|
exports.getProcessMessage = getProcessMessage;
|
|
@@ -1,13 +1,4 @@
|
|
|
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
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.useRouteExecution = void 0;
|
|
13
4
|
const react_query_1 = require("@tanstack/react-query");
|
|
@@ -51,31 +42,31 @@ const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchangeRateU
|
|
|
51
42
|
}
|
|
52
43
|
console.log('Route updated.', clonedUpdatedRoute);
|
|
53
44
|
};
|
|
54
|
-
const switchChainHook = (requiredChainId) =>
|
|
45
|
+
const switchChainHook = async (requiredChainId) => {
|
|
55
46
|
if (!account.isActive || !account.signer) {
|
|
56
47
|
return account.signer;
|
|
57
48
|
}
|
|
58
|
-
const currentChainId =
|
|
49
|
+
const currentChainId = await account.signer.getChainId();
|
|
59
50
|
if (currentChainId !== requiredChainId) {
|
|
60
|
-
const switched =
|
|
51
|
+
const switched = await switchChain(requiredChainId);
|
|
61
52
|
if (!switched) {
|
|
62
53
|
throw new Error('Chain was not switched.');
|
|
63
54
|
}
|
|
64
55
|
}
|
|
65
56
|
return account.signer;
|
|
66
|
-
}
|
|
67
|
-
const acceptExchangeRateUpdateHook = (params) =>
|
|
57
|
+
};
|
|
58
|
+
const acceptExchangeRateUpdateHook = async (params) => {
|
|
68
59
|
if (!onAcceptExchangeRateUpdate) {
|
|
69
60
|
return false;
|
|
70
61
|
}
|
|
71
|
-
const accepted =
|
|
62
|
+
const accepted = await new Promise((resolve) => onAcceptExchangeRateUpdate(resolve, params));
|
|
72
63
|
return accepted;
|
|
73
|
-
}
|
|
64
|
+
};
|
|
74
65
|
const executeRouteMutation = (0, react_query_1.useMutation)(() => {
|
|
75
66
|
if (!account.signer) {
|
|
76
67
|
throw Error('Account signer not found.');
|
|
77
68
|
}
|
|
78
|
-
if (!
|
|
69
|
+
if (!routeExecution?.route) {
|
|
79
70
|
throw Error('Execution route not found.');
|
|
80
71
|
}
|
|
81
72
|
queryClient.removeQueries(['routes']);
|
|
@@ -98,10 +89,10 @@ const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchangeRateU
|
|
|
98
89
|
if (!account.signer) {
|
|
99
90
|
throw Error('Account signer not found.');
|
|
100
91
|
}
|
|
101
|
-
if (!
|
|
92
|
+
if (!routeExecution?.route) {
|
|
102
93
|
throw Error('Execution route not found.');
|
|
103
94
|
}
|
|
104
|
-
return lifi.resumeRoute(account.signer, resumedRoute
|
|
95
|
+
return lifi.resumeRoute(account.signer, resumedRoute ?? routeExecution.route, {
|
|
105
96
|
updateCallback,
|
|
106
97
|
switchChainHook,
|
|
107
98
|
acceptExchangeRateUpdateHook,
|
|
@@ -137,9 +128,9 @@ const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchangeRateU
|
|
|
137
128
|
}, [resumeRouteMutation, routeId]);
|
|
138
129
|
const restartRouteMutation = (0, react_1.useCallback)(() => {
|
|
139
130
|
restartRoute(routeId);
|
|
140
|
-
resumeRoute(routeExecution
|
|
131
|
+
resumeRoute(routeExecution?.route);
|
|
141
132
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
142
|
-
}, [resumeRoute, routeExecution
|
|
133
|
+
}, [resumeRoute, routeExecution?.route, routeId]);
|
|
143
134
|
const deleteRouteMutation = (0, react_1.useCallback)(() => {
|
|
144
135
|
deleteRoute(routeId);
|
|
145
136
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -147,7 +138,7 @@ const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchangeRateU
|
|
|
147
138
|
// Resume route execution after page reload
|
|
148
139
|
(0, react_1.useEffect)(() => {
|
|
149
140
|
// Check if route is eligible for automatic resuming
|
|
150
|
-
if ((0, stores_1.isRouteActive)(routeExecution
|
|
141
|
+
if ((0, stores_1.isRouteActive)(routeExecution?.route) &&
|
|
151
142
|
account.isActive &&
|
|
152
143
|
!resumedAfterMount.current) {
|
|
153
144
|
resumedAfterMount.current = true;
|
|
@@ -157,8 +148,7 @@ const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchangeRateU
|
|
|
157
148
|
}, [account.isActive]);
|
|
158
149
|
(0, react_1.useEffect)(() => {
|
|
159
150
|
return () => {
|
|
160
|
-
|
|
161
|
-
const route = (_a = routeExecutionStoreContext.getState().routes[routeId]) === null || _a === void 0 ? void 0 : _a.route;
|
|
151
|
+
const route = routeExecutionStoreContext.getState().routes[routeId]?.route;
|
|
162
152
|
if (!route || !(0, stores_1.isRouteActive)(route)) {
|
|
163
153
|
return;
|
|
164
154
|
}
|
|
@@ -171,8 +161,8 @@ const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchangeRateU
|
|
|
171
161
|
executeRoute,
|
|
172
162
|
restartRoute: restartRouteMutation,
|
|
173
163
|
deleteRoute: deleteRouteMutation,
|
|
174
|
-
route: routeExecution
|
|
175
|
-
status: routeExecution
|
|
164
|
+
route: routeExecution?.route,
|
|
165
|
+
status: routeExecution?.status,
|
|
176
166
|
};
|
|
177
167
|
};
|
|
178
168
|
exports.useRouteExecution = useRouteExecution;
|
|
@@ -1,13 +1,4 @@
|
|
|
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
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.useSwapRoutes = void 0;
|
|
13
4
|
const address_1 = require("@ethersproject/address");
|
|
@@ -21,7 +12,6 @@ const providers_1 = require("../providers");
|
|
|
21
12
|
const stores_1 = require("../stores");
|
|
22
13
|
const refetchTime = 60000;
|
|
23
14
|
const useSwapRoutes = () => {
|
|
24
|
-
var _a, _b;
|
|
25
15
|
const lifi = (0, providers_1.useLiFi)();
|
|
26
16
|
const { variant, sdkConfig } = (0, providers_1.useWidgetConfig)();
|
|
27
17
|
const { account, provider } = (0, providers_1.useWallet)();
|
|
@@ -55,8 +45,8 @@ const useSwapRoutes = () => {
|
|
|
55
45
|
: true;
|
|
56
46
|
const isEnabled = !isNaN(fromChainId) &&
|
|
57
47
|
!isNaN(toChainId) &&
|
|
58
|
-
Boolean(fromToken
|
|
59
|
-
Boolean(toToken
|
|
48
|
+
Boolean(fromToken?.address) &&
|
|
49
|
+
Boolean(toToken?.address) &&
|
|
60
50
|
!Number.isNaN(slippage) &&
|
|
61
51
|
hasAmount &&
|
|
62
52
|
contractCallQuoteEnabled;
|
|
@@ -64,11 +54,11 @@ const useSwapRoutes = () => {
|
|
|
64
54
|
'routes',
|
|
65
55
|
account.address,
|
|
66
56
|
fromChainId,
|
|
67
|
-
fromToken
|
|
57
|
+
fromToken?.address,
|
|
68
58
|
fromTokenAmount,
|
|
69
59
|
toAddress,
|
|
70
60
|
toChainId,
|
|
71
|
-
toToken
|
|
61
|
+
toToken?.address,
|
|
72
62
|
toTokenAmount,
|
|
73
63
|
toContractAddress,
|
|
74
64
|
toContractCallData,
|
|
@@ -78,28 +68,28 @@ const useSwapRoutes = () => {
|
|
|
78
68
|
enabledExchanges,
|
|
79
69
|
routePriority,
|
|
80
70
|
variant,
|
|
81
|
-
|
|
71
|
+
sdkConfig?.defaultRouteOptions?.allowSwitchChain,
|
|
82
72
|
];
|
|
83
|
-
const previousDataUpdatedAt =
|
|
73
|
+
const previousDataUpdatedAt = queryClient.getQueryState(queryKey)?.dataUpdatedAt;
|
|
84
74
|
const refetchInterval = previousDataUpdatedAt
|
|
85
75
|
? Math.min(Math.abs(refetchTime - (Date.now() - previousDataUpdatedAt)), refetchTime)
|
|
86
76
|
: refetchTime;
|
|
87
|
-
const { data, isLoading, isFetching, isFetched, dataUpdatedAt, refetch } = (0, react_query_1.useQuery)(queryKey, ({ queryKey: [_, fromAddress, fromChainId, fromTokenAddress, fromTokenAmount, toAddress, toChainId, toTokenAddress, toTokenAmount, toContractAddress, toContractCallData, toContractGasLimit, slippage, enabledBridges, enabledExchanges, routePriority, variant, allowSwitchChain,], signal, }) =>
|
|
88
|
-
var _c, _d, _e;
|
|
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, }) => {
|
|
89
78
|
let toWalletAddress;
|
|
90
79
|
try {
|
|
91
80
|
toWalletAddress =
|
|
92
|
-
(
|
|
81
|
+
(await provider?.resolveName(toAddress)) ??
|
|
82
|
+
((0, address_1.isAddress)(toAddress) ? toAddress : fromAddress);
|
|
93
83
|
}
|
|
94
|
-
catch
|
|
84
|
+
catch {
|
|
95
85
|
toWalletAddress = (0, address_1.isAddress)(toAddress) ? toAddress : fromAddress;
|
|
96
86
|
}
|
|
97
87
|
const fromAmount = (0, big_js_1.default)(fromTokenAmount || 0)
|
|
98
|
-
.mul(
|
|
88
|
+
.mul(10 ** (fromToken?.decimals ?? 0))
|
|
99
89
|
.toFixed(0);
|
|
100
90
|
const formattedSlippage = parseFloat(slippage) / 100;
|
|
101
91
|
if (variant === 'nft') {
|
|
102
|
-
const contractCallQuote =
|
|
92
|
+
const contractCallQuote = await lifi.getContractCallQuote({
|
|
103
93
|
fromAddress,
|
|
104
94
|
fromChain: fromChainId,
|
|
105
95
|
fromToken: fromTokenAddress,
|
|
@@ -128,7 +118,7 @@ const useSwapRoutes = () => {
|
|
|
128
118
|
toAmountMin: toTokenAmount,
|
|
129
119
|
toToken: toToken,
|
|
130
120
|
toAddress: toAddress,
|
|
131
|
-
gasCostUSD:
|
|
121
|
+
gasCostUSD: contractCallQuote.estimate.gasCosts?.[0].amountUSD,
|
|
132
122
|
steps: [contractCallQuote],
|
|
133
123
|
};
|
|
134
124
|
return { routes: [route] };
|
|
@@ -153,20 +143,20 @@ const useSwapRoutes = () => {
|
|
|
153
143
|
allowSwitchChain: variant === 'refuel' ? false : allowSwitchChain,
|
|
154
144
|
},
|
|
155
145
|
}, { signal });
|
|
156
|
-
}
|
|
146
|
+
}, {
|
|
157
147
|
enabled: isEnabled,
|
|
158
148
|
refetchInterval,
|
|
159
149
|
staleTime: refetchTime,
|
|
160
150
|
cacheTime: refetchTime,
|
|
161
151
|
retry(failureCount, error) {
|
|
162
|
-
if (
|
|
152
|
+
if (error?.code === sdk_1.LifiErrorCode.NotFound) {
|
|
163
153
|
return false;
|
|
164
154
|
}
|
|
165
155
|
return true;
|
|
166
156
|
},
|
|
167
157
|
});
|
|
168
158
|
return {
|
|
169
|
-
routes: data
|
|
159
|
+
routes: data?.routes,
|
|
170
160
|
isLoading: isEnabled && isLoading,
|
|
171
161
|
isFetching,
|
|
172
162
|
isFetched,
|
package/cjs/hooks/useToken.js
CHANGED
|
@@ -7,13 +7,13 @@ const useTokenSearch_1 = require("./useTokenSearch");
|
|
|
7
7
|
const useToken = (chainId, tokenAddress) => {
|
|
8
8
|
const { tokens, isLoading } = (0, useTokens_1.useTokens)(chainId);
|
|
9
9
|
const token = (0, react_1.useMemo)(() => {
|
|
10
|
-
const token = tokens
|
|
10
|
+
const token = tokens?.find((token) => token.address === tokenAddress && token.chainId === chainId);
|
|
11
11
|
return token;
|
|
12
12
|
}, [chainId, tokenAddress, tokens]);
|
|
13
13
|
const tokenSearchEnabled = !isLoading && !token;
|
|
14
14
|
const { token: searchedToken, isLoading: isSearchedTokenLoading } = (0, useTokenSearch_1.useTokenSearch)(chainId, tokenAddress, tokenSearchEnabled);
|
|
15
15
|
return {
|
|
16
|
-
token: token
|
|
16
|
+
token: token ?? searchedToken,
|
|
17
17
|
isLoading: isLoading || (tokenSearchEnabled && isSearchedTokenLoading),
|
|
18
18
|
};
|
|
19
19
|
};
|
|
@@ -6,8 +6,7 @@ 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
|
-
const token = (_a = (tokensWithBalance !== null && tokensWithBalance !== void 0 ? tokensWithBalance : tokens)) === null || _a === void 0 ? void 0 : _a.find((token) => token.address === tokenAddress && token.chainId === chainId);
|
|
9
|
+
const token = (tokensWithBalance ?? tokens)?.find((token) => token.address === tokenAddress && token.chainId === chainId);
|
|
11
10
|
return token;
|
|
12
11
|
}, [chainId, tokenAddress, tokens, tokensWithBalance]);
|
|
13
12
|
return {
|