@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
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.useGasSufficiency = void 0;
13
4
  const react_query_1 = require("@tanstack/react-query");
@@ -20,9 +11,8 @@ const refetchInterval = 30000;
20
11
  const useGasSufficiency = (route) => {
21
12
  const { account } = (0, providers_1.useWallet)();
22
13
  const { getChainById } = (0, _1.useChains)();
23
- const { token: fromToken, getTokenBalancesWithRetry } = (0, useTokenBalance_1.useTokenBalance)(route === null || route === void 0 ? void 0 : route.fromToken);
24
- const { data: insufficientGas, isInitialLoading: insufficientGasLoading } = (0, react_query_1.useQuery)(['gas-sufficiency-check', account.address, route === null || route === void 0 ? void 0 : route.id], () => __awaiter(void 0, void 0, void 0, function* () {
25
- var _a, _b;
14
+ const { token: fromToken, getTokenBalancesWithRetry } = (0, useTokenBalance_1.useTokenBalance)(route?.fromToken);
15
+ const { data: insufficientGas, isInitialLoading: insufficientGasLoading } = (0, react_query_1.useQuery)(['gas-sufficiency-check', account.address, route?.id], async () => {
26
16
  if (!account.address || !route) {
27
17
  return null;
28
18
  }
@@ -33,7 +23,7 @@ const useGasSufficiency = (route) => {
33
23
  const { token } = step.estimate.gasCosts[0];
34
24
  const gasCostAmount = step.estimate.gasCosts
35
25
  .reduce((amount, gasCost) => amount.plus((0, big_js_1.default)(gasCost.amount || 0)), (0, big_js_1.default)(0))
36
- .div(Math.pow(10, token.decimals));
26
+ .div(10 ** token.decimals);
37
27
  const groupedGasCost = groupedGasCosts[token.chainId];
38
28
  const gasAmount = groupedGasCost
39
29
  ? groupedGasCost.gasAmount.plus(gasCostAmount)
@@ -47,59 +37,63 @@ const useGasSufficiency = (route) => {
47
37
  }
48
38
  return groupedGasCosts;
49
39
  }, {});
50
- if (route.fromToken.address === ((_a = gasCosts[route.fromChainId]) === null || _a === void 0 ? void 0 : _a.token.address)) {
51
- gasCosts[route.fromChainId].tokenAmount = (_b = gasCosts[route.fromChainId]) === null || _b === void 0 ? void 0 : _b.gasAmount.plus((0, big_js_1.default)(route.fromAmount).div(Math.pow(10, route.fromToken.decimals)));
40
+ if (route.fromToken.address === gasCosts[route.fromChainId]?.token.address) {
41
+ gasCosts[route.fromChainId].tokenAmount = gasCosts[route.fromChainId]?.gasAmount.plus((0, big_js_1.default)(route.fromAmount).div(10 ** route.fromToken.decimals));
52
42
  }
53
- const tokenBalances = yield getTokenBalancesWithRetry(account.address, Object.values(gasCosts).map((item) => item.token));
54
- if (!(tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.length)) {
43
+ const tokenBalances = await getTokenBalancesWithRetry(account.address, Object.values(gasCosts).map((item) => item.token));
44
+ if (!tokenBalances?.length) {
55
45
  return null;
56
46
  }
57
47
  [route.fromChainId, route.toChainId].forEach((chainId) => {
58
- var _a, _b, _c, _d, _e, _f;
59
48
  if (gasCosts[chainId]) {
60
- const gasTokenBalance = (0, big_js_1.default)((_b = (_a = tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.find((t) => t.chainId === gasCosts[chainId].token.chainId &&
61
- t.address === gasCosts[chainId].token.address)) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : 0);
49
+ const gasTokenBalance = (0, big_js_1.default)(tokenBalances?.find((t) => t.chainId === gasCosts[chainId].token.chainId &&
50
+ t.address === gasCosts[chainId].token.address)?.amount ?? 0);
62
51
  const insufficient = gasTokenBalance.lte(0) ||
63
- gasTokenBalance.lt((_c = gasCosts[chainId].gasAmount) !== null && _c !== void 0 ? _c : (0, big_js_1.default)(0)) ||
64
- gasTokenBalance.lt((_d = gasCosts[chainId].tokenAmount) !== null && _d !== void 0 ? _d : (0, big_js_1.default)(0));
52
+ gasTokenBalance.lt(gasCosts[chainId].gasAmount ?? (0, big_js_1.default)(0)) ||
53
+ gasTokenBalance.lt(gasCosts[chainId].tokenAmount ?? (0, big_js_1.default)(0));
65
54
  const insufficientAmount = insufficient
66
- ? (_f = (_e = gasCosts[chainId].tokenAmount) === null || _e === void 0 ? void 0 : _e.minus(gasTokenBalance)) !== null && _f !== void 0 ? _f : gasCosts[chainId].gasAmount.minus(gasTokenBalance)
55
+ ? gasCosts[chainId].tokenAmount?.minus(gasTokenBalance) ??
56
+ gasCosts[chainId].gasAmount.minus(gasTokenBalance)
67
57
  : undefined;
68
- gasCosts[chainId] = Object.assign(Object.assign({}, gasCosts[chainId]), { insufficient, insufficientAmount: insufficientAmount === null || insufficientAmount === void 0 ? void 0 : insufficientAmount.round(5, big_js_1.default.roundUp), chain: insufficient ? getChainById(chainId) : undefined });
58
+ gasCosts[chainId] = {
59
+ ...gasCosts[chainId],
60
+ insufficient,
61
+ insufficientAmount: insufficientAmount?.round(5, big_js_1.default.roundUp),
62
+ chain: insufficient ? getChainById(chainId) : undefined,
63
+ };
69
64
  }
70
65
  });
71
66
  const gasCostResult = Object.values(gasCosts).filter((gasCost) => gasCost.insufficient);
72
67
  return gasCostResult;
73
- }), {
68
+ }, {
74
69
  enabled: Boolean(account.address && route),
75
70
  refetchInterval,
76
71
  staleTime: refetchInterval,
77
72
  cacheTime: refetchInterval,
78
73
  });
79
- const { data: insufficientFunds, isInitialLoading: insufficientFundsLoading, } = (0, react_query_1.useQuery)(['funds-sufficiency-check', account.address, route === null || route === void 0 ? void 0 : route.id], () => __awaiter(void 0, void 0, void 0, function* () {
80
- var _c, _d, _e, _f;
74
+ const { data: insufficientFunds, isInitialLoading: insufficientFundsLoading, } = (0, react_query_1.useQuery)(['funds-sufficiency-check', account.address, route?.id], async () => {
81
75
  if (!account.address || !fromToken || !route || (0, stores_1.isRouteDone)(route)) {
82
76
  return null;
83
77
  }
84
- let currentTokenBalance = (0, big_js_1.default)((_c = fromToken === null || fromToken === void 0 ? void 0 : fromToken.amount) !== null && _c !== void 0 ? _c : 0);
85
- const currentAction = (_d = route.steps.filter((step) => !step.execution || step.execution.status !== 'DONE')[0]) === null || _d === void 0 ? void 0 : _d.action;
78
+ let currentTokenBalance = (0, big_js_1.default)(fromToken?.amount ?? 0);
79
+ const currentAction = route.steps.filter((step) => !step.execution || step.execution.status !== 'DONE')[0]?.action;
86
80
  if (fromToken.chainId === currentAction.fromToken.chainId &&
87
81
  fromToken.address === currentAction.fromToken.address &&
88
82
  currentTokenBalance.gt(0)) {
89
83
  const insufficientFunds = (0, big_js_1.default)(route.fromAmount)
90
- .div(Math.pow(10, route.fromToken.decimals))
84
+ .div(10 ** route.fromToken.decimals)
91
85
  .gt(currentTokenBalance);
92
86
  return insufficientFunds;
93
87
  }
94
- const tokenBalances = yield getTokenBalancesWithRetry(account.address, [
88
+ const tokenBalances = await getTokenBalancesWithRetry(account.address, [
95
89
  currentAction.fromToken,
96
90
  ]);
97
- currentTokenBalance = (0, big_js_1.default)((_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);
91
+ currentTokenBalance = (0, big_js_1.default)(tokenBalances?.[0]?.amount ?? 0);
98
92
  const insufficientFunds = (0, big_js_1.default)(currentAction.fromAmount)
99
- .div(Math.pow(10, currentAction.fromToken.decimals))
93
+ .div(10 ** currentAction.fromToken.decimals)
100
94
  .gt(currentTokenBalance);
101
95
  return insufficientFunds;
102
- }), {
96
+ }, {
103
97
  enabled: Boolean(account.address && route && fromToken),
104
98
  refetchInterval,
105
99
  staleTime: refetchInterval,
@@ -69,16 +69,12 @@ const processSubstatusMessages = {
69
69
  NOT_FOUND: {},
70
70
  };
71
71
  function getProcessMessage(t, getChainById, step, process) {
72
- var _a, _b, _c, _d, _e, _f, _g;
73
72
  if (process.error && process.status === 'FAILED') {
74
- const getTransactionNotSentMessage = () => {
75
- var _a, _b;
76
- return t(`swap.error.message.transactionNotSent`, {
77
- amount: (0, utils_1.formatTokenAmount)(step.action.fromAmount, step.action.fromToken.decimals),
78
- tokenSymbol: step.action.fromToken.symbol,
79
- chainName: (_b = (_a = getChainById(step.action.fromChainId)) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : '',
80
- });
81
- };
73
+ const getTransactionNotSentMessage = () => t(`swap.error.message.transactionNotSent`, {
74
+ amount: (0, utils_1.formatTokenAmount)(step.action.fromAmount, step.action.fromToken.decimals),
75
+ tokenSymbol: step.action.fromToken.symbol,
76
+ chainName: getChainById(step.action.fromChainId)?.name ?? '',
77
+ });
82
78
  let title = '';
83
79
  let message = '';
84
80
  switch (process.error.code) {
@@ -119,7 +115,7 @@ function getProcessMessage(t, getChainById, step, process) {
119
115
  message = t(`swap.error.message.transactionRejected`, {
120
116
  amount: (0, utils_1.formatTokenAmount)(step.action.fromAmount, step.action.fromToken.decimals),
121
117
  tokenSymbol: step.action.fromToken.symbol,
122
- chainName: (_b = (_a = getChainById(step.action.fromChainId)) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : '',
118
+ chainName: getChainById(step.action.fromChainId)?.name ?? '',
123
119
  });
124
120
  break;
125
121
  case sdk_1.LifiErrorCode.ProviderUnavailable:
@@ -135,7 +131,7 @@ function getProcessMessage(t, getChainById, step, process) {
135
131
  }
136
132
  return { title, message };
137
133
  }
138
- 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);
134
+ const title = processSubstatusMessages[process.status]?.[process.substatus]?.(t) ?? processStatusMessages[process.type]?.[process.status]?.(t);
139
135
  return { title };
140
136
  }
141
137
  exports.getProcessMessage = getProcessMessage;
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.useRouteExecution = void 0;
13
4
  const react_query_1 = require("@tanstack/react-query");
@@ -16,7 +7,6 @@ const shallow_1 = require("zustand/shallow");
16
7
  const providers_1 = require("../providers");
17
8
  const stores_1 = require("../stores");
18
9
  const events_1 = require("../types/events");
19
- const utils_1 = require("../utils");
20
10
  const useWidgetEvents_1 = require("./useWidgetEvents");
21
11
  const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchangeRateUpdate, }) => {
22
12
  const lifi = (0, providers_1.useLiFi)();
@@ -32,7 +22,7 @@ const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchangeRateU
32
22
  if (!routeExecution) {
33
23
  return;
34
24
  }
35
- const clonedUpdatedRoute = (0, utils_1.deepClone)(updatedRoute);
25
+ const clonedUpdatedRoute = structuredClone(updatedRoute);
36
26
  updateRoute(clonedUpdatedRoute);
37
27
  const process = (0, stores_1.getUpdatedProcess)(routeExecution.route, clonedUpdatedRoute);
38
28
  if (process) {
@@ -52,31 +42,31 @@ const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchangeRateU
52
42
  }
53
43
  console.log('Route updated.', clonedUpdatedRoute);
54
44
  };
55
- const switchChainHook = (requiredChainId) => __awaiter(void 0, void 0, void 0, function* () {
45
+ const switchChainHook = async (requiredChainId) => {
56
46
  if (!account.isActive || !account.signer) {
57
47
  return account.signer;
58
48
  }
59
- const currentChainId = yield account.signer.getChainId();
49
+ const currentChainId = await account.signer.getChainId();
60
50
  if (currentChainId !== requiredChainId) {
61
- const switched = yield switchChain(requiredChainId);
51
+ const switched = await switchChain(requiredChainId);
62
52
  if (!switched) {
63
53
  throw new Error('Chain was not switched.');
64
54
  }
65
55
  }
66
56
  return account.signer;
67
- });
68
- const acceptExchangeRateUpdateHook = (params) => __awaiter(void 0, void 0, void 0, function* () {
57
+ };
58
+ const acceptExchangeRateUpdateHook = async (params) => {
69
59
  if (!onAcceptExchangeRateUpdate) {
70
60
  return false;
71
61
  }
72
- const accepted = yield new Promise((resolve) => onAcceptExchangeRateUpdate(resolve, params));
62
+ const accepted = await new Promise((resolve) => onAcceptExchangeRateUpdate(resolve, params));
73
63
  return accepted;
74
- });
64
+ };
75
65
  const executeRouteMutation = (0, react_query_1.useMutation)(() => {
76
66
  if (!account.signer) {
77
67
  throw Error('Account signer not found.');
78
68
  }
79
- if (!(routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route)) {
69
+ if (!routeExecution?.route) {
80
70
  throw Error('Execution route not found.');
81
71
  }
82
72
  queryClient.removeQueries(['routes']);
@@ -99,10 +89,10 @@ const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchangeRateU
99
89
  if (!account.signer) {
100
90
  throw Error('Account signer not found.');
101
91
  }
102
- if (!(routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route)) {
92
+ if (!routeExecution?.route) {
103
93
  throw Error('Execution route not found.');
104
94
  }
105
- return lifi.resumeRoute(account.signer, resumedRoute !== null && resumedRoute !== void 0 ? resumedRoute : routeExecution.route, {
95
+ return lifi.resumeRoute(account.signer, resumedRoute ?? routeExecution.route, {
106
96
  updateCallback,
107
97
  switchChainHook,
108
98
  acceptExchangeRateUpdateHook,
@@ -138,9 +128,9 @@ const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchangeRateU
138
128
  }, [resumeRouteMutation, routeId]);
139
129
  const restartRouteMutation = (0, react_1.useCallback)(() => {
140
130
  restartRoute(routeId);
141
- resumeRoute(routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route);
131
+ resumeRoute(routeExecution?.route);
142
132
  // eslint-disable-next-line react-hooks/exhaustive-deps
143
- }, [resumeRoute, routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route, routeId]);
133
+ }, [resumeRoute, routeExecution?.route, routeId]);
144
134
  const deleteRouteMutation = (0, react_1.useCallback)(() => {
145
135
  deleteRoute(routeId);
146
136
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -148,7 +138,7 @@ const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchangeRateU
148
138
  // Resume route execution after page reload
149
139
  (0, react_1.useEffect)(() => {
150
140
  // Check if route is eligible for automatic resuming
151
- if ((0, stores_1.isRouteActive)(routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route) &&
141
+ if ((0, stores_1.isRouteActive)(routeExecution?.route) &&
152
142
  account.isActive &&
153
143
  !resumedAfterMount.current) {
154
144
  resumedAfterMount.current = true;
@@ -158,8 +148,7 @@ const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchangeRateU
158
148
  }, [account.isActive]);
159
149
  (0, react_1.useEffect)(() => {
160
150
  return () => {
161
- var _a;
162
- const route = (_a = routeExecutionStoreContext.getState().routes[routeId]) === null || _a === void 0 ? void 0 : _a.route;
151
+ const route = routeExecutionStoreContext.getState().routes[routeId]?.route;
163
152
  if (!route || !(0, stores_1.isRouteActive)(route)) {
164
153
  return;
165
154
  }
@@ -172,8 +161,8 @@ const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchangeRateU
172
161
  executeRoute,
173
162
  restartRoute: restartRouteMutation,
174
163
  deleteRoute: deleteRouteMutation,
175
- route: routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route,
176
- status: routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.status,
164
+ route: routeExecution?.route,
165
+ status: routeExecution?.status,
177
166
  };
178
167
  };
179
168
  exports.useRouteExecution = useRouteExecution;
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.useSwapRoutes = void 0;
13
4
  const address_1 = require("@ethersproject/address");
@@ -21,7 +12,6 @@ const providers_1 = require("../providers");
21
12
  const stores_1 = require("../stores");
22
13
  const refetchTime = 60000;
23
14
  const useSwapRoutes = () => {
24
- var _a, _b;
25
15
  const lifi = (0, providers_1.useLiFi)();
26
16
  const { variant, sdkConfig } = (0, providers_1.useWidgetConfig)();
27
17
  const { account, provider } = (0, providers_1.useWallet)();
@@ -55,8 +45,8 @@ const useSwapRoutes = () => {
55
45
  : true;
56
46
  const isEnabled = !isNaN(fromChainId) &&
57
47
  !isNaN(toChainId) &&
58
- Boolean(fromToken === null || fromToken === void 0 ? void 0 : fromToken.address) &&
59
- Boolean(toToken === null || toToken === void 0 ? void 0 : toToken.address) &&
48
+ Boolean(fromToken?.address) &&
49
+ Boolean(toToken?.address) &&
60
50
  !Number.isNaN(slippage) &&
61
51
  hasAmount &&
62
52
  contractCallQuoteEnabled;
@@ -64,11 +54,11 @@ const useSwapRoutes = () => {
64
54
  'routes',
65
55
  account.address,
66
56
  fromChainId,
67
- fromToken === null || fromToken === void 0 ? void 0 : fromToken.address,
57
+ fromToken?.address,
68
58
  fromTokenAmount,
69
59
  toAddress,
70
60
  toChainId,
71
- toToken === null || toToken === void 0 ? void 0 : toToken.address,
61
+ toToken?.address,
72
62
  toTokenAmount,
73
63
  toContractAddress,
74
64
  toContractCallData,
@@ -78,28 +68,28 @@ const useSwapRoutes = () => {
78
68
  enabledExchanges,
79
69
  routePriority,
80
70
  variant,
81
- (_a = sdkConfig === null || sdkConfig === void 0 ? void 0 : sdkConfig.defaultRouteOptions) === null || _a === void 0 ? void 0 : _a.allowSwitchChain,
71
+ sdkConfig?.defaultRouteOptions?.allowSwitchChain,
82
72
  ];
83
- const previousDataUpdatedAt = (_b = queryClient.getQueryState(queryKey)) === null || _b === void 0 ? void 0 : _b.dataUpdatedAt;
73
+ const previousDataUpdatedAt = queryClient.getQueryState(queryKey)?.dataUpdatedAt;
84
74
  const refetchInterval = previousDataUpdatedAt
85
75
  ? Math.min(Math.abs(refetchTime - (Date.now() - previousDataUpdatedAt)), refetchTime)
86
76
  : refetchTime;
87
- const { data, isLoading, isFetching, isFetched, dataUpdatedAt, refetch } = (0, react_query_1.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* () {
88
- var _c, _d, _e;
77
+ const { data, isLoading, isFetching, isFetched, dataUpdatedAt, refetch } = (0, react_query_1.useQuery)(queryKey, async ({ queryKey: [_, fromAddress, fromChainId, fromTokenAddress, fromTokenAmount, toAddress, toChainId, toTokenAddress, toTokenAmount, toContractAddress, toContractCallData, toContractGasLimit, slippage, enabledBridges, enabledExchanges, routePriority, variant, allowSwitchChain,], signal, }) => {
89
78
  let toWalletAddress;
90
79
  try {
91
80
  toWalletAddress =
92
- (_c = (yield (provider === null || provider === void 0 ? void 0 : provider.resolveName(toAddress)))) !== null && _c !== void 0 ? _c : ((0, address_1.isAddress)(toAddress) ? toAddress : fromAddress);
81
+ (await provider?.resolveName(toAddress)) ??
82
+ ((0, address_1.isAddress)(toAddress) ? toAddress : fromAddress);
93
83
  }
94
- catch (_f) {
84
+ catch {
95
85
  toWalletAddress = (0, address_1.isAddress)(toAddress) ? toAddress : fromAddress;
96
86
  }
97
87
  const fromAmount = (0, big_js_1.default)(fromTokenAmount || 0)
98
- .mul(Math.pow(10, ((_d = fromToken === null || fromToken === void 0 ? void 0 : fromToken.decimals) !== null && _d !== void 0 ? _d : 0)))
88
+ .mul(10 ** (fromToken?.decimals ?? 0))
99
89
  .toFixed(0);
100
90
  const formattedSlippage = parseFloat(slippage) / 100;
101
91
  if (variant === 'nft') {
102
- const contractCallQuote = yield lifi.getContractCallQuote({
92
+ const contractCallQuote = await lifi.getContractCallQuote({
103
93
  fromAddress,
104
94
  fromChain: fromChainId,
105
95
  fromToken: fromTokenAddress,
@@ -128,7 +118,7 @@ const useSwapRoutes = () => {
128
118
  toAmountMin: toTokenAmount,
129
119
  toToken: toToken,
130
120
  toAddress: toAddress,
131
- gasCostUSD: (_e = contractCallQuote.estimate.gasCosts) === null || _e === void 0 ? void 0 : _e[0].amountUSD,
121
+ gasCostUSD: contractCallQuote.estimate.gasCosts?.[0].amountUSD,
132
122
  steps: [contractCallQuote],
133
123
  };
134
124
  return { routes: [route] };
@@ -153,20 +143,20 @@ const useSwapRoutes = () => {
153
143
  allowSwitchChain: variant === 'refuel' ? false : allowSwitchChain,
154
144
  },
155
145
  }, { signal });
156
- }), {
146
+ }, {
157
147
  enabled: isEnabled,
158
148
  refetchInterval,
159
149
  staleTime: refetchTime,
160
150
  cacheTime: refetchTime,
161
151
  retry(failureCount, error) {
162
- if ((error === null || error === void 0 ? void 0 : error.code) === sdk_1.LifiErrorCode.NotFound) {
152
+ if (error?.code === sdk_1.LifiErrorCode.NotFound) {
163
153
  return false;
164
154
  }
165
155
  return true;
166
156
  },
167
157
  });
168
158
  return {
169
- routes: data === null || data === void 0 ? void 0 : data.routes,
159
+ routes: data?.routes,
170
160
  isLoading: isEnabled && isLoading,
171
161
  isFetching,
172
162
  isFetched,
@@ -7,13 +7,13 @@ const useTokenSearch_1 = require("./useTokenSearch");
7
7
  const useToken = (chainId, tokenAddress) => {
8
8
  const { tokens, isLoading } = (0, useTokens_1.useTokens)(chainId);
9
9
  const token = (0, react_1.useMemo)(() => {
10
- const token = tokens === null || tokens === void 0 ? void 0 : tokens.find((token) => token.address === tokenAddress && token.chainId === chainId);
10
+ const token = tokens?.find((token) => token.address === tokenAddress && token.chainId === chainId);
11
11
  return token;
12
12
  }, [chainId, tokenAddress, tokens]);
13
13
  const tokenSearchEnabled = !isLoading && !token;
14
14
  const { token: searchedToken, isLoading: isSearchedTokenLoading } = (0, useTokenSearch_1.useTokenSearch)(chainId, tokenAddress, tokenSearchEnabled);
15
15
  return {
16
- token: token !== null && token !== void 0 ? token : searchedToken,
16
+ token: token ?? searchedToken,
17
17
  isLoading: isLoading || (tokenSearchEnabled && isSearchedTokenLoading),
18
18
  };
19
19
  };
@@ -6,8 +6,7 @@ const useTokenBalances_1 = require("./useTokenBalances");
6
6
  const useTokenAddressBalance = (chainId, tokenAddress) => {
7
7
  const { tokens, tokensWithBalance, isBalanceLoading, refetch } = (0, useTokenBalances_1.useTokenBalances)(chainId);
8
8
  const token = (0, react_1.useMemo)(() => {
9
- var _a;
10
- 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);
9
+ const token = (tokensWithBalance ?? tokens)?.find((token) => token.address === tokenAddress && token.chainId === chainId);
11
10
  return token;
12
11
  }, [chainId, tokenAddress, tokens, tokensWithBalance]);
13
12
  return {
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.useTokenBalance = void 0;
13
4
  const react_query_1 = require("@tanstack/react-query");
@@ -19,17 +10,17 @@ const useTokenBalance = (token, accountAddress) => {
19
10
  const lifi = (0, providers_1.useLiFi)();
20
11
  const { account } = (0, providers_1.useWallet)();
21
12
  const queryClient = (0, react_query_1.useQueryClient)();
22
- const walletAddress = accountAddress !== null && accountAddress !== void 0 ? accountAddress : account.address;
23
- const getTokenBalancesWithRetry = (0, react_1.useCallback)((accountAddress, tokens, depth = 0) => __awaiter(void 0, void 0, void 0, function* () {
13
+ const walletAddress = accountAddress ?? account.address;
14
+ const getTokenBalancesWithRetry = (0, react_1.useCallback)(async (accountAddress, tokens, depth = 0) => {
24
15
  try {
25
- const tokenBalances = yield lifi.getTokenBalances(accountAddress, tokens);
16
+ const tokenBalances = await lifi.getTokenBalances(accountAddress, tokens);
26
17
  if (!tokenBalances.every((token) => token.blockNumber)) {
27
18
  if (depth > 10) {
28
19
  console.warn('Token balance backoff depth exceeded.');
29
20
  return undefined;
30
21
  }
31
- yield new Promise((resolve) => {
32
- setTimeout(resolve, Math.pow(1.5, depth) * 100);
22
+ await new Promise((resolve) => {
23
+ setTimeout(resolve, 1.5 ** depth * 100);
33
24
  });
34
25
  return getTokenBalancesWithRetry(accountAddress, tokens, depth + 1);
35
26
  }
@@ -38,26 +29,26 @@ const useTokenBalance = (token, accountAddress) => {
38
29
  catch (error) {
39
30
  //
40
31
  }
41
- }), [lifi]);
42
- const tokenBalanceQueryKey = (0, react_1.useMemo)(() => ['token-balance', walletAddress, token === null || token === void 0 ? void 0 : token.chainId, token === null || token === void 0 ? void 0 : token.address], [token === null || token === void 0 ? void 0 : token.address, token === null || token === void 0 ? void 0 : token.chainId, walletAddress]);
43
- const { data, isLoading, refetch } = (0, react_query_1.useQuery)(tokenBalanceQueryKey, ({ queryKey: [, accountAddress] }) => __awaiter(void 0, void 0, void 0, function* () {
44
- var _a;
45
- const cachedToken = (_a = queryClient
32
+ }, [lifi]);
33
+ const tokenBalanceQueryKey = (0, react_1.useMemo)(() => ['token-balance', walletAddress, token?.chainId, token?.address], [token?.address, token?.chainId, walletAddress]);
34
+ const { data, isLoading, refetch } = (0, react_query_1.useQuery)(tokenBalanceQueryKey, async ({ queryKey: [, accountAddress] }) => {
35
+ const cachedToken = queryClient
46
36
  .getQueryData([
47
37
  'token-balances',
48
38
  accountAddress,
49
39
  token.chainId,
50
- ])) === null || _a === void 0 ? void 0 : _a.find((t) => t.address === token.address);
40
+ ])
41
+ ?.find((t) => t.address === token.address);
51
42
  if (cachedToken) {
52
43
  return cachedToken;
53
44
  }
54
- const tokenBalances = yield getTokenBalancesWithRetry(accountAddress, [token]);
55
- if (!(tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.length)) {
45
+ const tokenBalances = await getTokenBalancesWithRetry(accountAddress, [token]);
46
+ if (!tokenBalances?.length) {
56
47
  throw Error('Could not get tokens balance.');
57
48
  }
58
49
  const cachedTokenAmount = queryClient.getQueryData(tokenBalanceQueryKey);
59
50
  const formattedAmount = (0, utils_1.formatTokenAmount)(tokenBalances[0].amount);
60
- if ((cachedTokenAmount === null || cachedTokenAmount === void 0 ? void 0 : cachedTokenAmount.amount) !== formattedAmount) {
51
+ if (cachedTokenAmount?.amount !== formattedAmount) {
61
52
  queryClient.setQueryDefaults(tokenBalanceQueryKey, {
62
53
  refetchInterval: defaultRefetchInterval,
63
54
  staleTime: defaultRefetchInterval,
@@ -66,12 +57,18 @@ const useTokenBalance = (token, accountAddress) => {
66
57
  queryClient.setQueryData(['token-balances', accountAddress, token.chainId], (data) => {
67
58
  if (data) {
68
59
  const index = data.findIndex((dataToken) => dataToken.address === token.address);
69
- data[index] = Object.assign(Object.assign({}, data[index]), { amount: formattedAmount });
60
+ data[index] = {
61
+ ...data[index],
62
+ amount: formattedAmount,
63
+ };
70
64
  }
71
65
  return data;
72
66
  });
73
- return Object.assign(Object.assign({}, tokenBalances[0]), { amount: formattedAmount });
74
- }), {
67
+ return {
68
+ ...tokenBalances[0],
69
+ amount: formattedAmount,
70
+ };
71
+ }, {
75
72
  enabled: Boolean(walletAddress && token),
76
73
  refetchInterval: defaultRefetchInterval,
77
74
  staleTime: defaultRefetchInterval,
@@ -79,7 +76,7 @@ const useTokenBalance = (token, accountAddress) => {
79
76
  const refetchAllBalances = () => {
80
77
  queryClient.refetchQueries([
81
78
  'token-balances',
82
- token === null || token === void 0 ? void 0 : token.chainId,
79
+ token?.chainId,
83
80
  accountAddress,
84
81
  ]);
85
82
  };
@@ -1,6 +1,6 @@
1
1
  import type { Token } from '../types';
2
2
  export declare const useTokenBalances: (selectedChainId?: number) => {
3
- tokens: Token[] | undefined;
3
+ tokens: Token[];
4
4
  tokensWithBalance: Token[] | undefined;
5
5
  featuredTokens: import("@lifi/types").Token[];
6
6
  isLoading: boolean;
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.useTokenBalances = void 0;
13
4
  /* eslint-disable consistent-return */
@@ -26,11 +17,11 @@ const useTokenBalances = (selectedChainId) => {
26
17
  const { tokens, isLoading } = (0, useTokens_1.useTokens)(selectedChainId);
27
18
  const [refetchInterval, setRefetchInterval] = (0, react_1.useState)(defaultRefetchInterval);
28
19
  const isBalanceLoadingEnabled = Boolean(account.address) &&
29
- Boolean(tokens === null || tokens === void 0 ? void 0 : tokens.length) &&
20
+ Boolean(tokens?.length) &&
30
21
  Boolean(selectedChainId);
31
- const { data: tokensWithBalance, isLoading: isBalanceLoading, refetch, } = (0, react_query_1.useQuery)(['token-balances', account.address, selectedChainId, tokens === null || tokens === void 0 ? void 0 : tokens.length], ({ queryKey: [, accountAddress] }) => __awaiter(void 0, void 0, void 0, function* () {
32
- const tokenBalances = yield lifi.getTokenBalances(accountAddress, tokens);
33
- if (!(tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.length)) {
22
+ const { data: tokensWithBalance, isLoading: isBalanceLoading, refetch, } = (0, react_query_1.useQuery)(['token-balances', account.address, selectedChainId, tokens?.length], async ({ queryKey: [, accountAddress] }) => {
23
+ const tokenBalances = await lifi.getTokenBalances(accountAddress, tokens);
24
+ if (!tokenBalances?.length) {
34
25
  // Sometimes RPCs (e.g. Arbitrum) don't return balances on first call
35
26
  // TODO: fix and remove backplane
36
27
  setRefetchInterval((interval) => interval === defaultRefetchInterval
@@ -38,12 +29,9 @@ const useTokenBalances = (selectedChainId) => {
38
29
  : interval * 2);
39
30
  throw Error('Could not get tokens balance.');
40
31
  }
41
- const featuredTokenAddresses = new Set(featuredTokens === null || featuredTokens === void 0 ? void 0 : featuredTokens.map((token) => token.address));
42
- const sortFn = (a, b) => {
43
- var _a, _b, _c, _d;
44
- return parseFloat((_a = b.amount) !== null && _a !== void 0 ? _a : '0') * parseFloat((_b = b.priceUSD) !== null && _b !== void 0 ? _b : '0') -
45
- parseFloat((_c = a.amount) !== null && _c !== void 0 ? _c : '0') * parseFloat((_d = a.priceUSD) !== null && _d !== void 0 ? _d : '0');
46
- };
32
+ const featuredTokenAddresses = new Set(featuredTokens?.map((token) => token.address));
33
+ const sortFn = (a, b) => parseFloat(b.amount ?? '0') * parseFloat(b.priceUSD ?? '0') -
34
+ parseFloat(a.amount ?? '0') * parseFloat(a.priceUSD ?? '0');
47
35
  const formattedTokens = (tokenBalances.length === 0 ? tokens : tokenBalances).map((token) => {
48
36
  token.amount = (0, utils_1.formatTokenAmount)(token.amount);
49
37
  return token;
@@ -60,7 +48,7 @@ const useTokenBalances = (selectedChainId) => {
60
48
  ...formattedTokens.filter((token) => token.amount === '0' && !featuredTokenAddresses.has(token.address)),
61
49
  ];
62
50
  return result;
63
- }), {
51
+ }, {
64
52
  enabled: isBalanceLoadingEnabled,
65
53
  refetchInterval,
66
54
  staleTime: refetchInterval,
@@ -1,5 +1,5 @@
1
1
  import type { Token } from '../types';
2
- export declare const useTokenSearch: (chainId?: number, token?: string, enabled?: boolean) => {
2
+ export declare const useTokenSearch: (chainId?: number, tokenQuery?: string, enabled?: boolean) => {
3
3
  token: Token | undefined;
4
4
  isLoading: boolean;
5
5
  };