@lifi/widget 1.15.1 → 1.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (346) hide show
  1. package/App.js +21 -0
  2. package/AppProvider.d.ts +0 -4
  3. package/AppProvider.js +2 -10
  4. package/README.md +1 -1
  5. package/cjs/App.js +21 -0
  6. package/cjs/AppProvider.d.ts +0 -4
  7. package/cjs/AppProvider.js +3 -12
  8. package/cjs/components/ActiveSwaps/ActiveSwapItem.d.ts +5 -0
  9. package/cjs/components/ActiveSwaps/ActiveSwapItem.js +45 -0
  10. package/cjs/components/{SwapsInProgress/SwapsInProgress.d.ts → ActiveSwaps/ActiveSwaps.d.ts} +1 -1
  11. package/cjs/components/ActiveSwaps/ActiveSwaps.js +30 -0
  12. package/cjs/components/ActiveSwaps/ActiveSwaps.style.d.ts +78 -0
  13. package/cjs/components/ActiveSwaps/ActiveSwaps.style.js +40 -0
  14. package/cjs/components/ActiveSwaps/index.d.ts +2 -0
  15. package/cjs/components/ActiveSwaps/index.js +18 -0
  16. package/cjs/components/AppContainer.js +2 -2
  17. package/cjs/components/Card/Card.d.ts +7 -4
  18. package/cjs/components/Card/Card.js +38 -28
  19. package/cjs/{pages/SelectTokenPage → components/ChainSelect}/ChainSelect.d.ts +0 -0
  20. package/cjs/components/ChainSelect/ChainSelect.js +35 -0
  21. package/cjs/components/{SwapsInProgress/SwapsInProgress.style.d.ts → ChainSelect/ChainSelect.style.d.ts} +10 -19
  22. package/cjs/components/ChainSelect/ChainSelect.style.js +19 -0
  23. package/cjs/components/ChainSelect/index.d.ts +2 -0
  24. package/cjs/components/ChainSelect/index.js +18 -0
  25. package/cjs/components/ChainSelect/useChainSelect.d.ts +8 -0
  26. package/cjs/components/ChainSelect/useChainSelect.js +33 -0
  27. package/cjs/components/GasSufficiencyMessage/GasSufficiencyMessage.js +3 -3
  28. package/cjs/components/Header/Header.js +1 -9
  29. package/cjs/components/Header/NavigationHeader.js +6 -11
  30. package/cjs/components/Header/useHeaderActionStore.d.ts +0 -2
  31. package/cjs/components/Header/useHeaderActionStore.js +1 -5
  32. package/cjs/components/PoweredBy/PoweredBy.style.d.ts +1 -1
  33. package/cjs/components/PoweredBy/PoweredBy.style.js +1 -0
  34. package/cjs/components/SelectChainAndToken.js +5 -5
  35. package/cjs/components/SendToWallet/SendToWallet.js +6 -6
  36. package/cjs/components/Step/CircularProgress.js +1 -1
  37. package/cjs/components/Step/CircularProgress.style.js +1 -1
  38. package/cjs/components/Step/StepProcess.js +1 -5
  39. package/cjs/components/Step/StepProcess.style.d.ts +1 -1
  40. package/cjs/components/Step/StepTimer.d.ts +1 -0
  41. package/cjs/components/Step/StepTimer.js +6 -6
  42. package/cjs/components/SwapButton/SwapButton.js +5 -32
  43. package/cjs/components/SwapButton/types.d.ts +2 -2
  44. package/cjs/components/SwapRouteCard/SwapRouteCard.js +1 -1
  45. package/cjs/components/TokenAvatar/TokenAvatar.style.js +0 -3
  46. package/cjs/components/TokenList/TokenList.js +7 -3
  47. package/cjs/components/TokenList/TokenList.style.js +4 -3
  48. package/cjs/components/TokenList/TokenListItem.js +1 -1
  49. package/cjs/components/TokenList/TokenNotFound.d.ts +2 -1
  50. package/cjs/components/TokenList/TokenNotFound.js +12 -2
  51. package/cjs/components/TokenList/types.d.ts +2 -2
  52. package/cjs/config/theme.js +24 -23
  53. package/cjs/config/version.d.ts +1 -1
  54. package/cjs/config/version.js +1 -1
  55. package/cjs/hooks/index.d.ts +2 -0
  56. package/cjs/hooks/index.js +2 -0
  57. package/cjs/hooks/useChains.d.ts +1 -97
  58. package/cjs/hooks/useChains.js +26 -20
  59. package/cjs/hooks/useFeaturedTokens.d.ts +1 -1
  60. package/cjs/hooks/useFeaturedTokens.js +6 -3
  61. package/cjs/hooks/useGasSufficiency.d.ts +1 -1
  62. package/cjs/hooks/useGasSufficiency.js +36 -28
  63. package/cjs/hooks/useInitializer.js +6 -0
  64. package/cjs/{components/Step/utils.d.ts → hooks/useProcessMessage.d.ts} +4 -0
  65. package/cjs/{components/Step/utils.js → hooks/useProcessMessage.js} +16 -10
  66. package/cjs/hooks/useRouteExecution.d.ts +1 -1
  67. package/cjs/hooks/useRouteExecution.js +26 -35
  68. package/cjs/hooks/useSwapRoutes.js +10 -11
  69. package/cjs/hooks/useToken.d.ts +0 -1
  70. package/cjs/hooks/useToken.js +1 -2
  71. package/cjs/hooks/useTokenBalances.d.ts +1 -2
  72. package/cjs/hooks/useTokenBalances.js +5 -6
  73. package/cjs/hooks/useTokenSearch.js +3 -2
  74. package/cjs/hooks/useTokens.d.ts +1 -2
  75. package/cjs/hooks/useTokens.js +32 -9
  76. package/cjs/hooks/useTools.js +11 -5
  77. package/cjs/hooks/useWidgetEvents.d.ts +3 -0
  78. package/cjs/hooks/useWidgetEvents.js +13 -0
  79. package/cjs/i18n/en/translation.json +14 -10
  80. package/cjs/i18n/index.d.ts +11 -7
  81. package/cjs/index.d.ts +1 -0
  82. package/cjs/index.js +3 -1
  83. package/cjs/pages/ActiveSwapsPage/ActiveSwapsEmpty.d.ts +2 -0
  84. package/cjs/pages/ActiveSwapsPage/ActiveSwapsEmpty.js +18 -0
  85. package/cjs/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +2 -0
  86. package/cjs/pages/ActiveSwapsPage/ActiveSwapsPage.js +21 -0
  87. package/cjs/pages/ActiveSwapsPage/index.d.ts +1 -0
  88. package/cjs/{components/SwapsInProgress → pages/ActiveSwapsPage}/index.js +1 -1
  89. package/cjs/pages/MainPage/MainPage.js +2 -3
  90. package/cjs/pages/MainPage/MainSwapButton.js +3 -1
  91. package/cjs/pages/MainPage/SwapRoutes.js +4 -1
  92. package/cjs/pages/SelectChainPage/SelectChainPage.d.ts +3 -0
  93. package/cjs/pages/SelectChainPage/SelectChainPage.js +33 -0
  94. package/cjs/pages/SelectChainPage/SelectChainPage.style.d.ts +21 -0
  95. package/cjs/pages/SelectChainPage/SelectChainPage.style.js +20 -0
  96. package/cjs/pages/SelectChainPage/index.d.ts +1 -0
  97. package/cjs/pages/SelectChainPage/index.js +17 -0
  98. package/cjs/pages/SelectTokenPage/SelectTokenPage.d.ts +2 -4
  99. package/cjs/pages/SelectTokenPage/SelectTokenPage.js +2 -2
  100. package/cjs/pages/SelectWalletPage/SelectWalletPage.js +4 -4
  101. package/cjs/pages/SelectWalletPage/SelectWalletPage.style.d.ts +2 -27
  102. package/cjs/pages/SelectWalletPage/SelectWalletPage.style.js +4 -14
  103. package/cjs/pages/SettingsPage/AdvancedPreferences.js +1 -1
  104. package/cjs/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +1 -1
  105. package/cjs/pages/SettingsPage/EnabledBridgesSelect.js +3 -6
  106. package/cjs/pages/SettingsPage/EnabledExchangesSelect.js +3 -5
  107. package/cjs/pages/SettingsPage/GasPriceSelect.js +1 -1
  108. package/cjs/pages/SettingsPage/RoutePrioritySelect.js +6 -2
  109. package/cjs/pages/SettingsPage/ShowDestinationWallet.js +1 -1
  110. package/cjs/pages/SettingsPage/SlippageInput.js +1 -1
  111. package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +3 -4
  112. package/cjs/pages/SwapHistoryPage/SwapHistoryPage.js +2 -3
  113. package/cjs/pages/SwapPage/StatusBottomSheet.js +25 -36
  114. package/cjs/pages/SwapPage/SwapPage.js +16 -3
  115. package/cjs/pages/SwapRoutesPage/SwapRoutesPage.js +4 -3
  116. package/cjs/providers/SDKProvider/SDKProvider.d.ts +4 -0
  117. package/cjs/providers/SDKProvider/SDKProvider.js +27 -0
  118. package/cjs/providers/SDKProvider/index.d.ts +1 -0
  119. package/cjs/providers/SDKProvider/index.js +17 -0
  120. package/cjs/providers/SwapFormProvider/SwapFormProvider.js +4 -30
  121. package/cjs/providers/SwapFormProvider/types.d.ts +5 -5
  122. package/cjs/providers/TelemetryProvider/TelemetryProvider.d.ts +4 -0
  123. package/cjs/providers/TelemetryProvider/TelemetryProvider.js +11 -0
  124. package/cjs/providers/TelemetryProvider/index.d.ts +1 -0
  125. package/cjs/providers/TelemetryProvider/index.js +17 -0
  126. package/cjs/providers/WalletProvider/WalletProvider.d.ts +1 -4
  127. package/cjs/providers/WalletProvider/WalletProvider.js +59 -1
  128. package/cjs/providers/WidgetProvider/WidgetProvider.js +1 -16
  129. package/cjs/providers/WidgetProvider/index.d.ts +1 -0
  130. package/cjs/providers/WidgetProvider/index.js +1 -0
  131. package/cjs/providers/WidgetProvider/utils.d.ts +4 -0
  132. package/cjs/providers/WidgetProvider/utils.js +13 -0
  133. package/cjs/providers/index.d.ts +2 -0
  134. package/cjs/providers/index.js +2 -0
  135. package/cjs/stores/chains/index.d.ts +3 -0
  136. package/cjs/stores/chains/index.js +19 -0
  137. package/cjs/stores/chains/types.d.ts +8 -0
  138. package/cjs/stores/chains/types.js +2 -0
  139. package/cjs/stores/chains/useChainOrder.d.ts +1 -0
  140. package/cjs/stores/chains/useChainOrder.js +12 -0
  141. package/cjs/stores/chains/useChainOrderStore.d.ts +19 -0
  142. package/cjs/stores/chains/useChainOrderStore.js +45 -0
  143. package/cjs/stores/route/index.d.ts +2 -1
  144. package/cjs/stores/route/index.js +2 -1
  145. package/cjs/stores/route/useExecutingRoutesIds.d.ts +1 -0
  146. package/cjs/stores/route/useExecutingRoutesIds.js +20 -0
  147. package/cjs/stores/route/useRouteStore.js +5 -4
  148. package/cjs/stores/route/utils.d.ts +4 -0
  149. package/cjs/stores/route/utils.js +21 -0
  150. package/cjs/stores/settings/index.d.ts +0 -1
  151. package/cjs/stores/settings/index.js +0 -1
  152. package/cjs/stores/settings/useAppearance.js +3 -1
  153. package/cjs/stores/settings/useSettingsStore.js +5 -2
  154. package/cjs/types/events.d.ts +5 -0
  155. package/cjs/types/events.js +9 -0
  156. package/cjs/types/index.d.ts +1 -0
  157. package/cjs/types/index.js +1 -0
  158. package/cjs/types/widget.d.ts +31 -23
  159. package/cjs/utils/colors.d.ts +1 -1
  160. package/cjs/utils/navigationRoutes.d.ts +5 -0
  161. package/cjs/utils/navigationRoutes.js +31 -4
  162. package/components/ActiveSwaps/ActiveSwapItem.d.ts +5 -0
  163. package/components/ActiveSwaps/ActiveSwapItem.js +41 -0
  164. package/components/{SwapsInProgress/SwapsInProgress.d.ts → ActiveSwaps/ActiveSwaps.d.ts} +1 -1
  165. package/components/ActiveSwaps/ActiveSwaps.js +26 -0
  166. package/components/ActiveSwaps/ActiveSwaps.style.d.ts +78 -0
  167. package/components/ActiveSwaps/ActiveSwaps.style.js +37 -0
  168. package/components/ActiveSwaps/index.d.ts +2 -0
  169. package/components/ActiveSwaps/index.js +2 -0
  170. package/components/AppContainer.js +1 -1
  171. package/components/Card/Card.d.ts +7 -4
  172. package/components/Card/Card.js +39 -29
  173. package/{pages/SelectTokenPage → components/ChainSelect}/ChainSelect.d.ts +0 -0
  174. package/components/ChainSelect/ChainSelect.js +31 -0
  175. package/components/{SwapsInProgress/SwapsInProgress.style.d.ts → ChainSelect/ChainSelect.style.d.ts} +10 -19
  176. package/components/ChainSelect/ChainSelect.style.js +16 -0
  177. package/components/ChainSelect/index.d.ts +2 -0
  178. package/components/ChainSelect/index.js +2 -0
  179. package/components/ChainSelect/useChainSelect.d.ts +8 -0
  180. package/components/ChainSelect/useChainSelect.js +29 -0
  181. package/components/GasSufficiencyMessage/GasSufficiencyMessage.js +3 -3
  182. package/components/Header/Header.js +1 -9
  183. package/components/Header/NavigationHeader.js +6 -11
  184. package/components/Header/useHeaderActionStore.d.ts +0 -2
  185. package/components/Header/useHeaderActionStore.js +0 -3
  186. package/components/PoweredBy/PoweredBy.style.d.ts +1 -1
  187. package/components/PoweredBy/PoweredBy.style.js +1 -0
  188. package/components/SelectChainAndToken.js +1 -1
  189. package/components/SendToWallet/SendToWallet.js +6 -6
  190. package/components/Step/CircularProgress.js +3 -3
  191. package/components/Step/CircularProgress.style.js +1 -1
  192. package/components/Step/StepProcess.js +2 -6
  193. package/components/Step/StepProcess.style.d.ts +1 -1
  194. package/components/Step/StepTimer.d.ts +1 -0
  195. package/components/Step/StepTimer.js +6 -6
  196. package/components/SwapButton/SwapButton.js +7 -34
  197. package/components/SwapButton/types.d.ts +2 -2
  198. package/components/SwapRouteCard/SwapRouteCard.js +1 -1
  199. package/components/TokenAvatar/TokenAvatar.style.js +0 -3
  200. package/components/TokenList/TokenList.js +7 -3
  201. package/components/TokenList/TokenList.style.js +4 -3
  202. package/components/TokenList/TokenListItem.js +1 -1
  203. package/components/TokenList/TokenNotFound.d.ts +2 -1
  204. package/components/TokenList/TokenNotFound.js +12 -2
  205. package/components/TokenList/types.d.ts +2 -2
  206. package/config/theme.js +24 -23
  207. package/config/version.d.ts +1 -1
  208. package/config/version.js +1 -1
  209. package/hooks/index.d.ts +2 -0
  210. package/hooks/index.js +2 -0
  211. package/hooks/useChains.d.ts +1 -97
  212. package/hooks/useChains.js +26 -20
  213. package/hooks/useFeaturedTokens.d.ts +1 -1
  214. package/hooks/useFeaturedTokens.js +6 -3
  215. package/hooks/useGasSufficiency.d.ts +1 -1
  216. package/hooks/useGasSufficiency.js +32 -24
  217. package/hooks/useInitializer.js +6 -0
  218. package/{components/Step/utils.d.ts → hooks/useProcessMessage.d.ts} +4 -0
  219. package/{pages/SwapPage/utils.js → hooks/useProcessMessage.js} +15 -10
  220. package/hooks/useRouteExecution.d.ts +1 -1
  221. package/hooks/useRouteExecution.js +26 -35
  222. package/hooks/useSwapRoutes.js +3 -4
  223. package/hooks/useToken.d.ts +0 -1
  224. package/hooks/useToken.js +1 -2
  225. package/hooks/useTokenBalances.d.ts +1 -2
  226. package/hooks/useTokenBalances.js +4 -5
  227. package/hooks/useTokenSearch.js +3 -2
  228. package/hooks/useTokens.d.ts +1 -2
  229. package/hooks/useTokens.js +32 -9
  230. package/hooks/useTools.js +11 -5
  231. package/hooks/useWidgetEvents.d.ts +3 -0
  232. package/hooks/useWidgetEvents.js +6 -0
  233. package/i18n/en/translation.json +14 -10
  234. package/i18n/index.d.ts +11 -7
  235. package/index.d.ts +1 -0
  236. package/index.js +1 -0
  237. package/package.json +15 -14
  238. package/pages/ActiveSwapsPage/ActiveSwapsEmpty.d.ts +2 -0
  239. package/pages/ActiveSwapsPage/ActiveSwapsEmpty.js +14 -0
  240. package/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +2 -0
  241. package/pages/ActiveSwapsPage/ActiveSwapsPage.js +17 -0
  242. package/pages/ActiveSwapsPage/index.d.ts +1 -0
  243. package/pages/ActiveSwapsPage/index.js +1 -0
  244. package/pages/MainPage/MainPage.js +2 -3
  245. package/pages/MainPage/MainSwapButton.js +3 -1
  246. package/pages/MainPage/SwapRoutes.js +4 -1
  247. package/pages/SelectChainPage/SelectChainPage.d.ts +3 -0
  248. package/pages/SelectChainPage/SelectChainPage.js +29 -0
  249. package/pages/SelectChainPage/SelectChainPage.style.d.ts +21 -0
  250. package/pages/SelectChainPage/SelectChainPage.style.js +17 -0
  251. package/pages/SelectChainPage/index.d.ts +1 -0
  252. package/pages/SelectChainPage/index.js +1 -0
  253. package/pages/SelectTokenPage/SelectTokenPage.d.ts +2 -4
  254. package/pages/SelectTokenPage/SelectTokenPage.js +2 -2
  255. package/pages/SelectWalletPage/SelectWalletPage.js +5 -5
  256. package/pages/SelectWalletPage/SelectWalletPage.style.d.ts +2 -27
  257. package/pages/SelectWalletPage/SelectWalletPage.style.js +4 -14
  258. package/pages/SettingsPage/AdvancedPreferences.js +2 -2
  259. package/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +1 -1
  260. package/pages/SettingsPage/EnabledBridgesSelect.js +4 -7
  261. package/pages/SettingsPage/EnabledExchangesSelect.js +4 -6
  262. package/pages/SettingsPage/GasPriceSelect.js +2 -2
  263. package/pages/SettingsPage/RoutePrioritySelect.js +7 -3
  264. package/pages/SettingsPage/ShowDestinationWallet.js +2 -2
  265. package/pages/SettingsPage/SlippageInput.js +2 -2
  266. package/pages/SwapDetailsPage/SwapDetailsPage.js +4 -5
  267. package/pages/SwapHistoryPage/SwapHistoryPage.js +3 -4
  268. package/pages/SwapPage/StatusBottomSheet.js +27 -38
  269. package/pages/SwapPage/SwapPage.js +16 -3
  270. package/pages/SwapRoutesPage/SwapRoutesPage.js +5 -4
  271. package/providers/SDKProvider/SDKProvider.d.ts +4 -0
  272. package/providers/SDKProvider/SDKProvider.js +19 -0
  273. package/providers/SDKProvider/index.d.ts +1 -0
  274. package/providers/SDKProvider/index.js +1 -0
  275. package/providers/SwapFormProvider/SwapFormProvider.js +4 -30
  276. package/providers/SwapFormProvider/types.d.ts +5 -5
  277. package/providers/TelemetryProvider/TelemetryProvider.d.ts +4 -0
  278. package/providers/TelemetryProvider/TelemetryProvider.js +7 -0
  279. package/providers/TelemetryProvider/index.d.ts +1 -0
  280. package/providers/TelemetryProvider/index.js +1 -0
  281. package/providers/WalletProvider/WalletProvider.d.ts +1 -4
  282. package/providers/WalletProvider/WalletProvider.js +59 -1
  283. package/providers/WidgetProvider/WidgetProvider.js +3 -18
  284. package/providers/WidgetProvider/index.d.ts +1 -0
  285. package/providers/WidgetProvider/index.js +1 -0
  286. package/providers/WidgetProvider/utils.d.ts +4 -0
  287. package/providers/WidgetProvider/utils.js +9 -0
  288. package/providers/index.d.ts +2 -0
  289. package/providers/index.js +2 -0
  290. package/stores/chains/index.d.ts +3 -0
  291. package/stores/chains/index.js +3 -0
  292. package/stores/chains/types.d.ts +8 -0
  293. package/stores/chains/types.js +1 -0
  294. package/stores/chains/useChainOrder.d.ts +1 -0
  295. package/stores/chains/useChainOrder.js +5 -0
  296. package/stores/chains/useChainOrderStore.d.ts +19 -0
  297. package/stores/chains/useChainOrderStore.js +39 -0
  298. package/stores/route/index.d.ts +2 -1
  299. package/stores/route/index.js +2 -1
  300. package/stores/route/useExecutingRoutesIds.d.ts +1 -0
  301. package/stores/route/useExecutingRoutesIds.js +13 -0
  302. package/stores/route/useRouteStore.js +5 -4
  303. package/stores/route/utils.d.ts +4 -0
  304. package/stores/route/utils.js +15 -0
  305. package/stores/settings/index.d.ts +0 -1
  306. package/stores/settings/index.js +0 -1
  307. package/stores/settings/useAppearance.js +3 -1
  308. package/stores/settings/useSettingsStore.js +5 -2
  309. package/tsconfig.cjs.tsbuildinfo +1 -1
  310. package/types/events.d.ts +5 -0
  311. package/types/events.js +6 -0
  312. package/types/index.d.ts +1 -0
  313. package/types/index.js +1 -0
  314. package/types/widget.d.ts +31 -23
  315. package/utils/colors.d.ts +1 -1
  316. package/utils/navigationRoutes.d.ts +5 -0
  317. package/utils/navigationRoutes.js +30 -3
  318. package/cjs/components/SwapButton/SwapButton.style.d.ts +0 -65
  319. package/cjs/components/SwapButton/SwapButton.style.js +0 -15
  320. package/cjs/components/SwapsInProgress/SwapsInProgress.js +0 -29
  321. package/cjs/components/SwapsInProgress/SwapsInProgress.style.js +0 -17
  322. package/cjs/components/SwapsInProgress/index.d.ts +0 -1
  323. package/cjs/config/lifi.d.ts +0 -4
  324. package/cjs/config/lifi.js +0 -14
  325. package/cjs/pages/SelectTokenPage/ChainSelect.js +0 -31
  326. package/cjs/pages/SwapPage/utils.d.ts +0 -6
  327. package/cjs/pages/SwapPage/utils.js +0 -93
  328. package/cjs/stores/route/useExecutingRoutes.d.ts +0 -2
  329. package/cjs/stores/route/useExecutingRoutes.js +0 -13
  330. package/cjs/stores/settings/useSetSettings.d.ts +0 -5
  331. package/cjs/stores/settings/useSetSettings.js +0 -12
  332. package/components/Step/utils.js +0 -89
  333. package/components/SwapButton/SwapButton.style.d.ts +0 -65
  334. package/components/SwapButton/SwapButton.style.js +0 -12
  335. package/components/SwapsInProgress/SwapsInProgress.js +0 -25
  336. package/components/SwapsInProgress/SwapsInProgress.style.js +0 -14
  337. package/components/SwapsInProgress/index.d.ts +0 -1
  338. package/components/SwapsInProgress/index.js +0 -1
  339. package/config/lifi.d.ts +0 -4
  340. package/config/lifi.js +0 -7
  341. package/pages/SelectTokenPage/ChainSelect.js +0 -27
  342. package/pages/SwapPage/utils.d.ts +0 -6
  343. package/stores/route/useExecutingRoutes.d.ts +0 -2
  344. package/stores/route/useExecutingRoutes.js +0 -6
  345. package/stores/settings/useSetSettings.d.ts +0 -5
  346. package/stores/settings/useSetSettings.js +0 -5
@@ -1,17 +1,16 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Done as DoneIcon, Info as InfoIcon, Warning as WarningIcon, } from '@mui/icons-material';
3
3
  import { Box, Button, Typography } from '@mui/material';
4
- import { useEffect, useMemo, useRef } from 'react';
4
+ import { useEffect, useRef } from 'react';
5
5
  import { useFormContext } from 'react-hook-form';
6
6
  import { useTranslation } from 'react-i18next';
7
7
  import { BottomSheet } from '../../components/BottomSheet';
8
8
  import { Token } from '../../components/Token';
9
- import { useChains, useNavigateBack, useTokenBalance } from '../../hooks';
9
+ import { getProcessMessage, useChains, useNavigateBack, useTokenBalance, } from '../../hooks';
10
10
  import { SwapFormKey } from '../../providers';
11
11
  import { IconCircle, IconContainer, iconStyles, } from './StatusBottomSheet.style';
12
- import { getProcessMessage } from './utils';
13
12
  export const StatusBottomSheet = ({ status, route, }) => {
14
- var _a, _b, _c, _d, _e;
13
+ var _a, _b, _c, _d, _e, _f, _g;
15
14
  const { t } = useTranslation();
16
15
  const { navigateBack } = useNavigateBack();
17
16
  const ref = useRef(null);
@@ -31,41 +30,31 @@ export const StatusBottomSheet = ({ status, route, }) => {
31
30
  clearFromAmount();
32
31
  (_a = ref.current) === null || _a === void 0 ? void 0 : _a.closeDrawer();
33
32
  };
34
- const { title, message } = useMemo(() => {
35
- var _a, _b;
36
- switch (status) {
37
- case 'success':
38
- return {
39
- title: t('swap.success.title.fundsReceived'),
40
- message: t('swap.success.message.fundsReceived', {
41
- amount: token === null || token === void 0 ? void 0 : token.amount,
42
- tokenSymbol: token === null || token === void 0 ? void 0 : token.symbol,
43
- chainName: (_a = getChainById(route.toChainId)) === null || _a === void 0 ? void 0 : _a.name,
44
- }),
45
- };
46
- case 'error': {
47
- const step = route.steps.find((step) => {
48
- var _a;
49
- return (_a = step.execution) === null || _a === void 0 ? void 0 : _a.process.some((process) => process.status === 'FAILED');
50
- });
51
- const process = (_b = step === null || step === void 0 ? void 0 : step.execution) === null || _b === void 0 ? void 0 : _b.process.find((process) => process.status === 'FAILED');
52
- if (!step || !process) {
53
- return {};
54
- }
55
- return getProcessMessage(t, getChainById, step, process);
33
+ let title;
34
+ let message;
35
+ switch (status) {
36
+ case 'success':
37
+ title = t('swap.success.title.fundsReceived');
38
+ message = t('swap.success.message.fundsReceived', {
39
+ amount: token === null || token === void 0 ? void 0 : token.amount,
40
+ tokenSymbol: token === null || token === void 0 ? void 0 : token.symbol,
41
+ chainName: (_a = getChainById(route.toChainId)) === null || _a === void 0 ? void 0 : _a.name,
42
+ });
43
+ break;
44
+ case 'error': {
45
+ const step = route.steps.find((step) => { var _a; return ((_a = step.execution) === null || _a === void 0 ? void 0 : _a.status) === 'FAILED'; });
46
+ const process = (_b = step === null || step === void 0 ? void 0 : step.execution) === null || _b === void 0 ? void 0 : _b.process.find((process) => process.status === 'FAILED');
47
+ if (!step || !process) {
48
+ break;
56
49
  }
57
- default:
58
- return {};
50
+ const processMessage = getProcessMessage(t, getChainById, step, process);
51
+ title = processMessage.title;
52
+ message = processMessage.message;
53
+ break;
59
54
  }
60
- }, [
61
- getChainById,
62
- route.steps,
63
- route.toChainId,
64
- status,
65
- t,
66
- token === null || token === void 0 ? void 0 : token.amount,
67
- token === null || token === void 0 ? void 0 : token.symbol,
68
- ]);
55
+ default:
56
+ break;
57
+ }
69
58
  useEffect(() => {
70
59
  var _a, _b;
71
60
  if ((status === 'success' || status === 'error') &&
@@ -74,5 +63,5 @@ export const StatusBottomSheet = ({ status, route, }) => {
74
63
  (_b = ref.current) === null || _b === void 0 ? void 0 : _b.openDrawer();
75
64
  }
76
65
  }, [refetchBalance, status]);
77
- return (_jsx(BottomSheet, Object.assign({ ref: ref }, { children: _jsxs(Box, Object.assign({ p: 3 }, { children: [_jsxs(IconContainer, { children: [_jsxs(IconCircle, Object.assign({ status: status, mb: 1 }, { children: [status === 'idle' ? (_jsx(InfoIcon, { color: "primary", sx: iconStyles })) : null, status === 'success' ? (_jsx(DoneIcon, { color: "success", sx: iconStyles })) : null, status === 'error' ? (_jsx(WarningIcon, { color: "error", sx: iconStyles })) : null] })), _jsx(Typography, Object.assign({ py: 1, fontSize: 18, fontWeight: 700 }, { children: title })), status === 'success' ? (_jsx(Token, { token: Object.assign(Object.assign({}, route.toToken), { amount: (_e = (_c = (_b = (_a = route.steps.at(-1)) === null || _a === void 0 ? void 0 : _a.execution) === null || _b === void 0 ? void 0 : _b.toAmount) !== null && _c !== void 0 ? _c : (_d = route.steps.at(-1)) === null || _d === void 0 ? void 0 : _d.estimate.toAmount) !== null && _e !== void 0 ? _e : route.toAmount }), py: 1 })) : null] }), _jsx(Typography, Object.assign({ pt: 2, pb: 1 }, { children: message })), _jsx(Box, Object.assign({ mt: 2 }, { children: _jsxs(Button, Object.assign({ variant: "contained", fullWidth: true, onClick: status === 'success' ? handleDone : handleClose }, { children: [status === 'idle' ? t('button.okay') : null, status === 'success' ? t('button.done') : null, status === 'error' ? t('button.tryAgain') : null] })) })), status === 'success' ? (_jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(Button, Object.assign({ variant: "outlined", fullWidth: true, onClick: handleClose }, { children: t('button.seeDetails') })) }))) : null] })) })));
66
+ return (_jsx(BottomSheet, Object.assign({ ref: ref }, { children: _jsxs(Box, Object.assign({ p: 3 }, { children: [_jsxs(IconContainer, { children: [_jsxs(IconCircle, Object.assign({ status: status, mb: 1 }, { children: [status === 'idle' ? (_jsx(InfoIcon, { color: "primary", sx: iconStyles })) : null, status === 'success' ? (_jsx(DoneIcon, { color: "success", sx: iconStyles })) : null, status === 'error' ? (_jsx(WarningIcon, { color: "error", sx: iconStyles })) : null] })), _jsx(Typography, Object.assign({ py: 1, fontSize: 18, fontWeight: 700 }, { children: title })), status === 'success' ? (_jsx(Token, { token: Object.assign(Object.assign({}, route.toToken), { amount: (_g = (_e = (_d = (_c = route.steps.at(-1)) === null || _c === void 0 ? void 0 : _c.execution) === null || _d === void 0 ? void 0 : _d.toAmount) !== null && _e !== void 0 ? _e : (_f = route.steps.at(-1)) === null || _f === void 0 ? void 0 : _f.estimate.toAmount) !== null && _g !== void 0 ? _g : route.toAmount }), py: 1 })) : null] }), _jsx(Typography, Object.assign({ pt: 2, pb: 1 }, { children: message })), _jsx(Box, Object.assign({ mt: 2 }, { children: _jsxs(Button, Object.assign({ variant: "contained", fullWidth: true, onClick: status === 'success' ? handleDone : handleClose }, { children: [status === 'idle' ? t('button.okay') : null, status === 'success' ? t('button.done') : null, status === 'error' ? t('button.tryAgain') : null] })) })), status === 'success' ? (_jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(Button, Object.assign({ variant: "outlined", fullWidth: true, onClick: handleClose }, { children: t('button.seeDetails') })) }))) : null] })) })));
78
67
  };
@@ -1,6 +1,16 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
1
10
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
11
  import { Box, Button } from '@mui/material';
3
12
  import { Fragment } from 'react';
13
+ import { useFormContext } from 'react-hook-form';
4
14
  import { useTranslation } from 'react-i18next';
5
15
  import { useLocation } from 'react-router-dom';
6
16
  import { GasSufficiencyMessage } from '../../components/GasSufficiencyMessage';
@@ -8,25 +18,28 @@ import { Step } from '../../components/Step';
8
18
  import { StepDivider } from '../../components/StepDivider';
9
19
  import { SwapButton } from '../../components/SwapButton';
10
20
  import { useNavigateBack, useRouteExecution } from '../../hooks';
21
+ import { SwapFormKey } from '../../providers';
11
22
  import { StatusBottomSheet } from './StatusBottomSheet';
12
23
  import { Container } from './SwapPage.style';
13
24
  export const SwapPage = () => {
14
25
  const { t } = useTranslation();
15
26
  const { state } = useLocation();
16
27
  const { navigateBack } = useNavigateBack();
28
+ const { setValue, formState: { isValid, isValidating }, } = useFormContext();
17
29
  const { route, status, executeRoute, restartRoute, deleteRoute } = useRouteExecution(state === null || state === void 0 ? void 0 : state.routeId);
18
30
  const handleRemoveRoute = () => {
19
31
  navigateBack();
20
32
  deleteRoute();
21
33
  };
22
- const handleSwapClick = () => {
34
+ const handleSwapClick = () => __awaiter(void 0, void 0, void 0, function* () {
23
35
  if (status === 'idle') {
24
36
  executeRoute();
37
+ setValue(SwapFormKey.FromAmount, '');
25
38
  }
26
39
  if (status === 'error') {
27
40
  restartRoute();
28
41
  }
29
- };
42
+ });
30
43
  // eslint-disable-next-line consistent-return
31
44
  const getSwapButtonText = () => {
32
45
  if (status === 'idle') {
@@ -41,5 +54,5 @@ export const SwapPage = () => {
41
54
  return (_jsxs(Fragment, { children: [_jsx(Step, { step: step, fromToken: index === 0
42
55
  ? Object.assign(Object.assign({}, step.action.fromToken), { amount: step.action.fromAmount }) : undefined, toToken: index === steps.length - 1
43
56
  ? Object.assign(Object.assign({}, step.action.toToken), { amount: (_b = (_a = step.execution) === null || _a === void 0 ? void 0 : _a.toAmount) !== null && _b !== void 0 ? _b : step.estimate.toAmount }) : undefined }), steps.length > 1 && index !== steps.length - 1 ? (_jsx(StepDivider, {})) : null] }, step.id));
44
- }), status === 'idle' ? (_jsx(GasSufficiencyMessage, { route: route, mt: 2 })) : null, status === 'idle' || status === 'error' ? (_jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(SwapButton, { text: getSwapButtonText(), onClick: handleSwapClick, currentRoute: route }) }))) : null, status === 'error' ? (_jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(Button, Object.assign({ variant: "outlined", onClick: handleRemoveRoute, fullWidth: true }, { children: t('button.removeSwap') })) }))) : null, route && status ? (_jsx(StatusBottomSheet, { status: status, route: route })) : null] }));
57
+ }), status === 'idle' ? (_jsx(GasSufficiencyMessage, { route: route, mt: 2 })) : null, status === 'idle' || status === 'error' ? (_jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(SwapButton, { text: getSwapButtonText(), onClick: handleSwapClick, currentRoute: route, disable: status === 'idle' && (isValidating || !isValid) }) }))) : null, status === 'error' ? (_jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(Button, Object.assign({ variant: "outlined", onClick: handleRemoveRoute, fullWidth: true }, { children: t('button.removeSwap') })) }))) : null, route && status ? (_jsx(StatusBottomSheet, { status: status, route: route })) : null] }));
45
58
  };
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useEffect } from 'react';
3
3
  import { useLocation, useNavigate } from 'react-router-dom';
4
- import { useSetHeaderAction } from '../../components/Header';
4
+ import { useHeaderActionStore } from '../../components/Header';
5
5
  import { ProgressToNextUpdate } from '../../components/ProgressToNextUpdate';
6
6
  import { SwapRouteCard, SwapRouteCardSkeleton, SwapRouteNotFoundCard, } from '../../components/SwapRouteCard';
7
7
  import { useSwapRoutes } from '../../hooks';
@@ -11,7 +11,6 @@ import { Stack } from './SwapRoutesPage.style';
11
11
  export const SwapRoutesPage = () => {
12
12
  const navigate = useNavigate();
13
13
  const { pathname } = useLocation();
14
- const setHeaderAction = useSetHeaderAction();
15
14
  const { routes: swapRoutes, isLoading, isFetching, dataUpdatedAt, refetchTime, refetch, } = useSwapRoutes();
16
15
  const setExecutableRoute = useSetExecutableRoute();
17
16
  const handleRouteClick = (route) => {
@@ -28,8 +27,10 @@ export const SwapRoutesPage = () => {
28
27
  // eslint-disable-next-line react-hooks/exhaustive-deps
29
28
  }, []);
30
29
  useEffect(() => {
31
- return setHeaderAction(_jsx(ProgressToNextUpdate, { updatedAt: dataUpdatedAt || new Date().getTime(), timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: { marginRight: -1 }, size: "medium", edge: "end" }));
32
- }, [dataUpdatedAt, isFetching, refetch, refetchTime, setHeaderAction]);
30
+ return useHeaderActionStore
31
+ .getState()
32
+ .setAction(_jsx(ProgressToNextUpdate, { updatedAt: dataUpdatedAt || new Date().getTime(), timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: { marginRight: -1 }, size: "medium", edge: "end" }));
33
+ }, [dataUpdatedAt, isFetching, refetch, refetchTime]);
33
34
  const routeNotFound = !(swapRoutes === null || swapRoutes === void 0 ? void 0 : swapRoutes.length) && !isLoading && !isFetching;
34
35
  return (_jsx(Stack, Object.assign({ direction: "column", spacing: 2, flex: 1 }, { children: routeNotFound ? (_jsx(SwapRouteNotFoundCard, {})) : isLoading || isFetching ? (Array.from({ length: 3 }).map((_, index) => (_jsx(SwapRouteCardSkeleton, {}, index)))) : (swapRoutes === null || swapRoutes === void 0 ? void 0 : swapRoutes.map((route) => (_jsx(SwapRouteCard, { route: route, onClick: () => handleRouteClick(route) }, route.id)))) })));
35
36
  };
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import LIFI from '@lifi/sdk';
3
+ export declare const useLiFi: () => LIFI;
4
+ export declare const SDKProvider: React.FC<React.PropsWithChildren>;
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import LIFI from '@lifi/sdk';
3
+ import { createContext, useContext, useMemo } from 'react';
4
+ import { useWidgetConfig } from '../WidgetProvider';
5
+ let lifi;
6
+ const SDKContext = createContext(null);
7
+ export const useLiFi = () => useContext(SDKContext);
8
+ export const SDKProvider = ({ children, }) => {
9
+ const { sdkConfig, integrator } = useWidgetConfig();
10
+ const value = useMemo(() => {
11
+ const config = Object.assign(Object.assign({}, sdkConfig), { defaultRouteOptions: Object.assign(Object.assign({}, sdkConfig === null || sdkConfig === void 0 ? void 0 : sdkConfig.defaultRouteOptions), { integrator: integrator !== null && integrator !== void 0 ? integrator : window.location.hostname }) });
12
+ if (!lifi) {
13
+ lifi = new LIFI(Object.assign({ disableVersionCheck: true }, config));
14
+ }
15
+ lifi.setConfig(config);
16
+ return lifi;
17
+ }, [integrator, sdkConfig]);
18
+ return _jsx(SDKContext.Provider, Object.assign({ value: value }, { children: children }));
19
+ };
@@ -0,0 +1 @@
1
+ export * from './SDKProvider';
@@ -0,0 +1 @@
1
+ export * from './SDKProvider';
@@ -1,8 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { ChainId } from '@lifi/sdk';
3
- import { useEffect } from 'react';
4
2
  import { FormProvider, useForm } from 'react-hook-form';
5
- import { useWallet } from '../WalletProvider';
6
3
  import { useWidgetConfig } from '../WidgetProvider';
7
4
  import { SwapFormKey } from './types';
8
5
  export const formDefaultValues = {
@@ -11,37 +8,14 @@ export const formDefaultValues = {
11
8
  [SwapFormKey.TokenSearchFilter]: '',
12
9
  };
13
10
  export const SwapFormProvider = ({ children, }) => {
14
- const { account } = useWallet();
15
11
  const { fromChain, fromToken, fromAmount, toChain, toToken, toAddress } = useWidgetConfig();
16
12
  const methods = useForm({
17
- defaultValues: Object.assign(Object.assign({}, formDefaultValues), { fromChain: fromChain !== null && fromChain !== void 0 ? fromChain : ChainId.ETH, fromToken, fromAmount: (typeof fromAmount === 'number'
13
+ defaultValues: Object.assign(Object.assign({}, formDefaultValues), { fromChain,
14
+ fromToken, fromAmount: (typeof fromAmount === 'number'
18
15
  ? fromAmount === null || fromAmount === void 0 ? void 0 : fromAmount.toPrecision()
19
- : fromAmount) || formDefaultValues.fromAmount, toChain: toChain !== null && toChain !== void 0 ? toChain : ChainId.ETH, toToken,
16
+ : fromAmount) || formDefaultValues.fromAmount, toChain,
17
+ toToken,
20
18
  toAddress }),
21
19
  });
22
- // Set wallet chain as default if no chains are provided by config and if they were not changed during widget usage
23
- useEffect(() => {
24
- if (!account.isActive || !account.chainId) {
25
- return;
26
- }
27
- const { isDirty: isFromChainDirty, isTouched: isFromChainTouched } = methods.getFieldState(SwapFormKey.FromChain, methods.formState);
28
- const { isDirty: isToChainDirty, isTouched: isToChainTouched } = methods.getFieldState(SwapFormKey.ToChain, methods.formState);
29
- if (!fromChain && !isFromChainDirty && !isFromChainTouched) {
30
- methods.setValue(SwapFormKey.FromChain, account.chainId, {
31
- shouldDirty: false,
32
- shouldTouch: false,
33
- });
34
- }
35
- if (!toChain &&
36
- !isToChainDirty &&
37
- !isToChainTouched &&
38
- !isFromChainDirty &&
39
- !isFromChainTouched) {
40
- methods.setValue(SwapFormKey.ToChain, account.chainId, {
41
- shouldDirty: false,
42
- shouldTouch: false,
43
- });
44
- }
45
- }, [account.chainId, account.isActive, fromChain, methods, toChain]);
46
20
  return _jsx(FormProvider, Object.assign({}, methods, { children: children }));
47
21
  };
@@ -16,12 +16,12 @@ export declare type SwapFormValues = {
16
16
  [SwapFormKey.ToToken]: string;
17
17
  [SwapFormKey.ToAddress]: string;
18
18
  };
19
- export declare type SwapFormDirection = 'from' | 'to';
19
+ export declare type SwapFormType = 'from' | 'to';
20
20
  export declare const SwapFormKeyHelper: {
21
- getChainKey: (formType: SwapFormDirection) => 'fromChain' | 'toChain';
22
- getTokenKey: (formType: SwapFormDirection) => 'fromToken' | 'toToken';
23
- getAmountKey: (formType: SwapFormDirection) => 'fromAmount' | 'toAmount';
21
+ getChainKey: (formType: SwapFormType) => 'fromChain' | 'toChain';
22
+ getTokenKey: (formType: SwapFormType) => 'fromToken' | 'toToken';
23
+ getAmountKey: (formType: SwapFormType) => 'fromAmount' | 'toAmount';
24
24
  };
25
25
  export interface SwapFormTypeProps {
26
- formType: SwapFormDirection;
26
+ formType: SwapFormType;
27
27
  }
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ export declare const TelemetryProvider: React.FC<{
3
+ children: React.ReactElement<any, any> | null;
4
+ }>;
@@ -0,0 +1,7 @@
1
+ import { useWidgetConfig } from '..';
2
+ import { useTelemetry } from '../../hooks';
3
+ export const TelemetryProvider = ({ children }) => {
4
+ const config = useWidgetConfig();
5
+ useTelemetry(config === null || config === void 0 ? void 0 : config.disableTelemetry);
6
+ return children;
7
+ };
@@ -0,0 +1 @@
1
+ export * from './TelemetryProvider';
@@ -0,0 +1 @@
1
+ export * from './TelemetryProvider';
@@ -1,11 +1,8 @@
1
1
  import type { Signer } from 'ethers';
2
2
  import type { FC, PropsWithChildren } from 'react';
3
- import type { WidgetWalletManagement } from '../../types';
4
3
  import type { WalletContextProps } from './types';
5
4
  export declare const useWallet: () => WalletContextProps;
6
- export declare const WalletProvider: FC<PropsWithChildren<{
7
- walletManagement?: WidgetWalletManagement;
8
- }>>;
5
+ export declare const WalletProvider: FC<PropsWithChildren>;
9
6
  export declare const extractAccountFromSigner: (signer?: Signer) => Promise<{
10
7
  address: string | undefined;
11
8
  isActive: boolean;
@@ -10,6 +10,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import { jsx as _jsx } from "react/jsx-runtime";
11
11
  import { addChain as walletAddChain, switchChain as walletSwitchChain, switchChainAndAddToken, useLiFiWalletManagement, } from '@lifi/wallet-management';
12
12
  import { createContext, useCallback, useContext, useEffect, useMemo, useState, } from 'react';
13
+ import { useFormContext } from 'react-hook-form';
14
+ import { useChainOrderStore } from '../../stores/chains';
15
+ import { SwapFormKey } from '../SwapFormProvider';
16
+ import { isItemAllowed, useWidgetConfig } from '../WidgetProvider';
13
17
  const stub = () => {
14
18
  throw new Error('You forgot to wrap your component in <WalletProvider>.');
15
19
  };
@@ -23,7 +27,9 @@ const initialContext = {
23
27
  };
24
28
  const WalletContext = createContext(initialContext);
25
29
  export const useWallet = () => useContext(WalletContext);
26
- export const WalletProvider = ({ children, walletManagement }) => {
30
+ export const WalletProvider = ({ children }) => {
31
+ const { walletManagement, fromChain, toChain, chains, disabledChains } = useWidgetConfig();
32
+ const methods = useFormContext();
27
33
  const { connect: walletManagementConnect, disconnect: walletManagementDisconnect, signer, provider, } = useLiFiWalletManagement();
28
34
  const [account, setAccount] = useState({});
29
35
  const connect = useCallback((wallet) => __awaiter(void 0, void 0, void 0, function* () {
@@ -88,6 +94,58 @@ export const WalletProvider = ({ children, walletManagement }) => {
88
94
  account,
89
95
  provider,
90
96
  }), [account, addChain, addToken, connect, disconnect, provider, switchChain]);
97
+ // Set wallet chain as default if no chains are provided by config and if they were not changed during widget usage
98
+ useEffect(() => {
99
+ const chainAllowed = account.chainId && isItemAllowed(account.chainId, chains, disabledChains);
100
+ if (!account.isActive || !account.chainId || !chainAllowed) {
101
+ return;
102
+ }
103
+ const [fromChainValue, toChainValue] = methods.getValues([
104
+ SwapFormKey.FromChain,
105
+ SwapFormKey.ToChain,
106
+ ]);
107
+ const { isDirty: isFromChainDirty } = methods.getFieldState(SwapFormKey.FromChain, methods.formState);
108
+ const { isDirty: isToChainDirty } = methods.getFieldState(SwapFormKey.ToChain, methods.formState);
109
+ const { isDirty: isFromTokenDirty } = methods.getFieldState(SwapFormKey.FromToken, methods.formState);
110
+ const { isDirty: isToTokenDirty } = methods.getFieldState(SwapFormKey.ToToken, methods.formState);
111
+ const { chainOrder, setChain } = useChainOrderStore.getState();
112
+ // Users can switch chains in the wallet.
113
+ // If we don't have a chain in the ordered chain list we should add it.
114
+ setChain(account.chainId);
115
+ // If we ran out of slots for the ordered chain list and the current chain isn't there
116
+ // we should make a recently switched chain as current.
117
+ const hasFromChainInOrderedList = chainOrder.includes(fromChainValue);
118
+ const hasToChainInOrderedList = chainOrder.includes(toChainValue);
119
+ if ((!fromChain && !isFromChainDirty && !isFromTokenDirty) ||
120
+ !hasFromChainInOrderedList) {
121
+ methods.setValue(SwapFormKey.FromChain, account.chainId, {
122
+ shouldDirty: false,
123
+ });
124
+ methods.setValue(SwapFormKey.FromToken, '', {
125
+ shouldDirty: false,
126
+ });
127
+ methods.setValue(SwapFormKey.FromAmount, '', {
128
+ shouldDirty: false,
129
+ });
130
+ }
131
+ if ((!toChain && !isToChainDirty && !isToTokenDirty) ||
132
+ !hasToChainInOrderedList) {
133
+ methods.setValue(SwapFormKey.ToChain, account.chainId, {
134
+ shouldDirty: false,
135
+ });
136
+ methods.setValue(SwapFormKey.ToToken, '', {
137
+ shouldDirty: false,
138
+ });
139
+ }
140
+ }, [
141
+ account.chainId,
142
+ account.isActive,
143
+ chains,
144
+ disabledChains,
145
+ fromChain,
146
+ methods,
147
+ toChain,
148
+ ]);
91
149
  return (_jsx(WalletContext.Provider, Object.assign({ value: value }, { children: children })));
92
150
  };
93
151
  export const extractAccountFromSigner = (signer) => __awaiter(void 0, void 0, void 0, function* () {
@@ -10,20 +10,15 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
- import { checkPackageUpdates, getChainByKey } from '@lifi/sdk';
14
- import { createContext, useContext, useEffect, useMemo } from 'react';
15
- import { updateLiFiConfig } from '../../config/lifi';
16
- import { name, version } from '../../config/version';
17
- const stub = () => {
18
- throw new Error('You forgot to wrap your component in <WidgetProvider>.');
19
- };
13
+ import { getChainByKey } from '@lifi/sdk';
14
+ import { createContext, useContext, useMemo } from 'react';
20
15
  const initialContext = {
21
16
  disabledChains: [],
22
17
  };
23
18
  const WidgetContext = createContext(initialContext);
24
19
  export const useWidgetConfig = () => useContext(WidgetContext);
25
20
  export const WidgetProvider = (_a) => {
26
- var { children } = _a, _b = _a.config, _c = _b === void 0 ? {} : _b, { fromChain, fromToken, toChain, toToken, fromAmount, integrator } = _c, config = __rest(_c, ["fromChain", "fromToken", "toChain", "toToken", "fromAmount", "integrator"]);
21
+ var { children } = _a, _b = _a.config, _c = _b === void 0 ? {} : _b, { fromChain, fromToken, toChain, toToken, fromAmount } = _c, config = __rest(_c, ["fromChain", "fromToken", "toChain", "toToken", "fromAmount"]);
27
22
  const value = useMemo(() => {
28
23
  var _a, _b, _c, _d;
29
24
  try {
@@ -53,15 +48,5 @@ export const WidgetProvider = (_a) => {
53
48
  return config;
54
49
  }
55
50
  }, [config, fromAmount, fromChain, fromToken, toChain, toToken]);
56
- useEffect(() => {
57
- updateLiFiConfig({
58
- defaultRouteOptions: {
59
- integrator: integrator !== null && integrator !== void 0 ? integrator : window.location.hostname,
60
- },
61
- });
62
- }, [integrator]);
63
- useEffect(() => {
64
- checkPackageUpdates(name, version);
65
- }, []);
66
51
  return (_jsx(WidgetContext.Provider, Object.assign({ value: value }, { children: children })));
67
52
  };
@@ -1,2 +1,3 @@
1
1
  export * from './types';
2
+ export * from './utils';
2
3
  export * from './WidgetProvider';
@@ -1,2 +1,3 @@
1
1
  export * from './types';
2
+ export * from './utils';
2
3
  export * from './WidgetProvider';
@@ -0,0 +1,4 @@
1
+ export declare const isItemAllowed: <T>(chainId: T, chains?: {
2
+ allow?: T[] | undefined;
3
+ deny?: T[] | undefined;
4
+ } | undefined, disabledChains?: T[] | undefined) => boolean;
@@ -0,0 +1,9 @@
1
+ export const isItemAllowed = (chainId, chains,
2
+ /** @deprecated Remove in the next major release */
3
+ disabledChains) => {
4
+ var _a, _b;
5
+ if ((_a = chains === null || chains === void 0 ? void 0 : chains.allow) === null || _a === void 0 ? void 0 : _a.length) {
6
+ return chains.allow.includes(chainId);
7
+ }
8
+ return !((disabledChains === null || disabledChains === void 0 ? void 0 : disabledChains.includes(chainId)) || ((_b = chains === null || chains === void 0 ? void 0 : chains.deny) === null || _b === void 0 ? void 0 : _b.includes(chainId)));
9
+ };
@@ -1,4 +1,6 @@
1
+ export * from './SDKProvider';
1
2
  export * from './SwapFormProvider';
3
+ export * from './TelemetryProvider';
2
4
  export * from './ThemeProvider';
3
5
  export * from './WalletProvider';
4
6
  export * from './WidgetProvider';
@@ -1,4 +1,6 @@
1
+ export * from './SDKProvider';
1
2
  export * from './SwapFormProvider';
3
+ export * from './TelemetryProvider';
2
4
  export * from './ThemeProvider';
3
5
  export * from './WalletProvider';
4
6
  export * from './WidgetProvider';
@@ -0,0 +1,3 @@
1
+ export * from './types';
2
+ export * from './useChainOrder';
3
+ export * from './useChainOrderStore';
@@ -0,0 +1,3 @@
1
+ export * from './types';
2
+ export * from './useChainOrder';
3
+ export * from './useChainOrderStore';
@@ -0,0 +1,8 @@
1
+ export interface ChainOrderState {
2
+ chainOrder: number[];
3
+ availableChains: number[];
4
+ }
5
+ export interface ChainOrderStore extends ChainOrderState {
6
+ initializeChains(chainIds: number[]): number[];
7
+ setChain(chainId: number): void;
8
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare const useChainOrder: () => [number[], (chainId: number) => void];
@@ -0,0 +1,5 @@
1
+ import shallow from 'zustand/shallow';
2
+ import { useChainOrderStore } from './useChainOrderStore';
3
+ export const useChainOrder = () => {
4
+ return useChainOrderStore((state) => [state.chainOrder, state.setChain], shallow);
5
+ };
@@ -0,0 +1,19 @@
1
+ import type { ChainOrderStore } from './types';
2
+ export declare const maxChainToOrder = 9;
3
+ export declare const useChainOrderStore: import("zustand").UseBoundStore<Omit<Omit<import("zustand").StoreApi<ChainOrderStore>, "persist"> & {
4
+ persist: {
5
+ setOptions: (options: Partial<import("zustand/middleware").PersistOptions<ChainOrderStore, {
6
+ chainOrder: number[];
7
+ }>>) => void;
8
+ clearStorage: () => void;
9
+ rehydrate: () => Promise<void>;
10
+ hasHydrated: () => boolean;
11
+ onHydrate: (fn: (state: ChainOrderStore) => void) => () => void;
12
+ onFinishHydration: (fn: (state: ChainOrderStore) => void) => () => void;
13
+ getOptions: () => Partial<import("zustand/middleware").PersistOptions<ChainOrderStore, {
14
+ chainOrder: number[];
15
+ }>>;
16
+ };
17
+ }, "setState"> & {
18
+ setState(nextStateOrUpdater: ChainOrderStore | Partial<ChainOrderStore> | ((state: import("immer/dist/internal").WritableDraft<ChainOrderStore>) => void), shouldReplace?: boolean | undefined): void;
19
+ }>;
@@ -0,0 +1,39 @@
1
+ /* eslint-disable no-underscore-dangle */
2
+ import create from 'zustand';
3
+ import { persist } from 'zustand/middleware';
4
+ import { immer } from 'zustand/middleware/immer';
5
+ export const maxChainToOrder = 9;
6
+ export const useChainOrderStore = create()(persist(immer((set, get) => ({
7
+ chainOrder: [],
8
+ availableChains: [],
9
+ initializeChains: (chainIds) => {
10
+ set((state) => {
11
+ state.availableChains = chainIds;
12
+ state.chainOrder = state.chainOrder.filter((chainId) => chainIds.includes(chainId));
13
+ const chainsToAdd = chainIds.filter((chainId) => !state.chainOrder.includes(chainId));
14
+ if (state.chainOrder.length === maxChainToOrder ||
15
+ !chainsToAdd.length) {
16
+ return;
17
+ }
18
+ const chainsToAddLength = maxChainToOrder - state.chainOrder.length;
19
+ for (let index = 0; index < chainsToAddLength; index++) {
20
+ state.chainOrder.push(chainsToAdd[index]);
21
+ }
22
+ });
23
+ return get().chainOrder;
24
+ },
25
+ setChain: (chainId) => set((state) => {
26
+ if (state.chainOrder.includes(chainId) ||
27
+ !state.availableChains.includes(chainId)) {
28
+ return;
29
+ }
30
+ state.chainOrder.unshift(chainId);
31
+ if (state.chainOrder.length > maxChainToOrder) {
32
+ state.chainOrder.pop();
33
+ }
34
+ }),
35
+ })), {
36
+ name: 'li.fi-widget-chains-order',
37
+ version: 0,
38
+ partialize: (state) => ({ chainOrder: state.chainOrder }),
39
+ }));
@@ -1,5 +1,6 @@
1
1
  export * from './types';
2
- export * from './useExecutingRoutes';
2
+ export * from './useExecutingRoutesIds';
3
3
  export * from './useRouteStore';
4
4
  export * from './useSetExecutableRoute';
5
5
  export * from './useSwapHistory';
6
+ export * from './utils';
@@ -1,5 +1,6 @@
1
1
  export * from './types';
2
- export * from './useExecutingRoutes';
2
+ export * from './useExecutingRoutesIds';
3
3
  export * from './useRouteStore';
4
4
  export * from './useSetExecutableRoute';
5
5
  export * from './useSwapHistory';
6
+ export * from './utils';
@@ -0,0 +1 @@
1
+ export declare const useExecutingRoutesIds: (address?: string) => string[];
@@ -0,0 +1,13 @@
1
+ import shallow from 'zustand/shallow';
2
+ import { useRouteStore } from './useRouteStore';
3
+ export const useExecutingRoutesIds = (address) => {
4
+ return useRouteStore((state) => Object.values(state.routes)
5
+ .filter((item) => item.route.fromAddress === address &&
6
+ (item.status === 'loading' || item.status === 'error'))
7
+ .sort((a, b) => {
8
+ var _a, _b, _c, _d;
9
+ return ((_b = (_a = b === null || b === void 0 ? void 0 : b.route.steps[0].execution) === null || _a === void 0 ? void 0 : _a.process[0].startedAt) !== null && _b !== void 0 ? _b : 0) -
10
+ ((_d = (_c = a === null || a === void 0 ? void 0 : a.route.steps[0].execution) === null || _c === void 0 ? void 0 : _c.process[0].startedAt) !== null && _d !== void 0 ? _d : 0);
11
+ })
12
+ .map(({ route }) => route.id), shallow);
13
+ };