@lifi/widget 4.3.1 → 4.4.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/dist/esm/App.d.ts +0 -1
- package/dist/esm/App.d.ts.map +1 -1
- package/dist/esm/AppDrawer.d.ts +1 -1
- package/dist/esm/AppDrawer.d.ts.map +1 -1
- package/dist/esm/components/ActionRow/ActionRow.d.ts +13 -0
- package/dist/esm/components/ActionRow/ActionRow.d.ts.map +1 -0
- package/dist/esm/components/AmountInput/AmountInput.style.d.ts +9 -0
- package/dist/esm/components/AmountInput/AmountInput.style.d.ts.map +1 -0
- package/dist/esm/components/AmountInput/AmountInputEndAdornment.d.ts +7 -0
- package/dist/esm/components/AmountInput/AmountInputEndAdornment.d.ts.map +1 -0
- package/dist/esm/components/AmountInput/PriceFormHelperText.style.d.ts +7 -0
- package/dist/esm/components/AmountInput/PriceFormHelperText.style.d.ts.map +1 -0
- package/dist/esm/components/Avatar/Avatar.d.ts +12 -0
- package/dist/esm/components/Avatar/Avatar.d.ts.map +1 -0
- package/dist/esm/components/Avatar/TokenAvatar.d.ts +14 -0
- package/dist/esm/components/Avatar/TokenAvatar.d.ts.map +1 -0
- package/dist/esm/components/BaseTransactionButton/BaseTransactionButton.d.ts +6 -0
- package/dist/esm/components/BaseTransactionButton/BaseTransactionButton.d.ts.map +1 -0
- package/dist/esm/components/BaseTransactionButton/types.d.ts +14 -0
- package/dist/esm/components/BaseTransactionButton/types.d.ts.map +1 -0
- package/dist/esm/components/BottomSheet/types.d.ts +11 -0
- package/dist/esm/components/BottomSheet/types.d.ts.map +1 -0
- package/dist/esm/components/ButtonTertiary.d.ts +7 -0
- package/dist/esm/components/ButtonTertiary.d.ts.map +1 -0
- package/dist/esm/components/Card/Card.d.ts +12 -0
- package/dist/esm/components/Card/Card.d.ts.map +1 -0
- package/dist/esm/components/Card/CardIconButton.d.ts +7 -0
- package/dist/esm/components/Card/CardIconButton.d.ts.map +1 -0
- package/dist/esm/components/Card/CardTitle.d.ts +9 -0
- package/dist/esm/components/Card/CardTitle.d.ts.map +1 -0
- package/dist/esm/components/Card/InputCard.d.ts +7 -0
- package/dist/esm/components/Card/InputCard.d.ts.map +1 -0
- package/dist/esm/components/ChainSelect/ChainSelect.d.ts +7 -0
- package/dist/esm/components/ChainSelect/ChainSelect.d.ts.map +1 -0
- package/dist/esm/components/ChainSelect/ChainSelect.style.d.ts +10 -0
- package/dist/esm/components/ChainSelect/ChainSelect.style.d.ts.map +1 -0
- package/dist/esm/components/ContractComponent/ContractComponent.d.ts +7 -0
- package/dist/esm/components/ContractComponent/ContractComponent.d.ts.map +1 -0
- package/dist/esm/components/ContractComponent/ItemPrice.d.ts +0 -1
- package/dist/esm/components/ContractComponent/ItemPrice.d.ts.map +1 -1
- package/dist/esm/components/ContractComponent/NFT/NFT.d.ts +0 -1
- package/dist/esm/components/ContractComponent/NFT/NFT.d.ts.map +1 -1
- package/dist/esm/components/ContractComponent/NFT/NFTBase.d.ts +0 -1
- package/dist/esm/components/ContractComponent/NFT/NFTBase.d.ts.map +1 -1
- package/dist/esm/components/ContractComponent/NFT/types.d.ts +0 -1
- package/dist/esm/components/ContractComponent/NFT/types.d.ts.map +1 -1
- package/dist/esm/components/ExecutionStatusCard/ExecutionStatusCard.d.ts +21 -0
- package/dist/esm/components/ExecutionStatusCard/ExecutionStatusCard.d.ts.map +1 -0
- package/dist/esm/components/ExecutionStatusCard/StatusIcon.d.ts +16 -0
- package/dist/esm/components/ExecutionStatusCard/StatusIcon.d.ts.map +1 -0
- package/dist/esm/components/ExecutionStatusCard/iconKey.js +1 -0
- package/dist/esm/components/ExecutionStatusCard/iconKey.js.map +1 -1
- package/dist/esm/components/FeeBreakdownTooltip.d.ts +13 -0
- package/dist/esm/components/FeeBreakdownTooltip.d.ts.map +1 -0
- package/dist/esm/components/IconCircle/IconCircle.d.ts +11 -0
- package/dist/esm/components/IconCircle/IconCircle.d.ts.map +1 -0
- package/dist/esm/components/IconCircle/statusIcons.d.ts +6 -0
- package/dist/esm/components/IconCircle/statusIcons.d.ts.map +1 -0
- package/dist/esm/components/IconTypography.d.ts +7 -0
- package/dist/esm/components/IconTypography.d.ts.map +1 -0
- package/dist/esm/components/ListItem/ListItemButton.d.ts +7 -0
- package/dist/esm/components/ListItem/ListItemButton.d.ts.map +1 -0
- package/dist/esm/components/ListItemButton.d.ts +7 -0
- package/dist/esm/components/ListItemButton.d.ts.map +1 -0
- package/dist/esm/components/Messages/WarningMessages.d.ts +11 -0
- package/dist/esm/components/Messages/WarningMessages.d.ts.map +1 -0
- package/dist/esm/components/PageContainer.d.ts +12 -0
- package/dist/esm/components/PageContainer.d.ts.map +1 -0
- package/dist/esm/components/PoweredBy/PoweredBy.d.ts +5 -0
- package/dist/esm/components/PoweredBy/PoweredBy.d.ts.map +1 -0
- package/dist/esm/components/ProgressToNextUpdate.d.ts +10 -0
- package/dist/esm/components/ProgressToNextUpdate.d.ts.map +1 -0
- package/dist/esm/components/RouteCard/RouteCard.d.ts +7 -0
- package/dist/esm/components/RouteCard/RouteCard.d.ts.map +1 -0
- package/dist/esm/components/RouteCard/RouteCardSkeleton.d.ts +7 -0
- package/dist/esm/components/RouteCard/RouteCardSkeleton.d.ts.map +1 -0
- package/dist/esm/components/RouteCard/RouteDetails.d.ts +10 -0
- package/dist/esm/components/RouteCard/RouteDetails.d.ts.map +1 -0
- package/dist/esm/components/RouteCard/RouteDetails.style.d.ts +12 -0
- package/dist/esm/components/RouteCard/RouteDetails.style.d.ts.map +1 -0
- package/dist/esm/components/RouteCard/RouteNotFoundCard.d.ts +5 -0
- package/dist/esm/components/RouteCard/RouteNotFoundCard.d.ts.map +1 -0
- package/dist/esm/components/RouteCard/RouteTokens.d.ts +11 -0
- package/dist/esm/components/RouteCard/RouteTokens.d.ts.map +1 -0
- package/dist/esm/components/RouteCard/RouteTokens.js +2 -2
- package/dist/esm/components/RouteCard/RouteTokens.js.map +1 -1
- package/dist/esm/components/RouteCard/types.d.ts +14 -0
- package/dist/esm/components/RouteCard/types.d.ts.map +1 -0
- package/dist/esm/components/Search/SearchInput.d.ts +17 -0
- package/dist/esm/components/Search/SearchInput.d.ts.map +1 -0
- package/dist/esm/components/SendToWallet/SendToWalletButton.d.ts +10 -0
- package/dist/esm/components/SendToWallet/SendToWalletButton.d.ts.map +1 -0
- package/dist/esm/components/SendToWallet/SendToWalletButton.js +15 -6
- package/dist/esm/components/SendToWallet/SendToWalletButton.js.map +1 -1
- package/dist/esm/components/Skeleton/WidgetSkeleton.d.ts +1 -4
- package/dist/esm/components/Skeleton/WidgetSkeleton.d.ts.map +1 -1
- package/dist/esm/components/StepActions/SentToWalletRow.d.ts +9 -0
- package/dist/esm/components/StepActions/SentToWalletRow.d.ts.map +1 -0
- package/dist/esm/components/StepActions/StepActionRow.style.d.ts +7 -0
- package/dist/esm/components/StepActions/StepActionRow.style.d.ts.map +1 -0
- package/dist/esm/components/StepActions/StepActionsList.d.ts +12 -0
- package/dist/esm/components/StepActions/StepActionsList.d.ts.map +1 -0
- package/dist/esm/components/StepActions/executionRows.d.ts +26 -0
- package/dist/esm/components/StepActions/executionRows.d.ts.map +1 -0
- package/dist/esm/components/Token/Token.d.ts +17 -0
- package/dist/esm/components/Token/Token.d.ts.map +1 -0
- package/dist/esm/components/TokenList/TokenNotFound.d.ts +6 -0
- package/dist/esm/components/TokenList/TokenNotFound.d.ts.map +1 -0
- package/dist/esm/components/TokenList/VirtualizedTokenList.d.ts +7 -0
- package/dist/esm/components/TokenList/VirtualizedTokenList.d.ts.map +1 -0
- package/dist/esm/components/TokenList/types.d.ts +20 -0
- package/dist/esm/components/TokenList/types.d.ts.map +1 -0
- package/dist/esm/components/TokenList/useTokenSelect.d.ts +6 -0
- package/dist/esm/components/TokenList/useTokenSelect.d.ts.map +1 -0
- package/dist/esm/components/TokenRate/TokenRate.d.ts +10 -0
- package/dist/esm/components/TokenRate/TokenRate.d.ts.map +1 -0
- package/dist/esm/components/TransactionCard/ActiveTransactionCard.js +1 -0
- package/dist/esm/components/TransactionCard/ActiveTransactionCard.js.map +1 -1
- package/dist/esm/components/TransactionCard/ActiveTransactionCard.style.js +9 -0
- package/dist/esm/components/TransactionCard/ActiveTransactionCard.style.js.map +1 -1
- package/dist/esm/components/TransactionCard/TransactionCard.style.d.ts +8 -0
- package/dist/esm/components/TransactionCard/TransactionCard.style.d.ts.map +1 -0
- package/dist/esm/config/constants.d.ts.map +1 -1
- package/dist/esm/config/version.d.ts +1 -1
- package/dist/esm/config/version.d.ts.map +1 -1
- package/dist/esm/config/version.js +1 -1
- package/dist/esm/config/version.js.map +1 -1
- package/dist/esm/hooks/useAddressActivity.d.ts +11 -0
- package/dist/esm/hooks/useAddressActivity.d.ts.map +1 -0
- package/dist/esm/hooks/useAddressValidation.d.ts +28 -0
- package/dist/esm/hooks/useAddressValidation.d.ts.map +1 -0
- package/dist/esm/hooks/useAddressValidation.js +6 -1
- package/dist/esm/hooks/useAddressValidation.js.map +1 -1
- package/dist/esm/hooks/useAvailableChains.d.ts +12 -0
- package/dist/esm/hooks/useAvailableChains.d.ts.map +1 -0
- package/dist/esm/hooks/useChain.d.ts +10 -0
- package/dist/esm/hooks/useChain.d.ts.map +1 -0
- package/dist/esm/hooks/useContactSupport.d.ts +5 -0
- package/dist/esm/hooks/useContactSupport.d.ts.map +1 -0
- package/dist/esm/hooks/useDebouncedWatch.d.ts +6 -0
- package/dist/esm/hooks/useDebouncedWatch.d.ts.map +1 -0
- package/dist/esm/hooks/useDisplayedTokens.js +48 -0
- package/dist/esm/hooks/useDisplayedTokens.js.map +1 -0
- package/dist/esm/hooks/useExplorer.d.ts +14 -0
- package/dist/esm/hooks/useExplorer.d.ts.map +1 -0
- package/dist/esm/hooks/useHeader.d.ts +6 -0
- package/dist/esm/hooks/useHeader.d.ts.map +1 -0
- package/dist/esm/hooks/useListHeight.d.ts +12 -0
- package/dist/esm/hooks/useListHeight.d.ts.map +1 -0
- package/dist/esm/hooks/useListHeight.js +1 -0
- package/dist/esm/hooks/useListHeight.js.map +1 -1
- package/dist/esm/hooks/useNavigateBack.d.ts +5 -0
- package/dist/esm/hooks/useNavigateBack.d.ts.map +1 -0
- package/dist/esm/hooks/usePacedRouteExecution.js +1 -0
- package/dist/esm/hooks/usePacedRouteExecution.js.map +1 -1
- package/dist/esm/hooks/useRouteExecution.d.ts +18 -0
- package/dist/esm/hooks/useRouteExecution.d.ts.map +1 -0
- package/dist/esm/hooks/useRouteExecutionMessage.d.ts +10 -0
- package/dist/esm/hooks/useRouteExecutionMessage.d.ts.map +1 -0
- package/dist/esm/hooks/useRouteExecutionMessage.js +1 -0
- package/dist/esm/hooks/useRouteExecutionMessage.js.map +1 -1
- package/dist/esm/hooks/useRoutes.d.ts +32 -0
- package/dist/esm/hooks/useRoutes.d.ts.map +1 -0
- package/dist/esm/hooks/useRoutes.js +12 -8
- package/dist/esm/hooks/useRoutes.js.map +1 -1
- package/dist/esm/hooks/useToAddressRequirements.d.ts +16 -0
- package/dist/esm/hooks/useToAddressRequirements.d.ts.map +1 -0
- package/dist/esm/hooks/useToken.d.ts +9 -0
- package/dist/esm/hooks/useToken.d.ts.map +1 -0
- package/dist/esm/hooks/useTokenAddressBalance.d.ts +11 -0
- package/dist/esm/hooks/useTokenAddressBalance.d.ts.map +1 -0
- package/dist/esm/hooks/useTokenBalances.d.ts +14 -0
- package/dist/esm/hooks/useTokenBalances.d.ts.map +1 -0
- package/dist/esm/hooks/useTokenBalances.js +5 -45
- package/dist/esm/hooks/useTokenBalances.js.map +1 -1
- package/dist/esm/hooks/useTokenList.d.ts +16 -0
- package/dist/esm/hooks/useTokenList.d.ts.map +1 -0
- package/dist/esm/hooks/useTokenList.js +31 -0
- package/dist/esm/hooks/useTokenList.js.map +1 -0
- package/dist/esm/hooks/useTools.d.ts +8 -0
- package/dist/esm/hooks/useTools.d.ts.map +1 -0
- package/dist/esm/hooks/useTransactionDetails.js +1 -3
- package/dist/esm/hooks/useTransactionDetails.js.map +1 -1
- package/dist/esm/hooks/useTransactionList.js +1 -0
- package/dist/esm/hooks/useTransactionList.js.map +1 -1
- package/dist/esm/hooks/useWidgetChains.d.ts +0 -1
- package/dist/esm/hooks/useWidgetChains.d.ts.map +1 -1
- package/dist/esm/hooks/useWidgetEvents.d.ts +0 -1
- package/dist/esm/hooks/useWidgetEvents.d.ts.map +1 -1
- package/dist/esm/i18n/en.json +321 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/pages/ActivitiesPage/ActivitiesPage.js +1 -0
- package/dist/esm/pages/ActivitiesPage/ActivitiesPage.js.map +1 -1
- package/dist/esm/pages/MainPage/MainWarningMessages.d.ts +10 -0
- package/dist/esm/pages/MainPage/MainWarningMessages.d.ts.map +1 -0
- package/dist/esm/pages/RoutesPage/RoutesPage.style.d.ts +7 -0
- package/dist/esm/pages/RoutesPage/RoutesPage.style.d.ts.map +1 -0
- package/dist/esm/pages/SelectChainPage/SelectChainPage.d.ts +6 -0
- package/dist/esm/pages/SelectChainPage/SelectChainPage.d.ts.map +1 -0
- package/dist/esm/pages/SelectChainPage/types.d.ts +8 -0
- package/dist/esm/pages/SelectChainPage/types.d.ts.map +1 -0
- package/dist/esm/pages/SelectTokenPage/SearchTokenInput.d.ts +10 -0
- package/dist/esm/pages/SelectTokenPage/SearchTokenInput.d.ts.map +1 -0
- package/dist/esm/pages/TransactionDetailsPage/ContactSupportButton.d.ts +9 -0
- package/dist/esm/pages/TransactionDetailsPage/ContactSupportButton.d.ts.map +1 -0
- package/dist/esm/pages/TransactionPage/ConfirmToAddressSheet.d.ts +14 -0
- package/dist/esm/pages/TransactionPage/ConfirmToAddressSheet.d.ts.map +1 -0
- package/dist/esm/pages/TransactionPage/ExchangeRateBottomSheet.d.ts +19 -0
- package/dist/esm/pages/TransactionPage/ExchangeRateBottomSheet.d.ts.map +1 -0
- package/dist/esm/pages/TransactionPage/ExecutionDoneCard.d.ts +12 -0
- package/dist/esm/pages/TransactionPage/ExecutionDoneCard.d.ts.map +1 -0
- package/dist/esm/pages/TransactionPage/ExecutionDoneCard.js +1 -0
- package/dist/esm/pages/TransactionPage/ExecutionDoneCard.js.map +1 -1
- package/dist/esm/pages/TransactionPage/RouteTracker.d.ts +11 -0
- package/dist/esm/pages/TransactionPage/RouteTracker.d.ts.map +1 -0
- package/dist/esm/pages/TransactionPage/StartTransactionButton.d.ts +6 -0
- package/dist/esm/pages/TransactionPage/StartTransactionButton.d.ts.map +1 -0
- package/dist/esm/pages/TransactionPage/TokenValueBottomSheet.d.ts +15 -0
- package/dist/esm/pages/TransactionPage/TokenValueBottomSheet.d.ts.map +1 -0
- package/dist/esm/pages/TransactionPage/TransactionContent.js +1 -0
- package/dist/esm/pages/TransactionPage/TransactionContent.js.map +1 -1
- package/dist/esm/pages/TransactionPage/TransactionDoneButtons.d.ts +12 -0
- package/dist/esm/pages/TransactionPage/TransactionDoneButtons.d.ts.map +1 -0
- package/dist/esm/pages/TransactionPage/TransactionDoneButtons.js +1 -0
- package/dist/esm/pages/TransactionPage/TransactionDoneButtons.js.map +1 -1
- package/dist/esm/pages/TransactionPage/TransactionExecutionContent.js +1 -0
- package/dist/esm/pages/TransactionPage/TransactionExecutionContent.js.map +1 -1
- package/dist/esm/pages/TransactionPage/TransactionPage.js +1 -0
- package/dist/esm/pages/TransactionPage/TransactionPage.js.map +1 -1
- package/dist/esm/pages/TransactionPage/types.d.ts +9 -0
- package/dist/esm/pages/TransactionPage/types.d.ts.map +1 -0
- package/dist/esm/pages/TransactionPage/utils.d.ts +6 -0
- package/dist/esm/pages/TransactionPage/utils.d.ts.map +1 -0
- package/dist/esm/providers/I18nProvider/I18nProvider.d.ts +5 -0
- package/dist/esm/providers/I18nProvider/I18nProvider.d.ts.map +1 -0
- package/dist/esm/providers/I18nProvider/types.d.ts +2 -3
- package/dist/esm/providers/I18nProvider/types.d.ts.map +1 -1
- package/dist/esm/providers/QueryClientProvider.d.ts +6 -0
- package/dist/esm/providers/QueryClientProvider.d.ts.map +1 -0
- package/dist/esm/providers/SDKClientProvider.d.ts +8 -0
- package/dist/esm/providers/SDKClientProvider.d.ts.map +1 -0
- package/dist/esm/providers/WalletProvider/WalletProvider.d.ts +10 -0
- package/dist/esm/providers/WalletProvider/WalletProvider.d.ts.map +1 -0
- package/dist/esm/providers/WalletProvider/WalletProvider.js +8 -3
- package/dist/esm/providers/WalletProvider/WalletProvider.js.map +1 -1
- package/dist/esm/providers/WidgetProvider/WidgetProvider.d.ts +8 -0
- package/dist/esm/providers/WidgetProvider/WidgetProvider.d.ts.map +1 -0
- package/dist/esm/providers/WidgetProvider/types.d.ts +11 -0
- package/dist/esm/providers/WidgetProvider/types.d.ts.map +1 -0
- package/dist/esm/shared.d.ts +107 -0
- package/dist/esm/shared.js +105 -0
- package/dist/esm/stores/StoreProvider.d.ts +7 -0
- package/dist/esm/stores/StoreProvider.d.ts.map +1 -0
- package/dist/esm/stores/bookmarks/BookmarkStore.d.ts +7 -0
- package/dist/esm/stores/bookmarks/BookmarkStore.d.ts.map +1 -0
- package/dist/esm/stores/bookmarks/types.d.ts +0 -1
- package/dist/esm/stores/bookmarks/types.d.ts.map +1 -1
- package/dist/esm/stores/chains/ChainOrderStore.d.ts +8 -0
- package/dist/esm/stores/chains/ChainOrderStore.d.ts.map +1 -0
- package/dist/esm/stores/chains/types.d.ts +27 -0
- package/dist/esm/stores/chains/types.d.ts.map +1 -0
- package/dist/esm/stores/form/createFormStore.js +1 -0
- package/dist/esm/stores/form/createFormStore.js.map +1 -1
- package/dist/esm/stores/form/types.d.ts +7 -7
- package/dist/esm/stores/form/types.d.ts.map +1 -1
- package/dist/esm/stores/form/types.js.map +1 -1
- package/dist/esm/stores/form/useFieldActions.d.ts +0 -1
- package/dist/esm/stores/form/useFieldActions.d.ts.map +1 -1
- package/dist/esm/stores/form/useFieldValues.d.ts +0 -1
- package/dist/esm/stores/form/useFieldValues.d.ts.map +1 -1
- package/dist/esm/stores/header/types.d.ts +20 -0
- package/dist/esm/stores/header/types.d.ts.map +1 -0
- package/dist/esm/stores/header/useHeaderStore.d.ts +8 -0
- package/dist/esm/stores/header/useHeaderStore.d.ts.map +1 -0
- package/dist/esm/stores/inputMode/useInputModeStore.d.ts +13 -0
- package/dist/esm/stores/inputMode/useInputModeStore.d.ts.map +1 -0
- package/dist/esm/stores/routes/RouteExecutionStore.d.ts +9 -0
- package/dist/esm/stores/routes/RouteExecutionStore.d.ts.map +1 -0
- package/dist/esm/stores/routes/createRouteExecutionStore.js +1 -0
- package/dist/esm/stores/routes/createRouteExecutionStore.js.map +1 -1
- package/dist/esm/stores/routes/types.d.ts +24 -0
- package/dist/esm/stores/routes/types.d.ts.map +1 -0
- package/dist/esm/stores/routes/types.js +14 -0
- package/dist/esm/stores/routes/types.js.map +1 -0
- package/dist/esm/stores/routes/useRouteExecutionIndicator.js +1 -0
- package/dist/esm/stores/routes/useRouteExecutionIndicator.js.map +1 -1
- package/dist/esm/stores/routes/utils.d.ts +9 -0
- package/dist/esm/stores/routes/utils.d.ts.map +1 -0
- package/dist/esm/stores/settings/SettingsStore.d.ts +8 -0
- package/dist/esm/stores/settings/SettingsStore.d.ts.map +1 -0
- package/dist/esm/stores/settings/types.d.ts +5 -2
- package/dist/esm/stores/settings/types.d.ts.map +1 -1
- package/dist/esm/stores/types.d.ts +9 -0
- package/dist/esm/stores/types.d.ts.map +1 -0
- package/dist/esm/themes/azureLight.d.ts +0 -1
- package/dist/esm/themes/azureLight.d.ts.map +1 -1
- package/dist/esm/themes/createTheme.d.ts +0 -1
- package/dist/esm/themes/createTheme.d.ts.map +1 -1
- package/dist/esm/themes/jumper.d.ts +0 -1
- package/dist/esm/themes/jumper.d.ts.map +1 -1
- package/dist/esm/themes/palettes.d.ts.map +1 -1
- package/dist/esm/themes/types.d.ts +0 -1
- package/dist/esm/themes/types.d.ts.map +1 -1
- package/dist/esm/themes/watermelonLight.d.ts +0 -1
- package/dist/esm/themes/watermelonLight.d.ts.map +1 -1
- package/dist/esm/themes/windows95.d.ts +0 -1
- package/dist/esm/themes/windows95.d.ts.map +1 -1
- package/dist/esm/types/events.d.ts +4 -3
- package/dist/esm/types/events.d.ts.map +1 -1
- package/dist/esm/types/token.d.ts +1 -2
- package/dist/esm/types/token.d.ts.map +1 -1
- package/dist/esm/types/widget.d.ts +72 -73
- package/dist/esm/types/widget.d.ts.map +1 -1
- package/dist/esm/utils/compactNumberFormatter.d.ts +8 -8
- package/dist/esm/utils/compactNumberFormatter.d.ts.map +1 -1
- package/dist/esm/utils/converters.d.ts +7 -0
- package/dist/esm/utils/converters.d.ts.map +1 -0
- package/dist/esm/utils/currencyExtendedFormatter.d.ts.map +1 -1
- package/dist/esm/utils/elements.d.ts +11 -0
- package/dist/esm/utils/elements.d.ts.map +1 -0
- package/dist/esm/utils/elements.js +8 -1
- package/dist/esm/utils/elements.js.map +1 -1
- package/dist/esm/utils/enum.d.ts +5 -0
- package/dist/esm/utils/enum.d.ts.map +1 -0
- package/dist/esm/utils/fees.d.ts +17 -0
- package/dist/esm/utils/fees.d.ts.map +1 -0
- package/dist/esm/utils/format.d.ts +14 -14
- package/dist/esm/utils/format.d.ts.map +1 -1
- package/dist/esm/utils/getPriceImpact.d.ts +1 -7
- package/dist/esm/utils/getPriceImpact.d.ts.map +1 -1
- package/dist/esm/utils/input.d.ts +5 -0
- package/dist/esm/utils/input.d.ts.map +1 -0
- package/dist/esm/utils/navigationRoutes.d.ts.map +1 -1
- package/dist/esm/utils/percentFormatter.d.ts +5 -5
- package/dist/esm/utils/percentFormatter.d.ts.map +1 -1
- package/dist/esm/utils/tokenList.js +3 -3
- package/dist/esm/utils/tokenList.js.map +1 -1
- package/dist/esm/utils/wallet.d.ts +5 -0
- package/dist/esm/utils/wallet.d.ts.map +1 -0
- package/package.json +28 -20
- package/src/components/RouteCard/RouteTokens.tsx +3 -2
- package/src/components/SendToWallet/SendToWalletButton.tsx +27 -5
- package/src/components/TransactionCard/ActiveTransactionCard.style.tsx +11 -0
- package/src/config/version.ts +1 -1
- package/src/hooks/useDisplayedTokens.ts +70 -0
- package/src/hooks/useListHeight.ts +4 -0
- package/src/hooks/useRoutes.ts +360 -325
- package/src/hooks/useTokenBalances.ts +8 -53
- package/src/hooks/useTokenList.ts +59 -0
- package/src/hooks/useTransactionDetails.ts +1 -3
- package/src/providers/WalletProvider/WalletProvider.tsx +15 -3
- package/src/shared.ts +191 -0
- package/src/stores/form/createFormStore.ts +1 -0
- package/src/stores/form/types.ts +1 -0
- package/src/utils/tokenList.ts +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAddressValidation.js","names":[],"sources":["../../../src/hooks/useAddressValidation.ts"],"sourcesContent":["import type { Chain, ChainType } from '@lifi/sdk'\nimport { getNameServiceAddress } from '@lifi/sdk'\nimport { useChainTypeFromAddress } from '@lifi/widget-provider'\nimport { useMutation } from '@tanstack/react-query'\nimport { useTranslation } from 'react-i18next'\nimport { useSDKClient } from '../providers/SDKClientProvider.js'\n\nexport enum AddressType {\n Address = 0,\n NameService = 1,\n}\n\ntype ValidationArgs = {\n value: string\n chainType?: ChainType\n chain?: Chain\n}\n\ntype ValidResponse = {\n address: string\n addressType: AddressType\n chainType: ChainType\n isValid: true\n}\n\ntype InvalidResponse = {\n error: string\n isValid: false\n}\n\nexport const useAddressValidation = (): {\n validateAddress: (\n args: ValidationArgs\n ) => Promise<ValidResponse | InvalidResponse>\n isValidating: boolean\n} => {\n const { t } = useTranslation()\n const { getChainTypeFromAddress } = useChainTypeFromAddress()\n const sdkClient = useSDKClient()\n\n const { mutateAsync: validateAddress, isPending: isValidating } = useMutation(\n {\n mutationFn: async ({\n value,\n chainType,\n chain,\n }: ValidationArgs): Promise<ValidResponse | InvalidResponse> => {\n try {\n if (!value) {\n throw new Error()\n }\n\n const _chainType = getChainTypeFromAddress(value)\n if (_chainType) {\n return {\n address: value,\n addressType: AddressType.Address,\n chainType: _chainType,\n isValid: true,\n }\n }\n\n const address = await getNameServiceAddress(\n sdkClient,\n value,\n chainType\n )\n\n if (address) {\n const _chainType = getChainTypeFromAddress(address)\n if (_chainType) {\n return {\n address: address,\n addressType: AddressType.NameService,\n chainType: _chainType,\n isValid: true,\n }\n }\n }\n\n throw new Error()\n } catch (_) {\n return {\n isValid: false,\n error: t(\n 'error.title.walletAddressInvalid',\n chain?.name\n ? { context: 'chain', chainName: chain.name }\n : undefined\n ),\n }\n }\n },\n }\n )\n\n return {\n validateAddress,\n isValidating,\n }\n}\n"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"useAddressValidation.js","names":[],"sources":["../../../src/hooks/useAddressValidation.ts"],"sourcesContent":["import type { Chain, ChainType } from '@lifi/sdk'\nimport { getNameServiceAddress } from '@lifi/sdk'\nimport { useChainTypeFromAddress } from '@lifi/widget-provider'\nimport { useMutation } from '@tanstack/react-query'\nimport { useTranslation } from 'react-i18next'\nimport { useSDKClient } from '../providers/SDKClientProvider.js'\n\nexport enum AddressType {\n Address = 0,\n NameService = 1,\n}\n\ntype ValidationArgs = {\n value: string\n chainType?: ChainType\n chain?: Chain\n}\n\ntype ValidResponse = {\n address: string\n addressType: AddressType\n chainType: ChainType\n isValid: true\n}\n\ntype InvalidResponse = {\n error: string\n isValid: false\n}\n\nexport const useAddressValidation = (): {\n validateAddress: (\n args: ValidationArgs\n ) => Promise<ValidResponse | InvalidResponse>\n isValidating: boolean\n} => {\n const { t } = useTranslation()\n const { getChainTypeFromAddress } = useChainTypeFromAddress()\n const sdkClient = useSDKClient()\n\n const { mutateAsync: validateAddress, isPending: isValidating } = useMutation(\n {\n mutationFn: async ({\n value,\n chainType,\n chain,\n }: ValidationArgs): Promise<ValidResponse | InvalidResponse> => {\n try {\n if (!value) {\n throw new Error()\n }\n\n const _chainType = getChainTypeFromAddress(value)\n if (_chainType) {\n return {\n address: value,\n addressType: AddressType.Address,\n chainType: _chainType,\n isValid: true,\n }\n }\n\n const address = await getNameServiceAddress(\n sdkClient,\n value,\n chainType\n )\n\n if (address) {\n const _chainType = getChainTypeFromAddress(address)\n if (_chainType) {\n return {\n address: address,\n addressType: AddressType.NameService,\n chainType: _chainType,\n isValid: true,\n }\n }\n }\n\n throw new Error()\n } catch (_) {\n return {\n isValid: false,\n error: t(\n 'error.title.walletAddressInvalid',\n chain?.name\n ? { context: 'chain', chainName: chain.name }\n : undefined\n ),\n }\n }\n },\n }\n )\n\n return {\n validateAddress,\n isValidating,\n }\n}\n"],"mappings":";;;;;;AAOA,IAAY,cAAL,yBAAA,aAAA;CACL,YAAA,YAAA,aAAA,KAAA;CACA,YAAA,YAAA,iBAAA,KAAA;;AACF,EAAA,CAAA,CAAA;AAoBA,MAAa,6BAKR;CACH,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,EAAE,4BAA4B,wBAAwB;CAC5D,MAAM,YAAY,aAAa;CAE/B,MAAM,EAAE,aAAa,iBAAiB,WAAW,iBAAiB,YAChE,EACE,YAAY,OAAO,EACjB,OACA,WACA,YAC8D;EAC9D,IAAI;GACF,IAAI,CAAC,OACH,MAAM,IAAI,MAAM;GAGlB,MAAM,aAAa,wBAAwB,KAAK;GAChD,IAAI,YACF,OAAO;IACL,SAAS;IACT,aAAA;IACA,WAAW;IACX,SAAS;GACX;GAGF,MAAM,UAAU,MAAM,sBACpB,WACA,OACA,SACF;GAEA,IAAI,SAAS;IACX,MAAM,aAAa,wBAAwB,OAAO;IAClD,IAAI,YACF,OAAO;KACI;KACT,aAAA;KACA,WAAW;KACX,SAAS;IACX;GAEJ;GAEA,MAAM,IAAI,MAAM;EAClB,SAAS,GAAG;GACV,OAAO;IACL,SAAS;IACT,OAAO,EACL,oCACA,OAAO,OACH;KAAE,SAAS;KAAS,WAAW,MAAM;IAAK,IAC1C,KAAA,CACN;GACF;EACF;CACF,EACF,CACF;CAEA,OAAO;EACL;EACA;CACF;AACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { WidgetConfig } from "../types/widget.js";
|
|
2
|
+
import { ChainType, ExtendedChain } from "@lifi/sdk";
|
|
3
|
+
//#region src/hooks/useAvailableChains.d.ts
|
|
4
|
+
type GetChainById = (chainId?: number, chains?: ExtendedChain[]) => ExtendedChain | undefined;
|
|
5
|
+
declare const useAvailableChains: (chainTypes?: ChainType[], widgetConfig?: WidgetConfig) => {
|
|
6
|
+
chains: ExtendedChain[] | undefined;
|
|
7
|
+
getChainById: GetChainById;
|
|
8
|
+
isLoading: boolean;
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { useAvailableChains };
|
|
12
|
+
//# sourceMappingURL=useAvailableChains.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAvailableChains.d.ts","names":[],"sources":["../../../src/hooks/useAvailableChains.ts"],"mappings":";;;KAUK,gBACH,kBACA,SAAS,oBACN;cAUQ,qBACX,aAAa,aACb,eAAe;EAEf,QAAQ;EACR,cAAc;EACd"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ExtendedChain } from "@lifi/sdk";
|
|
2
|
+
//#region src/hooks/useChain.d.ts
|
|
3
|
+
declare const useChain: (chainId?: number) => {
|
|
4
|
+
chain: ExtendedChain | undefined;
|
|
5
|
+
isLoading: boolean;
|
|
6
|
+
getChainById: (chainId?: number, chains?: ExtendedChain[]) => ExtendedChain | undefined;
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { useChain };
|
|
10
|
+
//# sourceMappingURL=useChain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useChain.d.ts","names":[],"sources":["../../../src/hooks/useChain.ts"],"mappings":";;cAIa,WACX;EAEA,OAAO;EACP;EACA,eACE,kBACA,SAAS,oBACN"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useContactSupport.d.ts","names":[],"sources":["../../../src/hooks/useContactSupport.ts"],"mappings":";cAGa,oBAAqB"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FormFieldArray, FormFieldNames } from "../stores/form/types.js";
|
|
2
|
+
//#region src/hooks/useDebouncedWatch.d.ts
|
|
3
|
+
declare const useDebouncedWatch: <T extends FormFieldNames[]>(delay: number, ...name: T) => FormFieldArray<T>;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { useDebouncedWatch };
|
|
6
|
+
//# sourceMappingURL=useDebouncedWatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDebouncedWatch.d.ts","names":[],"sources":["../../../src/hooks/useDebouncedWatch.ts"],"mappings":";;cAIa,oBAAqB,UAAU,kBAC1C,kBACG,MAAM,MACR,eAAe"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { useTokens } from "./useTokens.js";
|
|
2
|
+
import { isSearchMatch } from "../utils/tokenList.js";
|
|
3
|
+
import { usePinnedTokensStore } from "../stores/pinnedTokens/PinnedTokensStore.js";
|
|
4
|
+
import { useMemo } from "react";
|
|
5
|
+
//#region src/hooks/useDisplayedTokens.ts
|
|
6
|
+
const useDisplayedTokens = (selectedChainId, formType, isAllNetworks, search) => {
|
|
7
|
+
const { allTokens, isLoading: isTokensLoading, isSearchLoading } = useTokens(formType, search, isAllNetworks ? void 0 : selectedChainId);
|
|
8
|
+
const pinnedTokens = usePinnedTokensStore((state) => state.pinnedTokens);
|
|
9
|
+
const isPinnedToken = useMemo(() => {
|
|
10
|
+
if (isAllNetworks) {
|
|
11
|
+
const pinnedSet = /* @__PURE__ */ new Set();
|
|
12
|
+
Object.entries(pinnedTokens).forEach(([chainIdStr, addresses]) => {
|
|
13
|
+
const chainId = Number.parseInt(chainIdStr, 10);
|
|
14
|
+
addresses.forEach((address) => {
|
|
15
|
+
pinnedSet.add(`${chainId}-${address.toLowerCase()}`);
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
return (chainId, tokenAddress) => pinnedSet.has(`${chainId}-${tokenAddress.toLowerCase()}`);
|
|
19
|
+
}
|
|
20
|
+
if (selectedChainId) {
|
|
21
|
+
const chainPinnedTokens = pinnedTokens[selectedChainId] || [];
|
|
22
|
+
const pinnedSet = new Set(chainPinnedTokens.map((addr) => addr.toLowerCase()));
|
|
23
|
+
return (chainId, tokenAddress) => chainId === selectedChainId && pinnedSet.has(tokenAddress.toLowerCase());
|
|
24
|
+
}
|
|
25
|
+
}, [
|
|
26
|
+
isAllNetworks,
|
|
27
|
+
selectedChainId,
|
|
28
|
+
pinnedTokens
|
|
29
|
+
]);
|
|
30
|
+
return {
|
|
31
|
+
allTokens,
|
|
32
|
+
displayedTokensList: useMemo(() => {
|
|
33
|
+
return (isAllNetworks ? Object.values(allTokens ?? {}).flat() : selectedChainId ? allTokens?.[selectedChainId] : void 0)?.filter((t) => isSearchMatch(t, search)) ?? [];
|
|
34
|
+
}, [
|
|
35
|
+
allTokens,
|
|
36
|
+
isAllNetworks,
|
|
37
|
+
selectedChainId,
|
|
38
|
+
search
|
|
39
|
+
]),
|
|
40
|
+
isPinnedToken,
|
|
41
|
+
isTokensLoading,
|
|
42
|
+
isSearchLoading
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
//#endregion
|
|
46
|
+
export { useDisplayedTokens };
|
|
47
|
+
|
|
48
|
+
//# sourceMappingURL=useDisplayedTokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDisplayedTokens.js","names":[],"sources":["../../../src/hooks/useDisplayedTokens.ts"],"sourcesContent":["import type { TokenExtended } from '@lifi/sdk'\nimport { useMemo } from 'react'\nimport type { FormType } from '../stores/form/types.js'\nimport { usePinnedTokensStore } from '../stores/pinnedTokens/PinnedTokensStore.js'\nimport { isSearchMatch } from '../utils/tokenList.js'\nimport { useTokens } from './useTokens.js'\n\nexport type IsPinnedToken = (chainId: number, tokenAddress: string) => boolean\n\n// Balance-free core shared by useTokenList and useTokenBalances.\nexport const useDisplayedTokens = (\n selectedChainId?: number,\n formType?: FormType,\n isAllNetworks?: boolean,\n search?: string\n): {\n allTokens: Record<number, TokenExtended[]> | undefined\n displayedTokensList: TokenExtended[]\n isPinnedToken: IsPinnedToken | undefined\n isTokensLoading: boolean\n isSearchLoading: boolean\n} => {\n const {\n allTokens,\n isLoading: isTokensLoading,\n isSearchLoading,\n } = useTokens(formType, search, isAllNetworks ? undefined : selectedChainId)\n\n const pinnedTokens = usePinnedTokensStore((state) => state.pinnedTokens)\n\n const isPinnedToken = useMemo<IsPinnedToken | undefined>(() => {\n if (isAllNetworks) {\n const pinnedSet = new Set<string>()\n Object.entries(pinnedTokens).forEach(([chainIdStr, addresses]) => {\n const chainId = Number.parseInt(chainIdStr, 10)\n addresses.forEach((address) => {\n pinnedSet.add(`${chainId}-${address.toLowerCase()}`)\n })\n })\n return (chainId, tokenAddress) =>\n pinnedSet.has(`${chainId}-${tokenAddress.toLowerCase()}`)\n }\n if (selectedChainId) {\n const chainPinnedTokens = pinnedTokens[selectedChainId] || []\n const pinnedSet = new Set(\n chainPinnedTokens.map((addr) => addr.toLowerCase())\n )\n return (chainId, tokenAddress) =>\n chainId === selectedChainId && pinnedSet.has(tokenAddress.toLowerCase())\n }\n return undefined\n }, [isAllNetworks, selectedChainId, pinnedTokens])\n\n const displayedTokensList = useMemo(() => {\n const tokensByChain = isAllNetworks\n ? Object.values(allTokens ?? {}).flat()\n : selectedChainId\n ? allTokens?.[selectedChainId]\n : undefined\n return tokensByChain?.filter((t) => isSearchMatch(t, search)) ?? []\n }, [allTokens, isAllNetworks, selectedChainId, search])\n\n return {\n allTokens,\n displayedTokensList,\n isPinnedToken,\n isTokensLoading,\n isSearchLoading,\n }\n}\n"],"mappings":";;;;;AAUA,MAAa,sBACX,iBACA,UACA,eACA,WAOG;CACH,MAAM,EACJ,WACA,WAAW,iBACX,oBACE,UAAU,UAAU,QAAQ,gBAAgB,KAAA,IAAY,eAAe;CAE3E,MAAM,eAAe,sBAAsB,UAAU,MAAM,YAAY;CAEvE,MAAM,gBAAgB,cAAyC;EAC7D,IAAI,eAAe;GACjB,MAAM,4BAAY,IAAI,IAAY;GAClC,OAAO,QAAQ,YAAY,CAAC,CAAC,SAAS,CAAC,YAAY,eAAe;IAChE,MAAM,UAAU,OAAO,SAAS,YAAY,EAAE;IAC9C,UAAU,SAAS,YAAY;KAC7B,UAAU,IAAI,GAAG,QAAQ,GAAG,QAAQ,YAAY,GAAG;IACrD,CAAC;GACH,CAAC;GACD,QAAQ,SAAS,iBACf,UAAU,IAAI,GAAG,QAAQ,GAAG,aAAa,YAAY,GAAG;EAC5D;EACA,IAAI,iBAAiB;GACnB,MAAM,oBAAoB,aAAa,oBAAoB,CAAC;GAC5D,MAAM,YAAY,IAAI,IACpB,kBAAkB,KAAK,SAAS,KAAK,YAAY,CAAC,CACpD;GACA,QAAQ,SAAS,iBACf,YAAY,mBAAmB,UAAU,IAAI,aAAa,YAAY,CAAC;EAC3E;CAEF,GAAG;EAAC;EAAe;EAAiB;CAAY,CAAC;CAWjD,OAAO;EACL;EACA,qBAX0B,cAAc;GAMxC,QALsB,gBAClB,OAAO,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC,KAAK,IACpC,kBACE,YAAY,mBACZ,KAAA,EAAA,EACgB,QAAQ,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC;EACpE,GAAG;GAAC;GAAW;GAAe;GAAiB;EAAM,CAIjC;EAClB;EACA;EACA;CACF;AACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Chain } from "@lifi/sdk";
|
|
2
|
+
//#region src/hooks/useExplorer.d.ts
|
|
3
|
+
type TransactionLinkProps = {
|
|
4
|
+
chain?: Chain | number;
|
|
5
|
+
txHash?: string;
|
|
6
|
+
txLink?: string;
|
|
7
|
+
};
|
|
8
|
+
declare const useExplorer: () => {
|
|
9
|
+
getTransactionLink: (props: TransactionLinkProps) => string | undefined;
|
|
10
|
+
getAddressLink: (address: string, chain?: Chain | number) => string;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { useExplorer };
|
|
14
|
+
//# sourceMappingURL=useExplorer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useExplorer.d.ts","names":[],"sources":["../../../src/hooks/useExplorer.ts"],"mappings":";;KAiBK;EACH,QAAQ;EACR;EACA;;cAGW;EACX,qBAAqB,OAAO;EAC5B,iBAAiB,iBAAiB,QAAQ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHeader.d.ts","names":[],"sources":["../../../src/hooks/useHeader.ts"],"mappings":";;iBAIgB,UAAU,eAAe,SAAS"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { RefObject } from "react";
|
|
2
|
+
//#region src/hooks/useListHeight.d.ts
|
|
3
|
+
interface UseContentHeightProps {
|
|
4
|
+
listParentRef: RefObject<HTMLUListElement | HTMLDivElement | null>;
|
|
5
|
+
headerRef?: RefObject<HTMLElement | null>;
|
|
6
|
+
}
|
|
7
|
+
declare const useListHeight: ({ listParentRef, headerRef }: UseContentHeightProps) => {
|
|
8
|
+
listHeight: number;
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { useListHeight };
|
|
12
|
+
//# sourceMappingURL=useListHeight.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useListHeight.d.ts","names":[],"sources":["../../../src/hooks/useListHeight.ts"],"mappings":";;UAoDU;EACR,eAAe,UAAU,mBAAmB;EAC5C,YAAY,UAAU;;cAUX,kBACX,eACA,aACC;EAA0B"}
|
|
@@ -14,6 +14,7 @@ const getContentHeight = (elementId, listParentRef) => {
|
|
|
14
14
|
}
|
|
15
15
|
if (!containerElement || !headerElement) {
|
|
16
16
|
console.warn(`Can't find widget-scrollable-container or widget-header id.`);
|
|
17
|
+
if (listParentElement && oldHeight !== void 0) listParentElement.style.height = oldHeight;
|
|
17
18
|
return 0;
|
|
18
19
|
}
|
|
19
20
|
const { height: containerHeight } = containerElement.getBoundingClientRect();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useListHeight.js","names":[],"sources":["../../../src/hooks/useListHeight.ts"],"sourcesContent":["import { debounce, useTheme } from '@mui/material'\nimport type { RefObject } from 'react'\nimport { useLayoutEffect, useState } from 'react'\nimport {\n ElementId,\n getAppContainer,\n getHeaderElement,\n getScrollableContainer,\n} from '../utils/elements.js'\nimport { useDefaultElementId } from './useDefaultElementId.js'\n\nconst getContentHeight = (\n elementId: string,\n listParentRef: RefObject<HTMLUListElement | HTMLDivElement | null>\n) => {\n const containerElement = getScrollableContainer(elementId)\n\n const headerElement = getHeaderElement(elementId)\n\n const listParentElement = listParentRef?.current\n\n let oldHeight: string | undefined\n\n // This covers the case where in full height flex mode when the browser height is reduced\n // - this allows a virtualised list to be made smaller\n if (listParentElement) {\n oldHeight = listParentElement.style.height\n listParentElement.style.height = '0'\n }\n\n if (!containerElement || !headerElement) {\n console.warn(\n `Can't find ${ElementId.ScrollableContainer} or ${ElementId.Header} id.`\n )\n return 0\n }\n const { height: containerHeight } = containerElement.getBoundingClientRect()\n const { height: headerHeight } = headerElement.getBoundingClientRect()\n\n // This covers the case where in full height flex mode when the browser height is reduced the\n // - this allows a virtualised list to be set to minimum size\n if (listParentElement && oldHeight) {\n listParentElement.style.height = oldHeight\n }\n\n return containerHeight - headerHeight\n}\n\ninterface UseContentHeightProps {\n listParentRef: RefObject<HTMLUListElement | HTMLDivElement | null>\n headerRef?: RefObject<HTMLElement | null>\n}\n\nconst defaultMinListHeight = 360\nconst minMobileListHeight = 160\n\n// NOTE: this hook is implicitly tied to the widget height functionality in the\n// AppExpandedContainer, RelativeContainer and CssBaselineContainer components as defined in AppContainer.ts\n// CSS changes in those components can have implications for the functionality in this hook\n\nexport const useListHeight = ({\n listParentRef,\n headerRef,\n}: UseContentHeightProps): { listHeight: number } => {\n const elementId = useDefaultElementId() ?? ''\n const [contentHeight, setContentHeight] = useState<number>(0)\n const theme = useTheme()\n\n useLayoutEffect(() => {\n const handleResize = () => {\n setContentHeight(getContentHeight(elementId, listParentRef))\n }\n\n const processResize = debounce(() => handleResize(), 40)\n\n // calling this on initial mount prevents the lists resizing appearing glitchy\n handleResize()\n\n const appContainer = getAppContainer(elementId)\n\n let resizeObserver: ResizeObserver\n if (appContainer) {\n resizeObserver = new ResizeObserver(processResize)\n resizeObserver.observe(appContainer)\n }\n\n return () => {\n if (resizeObserver) {\n resizeObserver.disconnect()\n }\n }\n }, [elementId, listParentRef])\n\n const minListHeight =\n theme.container?.height === '100%'\n ? minMobileListHeight\n : defaultMinListHeight\n\n const listHeight = Math.max(\n contentHeight - (headerRef?.current?.offsetHeight ?? 0),\n minListHeight\n )\n\n return {\n listHeight,\n }\n}\n"],"mappings":";;;;;AAWA,MAAM,oBACJ,WACA,kBACG;CACH,MAAM,mBAAmB,uBAAuB,SAAS;CAEzD,MAAM,gBAAgB,iBAAiB,SAAS;CAEhD,MAAM,oBAAoB,eAAe;CAEzC,IAAI;CAIJ,IAAI,mBAAmB;EACrB,YAAY,kBAAkB,MAAM;EACpC,kBAAkB,MAAM,SAAS;CACnC;CAEA,IAAI,CAAC,oBAAoB,CAAC,eAAe;EACvC,QAAQ,KACN,6DACF;
|
|
1
|
+
{"version":3,"file":"useListHeight.js","names":[],"sources":["../../../src/hooks/useListHeight.ts"],"sourcesContent":["import { debounce, useTheme } from '@mui/material'\nimport type { RefObject } from 'react'\nimport { useLayoutEffect, useState } from 'react'\nimport {\n ElementId,\n getAppContainer,\n getHeaderElement,\n getScrollableContainer,\n} from '../utils/elements.js'\nimport { useDefaultElementId } from './useDefaultElementId.js'\n\nconst getContentHeight = (\n elementId: string,\n listParentRef: RefObject<HTMLUListElement | HTMLDivElement | null>\n) => {\n const containerElement = getScrollableContainer(elementId)\n\n const headerElement = getHeaderElement(elementId)\n\n const listParentElement = listParentRef?.current\n\n let oldHeight: string | undefined\n\n // This covers the case where in full height flex mode when the browser height is reduced\n // - this allows a virtualised list to be made smaller\n if (listParentElement) {\n oldHeight = listParentElement.style.height\n listParentElement.style.height = '0'\n }\n\n if (!containerElement || !headerElement) {\n console.warn(\n `Can't find ${ElementId.ScrollableContainer} or ${ElementId.Header} id.`\n )\n // Restore the height we zeroed above before returning early\n if (listParentElement && oldHeight !== undefined) {\n listParentElement.style.height = oldHeight\n }\n return 0\n }\n const { height: containerHeight } = containerElement.getBoundingClientRect()\n const { height: headerHeight } = headerElement.getBoundingClientRect()\n\n // This covers the case where in full height flex mode when the browser height is reduced the\n // - this allows a virtualised list to be set to minimum size\n if (listParentElement && oldHeight) {\n listParentElement.style.height = oldHeight\n }\n\n return containerHeight - headerHeight\n}\n\ninterface UseContentHeightProps {\n listParentRef: RefObject<HTMLUListElement | HTMLDivElement | null>\n headerRef?: RefObject<HTMLElement | null>\n}\n\nconst defaultMinListHeight = 360\nconst minMobileListHeight = 160\n\n// NOTE: this hook is implicitly tied to the widget height functionality in the\n// AppExpandedContainer, RelativeContainer and CssBaselineContainer components as defined in AppContainer.ts\n// CSS changes in those components can have implications for the functionality in this hook\n\nexport const useListHeight = ({\n listParentRef,\n headerRef,\n}: UseContentHeightProps): { listHeight: number } => {\n const elementId = useDefaultElementId() ?? ''\n const [contentHeight, setContentHeight] = useState<number>(0)\n const theme = useTheme()\n\n useLayoutEffect(() => {\n const handleResize = () => {\n setContentHeight(getContentHeight(elementId, listParentRef))\n }\n\n const processResize = debounce(() => handleResize(), 40)\n\n // calling this on initial mount prevents the lists resizing appearing glitchy\n handleResize()\n\n const appContainer = getAppContainer(elementId)\n\n let resizeObserver: ResizeObserver\n if (appContainer) {\n resizeObserver = new ResizeObserver(processResize)\n resizeObserver.observe(appContainer)\n }\n\n return () => {\n if (resizeObserver) {\n resizeObserver.disconnect()\n }\n }\n }, [elementId, listParentRef])\n\n const minListHeight =\n theme.container?.height === '100%'\n ? minMobileListHeight\n : defaultMinListHeight\n\n const listHeight = Math.max(\n contentHeight - (headerRef?.current?.offsetHeight ?? 0),\n minListHeight\n )\n\n return {\n listHeight,\n }\n}\n"],"mappings":";;;;;AAWA,MAAM,oBACJ,WACA,kBACG;CACH,MAAM,mBAAmB,uBAAuB,SAAS;CAEz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useNavigateBack.ts"],"mappings":";cAIa"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePacedRouteExecution.js","names":[],"sources":["../../../src/hooks/usePacedRouteExecution.ts"],"sourcesContent":["import type { ExchangeRateUpdateParams, RouteExtended } from '@lifi/sdk'\nimport { useMemo } from 'react'\nimport { RouteExecutionStatus } from '../stores/routes/types.js'\nimport { usePacedValue } from './usePacedValue.js'\nimport { useRouteExecution } from './useRouteExecution.js'\n\ninterface PacedRouteExecutionProps {\n routeId: string\n onAcceptExchangeRateUpdate?(\n resolver: (value: boolean) => void,\n data: ExchangeRateUpdateParams\n ): void\n}\n\n/**\n * Wraps {@link useRouteExecution} and paces `route`/`status` so the\n * `ExecutionStatusCard` animation has time to play between updates. Only the\n * display is paced — events and store writes happen at the SDK's real speed.\n */\nexport function usePacedRouteExecution({\n routeId,\n onAcceptExchangeRateUpdate,\n}: PacedRouteExecutionProps): {\n executeRoute: () => void\n restartRoute: () => void\n deleteRoute: () => void\n route: RouteExtended | undefined\n status: RouteExecutionStatus | undefined\n} {\n const { executeRoute, restartRoute, deleteRoute, route, status } =\n useRouteExecution({ routeId, onAcceptExchangeRateUpdate })\n\n // Pace route and status as one value so they always match. Skip pacing while\n // Idle, so the review screen shows live data.\n const live = useMemo(() => ({ route, status }), [route, status])\n const display = usePacedValue(live, status !== RouteExecutionStatus.Idle)\n\n return {\n executeRoute,\n restartRoute,\n deleteRoute,\n route: display.route,\n status: display.status,\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"usePacedRouteExecution.js","names":[],"sources":["../../../src/hooks/usePacedRouteExecution.ts"],"sourcesContent":["import type { ExchangeRateUpdateParams, RouteExtended } from '@lifi/sdk'\nimport { useMemo } from 'react'\nimport { RouteExecutionStatus } from '../stores/routes/types.js'\nimport { usePacedValue } from './usePacedValue.js'\nimport { useRouteExecution } from './useRouteExecution.js'\n\ninterface PacedRouteExecutionProps {\n routeId: string\n onAcceptExchangeRateUpdate?(\n resolver: (value: boolean) => void,\n data: ExchangeRateUpdateParams\n ): void\n}\n\n/**\n * Wraps {@link useRouteExecution} and paces `route`/`status` so the\n * `ExecutionStatusCard` animation has time to play between updates. Only the\n * display is paced — events and store writes happen at the SDK's real speed.\n */\nexport function usePacedRouteExecution({\n routeId,\n onAcceptExchangeRateUpdate,\n}: PacedRouteExecutionProps): {\n executeRoute: () => void\n restartRoute: () => void\n deleteRoute: () => void\n route: RouteExtended | undefined\n status: RouteExecutionStatus | undefined\n} {\n const { executeRoute, restartRoute, deleteRoute, route, status } =\n useRouteExecution({ routeId, onAcceptExchangeRateUpdate })\n\n // Pace route and status as one value so they always match. Skip pacing while\n // Idle, so the review screen shows live data.\n const live = useMemo(() => ({ route, status }), [route, status])\n const display = usePacedValue(live, status !== RouteExecutionStatus.Idle)\n\n return {\n executeRoute,\n restartRoute,\n deleteRoute,\n route: display.route,\n status: display.status,\n }\n}\n"],"mappings":";;;;;;;;;;AAmBA,SAAgB,uBAAuB,EACrC,SACA,8BAOA;CACA,MAAM,EAAE,cAAc,cAAc,aAAa,OAAO,WACtD,kBAAkB;EAAE;EAAS;CAA2B,CAAC;CAK3D,MAAM,UAAU,cADH,eAAe;EAAE;EAAO;CAAO,IAAI,CAAC,OAAO,MAAM,CAC7B,GAAG,WAAA,CAAoC;CAExE,OAAO;EACL;EACA;EACA;EACA,OAAO,QAAQ;EACf,QAAQ,QAAQ;CAClB;AACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { RouteExecutionStatus } from "../stores/routes/types.js";
|
|
2
|
+
import { ExchangeRateUpdateParams, RouteExtended } from "@lifi/sdk";
|
|
3
|
+
//#region src/hooks/useRouteExecution.d.ts
|
|
4
|
+
interface RouteExecutionProps {
|
|
5
|
+
routeId: string;
|
|
6
|
+
executeInBackground?: boolean;
|
|
7
|
+
onAcceptExchangeRateUpdate?(resolver: (value: boolean) => void, data: ExchangeRateUpdateParams): void;
|
|
8
|
+
}
|
|
9
|
+
declare const useRouteExecution: ({ routeId, executeInBackground, onAcceptExchangeRateUpdate }: RouteExecutionProps) => {
|
|
10
|
+
executeRoute: () => void;
|
|
11
|
+
restartRoute: () => void;
|
|
12
|
+
deleteRoute: () => void;
|
|
13
|
+
route: RouteExtended | undefined;
|
|
14
|
+
status: RouteExecutionStatus | undefined;
|
|
15
|
+
};
|
|
16
|
+
//#endregion
|
|
17
|
+
export { useRouteExecution };
|
|
18
|
+
//# sourceMappingURL=useRouteExecution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRouteExecution.d.ts","names":[],"sources":["../../../src/hooks/useRouteExecution.ts"],"mappings":";;;UAsBU;EACR;EACA;EACA,4BACE,WAAW,yBACX,MAAM;;cAIG,sBACX,SACA,qBACA,8BACC;EACD;EACA;EACA;EACA,OAAO;EACP,QAAQ"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RouteExecutionStatus } from "../stores/routes/types.js";
|
|
2
|
+
import { RouteExtended } from "@lifi/sdk";
|
|
3
|
+
//#region src/hooks/useRouteExecutionMessage.d.ts
|
|
4
|
+
declare const useRouteExecutionMessage: (route: RouteExtended, status: RouteExecutionStatus) => {
|
|
5
|
+
title: string | undefined;
|
|
6
|
+
message: string | undefined;
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { useRouteExecutionMessage };
|
|
10
|
+
//# sourceMappingURL=useRouteExecutionMessage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRouteExecutionMessage.d.ts","names":[],"sources":["../../../src/hooks/useRouteExecutionMessage.ts"],"mappings":";;;cAQa,2BACX,OAAO,eACP,QAAQ;EACL;EAA2B"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useWidgetConfig } from "../providers/WidgetProvider/WidgetProvider.js";
|
|
2
2
|
import { useAvailableChains } from "./useAvailableChains.js";
|
|
3
|
+
import "../stores/routes/types.js";
|
|
3
4
|
import { getActionMessage } from "../utils/getActionMessage.js";
|
|
4
5
|
import { getErrorMessage } from "../utils/getErrorMessage.js";
|
|
5
6
|
import { useTranslation } from "react-i18next";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRouteExecutionMessage.js","names":[],"sources":["../../../src/hooks/useRouteExecutionMessage.ts"],"sourcesContent":["import type { ExecutionActionType, RouteExtended } from '@lifi/sdk'\nimport { useTranslation } from 'react-i18next'\nimport { useWidgetConfig } from '../providers/WidgetProvider/WidgetProvider.js'\nimport { RouteExecutionStatus } from '../stores/routes/types.js'\nimport { getActionMessage } from '../utils/getActionMessage.js'\nimport { getErrorMessage } from '../utils/getErrorMessage.js'\nimport { useAvailableChains } from './useAvailableChains.js'\n\nexport const useRouteExecutionMessage = (\n route: RouteExtended,\n status: RouteExecutionStatus\n): { title: string | undefined; message: string | undefined } => {\n const { mode, modeOptions } = useWidgetConfig()\n const { t } = useTranslation()\n const { getChainById } = useAvailableChains()\n\n const transactionType =\n route.fromChainId === route.toChainId ? 'swap' : 'bridge'\n\n let title: string | undefined\n let message: string | undefined\n\n switch (status) {\n case RouteExecutionStatus.Pending: {\n // Use the first executing step, not the last one — in a multi-step route\n // the active step is often not the last.\n const activeStep =\n route.steps.find(\n (s) =>\n s.execution?.status === 'PENDING' ||\n s.execution?.status === 'ACTION_REQUIRED'\n ) ?? route.steps.at(-1)\n const lastAction = activeStep?.execution?.actions?.at(-1)\n const actionMessage =\n activeStep && lastAction\n ? getActionMessage(\n t,\n activeStep,\n lastAction.type,\n lastAction.status,\n lastAction.substatus,\n mode,\n modeOptions\n )\n : undefined\n // Fall back to a generic title when the step has no action to describe yet\n // (just after a restart, or before the first action exists).\n title =\n actionMessage?.title ?? t(`main.process.${transactionType}.pending`)\n message = actionMessage?.message\n break\n }\n case RouteExecutionStatus.Done: {\n title =\n mode === 'custom'\n ? t(\n `success.title.${modeOptions?.custom?.type ?? 'checkout'}Successful`\n )\n : t(`success.title.${transactionType}Successful`)\n break\n }\n case RouteExecutionStatus.Done | RouteExecutionStatus.Partial: {\n title = t(`success.title.${transactionType}PartiallySuccessful`)\n message = t('success.message.exchangePartiallySuccessful', {\n tool: route.steps.at(-1)?.toolDetails.name,\n tokenSymbol: route.steps.at(-1)?.action.toToken.symbol,\n })\n break\n }\n case RouteExecutionStatus.Done | RouteExecutionStatus.Refunded: {\n title = t('success.title.refundIssued')\n message = t('success.message.exchangePartiallySuccessful', {\n tool: route.steps.at(-1)?.toolDetails.name,\n tokenSymbol: route.steps.at(-1)?.action.toToken.symbol,\n })\n break\n }\n case RouteExecutionStatus.Failed: {\n const step = route.steps.find(\n (step) => step.execution?.status === 'FAILED'\n )\n if (!step) {\n break\n }\n const action = step.execution?.actions?.find(\n (action) => action.status === 'FAILED'\n ) || {\n status: 'FAILED',\n type: 'EXECUTION' as ExecutionActionType,\n error: step.execution?.error,\n } // synthetic action to represent a failed execution with no actions\n const actionMessage = getErrorMessage(t, getChainById, step, action)\n title = actionMessage.title\n message = actionMessage.message\n break\n }\n }\n\n return { title, message }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useRouteExecutionMessage.js","names":[],"sources":["../../../src/hooks/useRouteExecutionMessage.ts"],"sourcesContent":["import type { ExecutionActionType, RouteExtended } from '@lifi/sdk'\nimport { useTranslation } from 'react-i18next'\nimport { useWidgetConfig } from '../providers/WidgetProvider/WidgetProvider.js'\nimport { RouteExecutionStatus } from '../stores/routes/types.js'\nimport { getActionMessage } from '../utils/getActionMessage.js'\nimport { getErrorMessage } from '../utils/getErrorMessage.js'\nimport { useAvailableChains } from './useAvailableChains.js'\n\nexport const useRouteExecutionMessage = (\n route: RouteExtended,\n status: RouteExecutionStatus\n): { title: string | undefined; message: string | undefined } => {\n const { mode, modeOptions } = useWidgetConfig()\n const { t } = useTranslation()\n const { getChainById } = useAvailableChains()\n\n const transactionType =\n route.fromChainId === route.toChainId ? 'swap' : 'bridge'\n\n let title: string | undefined\n let message: string | undefined\n\n switch (status) {\n case RouteExecutionStatus.Pending: {\n // Use the first executing step, not the last one — in a multi-step route\n // the active step is often not the last.\n const activeStep =\n route.steps.find(\n (s) =>\n s.execution?.status === 'PENDING' ||\n s.execution?.status === 'ACTION_REQUIRED'\n ) ?? route.steps.at(-1)\n const lastAction = activeStep?.execution?.actions?.at(-1)\n const actionMessage =\n activeStep && lastAction\n ? getActionMessage(\n t,\n activeStep,\n lastAction.type,\n lastAction.status,\n lastAction.substatus,\n mode,\n modeOptions\n )\n : undefined\n // Fall back to a generic title when the step has no action to describe yet\n // (just after a restart, or before the first action exists).\n title =\n actionMessage?.title ?? t(`main.process.${transactionType}.pending`)\n message = actionMessage?.message\n break\n }\n case RouteExecutionStatus.Done: {\n title =\n mode === 'custom'\n ? t(\n `success.title.${modeOptions?.custom?.type ?? 'checkout'}Successful`\n )\n : t(`success.title.${transactionType}Successful`)\n break\n }\n case RouteExecutionStatus.Done | RouteExecutionStatus.Partial: {\n title = t(`success.title.${transactionType}PartiallySuccessful`)\n message = t('success.message.exchangePartiallySuccessful', {\n tool: route.steps.at(-1)?.toolDetails.name,\n tokenSymbol: route.steps.at(-1)?.action.toToken.symbol,\n })\n break\n }\n case RouteExecutionStatus.Done | RouteExecutionStatus.Refunded: {\n title = t('success.title.refundIssued')\n message = t('success.message.exchangePartiallySuccessful', {\n tool: route.steps.at(-1)?.toolDetails.name,\n tokenSymbol: route.steps.at(-1)?.action.toToken.symbol,\n })\n break\n }\n case RouteExecutionStatus.Failed: {\n const step = route.steps.find(\n (step) => step.execution?.status === 'FAILED'\n )\n if (!step) {\n break\n }\n const action = step.execution?.actions?.find(\n (action) => action.status === 'FAILED'\n ) || {\n status: 'FAILED',\n type: 'EXECUTION' as ExecutionActionType,\n error: step.execution?.error,\n } // synthetic action to represent a failed execution with no actions\n const actionMessage = getErrorMessage(t, getChainById, step, action)\n title = actionMessage.title\n message = actionMessage.message\n break\n }\n }\n\n return { title, message }\n}\n"],"mappings":";;;;;;;AAQA,MAAa,4BACX,OACA,WAC+D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,gBAAgB,GAAG,cAAc,MAPxC,KAAK,WAAW,SAAS,MACrC,WAAW,OAAO,WAAW,QAChC,KAAK;IACH,QAAQ;IACR,MAAM;IACN,OAAO,KAAK,WAAW;GACzB,CACmE;GACnE,QAAQ,cAAc;GACtB,UAAU,cAAc;GACxB;EACF;CACF;CAEA,OAAO;EAAE;EAAO;CAAQ;AAC1B"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ExtendedChain, Route } from "@lifi/sdk";
|
|
2
|
+
//#region src/hooks/useRoutes.d.ts
|
|
3
|
+
interface RoutesProps {
|
|
4
|
+
observableRoute?: Route;
|
|
5
|
+
/**
|
|
6
|
+
* Address to quote from when no wallet is connected. Treated as a non-signing
|
|
7
|
+
* placeholder, so signer-dependent (relayer/permit2) quotes are skipped.
|
|
8
|
+
*/
|
|
9
|
+
quoteFromAddress?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Keep showing the previous result while a new query (e.g. a token/amount
|
|
12
|
+
* change) is fetching, instead of clearing to a loading state.
|
|
13
|
+
*/
|
|
14
|
+
keepPreviousData?: boolean;
|
|
15
|
+
}
|
|
16
|
+
declare const useRoutes: ({ observableRoute, quoteFromAddress, keepPreviousData: keepPreviousDataEnabled }?: RoutesProps) => {
|
|
17
|
+
routes: Route[] | undefined;
|
|
18
|
+
isLoading: boolean;
|
|
19
|
+
isFetching: boolean;
|
|
20
|
+
isFetched: boolean;
|
|
21
|
+
isError: boolean;
|
|
22
|
+
dataUpdatedAt: number;
|
|
23
|
+
refetchTime: number;
|
|
24
|
+
refetch: () => void;
|
|
25
|
+
fromChain: ExtendedChain | undefined;
|
|
26
|
+
toChain: ExtendedChain | undefined;
|
|
27
|
+
queryKey: readonly unknown[];
|
|
28
|
+
setReviewableRoute: (route: Route) => void;
|
|
29
|
+
};
|
|
30
|
+
//#endregion
|
|
31
|
+
export { useRoutes };
|
|
32
|
+
//# sourceMappingURL=useRoutes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRoutes.d.ts","names":[],"sources":["../../../src/hooks/useRoutes.ts"],"mappings":";;UA2CU;EACR,kBAAkB;;;;;EAKlB;;;;;EAKA;;cAGW,cACX,iBACA,kBACA,kBAAkB,4BACjB;EACD,QAAQ;EACR;EACA;EACA;EACA;EACA;EACA;EACA;EACA,WAAW;EACX,SAAS;EACT;EACA,qBAAqB,OAAO"}
|
|
@@ -17,12 +17,12 @@ import { useIsBatchingSupported } from "./useIsBatchingSupported.js";
|
|
|
17
17
|
import { useToken } from "./useToken.js";
|
|
18
18
|
import { ChainType, LiFiErrorCode, convertQuoteToRoute, getContractCallsQuote, getRelayerQuote, getRoutes, parseUnits } from "@lifi/sdk";
|
|
19
19
|
import { useCallback, useMemo } from "react";
|
|
20
|
-
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
20
|
+
import { keepPreviousData, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
21
21
|
import { useChainTypeFromAddress, useEthereumContext } from "@lifi/widget-provider";
|
|
22
22
|
import { useAccount } from "@lifi/wallet-management";
|
|
23
23
|
//#region src/hooks/useRoutes.ts
|
|
24
24
|
const refetchTime = 6e4;
|
|
25
|
-
const useRoutes = ({ observableRoute } = {}) => {
|
|
25
|
+
const useRoutes = ({ observableRoute, quoteFromAddress, keepPreviousData: keepPreviousDataEnabled } = {}) => {
|
|
26
26
|
const { mode, modeOptions, contractTool, bridges, exchanges, feeConfig, useRelayerRoutes, keyPrefix } = useWidgetConfig();
|
|
27
27
|
const sdkClient = useSDKClient();
|
|
28
28
|
const setExecutableRoute = useSetExecutableRoute();
|
|
@@ -53,7 +53,9 @@ const useRoutes = ({ observableRoute } = {}) => {
|
|
|
53
53
|
const { account } = useAccount({ chainType: fromChain?.chainType });
|
|
54
54
|
const { isBatchingSupported, isBatchingSupportedLoading } = useIsBatchingSupported(fromChain, account.address);
|
|
55
55
|
const hasAmount = mode === "limit" ? Number(fromTokenAmount) > 0 && Number(toTokenAmount) > 0 : Number(fromTokenAmount) > 0 || Number(toTokenAmount) > 0;
|
|
56
|
-
const
|
|
56
|
+
const customType = mode === "custom" ? modeOptions?.custom?.type : void 0;
|
|
57
|
+
const contractCallQuoteEnabled = mode === "custom" && Boolean(contractCalls?.length) ? Boolean(account.address) : mode !== "custom" || customType === "deposit";
|
|
58
|
+
const effectiveFromAddress = account.address ?? quoteFromAddress;
|
|
57
59
|
const hasToAddressAndChainTypeSatisfied = !!toChain && !!toAddress && getChainTypeFromAddress(toAddress) === toChain.chainType;
|
|
58
60
|
const isToAddressSatisfied = toAddress ? hasToAddressAndChainTypeSatisfied : true;
|
|
59
61
|
const toWalletAddress = toAddress || void 0;
|
|
@@ -63,7 +65,7 @@ const useRoutes = ({ observableRoute } = {}) => {
|
|
|
63
65
|
const isEnabled = Boolean(Number(fromChain?.id)) && Boolean(Number(toChain?.id)) && Boolean(fromToken?.address) && Boolean(toToken?.address) && !Number.isNaN(slippage) && hasAmount && isToAddressSatisfied && contractCallQuoteEnabled && !isBatchingSupportedLoading;
|
|
64
66
|
const queryKey = useMemo(() => [
|
|
65
67
|
getQueryKey("routes", keyPrefix),
|
|
66
|
-
|
|
68
|
+
effectiveFromAddress,
|
|
67
69
|
fromChain?.id,
|
|
68
70
|
fromToken?.address,
|
|
69
71
|
fromTokenAmount,
|
|
@@ -92,7 +94,7 @@ const useRoutes = ({ observableRoute } = {}) => {
|
|
|
92
94
|
observableRoute?.id
|
|
93
95
|
], [
|
|
94
96
|
keyPrefix,
|
|
95
|
-
|
|
97
|
+
effectiveFromAddress,
|
|
96
98
|
fromChain?.id,
|
|
97
99
|
fromToken?.address,
|
|
98
100
|
fromTokenAmount,
|
|
@@ -122,7 +124,7 @@ const useRoutes = ({ observableRoute } = {}) => {
|
|
|
122
124
|
observableRoute?.id
|
|
123
125
|
]);
|
|
124
126
|
const { getIntermediateRoutes, setIntermediateRoutes } = useIntermediateRoutesStore();
|
|
125
|
-
const { data, isLoading, isFetching, isFetched, dataUpdatedAt, refetch } = useQuery({
|
|
127
|
+
const { data, isLoading, isFetching, isFetched, isError, dataUpdatedAt, refetch } = useQuery({
|
|
126
128
|
queryKey,
|
|
127
129
|
queryFn: async ({ queryKey: [_, fromAddress, fromChainId, fromTokenAddress, fromTokenAmount, toAddress, toChainId, toTokenAddress, toTokenAmount, validUntilDuration, partiallyFillable, contractCalls, slippage = void 0, swapOnly, disabledBridges, disabledExchanges, allowedBridges, allowedExchanges, routePriority, mode, allowSwitchChain, enabledRefuel, gasRecommendationFromAmount, configuredFee, disableMessageSigning, isBatchingSupported, isPrivate, _observableRouteId], signal }) => {
|
|
128
130
|
const fromAmount = parseUnits(fromTokenAmount, fromToken.decimals);
|
|
@@ -147,7 +149,7 @@ const useRoutes = ({ observableRoute } = {}) => {
|
|
|
147
149
|
toAmount,
|
|
148
150
|
slippage: formattedSlippage
|
|
149
151
|
});
|
|
150
|
-
if (mode === "custom" && contractCalls && toAmount) {
|
|
152
|
+
if (mode === "custom" && contractCalls?.length && toAmount) {
|
|
151
153
|
const contractCallQuote = await getContractCallsQuote(sdkClient, {
|
|
152
154
|
fromAddress,
|
|
153
155
|
fromChain: fromChainId,
|
|
@@ -180,7 +182,7 @@ const useRoutes = ({ observableRoute } = {}) => {
|
|
|
180
182
|
if (fromChainId === toChainId && fromTokenAddress === toTokenAddress && !(mode === "custom" && modeOptions?.custom?.type === "deposit")) return;
|
|
181
183
|
const isObservableRelayerRoute = observableRoute?.steps?.some((step) => !!isGaslessStep?.(step, fromChain));
|
|
182
184
|
const shouldUseMainRoutes = !observableRoute || !isObservableRelayerRoute;
|
|
183
|
-
const shouldUseRelayerQuote = mode !== "limit" && fromAddress && fromChain?.chainType === ChainType.EVM && fromChain.permit2 && fromChain.permit2Proxy && fromChain.relayerSupported && fromChain.nativeToken.address !== fromTokenAddress && useRelayerRoutes && !isBatchingSupported && (!observableRoute || isObservableRelayerRoute);
|
|
185
|
+
const shouldUseRelayerQuote = mode !== "limit" && account.address && fromAddress && fromChain?.chainType === ChainType.EVM && fromChain.permit2 && fromChain.permit2Proxy && fromChain.relayerSupported && fromChain.nativeToken.address !== fromTokenAddress && useRelayerRoutes && !isBatchingSupported && (!observableRoute || isObservableRelayerRoute);
|
|
184
186
|
const limitOrderRouteParams = mode === "limit" ? {
|
|
185
187
|
toAmount: toAmount?.toString(),
|
|
186
188
|
validUntil: Math.floor(Date.now() / 1e3) + validUntilDuration,
|
|
@@ -277,6 +279,7 @@ const useRoutes = ({ observableRoute } = {}) => {
|
|
|
277
279
|
},
|
|
278
280
|
enabled: isEnabled,
|
|
279
281
|
staleTime: refetchTime,
|
|
282
|
+
placeholderData: keepPreviousDataEnabled ? keepPreviousData : void 0,
|
|
280
283
|
refetchInterval(query) {
|
|
281
284
|
return Math.min(Math.abs(refetchTime - (Date.now() - query.state.dataUpdatedAt)), refetchTime);
|
|
282
285
|
},
|
|
@@ -305,6 +308,7 @@ const useRoutes = ({ observableRoute } = {}) => {
|
|
|
305
308
|
isLoading: isEnabled && isLoading,
|
|
306
309
|
isFetching,
|
|
307
310
|
isFetched,
|
|
311
|
+
isError,
|
|
308
312
|
dataUpdatedAt,
|
|
309
313
|
refetchTime,
|
|
310
314
|
refetch,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRoutes.js","names":[],"sources":["../../../src/hooks/useRoutes.ts"],"sourcesContent":["import type { ExtendedChain, Route, Token } from '@lifi/sdk'\nimport {\n ChainType,\n convertQuoteToRoute,\n getContractCallsQuote,\n getRelayerQuote,\n getRoutes,\n LiFiErrorCode,\n parseUnits,\n} from '@lifi/sdk'\nimport { useAccount } from '@lifi/wallet-management'\nimport {\n useChainTypeFromAddress,\n useEthereumContext,\n} from '@lifi/widget-provider'\nimport { useQuery, useQueryClient } from '@tanstack/react-query'\nimport { useCallback, useMemo } from 'react'\nimport { useSDKClient } from '../providers/SDKClientProvider.js'\nimport { useWidgetConfig } from '../providers/WidgetProvider/WidgetProvider.js'\nimport { useFieldValues } from '../stores/form/useFieldValues.js'\nimport { useNavigationTabsStore } from '../stores/navigationTabs/useNavigationTabsStore.js'\nimport { useIntermediateRoutesStore } from '../stores/routes/useIntermediateRoutesStore.js'\nimport { useSetExecutableRoute } from '../stores/routes/useSetExecutableRoute.js'\nimport { defaultSlippage } from '../stores/settings/createSettingsStore.js'\nimport { useSettings } from '../stores/settings/useSettings.js'\nimport { WidgetEvent } from '../types/events.js'\nimport type { TokensByChain } from '../types/token.js'\nimport { getQueryKey } from '../utils/queries.js'\nimport { updateTokenInCache } from '../utils/token.js'\nimport { useChain } from './useChain.js'\nimport { useDebouncedWatch } from './useDebouncedWatch.js'\nimport { useGasRefuel } from './useGasRefuel.js'\nimport { useIsBatchingSupported } from './useIsBatchingSupported.js'\nimport { useSwapOnly } from './useSwapOnly.js'\nimport { useToken } from './useToken.js'\nimport { useWidgetEvents } from './useWidgetEvents.js'\n\nconst refetchTime = 60_000\n\ninterface RoutesProps {\n observableRoute?: Route\n}\n\nexport const useRoutes = ({\n observableRoute,\n}: RoutesProps = {}): {\n routes: Route[] | undefined\n isLoading: boolean\n isFetching: boolean\n isFetched: boolean\n dataUpdatedAt: number\n refetchTime: number\n refetch: () => void\n fromChain: ExtendedChain | undefined\n toChain: ExtendedChain | undefined\n queryKey: readonly unknown[]\n setReviewableRoute: (route: Route) => void\n} => {\n const {\n mode,\n modeOptions,\n contractTool,\n bridges,\n exchanges,\n feeConfig,\n useRelayerRoutes,\n keyPrefix,\n } = useWidgetConfig()\n const sdkClient = useSDKClient()\n const setExecutableRoute = useSetExecutableRoute()\n const queryClient = useQueryClient()\n const emitter = useWidgetEvents()\n const swapOnly = useSwapOnly()\n const isPrivate = useNavigationTabsStore(\n (state) => state.activeTab === 'private'\n )\n\n const {\n disabledBridges,\n disabledExchanges,\n enabledBridges,\n enabledExchanges,\n enabledAutoRefuel,\n routePriority,\n slippage,\n } = useSettings([\n 'disabledBridges',\n 'disabledExchanges',\n 'enabledBridges',\n 'enabledExchanges',\n 'enabledAutoRefuel',\n 'routePriority',\n 'slippage',\n ])\n const [fromTokenAmount] = useDebouncedWatch(500, 'fromAmount')\n // Debounce toAmount like fromAmount to avoid a request per keystroke\n const [toTokenAmount] = useDebouncedWatch(500, 'toAmount')\n const [\n fromChainId,\n fromTokenAddress,\n toAddress,\n toChainId,\n toTokenAddress,\n contractCalls,\n ] = useFieldValues(\n 'fromChain',\n 'fromToken',\n 'toAddress',\n 'toChain',\n 'toToken',\n 'contractCalls'\n )\n const [validUntilDuration, partiallyFillable] = useFieldValues(\n 'validUntil',\n 'partiallyFillable'\n )\n const { token: fromToken } = useToken(fromChainId, fromTokenAddress)\n const { token: toToken } = useToken(toChainId, toTokenAddress)\n const { chain: fromChain } = useChain(fromChainId)\n const { chain: toChain } = useChain(toChainId)\n const { enabled: enabledRefuel, fromAmount: gasRecommendationFromAmount } =\n useGasRefuel()\n const { getChainTypeFromAddress } = useChainTypeFromAddress()\n const { isGaslessStep, disableMessageSigning } = useEthereumContext()\n const { account } = useAccount({ chainType: fromChain?.chainType })\n const { isBatchingSupported, isBatchingSupportedLoading } =\n useIsBatchingSupported(fromChain, account.address)\n\n // In limit mode toAmount is the user's limit target, derived from the sell\n // amount and limit price. It's keyed and sent to the backend so changing the\n // limit fetches a fresh quote. The receive card is read-only (it displays the\n // quote and never writes toAmount back), so keying on it can't loop. Both a\n // sell amount and a limit price (→ toAmount) are required before fetching.\n const hasAmount =\n mode === 'limit'\n ? Number(fromTokenAmount) > 0 && Number(toTokenAmount) > 0\n : Number(fromTokenAmount) > 0 || Number(toTokenAmount) > 0\n\n const contractCallQuoteEnabled: boolean =\n mode === 'custom' ? Boolean(contractCalls && account.address) : true\n\n // When we bridge between ecosystems we need to be sure toAddress is set and has the same chainType as toChain\n // If toAddress is set, it must have the same chainType as toChain\n const hasToAddressAndChainTypeSatisfied: boolean =\n !!toChain &&\n !!toAddress &&\n getChainTypeFromAddress(toAddress) === toChain.chainType\n // We need to check for toAddress only if it is set\n const isToAddressSatisfied = toAddress\n ? hasToAddressAndChainTypeSatisfied\n : true\n\n // toAddress might be an empty string, but we need to pass undefined if there is no value\n const toWalletAddress = toAddress || undefined\n\n // We need to send the full allowed tools array if custom tool settings are applied\n const allowedBridges =\n bridges?.allow?.length || bridges?.deny?.length ? enabledBridges : undefined\n const allowedExchanges =\n exchanges?.allow?.length || exchanges?.deny?.length\n ? enabledExchanges\n : undefined\n const allowSwitchChain = sdkClient.config?.routeOptions?.allowSwitchChain\n\n const isEnabled =\n Boolean(Number(fromChain?.id)) &&\n Boolean(Number(toChain?.id)) &&\n Boolean(fromToken?.address) &&\n Boolean(toToken?.address) &&\n !Number.isNaN(slippage) &&\n hasAmount &&\n isToAddressSatisfied &&\n contractCallQuoteEnabled &&\n !isBatchingSupportedLoading\n\n // Some values should be strictly typed and isEnabled ensures that\n const queryKey = useMemo(\n () =>\n [\n getQueryKey('routes', keyPrefix),\n account.address,\n fromChain?.id as number,\n fromToken?.address as string,\n fromTokenAmount,\n toWalletAddress,\n toChain?.id as number,\n toToken?.address as string,\n toTokenAmount,\n validUntilDuration,\n partiallyFillable,\n contractCalls,\n slippage,\n swapOnly,\n disabledBridges,\n disabledExchanges,\n allowedBridges,\n allowedExchanges,\n routePriority,\n mode,\n allowSwitchChain,\n enabledRefuel && enabledAutoRefuel,\n gasRecommendationFromAmount,\n feeConfig?.fee,\n disableMessageSigning,\n !!isBatchingSupported,\n isPrivate,\n observableRoute?.id,\n ] as const,\n [\n keyPrefix,\n account.address,\n fromChain?.id,\n fromToken?.address,\n fromTokenAmount,\n toWalletAddress,\n toChain?.id,\n toToken?.address,\n toTokenAmount,\n validUntilDuration,\n partiallyFillable,\n contractCalls,\n slippage,\n swapOnly,\n disabledBridges,\n disabledExchanges,\n allowedBridges,\n allowedExchanges,\n routePriority,\n mode,\n allowSwitchChain,\n enabledRefuel,\n enabledAutoRefuel,\n gasRecommendationFromAmount,\n feeConfig?.fee,\n disableMessageSigning,\n isBatchingSupported,\n isPrivate,\n observableRoute?.id,\n ]\n )\n\n const { getIntermediateRoutes, setIntermediateRoutes } =\n useIntermediateRoutesStore()\n\n const { data, isLoading, isFetching, isFetched, dataUpdatedAt, refetch } =\n useQuery({\n queryKey,\n queryFn: async ({\n queryKey: [\n _,\n fromAddress,\n fromChainId,\n fromTokenAddress,\n fromTokenAmount,\n toAddress,\n toChainId,\n toTokenAddress,\n toTokenAmount,\n validUntilDuration,\n partiallyFillable,\n contractCalls,\n slippage = defaultSlippage,\n swapOnly,\n disabledBridges,\n disabledExchanges,\n allowedBridges,\n allowedExchanges,\n routePriority,\n mode,\n allowSwitchChain,\n enabledRefuel,\n gasRecommendationFromAmount,\n configuredFee,\n disableMessageSigning,\n isBatchingSupported,\n isPrivate,\n // _observableRouteId must be the last element in the query key\n _observableRouteId,\n ],\n signal,\n }) => {\n const fromAmount = parseUnits(fromTokenAmount, fromToken!.decimals)\n const toAmount = toTokenAmount\n ? parseUnits(toTokenAmount, toToken!.decimals)\n : undefined\n const formattedSlippage = slippage\n ? Number.parseFloat(slippage) / 100\n : defaultSlippage\n\n const allowBridges = swapOnly\n ? []\n : observableRoute\n ? observableRoute.steps.flatMap((step) =>\n step.includedSteps.reduce((toolKeys, includedStep) => {\n if (includedStep.type === 'cross') {\n toolKeys.push(includedStep.toolDetails.key)\n }\n return toolKeys\n }, [] as string[])\n )\n : allowedBridges\n const allowExchanges = observableRoute\n ? observableRoute.steps.flatMap((step) =>\n step.includedSteps.reduce((toolKeys, includedStep) => {\n if (includedStep.type === 'swap') {\n toolKeys.push(includedStep.toolDetails.key)\n }\n return toolKeys\n }, [] as string[])\n )\n : allowedExchanges\n\n const calculatedFee = await feeConfig?.calculateFee?.({\n fromChain: fromChain!,\n toChain: toChain!,\n fromToken: fromToken!,\n toToken: toToken!,\n fromAddress,\n toAddress,\n fromAmount,\n toAmount,\n slippage: formattedSlippage,\n })\n\n if (mode === 'custom' && contractCalls && toAmount) {\n const contractCallQuote = await getContractCallsQuote(\n sdkClient,\n {\n // Contract calls are enabled only when fromAddress is set\n fromAddress: fromAddress as string,\n fromChain: fromChainId,\n fromToken: fromTokenAddress,\n toAmount: toAmount.toString(),\n toChain: toChainId,\n toToken: toTokenAddress,\n contractCalls,\n denyBridges: disabledBridges.length ? disabledBridges : undefined,\n denyExchanges: disabledExchanges.length\n ? disabledExchanges\n : undefined,\n allowBridges,\n allowExchanges,\n toFallbackAddress: toAddress,\n slippage: formattedSlippage,\n fee: calculatedFee || configuredFee,\n },\n { signal }\n )\n\n contractCallQuote.action.toToken = toToken!\n\n const customStep =\n mode === 'custom'\n ? contractCallQuote.includedSteps?.find(\n (step) => step.type === 'custom'\n )\n : undefined\n\n if (customStep && contractTool) {\n const toolDetails = {\n key: contractTool.name,\n name: contractTool.name,\n logoURI: contractTool.logoURI,\n }\n customStep.toolDetails = toolDetails\n contractCallQuote.toolDetails = toolDetails\n }\n\n const route: Route = convertQuoteToRoute(contractCallQuote)\n\n return [route]\n }\n\n // Prevent sending a request for the same chain token combinations.\n // Exception: proceed anyway if mode is custom and modeOptions custom type is deposit\n if (\n fromChainId === toChainId &&\n fromTokenAddress === toTokenAddress &&\n !(mode === 'custom' && modeOptions?.custom?.type === 'deposit')\n ) {\n return\n }\n\n const isObservableRelayerRoute = observableRoute?.steps?.some(\n (step) => !!isGaslessStep?.(step, fromChain)\n )\n\n const shouldUseMainRoutes =\n !observableRoute || !isObservableRelayerRoute\n const shouldUseRelayerQuote =\n // Relayer quotes don't support limit-order params\n mode !== 'limit' &&\n fromAddress &&\n fromChain?.chainType === ChainType.EVM &&\n fromChain.permit2 &&\n fromChain.permit2Proxy &&\n fromChain.relayerSupported &&\n fromChain.nativeToken.address !== fromTokenAddress &&\n useRelayerRoutes &&\n !isBatchingSupported &&\n (!observableRoute || isObservableRelayerRoute)\n\n const limitOrderRouteParams =\n mode === 'limit'\n ? {\n toAmount: toAmount?.toString(),\n validUntil: Math.floor(Date.now() / 1000) + validUntilDuration,\n partiallyFillable: partiallyFillable,\n }\n : undefined\n\n const mainRoutesPromise = shouldUseMainRoutes\n ? getRoutes(\n sdkClient,\n {\n fromAddress,\n fromAmount: fromAmount.toString(),\n fromChainId,\n fromTokenAddress,\n toAddress,\n toChainId,\n toTokenAddress,\n fromAmountForGas:\n enabledRefuel && gasRecommendationFromAmount\n ? gasRecommendationFromAmount\n : undefined,\n ...limitOrderRouteParams,\n options: {\n allowSwitchChain:\n mode === 'refuel' ? false : allowSwitchChain,\n bridges:\n allowBridges?.length || disabledBridges.length\n ? {\n allow: allowBridges,\n deny: disabledBridges.length\n ? disabledBridges\n : undefined,\n }\n : undefined,\n exchanges:\n allowExchanges?.length || disabledExchanges.length\n ? {\n allow: allowExchanges,\n deny: disabledExchanges.length\n ? disabledExchanges\n : undefined,\n }\n : undefined,\n order: routePriority,\n slippage: formattedSlippage,\n fee: calculatedFee || configuredFee,\n executionType: disableMessageSigning ? 'transaction' : 'all',\n ...(isPrivate && { private: true }),\n },\n },\n { signal }\n )\n : Promise.resolve(null)\n\n const relayerQuotePromise = shouldUseRelayerQuote\n ? getRelayerQuote(\n sdkClient,\n {\n fromAddress,\n fromAmount: fromAmount.toString(),\n fromChain: fromChainId,\n fromToken: fromTokenAddress,\n toAddress,\n toChain: toChainId,\n toToken: toTokenAddress,\n fromAmountForGas:\n enabledRefuel && gasRecommendationFromAmount\n ? gasRecommendationFromAmount\n : undefined,\n order: routePriority,\n slippage: formattedSlippage,\n fee: calculatedFee || configuredFee,\n ...(allowBridges?.length || disabledBridges.length\n ? {\n allowBridges: allowBridges,\n denyBridges: disabledBridges.length\n ? disabledBridges\n : undefined,\n }\n : undefined),\n ...(allowExchanges?.length || disabledExchanges.length\n ? {\n allowExchanges: allowExchanges,\n denyExchanges: disabledExchanges.length\n ? disabledExchanges\n : undefined,\n }\n : undefined),\n },\n { signal }\n )\n .then(convertQuoteToRoute)\n .catch(() => null)\n : Promise.resolve(null)\n\n // Wait for the main routes to complete first\n const routesResult = await mainRoutesPromise\n\n if (routesResult?.routes[0] && fromAddress) {\n // Update local tokens cache to keep priceUSD in sync\n const { fromToken, toToken } = routesResult.routes[0]\n ;[fromToken, toToken].forEach((token) => {\n // Update main tokens cache (verified)\n queryClient.setQueriesData<TokensByChain>(\n { queryKey: [getQueryKey('tokens', keyPrefix)] },\n (data) => updateTokenInCache(data, token)\n )\n\n // Update search tokens cache (unverified) - matches any search query\n queryClient.setQueriesData<TokensByChain>(\n {\n queryKey: [getQueryKey('tokens-search', keyPrefix)],\n exact: false,\n },\n (data) => updateTokenInCache(data, token)\n )\n\n queryClient.setQueriesData<Token[]>(\n {\n queryKey: [\n getQueryKey('token-balances', keyPrefix),\n fromAddress,\n token.chainId,\n ],\n },\n (data) => {\n if (data) {\n const clonedData = [...data]\n const index = clonedData.findIndex(\n (dataToken) => dataToken.address === token.address\n )\n if (index >= 0) {\n clonedData[index] = {\n ...clonedData[index],\n ...token,\n }\n }\n return clonedData\n }\n }\n )\n })\n }\n\n const initialRoutes = routesResult?.routes ?? []\n\n if (shouldUseRelayerQuote && initialRoutes.length) {\n setIntermediateRoutes(queryKey, initialRoutes)\n emitter.emit(WidgetEvent.AvailableRoutes, initialRoutes)\n // Return early if we're only using main routes\n } else if (shouldUseMainRoutes) {\n // If we don't need relayer quote, return the initial routes\n emitter.emit(WidgetEvent.AvailableRoutes, initialRoutes)\n return initialRoutes\n }\n\n const relayerRouteResult = await relayerQuotePromise\n // If we have a relayer route, add it to the routes array\n if (relayerRouteResult) {\n // Insert the relayer route at position 1 (after the first route)\n initialRoutes.splice(1, 0, relayerRouteResult)\n // Emit the updated routes\n emitter.emit(WidgetEvent.AvailableRoutes, initialRoutes)\n }\n\n return initialRoutes\n },\n enabled: isEnabled,\n staleTime: refetchTime,\n refetchInterval(query) {\n return Math.min(\n Math.abs(refetchTime - (Date.now() - query.state.dataUpdatedAt)),\n refetchTime\n )\n },\n retry(failureCount, error: any) {\n if (process.env.NODE_ENV === 'development') {\n console.warn('Route query failed:', { failureCount, error })\n }\n if (failureCount >= 3) {\n return false\n }\n if (error?.code === LiFiErrorCode.NotFound) {\n return false\n }\n return true\n },\n })\n\n const setReviewableRoute = useCallback(\n (route: Route) => {\n const queryDataKey = queryKey.toSpliced(queryKey.length - 1, 1, route.id)\n queryClient.setQueryData(queryDataKey, [route], {\n updatedAt: dataUpdatedAt || Date.now(),\n })\n setExecutableRoute(route)\n },\n [queryClient, dataUpdatedAt, setExecutableRoute, queryKey]\n )\n\n return {\n routes: data || getIntermediateRoutes(queryKey),\n isLoading: isEnabled && isLoading,\n isFetching,\n isFetched,\n dataUpdatedAt,\n refetchTime,\n refetch,\n fromChain,\n toChain,\n queryKey,\n setReviewableRoute,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAM,cAAc;AAMpB,MAAa,aAAa,EACxB,oBACe,CAAC,MAYb;CACH,MAAM,EACJ,MACA,aACA,cACA,SACA,WACA,WACA,kBACA,cACE,gBAAgB;CACpB,MAAM,YAAY,aAAa;CAC/B,MAAM,qBAAqB,sBAAsB;CACjD,MAAM,cAAc,eAAe;CACnC,MAAM,UAAU,gBAAgB;CAChC,MAAM,WAAW,YAAY;CAC7B,MAAM,YAAY,wBACf,UAAU,MAAM,cAAc,SACjC;CAEA,MAAM,EACJ,iBACA,mBACA,gBACA,kBACA,mBACA,eACA,aACE,YAAY;EACd;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,MAAM,CAAC,mBAAmB,kBAAkB,KAAK,YAAY;CAE7D,MAAM,CAAC,iBAAiB,kBAAkB,KAAK,UAAU;CACzD,MAAM,CACJ,aACA,kBACA,WACA,WACA,gBACA,iBACE,eACF,aACA,aACA,aACA,WACA,WACA,eACF;CACA,MAAM,CAAC,oBAAoB,qBAAqB,eAC9C,cACA,mBACF;CACA,MAAM,EAAE,OAAO,cAAc,SAAS,aAAa,gBAAgB;CACnE,MAAM,EAAE,OAAO,YAAY,SAAS,WAAW,cAAc;CAC7D,MAAM,EAAE,OAAO,cAAc,SAAS,WAAW;CACjD,MAAM,EAAE,OAAO,YA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IAAI,EACvC,CAAC;EACD,mBAAmB,KAAK;CAC1B,GACA;EAAC;EAAa;EAAe;EAAoB;CAAQ,CAC3D;CAEA,OAAO;EACL,QAAQ,QAAQ,sBAAsB,QAAQ;EAC9C,WAAW,aAAa;EACxB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"useRoutes.js","names":[],"sources":["../../../src/hooks/useRoutes.ts"],"sourcesContent":["import type { ExtendedChain, Route, Token } from '@lifi/sdk'\nimport {\n ChainType,\n convertQuoteToRoute,\n getContractCallsQuote,\n getRelayerQuote,\n getRoutes,\n LiFiErrorCode,\n parseUnits,\n} from '@lifi/sdk'\nimport { useAccount } from '@lifi/wallet-management'\nimport {\n useChainTypeFromAddress,\n useEthereumContext,\n} from '@lifi/widget-provider'\nimport {\n keepPreviousData,\n useQuery,\n useQueryClient,\n} from '@tanstack/react-query'\nimport { useCallback, useMemo } from 'react'\nimport { useSDKClient } from '../providers/SDKClientProvider.js'\nimport { useWidgetConfig } from '../providers/WidgetProvider/WidgetProvider.js'\nimport { useFieldValues } from '../stores/form/useFieldValues.js'\nimport { useNavigationTabsStore } from '../stores/navigationTabs/useNavigationTabsStore.js'\nimport { useIntermediateRoutesStore } from '../stores/routes/useIntermediateRoutesStore.js'\nimport { useSetExecutableRoute } from '../stores/routes/useSetExecutableRoute.js'\nimport { defaultSlippage } from '../stores/settings/createSettingsStore.js'\nimport { useSettings } from '../stores/settings/useSettings.js'\nimport { WidgetEvent } from '../types/events.js'\nimport type { TokensByChain } from '../types/token.js'\nimport { getQueryKey } from '../utils/queries.js'\nimport { updateTokenInCache } from '../utils/token.js'\nimport { useChain } from './useChain.js'\nimport { useDebouncedWatch } from './useDebouncedWatch.js'\nimport { useGasRefuel } from './useGasRefuel.js'\nimport { useIsBatchingSupported } from './useIsBatchingSupported.js'\nimport { useSwapOnly } from './useSwapOnly.js'\nimport { useToken } from './useToken.js'\nimport { useWidgetEvents } from './useWidgetEvents.js'\n\nconst refetchTime = 60_000\n\ninterface RoutesProps {\n observableRoute?: Route\n /**\n * Address to quote from when no wallet is connected. Treated as a non-signing\n * placeholder, so signer-dependent (relayer/permit2) quotes are skipped.\n */\n quoteFromAddress?: string\n /**\n * Keep showing the previous result while a new query (e.g. a token/amount\n * change) is fetching, instead of clearing to a loading state.\n */\n keepPreviousData?: boolean\n}\n\nexport const useRoutes = ({\n observableRoute,\n quoteFromAddress,\n keepPreviousData: keepPreviousDataEnabled,\n}: RoutesProps = {}): {\n routes: Route[] | undefined\n isLoading: boolean\n isFetching: boolean\n isFetched: boolean\n isError: boolean\n dataUpdatedAt: number\n refetchTime: number\n refetch: () => void\n fromChain: ExtendedChain | undefined\n toChain: ExtendedChain | undefined\n queryKey: readonly unknown[]\n setReviewableRoute: (route: Route) => void\n} => {\n const {\n mode,\n modeOptions,\n contractTool,\n bridges,\n exchanges,\n feeConfig,\n useRelayerRoutes,\n keyPrefix,\n } = useWidgetConfig()\n const sdkClient = useSDKClient()\n const setExecutableRoute = useSetExecutableRoute()\n const queryClient = useQueryClient()\n const emitter = useWidgetEvents()\n const swapOnly = useSwapOnly()\n const isPrivate = useNavigationTabsStore(\n (state) => state.activeTab === 'private'\n )\n\n const {\n disabledBridges,\n disabledExchanges,\n enabledBridges,\n enabledExchanges,\n enabledAutoRefuel,\n routePriority,\n slippage,\n } = useSettings([\n 'disabledBridges',\n 'disabledExchanges',\n 'enabledBridges',\n 'enabledExchanges',\n 'enabledAutoRefuel',\n 'routePriority',\n 'slippage',\n ])\n const [fromTokenAmount] = useDebouncedWatch(500, 'fromAmount')\n // Debounce toAmount like fromAmount to avoid a request per keystroke\n const [toTokenAmount] = useDebouncedWatch(500, 'toAmount')\n const [\n fromChainId,\n fromTokenAddress,\n toAddress,\n toChainId,\n toTokenAddress,\n contractCalls,\n ] = useFieldValues(\n 'fromChain',\n 'fromToken',\n 'toAddress',\n 'toChain',\n 'toToken',\n 'contractCalls'\n )\n const [validUntilDuration, partiallyFillable] = useFieldValues(\n 'validUntil',\n 'partiallyFillable'\n )\n const { token: fromToken } = useToken(fromChainId, fromTokenAddress)\n const { token: toToken } = useToken(toChainId, toTokenAddress)\n const { chain: fromChain } = useChain(fromChainId)\n const { chain: toChain } = useChain(toChainId)\n const { enabled: enabledRefuel, fromAmount: gasRecommendationFromAmount } =\n useGasRefuel()\n const { getChainTypeFromAddress } = useChainTypeFromAddress()\n const { isGaslessStep, disableMessageSigning } = useEthereumContext()\n const { account } = useAccount({ chainType: fromChain?.chainType })\n const { isBatchingSupported, isBatchingSupportedLoading } =\n useIsBatchingSupported(fromChain, account.address)\n\n // In limit mode toAmount is the user's limit target, derived from the sell\n // amount and limit price. It's keyed and sent to the backend so changing the\n // limit fetches a fresh quote. The receive card is read-only (it displays the\n // quote and never writes toAmount back), so keying on it can't loop. Both a\n // sell amount and a limit price (→ toAmount) are required before fetching.\n const hasAmount =\n mode === 'limit'\n ? Number(fromTokenAmount) > 0 && Number(toTokenAmount) > 0\n : Number(fromTokenAmount) > 0 || Number(toTokenAmount) > 0\n\n const customType = mode === 'custom' ? modeOptions?.custom?.type : undefined\n const isContractCallQuote =\n mode === 'custom' && Boolean(contractCalls?.length)\n // A contract-call quote needs a connected wallet to resolve fromAddress.\n // Deposit funding quotes a plain route with no contract calls and no wallet\n // (a placeholder fromAddress arrives via quoteFromAddress); every other custom\n // flow stays gated on a real wallet, as before.\n const contractCallQuoteEnabled: boolean = isContractCallQuote\n ? Boolean(account.address)\n : mode !== 'custom' || customType === 'deposit'\n\n const effectiveFromAddress = account.address ?? quoteFromAddress\n\n // When we bridge between ecosystems we need to be sure toAddress is set and has the same chainType as toChain\n // If toAddress is set, it must have the same chainType as toChain\n const hasToAddressAndChainTypeSatisfied: boolean =\n !!toChain &&\n !!toAddress &&\n getChainTypeFromAddress(toAddress) === toChain.chainType\n // We need to check for toAddress only if it is set\n const isToAddressSatisfied = toAddress\n ? hasToAddressAndChainTypeSatisfied\n : true\n\n // toAddress might be an empty string, but we need to pass undefined if there is no value\n const toWalletAddress = toAddress || undefined\n\n // We need to send the full allowed tools array if custom tool settings are applied\n const allowedBridges =\n bridges?.allow?.length || bridges?.deny?.length ? enabledBridges : undefined\n const allowedExchanges =\n exchanges?.allow?.length || exchanges?.deny?.length\n ? enabledExchanges\n : undefined\n const allowSwitchChain = sdkClient.config?.routeOptions?.allowSwitchChain\n\n const isEnabled =\n Boolean(Number(fromChain?.id)) &&\n Boolean(Number(toChain?.id)) &&\n Boolean(fromToken?.address) &&\n Boolean(toToken?.address) &&\n !Number.isNaN(slippage) &&\n hasAmount &&\n isToAddressSatisfied &&\n contractCallQuoteEnabled &&\n !isBatchingSupportedLoading\n\n // Some values should be strictly typed and isEnabled ensures that\n const queryKey = useMemo(\n () =>\n [\n getQueryKey('routes', keyPrefix),\n effectiveFromAddress,\n fromChain?.id as number,\n fromToken?.address as string,\n fromTokenAmount,\n toWalletAddress,\n toChain?.id as number,\n toToken?.address as string,\n toTokenAmount,\n validUntilDuration,\n partiallyFillable,\n contractCalls,\n slippage,\n swapOnly,\n disabledBridges,\n disabledExchanges,\n allowedBridges,\n allowedExchanges,\n routePriority,\n mode,\n allowSwitchChain,\n enabledRefuel && enabledAutoRefuel,\n gasRecommendationFromAmount,\n feeConfig?.fee,\n disableMessageSigning,\n !!isBatchingSupported,\n isPrivate,\n observableRoute?.id,\n ] as const,\n [\n keyPrefix,\n effectiveFromAddress,\n fromChain?.id,\n fromToken?.address,\n fromTokenAmount,\n toWalletAddress,\n toChain?.id,\n toToken?.address,\n toTokenAmount,\n validUntilDuration,\n partiallyFillable,\n contractCalls,\n slippage,\n swapOnly,\n disabledBridges,\n disabledExchanges,\n allowedBridges,\n allowedExchanges,\n routePriority,\n mode,\n allowSwitchChain,\n enabledRefuel,\n enabledAutoRefuel,\n gasRecommendationFromAmount,\n feeConfig?.fee,\n disableMessageSigning,\n isBatchingSupported,\n isPrivate,\n observableRoute?.id,\n ]\n )\n\n const { getIntermediateRoutes, setIntermediateRoutes } =\n useIntermediateRoutesStore()\n\n const {\n data,\n isLoading,\n isFetching,\n isFetched,\n isError,\n dataUpdatedAt,\n refetch,\n } = useQuery({\n queryKey,\n queryFn: async ({\n queryKey: [\n _,\n fromAddress,\n fromChainId,\n fromTokenAddress,\n fromTokenAmount,\n toAddress,\n toChainId,\n toTokenAddress,\n toTokenAmount,\n validUntilDuration,\n partiallyFillable,\n contractCalls,\n slippage = defaultSlippage,\n swapOnly,\n disabledBridges,\n disabledExchanges,\n allowedBridges,\n allowedExchanges,\n routePriority,\n mode,\n allowSwitchChain,\n enabledRefuel,\n gasRecommendationFromAmount,\n configuredFee,\n disableMessageSigning,\n isBatchingSupported,\n isPrivate,\n // _observableRouteId must be the last element in the query key\n _observableRouteId,\n ],\n signal,\n }) => {\n const fromAmount = parseUnits(fromTokenAmount, fromToken!.decimals)\n const toAmount = toTokenAmount\n ? parseUnits(toTokenAmount, toToken!.decimals)\n : undefined\n const formattedSlippage = slippage\n ? Number.parseFloat(slippage) / 100\n : defaultSlippage\n\n const allowBridges = swapOnly\n ? []\n : observableRoute\n ? observableRoute.steps.flatMap((step) =>\n step.includedSteps.reduce((toolKeys, includedStep) => {\n if (includedStep.type === 'cross') {\n toolKeys.push(includedStep.toolDetails.key)\n }\n return toolKeys\n }, [] as string[])\n )\n : allowedBridges\n const allowExchanges = observableRoute\n ? observableRoute.steps.flatMap((step) =>\n step.includedSteps.reduce((toolKeys, includedStep) => {\n if (includedStep.type === 'swap') {\n toolKeys.push(includedStep.toolDetails.key)\n }\n return toolKeys\n }, [] as string[])\n )\n : allowedExchanges\n\n const calculatedFee = await feeConfig?.calculateFee?.({\n fromChain: fromChain!,\n toChain: toChain!,\n fromToken: fromToken!,\n toToken: toToken!,\n fromAddress,\n toAddress,\n fromAmount,\n toAmount,\n slippage: formattedSlippage,\n })\n\n if (mode === 'custom' && contractCalls?.length && toAmount) {\n const contractCallQuote = await getContractCallsQuote(\n sdkClient,\n {\n // Contract calls are enabled only when fromAddress is set\n fromAddress: fromAddress as string,\n fromChain: fromChainId,\n fromToken: fromTokenAddress,\n toAmount: toAmount.toString(),\n toChain: toChainId,\n toToken: toTokenAddress,\n contractCalls,\n denyBridges: disabledBridges.length ? disabledBridges : undefined,\n denyExchanges: disabledExchanges.length\n ? disabledExchanges\n : undefined,\n allowBridges,\n allowExchanges,\n toFallbackAddress: toAddress,\n slippage: formattedSlippage,\n fee: calculatedFee || configuredFee,\n },\n { signal }\n )\n\n contractCallQuote.action.toToken = toToken!\n\n const customStep =\n mode === 'custom'\n ? contractCallQuote.includedSteps?.find(\n (step) => step.type === 'custom'\n )\n : undefined\n\n if (customStep && contractTool) {\n const toolDetails = {\n key: contractTool.name,\n name: contractTool.name,\n logoURI: contractTool.logoURI,\n }\n customStep.toolDetails = toolDetails\n contractCallQuote.toolDetails = toolDetails\n }\n\n const route: Route = convertQuoteToRoute(contractCallQuote)\n\n return [route]\n }\n\n // Prevent sending a request for the same chain token combinations.\n // Exception: proceed anyway if mode is custom and modeOptions custom type is deposit\n if (\n fromChainId === toChainId &&\n fromTokenAddress === toTokenAddress &&\n !(mode === 'custom' && modeOptions?.custom?.type === 'deposit')\n ) {\n return\n }\n\n const isObservableRelayerRoute = observableRoute?.steps?.some(\n (step) => !!isGaslessStep?.(step, fromChain)\n )\n\n const shouldUseMainRoutes = !observableRoute || !isObservableRelayerRoute\n const shouldUseRelayerQuote =\n // Relayer quotes don't support limit-order params\n mode !== 'limit' &&\n account.address &&\n fromAddress &&\n fromChain?.chainType === ChainType.EVM &&\n fromChain.permit2 &&\n fromChain.permit2Proxy &&\n fromChain.relayerSupported &&\n fromChain.nativeToken.address !== fromTokenAddress &&\n useRelayerRoutes &&\n !isBatchingSupported &&\n (!observableRoute || isObservableRelayerRoute)\n\n const limitOrderRouteParams =\n mode === 'limit'\n ? {\n toAmount: toAmount?.toString(),\n validUntil: Math.floor(Date.now() / 1000) + validUntilDuration,\n partiallyFillable: partiallyFillable,\n }\n : undefined\n\n const mainRoutesPromise = shouldUseMainRoutes\n ? getRoutes(\n sdkClient,\n {\n fromAddress,\n fromAmount: fromAmount.toString(),\n fromChainId,\n fromTokenAddress,\n toAddress,\n toChainId,\n toTokenAddress,\n fromAmountForGas:\n enabledRefuel && gasRecommendationFromAmount\n ? gasRecommendationFromAmount\n : undefined,\n ...limitOrderRouteParams,\n options: {\n allowSwitchChain: mode === 'refuel' ? false : allowSwitchChain,\n bridges:\n allowBridges?.length || disabledBridges.length\n ? {\n allow: allowBridges,\n deny: disabledBridges.length\n ? disabledBridges\n : undefined,\n }\n : undefined,\n exchanges:\n allowExchanges?.length || disabledExchanges.length\n ? {\n allow: allowExchanges,\n deny: disabledExchanges.length\n ? disabledExchanges\n : undefined,\n }\n : undefined,\n order: routePriority,\n slippage: formattedSlippage,\n fee: calculatedFee || configuredFee,\n executionType: disableMessageSigning ? 'transaction' : 'all',\n ...(isPrivate && { private: true }),\n },\n },\n { signal }\n )\n : Promise.resolve(null)\n\n const relayerQuotePromise = shouldUseRelayerQuote\n ? getRelayerQuote(\n sdkClient,\n {\n fromAddress,\n fromAmount: fromAmount.toString(),\n fromChain: fromChainId,\n fromToken: fromTokenAddress,\n toAddress,\n toChain: toChainId,\n toToken: toTokenAddress,\n fromAmountForGas:\n enabledRefuel && gasRecommendationFromAmount\n ? gasRecommendationFromAmount\n : undefined,\n order: routePriority,\n slippage: formattedSlippage,\n fee: calculatedFee || configuredFee,\n ...(allowBridges?.length || disabledBridges.length\n ? {\n allowBridges: allowBridges,\n denyBridges: disabledBridges.length\n ? disabledBridges\n : undefined,\n }\n : undefined),\n ...(allowExchanges?.length || disabledExchanges.length\n ? {\n allowExchanges: allowExchanges,\n denyExchanges: disabledExchanges.length\n ? disabledExchanges\n : undefined,\n }\n : undefined),\n },\n { signal }\n )\n .then(convertQuoteToRoute)\n .catch(() => null)\n : Promise.resolve(null)\n\n // Wait for the main routes to complete first\n const routesResult = await mainRoutesPromise\n\n if (routesResult?.routes[0] && fromAddress) {\n // Update local tokens cache to keep priceUSD in sync\n const { fromToken, toToken } = routesResult.routes[0]\n ;[fromToken, toToken].forEach((token) => {\n // Update main tokens cache (verified)\n queryClient.setQueriesData<TokensByChain>(\n { queryKey: [getQueryKey('tokens', keyPrefix)] },\n (data) => updateTokenInCache(data, token)\n )\n\n // Update search tokens cache (unverified) - matches any search query\n queryClient.setQueriesData<TokensByChain>(\n {\n queryKey: [getQueryKey('tokens-search', keyPrefix)],\n exact: false,\n },\n (data) => updateTokenInCache(data, token)\n )\n\n queryClient.setQueriesData<Token[]>(\n {\n queryKey: [\n getQueryKey('token-balances', keyPrefix),\n fromAddress,\n token.chainId,\n ],\n },\n (data) => {\n if (data) {\n const clonedData = [...data]\n const index = clonedData.findIndex(\n (dataToken) => dataToken.address === token.address\n )\n if (index >= 0) {\n clonedData[index] = {\n ...clonedData[index],\n ...token,\n }\n }\n return clonedData\n }\n }\n )\n })\n }\n\n const initialRoutes = routesResult?.routes ?? []\n\n if (shouldUseRelayerQuote && initialRoutes.length) {\n setIntermediateRoutes(queryKey, initialRoutes)\n emitter.emit(WidgetEvent.AvailableRoutes, initialRoutes)\n // Return early if we're only using main routes\n } else if (shouldUseMainRoutes) {\n // If we don't need relayer quote, return the initial routes\n emitter.emit(WidgetEvent.AvailableRoutes, initialRoutes)\n return initialRoutes\n }\n\n const relayerRouteResult = await relayerQuotePromise\n // If we have a relayer route, add it to the routes array\n if (relayerRouteResult) {\n // Insert the relayer route at position 1 (after the first route)\n initialRoutes.splice(1, 0, relayerRouteResult)\n // Emit the updated routes\n emitter.emit(WidgetEvent.AvailableRoutes, initialRoutes)\n }\n\n return initialRoutes\n },\n enabled: isEnabled,\n staleTime: refetchTime,\n placeholderData: keepPreviousDataEnabled ? keepPreviousData : undefined,\n refetchInterval(query) {\n return Math.min(\n Math.abs(refetchTime - (Date.now() - query.state.dataUpdatedAt)),\n refetchTime\n )\n },\n retry(failureCount, error: any) {\n if (process.env.NODE_ENV === 'development') {\n console.warn('Route query failed:', { failureCount, error })\n }\n if (failureCount >= 3) {\n return false\n }\n if (error?.code === LiFiErrorCode.NotFound) {\n return false\n }\n return true\n },\n })\n\n const setReviewableRoute = useCallback(\n (route: Route) => {\n const queryDataKey = queryKey.toSpliced(queryKey.length - 1, 1, route.id)\n queryClient.setQueryData(queryDataKey, [route], {\n updatedAt: dataUpdatedAt || Date.now(),\n })\n setExecutableRoute(route)\n },\n [queryClient, dataUpdatedAt, setExecutableRoute, queryKey]\n )\n\n return {\n routes: data || getIntermediateRoutes(queryKey),\n isLoading: isEnabled && isLoading,\n isFetching,\n isFetched,\n isError,\n dataUpdatedAt,\n refetchTime,\n refetch,\n fromChain,\n toChain,\n queryKey,\n setReviewableRoute,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAyCA,MAAM,cAAc;AAgBpB,MAAa,aAAa,EACxB,iBACA,kBACA,kBAAkB,4BACH,CAAC,MAab;CACH,MAAM,EACJ,MACA,aACA,cACA,SACA,WACA,WACA,kBACA,cACE,gBAAgB;CACpB,MAAM,YAAY,aAAa;CAC/B,MAAM,qBAAqB,sBAAsB;CACjD,MAAM,cAAc,eAAe;CACnC,MAAM,UAAU,gBAAgB;CAChC,MAAM,WAAW,YAAY;CAC7B,MAAM,YAAY,wBACf,UAAU,MAAM,cAAc,SACjC;CAEA,MAAM,EACJ,iBACA,mBACA,gBACA,kBACA,mBACA,eACA,aACE,YAAY;EACd;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,MAAM,CAAC,mBAAmB,kBAAkB,KAAK,YAAY;CAE7D,MAAM,CAAC,iBAAiB,kBAAkB,KAAK,UAAU;CACzD,MAAM,CACJ,aACA,kBACA,WACA,WACA,gBACA,iBACE,eACF,aACA,aACA,aACA,WACA,WACA,eACF;CACA,MAAM,CAAC,oBAAoB,qBAAqB,eAC9C,cACA,mBACF;CACA,MAAM,EAAE,OAAO,cAAc,SAAS,aAAa,gBAAgB;CACnE,MAAM,EAAE,OAAO,YAAY,SAAS,WAA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;EAC/B;EACA,WAAW;EACX,WAAW;EACX;EACA;EACA,SAAS;EACT,SAAS;EACT;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,iBAAiB;EACjB;EACA,WAAW;EACX;EACA,CAAC,CAAC;EACF;EACA,iBAAiB;CACnB,GACF;EACE;EACA;EACA,WAAW;EACX,WAAW;EACX;EACA;EACA,SAAS;EACT,SAAS;EACT;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,WAAW;EACX;EACA;EACA;EACA,iBAAiB;CACnB,CACF;CAEA,MAAM,EAAE,uBAAuB,0BAC7B,2BAA2B;CAE7B,MAAM,EACJ,MACA,WACA,YACA,WACA,SACA,eACA,YACE,SAAS;EACX;EACA,SAAS,OAAO,EACd,UAAU,CACR,GACA,aACA,aACA,kBACA,iBACA,WACA,WACA,gBACA,eACA,oBACA,mBACA,eACA,WAAA,KAAA,GACA,UACA,iBACA,mBACA,gBACA,kBACA,eACA,MACA,kBACA,eACA,6BACA,eACA,uBACA,qBACA,WAEA,qBAEF,aACI;GACJ,MAAM,aAAa,WAAW,iBAAiB,UAAW,QAAQ;GAClE,MAAM,WAAW,gBACb,WAAW,eAAe,QAAS,QAAQ,IAC3C,KAAA;GACJ,MAAM,oBAAoB,WACtB,OAAO,WAAW,QAAQ,IAAI,MAAA,KAAA;GAGlC,MAAM,eAAe,WACjB,CAAC,IACD,kBACE,gBAAgB,MAAM,SAAS,SAC7B,KAAK,cAAc,QAAQ,UAAU,iBAAiB;IACpD,IAAI,aAAa,SAAS,SACxB,SAAS,KAAK,aAAa,YAAY,GAAG;IAE5C,OAAO;GACT,GAAG,CAAC,CAAa,CACnB,IACA;GACN,MAAM,iBAAiB,kBACnB,gBAAgB,MAAM,SAAS,SAC7B,KAAK,cAAc,QAAQ,UAAU,iBAAiB;IACpD,IAAI,aAAa,SAAS,QACxB,SAAS,KAAK,aAAa,YAAY,GAA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B,OAAO;GAET,IAAI,OAAO,SAAS,cAAc,UAChC,OAAO;GAET,OAAO;EACT;CACF,CAAC;CAED,MAAM,qBAAqB,aACxB,UAAiB;EAChB,MAAM,eAAe,SAAS,UAAU,SAAS,SAAS,GAAG,GAAG,MAAM,EAAE;EACxE,YAAY,aAAa,cAAc,CAAC,KAAK,GAAG,EAC9C,WAAW,iBAAiB,KAAK,IAAI,EACvC,CAAC;EACD,mBAAmB,KAAK;CAC1B,GACA;EAAC;EAAa;EAAe;EAAoB;CAAQ,CAC3D;CAEA,OAAO;EACL,QAAQ,QAAQ,sBAAsB,QAAQ;EAC9C,WAAW,aAAa;EACxB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ChainType, RouteExtended } from "@lifi/sdk";
|
|
2
|
+
//#region src/hooks/useToAddressRequirements.d.ts
|
|
3
|
+
declare const useToAddressRequirements: (route?: RouteExtended) => {
|
|
4
|
+
requiredToAddress: boolean;
|
|
5
|
+
requiredToChainType: ChainType | undefined;
|
|
6
|
+
accountNotDeployedAtDestination: boolean;
|
|
7
|
+
accountDeployedAtDestination: boolean;
|
|
8
|
+
toAddress: string | undefined;
|
|
9
|
+
isFromContractAddress: boolean | undefined;
|
|
10
|
+
isToContractAddress: boolean | undefined;
|
|
11
|
+
isLoading: boolean;
|
|
12
|
+
isFetched: boolean;
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
export { useToAddressRequirements };
|
|
16
|
+
//# sourceMappingURL=useToAddressRequirements.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useToAddressRequirements.d.ts","names":[],"sources":["../../../src/hooks/useToAddressRequirements.ts"],"mappings":";;cAQa,2BACX,QAAQ;EAER;EACA,qBAAqB;EACrB;EACA;EACA;EACA;EACA;EACA;EACA"}
|