@lifi/widget 2.0.0-beta.1 → 2.0.0-beta.10

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 (283) hide show
  1. package/App.d.ts +4 -3
  2. package/AppDrawer.d.ts +1 -1
  3. package/AppDrawer.js +2 -1
  4. package/AppProvider.js +1 -1
  5. package/README.md +11 -12
  6. package/cjs/App.d.ts +4 -3
  7. package/cjs/AppDrawer.d.ts +1 -1
  8. package/cjs/AppDrawer.js +2 -1
  9. package/cjs/AppProvider.js +1 -1
  10. package/cjs/components/ChainSelect/ChainSelect.d.ts +1 -2
  11. package/cjs/components/ChainSelect/ChainSelect.style.js +1 -1
  12. package/cjs/components/ChainSelect/useChainSelect.js +6 -0
  13. package/cjs/components/GasMessage/FundsSufficiencyMessage.d.ts +1 -2
  14. package/cjs/components/GasMessage/GasMessage.js +1 -6
  15. package/cjs/components/Header/Header.js +2 -2
  16. package/cjs/components/Header/Header.style.d.ts +10 -3
  17. package/cjs/components/Header/Header.style.js +3 -0
  18. package/cjs/components/Header/NavigationHeader.js +23 -7
  19. package/cjs/components/Header/NavigationTabs.d.ts +1 -0
  20. package/cjs/components/Header/NavigationTabs.js +26 -0
  21. package/cjs/components/Header/NavigationTabs.style.d.ts +34 -0
  22. package/cjs/components/Header/NavigationTabs.style.js +61 -0
  23. package/cjs/components/Header/WalletHeader.d.ts +1 -0
  24. package/cjs/components/Header/WalletHeader.js +16 -9
  25. package/cjs/components/Header/useHeaderActionStore.js +0 -1
  26. package/cjs/components/Insurance/Insurance.js +2 -2
  27. package/cjs/components/Insurance/InsuranceCard.js +34 -12
  28. package/cjs/components/Insurance/InsuranceCollapsed.js +9 -11
  29. package/cjs/components/Insurance/index.d.ts +1 -0
  30. package/cjs/components/Insurance/index.js +1 -0
  31. package/cjs/components/Insurance/types.d.ts +12 -9
  32. package/cjs/components/NFT/NFT.js +2 -2
  33. package/cjs/components/NFT/types.d.ts +1 -1
  34. package/cjs/components/PoweredBy/PoweredBy.js +2 -3
  35. package/cjs/components/SelectChainAndToken.js +8 -7
  36. package/cjs/components/SelectTokenButton/SelectTokenButton.js +6 -3
  37. package/cjs/components/SendToWallet/SendToWallet.js +2 -2
  38. package/cjs/components/SmallAvatar.d.ts +1 -1
  39. package/cjs/components/Step/CircularProgress.d.ts +1 -2
  40. package/cjs/components/Step/Step.js +15 -5
  41. package/cjs/components/Step/StepList.d.ts +1 -2
  42. package/cjs/components/StepActions/StepActions.js +4 -20
  43. package/cjs/components/SwapButton/SwapButton.js +16 -4
  44. package/cjs/components/SwapInput/FormPriceHelperText.js +1 -1
  45. package/cjs/components/SwapInput/SwapInput.js +2 -2
  46. package/cjs/components/SwapInput/SwapInputEndAdornment.d.ts +1 -2
  47. package/cjs/components/SwapInput/SwapInputEndAdornment.js +2 -2
  48. package/cjs/components/SwapRouteCard/SwapRouteCard.js +19 -3
  49. package/cjs/components/SwapRouteCard/SwapRouteCardEssentials.js +1 -1
  50. package/cjs/components/SwapRouteCard/SwapRouteCardSkeleton.js +1 -1
  51. package/cjs/components/SwapRoutes/SwapRoutes.js +1 -1
  52. package/cjs/components/SwapRoutes/SwapRoutesExpanded.d.ts +2 -3
  53. package/cjs/components/SwapRoutes/SwapRoutesExpanded.js +2 -2
  54. package/cjs/components/SwapRoutes/SwapRoutesExpanded.style.js +1 -0
  55. package/cjs/components/Token/Token.js +1 -1
  56. package/cjs/components/TokenAvatar/TokenAvatar.d.ts +4 -4
  57. package/cjs/components/TokenList/TokenList.js +9 -4
  58. package/cjs/components/TokenList/TokenList.style.d.ts +5 -2
  59. package/cjs/components/TokenList/TokenList.style.js +20 -1
  60. package/cjs/components/TokenList/TokenListItem.d.ts +1 -1
  61. package/cjs/components/TokenList/TokenListItem.js +28 -5
  62. package/cjs/components/TokenList/VirtualizedTokenList.js +3 -3
  63. package/cjs/components/TokenList/types.d.ts +6 -3
  64. package/cjs/config/theme.js +15 -3
  65. package/cjs/config/version.d.ts +1 -1
  66. package/cjs/config/version.js +1 -1
  67. package/cjs/hooks/index.d.ts +2 -1
  68. package/cjs/hooks/index.js +2 -1
  69. package/cjs/hooks/useContentHeight.js +3 -5
  70. package/cjs/hooks/useFeaturedTokens.d.ts +1 -1
  71. package/cjs/hooks/useFundsSufficiency.js +2 -2
  72. package/cjs/hooks/useGasRefuel.d.ts +1 -1
  73. package/cjs/hooks/useGasRefuel.js +5 -15
  74. package/cjs/hooks/useGasSufficiency.js +12 -3
  75. package/cjs/hooks/useInitializer.js +0 -1
  76. package/cjs/hooks/useProcessMessage.d.ts +2 -1
  77. package/cjs/hooks/useProcessMessage.js +27 -9
  78. package/cjs/hooks/useRouteExecution.js +6 -5
  79. package/cjs/hooks/useSwapOnly.d.ts +1 -0
  80. package/cjs/hooks/useSwapOnly.js +9 -0
  81. package/cjs/hooks/useSwapRoutes.d.ts +1 -2
  82. package/cjs/hooks/useSwapRoutes.js +32 -18
  83. package/cjs/hooks/useToken.d.ts +1 -1
  84. package/cjs/hooks/useTokenAddressBalance.d.ts +2 -2
  85. package/cjs/hooks/useTokenBalance.js +6 -7
  86. package/cjs/hooks/useTokenBalances.d.ts +5 -5
  87. package/cjs/hooks/useTokenBalances.js +4 -19
  88. package/cjs/hooks/useTokenSearch.d.ts +2 -2
  89. package/cjs/hooks/useTokens.d.ts +2 -2
  90. package/cjs/i18n/bn.json +8 -0
  91. package/cjs/i18n/en.json +30 -5
  92. package/cjs/i18n/fr.json +8 -0
  93. package/cjs/i18n/id.json +22 -7
  94. package/cjs/i18n/ko.json +22 -7
  95. package/cjs/i18n/pt.json +32 -7
  96. package/cjs/i18n/th.json +21 -6
  97. package/cjs/i18n/uk.json +43 -18
  98. package/cjs/i18n/zh.json +23 -8
  99. package/cjs/icons/InsuraceLogo.d.ts +1 -1
  100. package/cjs/icons/LiFiFullLogo.d.ts +1 -1
  101. package/cjs/icons/LiFiLogo.d.ts +1 -1
  102. package/cjs/icons/LiFiToolLogo.d.ts +1 -1
  103. package/cjs/index.d.ts +1 -1
  104. package/cjs/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +1 -2
  105. package/cjs/pages/SelectTokenPage/SearchTokenInput.d.ts +1 -2
  106. package/cjs/pages/SelectTokenPage/SelectTokenPage.js +3 -1
  107. package/cjs/pages/SelectWalletPage/SelectWalletPage.d.ts +1 -2
  108. package/cjs/pages/SettingsPage/GasPriceSelect.d.ts +1 -2
  109. package/cjs/pages/SettingsPage/LanguageSelect.js +1 -1
  110. package/cjs/pages/SettingsPage/SettingsPage.d.ts +1 -2
  111. package/cjs/pages/SettingsPage/ShowDestinationWallet.d.ts +1 -2
  112. package/cjs/pages/SettingsPage/SlippageInput.d.ts +1 -2
  113. package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +6 -2
  114. package/cjs/pages/SwapPage/ExchangeRateBottomSheet.js +1 -1
  115. package/cjs/pages/SwapPage/StatusBottomSheet.js +15 -9
  116. package/cjs/pages/SwapPage/StatusBottomSheet.style.d.ts +1 -1
  117. package/cjs/pages/SwapPage/StatusBottomSheet.style.js +2 -2
  118. package/cjs/pages/SwapPage/SwapPage.js +31 -10
  119. package/cjs/pages/SwapPage/TokenValueBottomSheet.js +7 -12
  120. package/cjs/pages/SwapPage/utils.d.ts +2 -0
  121. package/cjs/pages/SwapPage/utils.js +10 -0
  122. package/cjs/providers/I18nProvider/I18nProvider.js +3 -3
  123. package/cjs/providers/SDKProvider/SDKProvider.js +2 -0
  124. package/cjs/providers/SwapFormProvider/FormUpdater.js +3 -0
  125. package/cjs/providers/WalletProvider/WalletProvider.js +77 -49
  126. package/cjs/providers/WalletProvider/types.d.ts +3 -5
  127. package/cjs/providers/WidgetProvider/WidgetProvider.js +1 -1
  128. package/cjs/stores/StoreProvider.d.ts +2 -2
  129. package/cjs/stores/StoreProvider.js +3 -2
  130. package/cjs/stores/routes/RouteExecutionStore.d.ts +1 -1
  131. package/cjs/stores/routes/RouteExecutionStore.js +0 -1
  132. package/cjs/stores/settings/index.d.ts +1 -0
  133. package/cjs/stores/settings/index.js +1 -0
  134. package/cjs/stores/settings/types.d.ts +11 -0
  135. package/cjs/stores/settings/useSplitSubvariantStore.d.ts +7 -0
  136. package/cjs/stores/settings/useSplitSubvariantStore.js +44 -0
  137. package/cjs/types/events.d.ts +9 -1
  138. package/cjs/types/events.js +1 -0
  139. package/cjs/types/token.d.ts +2 -2
  140. package/cjs/types/widget.d.ts +13 -8
  141. package/cjs/types/widget.js +4 -2
  142. package/cjs/utils/format.d.ts +1 -1
  143. package/cjs/utils/format.js +7 -12
  144. package/cjs/utils/wallet.d.ts +1 -1
  145. package/cjs/utils/wallet.js +3 -3
  146. package/components/ChainSelect/ChainSelect.d.ts +1 -2
  147. package/components/ChainSelect/ChainSelect.style.js +1 -1
  148. package/components/ChainSelect/useChainSelect.js +7 -1
  149. package/components/GasMessage/FundsSufficiencyMessage.d.ts +1 -2
  150. package/components/GasMessage/GasMessage.js +2 -7
  151. package/components/Header/Header.js +3 -3
  152. package/components/Header/Header.style.d.ts +10 -3
  153. package/components/Header/Header.style.js +3 -0
  154. package/components/Header/NavigationHeader.js +23 -7
  155. package/components/Header/NavigationTabs.d.ts +1 -0
  156. package/components/Header/NavigationTabs.js +22 -0
  157. package/components/Header/NavigationTabs.style.d.ts +34 -0
  158. package/components/Header/NavigationTabs.style.js +58 -0
  159. package/components/Header/WalletHeader.d.ts +1 -0
  160. package/components/Header/WalletHeader.js +14 -8
  161. package/components/Header/useHeaderActionStore.js +0 -1
  162. package/components/Insurance/Insurance.js +2 -2
  163. package/components/Insurance/InsuranceCard.js +37 -15
  164. package/components/Insurance/InsuranceCollapsed.js +9 -11
  165. package/components/Insurance/index.d.ts +1 -0
  166. package/components/Insurance/index.js +1 -0
  167. package/components/Insurance/types.d.ts +12 -9
  168. package/components/NFT/NFT.js +2 -2
  169. package/components/NFT/types.d.ts +1 -1
  170. package/components/PoweredBy/PoweredBy.js +2 -3
  171. package/components/SelectChainAndToken.js +9 -8
  172. package/components/SelectTokenButton/SelectTokenButton.js +7 -4
  173. package/components/SendToWallet/SendToWallet.js +2 -2
  174. package/components/SmallAvatar.d.ts +1 -1
  175. package/components/Step/CircularProgress.d.ts +1 -2
  176. package/components/Step/Step.js +16 -6
  177. package/components/Step/StepList.d.ts +1 -2
  178. package/components/StepActions/StepActions.js +4 -20
  179. package/components/SwapButton/SwapButton.js +16 -4
  180. package/components/SwapInput/FormPriceHelperText.js +2 -2
  181. package/components/SwapInput/SwapInput.js +3 -3
  182. package/components/SwapInput/SwapInputEndAdornment.d.ts +1 -2
  183. package/components/SwapInput/SwapInputEndAdornment.js +2 -2
  184. package/components/SwapRouteCard/SwapRouteCard.js +21 -5
  185. package/components/SwapRouteCard/SwapRouteCardEssentials.js +1 -1
  186. package/components/SwapRouteCard/SwapRouteCardSkeleton.js +1 -1
  187. package/components/SwapRoutes/SwapRoutes.js +1 -1
  188. package/components/SwapRoutes/SwapRoutesExpanded.d.ts +2 -3
  189. package/components/SwapRoutes/SwapRoutesExpanded.js +2 -2
  190. package/components/SwapRoutes/SwapRoutesExpanded.style.js +1 -0
  191. package/components/Token/Token.js +1 -1
  192. package/components/TokenAvatar/TokenAvatar.d.ts +4 -4
  193. package/components/TokenList/TokenList.js +10 -5
  194. package/components/TokenList/TokenList.style.d.ts +5 -2
  195. package/components/TokenList/TokenList.style.js +21 -2
  196. package/components/TokenList/TokenListItem.d.ts +1 -1
  197. package/components/TokenList/TokenListItem.js +32 -9
  198. package/components/TokenList/VirtualizedTokenList.js +3 -3
  199. package/components/TokenList/types.d.ts +6 -3
  200. package/config/theme.js +15 -3
  201. package/config/version.d.ts +1 -1
  202. package/config/version.js +1 -1
  203. package/hooks/index.d.ts +2 -1
  204. package/hooks/index.js +2 -1
  205. package/hooks/useContentHeight.js +4 -6
  206. package/hooks/useFeaturedTokens.d.ts +1 -1
  207. package/hooks/useFundsSufficiency.js +2 -2
  208. package/hooks/useGasRefuel.d.ts +1 -1
  209. package/hooks/useGasRefuel.js +5 -15
  210. package/hooks/useGasSufficiency.js +13 -4
  211. package/hooks/useInitializer.js +0 -1
  212. package/hooks/useProcessMessage.d.ts +2 -1
  213. package/hooks/useProcessMessage.js +27 -9
  214. package/hooks/useRouteExecution.js +6 -5
  215. package/hooks/useSwapOnly.d.ts +1 -0
  216. package/hooks/useSwapOnly.js +5 -0
  217. package/hooks/useSwapRoutes.d.ts +1 -2
  218. package/hooks/useSwapRoutes.js +32 -18
  219. package/hooks/useToken.d.ts +1 -1
  220. package/hooks/useTokenAddressBalance.d.ts +2 -2
  221. package/hooks/useTokenBalance.js +6 -7
  222. package/hooks/useTokenBalances.d.ts +5 -5
  223. package/hooks/useTokenBalances.js +4 -19
  224. package/hooks/useTokenSearch.d.ts +2 -2
  225. package/hooks/useTokens.d.ts +2 -2
  226. package/i18n/bn.json +8 -0
  227. package/i18n/en.json +30 -5
  228. package/i18n/fr.json +8 -0
  229. package/i18n/id.json +22 -7
  230. package/i18n/ko.json +22 -7
  231. package/i18n/pt.json +32 -7
  232. package/i18n/th.json +21 -6
  233. package/i18n/uk.json +43 -18
  234. package/i18n/zh.json +23 -8
  235. package/icons/InsuraceLogo.d.ts +1 -1
  236. package/icons/LiFiFullLogo.d.ts +1 -1
  237. package/icons/LiFiLogo.d.ts +1 -1
  238. package/icons/LiFiToolLogo.d.ts +1 -1
  239. package/index.d.ts +1 -1
  240. package/package.json +13 -13
  241. package/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +1 -2
  242. package/pages/SelectTokenPage/SearchTokenInput.d.ts +1 -2
  243. package/pages/SelectTokenPage/SelectTokenPage.js +4 -2
  244. package/pages/SelectWalletPage/SelectWalletPage.d.ts +1 -2
  245. package/pages/SettingsPage/GasPriceSelect.d.ts +1 -2
  246. package/pages/SettingsPage/LanguageSelect.js +1 -1
  247. package/pages/SettingsPage/SettingsPage.d.ts +1 -2
  248. package/pages/SettingsPage/ShowDestinationWallet.d.ts +1 -2
  249. package/pages/SettingsPage/SlippageInput.d.ts +1 -2
  250. package/pages/SwapDetailsPage/SwapDetailsPage.js +6 -2
  251. package/pages/SwapPage/ExchangeRateBottomSheet.js +2 -2
  252. package/pages/SwapPage/StatusBottomSheet.js +18 -12
  253. package/pages/SwapPage/StatusBottomSheet.style.d.ts +1 -1
  254. package/pages/SwapPage/StatusBottomSheet.style.js +1 -1
  255. package/pages/SwapPage/SwapPage.js +33 -12
  256. package/pages/SwapPage/TokenValueBottomSheet.js +8 -13
  257. package/pages/SwapPage/utils.d.ts +2 -0
  258. package/pages/SwapPage/utils.js +6 -0
  259. package/providers/I18nProvider/I18nProvider.js +3 -3
  260. package/providers/SDKProvider/SDKProvider.js +2 -0
  261. package/providers/SwapFormProvider/FormUpdater.js +3 -0
  262. package/providers/WalletProvider/WalletProvider.js +78 -50
  263. package/providers/WalletProvider/types.d.ts +3 -5
  264. package/providers/WidgetProvider/WidgetProvider.js +2 -2
  265. package/stores/StoreProvider.d.ts +2 -2
  266. package/stores/StoreProvider.js +3 -2
  267. package/stores/routes/RouteExecutionStore.d.ts +1 -1
  268. package/stores/routes/RouteExecutionStore.js +0 -1
  269. package/stores/settings/index.d.ts +1 -0
  270. package/stores/settings/index.js +1 -0
  271. package/stores/settings/types.d.ts +11 -0
  272. package/stores/settings/useSplitSubvariantStore.d.ts +7 -0
  273. package/stores/settings/useSplitSubvariantStore.js +37 -0
  274. package/tsconfig.cjs.tsbuildinfo +1 -1
  275. package/types/events.d.ts +9 -1
  276. package/types/events.js +1 -0
  277. package/types/token.d.ts +2 -2
  278. package/types/widget.d.ts +13 -8
  279. package/types/widget.js +4 -2
  280. package/utils/format.d.ts +1 -1
  281. package/utils/format.js +5 -10
  282. package/utils/wallet.d.ts +1 -1
  283. package/utils/wallet.js +1 -1
@@ -1,19 +1,20 @@
1
- import type { TokenAmount } from '@lifi/sdk';
1
+ import type { ExtendedChain } from '@lifi/sdk';
2
2
  import type { MutableRefObject } from 'react';
3
3
  import type { SwapFormType } from '../../providers';
4
- import type { Token } from '../../types';
4
+ import type { TokenAmount } from '../../types';
5
5
  export interface TokenListProps {
6
6
  formType: SwapFormType;
7
7
  height: number;
8
8
  onClick?(): void;
9
9
  }
10
10
  export interface VirtualizedTokenListProps {
11
- tokens: Token[];
11
+ tokens: TokenAmount[];
12
12
  featuredTokensLength?: number;
13
13
  scrollElementRef: MutableRefObject<HTMLElement | null>;
14
14
  isLoading: boolean;
15
15
  isBalanceLoading: boolean;
16
16
  chainId: number;
17
+ chain?: ExtendedChain;
17
18
  showBalance?: boolean;
18
19
  showFeatured?: boolean;
19
20
  onClick(tokenAddress: string): void;
@@ -26,6 +27,7 @@ export interface TokenListItemBaseProps {
26
27
  export interface TokenListItemProps extends TokenListItemBaseProps {
27
28
  showBalance?: boolean;
28
29
  token: TokenAmount;
30
+ chain?: ExtendedChain;
29
31
  isBalanceLoading?: boolean;
30
32
  startAdornment?: React.ReactNode;
31
33
  endAdornment?: React.ReactNode;
@@ -34,5 +36,6 @@ export interface TokenListItemButtonProps {
34
36
  onClick?(): void;
35
37
  showBalance?: boolean;
36
38
  token: TokenAmount;
39
+ chain?: ExtendedChain;
37
40
  isBalanceLoading?: boolean;
38
41
  }
package/config/theme.js CHANGED
@@ -1,9 +1,8 @@
1
1
  import { loadingButtonClasses } from '@mui/lab/LoadingButton';
2
2
  import { touchRippleClasses } from '@mui/material/ButtonBase';
3
- import { common } from '@mui/material/colors';
4
3
  import { dialogActionsClasses } from '@mui/material/DialogActions';
5
- import { alpha, createTheme as createMuiTheme, darken, getContrastRatio, lighten, } from '@mui/material/styles';
6
- import { keyframes } from '@mui/system';
4
+ import { common } from '@mui/material/colors';
5
+ import { alpha, createTheme as createMuiTheme, darken, getContrastRatio, keyframes, lighten, } from '@mui/material/styles';
7
6
  const palette = {
8
7
  primary: {
9
8
  main: '#3F49E1',
@@ -223,6 +222,19 @@ export const createTheme = (mode, theme = {}) => {
223
222
  }),
224
223
  },
225
224
  },
225
+ MuiTooltip: {
226
+ styleOverrides: {
227
+ tooltip: ({ theme }) => ({
228
+ backgroundColor: 'rgb(0 0 0 / 64%)',
229
+ backdropFilter: 'blur(3px)',
230
+ fontSize: '0.75rem',
231
+ padding: theme.spacing(1, 1.5),
232
+ }),
233
+ arrow: {
234
+ color: 'rgb(0 0 0 / 64%)',
235
+ },
236
+ },
237
+ },
226
238
  },
227
239
  });
228
240
  };
@@ -1,2 +1,2 @@
1
1
  export declare const name = "@lifi/widget";
2
- export declare const version = "2.0.0-beta.1";
2
+ export declare const version = "2.0.0-beta.10";
package/config/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/widget';
2
- export const version = '2.0.0-beta.1';
2
+ export const version = '2.0.0-beta.10';
package/hooks/index.d.ts CHANGED
@@ -15,12 +15,13 @@ export * from './useNavigateBack';
15
15
  export * from './useProcessMessage';
16
16
  export * from './useRouteExecution';
17
17
  export * from './useScrollableContainer';
18
+ export * from './useSwapOnly';
18
19
  export * from './useSwapRoutes';
19
20
  export * from './useToken';
20
21
  export * from './useTokenAddressBalance';
21
22
  export * from './useTokenBalance';
22
23
  export * from './useTokenBalances';
23
- export * from './useTokens';
24
24
  export * from './useTokenSearch';
25
+ export * from './useTokens';
25
26
  export * from './useTools';
26
27
  export * from './useWidgetEvents';
package/hooks/index.js CHANGED
@@ -15,12 +15,13 @@ export * from './useNavigateBack';
15
15
  export * from './useProcessMessage';
16
16
  export * from './useRouteExecution';
17
17
  export * from './useScrollableContainer';
18
+ export * from './useSwapOnly';
18
19
  export * from './useSwapRoutes';
19
20
  export * from './useToken';
20
21
  export * from './useTokenAddressBalance';
21
22
  export * from './useTokenBalance';
22
23
  export * from './useTokenBalances';
23
- export * from './useTokens';
24
24
  export * from './useTokenSearch';
25
+ export * from './useTokens';
25
26
  export * from './useTools';
26
27
  export * from './useWidgetEvents';
@@ -1,10 +1,10 @@
1
1
  import { useLayoutEffect, useState } from 'react';
2
- import { createElementId, ElementId } from '../utils';
2
+ import { ElementId, createElementId } from '../utils';
3
3
  import { useDefaultElementId } from './useDefaultElementId';
4
4
  import { getScrollableContainer } from './useScrollableContainer';
5
5
  const getContentHeight = (elementId) => {
6
- const headerElement = document.getElementById(createElementId(ElementId.Header, elementId));
7
6
  const containerElement = document.getElementById(createElementId(ElementId.ScrollableContainer, elementId));
7
+ const headerElement = document.getElementById(createElementId(ElementId.Header, elementId));
8
8
  if (!containerElement || !headerElement) {
9
9
  console.warn(`Can't find ${ElementId.ScrollableContainer} or ${ElementId.Header} id.`);
10
10
  return 0;
@@ -15,11 +15,9 @@ const getContentHeight = (elementId) => {
15
15
  };
16
16
  export const useContentHeight = () => {
17
17
  const elementId = useDefaultElementId();
18
- const [contentHeight, setContentHeight] = useState(() => getContentHeight(elementId));
18
+ const [contentHeight, setContentHeight] = useState(0);
19
19
  useLayoutEffect(() => {
20
- if (!contentHeight) {
21
- setContentHeight(getContentHeight(elementId));
22
- }
20
+ setContentHeight(getContentHeight(elementId));
23
21
  // eslint-disable-next-line react-hooks/exhaustive-deps
24
22
  }, []);
25
23
  return contentHeight;
@@ -1 +1 @@
1
- export declare const useFeaturedTokens: (selectedChainId?: number) => import("@lifi/types").Token[] | undefined;
1
+ export declare const useFeaturedTokens: (selectedChainId?: number) => import("@lifi/types").StaticToken[] | undefined;
@@ -7,8 +7,8 @@ import { useGetTokenBalancesWithRetry } from './useGetTokenBalancesWithRetry';
7
7
  import { useTokenAddressBalance } from './useTokenAddressBalance';
8
8
  const refetchInterval = 30000;
9
9
  export const useFundsSufficiency = (route) => {
10
- const { account, provider } = useWallet();
11
- const getTokenBalancesWithRetry = useGetTokenBalancesWithRetry(provider);
10
+ const { account } = useWallet();
11
+ const getTokenBalancesWithRetry = useGetTokenBalancesWithRetry(account.signer?.provider);
12
12
  const [fromChainId, fromTokenAddress, fromAmount] = useWatch({
13
13
  name: [
14
14
  SwapFormKey.FromChain,
@@ -3,5 +3,5 @@ export declare const useGasRefuel: () => {
3
3
  availble: boolean | undefined;
4
4
  isLoading: boolean;
5
5
  chain: import("@lifi/types").ExtendedChain | undefined;
6
- gasRecommendation: import("@lifi/types").GasRecommendationResponse | undefined;
6
+ fromAmount: string | undefined;
7
7
  };
@@ -7,12 +7,11 @@ import { useGasRecommendation } from './useGasRecommendation';
7
7
  import { useTokenBalance } from './useTokenBalance';
8
8
  export const useGasRefuel = () => {
9
9
  const { getChainById } = useChains();
10
- const [fromChainId, fromTokenAddress, toChainId, toTokenAddress, toAddress] = useWatch({
10
+ const [fromChainId, fromTokenAddress, toChainId, toAddress] = useWatch({
11
11
  name: [
12
12
  SwapFormKey.FromChain,
13
13
  SwapFormKey.FromToken,
14
14
  SwapFormKey.ToChain,
15
- SwapFormKey.ToToken,
16
15
  SwapFormKey.ToAddress,
17
16
  ],
18
17
  });
@@ -24,10 +23,7 @@ export const useGasRefuel = () => {
24
23
  // We don't allow same chain refuel.
25
24
  // If a user runs out of gas, he can't send a source chain transaction.
26
25
  fromChainId === toChainId ||
27
- // We don't want to apply auto refuel when swapping to native tokens
28
- toChain?.nativeToken.address === toTokenAddress ||
29
26
  !gasRecommendation?.available ||
30
- !gasRecommendation.recommended ||
31
27
  !nativeToken) {
32
28
  return false;
33
29
  }
@@ -38,20 +34,14 @@ export const useGasRefuel = () => {
38
34
  .div(2);
39
35
  const insufficientGas = tokenBalance.lt(recommendedAmount);
40
36
  return insufficientGas;
41
- }, [
42
- fromChainId,
43
- gasRecommendation?.available,
44
- gasRecommendation?.recommended,
45
- nativeToken,
46
- toChain?.nativeToken.address,
47
- toChainId,
48
- toTokenAddress,
49
- ]);
37
+ }, [fromChainId, gasRecommendation, nativeToken, toChainId]);
50
38
  return {
51
39
  enabled: enabled,
52
40
  availble: gasRecommendation?.available,
53
41
  isLoading: isLoading,
54
42
  chain: toChain,
55
- gasRecommendation,
43
+ fromAmount: gasRecommendation?.available
44
+ ? gasRecommendation.fromAmount
45
+ : undefined,
56
46
  };
57
47
  };
@@ -1,16 +1,24 @@
1
1
  import { useQuery } from '@tanstack/react-query';
2
2
  import Big from 'big.js';
3
- import { useChains, useGetTokenBalancesWithRetry } from '.';
3
+ import { useChains, useGasRefuel, useGetTokenBalancesWithRetry } from '.';
4
4
  import { useWallet } from '../providers';
5
+ import { useSettings } from '../stores';
5
6
  const refetchInterval = 30000;
6
7
  export const useGasSufficiency = (route) => {
7
- const { account, provider } = useWallet();
8
+ const { account } = useWallet();
8
9
  const { getChainById } = useChains();
9
- const getTokenBalancesWithRetry = useGetTokenBalancesWithRetry(provider);
10
+ const getTokenBalancesWithRetry = useGetTokenBalancesWithRetry(account.signer?.provider);
11
+ const { enabledAutoRefuel } = useSettings(['enabledAutoRefuel']);
12
+ const { enabled, isLoading: isRefuelLoading } = useGasRefuel();
13
+ const enabledRefuel = enabled && enabledAutoRefuel;
10
14
  const { data: insufficientGas, isInitialLoading } = useQuery(['gas-sufficiency-check', account.address, route?.id], async () => {
11
15
  if (!account.address || !route) {
12
16
  return;
13
17
  }
18
+ // TODO: include LI.Fuel into calculation once steps and tools are properly typed
19
+ // const refuelSteps = route.steps
20
+ // .flatMap((step) => step.includedSteps)
21
+ // .filter((includedStep) => includedStep.tool === 'lifuelProtocol');
14
22
  const gasCosts = route.steps
15
23
  .filter((step) => !step.execution || step.execution.status !== 'DONE')
16
24
  .reduce((groupedGasCosts, step) => {
@@ -66,8 +74,9 @@ export const useGasSufficiency = (route) => {
66
74
  staleTime: refetchInterval,
67
75
  cacheTime: refetchInterval,
68
76
  });
77
+ const isInsufficientGas = Boolean(insufficientGas?.length) && !isRefuelLoading && !enabledRefuel;
69
78
  return {
70
- insufficientGas,
79
+ insufficientGas: isInsufficientGas ? insufficientGas : undefined,
71
80
  isInitialLoading,
72
81
  };
73
82
  };
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-underscore-dangle */
2
1
  import { checkPackageUpdates } from '@lifi/sdk';
3
2
  import { useEffect } from 'react';
4
3
  import { name, version } from '../config/version';
@@ -1,10 +1,11 @@
1
1
  import type { EVMChain, LifiStep, Process } from '@lifi/sdk';
2
2
  import type { TFunction } from 'i18next';
3
+ import type { WidgetVariant } from '../types';
3
4
  export declare const useProcessMessage: (step?: LifiStep, process?: Process) => {
4
5
  title?: string | undefined;
5
6
  message?: string | undefined;
6
7
  };
7
- export declare function getProcessMessage(t: TFunction, getChainById: (chainId: number) => EVMChain | undefined, step: LifiStep, process: Process): {
8
+ export declare function getProcessMessage(t: TFunction, getChainById: (chainId: number) => EVMChain | undefined, step: LifiStep, process: Process, variant?: WidgetVariant): {
8
9
  title?: string;
9
10
  message?: string;
10
11
  };
@@ -1,18 +1,21 @@
1
1
  import { LifiErrorCode } from '@lifi/sdk';
2
2
  import { useTranslation } from 'react-i18next';
3
+ import { useWidgetConfig } from '../providers';
3
4
  import { formatTokenAmount } from '../utils';
4
5
  import { useChains } from './useChains';
5
6
  export const useProcessMessage = (step, process) => {
7
+ const { variant } = useWidgetConfig();
6
8
  const { t } = useTranslation();
7
9
  const { getChainById } = useChains();
8
10
  if (!step || !process) {
9
11
  return {};
10
12
  }
11
- return getProcessMessage(t, getChainById, step, process);
13
+ return getProcessMessage(t, getChainById, step, process, variant);
12
14
  };
13
15
  const processStatusMessages = {
14
16
  TOKEN_ALLOWANCE: {
15
17
  STARTED: (t) => t(`swap.process.tokenAllowance.started`),
18
+ ACTION_REQUIRED: (t) => t(`swap.process.tokenAllowance.pending`),
16
19
  PENDING: (t) => t(`swap.process.tokenAllowance.pending`),
17
20
  DONE: (t) => t(`swap.process.tokenAllowance.done`),
18
21
  },
@@ -24,7 +27,9 @@ const processStatusMessages = {
24
27
  STARTED: (t) => t(`swap.process.swap.started`),
25
28
  ACTION_REQUIRED: (t) => t(`swap.process.swap.actionRequired`),
26
29
  PENDING: (t) => t(`swap.process.swap.pending`),
27
- DONE: (t) => t(`swap.process.swap.done`),
30
+ DONE: (t, variant) => variant === 'nft'
31
+ ? t(`swap.process.nft.done`)
32
+ : t(`swap.process.swap.done`),
28
33
  },
29
34
  CROSS_CHAIN: {
30
35
  STARTED: (t) => t(`swap.process.crossChain.started`),
@@ -34,7 +39,9 @@ const processStatusMessages = {
34
39
  },
35
40
  RECEIVING_CHAIN: {
36
41
  PENDING: (t) => t(`swap.process.receivingChain.pending`),
37
- DONE: (t) => t(`swap.process.receivingChain.done`),
42
+ DONE: (t, variant) => variant === 'nft'
43
+ ? t(`swap.process.nft.done`)
44
+ : t(`swap.process.receivingChain.done`),
38
45
  },
39
46
  TRANSACTION: {},
40
47
  };
@@ -64,7 +71,7 @@ const processSubstatusMessages = {
64
71
  INVALID: {},
65
72
  NOT_FOUND: {},
66
73
  };
67
- export function getProcessMessage(t, getChainById, step, process) {
74
+ export function getProcessMessage(t, getChainById, step, process, variant) {
68
75
  if (process.error && process.status === 'FAILED') {
69
76
  const getTransactionNotSentMessage = () => t(`swap.error.message.transactionNotSent`, {
70
77
  amount: formatTokenAmount(step.action.fromAmount, step.action.fromToken.decimals),
@@ -74,6 +81,12 @@ export function getProcessMessage(t, getChainById, step, process) {
74
81
  let title = '';
75
82
  let message = '';
76
83
  switch (process.error.code) {
84
+ case LifiErrorCode.AllowanceRequired:
85
+ title = t(`swap.error.title.allowanceRequired`);
86
+ message = t(`swap.error.message.allowanceRequired`, {
87
+ tokenSymbol: step.action.fromToken.symbol,
88
+ });
89
+ break;
77
90
  case LifiErrorCode.BalanceError:
78
91
  title = t(`swap.error.title.balanceIsTooLow`);
79
92
  message = getTransactionNotSentMessage();
@@ -86,6 +99,14 @@ export function getProcessMessage(t, getChainById, step, process) {
86
99
  title = t(`swap.error.title.gasLimitIsTooLow`);
87
100
  message = getTransactionNotSentMessage();
88
101
  break;
102
+ case LifiErrorCode.InsufficientFunds:
103
+ title = t(`swap.error.title.insufficientFunds`);
104
+ message = `${t(`swap.error.message.insufficientFunds`)} ${getTransactionNotSentMessage()}`;
105
+ break;
106
+ case LifiErrorCode.SlippageError:
107
+ title = t(`swap.error.title.slippageNotMet`);
108
+ message = t(`swap.error.message.slippageThreshold`);
109
+ break;
89
110
  case LifiErrorCode.TransactionFailed:
90
111
  title = t(`swap.error.title.transactionFailed`);
91
112
  message = t(`swap.error.message.transactionFailed`);
@@ -102,10 +123,6 @@ export function getProcessMessage(t, getChainById, step, process) {
102
123
  title = t(`swap.error.title.transactionCanceled`);
103
124
  message = getTransactionNotSentMessage();
104
125
  break;
105
- case LifiErrorCode.SlippageError:
106
- title = t(`swap.error.title.slippageNotMet`);
107
- message = t(`swap.error.message.slippageThreshold`);
108
- break;
109
126
  case LifiErrorCode.TransactionRejected:
110
127
  title = t(`swap.error.title.transactionRejected`);
111
128
  message = t(`swap.error.message.transactionRejected`, {
@@ -127,6 +144,7 @@ export function getProcessMessage(t, getChainById, step, process) {
127
144
  }
128
145
  return { title, message };
129
146
  }
130
- const title = processSubstatusMessages[process.status]?.[process.substatus]?.(t) ?? processStatusMessages[process.type]?.[process.status]?.(t);
147
+ const title = processSubstatusMessages[process.status]?.[process.substatus]?.(t) ??
148
+ processStatusMessages[process.type]?.[process.status]?.(t, variant);
131
149
  return { title };
132
150
  }
@@ -14,7 +14,7 @@ export const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchan
14
14
  const routeExecutionStoreContext = useRouteExecutionStoreContext();
15
15
  const routeExecution = useRouteExecutionStore((state) => state.routes[routeId]);
16
16
  const [updateRoute, restartRoute, deleteRoute] = useRouteExecutionStore((state) => [state.updateRoute, state.restartRoute, state.deleteRoute], shallow);
17
- const updateCallback = (updatedRoute) => {
17
+ const updateRouteHook = (updatedRoute) => {
18
18
  const routeExecution = routeExecutionStoreContext.getState().routes[updatedRoute.id];
19
19
  if (!routeExecution) {
20
20
  return;
@@ -45,10 +45,11 @@ export const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchan
45
45
  }
46
46
  const currentChainId = await account.signer.getChainId();
47
47
  if (currentChainId !== requiredChainId) {
48
- const switched = await switchChain(requiredChainId);
49
- if (!switched) {
48
+ const signer = await switchChain(requiredChainId);
49
+ if (!signer) {
50
50
  throw new Error('Chain was not switched.');
51
51
  }
52
+ return signer;
52
53
  }
53
54
  return account.signer;
54
55
  };
@@ -68,7 +69,7 @@ export const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchan
68
69
  }
69
70
  queryClient.removeQueries(['routes'], { exact: false });
70
71
  return lifi.executeRoute(account.signer, routeExecution.route, {
71
- updateCallback,
72
+ updateRouteHook,
72
73
  switchChainHook,
73
74
  acceptExchangeRateUpdateHook,
74
75
  infiniteApproval: false,
@@ -90,7 +91,7 @@ export const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchan
90
91
  throw Error('Execution route not found.');
91
92
  }
92
93
  return lifi.resumeRoute(account.signer, resumedRoute ?? routeExecution.route, {
93
- updateCallback,
94
+ updateRouteHook,
94
95
  switchChainHook,
95
96
  acceptExchangeRateUpdateHook,
96
97
  infiniteApproval: false,
@@ -0,0 +1 @@
1
+ export declare const useSwapOnly: () => boolean;
@@ -0,0 +1,5 @@
1
+ import { useSplitSubvariantStore } from '../stores';
2
+ export const useSwapOnly = () => {
3
+ const state = useSplitSubvariantStore((state) => state.state);
4
+ return state === 'swap';
5
+ };
@@ -1,9 +1,8 @@
1
1
  import type { Route, RoutesResponse } from '@lifi/sdk';
2
2
  interface SwapRoutesProps {
3
- onSettled?: (data?: RoutesResponse) => void;
4
3
  insurableRoute?: Route;
5
4
  }
6
- export declare const useSwapRoutes: ({ onSettled, insurableRoute, }?: SwapRoutesProps) => {
5
+ export declare const useSwapRoutes: ({ insurableRoute }?: SwapRoutesProps) => {
7
6
  routes: Route[] | undefined;
8
7
  isLoading: boolean;
9
8
  isFetching: boolean;
@@ -7,12 +7,14 @@ import { v4 as uuidv4 } from 'uuid';
7
7
  import { useDebouncedWatch, useGasRefuel, useToken } from '.';
8
8
  import { SwapFormKey, useLiFi, useWallet, useWidgetConfig } from '../providers';
9
9
  import { useSettings } from '../stores';
10
+ import { useSwapOnly } from './useSwapOnly';
10
11
  const refetchTime = 60000;
11
- export const useSwapRoutes = ({ onSettled, insurableRoute, } = {}) => {
12
+ export const useSwapRoutes = ({ insurableRoute } = {}) => {
12
13
  const lifi = useLiFi();
13
- const { variant, sdkConfig, insurance } = useWidgetConfig();
14
- const { account, provider } = useWallet();
14
+ const { variant, sdkConfig, insurance, contractTool } = useWidgetConfig();
15
+ const { account } = useWallet();
15
16
  const queryClient = useQueryClient();
17
+ const swapOnly = useSwapOnly();
16
18
  const { slippage, enabledBridges, enabledAutoRefuel, enabledExchanges, routePriority, } = useSettings([
17
19
  'slippage',
18
20
  'routePriority',
@@ -36,7 +38,7 @@ export const useSwapRoutes = ({ onSettled, insurableRoute, } = {}) => {
36
38
  });
37
39
  const { token: fromToken } = useToken(fromChainId, fromTokenAddress);
38
40
  const { token: toToken } = useToken(toChainId, toTokenAddress);
39
- const { enabled: enabledRefuel, gasRecommendation } = useGasRefuel();
41
+ const { enabled: enabledRefuel, fromAmount: gasRecommendationFromAmount } = useGasRefuel();
40
42
  const hasAmount = (!isNaN(fromTokenAmount) && Number(fromTokenAmount) > 0) ||
41
43
  (!isNaN(toTokenAmount) && Number(toTokenAmount) > 0);
42
44
  const contractCallQuoteEnabled = variant === 'nft'
@@ -63,13 +65,13 @@ export const useSwapRoutes = ({ onSettled, insurableRoute, } = {}) => {
63
65
  toContractCallData,
64
66
  toContractGasLimit,
65
67
  slippage,
66
- enabledBridges,
68
+ swapOnly ? [] : enabledBridges,
67
69
  enabledExchanges,
68
70
  routePriority,
69
71
  variant,
70
72
  sdkConfig?.defaultRouteOptions?.allowSwitchChain,
71
73
  enabledRefuel && enabledAutoRefuel,
72
- gasRecommendation?.fromAmount,
74
+ gasRecommendationFromAmount,
73
75
  insurance,
74
76
  insurableRoute?.id,
75
77
  ];
@@ -77,7 +79,7 @@ export const useSwapRoutes = ({ onSettled, insurableRoute, } = {}) => {
77
79
  let toWalletAddress;
78
80
  try {
79
81
  toWalletAddress =
80
- (await provider?.resolveName(toAddress)) ??
82
+ (await account.signer?.provider?.resolveName(toAddress)) ??
81
83
  (isAddress(toAddress) ? toAddress : fromAddress);
82
84
  }
83
85
  catch {
@@ -87,6 +89,16 @@ export const useSwapRoutes = ({ onSettled, insurableRoute, } = {}) => {
87
89
  .mul(10 ** (fromToken?.decimals ?? 0))
88
90
  .toFixed(0);
89
91
  const formattedSlippage = parseFloat(slippage) / 100;
92
+ const allowedBridges = insurableRoute
93
+ ? insurableRoute.steps.flatMap((step) => step.includedSteps
94
+ .filter((includedStep) => includedStep.type === 'cross')
95
+ .map((includedStep) => includedStep.toolDetails.key))
96
+ : enabledBridges;
97
+ const allowedExchanges = insurableRoute
98
+ ? insurableRoute.steps.flatMap((step) => step.includedSteps
99
+ .filter((includedStep) => includedStep.type === 'swap')
100
+ .map((includedStep) => includedStep.toolDetails.key))
101
+ : enabledExchanges;
90
102
  if (variant === 'nft') {
91
103
  const contractCallQuote = await lifi.getContractCallQuote({
92
104
  fromAddress,
@@ -98,12 +110,25 @@ export const useSwapRoutes = ({ onSettled, insurableRoute, } = {}) => {
98
110
  toContractAddress,
99
111
  toContractCallData,
100
112
  toContractGasLimit,
113
+ allowBridges: allowedBridges,
101
114
  // toFallbackAddress: toAddress,
102
115
  slippage: formattedSlippage,
103
116
  }, { signal });
104
117
  contractCallQuote.estimate.toAmount = toTokenAmount;
105
118
  contractCallQuote.estimate.toAmountMin = toTokenAmount;
106
119
  contractCallQuote.action.toToken = toToken;
120
+ const customStep = variant === 'nft'
121
+ ? contractCallQuote.includedSteps?.find((step) => step.type === 'custom')
122
+ : undefined;
123
+ if (customStep && contractTool) {
124
+ const toolDetails = {
125
+ key: contractTool.name,
126
+ name: contractTool.name,
127
+ logoURI: contractTool.logoURI,
128
+ };
129
+ customStep.toolDetails = toolDetails;
130
+ contractCallQuote.toolDetails = toolDetails;
131
+ }
107
132
  const route = {
108
133
  id: uuidv4(),
109
134
  fromChainId: contractCallQuote.action.fromChainId,
@@ -123,16 +148,6 @@ export const useSwapRoutes = ({ onSettled, insurableRoute, } = {}) => {
123
148
  };
124
149
  return { routes: [route] };
125
150
  }
126
- const allowedBridges = insurableRoute
127
- ? insurableRoute.steps.flatMap((step) => step.includedSteps
128
- .filter((includedStep) => includedStep.type === 'cross')
129
- .map((includedStep) => includedStep.toolDetails.key))
130
- : enabledBridges;
131
- const allowedExchanges = insurableRoute
132
- ? insurableRoute.steps.flatMap((step) => step.includedSteps
133
- .filter((includedStep) => includedStep.type === 'swap')
134
- .map((includedStep) => includedStep.toolDetails.key))
135
- : enabledExchanges;
136
151
  return lifi.getRoutes({
137
152
  fromChainId,
138
153
  fromAmount,
@@ -189,7 +204,6 @@ export const useSwapRoutes = ({ onSettled, insurableRoute, } = {}) => {
189
204
  });
190
205
  }
191
206
  },
192
- onSettled,
193
207
  });
194
208
  return {
195
209
  routes: data?.routes,
@@ -1,4 +1,4 @@
1
1
  export declare const useToken: (chainId?: number, tokenAddress?: string) => {
2
- token: import("..").Token | undefined;
2
+ token: import("..").TokenAmount | undefined;
3
3
  isLoading: boolean;
4
4
  };
@@ -1,5 +1,5 @@
1
1
  export declare const useTokenAddressBalance: (chainId?: number, tokenAddress?: string) => {
2
- token: import("..").Token | undefined;
2
+ token: import("..").TokenAmount | undefined;
3
3
  isLoading: boolean;
4
- refetch: <TPageData>(options?: (import("@tanstack/query-core").RefetchOptions & import("@tanstack/query-core").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/query-core").QueryObserverResult<import("..").Token[], unknown>>;
4
+ refetch: <TPageData>(options?: (import("@tanstack/query-core").RefetchOptions & import("@tanstack/query-core").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/query-core").QueryObserverResult<import("..").TokenAmount[], unknown>>;
5
5
  };
@@ -1,14 +1,13 @@
1
1
  import { useQuery, useQueryClient } from '@tanstack/react-query';
2
2
  import { useCallback, useMemo } from 'react';
3
3
  import { useWallet } from '../providers';
4
- import { formatTokenAmount } from '../utils';
5
4
  import { useGetTokenBalancesWithRetry } from './useGetTokenBalancesWithRetry';
6
5
  const defaultRefetchInterval = 30000;
7
6
  export const useTokenBalance = (token, accountAddress) => {
8
- const { account, provider } = useWallet();
7
+ const { account } = useWallet();
9
8
  const queryClient = useQueryClient();
10
9
  const walletAddress = accountAddress || account.address;
11
- const getTokenBalancesWithRetry = useGetTokenBalancesWithRetry(provider);
10
+ const getTokenBalancesWithRetry = useGetTokenBalancesWithRetry(account.signer?.provider);
12
11
  const tokenBalanceQueryKey = useMemo(() => ['token-balance', walletAddress, token?.chainId, token?.address], [token?.address, token?.chainId, walletAddress]);
13
12
  const { data, isLoading, refetch } = useQuery(tokenBalanceQueryKey, async ({ queryKey: [, accountAddress] }) => {
14
13
  const cachedToken = queryClient
@@ -26,8 +25,8 @@ export const useTokenBalance = (token, accountAddress) => {
26
25
  throw Error('Could not get tokens balance.');
27
26
  }
28
27
  const cachedTokenAmount = queryClient.getQueryData(tokenBalanceQueryKey);
29
- const formattedAmount = formatTokenAmount(tokenBalances[0].amount);
30
- if (cachedTokenAmount?.amount !== formattedAmount) {
28
+ const tokenAmount = tokenBalances[0].amount;
29
+ if (cachedTokenAmount?.amount !== tokenAmount) {
31
30
  queryClient.setQueryDefaults(tokenBalanceQueryKey, {
32
31
  refetchInterval: defaultRefetchInterval,
33
32
  staleTime: defaultRefetchInterval,
@@ -39,14 +38,14 @@ export const useTokenBalance = (token, accountAddress) => {
39
38
  const index = clonedData.findIndex((dataToken) => dataToken.address === token.address);
40
39
  clonedData[index] = {
41
40
  ...clonedData[index],
42
- amount: formattedAmount,
41
+ amount: tokenAmount,
43
42
  };
44
43
  return clonedData;
45
44
  }
46
45
  });
47
46
  return {
48
47
  ...tokenBalances[0],
49
- amount: formattedAmount,
48
+ amount: tokenAmount,
50
49
  };
51
50
  }, {
52
51
  enabled: Boolean(walletAddress && token),
@@ -1,9 +1,9 @@
1
- import type { Token } from '../types';
1
+ import type { TokenAmount } from '../types';
2
2
  export declare const useTokenBalances: (selectedChainId?: number) => {
3
- tokens: Token[];
4
- tokensWithBalance: Token[] | undefined;
5
- featuredTokens: import("@lifi/types").Token[] | undefined;
3
+ tokens: TokenAmount[];
4
+ tokensWithBalance: TokenAmount[] | undefined;
5
+ featuredTokens: import("@lifi/types").StaticToken[] | undefined;
6
6
  isLoading: boolean;
7
7
  isBalanceLoading: boolean;
8
- refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<Token[], unknown>>;
8
+ refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<TokenAmount[], unknown>>;
9
9
  };