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

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
@@ -23,7 +23,7 @@ const SwapRoutesExpandedElement = () => {
23
23
  const { t } = (0, react_i18next_1.useTranslation)();
24
24
  const navigate = (0, react_router_dom_1.useNavigate)();
25
25
  const setExecutableRoute = (0, stores_1.useSetExecutableRoute)();
26
- const { containerStyle } = (0, providers_1.useWidgetConfig)();
26
+ const { variant, containerStyle } = (0, providers_1.useWidgetConfig)();
27
27
  const { isValid, isValidating } = (0, react_hook_form_1.useFormState)();
28
28
  const { routes, isLoading, isFetching, isFetched, dataUpdatedAt, refetchTime, refetch, } = (0, hooks_1.useSwapRoutes)();
29
29
  const currentRoute = routes?.[0];
@@ -37,6 +37,6 @@ const SwapRoutesExpandedElement = () => {
37
37
  };
38
38
  const expanded = Boolean(currentRoute || isLoading || isFetching || isFetched);
39
39
  const routeNotFound = !currentRoute && !isLoading && !isFetching && expanded;
40
- return ((0, jsx_runtime_1.jsx)(material_1.Collapse, { timeout: timeout.enter, in: expanded, orientation: "horizontal", children: (0, jsx_runtime_1.jsx)(material_1.Grow, { timeout: timeout.enter, in: expanded, mountOnEnter: true, unmountOnExit: true, children: (0, jsx_runtime_1.jsx)(SwapRoutesExpanded_style_1.Container, { sx: containerStyle, enableColorScheme: true, children: (0, jsx_runtime_1.jsxs)(SwapRoutesExpanded_style_1.ScrollableContainer, { children: [(0, jsx_runtime_1.jsxs)(SwapRoutesExpanded_style_1.Header, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 18, fontWeight: "700", flex: 1, noWrap: true, children: t('swap.routes') }), (0, jsx_runtime_1.jsx)(ProgressToNextUpdate_1.ProgressToNextUpdate, { updatedAt: dataUpdatedAt || new Date().getTime(), timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: { marginRight: -1 } })] }), (0, jsx_runtime_1.jsx)(material_1.Stack, { direction: "column", spacing: 2, flex: 1, paddingX: 3, paddingBottom: 3, children: routeNotFound ? ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteNotFoundCard, {})) : isLoading || (isFetching && !routes?.length) ? (Array.from({ length: 3 }).map((_, index) => ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCardSkeleton, {}, index)))) : (routes?.map((route, index) => ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCard, { route: route, onClick: () => handleRouteClick(route), active: index === 0, expanded: routes?.length <= 2 }, route.id)))) })] }) }) }) }));
40
+ return ((0, jsx_runtime_1.jsx)(material_1.Collapse, { timeout: timeout.enter, in: expanded, orientation: "horizontal", children: (0, jsx_runtime_1.jsx)(material_1.Grow, { timeout: timeout.enter, in: expanded, mountOnEnter: true, unmountOnExit: true, children: (0, jsx_runtime_1.jsx)(SwapRoutesExpanded_style_1.Container, { sx: containerStyle, enableColorScheme: true, children: (0, jsx_runtime_1.jsxs)(SwapRoutesExpanded_style_1.ScrollableContainer, { children: [(0, jsx_runtime_1.jsxs)(SwapRoutesExpanded_style_1.Header, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 18, fontWeight: "700", flex: 1, noWrap: true, children: variant === 'nft' ? t('swap.fromAmount') : t('header.routes') }), (0, jsx_runtime_1.jsx)(ProgressToNextUpdate_1.ProgressToNextUpdate, { updatedAt: dataUpdatedAt || new Date().getTime(), timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: { marginRight: -1 } })] }), (0, jsx_runtime_1.jsx)(material_1.Stack, { direction: "column", spacing: 2, flex: 1, paddingX: 3, paddingBottom: 3, children: routeNotFound ? ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteNotFoundCard, {})) : isLoading || (isFetching && !routes?.length) ? (Array.from({ length: 3 }).map((_, index) => ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCardSkeleton, {}, index)))) : (routes?.map((route, index) => ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCard, { route: route, onClick: () => handleRouteClick(route), active: index === 0, expanded: routes?.length <= 2 }, route.id)))) })] }) }) }) }));
41
41
  };
42
42
  exports.SwapRoutesExpandedElement = SwapRoutesExpandedElement;
@@ -11,6 +11,7 @@ exports.CollapseContainer = (0, styles_1.styled)(material_1.Box)(({ theme }) =>
11
11
  exports.ScrollableContainer = (0, styles_1.styled)(material_1.Box)({
12
12
  overflowY: 'auto',
13
13
  height: '100%',
14
+ width: '100%',
14
15
  flex: 1,
15
16
  display: 'flex',
16
17
  flexDirection: 'column',
@@ -17,7 +17,7 @@ const Token = ({ token, ...other }) => {
17
17
  return (0, jsx_runtime_1.jsx)(exports.TokenBase, { token: token, ...other });
18
18
  };
19
19
  exports.Token = Token;
20
- const TokenFallback = ({ token, connected, step, disableDescription, isLoading, ...other }) => {
20
+ const TokenFallback = ({ token, isLoading, ...other }) => {
21
21
  const { token: chainToken, isLoading: isLoadingToken } = (0, hooks_1.useToken)(token?.chainId, token?.address);
22
22
  return ((0, jsx_runtime_1.jsx)(exports.TokenBase, { token: { ...token, ...chainToken }, isLoading: isLoading || isLoadingToken, ...other }));
23
23
  };
@@ -1,19 +1,19 @@
1
1
  /// <reference types="react" />
2
- import type { Chain, Token } from '@lifi/sdk';
2
+ import type { Chain, StaticToken } from '@lifi/sdk';
3
3
  import type { SxProps, Theme } from '@mui/material';
4
4
  export declare const TokenAvatarFallback: React.FC<{
5
- token?: Token;
5
+ token?: StaticToken;
6
6
  isLoading?: boolean;
7
7
  sx?: SxProps<Theme>;
8
8
  }>;
9
9
  export declare const TokenAvatarBase: React.FC<{
10
- token?: Token;
10
+ token?: StaticToken;
11
11
  chain?: Chain;
12
12
  isLoading?: boolean;
13
13
  sx?: SxProps<Theme>;
14
14
  }>;
15
15
  export declare const TokenAvatar: React.FC<{
16
- token?: Token;
16
+ token?: StaticToken;
17
17
  chain?: Chain;
18
18
  isLoading?: boolean;
19
19
  sx?: SxProps<Theme>;
@@ -8,8 +8,8 @@ const react_hook_form_1 = require("react-hook-form");
8
8
  const hooks_1 = require("../../hooks");
9
9
  const providers_1 = require("../../providers");
10
10
  const TokenNotFound_1 = require("./TokenNotFound");
11
- const useTokenSelect_1 = require("./useTokenSelect");
12
11
  const VirtualizedTokenList_1 = require("./VirtualizedTokenList");
12
+ const useTokenSelect_1 = require("./useTokenSelect");
13
13
  const TokenList = ({ formType, height, onClick, }) => {
14
14
  const parentRef = (0, react_1.useRef)(null);
15
15
  const { account } = (0, providers_1.useWallet)();
@@ -17,8 +17,11 @@ const TokenList = ({ formType, height, onClick, }) => {
17
17
  name: [providers_1.SwapFormKeyHelper.getChainKey(formType)],
18
18
  });
19
19
  const [tokenSearchFilter] = (0, hooks_1.useDebouncedWatch)([providers_1.SwapFormKey.TokenSearchFilter], 320);
20
+ const { chain, isLoading: isChainLoading } = (0, hooks_1.useChain)(selectedChainId);
20
21
  const { tokens: chainTokens, tokensWithBalance, isLoading: isTokensLoading, isBalanceLoading, featuredTokens, } = (0, hooks_1.useTokenBalances)(selectedChainId);
21
- let filteredTokens = (tokensWithBalance ?? chainTokens ?? []);
22
+ let filteredTokens = (tokensWithBalance ??
23
+ chainTokens ??
24
+ []);
22
25
  const searchFilter = tokenSearchFilter?.toUpperCase() ?? '';
23
26
  filteredTokens = tokenSearchFilter
24
27
  ? filteredTokens.filter((token) => token.name.toUpperCase().includes(searchFilter) ||
@@ -30,13 +33,15 @@ const TokenList = ({ formType, height, onClick, }) => {
30
33
  !!tokenSearchFilter &&
31
34
  !!selectedChainId;
32
35
  const { token: searchedToken, isLoading: isSearchedTokenLoading } = (0, hooks_1.useTokenSearch)(selectedChainId, tokenSearchFilter, tokenSearchEnabled);
33
- const isLoading = isTokensLoading || (tokenSearchEnabled && isSearchedTokenLoading);
36
+ const isLoading = isTokensLoading ||
37
+ isChainLoading ||
38
+ (tokenSearchEnabled && isSearchedTokenLoading);
34
39
  const tokens = filteredTokens.length
35
40
  ? filteredTokens
36
41
  : searchedToken
37
42
  ? [searchedToken]
38
43
  : filteredTokens;
39
44
  const handleTokenClick = (0, useTokenSelect_1.useTokenSelect)(formType, onClick);
40
- return ((0, jsx_runtime_1.jsxs)(material_1.Box, { ref: parentRef, style: { height, overflow: 'auto' }, children: [!tokens.length && !isLoading ? ((0, jsx_runtime_1.jsx)(TokenNotFound_1.TokenNotFound, { formType: formType })) : null, (0, jsx_runtime_1.jsx)(VirtualizedTokenList_1.VirtualizedTokenList, { tokens: tokens, featuredTokensLength: featuredTokens?.length, scrollElementRef: parentRef, chainId: selectedChainId, isLoading: isLoading, isBalanceLoading: isBalanceLoading, showBalance: account.isActive, showFeatured: !tokenSearchFilter, onClick: handleTokenClick })] }));
45
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, { ref: parentRef, style: { height, overflow: 'auto' }, children: [!tokens.length && !isLoading ? ((0, jsx_runtime_1.jsx)(TokenNotFound_1.TokenNotFound, { formType: formType })) : null, (0, jsx_runtime_1.jsx)(VirtualizedTokenList_1.VirtualizedTokenList, { tokens: tokens, featuredTokensLength: featuredTokens?.length, scrollElementRef: parentRef, chainId: selectedChainId, chain: chain, isLoading: isLoading, isBalanceLoading: isBalanceLoading, showBalance: account.isActive, showFeatured: !tokenSearchFilter, onClick: handleTokenClick })] }));
41
46
  };
42
47
  exports.TokenList = TokenList;
@@ -1,5 +1,7 @@
1
1
  /// <reference types="react" />
2
- export declare const ListItemButton: import("@emotion/styled").StyledComponent<import("@mui/material").ListItemButtonBaseProps & Omit<{
2
+ import type { StyledComponent } from '@emotion/styled';
3
+ import type { ButtonProps, LinkProps } from '@mui/material';
4
+ export declare const ListItemButton: StyledComponent<import("@mui/material").ListItemButtonBaseProps & Omit<{
3
5
  action?: import("react").Ref<import("@mui/material").ButtonBaseActions> | undefined;
4
6
  centerRipple?: boolean | undefined;
5
7
  children?: import("react").ReactNode;
@@ -18,7 +20,7 @@ export declare const ListItemButton: import("@emotion/styled").StyledComponent<i
18
20
  }, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
19
21
  ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
20
22
  }, "className" | "style" | "classes" | "autoFocus" | "tabIndex" | "children" | "action" | "centerRipple" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "TouchRippleProps" | "touchRippleRef" | "alignItems" | "dense" | "divider" | "selected" | "disableGutters"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
21
- export declare const ListItem: import("@emotion/styled").StyledComponent<{
23
+ export declare const ListItem: StyledComponent<{
22
24
  button?: false | undefined;
23
25
  } & import("@mui/material").ListItemBaseProps & {
24
26
  components?: {
@@ -36,3 +38,4 @@ export declare const ListItem: import("@emotion/styled").StyledComponent<{
36
38
  } & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "ref"> & {
37
39
  ref?: ((instance: HTMLLIElement | null) => void) | import("react").RefObject<HTMLLIElement> | null | undefined;
38
40
  }, "button" | "className" | "style" | "classes" | "autoFocus" | "children" | "disabled" | "sx" | "alignItems" | "dense" | "divider" | "components" | "slotProps" | "slots" | "componentsProps" | "selected" | "disableGutters" | "ContainerComponent" | "ContainerProps" | "disablePadding" | "secondaryAction"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
41
+ export declare const LinkButton: StyledComponent<ButtonProps & LinkProps>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ListItem = exports.ListItemButton = void 0;
3
+ exports.LinkButton = exports.ListItem = exports.ListItemButton = void 0;
4
4
  const material_1 = require("@mui/material");
5
5
  const ListItemSecondaryAction_1 = require("@mui/material/ListItemSecondaryAction");
6
6
  const ListItemText_1 = require("@mui/material/ListItemText");
@@ -29,3 +29,22 @@ exports.ListItem = (0, styles_1.styled)(material_1.ListItem)(({ theme }) => ({
29
29
  whiteSpace: 'nowrap',
30
30
  },
31
31
  }));
32
+ exports.LinkButton = (0, styles_1.styled)(material_1.Button)(({ theme }) => ({
33
+ lineHeight: 1,
34
+ fontSize: '0.75rem',
35
+ fontWeight: 400,
36
+ padding: theme.spacing(0.375, 0.75),
37
+ color: 'inherit',
38
+ backgroundColor: 'unset',
39
+ '&:hover': {
40
+ backgroundColor: theme.palette.mode === 'light'
41
+ ? (0, styles_1.alpha)(theme.palette.common.black, 0.04)
42
+ : (0, styles_1.alpha)(theme.palette.common.white, 0.08),
43
+ },
44
+ [`.${material_1.buttonClasses.endIcon}`]: {
45
+ marginLeft: theme.spacing(0.25),
46
+ },
47
+ [`.${material_1.buttonClasses.endIcon} > *:nth-of-type(1)`]: {
48
+ fontSize: '0.75rem',
49
+ },
50
+ }));
@@ -2,5 +2,5 @@
2
2
  import type { TokenListItemButtonProps, TokenListItemProps } from './types';
3
3
  export declare const TokenListItem: React.FC<TokenListItemProps>;
4
4
  export declare const TokenListItemButton: React.FC<TokenListItemButtonProps>;
5
- export declare const TokenListItemSkeleton: () => JSX.Element;
5
+ export declare const TokenListItemSkeleton: () => import("react/jsx-runtime").JSX.Element;
6
6
  export declare const TokenAmountSkeleton: React.FC;
@@ -2,23 +2,46 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TokenAmountSkeleton = exports.TokenListItemSkeleton = exports.TokenListItemButton = exports.TokenListItem = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const OpenInNewRounded_1 = require("@mui/icons-material/OpenInNewRounded");
5
6
  const material_1 = require("@mui/material");
6
7
  const react_1 = require("react");
7
8
  const react_i18next_1 = require("react-i18next");
8
9
  const utils_1 = require("../../utils");
9
10
  const TokenList_style_1 = require("./TokenList.style");
10
- exports.TokenListItem = (0, react_1.memo)(({ onClick, size, start, token, showBalance, isBalanceLoading, startAdornment, endAdornment, }) => {
11
+ exports.TokenListItem = (0, react_1.memo)(({ onClick, size, start, token, chain, showBalance, isBalanceLoading, startAdornment, endAdornment, }) => {
11
12
  const handleClick = () => onClick?.(token.address);
12
13
  return ((0, jsx_runtime_1.jsxs)(TokenList_style_1.ListItem, { disablePadding: true, style: {
13
14
  height: `${size}px`,
14
15
  transform: `translateY(${start}px)`,
15
- }, children: [startAdornment, (0, jsx_runtime_1.jsx)(exports.TokenListItemButton, { token: token, showBalance: showBalance, isBalanceLoading: isBalanceLoading, onClick: handleClick }), endAdornment] }));
16
+ }, children: [startAdornment, (0, jsx_runtime_1.jsx)(exports.TokenListItemButton, { token: token, chain: chain, showBalance: showBalance, isBalanceLoading: isBalanceLoading, onClick: handleClick }), endAdornment] }));
16
17
  });
17
- const TokenListItemButton = ({ onClick, token, showBalance, isBalanceLoading, }) => {
18
+ const TokenListItemButton = ({ onClick, token, chain, showBalance, isBalanceLoading, }) => {
18
19
  const { t } = (0, react_i18next_1.useTranslation)();
19
20
  const tokenPrice = (0, utils_1.formatTokenPrice)(token.amount, token.priceUSD);
20
- return ((0, jsx_runtime_1.jsxs)(TokenList_style_1.ListItemButton, { onClick: onClick, dense: true, children: [(0, jsx_runtime_1.jsx)(material_1.ListItemAvatar, { children: (0, jsx_runtime_1.jsx)(material_1.Avatar, { src: token.logoURI, alt: token.symbol, children: token.symbol[0] }) }), (0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: token.symbol, secondary: token.name }), showBalance ? (isBalanceLoading ? ((0, jsx_runtime_1.jsx)(exports.TokenAmountSkeleton, {})) : ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { textAlign: 'right' }, children: [Number(token.amount) ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body1", noWrap: true, children: t('format.number', {
21
- value: token.amount,
21
+ const container = (0, react_1.useRef)(null);
22
+ const timeoutId = (0, react_1.useRef)();
23
+ const [showAddress, setShowAddress] = (0, react_1.useState)(false);
24
+ const onMouseEnter = () => {
25
+ timeoutId.current = setTimeout(() => setShowAddress(true), 350);
26
+ };
27
+ const onMouseLeave = () => {
28
+ clearTimeout(timeoutId.current);
29
+ if (showAddress) {
30
+ setShowAddress(false);
31
+ }
32
+ };
33
+ return ((0, jsx_runtime_1.jsxs)(TokenList_style_1.ListItemButton, { onClick: onClick, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, dense: true, children: [(0, jsx_runtime_1.jsx)(material_1.ListItemAvatar, { children: (0, jsx_runtime_1.jsx)(material_1.Avatar, { src: token.logoURI, alt: token.symbol, children: token.symbol[0] }) }), (0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: token.symbol, secondaryTypographyProps: {
34
+ component: 'div',
35
+ sx: {
36
+ overflow: 'auto',
37
+ marginLeft: -0.75,
38
+ },
39
+ }, secondary: (0, jsx_runtime_1.jsxs)(material_1.Box, { position: "relative", height: 18, ref: container, children: [(0, jsx_runtime_1.jsx)(material_1.Slide, { direction: "down", in: !showAddress, container: container.current, style: {
40
+ position: 'absolute',
41
+ }, appear: false, children: (0, jsx_runtime_1.jsx)(material_1.Box, { pl: 0.75, children: token.name }) }), (0, jsx_runtime_1.jsx)(material_1.Slide, { direction: "up", in: showAddress, container: container.current, style: {
42
+ position: 'absolute',
43
+ }, appear: false, mountOnEnter: true, children: (0, jsx_runtime_1.jsx)(TokenList_style_1.LinkButton, { size: "small", LinkComponent: material_1.Link, href: `${chain?.metamask.blockExplorerUrls[0]}address/${token.address}`, target: "_blank", rel: "nofollow noreferrer", onClick: (e) => e.stopPropagation(), endIcon: (0, jsx_runtime_1.jsx)(OpenInNewRounded_1.default, {}), children: (0, utils_1.shortenAddress)(token.address) }) })] }) }), showBalance ? (isBalanceLoading ? ((0, jsx_runtime_1.jsx)(exports.TokenAmountSkeleton, {})) : ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { textAlign: 'right' }, children: [Number(token.amount) ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body1", noWrap: true, children: t('format.number', {
44
+ value: (0, utils_1.formatTokenAmount)(token.amount),
22
45
  }) })) : null, tokenPrice ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { fontWeight: 400, fontSize: 12, color: "text.secondary", "data-price": token.priceUSD, children: t(`format.currency`, {
23
46
  value: tokenPrice,
24
47
  }) })) : null] }))) : null] }));
@@ -7,7 +7,7 @@ const react_virtual_1 = require("@tanstack/react-virtual");
7
7
  const react_1 = require("react");
8
8
  const react_i18next_1 = require("react-i18next");
9
9
  const TokenListItem_1 = require("./TokenListItem");
10
- const VirtualizedTokenList = ({ tokens, featuredTokensLength, scrollElementRef, chainId, isLoading, isBalanceLoading, showBalance, showFeatured, onClick, }) => {
10
+ const VirtualizedTokenList = ({ tokens, featuredTokensLength, scrollElementRef, chainId, chain, isLoading, isBalanceLoading, showBalance, showFeatured, onClick, }) => {
11
11
  const { t } = (0, react_i18next_1.useTranslation)();
12
12
  const hasFeaturedTokens = !!featuredTokensLength && showFeatured;
13
13
  const featuredTokensLastIndex = (featuredTokensLength ?? 0) - 1;
@@ -35,7 +35,7 @@ const VirtualizedTokenList = ({ tokens, featuredTokensLength, scrollElementRef,
35
35
  }
36
36
  return size;
37
37
  },
38
- getItemKey: (index) => tokens[index].address ?? index,
38
+ getItemKey: (index) => `${tokens[index].address}-${index}`,
39
39
  });
40
40
  (0, react_1.useEffect)(() => {
41
41
  if (getVirtualItems().length) {
@@ -49,7 +49,7 @@ const VirtualizedTokenList = ({ tokens, featuredTokensLength, scrollElementRef,
49
49
  }
50
50
  return ((0, jsx_runtime_1.jsx)(material_1.List, { style: { height: getTotalSize() }, disablePadding: true, children: getVirtualItems().map((item) => {
51
51
  const token = tokens[item.index];
52
- return ((0, jsx_runtime_1.jsx)(TokenListItem_1.TokenListItem, { onClick: onClick, size: item.size, start: item.start, token: token, isBalanceLoading: isBalanceLoading, showBalance: showBalance, startAdornment: hasFeaturedTokens && token.featured && item.index === 0 ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 14, fontWeight: 600, lineHeight: 1, px: 2, pb: 1.25, children: t('swap.featuredTokens') })) : null, endAdornment: hasFeaturedTokens &&
52
+ return ((0, jsx_runtime_1.jsx)(TokenListItem_1.TokenListItem, { onClick: onClick, size: item.size, start: item.start, token: token, chain: chain, isBalanceLoading: isBalanceLoading, showBalance: showBalance, startAdornment: hasFeaturedTokens && token.featured && item.index === 0 ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 14, fontWeight: 600, lineHeight: 1, px: 2, pb: 1.25, children: t('swap.featuredTokens') })) : null, endAdornment: hasFeaturedTokens &&
53
53
  token.featured &&
54
54
  item.index === featuredTokensLastIndex &&
55
55
  item.index !== tokensLastIndex ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 14, fontWeight: 600, lineHeight: 1, px: 2, py: 1.25, children: t('swap.otherTokens') })) : null }, item.key));
@@ -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
  }
@@ -3,10 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createTheme = void 0;
4
4
  const LoadingButton_1 = require("@mui/lab/LoadingButton");
5
5
  const ButtonBase_1 = require("@mui/material/ButtonBase");
6
- const colors_1 = require("@mui/material/colors");
7
6
  const DialogActions_1 = require("@mui/material/DialogActions");
7
+ const colors_1 = require("@mui/material/colors");
8
8
  const styles_1 = require("@mui/material/styles");
9
- const system_1 = require("@mui/system");
10
9
  const palette = {
11
10
  primary: {
12
11
  main: '#3F49E1',
@@ -46,7 +45,7 @@ const shape = {
46
45
  borderRadius: 12,
47
46
  borderRadiusSecondary: 8,
48
47
  };
49
- const enterKeyframe = (0, system_1.keyframes) `
48
+ const enterKeyframe = (0, styles_1.keyframes) `
50
49
  0% {
51
50
  transform: scale(0);
52
51
  opacity: 0.05;
@@ -226,6 +225,19 @@ const createTheme = (mode, theme = {}) => {
226
225
  }),
227
226
  },
228
227
  },
228
+ MuiTooltip: {
229
+ styleOverrides: {
230
+ tooltip: ({ theme }) => ({
231
+ backgroundColor: 'rgb(0 0 0 / 64%)',
232
+ backdropFilter: 'blur(3px)',
233
+ fontSize: '0.75rem',
234
+ padding: theme.spacing(1, 1.5),
235
+ }),
236
+ arrow: {
237
+ color: 'rgb(0 0 0 / 64%)',
238
+ },
239
+ },
240
+ },
229
241
  },
230
242
  });
231
243
  };
@@ -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.11";
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = exports.name = void 0;
4
4
  exports.name = '@lifi/widget';
5
- exports.version = '2.0.0-beta.1';
5
+ exports.version = '2.0.0-beta.11';
@@ -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';
@@ -31,12 +31,13 @@ __exportStar(require("./useNavigateBack"), exports);
31
31
  __exportStar(require("./useProcessMessage"), exports);
32
32
  __exportStar(require("./useRouteExecution"), exports);
33
33
  __exportStar(require("./useScrollableContainer"), exports);
34
+ __exportStar(require("./useSwapOnly"), exports);
34
35
  __exportStar(require("./useSwapRoutes"), exports);
35
36
  __exportStar(require("./useToken"), exports);
36
37
  __exportStar(require("./useTokenAddressBalance"), exports);
37
38
  __exportStar(require("./useTokenBalance"), exports);
38
39
  __exportStar(require("./useTokenBalances"), exports);
39
- __exportStar(require("./useTokens"), exports);
40
40
  __exportStar(require("./useTokenSearch"), exports);
41
+ __exportStar(require("./useTokens"), exports);
41
42
  __exportStar(require("./useTools"), exports);
42
43
  __exportStar(require("./useWidgetEvents"), exports);
@@ -6,8 +6,8 @@ const utils_1 = require("../utils");
6
6
  const useDefaultElementId_1 = require("./useDefaultElementId");
7
7
  const useScrollableContainer_1 = require("./useScrollableContainer");
8
8
  const getContentHeight = (elementId) => {
9
- const headerElement = document.getElementById((0, utils_1.createElementId)(utils_1.ElementId.Header, elementId));
10
9
  const containerElement = document.getElementById((0, utils_1.createElementId)(utils_1.ElementId.ScrollableContainer, elementId));
10
+ const headerElement = document.getElementById((0, utils_1.createElementId)(utils_1.ElementId.Header, elementId));
11
11
  if (!containerElement || !headerElement) {
12
12
  console.warn(`Can't find ${utils_1.ElementId.ScrollableContainer} or ${utils_1.ElementId.Header} id.`);
13
13
  return 0;
@@ -18,11 +18,9 @@ const getContentHeight = (elementId) => {
18
18
  };
19
19
  const useContentHeight = () => {
20
20
  const elementId = (0, useDefaultElementId_1.useDefaultElementId)();
21
- const [contentHeight, setContentHeight] = (0, react_1.useState)(() => getContentHeight(elementId));
21
+ const [contentHeight, setContentHeight] = (0, react_1.useState)(0);
22
22
  (0, react_1.useLayoutEffect)(() => {
23
- if (!contentHeight) {
24
- setContentHeight(getContentHeight(elementId));
25
- }
23
+ setContentHeight(getContentHeight(elementId));
26
24
  // eslint-disable-next-line react-hooks/exhaustive-deps
27
25
  }, []);
28
26
  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;
@@ -10,8 +10,8 @@ const useGetTokenBalancesWithRetry_1 = require("./useGetTokenBalancesWithRetry")
10
10
  const useTokenAddressBalance_1 = require("./useTokenAddressBalance");
11
11
  const refetchInterval = 30000;
12
12
  const useFundsSufficiency = (route) => {
13
- const { account, provider } = (0, providers_1.useWallet)();
14
- const getTokenBalancesWithRetry = (0, useGetTokenBalancesWithRetry_1.useGetTokenBalancesWithRetry)(provider);
13
+ const { account } = (0, providers_1.useWallet)();
14
+ const getTokenBalancesWithRetry = (0, useGetTokenBalancesWithRetry_1.useGetTokenBalancesWithRetry)(account.signer?.provider);
15
15
  const [fromChainId, fromTokenAddress, fromAmount] = (0, react_hook_form_1.useWatch)({
16
16
  name: [
17
17
  providers_1.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
  };
@@ -10,12 +10,11 @@ const useGasRecommendation_1 = require("./useGasRecommendation");
10
10
  const useTokenBalance_1 = require("./useTokenBalance");
11
11
  const useGasRefuel = () => {
12
12
  const { getChainById } = (0, _1.useChains)();
13
- const [fromChainId, fromTokenAddress, toChainId, toTokenAddress, toAddress] = (0, react_hook_form_1.useWatch)({
13
+ const [fromChainId, fromTokenAddress, toChainId, toAddress] = (0, react_hook_form_1.useWatch)({
14
14
  name: [
15
15
  providers_1.SwapFormKey.FromChain,
16
16
  providers_1.SwapFormKey.FromToken,
17
17
  providers_1.SwapFormKey.ToChain,
18
- providers_1.SwapFormKey.ToToken,
19
18
  providers_1.SwapFormKey.ToAddress,
20
19
  ],
21
20
  });
@@ -27,10 +26,7 @@ const useGasRefuel = () => {
27
26
  // We don't allow same chain refuel.
28
27
  // If a user runs out of gas, he can't send a source chain transaction.
29
28
  fromChainId === toChainId ||
30
- // We don't want to apply auto refuel when swapping to native tokens
31
- toChain?.nativeToken.address === toTokenAddress ||
32
29
  !gasRecommendation?.available ||
33
- !gasRecommendation.recommended ||
34
30
  !nativeToken) {
35
31
  return false;
36
32
  }
@@ -41,21 +37,15 @@ const useGasRefuel = () => {
41
37
  .div(2);
42
38
  const insufficientGas = tokenBalance.lt(recommendedAmount);
43
39
  return insufficientGas;
44
- }, [
45
- fromChainId,
46
- gasRecommendation?.available,
47
- gasRecommendation?.recommended,
48
- nativeToken,
49
- toChain?.nativeToken.address,
50
- toChainId,
51
- toTokenAddress,
52
- ]);
40
+ }, [fromChainId, gasRecommendation, nativeToken, toChainId]);
53
41
  return {
54
42
  enabled: enabled,
55
43
  availble: gasRecommendation?.available,
56
44
  isLoading: isLoading,
57
45
  chain: toChain,
58
- gasRecommendation,
46
+ fromAmount: gasRecommendation?.available
47
+ ? gasRecommendation.fromAmount
48
+ : undefined,
59
49
  };
60
50
  };
61
51
  exports.useGasRefuel = useGasRefuel;
@@ -5,15 +5,23 @@ const react_query_1 = require("@tanstack/react-query");
5
5
  const big_js_1 = require("big.js");
6
6
  const _1 = require(".");
7
7
  const providers_1 = require("../providers");
8
+ const stores_1 = require("../stores");
8
9
  const refetchInterval = 30000;
9
10
  const useGasSufficiency = (route) => {
10
- const { account, provider } = (0, providers_1.useWallet)();
11
+ const { account } = (0, providers_1.useWallet)();
11
12
  const { getChainById } = (0, _1.useChains)();
12
- const getTokenBalancesWithRetry = (0, _1.useGetTokenBalancesWithRetry)(provider);
13
+ const getTokenBalancesWithRetry = (0, _1.useGetTokenBalancesWithRetry)(account.signer?.provider);
14
+ const { enabledAutoRefuel } = (0, stores_1.useSettings)(['enabledAutoRefuel']);
15
+ const { enabled, isLoading: isRefuelLoading } = (0, _1.useGasRefuel)();
16
+ const enabledRefuel = enabled && enabledAutoRefuel;
13
17
  const { data: insufficientGas, isInitialLoading } = (0, react_query_1.useQuery)(['gas-sufficiency-check', account.address, route?.id], async () => {
14
18
  if (!account.address || !route) {
15
19
  return;
16
20
  }
21
+ // TODO: include LI.Fuel into calculation once steps and tools are properly typed
22
+ // const refuelSteps = route.steps
23
+ // .flatMap((step) => step.includedSteps)
24
+ // .filter((includedStep) => includedStep.tool === 'lifuelProtocol');
17
25
  const gasCosts = route.steps
18
26
  .filter((step) => !step.execution || step.execution.status !== 'DONE')
19
27
  .reduce((groupedGasCosts, step) => {
@@ -69,8 +77,9 @@ const useGasSufficiency = (route) => {
69
77
  staleTime: refetchInterval,
70
78
  cacheTime: refetchInterval,
71
79
  });
80
+ const isInsufficientGas = Boolean(insufficientGas?.length) && !isRefuelLoading && !enabledRefuel;
72
81
  return {
73
- insufficientGas,
82
+ insufficientGas: isInsufficientGas ? insufficientGas : undefined,
74
83
  isInitialLoading,
75
84
  };
76
85
  };
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useInitializer = void 0;
4
- /* eslint-disable no-underscore-dangle */
5
4
  const sdk_1 = require("@lifi/sdk");
6
5
  const react_1 = require("react");
7
6
  const version_1 = require("../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
  };