@lifi/widget 1.32.7 → 2.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (309) hide show
  1. package/App.js +3 -3
  2. package/AppDrawer.js +4 -3
  3. package/AppDrawer.style.d.ts +5 -5
  4. package/cjs/App.js +3 -3
  5. package/cjs/AppDrawer.js +4 -3
  6. package/cjs/AppDrawer.style.d.ts +5 -5
  7. package/cjs/components/ActiveSwaps/ActiveSwaps.style.d.ts +3 -3
  8. package/cjs/components/Card/CardIconButton.d.ts +29 -0
  9. package/cjs/components/Card/CardIconButton.js +17 -0
  10. package/cjs/components/Card/CardLabel.d.ts +26 -0
  11. package/cjs/components/Card/CardLabel.js +45 -0
  12. package/cjs/components/Card/CardTitle.d.ts +2 -2
  13. package/cjs/components/Card/index.d.ts +2 -0
  14. package/cjs/components/Card/index.js +2 -0
  15. package/cjs/components/GasMessage/FundsSufficiencyMessage.d.ts +1 -0
  16. package/cjs/components/GasMessage/FundsSufficiencyMessage.js +16 -0
  17. package/cjs/components/{GasSufficiencyMessage/GasSufficiencyMessage.d.ts → GasMessage/GasMessage.d.ts} +4 -2
  18. package/cjs/components/GasMessage/GasMessage.js +19 -0
  19. package/cjs/components/GasMessage/GasMessage.style.d.ts +34 -0
  20. package/cjs/components/GasMessage/GasMessage.style.js +48 -0
  21. package/cjs/components/GasMessage/GasRefuelMessage.d.ts +3 -0
  22. package/cjs/components/GasMessage/GasRefuelMessage.js +26 -0
  23. package/cjs/components/GasMessage/GasSufficiencyMessage.d.ts +7 -0
  24. package/cjs/components/GasMessage/GasSufficiencyMessage.js +21 -0
  25. package/cjs/components/GasMessage/index.d.ts +2 -0
  26. package/cjs/components/GasMessage/index.js +18 -0
  27. package/cjs/components/Header/Header.style.d.ts +5 -5
  28. package/cjs/components/Header/NavigationHeader.js +4 -4
  29. package/cjs/components/Header/WalletHeader.js +5 -5
  30. package/cjs/components/Insurance/Insurance.d.ts +3 -0
  31. package/cjs/components/Insurance/Insurance.js +11 -0
  32. package/cjs/components/Insurance/InsuranceCard.d.ts +3 -0
  33. package/cjs/components/Insurance/InsuranceCard.js +20 -0
  34. package/cjs/components/Insurance/InsuranceCollapsed.d.ts +3 -0
  35. package/cjs/components/Insurance/InsuranceCollapsed.js +32 -0
  36. package/cjs/components/Insurance/index.d.ts +1 -0
  37. package/cjs/components/{GasSufficiencyMessage → Insurance}/index.js +1 -1
  38. package/cjs/components/Insurance/types.d.ts +14 -0
  39. package/cjs/components/Insurance/types.js +2 -0
  40. package/cjs/components/NFT/NFT.style.d.ts +1 -1
  41. package/cjs/components/PoweredBy/PoweredBy.style.d.ts +1 -1
  42. package/cjs/components/ReverseTokensButton/ReverseTokensButton.style.d.ts +2 -2
  43. package/cjs/components/SendToWallet/SendToWallet.js +31 -25
  44. package/cjs/components/SendToWallet/SendToWallet.style.d.ts +2 -2
  45. package/cjs/components/SendToWallet/SendToWalletButton.js +3 -3
  46. package/cjs/components/SmallAvatar.d.ts +2 -2
  47. package/cjs/components/Step/CircularProgress.style.d.ts +1 -1
  48. package/cjs/components/Step/DestinationWalletAddress.js +2 -2
  49. package/cjs/components/Step/GasStepProcess.js +2 -2
  50. package/cjs/components/Step/Step.js +7 -5
  51. package/cjs/components/Step/StepList.d.ts +1 -1
  52. package/cjs/components/Step/StepProcess.style.d.ts +3 -3
  53. package/cjs/components/StepActions/StepActions.d.ts +5 -0
  54. package/cjs/components/StepActions/StepActions.js +55 -17
  55. package/cjs/components/StepActions/StepActions.style.d.ts +1 -1
  56. package/cjs/components/SwapButton/SwapButton.js +2 -2
  57. package/cjs/components/SwapButton/types.d.ts +1 -2
  58. package/cjs/components/SwapInput/SwapInput.style.d.ts +2 -2
  59. package/cjs/components/SwapInput/SwapInputAdornment.style.d.ts +3 -3
  60. package/cjs/components/SwapInput/SwapInputEndAdornment.js +18 -1
  61. package/cjs/components/SwapRouteCard/SwapRouteCard.d.ts +1 -2
  62. package/cjs/components/SwapRouteCard/SwapRouteCard.js +10 -26
  63. package/cjs/components/SwapRouteCard/SwapRouteCard.style.d.ts +4 -36
  64. package/cjs/components/SwapRouteCard/SwapRouteCard.style.js +7 -38
  65. package/cjs/components/SwapRouteCard/SwapRouteCardEssentials.d.ts +3 -0
  66. package/cjs/components/SwapRouteCard/SwapRouteCardEssentials.js +27 -0
  67. package/cjs/components/SwapRouteCard/SwapRouteCardSkeleton.js +5 -5
  68. package/cjs/components/SwapRouteCard/types.d.ts +2 -2
  69. package/cjs/components/SwapRouteCard/utils.d.ts +5 -0
  70. package/cjs/components/SwapRouteCard/utils.js +32 -2
  71. package/cjs/components/SwapRoutes/SwapRoutes.js +3 -12
  72. package/cjs/components/SwapRoutes/SwapRoutesExpanded.js +3 -5
  73. package/cjs/components/SwapRoutes/{SwapRoutes.style.d.ts → SwapRoutesExpanded.style.d.ts} +0 -9
  74. package/cjs/components/SwapRoutes/{SwapRoutes.style.js → SwapRoutesExpanded.style.js} +1 -12
  75. package/cjs/components/Switch.js +4 -4
  76. package/cjs/components/TextFitter/TextFitter.js +9 -3
  77. package/cjs/components/Token/Token.style.d.ts +2 -2
  78. package/cjs/config/theme.js +1 -1
  79. package/cjs/config/version.d.ts +1 -1
  80. package/cjs/config/version.js +1 -1
  81. package/cjs/hooks/index.d.ts +4 -0
  82. package/cjs/hooks/index.js +4 -0
  83. package/cjs/hooks/useChains.js +2 -2
  84. package/cjs/hooks/useFeaturedTokens.d.ts +1 -1
  85. package/cjs/hooks/useFeaturedTokens.js +2 -2
  86. package/cjs/hooks/useFundsSufficiency.d.ts +5 -0
  87. package/cjs/hooks/useFundsSufficiency.js +73 -0
  88. package/cjs/hooks/useGasRecommendation.d.ts +2 -0
  89. package/cjs/hooks/useGasRecommendation.js +23 -0
  90. package/cjs/hooks/useGasRefuel.d.ts +7 -0
  91. package/cjs/hooks/useGasRefuel.js +61 -0
  92. package/cjs/hooks/useGasSufficiency.d.ts +2 -3
  93. package/cjs/hooks/useGasSufficiency.js +6 -37
  94. package/cjs/hooks/useGetTokenBalancesWithRetry.d.ts +3 -0
  95. package/cjs/hooks/useGetTokenBalancesWithRetry.js +33 -0
  96. package/cjs/hooks/useSwapRoutes.d.ts +7 -2
  97. package/cjs/hooks/useSwapRoutes.js +31 -11
  98. package/cjs/hooks/useTokenAddressBalance.js +4 -2
  99. package/cjs/hooks/useTokenBalance.js +4 -22
  100. package/cjs/hooks/useTokenBalances.d.ts +1 -1
  101. package/cjs/hooks/useTokenSearch.js +2 -2
  102. package/cjs/hooks/useTokens.js +2 -3
  103. package/cjs/i18n/en.json +14 -7
  104. package/cjs/i18n/it.json +6 -2
  105. package/cjs/i18n/pt.json +234 -0
  106. package/cjs/i18n/uk.json +5 -1
  107. package/cjs/icons/InsuraceLogo.d.ts +2 -0
  108. package/cjs/icons/InsuraceLogo.js +11 -0
  109. package/cjs/icons/index.d.ts +1 -0
  110. package/cjs/icons/index.js +1 -0
  111. package/cjs/index.d.ts +0 -6
  112. package/cjs/index.js +1 -6
  113. package/cjs/pages/MainPage/MainGasMessage.d.ts +3 -0
  114. package/cjs/pages/MainPage/MainGasMessage.js +12 -0
  115. package/cjs/pages/MainPage/MainPage.js +3 -2
  116. package/cjs/pages/MainPage/MainSwapButton.js +1 -1
  117. package/cjs/pages/SettingsPage/ColorSchemeButtonGroup.js +2 -2
  118. package/cjs/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +2 -2
  119. package/cjs/pages/SettingsPage/ResetSettingsButton.js +3 -1
  120. package/cjs/pages/SettingsPage/RoutePrioritySelect.js +1 -1
  121. package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +4 -3
  122. package/cjs/pages/SwapPage/ExchangeRateBottomSheet.d.ts +1 -2
  123. package/cjs/pages/SwapPage/ExchangeRateBottomSheet.js +1 -14
  124. package/cjs/pages/SwapPage/StartSwapButton.d.ts +3 -2
  125. package/cjs/pages/SwapPage/StartSwapButton.js +14 -4
  126. package/cjs/pages/SwapPage/SwapPage.js +18 -7
  127. package/cjs/pages/SwapPage/types.d.ts +9 -0
  128. package/cjs/pages/SwapPage/types.js +2 -0
  129. package/cjs/pages/SwapRoutesPage/SwapRoutesPage.js +1 -1
  130. package/cjs/providers/SDKProvider/SDKProvider.d.ts +2 -2
  131. package/cjs/providers/SDKProvider/SDKProvider.js +2 -1
  132. package/cjs/providers/SwapFormProvider/FormUpdater.js +2 -3
  133. package/cjs/providers/WidgetProvider/WidgetProvider.js +17 -4
  134. package/cjs/providers/WidgetProvider/utils.d.ts +1 -1
  135. package/cjs/providers/WidgetProvider/utils.js +2 -4
  136. package/cjs/stores/StoreProvider.js +1 -1
  137. package/cjs/stores/routes/createRouteExecutionStore.js +3 -2
  138. package/cjs/stores/routes/index.d.ts +0 -1
  139. package/cjs/stores/routes/index.js +0 -1
  140. package/cjs/stores/routes/types.d.ts +1 -5
  141. package/cjs/stores/routes/useSetExecutableRoute.d.ts +1 -1
  142. package/cjs/stores/settings/types.d.ts +3 -2
  143. package/cjs/stores/settings/useSettingsStore.js +3 -1
  144. package/cjs/types/widget.d.ts +5 -10
  145. package/cjs/utils/format.js +4 -1
  146. package/components/ActiveSwaps/ActiveSwaps.style.d.ts +3 -3
  147. package/components/Card/CardIconButton.d.ts +29 -0
  148. package/components/Card/CardIconButton.js +14 -0
  149. package/components/Card/CardLabel.d.ts +26 -0
  150. package/components/Card/CardLabel.js +42 -0
  151. package/components/Card/CardTitle.d.ts +2 -2
  152. package/components/Card/index.d.ts +2 -0
  153. package/components/Card/index.js +2 -0
  154. package/components/GasMessage/FundsSufficiencyMessage.d.ts +1 -0
  155. package/components/GasMessage/FundsSufficiencyMessage.js +12 -0
  156. package/components/{GasSufficiencyMessage/GasSufficiencyMessage.d.ts → GasMessage/GasMessage.d.ts} +4 -2
  157. package/components/GasMessage/GasMessage.js +15 -0
  158. package/components/GasMessage/GasMessage.style.d.ts +34 -0
  159. package/components/GasMessage/GasMessage.style.js +45 -0
  160. package/components/GasMessage/GasRefuelMessage.d.ts +3 -0
  161. package/components/GasMessage/GasRefuelMessage.js +22 -0
  162. package/components/GasMessage/GasSufficiencyMessage.d.ts +7 -0
  163. package/components/GasMessage/GasSufficiencyMessage.js +17 -0
  164. package/components/GasMessage/index.d.ts +2 -0
  165. package/components/GasMessage/index.js +2 -0
  166. package/components/Header/Header.style.d.ts +5 -5
  167. package/components/Header/NavigationHeader.js +4 -4
  168. package/components/Header/WalletHeader.js +6 -6
  169. package/components/Insurance/Insurance.d.ts +3 -0
  170. package/components/Insurance/Insurance.js +7 -0
  171. package/components/Insurance/InsuranceCard.d.ts +3 -0
  172. package/components/Insurance/InsuranceCard.js +16 -0
  173. package/components/Insurance/InsuranceCollapsed.d.ts +3 -0
  174. package/components/Insurance/InsuranceCollapsed.js +28 -0
  175. package/components/Insurance/index.d.ts +1 -0
  176. package/components/Insurance/index.js +1 -0
  177. package/components/Insurance/types.d.ts +14 -0
  178. package/components/Insurance/types.js +1 -0
  179. package/components/NFT/NFT.style.d.ts +1 -1
  180. package/components/PoweredBy/PoweredBy.style.d.ts +1 -1
  181. package/components/ReverseTokensButton/ReverseTokensButton.style.d.ts +2 -2
  182. package/components/SendToWallet/SendToWallet.js +34 -28
  183. package/components/SendToWallet/SendToWallet.style.d.ts +2 -2
  184. package/components/SendToWallet/SendToWalletButton.js +4 -4
  185. package/components/SmallAvatar.d.ts +2 -2
  186. package/components/Step/CircularProgress.style.d.ts +1 -1
  187. package/components/Step/DestinationWalletAddress.js +2 -2
  188. package/components/Step/GasStepProcess.js +2 -2
  189. package/components/Step/Step.js +7 -5
  190. package/components/Step/StepList.d.ts +1 -1
  191. package/components/Step/StepProcess.style.d.ts +3 -3
  192. package/components/StepActions/StepActions.d.ts +5 -0
  193. package/components/StepActions/StepActions.js +52 -16
  194. package/components/StepActions/StepActions.style.d.ts +1 -1
  195. package/components/SwapButton/SwapButton.js +2 -2
  196. package/components/SwapButton/types.d.ts +1 -2
  197. package/components/SwapInput/SwapInput.style.d.ts +2 -2
  198. package/components/SwapInput/SwapInputAdornment.style.d.ts +3 -3
  199. package/components/SwapInput/SwapInputEndAdornment.js +19 -2
  200. package/components/SwapRouteCard/SwapRouteCard.d.ts +1 -2
  201. package/components/SwapRouteCard/SwapRouteCard.js +11 -26
  202. package/components/SwapRouteCard/SwapRouteCard.style.d.ts +4 -36
  203. package/components/SwapRouteCard/SwapRouteCard.style.js +7 -38
  204. package/components/SwapRouteCard/SwapRouteCardEssentials.d.ts +3 -0
  205. package/components/SwapRouteCard/SwapRouteCardEssentials.js +23 -0
  206. package/components/SwapRouteCard/SwapRouteCardSkeleton.js +5 -5
  207. package/components/SwapRouteCard/types.d.ts +2 -2
  208. package/components/SwapRouteCard/utils.d.ts +5 -0
  209. package/components/SwapRouteCard/utils.js +30 -1
  210. package/components/SwapRoutes/SwapRoutes.js +5 -14
  211. package/components/SwapRoutes/SwapRoutesExpanded.js +2 -4
  212. package/components/SwapRoutes/{SwapRoutes.style.d.ts → SwapRoutesExpanded.style.d.ts} +0 -9
  213. package/components/SwapRoutes/{SwapRoutes.style.js → SwapRoutesExpanded.style.js} +1 -12
  214. package/components/Switch.js +5 -5
  215. package/components/TextFitter/TextFitter.js +9 -3
  216. package/components/Token/Token.style.d.ts +2 -2
  217. package/config/theme.js +1 -1
  218. package/config/version.d.ts +1 -1
  219. package/config/version.js +1 -1
  220. package/hooks/index.d.ts +4 -0
  221. package/hooks/index.js +4 -0
  222. package/hooks/useChains.js +2 -2
  223. package/hooks/useFeaturedTokens.d.ts +1 -1
  224. package/hooks/useFeaturedTokens.js +2 -2
  225. package/hooks/useFundsSufficiency.d.ts +5 -0
  226. package/hooks/useFundsSufficiency.js +69 -0
  227. package/hooks/useGasRecommendation.d.ts +2 -0
  228. package/hooks/useGasRecommendation.js +19 -0
  229. package/hooks/useGasRefuel.d.ts +7 -0
  230. package/hooks/useGasRefuel.js +57 -0
  231. package/hooks/useGasSufficiency.d.ts +2 -3
  232. package/hooks/useGasSufficiency.js +7 -38
  233. package/hooks/useGetTokenBalancesWithRetry.d.ts +3 -0
  234. package/hooks/useGetTokenBalancesWithRetry.js +29 -0
  235. package/hooks/useSwapRoutes.d.ts +7 -2
  236. package/hooks/useSwapRoutes.js +32 -12
  237. package/hooks/useTokenAddressBalance.js +4 -2
  238. package/hooks/useTokenBalance.js +5 -23
  239. package/hooks/useTokenBalances.d.ts +1 -1
  240. package/hooks/useTokenSearch.js +2 -2
  241. package/hooks/useTokens.js +2 -3
  242. package/i18n/en.json +14 -7
  243. package/i18n/it.json +6 -2
  244. package/i18n/pt.json +234 -0
  245. package/i18n/uk.json +5 -1
  246. package/icons/InsuraceLogo.d.ts +2 -0
  247. package/icons/InsuraceLogo.js +7 -0
  248. package/icons/index.d.ts +1 -0
  249. package/icons/index.js +1 -0
  250. package/index.d.ts +0 -6
  251. package/index.js +0 -5
  252. package/package.json +12 -11
  253. package/pages/ActiveSwapsPage/ActiveSwapsPage.js +2 -2
  254. package/pages/MainPage/MainGasMessage.d.ts +3 -0
  255. package/pages/MainPage/MainGasMessage.js +8 -0
  256. package/pages/MainPage/MainPage.js +3 -2
  257. package/pages/MainPage/MainSwapButton.js +1 -1
  258. package/pages/SettingsPage/ColorSchemeButtonGroup.js +2 -2
  259. package/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +2 -2
  260. package/pages/SettingsPage/ResetSettingsButton.js +3 -1
  261. package/pages/SettingsPage/RoutePrioritySelect.js +1 -1
  262. package/pages/SwapDetailsPage/SwapDetailsPage.js +5 -4
  263. package/pages/SwapHistoryPage/SwapHistoryPage.js +2 -2
  264. package/pages/SwapPage/ExchangeRateBottomSheet.d.ts +1 -2
  265. package/pages/SwapPage/ExchangeRateBottomSheet.js +0 -12
  266. package/pages/SwapPage/StartSwapButton.d.ts +3 -2
  267. package/pages/SwapPage/StartSwapButton.js +13 -4
  268. package/pages/SwapPage/SwapPage.js +21 -10
  269. package/pages/SwapPage/types.d.ts +9 -0
  270. package/pages/SwapPage/types.js +1 -0
  271. package/pages/SwapRoutesPage/SwapRoutesPage.js +1 -1
  272. package/providers/SDKProvider/SDKProvider.d.ts +2 -2
  273. package/providers/SDKProvider/SDKProvider.js +3 -2
  274. package/providers/SwapFormProvider/FormUpdater.js +2 -3
  275. package/providers/WidgetProvider/WidgetProvider.js +17 -4
  276. package/providers/WidgetProvider/utils.d.ts +1 -1
  277. package/providers/WidgetProvider/utils.js +2 -4
  278. package/stores/StoreProvider.js +2 -2
  279. package/stores/routes/createRouteExecutionStore.js +3 -2
  280. package/stores/routes/index.d.ts +0 -1
  281. package/stores/routes/index.js +0 -1
  282. package/stores/routes/types.d.ts +1 -5
  283. package/stores/routes/useSetExecutableRoute.d.ts +1 -1
  284. package/stores/settings/types.d.ts +3 -2
  285. package/stores/settings/useSettingsStore.js +3 -1
  286. package/tsconfig.cjs.tsbuildinfo +1 -1
  287. package/types/widget.d.ts +5 -10
  288. package/utils/format.js +4 -1
  289. package/cjs/components/GasSufficiencyMessage/GasSufficiencyMessage.js +0 -31
  290. package/cjs/components/GasSufficiencyMessage/GasSufficiencyMessage.style.d.ts +0 -9
  291. package/cjs/components/GasSufficiencyMessage/GasSufficiencyMessage.style.js +0 -14
  292. package/cjs/components/GasSufficiencyMessage/index.d.ts +0 -1
  293. package/cjs/components/SwapRoutes/useSetRecommendedRoute.d.ts +0 -2
  294. package/cjs/components/SwapRoutes/useSetRecommendedRoute.js +0 -13
  295. package/cjs/config/env.d.ts +0 -3
  296. package/cjs/config/env.js +0 -6
  297. package/cjs/stores/routes/useRecommendedRouteStore.d.ts +0 -10
  298. package/cjs/stores/routes/useRecommendedRouteStore.js +0 -39
  299. package/components/GasSufficiencyMessage/GasSufficiencyMessage.js +0 -27
  300. package/components/GasSufficiencyMessage/GasSufficiencyMessage.style.d.ts +0 -9
  301. package/components/GasSufficiencyMessage/GasSufficiencyMessage.style.js +0 -11
  302. package/components/GasSufficiencyMessage/index.d.ts +0 -1
  303. package/components/GasSufficiencyMessage/index.js +0 -1
  304. package/components/SwapRoutes/useSetRecommendedRoute.d.ts +0 -2
  305. package/components/SwapRoutes/useSetRecommendedRoute.js +0 -9
  306. package/config/env.d.ts +0 -3
  307. package/config/env.js +0 -3
  308. package/stores/routes/useRecommendedRouteStore.d.ts +0 -10
  309. package/stores/routes/useRecommendedRouteStore.js +0 -32
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SwapRoutes = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const KeyboardArrowRight_1 = require("@mui/icons-material/KeyboardArrowRight");
6
5
  const material_1 = require("@mui/material");
7
6
  const react_hook_form_1 = require("react-hook-form");
8
7
  const react_i18next_1 = require("react-i18next");
@@ -13,16 +12,13 @@ const SwapRouteCard_1 = require("../../components/SwapRouteCard");
13
12
  const hooks_1 = require("../../hooks");
14
13
  const providers_1 = require("../../providers");
15
14
  const utils_1 = require("../../utils");
16
- const SwapRoutes_style_1 = require("./SwapRoutes.style");
17
- const useSetRecommendedRoute_1 = require("./useSetRecommendedRoute");
18
15
  const SwapRoutes = (props) => {
19
16
  const { t } = (0, react_i18next_1.useTranslation)();
20
- const { variant, useRecommendedRoute } = (0, providers_1.useWidgetConfig)();
21
17
  const navigate = (0, react_router_dom_1.useNavigate)();
18
+ const { variant, useRecommendedRoute } = (0, providers_1.useWidgetConfig)();
22
19
  const { isValid, isValidating } = (0, react_hook_form_1.useFormState)();
23
20
  const { routes, isLoading, isFetching, isFetched, dataUpdatedAt, refetchTime, refetch, } = (0, hooks_1.useSwapRoutes)();
24
21
  const currentRoute = routes?.[0];
25
- (0, useSetRecommendedRoute_1.useSetRecommendedRoute)(currentRoute, isFetching);
26
22
  if (!currentRoute && !isLoading && !isFetching && !isFetched) {
27
23
  return null;
28
24
  }
@@ -31,16 +27,11 @@ const SwapRoutes = (props) => {
31
27
  };
32
28
  const routeNotFound = !currentRoute && !isLoading && !isFetching;
33
29
  const onlyRecommendedRoute = variant === 'refuel' || useRecommendedRoute;
30
+ const showAll = !onlyRecommendedRoute && !routeNotFound && (routes?.length ?? 0) > 1;
34
31
  return ((0, jsx_runtime_1.jsxs)(Card_1.Card, { ...props, children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, { children: t('swap.routes') }), (0, jsx_runtime_1.jsx)(ProgressToNextUpdate_1.ProgressToNextUpdate, { updatedAt: dataUpdatedAt || new Date().getTime(), timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: {
35
32
  position: 'absolute',
36
33
  top: 8,
37
34
  right: 8,
38
- } }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { display: 'flex' }, children: [(0, jsx_runtime_1.jsx)(SwapRoutes_style_1.Stack, { direction: "row", spacing: 2, my: 2, ml: 2, mr: onlyRecommendedRoute || routeNotFound ? 2 : 1, sx: {
39
- borderRightWidth: !onlyRecommendedRoute &&
40
- !routeNotFound &&
41
- (isFetching || (routes && routes.length > 1))
42
- ? 1
43
- : 0,
44
- }, children: isLoading ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCardSkeleton, { minWidth: !onlyRecommendedRoute ? '80%' : '100%', variant: "dense" }), !onlyRecommendedRoute ? ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCardSkeleton, { minWidth: "80%", variant: "dense" })) : null] })) : !currentRoute ? ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteNotFoundCard, {})) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCard, { minWidth: !onlyRecommendedRoute && routes.length > 1 ? '80%' : '100%', route: currentRoute, variant: "dense", active: true }), !onlyRecommendedRoute && routes.length > 1 ? ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCard, { minWidth: "80%", route: routes[1], variant: "dense", pointerEvents: "none" })) : null] })) }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { display: 'flex', alignItems: 'center' }, children: !onlyRecommendedRoute && !routeNotFound ? ((0, jsx_runtime_1.jsx)(material_1.Box, { py: 1, pr: 1, children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { onClick: handleCardClick, size: "medium", disabled: isValidating || !isValid, children: (0, jsx_runtime_1.jsx)(KeyboardArrowRight_1.default, {}) }) })) : null })] })] }));
35
+ } }), (0, jsx_runtime_1.jsxs)(material_1.Box, { p: 2, children: [isLoading ? ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCardSkeleton, { variant: "cardless" })) : !currentRoute ? ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteNotFoundCard, {})) : ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCard, { route: currentRoute, variant: "cardless", active: true })), (0, jsx_runtime_1.jsx)(material_1.Collapse, { timeout: 225, in: showAll, unmountOnExit: true, mountOnEnter: true, appear: true, children: (0, jsx_runtime_1.jsx)(material_1.Box, { mt: 2, children: (0, jsx_runtime_1.jsx)(material_1.Button, { onClick: handleCardClick, disabled: isValidating || !isValid, fullWidth: true, children: t('button.showAll') }) }) })] })] }));
45
36
  };
46
37
  exports.SwapRoutes = SwapRoutes;
@@ -12,8 +12,7 @@ const stores_1 = require("../../stores");
12
12
  const utils_1 = require("../../utils");
13
13
  const ProgressToNextUpdate_1 = require("../ProgressToNextUpdate");
14
14
  const SwapRouteCard_1 = require("../SwapRouteCard");
15
- const SwapRoutes_style_1 = require("./SwapRoutes.style");
16
- const useSetRecommendedRoute_1 = require("./useSetRecommendedRoute");
15
+ const SwapRoutesExpanded_style_1 = require("./SwapRoutesExpanded.style");
17
16
  const timeout = { enter: 225, exit: 225, appear: 0 };
18
17
  const SwapRoutesExpanded = () => {
19
18
  const element = (0, react_router_dom_1.useRoutes)([
@@ -22,7 +21,7 @@ const SwapRoutesExpanded = () => {
22
21
  element: null,
23
22
  },
24
23
  ]);
25
- return ((0, jsx_runtime_1.jsx)(SwapRoutes_style_1.CollapseContainer, { children: (0, jsx_runtime_1.jsx)(material_1.Collapse, { timeout: timeout, in: !!element, orientation: "horizontal", children: (0, jsx_runtime_1.jsx)(material_1.Grow, { timeout: timeout, in: !!element, mountOnEnter: true, unmountOnExit: true, children: (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(exports.SwapRoutesExpandedElement, {}) }) }) }) }));
24
+ return ((0, jsx_runtime_1.jsx)(SwapRoutesExpanded_style_1.CollapseContainer, { children: (0, jsx_runtime_1.jsx)(material_1.Collapse, { timeout: timeout, in: !!element, orientation: "horizontal", children: (0, jsx_runtime_1.jsx)(material_1.Grow, { timeout: timeout, in: !!element, mountOnEnter: true, unmountOnExit: true, children: (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(exports.SwapRoutesExpandedElement, {}) }) }) }) }));
26
25
  };
27
26
  exports.SwapRoutesExpanded = SwapRoutesExpanded;
28
27
  const SwapRoutesExpandedElement = () => {
@@ -33,7 +32,6 @@ const SwapRoutesExpandedElement = () => {
33
32
  const { isValid, isValidating } = (0, react_hook_form_1.useFormState)();
34
33
  const { routes, isLoading, isFetching, isFetched, dataUpdatedAt, refetchTime, refetch, } = (0, hooks_1.useSwapRoutes)();
35
34
  const currentRoute = routes?.[0];
36
- (0, useSetRecommendedRoute_1.useSetRecommendedRoute)(currentRoute, isFetching);
37
35
  const handleRouteClick = (route) => {
38
36
  if (isValid && !isValidating) {
39
37
  setExecutableRoute(route);
@@ -44,6 +42,6 @@ const SwapRoutesExpandedElement = () => {
44
42
  };
45
43
  const expanded = Boolean(currentRoute || isLoading || isFetching || isFetched);
46
44
  const routeNotFound = !currentRoute && !isLoading && !isFetching && expanded;
47
- 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)(SwapRoutes_style_1.Container, { sx: containerStyle, enableColorScheme: true, children: (0, jsx_runtime_1.jsxs)(SwapRoutes_style_1.ScrollableContainer, { children: [(0, jsx_runtime_1.jsxs)(SwapRoutes_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 ? (Array.from({ length: 3 }).map((_, index) => ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCardSkeleton, { variant: "stretched" }, index)))) : (routes?.map((route, index) => ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCard, { route: route, onClick: () => handleRouteClick(route), active: index === 0, variant: "stretched", expanded: routes?.length <= 2 }, route.id)))) })] }) }) }) }));
45
+ 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)))) })] }) }) }) }));
48
46
  };
49
47
  exports.SwapRoutesExpandedElement = SwapRoutesExpandedElement;
@@ -31,12 +31,3 @@ export declare const Header: import("@emotion/styled").StyledComponent<import("@
31
31
  } & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
32
32
  ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
33
33
  }, "children" | "sx" | "ref" | ("p" | "color" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint") | "component"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
34
- export declare const Stack: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
35
- children?: import("react").ReactNode;
36
- direction?: import("@mui/system").ResponsiveStyleValue<"column" | "column-reverse" | "row" | "row-reverse"> | undefined;
37
- spacing?: import("@mui/system").ResponsiveStyleValue<string | number> | undefined;
38
- divider?: import("react").ReactNode;
39
- sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
40
- } & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
41
- ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
42
- }, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "direction" | ("p" | "color" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint") | "divider" | "spacing"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Stack = exports.Header = exports.Container = exports.ScrollableContainer = exports.CollapseContainer = void 0;
3
+ exports.Header = exports.Container = exports.ScrollableContainer = exports.CollapseContainer = void 0;
4
4
  const material_1 = require("@mui/material");
5
5
  const styles_1 = require("@mui/material/styles");
6
6
  const AppContainer_1 = require("../AppContainer");
@@ -35,14 +35,3 @@ exports.Header = (0, styles_1.styled)(material_1.Box)(({ theme }) => ({
35
35
  top: 0,
36
36
  zIndex: 1200,
37
37
  }));
38
- exports.Stack = (0, styles_1.styled)(material_1.Stack)(({ theme }) => ({
39
- alignItems: 'stretch',
40
- display: 'flex',
41
- flex: 1,
42
- flexWrap: 'nowrap',
43
- overflow: 'hidden',
44
- borderRight: `solid ${theme.palette.mode === 'light'
45
- ? theme.palette.grey[300]
46
- : theme.palette.grey[800]}`,
47
- width: 'calc(100% - 48px)',
48
- }));
@@ -31,8 +31,8 @@ exports.Switch = (0, styles_1.styled)(material_1.Switch)(({ theme }) => ({
31
31
  },
32
32
  [`&.${Switch_1.switchClasses.disabled} .${Switch_1.switchClasses.thumb}`]: {
33
33
  color: theme.palette.mode === 'light'
34
- ? theme.palette.grey[100]
35
- : theme.palette.grey[600],
34
+ ? (0, styles_1.alpha)(theme.palette.common.black, 0.12)
35
+ : (0, styles_1.alpha)(theme.palette.common.white, 0.12),
36
36
  },
37
37
  [`&.${Switch_1.switchClasses.disabled} + .${Switch_1.switchClasses.track}`]: {
38
38
  opacity: theme.palette.mode === 'light' ? 0.7 : 0.3,
@@ -46,8 +46,8 @@ exports.Switch = (0, styles_1.styled)(material_1.Switch)(({ theme }) => ({
46
46
  [`.${Switch_1.switchClasses.track}`]: {
47
47
  borderRadius: 24 / 2,
48
48
  backgroundColor: theme.palette.mode === 'light'
49
- ? theme.palette.grey[300]
50
- : theme.palette.grey[800],
49
+ ? (0, styles_1.alpha)(theme.palette.common.black, 0.16)
50
+ : (0, styles_1.alpha)(theme.palette.common.white, 0.16),
51
51
  opacity: 1,
52
52
  transition: theme.transitions.create(['background-color'], {
53
53
  duration: theme.transitions.duration.standard,
@@ -4,6 +4,7 @@ exports.TextFitter = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const styles_1 = require("@mui/material/styles");
6
6
  const react_1 = require("react");
7
+ const react_intersection_observer_1 = require("react-intersection-observer");
7
8
  const initialState = {
8
9
  x: 0,
9
10
  y: 0,
@@ -14,7 +15,13 @@ const TextFitter = ({ children, width = '100%', height, maxHeight, preserveAspec
14
15
  const theme = (0, styles_1.useTheme)();
15
16
  const textRef = (0, react_1.useRef)(null);
16
17
  const [viewBox, setViewBox] = (0, react_1.useState)(initialState);
17
- // const [textRect, setTextRect] = useState<Partial<DOMRect>>(initialState);
18
+ const [ref] = (0, react_intersection_observer_1.useInView)({
19
+ onChange(inView) {
20
+ if (inView) {
21
+ calculateBox();
22
+ }
23
+ },
24
+ });
18
25
  const calculateBox = (0, react_1.useCallback)(() => {
19
26
  if (!textRef.current) {
20
27
  return;
@@ -28,7 +35,6 @@ const TextFitter = ({ children, width = '100%', height, maxHeight, preserveAspec
28
35
  box.height -= box.height * cropBottom;
29
36
  }
30
37
  setViewBox(box);
31
- // setTextRect(textRef.current.getBoundingClientRect());
32
38
  onFit?.();
33
39
  }, [cropBottom, cropTop, onFit]);
34
40
  (0, react_1.useLayoutEffect)(() => {
@@ -47,6 +53,6 @@ const TextFitter = ({ children, width = '100%', height, maxHeight, preserveAspec
47
53
  // ? maxHeight
48
54
  // : height
49
55
  // }
50
- preserveAspectRatio: preserveAspectRatio, fill: theme.palette.text.primary, children: (0, jsx_runtime_1.jsx)("text", { x: 0, y: 0, style: textStyle, ref: textRef, children: children }) }));
56
+ preserveAspectRatio: preserveAspectRatio, fill: theme.palette.text.primary, ref: ref, children: (0, jsx_runtime_1.jsx)("text", { x: 0, y: 0, style: textStyle, ref: textRef, children: children }) }));
51
57
  };
52
58
  exports.TextFitter = TextFitter;
@@ -17,8 +17,8 @@ export declare const TextSecondary: import("@emotion/styled").StyledComponent<im
17
17
  noWrap?: boolean | undefined;
18
18
  paragraph?: boolean | undefined;
19
19
  sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
20
- variant?: "button" | "caption" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "inherit" | "subtitle1" | "subtitle2" | "body1" | "body2" | "overline" | "@supports (font-variation-settings: normal)" | undefined;
21
- variantMapping?: Partial<Record<"button" | "caption" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "inherit" | "subtitle1" | "subtitle2" | "body1" | "body2" | "overline" | "@supports (font-variation-settings: normal)", string>> | undefined;
20
+ variant?: import("@mui/types").OverridableStringUnion<"inherit" | import("@mui/material").TypographyVariant, import("@mui/material").TypographyPropsVariantOverrides> | undefined;
21
+ variantMapping?: Partial<Record<import("@mui/types").OverridableStringUnion<"inherit" | import("@mui/material").TypographyVariant, import("@mui/material").TypographyPropsVariantOverrides>, string>> | undefined;
22
22
  } & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
23
23
  ref?: ((instance: HTMLSpanElement | null) => void) | import("react").RefObject<HTMLSpanElement> | null | undefined;
24
24
  }, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "variant" | ("p" | "color" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint") | "align" | "gutterBottom" | "noWrap" | "paragraph" | "variantMapping"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
@@ -22,7 +22,7 @@ const palette = {
22
22
  main: '#0AA65B',
23
23
  },
24
24
  warning: {
25
- main: '#FFE668',
25
+ main: '#FFCC00',
26
26
  },
27
27
  error: {
28
28
  main: '#E5452F',
@@ -1,2 +1,2 @@
1
1
  export declare const name = "@lifi/widget";
2
- export declare const version = "1.32.7";
2
+ export declare const version = "2.0.0-alpha.0";
@@ -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 = '1.32.7';
5
+ exports.version = '2.0.0-alpha.0';
@@ -5,7 +5,11 @@ export * from './useDebouncedWatch';
5
5
  export * from './useDefaultElementId';
6
6
  export * from './useExpandableVariant';
7
7
  export * from './useFeaturedTokens';
8
+ export * from './useFundsSufficiency';
9
+ export * from './useGasRecommendation';
10
+ export * from './useGasRefuel';
8
11
  export * from './useGasSufficiency';
12
+ export * from './useGetTokenBalancesWithRetry';
9
13
  export * from './useInitializer';
10
14
  export * from './useNavigateBack';
11
15
  export * from './useProcessMessage';
@@ -21,7 +21,11 @@ __exportStar(require("./useDebouncedWatch"), exports);
21
21
  __exportStar(require("./useDefaultElementId"), exports);
22
22
  __exportStar(require("./useExpandableVariant"), exports);
23
23
  __exportStar(require("./useFeaturedTokens"), exports);
24
+ __exportStar(require("./useFundsSufficiency"), exports);
25
+ __exportStar(require("./useGasRecommendation"), exports);
26
+ __exportStar(require("./useGasRefuel"), exports);
24
27
  __exportStar(require("./useGasSufficiency"), exports);
28
+ __exportStar(require("./useGetTokenBalancesWithRetry"), exports);
25
29
  __exportStar(require("./useInitializer"), exports);
26
30
  __exportStar(require("./useNavigateBack"), exports);
27
31
  __exportStar(require("./useProcessMessage"), exports);
@@ -7,13 +7,13 @@ const react_hook_form_1 = require("react-hook-form");
7
7
  const providers_1 = require("../providers");
8
8
  const stores_1 = require("../stores");
9
9
  const useChains = () => {
10
- const { disabledChains, chains } = (0, providers_1.useWidgetConfig)();
10
+ const { chains } = (0, providers_1.useWidgetConfig)();
11
11
  const lifi = (0, providers_1.useLiFi)();
12
12
  const { getValues, setValue } = (0, react_hook_form_1.useFormContext)();
13
13
  const initializeChains = (0, stores_1.useChainOrderStore)((state) => state.initializeChains);
14
14
  const { data, isLoading } = (0, react_query_1.useQuery)(['chains'], async () => {
15
15
  const availableChains = await lifi.getChains();
16
- const filteredChains = availableChains.filter((chain) => (0, providers_1.isItemAllowed)(chain.id, chains, disabledChains));
16
+ const filteredChains = availableChains.filter((chain) => (0, providers_1.isItemAllowed)(chain.id, chains));
17
17
  const chainOrder = initializeChains(filteredChains.map((chain) => chain.id));
18
18
  const [fromChainValue, toChainValue] = getValues([
19
19
  providers_1.SwapFormKey.FromChain,
@@ -1 +1 @@
1
- export declare const useFeaturedTokens: (selectedChainId?: number) => import("@lifi/types").Token[];
1
+ export declare const useFeaturedTokens: (selectedChainId?: number) => import("@lifi/types").Token[] | undefined;
@@ -4,7 +4,7 @@ exports.useFeaturedTokens = void 0;
4
4
  const react_1 = require("react");
5
5
  const providers_1 = require("../providers");
6
6
  const useFeaturedTokens = (selectedChainId) => {
7
- const { featuredTokens, tokens } = (0, providers_1.useWidgetConfig)();
8
- return (0, react_1.useMemo)(() => [...(tokens?.featured ?? []), ...(featuredTokens ?? [])].filter((token) => token.chainId === selectedChainId), [featuredTokens, selectedChainId, tokens?.featured]);
7
+ const { tokens } = (0, providers_1.useWidgetConfig)();
8
+ return (0, react_1.useMemo)(() => tokens?.featured?.filter((token) => token.chainId === selectedChainId), [selectedChainId, tokens?.featured]);
9
9
  };
10
10
  exports.useFeaturedTokens = useFeaturedTokens;
@@ -0,0 +1,5 @@
1
+ import type { Route } from '@lifi/sdk';
2
+ export declare const useFundsSufficiency: (route?: Route) => {
3
+ insufficientFunds: boolean | undefined;
4
+ isInitialLoading: boolean;
5
+ };
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useFundsSufficiency = void 0;
4
+ const react_query_1 = require("@tanstack/react-query");
5
+ const big_js_1 = require("big.js");
6
+ const react_hook_form_1 = require("react-hook-form");
7
+ const providers_1 = require("../providers");
8
+ const stores_1 = require("../stores");
9
+ const useGetTokenBalancesWithRetry_1 = require("./useGetTokenBalancesWithRetry");
10
+ const useTokenAddressBalance_1 = require("./useTokenAddressBalance");
11
+ const refetchInterval = 30000;
12
+ const useFundsSufficiency = (route) => {
13
+ const { account, provider } = (0, providers_1.useWallet)();
14
+ const getTokenBalancesWithRetry = (0, useGetTokenBalancesWithRetry_1.useGetTokenBalancesWithRetry)(provider);
15
+ const [fromChainId, fromTokenAddress, fromAmount] = (0, react_hook_form_1.useWatch)({
16
+ name: [
17
+ providers_1.SwapFormKey.FromChain,
18
+ providers_1.SwapFormKey.FromToken,
19
+ providers_1.SwapFormKey.FromAmount,
20
+ ],
21
+ });
22
+ let chainId = fromChainId;
23
+ let tokenAddress = fromTokenAddress;
24
+ if (route) {
25
+ chainId = route.fromToken.chainId;
26
+ tokenAddress = route.fromToken.address;
27
+ }
28
+ const { token, isLoading } = (0, useTokenAddressBalance_1.useTokenAddressBalance)(chainId, tokenAddress);
29
+ const { data: insufficientFunds, isInitialLoading } = (0, react_query_1.useQuery)([
30
+ 'funds-sufficiency-check',
31
+ account.address,
32
+ chainId,
33
+ tokenAddress,
34
+ route?.id ?? fromAmount,
35
+ ], async () => {
36
+ if (!account.address || !token) {
37
+ return;
38
+ }
39
+ let currentTokenBalance = (0, big_js_1.default)(token?.amount || 0);
40
+ if (!route || (0, stores_1.isRouteDone)(route)) {
41
+ const insufficientFunds = currentTokenBalance.lt((0, big_js_1.default)(fromAmount || 0));
42
+ return insufficientFunds;
43
+ }
44
+ const currentAction = route.steps.filter((step) => !step.execution || step.execution.status !== 'DONE')[0]?.action;
45
+ if (token.chainId === currentAction.fromToken.chainId &&
46
+ token.address === currentAction.fromToken.address &&
47
+ currentTokenBalance.gt(0)) {
48
+ const insufficientFunds = (0, big_js_1.default)(route.fromAmount)
49
+ .div(10 ** route.fromToken.decimals)
50
+ .gt(currentTokenBalance);
51
+ return insufficientFunds;
52
+ }
53
+ const tokenBalances = await getTokenBalancesWithRetry(account.address, [
54
+ currentAction.fromToken,
55
+ ]);
56
+ currentTokenBalance = (0, big_js_1.default)(tokenBalances?.[0]?.amount || 0);
57
+ const insufficientFunds = (0, big_js_1.default)(currentAction.fromAmount)
58
+ .div(10 ** currentAction.fromToken.decimals)
59
+ .gt(currentTokenBalance);
60
+ return insufficientFunds;
61
+ }, {
62
+ enabled: Boolean(account.address && token && !isLoading),
63
+ refetchInterval,
64
+ staleTime: refetchInterval,
65
+ cacheTime: refetchInterval,
66
+ keepPreviousData: true,
67
+ });
68
+ return {
69
+ insufficientFunds,
70
+ isInitialLoading,
71
+ };
72
+ };
73
+ exports.useFundsSufficiency = useFundsSufficiency;
@@ -0,0 +1,2 @@
1
+ import type { ChainId } from '@lifi/sdk';
2
+ export declare const useGasRecommendation: (chainId: ChainId, fromChain?: ChainId, fromToken?: string) => import("@tanstack/react-query").UseQueryResult<import("@lifi/sdk").GasRecommendationResponse, unknown>;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useGasRecommendation = void 0;
4
+ const react_query_1 = require("@tanstack/react-query");
5
+ const providers_1 = require("../providers");
6
+ const refetchInterval = 60000;
7
+ const useGasRecommendation = (chainId, fromChain, fromToken) => {
8
+ const lifi = (0, providers_1.useLiFi)();
9
+ return (0, react_query_1.useQuery)(['gas-recommendation', chainId, fromChain, fromToken], async ({ queryKey: [_, chainId, fromChain, fromToken] }) => {
10
+ const gasRecommendation = await lifi.getGasRecommendation({
11
+ chainId: chainId,
12
+ fromChain: fromChain,
13
+ fromToken: fromToken,
14
+ });
15
+ return gasRecommendation;
16
+ }, {
17
+ enabled: Boolean(chainId),
18
+ refetchInterval,
19
+ staleTime: refetchInterval,
20
+ cacheTime: refetchInterval,
21
+ });
22
+ };
23
+ exports.useGasRecommendation = useGasRecommendation;
@@ -0,0 +1,7 @@
1
+ export declare const useGasRefuel: () => {
2
+ enabled: boolean;
3
+ availble: boolean | undefined;
4
+ isLoading: boolean;
5
+ chain: import("@lifi/types").ExtendedChain | undefined;
6
+ gasRecommendation: import("@lifi/types").GasRecommendationResponse | undefined;
7
+ };
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useGasRefuel = void 0;
4
+ const big_js_1 = require("big.js");
5
+ const react_1 = require("react");
6
+ const react_hook_form_1 = require("react-hook-form");
7
+ const _1 = require(".");
8
+ const providers_1 = require("../providers");
9
+ const useGasRecommendation_1 = require("./useGasRecommendation");
10
+ const useTokenBalance_1 = require("./useTokenBalance");
11
+ const useGasRefuel = () => {
12
+ const { getChainById } = (0, _1.useChains)();
13
+ const [fromChainId, fromTokenAddress, toChainId, toTokenAddress, toAddress] = (0, react_hook_form_1.useWatch)({
14
+ name: [
15
+ providers_1.SwapFormKey.FromChain,
16
+ providers_1.SwapFormKey.FromToken,
17
+ providers_1.SwapFormKey.ToChain,
18
+ providers_1.SwapFormKey.ToToken,
19
+ providers_1.SwapFormKey.ToAddress,
20
+ ],
21
+ });
22
+ const toChain = getChainById(toChainId);
23
+ const { token: nativeToken } = (0, useTokenBalance_1.useTokenBalance)(toChainId && toChain?.nativeToken, toAddress);
24
+ const { data: gasRecommendation, isLoading } = (0, useGasRecommendation_1.useGasRecommendation)(toChainId, fromChainId, fromTokenAddress);
25
+ const enabled = (0, react_1.useMemo)(() => {
26
+ if (
27
+ // We don't allow same chain refuel.
28
+ // If a user runs out of gas, he can't send a source chain transaction.
29
+ fromChainId === toChainId ||
30
+ // We don't want to apply auto refuel when swapping to native tokens
31
+ toChain?.nativeToken.address === toTokenAddress ||
32
+ !gasRecommendation?.available ||
33
+ !gasRecommendation.recommended ||
34
+ !nativeToken) {
35
+ return false;
36
+ }
37
+ const tokenBalance = (0, big_js_1.default)(nativeToken.amount ?? 0);
38
+ // check if the user balance < 50% of the recommended amount
39
+ const recommendedAmount = (0, big_js_1.default)(gasRecommendation.recommended.amount)
40
+ .div(10 ** gasRecommendation.recommended.token.decimals)
41
+ .div(2);
42
+ const insufficientGas = tokenBalance.lt(recommendedAmount);
43
+ return insufficientGas;
44
+ }, [
45
+ fromChainId,
46
+ gasRecommendation?.available,
47
+ gasRecommendation?.recommended,
48
+ nativeToken,
49
+ toChain?.nativeToken.address,
50
+ toChainId,
51
+ toTokenAddress,
52
+ ]);
53
+ return {
54
+ enabled: enabled,
55
+ availble: gasRecommendation?.available,
56
+ isLoading: isLoading,
57
+ chain: toChain,
58
+ gasRecommendation,
59
+ };
60
+ };
61
+ exports.useGasRefuel = useGasRefuel;
@@ -9,7 +9,6 @@ export interface GasSufficiency {
9
9
  chain?: EVMChain;
10
10
  }
11
11
  export declare const useGasSufficiency: (route?: Route) => {
12
- insufficientGas: GasSufficiency[] | null | undefined;
13
- insufficientFunds: boolean | null | undefined;
14
- isLoading: boolean;
12
+ insufficientGas: GasSufficiency[] | undefined;
13
+ isInitialLoading: boolean;
15
14
  };
@@ -5,16 +5,14 @@ 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");
9
- const useTokenBalance_1 = require("./useTokenBalance");
10
8
  const refetchInterval = 30000;
11
9
  const useGasSufficiency = (route) => {
12
- const { account } = (0, providers_1.useWallet)();
10
+ const { account, provider } = (0, providers_1.useWallet)();
13
11
  const { getChainById } = (0, _1.useChains)();
14
- const { token: fromToken, getTokenBalancesWithRetry } = (0, useTokenBalance_1.useTokenBalance)(route?.fromToken);
15
- const { data: insufficientGas, isInitialLoading: insufficientGasLoading } = (0, react_query_1.useQuery)(['gas-sufficiency-check', account.address, route?.id], async () => {
12
+ const getTokenBalancesWithRetry = (0, _1.useGetTokenBalancesWithRetry)(provider);
13
+ const { data: insufficientGas, isInitialLoading } = (0, react_query_1.useQuery)(['gas-sufficiency-check', account.address, route?.id], async () => {
16
14
  if (!account.address || !route) {
17
- return null;
15
+ return;
18
16
  }
19
17
  const gasCosts = route.steps
20
18
  .filter((step) => !step.execution || step.execution.status !== 'DONE')
@@ -42,7 +40,7 @@ const useGasSufficiency = (route) => {
42
40
  }
43
41
  const tokenBalances = await getTokenBalancesWithRetry(account.address, Object.values(gasCosts).map((item) => item.token));
44
42
  if (!tokenBalances?.length) {
45
- return null;
43
+ return;
46
44
  }
47
45
  [route.fromChainId, route.toChainId].forEach((chainId) => {
48
46
  if (gasCosts[chainId]) {
@@ -71,38 +69,9 @@ const useGasSufficiency = (route) => {
71
69
  staleTime: refetchInterval,
72
70
  cacheTime: refetchInterval,
73
71
  });
74
- const { data: insufficientFunds, isInitialLoading: insufficientFundsLoading, } = (0, react_query_1.useQuery)(['funds-sufficiency-check', account.address, route?.id], async () => {
75
- if (!account.address || !fromToken || !route || (0, stores_1.isRouteDone)(route)) {
76
- return null;
77
- }
78
- let currentTokenBalance = (0, big_js_1.default)(fromToken?.amount ?? 0);
79
- const currentAction = route.steps.filter((step) => !step.execution || step.execution.status !== 'DONE')[0]?.action;
80
- if (fromToken.chainId === currentAction.fromToken.chainId &&
81
- fromToken.address === currentAction.fromToken.address &&
82
- currentTokenBalance.gt(0)) {
83
- const insufficientFunds = (0, big_js_1.default)(route.fromAmount)
84
- .div(10 ** route.fromToken.decimals)
85
- .gt(currentTokenBalance);
86
- return insufficientFunds;
87
- }
88
- const tokenBalances = await getTokenBalancesWithRetry(account.address, [
89
- currentAction.fromToken,
90
- ]);
91
- currentTokenBalance = (0, big_js_1.default)(tokenBalances?.[0]?.amount ?? 0);
92
- const insufficientFunds = (0, big_js_1.default)(currentAction.fromAmount)
93
- .div(10 ** currentAction.fromToken.decimals)
94
- .gt(currentTokenBalance);
95
- return insufficientFunds;
96
- }, {
97
- enabled: Boolean(account.address && route && fromToken),
98
- refetchInterval,
99
- staleTime: refetchInterval,
100
- cacheTime: refetchInterval,
101
- });
102
72
  return {
103
73
  insufficientGas,
104
- insufficientFunds,
105
- isLoading: insufficientGasLoading || insufficientFundsLoading,
74
+ isInitialLoading,
106
75
  };
107
76
  };
108
77
  exports.useGasSufficiency = useGasSufficiency;
@@ -0,0 +1,3 @@
1
+ import type { Provider } from '@ethersproject/providers';
2
+ import type { Token, TokenAmount } from '@lifi/sdk';
3
+ export declare const useGetTokenBalancesWithRetry: (provider?: Provider) => (accountAddress: string, tokens: Token[], depth?: number) => Promise<TokenAmount[] | undefined>;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useGetTokenBalancesWithRetry = void 0;
4
+ const address_1 = require("@ethersproject/address");
5
+ const react_1 = require("react");
6
+ const providers_1 = require("../providers");
7
+ const useGetTokenBalancesWithRetry = (provider) => {
8
+ const lifi = (0, providers_1.useLiFi)();
9
+ const getTokenBalancesWithRetry = (0, react_1.useCallback)(async (accountAddress, tokens, depth = 0) => {
10
+ try {
11
+ const walletAddress = (0, address_1.isAddress)(accountAddress)
12
+ ? accountAddress
13
+ : await provider?.resolveName(accountAddress);
14
+ const tokenBalances = await lifi.getTokenBalances(walletAddress, tokens);
15
+ if (!tokenBalances.every((token) => token.blockNumber)) {
16
+ if (depth > 10) {
17
+ console.warn('Token balance backoff depth exceeded.');
18
+ return undefined;
19
+ }
20
+ await new Promise((resolve) => {
21
+ setTimeout(resolve, 1.5 ** depth * 100);
22
+ });
23
+ return getTokenBalancesWithRetry(accountAddress, tokens, depth + 1);
24
+ }
25
+ return tokenBalances;
26
+ }
27
+ catch (error) {
28
+ //
29
+ }
30
+ }, [lifi, provider]);
31
+ return getTokenBalancesWithRetry;
32
+ };
33
+ exports.useGetTokenBalancesWithRetry = useGetTokenBalancesWithRetry;
@@ -1,10 +1,15 @@
1
1
  import type { Route, RoutesResponse } from '@lifi/sdk';
2
- export declare const useSwapRoutes: () => {
2
+ interface SwapRoutesProps {
3
+ onSettled?: (data?: RoutesResponse) => void;
4
+ insurableRoute?: Route;
5
+ }
6
+ export declare const useSwapRoutes: ({ onSettled, insurableRoute, }?: SwapRoutesProps) => {
3
7
  routes: Route[] | undefined;
4
8
  isLoading: boolean;
5
9
  isFetching: boolean;
6
10
  isFetched: boolean;
7
11
  dataUpdatedAt: number;
8
12
  refetchTime: number;
9
- refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<RoutesResponse, any>>;
13
+ refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<RoutesResponse, unknown>>;
10
14
  };
15
+ export {};