@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
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useAccountDisconnect = exports.useAccount = void 0;
|
|
4
|
+
const sdk_1 = require("@lifi/sdk");
|
|
5
|
+
const wallet_adapter_react_1 = require("@solana/wallet-adapter-react");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const wagmi_1 = require("wagmi");
|
|
8
|
+
const useAccount = () => {
|
|
9
|
+
const account = (0, wagmi_1.useAccount)();
|
|
10
|
+
const { wallet } = (0, wallet_adapter_react_1.useWallet)();
|
|
11
|
+
return (0, react_1.useMemo)(() => {
|
|
12
|
+
const svm = wallet?.adapter.publicKey
|
|
13
|
+
? {
|
|
14
|
+
address: wallet?.adapter.publicKey.toString(),
|
|
15
|
+
chainId: sdk_1.ChainId.SOL,
|
|
16
|
+
chainType: sdk_1.ChainType.SVM,
|
|
17
|
+
connector: wallet?.adapter,
|
|
18
|
+
isConnected: Boolean(wallet?.adapter.publicKey),
|
|
19
|
+
isConnecting: false,
|
|
20
|
+
isReconnecting: false,
|
|
21
|
+
isDisconnected: !wallet,
|
|
22
|
+
status: 'connected',
|
|
23
|
+
}
|
|
24
|
+
: {
|
|
25
|
+
chainType: sdk_1.ChainType.SVM,
|
|
26
|
+
isConnected: false,
|
|
27
|
+
isConnecting: false,
|
|
28
|
+
isReconnecting: false,
|
|
29
|
+
isDisconnected: true,
|
|
30
|
+
status: 'disconnected',
|
|
31
|
+
};
|
|
32
|
+
const evm = { ...account, chainType: sdk_1.ChainType.EVM };
|
|
33
|
+
return {
|
|
34
|
+
account: account.isConnected ? evm : svm,
|
|
35
|
+
accounts: [evm, svm],
|
|
36
|
+
};
|
|
37
|
+
}, [account, wallet]);
|
|
38
|
+
};
|
|
39
|
+
exports.useAccount = useAccount;
|
|
40
|
+
const useAccountDisconnect = () => {
|
|
41
|
+
const account = (0, wagmi_1.useAccount)();
|
|
42
|
+
const { disconnect: wagmiDisconnect } = (0, wagmi_1.useDisconnect)();
|
|
43
|
+
const { wallet, disconnect } = (0, wallet_adapter_react_1.useWallet)();
|
|
44
|
+
return () => {
|
|
45
|
+
if (account.isConnected) {
|
|
46
|
+
wagmiDisconnect();
|
|
47
|
+
}
|
|
48
|
+
if (wallet) {
|
|
49
|
+
disconnect();
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
exports.useAccountDisconnect = useAccountDisconnect;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useAvailableChains = void 0;
|
|
4
|
+
const sdk_1 = require("@lifi/sdk");
|
|
5
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const useAvailableChains = () => {
|
|
8
|
+
const { data, isLoading } = (0, react_query_1.useQuery)({
|
|
9
|
+
queryKey: ['chains'],
|
|
10
|
+
queryFn: async () => {
|
|
11
|
+
const chains = await (0, sdk_1.getChains)({
|
|
12
|
+
chainTypes: [sdk_1.ChainType.EVM, sdk_1.ChainType.SVM],
|
|
13
|
+
});
|
|
14
|
+
sdk_1.config.setChains(chains);
|
|
15
|
+
return chains;
|
|
16
|
+
},
|
|
17
|
+
refetchInterval: 300000,
|
|
18
|
+
staleTime: 300000,
|
|
19
|
+
});
|
|
20
|
+
const getChainById = (0, react_1.useCallback)((chainId, chains = data) => {
|
|
21
|
+
if (!chainId) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const chain = chains?.find((chain) => chain.id === chainId);
|
|
25
|
+
// if (!chain) {
|
|
26
|
+
// throw new Error('Chain not found or chainId is invalid.');
|
|
27
|
+
// }
|
|
28
|
+
return chain;
|
|
29
|
+
}, [data]);
|
|
30
|
+
return {
|
|
31
|
+
chains: data,
|
|
32
|
+
getChainById,
|
|
33
|
+
isLoading,
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
exports.useAvailableChains = useAvailableChains;
|
package/cjs/hooks/useChain.js
CHANGED
|
@@ -2,13 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useChain = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
-
const
|
|
5
|
+
const useAvailableChains_1 = require("./useAvailableChains");
|
|
6
6
|
const useChain = (chainId) => {
|
|
7
|
-
const {
|
|
8
|
-
const chain = (0, react_1.useMemo)(() =>
|
|
9
|
-
const chain = chains?.find((chain) => chain.id === chainId);
|
|
10
|
-
return chain;
|
|
11
|
-
}, [chainId, chains]);
|
|
7
|
+
const { isLoading, getChainById } = (0, useAvailableChains_1.useAvailableChains)();
|
|
8
|
+
const chain = (0, react_1.useMemo)(() => getChainById(chainId), [chainId, getChainById]);
|
|
12
9
|
return {
|
|
13
10
|
chain,
|
|
14
11
|
isLoading,
|
package/cjs/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/cjs/hooks/useChains.js
CHANGED
|
@@ -1,51 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useChains = void 0;
|
|
4
|
-
const react_query_1 = require("@tanstack/react-query");
|
|
5
4
|
const react_1 = require("react");
|
|
6
|
-
const react_hook_form_1 = require("react-hook-form");
|
|
7
5
|
const providers_1 = require("../providers");
|
|
8
|
-
const
|
|
6
|
+
const useAvailableChains_1 = require("./useAvailableChains");
|
|
9
7
|
const useChains = () => {
|
|
10
|
-
const { chains
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
const { data: availableChains, isLoading: isLoadingAvailableChains } = (0, react_query_1.useQuery)(['chains'], async () => lifi.getChains(), {
|
|
15
|
-
refetchInterval: 300000,
|
|
16
|
-
staleTime: 300000,
|
|
17
|
-
});
|
|
18
|
-
const { data: filteredChains, isLoading: isLoadingFilteredChains } = (0, react_query_1.useQuery)(['filtered-chains', availableChains?.length, keyPrefix], async () => {
|
|
19
|
-
if (!availableChains) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
const filteredChains = availableChains.filter((chain) => (0, providers_1.isItemAllowed)(chain.id, chains));
|
|
23
|
-
const chainOrder = initializeChains(filteredChains.map((chain) => chain.id));
|
|
24
|
-
const [fromChainValue, toChainValue] = getValues([
|
|
25
|
-
providers_1.FormKey.FromChain,
|
|
26
|
-
providers_1.FormKey.ToChain,
|
|
27
|
-
]);
|
|
28
|
-
if (!fromChainValue) {
|
|
29
|
-
setValue(providers_1.FormKey.FromChain, chainOrder[0]);
|
|
30
|
-
}
|
|
31
|
-
if (!toChainValue) {
|
|
32
|
-
setValue(providers_1.FormKey.ToChain, chainOrder[0]);
|
|
33
|
-
}
|
|
8
|
+
const { chains } = (0, providers_1.useWidgetConfig)();
|
|
9
|
+
const { chains: availableChains, isLoading: isLoadingAvailableChains, getChainById, } = (0, useAvailableChains_1.useAvailableChains)();
|
|
10
|
+
const filteredChains = (0, react_1.useMemo)(() => {
|
|
11
|
+
const filteredChains = availableChains?.filter((chain) => (0, providers_1.isItemAllowed)(chain.id, chains));
|
|
34
12
|
return filteredChains;
|
|
35
|
-
},
|
|
36
|
-
enabled: Boolean(availableChains),
|
|
37
|
-
});
|
|
38
|
-
const getChainById = (0, react_1.useCallback)((chainId) => {
|
|
39
|
-
const chain = availableChains?.find((chain) => chain.id === chainId);
|
|
40
|
-
// if (!chain) {
|
|
41
|
-
// throw new Error('Chain not found or chainId is invalid.');
|
|
42
|
-
// }
|
|
43
|
-
return chain;
|
|
44
|
-
}, [availableChains]);
|
|
13
|
+
}, [availableChains, chains]);
|
|
45
14
|
return {
|
|
46
15
|
chains: filteredChains,
|
|
47
16
|
getChainById,
|
|
48
|
-
isLoading: isLoadingAvailableChains
|
|
17
|
+
isLoading: isLoadingAvailableChains,
|
|
49
18
|
};
|
|
50
19
|
};
|
|
51
20
|
exports.useChains = useChains;
|
|
@@ -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
|
};
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useFromTokenSufficiency = void 0;
|
|
4
4
|
const react_query_1 = require("@tanstack/react-query");
|
|
5
|
-
const big_js_1 = require("big.js");
|
|
6
5
|
const react_hook_form_1 = require("react-hook-form");
|
|
6
|
+
const viem_1 = require("viem");
|
|
7
7
|
const providers_1 = require("../providers");
|
|
8
8
|
const stores_1 = require("../stores");
|
|
9
|
-
const
|
|
9
|
+
const useAccount_1 = require("./useAccount");
|
|
10
10
|
const useTokenAddressBalance_1 = require("./useTokenAddressBalance");
|
|
11
|
+
const useTokenBalance_1 = require("./useTokenBalance");
|
|
11
12
|
const refetchInterval = 30000;
|
|
12
13
|
const useFromTokenSufficiency = (route) => {
|
|
13
|
-
const { account } = (0,
|
|
14
|
-
const getTokenBalancesWithRetry = (0, useGetTokenBalancesWithRetry_1.useGetTokenBalancesWithRetry)(account.signer?.provider);
|
|
14
|
+
const { account } = (0, useAccount_1.useAccount)();
|
|
15
15
|
const [fromChainId, fromTokenAddress, fromAmount] = (0, react_hook_form_1.useWatch)({
|
|
16
16
|
name: [providers_1.FormKey.FromChain, providers_1.FormKey.FromToken, providers_1.FormKey.FromAmount],
|
|
17
17
|
});
|
|
@@ -21,49 +21,47 @@ const useFromTokenSufficiency = (route) => {
|
|
|
21
21
|
chainId = route.fromToken.chainId;
|
|
22
22
|
tokenAddress = route.fromToken.address;
|
|
23
23
|
}
|
|
24
|
-
const { token, isLoading } = (0, useTokenAddressBalance_1.useTokenAddressBalance)(chainId, tokenAddress);
|
|
25
|
-
const { data: insufficientFromToken,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
24
|
+
const { token, isLoading: isTokenAddressBalanceLoading } = (0, useTokenAddressBalance_1.useTokenAddressBalance)(chainId, tokenAddress);
|
|
25
|
+
const { data: insufficientFromToken, isLoading } = (0, react_query_1.useQuery)({
|
|
26
|
+
queryKey: [
|
|
27
|
+
'from-token-sufficiency-check',
|
|
28
|
+
account.address,
|
|
29
|
+
chainId,
|
|
30
|
+
tokenAddress,
|
|
31
|
+
route?.id ?? fromAmount,
|
|
32
|
+
],
|
|
33
|
+
queryFn: async () => {
|
|
34
|
+
if (!account.address || !token) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const parsedFromAmount = (0, viem_1.parseUnits)(fromAmount, token.decimals);
|
|
38
|
+
let currentTokenBalance = token.amount ?? 0n;
|
|
39
|
+
if (!route || (0, stores_1.isRouteDone)(route)) {
|
|
40
|
+
const insufficientFunds = currentTokenBalance < parsedFromAmount;
|
|
41
|
+
return insufficientFunds;
|
|
42
|
+
}
|
|
43
|
+
const currentAction = route.steps.filter((step) => !step.execution || step.execution.status !== 'DONE')[0]?.action;
|
|
44
|
+
if (token.chainId === currentAction.fromToken.chainId &&
|
|
45
|
+
token.address === currentAction.fromToken.address &&
|
|
46
|
+
currentTokenBalance > 0) {
|
|
47
|
+
const insufficientFunds = BigInt(route.fromAmount) > currentTokenBalance;
|
|
48
|
+
return insufficientFunds;
|
|
49
|
+
}
|
|
50
|
+
const tokenBalances = await (0, useTokenBalance_1.getTokenBalancesWithRetry)(account.address, [
|
|
51
|
+
currentAction.fromToken,
|
|
52
|
+
]);
|
|
53
|
+
currentTokenBalance = tokenBalances?.[0]?.amount ?? 0n;
|
|
54
|
+
const insufficientFunds = BigInt(currentAction.fromAmount) > currentTokenBalance;
|
|
38
55
|
return insufficientFunds;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (token.chainId === currentAction.fromToken.chainId &&
|
|
42
|
-
token.address === currentAction.fromToken.address &&
|
|
43
|
-
currentTokenBalance.gt(0)) {
|
|
44
|
-
const insufficientFunds = (0, big_js_1.default)(route.fromAmount)
|
|
45
|
-
.div(10 ** route.fromToken.decimals)
|
|
46
|
-
.gt(currentTokenBalance);
|
|
47
|
-
return insufficientFunds;
|
|
48
|
-
}
|
|
49
|
-
const tokenBalances = await getTokenBalancesWithRetry(account.address, [
|
|
50
|
-
currentAction.fromToken,
|
|
51
|
-
]);
|
|
52
|
-
currentTokenBalance = (0, big_js_1.default)(tokenBalances?.[0]?.amount || 0);
|
|
53
|
-
const insufficientFunds = (0, big_js_1.default)(currentAction.fromAmount)
|
|
54
|
-
.div(10 ** currentAction.fromToken.decimals)
|
|
55
|
-
.gt(currentTokenBalance);
|
|
56
|
-
return insufficientFunds;
|
|
57
|
-
}, {
|
|
58
|
-
enabled: Boolean(account.address && token && !isLoading),
|
|
56
|
+
},
|
|
57
|
+
enabled: Boolean(account.address && token && !isTokenAddressBalanceLoading),
|
|
59
58
|
refetchInterval,
|
|
60
59
|
staleTime: refetchInterval,
|
|
61
|
-
|
|
62
|
-
keepPreviousData: true,
|
|
60
|
+
placeholderData: react_query_1.keepPreviousData,
|
|
63
61
|
});
|
|
64
62
|
return {
|
|
65
63
|
insufficientFromToken,
|
|
66
|
-
|
|
64
|
+
isLoading,
|
|
67
65
|
};
|
|
68
66
|
};
|
|
69
67
|
exports.useFromTokenSufficiency = useFromTokenSufficiency;
|
|
@@ -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,28 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useGasRecommendation = void 0;
|
|
4
|
+
const sdk_1 = require("@lifi/sdk");
|
|
4
5
|
const react_query_1 = require("@tanstack/react-query");
|
|
5
|
-
const
|
|
6
|
-
const useChains_1 = require("./useChains");
|
|
6
|
+
const useAvailableChains_1 = require("./useAvailableChains");
|
|
7
7
|
const refetchInterval = 60000;
|
|
8
|
-
const useGasRecommendation = (
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
8
|
+
const useGasRecommendation = (toChainId, fromChain, fromToken) => {
|
|
9
|
+
const { chains } = (0, useAvailableChains_1.useAvailableChains)();
|
|
10
|
+
const checkRecommendationLiFuel = Boolean(toChainId) &&
|
|
11
|
+
Boolean(fromChain) &&
|
|
12
|
+
Boolean(fromToken) &&
|
|
13
|
+
Boolean(chains?.length);
|
|
14
|
+
const checkRecommendationMaxButton = Boolean(toChainId) && !fromChain && !fromToken && Boolean(chains?.length);
|
|
15
|
+
return (0, react_query_1.useQuery)({
|
|
16
|
+
queryKey: ['gas-recommendation', toChainId, fromChain, fromToken],
|
|
17
|
+
queryFn: async ({ queryKey: [_, toChainId, fromChain, fromToken], signal, }) => {
|
|
18
|
+
if (!chains?.some((chain) => chain.id === toChainId)) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
const gasRecommendation = await (0, sdk_1.getGasRecommendation)({
|
|
22
|
+
chainId: toChainId,
|
|
23
|
+
fromChain: fromChain,
|
|
24
|
+
fromToken: fromToken,
|
|
25
|
+
}, { signal });
|
|
26
|
+
return gasRecommendation;
|
|
27
|
+
},
|
|
28
|
+
enabled: checkRecommendationLiFuel || checkRecommendationMaxButton,
|
|
23
29
|
refetchInterval,
|
|
24
30
|
staleTime: refetchInterval,
|
|
25
|
-
cacheTime: refetchInterval,
|
|
26
31
|
});
|
|
27
32
|
};
|
|
28
33
|
exports.useGasRecommendation = useGasRecommendation;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useGasRefuel = void 0;
|
|
4
|
-
const big_js_1 = require("big.js");
|
|
5
4
|
const react_1 = require("react");
|
|
6
5
|
const react_hook_form_1 = require("react-hook-form");
|
|
7
6
|
const _1 = require(".");
|
|
@@ -9,7 +8,7 @@ const providers_1 = require("../providers");
|
|
|
9
8
|
const useGasRecommendation_1 = require("./useGasRecommendation");
|
|
10
9
|
const useTokenBalance_1 = require("./useTokenBalance");
|
|
11
10
|
const useGasRefuel = () => {
|
|
12
|
-
const { getChainById } = (0, _1.
|
|
11
|
+
const { getChainById } = (0, _1.useAvailableChains)();
|
|
13
12
|
const [fromChainId, fromTokenAddress, toChainId, toAddress] = (0, react_hook_form_1.useWatch)({
|
|
14
13
|
name: [
|
|
15
14
|
providers_1.FormKey.FromChain,
|
|
@@ -19,25 +18,33 @@ const useGasRefuel = () => {
|
|
|
19
18
|
],
|
|
20
19
|
});
|
|
21
20
|
const toChain = getChainById(toChainId);
|
|
22
|
-
const
|
|
21
|
+
const fromChain = getChainById(fromChainId);
|
|
22
|
+
const { token: nativeToken } = (0, useTokenBalance_1.useTokenBalance)(toAddress, toChainId && toChain?.nativeToken, toChain);
|
|
23
23
|
const { data: gasRecommendation, isLoading } = (0, useGasRecommendation_1.useGasRecommendation)(toChainId, fromChainId, fromTokenAddress);
|
|
24
|
+
// When we bridge between ecosystems we need to be sure toAddress is set
|
|
25
|
+
const isChainTypeSatisfied = fromChain?.chainType !== toChain?.chainType ? Boolean(toAddress) : true;
|
|
24
26
|
const enabled = (0, react_1.useMemo)(() => {
|
|
25
27
|
if (
|
|
26
28
|
// We don't allow same chain refuel.
|
|
27
29
|
// If a user runs out of gas, he can't send a source chain transaction.
|
|
28
30
|
fromChainId === toChainId ||
|
|
29
31
|
!gasRecommendation?.available ||
|
|
30
|
-
!nativeToken
|
|
32
|
+
!nativeToken ||
|
|
33
|
+
!isChainTypeSatisfied) {
|
|
31
34
|
return false;
|
|
32
35
|
}
|
|
33
|
-
const tokenBalance =
|
|
34
|
-
//
|
|
35
|
-
const recommendedAmount = (
|
|
36
|
-
|
|
37
|
-
.div(2);
|
|
38
|
-
const insufficientGas = tokenBalance.lt(recommendedAmount);
|
|
36
|
+
const tokenBalance = nativeToken.amount ?? 0n;
|
|
37
|
+
// Check if the user balance < 50% of the recommended amount
|
|
38
|
+
const recommendedAmount = BigInt(gasRecommendation.recommended.amount) / 2n;
|
|
39
|
+
const insufficientGas = tokenBalance < recommendedAmount;
|
|
39
40
|
return insufficientGas;
|
|
40
|
-
}, [
|
|
41
|
+
}, [
|
|
42
|
+
fromChainId,
|
|
43
|
+
gasRecommendation,
|
|
44
|
+
isChainTypeSatisfied,
|
|
45
|
+
nativeToken,
|
|
46
|
+
toChainId,
|
|
47
|
+
]);
|
|
41
48
|
return {
|
|
42
49
|
enabled: enabled,
|
|
43
50
|
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
|
};
|
|
@@ -2,93 +2,90 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useGasSufficiency = void 0;
|
|
4
4
|
const react_query_1 = require("@tanstack/react-query");
|
|
5
|
-
const big_js_1 = require("big.js");
|
|
6
5
|
const _1 = require(".");
|
|
7
|
-
const providers_1 = require("../providers");
|
|
8
6
|
const stores_1 = require("../stores");
|
|
7
|
+
const useAccount_1 = require("./useAccount");
|
|
9
8
|
const refetchInterval = 30000;
|
|
10
9
|
const useGasSufficiency = (route) => {
|
|
11
|
-
const { account } = (0,
|
|
12
|
-
const { getChainById } = (0, _1.
|
|
13
|
-
const getTokenBalancesWithRetry = (0, _1.useGetTokenBalancesWithRetry)(account.signer?.provider);
|
|
14
|
-
const { sdkConfig } = (0, providers_1.useWidgetConfig)();
|
|
15
|
-
const isMultisigSigner = sdkConfig?.multisigConfig?.isMultisigSigner;
|
|
10
|
+
const { account } = (0, useAccount_1.useAccount)();
|
|
11
|
+
const { getChainById } = (0, _1.useAvailableChains)();
|
|
16
12
|
const { enabledAutoRefuel } = (0, stores_1.useSettings)(['enabledAutoRefuel']);
|
|
17
13
|
const { enabled, isLoading: isRefuelLoading } = (0, _1.useGasRefuel)();
|
|
18
14
|
const enabledRefuel = enabled && enabledAutoRefuel;
|
|
19
|
-
const { data: insufficientGas,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
15
|
+
const { data: insufficientGas, isLoading } = (0, react_query_1.useQuery)({
|
|
16
|
+
queryKey: ['gas-sufficiency-check', account.address, route?.id],
|
|
17
|
+
queryFn: async () => {
|
|
18
|
+
// TODO: include LI.Fuel into calculation once steps and tools are properly typed
|
|
19
|
+
// const refuelSteps = route.steps
|
|
20
|
+
// .flatMap((step) => step.includedSteps)
|
|
21
|
+
// .filter((includedStep) => includedStep.tool === 'lifuelProtocol');
|
|
22
|
+
const gasCosts = route.steps
|
|
23
|
+
.filter((step) => !step.execution || step.execution.status !== 'DONE')
|
|
24
|
+
.reduce((groupedGasCosts, step) => {
|
|
25
|
+
if (step.estimate.gasCosts &&
|
|
26
|
+
account.connector?.id !== 'safe') {
|
|
27
|
+
const { token } = step.estimate.gasCosts[0];
|
|
28
|
+
const gasCostAmount = step.estimate.gasCosts.reduce((amount, gasCost) => amount + BigInt(gasCost.amount), 0n);
|
|
29
|
+
groupedGasCosts[token.chainId] = {
|
|
30
|
+
gasAmount: groupedGasCosts[token.chainId]
|
|
31
|
+
? groupedGasCosts[token.chainId].gasAmount + gasCostAmount
|
|
32
|
+
: gasCostAmount,
|
|
33
|
+
token,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
// Add fees paid in native tokens to gas sufficiency check (included: false)
|
|
37
|
+
const nonIncludedFeeCosts = step.estimate.feeCosts?.filter((feeCost) => !feeCost.included);
|
|
38
|
+
if (nonIncludedFeeCosts?.length) {
|
|
39
|
+
const { token } = nonIncludedFeeCosts[0];
|
|
40
|
+
const feeCostAmount = nonIncludedFeeCosts.reduce((amount, feeCost) => amount + BigInt(feeCost.amount), 0n);
|
|
41
|
+
groupedGasCosts[token.chainId] = {
|
|
42
|
+
gasAmount: groupedGasCosts[token.chainId]
|
|
43
|
+
? groupedGasCosts[token.chainId].gasAmount + feeCostAmount
|
|
44
|
+
: feeCostAmount,
|
|
45
|
+
token,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return groupedGasCosts;
|
|
49
|
+
}, {});
|
|
50
|
+
if (route.fromToken.address === gasCosts[route.fromChainId]?.token.address) {
|
|
51
|
+
gasCosts[route.fromChainId].tokenAmount =
|
|
52
|
+
gasCosts[route.fromChainId]?.gasAmount + BigInt(route.fromAmount);
|
|
39
53
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const { token } = nonIncludedFeeCosts[0];
|
|
44
|
-
const feeCostAmount = nonIncludedFeeCosts
|
|
45
|
-
.reduce((amount, feeCost) => amount.plus((0, big_js_1.default)(feeCost.amount || 0)), (0, big_js_1.default)(0))
|
|
46
|
-
.div(10 ** token.decimals);
|
|
47
|
-
groupedGasCosts[token.chainId] = {
|
|
48
|
-
gasAmount: groupedGasCosts[token.chainId]?.gasAmount.plus(feeCostAmount) ?? feeCostAmount,
|
|
49
|
-
token,
|
|
50
|
-
};
|
|
54
|
+
const tokenBalances = await (0, _1.getTokenBalancesWithRetry)(account.address, Object.values(gasCosts).map((item) => item.token));
|
|
55
|
+
if (!tokenBalances?.length) {
|
|
56
|
+
return [];
|
|
51
57
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
insufficientAmount: insufficientAmount?.round(5, big_js_1.default.roundUp),
|
|
76
|
-
chain: insufficient ? getChainById(chainId) : undefined,
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
const gasCostResult = Object.values(gasCosts).filter((gasCost) => gasCost.insufficient);
|
|
81
|
-
return gasCostResult;
|
|
82
|
-
}, {
|
|
58
|
+
[route.fromChainId, route.toChainId].forEach((chainId) => {
|
|
59
|
+
if (gasCosts[chainId]) {
|
|
60
|
+
const gasTokenBalance = tokenBalances?.find((t) => t.chainId === gasCosts[chainId].token.chainId &&
|
|
61
|
+
t.address === gasCosts[chainId].token.address)?.amount ?? 0n;
|
|
62
|
+
const insufficient = gasTokenBalance <= 0n ||
|
|
63
|
+
gasTokenBalance < gasCosts[chainId].gasAmount ||
|
|
64
|
+
gasTokenBalance < (gasCosts[chainId].tokenAmount ?? 0n);
|
|
65
|
+
const insufficientAmount = insufficient
|
|
66
|
+
? gasCosts[chainId].tokenAmount
|
|
67
|
+
? gasCosts[chainId].tokenAmount - gasTokenBalance
|
|
68
|
+
: gasCosts[chainId].gasAmount - gasTokenBalance
|
|
69
|
+
: undefined;
|
|
70
|
+
gasCosts[chainId] = {
|
|
71
|
+
...gasCosts[chainId],
|
|
72
|
+
insufficient,
|
|
73
|
+
insufficientAmount,
|
|
74
|
+
chain: insufficient ? getChainById(chainId) : undefined,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
const gasCostResult = Object.values(gasCosts).filter((gasCost) => gasCost.insufficient);
|
|
79
|
+
return gasCostResult;
|
|
80
|
+
},
|
|
83
81
|
enabled: Boolean(account.address && route),
|
|
84
82
|
refetchInterval,
|
|
85
83
|
staleTime: refetchInterval,
|
|
86
|
-
cacheTime: refetchInterval,
|
|
87
84
|
});
|
|
88
85
|
const isInsufficientGas = Boolean(insufficientGas?.length) && !isRefuelLoading && !enabledRefuel;
|
|
89
86
|
return {
|
|
90
87
|
insufficientGas: isInsufficientGas ? insufficientGas : undefined,
|
|
91
|
-
|
|
88
|
+
isLoading,
|
|
92
89
|
};
|
|
93
90
|
};
|
|
94
91
|
exports.useGasSufficiency = useGasSufficiency;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useLanguages = void 0;
|
|
4
|
+
const react_i18next_1 = require("react-i18next");
|
|
5
|
+
const providers_1 = require("../providers");
|
|
6
|
+
const stores_1 = require("../stores");
|
|
7
|
+
const useLanguages = () => {
|
|
8
|
+
const { t, i18n } = (0, react_i18next_1.useTranslation)();
|
|
9
|
+
const { languages } = (0, providers_1.useWidgetConfig)();
|
|
10
|
+
const { language } = (0, stores_1.useSettings)(['language']);
|
|
11
|
+
const setValue = (0, stores_1.useSettingsStore)((state) => state.setValue);
|
|
12
|
+
const sortedLanguages = Object.keys(i18n.store.data).sort();
|
|
13
|
+
const selectedLanguageCode = sortedLanguages.includes(language || i18n.resolvedLanguage || '')
|
|
14
|
+
? language || i18n.resolvedLanguage
|
|
15
|
+
: languages?.default || languages?.allow?.[0];
|
|
16
|
+
return {
|
|
17
|
+
availableLanguages: sortedLanguages,
|
|
18
|
+
selectedLanguageCode: selectedLanguageCode,
|
|
19
|
+
selectedLanguageDisplayName: t('language.name', {
|
|
20
|
+
lng: selectedLanguageCode,
|
|
21
|
+
}),
|
|
22
|
+
setLanguageWithCode: (code) => {
|
|
23
|
+
setValue('language', code);
|
|
24
|
+
i18n.changeLanguage(code);
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
exports.useLanguages = useLanguages;
|