@lifi/widget 1.32.8 → 2.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (343) hide show
  1. package/App.js +3 -3
  2. package/AppDrawer.js +4 -3
  3. package/AppDrawer.style.d.ts +5 -5
  4. package/AppProvider.js +4 -3
  5. package/cjs/App.js +3 -3
  6. package/cjs/AppDrawer.js +4 -3
  7. package/cjs/AppDrawer.style.d.ts +5 -5
  8. package/cjs/AppProvider.js +2 -1
  9. package/cjs/components/ActiveSwaps/ActiveSwaps.style.d.ts +5 -5
  10. package/cjs/components/Card/CardIconButton.d.ts +29 -0
  11. package/cjs/components/Card/CardIconButton.js +17 -0
  12. package/cjs/components/Card/CardLabel.d.ts +26 -0
  13. package/cjs/components/Card/CardLabel.js +45 -0
  14. package/cjs/components/Card/CardTitle.d.ts +2 -2
  15. package/cjs/components/Card/index.d.ts +2 -0
  16. package/cjs/components/Card/index.js +2 -0
  17. package/cjs/components/GasMessage/FundsSufficiencyMessage.d.ts +1 -0
  18. package/cjs/components/GasMessage/FundsSufficiencyMessage.js +16 -0
  19. package/cjs/components/{GasSufficiencyMessage/GasSufficiencyMessage.d.ts → GasMessage/GasMessage.d.ts} +4 -2
  20. package/cjs/components/GasMessage/GasMessage.js +19 -0
  21. package/cjs/components/GasMessage/GasMessage.style.d.ts +34 -0
  22. package/cjs/components/GasMessage/GasMessage.style.js +48 -0
  23. package/cjs/components/GasMessage/GasRefuelMessage.d.ts +3 -0
  24. package/cjs/components/GasMessage/GasRefuelMessage.js +26 -0
  25. package/cjs/components/GasMessage/GasSufficiencyMessage.d.ts +7 -0
  26. package/cjs/components/GasMessage/GasSufficiencyMessage.js +21 -0
  27. package/cjs/components/GasMessage/index.d.ts +2 -0
  28. package/cjs/components/GasMessage/index.js +18 -0
  29. package/cjs/components/Header/Header.style.d.ts +6 -6
  30. package/cjs/components/Header/NavigationHeader.js +4 -4
  31. package/cjs/components/Header/WalletHeader.js +5 -5
  32. package/cjs/components/Insurance/Insurance.d.ts +3 -0
  33. package/cjs/components/Insurance/Insurance.js +11 -0
  34. package/cjs/components/Insurance/InsuranceCard.d.ts +3 -0
  35. package/cjs/components/Insurance/InsuranceCard.js +20 -0
  36. package/cjs/components/Insurance/InsuranceCollapsed.d.ts +3 -0
  37. package/cjs/components/Insurance/InsuranceCollapsed.js +32 -0
  38. package/cjs/components/Insurance/index.d.ts +1 -0
  39. package/cjs/components/{GasSufficiencyMessage → Insurance}/index.js +1 -1
  40. package/cjs/components/Insurance/types.d.ts +14 -0
  41. package/cjs/components/Insurance/types.js +2 -0
  42. package/cjs/components/ListItemButton.d.ts +1 -1
  43. package/cjs/components/NFT/NFT.style.d.ts +1 -1
  44. package/cjs/components/PoweredBy/PoweredBy.style.d.ts +3 -12
  45. package/cjs/components/ReverseTokensButton/ReverseTokensButton.style.d.ts +2 -2
  46. package/cjs/components/SendToWallet/SendToWallet.js +31 -25
  47. package/cjs/components/SendToWallet/SendToWallet.style.d.ts +2 -2
  48. package/cjs/components/SendToWallet/SendToWalletButton.js +3 -3
  49. package/cjs/components/SmallAvatar.d.ts +2 -2
  50. package/cjs/components/Step/CircularProgress.style.d.ts +1 -1
  51. package/cjs/components/Step/DestinationWalletAddress.d.ts +2 -2
  52. package/cjs/components/Step/DestinationWalletAddress.js +4 -8
  53. package/cjs/components/Step/GasStepProcess.d.ts +2 -2
  54. package/cjs/components/Step/GasStepProcess.js +3 -3
  55. package/cjs/components/Step/Step.d.ts +2 -2
  56. package/cjs/components/Step/Step.js +6 -8
  57. package/cjs/components/Step/StepList.d.ts +1 -1
  58. package/cjs/components/Step/StepProcess.d.ts +2 -2
  59. package/cjs/components/Step/StepProcess.js +1 -5
  60. package/cjs/components/Step/StepProcess.style.d.ts +3 -39
  61. package/cjs/components/Step/StepTimer.d.ts +2 -2
  62. package/cjs/components/Step/StepTimer.js +1 -1
  63. package/cjs/components/StepActions/StepActions.d.ts +6 -1
  64. package/cjs/components/StepActions/StepActions.js +54 -17
  65. package/cjs/components/StepActions/StepActions.style.d.ts +1 -1
  66. package/cjs/components/StepActions/types.d.ts +2 -2
  67. package/cjs/components/SwapButton/SwapButton.js +2 -2
  68. package/cjs/components/SwapButton/types.d.ts +1 -2
  69. package/cjs/components/SwapInput/SwapInput.style.d.ts +2 -2
  70. package/cjs/components/SwapInput/SwapInputAdornment.style.d.ts +3 -3
  71. package/cjs/components/SwapInput/SwapInputEndAdornment.js +18 -1
  72. package/cjs/components/SwapRouteCard/SwapRouteCard.d.ts +1 -2
  73. package/cjs/components/SwapRouteCard/SwapRouteCard.js +10 -26
  74. package/cjs/components/SwapRouteCard/SwapRouteCard.style.d.ts +4 -36
  75. package/cjs/components/SwapRouteCard/SwapRouteCard.style.js +7 -38
  76. package/cjs/components/SwapRouteCard/SwapRouteCardEssentials.d.ts +3 -0
  77. package/cjs/components/SwapRouteCard/SwapRouteCardEssentials.js +27 -0
  78. package/cjs/components/SwapRouteCard/SwapRouteCardSkeleton.js +5 -5
  79. package/cjs/components/SwapRouteCard/types.d.ts +2 -2
  80. package/cjs/components/SwapRouteCard/utils.d.ts +5 -0
  81. package/cjs/components/SwapRouteCard/utils.js +32 -2
  82. package/cjs/components/SwapRoutes/SwapRoutes.js +3 -12
  83. package/cjs/components/SwapRoutes/SwapRoutesExpanded.js +4 -11
  84. package/cjs/components/SwapRoutes/{SwapRoutes.style.d.ts → SwapRoutesExpanded.style.d.ts} +0 -9
  85. package/cjs/components/SwapRoutes/{SwapRoutes.style.js → SwapRoutesExpanded.style.js} +1 -12
  86. package/cjs/components/Switch.js +4 -4
  87. package/cjs/components/Token/Token.d.ts +2 -2
  88. package/cjs/components/Token/Token.style.d.ts +2 -2
  89. package/cjs/components/TokenList/TokenList.style.d.ts +2 -2
  90. package/cjs/config/theme.js +1 -1
  91. package/cjs/config/version.d.ts +1 -1
  92. package/cjs/config/version.js +1 -1
  93. package/cjs/hooks/index.d.ts +4 -0
  94. package/cjs/hooks/index.js +4 -0
  95. package/cjs/hooks/useChains.js +2 -2
  96. package/cjs/hooks/useFeaturedTokens.d.ts +1 -1
  97. package/cjs/hooks/useFeaturedTokens.js +2 -2
  98. package/cjs/hooks/useFundsSufficiency.d.ts +5 -0
  99. package/cjs/hooks/useFundsSufficiency.js +73 -0
  100. package/cjs/hooks/useGasRecommendation.d.ts +2 -0
  101. package/cjs/hooks/useGasRecommendation.js +23 -0
  102. package/cjs/hooks/useGasRefuel.d.ts +7 -0
  103. package/cjs/hooks/useGasRefuel.js +61 -0
  104. package/cjs/hooks/useGasSufficiency.d.ts +2 -3
  105. package/cjs/hooks/useGasSufficiency.js +6 -37
  106. package/cjs/hooks/useGetTokenBalancesWithRetry.d.ts +3 -0
  107. package/cjs/hooks/useGetTokenBalancesWithRetry.js +33 -0
  108. package/cjs/hooks/useProcessMessage.d.ts +3 -3
  109. package/cjs/hooks/useSwapRoutes.d.ts +7 -2
  110. package/cjs/hooks/useSwapRoutes.js +31 -11
  111. package/cjs/hooks/useTokenAddressBalance.js +4 -2
  112. package/cjs/hooks/useTokenBalance.js +4 -22
  113. package/cjs/hooks/useTokenBalances.d.ts +1 -1
  114. package/cjs/hooks/useTokenSearch.js +2 -2
  115. package/cjs/hooks/useTokens.js +2 -3
  116. package/cjs/i18n/en.json +14 -7
  117. package/cjs/i18n/it.json +6 -2
  118. package/cjs/i18n/pt.json +234 -0
  119. package/cjs/i18n/uk.json +5 -1
  120. package/cjs/icons/InsuraceLogo.d.ts +2 -0
  121. package/cjs/icons/InsuraceLogo.js +11 -0
  122. package/cjs/icons/index.d.ts +1 -0
  123. package/cjs/icons/index.js +1 -0
  124. package/cjs/index.d.ts +0 -6
  125. package/cjs/index.js +1 -6
  126. package/cjs/pages/MainPage/MainGasMessage.d.ts +3 -0
  127. package/cjs/pages/MainPage/MainGasMessage.js +12 -0
  128. package/cjs/pages/MainPage/MainPage.js +3 -2
  129. package/cjs/pages/MainPage/MainSwapButton.js +1 -1
  130. package/cjs/pages/SelectEnabledToolsPage/SelectEnabledToolsPage.style.d.ts +1 -1
  131. package/cjs/pages/SettingsPage/ColorSchemeButtonGroup.js +2 -2
  132. package/cjs/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +2 -2
  133. package/cjs/pages/SettingsPage/EnabledToolsButton.style.d.ts +1 -1
  134. package/cjs/pages/SettingsPage/RoutePrioritySelect.js +1 -1
  135. package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +4 -3
  136. package/cjs/pages/SwapPage/ExchangeRateBottomSheet.d.ts +1 -2
  137. package/cjs/pages/SwapPage/ExchangeRateBottomSheet.js +1 -14
  138. package/cjs/pages/SwapPage/StartSwapButton.d.ts +3 -2
  139. package/cjs/pages/SwapPage/StartSwapButton.js +14 -4
  140. package/cjs/pages/SwapPage/SwapPage.js +18 -7
  141. package/cjs/pages/SwapPage/types.d.ts +9 -0
  142. package/cjs/pages/SwapPage/types.js +2 -0
  143. package/cjs/pages/SwapRoutesPage/SwapRoutesPage.js +1 -1
  144. package/cjs/pages/SwapRoutesPage/SwapRoutesPage.style.d.ts +2 -1
  145. package/cjs/providers/SDKProvider/SDKProvider.d.ts +2 -2
  146. package/cjs/providers/SDKProvider/SDKProvider.js +2 -1
  147. package/cjs/providers/SwapFormProvider/FormUpdater.js +2 -3
  148. package/cjs/providers/SwapFormProvider/SwapFormProvider.js +2 -3
  149. package/cjs/providers/SwapFormProvider/index.d.ts +1 -0
  150. package/cjs/providers/SwapFormProvider/index.js +1 -0
  151. package/cjs/providers/WidgetProvider/WidgetProvider.js +17 -4
  152. package/cjs/providers/WidgetProvider/utils.d.ts +1 -1
  153. package/cjs/providers/WidgetProvider/utils.js +2 -4
  154. package/cjs/stores/StoreProvider.js +1 -1
  155. package/cjs/stores/routes/createRouteExecutionStore.js +3 -2
  156. package/cjs/stores/routes/index.d.ts +0 -1
  157. package/cjs/stores/routes/index.js +0 -1
  158. package/cjs/stores/routes/types.d.ts +1 -5
  159. package/cjs/stores/routes/useSetExecutableRoute.d.ts +1 -1
  160. package/cjs/stores/settings/types.d.ts +1 -0
  161. package/cjs/stores/settings/useSettingsStore.js +1 -0
  162. package/cjs/types/widget.d.ts +5 -10
  163. package/cjs/utils/format.js +4 -1
  164. package/components/ActiveSwaps/ActiveSwaps.style.d.ts +5 -5
  165. package/components/Card/CardIconButton.d.ts +29 -0
  166. package/components/Card/CardIconButton.js +14 -0
  167. package/components/Card/CardLabel.d.ts +26 -0
  168. package/components/Card/CardLabel.js +42 -0
  169. package/components/Card/CardTitle.d.ts +2 -2
  170. package/components/Card/index.d.ts +2 -0
  171. package/components/Card/index.js +2 -0
  172. package/components/GasMessage/FundsSufficiencyMessage.d.ts +1 -0
  173. package/components/GasMessage/FundsSufficiencyMessage.js +12 -0
  174. package/components/{GasSufficiencyMessage/GasSufficiencyMessage.d.ts → GasMessage/GasMessage.d.ts} +4 -2
  175. package/components/GasMessage/GasMessage.js +15 -0
  176. package/components/GasMessage/GasMessage.style.d.ts +34 -0
  177. package/components/GasMessage/GasMessage.style.js +45 -0
  178. package/components/GasMessage/GasRefuelMessage.d.ts +3 -0
  179. package/components/GasMessage/GasRefuelMessage.js +22 -0
  180. package/components/GasMessage/GasSufficiencyMessage.d.ts +7 -0
  181. package/components/GasMessage/GasSufficiencyMessage.js +17 -0
  182. package/components/GasMessage/index.d.ts +2 -0
  183. package/components/GasMessage/index.js +2 -0
  184. package/components/Header/Header.style.d.ts +6 -6
  185. package/components/Header/NavigationHeader.js +4 -4
  186. package/components/Header/WalletHeader.js +6 -6
  187. package/components/Insurance/Insurance.d.ts +3 -0
  188. package/components/Insurance/Insurance.js +7 -0
  189. package/components/Insurance/InsuranceCard.d.ts +3 -0
  190. package/components/Insurance/InsuranceCard.js +16 -0
  191. package/components/Insurance/InsuranceCollapsed.d.ts +3 -0
  192. package/components/Insurance/InsuranceCollapsed.js +28 -0
  193. package/components/Insurance/index.d.ts +1 -0
  194. package/components/Insurance/index.js +1 -0
  195. package/components/Insurance/types.d.ts +14 -0
  196. package/components/Insurance/types.js +1 -0
  197. package/components/ListItemButton.d.ts +1 -1
  198. package/components/NFT/NFT.style.d.ts +1 -1
  199. package/components/PoweredBy/PoweredBy.style.d.ts +3 -12
  200. package/components/ReverseTokensButton/ReverseTokensButton.style.d.ts +2 -2
  201. package/components/SendToWallet/SendToWallet.js +34 -28
  202. package/components/SendToWallet/SendToWallet.style.d.ts +2 -2
  203. package/components/SendToWallet/SendToWalletButton.js +4 -4
  204. package/components/SmallAvatar.d.ts +2 -2
  205. package/components/Step/CircularProgress.style.d.ts +1 -1
  206. package/components/Step/DestinationWalletAddress.d.ts +2 -2
  207. package/components/Step/DestinationWalletAddress.js +4 -8
  208. package/components/Step/GasStepProcess.d.ts +2 -2
  209. package/components/Step/GasStepProcess.js +3 -3
  210. package/components/Step/Step.d.ts +2 -2
  211. package/components/Step/Step.js +6 -8
  212. package/components/Step/StepList.d.ts +1 -1
  213. package/components/Step/StepProcess.d.ts +2 -2
  214. package/components/Step/StepProcess.js +1 -5
  215. package/components/Step/StepProcess.style.d.ts +3 -39
  216. package/components/Step/StepTimer.d.ts +2 -2
  217. package/components/Step/StepTimer.js +1 -1
  218. package/components/StepActions/StepActions.d.ts +6 -1
  219. package/components/StepActions/StepActions.js +51 -16
  220. package/components/StepActions/StepActions.style.d.ts +1 -1
  221. package/components/StepActions/types.d.ts +2 -2
  222. package/components/SwapButton/SwapButton.js +2 -2
  223. package/components/SwapButton/types.d.ts +1 -2
  224. package/components/SwapInput/SwapInput.style.d.ts +2 -2
  225. package/components/SwapInput/SwapInputAdornment.style.d.ts +3 -3
  226. package/components/SwapInput/SwapInputEndAdornment.js +19 -2
  227. package/components/SwapRouteCard/SwapRouteCard.d.ts +1 -2
  228. package/components/SwapRouteCard/SwapRouteCard.js +11 -26
  229. package/components/SwapRouteCard/SwapRouteCard.style.d.ts +4 -36
  230. package/components/SwapRouteCard/SwapRouteCard.style.js +7 -38
  231. package/components/SwapRouteCard/SwapRouteCardEssentials.d.ts +3 -0
  232. package/components/SwapRouteCard/SwapRouteCardEssentials.js +23 -0
  233. package/components/SwapRouteCard/SwapRouteCardSkeleton.js +5 -5
  234. package/components/SwapRouteCard/types.d.ts +2 -2
  235. package/components/SwapRouteCard/utils.d.ts +5 -0
  236. package/components/SwapRouteCard/utils.js +30 -1
  237. package/components/SwapRoutes/SwapRoutes.js +5 -14
  238. package/components/SwapRoutes/SwapRoutesExpanded.js +4 -11
  239. package/components/SwapRoutes/{SwapRoutes.style.d.ts → SwapRoutesExpanded.style.d.ts} +0 -9
  240. package/components/SwapRoutes/{SwapRoutes.style.js → SwapRoutesExpanded.style.js} +1 -12
  241. package/components/Switch.js +5 -5
  242. package/components/Token/Token.d.ts +2 -2
  243. package/components/Token/Token.style.d.ts +2 -2
  244. package/components/TokenList/TokenList.style.d.ts +2 -2
  245. package/config/theme.js +1 -1
  246. package/config/version.d.ts +1 -1
  247. package/config/version.js +1 -1
  248. package/hooks/index.d.ts +4 -0
  249. package/hooks/index.js +4 -0
  250. package/hooks/useChains.js +2 -2
  251. package/hooks/useFeaturedTokens.d.ts +1 -1
  252. package/hooks/useFeaturedTokens.js +2 -2
  253. package/hooks/useFundsSufficiency.d.ts +5 -0
  254. package/hooks/useFundsSufficiency.js +69 -0
  255. package/hooks/useGasRecommendation.d.ts +2 -0
  256. package/hooks/useGasRecommendation.js +19 -0
  257. package/hooks/useGasRefuel.d.ts +7 -0
  258. package/hooks/useGasRefuel.js +57 -0
  259. package/hooks/useGasSufficiency.d.ts +2 -3
  260. package/hooks/useGasSufficiency.js +7 -38
  261. package/hooks/useGetTokenBalancesWithRetry.d.ts +3 -0
  262. package/hooks/useGetTokenBalancesWithRetry.js +29 -0
  263. package/hooks/useProcessMessage.d.ts +3 -3
  264. package/hooks/useSwapRoutes.d.ts +7 -2
  265. package/hooks/useSwapRoutes.js +32 -12
  266. package/hooks/useTokenAddressBalance.js +4 -2
  267. package/hooks/useTokenBalance.js +5 -23
  268. package/hooks/useTokenBalances.d.ts +1 -1
  269. package/hooks/useTokenSearch.js +2 -2
  270. package/hooks/useTokens.js +2 -3
  271. package/i18n/en.json +14 -7
  272. package/i18n/it.json +6 -2
  273. package/i18n/pt.json +234 -0
  274. package/i18n/uk.json +5 -1
  275. package/icons/InsuraceLogo.d.ts +2 -0
  276. package/icons/InsuraceLogo.js +7 -0
  277. package/icons/index.d.ts +1 -0
  278. package/icons/index.js +1 -0
  279. package/index.d.ts +0 -6
  280. package/index.js +0 -5
  281. package/package.json +12 -12
  282. package/pages/ActiveSwapsPage/ActiveSwapsPage.js +2 -2
  283. package/pages/MainPage/MainGasMessage.d.ts +3 -0
  284. package/pages/MainPage/MainGasMessage.js +8 -0
  285. package/pages/MainPage/MainPage.js +3 -2
  286. package/pages/MainPage/MainSwapButton.js +1 -1
  287. package/pages/SelectEnabledToolsPage/SelectEnabledToolsPage.style.d.ts +1 -1
  288. package/pages/SettingsPage/ColorSchemeButtonGroup.js +2 -2
  289. package/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +2 -2
  290. package/pages/SettingsPage/EnabledToolsButton.style.d.ts +1 -1
  291. package/pages/SettingsPage/RoutePrioritySelect.js +1 -1
  292. package/pages/SwapDetailsPage/SwapDetailsPage.js +5 -4
  293. package/pages/SwapHistoryPage/SwapHistoryPage.js +2 -2
  294. package/pages/SwapPage/ExchangeRateBottomSheet.d.ts +1 -2
  295. package/pages/SwapPage/ExchangeRateBottomSheet.js +0 -12
  296. package/pages/SwapPage/StartSwapButton.d.ts +3 -2
  297. package/pages/SwapPage/StartSwapButton.js +13 -4
  298. package/pages/SwapPage/SwapPage.js +21 -10
  299. package/pages/SwapPage/types.d.ts +9 -0
  300. package/pages/SwapPage/types.js +1 -0
  301. package/pages/SwapRoutesPage/SwapRoutesPage.js +1 -1
  302. package/pages/SwapRoutesPage/SwapRoutesPage.style.d.ts +2 -1
  303. package/providers/SDKProvider/SDKProvider.d.ts +2 -2
  304. package/providers/SDKProvider/SDKProvider.js +3 -2
  305. package/providers/SwapFormProvider/FormUpdater.js +2 -3
  306. package/providers/SwapFormProvider/SwapFormProvider.js +2 -3
  307. package/providers/SwapFormProvider/index.d.ts +1 -0
  308. package/providers/SwapFormProvider/index.js +1 -0
  309. package/providers/WidgetProvider/WidgetProvider.js +17 -4
  310. package/providers/WidgetProvider/utils.d.ts +1 -1
  311. package/providers/WidgetProvider/utils.js +2 -4
  312. package/stores/StoreProvider.js +2 -2
  313. package/stores/routes/createRouteExecutionStore.js +3 -2
  314. package/stores/routes/index.d.ts +0 -1
  315. package/stores/routes/index.js +0 -1
  316. package/stores/routes/types.d.ts +1 -5
  317. package/stores/routes/useSetExecutableRoute.d.ts +1 -1
  318. package/stores/settings/types.d.ts +1 -0
  319. package/stores/settings/useSettingsStore.js +1 -0
  320. package/tsconfig.cjs.tsbuildinfo +1 -1
  321. package/types/widget.d.ts +5 -10
  322. package/utils/format.js +4 -1
  323. package/cjs/components/GasSufficiencyMessage/GasSufficiencyMessage.js +0 -31
  324. package/cjs/components/GasSufficiencyMessage/GasSufficiencyMessage.style.d.ts +0 -9
  325. package/cjs/components/GasSufficiencyMessage/GasSufficiencyMessage.style.js +0 -14
  326. package/cjs/components/GasSufficiencyMessage/index.d.ts +0 -1
  327. package/cjs/components/SwapRoutes/useSetRecommendedRoute.d.ts +0 -2
  328. package/cjs/components/SwapRoutes/useSetRecommendedRoute.js +0 -13
  329. package/cjs/config/env.d.ts +0 -3
  330. package/cjs/config/env.js +0 -6
  331. package/cjs/stores/routes/useRecommendedRouteStore.d.ts +0 -10
  332. package/cjs/stores/routes/useRecommendedRouteStore.js +0 -39
  333. package/components/GasSufficiencyMessage/GasSufficiencyMessage.js +0 -27
  334. package/components/GasSufficiencyMessage/GasSufficiencyMessage.style.d.ts +0 -9
  335. package/components/GasSufficiencyMessage/GasSufficiencyMessage.style.js +0 -11
  336. package/components/GasSufficiencyMessage/index.d.ts +0 -1
  337. package/components/GasSufficiencyMessage/index.js +0 -1
  338. package/components/SwapRoutes/useSetRecommendedRoute.d.ts +0 -2
  339. package/components/SwapRoutes/useSetRecommendedRoute.js +0 -9
  340. package/config/env.d.ts +0 -3
  341. package/config/env.js +0 -3
  342. package/stores/routes/useRecommendedRouteStore.d.ts +0 -10
  343. package/stores/routes/useRecommendedRouteStore.js +0 -32
@@ -1,43 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IconButton = exports.Label = void 0;
3
+ exports.IconTypography = void 0;
4
4
  const material_1 = require("@mui/material");
5
5
  const styles_1 = require("@mui/material/styles");
6
- const utils_1 = require("../../utils");
7
- exports.Label = (0, styles_1.styled)(material_1.Typography, {
8
- shouldForwardProp: (prop) => prop !== 'active',
9
- })(({ theme, active }) => ({
10
- backgroundColor: active ? theme.palette.secondary.main : 'transparent',
11
- border: '1px solid',
12
- borderColor: active
13
- ? theme.palette.secondary.main
14
- : theme.palette.mode === 'light'
15
- ? theme.palette.grey[300]
16
- : theme.palette.grey[800],
17
- borderRadius: theme.shape.borderRadiusSecondary,
18
- color: active
19
- ? (0, utils_1.getContrastTextColor)(theme, theme.palette.secondary.main)
20
- : theme.palette.text.secondary,
21
- padding: theme.spacing(0.75),
22
- fontSize: 12,
23
- lineHeight: 1,
24
- fontWeight: '600',
25
- height: 24,
26
- letterSpacing: '0.05rem',
27
- textTransform: 'uppercase',
28
- display: 'inline-flex',
29
- userSelect: 'none',
6
+ exports.IconTypography = (0, styles_1.styled)(material_1.Typography)(({ theme }) => ({
7
+ color: theme.palette.mode === 'light'
8
+ ? (0, styles_1.alpha)(theme.palette.common.black, 0.24)
9
+ : (0, styles_1.alpha)(theme.palette.common.white, 0.32),
10
+ lineHeight: 0,
11
+ marginRight: theme.spacing(0.5),
30
12
  }));
31
- exports.IconButton = (0, styles_1.styled)(material_1.IconButton, {
32
- shouldForwardProp: (prop) => prop !== 'active',
33
- })(({ theme, active }) => {
34
- const backgroundColor = theme.palette.mode === 'light'
35
- ? theme.palette.common.black
36
- : theme.palette.common.white;
37
- return {
38
- backgroundColor: (0, styles_1.alpha)(backgroundColor, 0.04),
39
- '&:hover': {
40
- backgroundColor: (0, styles_1.alpha)(backgroundColor, 0.08),
41
- },
42
- };
43
- });
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import type { SwapRouteCardEssentialsProps } from './types';
3
+ export declare const SwapRouteCardEssentials: React.FC<SwapRouteCardEssentialsProps>;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SwapRouteCardEssentials = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const AccessTimeFilled_1 = require("@mui/icons-material/AccessTimeFilled");
6
+ const EvStation_1 = require("@mui/icons-material/EvStation");
7
+ const Layers_1 = require("@mui/icons-material/Layers");
8
+ const MonetizationOn_1 = require("@mui/icons-material/MonetizationOn");
9
+ const material_1 = require("@mui/material");
10
+ const react_i18next_1 = require("react-i18next");
11
+ const SwapRouteCard_style_1 = require("./SwapRouteCard.style");
12
+ const utils_1 = require("./utils");
13
+ const SwapRouteCardEssentials = ({ route, dense }) => {
14
+ const { t } = (0, react_i18next_1.useTranslation)();
15
+ const executionTimeMinutes = Math.ceil(route.steps
16
+ .map((step) => step.estimate.executionDuration)
17
+ .reduce((duration, x) => duration + x, 0) / 60);
18
+ const gasCostUSD = parseFloat(route.gasCostUSD ?? '') || 0.01;
19
+ const gasCosts = (0, utils_1.getGasCostsBreakdown)(route);
20
+ const feeCosts = (0, utils_1.getFeeCostsBreakdown)(route, false);
21
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", justifyContent: 'space-between', flex: 1, mt: 2, children: [(0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: (0, jsx_runtime_1.jsxs)(material_1.Box, { component: "span", children: [t(`tooltip.estimatedNetworkFee`), gasCosts.map((gas, index) => ((0, jsx_runtime_1.jsxs)(material_1.Typography, { fontSize: 11, children: [gas.amount?.toFixed(9), " ", gas.token.symbol, " (", t(`format.currency`, { value: gas.amountUSD }), ")"] }, `${gas.token.address}${index}`)))] }), placement: "top", enterDelay: 400, arrow: true, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", alignItems: "center", mr: dense ? 0 : 2, children: [(0, jsx_runtime_1.jsx)(SwapRouteCard_style_1.IconTypography, { children: (0, jsx_runtime_1.jsx)(EvStation_1.default, { fontSize: "small" }) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1, children: t(`format.currency`, { value: gasCostUSD }) })] }) }), (0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: (0, jsx_runtime_1.jsxs)(material_1.Box, { component: "span", children: [t(`tooltip.additionalProviderFee`), feeCosts.map((fee, index) => ((0, jsx_runtime_1.jsxs)(material_1.Typography, { fontSize: 11, children: [fee.amount?.toFixed(9), " ", fee.token.symbol, " (", t(`format.currency`, { value: fee.amountUSD }), ")"] }, `${fee.token.address}${index}`)))] }), placement: "top", enterDelay: 400, arrow: true, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", alignItems: "center", mr: dense ? 0 : 2, children: [(0, jsx_runtime_1.jsx)(SwapRouteCard_style_1.IconTypography, { children: (0, jsx_runtime_1.jsx)(MonetizationOn_1.default, { fontSize: "small" }) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1, children: t(`format.currency`, {
22
+ value: feeCosts.reduce((sum, feeCost) => sum + feeCost.amountUSD, 0),
23
+ }) })] }) }), (0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: t(`tooltip.estimatedTime`), placement: "top", enterDelay: 400, arrow: true, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", alignItems: "center", mr: dense ? 0 : 2, children: [(0, jsx_runtime_1.jsx)(SwapRouteCard_style_1.IconTypography, { children: (0, jsx_runtime_1.jsx)(AccessTimeFilled_1.default, { fontSize: "small" }) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1, children: t('swap.estimatedTime', {
24
+ value: executionTimeMinutes,
25
+ }) })] }) }), (0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: t(`tooltip.numberOfSteps`), placement: "top", enterDelay: 400, arrow: true, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", alignItems: "center", children: [(0, jsx_runtime_1.jsx)(SwapRouteCard_style_1.IconTypography, { children: (0, jsx_runtime_1.jsx)(Layers_1.default, { fontSize: "small" }) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1, children: route.steps.length })] }) })] }));
26
+ };
27
+ exports.SwapRouteCardEssentials = SwapRouteCardEssentials;
@@ -6,10 +6,10 @@ const material_1 = require("@mui/material");
6
6
  const providers_1 = require("../../providers");
7
7
  const Card_1 = require("../Card");
8
8
  const SwapRouteCardSkeleton = ({ variant, ...other }) => {
9
- const { variant: widgetVariant, useRecommendedRoute } = (0, providers_1.useWidgetConfig)();
10
- const cardContent = ((0, jsx_runtime_1.jsxs)(material_1.Box, { flex: 1, children: [widgetVariant !== 'refuel' && !useRecommendedRoute ? ((0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", justifyContent: "space-between", alignItems: "center", mb: 2, children: [(0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "rectangular", width: 118, height: 24, sx: (theme) => ({
11
- borderRadius: `${theme.shape.borderRadiusSecondary}px`,
12
- }) }), variant === 'stretched' ? ((0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", children: [(0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", width: 52, height: 24, sx: { marginRight: 2 } }), (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", width: 44, height: 24, sx: { marginRight: 2 } }), (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", width: 32, height: 24 })] })) : null] })) : null, (0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", alignItems: "center", children: [(0, jsx_runtime_1.jsx)(material_1.Box, { mr: 2, children: (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "circular", width: 32, height: 32 }) }), (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", width: 96, height: 32 })] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { ml: 6, display: "flex", alignItems: "center", children: [(0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", width: 102, height: 16, sx: { borderRadius: 0.5 } }), variant === 'stretched' ? ((0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", width: 72, height: 16, sx: { marginLeft: 1 } })) : null] })] }), variant !== 'stretched' ? ((0, jsx_runtime_1.jsxs)(material_1.Box, { mt: 2, display: "flex", justifyContent: "space-between", children: [(0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", width: 48, height: 24 }), (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", width: 48, height: 24 })] })) : null] }));
13
- return widgetVariant === 'refuel' ? (cardContent) : ((0, jsx_runtime_1.jsx)(Card_1.Card, { indented: true, ...other, children: cardContent }));
9
+ const { variant: widgetVariant } = (0, providers_1.useWidgetConfig)();
10
+ const cardContent = ((0, jsx_runtime_1.jsxs)(material_1.Box, { flex: 1, children: [widgetVariant !== 'refuel' ? ((0, jsx_runtime_1.jsx)(material_1.Box, { display: "flex", alignItems: "center", mb: 2, children: (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "rectangular", width: 112, height: 24, sx: (theme) => ({
11
+ borderRadius: `${theme.shape.borderRadius}px`,
12
+ }) }) })) : null, (0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", alignItems: "center", children: [(0, jsx_runtime_1.jsx)(material_1.Box, { mr: 2, children: (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "circular", width: 32, height: 32 }) }), (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", width: 96, height: 32 })] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { ml: 6, display: "flex", alignItems: "center", children: [(0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", width: 102, height: 16 }), (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", width: 72, height: 16, sx: { marginLeft: 1 } })] })] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { mt: 2, display: "flex", justifyContent: "space-between", children: [(0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", width: 64, height: 20 }), (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", width: 64, height: 20 }), (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", width: 48, height: 20 }), (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", width: 32, height: 20 })] })] }));
13
+ return widgetVariant === 'refuel' || variant === 'cardless' ? (cardContent) : ((0, jsx_runtime_1.jsx)(Card_1.Card, { indented: true, ...other, children: cardContent }));
14
14
  };
15
15
  exports.SwapRouteCardSkeleton = SwapRouteCardSkeleton;
@@ -1,7 +1,7 @@
1
1
  import type { Route } from '@lifi/sdk';
2
2
  export interface SwapRouteCardProps {
3
3
  route: Route;
4
- variant?: 'default' | 'stretched' | 'dense';
4
+ variant?: 'default' | 'cardless';
5
5
  active?: boolean;
6
6
  expanded?: boolean;
7
7
  }
@@ -10,5 +10,5 @@ export interface SwapRouteCardEssentialsProps {
10
10
  dense?: boolean;
11
11
  }
12
12
  export interface SwapRouteCardSkeletonProps {
13
- variant?: 'default' | 'stretched' | 'dense';
13
+ variant?: 'default' | 'cardless';
14
14
  }
@@ -5,3 +5,8 @@ export declare const getGasCostsBreakdown: (route: Route) => {
5
5
  amountUSD: number;
6
6
  token: Token;
7
7
  }[];
8
+ export declare const getFeeCostsBreakdown: (route: Route, included?: boolean) => {
9
+ amount: Big;
10
+ amountUSD: number;
11
+ token: Token;
12
+ }[];
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getGasCostsBreakdown = void 0;
3
+ exports.getFeeCostsBreakdown = exports.getGasCostsBreakdown = void 0;
4
4
  const big_js_1 = require("big.js");
5
5
  const getGasCostsBreakdown = (route) => {
6
6
  return Object.values(route.steps.reduce((groupedGasCosts, step) => {
7
- if (step.estimate.gasCosts) {
7
+ if (step.estimate.gasCosts?.length) {
8
8
  const { token } = step.estimate.gasCosts[0];
9
9
  const gasCostAmount = step.estimate.gasCosts
10
10
  .reduce((amount, gasCost) => amount.plus((0, big_js_1.default)(gasCost.amount || 0)), (0, big_js_1.default)(0))
@@ -28,3 +28,33 @@ const getGasCostsBreakdown = (route) => {
28
28
  }, {}));
29
29
  };
30
30
  exports.getGasCostsBreakdown = getGasCostsBreakdown;
31
+ const getFeeCostsBreakdown = (route, included) => {
32
+ return Object.values(route.steps.reduce((groupedFeeCosts, step) => {
33
+ let feeCosts = step.estimate.feeCosts;
34
+ if (typeof included === 'boolean') {
35
+ feeCosts = feeCosts?.filter((feeCost) => feeCost.included === included);
36
+ }
37
+ if (feeCosts?.length) {
38
+ const { token } = feeCosts[0];
39
+ const feeCostAmount = feeCosts
40
+ .reduce((amount, feeCost) => amount.plus((0, big_js_1.default)(feeCost.amount || 0)), (0, big_js_1.default)(0))
41
+ .div(10 ** token.decimals);
42
+ const feeCostAmountUSD = feeCosts.reduce((amount, feeCost) => amount + parseFloat(feeCost.amountUSD || '0'), 0);
43
+ const groupedFeeCost = groupedFeeCosts[token.chainId];
44
+ const amount = groupedFeeCost
45
+ ? groupedFeeCost.amount.plus(feeCostAmount)
46
+ : feeCostAmount;
47
+ const amountUSD = groupedFeeCost
48
+ ? groupedFeeCost.amountUSD + feeCostAmountUSD
49
+ : feeCostAmountUSD;
50
+ groupedFeeCosts[token.chainId] = {
51
+ amount,
52
+ amountUSD,
53
+ token,
54
+ };
55
+ return groupedFeeCosts;
56
+ }
57
+ return groupedFeeCosts;
58
+ }, {}));
59
+ };
60
+ exports.getFeeCostsBreakdown = getFeeCostsBreakdown;
@@ -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,17 +12,11 @@ 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
- const element = (0, react_router_dom_1.useRoutes)([
20
- {
21
- path: '/',
22
- element: null,
23
- },
24
- ]);
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, {}) }) }) }) }));
18
+ const element = (0, react_router_dom_1.useMatch)('/');
19
+ 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
20
  };
27
21
  exports.SwapRoutesExpanded = SwapRoutesExpanded;
28
22
  const SwapRoutesExpandedElement = () => {
@@ -33,7 +27,6 @@ const SwapRoutesExpandedElement = () => {
33
27
  const { isValid, isValidating } = (0, react_hook_form_1.useFormState)();
34
28
  const { routes, isLoading, isFetching, isFetched, dataUpdatedAt, refetchTime, refetch, } = (0, hooks_1.useSwapRoutes)();
35
29
  const currentRoute = routes?.[0];
36
- (0, useSetRecommendedRoute_1.useSetRecommendedRoute)(currentRoute, isFetching);
37
30
  const handleRouteClick = (route) => {
38
31
  if (isValid && !isValidating) {
39
32
  setExecutableRoute(route);
@@ -44,6 +37,6 @@ const SwapRoutesExpandedElement = () => {
44
37
  };
45
38
  const expanded = Boolean(currentRoute || isLoading || isFetching || isFetched);
46
39
  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)))) })] }) }) }) }));
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)))) })] }) }) }) }));
48
41
  };
49
42
  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,
@@ -1,10 +1,10 @@
1
1
  /// <reference types="react" />
2
- import type { Step, TokenAmount } from '@lifi/sdk';
2
+ import type { LifiStep, TokenAmount } from '@lifi/sdk';
3
3
  import type { BoxProps } from '@mui/material';
4
4
  interface TokenProps {
5
5
  token?: TokenAmount;
6
6
  connected?: boolean;
7
- step?: Step;
7
+ step?: LifiStep;
8
8
  disableDescription?: boolean;
9
9
  isLoading?: boolean;
10
10
  }
@@ -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> & {
@@ -17,7 +17,7 @@ export declare const ListItemButton: import("@emotion/styled").StyledComponent<i
17
17
  touchRippleRef?: import("react").Ref<import("@mui/material/ButtonBase/TouchRipple").TouchRippleActions> | undefined;
18
18
  }, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
19
19
  ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
20
- }, "className" | "style" | "classes" | "tabIndex" | "children" | "action" | "centerRipple" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "TouchRippleProps" | "touchRippleRef" | "alignItems" | "autoFocus" | "dense" | "divider" | "selected" | "disableGutters"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
20
+ }, "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
21
  export declare const ListItem: import("@emotion/styled").StyledComponent<{
22
22
  button?: false | undefined;
23
23
  } & import("@mui/material").ListItemBaseProps & {
@@ -35,4 +35,4 @@ export declare const ListItem: import("@emotion/styled").StyledComponent<{
35
35
  } | undefined;
36
36
  } & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "ref"> & {
37
37
  ref?: ((instance: HTMLLIElement | null) => void) | import("react").RefObject<HTMLLIElement> | null | undefined;
38
- }, "button" | "className" | "style" | "classes" | "children" | "disabled" | "sx" | "alignItems" | "autoFocus" | "dense" | "divider" | "components" | "slotProps" | "slots" | "componentsProps" | "selected" | "disableGutters" | "ContainerComponent" | "ContainerProps" | "disablePadding" | "secondaryAction"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
38
+ }, "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>, {}, {}>;
@@ -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.8";
2
+ export declare const version = "2.0.0-alpha.1";
@@ -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.8';
5
+ exports.version = '2.0.0-alpha.1';
@@ -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
+ };