@lifi/widget 3.40.11 → 4.0.0-alpha.2
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/dist/esm/AppDefault.d.ts +8 -0
- package/dist/esm/AppDefault.js +231 -14
- package/dist/esm/AppDefault.js.map +1 -1
- package/dist/esm/AppLayout.d.ts +1 -0
- package/dist/esm/AppLayout.js +19 -0
- package/dist/esm/AppLayout.js.map +1 -0
- package/dist/esm/AppProvider.js +7 -20
- package/dist/esm/AppProvider.js.map +1 -1
- package/dist/esm/components/ActiveTransactions/ActiveTransactionItem.js +9 -6
- package/dist/esm/components/ActiveTransactions/ActiveTransactionItem.js.map +1 -1
- package/dist/esm/components/ActiveTransactions/ActiveTransactions.js +2 -2
- package/dist/esm/components/ActiveTransactions/ActiveTransactions.js.map +1 -1
- package/dist/esm/components/ActiveTransactions/ActiveTransactions.style.d.ts +2 -2
- package/dist/esm/components/AmountInput/AmountInput.js +5 -7
- package/dist/esm/components/AmountInput/AmountInput.js.map +1 -1
- package/dist/esm/components/AmountInput/AmountInput.style.d.ts +2 -2
- package/dist/esm/components/AmountInput/AmountInputAdornment.style.d.ts +1 -1
- package/dist/esm/components/AmountInput/AmountInputEndAdornment.js +1 -1
- package/dist/esm/components/AmountInput/AmountInputEndAdornment.js.map +1 -1
- package/dist/esm/components/AmountInput/PriceFormHelperText.style.d.ts +1 -1
- package/dist/esm/components/AppContainer.d.ts +1 -1
- package/dist/esm/components/Avatar/AccountAvatar.d.ts +1 -1
- package/dist/esm/components/Avatar/AccountAvatar.js.map +1 -1
- package/dist/esm/components/Avatar/Avatar.style.d.ts +1 -1
- package/dist/esm/components/Avatar/SmallAvatar.d.ts +1 -1
- package/dist/esm/components/ButtonTertiary.d.ts +1 -1
- package/dist/esm/components/Card/Card.d.ts +1 -1
- package/dist/esm/components/Card/CardButton.style.d.ts +2 -2
- package/dist/esm/components/Card/CardHeader.d.ts +1 -1
- package/dist/esm/components/Card/CardIconButton.d.ts +3 -3
- package/dist/esm/components/Card/CardLabel.d.ts +1 -1
- package/dist/esm/components/Card/CardTitle.d.ts +1 -1
- package/dist/esm/components/Card/InputCard.d.ts +1 -1
- package/dist/esm/components/ChainSelect/ChainSelect.js +8 -3
- package/dist/esm/components/ChainSelect/ChainSelect.js.map +1 -1
- package/dist/esm/components/ChainSelect/ChainSelect.style.d.ts +3 -3
- package/dist/esm/components/Chains/ChainList.style.d.ts +4 -4
- package/dist/esm/components/Chains/VirtualizedChainList.d.ts +1 -1
- package/dist/esm/components/Chains/VirtualizedChainList.js +7 -1
- package/dist/esm/components/Chains/VirtualizedChainList.js.map +1 -1
- package/dist/esm/components/ContractComponent/ItemPrice.d.ts +1 -1
- package/dist/esm/components/ContractComponent/ItemPrice.js +1 -1
- package/dist/esm/components/ContractComponent/ItemPrice.js.map +1 -1
- package/dist/esm/components/ContractComponent/NFT/NFT.js +1 -1
- package/dist/esm/components/ContractComponent/NFT/NFT.js.map +1 -1
- package/dist/esm/components/ContractComponent/NFT/NFT.style.d.ts +1 -1
- package/dist/esm/components/Header/BackButton.d.ts +1 -2
- package/dist/esm/components/Header/BackButton.js +16 -2
- package/dist/esm/components/Header/BackButton.js.map +1 -1
- package/dist/esm/components/Header/DisconnectIconButton.d.ts +1 -1
- package/dist/esm/components/Header/DisconnectIconButton.js.map +1 -1
- package/dist/esm/components/Header/Header.js +1 -1
- package/dist/esm/components/Header/Header.js.map +1 -1
- package/dist/esm/components/Header/Header.style.d.ts +3 -3
- package/dist/esm/components/Header/NavigationHeader.js +7 -13
- package/dist/esm/components/Header/NavigationHeader.js.map +1 -1
- package/dist/esm/components/Header/SettingsButton.js +3 -3
- package/dist/esm/components/Header/SettingsButton.js.map +1 -1
- package/dist/esm/components/Header/SettingsButton.style.d.ts +2 -2
- package/dist/esm/components/Header/TransactionHistoryButton.js +3 -3
- package/dist/esm/components/Header/TransactionHistoryButton.js.map +1 -1
- package/dist/esm/components/Header/WalletHeader.js.map +1 -1
- package/dist/esm/components/ListItem/ListItem.d.ts +1 -1
- package/dist/esm/components/ListItem/ListItemButton.d.ts +1 -1
- package/dist/esm/components/ListItemButton.d.ts +1 -1
- package/dist/esm/components/Messages/GasSufficiencyMessage.js +1 -1
- package/dist/esm/components/Messages/GasSufficiencyMessage.js.map +1 -1
- package/dist/esm/components/PageContainer.d.ts +1 -1
- package/dist/esm/components/PageEntered.js +1 -1
- package/dist/esm/components/PageEntered.js.map +1 -1
- package/dist/esm/components/PoweredBy/PoweredBy.style.d.ts +1 -1
- package/dist/esm/components/ReverseTokensButton/ReverseTokensButton.js +0 -9
- package/dist/esm/components/ReverseTokensButton/ReverseTokensButton.js.map +1 -1
- package/dist/esm/components/ReverseTokensButton/ReverseTokensButton.style.d.ts +1 -1
- package/dist/esm/components/RouteCard/RouteCard.js +1 -3
- package/dist/esm/components/RouteCard/RouteCard.js.map +1 -1
- package/dist/esm/components/Routes/Routes.js +3 -4
- package/dist/esm/components/Routes/Routes.js.map +1 -1
- package/dist/esm/components/Routes/RoutesContent.js +1 -2
- package/dist/esm/components/Routes/RoutesContent.js.map +1 -1
- package/dist/esm/components/Routes/RoutesExpanded.js +4 -3
- package/dist/esm/components/Routes/RoutesExpanded.js.map +1 -1
- package/dist/esm/components/Routes/RoutesExpanded.style.d.ts +1 -1
- package/dist/esm/components/Search/SearchInput.style.d.ts +1 -1
- package/dist/esm/components/Search/SearchNotFound.style.d.ts +2 -2
- package/dist/esm/components/SelectChainAndToken.js +2 -3
- package/dist/esm/components/SelectChainAndToken.js.map +1 -1
- package/dist/esm/components/SelectTokenButton/SelectTokenButton.js +10 -10
- package/dist/esm/components/SelectTokenButton/SelectTokenButton.js.map +1 -1
- package/dist/esm/components/SelectTokenButton/SelectTokenButton.style.d.ts +3 -3
- package/dist/esm/components/SendToWallet/SendToWallet.style.d.ts +1 -1
- package/dist/esm/components/SendToWallet/SendToWalletButton.js +10 -8
- package/dist/esm/components/SendToWallet/SendToWalletButton.js.map +1 -1
- package/dist/esm/components/SettingsListItemButton.d.ts +1 -1
- package/dist/esm/components/Skeleton/WidgetSkeleton.style.d.ts +4 -4
- package/dist/esm/components/Step/CircularProgress.d.ts +3 -3
- package/dist/esm/components/Step/CircularProgress.js +8 -8
- package/dist/esm/components/Step/CircularProgress.js.map +1 -1
- package/dist/esm/components/Step/CircularProgress.style.d.ts +2 -2
- package/dist/esm/components/Step/CircularProgress.style.js.map +1 -1
- package/dist/esm/components/Step/Step.js +8 -11
- package/dist/esm/components/Step/Step.js.map +1 -1
- package/dist/esm/components/Step/StepAction.d.ts +5 -0
- package/dist/esm/components/Step/{StepProcess.js → StepAction.js} +16 -12
- package/dist/esm/components/Step/StepAction.js.map +1 -0
- package/dist/esm/components/StepActions/StepActions.js +3 -2
- package/dist/esm/components/StepActions/StepActions.js.map +1 -1
- package/dist/esm/components/StepActions/StepActions.style.d.ts +2 -2
- package/dist/esm/components/StepDivider/StepDivider.style.d.ts +1 -1
- package/dist/esm/components/Tabs/NavigationTabs.d.ts +4 -4
- package/dist/esm/components/Tabs/Tabs.style.d.ts +3 -3
- package/dist/esm/components/Timer/StepTimer.js +26 -74
- package/dist/esm/components/Timer/StepTimer.js.map +1 -1
- package/dist/esm/components/Token/Token.style.d.ts +1 -1
- package/dist/esm/components/TokenList/PinTokenButton.d.ts +6 -0
- package/dist/esm/components/TokenList/PinTokenButton.js +29 -0
- package/dist/esm/components/TokenList/PinTokenButton.js.map +1 -0
- package/dist/esm/components/TokenList/TokenDetailsSheetContent.style.d.ts +2 -2
- package/dist/esm/components/TokenList/TokenList.js +13 -5
- package/dist/esm/components/TokenList/TokenList.js.map +1 -1
- package/dist/esm/components/TokenList/TokenList.style.d.ts +6 -6
- package/dist/esm/components/TokenList/TokenListItem.js +5 -4
- package/dist/esm/components/TokenList/TokenListItem.js.map +1 -1
- package/dist/esm/components/TokenList/VirtualizedTokenList.js +63 -38
- package/dist/esm/components/TokenList/VirtualizedTokenList.js.map +1 -1
- package/dist/esm/components/TokenList/types.d.ts +2 -3
- package/dist/esm/components/TokenList/useTokenSelect.js +2 -3
- package/dist/esm/components/TokenList/useTokenSelect.js.map +1 -1
- package/dist/esm/components/TokenRate/TokenRate.d.ts +1 -1
- package/dist/esm/components/TokenRate/TokenRate.js +1 -1
- package/dist/esm/components/TokenRate/TokenRate.js.map +1 -1
- package/dist/esm/components/TokenRate/TokenRate.style.d.ts +1 -1
- package/dist/esm/components/TransactionDetails.js +3 -2
- package/dist/esm/components/TransactionDetails.js.map +1 -1
- package/dist/esm/config/version.d.ts +1 -1
- package/dist/esm/config/version.js +1 -1
- package/dist/esm/config/version.js.map +1 -1
- package/dist/esm/hooks/useActionMessage.d.ts +5 -0
- package/dist/esm/hooks/useActionMessage.js +18 -0
- package/dist/esm/hooks/useActionMessage.js.map +1 -0
- package/dist/esm/hooks/useAddressActivity.js +18 -9
- package/dist/esm/hooks/useAddressActivity.js.map +1 -1
- package/dist/esm/hooks/useAddressValidation.js +5 -2
- package/dist/esm/hooks/useAddressValidation.js.map +1 -1
- package/dist/esm/hooks/useAvailableChains.d.ts +2 -1
- package/dist/esm/hooks/useAvailableChains.js +32 -11
- package/dist/esm/hooks/useAvailableChains.js.map +1 -1
- package/dist/esm/hooks/useExplorer.js +1 -2
- package/dist/esm/hooks/useExplorer.js.map +1 -1
- package/dist/esm/hooks/useFilteredByTokenBalances.js +3 -1
- package/dist/esm/hooks/useFilteredByTokenBalances.js.map +1 -1
- package/dist/esm/hooks/useFromTokenSufficiency.d.ts +1 -1
- package/dist/esm/hooks/useFromTokenSufficiency.js +4 -4
- package/dist/esm/hooks/useFromTokenSufficiency.js.map +1 -1
- package/dist/esm/hooks/useGasRecommendation.js +3 -1
- package/dist/esm/hooks/useGasRecommendation.js.map +1 -1
- package/dist/esm/hooks/useGasSufficiency.js +21 -15
- package/dist/esm/hooks/useGasSufficiency.js.map +1 -1
- package/dist/esm/hooks/useHasChainExpansion.d.ts +1 -1
- package/dist/esm/hooks/useHasChainExpansion.js +11 -3
- package/dist/esm/hooks/useHasChainExpansion.js.map +1 -1
- package/dist/esm/hooks/useInitializeSDKProviders.d.ts +1 -0
- package/dist/esm/hooks/useInitializeSDKProviders.js +11 -0
- package/dist/esm/hooks/useInitializeSDKProviders.js.map +1 -0
- package/dist/esm/hooks/useIsBatchingSupported.js +7 -3
- package/dist/esm/hooks/useIsBatchingSupported.js.map +1 -1
- package/dist/esm/hooks/useIsContractAddress.js +12 -9
- package/dist/esm/hooks/useIsContractAddress.js.map +1 -1
- package/dist/esm/hooks/useNavigateBack.d.ts +1 -4
- package/dist/esm/hooks/useNavigateBack.js +9 -23
- package/dist/esm/hooks/useNavigateBack.js.map +1 -1
- package/dist/esm/hooks/useRouteExecution.js +12 -13
- package/dist/esm/hooks/useRouteExecution.js.map +1 -1
- package/dist/esm/hooks/useRoutes.js +23 -60
- package/dist/esm/hooks/useRoutes.js.map +1 -1
- package/dist/esm/hooks/useToAddressAutoPopulate.js +3 -1
- package/dist/esm/hooks/useToAddressAutoPopulate.js.map +1 -1
- package/dist/esm/hooks/useToAddressRequirements.js +3 -2
- package/dist/esm/hooks/useToAddressRequirements.js.map +1 -1
- package/dist/esm/hooks/useTokenBalance.d.ts +3 -3
- package/dist/esm/hooks/useTokenBalance.js +8 -6
- package/dist/esm/hooks/useTokenBalance.js.map +1 -1
- package/dist/esm/hooks/useTokenBalances.d.ts +1 -0
- package/dist/esm/hooks/useTokenBalances.js +70 -5
- package/dist/esm/hooks/useTokenBalances.js.map +1 -1
- package/dist/esm/hooks/useTokenBalancesQueries.js +4 -2
- package/dist/esm/hooks/useTokenBalancesQueries.js.map +1 -1
- package/dist/esm/hooks/useTokenSearch.js +3 -1
- package/dist/esm/hooks/useTokenSearch.js.map +1 -1
- package/dist/esm/hooks/useTokens.js +11 -5
- package/dist/esm/hooks/useTokens.js.map +1 -1
- package/dist/esm/hooks/useTools.js +3 -1
- package/dist/esm/hooks/useTools.js.map +1 -1
- package/dist/esm/hooks/useTransactionDetails.js +3 -1
- package/dist/esm/hooks/useTransactionDetails.js.map +1 -1
- package/dist/esm/hooks/useTransactionHistory.js +3 -1
- package/dist/esm/hooks/useTransactionHistory.js.map +1 -1
- package/dist/esm/hooks/useWidgetChains.d.ts +6 -0
- package/dist/esm/hooks/useWidgetChains.js +5 -0
- package/dist/esm/hooks/useWidgetChains.js.map +1 -0
- package/dist/esm/i18n/bn.json +4 -1
- package/dist/esm/i18n/de.json +4 -1
- package/dist/esm/i18n/en.json +3 -14
- package/dist/esm/i18n/es.json +4 -1
- package/dist/esm/i18n/fr.json +4 -1
- package/dist/esm/i18n/hi.json +4 -1
- package/dist/esm/i18n/id.json +4 -1
- package/dist/esm/i18n/it.json +4 -1
- package/dist/esm/i18n/ja.json +4 -1
- package/dist/esm/i18n/ko.json +4 -1
- package/dist/esm/i18n/pl.json +4 -1
- package/dist/esm/i18n/pt.json +4 -1
- package/dist/esm/i18n/th.json +4 -1
- package/dist/esm/i18n/tr.json +4 -1
- package/dist/esm/i18n/uk.json +4 -1
- package/dist/esm/i18n/vi.json +4 -1
- package/dist/esm/i18n/zh.json +4 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/pages/LanguagesPage.js +7 -6
- package/dist/esm/pages/LanguagesPage.js.map +1 -1
- package/dist/esm/pages/MainPage/MainPage.js +1 -3
- package/dist/esm/pages/MainPage/MainPage.js.map +1 -1
- package/dist/esm/pages/MainPage/ReviewButton.js +5 -5
- package/dist/esm/pages/MainPage/ReviewButton.js.map +1 -1
- package/dist/esm/pages/RoutesPage/RoutesPage.d.ts +1 -2
- package/dist/esm/pages/RoutesPage/RoutesPage.js +5 -4
- package/dist/esm/pages/RoutesPage/RoutesPage.js.map +1 -1
- package/dist/esm/pages/SelectChainPage/SelectChainPage.js +1 -1
- package/dist/esm/pages/SelectChainPage/SelectChainPage.js.map +1 -1
- package/dist/esm/pages/SelectTokenPage/SelectTokenPage.js +2 -13
- package/dist/esm/pages/SelectTokenPage/SelectTokenPage.js.map +1 -1
- package/dist/esm/pages/SendToWallet/BookmarksPage.js +3 -5
- package/dist/esm/pages/SendToWallet/BookmarksPage.js.map +1 -1
- package/dist/esm/pages/SendToWallet/ConfirmAddressSheet.js +1 -1
- package/dist/esm/pages/SendToWallet/ConfirmAddressSheet.js.map +1 -1
- package/dist/esm/pages/SendToWallet/ConnectedWalletsPage.js +4 -3
- package/dist/esm/pages/SendToWallet/ConnectedWalletsPage.js.map +1 -1
- package/dist/esm/pages/SendToWallet/RecentWalletsPage.js +4 -7
- package/dist/esm/pages/SendToWallet/RecentWalletsPage.js.map +1 -1
- package/dist/esm/pages/SendToWallet/SendToConfiguredWalletPage.js +1 -1
- package/dist/esm/pages/SendToWallet/SendToConfiguredWalletPage.js.map +1 -1
- package/dist/esm/pages/SendToWallet/SendToWalletPage.d.ts +1 -1
- package/dist/esm/pages/SendToWallet/SendToWalletPage.js +5 -5
- package/dist/esm/pages/SendToWallet/SendToWalletPage.js.map +1 -1
- package/dist/esm/pages/SendToWallet/SendToWalletPage.style.d.ts +8 -8
- package/dist/esm/pages/SettingsPage/BridgeAndExchangeSettings.js +4 -2
- package/dist/esm/pages/SettingsPage/BridgeAndExchangeSettings.js.map +1 -1
- package/dist/esm/pages/SettingsPage/LanguageSetting.js +2 -2
- package/dist/esm/pages/SettingsPage/LanguageSetting.js.map +1 -1
- package/dist/esm/pages/SettingsPage/SettingsCard/SettingCard.style.d.ts +1 -1
- package/dist/esm/pages/SettingsPage/SettingsCard/SettingCardExpandable.d.ts +12 -2
- package/dist/esm/pages/SettingsPage/SettingsCard/SettingCardExpandable.js +10 -4
- package/dist/esm/pages/SettingsPage/SettingsCard/SettingCardExpandable.js.map +1 -1
- package/dist/esm/pages/SettingsPage/SettingsCard/SettingsAccordian.d.ts +1 -1
- package/dist/esm/pages/SettingsPage/SettingsCard/SettingsAccordian.js +2 -2
- package/dist/esm/pages/SettingsPage/SettingsCard/SettingsAccordian.js.map +1 -1
- package/dist/esm/pages/SettingsPage/SettingsPage.js +5 -1
- package/dist/esm/pages/SettingsPage/SettingsPage.js.map +1 -1
- package/dist/esm/pages/SettingsPage/SlippageSettings/SlippageSettings.js +3 -3
- package/dist/esm/pages/SettingsPage/SlippageSettings/SlippageSettings.js.map +1 -1
- package/dist/esm/pages/SettingsPage/SlippageSettings/SlippageSettings.style.d.ts +3 -3
- package/dist/esm/pages/SettingsPage/SlippageSettings/SlippageSettings.style.js +9 -9
- package/dist/esm/pages/SettingsPage/SmallBalanceFilterSettings.d.ts +1 -0
- package/dist/esm/pages/SettingsPage/SmallBalanceFilterSettings.js +58 -0
- package/dist/esm/pages/SettingsPage/SmallBalanceFilterSettings.js.map +1 -0
- package/dist/esm/pages/TransactionDetailsPage/TransactionDetailsPage.js +7 -8
- package/dist/esm/pages/TransactionDetailsPage/TransactionDetailsPage.js.map +1 -1
- package/dist/esm/pages/TransactionHistoryPage/TransactionHistoryItem.js +4 -3
- package/dist/esm/pages/TransactionHistoryPage/TransactionHistoryItem.js.map +1 -1
- package/dist/esm/pages/TransactionHistoryPage/TransactionHistoryPage.d.ts +1 -2
- package/dist/esm/pages/TransactionHistoryPage/TransactionHistoryPage.js.map +1 -1
- package/dist/esm/pages/TransactionPage/StatusBottomSheet.js +13 -12
- package/dist/esm/pages/TransactionPage/StatusBottomSheet.js.map +1 -1
- package/dist/esm/pages/TransactionPage/TransactionPage.d.ts +1 -1
- package/dist/esm/pages/TransactionPage/TransactionPage.js +13 -6
- package/dist/esm/pages/TransactionPage/TransactionPage.js.map +1 -1
- package/dist/esm/providers/I18nProvider/I18nProvider.js +1 -0
- package/dist/esm/providers/I18nProvider/I18nProvider.js.map +1 -1
- package/dist/esm/providers/SDKClientProvider.d.ts +4 -0
- package/dist/esm/providers/SDKClientProvider.js +29 -0
- package/dist/esm/providers/SDKClientProvider.js.map +1 -0
- package/dist/esm/providers/WalletProvider/WalletProvider.d.ts +7 -2
- package/dist/esm/providers/WalletProvider/WalletProvider.js +27 -11
- package/dist/esm/providers/WalletProvider/WalletProvider.js.map +1 -1
- package/dist/esm/providers/WalletProvider/useExternalWalletProvider.js +15 -18
- package/dist/esm/providers/WalletProvider/useExternalWalletProvider.js.map +1 -1
- package/dist/esm/providers/WidgetProvider/WidgetProvider.js +0 -27
- package/dist/esm/providers/WidgetProvider/WidgetProvider.js.map +1 -1
- package/dist/esm/stores/StoreProvider.js +2 -1
- package/dist/esm/stores/StoreProvider.js.map +1 -1
- package/dist/esm/stores/bookmarks/types.d.ts +2 -3
- package/dist/esm/stores/chains/ChainOrderStore.js +17 -12
- package/dist/esm/stores/chains/ChainOrderStore.js.map +1 -1
- package/dist/esm/stores/chains/createChainOrderStore.d.ts +0 -8
- package/dist/esm/stores/chains/createChainOrderStore.js +1 -5
- package/dist/esm/stores/chains/createChainOrderStore.js.map +1 -1
- package/dist/esm/stores/form/FormStore.js +18 -8
- package/dist/esm/stores/form/FormStore.js.map +1 -1
- package/dist/esm/stores/form/FormUpdater.js +5 -50
- package/dist/esm/stores/form/FormUpdater.js.map +1 -1
- package/dist/esm/stores/form/URLSearchParamsBuilder.js +11 -31
- package/dist/esm/stores/form/URLSearchParamsBuilder.js.map +1 -1
- package/dist/esm/stores/form/getDefaultValuesFromQueryString.d.ts +7 -0
- package/dist/esm/stores/form/getDefaultValuesFromQueryString.js +32 -0
- package/dist/esm/stores/form/getDefaultValuesFromQueryString.js.map +1 -0
- package/dist/esm/stores/form/types.d.ts +2 -3
- package/dist/esm/stores/form/types.js.map +1 -1
- package/dist/esm/stores/header/types.d.ts +5 -3
- package/dist/esm/stores/header/useHeaderStore.js +14 -0
- package/dist/esm/stores/header/useHeaderStore.js.map +1 -1
- package/dist/esm/stores/pinnedTokens/PinnedTokensStore.d.ts +4 -0
- package/dist/esm/stores/pinnedTokens/PinnedTokensStore.js +20 -0
- package/dist/esm/stores/pinnedTokens/PinnedTokensStore.js.map +1 -0
- package/dist/esm/stores/pinnedTokens/createPinnedTokensStore.d.ts +19 -0
- package/dist/esm/stores/pinnedTokens/createPinnedTokensStore.js +61 -0
- package/dist/esm/stores/pinnedTokens/createPinnedTokensStore.js.map +1 -0
- package/dist/esm/stores/pinnedTokens/types.d.ts +17 -0
- package/dist/esm/stores/pinnedTokens/types.js +2 -0
- package/dist/esm/stores/pinnedTokens/types.js.map +1 -0
- package/dist/esm/stores/routes/RouteExecutionStore.d.ts +2 -3
- package/dist/esm/stores/routes/RouteExecutionStore.js.map +1 -1
- package/dist/esm/stores/routes/createRouteExecutionStore.js +2 -5
- package/dist/esm/stores/routes/createRouteExecutionStore.js.map +1 -1
- package/dist/esm/stores/routes/useExecutingRoutesIds.js +2 -2
- package/dist/esm/stores/routes/useExecutingRoutesIds.js.map +1 -1
- package/dist/esm/stores/routes/utils.d.ts +2 -2
- package/dist/esm/stores/routes/utils.js +15 -15
- package/dist/esm/stores/routes/utils.js.map +1 -1
- package/dist/esm/stores/settings/SettingsStore.d.ts +2 -3
- package/dist/esm/stores/settings/SettingsStore.js.map +1 -1
- package/dist/esm/stores/settings/createSettingsStore.d.ts +2 -0
- package/dist/esm/stores/settings/createSettingsStore.js +2 -1
- package/dist/esm/stores/settings/createSettingsStore.js.map +1 -1
- package/dist/esm/stores/settings/types.d.ts +3 -3
- package/dist/esm/stores/settings/types.js.map +1 -1
- package/dist/esm/types/events.d.ts +2 -10
- package/dist/esm/types/events.js +0 -1
- package/dist/esm/types/events.js.map +1 -1
- package/dist/esm/types/token.d.ts +1 -0
- package/dist/esm/types/widget.d.ts +9 -16
- package/dist/esm/types/widget.js +1 -0
- package/dist/esm/types/widget.js.map +1 -1
- package/dist/esm/utils/chainType.d.ts +1 -2
- package/dist/esm/utils/chainType.js +1 -19
- package/dist/esm/utils/chainType.js.map +1 -1
- package/dist/esm/utils/converters.js +11 -18
- package/dist/esm/utils/converters.js.map +1 -1
- package/dist/esm/utils/format.d.ts +1 -0
- package/dist/esm/utils/format.js +2 -1
- package/dist/esm/utils/format.js.map +1 -1
- package/dist/esm/utils/getActionMessage.d.ts +7 -0
- package/dist/esm/utils/getActionMessage.js +111 -0
- package/dist/esm/utils/getActionMessage.js.map +1 -0
- package/dist/esm/utils/getErrorMessage.d.ts +6 -0
- package/dist/esm/utils/getErrorMessage.js +118 -0
- package/dist/esm/utils/getErrorMessage.js.map +1 -0
- package/dist/esm/utils/prepareActions.d.ts +2 -0
- package/dist/esm/utils/prepareActions.js +24 -0
- package/dist/esm/utils/prepareActions.js.map +1 -0
- package/dist/esm/utils/tokenList.d.ts +3 -2
- package/dist/esm/utils/tokenList.js +104 -8
- package/dist/esm/utils/tokenList.js.map +1 -1
- package/package.json +30 -23
- package/src/AppDefault.tsx +279 -31
- package/src/AppLayout.tsx +36 -0
- package/src/AppProvider.tsx +12 -40
- package/src/components/ActiveTransactions/ActiveTransactionItem.tsx +9 -6
- package/src/components/ActiveTransactions/ActiveTransactions.tsx +2 -2
- package/src/components/AmountInput/AmountInput.tsx +6 -8
- package/src/components/AmountInput/AmountInputEndAdornment.tsx +1 -1
- package/src/components/Avatar/AccountAvatar.tsx +1 -1
- package/src/components/ChainSelect/ChainSelect.tsx +8 -4
- package/src/components/Chains/VirtualizedChainList.tsx +7 -3
- package/src/components/ContractComponent/ItemPrice.tsx +1 -2
- package/src/components/ContractComponent/NFT/NFT.tsx +1 -1
- package/src/components/Header/BackButton.tsx +15 -3
- package/src/components/Header/DisconnectIconButton.tsx +2 -1
- package/src/components/Header/Header.tsx +1 -1
- package/src/components/Header/NavigationHeader.tsx +23 -46
- package/src/components/Header/SettingsButton.tsx +3 -3
- package/src/components/Header/TransactionHistoryButton.tsx +3 -3
- package/src/components/Header/WalletHeader.tsx +1 -1
- package/src/components/Messages/GasSufficiencyMessage.tsx +1 -1
- package/src/components/PageEntered.ts +1 -1
- package/src/components/ReverseTokensButton/ReverseTokensButton.tsx +0 -10
- package/src/components/RouteCard/RouteCard.tsx +1 -3
- package/src/components/Routes/Routes.tsx +3 -4
- package/src/components/Routes/RoutesContent.tsx +1 -2
- package/src/components/Routes/RoutesExpanded.tsx +4 -3
- package/src/components/SelectChainAndToken.tsx +2 -4
- package/src/components/SelectTokenButton/SelectTokenButton.tsx +11 -13
- package/src/components/SendToWallet/SendToWalletButton.tsx +9 -12
- package/src/components/Step/CircularProgress.style.tsx +3 -3
- package/src/components/Step/CircularProgress.tsx +11 -11
- package/src/components/Step/Step.tsx +13 -14
- package/src/components/Step/{StepProcess.tsx → StepAction.tsx} +20 -15
- package/src/components/StepActions/StepActions.tsx +3 -2
- package/src/components/Timer/StepTimer.tsx +43 -105
- package/src/components/TokenList/PinTokenButton.tsx +50 -0
- package/src/components/TokenList/TokenList.tsx +67 -59
- package/src/components/TokenList/TokenListItem.tsx +20 -11
- package/src/components/TokenList/VirtualizedTokenList.tsx +80 -53
- package/src/components/TokenList/types.ts +2 -3
- package/src/components/TokenList/useTokenSelect.ts +2 -8
- package/src/components/TokenRate/TokenRate.tsx +1 -2
- package/src/components/TransactionDetails.tsx +3 -2
- package/src/config/version.ts +1 -1
- package/src/hooks/useActionMessage.ts +33 -0
- package/src/hooks/useAddressActivity.ts +19 -11
- package/src/hooks/useAddressValidation.ts +9 -2
- package/src/hooks/useAvailableChains.ts +42 -14
- package/src/hooks/useExplorer.ts +1 -2
- package/src/hooks/useFilteredByTokenBalances.ts +3 -1
- package/src/hooks/useFromTokenSufficiency.ts +8 -5
- package/src/hooks/useGasRecommendation.ts +3 -0
- package/src/hooks/useGasSufficiency.ts +23 -13
- package/src/hooks/useHasChainExpansion.ts +13 -3
- package/src/hooks/useInitializeSDKProviders.ts +12 -0
- package/src/hooks/useIsBatchingSupported.ts +11 -5
- package/src/hooks/useIsContractAddress.ts +14 -10
- package/src/hooks/useNavigateBack.ts +11 -29
- package/src/hooks/useRouteExecution.ts +12 -16
- package/src/hooks/useRoutes.ts +26 -74
- package/src/hooks/useToAddressAutoPopulate.ts +3 -1
- package/src/hooks/useToAddressRequirements.ts +3 -2
- package/src/hooks/useTokenBalance.ts +18 -3
- package/src/hooks/useTokenBalances.ts +91 -5
- package/src/hooks/useTokenBalancesQueries.ts +4 -2
- package/src/hooks/useTokenSearch.ts +10 -3
- package/src/hooks/useTokens.ts +11 -6
- package/src/hooks/useTools.ts +3 -1
- package/src/hooks/useTransactionDetails.ts +3 -0
- package/src/hooks/useTransactionHistory.ts +3 -0
- package/src/hooks/useWidgetChains.ts +6 -0
- package/src/index.ts +2 -8
- package/src/pages/LanguagesPage.tsx +2 -1
- package/src/pages/MainPage/MainPage.tsx +1 -3
- package/src/pages/MainPage/ReviewButton.tsx +5 -5
- package/src/pages/RoutesPage/RoutesPage.tsx +6 -6
- package/src/pages/SelectChainPage/SelectChainPage.tsx +1 -1
- package/src/pages/SelectTokenPage/SelectTokenPage.tsx +4 -28
- package/src/pages/SendToWallet/BookmarksPage.tsx +3 -5
- package/src/pages/SendToWallet/ConfirmAddressSheet.tsx +1 -1
- package/src/pages/SendToWallet/ConnectedWalletsPage.tsx +5 -4
- package/src/pages/SendToWallet/RecentWalletsPage.tsx +4 -7
- package/src/pages/SendToWallet/SendToConfiguredWalletPage.tsx +1 -1
- package/src/pages/SendToWallet/SendToWalletPage.tsx +6 -6
- package/src/pages/SettingsPage/BridgeAndExchangeSettings.tsx +4 -2
- package/src/pages/SettingsPage/LanguageSetting.tsx +2 -2
- package/src/pages/SettingsPage/SettingsCard/SettingCardExpandable.tsx +63 -33
- package/src/pages/SettingsPage/SettingsCard/SettingsAccordian.tsx +3 -2
- package/src/pages/SettingsPage/SettingsPage.tsx +7 -0
- package/src/pages/SettingsPage/SlippageSettings/SlippageSettings.style.tsx +10 -10
- package/src/pages/SettingsPage/SlippageSettings/SlippageSettings.tsx +5 -5
- package/src/pages/SettingsPage/SmallBalanceFilterSettings.tsx +116 -0
- package/src/pages/TransactionDetailsPage/TransactionDetailsPage.tsx +7 -8
- package/src/pages/TransactionHistoryPage/TransactionHistoryItem.tsx +4 -3
- package/src/pages/TransactionHistoryPage/TransactionHistoryPage.tsx +1 -2
- package/src/pages/TransactionPage/StatusBottomSheet.tsx +15 -14
- package/src/pages/TransactionPage/TransactionPage.tsx +14 -7
- package/src/providers/I18nProvider/I18nProvider.tsx +1 -0
- package/src/providers/SDKClientProvider.tsx +41 -0
- package/src/providers/WalletProvider/WalletProvider.tsx +61 -20
- package/src/providers/WalletProvider/useExternalWalletProvider.ts +20 -18
- package/src/providers/WidgetProvider/WidgetProvider.tsx +0 -29
- package/src/stores/StoreProvider.tsx +10 -7
- package/src/stores/bookmarks/types.ts +2 -3
- package/src/stores/chains/ChainOrderStore.tsx +29 -16
- package/src/stores/chains/createChainOrderStore.ts +1 -5
- package/src/stores/form/FormStore.tsx +19 -18
- package/src/stores/form/FormUpdater.tsx +5 -73
- package/src/stores/form/URLSearchParamsBuilder.tsx +12 -39
- package/src/stores/form/getDefaultValuesFromQueryString.ts +48 -0
- package/src/stores/form/types.ts +2 -5
- package/src/stores/header/types.ts +5 -3
- package/src/stores/header/useHeaderStore.tsx +14 -0
- package/src/stores/pinnedTokens/PinnedTokensStore.tsx +38 -0
- package/src/stores/pinnedTokens/createPinnedTokensStore.ts +71 -0
- package/src/stores/pinnedTokens/types.ts +20 -0
- package/src/stores/routes/RouteExecutionStore.tsx +2 -5
- package/src/stores/routes/createRouteExecutionStore.ts +4 -5
- package/src/stores/routes/useExecutingRoutesIds.ts +2 -2
- package/src/stores/routes/utils.ts +21 -19
- package/src/stores/settings/SettingsStore.tsx +2 -3
- package/src/stores/settings/createSettingsStore.ts +2 -1
- package/src/stores/settings/types.ts +3 -5
- package/src/types/events.ts +2 -11
- package/src/types/token.ts +1 -0
- package/src/types/widget.ts +18 -26
- package/src/utils/chainType.ts +1 -24
- package/src/utils/converters.ts +14 -20
- package/src/utils/format.ts +3 -1
- package/src/utils/getActionMessage.ts +168 -0
- package/src/utils/getErrorMessage.ts +144 -0
- package/src/utils/prepareActions.ts +27 -0
- package/src/utils/tokenList.ts +117 -11
- package/CHANGELOG.md +0 -2646
- package/dist/esm/AppRoutes.d.ts +0 -1
- package/dist/esm/AppRoutes.js +0 -111
- package/dist/esm/AppRoutes.js.map +0 -1
- package/dist/esm/components/Step/StepProcess.d.ts +0 -5
- package/dist/esm/components/Step/StepProcess.js.map +0 -1
- package/dist/esm/config/baseAccount.d.ts +0 -2
- package/dist/esm/config/baseAccount.js +0 -6
- package/dist/esm/config/baseAccount.js.map +0 -1
- package/dist/esm/config/coinbase.d.ts +0 -2
- package/dist/esm/config/coinbase.js +0 -6
- package/dist/esm/config/coinbase.js.map +0 -1
- package/dist/esm/config/metaMask.d.ts +0 -2
- package/dist/esm/config/metaMask.js +0 -11
- package/dist/esm/config/metaMask.js.map +0 -1
- package/dist/esm/config/walletConnect.d.ts +0 -2
- package/dist/esm/config/walletConnect.js +0 -4
- package/dist/esm/config/walletConnect.js.map +0 -1
- package/dist/esm/hooks/useExpansionRoutes.d.ts +0 -2
- package/dist/esm/hooks/useExpansionRoutes.js +0 -26
- package/dist/esm/hooks/useExpansionRoutes.js.map +0 -1
- package/dist/esm/hooks/useInternalWalletProvider.d.ts +0 -1
- package/dist/esm/hooks/useInternalWalletProvider.js +0 -6
- package/dist/esm/hooks/useInternalWalletProvider.js.map +0 -1
- package/dist/esm/hooks/useProcessMessage.d.ts +0 -11
- package/dist/esm/hooks/useProcessMessage.js +0 -199
- package/dist/esm/hooks/useProcessMessage.js.map +0 -1
- package/dist/esm/providers/WalletProvider/EVMBaseProvider.d.ts +0 -2
- package/dist/esm/providers/WalletProvider/EVMBaseProvider.js +0 -31
- package/dist/esm/providers/WalletProvider/EVMBaseProvider.js.map +0 -1
- package/dist/esm/providers/WalletProvider/EVMExternalContext.d.ts +0 -1
- package/dist/esm/providers/WalletProvider/EVMExternalContext.js +0 -3
- package/dist/esm/providers/WalletProvider/EVMExternalContext.js.map +0 -1
- package/dist/esm/providers/WalletProvider/EVMProvider.d.ts +0 -2
- package/dist/esm/providers/WalletProvider/EVMProvider.js +0 -20
- package/dist/esm/providers/WalletProvider/EVMProvider.js.map +0 -1
- package/dist/esm/providers/WalletProvider/SDKProviders.d.ts +0 -1
- package/dist/esm/providers/WalletProvider/SDKProviders.js +0 -62
- package/dist/esm/providers/WalletProvider/SDKProviders.js.map +0 -1
- package/dist/esm/providers/WalletProvider/SVMBaseProvider.d.ts +0 -2
- package/dist/esm/providers/WalletProvider/SVMBaseProvider.js +0 -27
- package/dist/esm/providers/WalletProvider/SVMBaseProvider.js.map +0 -1
- package/dist/esm/providers/WalletProvider/SVMExternalContext.d.ts +0 -1
- package/dist/esm/providers/WalletProvider/SVMExternalContext.js +0 -3
- package/dist/esm/providers/WalletProvider/SVMExternalContext.js.map +0 -1
- package/dist/esm/providers/WalletProvider/SVMProvider.d.ts +0 -2
- package/dist/esm/providers/WalletProvider/SVMProvider.js +0 -20
- package/dist/esm/providers/WalletProvider/SVMProvider.js.map +0 -1
- package/dist/esm/providers/WalletProvider/SuiBaseProvider.d.ts +0 -2
- package/dist/esm/providers/WalletProvider/SuiBaseProvider.js +0 -17
- package/dist/esm/providers/WalletProvider/SuiBaseProvider.js.map +0 -1
- package/dist/esm/providers/WalletProvider/SuiExternalContext.d.ts +0 -1
- package/dist/esm/providers/WalletProvider/SuiExternalContext.js +0 -3
- package/dist/esm/providers/WalletProvider/SuiExternalContext.js.map +0 -1
- package/dist/esm/providers/WalletProvider/SuiProvider.d.ts +0 -2
- package/dist/esm/providers/WalletProvider/SuiProvider.js +0 -20
- package/dist/esm/providers/WalletProvider/SuiProvider.js.map +0 -1
- package/dist/esm/providers/WalletProvider/UTXOBaseProvider.d.ts +0 -2
- package/dist/esm/providers/WalletProvider/UTXOBaseProvider.js +0 -18
- package/dist/esm/providers/WalletProvider/UTXOBaseProvider.js.map +0 -1
- package/dist/esm/providers/WalletProvider/UTXOExternalContext.d.ts +0 -1
- package/dist/esm/providers/WalletProvider/UTXOExternalContext.js +0 -3
- package/dist/esm/providers/WalletProvider/UTXOExternalContext.js.map +0 -1
- package/dist/esm/providers/WalletProvider/UTXOProvider.d.ts +0 -2
- package/dist/esm/providers/WalletProvider/UTXOProvider.js +0 -20
- package/dist/esm/providers/WalletProvider/UTXOProvider.js.map +0 -1
- package/package.json.tmp +0 -100
- package/src/AppRoutes.tsx +0 -112
- package/src/config/baseAccount.ts +0 -7
- package/src/config/coinbase.ts +0 -7
- package/src/config/metaMask.ts +0 -13
- package/src/config/walletConnect.ts +0 -5
- package/src/hooks/useExpansionRoutes.ts +0 -29
- package/src/hooks/useInternalWalletProvider.ts +0 -6
- package/src/hooks/useProcessMessage.ts +0 -273
- package/src/i18n/bn.json +0 -354
- package/src/i18n/de.json +0 -354
- package/src/i18n/en.json +0 -368
- package/src/i18n/es.json +0 -354
- package/src/i18n/fr.json +0 -354
- package/src/i18n/hi.json +0 -354
- package/src/i18n/id.json +0 -354
- package/src/i18n/it.json +0 -354
- package/src/i18n/ja.json +0 -354
- package/src/i18n/ko.json +0 -354
- package/src/i18n/pl.json +0 -354
- package/src/i18n/pt.json +0 -354
- package/src/i18n/th.json +0 -354
- package/src/i18n/tr.json +0 -354
- package/src/i18n/uk.json +0 -354
- package/src/i18n/vi.json +0 -354
- package/src/i18n/zh.json +0 -354
- package/src/providers/WalletProvider/EVMBaseProvider.tsx +0 -41
- package/src/providers/WalletProvider/EVMExternalContext.ts +0 -3
- package/src/providers/WalletProvider/EVMProvider.tsx +0 -28
- package/src/providers/WalletProvider/SDKProviders.tsx +0 -86
- package/src/providers/WalletProvider/SVMBaseProvider.tsx +0 -37
- package/src/providers/WalletProvider/SVMExternalContext.ts +0 -3
- package/src/providers/WalletProvider/SVMProvider.tsx +0 -29
- package/src/providers/WalletProvider/SuiBaseProvider.tsx +0 -31
- package/src/providers/WalletProvider/SuiExternalContext.ts +0 -3
- package/src/providers/WalletProvider/SuiProvider.tsx +0 -28
- package/src/providers/WalletProvider/UTXOBaseProvider.tsx +0 -29
- package/src/providers/WalletProvider/UTXOExternalContext.ts +0 -3
- package/src/providers/WalletProvider/UTXOProvider.tsx +0 -28
- package/src/utils/compactNumberFormatter.test.ts +0 -67
- package/src/utils/format.test.ts +0 -53
- package/tsconfig.json +0 -15
|
@@ -1,91 +1,24 @@
|
|
|
1
1
|
import { useAccount } from '@lifi/wallet-management'
|
|
2
2
|
import { useEffect } from 'react'
|
|
3
|
-
import { useChains } from '../../hooks/useChains.js'
|
|
4
3
|
import { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js'
|
|
5
4
|
import { useBookmarkActions } from '../../stores/bookmarks/useBookmarkActions.js'
|
|
6
5
|
import { formDefaultValues } from '../../stores/form/createFormStore.js'
|
|
7
6
|
import { useSendToWalletActions } from '../../stores/settings/useSendToWalletStore.js'
|
|
8
|
-
import { isItemAllowed } from '../../utils/item.js'
|
|
9
7
|
import type { DefaultValues } from './types.js'
|
|
10
8
|
import { useFieldActions } from './useFieldActions.js'
|
|
11
9
|
|
|
12
10
|
export const FormUpdater: React.FC<{
|
|
13
11
|
reactiveFormValues: Partial<DefaultValues>
|
|
14
12
|
}> = ({ reactiveFormValues }) => {
|
|
15
|
-
const {
|
|
16
|
-
fromChain,
|
|
17
|
-
toChain,
|
|
18
|
-
toAddress,
|
|
19
|
-
chains: configChains,
|
|
20
|
-
} = useWidgetConfig()
|
|
13
|
+
const { toAddress } = useWidgetConfig()
|
|
21
14
|
const { account } = useAccount()
|
|
22
|
-
const { chains } = useChains()
|
|
23
15
|
const { setSendToWallet } = useSendToWalletActions()
|
|
24
16
|
const { setSelectedBookmark } = useBookmarkActions()
|
|
25
|
-
const {
|
|
26
|
-
useFieldActions()
|
|
27
|
-
|
|
28
|
-
// Set wallet chain as default if no chains are provided by config and if they were not changed during widget usage
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
const fromChainAllowed =
|
|
31
|
-
account.chainId &&
|
|
32
|
-
chains?.some(
|
|
33
|
-
(chain) =>
|
|
34
|
-
chain.id === account.chainId &&
|
|
35
|
-
isItemAllowed(chain.id, configChains?.from)
|
|
36
|
-
)
|
|
37
|
-
const toChainAllowed =
|
|
38
|
-
account.chainId &&
|
|
39
|
-
chains?.some(
|
|
40
|
-
(chain) =>
|
|
41
|
-
chain.id === account.chainId &&
|
|
42
|
-
isItemAllowed(chain.id, configChains?.to)
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
if (
|
|
46
|
-
!account.isConnected ||
|
|
47
|
-
!account.chainId ||
|
|
48
|
-
(!fromChainAllowed && !toChainAllowed)
|
|
49
|
-
) {
|
|
50
|
-
return
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (
|
|
54
|
-
!fromChain &&
|
|
55
|
-
!isTouched('fromChain') &&
|
|
56
|
-
!isTouched('fromToken') &&
|
|
57
|
-
fromChainAllowed
|
|
58
|
-
) {
|
|
59
|
-
resetField('fromChain', { defaultValue: account.chainId })
|
|
60
|
-
setFieldValue('fromToken', '')
|
|
61
|
-
if (isTouched('fromAmount')) {
|
|
62
|
-
setFieldValue('fromAmount', '')
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
if (
|
|
66
|
-
!toChain &&
|
|
67
|
-
!isTouched('toChain') &&
|
|
68
|
-
!isTouched('toToken') &&
|
|
69
|
-
toChainAllowed
|
|
70
|
-
) {
|
|
71
|
-
resetField('toChain', { defaultValue: account.chainId })
|
|
72
|
-
setFieldValue('toToken', '')
|
|
73
|
-
}
|
|
74
|
-
}, [
|
|
75
|
-
account.chainId,
|
|
76
|
-
account.isConnected,
|
|
77
|
-
chains,
|
|
78
|
-
fromChain,
|
|
79
|
-
toChain,
|
|
80
|
-
isTouched,
|
|
81
|
-
resetField,
|
|
82
|
-
setFieldValue,
|
|
83
|
-
configChains?.from,
|
|
84
|
-
configChains?.to,
|
|
85
|
-
])
|
|
17
|
+
const { setUserAndDefaultValues } = useFieldActions()
|
|
86
18
|
|
|
87
|
-
//
|
|
88
|
-
//
|
|
19
|
+
// React to changes in widget config options (reactiveFormValues), updating userValues accordingly.
|
|
20
|
+
// Includes special logic for chain fields, where account.chainId is only a fallback and not a direct reactivity source.
|
|
21
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: account.chainId is used as a fallback only and does not need to be a dependency for reactivity.
|
|
89
22
|
useEffect(() => {
|
|
90
23
|
if (reactiveFormValues.toAddress) {
|
|
91
24
|
setSendToWallet(true)
|
|
@@ -98,7 +31,6 @@ export const FormUpdater: React.FC<{
|
|
|
98
31
|
accountForChainId(reactiveFormValues, account.chainId)
|
|
99
32
|
)
|
|
100
33
|
}, [
|
|
101
|
-
account.chainId,
|
|
102
34
|
toAddress,
|
|
103
35
|
reactiveFormValues,
|
|
104
36
|
setUserAndDefaultValues,
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
+
import { useLocation } from '@tanstack/react-router'
|
|
1
2
|
import { useEffect } from 'react'
|
|
2
|
-
import { useLocation } from 'react-router-dom'
|
|
3
3
|
import { useAddressValidation } from '../../hooks/useAddressValidation.js'
|
|
4
|
+
import { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js'
|
|
4
5
|
import { useSendToWalletActions } from '../../stores/settings/useSendToWalletStore.js'
|
|
5
|
-
import { formatInputAmount } from '../../utils/format.js'
|
|
6
6
|
import { useBookmarkActions } from '../bookmarks/useBookmarkActions.js'
|
|
7
|
-
import type {
|
|
7
|
+
import type { FormFieldNames } from '../form/types.js'
|
|
8
8
|
import { useFieldActions } from '../form/useFieldActions.js'
|
|
9
9
|
import { useFieldValues } from '../form/useFieldValues.js'
|
|
10
10
|
import { useTouchedFields } from '../form/useTouchedFields.js'
|
|
11
|
+
import { getDefaultValuesFromQueryString } from './getDefaultValuesFromQueryString.js'
|
|
11
12
|
|
|
12
13
|
const formValueKeys: FormFieldNames[] = [
|
|
13
14
|
'fromAmount',
|
|
@@ -18,34 +19,6 @@ const formValueKeys: FormFieldNames[] = [
|
|
|
18
19
|
'toToken',
|
|
19
20
|
]
|
|
20
21
|
|
|
21
|
-
const getDefaultValuesFromQueryString = (): Partial<DefaultValues> => {
|
|
22
|
-
const searchParams = Object.fromEntries(
|
|
23
|
-
new URLSearchParams(window?.location.search)
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
// Prevent using fromToken/toToken params if chain is not selected
|
|
27
|
-
;['from', 'to'].forEach((key) => {
|
|
28
|
-
if (searchParams[`${key}Token`] && !searchParams[`${key}Chain`]) {
|
|
29
|
-
delete searchParams[`${key}Token`]
|
|
30
|
-
}
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
return {
|
|
34
|
-
...(Number.isFinite(Number.parseInt(searchParams.fromChain, 10))
|
|
35
|
-
? { fromChain: Number.parseInt(searchParams.fromChain, 10) }
|
|
36
|
-
: {}),
|
|
37
|
-
...(Number.isFinite(Number.parseInt(searchParams.toChain, 10))
|
|
38
|
-
? { toChain: Number.parseInt(searchParams.toChain, 10) }
|
|
39
|
-
: {}),
|
|
40
|
-
...(searchParams.fromToken ? { fromToken: searchParams.fromToken } : {}),
|
|
41
|
-
...(searchParams.toToken ? { toToken: searchParams.toToken } : {}),
|
|
42
|
-
...(Number.isFinite(Number.parseFloat(searchParams.fromAmount))
|
|
43
|
-
? { fromAmount: formatInputAmount(searchParams.fromAmount) }
|
|
44
|
-
: {}),
|
|
45
|
-
...(searchParams.toAddress ? { toAddress: searchParams.toAddress } : {}),
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
22
|
export const URLSearchParamsBuilder = () => {
|
|
50
23
|
const { pathname } = useLocation()
|
|
51
24
|
const touchedFields = useTouchedFields()
|
|
@@ -53,7 +26,7 @@ export const URLSearchParamsBuilder = () => {
|
|
|
53
26
|
const { setSendToWallet } = useSendToWalletActions()
|
|
54
27
|
const { setSelectedBookmark, addRecentWallet } = useBookmarkActions()
|
|
55
28
|
const { validateAddress } = useAddressValidation()
|
|
56
|
-
|
|
29
|
+
const { buildUrl } = useWidgetConfig()
|
|
57
30
|
// Using these methods as trying to use the touchedFields and values above
|
|
58
31
|
// often has a lag that can effect the widgets initialisation sequence
|
|
59
32
|
// and accidentally cause values to be wiped from the query string
|
|
@@ -62,7 +35,8 @@ export const URLSearchParamsBuilder = () => {
|
|
|
62
35
|
|
|
63
36
|
useEffect(() => {
|
|
64
37
|
// get the initial values from the querystring
|
|
65
|
-
const formValues = getDefaultValuesFromQueryString()
|
|
38
|
+
const formValues = getDefaultValuesFromQueryString({ buildUrl })
|
|
39
|
+
const { toAddress, ...initialFormValues } = formValues
|
|
66
40
|
|
|
67
41
|
/**
|
|
68
42
|
* When URL builder is enabled and user opens a page with toAddress parameter,
|
|
@@ -71,19 +45,17 @@ export const URLSearchParamsBuilder = () => {
|
|
|
71
45
|
* same way as a manually entered and validated address.
|
|
72
46
|
*/
|
|
73
47
|
const initializeFromAddress = async () => {
|
|
74
|
-
if (
|
|
48
|
+
if (toAddress) {
|
|
75
49
|
try {
|
|
76
50
|
const validationResult = await validateAddress({
|
|
77
|
-
value:
|
|
51
|
+
value: toAddress,
|
|
78
52
|
})
|
|
79
|
-
// Check if the toAddress is still in the query string
|
|
80
|
-
// Could be modified by the user before the validation is done
|
|
81
|
-
const { toAddress } = getDefaultValuesFromQueryString()
|
|
82
53
|
if (validationResult.isValid && toAddress) {
|
|
83
54
|
const bookmark = {
|
|
84
55
|
address: validationResult.address,
|
|
85
56
|
chainType: validationResult.chainType,
|
|
86
57
|
}
|
|
58
|
+
setUserAndDefaultValues({ toAddress })
|
|
87
59
|
setSelectedBookmark(bookmark)
|
|
88
60
|
addRecentWallet(bookmark)
|
|
89
61
|
setSendToWallet(true)
|
|
@@ -94,14 +66,15 @@ export const URLSearchParamsBuilder = () => {
|
|
|
94
66
|
}
|
|
95
67
|
}
|
|
96
68
|
|
|
69
|
+
setUserAndDefaultValues(initialFormValues)
|
|
97
70
|
initializeFromAddress()
|
|
98
|
-
setUserAndDefaultValues(formValues)
|
|
99
71
|
}, [
|
|
100
72
|
setUserAndDefaultValues,
|
|
101
73
|
setSendToWallet,
|
|
102
74
|
validateAddress,
|
|
103
75
|
setSelectedBookmark,
|
|
104
76
|
addRecentWallet,
|
|
77
|
+
buildUrl,
|
|
105
78
|
])
|
|
106
79
|
|
|
107
80
|
// biome-ignore lint/correctness/useExhaustiveDependencies: run only when pathname changes
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { formatInputAmount } from '../../utils/format.js'
|
|
2
|
+
import type { DefaultValues } from './types.js'
|
|
3
|
+
|
|
4
|
+
interface GetDefaultValuesFromQueryStringOptions {
|
|
5
|
+
includeToAddress?: boolean
|
|
6
|
+
buildUrl?: boolean
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const getDefaultValuesFromQueryString = ({
|
|
10
|
+
buildUrl = false,
|
|
11
|
+
includeToAddress = true,
|
|
12
|
+
}: GetDefaultValuesFromQueryStringOptions): Partial<DefaultValues> => {
|
|
13
|
+
if (typeof window === 'undefined') {
|
|
14
|
+
return {}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (!buildUrl) {
|
|
18
|
+
return {}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const searchParams = Object.fromEntries(
|
|
22
|
+
new URLSearchParams(window.location.search)
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
// Prevent using fromToken/toToken params if chain is not selected.
|
|
26
|
+
;(['from', 'to'] as const).forEach((key) => {
|
|
27
|
+
if (searchParams[`${key}Token`] && !searchParams[`${key}Chain`]) {
|
|
28
|
+
delete searchParams[`${key}Token`]
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
...(Number.isFinite(Number.parseInt(searchParams.fromChain, 10))
|
|
34
|
+
? { fromChain: Number.parseInt(searchParams.fromChain, 10) }
|
|
35
|
+
: {}),
|
|
36
|
+
...(Number.isFinite(Number.parseInt(searchParams.toChain, 10))
|
|
37
|
+
? { toChain: Number.parseInt(searchParams.toChain, 10) }
|
|
38
|
+
: {}),
|
|
39
|
+
...(searchParams.fromToken ? { fromToken: searchParams.fromToken } : {}),
|
|
40
|
+
...(searchParams.toToken ? { toToken: searchParams.toToken } : {}),
|
|
41
|
+
...(Number.isFinite(Number.parseFloat(searchParams.fromAmount))
|
|
42
|
+
? { fromAmount: formatInputAmount(searchParams.fromAmount) }
|
|
43
|
+
: {}),
|
|
44
|
+
...(includeToAddress && searchParams.toAddress
|
|
45
|
+
? { toAddress: searchParams.toAddress }
|
|
46
|
+
: {}),
|
|
47
|
+
}
|
|
48
|
+
}
|
package/src/stores/form/types.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { ContractCall } from '@lifi/sdk'
|
|
2
|
-
import type { StoreApi } from 'zustand'
|
|
3
|
-
import type { UseBoundStoreWithEqualityFn } from 'zustand/traditional'
|
|
2
|
+
import type { StoreApi, UseBoundStore } from 'zustand'
|
|
4
3
|
|
|
5
4
|
export interface DefaultFieldValues {
|
|
6
5
|
fromChain?: number
|
|
@@ -85,9 +84,7 @@ export type FormValuesState = FormProps &
|
|
|
85
84
|
ValidationProps &
|
|
86
85
|
ValidationActions
|
|
87
86
|
|
|
88
|
-
export type FormStoreStore =
|
|
89
|
-
StoreApi<FormValuesState>
|
|
90
|
-
>
|
|
87
|
+
export type FormStoreStore = UseBoundStore<StoreApi<FormValuesState>>
|
|
91
88
|
|
|
92
89
|
export interface SetOptions {
|
|
93
90
|
isDirty?: boolean
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { StoreApi } from 'zustand'
|
|
2
|
-
import type { UseBoundStoreWithEqualityFn } from 'zustand/traditional'
|
|
1
|
+
import type { StoreApi, UseBoundStore } from 'zustand'
|
|
3
2
|
|
|
4
|
-
export type HeaderStore =
|
|
3
|
+
export type HeaderStore = UseBoundStore<StoreApi<HeaderState>>
|
|
5
4
|
|
|
6
5
|
interface HeaderStateBase {
|
|
7
6
|
element?: React.ReactNode | null
|
|
8
7
|
title?: string
|
|
9
8
|
headerHeight: number
|
|
9
|
+
backAction?: () => void
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export interface HeaderState extends HeaderStateBase {
|
|
@@ -15,4 +15,6 @@ export interface HeaderState extends HeaderStateBase {
|
|
|
15
15
|
removeAction(): void
|
|
16
16
|
removeTitle(): void
|
|
17
17
|
setHeaderHeight(headerHeight: number): void
|
|
18
|
+
setBackAction(action: () => void): void
|
|
19
|
+
executeBackAction(): void
|
|
18
20
|
}
|
|
@@ -84,4 +84,18 @@ const createHeaderStore = () =>
|
|
|
84
84
|
headerHeight,
|
|
85
85
|
}))
|
|
86
86
|
},
|
|
87
|
+
setBackAction: (action) => {
|
|
88
|
+
set(() => ({
|
|
89
|
+
backAction: action,
|
|
90
|
+
}))
|
|
91
|
+
},
|
|
92
|
+
executeBackAction: () => {
|
|
93
|
+
const { backAction } = get()
|
|
94
|
+
if (backAction) {
|
|
95
|
+
backAction()
|
|
96
|
+
set(() => ({
|
|
97
|
+
backAction: undefined,
|
|
98
|
+
}))
|
|
99
|
+
}
|
|
100
|
+
},
|
|
87
101
|
}))
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { createContext, useContext, useRef } from 'react'
|
|
2
|
+
import { useShallow } from 'zustand/shallow'
|
|
3
|
+
import type { PersistStoreProviderProps } from '../types.js'
|
|
4
|
+
import { createPinnedTokensStore } from './createPinnedTokensStore.js'
|
|
5
|
+
import type { PinnedTokensState, PinnedTokensStore } from './types.js'
|
|
6
|
+
|
|
7
|
+
const PinnedTokensStoreContext = createContext<PinnedTokensStore | null>(null)
|
|
8
|
+
|
|
9
|
+
export const PinnedTokensStoreProvider: React.FC<PersistStoreProviderProps> = ({
|
|
10
|
+
children,
|
|
11
|
+
...props
|
|
12
|
+
}) => {
|
|
13
|
+
const storeRef = useRef<PinnedTokensStore>(null)
|
|
14
|
+
|
|
15
|
+
if (!storeRef.current) {
|
|
16
|
+
storeRef.current = createPinnedTokensStore(props)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<PinnedTokensStoreContext.Provider value={storeRef.current}>
|
|
21
|
+
{children}
|
|
22
|
+
</PinnedTokensStoreContext.Provider>
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function usePinnedTokensStore<T>(
|
|
27
|
+
selector: (store: PinnedTokensState) => T
|
|
28
|
+
) {
|
|
29
|
+
const useStore = useContext(PinnedTokensStoreContext)
|
|
30
|
+
|
|
31
|
+
if (!useStore) {
|
|
32
|
+
throw new Error(
|
|
33
|
+
`You forgot to wrap your component in <${PinnedTokensStoreProvider.name}>.`
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return useStore(useShallow(selector))
|
|
38
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { create } from 'zustand'
|
|
2
|
+
import { persist } from 'zustand/middleware'
|
|
3
|
+
import type { PersistStoreProps } from '../types.js'
|
|
4
|
+
import type { PinnedTokensState } from './types.js'
|
|
5
|
+
|
|
6
|
+
export const createPinnedTokensStore = ({ namePrefix }: PersistStoreProps) =>
|
|
7
|
+
create<PinnedTokensState>()(
|
|
8
|
+
persist(
|
|
9
|
+
(set, get) => ({
|
|
10
|
+
pinnedTokens: {},
|
|
11
|
+
pinToken: (chainId: number, tokenAddress: string) => {
|
|
12
|
+
set((state) => {
|
|
13
|
+
const normalizedAddress = tokenAddress.toLowerCase()
|
|
14
|
+
const chainTokens = state.pinnedTokens[chainId] || []
|
|
15
|
+
if (!chainTokens.includes(normalizedAddress)) {
|
|
16
|
+
return {
|
|
17
|
+
pinnedTokens: {
|
|
18
|
+
...state.pinnedTokens,
|
|
19
|
+
[chainId]: [...chainTokens, normalizedAddress],
|
|
20
|
+
},
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return state
|
|
24
|
+
})
|
|
25
|
+
},
|
|
26
|
+
unpinToken: (chainId: number, tokenAddress: string) => {
|
|
27
|
+
set((state) => {
|
|
28
|
+
const normalizedAddress = tokenAddress.toLowerCase()
|
|
29
|
+
const chainTokens = state.pinnedTokens[chainId] || []
|
|
30
|
+
if (chainTokens.includes(normalizedAddress)) {
|
|
31
|
+
return {
|
|
32
|
+
pinnedTokens: {
|
|
33
|
+
...state.pinnedTokens,
|
|
34
|
+
[chainId]: chainTokens.filter(
|
|
35
|
+
(addr) => addr !== normalizedAddress
|
|
36
|
+
),
|
|
37
|
+
},
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return state
|
|
41
|
+
})
|
|
42
|
+
},
|
|
43
|
+
isPinned: (chainId: number, tokenAddress: string) => {
|
|
44
|
+
const normalizedAddress = tokenAddress.toLowerCase()
|
|
45
|
+
const chainTokens = get().pinnedTokens[chainId] || []
|
|
46
|
+
return chainTokens.includes(normalizedAddress)
|
|
47
|
+
},
|
|
48
|
+
getPinnedTokens: (chainId: number) => {
|
|
49
|
+
return get().pinnedTokens[chainId] || []
|
|
50
|
+
},
|
|
51
|
+
getAllPinnedTokens: () => {
|
|
52
|
+
const allPinned: Array<{ chainId: number; tokenAddress: string }> = []
|
|
53
|
+
const pinnedTokens = get().pinnedTokens
|
|
54
|
+
Object.entries(pinnedTokens).forEach(([chainIdStr, addresses]) => {
|
|
55
|
+
const chainId = Number.parseInt(chainIdStr, 10)
|
|
56
|
+
addresses.forEach((address) => {
|
|
57
|
+
allPinned.push({ chainId, tokenAddress: address })
|
|
58
|
+
})
|
|
59
|
+
})
|
|
60
|
+
return allPinned
|
|
61
|
+
},
|
|
62
|
+
}),
|
|
63
|
+
{
|
|
64
|
+
name: `${namePrefix || 'li.fi'}-pinned-tokens`,
|
|
65
|
+
version: 0,
|
|
66
|
+
partialize: (state) => ({
|
|
67
|
+
pinnedTokens: state.pinnedTokens,
|
|
68
|
+
}),
|
|
69
|
+
}
|
|
70
|
+
)
|
|
71
|
+
)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { StoreApi } from 'zustand'
|
|
2
|
+
import type { UseBoundStoreWithEqualityFn } from 'zustand/traditional'
|
|
3
|
+
|
|
4
|
+
export interface PinnedTokensProps {
|
|
5
|
+
pinnedTokens: Record<number, string[]>
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface PinnedTokensActions {
|
|
9
|
+
pinToken: (chainId: number, tokenAddress: string) => void
|
|
10
|
+
unpinToken: (chainId: number, tokenAddress: string) => void
|
|
11
|
+
isPinned: (chainId: number, tokenAddress: string) => boolean
|
|
12
|
+
getPinnedTokens: (chainId: number) => string[]
|
|
13
|
+
getAllPinnedTokens: () => Array<{ chainId: number; tokenAddress: string }>
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type PinnedTokensState = PinnedTokensProps & PinnedTokensActions
|
|
17
|
+
|
|
18
|
+
export type PinnedTokensStore = UseBoundStoreWithEqualityFn<
|
|
19
|
+
StoreApi<PinnedTokensState>
|
|
20
|
+
>
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { createContext, useContext, useRef } from 'react'
|
|
2
|
-
import type { StoreApi } from 'zustand'
|
|
2
|
+
import type { StoreApi, UseBoundStore } from 'zustand'
|
|
3
3
|
import { useShallow } from 'zustand/shallow'
|
|
4
|
-
import type { UseBoundStoreWithEqualityFn } from 'zustand/traditional'
|
|
5
4
|
import type { PersistStoreProviderProps } from '../types.js'
|
|
6
5
|
import { createRouteExecutionStore } from './createRouteExecutionStore.js'
|
|
7
6
|
import type { RouteExecutionState } from './types.js'
|
|
8
7
|
|
|
9
|
-
type RouteExecutionStore =
|
|
10
|
-
StoreApi<RouteExecutionState>
|
|
11
|
-
>
|
|
8
|
+
type RouteExecutionStore = UseBoundStore<StoreApi<RouteExecutionState>>
|
|
12
9
|
|
|
13
10
|
const RouteExecutionStoreContext = createContext<RouteExecutionStore | null>(
|
|
14
11
|
null
|
|
@@ -121,7 +121,7 @@ export const createRouteExecutionStore = ({ namePrefix }: PersistStoreProps) =>
|
|
|
121
121
|
}),
|
|
122
122
|
{
|
|
123
123
|
name: `${namePrefix || 'li.fi'}-widget-routes`,
|
|
124
|
-
version:
|
|
124
|
+
version: 3,
|
|
125
125
|
partialize: (state) => ({ routes: state.routes }),
|
|
126
126
|
merge: (persistedState: any, currentState: RouteExecutionState) => {
|
|
127
127
|
const state = {
|
|
@@ -134,10 +134,9 @@ export const createRouteExecutionStore = ({ namePrefix }: PersistStoreProps) =>
|
|
|
134
134
|
const oneDay = 1000 * 60 * 60 * 24
|
|
135
135
|
Object.values(state.routes).forEach((routeExecution) => {
|
|
136
136
|
const startedAt =
|
|
137
|
-
routeExecution?.route.steps
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
?.startedAt ?? 0
|
|
137
|
+
routeExecution?.route.steps?.find(
|
|
138
|
+
(step) => step.execution?.status === 'FAILED'
|
|
139
|
+
)?.execution?.startedAt ?? 0
|
|
141
140
|
const outdated = startedAt > 0 && currentTime - startedAt > oneDay
|
|
142
141
|
if (routeExecution?.route && outdated) {
|
|
143
142
|
delete state.routes[routeExecution.route.id]
|
|
@@ -16,8 +16,8 @@ export const useExecutingRoutesIds = () => {
|
|
|
16
16
|
)
|
|
17
17
|
.sort(
|
|
18
18
|
(a, b) =>
|
|
19
|
-
(b?.route.steps[0].execution?.
|
|
20
|
-
(a?.route.steps[0].execution?.
|
|
19
|
+
(b?.route.steps[0].execution?.startedAt ?? 0) -
|
|
20
|
+
(a?.route.steps[0].execution?.startedAt ?? 0)
|
|
21
21
|
)
|
|
22
22
|
.map(({ route }) => route.id)
|
|
23
23
|
)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ExecutionAction, RouteExtended } from '@lifi/sdk'
|
|
2
2
|
import microdiff from 'microdiff'
|
|
3
3
|
|
|
4
4
|
export const isRouteDone = (route: RouteExtended) => {
|
|
@@ -7,13 +7,13 @@ export const isRouteDone = (route: RouteExtended) => {
|
|
|
7
7
|
|
|
8
8
|
export const isRoutePartiallyDone = (route: RouteExtended) => {
|
|
9
9
|
return route.steps.some((step) =>
|
|
10
|
-
step.execution?.
|
|
10
|
+
step.execution?.actions?.some((action) => action.substatus === 'PARTIAL')
|
|
11
11
|
)
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export const isRouteRefunded = (route: RouteExtended) => {
|
|
15
15
|
return route.steps.some((step) =>
|
|
16
|
-
step.execution?.
|
|
16
|
+
step.execution?.actions?.some((action) => action.substatus === 'REFUNDED')
|
|
17
17
|
)
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -31,31 +31,33 @@ export const isRouteActive = (route?: RouteExtended) => {
|
|
|
31
31
|
return !isDone && !isFailed && alreadyStarted
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
export const
|
|
34
|
+
export const getUpdatedAction = (
|
|
35
35
|
currentRoute: RouteExtended,
|
|
36
36
|
updatedRoute: RouteExtended
|
|
37
|
-
):
|
|
38
|
-
const
|
|
39
|
-
diff.path.includes('
|
|
37
|
+
): ExecutionAction | undefined => {
|
|
38
|
+
const actionDiff = microdiff(currentRoute, updatedRoute).find((diff) =>
|
|
39
|
+
diff.path.includes('actions')
|
|
40
40
|
)
|
|
41
|
-
if (!
|
|
41
|
+
if (!actionDiff) {
|
|
42
42
|
return undefined
|
|
43
43
|
}
|
|
44
|
-
// Find
|
|
45
|
-
// e.g. ['steps', 0, 'execution', '
|
|
46
|
-
const
|
|
47
|
-
const
|
|
44
|
+
// Find action index in the diff array so we can slice the complete action object
|
|
45
|
+
// e.g. ['steps', 0, 'execution', 'actions', 0, 'message']
|
|
46
|
+
const actionDiffIndex = actionDiff.path.indexOf('actions') + 2
|
|
47
|
+
const actionPathSlice = actionDiff.path.slice(0, actionDiffIndex)
|
|
48
48
|
// Reduce updated route using the diff path to get updated process
|
|
49
|
-
const
|
|
49
|
+
const action = actionPathSlice.reduce(
|
|
50
50
|
(obj, path) => obj[path],
|
|
51
51
|
updatedRoute as any
|
|
52
|
-
) as
|
|
53
|
-
return
|
|
52
|
+
) as ExecutionAction
|
|
53
|
+
return action
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
export const getSourceTxHash = (route?: RouteExtended) => {
|
|
57
|
-
const
|
|
58
|
-
.filter(
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
const sourceAction = route?.steps[0].execution?.actions
|
|
58
|
+
.filter(
|
|
59
|
+
(action) => !['RESET_ALLOWANCE', 'SET_ALLOWANCE'].includes(action.type)
|
|
60
|
+
)
|
|
61
|
+
.find((action) => action.txHash || action.taskId)
|
|
62
|
+
return sourceAction?.txHash || sourceAction?.taskId
|
|
61
63
|
}
|
|
@@ -4,13 +4,12 @@ import {
|
|
|
4
4
|
useContext,
|
|
5
5
|
useRef,
|
|
6
6
|
} from 'react'
|
|
7
|
-
import type { StoreApi } from 'zustand'
|
|
7
|
+
import type { StoreApi, UseBoundStore } from 'zustand'
|
|
8
8
|
import { useShallow } from 'zustand/shallow'
|
|
9
|
-
import type { UseBoundStoreWithEqualityFn } from 'zustand/traditional'
|
|
10
9
|
import { createSettingsStore } from './createSettingsStore.js'
|
|
11
10
|
import type { SettingsState, SettingsStoreProviderProps } from './types.js'
|
|
12
11
|
|
|
13
|
-
type SettingsStore =
|
|
12
|
+
type SettingsStore = UseBoundStore<StoreApi<SettingsState>>
|
|
14
13
|
|
|
15
14
|
const SettingsStoreContext = createContext<SettingsStore | null>(null)
|
|
16
15
|
|
|
@@ -29,6 +29,7 @@ const defaultSettings: SettingsProps = {
|
|
|
29
29
|
enabledExchanges: [],
|
|
30
30
|
_enabledBridges: {},
|
|
31
31
|
_enabledExchanges: {},
|
|
32
|
+
smallBalanceThreshold: undefined,
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
export const createSettingsStore = (config: WidgetConfig) =>
|
|
@@ -145,7 +146,7 @@ export const createSettingsStore = (config: WidgetConfig) =>
|
|
|
145
146
|
}),
|
|
146
147
|
{
|
|
147
148
|
name: 'li.fi-widget-settings',
|
|
148
|
-
version:
|
|
149
|
+
version: 6,
|
|
149
150
|
partialize: (state) => {
|
|
150
151
|
const {
|
|
151
152
|
disabledBridges,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Order } from '@lifi/sdk'
|
|
2
2
|
import type { PropsWithChildren } from 'react'
|
|
3
|
-
import type { StoreApi } from 'zustand'
|
|
4
|
-
import type { UseBoundStoreWithEqualityFn } from 'zustand/traditional'
|
|
3
|
+
import type { StoreApi, UseBoundStore } from 'zustand'
|
|
5
4
|
import type { LanguageResource } from '../../providers/I18nProvider/types.js'
|
|
6
5
|
import type { SplitSubvariant, WidgetConfig } from '../../types/widget.js'
|
|
7
6
|
|
|
@@ -29,6 +28,7 @@ export interface SettingsProps {
|
|
|
29
28
|
disabledExchanges: string[]
|
|
30
29
|
enabledExchanges: string[]
|
|
31
30
|
_enabledExchanges: Record<string, boolean>
|
|
31
|
+
smallBalanceThreshold?: string
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
export interface SettingsActions {
|
|
@@ -61,9 +61,7 @@ export interface SplitSubvariantState {
|
|
|
61
61
|
setState(state: SplitSubvariant): void
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
export type SplitSubvariantStore =
|
|
65
|
-
StoreApi<SplitSubvariantState>
|
|
66
|
-
>
|
|
64
|
+
export type SplitSubvariantStore = UseBoundStore<StoreApi<SplitSubvariantState>>
|
|
67
65
|
|
|
68
66
|
export interface SplitSubvariantProps {
|
|
69
67
|
state?: SplitSubvariant
|