@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.
Files changed (244) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/esm/components/AmountInput/AmountInput.js +75 -17
  3. package/dist/esm/components/AmountInput/AmountInput.js.map +1 -1
  4. package/dist/esm/components/AmountInput/AmountInput.style.d.ts +4 -0
  5. package/dist/esm/components/AmountInput/AmountInput.style.js +11 -0
  6. package/dist/esm/components/AmountInput/AmountInput.style.js.map +1 -1
  7. package/dist/esm/components/AmountInput/AmountInputAdornment.style.d.ts +1 -0
  8. package/dist/esm/components/AmountInput/AmountInputAdornment.style.js +64 -5
  9. package/dist/esm/components/AmountInput/AmountInputAdornment.style.js.map +1 -1
  10. package/dist/esm/components/AmountInput/AmountInputEndAdornment.js +20 -7
  11. package/dist/esm/components/AmountInput/AmountInputEndAdornment.js.map +1 -1
  12. package/dist/esm/components/AmountInput/PriceFormHelperText.js +41 -15
  13. package/dist/esm/components/AmountInput/PriceFormHelperText.js.map +1 -1
  14. package/dist/esm/components/AmountInput/PriceFormHelperText.style.d.ts +1 -0
  15. package/dist/esm/components/AmountInput/PriceFormHelperText.style.js +29 -0
  16. package/dist/esm/components/AmountInput/PriceFormHelperText.style.js.map +1 -0
  17. package/dist/esm/components/AppContainer.js +1 -0
  18. package/dist/esm/components/AppContainer.js.map +1 -1
  19. package/dist/esm/components/ChainSelect/useChainSelect.js +2 -4
  20. package/dist/esm/components/ChainSelect/useChainSelect.js.map +1 -1
  21. package/dist/esm/components/Chains/ChainsExpanded.d.ts +1 -1
  22. package/dist/esm/components/Chains/ChainsExpanded.js +3 -2
  23. package/dist/esm/components/Chains/ChainsExpanded.js.map +1 -1
  24. package/dist/esm/components/Chains/ChainsExpanded.style.js +1 -2
  25. package/dist/esm/components/Chains/ChainsExpanded.style.js.map +1 -1
  26. package/dist/esm/components/Chains/SelectChainContent.d.ts +1 -1
  27. package/dist/esm/components/Chains/SelectChainContent.js +3 -2
  28. package/dist/esm/components/Chains/SelectChainContent.js.map +1 -1
  29. package/dist/esm/components/Chains/VirtualizedChainList.js +5 -3
  30. package/dist/esm/components/Chains/VirtualizedChainList.js.map +1 -1
  31. package/dist/esm/components/Expansion/Expansion.js +5 -16
  32. package/dist/esm/components/Expansion/Expansion.js.map +1 -1
  33. package/dist/esm/components/Expansion/Expansion.style.d.ts +32 -0
  34. package/dist/esm/components/Expansion/Expansion.style.js +40 -0
  35. package/dist/esm/components/Expansion/Expansion.style.js.map +1 -0
  36. package/dist/esm/components/Expansion/ExpansionTransition.d.ts +0 -1
  37. package/dist/esm/components/Expansion/ExpansionTransition.js +1 -30
  38. package/dist/esm/components/Expansion/ExpansionTransition.js.map +1 -1
  39. package/dist/esm/components/Header/NavigationHeader.js +5 -1
  40. package/dist/esm/components/Header/NavigationHeader.js.map +1 -1
  41. package/dist/esm/components/Routes/RoutesContent.d.ts +2 -3
  42. package/dist/esm/components/Routes/RoutesContent.js +8 -23
  43. package/dist/esm/components/Routes/RoutesContent.js.map +1 -1
  44. package/dist/esm/components/Routes/RoutesExpanded.d.ts +2 -3
  45. package/dist/esm/components/Routes/RoutesExpanded.js +24 -8
  46. package/dist/esm/components/Routes/RoutesExpanded.js.map +1 -1
  47. package/dist/esm/components/Routes/RoutesExpanded.style.js +2 -2
  48. package/dist/esm/components/Routes/RoutesExpanded.style.js.map +1 -1
  49. package/dist/esm/components/SendToWallet/SendToWalletButton.js +1 -1
  50. package/dist/esm/components/SendToWallet/SendToWalletButton.js.map +1 -1
  51. package/dist/esm/components/SendToWallet/SendToWalletExpandButton.js +3 -3
  52. package/dist/esm/components/SendToWallet/SendToWalletExpandButton.js.map +1 -1
  53. package/dist/esm/components/Step/StepProcess.js +3 -8
  54. package/dist/esm/components/Step/StepProcess.js.map +1 -1
  55. package/dist/esm/components/TokenList/TokenDetailsSheetContent.js +1 -2
  56. package/dist/esm/components/TokenList/TokenDetailsSheetContent.js.map +1 -1
  57. package/dist/esm/components/TokenList/useTokenSelect.js +2 -4
  58. package/dist/esm/components/TokenList/useTokenSelect.js.map +1 -1
  59. package/dist/esm/config/version.d.ts +1 -1
  60. package/dist/esm/config/version.js +1 -1
  61. package/dist/esm/hooks/useFromAmountThreshold.js +2 -2
  62. package/dist/esm/hooks/useFromAmountThreshold.js.map +1 -1
  63. package/dist/esm/hooks/useGasSufficiency.js +3 -3
  64. package/dist/esm/hooks/useGasSufficiency.js.map +1 -1
  65. package/dist/esm/hooks/useNavigateBack.d.ts +1 -1
  66. package/dist/esm/hooks/useNavigateBack.js +8 -2
  67. package/dist/esm/hooks/useNavigateBack.js.map +1 -1
  68. package/dist/esm/hooks/useRouteExecution.js +1 -2
  69. package/dist/esm/hooks/useRouteExecution.js.map +1 -1
  70. package/dist/esm/hooks/useRoutes.js +51 -8
  71. package/dist/esm/hooks/useRoutes.js.map +1 -1
  72. package/dist/esm/hooks/useSettingMonitor.js +1 -2
  73. package/dist/esm/hooks/useSettingMonitor.js.map +1 -1
  74. package/dist/esm/hooks/useTokenAddressBalance.js +4 -1
  75. package/dist/esm/hooks/useTokenAddressBalance.js.map +1 -1
  76. package/dist/esm/hooks/useTokenSearch.js +5 -2
  77. package/dist/esm/hooks/useTokenSearch.js.map +1 -1
  78. package/dist/esm/hooks/useTokens.js +2 -2
  79. package/dist/esm/hooks/useTokens.js.map +1 -1
  80. package/dist/esm/hooks/useTools.js +2 -2
  81. package/dist/esm/hooks/useTools.js.map +1 -1
  82. package/dist/esm/i18n/bn.json +1 -1
  83. package/dist/esm/i18n/de.json +1 -1
  84. package/dist/esm/i18n/en.json +1 -1
  85. package/dist/esm/i18n/es.json +1 -1
  86. package/dist/esm/i18n/fr.json +1 -1
  87. package/dist/esm/i18n/hi.json +1 -1
  88. package/dist/esm/i18n/id.json +1 -1
  89. package/dist/esm/i18n/it.json +1 -1
  90. package/dist/esm/i18n/ja.json +1 -1
  91. package/dist/esm/i18n/ko.json +1 -1
  92. package/dist/esm/i18n/pt.json +1 -1
  93. package/dist/esm/i18n/th.json +1 -1
  94. package/dist/esm/i18n/tr.json +1 -1
  95. package/dist/esm/i18n/uk.json +1 -1
  96. package/dist/esm/i18n/vi.json +1 -1
  97. package/dist/esm/i18n/zh.json +1 -1
  98. package/dist/esm/pages/SelectEnabledToolsPage.js +4 -2
  99. package/dist/esm/pages/SelectEnabledToolsPage.js.map +1 -1
  100. package/dist/esm/pages/SelectTokenPage/SearchTokenInput.js +14 -7
  101. package/dist/esm/pages/SelectTokenPage/SearchTokenInput.js.map +1 -1
  102. package/dist/esm/pages/SettingsPage/BridgeAndExchangeSettings.js +1 -2
  103. package/dist/esm/pages/SettingsPage/BridgeAndExchangeSettings.js.map +1 -1
  104. package/dist/esm/pages/TransactionPage/TransactionPage.js +5 -3
  105. package/dist/esm/pages/TransactionPage/TransactionPage.js.map +1 -1
  106. package/dist/esm/stores/bookmarks/BookmarkStore.d.ts +1 -2
  107. package/dist/esm/stores/bookmarks/BookmarkStore.js +3 -3
  108. package/dist/esm/stores/bookmarks/BookmarkStore.js.map +1 -1
  109. package/dist/esm/stores/bookmarks/useBookmarkActions.js +1 -2
  110. package/dist/esm/stores/bookmarks/useBookmarkActions.js.map +1 -1
  111. package/dist/esm/stores/bookmarks/useBookmarks.js +1 -2
  112. package/dist/esm/stores/bookmarks/useBookmarks.js.map +1 -1
  113. package/dist/esm/stores/chains/ChainOrderStore.d.ts +1 -1
  114. package/dist/esm/stores/chains/ChainOrderStore.js +3 -2
  115. package/dist/esm/stores/chains/ChainOrderStore.js.map +1 -1
  116. package/dist/esm/stores/chains/useChainOrder.js +1 -2
  117. package/dist/esm/stores/chains/useChainOrder.js.map +1 -1
  118. package/dist/esm/stores/form/useFieldActions.js +1 -2
  119. package/dist/esm/stores/form/useFieldActions.js.map +1 -1
  120. package/dist/esm/stores/form/useFieldValues.js +1 -2
  121. package/dist/esm/stores/form/useFieldValues.js.map +1 -1
  122. package/dist/esm/stores/form/useFormStore.d.ts +1 -2
  123. package/dist/esm/stores/form/useFormStore.js +3 -3
  124. package/dist/esm/stores/form/useFormStore.js.map +1 -1
  125. package/dist/esm/stores/form/useTouchedFields.js +1 -2
  126. package/dist/esm/stores/form/useTouchedFields.js.map +1 -1
  127. package/dist/esm/stores/form/useValidation.js +5 -2
  128. package/dist/esm/stores/form/useValidation.js.map +1 -1
  129. package/dist/esm/stores/form/useValidationActions.js +1 -2
  130. package/dist/esm/stores/form/useValidationActions.js.map +1 -1
  131. package/dist/esm/stores/header/useHeaderStore.d.ts +1 -1
  132. package/dist/esm/stores/header/useHeaderStore.js +3 -2
  133. package/dist/esm/stores/header/useHeaderStore.js.map +1 -1
  134. package/dist/esm/stores/inputMode/useInputModeStore.d.ts +9 -0
  135. package/dist/esm/stores/inputMode/useInputModeStore.js +19 -0
  136. package/dist/esm/stores/inputMode/useInputModeStore.js.map +1 -0
  137. package/dist/esm/stores/routes/RouteExecutionStore.d.ts +1 -1
  138. package/dist/esm/stores/routes/RouteExecutionStore.js +3 -2
  139. package/dist/esm/stores/routes/RouteExecutionStore.js.map +1 -1
  140. package/dist/esm/stores/routes/useExecutingRoutesIds.js +1 -2
  141. package/dist/esm/stores/routes/useExecutingRoutesIds.js.map +1 -1
  142. package/dist/esm/stores/settings/useSendToWalletStore.d.ts +2 -1
  143. package/dist/esm/stores/settings/useSendToWalletStore.js +6 -3
  144. package/dist/esm/stores/settings/useSendToWalletStore.js.map +1 -1
  145. package/dist/esm/stores/settings/useSettings.js +1 -2
  146. package/dist/esm/stores/settings/useSettings.js.map +1 -1
  147. package/dist/esm/stores/settings/useSettingsActions.js +1 -2
  148. package/dist/esm/stores/settings/useSettingsActions.js.map +1 -1
  149. package/dist/esm/stores/settings/useSettingsStore.d.ts +2 -1
  150. package/dist/esm/stores/settings/useSettingsStore.js +5 -1
  151. package/dist/esm/stores/settings/useSettingsStore.js.map +1 -1
  152. package/dist/esm/stores/settings/useSplitSubvariantStore.js +2 -1
  153. package/dist/esm/stores/settings/useSplitSubvariantStore.js.map +1 -1
  154. package/dist/esm/themes/createTheme.js +5 -1
  155. package/dist/esm/themes/createTheme.js.map +1 -1
  156. package/dist/esm/types/widget.d.ts +2 -1
  157. package/dist/esm/types/widget.js +1 -0
  158. package/dist/esm/types/widget.js.map +1 -1
  159. package/dist/esm/utils/format.d.ts +4 -0
  160. package/dist/esm/utils/format.js +26 -0
  161. package/dist/esm/utils/format.js.map +1 -1
  162. package/dist/esm/utils/getPriceImpact.d.ts +2 -2
  163. package/dist/esm/utils/getPriceImpact.js.map +1 -1
  164. package/package.json +12 -12
  165. package/package.json.tmp +14 -14
  166. package/src/components/AmountInput/AmountInput.style.tsx +13 -0
  167. package/src/components/AmountInput/AmountInput.tsx +91 -18
  168. package/src/components/AmountInput/AmountInputAdornment.style.tsx +66 -5
  169. package/src/components/AmountInput/AmountInputEndAdornment.tsx +40 -10
  170. package/src/components/AmountInput/PriceFormHelperText.style.tsx +29 -0
  171. package/src/components/AmountInput/PriceFormHelperText.tsx +63 -19
  172. package/src/components/AppContainer.tsx +1 -0
  173. package/src/components/ChainSelect/useChainSelect.ts +2 -4
  174. package/src/components/Chains/ChainsExpanded.style.tsx +1 -2
  175. package/src/components/Chains/ChainsExpanded.tsx +6 -2
  176. package/src/components/Chains/SelectChainContent.tsx +81 -82
  177. package/src/components/Chains/VirtualizedChainList.tsx +5 -6
  178. package/src/components/Expansion/Expansion.style.tsx +43 -0
  179. package/src/components/Expansion/Expansion.tsx +8 -23
  180. package/src/components/Expansion/ExpansionTransition.tsx +5 -33
  181. package/src/components/Header/NavigationHeader.tsx +10 -1
  182. package/src/components/Routes/RoutesContent.tsx +14 -31
  183. package/src/components/Routes/RoutesExpanded.style.ts +2 -2
  184. package/src/components/Routes/RoutesExpanded.tsx +33 -13
  185. package/src/components/SendToWallet/SendToWalletButton.tsx +1 -1
  186. package/src/components/SendToWallet/SendToWalletExpandButton.tsx +8 -3
  187. package/src/components/Step/StepProcess.tsx +3 -8
  188. package/src/components/TokenList/TokenDetailsSheetContent.tsx +1 -2
  189. package/src/components/TokenList/useTokenSelect.ts +2 -4
  190. package/src/config/version.ts +1 -1
  191. package/src/hooks/useFromAmountThreshold.ts +6 -2
  192. package/src/hooks/useGasSufficiency.ts +4 -4
  193. package/src/hooks/useNavigateBack.ts +26 -17
  194. package/src/hooks/useRouteExecution.ts +1 -3
  195. package/src/hooks/useRoutes.ts +92 -37
  196. package/src/hooks/useSettingMonitor.ts +7 -11
  197. package/src/hooks/useTokenAddressBalance.ts +6 -1
  198. package/src/hooks/useTokenSearch.ts +5 -2
  199. package/src/hooks/useTokens.ts +2 -2
  200. package/src/hooks/useTools.ts +2 -2
  201. package/src/i18n/bn.json +1 -1
  202. package/src/i18n/de.json +1 -1
  203. package/src/i18n/en.json +1 -1
  204. package/src/i18n/es.json +1 -1
  205. package/src/i18n/fr.json +1 -1
  206. package/src/i18n/hi.json +1 -1
  207. package/src/i18n/id.json +1 -1
  208. package/src/i18n/it.json +1 -1
  209. package/src/i18n/ja.json +1 -1
  210. package/src/i18n/ko.json +1 -1
  211. package/src/i18n/pt.json +1 -1
  212. package/src/i18n/th.json +1 -1
  213. package/src/i18n/tr.json +1 -1
  214. package/src/i18n/uk.json +1 -1
  215. package/src/i18n/vi.json +1 -1
  216. package/src/i18n/zh.json +1 -1
  217. package/src/pages/SelectEnabledToolsPage.tsx +4 -5
  218. package/src/pages/SelectTokenPage/SearchTokenInput.tsx +19 -7
  219. package/src/pages/SettingsPage/BridgeAndExchangeSettings.tsx +1 -2
  220. package/src/pages/TransactionPage/TransactionPage.tsx +17 -9
  221. package/src/stores/bookmarks/BookmarkStore.tsx +3 -6
  222. package/src/stores/bookmarks/useBookmarkActions.ts +9 -13
  223. package/src/stores/bookmarks/useBookmarks.ts +1 -3
  224. package/src/stores/chains/ChainOrderStore.tsx +3 -3
  225. package/src/stores/chains/useChainOrder.ts +1 -5
  226. package/src/stores/form/useFieldActions.ts +10 -14
  227. package/src/stores/form/useFieldValues.ts +1 -3
  228. package/src/stores/form/useFormStore.ts +3 -6
  229. package/src/stores/form/useTouchedFields.ts +1 -2
  230. package/src/stores/form/useValidation.ts +5 -5
  231. package/src/stores/form/useValidationActions.ts +5 -9
  232. package/src/stores/header/useHeaderStore.tsx +3 -5
  233. package/src/stores/inputMode/useInputModeStore.ts +29 -0
  234. package/src/stores/routes/RouteExecutionStore.tsx +3 -3
  235. package/src/stores/routes/useExecutingRoutesIds.ts +14 -17
  236. package/src/stores/settings/useSendToWalletStore.ts +11 -8
  237. package/src/stores/settings/useSettings.ts +8 -11
  238. package/src/stores/settings/useSettingsActions.ts +8 -12
  239. package/src/stores/settings/useSettingsStore.ts +8 -1
  240. package/src/stores/settings/useSplitSubvariantStore.tsx +2 -1
  241. package/src/themes/createTheme.ts +5 -1
  242. package/src/types/widget.ts +1 -0
  243. package/src/utils/format.ts +33 -0
  244. 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 { useSendToWalletStore } from '../../stores/settings/useSendToWalletStore.js'
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
- useSendToWalletStore.getState().showSendToWallet
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.txHash
16
+ const transactionLink = process.txLink
17
17
  ? getTransactionLink({
18
- txHash: process.txHash,
18
+ txLink: process.txLink,
19
19
  chain: process.chainId,
20
20
  })
21
- : process.txLink
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: formatTokenPrice('1', token.priceUSD, token.decimals),
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
- onChange(tokenAddress)
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
  }
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/widget'
2
- export const version = '3.25.0'
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(fromAmount, token?.priceUSD)
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
- // TODO: find a better router with nested memory routers support
9
- // https://github.com/remix-run/react-router/pull/9112
10
- // https://github.com/remix-run/react-router/discussions/9601
11
- //
12
- // if (window.history.length > 2) {
13
- navigate(-1)
14
- // } else {
15
- // navigate(
16
- // window.location.pathname.substring(
17
- // 0,
18
- // window.location.pathname.lastIndexOf('/'),
19
- // ) || '/',
20
- // { replace: true },
21
- // );
22
- // }
23
- }, [navigate])
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) => {
@@ -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
- getQueryKey('routes', keyPrefix),
142
- account.address,
143
- fromChain?.id as number,
144
- fromToken?.address as string,
145
- fromTokenAmount,
146
- toWalletAddress,
147
- toChain?.id as number,
148
- toToken?.address as string,
149
- toTokenAmount,
150
- contractCalls,
151
- slippage,
152
- swapOnly,
153
- disabledBridges,
154
- disabledExchanges,
155
- allowedBridges,
156
- allowedExchanges,
157
- routePriority,
158
- subvariant,
159
- allowSwitchChain,
160
- enabledRefuel && enabledAutoRefuel,
161
- gasRecommendationFromAmount,
162
- feeConfig?.fee || fee,
163
- !!isBatchingSupported,
164
- observableRoute?.id,
165
- ] as const
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
- clonedData[index] = {
424
- ...clonedData[index],
425
- ...token,
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 = (route: Route) => {
480
- const queryDataKey = queryKey.toSpliced(queryKey.length - 1, 1, route.id)
481
- queryClient.setQueryData(queryDataKey, [route], {
482
- updatedAt: dataUpdatedAt || Date.now(),
483
- })
484
- setExecutableRoute(route)
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
- (state) => [
19
- state.disabledBridges,
20
- state.disabledExchanges,
21
- state.routePriority,
22
- state.slippage,
23
- state.gasPrice,
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
- const token = (tokensWithBalance ?? tokens)?.find(
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]?.push(token as TokenExtended)
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
  }
@@ -19,8 +19,8 @@ export const useTokens = (selectedChainId?: number) => {
19
19
  ChainType.MVM,
20
20
  ],
21
21
  }),
22
- refetchInterval: 3_600_000,
23
- staleTime: 3_600_000,
22
+ refetchInterval: 300_000,
23
+ staleTime: 300_000,
24
24
  })
25
25
  const {
26
26
  chains,
@@ -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 { useSettingsStore } from '../stores/settings/useSettingsStore.js'
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 } = useSettingsStore.getState()
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
@@ -36,7 +36,7 @@
36
36
  "getGas": "গ্যাস পান",
37
37
  "learnMore": "আরও জানুন",
38
38
  "light": "লাইট",
39
- "max": "সর্বোচ্চ",
39
+ "max": "",
40
40
  "ok": "ঠিক আছে",
41
41
  "options": "",
42
42
  "removeTransaction": "",
package/src/i18n/de.json CHANGED
@@ -36,7 +36,7 @@
36
36
  "getGas": "Gas erhalten",
37
37
  "learnMore": "Mehr erfahren",
38
38
  "light": "Hell",
39
- "max": "max",
39
+ "max": "",
40
40
  "ok": "OK",
41
41
  "options": "",
42
42
  "removeTransaction": "Transaktion entfernen",
package/src/i18n/en.json CHANGED
@@ -36,7 +36,7 @@
36
36
  "getGas": "Get gas",
37
37
  "learnMore": "Learn more",
38
38
  "light": "Light",
39
- "max": "max",
39
+ "max": "MAX",
40
40
  "ok": "Ok",
41
41
  "options": "Options",
42
42
  "removeTransaction": "Remove transaction",
package/src/i18n/es.json CHANGED
@@ -36,7 +36,7 @@
36
36
  "getGas": "Obtener gas",
37
37
  "learnMore": "Aprender más",
38
38
  "light": "Luz",
39
- "max": "máximo",
39
+ "max": "",
40
40
  "ok": "Ok",
41
41
  "options": "Opciones",
42
42
  "removeTransaction": "Eliminar transacción",
package/src/i18n/fr.json CHANGED
@@ -36,7 +36,7 @@
36
36
  "getGas": "Obtenir du gaz",
37
37
  "learnMore": "Plus d'info",
38
38
  "light": "Clair",
39
- "max": "max",
39
+ "max": "",
40
40
  "ok": "Ok",
41
41
  "options": "Options",
42
42
  "removeTransaction": "Supprimer la transaction",
package/src/i18n/hi.json CHANGED
@@ -36,7 +36,7 @@
36
36
  "getGas": "गेस शुल्क ले",
37
37
  "learnMore": "",
38
38
  "light": "रोशनी",
39
- "max": "अधिकतम",
39
+ "max": "",
40
40
  "ok": "ठीक है",
41
41
  "options": "",
42
42
  "removeTransaction": "",
package/src/i18n/id.json CHANGED
@@ -36,7 +36,7 @@
36
36
  "getGas": "Dapatkan gas",
37
37
  "learnMore": "Pelajari lebih lanjut",
38
38
  "light": "Terang",
39
- "max": "maks",
39
+ "max": "",
40
40
  "ok": "Ya",
41
41
  "options": "Opsi",
42
42
  "removeTransaction": "Hapus transaksi",
package/src/i18n/it.json CHANGED
@@ -36,7 +36,7 @@
36
36
  "getGas": "Ottieni gas",
37
37
  "learnMore": "Ulteriori informazioni",
38
38
  "light": "Chiaro",
39
- "max": "massimo",
39
+ "max": "",
40
40
  "ok": "Ok",
41
41
  "options": "",
42
42
  "removeTransaction": "Rimuovi transazione",
package/src/i18n/ja.json CHANGED
@@ -36,7 +36,7 @@
36
36
  "getGas": "ガス代を入手",
37
37
  "learnMore": "さらに詳しく",
38
38
  "light": "ライト",
39
- "max": "最大値",
39
+ "max": "",
40
40
  "ok": "OK",
41
41
  "options": "オプション",
42
42
  "removeTransaction": "トランザクションを削除",
package/src/i18n/ko.json CHANGED
@@ -36,7 +36,7 @@
36
36
  "getGas": "가스 받기",
37
37
  "learnMore": "자세히 알아보기",
38
38
  "light": "밝게",
39
- "max": "최대",
39
+ "max": "",
40
40
  "ok": "확인",
41
41
  "options": "",
42
42
  "removeTransaction": "거래 지우기",
package/src/i18n/pt.json CHANGED
@@ -36,7 +36,7 @@
36
36
  "getGas": "Obter gás",
37
37
  "learnMore": "Saiba mais",
38
38
  "light": "Claro",
39
- "max": "máximo",
39
+ "max": "",
40
40
  "ok": "Tudo certo",
41
41
  "options": "Opções",
42
42
  "removeTransaction": "Remover transação",
package/src/i18n/th.json CHANGED
@@ -36,7 +36,7 @@
36
36
  "getGas": "รับแก็ส",
37
37
  "learnMore": "เรียนรู้เพิ่มเติม",
38
38
  "light": "สว่าง",
39
- "max": "สูงสุด",
39
+ "max": "",
40
40
  "ok": "ตกลง",
41
41
  "options": "การตั้งค่า",
42
42
  "removeTransaction": "นำรายการออก",
package/src/i18n/tr.json CHANGED
@@ -36,7 +36,7 @@
36
36
  "getGas": "Gaz al",
37
37
  "learnMore": "Daha fazla bilgi edinin",
38
38
  "light": "Açık",
39
- "max": "maksimum",
39
+ "max": "",
40
40
  "ok": "Tamam",
41
41
  "options": "Ayarlar",
42
42
  "removeTransaction": "İşlemi kaldır",
package/src/i18n/uk.json CHANGED
@@ -36,7 +36,7 @@
36
36
  "getGas": "Отримати газ",
37
37
  "learnMore": "Докладніше",
38
38
  "light": "Світла",
39
- "max": "макс",
39
+ "max": "",
40
40
  "ok": "Ок",
41
41
  "options": "Опції",
42
42
  "removeTransaction": "Видалити транзакцію",