@lifi/widget 1.31.0 → 1.32.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 (413) hide show
  1. package/App.js +4 -16
  2. package/AppDrawer.js +13 -7
  3. package/AppDrawer.style.d.ts +2 -2
  4. package/AppDrawer.style.js +1 -1
  5. package/AppProvider.js +2 -2
  6. package/AppRoutes.js +9 -0
  7. package/cjs/App.js +4 -16
  8. package/cjs/AppDrawer.js +13 -7
  9. package/cjs/AppDrawer.style.d.ts +2 -2
  10. package/cjs/AppDrawer.style.js +1 -1
  11. package/cjs/AppProvider.js +1 -1
  12. package/cjs/AppRoutes.js +9 -0
  13. package/cjs/components/ActiveSwaps/ActiveSwapItem.js +9 -7
  14. package/cjs/components/ActiveSwaps/ActiveSwaps.js +3 -3
  15. package/cjs/components/ActiveSwaps/ActiveSwaps.style.d.ts +3 -3
  16. package/cjs/components/AppContainer.d.ts +2 -2
  17. package/cjs/components/AppContainer.js +1 -1
  18. package/cjs/components/BottomSheet/BottomSheet.d.ts +1 -1
  19. package/cjs/components/BottomSheet/BottomSheet.js +2 -2
  20. package/cjs/components/Card/Card.d.ts +2 -2
  21. package/cjs/components/Card/CardHeader.d.ts +1 -1
  22. package/cjs/components/Card/CardTitle.d.ts +1 -1
  23. package/cjs/components/ChainSelect/ChainSelect.d.ts +0 -1
  24. package/cjs/components/ChainSelect/ChainSelect.js +3 -4
  25. package/cjs/components/ChainSelect/ChainSelect.style.d.ts +3 -3
  26. package/cjs/components/ContractComponent/ContractComponent.js +1 -1
  27. package/cjs/components/Dialog.js +1 -1
  28. package/cjs/components/GasSufficiencyMessage/GasSufficiencyMessage.js +13 -28
  29. package/cjs/components/GasSufficiencyMessage/GasSufficiencyMessage.style.d.ts +1 -1
  30. package/cjs/components/Header/Header.js +1 -1
  31. package/cjs/components/Header/Header.style.d.ts +3 -3
  32. package/cjs/components/Header/NavigationHeader.js +6 -2
  33. package/cjs/components/Header/WalletHeader.js +12 -22
  34. package/cjs/{pages/SelectNativeTokenPage/SelectNativeTokenPage.style.d.ts → components/ListItemButton.d.ts} +1 -2
  35. package/cjs/{pages/SelectWalletPage/SelectWalletPage.style.js → components/ListItemButton.js} +2 -8
  36. package/cjs/components/ListItemText.d.ts +2 -0
  37. package/cjs/{pages/SelectNativeTokenPage/SelectNativeTokenPage.style.js → components/ListItemText.js} +1 -10
  38. package/cjs/components/NFT/NFT.js +2 -14
  39. package/cjs/components/NFT/NFT.style.d.ts +1 -1
  40. package/cjs/components/NotFound.js +2 -2
  41. package/cjs/components/PoweredBy/PoweredBy.js +2 -2
  42. package/cjs/components/PoweredBy/PoweredBy.style.d.ts +1 -1
  43. package/cjs/components/ProgressToNextUpdate/ProgressToNextUpdate.js +5 -17
  44. package/cjs/components/ReverseTokensButton/ReverseTokensButton.js +1 -1
  45. package/cjs/components/ReverseTokensButton/ReverseTokensButton.style.d.ts +1 -1
  46. package/cjs/components/Select.js +1 -0
  47. package/cjs/components/SelectChainAndToken.js +4 -4
  48. package/cjs/components/SelectTokenButton/SelectTokenButton.js +2 -2
  49. package/cjs/components/SelectTokenButton/SelectTokenButton.style.d.ts +1 -1
  50. package/cjs/components/SendToWallet/SendToWallet.js +9 -19
  51. package/cjs/components/SendToWallet/SendToWallet.style.d.ts +1 -1
  52. package/cjs/components/SendToWallet/SendToWalletButton.js +5 -5
  53. package/cjs/components/SmallAvatar.d.ts +3 -3
  54. package/cjs/components/Step/CircularProgress.d.ts +0 -1
  55. package/cjs/components/Step/CircularProgress.js +2 -2
  56. package/cjs/components/Step/CircularProgress.style.d.ts +1 -1
  57. package/cjs/components/Step/DestinationWalletAddress.js +6 -7
  58. package/cjs/components/Step/GasStepProcess.js +8 -8
  59. package/cjs/components/Step/Step.js +4 -5
  60. package/cjs/components/Step/StepList.d.ts +0 -1
  61. package/cjs/components/Step/StepList.js +8 -4
  62. package/cjs/components/Step/StepProcess.js +3 -3
  63. package/cjs/components/Step/StepProcess.style.d.ts +2 -2
  64. package/cjs/components/Step/StepTimer.js +4 -8
  65. package/cjs/components/StepActions/StepActions.js +20 -37
  66. package/cjs/components/StepActions/StepActions.style.d.ts +1 -1
  67. package/cjs/components/StepDivider/StepDivider.style.d.ts +1 -1
  68. package/cjs/components/SwapButton/SwapButton.js +5 -14
  69. package/cjs/components/SwapInput/FormPriceHelperText.js +6 -6
  70. package/cjs/components/SwapInput/SwapInput.js +4 -16
  71. package/cjs/components/SwapInput/SwapInput.style.d.ts +1 -1
  72. package/cjs/components/SwapInput/SwapInputAdornment.style.d.ts +1 -1
  73. package/cjs/components/SwapInput/SwapInputEndAdornment.d.ts +0 -1
  74. package/cjs/components/SwapInput/SwapInputEndAdornment.js +2 -3
  75. package/cjs/components/SwapRouteCard/SwapRouteCard.js +9 -25
  76. package/cjs/components/SwapRouteCard/SwapRouteCard.style.d.ts +2 -2
  77. package/cjs/components/SwapRouteCard/SwapRouteCardSkeleton.js +4 -16
  78. package/cjs/components/SwapRouteCard/SwapRouteNotFoundCard.js +2 -2
  79. package/cjs/components/SwapRouteCard/utils.js +1 -1
  80. package/cjs/components/SwapRoutes/SwapRoutes.js +4 -4
  81. package/cjs/components/SwapRoutes/SwapRoutes.style.d.ts +5 -5
  82. package/cjs/components/SwapRoutes/SwapRoutesExpanded.d.ts +0 -1
  83. package/cjs/components/SwapRoutes/SwapRoutesExpanded.js +3 -3
  84. package/cjs/components/TextFitter/TextFitter.js +3 -3
  85. package/cjs/components/Token/Token.js +19 -33
  86. package/cjs/components/Token/Token.style.d.ts +3 -3
  87. package/cjs/components/TokenAvatar/TokenAvatar.js +6 -7
  88. package/cjs/components/TokenAvatar/TokenAvatar.style.d.ts +2 -2
  89. package/cjs/components/TokenList/TokenList.js +3 -4
  90. package/cjs/components/TokenList/TokenList.style.d.ts +2 -2
  91. package/cjs/components/TokenList/TokenList.style.js +2 -6
  92. package/cjs/components/TokenList/TokenListItem.js +9 -9
  93. package/cjs/components/TokenList/TokenNotFound.js +4 -5
  94. package/cjs/components/TokenList/VirtualizedTokenList.js +10 -11
  95. package/cjs/components/TokenList/useTokenSelect.js +2 -2
  96. package/cjs/config/env.js +1 -1
  97. package/cjs/config/sentry.js +3 -12
  98. package/cjs/config/theme.js +44 -16
  99. package/cjs/config/version.d.ts +1 -1
  100. package/cjs/config/version.js +1 -1
  101. package/cjs/hooks/useChain.js +1 -1
  102. package/cjs/hooks/useChains.js +5 -14
  103. package/cjs/hooks/useContentHeight.js +1 -2
  104. package/cjs/hooks/useFeaturedTokens.js +1 -4
  105. package/cjs/hooks/useGasSufficiency.js +28 -34
  106. package/cjs/hooks/useProcessMessage.js +7 -11
  107. package/cjs/hooks/useRouteExecution.js +17 -28
  108. package/cjs/hooks/useSwapRoutes.js +16 -26
  109. package/cjs/hooks/useToken.js +2 -2
  110. package/cjs/hooks/useTokenAddressBalance.js +1 -2
  111. package/cjs/hooks/useTokenBalance.js +24 -27
  112. package/cjs/hooks/useTokenBalances.d.ts +1 -1
  113. package/cjs/hooks/useTokenBalances.js +8 -20
  114. package/cjs/hooks/useTokenSearch.d.ts +1 -1
  115. package/cjs/hooks/useTokenSearch.js +12 -21
  116. package/cjs/hooks/useTokens.d.ts +1 -1
  117. package/cjs/hooks/useTokens.js +36 -38
  118. package/cjs/hooks/useTools.d.ts +2 -11
  119. package/cjs/hooks/useTools.js +10 -19
  120. package/cjs/i18n/en.json +8 -4
  121. package/cjs/icons/LiFiFullLogo.js +1 -1
  122. package/cjs/icons/LiFiLogo.js +1 -1
  123. package/cjs/icons/LiFiToolLogo.js +1 -1
  124. package/cjs/index.d.ts +1 -0
  125. package/cjs/index.js +2 -0
  126. package/cjs/pages/ActiveSwapsPage/ActiveSwapsEmpty.js +2 -2
  127. package/cjs/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +0 -1
  128. package/cjs/pages/ActiveSwapsPage/ActiveSwapsPage.js +3 -3
  129. package/cjs/pages/MainPage/MainPage.js +1 -1
  130. package/cjs/pages/MainPage/MainPage.style.d.ts +1 -1
  131. package/cjs/pages/MainPage/MainSwapButton.js +3 -12
  132. package/cjs/pages/SelectChainPage/SelectChainPage.js +6 -14
  133. package/cjs/pages/SelectEnabledToolsPage/SelectEnabledToolsPage.d.ts +4 -0
  134. package/cjs/pages/SelectEnabledToolsPage/SelectEnabledToolsPage.js +51 -0
  135. package/cjs/pages/SelectEnabledToolsPage/SelectEnabledToolsPage.style.d.ts +20 -0
  136. package/cjs/pages/SelectEnabledToolsPage/SelectEnabledToolsPage.style.js +8 -0
  137. package/cjs/pages/SelectEnabledToolsPage/index.d.ts +1 -0
  138. package/cjs/pages/SelectEnabledToolsPage/index.js +17 -0
  139. package/cjs/pages/SelectNativeTokenPage/SelectNativeTokenPage.js +4 -3
  140. package/cjs/pages/SelectTokenPage/SearchTokenInput.d.ts +0 -1
  141. package/cjs/pages/SelectTokenPage/SearchTokenInput.js +4 -1
  142. package/cjs/pages/SelectTokenPage/SelectTokenPage.js +2 -3
  143. package/cjs/pages/SelectWalletPage/SelectWalletPage.d.ts +0 -1
  144. package/cjs/pages/SelectWalletPage/SelectWalletPage.js +13 -19
  145. package/cjs/pages/SettingsPage/ColorSchemeButtonGroup.js +3 -3
  146. package/cjs/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +1 -1
  147. package/cjs/pages/SettingsPage/EnabledToolsButton.d.ts +4 -0
  148. package/cjs/pages/SettingsPage/EnabledToolsButton.js +25 -0
  149. package/cjs/pages/{SelectChainPage/SelectChainPage.style.d.ts → SettingsPage/EnabledToolsButton.style.d.ts} +1 -1
  150. package/cjs/pages/{SelectChainPage/SelectChainPage.style.js → SettingsPage/EnabledToolsButton.style.js} +7 -10
  151. package/cjs/pages/SettingsPage/GasPriceSelect.d.ts +0 -1
  152. package/cjs/pages/SettingsPage/GasPriceSelect.js +1 -1
  153. package/cjs/pages/SettingsPage/LanguageSelect.js +5 -6
  154. package/cjs/pages/SettingsPage/ResetSettingsButton.d.ts +2 -0
  155. package/cjs/pages/SettingsPage/ResetSettingsButton.js +27 -0
  156. package/cjs/pages/SettingsPage/RoutePrioritySelect.js +4 -4
  157. package/cjs/pages/SettingsPage/SettingsPage.d.ts +0 -1
  158. package/cjs/pages/SettingsPage/SettingsPage.js +3 -2
  159. package/cjs/pages/SettingsPage/ShowDestinationWallet.d.ts +0 -1
  160. package/cjs/pages/SettingsPage/ShowDestinationWallet.js +3 -3
  161. package/cjs/pages/SettingsPage/SlippageInput.d.ts +0 -1
  162. package/cjs/pages/SettingsPage/SlippageInput.js +3 -3
  163. package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +14 -22
  164. package/cjs/pages/SwapDetailsPage/SwapDetailsPage.style.d.ts +1 -1
  165. package/cjs/pages/SwapHistoryPage/SwapHistoryEmpty.js +2 -2
  166. package/cjs/pages/SwapHistoryPage/SwapHistoryItem.js +9 -7
  167. package/cjs/pages/SwapHistoryPage/SwapHistoryPage.js +2 -2
  168. package/cjs/pages/SwapPage/ExchangeRateBottomSheet.js +21 -26
  169. package/cjs/pages/SwapPage/StartSwapButton.js +1 -1
  170. package/cjs/pages/SwapPage/StatusBottomSheet.js +21 -19
  171. package/cjs/pages/SwapPage/StatusBottomSheet.style.d.ts +2 -2
  172. package/cjs/pages/SwapPage/SwapPage.js +9 -21
  173. package/cjs/pages/SwapPage/SwapPage.style.d.ts +1 -1
  174. package/cjs/pages/SwapPage/TokenValueBottomSheet.js +8 -9
  175. package/cjs/pages/SwapRoutesPage/SwapRoutesPage.js +3 -3
  176. package/cjs/pages/SwapRoutesPage/SwapRoutesPage.style.d.ts +1 -1
  177. package/cjs/providers/I18nProvider/I18nProvider.js +7 -8
  178. package/cjs/providers/SDKProvider/SDKProvider.js +15 -4
  179. package/cjs/providers/SwapFormProvider/SwapFormProvider.js +12 -6
  180. package/cjs/providers/SwapFormProvider/URLSearchParamsBuilder.js +3 -12
  181. package/cjs/providers/TelemetryProvider/TelemetryProvider.js +1 -1
  182. package/cjs/providers/ThemeProvider/ThemeProvider.js +2 -2
  183. package/cjs/providers/WalletProvider/WalletProvider.js +30 -39
  184. package/cjs/providers/WidgetProvider/WidgetProvider.js +18 -23
  185. package/cjs/providers/WidgetProvider/utils.js +2 -3
  186. package/cjs/stores/StoreProvider.js +2 -2
  187. package/cjs/stores/chains/ChainOrderStore.js +2 -14
  188. package/cjs/stores/routes/RouteExecutionStore.js +2 -14
  189. package/cjs/stores/routes/createRouteExecutionStore.js +27 -16
  190. package/cjs/stores/routes/useExecutingRoutesIds.js +2 -5
  191. package/cjs/stores/routes/useSwapHistory.js +3 -6
  192. package/cjs/stores/routes/utils.js +4 -4
  193. package/cjs/stores/settings/SettingsStore.js +10 -20
  194. package/cjs/stores/settings/createSettingsStore.js +29 -25
  195. package/cjs/stores/settings/types.d.ts +6 -6
  196. package/cjs/utils/colors.js +1 -1
  197. package/cjs/utils/format.js +3 -3
  198. package/cjs/utils/index.d.ts +0 -1
  199. package/cjs/utils/index.js +0 -1
  200. package/cjs/utils/navigationRoutes.d.ts +2 -0
  201. package/cjs/utils/navigationRoutes.js +6 -0
  202. package/components/ActiveSwaps/ActiveSwapItem.js +9 -7
  203. package/components/ActiveSwaps/ActiveSwaps.js +3 -3
  204. package/components/ActiveSwaps/ActiveSwaps.style.d.ts +3 -3
  205. package/components/AppContainer.d.ts +2 -2
  206. package/components/AppContainer.js +1 -1
  207. package/components/BottomSheet/BottomSheet.d.ts +1 -1
  208. package/components/BottomSheet/BottomSheet.js +2 -2
  209. package/components/Card/Card.d.ts +2 -2
  210. package/components/Card/CardHeader.d.ts +1 -1
  211. package/components/Card/CardTitle.d.ts +1 -1
  212. package/components/ChainSelect/ChainSelect.d.ts +0 -1
  213. package/components/ChainSelect/ChainSelect.js +3 -4
  214. package/components/ChainSelect/ChainSelect.style.d.ts +3 -3
  215. package/components/ContractComponent/ContractComponent.js +1 -1
  216. package/components/Dialog.js +1 -1
  217. package/components/GasSufficiencyMessage/GasSufficiencyMessage.js +13 -28
  218. package/components/GasSufficiencyMessage/GasSufficiencyMessage.style.d.ts +1 -1
  219. package/components/Header/Header.js +1 -1
  220. package/components/Header/Header.style.d.ts +3 -3
  221. package/components/Header/NavigationHeader.js +6 -2
  222. package/components/Header/WalletHeader.js +12 -22
  223. package/{pages/SelectChainPage/SelectChainPage.style.d.ts → components/ListItemButton.d.ts} +1 -2
  224. package/components/ListItemButton.js +11 -0
  225. package/components/ListItemText.d.ts +2 -0
  226. package/components/ListItemText.js +8 -0
  227. package/components/NFT/NFT.js +2 -14
  228. package/components/NFT/NFT.style.d.ts +1 -1
  229. package/components/NotFound.js +2 -2
  230. package/components/PoweredBy/PoweredBy.js +2 -2
  231. package/components/PoweredBy/PoweredBy.style.d.ts +1 -1
  232. package/components/ProgressToNextUpdate/ProgressToNextUpdate.js +5 -17
  233. package/components/ReverseTokensButton/ReverseTokensButton.js +1 -1
  234. package/components/ReverseTokensButton/ReverseTokensButton.style.d.ts +1 -1
  235. package/components/Select.js +1 -0
  236. package/components/SelectChainAndToken.js +4 -4
  237. package/components/SelectTokenButton/SelectTokenButton.js +2 -2
  238. package/components/SelectTokenButton/SelectTokenButton.style.d.ts +1 -1
  239. package/components/SendToWallet/SendToWallet.js +9 -19
  240. package/components/SendToWallet/SendToWallet.style.d.ts +1 -1
  241. package/components/SendToWallet/SendToWalletButton.js +5 -5
  242. package/components/SmallAvatar.d.ts +3 -3
  243. package/components/Step/CircularProgress.d.ts +0 -1
  244. package/components/Step/CircularProgress.js +2 -2
  245. package/components/Step/CircularProgress.style.d.ts +1 -1
  246. package/components/Step/DestinationWalletAddress.js +6 -7
  247. package/components/Step/GasStepProcess.js +8 -8
  248. package/components/Step/Step.js +4 -5
  249. package/components/Step/StepList.d.ts +0 -1
  250. package/components/Step/StepList.js +8 -4
  251. package/components/Step/StepProcess.js +3 -3
  252. package/components/Step/StepProcess.style.d.ts +2 -2
  253. package/components/Step/StepTimer.js +4 -8
  254. package/components/StepActions/StepActions.js +20 -37
  255. package/components/StepActions/StepActions.style.d.ts +1 -1
  256. package/components/StepDivider/StepDivider.style.d.ts +1 -1
  257. package/components/SwapButton/SwapButton.js +5 -14
  258. package/components/SwapInput/FormPriceHelperText.js +6 -6
  259. package/components/SwapInput/SwapInput.js +4 -16
  260. package/components/SwapInput/SwapInput.style.d.ts +1 -1
  261. package/components/SwapInput/SwapInputAdornment.style.d.ts +1 -1
  262. package/components/SwapInput/SwapInputEndAdornment.d.ts +0 -1
  263. package/components/SwapInput/SwapInputEndAdornment.js +2 -3
  264. package/components/SwapRouteCard/SwapRouteCard.js +9 -25
  265. package/components/SwapRouteCard/SwapRouteCard.style.d.ts +2 -2
  266. package/components/SwapRouteCard/SwapRouteCardSkeleton.js +4 -16
  267. package/components/SwapRouteCard/SwapRouteNotFoundCard.js +2 -2
  268. package/components/SwapRouteCard/utils.js +1 -1
  269. package/components/SwapRoutes/SwapRoutes.js +4 -4
  270. package/components/SwapRoutes/SwapRoutes.style.d.ts +5 -5
  271. package/components/SwapRoutes/SwapRoutesExpanded.d.ts +0 -1
  272. package/components/SwapRoutes/SwapRoutesExpanded.js +3 -3
  273. package/components/TextFitter/TextFitter.js +3 -3
  274. package/components/Token/Token.js +19 -33
  275. package/components/Token/Token.style.d.ts +3 -3
  276. package/components/TokenAvatar/TokenAvatar.js +6 -7
  277. package/components/TokenAvatar/TokenAvatar.style.d.ts +2 -2
  278. package/components/TokenList/TokenList.js +3 -4
  279. package/components/TokenList/TokenList.style.d.ts +2 -2
  280. package/components/TokenList/TokenList.style.js +3 -7
  281. package/components/TokenList/TokenListItem.js +9 -9
  282. package/components/TokenList/TokenNotFound.js +4 -5
  283. package/components/TokenList/VirtualizedTokenList.js +10 -11
  284. package/components/TokenList/useTokenSelect.js +2 -2
  285. package/config/env.js +1 -1
  286. package/config/sentry.js +3 -12
  287. package/config/theme.js +44 -16
  288. package/config/version.d.ts +1 -1
  289. package/config/version.js +1 -1
  290. package/hooks/useChain.js +1 -1
  291. package/hooks/useChains.js +5 -14
  292. package/hooks/useContentHeight.js +1 -2
  293. package/hooks/useFeaturedTokens.js +1 -4
  294. package/hooks/useGasSufficiency.js +28 -34
  295. package/hooks/useProcessMessage.js +7 -11
  296. package/hooks/useRouteExecution.js +17 -28
  297. package/hooks/useSwapRoutes.js +16 -26
  298. package/hooks/useToken.js +2 -2
  299. package/hooks/useTokenAddressBalance.js +1 -2
  300. package/hooks/useTokenBalance.js +24 -27
  301. package/hooks/useTokenBalances.d.ts +1 -1
  302. package/hooks/useTokenBalances.js +8 -20
  303. package/hooks/useTokenSearch.d.ts +1 -1
  304. package/hooks/useTokenSearch.js +12 -21
  305. package/hooks/useTokens.d.ts +1 -1
  306. package/hooks/useTokens.js +36 -38
  307. package/hooks/useTools.d.ts +2 -11
  308. package/hooks/useTools.js +10 -19
  309. package/i18n/en.json +8 -4
  310. package/icons/LiFiFullLogo.js +1 -1
  311. package/icons/LiFiLogo.js +1 -1
  312. package/icons/LiFiToolLogo.js +1 -1
  313. package/index.d.ts +1 -0
  314. package/index.js +2 -0
  315. package/package.json +9 -9
  316. package/pages/ActiveSwapsPage/ActiveSwapsEmpty.js +2 -2
  317. package/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +0 -1
  318. package/pages/ActiveSwapsPage/ActiveSwapsPage.js +3 -3
  319. package/pages/MainPage/MainPage.js +1 -1
  320. package/pages/MainPage/MainPage.style.d.ts +1 -1
  321. package/pages/MainPage/MainSwapButton.js +3 -12
  322. package/pages/SelectChainPage/SelectChainPage.js +6 -14
  323. package/pages/SelectEnabledToolsPage/SelectEnabledToolsPage.d.ts +4 -0
  324. package/pages/SelectEnabledToolsPage/SelectEnabledToolsPage.js +47 -0
  325. package/pages/SelectEnabledToolsPage/SelectEnabledToolsPage.style.d.ts +20 -0
  326. package/pages/SelectEnabledToolsPage/SelectEnabledToolsPage.style.js +5 -0
  327. package/pages/SelectEnabledToolsPage/index.d.ts +1 -0
  328. package/pages/SelectEnabledToolsPage/index.js +1 -0
  329. package/pages/SelectNativeTokenPage/SelectNativeTokenPage.js +4 -3
  330. package/pages/SelectTokenPage/SearchTokenInput.d.ts +0 -1
  331. package/pages/SelectTokenPage/SearchTokenInput.js +4 -1
  332. package/pages/SelectTokenPage/SelectTokenPage.js +2 -3
  333. package/pages/SelectWalletPage/SelectWalletPage.d.ts +0 -1
  334. package/pages/SelectWalletPage/SelectWalletPage.js +13 -19
  335. package/pages/SettingsPage/ColorSchemeButtonGroup.js +3 -3
  336. package/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +1 -1
  337. package/pages/SettingsPage/EnabledToolsButton.d.ts +4 -0
  338. package/pages/SettingsPage/EnabledToolsButton.js +21 -0
  339. package/{cjs/pages/SelectWalletPage/SelectWalletPage.style.d.ts → pages/SettingsPage/EnabledToolsButton.style.d.ts} +1 -1
  340. package/pages/SettingsPage/EnabledToolsButton.style.js +14 -0
  341. package/pages/SettingsPage/GasPriceSelect.d.ts +0 -1
  342. package/pages/SettingsPage/GasPriceSelect.js +1 -1
  343. package/pages/SettingsPage/LanguageSelect.js +5 -6
  344. package/pages/SettingsPage/ResetSettingsButton.d.ts +2 -0
  345. package/pages/SettingsPage/ResetSettingsButton.js +23 -0
  346. package/pages/SettingsPage/RoutePrioritySelect.js +4 -4
  347. package/pages/SettingsPage/SettingsPage.d.ts +0 -1
  348. package/pages/SettingsPage/SettingsPage.js +3 -2
  349. package/pages/SettingsPage/ShowDestinationWallet.d.ts +0 -1
  350. package/pages/SettingsPage/ShowDestinationWallet.js +3 -3
  351. package/pages/SettingsPage/SlippageInput.d.ts +0 -1
  352. package/pages/SettingsPage/SlippageInput.js +3 -3
  353. package/pages/SwapDetailsPage/SwapDetailsPage.js +14 -22
  354. package/pages/SwapDetailsPage/SwapDetailsPage.style.d.ts +1 -1
  355. package/pages/SwapHistoryPage/SwapHistoryEmpty.js +2 -2
  356. package/pages/SwapHistoryPage/SwapHistoryItem.js +9 -7
  357. package/pages/SwapHistoryPage/SwapHistoryPage.js +2 -2
  358. package/pages/SwapPage/ExchangeRateBottomSheet.js +21 -26
  359. package/pages/SwapPage/StartSwapButton.js +1 -1
  360. package/pages/SwapPage/StatusBottomSheet.js +21 -19
  361. package/pages/SwapPage/StatusBottomSheet.style.d.ts +2 -2
  362. package/pages/SwapPage/SwapPage.js +9 -21
  363. package/pages/SwapPage/SwapPage.style.d.ts +1 -1
  364. package/pages/SwapPage/TokenValueBottomSheet.js +8 -9
  365. package/pages/SwapRoutesPage/SwapRoutesPage.js +3 -3
  366. package/pages/SwapRoutesPage/SwapRoutesPage.style.d.ts +1 -1
  367. package/providers/I18nProvider/I18nProvider.js +7 -8
  368. package/providers/SDKProvider/SDKProvider.js +15 -4
  369. package/providers/SwapFormProvider/SwapFormProvider.js +12 -6
  370. package/providers/SwapFormProvider/URLSearchParamsBuilder.js +3 -12
  371. package/providers/TelemetryProvider/TelemetryProvider.js +1 -1
  372. package/providers/ThemeProvider/ThemeProvider.js +2 -2
  373. package/providers/WalletProvider/WalletProvider.js +30 -39
  374. package/providers/WidgetProvider/WidgetProvider.js +18 -23
  375. package/providers/WidgetProvider/utils.js +2 -3
  376. package/stores/StoreProvider.js +2 -2
  377. package/stores/chains/ChainOrderStore.js +2 -14
  378. package/stores/routes/RouteExecutionStore.js +2 -14
  379. package/stores/routes/createRouteExecutionStore.js +27 -16
  380. package/stores/routes/useExecutingRoutesIds.js +2 -5
  381. package/stores/routes/useSwapHistory.js +3 -6
  382. package/stores/routes/utils.js +4 -4
  383. package/stores/settings/SettingsStore.js +10 -20
  384. package/stores/settings/createSettingsStore.js +29 -25
  385. package/stores/settings/types.d.ts +6 -6
  386. package/tsconfig.cjs.tsbuildinfo +1 -1
  387. package/utils/colors.js +1 -1
  388. package/utils/format.js +3 -3
  389. package/utils/index.d.ts +0 -1
  390. package/utils/index.js +0 -1
  391. package/utils/navigationRoutes.d.ts +2 -0
  392. package/utils/navigationRoutes.js +6 -0
  393. package/cjs/pages/SettingsPage/AdvancedPreferences.d.ts +0 -2
  394. package/cjs/pages/SettingsPage/AdvancedPreferences.js +0 -24
  395. package/cjs/pages/SettingsPage/EnabledBridgesSelect.d.ts +0 -2
  396. package/cjs/pages/SettingsPage/EnabledBridgesSelect.js +0 -24
  397. package/cjs/pages/SettingsPage/EnabledExchangesSelect.d.ts +0 -2
  398. package/cjs/pages/SettingsPage/EnabledExchangesSelect.js +0 -24
  399. package/cjs/utils/deepClone.d.ts +0 -1
  400. package/cjs/utils/deepClone.js +0 -7
  401. package/pages/SelectChainPage/SelectChainPage.style.js +0 -17
  402. package/pages/SelectNativeTokenPage/SelectNativeTokenPage.style.d.ts +0 -21
  403. package/pages/SelectNativeTokenPage/SelectNativeTokenPage.style.js +0 -17
  404. package/pages/SelectWalletPage/SelectWalletPage.style.d.ts +0 -21
  405. package/pages/SelectWalletPage/SelectWalletPage.style.js +0 -17
  406. package/pages/SettingsPage/AdvancedPreferences.d.ts +0 -2
  407. package/pages/SettingsPage/AdvancedPreferences.js +0 -20
  408. package/pages/SettingsPage/EnabledBridgesSelect.d.ts +0 -2
  409. package/pages/SettingsPage/EnabledBridgesSelect.js +0 -20
  410. package/pages/SettingsPage/EnabledExchangesSelect.d.ts +0 -2
  411. package/pages/SettingsPage/EnabledExchangesSelect.js +0 -20
  412. package/utils/deepClone.d.ts +0 -1
  413. package/utils/deepClone.js +0 -3
package/config/theme.js CHANGED
@@ -42,10 +42,12 @@ const shape = {
42
42
  borderRadiusSecondary: 8,
43
43
  };
44
44
  export const createTheme = (mode, theme = {}) => {
45
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
46
- const primaryMainColor = (_c = (_b = (_a = theme.palette) === null || _a === void 0 ? void 0 : _a.primary) === null || _b === void 0 ? void 0 : _b.main) !== null && _c !== void 0 ? _c : palette.primary.main;
47
- const primaryLightColor = lighten((_f = (_e = (_d = theme.palette) === null || _d === void 0 ? void 0 : _d.primary) === null || _e === void 0 ? void 0 : _e.main) !== null && _f !== void 0 ? _f : palette.primary.main, 0.5);
48
- const primaryDarkColor = darken((_j = (_h = (_g = theme.palette) === null || _g === void 0 ? void 0 : _g.primary) === null || _h === void 0 ? void 0 : _h.main) !== null && _j !== void 0 ? _j : palette.primary.main, 0.2);
45
+ const primaryMainColor = theme.palette?.primary?.main ??
46
+ palette.primary.main;
47
+ const primaryLightColor = lighten(theme.palette?.primary?.main ??
48
+ palette.primary.main, 0.5);
49
+ const primaryDarkColor = darken(theme.palette?.primary?.main ??
50
+ palette.primary.main, 0.2);
49
51
  const contrastButtonColor = getContrastRatio(common.white, primaryMainColor) >= 3
50
52
  ? common.white
51
53
  : common.black;
@@ -53,17 +55,33 @@ export const createTheme = (mode, theme = {}) => {
53
55
  ? common.white
54
56
  : common.black;
55
57
  return createMuiTheme({
56
- typography: Object.assign({ fontFamily: 'Inter var, Inter, sans-serif' }, theme.typography),
57
- palette: Object.assign(Object.assign(Object.assign(Object.assign({ mode }, palette), (mode === 'light' ? paletteLight : paletteDark)), theme.palette), { primary: {
58
+ typography: {
59
+ fontFamily: 'Inter var, Inter, sans-serif',
60
+ ...theme.typography,
61
+ },
62
+ palette: {
63
+ mode,
64
+ ...palette,
65
+ ...(mode === 'light' ? paletteLight : paletteDark),
66
+ ...theme.palette,
67
+ primary: {
58
68
  main: primaryMainColor,
59
69
  light: primaryLightColor,
60
70
  dark: primaryDarkColor,
61
- }, secondary: {
62
- main: (_m = (_l = (_k = theme.palette) === null || _k === void 0 ? void 0 : _k.secondary) === null || _l === void 0 ? void 0 : _l.main) !== null && _m !== void 0 ? _m : palette.secondary.main,
63
- light: lighten((_q = (_p = (_o = theme.palette) === null || _o === void 0 ? void 0 : _o.secondary) === null || _p === void 0 ? void 0 : _p.main) !== null && _q !== void 0 ? _q : palette.secondary.main, 0.5),
64
- dark: darken((_t = (_s = (_r = theme.palette) === null || _r === void 0 ? void 0 : _r.secondary) === null || _s === void 0 ? void 0 : _s.main) !== null && _t !== void 0 ? _t : palette.secondary.main, 0.2),
65
- } }),
66
- shape: Object.assign(Object.assign({}, shape), theme.shape),
71
+ },
72
+ secondary: {
73
+ main: theme.palette?.secondary?.main ??
74
+ palette.secondary.main,
75
+ light: lighten(theme.palette?.secondary?.main ??
76
+ palette.secondary.main, 0.5),
77
+ dark: darken(theme.palette?.secondary?.main ??
78
+ palette.secondary.main, 0.2),
79
+ },
80
+ },
81
+ shape: {
82
+ ...shape,
83
+ ...theme.shape,
84
+ },
67
85
  breakpoints: {
68
86
  values: {
69
87
  xs: 0,
@@ -76,7 +94,14 @@ export const createTheme = (mode, theme = {}) => {
76
94
  components: {
77
95
  MuiScopedCssBaseline: {
78
96
  styleOverrides: {
79
- root: Object.assign(Object.assign({ fontFamily: 'Inter, sans-serif' }, theme.typography), { '@supports (font-variation-settings: normal)': Object.assign({ fontFamily: 'Inter var, sans-serif' }, theme.typography) }),
97
+ root: {
98
+ fontFamily: 'Inter, sans-serif',
99
+ ...theme.typography,
100
+ '@supports (font-variation-settings: normal)': {
101
+ fontFamily: 'Inter var, sans-serif',
102
+ ...theme.typography,
103
+ },
104
+ },
80
105
  },
81
106
  },
82
107
  MuiButton: {
@@ -85,7 +110,7 @@ export const createTheme = (mode, theme = {}) => {
85
110
  },
86
111
  styleOverrides: {
87
112
  root: {
88
- borderRadius: (_v = (_u = theme.shape) === null || _u === void 0 ? void 0 : _u.borderRadiusSecondary) !== null && _v !== void 0 ? _v : shape.borderRadiusSecondary,
113
+ borderRadius: theme.shape?.borderRadiusSecondary ?? shape.borderRadiusSecondary,
89
114
  textTransform: 'none',
90
115
  fontSize: '1rem',
91
116
  [`&.Mui-disabled, &.Mui-disabled:hover`]: {
@@ -142,12 +167,15 @@ export const createTheme = (mode, theme = {}) => {
142
167
  },
143
168
  },
144
169
  },
145
- MuiAvatar: Object.assign({ styleOverrides: {
170
+ MuiAvatar: {
171
+ styleOverrides: {
146
172
  root: {
147
173
  height: 32,
148
174
  width: 32,
149
175
  },
150
- } }, (_w = theme.components) === null || _w === void 0 ? void 0 : _w.MuiAvatar),
176
+ },
177
+ ...theme.components?.MuiAvatar,
178
+ },
151
179
  MuiListItemAvatar: {
152
180
  styleOverrides: {
153
181
  root: {
@@ -1,2 +1,2 @@
1
1
  export declare const name = "@lifi/widget";
2
- export declare const version = "1.31.0";
2
+ export declare const version = "1.32.0";
package/config/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/widget';
2
- export const version = '1.31.0';
2
+ export const version = '1.32.0';
package/hooks/useChain.js CHANGED
@@ -3,7 +3,7 @@ import { useChains } from './useChains';
3
3
  export const useChain = (chainId) => {
4
4
  const { chains, isLoading } = useChains();
5
5
  const chain = useMemo(() => {
6
- const chain = chains === null || chains === void 0 ? void 0 : chains.find((chain) => chain.id === chainId);
6
+ const chain = chains?.find((chain) => chain.id === chainId);
7
7
  return chain;
8
8
  }, [chainId, chains]);
9
9
  return {
@@ -1,12 +1,3 @@
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
- };
10
1
  import { useQuery } from '@tanstack/react-query';
11
2
  import { useCallback } from 'react';
12
3
  import { useFormContext } from 'react-hook-form';
@@ -17,8 +8,8 @@ export const useChains = () => {
17
8
  const lifi = useLiFi();
18
9
  const { getValues, setValue } = useFormContext();
19
10
  const initializeChains = useChainOrderStore((state) => state.initializeChains);
20
- const { data, isLoading } = useQuery(['chains'], () => __awaiter(void 0, void 0, void 0, function* () {
21
- const availableChains = yield lifi.getChains();
11
+ const { data, isLoading } = useQuery(['chains'], async () => {
12
+ const availableChains = await lifi.getChains();
22
13
  const filteredChains = availableChains.filter((chain) => isItemAllowed(chain.id, chains, disabledChains));
23
14
  const chainOrder = initializeChains(filteredChains.map((chain) => chain.id));
24
15
  const [fromChainValue, toChainValue] = getValues([
@@ -32,16 +23,16 @@ export const useChains = () => {
32
23
  setValue(SwapFormKey.ToChain, chainOrder[0]);
33
24
  }
34
25
  return { availableChains, filteredChains };
35
- }), {
26
+ }, {
36
27
  refetchInterval: 180000,
37
28
  staleTime: 180000,
38
29
  });
39
30
  const getChainById = useCallback((chainId) => {
40
- const chain = data === null || data === void 0 ? void 0 : data.availableChains.find((chain) => chain.id === chainId);
31
+ const chain = data?.availableChains.find((chain) => chain.id === chainId);
41
32
  // if (!chain) {
42
33
  // throw new Error('Chain not found or chainId is invalid.');
43
34
  // }
44
35
  return chain;
45
36
  }, [data]);
46
- return { chains: data === null || data === void 0 ? void 0 : data.filteredChains, getChainById, isLoading };
37
+ return { chains: data?.filteredChains, getChainById, isLoading };
47
38
  };
@@ -27,11 +27,10 @@ export const useContentHeight = () => {
27
27
  export const useSetContentHeight = (ref) => {
28
28
  const elementId = useDefaultElementId();
29
29
  useLayoutEffect(() => {
30
- var _a;
31
30
  const scrollableContainer = getScrollableContainer(elementId);
32
31
  if (!scrollableContainer ||
33
32
  !ref.current ||
34
- ((_a = ref.current) === null || _a === void 0 ? void 0 : _a.clientHeight) <= (scrollableContainer === null || scrollableContainer === void 0 ? void 0 : scrollableContainer.clientHeight)) {
33
+ ref.current?.clientHeight <= scrollableContainer?.clientHeight) {
35
34
  return;
36
35
  }
37
36
  scrollableContainer.style.height = `${ref.current.clientHeight}px`;
@@ -2,8 +2,5 @@ import { useMemo } from 'react';
2
2
  import { useWidgetConfig } from '../providers';
3
3
  export const useFeaturedTokens = (selectedChainId) => {
4
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]);
5
+ return useMemo(() => [...(tokens?.featured ?? []), ...(featuredTokens ?? [])].filter((token) => token.chainId === selectedChainId), [featuredTokens, selectedChainId, tokens?.featured]);
9
6
  };
@@ -1,12 +1,3 @@
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
- };
10
1
  import { useQuery } from '@tanstack/react-query';
11
2
  import Big from 'big.js';
12
3
  import { useChains } from '.';
@@ -17,9 +8,8 @@ const refetchInterval = 30000;
17
8
  export const useGasSufficiency = (route) => {
18
9
  const { account } = useWallet();
19
10
  const { getChainById } = useChains();
20
- const { token: fromToken, getTokenBalancesWithRetry } = useTokenBalance(route === null || route === void 0 ? void 0 : route.fromToken);
21
- const { data: insufficientGas, isInitialLoading: insufficientGasLoading } = useQuery(['gas-sufficiency-check', account.address, route === null || route === void 0 ? void 0 : route.id], () => __awaiter(void 0, void 0, void 0, function* () {
22
- var _a, _b;
11
+ const { token: fromToken, getTokenBalancesWithRetry } = useTokenBalance(route?.fromToken);
12
+ const { data: insufficientGas, isInitialLoading: insufficientGasLoading } = useQuery(['gas-sufficiency-check', account.address, route?.id], async () => {
23
13
  if (!account.address || !route) {
24
14
  return null;
25
15
  }
@@ -30,7 +20,7 @@ export const useGasSufficiency = (route) => {
30
20
  const { token } = step.estimate.gasCosts[0];
31
21
  const gasCostAmount = step.estimate.gasCosts
32
22
  .reduce((amount, gasCost) => amount.plus(Big(gasCost.amount || 0)), Big(0))
33
- .div(Math.pow(10, token.decimals));
23
+ .div(10 ** token.decimals);
34
24
  const groupedGasCost = groupedGasCosts[token.chainId];
35
25
  const gasAmount = groupedGasCost
36
26
  ? groupedGasCost.gasAmount.plus(gasCostAmount)
@@ -44,59 +34,63 @@ export const useGasSufficiency = (route) => {
44
34
  }
45
35
  return groupedGasCosts;
46
36
  }, {});
47
- if (route.fromToken.address === ((_a = gasCosts[route.fromChainId]) === null || _a === void 0 ? void 0 : _a.token.address)) {
48
- gasCosts[route.fromChainId].tokenAmount = (_b = gasCosts[route.fromChainId]) === null || _b === void 0 ? void 0 : _b.gasAmount.plus(Big(route.fromAmount).div(Math.pow(10, route.fromToken.decimals)));
37
+ if (route.fromToken.address === gasCosts[route.fromChainId]?.token.address) {
38
+ gasCosts[route.fromChainId].tokenAmount = gasCosts[route.fromChainId]?.gasAmount.plus(Big(route.fromAmount).div(10 ** route.fromToken.decimals));
49
39
  }
50
- const tokenBalances = yield getTokenBalancesWithRetry(account.address, Object.values(gasCosts).map((item) => item.token));
51
- if (!(tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.length)) {
40
+ const tokenBalances = await getTokenBalancesWithRetry(account.address, Object.values(gasCosts).map((item) => item.token));
41
+ if (!tokenBalances?.length) {
52
42
  return null;
53
43
  }
54
44
  [route.fromChainId, route.toChainId].forEach((chainId) => {
55
- var _a, _b, _c, _d, _e, _f;
56
45
  if (gasCosts[chainId]) {
57
- const gasTokenBalance = Big((_b = (_a = tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.find((t) => t.chainId === gasCosts[chainId].token.chainId &&
58
- t.address === gasCosts[chainId].token.address)) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : 0);
46
+ const gasTokenBalance = Big(tokenBalances?.find((t) => t.chainId === gasCosts[chainId].token.chainId &&
47
+ t.address === gasCosts[chainId].token.address)?.amount ?? 0);
59
48
  const insufficient = gasTokenBalance.lte(0) ||
60
- gasTokenBalance.lt((_c = gasCosts[chainId].gasAmount) !== null && _c !== void 0 ? _c : Big(0)) ||
61
- gasTokenBalance.lt((_d = gasCosts[chainId].tokenAmount) !== null && _d !== void 0 ? _d : Big(0));
49
+ gasTokenBalance.lt(gasCosts[chainId].gasAmount ?? Big(0)) ||
50
+ gasTokenBalance.lt(gasCosts[chainId].tokenAmount ?? Big(0));
62
51
  const insufficientAmount = insufficient
63
- ? (_f = (_e = gasCosts[chainId].tokenAmount) === null || _e === void 0 ? void 0 : _e.minus(gasTokenBalance)) !== null && _f !== void 0 ? _f : gasCosts[chainId].gasAmount.minus(gasTokenBalance)
52
+ ? gasCosts[chainId].tokenAmount?.minus(gasTokenBalance) ??
53
+ gasCosts[chainId].gasAmount.minus(gasTokenBalance)
64
54
  : undefined;
65
- gasCosts[chainId] = Object.assign(Object.assign({}, gasCosts[chainId]), { insufficient, insufficientAmount: insufficientAmount === null || insufficientAmount === void 0 ? void 0 : insufficientAmount.round(5, Big.roundUp), chain: insufficient ? getChainById(chainId) : undefined });
55
+ gasCosts[chainId] = {
56
+ ...gasCosts[chainId],
57
+ insufficient,
58
+ insufficientAmount: insufficientAmount?.round(5, Big.roundUp),
59
+ chain: insufficient ? getChainById(chainId) : undefined,
60
+ };
66
61
  }
67
62
  });
68
63
  const gasCostResult = Object.values(gasCosts).filter((gasCost) => gasCost.insufficient);
69
64
  return gasCostResult;
70
- }), {
65
+ }, {
71
66
  enabled: Boolean(account.address && route),
72
67
  refetchInterval,
73
68
  staleTime: refetchInterval,
74
69
  cacheTime: refetchInterval,
75
70
  });
76
- const { data: insufficientFunds, isInitialLoading: insufficientFundsLoading, } = useQuery(['funds-sufficiency-check', account.address, route === null || route === void 0 ? void 0 : route.id], () => __awaiter(void 0, void 0, void 0, function* () {
77
- var _c, _d, _e, _f;
71
+ const { data: insufficientFunds, isInitialLoading: insufficientFundsLoading, } = useQuery(['funds-sufficiency-check', account.address, route?.id], async () => {
78
72
  if (!account.address || !fromToken || !route || isRouteDone(route)) {
79
73
  return null;
80
74
  }
81
- let currentTokenBalance = Big((_c = fromToken === null || fromToken === void 0 ? void 0 : fromToken.amount) !== null && _c !== void 0 ? _c : 0);
82
- const currentAction = (_d = route.steps.filter((step) => !step.execution || step.execution.status !== 'DONE')[0]) === null || _d === void 0 ? void 0 : _d.action;
75
+ let currentTokenBalance = Big(fromToken?.amount ?? 0);
76
+ const currentAction = route.steps.filter((step) => !step.execution || step.execution.status !== 'DONE')[0]?.action;
83
77
  if (fromToken.chainId === currentAction.fromToken.chainId &&
84
78
  fromToken.address === currentAction.fromToken.address &&
85
79
  currentTokenBalance.gt(0)) {
86
80
  const insufficientFunds = Big(route.fromAmount)
87
- .div(Math.pow(10, route.fromToken.decimals))
81
+ .div(10 ** route.fromToken.decimals)
88
82
  .gt(currentTokenBalance);
89
83
  return insufficientFunds;
90
84
  }
91
- const tokenBalances = yield getTokenBalancesWithRetry(account.address, [
85
+ const tokenBalances = await getTokenBalancesWithRetry(account.address, [
92
86
  currentAction.fromToken,
93
87
  ]);
94
- currentTokenBalance = Big((_f = (_e = tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances[0]) === null || _e === void 0 ? void 0 : _e.amount) !== null && _f !== void 0 ? _f : 0);
88
+ currentTokenBalance = Big(tokenBalances?.[0]?.amount ?? 0);
95
89
  const insufficientFunds = Big(currentAction.fromAmount)
96
- .div(Math.pow(10, currentAction.fromToken.decimals))
90
+ .div(10 ** currentAction.fromToken.decimals)
97
91
  .gt(currentTokenBalance);
98
92
  return insufficientFunds;
99
- }), {
93
+ }, {
100
94
  enabled: Boolean(account.address && route && fromToken),
101
95
  refetchInterval,
102
96
  staleTime: refetchInterval,
@@ -65,16 +65,12 @@ const processSubstatusMessages = {
65
65
  NOT_FOUND: {},
66
66
  };
67
67
  export function getProcessMessage(t, getChainById, step, process) {
68
- var _a, _b, _c, _d, _e, _f, _g;
69
68
  if (process.error && process.status === 'FAILED') {
70
- const getTransactionNotSentMessage = () => {
71
- var _a, _b;
72
- return t(`swap.error.message.transactionNotSent`, {
73
- amount: formatTokenAmount(step.action.fromAmount, step.action.fromToken.decimals),
74
- tokenSymbol: step.action.fromToken.symbol,
75
- chainName: (_b = (_a = getChainById(step.action.fromChainId)) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : '',
76
- });
77
- };
69
+ const getTransactionNotSentMessage = () => t(`swap.error.message.transactionNotSent`, {
70
+ amount: formatTokenAmount(step.action.fromAmount, step.action.fromToken.decimals),
71
+ tokenSymbol: step.action.fromToken.symbol,
72
+ chainName: getChainById(step.action.fromChainId)?.name ?? '',
73
+ });
78
74
  let title = '';
79
75
  let message = '';
80
76
  switch (process.error.code) {
@@ -115,7 +111,7 @@ export function getProcessMessage(t, getChainById, step, process) {
115
111
  message = t(`swap.error.message.transactionRejected`, {
116
112
  amount: formatTokenAmount(step.action.fromAmount, step.action.fromToken.decimals),
117
113
  tokenSymbol: step.action.fromToken.symbol,
118
- chainName: (_b = (_a = getChainById(step.action.fromChainId)) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : '',
114
+ chainName: getChainById(step.action.fromChainId)?.name ?? '',
119
115
  });
120
116
  break;
121
117
  case LifiErrorCode.ProviderUnavailable:
@@ -131,6 +127,6 @@ export function getProcessMessage(t, getChainById, step, process) {
131
127
  }
132
128
  return { title, message };
133
129
  }
134
- const title = (_e = (_d = (_c = processSubstatusMessages[process.status]) === null || _c === void 0 ? void 0 : _c[process.substatus]) === null || _d === void 0 ? void 0 : _d.call(_c, t)) !== null && _e !== void 0 ? _e : (_g = (_f = processStatusMessages[process.type]) === null || _f === void 0 ? void 0 : _f[process.status]) === null || _g === void 0 ? void 0 : _g.call(_f, t);
130
+ const title = processSubstatusMessages[process.status]?.[process.substatus]?.(t) ?? processStatusMessages[process.type]?.[process.status]?.(t);
135
131
  return { title };
136
132
  }
@@ -1,19 +1,9 @@
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
- };
10
1
  import { useMutation, useQueryClient } from '@tanstack/react-query';
11
2
  import { useCallback, useEffect, useRef } from 'react';
12
3
  import { shallow } from 'zustand/shallow';
13
4
  import { useLiFi, useWallet } from '../providers';
14
5
  import { getUpdatedProcess, isRouteActive, isRouteDone, isRouteFailed, useRouteExecutionStore, useRouteExecutionStoreContext, } from '../stores';
15
6
  import { WidgetEvent } from '../types/events';
16
- import { deepClone } from '../utils';
17
7
  import { useWidgetEvents } from './useWidgetEvents';
18
8
  export const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchangeRateUpdate, }) => {
19
9
  const lifi = useLiFi();
@@ -29,7 +19,7 @@ export const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchan
29
19
  if (!routeExecution) {
30
20
  return;
31
21
  }
32
- const clonedUpdatedRoute = deepClone(updatedRoute);
22
+ const clonedUpdatedRoute = structuredClone(updatedRoute);
33
23
  updateRoute(clonedUpdatedRoute);
34
24
  const process = getUpdatedProcess(routeExecution.route, clonedUpdatedRoute);
35
25
  if (process) {
@@ -49,31 +39,31 @@ export const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchan
49
39
  }
50
40
  console.log('Route updated.', clonedUpdatedRoute);
51
41
  };
52
- const switchChainHook = (requiredChainId) => __awaiter(void 0, void 0, void 0, function* () {
42
+ const switchChainHook = async (requiredChainId) => {
53
43
  if (!account.isActive || !account.signer) {
54
44
  return account.signer;
55
45
  }
56
- const currentChainId = yield account.signer.getChainId();
46
+ const currentChainId = await account.signer.getChainId();
57
47
  if (currentChainId !== requiredChainId) {
58
- const switched = yield switchChain(requiredChainId);
48
+ const switched = await switchChain(requiredChainId);
59
49
  if (!switched) {
60
50
  throw new Error('Chain was not switched.');
61
51
  }
62
52
  }
63
53
  return account.signer;
64
- });
65
- const acceptExchangeRateUpdateHook = (params) => __awaiter(void 0, void 0, void 0, function* () {
54
+ };
55
+ const acceptExchangeRateUpdateHook = async (params) => {
66
56
  if (!onAcceptExchangeRateUpdate) {
67
57
  return false;
68
58
  }
69
- const accepted = yield new Promise((resolve) => onAcceptExchangeRateUpdate(resolve, params));
59
+ const accepted = await new Promise((resolve) => onAcceptExchangeRateUpdate(resolve, params));
70
60
  return accepted;
71
- });
61
+ };
72
62
  const executeRouteMutation = useMutation(() => {
73
63
  if (!account.signer) {
74
64
  throw Error('Account signer not found.');
75
65
  }
76
- if (!(routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route)) {
66
+ if (!routeExecution?.route) {
77
67
  throw Error('Execution route not found.');
78
68
  }
79
69
  queryClient.removeQueries(['routes']);
@@ -96,10 +86,10 @@ export const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchan
96
86
  if (!account.signer) {
97
87
  throw Error('Account signer not found.');
98
88
  }
99
- if (!(routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route)) {
89
+ if (!routeExecution?.route) {
100
90
  throw Error('Execution route not found.');
101
91
  }
102
- return lifi.resumeRoute(account.signer, resumedRoute !== null && resumedRoute !== void 0 ? resumedRoute : routeExecution.route, {
92
+ return lifi.resumeRoute(account.signer, resumedRoute ?? routeExecution.route, {
103
93
  updateCallback,
104
94
  switchChainHook,
105
95
  acceptExchangeRateUpdateHook,
@@ -135,9 +125,9 @@ export const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchan
135
125
  }, [resumeRouteMutation, routeId]);
136
126
  const restartRouteMutation = useCallback(() => {
137
127
  restartRoute(routeId);
138
- resumeRoute(routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route);
128
+ resumeRoute(routeExecution?.route);
139
129
  // eslint-disable-next-line react-hooks/exhaustive-deps
140
- }, [resumeRoute, routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route, routeId]);
130
+ }, [resumeRoute, routeExecution?.route, routeId]);
141
131
  const deleteRouteMutation = useCallback(() => {
142
132
  deleteRoute(routeId);
143
133
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -145,7 +135,7 @@ export const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchan
145
135
  // Resume route execution after page reload
146
136
  useEffect(() => {
147
137
  // Check if route is eligible for automatic resuming
148
- if (isRouteActive(routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route) &&
138
+ if (isRouteActive(routeExecution?.route) &&
149
139
  account.isActive &&
150
140
  !resumedAfterMount.current) {
151
141
  resumedAfterMount.current = true;
@@ -155,8 +145,7 @@ export const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchan
155
145
  }, [account.isActive]);
156
146
  useEffect(() => {
157
147
  return () => {
158
- var _a;
159
- const route = (_a = routeExecutionStoreContext.getState().routes[routeId]) === null || _a === void 0 ? void 0 : _a.route;
148
+ const route = routeExecutionStoreContext.getState().routes[routeId]?.route;
160
149
  if (!route || !isRouteActive(route)) {
161
150
  return;
162
151
  }
@@ -169,7 +158,7 @@ export const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchan
169
158
  executeRoute,
170
159
  restartRoute: restartRouteMutation,
171
160
  deleteRoute: deleteRouteMutation,
172
- route: routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route,
173
- status: routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.status,
161
+ route: routeExecution?.route,
162
+ status: routeExecution?.status,
174
163
  };
175
164
  };
@@ -1,12 +1,3 @@
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
- };
10
1
  import { isAddress } from '@ethersproject/address';
11
2
  import { LifiErrorCode } from '@lifi/sdk';
12
3
  import { useQuery, useQueryClient } from '@tanstack/react-query';
@@ -18,7 +9,6 @@ import { SwapFormKey, useLiFi, useWallet, useWidgetConfig } from '../providers';
18
9
  import { useSettings } from '../stores';
19
10
  const refetchTime = 60000;
20
11
  export const useSwapRoutes = () => {
21
- var _a, _b;
22
12
  const lifi = useLiFi();
23
13
  const { variant, sdkConfig } = useWidgetConfig();
24
14
  const { account, provider } = useWallet();
@@ -52,8 +42,8 @@ export const useSwapRoutes = () => {
52
42
  : true;
53
43
  const isEnabled = !isNaN(fromChainId) &&
54
44
  !isNaN(toChainId) &&
55
- Boolean(fromToken === null || fromToken === void 0 ? void 0 : fromToken.address) &&
56
- Boolean(toToken === null || toToken === void 0 ? void 0 : toToken.address) &&
45
+ Boolean(fromToken?.address) &&
46
+ Boolean(toToken?.address) &&
57
47
  !Number.isNaN(slippage) &&
58
48
  hasAmount &&
59
49
  contractCallQuoteEnabled;
@@ -61,11 +51,11 @@ export const useSwapRoutes = () => {
61
51
  'routes',
62
52
  account.address,
63
53
  fromChainId,
64
- fromToken === null || fromToken === void 0 ? void 0 : fromToken.address,
54
+ fromToken?.address,
65
55
  fromTokenAmount,
66
56
  toAddress,
67
57
  toChainId,
68
- toToken === null || toToken === void 0 ? void 0 : toToken.address,
58
+ toToken?.address,
69
59
  toTokenAmount,
70
60
  toContractAddress,
71
61
  toContractCallData,
@@ -75,28 +65,28 @@ export const useSwapRoutes = () => {
75
65
  enabledExchanges,
76
66
  routePriority,
77
67
  variant,
78
- (_a = sdkConfig === null || sdkConfig === void 0 ? void 0 : sdkConfig.defaultRouteOptions) === null || _a === void 0 ? void 0 : _a.allowSwitchChain,
68
+ sdkConfig?.defaultRouteOptions?.allowSwitchChain,
79
69
  ];
80
- const previousDataUpdatedAt = (_b = queryClient.getQueryState(queryKey)) === null || _b === void 0 ? void 0 : _b.dataUpdatedAt;
70
+ const previousDataUpdatedAt = queryClient.getQueryState(queryKey)?.dataUpdatedAt;
81
71
  const refetchInterval = previousDataUpdatedAt
82
72
  ? Math.min(Math.abs(refetchTime - (Date.now() - previousDataUpdatedAt)), refetchTime)
83
73
  : refetchTime;
84
- const { data, isLoading, isFetching, isFetched, dataUpdatedAt, refetch } = useQuery(queryKey, ({ queryKey: [_, fromAddress, fromChainId, fromTokenAddress, fromTokenAmount, toAddress, toChainId, toTokenAddress, toTokenAmount, toContractAddress, toContractCallData, toContractGasLimit, slippage, enabledBridges, enabledExchanges, routePriority, variant, allowSwitchChain,], signal, }) => __awaiter(void 0, void 0, void 0, function* () {
85
- var _c, _d, _e;
74
+ const { data, isLoading, isFetching, isFetched, dataUpdatedAt, refetch } = useQuery(queryKey, async ({ queryKey: [_, fromAddress, fromChainId, fromTokenAddress, fromTokenAmount, toAddress, toChainId, toTokenAddress, toTokenAmount, toContractAddress, toContractCallData, toContractGasLimit, slippage, enabledBridges, enabledExchanges, routePriority, variant, allowSwitchChain,], signal, }) => {
86
75
  let toWalletAddress;
87
76
  try {
88
77
  toWalletAddress =
89
- (_c = (yield (provider === null || provider === void 0 ? void 0 : provider.resolveName(toAddress)))) !== null && _c !== void 0 ? _c : (isAddress(toAddress) ? toAddress : fromAddress);
78
+ (await provider?.resolveName(toAddress)) ??
79
+ (isAddress(toAddress) ? toAddress : fromAddress);
90
80
  }
91
- catch (_f) {
81
+ catch {
92
82
  toWalletAddress = isAddress(toAddress) ? toAddress : fromAddress;
93
83
  }
94
84
  const fromAmount = Big(fromTokenAmount || 0)
95
- .mul(Math.pow(10, ((_d = fromToken === null || fromToken === void 0 ? void 0 : fromToken.decimals) !== null && _d !== void 0 ? _d : 0)))
85
+ .mul(10 ** (fromToken?.decimals ?? 0))
96
86
  .toFixed(0);
97
87
  const formattedSlippage = parseFloat(slippage) / 100;
98
88
  if (variant === 'nft') {
99
- const contractCallQuote = yield lifi.getContractCallQuote({
89
+ const contractCallQuote = await lifi.getContractCallQuote({
100
90
  fromAddress,
101
91
  fromChain: fromChainId,
102
92
  fromToken: fromTokenAddress,
@@ -125,7 +115,7 @@ export const useSwapRoutes = () => {
125
115
  toAmountMin: toTokenAmount,
126
116
  toToken: toToken,
127
117
  toAddress: toAddress,
128
- gasCostUSD: (_e = contractCallQuote.estimate.gasCosts) === null || _e === void 0 ? void 0 : _e[0].amountUSD,
118
+ gasCostUSD: contractCallQuote.estimate.gasCosts?.[0].amountUSD,
129
119
  steps: [contractCallQuote],
130
120
  };
131
121
  return { routes: [route] };
@@ -150,20 +140,20 @@ export const useSwapRoutes = () => {
150
140
  allowSwitchChain: variant === 'refuel' ? false : allowSwitchChain,
151
141
  },
152
142
  }, { signal });
153
- }), {
143
+ }, {
154
144
  enabled: isEnabled,
155
145
  refetchInterval,
156
146
  staleTime: refetchTime,
157
147
  cacheTime: refetchTime,
158
148
  retry(failureCount, error) {
159
- if ((error === null || error === void 0 ? void 0 : error.code) === LifiErrorCode.NotFound) {
149
+ if (error?.code === LifiErrorCode.NotFound) {
160
150
  return false;
161
151
  }
162
152
  return true;
163
153
  },
164
154
  });
165
155
  return {
166
- routes: data === null || data === void 0 ? void 0 : data.routes,
156
+ routes: data?.routes,
167
157
  isLoading: isEnabled && isLoading,
168
158
  isFetching,
169
159
  isFetched,
package/hooks/useToken.js CHANGED
@@ -4,13 +4,13 @@ import { useTokenSearch } from './useTokenSearch';
4
4
  export const useToken = (chainId, tokenAddress) => {
5
5
  const { tokens, isLoading } = useTokens(chainId);
6
6
  const token = useMemo(() => {
7
- const token = tokens === null || tokens === void 0 ? void 0 : tokens.find((token) => token.address === tokenAddress && token.chainId === chainId);
7
+ const token = tokens?.find((token) => token.address === tokenAddress && token.chainId === chainId);
8
8
  return token;
9
9
  }, [chainId, tokenAddress, tokens]);
10
10
  const tokenSearchEnabled = !isLoading && !token;
11
11
  const { token: searchedToken, isLoading: isSearchedTokenLoading } = useTokenSearch(chainId, tokenAddress, tokenSearchEnabled);
12
12
  return {
13
- token: token !== null && token !== void 0 ? token : searchedToken,
13
+ token: token ?? searchedToken,
14
14
  isLoading: isLoading || (tokenSearchEnabled && isSearchedTokenLoading),
15
15
  };
16
16
  };
@@ -3,8 +3,7 @@ import { useTokenBalances } from './useTokenBalances';
3
3
  export const useTokenAddressBalance = (chainId, tokenAddress) => {
4
4
  const { tokens, tokensWithBalance, isBalanceLoading, refetch } = useTokenBalances(chainId);
5
5
  const token = useMemo(() => {
6
- var _a;
7
- const token = (_a = (tokensWithBalance !== null && tokensWithBalance !== void 0 ? tokensWithBalance : tokens)) === null || _a === void 0 ? void 0 : _a.find((token) => token.address === tokenAddress && token.chainId === chainId);
6
+ const token = (tokensWithBalance ?? tokens)?.find((token) => token.address === tokenAddress && token.chainId === chainId);
8
7
  return token;
9
8
  }, [chainId, tokenAddress, tokens, tokensWithBalance]);
10
9
  return {