@lifi/widget 1.15.1 → 1.17.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 (346) hide show
  1. package/App.js +21 -0
  2. package/AppProvider.d.ts +0 -4
  3. package/AppProvider.js +2 -10
  4. package/README.md +1 -1
  5. package/cjs/App.js +21 -0
  6. package/cjs/AppProvider.d.ts +0 -4
  7. package/cjs/AppProvider.js +3 -12
  8. package/cjs/components/ActiveSwaps/ActiveSwapItem.d.ts +5 -0
  9. package/cjs/components/ActiveSwaps/ActiveSwapItem.js +45 -0
  10. package/cjs/components/{SwapsInProgress/SwapsInProgress.d.ts → ActiveSwaps/ActiveSwaps.d.ts} +1 -1
  11. package/cjs/components/ActiveSwaps/ActiveSwaps.js +30 -0
  12. package/cjs/components/ActiveSwaps/ActiveSwaps.style.d.ts +78 -0
  13. package/cjs/components/ActiveSwaps/ActiveSwaps.style.js +40 -0
  14. package/cjs/components/ActiveSwaps/index.d.ts +2 -0
  15. package/cjs/components/ActiveSwaps/index.js +18 -0
  16. package/cjs/components/AppContainer.js +2 -2
  17. package/cjs/components/Card/Card.d.ts +7 -4
  18. package/cjs/components/Card/Card.js +38 -28
  19. package/cjs/{pages/SelectTokenPage → components/ChainSelect}/ChainSelect.d.ts +0 -0
  20. package/cjs/components/ChainSelect/ChainSelect.js +35 -0
  21. package/cjs/components/{SwapsInProgress/SwapsInProgress.style.d.ts → ChainSelect/ChainSelect.style.d.ts} +10 -19
  22. package/cjs/components/ChainSelect/ChainSelect.style.js +19 -0
  23. package/cjs/components/ChainSelect/index.d.ts +2 -0
  24. package/cjs/components/ChainSelect/index.js +18 -0
  25. package/cjs/components/ChainSelect/useChainSelect.d.ts +8 -0
  26. package/cjs/components/ChainSelect/useChainSelect.js +33 -0
  27. package/cjs/components/GasSufficiencyMessage/GasSufficiencyMessage.js +3 -3
  28. package/cjs/components/Header/Header.js +1 -9
  29. package/cjs/components/Header/NavigationHeader.js +6 -11
  30. package/cjs/components/Header/useHeaderActionStore.d.ts +0 -2
  31. package/cjs/components/Header/useHeaderActionStore.js +1 -5
  32. package/cjs/components/PoweredBy/PoweredBy.style.d.ts +1 -1
  33. package/cjs/components/PoweredBy/PoweredBy.style.js +1 -0
  34. package/cjs/components/SelectChainAndToken.js +5 -5
  35. package/cjs/components/SendToWallet/SendToWallet.js +6 -6
  36. package/cjs/components/Step/CircularProgress.js +1 -1
  37. package/cjs/components/Step/CircularProgress.style.js +1 -1
  38. package/cjs/components/Step/StepProcess.js +1 -5
  39. package/cjs/components/Step/StepProcess.style.d.ts +1 -1
  40. package/cjs/components/Step/StepTimer.d.ts +1 -0
  41. package/cjs/components/Step/StepTimer.js +6 -6
  42. package/cjs/components/SwapButton/SwapButton.js +5 -32
  43. package/cjs/components/SwapButton/types.d.ts +2 -2
  44. package/cjs/components/SwapRouteCard/SwapRouteCard.js +1 -1
  45. package/cjs/components/TokenAvatar/TokenAvatar.style.js +0 -3
  46. package/cjs/components/TokenList/TokenList.js +7 -3
  47. package/cjs/components/TokenList/TokenList.style.js +4 -3
  48. package/cjs/components/TokenList/TokenListItem.js +1 -1
  49. package/cjs/components/TokenList/TokenNotFound.d.ts +2 -1
  50. package/cjs/components/TokenList/TokenNotFound.js +12 -2
  51. package/cjs/components/TokenList/types.d.ts +2 -2
  52. package/cjs/config/theme.js +24 -23
  53. package/cjs/config/version.d.ts +1 -1
  54. package/cjs/config/version.js +1 -1
  55. package/cjs/hooks/index.d.ts +2 -0
  56. package/cjs/hooks/index.js +2 -0
  57. package/cjs/hooks/useChains.d.ts +1 -97
  58. package/cjs/hooks/useChains.js +26 -20
  59. package/cjs/hooks/useFeaturedTokens.d.ts +1 -1
  60. package/cjs/hooks/useFeaturedTokens.js +6 -3
  61. package/cjs/hooks/useGasSufficiency.d.ts +1 -1
  62. package/cjs/hooks/useGasSufficiency.js +36 -28
  63. package/cjs/hooks/useInitializer.js +6 -0
  64. package/cjs/{components/Step/utils.d.ts → hooks/useProcessMessage.d.ts} +4 -0
  65. package/cjs/{components/Step/utils.js → hooks/useProcessMessage.js} +16 -10
  66. package/cjs/hooks/useRouteExecution.d.ts +1 -1
  67. package/cjs/hooks/useRouteExecution.js +26 -35
  68. package/cjs/hooks/useSwapRoutes.js +10 -11
  69. package/cjs/hooks/useToken.d.ts +0 -1
  70. package/cjs/hooks/useToken.js +1 -2
  71. package/cjs/hooks/useTokenBalances.d.ts +1 -2
  72. package/cjs/hooks/useTokenBalances.js +5 -6
  73. package/cjs/hooks/useTokenSearch.js +3 -2
  74. package/cjs/hooks/useTokens.d.ts +1 -2
  75. package/cjs/hooks/useTokens.js +32 -9
  76. package/cjs/hooks/useTools.js +11 -5
  77. package/cjs/hooks/useWidgetEvents.d.ts +3 -0
  78. package/cjs/hooks/useWidgetEvents.js +13 -0
  79. package/cjs/i18n/en/translation.json +14 -10
  80. package/cjs/i18n/index.d.ts +11 -7
  81. package/cjs/index.d.ts +1 -0
  82. package/cjs/index.js +3 -1
  83. package/cjs/pages/ActiveSwapsPage/ActiveSwapsEmpty.d.ts +2 -0
  84. package/cjs/pages/ActiveSwapsPage/ActiveSwapsEmpty.js +18 -0
  85. package/cjs/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +2 -0
  86. package/cjs/pages/ActiveSwapsPage/ActiveSwapsPage.js +21 -0
  87. package/cjs/pages/ActiveSwapsPage/index.d.ts +1 -0
  88. package/cjs/{components/SwapsInProgress → pages/ActiveSwapsPage}/index.js +1 -1
  89. package/cjs/pages/MainPage/MainPage.js +2 -3
  90. package/cjs/pages/MainPage/MainSwapButton.js +3 -1
  91. package/cjs/pages/MainPage/SwapRoutes.js +4 -1
  92. package/cjs/pages/SelectChainPage/SelectChainPage.d.ts +3 -0
  93. package/cjs/pages/SelectChainPage/SelectChainPage.js +33 -0
  94. package/cjs/pages/SelectChainPage/SelectChainPage.style.d.ts +21 -0
  95. package/cjs/pages/SelectChainPage/SelectChainPage.style.js +20 -0
  96. package/cjs/pages/SelectChainPage/index.d.ts +1 -0
  97. package/cjs/pages/SelectChainPage/index.js +17 -0
  98. package/cjs/pages/SelectTokenPage/SelectTokenPage.d.ts +2 -4
  99. package/cjs/pages/SelectTokenPage/SelectTokenPage.js +2 -2
  100. package/cjs/pages/SelectWalletPage/SelectWalletPage.js +4 -4
  101. package/cjs/pages/SelectWalletPage/SelectWalletPage.style.d.ts +2 -27
  102. package/cjs/pages/SelectWalletPage/SelectWalletPage.style.js +4 -14
  103. package/cjs/pages/SettingsPage/AdvancedPreferences.js +1 -1
  104. package/cjs/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +1 -1
  105. package/cjs/pages/SettingsPage/EnabledBridgesSelect.js +3 -6
  106. package/cjs/pages/SettingsPage/EnabledExchangesSelect.js +3 -5
  107. package/cjs/pages/SettingsPage/GasPriceSelect.js +1 -1
  108. package/cjs/pages/SettingsPage/RoutePrioritySelect.js +6 -2
  109. package/cjs/pages/SettingsPage/ShowDestinationWallet.js +1 -1
  110. package/cjs/pages/SettingsPage/SlippageInput.js +1 -1
  111. package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +3 -4
  112. package/cjs/pages/SwapHistoryPage/SwapHistoryPage.js +2 -3
  113. package/cjs/pages/SwapPage/StatusBottomSheet.js +25 -36
  114. package/cjs/pages/SwapPage/SwapPage.js +16 -3
  115. package/cjs/pages/SwapRoutesPage/SwapRoutesPage.js +4 -3
  116. package/cjs/providers/SDKProvider/SDKProvider.d.ts +4 -0
  117. package/cjs/providers/SDKProvider/SDKProvider.js +27 -0
  118. package/cjs/providers/SDKProvider/index.d.ts +1 -0
  119. package/cjs/providers/SDKProvider/index.js +17 -0
  120. package/cjs/providers/SwapFormProvider/SwapFormProvider.js +4 -30
  121. package/cjs/providers/SwapFormProvider/types.d.ts +5 -5
  122. package/cjs/providers/TelemetryProvider/TelemetryProvider.d.ts +4 -0
  123. package/cjs/providers/TelemetryProvider/TelemetryProvider.js +11 -0
  124. package/cjs/providers/TelemetryProvider/index.d.ts +1 -0
  125. package/cjs/providers/TelemetryProvider/index.js +17 -0
  126. package/cjs/providers/WalletProvider/WalletProvider.d.ts +1 -4
  127. package/cjs/providers/WalletProvider/WalletProvider.js +59 -1
  128. package/cjs/providers/WidgetProvider/WidgetProvider.js +1 -16
  129. package/cjs/providers/WidgetProvider/index.d.ts +1 -0
  130. package/cjs/providers/WidgetProvider/index.js +1 -0
  131. package/cjs/providers/WidgetProvider/utils.d.ts +4 -0
  132. package/cjs/providers/WidgetProvider/utils.js +13 -0
  133. package/cjs/providers/index.d.ts +2 -0
  134. package/cjs/providers/index.js +2 -0
  135. package/cjs/stores/chains/index.d.ts +3 -0
  136. package/cjs/stores/chains/index.js +19 -0
  137. package/cjs/stores/chains/types.d.ts +8 -0
  138. package/cjs/stores/chains/types.js +2 -0
  139. package/cjs/stores/chains/useChainOrder.d.ts +1 -0
  140. package/cjs/stores/chains/useChainOrder.js +12 -0
  141. package/cjs/stores/chains/useChainOrderStore.d.ts +19 -0
  142. package/cjs/stores/chains/useChainOrderStore.js +45 -0
  143. package/cjs/stores/route/index.d.ts +2 -1
  144. package/cjs/stores/route/index.js +2 -1
  145. package/cjs/stores/route/useExecutingRoutesIds.d.ts +1 -0
  146. package/cjs/stores/route/useExecutingRoutesIds.js +20 -0
  147. package/cjs/stores/route/useRouteStore.js +5 -4
  148. package/cjs/stores/route/utils.d.ts +4 -0
  149. package/cjs/stores/route/utils.js +21 -0
  150. package/cjs/stores/settings/index.d.ts +0 -1
  151. package/cjs/stores/settings/index.js +0 -1
  152. package/cjs/stores/settings/useAppearance.js +3 -1
  153. package/cjs/stores/settings/useSettingsStore.js +5 -2
  154. package/cjs/types/events.d.ts +5 -0
  155. package/cjs/types/events.js +9 -0
  156. package/cjs/types/index.d.ts +1 -0
  157. package/cjs/types/index.js +1 -0
  158. package/cjs/types/widget.d.ts +31 -23
  159. package/cjs/utils/colors.d.ts +1 -1
  160. package/cjs/utils/navigationRoutes.d.ts +5 -0
  161. package/cjs/utils/navigationRoutes.js +31 -4
  162. package/components/ActiveSwaps/ActiveSwapItem.d.ts +5 -0
  163. package/components/ActiveSwaps/ActiveSwapItem.js +41 -0
  164. package/components/{SwapsInProgress/SwapsInProgress.d.ts → ActiveSwaps/ActiveSwaps.d.ts} +1 -1
  165. package/components/ActiveSwaps/ActiveSwaps.js +26 -0
  166. package/components/ActiveSwaps/ActiveSwaps.style.d.ts +78 -0
  167. package/components/ActiveSwaps/ActiveSwaps.style.js +37 -0
  168. package/components/ActiveSwaps/index.d.ts +2 -0
  169. package/components/ActiveSwaps/index.js +2 -0
  170. package/components/AppContainer.js +1 -1
  171. package/components/Card/Card.d.ts +7 -4
  172. package/components/Card/Card.js +39 -29
  173. package/{pages/SelectTokenPage → components/ChainSelect}/ChainSelect.d.ts +0 -0
  174. package/components/ChainSelect/ChainSelect.js +31 -0
  175. package/components/{SwapsInProgress/SwapsInProgress.style.d.ts → ChainSelect/ChainSelect.style.d.ts} +10 -19
  176. package/components/ChainSelect/ChainSelect.style.js +16 -0
  177. package/components/ChainSelect/index.d.ts +2 -0
  178. package/components/ChainSelect/index.js +2 -0
  179. package/components/ChainSelect/useChainSelect.d.ts +8 -0
  180. package/components/ChainSelect/useChainSelect.js +29 -0
  181. package/components/GasSufficiencyMessage/GasSufficiencyMessage.js +3 -3
  182. package/components/Header/Header.js +1 -9
  183. package/components/Header/NavigationHeader.js +6 -11
  184. package/components/Header/useHeaderActionStore.d.ts +0 -2
  185. package/components/Header/useHeaderActionStore.js +0 -3
  186. package/components/PoweredBy/PoweredBy.style.d.ts +1 -1
  187. package/components/PoweredBy/PoweredBy.style.js +1 -0
  188. package/components/SelectChainAndToken.js +1 -1
  189. package/components/SendToWallet/SendToWallet.js +6 -6
  190. package/components/Step/CircularProgress.js +3 -3
  191. package/components/Step/CircularProgress.style.js +1 -1
  192. package/components/Step/StepProcess.js +2 -6
  193. package/components/Step/StepProcess.style.d.ts +1 -1
  194. package/components/Step/StepTimer.d.ts +1 -0
  195. package/components/Step/StepTimer.js +6 -6
  196. package/components/SwapButton/SwapButton.js +7 -34
  197. package/components/SwapButton/types.d.ts +2 -2
  198. package/components/SwapRouteCard/SwapRouteCard.js +1 -1
  199. package/components/TokenAvatar/TokenAvatar.style.js +0 -3
  200. package/components/TokenList/TokenList.js +7 -3
  201. package/components/TokenList/TokenList.style.js +4 -3
  202. package/components/TokenList/TokenListItem.js +1 -1
  203. package/components/TokenList/TokenNotFound.d.ts +2 -1
  204. package/components/TokenList/TokenNotFound.js +12 -2
  205. package/components/TokenList/types.d.ts +2 -2
  206. package/config/theme.js +24 -23
  207. package/config/version.d.ts +1 -1
  208. package/config/version.js +1 -1
  209. package/hooks/index.d.ts +2 -0
  210. package/hooks/index.js +2 -0
  211. package/hooks/useChains.d.ts +1 -97
  212. package/hooks/useChains.js +26 -20
  213. package/hooks/useFeaturedTokens.d.ts +1 -1
  214. package/hooks/useFeaturedTokens.js +6 -3
  215. package/hooks/useGasSufficiency.d.ts +1 -1
  216. package/hooks/useGasSufficiency.js +32 -24
  217. package/hooks/useInitializer.js +6 -0
  218. package/{components/Step/utils.d.ts → hooks/useProcessMessage.d.ts} +4 -0
  219. package/{pages/SwapPage/utils.js → hooks/useProcessMessage.js} +15 -10
  220. package/hooks/useRouteExecution.d.ts +1 -1
  221. package/hooks/useRouteExecution.js +26 -35
  222. package/hooks/useSwapRoutes.js +3 -4
  223. package/hooks/useToken.d.ts +0 -1
  224. package/hooks/useToken.js +1 -2
  225. package/hooks/useTokenBalances.d.ts +1 -2
  226. package/hooks/useTokenBalances.js +4 -5
  227. package/hooks/useTokenSearch.js +3 -2
  228. package/hooks/useTokens.d.ts +1 -2
  229. package/hooks/useTokens.js +32 -9
  230. package/hooks/useTools.js +11 -5
  231. package/hooks/useWidgetEvents.d.ts +3 -0
  232. package/hooks/useWidgetEvents.js +6 -0
  233. package/i18n/en/translation.json +14 -10
  234. package/i18n/index.d.ts +11 -7
  235. package/index.d.ts +1 -0
  236. package/index.js +1 -0
  237. package/package.json +15 -14
  238. package/pages/ActiveSwapsPage/ActiveSwapsEmpty.d.ts +2 -0
  239. package/pages/ActiveSwapsPage/ActiveSwapsEmpty.js +14 -0
  240. package/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +2 -0
  241. package/pages/ActiveSwapsPage/ActiveSwapsPage.js +17 -0
  242. package/pages/ActiveSwapsPage/index.d.ts +1 -0
  243. package/pages/ActiveSwapsPage/index.js +1 -0
  244. package/pages/MainPage/MainPage.js +2 -3
  245. package/pages/MainPage/MainSwapButton.js +3 -1
  246. package/pages/MainPage/SwapRoutes.js +4 -1
  247. package/pages/SelectChainPage/SelectChainPage.d.ts +3 -0
  248. package/pages/SelectChainPage/SelectChainPage.js +29 -0
  249. package/pages/SelectChainPage/SelectChainPage.style.d.ts +21 -0
  250. package/pages/SelectChainPage/SelectChainPage.style.js +17 -0
  251. package/pages/SelectChainPage/index.d.ts +1 -0
  252. package/pages/SelectChainPage/index.js +1 -0
  253. package/pages/SelectTokenPage/SelectTokenPage.d.ts +2 -4
  254. package/pages/SelectTokenPage/SelectTokenPage.js +2 -2
  255. package/pages/SelectWalletPage/SelectWalletPage.js +5 -5
  256. package/pages/SelectWalletPage/SelectWalletPage.style.d.ts +2 -27
  257. package/pages/SelectWalletPage/SelectWalletPage.style.js +4 -14
  258. package/pages/SettingsPage/AdvancedPreferences.js +2 -2
  259. package/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +1 -1
  260. package/pages/SettingsPage/EnabledBridgesSelect.js +4 -7
  261. package/pages/SettingsPage/EnabledExchangesSelect.js +4 -6
  262. package/pages/SettingsPage/GasPriceSelect.js +2 -2
  263. package/pages/SettingsPage/RoutePrioritySelect.js +7 -3
  264. package/pages/SettingsPage/ShowDestinationWallet.js +2 -2
  265. package/pages/SettingsPage/SlippageInput.js +2 -2
  266. package/pages/SwapDetailsPage/SwapDetailsPage.js +4 -5
  267. package/pages/SwapHistoryPage/SwapHistoryPage.js +3 -4
  268. package/pages/SwapPage/StatusBottomSheet.js +27 -38
  269. package/pages/SwapPage/SwapPage.js +16 -3
  270. package/pages/SwapRoutesPage/SwapRoutesPage.js +5 -4
  271. package/providers/SDKProvider/SDKProvider.d.ts +4 -0
  272. package/providers/SDKProvider/SDKProvider.js +19 -0
  273. package/providers/SDKProvider/index.d.ts +1 -0
  274. package/providers/SDKProvider/index.js +1 -0
  275. package/providers/SwapFormProvider/SwapFormProvider.js +4 -30
  276. package/providers/SwapFormProvider/types.d.ts +5 -5
  277. package/providers/TelemetryProvider/TelemetryProvider.d.ts +4 -0
  278. package/providers/TelemetryProvider/TelemetryProvider.js +7 -0
  279. package/providers/TelemetryProvider/index.d.ts +1 -0
  280. package/providers/TelemetryProvider/index.js +1 -0
  281. package/providers/WalletProvider/WalletProvider.d.ts +1 -4
  282. package/providers/WalletProvider/WalletProvider.js +59 -1
  283. package/providers/WidgetProvider/WidgetProvider.js +3 -18
  284. package/providers/WidgetProvider/index.d.ts +1 -0
  285. package/providers/WidgetProvider/index.js +1 -0
  286. package/providers/WidgetProvider/utils.d.ts +4 -0
  287. package/providers/WidgetProvider/utils.js +9 -0
  288. package/providers/index.d.ts +2 -0
  289. package/providers/index.js +2 -0
  290. package/stores/chains/index.d.ts +3 -0
  291. package/stores/chains/index.js +3 -0
  292. package/stores/chains/types.d.ts +8 -0
  293. package/stores/chains/types.js +1 -0
  294. package/stores/chains/useChainOrder.d.ts +1 -0
  295. package/stores/chains/useChainOrder.js +5 -0
  296. package/stores/chains/useChainOrderStore.d.ts +19 -0
  297. package/stores/chains/useChainOrderStore.js +39 -0
  298. package/stores/route/index.d.ts +2 -1
  299. package/stores/route/index.js +2 -1
  300. package/stores/route/useExecutingRoutesIds.d.ts +1 -0
  301. package/stores/route/useExecutingRoutesIds.js +13 -0
  302. package/stores/route/useRouteStore.js +5 -4
  303. package/stores/route/utils.d.ts +4 -0
  304. package/stores/route/utils.js +15 -0
  305. package/stores/settings/index.d.ts +0 -1
  306. package/stores/settings/index.js +0 -1
  307. package/stores/settings/useAppearance.js +3 -1
  308. package/stores/settings/useSettingsStore.js +5 -2
  309. package/tsconfig.cjs.tsbuildinfo +1 -1
  310. package/types/events.d.ts +5 -0
  311. package/types/events.js +6 -0
  312. package/types/index.d.ts +1 -0
  313. package/types/index.js +1 -0
  314. package/types/widget.d.ts +31 -23
  315. package/utils/colors.d.ts +1 -1
  316. package/utils/navigationRoutes.d.ts +5 -0
  317. package/utils/navigationRoutes.js +30 -3
  318. package/cjs/components/SwapButton/SwapButton.style.d.ts +0 -65
  319. package/cjs/components/SwapButton/SwapButton.style.js +0 -15
  320. package/cjs/components/SwapsInProgress/SwapsInProgress.js +0 -29
  321. package/cjs/components/SwapsInProgress/SwapsInProgress.style.js +0 -17
  322. package/cjs/components/SwapsInProgress/index.d.ts +0 -1
  323. package/cjs/config/lifi.d.ts +0 -4
  324. package/cjs/config/lifi.js +0 -14
  325. package/cjs/pages/SelectTokenPage/ChainSelect.js +0 -31
  326. package/cjs/pages/SwapPage/utils.d.ts +0 -6
  327. package/cjs/pages/SwapPage/utils.js +0 -93
  328. package/cjs/stores/route/useExecutingRoutes.d.ts +0 -2
  329. package/cjs/stores/route/useExecutingRoutes.js +0 -13
  330. package/cjs/stores/settings/useSetSettings.d.ts +0 -5
  331. package/cjs/stores/settings/useSetSettings.js +0 -12
  332. package/components/Step/utils.js +0 -89
  333. package/components/SwapButton/SwapButton.style.d.ts +0 -65
  334. package/components/SwapButton/SwapButton.style.js +0 -12
  335. package/components/SwapsInProgress/SwapsInProgress.js +0 -25
  336. package/components/SwapsInProgress/SwapsInProgress.style.js +0 -14
  337. package/components/SwapsInProgress/index.d.ts +0 -1
  338. package/components/SwapsInProgress/index.js +0 -1
  339. package/config/lifi.d.ts +0 -4
  340. package/config/lifi.js +0 -7
  341. package/pages/SelectTokenPage/ChainSelect.js +0 -27
  342. package/pages/SwapPage/utils.d.ts +0 -6
  343. package/stores/route/useExecutingRoutes.d.ts +0 -2
  344. package/stores/route/useExecutingRoutes.js +0 -6
  345. package/stores/settings/useSetSettings.d.ts +0 -5
  346. package/stores/settings/useSetSettings.js +0 -5
@@ -3,9 +3,6 @@ import { avatarClasses } from '@mui/material/Avatar';
3
3
  import { badgeClasses } from '@mui/material/Badge';
4
4
  import { styled } from '@mui/material/styles';
5
5
  export const TokenAvatarGroup = styled(AvatarGroup)(({ theme }) => ({
6
- [`& .${avatarClasses.root}`]: {
7
- background: theme.palette.background.paper,
8
- },
9
6
  [`& .${badgeClasses.badge}:last-child .${avatarClasses.root}`]: {
10
7
  marginLeft: theme.spacing(-1),
11
8
  boxSizing: 'border-box',
@@ -32,7 +32,9 @@ export const TokenList = ({ formType, height, onClick, }) => {
32
32
  ? [searchedToken]
33
33
  : filteredTokens;
34
34
  const handleTokenClick = useCallback((tokenAddress) => {
35
- setValue(SwapFormKeyHelper.getTokenKey(formType), tokenAddress);
35
+ setValue(SwapFormKeyHelper.getTokenKey(formType), tokenAddress, {
36
+ shouldDirty: true,
37
+ });
36
38
  setValue(SwapFormKeyHelper.getAmountKey(formType), '');
37
39
  const oppositeFormType = formType === 'from' ? 'to' : 'from';
38
40
  const [selectedOppositeToken, selectedOppositeChain, selectedChain] = getValues([
@@ -42,9 +44,11 @@ export const TokenList = ({ formType, height, onClick, }) => {
42
44
  ]);
43
45
  if (selectedOppositeToken === tokenAddress &&
44
46
  selectedOppositeChain === selectedChain) {
45
- setValue(SwapFormKeyHelper.getTokenKey(oppositeFormType), '');
47
+ setValue(SwapFormKeyHelper.getTokenKey(oppositeFormType), '', {
48
+ shouldDirty: false,
49
+ });
46
50
  }
47
51
  onClick === null || onClick === void 0 ? void 0 : onClick();
48
52
  }, [formType, getValues, onClick, setValue]);
49
- return (_jsxs(Box, Object.assign({ ref: parentRef, style: { height, overflow: 'auto' } }, { children: [!tokens.length && !isLoading ? _jsx(TokenNotFound, {}) : null, _jsx(VirtualizedTokenList, { tokens: tokens, featuredTokensLength: featuredTokens === null || featuredTokens === void 0 ? void 0 : featuredTokens.length, scrollElementRef: parentRef, chainId: selectedChainId, isLoading: isLoading, isBalanceLoading: isBalanceLoading, showBalance: account.isActive, showFeatured: !tokenSearchFilter, onClick: handleTokenClick })] })));
53
+ return (_jsxs(Box, Object.assign({ ref: parentRef, style: { height, overflow: 'auto' } }, { children: [!tokens.length && !isLoading ? (_jsx(TokenNotFound, { formType: formType })) : null, _jsx(VirtualizedTokenList, { tokens: tokens, featuredTokensLength: featuredTokens === null || featuredTokens === void 0 ? void 0 : featuredTokens.length, scrollElementRef: parentRef, chainId: selectedChainId, isLoading: isLoading, isBalanceLoading: isBalanceLoading, showBalance: account.isActive, showFeatured: !tokenSearchFilter, onClick: handleTokenClick })] })));
50
54
  };
@@ -4,7 +4,8 @@ import { styled } from '@mui/material/styles';
4
4
  import { getContrastAlphaColor } from '../../utils';
5
5
  export const ListItemButton = styled(MuiListItemButton)(({ theme }) => ({
6
6
  borderRadius: theme.shape.borderRadiusSecondary,
7
- paddingLeft: theme.spacing(2),
7
+ paddingLeft: theme.spacing(1.5),
8
+ paddingRight: theme.spacing(1.5),
8
9
  height: 64,
9
10
  width: '100%',
10
11
  '&:hover': {
@@ -18,8 +19,8 @@ export const ListItem = styled(MuiListItem)(({ theme }) => ({
18
19
  height: 64,
19
20
  flexDirection: 'column',
20
21
  alignItems: 'flex-start',
21
- padding: theme.spacing(0, 3),
22
+ padding: theme.spacing(0, 1.5),
22
23
  [`.${listItemSecondaryActionClasses.root}`]: {
23
- right: theme.spacing(5),
24
+ right: theme.spacing(3),
24
25
  },
25
26
  }));
@@ -16,7 +16,7 @@ export const TokenListItem = memo(({ onClick, size, start, token, showBalance, i
16
16
  }) }))) : null] })))) : null] })), endAdornment] })));
17
17
  });
18
18
  export const TokenListItemSkeleton = () => {
19
- return (_jsxs(ListItem, Object.assign({ secondaryAction: _jsx(TokenAmountSkeleton, {}), disablePadding: true, sx: { position: 'relative', flexDirection: 'row', alignItems: 'center' } }, { children: [_jsx(ListItemAvatar, { children: _jsx(Skeleton, { variant: "circular", width: 32, height: 32, sx: { marginLeft: 2, marginRight: 2 } }) }), _jsx(ListItemText, { primary: _jsx(Skeleton, { variant: "text", width: 48, height: 20 }), secondary: _jsx(Skeleton, { variant: "text", width: 96, height: 20 }) })] })));
19
+ return (_jsxs(ListItem, Object.assign({ secondaryAction: _jsx(TokenAmountSkeleton, {}), disablePadding: true, sx: { position: 'relative', flexDirection: 'row', alignItems: 'center' } }, { children: [_jsx(ListItemAvatar, { children: _jsx(Skeleton, { variant: "circular", width: 32, height: 32, sx: { marginLeft: 1.5, marginRight: 2 } }) }), _jsx(ListItemText, { primary: _jsx(Skeleton, { variant: "text", width: 48, height: 20 }), secondary: _jsx(Skeleton, { variant: "text", width: 96, height: 20 }) })] })));
20
20
  };
21
21
  export const TokenAmountSkeleton = () => {
22
22
  return (_jsxs(Box, Object.assign({ sx: {
@@ -1,2 +1,3 @@
1
1
  /// <reference types="react" />
2
- export declare const TokenNotFound: React.FC;
2
+ import type { SwapFormTypeProps } from '../../providers';
3
+ export declare const TokenNotFound: React.FC<SwapFormTypeProps>;
@@ -1,9 +1,17 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { SearchOff as SearchOffIcon } from '@mui/icons-material';
3
3
  import { Box, Typography } from '@mui/material';
4
+ import { useWatch } from 'react-hook-form';
4
5
  import { useTranslation } from 'react-i18next';
5
- export const TokenNotFound = () => {
6
+ import { useChains } from '../../hooks';
7
+ import { SwapFormKeyHelper } from '../../providers';
8
+ export const TokenNotFound = ({ formType }) => {
9
+ var _a;
6
10
  const { t } = useTranslation();
11
+ const [selectedChainId] = useWatch({
12
+ name: [SwapFormKeyHelper.getChainKey(formType)],
13
+ });
14
+ const { getChainById } = useChains();
7
15
  return (_jsxs(Box, Object.assign({ sx: {
8
16
  display: 'flex',
9
17
  justifyContent: 'center',
@@ -11,5 +19,7 @@ export const TokenNotFound = () => {
11
19
  flexDirection: 'column',
12
20
  flex: 1,
13
21
  padding: 3,
14
- } }, { children: [_jsx(Typography, Object.assign({ fontSize: 48, lineHeight: 1 }, { children: _jsx(SearchOffIcon, { fontSize: "inherit" }) })), _jsx(Typography, Object.assign({ fontSize: 14, color: "text.secondary", textAlign: "center", mt: 2, px: 2 }, { children: t('swap.couldntFindTokens') }))] })));
22
+ } }, { children: [_jsx(Typography, Object.assign({ fontSize: 48, lineHeight: 1 }, { children: _jsx(SearchOffIcon, { fontSize: "inherit" }) })), _jsx(Typography, Object.assign({ fontSize: 14, color: "text.secondary", textAlign: "center", mt: 2, px: 2 }, { children: t('swap.info.message.emptyTokenList', {
23
+ chainName: (_a = getChainById(selectedChainId)) === null || _a === void 0 ? void 0 : _a.name,
24
+ }) }))] })));
15
25
  };
@@ -1,9 +1,9 @@
1
1
  import type { TokenAmount } from '@lifi/sdk';
2
2
  import type { MutableRefObject } from 'react';
3
- import type { SwapFormDirection } from '../../providers';
3
+ import type { SwapFormType } from '../../providers';
4
4
  import type { Token } from '../../types';
5
5
  export interface TokenListProps {
6
- formType: SwapFormDirection;
6
+ formType: SwapFormType;
7
7
  height: number;
8
8
  onClick?(): void;
9
9
  }
package/config/theme.js CHANGED
@@ -85,7 +85,29 @@ export const createTheme = (mode, theme = {}) => {
85
85
  defaultProps: {
86
86
  disableElevation: true,
87
87
  },
88
- styleOverrides: Object.assign(Object.assign({}, (mode === 'dark'
88
+ styleOverrides: Object.assign({ root: {
89
+ borderRadius: (_v = (_u = theme.shape) === null || _u === void 0 ? void 0 : _u.borderRadiusSecondary) !== null && _v !== void 0 ? _v : shape.borderRadiusSecondary,
90
+ textTransform: 'none',
91
+ fontSize: '1rem',
92
+ '&.Mui-disabled, &.Mui-disabled:hover': {
93
+ color: mode === 'light'
94
+ ? 'rgb(0 0 0 / 70%)'
95
+ : 'rgb(255 255 255 / 70%)',
96
+ cursor: 'not-allowed',
97
+ pointerEvents: 'auto',
98
+ },
99
+ }, contained: {
100
+ '&:hover': {
101
+ color: getContrastRatio(common.white, primaryMainColor) >= 3
102
+ ? common.white
103
+ : common.black,
104
+ },
105
+ }, sizeMedium: {
106
+ padding: '10px 16px',
107
+ [`.${dialogActionsClasses.root} &`]: {
108
+ padding: '6px 12px',
109
+ },
110
+ } }, (mode === 'dark'
89
111
  ? {
90
112
  outlined: {
91
113
  color: primaryLightColor,
@@ -103,28 +125,7 @@ export const createTheme = (mode, theme = {}) => {
103
125
  },
104
126
  },
105
127
  }
106
- : {})), { root: {
107
- borderRadius: (_v = (_u = theme.shape) === null || _u === void 0 ? void 0 : _u.borderRadiusSecondary) !== null && _v !== void 0 ? _v : shape.borderRadiusSecondary,
108
- textTransform: 'none',
109
- fontSize: '1rem',
110
- padding: '10px 16px',
111
- [`.${dialogActionsClasses.root} &`]: {
112
- padding: '6px 12px',
113
- },
114
- '&.Mui-disabled, &.Mui-disabled:hover': {
115
- color: mode === 'light'
116
- ? 'rgb(0 0 0 / 70%)'
117
- : 'rgb(255 255 255 / 70%)',
118
- cursor: 'not-allowed',
119
- pointerEvents: 'auto',
120
- },
121
- }, contained: {
122
- '&:hover': {
123
- color: getContrastRatio(common.white, primaryMainColor) >= 3
124
- ? common.white
125
- : common.black,
126
- },
127
- } }),
128
+ : {})),
128
129
  },
129
130
  MuiIconButton: {
130
131
  styleOverrides: {
@@ -1,2 +1,2 @@
1
1
  export declare const name = "@lifi/widget";
2
- export declare const version = "1.15.1";
2
+ export declare const version = "1.17.0";
package/config/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/widget';
2
- export const version = '1.15.1';
2
+ export const version = '1.17.0';
package/hooks/index.d.ts CHANGED
@@ -6,6 +6,7 @@ export * from './useFeaturedTokens';
6
6
  export * from './useGasSufficiency';
7
7
  export * from './useInitializer';
8
8
  export * from './useNavigateBack';
9
+ export * from './useProcessMessage';
9
10
  export * from './useRouteExecution';
10
11
  export * from './useScrollableContainer';
11
12
  export * from './useSwapRoutes';
@@ -16,3 +17,4 @@ export * from './useTokenBalances';
16
17
  export * from './useTokens';
17
18
  export * from './useTokenSearch';
18
19
  export * from './useTools';
20
+ export * from './useWidgetEvents';
package/hooks/index.js CHANGED
@@ -6,6 +6,7 @@ export * from './useFeaturedTokens';
6
6
  export * from './useGasSufficiency';
7
7
  export * from './useInitializer';
8
8
  export * from './useNavigateBack';
9
+ export * from './useProcessMessage';
9
10
  export * from './useRouteExecution';
10
11
  export * from './useScrollableContainer';
11
12
  export * from './useSwapRoutes';
@@ -16,3 +17,4 @@ export * from './useTokenBalances';
16
17
  export * from './useTokens';
17
18
  export * from './useTokenSearch';
18
19
  export * from './useTools';
20
+ export * from './useWidgetEvents';
@@ -1,101 +1,5 @@
1
1
  export declare const useChains: () => {
2
- error: unknown;
3
- isError: true;
4
- isLoading: false;
5
- isLoadingError: false;
6
- isRefetchError: true;
7
- isSuccess: false;
8
- status: "error";
9
- dataUpdatedAt: number;
10
- errorUpdatedAt: number;
11
- failureCount: number;
12
- errorUpdateCount: number;
13
- isFetched: boolean;
14
- isFetchedAfterMount: boolean;
15
- isFetching: boolean;
16
- isPaused: boolean;
17
- isPlaceholderData: boolean;
18
- isPreviousData: boolean;
19
- isRefetching: boolean;
20
- isStale: boolean;
21
- refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@lifi/types").EVMChain[], unknown>>;
22
- remove: () => void;
23
- fetchStatus: import("@tanstack/react-query").FetchStatus;
24
- chains: import("@lifi/types").EVMChain[] | undefined;
25
- getChainById: (chainId: number) => import("@lifi/types").EVMChain | undefined;
26
- } | {
27
- error: null;
28
- isError: false;
29
- isLoading: false;
30
- isLoadingError: false;
31
- isRefetchError: false;
32
- isSuccess: true;
33
- status: "success";
34
- dataUpdatedAt: number;
35
- errorUpdatedAt: number;
36
- failureCount: number;
37
- errorUpdateCount: number;
38
- isFetched: boolean;
39
- isFetchedAfterMount: boolean;
40
- isFetching: boolean;
41
- isPaused: boolean;
42
- isPlaceholderData: boolean;
43
- isPreviousData: boolean;
44
- isRefetching: boolean;
45
- isStale: boolean;
46
- refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@lifi/types").EVMChain[], unknown>>;
47
- remove: () => void;
48
- fetchStatus: import("@tanstack/react-query").FetchStatus;
49
- chains: import("@lifi/types").EVMChain[] | undefined;
50
- getChainById: (chainId: number) => import("@lifi/types").EVMChain | undefined;
51
- } | {
52
- error: unknown;
53
- isError: true;
54
- isLoading: false;
55
- isLoadingError: true;
56
- isRefetchError: false;
57
- isSuccess: false;
58
- status: "error";
59
- dataUpdatedAt: number;
60
- errorUpdatedAt: number;
61
- failureCount: number;
62
- errorUpdateCount: number;
63
- isFetched: boolean;
64
- isFetchedAfterMount: boolean;
65
- isFetching: boolean;
66
- isPaused: boolean;
67
- isPlaceholderData: boolean;
68
- isPreviousData: boolean;
69
- isRefetching: boolean;
70
- isStale: boolean;
71
- refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@lifi/types").EVMChain[], unknown>>;
72
- remove: () => void;
73
- fetchStatus: import("@tanstack/react-query").FetchStatus;
74
- chains: import("@lifi/types").EVMChain[] | undefined;
75
- getChainById: (chainId: number) => import("@lifi/types").EVMChain | undefined;
76
- } | {
77
- error: null;
78
- isError: false;
79
- isLoading: true;
80
- isLoadingError: false;
81
- isRefetchError: false;
82
- isSuccess: false;
83
- status: "loading";
84
- dataUpdatedAt: number;
85
- errorUpdatedAt: number;
86
- failureCount: number;
87
- errorUpdateCount: number;
88
- isFetched: boolean;
89
- isFetchedAfterMount: boolean;
90
- isFetching: boolean;
91
- isPaused: boolean;
92
- isPlaceholderData: boolean;
93
- isPreviousData: boolean;
94
- isRefetching: boolean;
95
- isStale: boolean;
96
- refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@lifi/types").EVMChain[], unknown>>;
97
- remove: () => void;
98
- fetchStatus: import("@tanstack/react-query").FetchStatus;
99
2
  chains: import("@lifi/types").EVMChain[] | undefined;
100
3
  getChainById: (chainId: number) => import("@lifi/types").EVMChain | undefined;
4
+ isLoading: boolean;
101
5
  };
@@ -7,33 +7,39 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- var __rest = (this && this.__rest) || function (s, e) {
11
- var t = {};
12
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
13
- t[p] = s[p];
14
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
15
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
16
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
17
- t[p[i]] = s[p[i]];
18
- }
19
- return t;
20
- };
21
10
  import { useQuery } from '@tanstack/react-query';
22
11
  import { useCallback } from 'react';
23
- import { LiFi } from '../config/lifi';
24
- import { useWidgetConfig } from '../providers/WidgetProvider';
12
+ import { useFormContext } from 'react-hook-form';
13
+ import { isItemAllowed, SwapFormKey, useLiFi, useWidgetConfig, } from '../providers';
14
+ import { useChainOrderStore } from '../stores/chains';
25
15
  export const useChains = () => {
26
- const { disabledChains } = useWidgetConfig();
27
- const _a = useQuery(['chains'], () => __awaiter(void 0, void 0, void 0, function* () {
28
- const chains = yield LiFi.getChains();
29
- return chains.filter((chain) => !(disabledChains === null || disabledChains === void 0 ? void 0 : disabledChains.includes(chain.id)));
30
- })), { data } = _a, other = __rest(_a, ["data"]);
16
+ const { disabledChains, chains } = useWidgetConfig();
17
+ const lifi = useLiFi();
18
+ const { getValues, setValue } = useFormContext();
19
+ const { data, isLoading } = useQuery(['chains'], () => __awaiter(void 0, void 0, void 0, function* () {
20
+ const availableChains = yield lifi.getChains();
21
+ const filteredChains = availableChains.filter((chain) => isItemAllowed(chain.id, chains, disabledChains));
22
+ const chainOrder = useChainOrderStore
23
+ .getState()
24
+ .initializeChains(filteredChains.map((chain) => chain.id));
25
+ const [fromChainValue, toChainValue] = getValues([
26
+ SwapFormKey.FromChain,
27
+ SwapFormKey.ToChain,
28
+ ]);
29
+ if (!fromChainValue) {
30
+ setValue(SwapFormKey.FromChain, chainOrder[0]);
31
+ }
32
+ if (!toChainValue) {
33
+ setValue(SwapFormKey.ToChain, chainOrder[0]);
34
+ }
35
+ return { availableChains, filteredChains };
36
+ }));
31
37
  const getChainById = useCallback((chainId) => {
32
- const chain = data === null || data === void 0 ? void 0 : data.find((chain) => chain.id === chainId);
38
+ const chain = data === null || data === void 0 ? void 0 : data.availableChains.find((chain) => chain.id === chainId);
33
39
  // if (!chain) {
34
40
  // throw new Error('Chain not found or chainId is invalid.');
35
41
  // }
36
42
  return chain;
37
43
  }, [data]);
38
- return Object.assign({ chains: data, getChainById }, other);
44
+ return { chains: data === null || data === void 0 ? void 0 : data.filteredChains, getChainById, isLoading };
39
45
  };
@@ -1 +1 @@
1
- export declare const useFeaturedTokens: (selectedChainId: number) => import("@lifi/types").Token[] | undefined;
1
+ export declare const useFeaturedTokens: (selectedChainId?: number) => import("@lifi/types").Token[];
@@ -1,6 +1,9 @@
1
1
  import { useMemo } from 'react';
2
- import { useWidgetConfig } from '../providers/WidgetProvider';
2
+ import { useWidgetConfig } from '../providers';
3
3
  export const useFeaturedTokens = (selectedChainId) => {
4
- const { featuredTokens } = useWidgetConfig();
5
- return useMemo(() => featuredTokens === null || featuredTokens === void 0 ? void 0 : featuredTokens.filter((token) => token.chainId === selectedChainId), [featuredTokens, selectedChainId]);
4
+ const { featuredTokens, tokens } = useWidgetConfig();
5
+ return useMemo(() => {
6
+ var _a;
7
+ return [...((_a = tokens === null || tokens === void 0 ? void 0 : tokens.featured) !== null && _a !== void 0 ? _a : []), ...(featuredTokens !== null && featuredTokens !== void 0 ? featuredTokens : [])].filter((token) => token.chainId === selectedChainId);
8
+ }, [featuredTokens, selectedChainId, tokens === null || tokens === void 0 ? void 0 : tokens.featured]);
6
9
  };
@@ -9,7 +9,7 @@ interface GasSufficiency {
9
9
  chain?: EVMChain;
10
10
  }
11
11
  export declare const useGasSufficiency: (route?: Route) => {
12
- insufficientGas: GasSufficiency[];
12
+ insufficientGas: GasSufficiency[] | undefined;
13
13
  insufficientFunds: boolean;
14
14
  };
15
15
  export {};
@@ -1,11 +1,20 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
1
10
  import Big from 'big.js';
2
- import { useMemo } from 'react';
11
+ import { useCallback, useEffect, useMemo, useState } from 'react';
3
12
  import { useWatch } from 'react-hook-form';
4
13
  import { useChains, useDebouncedWatch } from '.';
5
- import { SwapFormKey, SwapFormKeyHelper } from '../providers/SwapFormProvider';
6
- import { useWallet } from '../providers/WalletProvider';
14
+ import { SwapFormKey, SwapFormKeyHelper, useLiFi, useWallet, } from '../providers';
7
15
  import { useTokenBalances } from './useTokenBalances';
8
16
  export const useGasSufficiency = (route) => {
17
+ const lifi = useLiFi();
9
18
  const { account } = useWallet();
10
19
  const [fromChainId, toChainId, fromToken] = useWatch({
11
20
  name: [
@@ -17,20 +26,12 @@ export const useGasSufficiency = (route) => {
17
26
  const fromAmount = useDebouncedWatch(SwapFormKey.FromAmount, 250);
18
27
  const { getChainById } = useChains();
19
28
  const { tokensWithBalance: fromChainTokenBalances } = useTokenBalances(fromChainId);
20
- const { tokensWithBalance: toChainTokenBalances } = useTokenBalances(toChainId);
21
- const insufficientGas = useMemo(() => {
29
+ const [insufficientGas, setInsufficientGas] = useState();
30
+ const checkInsufficientGas = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
22
31
  var _a;
23
- if (!account.isActive ||
24
- !route ||
25
- !fromAmount ||
26
- !fromChainTokenBalances ||
27
- !toChainTokenBalances) {
28
- return [];
32
+ if (!account.isActive || !route || !fromAmount) {
33
+ return;
29
34
  }
30
- const tokenBalancesByChain = {
31
- [fromChainId]: fromChainTokenBalances,
32
- [toChainId]: toChainTokenBalances,
33
- };
34
35
  const gasCosts = route.steps.reduce((groupedGasCosts, step) => {
35
36
  if (step.estimate.gasCosts) {
36
37
  const { token } = step.estimate.gasCosts[0];
@@ -55,30 +56,34 @@ export const useGasSufficiency = (route) => {
55
56
  route.fromToken.address === gasCosts[fromChainId].token.address) {
56
57
  gasCosts[fromChainId].tokenAmount = (_a = gasCosts[fromChainId]) === null || _a === void 0 ? void 0 : _a.gasAmount.plus(Big(fromAmount));
57
58
  }
59
+ const tokenBalances = yield lifi.getTokenBalances(account.address, Object.values(gasCosts).map((item) => item.token));
60
+ if (!(tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.length)) {
61
+ return;
62
+ }
58
63
  [fromChainId, toChainId].forEach((chainId) => {
59
- var _a, _b, _c, _d, _e, _f, _g;
64
+ var _a, _b, _c, _d, _e, _f;
60
65
  if (gasCosts[chainId]) {
61
- const gasTokenBalance = Big((_c = (_b = (_a = tokenBalancesByChain[chainId]) === null || _a === void 0 ? void 0 : _a.find((t) => t.address === gasCosts[chainId].token.address)) === null || _b === void 0 ? void 0 : _b.amount) !== null && _c !== void 0 ? _c : 0);
66
+ const gasTokenBalance = Big((_b = (_a = tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.find((t) => t.address === gasCosts[chainId].token.address)) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : 0);
62
67
  const insufficientFromChainGas = gasTokenBalance.lte(0) ||
63
- gasTokenBalance.lt((_d = gasCosts[chainId].gasAmount) !== null && _d !== void 0 ? _d : Big(0)) ||
64
- gasTokenBalance.lt((_e = gasCosts[chainId].tokenAmount) !== null && _e !== void 0 ? _e : Big(0));
68
+ gasTokenBalance.lt((_c = gasCosts[chainId].gasAmount) !== null && _c !== void 0 ? _c : Big(0)) ||
69
+ gasTokenBalance.lt((_d = gasCosts[chainId].tokenAmount) !== null && _d !== void 0 ? _d : Big(0));
65
70
  const insufficientFromChainGasAmount = insufficientFromChainGas
66
- ? (_g = (_f = gasCosts[chainId].tokenAmount) === null || _f === void 0 ? void 0 : _f.minus(gasTokenBalance)) !== null && _g !== void 0 ? _g : gasCosts[chainId].gasAmount.minus(gasTokenBalance)
71
+ ? (_f = (_e = gasCosts[chainId].tokenAmount) === null || _e === void 0 ? void 0 : _e.minus(gasTokenBalance)) !== null && _f !== void 0 ? _f : gasCosts[chainId].gasAmount.minus(gasTokenBalance)
67
72
  : undefined;
68
73
  gasCosts[chainId] = Object.assign(Object.assign({}, gasCosts[chainId]), { insufficient: insufficientFromChainGas, insufficientAmount: insufficientFromChainGasAmount });
69
74
  }
70
75
  });
71
76
  const gasCostResult = Object.values(gasCosts).filter((gasCost) => gasCost.insufficient);
72
- return gasCostResult;
73
- }, [
77
+ setInsufficientGas(gasCostResult);
78
+ }), [
79
+ account.address,
74
80
  account.isActive,
75
81
  fromAmount,
76
82
  fromChainId,
77
- fromChainTokenBalances,
78
83
  getChainById,
84
+ lifi,
79
85
  route,
80
86
  toChainId,
81
- toChainTokenBalances,
82
87
  ]);
83
88
  const insufficientFunds = useMemo(() => {
84
89
  var _a, _b;
@@ -91,6 +96,9 @@ export const useGasSufficiency = (route) => {
91
96
  const balance = Big((_b = (_a = fromChainTokenBalances === null || fromChainTokenBalances === void 0 ? void 0 : fromChainTokenBalances.find((t) => t.address === fromToken)) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : 0);
92
97
  return Big(fromAmount).gt(balance);
93
98
  }, [account.isActive, fromAmount, fromChainTokenBalances, fromToken]);
99
+ useEffect(() => {
100
+ checkInsufficientGas();
101
+ }, [checkInsufficientGas]);
94
102
  return {
95
103
  insufficientGas,
96
104
  insufficientFunds,
@@ -1,5 +1,11 @@
1
1
  /* eslint-disable no-underscore-dangle */
2
+ import { checkPackageUpdates } from '@lifi/sdk';
3
+ import { useEffect } from 'react';
4
+ import { name, version } from '../config/version';
2
5
  import { useTools } from './useTools';
3
6
  export const useInitializer = () => {
4
7
  useTools();
8
+ useEffect(() => {
9
+ checkPackageUpdates(name, version);
10
+ }, []);
5
11
  };
@@ -1,5 +1,9 @@
1
1
  import type { EVMChain, Process, Step } from '@lifi/sdk';
2
2
  import type { TFunction } from 'react-i18next';
3
+ export declare const useProcessMessage: (step?: Step, process?: Process) => {
4
+ title?: string | undefined;
5
+ message?: string | undefined;
6
+ };
3
7
  export declare function getProcessMessage(t: TFunction<'translation', undefined>, getChainById: (chainId: number) => EVMChain | undefined, step: Step, process: Process): {
4
8
  title?: string;
5
9
  message?: string;
@@ -1,9 +1,14 @@
1
- import { LifiErrorCode, MetaMaskProviderErrorCode } from '@lifi/sdk';
2
- import { formatTokenAmount } from '../../utils';
3
- const formatProcessMessage = (initialMessage, args = {}) => {
4
- return Object.keys(args).reduce((message, key) => {
5
- return message.replace(`{${key}}`, args[key]);
6
- }, initialMessage);
1
+ import { LifiErrorCode } from '@lifi/sdk';
2
+ import { useTranslation } from 'react-i18next';
3
+ import { formatTokenAmount } from '../utils';
4
+ import { useChains } from './useChains';
5
+ export const useProcessMessage = (step, process) => {
6
+ const { t } = useTranslation();
7
+ const { getChainById } = useChains();
8
+ if (!step || !process) {
9
+ return {};
10
+ }
11
+ return getProcessMessage(t, getChainById, step, process);
7
12
  };
8
13
  const processMessages = {
9
14
  TOKEN_ALLOWANCE: {
@@ -12,7 +17,7 @@ const processMessages = {
12
17
  DONE: (t) => t(`swap.process.tokenAllowance.done`),
13
18
  },
14
19
  SWITCH_CHAIN: {
15
- PENDING: (t) => t(`swap.process.switchChain.pending`),
20
+ ACTION_REQUIRED: (t) => t(`swap.process.switchChain.actionRequired`),
16
21
  DONE: (t) => t(`swap.process.switchChain.done`),
17
22
  },
18
23
  SWAP: {
@@ -67,9 +72,9 @@ export function getProcessMessage(t, getChainById, step, process) {
67
72
  title = t(`swap.error.title.slippageTooLarge`);
68
73
  message = t(`swap.error.message.slippageTooLarge`);
69
74
  break;
70
- case MetaMaskProviderErrorCode.userRejectedRequest:
71
- title = t(`swap.error.title.userRejectedSignatureRequest`);
72
- message = t(`swap.error.message.signatureRequired`, {
75
+ case LifiErrorCode.TransactionRejected:
76
+ title = t(`swap.error.title.transactionRejected`);
77
+ message = t(`swap.error.message.transactionRejected`, {
73
78
  amount: formatTokenAmount(step.action.fromAmount, step.action.fromToken.decimals),
74
79
  tokenSymbol: step.action.fromToken.symbol,
75
80
  chainName: (_b = (_a = getChainById(step.action.fromChainId)) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : '',
@@ -1,5 +1,5 @@
1
1
  import type { Route } from '@lifi/sdk';
2
- export declare const useRouteExecution: (routeId: string) => {
2
+ export declare const useRouteExecution: (routeId: string, executeInBackground?: boolean) => {
3
3
  executeRoute: () => void;
4
4
  restartRoute: () => void;
5
5
  deleteRoute: () => void;