@lifi/widget 1.31.0 → 1.32.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 +4 -16
- package/AppDrawer.js +13 -7
- package/AppDrawer.style.d.ts +2 -2
- package/AppDrawer.style.js +1 -1
- package/AppProvider.js +2 -2
- package/AppRoutes.js +9 -0
- package/cjs/App.js +4 -16
- package/cjs/AppDrawer.js +13 -7
- package/cjs/AppDrawer.style.d.ts +2 -2
- 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 +3 -3
- 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 +3 -3
- 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 +1 -1
- 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 +1 -1
- 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 +2 -2
- 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 +1 -1
- package/cjs/components/SwapInput/SwapInputAdornment.style.d.ts +1 -1
- 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 +2 -2
- 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 +2 -2
- 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 +17 -28
- 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 +10 -19
- package/cjs/i18n/en.json +8 -4
- 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 +1 -1
- 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 +18 -23
- package/cjs/providers/WidgetProvider/utils.js +2 -3
- package/cjs/stores/StoreProvider.js +2 -2
- package/cjs/stores/chains/ChainOrderStore.js +2 -14
- package/cjs/stores/routes/RouteExecutionStore.js +2 -14
- package/cjs/stores/routes/createRouteExecutionStore.js +27 -16
- package/cjs/stores/routes/useExecutingRoutesIds.js +2 -5
- package/cjs/stores/routes/useSwapHistory.js +3 -6
- package/cjs/stores/routes/utils.js +4 -4
- package/cjs/stores/settings/SettingsStore.js +10 -20
- package/cjs/stores/settings/createSettingsStore.js +29 -25
- package/cjs/stores/settings/types.d.ts +6 -6
- package/cjs/utils/colors.js +1 -1
- package/cjs/utils/format.js +3 -3
- package/cjs/utils/index.d.ts +0 -1
- package/cjs/utils/index.js +0 -1
- 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 +3 -3
- 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 +3 -3
- 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 +1 -1
- 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 +1 -1
- 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 +2 -2
- 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 +1 -1
- package/components/SwapInput/SwapInputAdornment.style.d.ts +1 -1
- 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 +2 -2
- 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 +2 -2
- 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 +17 -28
- 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 +10 -19
- package/i18n/en.json +8 -4
- 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 +9 -9
- 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 +1 -1
- 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 +18 -23
- package/providers/WidgetProvider/utils.js +2 -3
- package/stores/StoreProvider.js +2 -2
- package/stores/chains/ChainOrderStore.js +2 -14
- package/stores/routes/RouteExecutionStore.js +2 -14
- package/stores/routes/createRouteExecutionStore.js +27 -16
- package/stores/routes/useExecutingRoutesIds.js +2 -5
- package/stores/routes/useSwapHistory.js +3 -6
- package/stores/routes/utils.js +4 -4
- package/stores/settings/SettingsStore.js +10 -20
- package/stores/settings/createSettingsStore.js +29 -25
- package/stores/settings/types.d.ts +6 -6
- package/tsconfig.cjs.tsbuildinfo +1 -1
- package/utils/colors.js +1 -1
- package/utils/format.js +3 -3
- package/utils/index.d.ts +0 -1
- package/utils/index.js +0 -1
- 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/utils/deepClone.d.ts +0 -1
- package/cjs/utils/deepClone.js +0 -7
- 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/utils/deepClone.d.ts +0 -1
- package/utils/deepClone.js +0 -3
package/config/theme.js
CHANGED
|
@@ -42,10 +42,12 @@ const shape = {
|
|
|
42
42
|
borderRadiusSecondary: 8,
|
|
43
43
|
};
|
|
44
44
|
export const createTheme = (mode, theme = {}) => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const primaryLightColor = lighten(
|
|
48
|
-
|
|
45
|
+
const primaryMainColor = theme.palette?.primary?.main ??
|
|
46
|
+
palette.primary.main;
|
|
47
|
+
const primaryLightColor = lighten(theme.palette?.primary?.main ??
|
|
48
|
+
palette.primary.main, 0.5);
|
|
49
|
+
const primaryDarkColor = darken(theme.palette?.primary?.main ??
|
|
50
|
+
palette.primary.main, 0.2);
|
|
49
51
|
const contrastButtonColor = getContrastRatio(common.white, primaryMainColor) >= 3
|
|
50
52
|
? common.white
|
|
51
53
|
: common.black;
|
|
@@ -53,17 +55,33 @@ export const createTheme = (mode, theme = {}) => {
|
|
|
53
55
|
? common.white
|
|
54
56
|
: common.black;
|
|
55
57
|
return createMuiTheme({
|
|
56
|
-
typography:
|
|
57
|
-
|
|
58
|
+
typography: {
|
|
59
|
+
fontFamily: 'Inter var, Inter, sans-serif',
|
|
60
|
+
...theme.typography,
|
|
61
|
+
},
|
|
62
|
+
palette: {
|
|
63
|
+
mode,
|
|
64
|
+
...palette,
|
|
65
|
+
...(mode === 'light' ? paletteLight : paletteDark),
|
|
66
|
+
...theme.palette,
|
|
67
|
+
primary: {
|
|
58
68
|
main: primaryMainColor,
|
|
59
69
|
light: primaryLightColor,
|
|
60
70
|
dark: primaryDarkColor,
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
71
|
+
},
|
|
72
|
+
secondary: {
|
|
73
|
+
main: theme.palette?.secondary?.main ??
|
|
74
|
+
palette.secondary.main,
|
|
75
|
+
light: lighten(theme.palette?.secondary?.main ??
|
|
76
|
+
palette.secondary.main, 0.5),
|
|
77
|
+
dark: darken(theme.palette?.secondary?.main ??
|
|
78
|
+
palette.secondary.main, 0.2),
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
shape: {
|
|
82
|
+
...shape,
|
|
83
|
+
...theme.shape,
|
|
84
|
+
},
|
|
67
85
|
breakpoints: {
|
|
68
86
|
values: {
|
|
69
87
|
xs: 0,
|
|
@@ -76,7 +94,14 @@ export const createTheme = (mode, theme = {}) => {
|
|
|
76
94
|
components: {
|
|
77
95
|
MuiScopedCssBaseline: {
|
|
78
96
|
styleOverrides: {
|
|
79
|
-
root:
|
|
97
|
+
root: {
|
|
98
|
+
fontFamily: 'Inter, sans-serif',
|
|
99
|
+
...theme.typography,
|
|
100
|
+
'@supports (font-variation-settings: normal)': {
|
|
101
|
+
fontFamily: 'Inter var, sans-serif',
|
|
102
|
+
...theme.typography,
|
|
103
|
+
},
|
|
104
|
+
},
|
|
80
105
|
},
|
|
81
106
|
},
|
|
82
107
|
MuiButton: {
|
|
@@ -85,7 +110,7 @@ export const createTheme = (mode, theme = {}) => {
|
|
|
85
110
|
},
|
|
86
111
|
styleOverrides: {
|
|
87
112
|
root: {
|
|
88
|
-
borderRadius:
|
|
113
|
+
borderRadius: theme.shape?.borderRadiusSecondary ?? shape.borderRadiusSecondary,
|
|
89
114
|
textTransform: 'none',
|
|
90
115
|
fontSize: '1rem',
|
|
91
116
|
[`&.Mui-disabled, &.Mui-disabled:hover`]: {
|
|
@@ -142,12 +167,15 @@ export const createTheme = (mode, theme = {}) => {
|
|
|
142
167
|
},
|
|
143
168
|
},
|
|
144
169
|
},
|
|
145
|
-
MuiAvatar:
|
|
170
|
+
MuiAvatar: {
|
|
171
|
+
styleOverrides: {
|
|
146
172
|
root: {
|
|
147
173
|
height: 32,
|
|
148
174
|
width: 32,
|
|
149
175
|
},
|
|
150
|
-
}
|
|
176
|
+
},
|
|
177
|
+
...theme.components?.MuiAvatar,
|
|
178
|
+
},
|
|
151
179
|
MuiListItemAvatar: {
|
|
152
180
|
styleOverrides: {
|
|
153
181
|
root: {
|
package/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.0";
|
package/config/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/widget';
|
|
2
|
-
export const version = '1.
|
|
2
|
+
export const version = '1.32.0';
|
package/hooks/useChain.js
CHANGED
|
@@ -3,7 +3,7 @@ import { useChains } from './useChains';
|
|
|
3
3
|
export const useChain = (chainId) => {
|
|
4
4
|
const { chains, isLoading } = useChains();
|
|
5
5
|
const chain = useMemo(() => {
|
|
6
|
-
const chain = chains
|
|
6
|
+
const chain = chains?.find((chain) => chain.id === chainId);
|
|
7
7
|
return chain;
|
|
8
8
|
}, [chainId, chains]);
|
|
9
9
|
return {
|
package/hooks/useChains.js
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import { useQuery } from '@tanstack/react-query';
|
|
11
2
|
import { useCallback } from 'react';
|
|
12
3
|
import { useFormContext } from 'react-hook-form';
|
|
@@ -17,8 +8,8 @@ export const useChains = () => {
|
|
|
17
8
|
const lifi = useLiFi();
|
|
18
9
|
const { getValues, setValue } = useFormContext();
|
|
19
10
|
const initializeChains = useChainOrderStore((state) => state.initializeChains);
|
|
20
|
-
const { data, isLoading } = useQuery(['chains'], () =>
|
|
21
|
-
const availableChains =
|
|
11
|
+
const { data, isLoading } = useQuery(['chains'], async () => {
|
|
12
|
+
const availableChains = await lifi.getChains();
|
|
22
13
|
const filteredChains = availableChains.filter((chain) => isItemAllowed(chain.id, chains, disabledChains));
|
|
23
14
|
const chainOrder = initializeChains(filteredChains.map((chain) => chain.id));
|
|
24
15
|
const [fromChainValue, toChainValue] = getValues([
|
|
@@ -32,16 +23,16 @@ export const useChains = () => {
|
|
|
32
23
|
setValue(SwapFormKey.ToChain, chainOrder[0]);
|
|
33
24
|
}
|
|
34
25
|
return { availableChains, filteredChains };
|
|
35
|
-
}
|
|
26
|
+
}, {
|
|
36
27
|
refetchInterval: 180000,
|
|
37
28
|
staleTime: 180000,
|
|
38
29
|
});
|
|
39
30
|
const getChainById = useCallback((chainId) => {
|
|
40
|
-
const chain = data
|
|
31
|
+
const chain = data?.availableChains.find((chain) => chain.id === chainId);
|
|
41
32
|
// if (!chain) {
|
|
42
33
|
// throw new Error('Chain not found or chainId is invalid.');
|
|
43
34
|
// }
|
|
44
35
|
return chain;
|
|
45
36
|
}, [data]);
|
|
46
|
-
return { chains: data
|
|
37
|
+
return { chains: data?.filteredChains, getChainById, isLoading };
|
|
47
38
|
};
|
|
@@ -27,11 +27,10 @@ export const useContentHeight = () => {
|
|
|
27
27
|
export const useSetContentHeight = (ref) => {
|
|
28
28
|
const elementId = useDefaultElementId();
|
|
29
29
|
useLayoutEffect(() => {
|
|
30
|
-
var _a;
|
|
31
30
|
const scrollableContainer = getScrollableContainer(elementId);
|
|
32
31
|
if (!scrollableContainer ||
|
|
33
32
|
!ref.current ||
|
|
34
|
-
|
|
33
|
+
ref.current?.clientHeight <= scrollableContainer?.clientHeight) {
|
|
35
34
|
return;
|
|
36
35
|
}
|
|
37
36
|
scrollableContainer.style.height = `${ref.current.clientHeight}px`;
|
|
@@ -2,8 +2,5 @@ import { useMemo } from 'react';
|
|
|
2
2
|
import { useWidgetConfig } from '../providers';
|
|
3
3
|
export const useFeaturedTokens = (selectedChainId) => {
|
|
4
4
|
const { featuredTokens, tokens } = useWidgetConfig();
|
|
5
|
-
return useMemo(() =>
|
|
6
|
-
var _a;
|
|
7
|
-
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);
|
|
8
|
-
}, [featuredTokens, selectedChainId, tokens === null || tokens === void 0 ? void 0 : tokens.featured]);
|
|
5
|
+
return useMemo(() => [...(tokens?.featured ?? []), ...(featuredTokens ?? [])].filter((token) => token.chainId === selectedChainId), [featuredTokens, selectedChainId, tokens?.featured]);
|
|
9
6
|
};
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import { useQuery } from '@tanstack/react-query';
|
|
11
2
|
import Big from 'big.js';
|
|
12
3
|
import { useChains } from '.';
|
|
@@ -17,9 +8,8 @@ const refetchInterval = 30000;
|
|
|
17
8
|
export const useGasSufficiency = (route) => {
|
|
18
9
|
const { account } = useWallet();
|
|
19
10
|
const { getChainById } = useChains();
|
|
20
|
-
const { token: fromToken, getTokenBalancesWithRetry } = useTokenBalance(route
|
|
21
|
-
const { data: insufficientGas, isInitialLoading: insufficientGasLoading } = useQuery(['gas-sufficiency-check', account.address, route
|
|
22
|
-
var _a, _b;
|
|
11
|
+
const { token: fromToken, getTokenBalancesWithRetry } = useTokenBalance(route?.fromToken);
|
|
12
|
+
const { data: insufficientGas, isInitialLoading: insufficientGasLoading } = useQuery(['gas-sufficiency-check', account.address, route?.id], async () => {
|
|
23
13
|
if (!account.address || !route) {
|
|
24
14
|
return null;
|
|
25
15
|
}
|
|
@@ -30,7 +20,7 @@ export const useGasSufficiency = (route) => {
|
|
|
30
20
|
const { token } = step.estimate.gasCosts[0];
|
|
31
21
|
const gasCostAmount = step.estimate.gasCosts
|
|
32
22
|
.reduce((amount, gasCost) => amount.plus(Big(gasCost.amount || 0)), Big(0))
|
|
33
|
-
.div(
|
|
23
|
+
.div(10 ** token.decimals);
|
|
34
24
|
const groupedGasCost = groupedGasCosts[token.chainId];
|
|
35
25
|
const gasAmount = groupedGasCost
|
|
36
26
|
? groupedGasCost.gasAmount.plus(gasCostAmount)
|
|
@@ -44,59 +34,63 @@ export const useGasSufficiency = (route) => {
|
|
|
44
34
|
}
|
|
45
35
|
return groupedGasCosts;
|
|
46
36
|
}, {});
|
|
47
|
-
if (route.fromToken.address ===
|
|
48
|
-
gasCosts[route.fromChainId].tokenAmount =
|
|
37
|
+
if (route.fromToken.address === gasCosts[route.fromChainId]?.token.address) {
|
|
38
|
+
gasCosts[route.fromChainId].tokenAmount = gasCosts[route.fromChainId]?.gasAmount.plus(Big(route.fromAmount).div(10 ** route.fromToken.decimals));
|
|
49
39
|
}
|
|
50
|
-
const tokenBalances =
|
|
51
|
-
if (!
|
|
40
|
+
const tokenBalances = await getTokenBalancesWithRetry(account.address, Object.values(gasCosts).map((item) => item.token));
|
|
41
|
+
if (!tokenBalances?.length) {
|
|
52
42
|
return null;
|
|
53
43
|
}
|
|
54
44
|
[route.fromChainId, route.toChainId].forEach((chainId) => {
|
|
55
|
-
var _a, _b, _c, _d, _e, _f;
|
|
56
45
|
if (gasCosts[chainId]) {
|
|
57
|
-
const gasTokenBalance = Big(
|
|
58
|
-
t.address === gasCosts[chainId].token.address)
|
|
46
|
+
const gasTokenBalance = Big(tokenBalances?.find((t) => t.chainId === gasCosts[chainId].token.chainId &&
|
|
47
|
+
t.address === gasCosts[chainId].token.address)?.amount ?? 0);
|
|
59
48
|
const insufficient = gasTokenBalance.lte(0) ||
|
|
60
|
-
gasTokenBalance.lt(
|
|
61
|
-
gasTokenBalance.lt(
|
|
49
|
+
gasTokenBalance.lt(gasCosts[chainId].gasAmount ?? Big(0)) ||
|
|
50
|
+
gasTokenBalance.lt(gasCosts[chainId].tokenAmount ?? Big(0));
|
|
62
51
|
const insufficientAmount = insufficient
|
|
63
|
-
?
|
|
52
|
+
? gasCosts[chainId].tokenAmount?.minus(gasTokenBalance) ??
|
|
53
|
+
gasCosts[chainId].gasAmount.minus(gasTokenBalance)
|
|
64
54
|
: undefined;
|
|
65
|
-
gasCosts[chainId] =
|
|
55
|
+
gasCosts[chainId] = {
|
|
56
|
+
...gasCosts[chainId],
|
|
57
|
+
insufficient,
|
|
58
|
+
insufficientAmount: insufficientAmount?.round(5, Big.roundUp),
|
|
59
|
+
chain: insufficient ? getChainById(chainId) : undefined,
|
|
60
|
+
};
|
|
66
61
|
}
|
|
67
62
|
});
|
|
68
63
|
const gasCostResult = Object.values(gasCosts).filter((gasCost) => gasCost.insufficient);
|
|
69
64
|
return gasCostResult;
|
|
70
|
-
}
|
|
65
|
+
}, {
|
|
71
66
|
enabled: Boolean(account.address && route),
|
|
72
67
|
refetchInterval,
|
|
73
68
|
staleTime: refetchInterval,
|
|
74
69
|
cacheTime: refetchInterval,
|
|
75
70
|
});
|
|
76
|
-
const { data: insufficientFunds, isInitialLoading: insufficientFundsLoading, } = useQuery(['funds-sufficiency-check', account.address, route
|
|
77
|
-
var _c, _d, _e, _f;
|
|
71
|
+
const { data: insufficientFunds, isInitialLoading: insufficientFundsLoading, } = useQuery(['funds-sufficiency-check', account.address, route?.id], async () => {
|
|
78
72
|
if (!account.address || !fromToken || !route || isRouteDone(route)) {
|
|
79
73
|
return null;
|
|
80
74
|
}
|
|
81
|
-
let currentTokenBalance = Big(
|
|
82
|
-
const currentAction =
|
|
75
|
+
let currentTokenBalance = Big(fromToken?.amount ?? 0);
|
|
76
|
+
const currentAction = route.steps.filter((step) => !step.execution || step.execution.status !== 'DONE')[0]?.action;
|
|
83
77
|
if (fromToken.chainId === currentAction.fromToken.chainId &&
|
|
84
78
|
fromToken.address === currentAction.fromToken.address &&
|
|
85
79
|
currentTokenBalance.gt(0)) {
|
|
86
80
|
const insufficientFunds = Big(route.fromAmount)
|
|
87
|
-
.div(
|
|
81
|
+
.div(10 ** route.fromToken.decimals)
|
|
88
82
|
.gt(currentTokenBalance);
|
|
89
83
|
return insufficientFunds;
|
|
90
84
|
}
|
|
91
|
-
const tokenBalances =
|
|
85
|
+
const tokenBalances = await getTokenBalancesWithRetry(account.address, [
|
|
92
86
|
currentAction.fromToken,
|
|
93
87
|
]);
|
|
94
|
-
currentTokenBalance = Big(
|
|
88
|
+
currentTokenBalance = Big(tokenBalances?.[0]?.amount ?? 0);
|
|
95
89
|
const insufficientFunds = Big(currentAction.fromAmount)
|
|
96
|
-
.div(
|
|
90
|
+
.div(10 ** currentAction.fromToken.decimals)
|
|
97
91
|
.gt(currentTokenBalance);
|
|
98
92
|
return insufficientFunds;
|
|
99
|
-
}
|
|
93
|
+
}, {
|
|
100
94
|
enabled: Boolean(account.address && route && fromToken),
|
|
101
95
|
refetchInterval,
|
|
102
96
|
staleTime: refetchInterval,
|
|
@@ -65,16 +65,12 @@ const processSubstatusMessages = {
|
|
|
65
65
|
NOT_FOUND: {},
|
|
66
66
|
};
|
|
67
67
|
export function getProcessMessage(t, getChainById, step, process) {
|
|
68
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
69
68
|
if (process.error && process.status === 'FAILED') {
|
|
70
|
-
const getTransactionNotSentMessage = () => {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
chainName: (_b = (_a = getChainById(step.action.fromChainId)) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : '',
|
|
76
|
-
});
|
|
77
|
-
};
|
|
69
|
+
const getTransactionNotSentMessage = () => t(`swap.error.message.transactionNotSent`, {
|
|
70
|
+
amount: formatTokenAmount(step.action.fromAmount, step.action.fromToken.decimals),
|
|
71
|
+
tokenSymbol: step.action.fromToken.symbol,
|
|
72
|
+
chainName: getChainById(step.action.fromChainId)?.name ?? '',
|
|
73
|
+
});
|
|
78
74
|
let title = '';
|
|
79
75
|
let message = '';
|
|
80
76
|
switch (process.error.code) {
|
|
@@ -115,7 +111,7 @@ export function getProcessMessage(t, getChainById, step, process) {
|
|
|
115
111
|
message = t(`swap.error.message.transactionRejected`, {
|
|
116
112
|
amount: formatTokenAmount(step.action.fromAmount, step.action.fromToken.decimals),
|
|
117
113
|
tokenSymbol: step.action.fromToken.symbol,
|
|
118
|
-
chainName:
|
|
114
|
+
chainName: getChainById(step.action.fromChainId)?.name ?? '',
|
|
119
115
|
});
|
|
120
116
|
break;
|
|
121
117
|
case LifiErrorCode.ProviderUnavailable:
|
|
@@ -131,6 +127,6 @@ export function getProcessMessage(t, getChainById, step, process) {
|
|
|
131
127
|
}
|
|
132
128
|
return { title, message };
|
|
133
129
|
}
|
|
134
|
-
const title =
|
|
130
|
+
const title = processSubstatusMessages[process.status]?.[process.substatus]?.(t) ?? processStatusMessages[process.type]?.[process.status]?.(t);
|
|
135
131
|
return { title };
|
|
136
132
|
}
|
|
@@ -1,19 +1,9 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
11
2
|
import { useCallback, useEffect, useRef } from 'react';
|
|
12
3
|
import { shallow } from 'zustand/shallow';
|
|
13
4
|
import { useLiFi, useWallet } from '../providers';
|
|
14
5
|
import { getUpdatedProcess, isRouteActive, isRouteDone, isRouteFailed, useRouteExecutionStore, useRouteExecutionStoreContext, } from '../stores';
|
|
15
6
|
import { WidgetEvent } from '../types/events';
|
|
16
|
-
import { deepClone } from '../utils';
|
|
17
7
|
import { useWidgetEvents } from './useWidgetEvents';
|
|
18
8
|
export const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchangeRateUpdate, }) => {
|
|
19
9
|
const lifi = useLiFi();
|
|
@@ -29,7 +19,7 @@ export const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchan
|
|
|
29
19
|
if (!routeExecution) {
|
|
30
20
|
return;
|
|
31
21
|
}
|
|
32
|
-
const clonedUpdatedRoute =
|
|
22
|
+
const clonedUpdatedRoute = structuredClone(updatedRoute);
|
|
33
23
|
updateRoute(clonedUpdatedRoute);
|
|
34
24
|
const process = getUpdatedProcess(routeExecution.route, clonedUpdatedRoute);
|
|
35
25
|
if (process) {
|
|
@@ -49,31 +39,31 @@ export const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchan
|
|
|
49
39
|
}
|
|
50
40
|
console.log('Route updated.', clonedUpdatedRoute);
|
|
51
41
|
};
|
|
52
|
-
const switchChainHook = (requiredChainId) =>
|
|
42
|
+
const switchChainHook = async (requiredChainId) => {
|
|
53
43
|
if (!account.isActive || !account.signer) {
|
|
54
44
|
return account.signer;
|
|
55
45
|
}
|
|
56
|
-
const currentChainId =
|
|
46
|
+
const currentChainId = await account.signer.getChainId();
|
|
57
47
|
if (currentChainId !== requiredChainId) {
|
|
58
|
-
const switched =
|
|
48
|
+
const switched = await switchChain(requiredChainId);
|
|
59
49
|
if (!switched) {
|
|
60
50
|
throw new Error('Chain was not switched.');
|
|
61
51
|
}
|
|
62
52
|
}
|
|
63
53
|
return account.signer;
|
|
64
|
-
}
|
|
65
|
-
const acceptExchangeRateUpdateHook = (params) =>
|
|
54
|
+
};
|
|
55
|
+
const acceptExchangeRateUpdateHook = async (params) => {
|
|
66
56
|
if (!onAcceptExchangeRateUpdate) {
|
|
67
57
|
return false;
|
|
68
58
|
}
|
|
69
|
-
const accepted =
|
|
59
|
+
const accepted = await new Promise((resolve) => onAcceptExchangeRateUpdate(resolve, params));
|
|
70
60
|
return accepted;
|
|
71
|
-
}
|
|
61
|
+
};
|
|
72
62
|
const executeRouteMutation = useMutation(() => {
|
|
73
63
|
if (!account.signer) {
|
|
74
64
|
throw Error('Account signer not found.');
|
|
75
65
|
}
|
|
76
|
-
if (!
|
|
66
|
+
if (!routeExecution?.route) {
|
|
77
67
|
throw Error('Execution route not found.');
|
|
78
68
|
}
|
|
79
69
|
queryClient.removeQueries(['routes']);
|
|
@@ -96,10 +86,10 @@ export const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchan
|
|
|
96
86
|
if (!account.signer) {
|
|
97
87
|
throw Error('Account signer not found.');
|
|
98
88
|
}
|
|
99
|
-
if (!
|
|
89
|
+
if (!routeExecution?.route) {
|
|
100
90
|
throw Error('Execution route not found.');
|
|
101
91
|
}
|
|
102
|
-
return lifi.resumeRoute(account.signer, resumedRoute
|
|
92
|
+
return lifi.resumeRoute(account.signer, resumedRoute ?? routeExecution.route, {
|
|
103
93
|
updateCallback,
|
|
104
94
|
switchChainHook,
|
|
105
95
|
acceptExchangeRateUpdateHook,
|
|
@@ -135,9 +125,9 @@ export const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchan
|
|
|
135
125
|
}, [resumeRouteMutation, routeId]);
|
|
136
126
|
const restartRouteMutation = useCallback(() => {
|
|
137
127
|
restartRoute(routeId);
|
|
138
|
-
resumeRoute(routeExecution
|
|
128
|
+
resumeRoute(routeExecution?.route);
|
|
139
129
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
140
|
-
}, [resumeRoute, routeExecution
|
|
130
|
+
}, [resumeRoute, routeExecution?.route, routeId]);
|
|
141
131
|
const deleteRouteMutation = useCallback(() => {
|
|
142
132
|
deleteRoute(routeId);
|
|
143
133
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -145,7 +135,7 @@ export const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchan
|
|
|
145
135
|
// Resume route execution after page reload
|
|
146
136
|
useEffect(() => {
|
|
147
137
|
// Check if route is eligible for automatic resuming
|
|
148
|
-
if (isRouteActive(routeExecution
|
|
138
|
+
if (isRouteActive(routeExecution?.route) &&
|
|
149
139
|
account.isActive &&
|
|
150
140
|
!resumedAfterMount.current) {
|
|
151
141
|
resumedAfterMount.current = true;
|
|
@@ -155,8 +145,7 @@ export const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchan
|
|
|
155
145
|
}, [account.isActive]);
|
|
156
146
|
useEffect(() => {
|
|
157
147
|
return () => {
|
|
158
|
-
|
|
159
|
-
const route = (_a = routeExecutionStoreContext.getState().routes[routeId]) === null || _a === void 0 ? void 0 : _a.route;
|
|
148
|
+
const route = routeExecutionStoreContext.getState().routes[routeId]?.route;
|
|
160
149
|
if (!route || !isRouteActive(route)) {
|
|
161
150
|
return;
|
|
162
151
|
}
|
|
@@ -169,7 +158,7 @@ export const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchan
|
|
|
169
158
|
executeRoute,
|
|
170
159
|
restartRoute: restartRouteMutation,
|
|
171
160
|
deleteRoute: deleteRouteMutation,
|
|
172
|
-
route: routeExecution
|
|
173
|
-
status: routeExecution
|
|
161
|
+
route: routeExecution?.route,
|
|
162
|
+
status: routeExecution?.status,
|
|
174
163
|
};
|
|
175
164
|
};
|
package/hooks/useSwapRoutes.js
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import { isAddress } from '@ethersproject/address';
|
|
11
2
|
import { LifiErrorCode } from '@lifi/sdk';
|
|
12
3
|
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
|
@@ -18,7 +9,6 @@ import { SwapFormKey, useLiFi, useWallet, useWidgetConfig } from '../providers';
|
|
|
18
9
|
import { useSettings } from '../stores';
|
|
19
10
|
const refetchTime = 60000;
|
|
20
11
|
export const useSwapRoutes = () => {
|
|
21
|
-
var _a, _b;
|
|
22
12
|
const lifi = useLiFi();
|
|
23
13
|
const { variant, sdkConfig } = useWidgetConfig();
|
|
24
14
|
const { account, provider } = useWallet();
|
|
@@ -52,8 +42,8 @@ export const useSwapRoutes = () => {
|
|
|
52
42
|
: true;
|
|
53
43
|
const isEnabled = !isNaN(fromChainId) &&
|
|
54
44
|
!isNaN(toChainId) &&
|
|
55
|
-
Boolean(fromToken
|
|
56
|
-
Boolean(toToken
|
|
45
|
+
Boolean(fromToken?.address) &&
|
|
46
|
+
Boolean(toToken?.address) &&
|
|
57
47
|
!Number.isNaN(slippage) &&
|
|
58
48
|
hasAmount &&
|
|
59
49
|
contractCallQuoteEnabled;
|
|
@@ -61,11 +51,11 @@ export const useSwapRoutes = () => {
|
|
|
61
51
|
'routes',
|
|
62
52
|
account.address,
|
|
63
53
|
fromChainId,
|
|
64
|
-
fromToken
|
|
54
|
+
fromToken?.address,
|
|
65
55
|
fromTokenAmount,
|
|
66
56
|
toAddress,
|
|
67
57
|
toChainId,
|
|
68
|
-
toToken
|
|
58
|
+
toToken?.address,
|
|
69
59
|
toTokenAmount,
|
|
70
60
|
toContractAddress,
|
|
71
61
|
toContractCallData,
|
|
@@ -75,28 +65,28 @@ export const useSwapRoutes = () => {
|
|
|
75
65
|
enabledExchanges,
|
|
76
66
|
routePriority,
|
|
77
67
|
variant,
|
|
78
|
-
|
|
68
|
+
sdkConfig?.defaultRouteOptions?.allowSwitchChain,
|
|
79
69
|
];
|
|
80
|
-
const previousDataUpdatedAt =
|
|
70
|
+
const previousDataUpdatedAt = queryClient.getQueryState(queryKey)?.dataUpdatedAt;
|
|
81
71
|
const refetchInterval = previousDataUpdatedAt
|
|
82
72
|
? Math.min(Math.abs(refetchTime - (Date.now() - previousDataUpdatedAt)), refetchTime)
|
|
83
73
|
: refetchTime;
|
|
84
|
-
const { data, isLoading, isFetching, isFetched, dataUpdatedAt, refetch } = useQuery(queryKey, ({ queryKey: [_, fromAddress, fromChainId, fromTokenAddress, fromTokenAmount, toAddress, toChainId, toTokenAddress, toTokenAmount, toContractAddress, toContractCallData, toContractGasLimit, slippage, enabledBridges, enabledExchanges, routePriority, variant, allowSwitchChain,], signal, }) =>
|
|
85
|
-
var _c, _d, _e;
|
|
74
|
+
const { data, isLoading, isFetching, isFetched, dataUpdatedAt, refetch } = useQuery(queryKey, async ({ queryKey: [_, fromAddress, fromChainId, fromTokenAddress, fromTokenAmount, toAddress, toChainId, toTokenAddress, toTokenAmount, toContractAddress, toContractCallData, toContractGasLimit, slippage, enabledBridges, enabledExchanges, routePriority, variant, allowSwitchChain,], signal, }) => {
|
|
86
75
|
let toWalletAddress;
|
|
87
76
|
try {
|
|
88
77
|
toWalletAddress =
|
|
89
|
-
(
|
|
78
|
+
(await provider?.resolveName(toAddress)) ??
|
|
79
|
+
(isAddress(toAddress) ? toAddress : fromAddress);
|
|
90
80
|
}
|
|
91
|
-
catch
|
|
81
|
+
catch {
|
|
92
82
|
toWalletAddress = isAddress(toAddress) ? toAddress : fromAddress;
|
|
93
83
|
}
|
|
94
84
|
const fromAmount = Big(fromTokenAmount || 0)
|
|
95
|
-
.mul(
|
|
85
|
+
.mul(10 ** (fromToken?.decimals ?? 0))
|
|
96
86
|
.toFixed(0);
|
|
97
87
|
const formattedSlippage = parseFloat(slippage) / 100;
|
|
98
88
|
if (variant === 'nft') {
|
|
99
|
-
const contractCallQuote =
|
|
89
|
+
const contractCallQuote = await lifi.getContractCallQuote({
|
|
100
90
|
fromAddress,
|
|
101
91
|
fromChain: fromChainId,
|
|
102
92
|
fromToken: fromTokenAddress,
|
|
@@ -125,7 +115,7 @@ export const useSwapRoutes = () => {
|
|
|
125
115
|
toAmountMin: toTokenAmount,
|
|
126
116
|
toToken: toToken,
|
|
127
117
|
toAddress: toAddress,
|
|
128
|
-
gasCostUSD:
|
|
118
|
+
gasCostUSD: contractCallQuote.estimate.gasCosts?.[0].amountUSD,
|
|
129
119
|
steps: [contractCallQuote],
|
|
130
120
|
};
|
|
131
121
|
return { routes: [route] };
|
|
@@ -150,20 +140,20 @@ export const useSwapRoutes = () => {
|
|
|
150
140
|
allowSwitchChain: variant === 'refuel' ? false : allowSwitchChain,
|
|
151
141
|
},
|
|
152
142
|
}, { signal });
|
|
153
|
-
}
|
|
143
|
+
}, {
|
|
154
144
|
enabled: isEnabled,
|
|
155
145
|
refetchInterval,
|
|
156
146
|
staleTime: refetchTime,
|
|
157
147
|
cacheTime: refetchTime,
|
|
158
148
|
retry(failureCount, error) {
|
|
159
|
-
if (
|
|
149
|
+
if (error?.code === LifiErrorCode.NotFound) {
|
|
160
150
|
return false;
|
|
161
151
|
}
|
|
162
152
|
return true;
|
|
163
153
|
},
|
|
164
154
|
});
|
|
165
155
|
return {
|
|
166
|
-
routes: data
|
|
156
|
+
routes: data?.routes,
|
|
167
157
|
isLoading: isEnabled && isLoading,
|
|
168
158
|
isFetching,
|
|
169
159
|
isFetched,
|
package/hooks/useToken.js
CHANGED
|
@@ -4,13 +4,13 @@ import { useTokenSearch } from './useTokenSearch';
|
|
|
4
4
|
export const useToken = (chainId, tokenAddress) => {
|
|
5
5
|
const { tokens, isLoading } = useTokens(chainId);
|
|
6
6
|
const token = useMemo(() => {
|
|
7
|
-
const token = tokens
|
|
7
|
+
const token = tokens?.find((token) => token.address === tokenAddress && token.chainId === chainId);
|
|
8
8
|
return token;
|
|
9
9
|
}, [chainId, tokenAddress, tokens]);
|
|
10
10
|
const tokenSearchEnabled = !isLoading && !token;
|
|
11
11
|
const { token: searchedToken, isLoading: isSearchedTokenLoading } = useTokenSearch(chainId, tokenAddress, tokenSearchEnabled);
|
|
12
12
|
return {
|
|
13
|
-
token: token
|
|
13
|
+
token: token ?? searchedToken,
|
|
14
14
|
isLoading: isLoading || (tokenSearchEnabled && isSearchedTokenLoading),
|
|
15
15
|
};
|
|
16
16
|
};
|
|
@@ -3,8 +3,7 @@ import { useTokenBalances } from './useTokenBalances';
|
|
|
3
3
|
export const useTokenAddressBalance = (chainId, tokenAddress) => {
|
|
4
4
|
const { tokens, tokensWithBalance, isBalanceLoading, refetch } = useTokenBalances(chainId);
|
|
5
5
|
const token = useMemo(() => {
|
|
6
|
-
|
|
7
|
-
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);
|
|
6
|
+
const token = (tokensWithBalance ?? tokens)?.find((token) => token.address === tokenAddress && token.chainId === chainId);
|
|
8
7
|
return token;
|
|
9
8
|
}, [chainId, tokenAddress, tokens, tokensWithBalance]);
|
|
10
9
|
return {
|