@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,24 @@
|
|
|
1
|
+
import { useTranslation } from 'react-i18next';
|
|
2
|
+
import { useWidgetConfig } from '../providers';
|
|
3
|
+
import { useSettings, useSettingsStore } from '../stores';
|
|
4
|
+
export const useLanguages = () => {
|
|
5
|
+
const { t, i18n } = useTranslation();
|
|
6
|
+
const { languages } = useWidgetConfig();
|
|
7
|
+
const { language } = useSettings(['language']);
|
|
8
|
+
const setValue = useSettingsStore((state) => state.setValue);
|
|
9
|
+
const sortedLanguages = Object.keys(i18n.store.data).sort();
|
|
10
|
+
const selectedLanguageCode = sortedLanguages.includes(language || i18n.resolvedLanguage || '')
|
|
11
|
+
? language || i18n.resolvedLanguage
|
|
12
|
+
: languages?.default || languages?.allow?.[0];
|
|
13
|
+
return {
|
|
14
|
+
availableLanguages: sortedLanguages,
|
|
15
|
+
selectedLanguageCode: selectedLanguageCode,
|
|
16
|
+
selectedLanguageDisplayName: t('language.name', {
|
|
17
|
+
lng: selectedLanguageCode,
|
|
18
|
+
}),
|
|
19
|
+
setLanguageWithCode: (code) => {
|
|
20
|
+
setValue('language', code);
|
|
21
|
+
i18n.changeLanguage(code);
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { EVMChain,
|
|
1
|
+
import type { EVMChain, LiFiStep, Process } from '@lifi/sdk';
|
|
2
2
|
import type { TFunction } from 'i18next';
|
|
3
3
|
import type { WidgetSubvariant } from '../types';
|
|
4
|
-
export declare const useProcessMessage: (step?:
|
|
4
|
+
export declare const useProcessMessage: (step?: LiFiStep, process?: Process) => {
|
|
5
5
|
title?: string | undefined;
|
|
6
6
|
message?: string | undefined;
|
|
7
7
|
};
|
|
8
|
-
export declare function getProcessMessage(t: TFunction, getChainById: (chainId: number) => EVMChain | undefined, step:
|
|
8
|
+
export declare function getProcessMessage(t: TFunction, getChainById: (chainId: number) => EVMChain | undefined, step: LiFiStep, process: Process, subvariant?: WidgetSubvariant): {
|
|
9
9
|
title?: string;
|
|
10
10
|
message?: string;
|
|
11
11
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LiFiErrorCode } from '@lifi/sdk';
|
|
2
2
|
import { useTranslation } from 'react-i18next';
|
|
3
3
|
import { useWidgetConfig } from '../providers';
|
|
4
4
|
import { formatTokenAmount } from '../utils';
|
|
5
|
-
import {
|
|
5
|
+
import { useAvailableChains } from './useAvailableChains';
|
|
6
6
|
export const useProcessMessage = (step, process) => {
|
|
7
7
|
const { subvariant } = useWidgetConfig();
|
|
8
8
|
const { t } = useTranslation();
|
|
9
|
-
const { getChainById } =
|
|
9
|
+
const { getChainById } = useAvailableChains();
|
|
10
10
|
if (!step || !process) {
|
|
11
11
|
return {};
|
|
12
12
|
}
|
|
@@ -73,72 +73,76 @@ const processSubstatusMessages = {
|
|
|
73
73
|
};
|
|
74
74
|
export function getProcessMessage(t, getChainById, step, process, subvariant) {
|
|
75
75
|
if (process.error && process.status === 'FAILED') {
|
|
76
|
-
const
|
|
77
|
-
amount: formatTokenAmount(step.action.fromAmount, step.action.fromToken.decimals),
|
|
76
|
+
const getDefaultErrorMessage = (key) => `${t(key ?? 'error.message.transactionNotSent')} ${t('error.message.remainInYourWallet', {
|
|
77
|
+
amount: formatTokenAmount(BigInt(step.action.fromAmount), step.action.fromToken.decimals),
|
|
78
78
|
tokenSymbol: step.action.fromToken.symbol,
|
|
79
79
|
chainName: getChainById(step.action.fromChainId)?.name ?? '',
|
|
80
|
-
})
|
|
80
|
+
})}`;
|
|
81
81
|
let title = '';
|
|
82
82
|
let message = '';
|
|
83
83
|
switch (process.error.code) {
|
|
84
|
-
case
|
|
84
|
+
case LiFiErrorCode.AllowanceRequired:
|
|
85
85
|
title = t(`error.title.allowanceRequired`);
|
|
86
86
|
message = t(`error.message.allowanceRequired`, {
|
|
87
87
|
tokenSymbol: step.action.fromToken.symbol,
|
|
88
88
|
});
|
|
89
89
|
break;
|
|
90
|
-
case
|
|
90
|
+
case LiFiErrorCode.BalanceError:
|
|
91
91
|
title = t(`error.title.balanceIsTooLow`);
|
|
92
|
-
message =
|
|
92
|
+
message = getDefaultErrorMessage();
|
|
93
93
|
break;
|
|
94
|
-
case
|
|
94
|
+
case LiFiErrorCode.ChainSwitchError:
|
|
95
95
|
title = t(`error.title.chainSwitch`);
|
|
96
|
-
message =
|
|
96
|
+
message = getDefaultErrorMessage();
|
|
97
97
|
break;
|
|
98
|
-
case
|
|
98
|
+
case LiFiErrorCode.GasLimitError:
|
|
99
99
|
title = t(`error.title.gasLimitIsTooLow`);
|
|
100
|
-
message =
|
|
100
|
+
message = getDefaultErrorMessage();
|
|
101
101
|
break;
|
|
102
|
-
case
|
|
102
|
+
case LiFiErrorCode.InsufficientFunds:
|
|
103
103
|
title = t(`error.title.insufficientFunds`);
|
|
104
|
-
message = `${t(`error.message.insufficientFunds`)} ${
|
|
104
|
+
message = `${t(`error.message.insufficientFunds`)} ${getDefaultErrorMessage()}`;
|
|
105
105
|
break;
|
|
106
|
-
case
|
|
106
|
+
case LiFiErrorCode.SlippageError:
|
|
107
107
|
title = t(`error.title.slippageNotMet`);
|
|
108
108
|
message = t(`error.message.slippageThreshold`);
|
|
109
109
|
break;
|
|
110
|
-
case
|
|
110
|
+
case LiFiErrorCode.TransactionFailed:
|
|
111
111
|
title = t(`error.title.transactionFailed`);
|
|
112
112
|
message = t(`error.message.transactionFailed`);
|
|
113
113
|
break;
|
|
114
|
-
case
|
|
114
|
+
case LiFiErrorCode.TransactionUnderpriced:
|
|
115
115
|
title = t(`error.title.transactionUnderpriced`);
|
|
116
|
-
message =
|
|
116
|
+
message = getDefaultErrorMessage();
|
|
117
117
|
break;
|
|
118
|
-
case
|
|
118
|
+
case LiFiErrorCode.TransactionUnprepared:
|
|
119
119
|
title = t(`error.title.transactionUnprepared`);
|
|
120
|
-
message =
|
|
120
|
+
message = getDefaultErrorMessage();
|
|
121
121
|
break;
|
|
122
|
-
case
|
|
122
|
+
case LiFiErrorCode.TransactionCanceled:
|
|
123
123
|
title = t(`error.title.transactionCanceled`);
|
|
124
|
-
message =
|
|
124
|
+
message = getDefaultErrorMessage('error.message.transactionCanceled');
|
|
125
125
|
break;
|
|
126
|
-
case
|
|
127
|
-
title = t(`error.title.
|
|
128
|
-
message =
|
|
129
|
-
|
|
126
|
+
case LiFiErrorCode.ExchangeRateUpdateCanceled:
|
|
127
|
+
title = t(`error.title.exchangeRateUpdateCanceled`);
|
|
128
|
+
message = getDefaultErrorMessage();
|
|
129
|
+
break;
|
|
130
|
+
case LiFiErrorCode.SignatureRejected:
|
|
131
|
+
title = t(`error.title.signatureRejected`);
|
|
132
|
+
message = t(`error.message.signatureRejected`, {
|
|
133
|
+
amount: formatTokenAmount(BigInt(step.action.fromAmount), step.action.fromToken.decimals),
|
|
130
134
|
tokenSymbol: step.action.fromToken.symbol,
|
|
131
135
|
chainName: getChainById(step.action.fromChainId)?.name ?? '',
|
|
132
136
|
});
|
|
133
137
|
break;
|
|
134
|
-
case
|
|
138
|
+
case LiFiErrorCode.ProviderUnavailable:
|
|
135
139
|
default:
|
|
136
140
|
title = t(`error.title.unknown`);
|
|
137
141
|
if (process.txLink) {
|
|
138
142
|
message = t(`error.message.transactionFailed`);
|
|
139
143
|
}
|
|
140
144
|
else {
|
|
141
|
-
message = t(`error.message.unknown`);
|
|
145
|
+
message = process.error.message || t(`error.message.unknown`);
|
|
142
146
|
}
|
|
143
147
|
break;
|
|
144
148
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useRequiredToAddress: () => boolean | undefined;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useWatch } from 'react-hook-form';
|
|
2
|
+
import { useChain } from '../hooks';
|
|
3
|
+
import { FormKey, useWidgetConfig } from '../providers';
|
|
4
|
+
import { RequiredUI } from '../types';
|
|
5
|
+
export const useRequiredToAddress = () => {
|
|
6
|
+
const { requiredUI } = useWidgetConfig();
|
|
7
|
+
const [fromChainId, toChainId] = useWatch({
|
|
8
|
+
name: [FormKey.FromChain, FormKey.ToChain],
|
|
9
|
+
});
|
|
10
|
+
const { chain: fromChain } = useChain(fromChainId);
|
|
11
|
+
const { chain: toChain } = useChain(toChainId);
|
|
12
|
+
const differentChainType = fromChain && toChain && fromChain.chainType !== toChain.chainType;
|
|
13
|
+
const requiredToAddress = requiredUI?.includes(RequiredUI.ToAddress) || differentChainType;
|
|
14
|
+
return requiredToAddress;
|
|
15
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ExchangeRateUpdateParams
|
|
1
|
+
import type { ExchangeRateUpdateParams } from '@lifi/sdk';
|
|
2
2
|
interface RouteExecutionProps {
|
|
3
3
|
routeId: string;
|
|
4
4
|
executeInBackground?: boolean;
|
|
@@ -8,7 +8,7 @@ export declare const useRouteExecution: ({ routeId, executeInBackground, onAccep
|
|
|
8
8
|
executeRoute: () => void;
|
|
9
9
|
restartRoute: () => void;
|
|
10
10
|
deleteRoute: () => void;
|
|
11
|
-
route:
|
|
11
|
+
route: import("@lifi/sdk").RouteExtended | undefined;
|
|
12
12
|
status: import("../stores").RouteExecutionStatus | undefined;
|
|
13
13
|
};
|
|
14
14
|
export {};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
+
import { executeRoute, resumeRoute, updateRouteExecution } from '@lifi/sdk';
|
|
1
2
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
2
3
|
import { useCallback, useEffect, useRef } from 'react';
|
|
3
4
|
import { shallow } from 'zustand/shallow';
|
|
4
|
-
import { useLiFi, useWallet } from '../providers';
|
|
5
5
|
import { getUpdatedProcess, isRouteActive, isRouteDone, isRouteFailed, useRouteExecutionStore, useRouteExecutionStoreContext, } from '../stores';
|
|
6
6
|
import { WidgetEvent } from '../types/events';
|
|
7
|
+
import { useAccount } from './useAccount';
|
|
7
8
|
import { useWidgetEvents } from './useWidgetEvents';
|
|
8
9
|
export const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchangeRateUpdate, }) => {
|
|
9
|
-
const lifi = useLiFi();
|
|
10
10
|
const queryClient = useQueryClient();
|
|
11
|
-
const { account
|
|
11
|
+
const { account } = useAccount();
|
|
12
12
|
const resumedAfterMount = useRef(false);
|
|
13
13
|
const emitter = useWidgetEvents();
|
|
14
14
|
const routeExecutionStoreContext = useRouteExecutionStoreContext();
|
|
@@ -39,20 +39,6 @@ export const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchan
|
|
|
39
39
|
}
|
|
40
40
|
console.log('Route updated.', clonedUpdatedRoute);
|
|
41
41
|
};
|
|
42
|
-
const switchChainHook = async (requiredChainId) => {
|
|
43
|
-
if (!account.isActive || !account.signer) {
|
|
44
|
-
return account.signer;
|
|
45
|
-
}
|
|
46
|
-
const currentChainId = await account.signer.getChainId();
|
|
47
|
-
if (currentChainId !== requiredChainId) {
|
|
48
|
-
const signer = await switchChain(requiredChainId);
|
|
49
|
-
if (!signer) {
|
|
50
|
-
throw new Error('Chain was not switched.');
|
|
51
|
-
}
|
|
52
|
-
return signer;
|
|
53
|
-
}
|
|
54
|
-
return account.signer;
|
|
55
|
-
};
|
|
56
42
|
const acceptExchangeRateUpdateHook = async (params) => {
|
|
57
43
|
if (!onAcceptExchangeRateUpdate) {
|
|
58
44
|
return false;
|
|
@@ -60,22 +46,22 @@ export const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchan
|
|
|
60
46
|
const accepted = await new Promise((resolve) => onAcceptExchangeRateUpdate(resolve, params));
|
|
61
47
|
return accepted;
|
|
62
48
|
};
|
|
63
|
-
const executeRouteMutation = useMutation(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
49
|
+
const executeRouteMutation = useMutation({
|
|
50
|
+
mutationFn: () => {
|
|
51
|
+
if (!account.isConnected) {
|
|
52
|
+
throw Error('Account is not connected.');
|
|
53
|
+
}
|
|
54
|
+
if (!routeExecution?.route) {
|
|
55
|
+
throw Error('Execution route not found.');
|
|
56
|
+
}
|
|
57
|
+
queryClient.removeQueries({ queryKey: ['routes'], exact: false });
|
|
58
|
+
return executeRoute(routeExecution.route, {
|
|
59
|
+
updateRouteHook,
|
|
60
|
+
acceptExchangeRateUpdateHook,
|
|
61
|
+
infiniteApproval: false,
|
|
62
|
+
executeInBackground,
|
|
63
|
+
});
|
|
64
|
+
},
|
|
79
65
|
onMutate: () => {
|
|
80
66
|
console.log('Execution started.', routeId);
|
|
81
67
|
if (routeExecution) {
|
|
@@ -83,26 +69,26 @@ export const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchan
|
|
|
83
69
|
}
|
|
84
70
|
},
|
|
85
71
|
});
|
|
86
|
-
const resumeRouteMutation = useMutation(
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
72
|
+
const resumeRouteMutation = useMutation({
|
|
73
|
+
mutationFn: (resumedRoute) => {
|
|
74
|
+
if (!account.isConnected) {
|
|
75
|
+
throw Error('Account is not connected.');
|
|
76
|
+
}
|
|
77
|
+
if (!routeExecution?.route) {
|
|
78
|
+
throw Error('Execution route not found.');
|
|
79
|
+
}
|
|
80
|
+
return resumeRoute(resumedRoute ?? routeExecution.route, {
|
|
81
|
+
updateRouteHook,
|
|
82
|
+
acceptExchangeRateUpdateHook,
|
|
83
|
+
infiniteApproval: false,
|
|
84
|
+
executeInBackground,
|
|
85
|
+
});
|
|
86
|
+
},
|
|
101
87
|
onMutate: () => {
|
|
102
88
|
console.log('Resumed to execution.', routeId);
|
|
103
89
|
},
|
|
104
90
|
});
|
|
105
|
-
const
|
|
91
|
+
const _executeRoute = useCallback(() => {
|
|
106
92
|
executeRouteMutation.mutateAsync(undefined, {
|
|
107
93
|
onError: (error) => {
|
|
108
94
|
console.warn('Execution failed!', routeId, error);
|
|
@@ -112,7 +98,7 @@ export const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchan
|
|
|
112
98
|
},
|
|
113
99
|
});
|
|
114
100
|
}, [executeRouteMutation, routeId]);
|
|
115
|
-
const
|
|
101
|
+
const _resumeRoute = useCallback((route) => {
|
|
116
102
|
resumeRouteMutation.mutateAsync(route, {
|
|
117
103
|
onError: (error) => {
|
|
118
104
|
console.warn('Resumed execution failed.', routeId, error);
|
|
@@ -124,9 +110,9 @@ export const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchan
|
|
|
124
110
|
}, [resumeRouteMutation, routeId]);
|
|
125
111
|
const restartRouteMutation = useCallback(() => {
|
|
126
112
|
restartRoute(routeId);
|
|
127
|
-
|
|
113
|
+
_resumeRoute(routeExecution?.route);
|
|
128
114
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
129
|
-
}, [
|
|
115
|
+
}, [_resumeRoute, routeExecution?.route, routeId]);
|
|
130
116
|
const deleteRouteMutation = useCallback(() => {
|
|
131
117
|
deleteRoute(routeId);
|
|
132
118
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -135,26 +121,26 @@ export const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchan
|
|
|
135
121
|
useEffect(() => {
|
|
136
122
|
// Check if route is eligible for automatic resuming
|
|
137
123
|
if (isRouteActive(routeExecution?.route) &&
|
|
138
|
-
account.
|
|
124
|
+
account.isConnected &&
|
|
139
125
|
!resumedAfterMount.current) {
|
|
140
126
|
resumedAfterMount.current = true;
|
|
141
|
-
|
|
127
|
+
_resumeRoute();
|
|
142
128
|
}
|
|
143
129
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
144
|
-
}, [account.
|
|
130
|
+
}, [account.isConnected]);
|
|
145
131
|
useEffect(() => {
|
|
146
132
|
return () => {
|
|
147
133
|
const route = routeExecutionStoreContext.getState().routes[routeId]?.route;
|
|
148
134
|
if (!route || !isRouteActive(route)) {
|
|
149
135
|
return;
|
|
150
136
|
}
|
|
151
|
-
|
|
137
|
+
updateRouteExecution(route, { executeInBackground: true });
|
|
152
138
|
console.log('Move route execution to background.', routeId);
|
|
153
139
|
resumedAfterMount.current = false;
|
|
154
140
|
};
|
|
155
|
-
}, [
|
|
141
|
+
}, [routeExecutionStoreContext, routeId]);
|
|
156
142
|
return {
|
|
157
|
-
executeRoute,
|
|
143
|
+
executeRoute: _executeRoute,
|
|
158
144
|
restartRoute: restartRouteMutation,
|
|
159
145
|
deleteRoute: deleteRouteMutation,
|
|
160
146
|
route: routeExecution?.route,
|
package/hooks/useRoutes.d.ts
CHANGED
|
@@ -9,6 +9,6 @@ export declare const useRoutes: ({ insurableRoute }?: RoutesProps) => {
|
|
|
9
9
|
isFetched: boolean;
|
|
10
10
|
dataUpdatedAt: number;
|
|
11
11
|
refetchTime: number;
|
|
12
|
-
refetch:
|
|
12
|
+
refetch: (options?: import("@tanstack/query-core/build/legacy/queryClient-IoYjXsnV").Z | undefined) => Promise<import("@tanstack/query-core/build/legacy/queryClient-IoYjXsnV").ac<RoutesResponse, Error>>;
|
|
13
13
|
};
|
|
14
14
|
export {};
|