@lifi/widget 3.25.0 → 3.26.1
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/CHANGELOG.md +27 -0
- package/dist/esm/components/AmountInput/AmountInput.js +75 -17
- package/dist/esm/components/AmountInput/AmountInput.js.map +1 -1
- package/dist/esm/components/AmountInput/AmountInput.style.d.ts +4 -0
- package/dist/esm/components/AmountInput/AmountInput.style.js +11 -0
- package/dist/esm/components/AmountInput/AmountInput.style.js.map +1 -1
- package/dist/esm/components/AmountInput/AmountInputAdornment.style.d.ts +1 -0
- package/dist/esm/components/AmountInput/AmountInputAdornment.style.js +64 -5
- package/dist/esm/components/AmountInput/AmountInputAdornment.style.js.map +1 -1
- package/dist/esm/components/AmountInput/AmountInputEndAdornment.js +20 -7
- package/dist/esm/components/AmountInput/AmountInputEndAdornment.js.map +1 -1
- package/dist/esm/components/AmountInput/PriceFormHelperText.js +41 -15
- package/dist/esm/components/AmountInput/PriceFormHelperText.js.map +1 -1
- package/dist/esm/components/AmountInput/PriceFormHelperText.style.d.ts +1 -0
- package/dist/esm/components/AmountInput/PriceFormHelperText.style.js +29 -0
- package/dist/esm/components/AmountInput/PriceFormHelperText.style.js.map +1 -0
- package/dist/esm/components/AppContainer.js +1 -0
- package/dist/esm/components/AppContainer.js.map +1 -1
- package/dist/esm/components/ChainSelect/useChainSelect.js +2 -4
- package/dist/esm/components/ChainSelect/useChainSelect.js.map +1 -1
- package/dist/esm/components/Chains/ChainsExpanded.d.ts +1 -1
- package/dist/esm/components/Chains/ChainsExpanded.js +3 -2
- package/dist/esm/components/Chains/ChainsExpanded.js.map +1 -1
- package/dist/esm/components/Chains/ChainsExpanded.style.js +1 -2
- package/dist/esm/components/Chains/ChainsExpanded.style.js.map +1 -1
- package/dist/esm/components/Chains/SelectChainContent.d.ts +1 -1
- package/dist/esm/components/Chains/SelectChainContent.js +3 -2
- package/dist/esm/components/Chains/SelectChainContent.js.map +1 -1
- package/dist/esm/components/Chains/VirtualizedChainList.js +5 -3
- package/dist/esm/components/Chains/VirtualizedChainList.js.map +1 -1
- package/dist/esm/components/Expansion/Expansion.js +5 -16
- package/dist/esm/components/Expansion/Expansion.js.map +1 -1
- package/dist/esm/components/Expansion/Expansion.style.d.ts +32 -0
- package/dist/esm/components/Expansion/Expansion.style.js +40 -0
- package/dist/esm/components/Expansion/Expansion.style.js.map +1 -0
- package/dist/esm/components/Expansion/ExpansionTransition.d.ts +0 -1
- package/dist/esm/components/Expansion/ExpansionTransition.js +1 -30
- package/dist/esm/components/Expansion/ExpansionTransition.js.map +1 -1
- package/dist/esm/components/Header/NavigationHeader.js +5 -1
- package/dist/esm/components/Header/NavigationHeader.js.map +1 -1
- package/dist/esm/components/Routes/RoutesContent.d.ts +2 -3
- package/dist/esm/components/Routes/RoutesContent.js +8 -23
- package/dist/esm/components/Routes/RoutesContent.js.map +1 -1
- package/dist/esm/components/Routes/RoutesExpanded.d.ts +2 -3
- package/dist/esm/components/Routes/RoutesExpanded.js +24 -8
- package/dist/esm/components/Routes/RoutesExpanded.js.map +1 -1
- package/dist/esm/components/Routes/RoutesExpanded.style.js +2 -2
- package/dist/esm/components/Routes/RoutesExpanded.style.js.map +1 -1
- package/dist/esm/components/SendToWallet/SendToWalletButton.js +1 -1
- package/dist/esm/components/SendToWallet/SendToWalletButton.js.map +1 -1
- package/dist/esm/components/SendToWallet/SendToWalletExpandButton.js +3 -3
- package/dist/esm/components/SendToWallet/SendToWalletExpandButton.js.map +1 -1
- package/dist/esm/components/Step/StepProcess.js +3 -8
- package/dist/esm/components/Step/StepProcess.js.map +1 -1
- package/dist/esm/components/TokenList/TokenDetailsSheetContent.js +1 -2
- package/dist/esm/components/TokenList/TokenDetailsSheetContent.js.map +1 -1
- package/dist/esm/components/TokenList/useTokenSelect.js +2 -4
- package/dist/esm/components/TokenList/useTokenSelect.js.map +1 -1
- package/dist/esm/config/version.d.ts +1 -1
- package/dist/esm/config/version.js +1 -1
- package/dist/esm/hooks/useFromAmountThreshold.js +2 -2
- package/dist/esm/hooks/useFromAmountThreshold.js.map +1 -1
- package/dist/esm/hooks/useGasSufficiency.js +3 -3
- package/dist/esm/hooks/useGasSufficiency.js.map +1 -1
- package/dist/esm/hooks/useNavigateBack.d.ts +1 -1
- package/dist/esm/hooks/useNavigateBack.js +8 -2
- package/dist/esm/hooks/useNavigateBack.js.map +1 -1
- package/dist/esm/hooks/useRouteExecution.js +1 -2
- package/dist/esm/hooks/useRouteExecution.js.map +1 -1
- package/dist/esm/hooks/useRoutes.js +51 -8
- package/dist/esm/hooks/useRoutes.js.map +1 -1
- package/dist/esm/hooks/useSettingMonitor.js +1 -2
- package/dist/esm/hooks/useSettingMonitor.js.map +1 -1
- package/dist/esm/hooks/useTokenAddressBalance.js +4 -1
- package/dist/esm/hooks/useTokenAddressBalance.js.map +1 -1
- package/dist/esm/hooks/useTokenSearch.js +5 -2
- package/dist/esm/hooks/useTokenSearch.js.map +1 -1
- package/dist/esm/hooks/useTokens.js +2 -2
- package/dist/esm/hooks/useTokens.js.map +1 -1
- package/dist/esm/hooks/useTools.js +2 -2
- package/dist/esm/hooks/useTools.js.map +1 -1
- package/dist/esm/i18n/bn.json +1 -1
- package/dist/esm/i18n/de.json +1 -1
- package/dist/esm/i18n/en.json +1 -1
- package/dist/esm/i18n/es.json +1 -1
- package/dist/esm/i18n/fr.json +1 -1
- package/dist/esm/i18n/hi.json +1 -1
- package/dist/esm/i18n/id.json +1 -1
- package/dist/esm/i18n/it.json +1 -1
- package/dist/esm/i18n/ja.json +1 -1
- package/dist/esm/i18n/ko.json +1 -1
- package/dist/esm/i18n/pt.json +1 -1
- package/dist/esm/i18n/th.json +1 -1
- package/dist/esm/i18n/tr.json +1 -1
- package/dist/esm/i18n/uk.json +1 -1
- package/dist/esm/i18n/vi.json +1 -1
- package/dist/esm/i18n/zh.json +1 -1
- package/dist/esm/pages/SelectEnabledToolsPage.js +4 -2
- package/dist/esm/pages/SelectEnabledToolsPage.js.map +1 -1
- package/dist/esm/pages/SelectTokenPage/SearchTokenInput.js +14 -7
- package/dist/esm/pages/SelectTokenPage/SearchTokenInput.js.map +1 -1
- package/dist/esm/pages/SettingsPage/BridgeAndExchangeSettings.js +1 -2
- package/dist/esm/pages/SettingsPage/BridgeAndExchangeSettings.js.map +1 -1
- package/dist/esm/pages/TransactionPage/TransactionPage.js +5 -3
- package/dist/esm/pages/TransactionPage/TransactionPage.js.map +1 -1
- package/dist/esm/stores/bookmarks/BookmarkStore.d.ts +1 -2
- package/dist/esm/stores/bookmarks/BookmarkStore.js +3 -3
- package/dist/esm/stores/bookmarks/BookmarkStore.js.map +1 -1
- package/dist/esm/stores/bookmarks/useBookmarkActions.js +1 -2
- package/dist/esm/stores/bookmarks/useBookmarkActions.js.map +1 -1
- package/dist/esm/stores/bookmarks/useBookmarks.js +1 -2
- package/dist/esm/stores/bookmarks/useBookmarks.js.map +1 -1
- package/dist/esm/stores/chains/ChainOrderStore.d.ts +1 -1
- package/dist/esm/stores/chains/ChainOrderStore.js +3 -2
- package/dist/esm/stores/chains/ChainOrderStore.js.map +1 -1
- package/dist/esm/stores/chains/useChainOrder.js +1 -2
- package/dist/esm/stores/chains/useChainOrder.js.map +1 -1
- package/dist/esm/stores/form/useFieldActions.js +1 -2
- package/dist/esm/stores/form/useFieldActions.js.map +1 -1
- package/dist/esm/stores/form/useFieldValues.js +1 -2
- package/dist/esm/stores/form/useFieldValues.js.map +1 -1
- package/dist/esm/stores/form/useFormStore.d.ts +1 -2
- package/dist/esm/stores/form/useFormStore.js +3 -3
- package/dist/esm/stores/form/useFormStore.js.map +1 -1
- package/dist/esm/stores/form/useTouchedFields.js +1 -2
- package/dist/esm/stores/form/useTouchedFields.js.map +1 -1
- package/dist/esm/stores/form/useValidation.js +5 -2
- package/dist/esm/stores/form/useValidation.js.map +1 -1
- package/dist/esm/stores/form/useValidationActions.js +1 -2
- package/dist/esm/stores/form/useValidationActions.js.map +1 -1
- package/dist/esm/stores/header/useHeaderStore.d.ts +1 -1
- package/dist/esm/stores/header/useHeaderStore.js +3 -2
- package/dist/esm/stores/header/useHeaderStore.js.map +1 -1
- package/dist/esm/stores/inputMode/useInputModeStore.d.ts +9 -0
- package/dist/esm/stores/inputMode/useInputModeStore.js +19 -0
- package/dist/esm/stores/inputMode/useInputModeStore.js.map +1 -0
- package/dist/esm/stores/routes/RouteExecutionStore.d.ts +1 -1
- package/dist/esm/stores/routes/RouteExecutionStore.js +3 -2
- package/dist/esm/stores/routes/RouteExecutionStore.js.map +1 -1
- package/dist/esm/stores/routes/useExecutingRoutesIds.js +1 -2
- package/dist/esm/stores/routes/useExecutingRoutesIds.js.map +1 -1
- package/dist/esm/stores/settings/useSendToWalletStore.d.ts +2 -1
- package/dist/esm/stores/settings/useSendToWalletStore.js +6 -3
- package/dist/esm/stores/settings/useSendToWalletStore.js.map +1 -1
- package/dist/esm/stores/settings/useSettings.js +1 -2
- package/dist/esm/stores/settings/useSettings.js.map +1 -1
- package/dist/esm/stores/settings/useSettingsActions.js +1 -2
- package/dist/esm/stores/settings/useSettingsActions.js.map +1 -1
- package/dist/esm/stores/settings/useSettingsStore.d.ts +2 -1
- package/dist/esm/stores/settings/useSettingsStore.js +5 -1
- package/dist/esm/stores/settings/useSettingsStore.js.map +1 -1
- package/dist/esm/stores/settings/useSplitSubvariantStore.js +2 -1
- package/dist/esm/stores/settings/useSplitSubvariantStore.js.map +1 -1
- package/dist/esm/themes/createTheme.js +5 -1
- package/dist/esm/themes/createTheme.js.map +1 -1
- package/dist/esm/types/widget.d.ts +2 -1
- package/dist/esm/types/widget.js +1 -0
- package/dist/esm/types/widget.js.map +1 -1
- package/dist/esm/utils/format.d.ts +4 -0
- package/dist/esm/utils/format.js +26 -0
- package/dist/esm/utils/format.js.map +1 -1
- package/dist/esm/utils/getPriceImpact.d.ts +2 -2
- package/dist/esm/utils/getPriceImpact.js.map +1 -1
- package/package.json +12 -12
- package/package.json.tmp +14 -14
- package/src/components/AmountInput/AmountInput.style.tsx +13 -0
- package/src/components/AmountInput/AmountInput.tsx +91 -18
- package/src/components/AmountInput/AmountInputAdornment.style.tsx +66 -5
- package/src/components/AmountInput/AmountInputEndAdornment.tsx +40 -10
- package/src/components/AmountInput/PriceFormHelperText.style.tsx +29 -0
- package/src/components/AmountInput/PriceFormHelperText.tsx +63 -19
- package/src/components/AppContainer.tsx +1 -0
- package/src/components/ChainSelect/useChainSelect.ts +2 -4
- package/src/components/Chains/ChainsExpanded.style.tsx +1 -2
- package/src/components/Chains/ChainsExpanded.tsx +6 -2
- package/src/components/Chains/SelectChainContent.tsx +81 -82
- package/src/components/Chains/VirtualizedChainList.tsx +5 -6
- package/src/components/Expansion/Expansion.style.tsx +43 -0
- package/src/components/Expansion/Expansion.tsx +8 -23
- package/src/components/Expansion/ExpansionTransition.tsx +5 -33
- package/src/components/Header/NavigationHeader.tsx +10 -1
- package/src/components/Routes/RoutesContent.tsx +14 -31
- package/src/components/Routes/RoutesExpanded.style.ts +2 -2
- package/src/components/Routes/RoutesExpanded.tsx +33 -13
- package/src/components/SendToWallet/SendToWalletButton.tsx +1 -1
- package/src/components/SendToWallet/SendToWalletExpandButton.tsx +8 -3
- package/src/components/Step/StepProcess.tsx +3 -8
- package/src/components/TokenList/TokenDetailsSheetContent.tsx +1 -2
- package/src/components/TokenList/useTokenSelect.ts +2 -4
- package/src/config/version.ts +1 -1
- package/src/hooks/useFromAmountThreshold.ts +6 -2
- package/src/hooks/useGasSufficiency.ts +4 -4
- package/src/hooks/useNavigateBack.ts +26 -17
- package/src/hooks/useRouteExecution.ts +1 -3
- package/src/hooks/useRoutes.ts +92 -37
- package/src/hooks/useSettingMonitor.ts +7 -11
- package/src/hooks/useTokenAddressBalance.ts +6 -1
- package/src/hooks/useTokenSearch.ts +5 -2
- package/src/hooks/useTokens.ts +2 -2
- package/src/hooks/useTools.ts +2 -2
- package/src/i18n/bn.json +1 -1
- package/src/i18n/de.json +1 -1
- package/src/i18n/en.json +1 -1
- package/src/i18n/es.json +1 -1
- package/src/i18n/fr.json +1 -1
- package/src/i18n/hi.json +1 -1
- package/src/i18n/id.json +1 -1
- package/src/i18n/it.json +1 -1
- package/src/i18n/ja.json +1 -1
- package/src/i18n/ko.json +1 -1
- package/src/i18n/pt.json +1 -1
- package/src/i18n/th.json +1 -1
- package/src/i18n/tr.json +1 -1
- package/src/i18n/uk.json +1 -1
- package/src/i18n/vi.json +1 -1
- package/src/i18n/zh.json +1 -1
- package/src/pages/SelectEnabledToolsPage.tsx +4 -5
- package/src/pages/SelectTokenPage/SearchTokenInput.tsx +19 -7
- package/src/pages/SettingsPage/BridgeAndExchangeSettings.tsx +1 -2
- package/src/pages/TransactionPage/TransactionPage.tsx +17 -9
- package/src/stores/bookmarks/BookmarkStore.tsx +3 -6
- package/src/stores/bookmarks/useBookmarkActions.ts +9 -13
- package/src/stores/bookmarks/useBookmarks.ts +1 -3
- package/src/stores/chains/ChainOrderStore.tsx +3 -3
- package/src/stores/chains/useChainOrder.ts +1 -5
- package/src/stores/form/useFieldActions.ts +10 -14
- package/src/stores/form/useFieldValues.ts +1 -3
- package/src/stores/form/useFormStore.ts +3 -6
- package/src/stores/form/useTouchedFields.ts +1 -2
- package/src/stores/form/useValidation.ts +5 -5
- package/src/stores/form/useValidationActions.ts +5 -9
- package/src/stores/header/useHeaderStore.tsx +3 -5
- package/src/stores/inputMode/useInputModeStore.ts +29 -0
- package/src/stores/routes/RouteExecutionStore.tsx +3 -3
- package/src/stores/routes/useExecutingRoutesIds.ts +14 -17
- package/src/stores/settings/useSendToWalletStore.ts +11 -8
- package/src/stores/settings/useSettings.ts +8 -11
- package/src/stores/settings/useSettingsActions.ts +8 -12
- package/src/stores/settings/useSettingsStore.ts +8 -1
- package/src/stores/settings/useSplitSubvariantStore.tsx +2 -1
- package/src/themes/createTheme.ts +5 -1
- package/src/types/widget.ts +1 -0
- package/src/utils/format.ts +33 -0
- package/src/utils/getPriceImpact.ts +2 -2
|
@@ -36,7 +36,7 @@ export const SendToWalletButton: React.FC<CardProps> = (props) => {
|
|
|
36
36
|
subvariant,
|
|
37
37
|
subvariantOptions,
|
|
38
38
|
} = useWidgetConfig()
|
|
39
|
-
const { showSendToWallet } = useSendToWalletStore()
|
|
39
|
+
const { showSendToWallet } = useSendToWalletStore((state) => state)
|
|
40
40
|
const [toAddressFieldValue, toChainId, toTokenAddress] = useFieldValues(
|
|
41
41
|
'toAddress',
|
|
42
42
|
'toChain',
|
|
@@ -7,7 +7,10 @@ import { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.j
|
|
|
7
7
|
import { useBookmarkActions } from '../../stores/bookmarks/useBookmarkActions.js'
|
|
8
8
|
import { useFieldActions } from '../../stores/form/useFieldActions.js'
|
|
9
9
|
import { useFieldValues } from '../../stores/form/useFieldValues.js'
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
sendToWalletStore,
|
|
12
|
+
useSendToWalletStore,
|
|
13
|
+
} from '../../stores/settings/useSendToWalletStore.js'
|
|
11
14
|
import { WidgetEvent } from '../../types/events.js'
|
|
12
15
|
import { DisabledUI, HiddenUI } from '../../types/widget.js'
|
|
13
16
|
|
|
@@ -17,7 +20,9 @@ export const SendToWalletExpandButton: React.FC = () => {
|
|
|
17
20
|
const { setFieldValue } = useFieldActions()
|
|
18
21
|
const { setSelectedBookmark } = useBookmarkActions()
|
|
19
22
|
const emitter = useWidgetEvents()
|
|
20
|
-
const { showSendToWallet, setSendToWallet } = useSendToWalletStore(
|
|
23
|
+
const { showSendToWallet, setSendToWallet } = useSendToWalletStore(
|
|
24
|
+
(state) => state
|
|
25
|
+
)
|
|
21
26
|
const [toAddressFieldValue] = useFieldValues('toAddress')
|
|
22
27
|
const { requiredToAddress } = useToAddressRequirements()
|
|
23
28
|
|
|
@@ -33,7 +38,7 @@ export const SendToWalletExpandButton: React.FC = () => {
|
|
|
33
38
|
setSendToWallet(!showSendToWallet)
|
|
34
39
|
emitter.emit(
|
|
35
40
|
WidgetEvent.SendToWalletToggled,
|
|
36
|
-
|
|
41
|
+
sendToWalletStore.getState().showSendToWallet
|
|
37
42
|
)
|
|
38
43
|
}
|
|
39
44
|
|
|
@@ -13,17 +13,12 @@ export const StepProcess: React.FC<{
|
|
|
13
13
|
const { title, message } = useProcessMessage(step, process)
|
|
14
14
|
const { getTransactionLink } = useExplorer()
|
|
15
15
|
|
|
16
|
-
const transactionLink = process.
|
|
16
|
+
const transactionLink = process.txLink
|
|
17
17
|
? getTransactionLink({
|
|
18
|
-
|
|
18
|
+
txLink: process.txLink,
|
|
19
19
|
chain: process.chainId,
|
|
20
20
|
})
|
|
21
|
-
:
|
|
22
|
-
? getTransactionLink({
|
|
23
|
-
txLink: process.txLink,
|
|
24
|
-
chain: process.chainId,
|
|
25
|
-
})
|
|
26
|
-
: undefined
|
|
21
|
+
: undefined
|
|
27
22
|
|
|
28
23
|
return (
|
|
29
24
|
<Box
|
|
@@ -7,7 +7,6 @@ import { useTranslation } from 'react-i18next'
|
|
|
7
7
|
import { useAvailableChains } from '../../hooks/useAvailableChains.js'
|
|
8
8
|
import { useExplorer } from '../../hooks/useExplorer.js'
|
|
9
9
|
import { useTokenSearch } from '../../hooks/useTokenSearch.js'
|
|
10
|
-
import { formatTokenPrice } from '../../utils/format.js'
|
|
11
10
|
import { shortenAddress } from '../../utils/wallet.js'
|
|
12
11
|
import { TokenAvatar } from '../Avatar/TokenAvatar.js'
|
|
13
12
|
import { CardIconButton } from '../Card/CardIconButton.js'
|
|
@@ -119,7 +118,7 @@ export const TokenDetailsSheetContent = forwardRef<
|
|
|
119
118
|
>
|
|
120
119
|
{token?.priceUSD
|
|
121
120
|
? t('format.currency', {
|
|
122
|
-
value:
|
|
121
|
+
value: token.priceUSD,
|
|
123
122
|
})
|
|
124
123
|
: noDataLabel}
|
|
125
124
|
</Typography>
|
|
@@ -6,7 +6,6 @@ import { useChainOrderStoreContext } from '../../stores/chains/ChainOrderStore.j
|
|
|
6
6
|
import type { FormType } from '../../stores/form/types.js'
|
|
7
7
|
import { FormKeyHelper } from '../../stores/form/types.js'
|
|
8
8
|
import { useFieldActions } from '../../stores/form/useFieldActions.js'
|
|
9
|
-
import { useFieldController } from '../../stores/form/useFieldController.js'
|
|
10
9
|
import { WidgetEvent } from '../../types/events.js'
|
|
11
10
|
import type { DisabledUI } from '../../types/widget.js'
|
|
12
11
|
|
|
@@ -23,11 +22,10 @@ export const useTokenSelect = (formType: FormType, onClick?: () => void) => {
|
|
|
23
22
|
const chainOrderStore = useChainOrderStoreContext()
|
|
24
23
|
|
|
25
24
|
const tokenKey = FormKeyHelper.getTokenKey(formType)
|
|
26
|
-
const { onChange } = useFieldController({ name: tokenKey })
|
|
27
25
|
|
|
28
26
|
return useCallback(
|
|
29
27
|
(tokenAddress: string, chainId?: number) => {
|
|
30
|
-
|
|
28
|
+
setFieldValue(tokenKey, tokenAddress, { isDirty: true, isTouched: true })
|
|
31
29
|
const selectedChainId =
|
|
32
30
|
chainId ?? getFieldValues(FormKeyHelper.getChainKey(formType))[0]
|
|
33
31
|
// Set chain again to trigger URL builder update
|
|
@@ -105,10 +103,10 @@ export const useTokenSelect = (formType: FormType, onClick?: () => void) => {
|
|
|
105
103
|
emitter,
|
|
106
104
|
formType,
|
|
107
105
|
getFieldValues,
|
|
108
|
-
onChange,
|
|
109
106
|
onClick,
|
|
110
107
|
setFieldValue,
|
|
111
108
|
subvariant,
|
|
109
|
+
tokenKey,
|
|
112
110
|
]
|
|
113
111
|
)
|
|
114
112
|
}
|
package/src/config/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/widget'
|
|
2
|
-
export const version = '3.
|
|
2
|
+
export const version = '3.26.1'
|
|
@@ -16,13 +16,17 @@ export const useFromAmountThreshold = () => {
|
|
|
16
16
|
const { token } = useToken(chainId, tokenAddress)
|
|
17
17
|
|
|
18
18
|
const belowMinFromAmountUSD = useMemo(() => {
|
|
19
|
-
const fromAmountUSD = formatTokenPrice(
|
|
19
|
+
const fromAmountUSD = formatTokenPrice(
|
|
20
|
+
fromAmount,
|
|
21
|
+
token?.priceUSD,
|
|
22
|
+
token?.decimals
|
|
23
|
+
)
|
|
20
24
|
|
|
21
25
|
if (!minFromAmountUSD || !fromAmountUSD) {
|
|
22
26
|
return false
|
|
23
27
|
}
|
|
24
28
|
return fromAmountUSD < minFromAmountUSD
|
|
25
|
-
}, [minFromAmountUSD, fromAmount, token?.priceUSD])
|
|
29
|
+
}, [minFromAmountUSD, fromAmount, token?.priceUSD, token?.decimals])
|
|
26
30
|
|
|
27
31
|
return {
|
|
28
32
|
belowMinFromAmountUSD,
|
|
@@ -57,7 +57,7 @@ export const useGasSufficiency = (route?: RouteExtended) => {
|
|
|
57
57
|
EVMAccount.chainType
|
|
58
58
|
)
|
|
59
59
|
|
|
60
|
-
const { data: insufficientGas, isLoading } = useQuery({
|
|
60
|
+
const { data: insufficientGas, isLoading } = useQuery<GasSufficiency[]>({
|
|
61
61
|
queryKey: [
|
|
62
62
|
getQueryKey('gas-sufficiency-check', keyPrefix),
|
|
63
63
|
relevantAccountsQueryKey,
|
|
@@ -66,7 +66,7 @@ export const useGasSufficiency = (route?: RouteExtended) => {
|
|
|
66
66
|
] as const,
|
|
67
67
|
queryFn: async () => {
|
|
68
68
|
if (!route) {
|
|
69
|
-
return
|
|
69
|
+
return []
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
// Filter out steps that are relayer steps or have primaryType 'Permit' or 'Order'
|
|
@@ -80,7 +80,7 @@ export const useGasSufficiency = (route?: RouteExtended) => {
|
|
|
80
80
|
|
|
81
81
|
// If all steps are filtered out, we don't need to check for gas sufficiency
|
|
82
82
|
if (!filteredSteps.length) {
|
|
83
|
-
return
|
|
83
|
+
return []
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
// We assume that LI.Fuel protocol always refuels the destination chain
|
|
@@ -163,7 +163,7 @@ export const useGasSufficiency = (route?: RouteExtended) => {
|
|
|
163
163
|
.flatMap((result) => result.value)
|
|
164
164
|
|
|
165
165
|
if (!tokenBalances?.length) {
|
|
166
|
-
return
|
|
166
|
+
return []
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
Object.keys(gasCosts).forEach((chainId) => {
|
|
@@ -4,23 +4,32 @@ import { useNavigate } from 'react-router-dom'
|
|
|
4
4
|
export const useNavigateBack = () => {
|
|
5
5
|
const navigate = useNavigate()
|
|
6
6
|
|
|
7
|
-
const navigateBack = useCallback(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
7
|
+
const navigateBack = useCallback(
|
|
8
|
+
(toPathname?: string) => {
|
|
9
|
+
// TODO: find a better router with nested memory routers support
|
|
10
|
+
// https://github.com/remix-run/react-router/pull/9112
|
|
11
|
+
// https://github.com/remix-run/react-router/discussions/9601
|
|
12
|
+
//
|
|
13
|
+
// if (window.history.length > 2) {
|
|
14
|
+
// navigate(-1)
|
|
15
|
+
// } else {
|
|
16
|
+
// navigate(
|
|
17
|
+
// window.location.pathname.substring(
|
|
18
|
+
// 0,
|
|
19
|
+
// window.location.pathname.lastIndexOf('/'),
|
|
20
|
+
// ) || '/',
|
|
21
|
+
// { replace: true },
|
|
22
|
+
// );
|
|
23
|
+
// }
|
|
24
|
+
|
|
25
|
+
if (toPathname) {
|
|
26
|
+
navigate(toPathname)
|
|
27
|
+
} else {
|
|
28
|
+
navigate(-1)
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
[navigate]
|
|
32
|
+
)
|
|
24
33
|
|
|
25
34
|
return { navigateBack, navigate }
|
|
26
35
|
}
|
|
@@ -3,7 +3,6 @@ import { executeRoute, resumeRoute, updateRouteExecution } from '@lifi/sdk'
|
|
|
3
3
|
import { useAccount } from '@lifi/wallet-management'
|
|
4
4
|
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
|
5
5
|
import { useCallback, useEffect, useRef } from 'react'
|
|
6
|
-
import { shallow } from 'zustand/shallow'
|
|
7
6
|
import { useWidgetConfig } from '../providers/WidgetProvider/WidgetProvider.js'
|
|
8
7
|
import {
|
|
9
8
|
useRouteExecutionStore,
|
|
@@ -43,8 +42,7 @@ export const useRouteExecution = ({
|
|
|
43
42
|
(state) => state.routes[routeId]
|
|
44
43
|
)
|
|
45
44
|
const [updateRoute, restartRoute, deleteRoute] = useRouteExecutionStore(
|
|
46
|
-
(state) => [state.updateRoute, state.restartRoute, state.deleteRoute]
|
|
47
|
-
shallow
|
|
45
|
+
(state) => [state.updateRoute, state.restartRoute, state.deleteRoute]
|
|
48
46
|
)
|
|
49
47
|
|
|
50
48
|
const updateRouteHook = (updatedRoute: Route) => {
|
package/src/hooks/useRoutes.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Route, Token } from '@lifi/sdk'
|
|
1
|
+
import type { Route, Token, TokensResponse } from '@lifi/sdk'
|
|
2
2
|
import {
|
|
3
3
|
ChainType,
|
|
4
4
|
convertQuoteToRoute,
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
} from '@lifi/sdk'
|
|
11
11
|
import { useAccount } from '@lifi/wallet-management'
|
|
12
12
|
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
|
13
|
+
import { useCallback, useMemo } from 'react'
|
|
13
14
|
import { parseUnits } from 'viem'
|
|
14
15
|
import { useWidgetConfig } from '../providers/WidgetProvider/WidgetProvider.js'
|
|
15
16
|
import { useFieldValues } from '../stores/form/useFieldValues.js'
|
|
@@ -137,32 +138,63 @@ export const useRoutes = ({ observableRoute }: RoutesProps = {}) => {
|
|
|
137
138
|
!isBatchingSupportedLoading
|
|
138
139
|
|
|
139
140
|
// Some values should be strictly typed and isEnabled ensures that
|
|
140
|
-
const queryKey =
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
141
|
+
const queryKey = useMemo(
|
|
142
|
+
() =>
|
|
143
|
+
[
|
|
144
|
+
getQueryKey('routes', keyPrefix),
|
|
145
|
+
account.address,
|
|
146
|
+
fromChain?.id as number,
|
|
147
|
+
fromToken?.address as string,
|
|
148
|
+
fromTokenAmount,
|
|
149
|
+
toWalletAddress,
|
|
150
|
+
toChain?.id as number,
|
|
151
|
+
toToken?.address as string,
|
|
152
|
+
toTokenAmount,
|
|
153
|
+
contractCalls,
|
|
154
|
+
slippage,
|
|
155
|
+
swapOnly,
|
|
156
|
+
disabledBridges,
|
|
157
|
+
disabledExchanges,
|
|
158
|
+
allowedBridges,
|
|
159
|
+
allowedExchanges,
|
|
160
|
+
routePriority,
|
|
161
|
+
subvariant,
|
|
162
|
+
allowSwitchChain,
|
|
163
|
+
enabledRefuel && enabledAutoRefuel,
|
|
164
|
+
gasRecommendationFromAmount,
|
|
165
|
+
feeConfig?.fee || fee,
|
|
166
|
+
!!isBatchingSupported,
|
|
167
|
+
observableRoute?.id,
|
|
168
|
+
] as const,
|
|
169
|
+
[
|
|
170
|
+
keyPrefix,
|
|
171
|
+
account.address,
|
|
172
|
+
fromChain?.id,
|
|
173
|
+
fromToken?.address,
|
|
174
|
+
fromTokenAmount,
|
|
175
|
+
toWalletAddress,
|
|
176
|
+
toChain?.id,
|
|
177
|
+
toToken?.address,
|
|
178
|
+
toTokenAmount,
|
|
179
|
+
contractCalls,
|
|
180
|
+
slippage,
|
|
181
|
+
swapOnly,
|
|
182
|
+
disabledBridges,
|
|
183
|
+
disabledExchanges,
|
|
184
|
+
allowedBridges,
|
|
185
|
+
allowedExchanges,
|
|
186
|
+
routePriority,
|
|
187
|
+
subvariant,
|
|
188
|
+
allowSwitchChain,
|
|
189
|
+
enabledRefuel,
|
|
190
|
+
enabledAutoRefuel,
|
|
191
|
+
gasRecommendationFromAmount,
|
|
192
|
+
feeConfig?.fee,
|
|
193
|
+
fee,
|
|
194
|
+
isBatchingSupported,
|
|
195
|
+
observableRoute?.id,
|
|
196
|
+
]
|
|
197
|
+
)
|
|
166
198
|
|
|
167
199
|
const { getIntermediateRoutes, setIntermediateRoutes } =
|
|
168
200
|
useIntermediateRoutesStore()
|
|
@@ -406,6 +438,24 @@ export const useRoutes = ({ observableRoute }: RoutesProps = {}) => {
|
|
|
406
438
|
// Update local tokens cache to keep priceUSD in sync
|
|
407
439
|
const { fromToken, toToken } = routesResult.routes[0]
|
|
408
440
|
;[fromToken, toToken].forEach((token) => {
|
|
441
|
+
queryClient.setQueriesData<TokensResponse>(
|
|
442
|
+
{ queryKey: [getQueryKey('tokens', keyPrefix)] },
|
|
443
|
+
(data) => {
|
|
444
|
+
if (data) {
|
|
445
|
+
const clonedData = { ...data }
|
|
446
|
+
const index = clonedData.tokens?.[token.chainId]?.findIndex(
|
|
447
|
+
(dataToken) => dataToken.address === token.address
|
|
448
|
+
)
|
|
449
|
+
if (index >= 0) {
|
|
450
|
+
clonedData.tokens[token.chainId][index] = {
|
|
451
|
+
...clonedData.tokens[token.chainId][index],
|
|
452
|
+
...token,
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
return clonedData
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
)
|
|
409
459
|
queryClient.setQueriesData<Token[]>(
|
|
410
460
|
{
|
|
411
461
|
queryKey: [
|
|
@@ -420,9 +470,11 @@ export const useRoutes = ({ observableRoute }: RoutesProps = {}) => {
|
|
|
420
470
|
const index = clonedData.findIndex(
|
|
421
471
|
(dataToken) => dataToken.address === token.address
|
|
422
472
|
)
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
473
|
+
if (index >= 0) {
|
|
474
|
+
clonedData[index] = {
|
|
475
|
+
...clonedData[index],
|
|
476
|
+
...token,
|
|
477
|
+
}
|
|
426
478
|
}
|
|
427
479
|
return clonedData
|
|
428
480
|
}
|
|
@@ -476,13 +528,16 @@ export const useRoutes = ({ observableRoute }: RoutesProps = {}) => {
|
|
|
476
528
|
},
|
|
477
529
|
})
|
|
478
530
|
|
|
479
|
-
const setReviewableRoute = (
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
531
|
+
const setReviewableRoute = useCallback(
|
|
532
|
+
(route: Route) => {
|
|
533
|
+
const queryDataKey = queryKey.toSpliced(queryKey.length - 1, 1, route.id)
|
|
534
|
+
queryClient.setQueryData(queryDataKey, [route], {
|
|
535
|
+
updatedAt: dataUpdatedAt || Date.now(),
|
|
536
|
+
})
|
|
537
|
+
setExecutableRoute(route)
|
|
538
|
+
},
|
|
539
|
+
[queryClient, dataUpdatedAt, setExecutableRoute, queryKey]
|
|
540
|
+
)
|
|
486
541
|
|
|
487
542
|
return {
|
|
488
543
|
routes: data || getIntermediateRoutes(queryKey),
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { shallow } from 'zustand/shallow'
|
|
2
1
|
import { useWidgetConfig } from '../providers/WidgetProvider/WidgetProvider.js'
|
|
3
2
|
import { useSettingsActions } from '../stores/settings/useSettingsActions.js'
|
|
4
3
|
import {
|
|
@@ -14,16 +13,13 @@ export const useSettingMonitor = () => {
|
|
|
14
13
|
routePriority,
|
|
15
14
|
slippage,
|
|
16
15
|
gasPrice,
|
|
17
|
-
] = useSettingsStore(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
],
|
|
25
|
-
shallow
|
|
26
|
-
)
|
|
16
|
+
] = useSettingsStore((state) => [
|
|
17
|
+
state.disabledBridges,
|
|
18
|
+
state.disabledExchanges,
|
|
19
|
+
state.routePriority,
|
|
20
|
+
state.slippage,
|
|
21
|
+
state.gasPrice,
|
|
22
|
+
])
|
|
27
23
|
const { tools } = useTools()
|
|
28
24
|
const config = useWidgetConfig()
|
|
29
25
|
const { setDefaultSettings, resetSettings } = useSettingsActions()
|
|
@@ -11,9 +11,14 @@ export const useTokenAddressBalance = (
|
|
|
11
11
|
|
|
12
12
|
const token = useMemo(() => {
|
|
13
13
|
if (tokenAddress && chainId) {
|
|
14
|
-
|
|
14
|
+
let token = tokensWithBalance?.find(
|
|
15
15
|
(token) => token.address === tokenAddress && token.chainId === chainId
|
|
16
16
|
)
|
|
17
|
+
if (!token) {
|
|
18
|
+
token = tokens?.find(
|
|
19
|
+
(token) => token.address === tokenAddress && token.chainId === chainId
|
|
20
|
+
)
|
|
21
|
+
}
|
|
17
22
|
return token as TokenAmount
|
|
18
23
|
}
|
|
19
24
|
}, [chainId, tokenAddress, tokens, tokensWithBalance])
|
|
@@ -61,8 +61,11 @@ export const useTokenSearch = (
|
|
|
61
61
|
(t) => t.address === token.address
|
|
62
62
|
)
|
|
63
63
|
) {
|
|
64
|
-
const clonedData = { ...data }
|
|
65
|
-
clonedData.tokens[chainId as number]
|
|
64
|
+
const clonedData = { ...data, tokens: { ...data.tokens } }
|
|
65
|
+
clonedData.tokens[chainId as number] = [
|
|
66
|
+
...(clonedData.tokens[chainId as number] ?? []),
|
|
67
|
+
token,
|
|
68
|
+
]
|
|
66
69
|
return clonedData
|
|
67
70
|
}
|
|
68
71
|
}
|
package/src/hooks/useTokens.ts
CHANGED
package/src/hooks/useTools.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getTools, type ToolsResponse } from '@lifi/sdk'
|
|
2
2
|
import { useQuery } from '@tanstack/react-query'
|
|
3
3
|
import { useWidgetConfig } from '../providers/WidgetProvider/WidgetProvider.js'
|
|
4
|
-
import {
|
|
4
|
+
import { settingsStore } from '../stores/settings/useSettingsStore.js'
|
|
5
5
|
import { getConfigItemSets, isItemAllowedForSets } from '../utils/item.js'
|
|
6
6
|
import { getQueryKey } from '../utils/queries.js'
|
|
7
7
|
|
|
@@ -33,7 +33,7 @@ export const useTools = () => {
|
|
|
33
33
|
isItemAllowedForSets(exchange.key, exchangesConfigSets)
|
|
34
34
|
),
|
|
35
35
|
}
|
|
36
|
-
const { initializeTools } =
|
|
36
|
+
const { initializeTools } = settingsStore.getState()
|
|
37
37
|
initializeTools(
|
|
38
38
|
'Bridges',
|
|
39
39
|
result.bridges.map((bridge) => bridge.key)
|
package/src/i18n/bn.json
CHANGED
package/src/i18n/de.json
CHANGED
package/src/i18n/en.json
CHANGED
package/src/i18n/es.json
CHANGED
package/src/i18n/fr.json
CHANGED
package/src/i18n/hi.json
CHANGED
package/src/i18n/id.json
CHANGED
package/src/i18n/it.json
CHANGED
package/src/i18n/ja.json
CHANGED
package/src/i18n/ko.json
CHANGED
package/src/i18n/pt.json
CHANGED
package/src/i18n/th.json
CHANGED
package/src/i18n/tr.json
CHANGED