@lifi/widget 2.9.3 → 3.0.0-alpha.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/AppProvider.js +2 -2
- package/AppRoutes.js +75 -67
- package/cjs/AppProvider.js +1 -1
- package/cjs/AppRoutes.js +74 -66
- package/cjs/components/ActiveTransactions/ActiveTransactionItem.js +1 -5
- package/cjs/components/ActiveTransactions/ActiveTransactions.js +2 -2
- package/cjs/components/AmountInput/AmountInputEndAdornment.js +9 -10
- package/cjs/components/AmountInput/FormPriceHelperText.js +1 -1
- package/cjs/components/BaseTransactionButton/BaseTransactionButton.js +5 -4
- package/cjs/components/Card/CardLabel.d.ts +1 -1
- package/cjs/components/ChainSelect/ChainSelect.js +8 -5
- package/cjs/components/ChainSelect/useChainSelect.js +21 -2
- package/cjs/components/GasMessage/GasMessage.style.js +3 -6
- package/cjs/components/GasMessage/GasSufficiencyMessage.js +2 -1
- package/cjs/components/Header/Header.style.d.ts +8 -0
- package/cjs/components/Header/Header.style.js +16 -1
- package/cjs/components/Header/NavigationHeader.d.ts +1 -0
- package/cjs/components/Header/NavigationHeader.js +15 -8
- package/cjs/components/Header/NavigationTabs.js +2 -2
- package/cjs/components/Header/SettingsButton.d.ts +1 -0
- package/cjs/components/Header/SettingsButton.js +25 -0
- package/cjs/components/Header/SettingsButton.style.d.ts +11 -0
- package/cjs/components/Header/SettingsButton.style.js +43 -0
- package/cjs/components/Header/WalletHeader.js +11 -24
- package/cjs/components/Header/WalletMenu.d.ts +3 -1
- package/cjs/components/Header/WalletMenu.js +58 -24
- package/cjs/components/Header/WalletMenu.style.d.ts +1 -0
- package/cjs/components/Header/WalletMenu.style.js +27 -0
- package/cjs/components/Insurance/InsuranceCollapsed.js +1 -1
- package/cjs/components/NFT/NFT.js +3 -1
- package/cjs/components/NFT/types.d.ts +1 -1
- package/cjs/components/PoweredBy/PoweredBy.js +2 -1
- package/cjs/components/RouteCard/RouteCard.js +3 -3
- package/cjs/components/RouteCard/RouteCardEssentials.js +2 -1
- package/cjs/components/RouteCard/utils.d.ts +2 -3
- package/cjs/components/RouteCard/utils.js +4 -9
- package/cjs/components/SendToWallet/SendToWallet.js +24 -21
- package/cjs/components/SendToWallet/SendToWalletButton.js +3 -2
- package/{pages/SelectEnabledToolsPage/SelectEnabledToolsPage.style.d.ts → cjs/components/SettingsListItemButton.d.ts} +1 -1
- package/cjs/components/SettingsListItemButton.js +8 -0
- package/cjs/components/Step/DestinationWalletAddress.d.ts +2 -2
- package/cjs/components/Step/GasStepProcess.d.ts +2 -2
- package/cjs/components/Step/Step.d.ts +2 -2
- package/cjs/components/Step/Step.js +1 -1
- package/cjs/components/Step/StepList.d.ts +2 -2
- package/cjs/components/Step/StepList.js +4 -4
- package/cjs/components/Step/StepProcess.d.ts +2 -2
- package/cjs/components/Step/StepTimer.d.ts +2 -2
- package/cjs/components/StepActions/StepActions.d.ts +3 -3
- package/cjs/components/StepActions/StepActions.js +11 -14
- package/cjs/components/StepActions/types.d.ts +2 -2
- package/cjs/components/{Header/NavigationTabs.style.d.ts → Tabs/Tabs.style.d.ts} +2 -2
- package/cjs/components/{Header/NavigationTabs.style.js → Tabs/Tabs.style.js} +9 -31
- package/cjs/components/Tabs/index.d.ts +1 -0
- package/cjs/{providers/SDKProvider → components/Tabs}/index.js +1 -1
- package/cjs/components/Token/Token.d.ts +3 -3
- package/cjs/components/Token/Token.js +5 -5
- package/cjs/components/TokenList/TokenList.js +2 -2
- package/cjs/components/TokenList/TokenListItem.js +9 -5
- package/cjs/components/TokenList/TokenNotFound.js +1 -1
- package/cjs/components/TokenList/VirtualizedTokenList.js +2 -1
- package/cjs/config/queryClient.js +0 -4
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/hooks/index.d.ts +7 -1
- package/cjs/hooks/index.js +7 -1
- package/cjs/hooks/useAccount.d.ts +31 -0
- package/cjs/hooks/useAccount.js +53 -0
- package/cjs/hooks/useAvailableChains.d.ts +6 -0
- package/cjs/hooks/useAvailableChains.js +36 -0
- package/cjs/hooks/useChain.js +3 -6
- package/cjs/hooks/useChains.d.ts +1 -1
- package/cjs/hooks/useChains.js +7 -38
- package/cjs/hooks/useFromTokenSufficiency.d.ts +3 -3
- package/cjs/hooks/useFromTokenSufficiency.js +39 -41
- package/cjs/hooks/useGasRecommendation.d.ts +2 -2
- package/cjs/hooks/useGasRecommendation.js +23 -18
- package/cjs/hooks/useGasRefuel.js +18 -11
- package/cjs/hooks/useGasSufficiency.d.ts +6 -7
- package/cjs/hooks/useGasSufficiency.js +68 -71
- package/cjs/hooks/useLanguages.d.ts +6 -0
- package/cjs/hooks/useLanguages.js +28 -0
- package/cjs/hooks/useProcessMessage.d.ts +3 -3
- package/cjs/hooks/useProcessMessage.js +32 -28
- package/cjs/hooks/useRequiredToAddress.d.ts +1 -0
- package/cjs/hooks/useRequiredToAddress.js +19 -0
- package/cjs/hooks/useRouteExecution.d.ts +2 -2
- package/cjs/hooks/useRouteExecution.js +44 -58
- package/cjs/hooks/useRoutes.d.ts +1 -1
- package/cjs/hooks/useRoutes.js +128 -113
- package/cjs/hooks/useSettingMonitor.d.ts +11 -0
- package/cjs/hooks/useSettingMonitor.js +57 -0
- package/cjs/hooks/useTokenAddressBalance.d.ts +1 -1
- package/cjs/hooks/useTokenBalance.d.ts +5 -3
- package/cjs/hooks/useTokenBalance.js +77 -47
- package/cjs/hooks/useTokenBalances.d.ts +3 -3
- package/cjs/hooks/useTokenBalances.js +34 -24
- package/cjs/hooks/useTokenSearch.js +18 -17
- package/cjs/hooks/useTokens.d.ts +2 -1
- package/cjs/hooks/useTokens.js +18 -15
- package/cjs/hooks/useTools.d.ts +1 -1
- package/cjs/hooks/useTools.js +12 -11
- package/cjs/hooks/useTransactionDetails.d.ts +4 -0
- package/cjs/hooks/useTransactionDetails.js +56 -0
- package/cjs/hooks/useTransactionHistory.d.ts +5 -0
- package/cjs/hooks/useTransactionHistory.js +39 -0
- package/cjs/i18n/en.json +18 -9
- package/cjs/i18n/fr.json +7 -4
- package/cjs/i18n/pt.json +7 -4
- package/cjs/i18n/tr.json +7 -4
- package/cjs/i18n/uk.json +7 -4
- package/cjs/i18n/zh.json +7 -4
- package/cjs/icons/index.d.ts +1 -3
- package/cjs/icons/index.js +1 -3
- package/cjs/icons/lifi.d.ts +1 -0
- package/cjs/icons/lifi.js +4 -0
- package/cjs/index.d.ts +2 -3
- package/cjs/index.js +4 -4
- package/cjs/pages/ActiveTransactionsPage/ActiveTransactionsPage.js +2 -2
- package/cjs/pages/LanguagesPage/LanguagesPage.d.ts +2 -0
- package/cjs/pages/LanguagesPage/LanguagesPage.js +22 -0
- package/cjs/pages/LanguagesPage/index.d.ts +1 -0
- package/cjs/pages/LanguagesPage/index.js +17 -0
- package/cjs/pages/SelectEnabledToolsPage/SelectEnabledToolsPage.js +15 -5
- package/cjs/pages/SelectWalletPage/EVMListItemButton.d.ts +8 -0
- package/cjs/pages/SelectWalletPage/EVMListItemButton.js +40 -0
- package/cjs/pages/SelectWalletPage/SVMListItemButton.d.ts +6 -0
- package/cjs/pages/SelectWalletPage/SVMListItemButton.js +34 -0
- package/cjs/pages/SelectWalletPage/SelectWalletPage.js +31 -32
- package/cjs/pages/SelectWalletPage/utils.d.ts +3 -0
- package/cjs/pages/SelectWalletPage/utils.js +21 -0
- package/{pages/SettingsPage/EnabledToolsButton.d.ts → cjs/pages/SettingsPage/BridgeAndExchangeSettings.d.ts} +1 -1
- package/cjs/pages/SettingsPage/BridgeAndExchangeSettings.js +36 -0
- package/cjs/pages/SettingsPage/GasPriceSettings.d.ts +2 -0
- package/cjs/pages/SettingsPage/GasPriceSettings.js +21 -0
- package/cjs/pages/SettingsPage/LanguageSetting.d.ts +2 -0
- package/cjs/pages/SettingsPage/LanguageSetting.js +26 -0
- package/cjs/pages/SettingsPage/ResetSettingsButton.js +3 -30
- package/cjs/pages/SettingsPage/RoutePrioritySettings.d.ts +2 -0
- package/cjs/pages/SettingsPage/RoutePrioritySettings.js +25 -0
- package/cjs/pages/SettingsPage/SendToWalletOptionSetting.d.ts +1 -0
- package/cjs/pages/SettingsPage/{ShowDestinationWallet.js → SendToWalletOptionSetting.js} +6 -9
- package/cjs/pages/SettingsPage/SettingsCard/BadgedValue.d.ts +8 -0
- package/cjs/pages/SettingsPage/SettingsCard/BadgedValue.js +7 -0
- package/cjs/pages/SettingsPage/SettingsCard/SettingCard.d.ts +2 -0
- package/cjs/pages/SettingsPage/SettingsCard/SettingCard.js +11 -0
- package/cjs/pages/SettingsPage/SettingsCard/SettingCard.style.d.ts +19 -0
- package/cjs/pages/SettingsPage/SettingsCard/SettingCard.style.js +53 -0
- package/cjs/pages/SettingsPage/SettingsCard/SettingCardButton.d.ts +7 -0
- package/cjs/pages/SettingsPage/SettingsCard/SettingCardButton.js +8 -0
- package/cjs/pages/SettingsPage/SettingsCard/SettingCardExpandable.d.ts +7 -0
- package/cjs/pages/SettingsPage/SettingsCard/SettingCardExpandable.js +16 -0
- package/cjs/pages/SettingsPage/SettingsCard/SettingsAccordian.d.ts +6 -0
- package/cjs/pages/SettingsPage/SettingsCard/SettingsAccordian.js +36 -0
- package/cjs/pages/SettingsPage/SettingsCard/index.d.ts +6 -0
- package/cjs/pages/SettingsPage/SettingsCard/index.js +22 -0
- package/cjs/pages/SettingsPage/SettingsCard/types.d.ts +5 -0
- package/cjs/pages/SettingsPage/SettingsPage.js +9 -8
- package/cjs/pages/SettingsPage/SlippageSettings/SlippageSettings.d.ts +2 -0
- package/cjs/pages/SettingsPage/SlippageSettings/SlippageSettings.js +51 -0
- package/cjs/pages/SettingsPage/SlippageSettings/SlippageSettings.style.d.ts +16 -0
- package/cjs/pages/SettingsPage/SlippageSettings/SlippageSettings.style.js +74 -0
- package/cjs/pages/SettingsPage/SlippageSettings/index.d.ts +1 -0
- package/cjs/pages/SettingsPage/SlippageSettings/index.js +17 -0
- package/cjs/pages/SettingsPage/ThemeSettings.d.ts +2 -0
- package/cjs/pages/SettingsPage/ThemeSettings.js +39 -0
- package/cjs/pages/TransactionDetailsPage/ContactSupportButton.js +2 -2
- package/cjs/pages/TransactionDetailsPage/TransactionDetailsPage.js +33 -28
- package/cjs/pages/TransactionDetailsPage/TransactionDetailsSkeleton.d.ts +1 -0
- package/cjs/pages/TransactionDetailsPage/TransactionDetailsSkeleton.js +31 -0
- package/cjs/pages/TransactionHistoryPage/TransactionHistoryItem.d.ts +4 -2
- package/cjs/pages/TransactionHistoryPage/TransactionHistoryItem.js +34 -7
- package/cjs/pages/TransactionHistoryPage/TransactionHistoryPage.js +21 -22
- package/cjs/pages/TransactionHistoryPage/TransactionHistorySkeleton.d.ts +1 -0
- package/cjs/pages/TransactionHistoryPage/TransactionHistorySkeleton.js +26 -0
- package/cjs/pages/TransactionHistoryPage/constants.d.ts +1 -0
- package/cjs/pages/TransactionHistoryPage/constants.js +4 -0
- package/cjs/pages/TransactionPage/ExchangeRateBottomSheet.js +11 -10
- package/cjs/pages/TransactionPage/StartTransactionButton.js +2 -2
- package/cjs/pages/TransactionPage/StatusBottomSheet.js +12 -8
- package/cjs/pages/TransactionPage/TransactionPage.js +1 -1
- package/cjs/providers/FormProvider/FormUpdater.js +4 -4
- package/cjs/providers/I18nProvider/I18nProvider.js +3 -7
- package/cjs/providers/I18nProvider/types.d.ts +4 -3
- package/cjs/providers/WalletProvider/EVMProvider.d.ts +3 -0
- package/cjs/providers/WalletProvider/EVMProvider.js +79 -0
- package/cjs/providers/WalletProvider/SDKProviders.d.ts +1 -0
- package/cjs/providers/WalletProvider/SDKProviders.js +31 -0
- package/cjs/providers/WalletProvider/SolanaProvider.d.ts +3 -0
- package/cjs/providers/WalletProvider/SolanaProvider.js +35 -0
- package/cjs/providers/WalletProvider/WalletProvider.d.ts +1 -15
- package/cjs/providers/WalletProvider/WalletProvider.js +5 -183
- package/cjs/providers/WalletProvider/index.d.ts +1 -1
- package/cjs/providers/WalletProvider/index.js +1 -1
- package/cjs/providers/WalletProvider/utils.d.ts +3 -0
- package/cjs/providers/WalletProvider/utils.js +25 -0
- package/cjs/providers/WidgetProvider/WidgetProvider.js +51 -35
- package/cjs/providers/index.d.ts +0 -1
- package/cjs/providers/index.js +0 -1
- package/cjs/stores/chains/ChainOrderStore.js +24 -0
- package/cjs/stores/header/useHeaderStore.d.ts +1 -1
- package/cjs/stores/header/useHeaderStore.js +2 -2
- package/cjs/stores/routes/createRouteExecutionStore.js +6 -60
- package/cjs/stores/routes/index.d.ts +0 -1
- package/cjs/stores/routes/index.js +0 -1
- package/cjs/stores/routes/types.d.ts +2 -2
- package/cjs/stores/routes/utils.d.ts +8 -8
- package/cjs/stores/routes/utils.js +7 -5
- package/cjs/stores/settings/useSettingsStore.js +2 -4
- package/cjs/stores/settings/useSplitSubvariantStore.d.ts +1 -1
- package/cjs/stores/settings/useSplitSubvariantStore.js +2 -2
- package/cjs/types/events.d.ts +6 -5
- package/cjs/types/events.js +1 -1
- package/cjs/types/widget.d.ts +7 -14
- package/cjs/utils/colors.d.ts +3 -0
- package/cjs/utils/colors.js +13 -1
- package/cjs/utils/converters.d.ts +3 -0
- package/cjs/utils/converters.js +172 -0
- package/cjs/utils/format.d.ts +1 -1
- package/cjs/utils/format.js +5 -12
- package/cjs/utils/index.d.ts +1 -0
- package/cjs/utils/index.js +1 -0
- package/cjs/utils/navigationRoutes.d.ts +1 -0
- package/cjs/utils/navigationRoutes.js +3 -1
- package/cjs/utils/svm.d.ts +1 -0
- package/cjs/utils/svm.js +14 -0
- package/components/ActiveTransactions/ActiveTransactionItem.js +1 -5
- package/components/ActiveTransactions/ActiveTransactions.js +2 -2
- package/components/AmountInput/AmountInputEndAdornment.js +10 -11
- package/components/AmountInput/FormPriceHelperText.js +1 -1
- package/components/BaseTransactionButton/BaseTransactionButton.js +6 -5
- package/components/Card/CardLabel.d.ts +1 -1
- package/components/ChainSelect/ChainSelect.js +8 -5
- package/components/ChainSelect/useChainSelect.js +22 -3
- package/components/GasMessage/GasMessage.style.js +3 -6
- package/components/GasMessage/GasSufficiencyMessage.js +2 -1
- package/components/Header/Header.style.d.ts +8 -0
- package/components/Header/Header.style.js +16 -1
- package/components/Header/NavigationHeader.d.ts +1 -0
- package/components/Header/NavigationHeader.js +16 -10
- package/components/Header/NavigationTabs.js +3 -3
- package/components/Header/SettingsButton.d.ts +1 -0
- package/components/Header/SettingsButton.js +21 -0
- package/components/Header/SettingsButton.style.d.ts +11 -0
- package/components/Header/SettingsButton.style.js +40 -0
- package/components/Header/WalletHeader.js +15 -28
- package/components/Header/WalletMenu.d.ts +3 -1
- package/components/Header/WalletMenu.js +58 -25
- package/components/Header/WalletMenu.style.d.ts +1 -0
- package/components/Header/WalletMenu.style.js +24 -0
- package/components/Insurance/InsuranceCollapsed.js +1 -1
- package/components/NFT/NFT.js +3 -1
- package/components/NFT/types.d.ts +1 -1
- package/components/PoweredBy/PoweredBy.js +2 -1
- package/components/RouteCard/RouteCard.js +3 -3
- package/components/RouteCard/RouteCardEssentials.js +2 -1
- package/components/RouteCard/utils.d.ts +2 -3
- package/components/RouteCard/utils.js +4 -9
- package/components/SendToWallet/SendToWallet.js +26 -23
- package/components/SendToWallet/SendToWalletButton.js +5 -4
- package/{cjs/pages/SelectEnabledToolsPage/SelectEnabledToolsPage.style.d.ts → components/SettingsListItemButton.d.ts} +1 -1
- package/components/SettingsListItemButton.js +5 -0
- package/components/Step/DestinationWalletAddress.d.ts +2 -2
- package/components/Step/GasStepProcess.d.ts +2 -2
- package/components/Step/Step.d.ts +2 -2
- package/components/Step/Step.js +2 -2
- package/components/Step/StepList.d.ts +2 -2
- package/components/Step/StepList.js +4 -4
- package/components/Step/StepProcess.d.ts +2 -2
- package/components/Step/StepTimer.d.ts +2 -2
- package/components/StepActions/StepActions.d.ts +3 -3
- package/components/StepActions/StepActions.js +12 -15
- package/components/StepActions/types.d.ts +2 -2
- package/components/{Header/NavigationTabs.style.d.ts → Tabs/Tabs.style.d.ts} +2 -2
- package/components/Tabs/Tabs.style.js +36 -0
- package/components/Tabs/index.d.ts +1 -0
- package/components/Tabs/index.js +1 -0
- package/components/Token/Token.d.ts +3 -3
- package/components/Token/Token.js +5 -5
- package/components/TokenList/TokenList.js +4 -4
- package/components/TokenList/TokenListItem.js +9 -6
- package/components/TokenList/TokenNotFound.js +2 -2
- package/components/TokenList/VirtualizedTokenList.js +2 -1
- package/config/queryClient.js +0 -4
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/index.d.ts +7 -1
- package/hooks/index.js +7 -1
- package/hooks/useAccount.d.ts +31 -0
- package/hooks/useAccount.js +48 -0
- package/hooks/useAvailableChains.d.ts +6 -0
- package/hooks/useAvailableChains.js +32 -0
- package/hooks/useChain.js +3 -6
- package/hooks/useChains.d.ts +1 -1
- package/hooks/useChains.js +9 -40
- package/hooks/useFromTokenSufficiency.d.ts +3 -3
- package/hooks/useFromTokenSufficiency.js +41 -43
- package/hooks/useGasRecommendation.d.ts +2 -2
- package/hooks/useGasRecommendation.js +23 -18
- package/hooks/useGasRefuel.js +19 -12
- package/hooks/useGasSufficiency.d.ts +6 -7
- package/hooks/useGasSufficiency.js +69 -72
- package/hooks/useLanguages.d.ts +6 -0
- package/hooks/useLanguages.js +24 -0
- package/hooks/useProcessMessage.d.ts +3 -3
- package/hooks/useProcessMessage.js +33 -29
- package/hooks/useRequiredToAddress.d.ts +1 -0
- package/hooks/useRequiredToAddress.js +15 -0
- package/hooks/useRouteExecution.d.ts +2 -2
- package/hooks/useRouteExecution.js +44 -58
- package/hooks/useRoutes.d.ts +1 -1
- package/hooks/useRoutes.js +131 -116
- package/hooks/useSettingMonitor.d.ts +11 -0
- package/hooks/useSettingMonitor.js +53 -0
- package/hooks/useTokenAddressBalance.d.ts +1 -1
- package/hooks/useTokenBalance.d.ts +5 -3
- package/hooks/useTokenBalance.js +74 -45
- package/hooks/useTokenBalances.d.ts +3 -3
- package/hooks/useTokenBalances.js +34 -24
- package/hooks/useTokenSearch.js +18 -17
- package/hooks/useTokens.d.ts +2 -1
- package/hooks/useTokens.js +19 -16
- package/hooks/useTools.d.ts +1 -1
- package/hooks/useTools.js +13 -12
- package/hooks/useTransactionDetails.d.ts +4 -0
- package/hooks/useTransactionDetails.js +52 -0
- package/hooks/useTransactionHistory.d.ts +5 -0
- package/hooks/useTransactionHistory.js +35 -0
- package/i18n/en.json +18 -9
- package/i18n/fr.json +7 -4
- package/i18n/pt.json +7 -4
- package/i18n/tr.json +7 -4
- package/i18n/uk.json +7 -4
- package/i18n/zh.json +7 -4
- package/icons/index.d.ts +1 -3
- package/icons/index.js +1 -3
- package/icons/lifi.d.ts +1 -0
- package/icons/lifi.js +1 -0
- package/index.d.ts +2 -3
- package/index.js +2 -4
- package/package.json +19 -19
- package/pages/ActiveTransactionsPage/ActiveTransactionsPage.js +2 -2
- package/pages/LanguagesPage/LanguagesPage.d.ts +2 -0
- package/pages/LanguagesPage/LanguagesPage.js +18 -0
- package/pages/LanguagesPage/index.d.ts +1 -0
- package/pages/LanguagesPage/index.js +1 -0
- package/pages/SelectEnabledToolsPage/SelectEnabledToolsPage.js +16 -6
- package/pages/SelectWalletPage/EVMListItemButton.d.ts +8 -0
- package/pages/SelectWalletPage/EVMListItemButton.js +36 -0
- package/pages/SelectWalletPage/SVMListItemButton.d.ts +6 -0
- package/pages/SelectWalletPage/SVMListItemButton.js +30 -0
- package/pages/SelectWalletPage/SelectWalletPage.js +34 -35
- package/pages/SelectWalletPage/utils.d.ts +3 -0
- package/pages/SelectWalletPage/utils.js +17 -0
- package/{cjs/pages/SettingsPage/EnabledToolsButton.d.ts → pages/SettingsPage/BridgeAndExchangeSettings.d.ts} +1 -1
- package/pages/SettingsPage/BridgeAndExchangeSettings.js +32 -0
- package/pages/SettingsPage/GasPriceSettings.d.ts +2 -0
- package/pages/SettingsPage/GasPriceSettings.js +17 -0
- package/pages/SettingsPage/LanguageSetting.d.ts +2 -0
- package/pages/SettingsPage/LanguageSetting.js +22 -0
- package/pages/SettingsPage/ResetSettingsButton.js +4 -31
- package/pages/SettingsPage/RoutePrioritySettings.d.ts +2 -0
- package/pages/SettingsPage/RoutePrioritySettings.js +21 -0
- package/pages/SettingsPage/SendToWalletOptionSetting.d.ts +1 -0
- package/pages/SettingsPage/{ShowDestinationWallet.js → SendToWalletOptionSetting.js} +4 -7
- package/pages/SettingsPage/SettingsCard/BadgedValue.d.ts +8 -0
- package/pages/SettingsPage/SettingsCard/BadgedValue.js +3 -0
- package/pages/SettingsPage/SettingsCard/SettingCard.d.ts +2 -0
- package/pages/SettingsPage/SettingsCard/SettingCard.js +7 -0
- package/pages/SettingsPage/SettingsCard/SettingCard.style.d.ts +19 -0
- package/pages/SettingsPage/SettingsCard/SettingCard.style.js +50 -0
- package/pages/SettingsPage/SettingsCard/SettingCardButton.d.ts +7 -0
- package/pages/SettingsPage/SettingsCard/SettingCardButton.js +4 -0
- package/pages/SettingsPage/SettingsCard/SettingCardExpandable.d.ts +7 -0
- package/pages/SettingsPage/SettingsCard/SettingCardExpandable.js +12 -0
- package/pages/SettingsPage/SettingsCard/SettingsAccordian.d.ts +6 -0
- package/pages/SettingsPage/SettingsCard/SettingsAccordian.js +31 -0
- package/pages/SettingsPage/SettingsCard/index.d.ts +6 -0
- package/pages/SettingsPage/SettingsCard/index.js +6 -0
- package/pages/SettingsPage/SettingsCard/types.d.ts +5 -0
- package/pages/SettingsPage/SettingsPage.js +10 -9
- package/pages/SettingsPage/SlippageSettings/SlippageSettings.d.ts +2 -0
- package/pages/SettingsPage/SlippageSettings/SlippageSettings.js +47 -0
- package/pages/SettingsPage/SlippageSettings/SlippageSettings.style.d.ts +16 -0
- package/pages/SettingsPage/SlippageSettings/SlippageSettings.style.js +71 -0
- package/pages/SettingsPage/SlippageSettings/index.d.ts +1 -0
- package/pages/SettingsPage/SlippageSettings/index.js +1 -0
- package/pages/SettingsPage/ThemeSettings.d.ts +2 -0
- package/pages/SettingsPage/ThemeSettings.js +35 -0
- package/pages/TransactionDetailsPage/ContactSupportButton.js +2 -2
- package/pages/TransactionDetailsPage/TransactionDetailsPage.js +38 -33
- package/pages/TransactionDetailsPage/TransactionDetailsSkeleton.d.ts +1 -0
- package/pages/TransactionDetailsPage/TransactionDetailsSkeleton.js +27 -0
- package/pages/TransactionHistoryPage/TransactionHistoryItem.d.ts +4 -2
- package/pages/TransactionHistoryPage/TransactionHistoryItem.js +34 -7
- package/pages/TransactionHistoryPage/TransactionHistoryPage.js +24 -25
- package/pages/TransactionHistoryPage/TransactionHistorySkeleton.d.ts +1 -0
- package/pages/TransactionHistoryPage/TransactionHistorySkeleton.js +22 -0
- package/pages/TransactionHistoryPage/constants.d.ts +1 -0
- package/pages/TransactionHistoryPage/constants.js +1 -0
- package/pages/TransactionPage/ExchangeRateBottomSheet.js +11 -10
- package/pages/TransactionPage/StartTransactionButton.js +2 -2
- package/pages/TransactionPage/StatusBottomSheet.js +14 -10
- package/pages/TransactionPage/TransactionPage.js +1 -1
- package/providers/FormProvider/FormUpdater.js +4 -4
- package/providers/I18nProvider/I18nProvider.js +4 -8
- package/providers/I18nProvider/types.d.ts +4 -3
- package/providers/WalletProvider/EVMProvider.d.ts +3 -0
- package/providers/WalletProvider/EVMProvider.js +74 -0
- package/providers/WalletProvider/SDKProviders.d.ts +1 -0
- package/providers/WalletProvider/SDKProviders.js +27 -0
- package/providers/WalletProvider/SolanaProvider.d.ts +3 -0
- package/providers/WalletProvider/SolanaProvider.js +30 -0
- package/providers/WalletProvider/WalletProvider.d.ts +1 -15
- package/providers/WalletProvider/WalletProvider.js +5 -181
- package/providers/WalletProvider/index.d.ts +1 -1
- package/providers/WalletProvider/index.js +1 -1
- package/providers/WalletProvider/utils.d.ts +3 -0
- package/providers/WalletProvider/utils.js +21 -0
- package/providers/WidgetProvider/WidgetProvider.js +52 -36
- package/providers/index.d.ts +0 -1
- package/providers/index.js +0 -1
- package/stores/chains/ChainOrderStore.js +25 -1
- package/stores/header/useHeaderStore.d.ts +1 -1
- package/stores/header/useHeaderStore.js +2 -2
- package/stores/routes/createRouteExecutionStore.js +6 -60
- package/stores/routes/index.d.ts +0 -1
- package/stores/routes/index.js +0 -1
- package/stores/routes/types.d.ts +2 -2
- package/stores/routes/utils.d.ts +8 -8
- package/stores/routes/utils.js +5 -3
- package/stores/settings/useSettingsStore.js +2 -4
- package/stores/settings/useSplitSubvariantStore.d.ts +1 -1
- package/stores/settings/useSplitSubvariantStore.js +2 -2
- package/tsconfig.cjs.tsbuildinfo +1 -1
- package/types/events.d.ts +6 -5
- package/types/events.js +1 -1
- package/types/widget.d.ts +7 -14
- package/utils/colors.d.ts +3 -0
- package/utils/colors.js +10 -1
- package/utils/converters.d.ts +3 -0
- package/utils/converters.js +168 -0
- package/utils/format.d.ts +1 -1
- package/utils/format.js +5 -12
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
- package/utils/navigationRoutes.d.ts +1 -0
- package/utils/navigationRoutes.js +3 -1
- package/utils/svm.d.ts +1 -0
- package/utils/svm.js +10 -0
- package/cjs/components/LiFiLogo.d.ts +0 -5
- package/cjs/components/LiFiLogo.js +0 -10
- package/cjs/fonts/Inter-Black.woff +0 -0
- package/cjs/fonts/Inter-Black.woff2 +0 -0
- package/cjs/fonts/Inter-BlackItalic.woff +0 -0
- package/cjs/fonts/Inter-BlackItalic.woff2 +0 -0
- package/cjs/fonts/Inter-Bold.woff +0 -0
- package/cjs/fonts/Inter-Bold.woff2 +0 -0
- package/cjs/fonts/Inter-BoldItalic.woff +0 -0
- package/cjs/fonts/Inter-BoldItalic.woff2 +0 -0
- package/cjs/fonts/Inter-ExtraBold.woff +0 -0
- package/cjs/fonts/Inter-ExtraBold.woff2 +0 -0
- package/cjs/fonts/Inter-ExtraBoldItalic.woff +0 -0
- package/cjs/fonts/Inter-ExtraBoldItalic.woff2 +0 -0
- package/cjs/fonts/Inter-ExtraLight.woff +0 -0
- package/cjs/fonts/Inter-ExtraLight.woff2 +0 -0
- package/cjs/fonts/Inter-ExtraLightItalic.woff +0 -0
- package/cjs/fonts/Inter-ExtraLightItalic.woff2 +0 -0
- package/cjs/fonts/Inter-Italic.woff +0 -0
- package/cjs/fonts/Inter-Italic.woff2 +0 -0
- package/cjs/fonts/Inter-Light.woff +0 -0
- package/cjs/fonts/Inter-Light.woff2 +0 -0
- package/cjs/fonts/Inter-LightItalic.woff +0 -0
- package/cjs/fonts/Inter-LightItalic.woff2 +0 -0
- package/cjs/fonts/Inter-Medium.woff +0 -0
- package/cjs/fonts/Inter-Medium.woff2 +0 -0
- package/cjs/fonts/Inter-MediumItalic.woff +0 -0
- package/cjs/fonts/Inter-MediumItalic.woff2 +0 -0
- package/cjs/fonts/Inter-Regular.woff +0 -0
- package/cjs/fonts/Inter-Regular.woff2 +0 -0
- package/cjs/fonts/Inter-SemiBold.woff +0 -0
- package/cjs/fonts/Inter-SemiBold.woff2 +0 -0
- package/cjs/fonts/Inter-SemiBoldItalic.woff +0 -0
- package/cjs/fonts/Inter-SemiBoldItalic.woff2 +0 -0
- package/cjs/fonts/Inter-Thin.woff +0 -0
- package/cjs/fonts/Inter-Thin.woff2 +0 -0
- package/cjs/fonts/Inter-ThinItalic.woff +0 -0
- package/cjs/fonts/Inter-ThinItalic.woff2 +0 -0
- package/cjs/fonts/Inter-italic.var.woff2 +0 -0
- package/cjs/fonts/Inter-roman.var.woff2 +0 -0
- package/cjs/fonts/Inter.var.woff2 +0 -0
- package/cjs/fonts/inter.css +0 -217
- package/cjs/hooks/useGetTokenBalancesWithRetry.d.ts +0 -3
- package/cjs/hooks/useGetTokenBalancesWithRetry.js +0 -33
- package/cjs/icons/LiFiFullLogo.d.ts +0 -2
- package/cjs/icons/LiFiFullLogo.js +0 -6
- package/cjs/icons/LiFiLogo.d.ts +0 -2
- package/cjs/icons/LiFiLogo.js +0 -6
- package/cjs/icons/LiFiToolLogo.d.ts +0 -2
- package/cjs/icons/LiFiToolLogo.js +0 -6
- package/cjs/pages/SelectEnabledToolsPage/SelectEnabledToolsPage.style.js +0 -8
- package/cjs/pages/SettingsPage/ColorSchemeButtonGroup.d.ts +0 -2
- package/cjs/pages/SettingsPage/ColorSchemeButtonGroup.js +0 -27
- package/cjs/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +0 -4
- package/cjs/pages/SettingsPage/ColorSchemeButtonGroup.style.js +0 -19
- package/cjs/pages/SettingsPage/EnabledToolsButton.js +0 -25
- package/cjs/pages/SettingsPage/EnabledToolsButton.style.d.ts +0 -5
- package/cjs/pages/SettingsPage/EnabledToolsButton.style.js +0 -17
- package/cjs/pages/SettingsPage/GasPriceSelect.d.ts +0 -1
- package/cjs/pages/SettingsPage/GasPriceSelect.js +0 -17
- package/cjs/pages/SettingsPage/LanguageSelect.d.ts +0 -2
- package/cjs/pages/SettingsPage/LanguageSelect.js +0 -37
- package/cjs/pages/SettingsPage/RoutePrioritySelect.d.ts +0 -2
- package/cjs/pages/SettingsPage/RoutePrioritySelect.js +0 -23
- package/cjs/pages/SettingsPage/ShowDestinationWallet.d.ts +0 -1
- package/cjs/pages/SettingsPage/SlippageInput.d.ts +0 -1
- package/cjs/pages/SettingsPage/SlippageInput.js +0 -30
- package/cjs/providers/SDKProvider/SDKProvider.d.ts +0 -4
- package/cjs/providers/SDKProvider/SDKProvider.js +0 -41
- package/cjs/providers/SDKProvider/index.d.ts +0 -1
- package/cjs/providers/WalletProvider/types.d.ts +0 -17
- package/cjs/stores/routes/useTransactionHistory.d.ts +0 -2
- package/cjs/stores/routes/useTransactionHistory.js +0 -15
- package/components/Header/NavigationTabs.style.js +0 -58
- package/components/LiFiLogo.d.ts +0 -5
- package/components/LiFiLogo.js +0 -6
- package/fonts/Inter-Black.woff +0 -0
- package/fonts/Inter-Black.woff2 +0 -0
- package/fonts/Inter-BlackItalic.woff +0 -0
- package/fonts/Inter-BlackItalic.woff2 +0 -0
- package/fonts/Inter-Bold.woff +0 -0
- package/fonts/Inter-Bold.woff2 +0 -0
- package/fonts/Inter-BoldItalic.woff +0 -0
- package/fonts/Inter-BoldItalic.woff2 +0 -0
- package/fonts/Inter-ExtraBold.woff +0 -0
- package/fonts/Inter-ExtraBold.woff2 +0 -0
- package/fonts/Inter-ExtraBoldItalic.woff +0 -0
- package/fonts/Inter-ExtraBoldItalic.woff2 +0 -0
- package/fonts/Inter-ExtraLight.woff +0 -0
- package/fonts/Inter-ExtraLight.woff2 +0 -0
- package/fonts/Inter-ExtraLightItalic.woff +0 -0
- package/fonts/Inter-ExtraLightItalic.woff2 +0 -0
- package/fonts/Inter-Italic.woff +0 -0
- package/fonts/Inter-Italic.woff2 +0 -0
- package/fonts/Inter-Light.woff +0 -0
- package/fonts/Inter-Light.woff2 +0 -0
- package/fonts/Inter-LightItalic.woff +0 -0
- package/fonts/Inter-LightItalic.woff2 +0 -0
- package/fonts/Inter-Medium.woff +0 -0
- package/fonts/Inter-Medium.woff2 +0 -0
- package/fonts/Inter-MediumItalic.woff +0 -0
- package/fonts/Inter-MediumItalic.woff2 +0 -0
- package/fonts/Inter-Regular.woff +0 -0
- package/fonts/Inter-Regular.woff2 +0 -0
- package/fonts/Inter-SemiBold.woff +0 -0
- package/fonts/Inter-SemiBold.woff2 +0 -0
- package/fonts/Inter-SemiBoldItalic.woff +0 -0
- package/fonts/Inter-SemiBoldItalic.woff2 +0 -0
- package/fonts/Inter-Thin.woff +0 -0
- package/fonts/Inter-Thin.woff2 +0 -0
- package/fonts/Inter-ThinItalic.woff +0 -0
- package/fonts/Inter-ThinItalic.woff2 +0 -0
- package/fonts/Inter-italic.var.woff2 +0 -0
- package/fonts/Inter-roman.var.woff2 +0 -0
- package/fonts/Inter.var.woff2 +0 -0
- package/fonts/inter.css +0 -217
- package/hooks/useGetTokenBalancesWithRetry.d.ts +0 -3
- package/hooks/useGetTokenBalancesWithRetry.js +0 -29
- package/icons/LiFiFullLogo.d.ts +0 -2
- package/icons/LiFiFullLogo.js +0 -2
- package/icons/LiFiLogo.d.ts +0 -2
- package/icons/LiFiLogo.js +0 -2
- package/icons/LiFiToolLogo.d.ts +0 -2
- package/icons/LiFiToolLogo.js +0 -2
- package/pages/SelectEnabledToolsPage/SelectEnabledToolsPage.style.js +0 -5
- package/pages/SettingsPage/ColorSchemeButtonGroup.d.ts +0 -2
- package/pages/SettingsPage/ColorSchemeButtonGroup.js +0 -23
- package/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +0 -4
- package/pages/SettingsPage/ColorSchemeButtonGroup.style.js +0 -16
- package/pages/SettingsPage/EnabledToolsButton.js +0 -21
- package/pages/SettingsPage/EnabledToolsButton.style.d.ts +0 -5
- package/pages/SettingsPage/EnabledToolsButton.style.js +0 -14
- package/pages/SettingsPage/GasPriceSelect.d.ts +0 -1
- package/pages/SettingsPage/GasPriceSelect.js +0 -13
- package/pages/SettingsPage/LanguageSelect.d.ts +0 -2
- package/pages/SettingsPage/LanguageSelect.js +0 -33
- package/pages/SettingsPage/RoutePrioritySelect.d.ts +0 -2
- package/pages/SettingsPage/RoutePrioritySelect.js +0 -19
- package/pages/SettingsPage/ShowDestinationWallet.d.ts +0 -1
- package/pages/SettingsPage/SlippageInput.d.ts +0 -1
- package/pages/SettingsPage/SlippageInput.js +0 -26
- package/providers/SDKProvider/SDKProvider.d.ts +0 -4
- package/providers/SDKProvider/SDKProvider.js +0 -36
- package/providers/SDKProvider/index.d.ts +0 -1
- package/providers/SDKProvider/index.js +0 -1
- package/providers/WalletProvider/types.d.ts +0 -17
- package/stores/routes/useTransactionHistory.d.ts +0 -2
- package/stores/routes/useTransactionHistory.js +0 -11
- /package/cjs/{providers/WalletProvider → pages/SettingsPage/SettingsCard}/types.js +0 -0
- /package/{providers/WalletProvider → pages/SettingsPage/SettingsCard}/types.js +0 -0
package/hooks/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export * from './useAccount';
|
|
2
|
+
export * from './useAvailableChains';
|
|
1
3
|
export * from './useChain';
|
|
2
4
|
export * from './useChains';
|
|
3
5
|
export * from './useContentHeight';
|
|
@@ -9,13 +11,15 @@ export * from './useFromTokenSufficiency';
|
|
|
9
11
|
export * from './useGasRecommendation';
|
|
10
12
|
export * from './useGasRefuel';
|
|
11
13
|
export * from './useGasSufficiency';
|
|
12
|
-
export * from './useGetTokenBalancesWithRetry';
|
|
13
14
|
export * from './useInitializer';
|
|
15
|
+
export * from './useLanguages';
|
|
14
16
|
export * from './useNavigateBack';
|
|
15
17
|
export * from './useProcessMessage';
|
|
18
|
+
export * from './useRequiredToAddress';
|
|
16
19
|
export * from './useRouteExecution';
|
|
17
20
|
export * from './useRoutes';
|
|
18
21
|
export * from './useScrollableContainer';
|
|
22
|
+
export * from './useSettingMonitor';
|
|
19
23
|
export * from './useSwapOnly';
|
|
20
24
|
export * from './useToken';
|
|
21
25
|
export * from './useTokenAddressBalance';
|
|
@@ -24,4 +28,6 @@ export * from './useTokenBalances';
|
|
|
24
28
|
export * from './useTokenSearch';
|
|
25
29
|
export * from './useTokens';
|
|
26
30
|
export * from './useTools';
|
|
31
|
+
export * from './useTransactionDetails';
|
|
32
|
+
export * from './useTransactionHistory';
|
|
27
33
|
export * from './useWidgetEvents';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ChainType } from '@lifi/sdk';
|
|
2
|
+
import type { WalletAdapter } from '@solana/wallet-adapter-base';
|
|
3
|
+
import type { Chain } from 'viem';
|
|
4
|
+
import type { Connector } from 'wagmi';
|
|
5
|
+
export interface AccountBase {
|
|
6
|
+
address?: string;
|
|
7
|
+
addresses?: readonly string[];
|
|
8
|
+
chain?: Chain;
|
|
9
|
+
chainId?: number;
|
|
10
|
+
chainType?: ChainType;
|
|
11
|
+
isConnected: boolean;
|
|
12
|
+
isConnecting: boolean;
|
|
13
|
+
isDisconnected: boolean;
|
|
14
|
+
isReconnecting: boolean;
|
|
15
|
+
status: 'connected' | 'reconnecting' | 'connecting' | 'disconnected';
|
|
16
|
+
}
|
|
17
|
+
export interface EVMAccount extends AccountBase {
|
|
18
|
+
chainType: ChainType.EVM;
|
|
19
|
+
connector?: Connector;
|
|
20
|
+
}
|
|
21
|
+
export interface SVMAccount extends AccountBase {
|
|
22
|
+
chainType: ChainType.SVM;
|
|
23
|
+
connector?: WalletAdapter;
|
|
24
|
+
}
|
|
25
|
+
export type Account = EVMAccount | SVMAccount;
|
|
26
|
+
export interface AccountResult {
|
|
27
|
+
account: Account;
|
|
28
|
+
accounts: Account[];
|
|
29
|
+
}
|
|
30
|
+
export declare const useAccount: () => AccountResult;
|
|
31
|
+
export declare const useAccountDisconnect: () => () => void;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ChainId, ChainType } from '@lifi/sdk';
|
|
2
|
+
import { useWallet } from '@solana/wallet-adapter-react';
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import { useDisconnect, useAccount as useWagmiAccount } from 'wagmi';
|
|
5
|
+
export const useAccount = () => {
|
|
6
|
+
const account = useWagmiAccount();
|
|
7
|
+
const { wallet } = useWallet();
|
|
8
|
+
return useMemo(() => {
|
|
9
|
+
const svm = wallet?.adapter.publicKey
|
|
10
|
+
? {
|
|
11
|
+
address: wallet?.adapter.publicKey.toString(),
|
|
12
|
+
chainId: ChainId.SOL,
|
|
13
|
+
chainType: ChainType.SVM,
|
|
14
|
+
connector: wallet?.adapter,
|
|
15
|
+
isConnected: Boolean(wallet?.adapter.publicKey),
|
|
16
|
+
isConnecting: false,
|
|
17
|
+
isReconnecting: false,
|
|
18
|
+
isDisconnected: !wallet,
|
|
19
|
+
status: 'connected',
|
|
20
|
+
}
|
|
21
|
+
: {
|
|
22
|
+
chainType: ChainType.SVM,
|
|
23
|
+
isConnected: false,
|
|
24
|
+
isConnecting: false,
|
|
25
|
+
isReconnecting: false,
|
|
26
|
+
isDisconnected: true,
|
|
27
|
+
status: 'disconnected',
|
|
28
|
+
};
|
|
29
|
+
const evm = { ...account, chainType: ChainType.EVM };
|
|
30
|
+
return {
|
|
31
|
+
account: account.isConnected ? evm : svm,
|
|
32
|
+
accounts: [evm, svm],
|
|
33
|
+
};
|
|
34
|
+
}, [account, wallet]);
|
|
35
|
+
};
|
|
36
|
+
export const useAccountDisconnect = () => {
|
|
37
|
+
const account = useWagmiAccount();
|
|
38
|
+
const { disconnect: wagmiDisconnect } = useDisconnect();
|
|
39
|
+
const { wallet, disconnect } = useWallet();
|
|
40
|
+
return () => {
|
|
41
|
+
if (account.isConnected) {
|
|
42
|
+
wagmiDisconnect();
|
|
43
|
+
}
|
|
44
|
+
if (wallet) {
|
|
45
|
+
disconnect();
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ChainType, config, getChains } from '@lifi/sdk';
|
|
2
|
+
import { useQuery } from '@tanstack/react-query';
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
|
+
export const useAvailableChains = () => {
|
|
5
|
+
const { data, isLoading } = useQuery({
|
|
6
|
+
queryKey: ['chains'],
|
|
7
|
+
queryFn: async () => {
|
|
8
|
+
const chains = await getChains({
|
|
9
|
+
chainTypes: [ChainType.EVM, ChainType.SVM],
|
|
10
|
+
});
|
|
11
|
+
config.setChains(chains);
|
|
12
|
+
return chains;
|
|
13
|
+
},
|
|
14
|
+
refetchInterval: 300000,
|
|
15
|
+
staleTime: 300000,
|
|
16
|
+
});
|
|
17
|
+
const getChainById = useCallback((chainId, chains = data) => {
|
|
18
|
+
if (!chainId) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const chain = chains?.find((chain) => chain.id === chainId);
|
|
22
|
+
// if (!chain) {
|
|
23
|
+
// throw new Error('Chain not found or chainId is invalid.');
|
|
24
|
+
// }
|
|
25
|
+
return chain;
|
|
26
|
+
}, [data]);
|
|
27
|
+
return {
|
|
28
|
+
chains: data,
|
|
29
|
+
getChainById,
|
|
30
|
+
isLoading,
|
|
31
|
+
};
|
|
32
|
+
};
|
package/hooks/useChain.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { useAvailableChains } from './useAvailableChains';
|
|
3
3
|
export const useChain = (chainId) => {
|
|
4
|
-
const {
|
|
5
|
-
const chain = useMemo(() =>
|
|
6
|
-
const chain = chains?.find((chain) => chain.id === chainId);
|
|
7
|
-
return chain;
|
|
8
|
-
}, [chainId, chains]);
|
|
4
|
+
const { isLoading, getChainById } = useAvailableChains();
|
|
5
|
+
const chain = useMemo(() => getChainById(chainId), [chainId, getChainById]);
|
|
9
6
|
return {
|
|
10
7
|
chain,
|
|
11
8
|
isLoading,
|
package/hooks/useChains.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const useChains: () => {
|
|
2
2
|
chains: import("@lifi/types").ExtendedChain[] | undefined;
|
|
3
|
-
getChainById: (chainId
|
|
3
|
+
getChainById: (chainId?: number | undefined, chains?: import("@lifi/types").ExtendedChain[] | undefined) => import("@lifi/types").ExtendedChain | undefined;
|
|
4
4
|
isLoading: boolean;
|
|
5
5
|
};
|
package/hooks/useChains.js
CHANGED
|
@@ -1,47 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { FormKey, isItemAllowed, useLiFi, useWidgetConfig } from '../providers';
|
|
5
|
-
import { useChainOrderStore } from '../stores';
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { isItemAllowed, useWidgetConfig } from '../providers';
|
|
3
|
+
import { useAvailableChains } from './useAvailableChains';
|
|
6
4
|
export const useChains = () => {
|
|
7
|
-
const { chains
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
const { data: availableChains, isLoading: isLoadingAvailableChains } = useQuery(['chains'], async () => lifi.getChains(), {
|
|
12
|
-
refetchInterval: 300000,
|
|
13
|
-
staleTime: 300000,
|
|
14
|
-
});
|
|
15
|
-
const { data: filteredChains, isLoading: isLoadingFilteredChains } = useQuery(['filtered-chains', availableChains?.length, keyPrefix], async () => {
|
|
16
|
-
if (!availableChains) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
const filteredChains = availableChains.filter((chain) => isItemAllowed(chain.id, chains));
|
|
20
|
-
const chainOrder = initializeChains(filteredChains.map((chain) => chain.id));
|
|
21
|
-
const [fromChainValue, toChainValue] = getValues([
|
|
22
|
-
FormKey.FromChain,
|
|
23
|
-
FormKey.ToChain,
|
|
24
|
-
]);
|
|
25
|
-
if (!fromChainValue) {
|
|
26
|
-
setValue(FormKey.FromChain, chainOrder[0]);
|
|
27
|
-
}
|
|
28
|
-
if (!toChainValue) {
|
|
29
|
-
setValue(FormKey.ToChain, chainOrder[0]);
|
|
30
|
-
}
|
|
5
|
+
const { chains } = useWidgetConfig();
|
|
6
|
+
const { chains: availableChains, isLoading: isLoadingAvailableChains, getChainById, } = useAvailableChains();
|
|
7
|
+
const filteredChains = useMemo(() => {
|
|
8
|
+
const filteredChains = availableChains?.filter((chain) => isItemAllowed(chain.id, chains));
|
|
31
9
|
return filteredChains;
|
|
32
|
-
},
|
|
33
|
-
enabled: Boolean(availableChains),
|
|
34
|
-
});
|
|
35
|
-
const getChainById = useCallback((chainId) => {
|
|
36
|
-
const chain = availableChains?.find((chain) => chain.id === chainId);
|
|
37
|
-
// if (!chain) {
|
|
38
|
-
// throw new Error('Chain not found or chainId is invalid.');
|
|
39
|
-
// }
|
|
40
|
-
return chain;
|
|
41
|
-
}, [availableChains]);
|
|
10
|
+
}, [availableChains, chains]);
|
|
42
11
|
return {
|
|
43
12
|
chains: filteredChains,
|
|
44
13
|
getChainById,
|
|
45
|
-
isLoading: isLoadingAvailableChains
|
|
14
|
+
isLoading: isLoadingAvailableChains,
|
|
46
15
|
};
|
|
47
16
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const useFromTokenSufficiency: (route?:
|
|
1
|
+
import type { RouteExtended } from '@lifi/sdk';
|
|
2
|
+
export declare const useFromTokenSufficiency: (route?: RouteExtended) => {
|
|
3
3
|
insufficientFromToken: boolean | undefined;
|
|
4
|
-
|
|
4
|
+
isLoading: boolean;
|
|
5
5
|
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { useQuery } from '@tanstack/react-query';
|
|
2
|
-
import Big from 'big.js';
|
|
1
|
+
import { keepPreviousData, useQuery } from '@tanstack/react-query';
|
|
3
2
|
import { useWatch } from 'react-hook-form';
|
|
4
|
-
import {
|
|
3
|
+
import { parseUnits } from 'viem';
|
|
4
|
+
import { FormKey } from '../providers';
|
|
5
5
|
import { isRouteDone } from '../stores';
|
|
6
|
-
import {
|
|
6
|
+
import { useAccount } from './useAccount';
|
|
7
7
|
import { useTokenAddressBalance } from './useTokenAddressBalance';
|
|
8
|
+
import { getTokenBalancesWithRetry } from './useTokenBalance';
|
|
8
9
|
const refetchInterval = 30000;
|
|
9
10
|
export const useFromTokenSufficiency = (route) => {
|
|
10
|
-
const { account } =
|
|
11
|
-
const getTokenBalancesWithRetry = useGetTokenBalancesWithRetry(account.signer?.provider);
|
|
11
|
+
const { account } = useAccount();
|
|
12
12
|
const [fromChainId, fromTokenAddress, fromAmount] = useWatch({
|
|
13
13
|
name: [FormKey.FromChain, FormKey.FromToken, FormKey.FromAmount],
|
|
14
14
|
});
|
|
@@ -18,48 +18,46 @@ export const useFromTokenSufficiency = (route) => {
|
|
|
18
18
|
chainId = route.fromToken.chainId;
|
|
19
19
|
tokenAddress = route.fromToken.address;
|
|
20
20
|
}
|
|
21
|
-
const { token, isLoading } = useTokenAddressBalance(chainId, tokenAddress);
|
|
22
|
-
const { data: insufficientFromToken,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
21
|
+
const { token, isLoading: isTokenAddressBalanceLoading } = useTokenAddressBalance(chainId, tokenAddress);
|
|
22
|
+
const { data: insufficientFromToken, isLoading } = useQuery({
|
|
23
|
+
queryKey: [
|
|
24
|
+
'from-token-sufficiency-check',
|
|
25
|
+
account.address,
|
|
26
|
+
chainId,
|
|
27
|
+
tokenAddress,
|
|
28
|
+
route?.id ?? fromAmount,
|
|
29
|
+
],
|
|
30
|
+
queryFn: async () => {
|
|
31
|
+
if (!account.address || !token) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const parsedFromAmount = parseUnits(fromAmount, token.decimals);
|
|
35
|
+
let currentTokenBalance = token.amount ?? 0n;
|
|
36
|
+
if (!route || isRouteDone(route)) {
|
|
37
|
+
const insufficientFunds = currentTokenBalance < parsedFromAmount;
|
|
38
|
+
return insufficientFunds;
|
|
39
|
+
}
|
|
40
|
+
const currentAction = route.steps.filter((step) => !step.execution || step.execution.status !== 'DONE')[0]?.action;
|
|
41
|
+
if (token.chainId === currentAction.fromToken.chainId &&
|
|
42
|
+
token.address === currentAction.fromToken.address &&
|
|
43
|
+
currentTokenBalance > 0) {
|
|
44
|
+
const insufficientFunds = BigInt(route.fromAmount) > currentTokenBalance;
|
|
45
|
+
return insufficientFunds;
|
|
46
|
+
}
|
|
47
|
+
const tokenBalances = await getTokenBalancesWithRetry(account.address, [
|
|
48
|
+
currentAction.fromToken,
|
|
49
|
+
]);
|
|
50
|
+
currentTokenBalance = tokenBalances?.[0]?.amount ?? 0n;
|
|
51
|
+
const insufficientFunds = BigInt(currentAction.fromAmount) > currentTokenBalance;
|
|
35
52
|
return insufficientFunds;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (token.chainId === currentAction.fromToken.chainId &&
|
|
39
|
-
token.address === currentAction.fromToken.address &&
|
|
40
|
-
currentTokenBalance.gt(0)) {
|
|
41
|
-
const insufficientFunds = Big(route.fromAmount)
|
|
42
|
-
.div(10 ** route.fromToken.decimals)
|
|
43
|
-
.gt(currentTokenBalance);
|
|
44
|
-
return insufficientFunds;
|
|
45
|
-
}
|
|
46
|
-
const tokenBalances = await getTokenBalancesWithRetry(account.address, [
|
|
47
|
-
currentAction.fromToken,
|
|
48
|
-
]);
|
|
49
|
-
currentTokenBalance = Big(tokenBalances?.[0]?.amount || 0);
|
|
50
|
-
const insufficientFunds = Big(currentAction.fromAmount)
|
|
51
|
-
.div(10 ** currentAction.fromToken.decimals)
|
|
52
|
-
.gt(currentTokenBalance);
|
|
53
|
-
return insufficientFunds;
|
|
54
|
-
}, {
|
|
55
|
-
enabled: Boolean(account.address && token && !isLoading),
|
|
53
|
+
},
|
|
54
|
+
enabled: Boolean(account.address && token && !isTokenAddressBalanceLoading),
|
|
56
55
|
refetchInterval,
|
|
57
56
|
staleTime: refetchInterval,
|
|
58
|
-
|
|
59
|
-
keepPreviousData: true,
|
|
57
|
+
placeholderData: keepPreviousData,
|
|
60
58
|
});
|
|
61
59
|
return {
|
|
62
60
|
insufficientFromToken,
|
|
63
|
-
|
|
61
|
+
isLoading,
|
|
64
62
|
};
|
|
65
63
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type
|
|
2
|
-
export declare const useGasRecommendation: (
|
|
1
|
+
import { type ChainId } from '@lifi/sdk';
|
|
2
|
+
export declare const useGasRecommendation: (toChainId: ChainId, fromChain?: ChainId, fromToken?: string) => import("@tanstack/react-query/build/legacy/types").UseQueryResult<import("@lifi/sdk").GasRecommendationResponse | null, Error>;
|
|
@@ -1,24 +1,29 @@
|
|
|
1
|
+
import { getGasRecommendation } from '@lifi/sdk';
|
|
1
2
|
import { useQuery } from '@tanstack/react-query';
|
|
2
|
-
import {
|
|
3
|
-
import { useChains } from './useChains';
|
|
3
|
+
import { useAvailableChains } from './useAvailableChains';
|
|
4
4
|
const refetchInterval = 60000;
|
|
5
|
-
export const useGasRecommendation = (
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
5
|
+
export const useGasRecommendation = (toChainId, fromChain, fromToken) => {
|
|
6
|
+
const { chains } = useAvailableChains();
|
|
7
|
+
const checkRecommendationLiFuel = Boolean(toChainId) &&
|
|
8
|
+
Boolean(fromChain) &&
|
|
9
|
+
Boolean(fromToken) &&
|
|
10
|
+
Boolean(chains?.length);
|
|
11
|
+
const checkRecommendationMaxButton = Boolean(toChainId) && !fromChain && !fromToken && Boolean(chains?.length);
|
|
12
|
+
return useQuery({
|
|
13
|
+
queryKey: ['gas-recommendation', toChainId, fromChain, fromToken],
|
|
14
|
+
queryFn: async ({ queryKey: [_, toChainId, fromChain, fromToken], signal, }) => {
|
|
15
|
+
if (!chains?.some((chain) => chain.id === toChainId)) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const gasRecommendation = await getGasRecommendation({
|
|
19
|
+
chainId: toChainId,
|
|
20
|
+
fromChain: fromChain,
|
|
21
|
+
fromToken: fromToken,
|
|
22
|
+
}, { signal });
|
|
23
|
+
return gasRecommendation;
|
|
24
|
+
},
|
|
25
|
+
enabled: checkRecommendationLiFuel || checkRecommendationMaxButton,
|
|
20
26
|
refetchInterval,
|
|
21
27
|
staleTime: refetchInterval,
|
|
22
|
-
cacheTime: refetchInterval,
|
|
23
28
|
});
|
|
24
29
|
};
|
package/hooks/useGasRefuel.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import Big from 'big.js';
|
|
2
1
|
import { useMemo } from 'react';
|
|
3
2
|
import { useWatch } from 'react-hook-form';
|
|
4
|
-
import {
|
|
3
|
+
import { useAvailableChains } from '.';
|
|
5
4
|
import { FormKey } from '../providers';
|
|
6
5
|
import { useGasRecommendation } from './useGasRecommendation';
|
|
7
6
|
import { useTokenBalance } from './useTokenBalance';
|
|
8
7
|
export const useGasRefuel = () => {
|
|
9
|
-
const { getChainById } =
|
|
8
|
+
const { getChainById } = useAvailableChains();
|
|
10
9
|
const [fromChainId, fromTokenAddress, toChainId, toAddress] = useWatch({
|
|
11
10
|
name: [
|
|
12
11
|
FormKey.FromChain,
|
|
@@ -16,25 +15,33 @@ export const useGasRefuel = () => {
|
|
|
16
15
|
],
|
|
17
16
|
});
|
|
18
17
|
const toChain = getChainById(toChainId);
|
|
19
|
-
const
|
|
18
|
+
const fromChain = getChainById(fromChainId);
|
|
19
|
+
const { token: nativeToken } = useTokenBalance(toAddress, toChainId && toChain?.nativeToken, toChain);
|
|
20
20
|
const { data: gasRecommendation, isLoading } = useGasRecommendation(toChainId, fromChainId, fromTokenAddress);
|
|
21
|
+
// When we bridge between ecosystems we need to be sure toAddress is set
|
|
22
|
+
const isChainTypeSatisfied = fromChain?.chainType !== toChain?.chainType ? Boolean(toAddress) : true;
|
|
21
23
|
const enabled = useMemo(() => {
|
|
22
24
|
if (
|
|
23
25
|
// We don't allow same chain refuel.
|
|
24
26
|
// If a user runs out of gas, he can't send a source chain transaction.
|
|
25
27
|
fromChainId === toChainId ||
|
|
26
28
|
!gasRecommendation?.available ||
|
|
27
|
-
!nativeToken
|
|
29
|
+
!nativeToken ||
|
|
30
|
+
!isChainTypeSatisfied) {
|
|
28
31
|
return false;
|
|
29
32
|
}
|
|
30
|
-
const tokenBalance =
|
|
31
|
-
//
|
|
32
|
-
const recommendedAmount =
|
|
33
|
-
|
|
34
|
-
.div(2);
|
|
35
|
-
const insufficientGas = tokenBalance.lt(recommendedAmount);
|
|
33
|
+
const tokenBalance = nativeToken.amount ?? 0n;
|
|
34
|
+
// Check if the user balance < 50% of the recommended amount
|
|
35
|
+
const recommendedAmount = BigInt(gasRecommendation.recommended.amount) / 2n;
|
|
36
|
+
const insufficientGas = tokenBalance < recommendedAmount;
|
|
36
37
|
return insufficientGas;
|
|
37
|
-
}, [
|
|
38
|
+
}, [
|
|
39
|
+
fromChainId,
|
|
40
|
+
gasRecommendation,
|
|
41
|
+
isChainTypeSatisfied,
|
|
42
|
+
nativeToken,
|
|
43
|
+
toChainId,
|
|
44
|
+
]);
|
|
38
45
|
return {
|
|
39
46
|
enabled: enabled,
|
|
40
47
|
availble: gasRecommendation?.available,
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import Big from 'big.js';
|
|
1
|
+
import { type EVMChain, type RouteExtended, type Token } from '@lifi/sdk';
|
|
3
2
|
export interface GasSufficiency {
|
|
4
|
-
gasAmount:
|
|
5
|
-
tokenAmount?:
|
|
6
|
-
insufficientAmount?:
|
|
3
|
+
gasAmount: bigint;
|
|
4
|
+
tokenAmount?: bigint;
|
|
5
|
+
insufficientAmount?: bigint;
|
|
7
6
|
insufficient?: boolean;
|
|
8
7
|
token: Token;
|
|
9
8
|
chain?: EVMChain;
|
|
10
9
|
}
|
|
11
|
-
export declare const useGasSufficiency: (route?:
|
|
10
|
+
export declare const useGasSufficiency: (route?: RouteExtended) => {
|
|
12
11
|
insufficientGas: GasSufficiency[] | undefined;
|
|
13
|
-
|
|
12
|
+
isLoading: boolean;
|
|
14
13
|
};
|
|
@@ -1,90 +1,87 @@
|
|
|
1
1
|
import { useQuery } from '@tanstack/react-query';
|
|
2
|
-
import
|
|
3
|
-
import { useChains, useGasRefuel, useGetTokenBalancesWithRetry } from '.';
|
|
4
|
-
import { useWallet, useWidgetConfig } from '../providers';
|
|
2
|
+
import { getTokenBalancesWithRetry, useAvailableChains, useGasRefuel } from '.';
|
|
5
3
|
import { useSettings } from '../stores';
|
|
4
|
+
import { useAccount } from './useAccount';
|
|
6
5
|
const refetchInterval = 30000;
|
|
7
6
|
export const useGasSufficiency = (route) => {
|
|
8
|
-
const { account } =
|
|
9
|
-
const { getChainById } =
|
|
10
|
-
const getTokenBalancesWithRetry = useGetTokenBalancesWithRetry(account.signer?.provider);
|
|
11
|
-
const { sdkConfig } = useWidgetConfig();
|
|
12
|
-
const isMultisigSigner = sdkConfig?.multisigConfig?.isMultisigSigner;
|
|
7
|
+
const { account } = useAccount();
|
|
8
|
+
const { getChainById } = useAvailableChains();
|
|
13
9
|
const { enabledAutoRefuel } = useSettings(['enabledAutoRefuel']);
|
|
14
10
|
const { enabled, isLoading: isRefuelLoading } = useGasRefuel();
|
|
15
11
|
const enabledRefuel = enabled && enabledAutoRefuel;
|
|
16
|
-
const { data: insufficientGas,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
12
|
+
const { data: insufficientGas, isLoading } = useQuery({
|
|
13
|
+
queryKey: ['gas-sufficiency-check', account.address, route?.id],
|
|
14
|
+
queryFn: async () => {
|
|
15
|
+
// TODO: include LI.Fuel into calculation once steps and tools are properly typed
|
|
16
|
+
// const refuelSteps = route.steps
|
|
17
|
+
// .flatMap((step) => step.includedSteps)
|
|
18
|
+
// .filter((includedStep) => includedStep.tool === 'lifuelProtocol');
|
|
19
|
+
const gasCosts = route.steps
|
|
20
|
+
.filter((step) => !step.execution || step.execution.status !== 'DONE')
|
|
21
|
+
.reduce((groupedGasCosts, step) => {
|
|
22
|
+
if (step.estimate.gasCosts &&
|
|
23
|
+
account.connector?.id !== 'safe') {
|
|
24
|
+
const { token } = step.estimate.gasCosts[0];
|
|
25
|
+
const gasCostAmount = step.estimate.gasCosts.reduce((amount, gasCost) => amount + BigInt(gasCost.amount), 0n);
|
|
26
|
+
groupedGasCosts[token.chainId] = {
|
|
27
|
+
gasAmount: groupedGasCosts[token.chainId]
|
|
28
|
+
? groupedGasCosts[token.chainId].gasAmount + gasCostAmount
|
|
29
|
+
: gasCostAmount,
|
|
30
|
+
token,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
// Add fees paid in native tokens to gas sufficiency check (included: false)
|
|
34
|
+
const nonIncludedFeeCosts = step.estimate.feeCosts?.filter((feeCost) => !feeCost.included);
|
|
35
|
+
if (nonIncludedFeeCosts?.length) {
|
|
36
|
+
const { token } = nonIncludedFeeCosts[0];
|
|
37
|
+
const feeCostAmount = nonIncludedFeeCosts.reduce((amount, feeCost) => amount + BigInt(feeCost.amount), 0n);
|
|
38
|
+
groupedGasCosts[token.chainId] = {
|
|
39
|
+
gasAmount: groupedGasCosts[token.chainId]
|
|
40
|
+
? groupedGasCosts[token.chainId].gasAmount + feeCostAmount
|
|
41
|
+
: feeCostAmount,
|
|
42
|
+
token,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return groupedGasCosts;
|
|
46
|
+
}, {});
|
|
47
|
+
if (route.fromToken.address === gasCosts[route.fromChainId]?.token.address) {
|
|
48
|
+
gasCosts[route.fromChainId].tokenAmount =
|
|
49
|
+
gasCosts[route.fromChainId]?.gasAmount + BigInt(route.fromAmount);
|
|
36
50
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const { token } = nonIncludedFeeCosts[0];
|
|
41
|
-
const feeCostAmount = nonIncludedFeeCosts
|
|
42
|
-
.reduce((amount, feeCost) => amount.plus(Big(feeCost.amount || 0)), Big(0))
|
|
43
|
-
.div(10 ** token.decimals);
|
|
44
|
-
groupedGasCosts[token.chainId] = {
|
|
45
|
-
gasAmount: groupedGasCosts[token.chainId]?.gasAmount.plus(feeCostAmount) ?? feeCostAmount,
|
|
46
|
-
token,
|
|
47
|
-
};
|
|
51
|
+
const tokenBalances = await getTokenBalancesWithRetry(account.address, Object.values(gasCosts).map((item) => item.token));
|
|
52
|
+
if (!tokenBalances?.length) {
|
|
53
|
+
return [];
|
|
48
54
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
insufficientAmount: insufficientAmount?.round(5, Big.roundUp),
|
|
73
|
-
chain: insufficient ? getChainById(chainId) : undefined,
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
const gasCostResult = Object.values(gasCosts).filter((gasCost) => gasCost.insufficient);
|
|
78
|
-
return gasCostResult;
|
|
79
|
-
}, {
|
|
55
|
+
[route.fromChainId, route.toChainId].forEach((chainId) => {
|
|
56
|
+
if (gasCosts[chainId]) {
|
|
57
|
+
const gasTokenBalance = tokenBalances?.find((t) => t.chainId === gasCosts[chainId].token.chainId &&
|
|
58
|
+
t.address === gasCosts[chainId].token.address)?.amount ?? 0n;
|
|
59
|
+
const insufficient = gasTokenBalance <= 0n ||
|
|
60
|
+
gasTokenBalance < gasCosts[chainId].gasAmount ||
|
|
61
|
+
gasTokenBalance < (gasCosts[chainId].tokenAmount ?? 0n);
|
|
62
|
+
const insufficientAmount = insufficient
|
|
63
|
+
? gasCosts[chainId].tokenAmount
|
|
64
|
+
? gasCosts[chainId].tokenAmount - gasTokenBalance
|
|
65
|
+
: gasCosts[chainId].gasAmount - gasTokenBalance
|
|
66
|
+
: undefined;
|
|
67
|
+
gasCosts[chainId] = {
|
|
68
|
+
...gasCosts[chainId],
|
|
69
|
+
insufficient,
|
|
70
|
+
insufficientAmount,
|
|
71
|
+
chain: insufficient ? getChainById(chainId) : undefined,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
const gasCostResult = Object.values(gasCosts).filter((gasCost) => gasCost.insufficient);
|
|
76
|
+
return gasCostResult;
|
|
77
|
+
},
|
|
80
78
|
enabled: Boolean(account.address && route),
|
|
81
79
|
refetchInterval,
|
|
82
80
|
staleTime: refetchInterval,
|
|
83
|
-
cacheTime: refetchInterval,
|
|
84
81
|
});
|
|
85
82
|
const isInsufficientGas = Boolean(insufficientGas?.length) && !isRefuelLoading && !enabledRefuel;
|
|
86
83
|
return {
|
|
87
84
|
insufficientGas: isInsufficientGas ? insufficientGas : undefined,
|
|
88
|
-
|
|
85
|
+
isLoading,
|
|
89
86
|
};
|
|
90
87
|
};
|