@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
|
@@ -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");
|
|
@@ -16,7 +7,6 @@ const shallow_1 = require("zustand/shallow");
|
|
|
16
7
|
const providers_1 = require("../providers");
|
|
17
8
|
const stores_1 = require("../stores");
|
|
18
9
|
const events_1 = require("../types/events");
|
|
19
|
-
const utils_1 = require("../utils");
|
|
20
10
|
const useWidgetEvents_1 = require("./useWidgetEvents");
|
|
21
11
|
const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchangeRateUpdate, }) => {
|
|
22
12
|
const lifi = (0, providers_1.useLiFi)();
|
|
@@ -32,7 +22,7 @@ const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchangeRateU
|
|
|
32
22
|
if (!routeExecution) {
|
|
33
23
|
return;
|
|
34
24
|
}
|
|
35
|
-
const clonedUpdatedRoute = (
|
|
25
|
+
const clonedUpdatedRoute = structuredClone(updatedRoute);
|
|
36
26
|
updateRoute(clonedUpdatedRoute);
|
|
37
27
|
const process = (0, stores_1.getUpdatedProcess)(routeExecution.route, clonedUpdatedRoute);
|
|
38
28
|
if (process) {
|
|
@@ -52,31 +42,31 @@ const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchangeRateU
|
|
|
52
42
|
}
|
|
53
43
|
console.log('Route updated.', clonedUpdatedRoute);
|
|
54
44
|
};
|
|
55
|
-
const switchChainHook = (requiredChainId) =>
|
|
45
|
+
const switchChainHook = async (requiredChainId) => {
|
|
56
46
|
if (!account.isActive || !account.signer) {
|
|
57
47
|
return account.signer;
|
|
58
48
|
}
|
|
59
|
-
const currentChainId =
|
|
49
|
+
const currentChainId = await account.signer.getChainId();
|
|
60
50
|
if (currentChainId !== requiredChainId) {
|
|
61
|
-
const switched =
|
|
51
|
+
const switched = await switchChain(requiredChainId);
|
|
62
52
|
if (!switched) {
|
|
63
53
|
throw new Error('Chain was not switched.');
|
|
64
54
|
}
|
|
65
55
|
}
|
|
66
56
|
return account.signer;
|
|
67
|
-
}
|
|
68
|
-
const acceptExchangeRateUpdateHook = (params) =>
|
|
57
|
+
};
|
|
58
|
+
const acceptExchangeRateUpdateHook = async (params) => {
|
|
69
59
|
if (!onAcceptExchangeRateUpdate) {
|
|
70
60
|
return false;
|
|
71
61
|
}
|
|
72
|
-
const accepted =
|
|
62
|
+
const accepted = await new Promise((resolve) => onAcceptExchangeRateUpdate(resolve, params));
|
|
73
63
|
return accepted;
|
|
74
|
-
}
|
|
64
|
+
};
|
|
75
65
|
const executeRouteMutation = (0, react_query_1.useMutation)(() => {
|
|
76
66
|
if (!account.signer) {
|
|
77
67
|
throw Error('Account signer not found.');
|
|
78
68
|
}
|
|
79
|
-
if (!
|
|
69
|
+
if (!routeExecution?.route) {
|
|
80
70
|
throw Error('Execution route not found.');
|
|
81
71
|
}
|
|
82
72
|
queryClient.removeQueries(['routes']);
|
|
@@ -99,10 +89,10 @@ const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchangeRateU
|
|
|
99
89
|
if (!account.signer) {
|
|
100
90
|
throw Error('Account signer not found.');
|
|
101
91
|
}
|
|
102
|
-
if (!
|
|
92
|
+
if (!routeExecution?.route) {
|
|
103
93
|
throw Error('Execution route not found.');
|
|
104
94
|
}
|
|
105
|
-
return lifi.resumeRoute(account.signer, resumedRoute
|
|
95
|
+
return lifi.resumeRoute(account.signer, resumedRoute ?? routeExecution.route, {
|
|
106
96
|
updateCallback,
|
|
107
97
|
switchChainHook,
|
|
108
98
|
acceptExchangeRateUpdateHook,
|
|
@@ -138,9 +128,9 @@ const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchangeRateU
|
|
|
138
128
|
}, [resumeRouteMutation, routeId]);
|
|
139
129
|
const restartRouteMutation = (0, react_1.useCallback)(() => {
|
|
140
130
|
restartRoute(routeId);
|
|
141
|
-
resumeRoute(routeExecution
|
|
131
|
+
resumeRoute(routeExecution?.route);
|
|
142
132
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
143
|
-
}, [resumeRoute, routeExecution
|
|
133
|
+
}, [resumeRoute, routeExecution?.route, routeId]);
|
|
144
134
|
const deleteRouteMutation = (0, react_1.useCallback)(() => {
|
|
145
135
|
deleteRoute(routeId);
|
|
146
136
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -148,7 +138,7 @@ const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchangeRateU
|
|
|
148
138
|
// Resume route execution after page reload
|
|
149
139
|
(0, react_1.useEffect)(() => {
|
|
150
140
|
// Check if route is eligible for automatic resuming
|
|
151
|
-
if ((0, stores_1.isRouteActive)(routeExecution
|
|
141
|
+
if ((0, stores_1.isRouteActive)(routeExecution?.route) &&
|
|
152
142
|
account.isActive &&
|
|
153
143
|
!resumedAfterMount.current) {
|
|
154
144
|
resumedAfterMount.current = true;
|
|
@@ -158,8 +148,7 @@ const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchangeRateU
|
|
|
158
148
|
}, [account.isActive]);
|
|
159
149
|
(0, react_1.useEffect)(() => {
|
|
160
150
|
return () => {
|
|
161
|
-
|
|
162
|
-
const route = (_a = routeExecutionStoreContext.getState().routes[routeId]) === null || _a === void 0 ? void 0 : _a.route;
|
|
151
|
+
const route = routeExecutionStoreContext.getState().routes[routeId]?.route;
|
|
163
152
|
if (!route || !(0, stores_1.isRouteActive)(route)) {
|
|
164
153
|
return;
|
|
165
154
|
}
|
|
@@ -172,8 +161,8 @@ const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchangeRateU
|
|
|
172
161
|
executeRoute,
|
|
173
162
|
restartRoute: restartRouteMutation,
|
|
174
163
|
deleteRoute: deleteRouteMutation,
|
|
175
|
-
route: routeExecution
|
|
176
|
-
status: routeExecution
|
|
164
|
+
route: routeExecution?.route,
|
|
165
|
+
status: routeExecution?.status,
|
|
177
166
|
};
|
|
178
167
|
};
|
|
179
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 {
|
|
@@ -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.useTokenBalance = void 0;
|
|
13
4
|
const react_query_1 = require("@tanstack/react-query");
|
|
@@ -19,17 +10,17 @@ const useTokenBalance = (token, accountAddress) => {
|
|
|
19
10
|
const lifi = (0, providers_1.useLiFi)();
|
|
20
11
|
const { account } = (0, providers_1.useWallet)();
|
|
21
12
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
22
|
-
const walletAddress = accountAddress
|
|
23
|
-
const getTokenBalancesWithRetry = (0, react_1.useCallback)((accountAddress, tokens, depth = 0) =>
|
|
13
|
+
const walletAddress = accountAddress ?? account.address;
|
|
14
|
+
const getTokenBalancesWithRetry = (0, react_1.useCallback)(async (accountAddress, tokens, depth = 0) => {
|
|
24
15
|
try {
|
|
25
|
-
const tokenBalances =
|
|
16
|
+
const tokenBalances = await lifi.getTokenBalances(accountAddress, tokens);
|
|
26
17
|
if (!tokenBalances.every((token) => token.blockNumber)) {
|
|
27
18
|
if (depth > 10) {
|
|
28
19
|
console.warn('Token balance backoff depth exceeded.');
|
|
29
20
|
return undefined;
|
|
30
21
|
}
|
|
31
|
-
|
|
32
|
-
setTimeout(resolve,
|
|
22
|
+
await new Promise((resolve) => {
|
|
23
|
+
setTimeout(resolve, 1.5 ** depth * 100);
|
|
33
24
|
});
|
|
34
25
|
return getTokenBalancesWithRetry(accountAddress, tokens, depth + 1);
|
|
35
26
|
}
|
|
@@ -38,26 +29,26 @@ const useTokenBalance = (token, accountAddress) => {
|
|
|
38
29
|
catch (error) {
|
|
39
30
|
//
|
|
40
31
|
}
|
|
41
|
-
}
|
|
42
|
-
const tokenBalanceQueryKey = (0, react_1.useMemo)(() => ['token-balance', walletAddress, token
|
|
43
|
-
const { data, isLoading, refetch } = (0, react_query_1.useQuery)(tokenBalanceQueryKey, ({ queryKey: [, accountAddress] }) =>
|
|
44
|
-
|
|
45
|
-
const cachedToken = (_a = queryClient
|
|
32
|
+
}, [lifi]);
|
|
33
|
+
const tokenBalanceQueryKey = (0, react_1.useMemo)(() => ['token-balance', walletAddress, token?.chainId, token?.address], [token?.address, token?.chainId, walletAddress]);
|
|
34
|
+
const { data, isLoading, refetch } = (0, react_query_1.useQuery)(tokenBalanceQueryKey, async ({ queryKey: [, accountAddress] }) => {
|
|
35
|
+
const cachedToken = queryClient
|
|
46
36
|
.getQueryData([
|
|
47
37
|
'token-balances',
|
|
48
38
|
accountAddress,
|
|
49
39
|
token.chainId,
|
|
50
|
-
])
|
|
40
|
+
])
|
|
41
|
+
?.find((t) => t.address === token.address);
|
|
51
42
|
if (cachedToken) {
|
|
52
43
|
return cachedToken;
|
|
53
44
|
}
|
|
54
|
-
const tokenBalances =
|
|
55
|
-
if (!
|
|
45
|
+
const tokenBalances = await getTokenBalancesWithRetry(accountAddress, [token]);
|
|
46
|
+
if (!tokenBalances?.length) {
|
|
56
47
|
throw Error('Could not get tokens balance.');
|
|
57
48
|
}
|
|
58
49
|
const cachedTokenAmount = queryClient.getQueryData(tokenBalanceQueryKey);
|
|
59
50
|
const formattedAmount = (0, utils_1.formatTokenAmount)(tokenBalances[0].amount);
|
|
60
|
-
if (
|
|
51
|
+
if (cachedTokenAmount?.amount !== formattedAmount) {
|
|
61
52
|
queryClient.setQueryDefaults(tokenBalanceQueryKey, {
|
|
62
53
|
refetchInterval: defaultRefetchInterval,
|
|
63
54
|
staleTime: defaultRefetchInterval,
|
|
@@ -66,12 +57,18 @@ const useTokenBalance = (token, accountAddress) => {
|
|
|
66
57
|
queryClient.setQueryData(['token-balances', accountAddress, token.chainId], (data) => {
|
|
67
58
|
if (data) {
|
|
68
59
|
const index = data.findIndex((dataToken) => dataToken.address === token.address);
|
|
69
|
-
data[index] =
|
|
60
|
+
data[index] = {
|
|
61
|
+
...data[index],
|
|
62
|
+
amount: formattedAmount,
|
|
63
|
+
};
|
|
70
64
|
}
|
|
71
65
|
return data;
|
|
72
66
|
});
|
|
73
|
-
return
|
|
74
|
-
|
|
67
|
+
return {
|
|
68
|
+
...tokenBalances[0],
|
|
69
|
+
amount: formattedAmount,
|
|
70
|
+
};
|
|
71
|
+
}, {
|
|
75
72
|
enabled: Boolean(walletAddress && token),
|
|
76
73
|
refetchInterval: defaultRefetchInterval,
|
|
77
74
|
staleTime: defaultRefetchInterval,
|
|
@@ -79,7 +76,7 @@ const useTokenBalance = (token, accountAddress) => {
|
|
|
79
76
|
const refetchAllBalances = () => {
|
|
80
77
|
queryClient.refetchQueries([
|
|
81
78
|
'token-balances',
|
|
82
|
-
token
|
|
79
|
+
token?.chainId,
|
|
83
80
|
accountAddress,
|
|
84
81
|
]);
|
|
85
82
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Token } from '../types';
|
|
2
2
|
export declare const useTokenBalances: (selectedChainId?: number) => {
|
|
3
|
-
tokens: Token[]
|
|
3
|
+
tokens: Token[];
|
|
4
4
|
tokensWithBalance: Token[] | undefined;
|
|
5
5
|
featuredTokens: import("@lifi/types").Token[];
|
|
6
6
|
isLoading: boolean;
|
|
@@ -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.useTokenBalances = void 0;
|
|
13
4
|
/* eslint-disable consistent-return */
|
|
@@ -26,11 +17,11 @@ const useTokenBalances = (selectedChainId) => {
|
|
|
26
17
|
const { tokens, isLoading } = (0, useTokens_1.useTokens)(selectedChainId);
|
|
27
18
|
const [refetchInterval, setRefetchInterval] = (0, react_1.useState)(defaultRefetchInterval);
|
|
28
19
|
const isBalanceLoadingEnabled = Boolean(account.address) &&
|
|
29
|
-
Boolean(tokens
|
|
20
|
+
Boolean(tokens?.length) &&
|
|
30
21
|
Boolean(selectedChainId);
|
|
31
|
-
const { data: tokensWithBalance, isLoading: isBalanceLoading, refetch, } = (0, react_query_1.useQuery)(['token-balances', account.address, selectedChainId, tokens
|
|
32
|
-
const tokenBalances =
|
|
33
|
-
if (!
|
|
22
|
+
const { data: tokensWithBalance, isLoading: isBalanceLoading, refetch, } = (0, react_query_1.useQuery)(['token-balances', account.address, selectedChainId, tokens?.length], async ({ queryKey: [, accountAddress] }) => {
|
|
23
|
+
const tokenBalances = await lifi.getTokenBalances(accountAddress, tokens);
|
|
24
|
+
if (!tokenBalances?.length) {
|
|
34
25
|
// Sometimes RPCs (e.g. Arbitrum) don't return balances on first call
|
|
35
26
|
// TODO: fix and remove backplane
|
|
36
27
|
setRefetchInterval((interval) => interval === defaultRefetchInterval
|
|
@@ -38,12 +29,9 @@ const useTokenBalances = (selectedChainId) => {
|
|
|
38
29
|
: interval * 2);
|
|
39
30
|
throw Error('Could not get tokens balance.');
|
|
40
31
|
}
|
|
41
|
-
const featuredTokenAddresses = new Set(featuredTokens
|
|
42
|
-
const sortFn = (a, b) =>
|
|
43
|
-
|
|
44
|
-
return parseFloat((_a = b.amount) !== null && _a !== void 0 ? _a : '0') * parseFloat((_b = b.priceUSD) !== null && _b !== void 0 ? _b : '0') -
|
|
45
|
-
parseFloat((_c = a.amount) !== null && _c !== void 0 ? _c : '0') * parseFloat((_d = a.priceUSD) !== null && _d !== void 0 ? _d : '0');
|
|
46
|
-
};
|
|
32
|
+
const featuredTokenAddresses = new Set(featuredTokens?.map((token) => token.address));
|
|
33
|
+
const sortFn = (a, b) => parseFloat(b.amount ?? '0') * parseFloat(b.priceUSD ?? '0') -
|
|
34
|
+
parseFloat(a.amount ?? '0') * parseFloat(a.priceUSD ?? '0');
|
|
47
35
|
const formattedTokens = (tokenBalances.length === 0 ? tokens : tokenBalances).map((token) => {
|
|
48
36
|
token.amount = (0, utils_1.formatTokenAmount)(token.amount);
|
|
49
37
|
return token;
|
|
@@ -60,7 +48,7 @@ const useTokenBalances = (selectedChainId) => {
|
|
|
60
48
|
...formattedTokens.filter((token) => token.amount === '0' && !featuredTokenAddresses.has(token.address)),
|
|
61
49
|
];
|
|
62
50
|
return result;
|
|
63
|
-
}
|
|
51
|
+
}, {
|
|
64
52
|
enabled: isBalanceLoadingEnabled,
|
|
65
53
|
refetchInterval,
|
|
66
54
|
staleTime: refetchInterval,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Token } from '../types';
|
|
2
|
-
export declare const useTokenSearch: (chainId?: number,
|
|
2
|
+
export declare const useTokenSearch: (chainId?: number, tokenQuery?: string, enabled?: boolean) => {
|
|
3
3
|
token: Token | undefined;
|
|
4
4
|
isLoading: boolean;
|
|
5
5
|
};
|