@lifi/widget 1.14.1 → 1.16.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 (311) hide show
  1. package/App.js +21 -0
  2. package/cjs/App.js +21 -0
  3. package/cjs/components/ActiveSwaps/ActiveSwapItem.d.ts +5 -0
  4. package/cjs/components/ActiveSwaps/ActiveSwapItem.js +45 -0
  5. package/cjs/components/{SwapInProgress/SwapInProgress.d.ts → ActiveSwaps/ActiveSwaps.d.ts} +1 -1
  6. package/cjs/components/ActiveSwaps/ActiveSwaps.js +30 -0
  7. package/cjs/components/ActiveSwaps/ActiveSwaps.style.d.ts +78 -0
  8. package/cjs/components/ActiveSwaps/ActiveSwaps.style.js +40 -0
  9. package/cjs/components/ActiveSwaps/index.d.ts +2 -0
  10. package/cjs/components/ActiveSwaps/index.js +18 -0
  11. package/cjs/components/Card/Card.d.ts +7 -4
  12. package/cjs/components/Card/Card.js +38 -28
  13. package/cjs/{pages/SelectTokenPage → components/ChainSelect}/ChainSelect.d.ts +1 -1
  14. package/cjs/components/ChainSelect/ChainSelect.js +35 -0
  15. package/cjs/components/{SwapInProgress/SwapInProgress.style.d.ts → ChainSelect/ChainSelect.style.d.ts} +10 -19
  16. package/cjs/components/ChainSelect/ChainSelect.style.js +19 -0
  17. package/cjs/components/ChainSelect/index.d.ts +2 -0
  18. package/cjs/components/ChainSelect/index.js +18 -0
  19. package/cjs/components/ChainSelect/useChainSelect.d.ts +8 -0
  20. package/cjs/components/ChainSelect/useChainSelect.js +33 -0
  21. package/cjs/components/Header/Header.js +3 -11
  22. package/cjs/components/Header/NavigationHeader.js +10 -17
  23. package/cjs/components/Header/WalletHeader.js +4 -5
  24. package/cjs/components/PoweredBy/PoweredBy.style.d.ts +1 -1
  25. package/cjs/components/PoweredBy/PoweredBy.style.js +1 -0
  26. package/cjs/components/ReverseTokensButton/ReverseTokensButton.js +10 -10
  27. package/cjs/components/SelectTokenButton/SelectTokenButton.d.ts +1 -1
  28. package/cjs/components/SelectTokenButton/SelectTokenButton.js +3 -3
  29. package/{components/SwapInProgress/SwapInProgress.d.ts → cjs/components/SendToWallet/SendToWallet.d.ts} +1 -1
  30. package/cjs/components/SendToWallet/SendToWallet.js +53 -0
  31. package/cjs/components/SendToWallet/SendToWallet.style.d.ts +19 -0
  32. package/cjs/components/SendToWallet/SendToWallet.style.js +15 -0
  33. package/cjs/components/SendToWallet/index.d.ts +1 -0
  34. package/cjs/components/{SwapInProgress → SendToWallet}/index.js +1 -1
  35. package/cjs/components/Step/CircularProgress.js +1 -1
  36. package/cjs/components/Step/CircularProgress.style.js +1 -1
  37. package/cjs/components/Step/StepProcess.js +1 -5
  38. package/cjs/components/Step/StepProcess.style.d.ts +1 -1
  39. package/cjs/components/Step/StepTimer.d.ts +1 -0
  40. package/cjs/components/Step/StepTimer.js +6 -6
  41. package/cjs/components/SwapButton/SwapButton.js +10 -14
  42. package/cjs/components/SwapButton/types.d.ts +2 -2
  43. package/cjs/components/SwapInput/FormPriceHelperText.d.ts +1 -1
  44. package/cjs/components/SwapInput/FormPriceHelperText.js +4 -4
  45. package/cjs/components/SwapInput/SwapInput.d.ts +1 -1
  46. package/cjs/components/SwapInput/SwapInput.js +4 -4
  47. package/cjs/components/SwapInput/SwapInputAdornment.d.ts +1 -1
  48. package/cjs/components/SwapInput/SwapInputAdornment.js +4 -4
  49. package/cjs/components/SwapRouteCard/SwapRouteCard.js +5 -4
  50. package/cjs/components/SwapRouteCard/SwapRouteCard.style.js +3 -3
  51. package/cjs/components/TokenAvatar/TokenAvatar.style.js +0 -3
  52. package/cjs/components/TokenList/TokenList.js +14 -11
  53. package/cjs/components/TokenList/types.d.ts +1 -1
  54. package/cjs/config/theme.js +24 -23
  55. package/cjs/config/version.d.ts +1 -1
  56. package/cjs/config/version.js +1 -1
  57. package/cjs/hooks/index.d.ts +3 -0
  58. package/cjs/hooks/index.js +3 -0
  59. package/cjs/hooks/useChains.d.ts +1 -97
  60. package/cjs/hooks/useChains.js +8 -15
  61. package/cjs/hooks/useNavigateBack.d.ts +4 -0
  62. package/cjs/hooks/useNavigateBack.js +18 -0
  63. package/cjs/{components/Step/utils.d.ts → hooks/useProcessMessage.d.ts} +4 -0
  64. package/cjs/{components/Step/utils.js → hooks/useProcessMessage.js} +16 -10
  65. package/cjs/hooks/useRouteExecution.d.ts +1 -1
  66. package/cjs/hooks/useRouteExecution.js +20 -29
  67. package/cjs/hooks/useSwapRoutes.js +18 -7
  68. package/cjs/hooks/useWidgetEvents.d.ts +3 -0
  69. package/cjs/hooks/useWidgetEvents.js +13 -0
  70. package/cjs/i18n/en/translation.json +25 -15
  71. package/cjs/i18n/index.d.ts +20 -10
  72. package/cjs/index.d.ts +1 -0
  73. package/cjs/index.js +3 -1
  74. package/cjs/pages/ActiveSwapsPage/ActiveSwapsEmpty.d.ts +2 -0
  75. package/cjs/pages/ActiveSwapsPage/ActiveSwapsEmpty.js +18 -0
  76. package/cjs/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +2 -0
  77. package/cjs/pages/ActiveSwapsPage/ActiveSwapsPage.js +21 -0
  78. package/cjs/pages/ActiveSwapsPage/index.d.ts +1 -0
  79. package/cjs/pages/ActiveSwapsPage/index.js +17 -0
  80. package/cjs/pages/MainPage/MainPage.js +2 -2
  81. package/cjs/pages/MainPage/MainSwapButton.js +3 -1
  82. package/cjs/pages/MainPage/SwapRoutes.js +4 -1
  83. package/cjs/pages/SelectChainPage/SelectChainPage.d.ts +3 -0
  84. package/cjs/pages/SelectChainPage/SelectChainPage.js +33 -0
  85. package/cjs/pages/SelectChainPage/SelectChainPage.style.d.ts +21 -0
  86. package/cjs/pages/SelectChainPage/SelectChainPage.style.js +20 -0
  87. package/cjs/pages/SelectChainPage/index.d.ts +1 -0
  88. package/cjs/pages/SelectChainPage/index.js +17 -0
  89. package/cjs/pages/SelectTokenPage/SearchTokenInput.js +3 -3
  90. package/cjs/pages/SelectTokenPage/SelectTokenPage.d.ts +2 -4
  91. package/cjs/pages/SelectTokenPage/SelectTokenPage.js +4 -8
  92. package/cjs/pages/SelectWalletPage/SelectWalletPage.js +10 -10
  93. package/cjs/pages/SelectWalletPage/SelectWalletPage.style.d.ts +2 -27
  94. package/cjs/pages/SelectWalletPage/SelectWalletPage.style.js +4 -14
  95. package/cjs/pages/SettingsPage/AdvancedPreferences.js +2 -2
  96. package/cjs/pages/SettingsPage/ColorSchemeButtonGroup.js +2 -2
  97. package/cjs/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +1 -1
  98. package/cjs/pages/SettingsPage/EnabledBridgesSelect.js +3 -6
  99. package/cjs/pages/SettingsPage/EnabledExchangesSelect.js +3 -5
  100. package/cjs/pages/SettingsPage/RoutePrioritySelect.js +5 -1
  101. package/cjs/pages/SettingsPage/SettingsPage.js +2 -1
  102. package/cjs/pages/SettingsPage/ShowDestinationWallet.d.ts +2 -0
  103. package/cjs/pages/SettingsPage/ShowDestinationWallet.js +22 -0
  104. package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +4 -3
  105. package/cjs/pages/SwapHistoryPage/SwapHistoryPage.js +2 -2
  106. package/cjs/pages/SwapPage/StatusBottomSheet.js +29 -41
  107. package/cjs/pages/SwapPage/SwapPage.js +7 -3
  108. package/cjs/pages/SwapRoutesPage/SwapRoutesPage.js +1 -1
  109. package/cjs/providers/SwapFormProvider/SwapFormProvider.d.ts +1 -0
  110. package/cjs/providers/SwapFormProvider/SwapFormProvider.js +43 -9
  111. package/cjs/providers/SwapFormProvider/types.d.ts +3 -1
  112. package/cjs/providers/SwapFormProvider/types.js +1 -0
  113. package/cjs/providers/WalletProvider/WalletProvider.js +10 -4
  114. package/cjs/providers/WalletProvider/types.d.ts +4 -2
  115. package/cjs/providers/WidgetProvider/WidgetProvider.js +3 -7
  116. package/cjs/providers/index.d.ts +4 -0
  117. package/cjs/providers/index.js +20 -0
  118. package/cjs/stores/chains/index.d.ts +4 -0
  119. package/cjs/stores/chains/index.js +20 -0
  120. package/cjs/stores/chains/types.d.ts +8 -0
  121. package/cjs/stores/chains/types.js +2 -0
  122. package/cjs/stores/chains/useChainOrder.d.ts +1 -0
  123. package/cjs/stores/chains/useChainOrder.js +12 -0
  124. package/cjs/stores/chains/useChainOrderStore.d.ts +19 -0
  125. package/cjs/stores/chains/useChainOrderStore.js +42 -0
  126. package/cjs/stores/chains/useInitializeChainOrder.d.ts +1 -0
  127. package/cjs/stores/chains/useInitializeChainOrder.js +12 -0
  128. package/cjs/stores/route/index.d.ts +2 -1
  129. package/cjs/stores/route/index.js +2 -1
  130. package/cjs/stores/route/useExecutingRoutesIds.d.ts +1 -0
  131. package/cjs/stores/route/useExecutingRoutesIds.js +20 -0
  132. package/cjs/stores/route/useRouteStore.js +5 -4
  133. package/cjs/stores/route/utils.d.ts +4 -0
  134. package/cjs/stores/route/utils.js +21 -0
  135. package/cjs/stores/settings/types.d.ts +2 -1
  136. package/cjs/stores/settings/useSettingsStore.d.ts +4 -2
  137. package/cjs/stores/settings/useSettingsStore.js +6 -2
  138. package/cjs/types/events.d.ts +5 -0
  139. package/cjs/types/events.js +9 -0
  140. package/cjs/types/index.d.ts +1 -0
  141. package/cjs/types/index.js +1 -0
  142. package/cjs/types/widget.d.ts +3 -1
  143. package/cjs/utils/format.js +7 -2
  144. package/cjs/utils/navigationRoutes.d.ts +5 -0
  145. package/cjs/utils/navigationRoutes.js +31 -4
  146. package/components/ActiveSwaps/ActiveSwapItem.d.ts +5 -0
  147. package/components/ActiveSwaps/ActiveSwapItem.js +41 -0
  148. package/components/ActiveSwaps/ActiveSwaps.d.ts +3 -0
  149. package/components/ActiveSwaps/ActiveSwaps.js +26 -0
  150. package/components/ActiveSwaps/ActiveSwaps.style.d.ts +78 -0
  151. package/components/ActiveSwaps/ActiveSwaps.style.js +37 -0
  152. package/components/ActiveSwaps/index.d.ts +2 -0
  153. package/components/ActiveSwaps/index.js +2 -0
  154. package/components/Card/Card.d.ts +7 -4
  155. package/components/Card/Card.js +39 -29
  156. package/{pages/SelectTokenPage → components/ChainSelect}/ChainSelect.d.ts +1 -1
  157. package/components/ChainSelect/ChainSelect.js +31 -0
  158. package/components/{SwapInProgress/SwapInProgress.style.d.ts → ChainSelect/ChainSelect.style.d.ts} +10 -19
  159. package/components/ChainSelect/ChainSelect.style.js +16 -0
  160. package/components/ChainSelect/index.d.ts +2 -0
  161. package/components/ChainSelect/index.js +2 -0
  162. package/components/ChainSelect/useChainSelect.d.ts +8 -0
  163. package/components/ChainSelect/useChainSelect.js +29 -0
  164. package/components/Header/Header.js +2 -10
  165. package/components/Header/NavigationHeader.js +11 -18
  166. package/components/Header/WalletHeader.js +1 -2
  167. package/components/PoweredBy/PoweredBy.style.d.ts +1 -1
  168. package/components/PoweredBy/PoweredBy.style.js +1 -0
  169. package/components/ReverseTokensButton/ReverseTokensButton.js +1 -1
  170. package/components/SelectTokenButton/SelectTokenButton.d.ts +1 -1
  171. package/components/SelectTokenButton/SelectTokenButton.js +1 -1
  172. package/components/SendToWallet/SendToWallet.d.ts +3 -0
  173. package/components/SendToWallet/SendToWallet.js +49 -0
  174. package/components/SendToWallet/SendToWallet.style.d.ts +19 -0
  175. package/components/SendToWallet/SendToWallet.style.js +12 -0
  176. package/components/SendToWallet/index.d.ts +1 -0
  177. package/components/SendToWallet/index.js +1 -0
  178. package/components/Step/CircularProgress.js +3 -3
  179. package/components/Step/CircularProgress.style.js +1 -1
  180. package/components/Step/StepProcess.js +2 -6
  181. package/components/Step/StepProcess.style.d.ts +1 -1
  182. package/components/Step/StepTimer.d.ts +1 -0
  183. package/components/Step/StepTimer.js +6 -6
  184. package/components/SwapButton/SwapButton.js +7 -11
  185. package/components/SwapButton/types.d.ts +2 -2
  186. package/components/SwapInput/FormPriceHelperText.d.ts +1 -1
  187. package/components/SwapInput/FormPriceHelperText.js +1 -1
  188. package/components/SwapInput/SwapInput.d.ts +1 -1
  189. package/components/SwapInput/SwapInput.js +1 -1
  190. package/components/SwapInput/SwapInputAdornment.d.ts +1 -1
  191. package/components/SwapInput/SwapInputAdornment.js +1 -1
  192. package/components/SwapRouteCard/SwapRouteCard.js +5 -4
  193. package/components/SwapRouteCard/SwapRouteCard.style.js +3 -3
  194. package/components/TokenAvatar/TokenAvatar.style.js +0 -3
  195. package/components/TokenList/TokenList.js +7 -4
  196. package/components/TokenList/types.d.ts +1 -1
  197. package/config/theme.js +24 -23
  198. package/config/version.d.ts +1 -1
  199. package/config/version.js +1 -1
  200. package/hooks/index.d.ts +3 -0
  201. package/hooks/index.js +3 -0
  202. package/hooks/useChains.d.ts +1 -97
  203. package/hooks/useChains.js +8 -15
  204. package/hooks/useNavigateBack.d.ts +4 -0
  205. package/hooks/useNavigateBack.js +14 -0
  206. package/{components/Step/utils.d.ts → hooks/useProcessMessage.d.ts} +4 -0
  207. package/{pages/SwapPage/utils.js → hooks/useProcessMessage.js} +15 -10
  208. package/hooks/useRouteExecution.d.ts +1 -1
  209. package/hooks/useRouteExecution.js +21 -30
  210. package/hooks/useSwapRoutes.js +18 -7
  211. package/hooks/useWidgetEvents.d.ts +3 -0
  212. package/hooks/useWidgetEvents.js +6 -0
  213. package/i18n/en/translation.json +25 -15
  214. package/i18n/index.d.ts +20 -10
  215. package/index.d.ts +1 -0
  216. package/index.js +1 -0
  217. package/package.json +17 -19
  218. package/pages/ActiveSwapsPage/ActiveSwapsEmpty.d.ts +2 -0
  219. package/pages/ActiveSwapsPage/ActiveSwapsEmpty.js +14 -0
  220. package/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +2 -0
  221. package/pages/ActiveSwapsPage/ActiveSwapsPage.js +17 -0
  222. package/pages/ActiveSwapsPage/index.d.ts +1 -0
  223. package/pages/ActiveSwapsPage/index.js +1 -0
  224. package/pages/MainPage/MainPage.js +2 -2
  225. package/pages/MainPage/MainSwapButton.js +3 -1
  226. package/pages/MainPage/SwapRoutes.js +4 -1
  227. package/pages/SelectChainPage/SelectChainPage.d.ts +3 -0
  228. package/pages/SelectChainPage/SelectChainPage.js +29 -0
  229. package/pages/SelectChainPage/SelectChainPage.style.d.ts +21 -0
  230. package/pages/SelectChainPage/SelectChainPage.style.js +17 -0
  231. package/pages/SelectChainPage/index.d.ts +1 -0
  232. package/pages/SelectChainPage/index.js +1 -0
  233. package/pages/SelectTokenPage/SearchTokenInput.js +1 -1
  234. package/pages/SelectTokenPage/SelectTokenPage.d.ts +2 -4
  235. package/pages/SelectTokenPage/SelectTokenPage.js +5 -9
  236. package/pages/SelectWalletPage/SelectWalletPage.js +10 -10
  237. package/pages/SelectWalletPage/SelectWalletPage.style.d.ts +2 -27
  238. package/pages/SelectWalletPage/SelectWalletPage.style.js +4 -14
  239. package/pages/SettingsPage/AdvancedPreferences.js +2 -2
  240. package/pages/SettingsPage/ColorSchemeButtonGroup.js +1 -1
  241. package/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +1 -1
  242. package/pages/SettingsPage/EnabledBridgesSelect.js +4 -7
  243. package/pages/SettingsPage/EnabledExchangesSelect.js +4 -6
  244. package/pages/SettingsPage/RoutePrioritySelect.js +5 -1
  245. package/pages/SettingsPage/SettingsPage.js +2 -1
  246. package/pages/SettingsPage/ShowDestinationWallet.d.ts +2 -0
  247. package/pages/SettingsPage/ShowDestinationWallet.js +18 -0
  248. package/pages/SwapDetailsPage/SwapDetailsPage.js +5 -4
  249. package/pages/SwapHistoryPage/SwapHistoryPage.js +1 -1
  250. package/pages/SwapPage/StatusBottomSheet.js +30 -42
  251. package/pages/SwapPage/SwapPage.js +9 -5
  252. package/pages/SwapRoutesPage/SwapRoutesPage.js +1 -1
  253. package/providers/SwapFormProvider/SwapFormProvider.d.ts +1 -0
  254. package/providers/SwapFormProvider/SwapFormProvider.js +43 -9
  255. package/providers/SwapFormProvider/types.d.ts +3 -1
  256. package/providers/SwapFormProvider/types.js +1 -0
  257. package/providers/WalletProvider/WalletProvider.js +10 -4
  258. package/providers/WalletProvider/types.d.ts +4 -2
  259. package/providers/WidgetProvider/WidgetProvider.js +3 -7
  260. package/providers/index.d.ts +4 -0
  261. package/providers/index.js +4 -0
  262. package/stores/chains/index.d.ts +4 -0
  263. package/stores/chains/index.js +4 -0
  264. package/stores/chains/types.d.ts +8 -0
  265. package/stores/chains/types.js +1 -0
  266. package/stores/chains/useChainOrder.d.ts +1 -0
  267. package/stores/chains/useChainOrder.js +5 -0
  268. package/stores/chains/useChainOrderStore.d.ts +19 -0
  269. package/stores/chains/useChainOrderStore.js +36 -0
  270. package/stores/chains/useInitializeChainOrder.d.ts +1 -0
  271. package/stores/chains/useInitializeChainOrder.js +5 -0
  272. package/stores/route/index.d.ts +2 -1
  273. package/stores/route/index.js +2 -1
  274. package/stores/route/useExecutingRoutesIds.d.ts +1 -0
  275. package/stores/route/useExecutingRoutesIds.js +13 -0
  276. package/stores/route/useRouteStore.js +5 -4
  277. package/stores/route/utils.d.ts +4 -0
  278. package/stores/route/utils.js +15 -0
  279. package/stores/settings/types.d.ts +2 -1
  280. package/stores/settings/useSettingsStore.d.ts +4 -2
  281. package/stores/settings/useSettingsStore.js +6 -2
  282. package/tsconfig.cjs.tsbuildinfo +1 -1
  283. package/types/events.d.ts +5 -0
  284. package/types/events.js +6 -0
  285. package/types/index.d.ts +1 -0
  286. package/types/index.js +1 -0
  287. package/types/widget.d.ts +3 -1
  288. package/utils/format.js +7 -2
  289. package/utils/navigationRoutes.d.ts +5 -0
  290. package/utils/navigationRoutes.js +30 -3
  291. package/cjs/components/SwapButton/SwapButton.style.d.ts +0 -65
  292. package/cjs/components/SwapButton/SwapButton.style.js +0 -15
  293. package/cjs/components/SwapInProgress/SwapInProgress.js +0 -29
  294. package/cjs/components/SwapInProgress/SwapInProgress.style.js +0 -17
  295. package/cjs/components/SwapInProgress/index.d.ts +0 -1
  296. package/cjs/pages/SelectTokenPage/ChainSelect.js +0 -32
  297. package/cjs/pages/SwapPage/utils.d.ts +0 -6
  298. package/cjs/pages/SwapPage/utils.js +0 -93
  299. package/cjs/stores/route/useExecutingRoutes.d.ts +0 -2
  300. package/cjs/stores/route/useExecutingRoutes.js +0 -13
  301. package/components/Step/utils.js +0 -89
  302. package/components/SwapButton/SwapButton.style.d.ts +0 -65
  303. package/components/SwapButton/SwapButton.style.js +0 -12
  304. package/components/SwapInProgress/SwapInProgress.js +0 -25
  305. package/components/SwapInProgress/SwapInProgress.style.js +0 -14
  306. package/components/SwapInProgress/index.d.ts +0 -1
  307. package/components/SwapInProgress/index.js +0 -1
  308. package/pages/SelectTokenPage/ChainSelect.js +0 -28
  309. package/pages/SwapPage/utils.d.ts +0 -6
  310. package/stores/route/useExecutingRoutes.d.ts +0 -2
  311. package/stores/route/useExecutingRoutes.js +0 -6
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const ShowDestinationWallet: () => JSX.Element;
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box, Typography } from '@mui/material';
3
+ import { useTranslation } from 'react-i18next';
4
+ import { Switch } from '../../components/Switch';
5
+ import { useSetSettings, useSettings } from '../../stores';
6
+ export const ShowDestinationWallet = () => {
7
+ const { t } = useTranslation();
8
+ const [setValue] = useSetSettings();
9
+ const { showDestinationWallet } = useSettings(['showDestinationWallet']);
10
+ const onChange = (_, checked) => {
11
+ setValue('showDestinationWallet', checked);
12
+ };
13
+ return (_jsx(Box, Object.assign({ px: 3, pt: 2 }, { children: _jsxs(Box, Object.assign({ sx: {
14
+ display: 'flex',
15
+ justifyContent: 'space-between',
16
+ alignItems: 'center',
17
+ } }, { children: [_jsx(Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' } }, { children: _jsx(Typography, Object.assign({ variant: "subtitle1", color: "text.primary", lineHeight: "normal" }, { children: t(`settings.showDestinationWallet`) })) })), _jsx(Switch, { checked: showDestinationWallet, onChange: onChange })] })) })));
18
+ };
@@ -12,19 +12,20 @@ import { ContentCopy as ContentCopyIcon, DeleteOutline as DeleteIcon, } from '@m
12
12
  import { Box, Button, DialogActions, DialogContent, DialogContentText, DialogTitle, IconButton, Typography, } from '@mui/material';
13
13
  import { Fragment, useCallback, useEffect, useState } from 'react';
14
14
  import { useTranslation } from 'react-i18next';
15
- import { useLocation, useNavigate } from 'react-router-dom';
15
+ import { useLocation } from 'react-router-dom';
16
16
  import shallow from 'zustand/shallow';
17
17
  import { Card, CardTitle } from '../../components/Card';
18
18
  import { Dialog } from '../../components/Dialog';
19
19
  import { useSetHeaderAction } from '../../components/Header';
20
20
  import { Step } from '../../components/Step';
21
21
  import { StepDivider } from '../../components/StepDivider';
22
+ import { useNavigateBack } from '../../hooks';
22
23
  import { useRouteStore } from '../../stores';
23
24
  import { Container } from './SwapDetailsPage.style';
24
25
  export const SwapDetailsPage = () => {
25
26
  var _a, _b;
26
27
  const { t } = useTranslation();
27
- const navigate = useNavigate();
28
+ const { navigateBack } = useNavigateBack();
28
29
  const setHeaderAction = useSetHeaderAction();
29
30
  const { state } = useLocation();
30
31
  const [routeExecution, deleteRoute] = useRouteStore((store) => [store.routes[state === null || state === void 0 ? void 0 : state.routeId], store.deleteRoute], shallow);
@@ -33,7 +34,7 @@ export const SwapDetailsPage = () => {
33
34
  setOpen((open) => !open);
34
35
  }, []);
35
36
  const handleDeleteRoute = () => {
36
- navigate(-1);
37
+ navigateBack();
37
38
  if (routeExecution) {
38
39
  deleteRoute(routeExecution.route.id);
39
40
  }
@@ -58,5 +59,5 @@ export const SwapDetailsPage = () => {
58
59
  }), _jsxs(Card, Object.assign({ mt: 2 }, { children: [_jsxs(Box, Object.assign({ sx: {
59
60
  display: 'flex',
60
61
  flex: 1,
61
- } }, { children: [_jsx(CardTitle, Object.assign({ flex: 1 }, { children: t('swap.routeId') })), _jsx(Box, Object.assign({ mr: 1, mt: 1 }, { children: _jsx(IconButton, Object.assign({ size: "medium", "aria-label": "settings", onClick: copyRouteId }, { children: _jsx(ContentCopyIcon, { fontSize: "small" }) })) }))] })), _jsx(Typography, Object.assign({ variant: "body2", pt: 1, pb: 2, px: 2, sx: { wordBreak: 'break-all' } }, { children: routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route.id }))] })), _jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(Button, Object.assign({ variant: "contained", href: "https://discord.com/channels/849912621360218112/863689862514343946", target: "_blank", rel: "nofollow noreferrer", fullWidth: true }, { children: t('button.contactSupport') })) })), _jsxs(Dialog, Object.assign({ open: open, onClose: toggleDialog }, { children: [_jsx(DialogTitle, { children: t('swap.warning.title.deleteSwap') }), _jsx(DialogContent, { children: _jsx(DialogContentText, { children: t('swap.warning.message.deleteSwap') }) }), _jsxs(DialogActions, { children: [_jsx(Button, Object.assign({ onClick: toggleDialog }, { children: t('button.cancel') })), _jsx(Button, Object.assign({ onClick: handleDeleteRoute, autoFocus: true }, { children: t('button.delete') }))] })] }))] }));
62
+ } }, { children: [_jsx(CardTitle, Object.assign({ flex: 1 }, { children: t('swap.supportId') })), _jsx(Box, Object.assign({ mr: 1, mt: 1 }, { children: _jsx(IconButton, Object.assign({ size: "medium", "aria-label": "settings", onClick: copyRouteId }, { children: _jsx(ContentCopyIcon, { fontSize: "small" }) })) }))] })), _jsx(Typography, Object.assign({ variant: "body2", pt: 1, pb: 2, px: 2, sx: { wordBreak: 'break-all' } }, { children: routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route.id }))] })), _jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(Button, Object.assign({ variant: "contained", href: "https://discord.com/channels/849912621360218112/863689862514343946", target: "_blank", rel: "nofollow noreferrer", fullWidth: true }, { children: t('button.contactSupport') })) })), _jsxs(Dialog, Object.assign({ open: open, onClose: toggleDialog }, { children: [_jsx(DialogTitle, { children: t('swap.warning.title.deleteSwap') }), _jsx(DialogContent, { children: _jsx(DialogContentText, { children: t('swap.warning.message.deleteSwap') }) }), _jsxs(DialogActions, { children: [_jsx(Button, Object.assign({ onClick: toggleDialog }, { children: t('button.cancel') })), _jsx(Button, Object.assign({ onClick: handleDeleteRoute, autoFocus: true }, { children: t('button.delete') }))] })] }))] }));
62
63
  };
@@ -5,7 +5,7 @@ import { useCallback, useEffect, useState } from 'react';
5
5
  import { useTranslation } from 'react-i18next';
6
6
  import { Dialog } from '../../components/Dialog';
7
7
  import { useSetHeaderAction } from '../../components/Header';
8
- import { useWallet } from '../../providers/WalletProvider';
8
+ import { useWallet } from '../../providers';
9
9
  import { useRouteStore } from '../../stores';
10
10
  import { useSwapHistory } from '../../stores/route';
11
11
  import { SwapHistoryEmpty } from './SwapHistoryEmpty';
@@ -1,20 +1,18 @@
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
- import { useNavigate } from 'react-router-dom';
8
7
  import { BottomSheet } from '../../components/BottomSheet';
9
8
  import { Token } from '../../components/Token';
10
- import { useChains, useTokenBalance } from '../../hooks';
11
- import { SwapFormKey } from '../../providers/SwapFormProvider';
9
+ import { getProcessMessage, useChains, useNavigateBack, useTokenBalance, } from '../../hooks';
10
+ import { SwapFormKey } from '../../providers';
12
11
  import { IconCircle, IconContainer, iconStyles, } from './StatusBottomSheet.style';
13
- import { getProcessMessage } from './utils';
14
12
  export const StatusBottomSheet = ({ status, route, }) => {
15
- var _a, _b, _c, _d, _e;
13
+ var _a, _b, _c, _d, _e, _f, _g;
16
14
  const { t } = useTranslation();
17
- const navigate = useNavigate();
15
+ const { navigateBack } = useNavigateBack();
18
16
  const ref = useRef(null);
19
17
  const { getChainById } = useChains();
20
18
  const { token, refetch: refetchBalance } = useTokenBalance(route.toChainId, route.toToken.address);
@@ -25,48 +23,38 @@ export const StatusBottomSheet = ({ status, route, }) => {
25
23
  };
26
24
  const handleDone = () => {
27
25
  clearFromAmount();
28
- navigate(-1);
26
+ navigateBack();
29
27
  };
30
28
  const handleClose = () => {
31
29
  var _a;
32
30
  clearFromAmount();
33
31
  (_a = ref.current) === null || _a === void 0 ? void 0 : _a.closeDrawer();
34
32
  };
35
- const { title, message } = useMemo(() => {
36
- var _a, _b;
37
- switch (status) {
38
- case 'success':
39
- return {
40
- title: t('swap.success.title.fundsReceived'),
41
- message: t('swap.success.message.fundsReceived', {
42
- amount: token === null || token === void 0 ? void 0 : token.amount,
43
- tokenSymbol: token === null || token === void 0 ? void 0 : token.symbol,
44
- chainName: (_a = getChainById(route.toChainId)) === null || _a === void 0 ? void 0 : _a.name,
45
- }),
46
- };
47
- case 'error': {
48
- const step = route.steps.find((step) => {
49
- var _a;
50
- return (_a = step.execution) === null || _a === void 0 ? void 0 : _a.process.some((process) => process.status === 'FAILED');
51
- });
52
- 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');
53
- if (!step || !process) {
54
- return {};
55
- }
56
- 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;
57
49
  }
58
- default:
59
- return {};
50
+ const processMessage = getProcessMessage(t, getChainById, step, process);
51
+ title = processMessage.title;
52
+ message = processMessage.message;
53
+ break;
60
54
  }
61
- }, [
62
- getChainById,
63
- route.steps,
64
- route.toChainId,
65
- status,
66
- t,
67
- token === null || token === void 0 ? void 0 : token.amount,
68
- token === null || token === void 0 ? void 0 : token.symbol,
69
- ]);
55
+ default:
56
+ break;
57
+ }
70
58
  useEffect(() => {
71
59
  var _a, _b;
72
60
  if ((status === 'success' || status === 'error') &&
@@ -75,5 +63,5 @@ export const StatusBottomSheet = ({ status, route, }) => {
75
63
  (_b = ref.current) === null || _b === void 0 ? void 0 : _b.openDrawer();
76
64
  }
77
65
  }, [refetchBalance, status]);
78
- 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] })) })));
79
67
  };
@@ -1,27 +1,31 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Box, Button } from '@mui/material';
3
3
  import { Fragment } from 'react';
4
+ import { useFormContext } from 'react-hook-form';
4
5
  import { useTranslation } from 'react-i18next';
5
- import { useLocation, useNavigate } from 'react-router-dom';
6
+ import { useLocation } from 'react-router-dom';
6
7
  import { GasSufficiencyMessage } from '../../components/GasSufficiencyMessage';
7
8
  import { Step } from '../../components/Step';
8
9
  import { StepDivider } from '../../components/StepDivider';
9
10
  import { SwapButton } from '../../components/SwapButton';
10
- import { useRouteExecution } from '../../hooks';
11
+ import { useNavigateBack, useRouteExecution } from '../../hooks';
12
+ import { SwapFormKey } from '../../providers';
11
13
  import { StatusBottomSheet } from './StatusBottomSheet';
12
14
  import { Container } from './SwapPage.style';
13
15
  export const SwapPage = () => {
14
16
  const { t } = useTranslation();
15
17
  const { state } = useLocation();
16
- const navigate = useNavigate();
18
+ const { navigateBack } = useNavigateBack();
19
+ const { setValue, formState: { isValid, isValidating }, } = useFormContext();
17
20
  const { route, status, executeRoute, restartRoute, deleteRoute } = useRouteExecution(state === null || state === void 0 ? void 0 : state.routeId);
18
21
  const handleRemoveRoute = () => {
19
- navigate(-1);
22
+ navigateBack();
20
23
  deleteRoute();
21
24
  };
22
25
  const handleSwapClick = () => {
23
26
  if (status === 'idle') {
24
27
  executeRoute();
28
+ setValue(SwapFormKey.FromAmount, '');
25
29
  }
26
30
  if (status === 'error') {
27
31
  restartRoute();
@@ -41,5 +45,5 @@ export const SwapPage = () => {
41
45
  return (_jsxs(Fragment, { children: [_jsx(Step, { step: step, fromToken: index === 0
42
46
  ? Object.assign(Object.assign({}, step.action.fromToken), { amount: step.action.fromAmount }) : undefined, toToken: index === steps.length - 1
43
47
  ? 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] }));
48
+ }), 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
49
  };
@@ -12,7 +12,7 @@ export const SwapRoutesPage = () => {
12
12
  const navigate = useNavigate();
13
13
  const { pathname } = useLocation();
14
14
  const setHeaderAction = useSetHeaderAction();
15
- const { routes: swapRoutes, isLoading, isFetching, isFetched, dataUpdatedAt, refetchTime, refetch, } = useSwapRoutes();
15
+ const { routes: swapRoutes, isLoading, isFetching, dataUpdatedAt, refetchTime, refetch, } = useSwapRoutes();
16
16
  const setExecutableRoute = useSetExecutableRoute();
17
17
  const handleRouteClick = (route) => {
18
18
  setExecutableRoute(route);
@@ -1,6 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  export declare const formDefaultValues: {
3
3
  fromAmount: string;
4
+ toAddress: string;
4
5
  tokenSearchFilter: string;
5
6
  };
6
7
  export declare const SwapFormProvider: React.FC<React.PropsWithChildren<{}>>;
@@ -2,40 +2,74 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { ChainId } from '@lifi/sdk';
3
3
  import { useEffect } from 'react';
4
4
  import { FormProvider, useForm } from 'react-hook-form';
5
+ import { useChainOrderStore, useSetChainOrder } from '../../stores/chains';
5
6
  import { useWallet } from '../WalletProvider';
6
7
  import { useWidgetConfig } from '../WidgetProvider';
7
8
  import { SwapFormKey } from './types';
8
9
  export const formDefaultValues = {
9
10
  [SwapFormKey.FromAmount]: '',
11
+ [SwapFormKey.ToAddress]: '',
10
12
  [SwapFormKey.TokenSearchFilter]: '',
11
13
  };
12
14
  export const SwapFormProvider = ({ children, }) => {
15
+ const [setChain] = useSetChainOrder();
13
16
  const { account } = useWallet();
14
- const { fromChain, fromToken, fromAmount, toChain, toToken } = useWidgetConfig();
17
+ const { fromChain, fromToken, fromAmount, toChain, toToken, toAddress } = useWidgetConfig();
15
18
  const methods = useForm({
16
19
  defaultValues: Object.assign(Object.assign({}, formDefaultValues), { fromChain: fromChain !== null && fromChain !== void 0 ? fromChain : ChainId.ETH, fromToken, fromAmount: (typeof fromAmount === 'number'
17
20
  ? fromAmount === null || fromAmount === void 0 ? void 0 : fromAmount.toPrecision()
18
- : fromAmount) || formDefaultValues.fromAmount, toChain: toChain !== null && toChain !== void 0 ? toChain : ChainId.ETH, toToken }),
21
+ : fromAmount) || formDefaultValues.fromAmount, toChain: toChain !== null && toChain !== void 0 ? toChain : ChainId.ETH, toToken,
22
+ toAddress }),
19
23
  });
20
24
  // Set wallet chain as default if no chains are provided by config and if they were not changed during widget usage
21
25
  useEffect(() => {
22
26
  if (!account.isActive || !account.chainId) {
23
27
  return;
24
28
  }
25
- const { isDirty: isFromChainDirty, isTouched: isFromChainTouched } = methods.getFieldState(SwapFormKey.FromChain, methods.formState);
26
- if (!fromChain && !isFromChainDirty && !isFromChainTouched) {
29
+ const [fromChainValue, toChainValue] = methods.getValues([
30
+ SwapFormKey.FromChain,
31
+ SwapFormKey.ToChain,
32
+ ]);
33
+ const { isDirty: isFromChainDirty } = methods.getFieldState(SwapFormKey.FromChain, methods.formState);
34
+ const { isDirty: isToChainDirty } = methods.getFieldState(SwapFormKey.ToChain, methods.formState);
35
+ const { isDirty: isFromTokenDirty } = methods.getFieldState(SwapFormKey.FromToken, methods.formState);
36
+ const { isDirty: isToTokenDirty } = methods.getFieldState(SwapFormKey.ToToken, methods.formState);
37
+ // Users can switch chains in the wallet.
38
+ // If we don't have a chain in the ordered chain list we should add it.
39
+ setChain(account.chainId);
40
+ // If we ran out of slots for the ordered chain list and the current chain isn't there
41
+ // we should make a recently switched chain as current.
42
+ const { chainOrder } = useChainOrderStore.getState();
43
+ const hasFromChainInOrderedList = chainOrder.includes(fromChainValue);
44
+ const hasToChainInOrderedList = chainOrder.includes(toChainValue);
45
+ if ((!fromChain && !isFromChainDirty && !isFromTokenDirty) ||
46
+ !hasFromChainInOrderedList) {
27
47
  methods.setValue(SwapFormKey.FromChain, account.chainId, {
28
48
  shouldDirty: false,
29
- shouldTouch: false,
49
+ });
50
+ methods.setValue(SwapFormKey.FromToken, '', {
51
+ shouldDirty: false,
52
+ });
53
+ methods.setValue(SwapFormKey.FromAmount, '', {
54
+ shouldDirty: false,
30
55
  });
31
56
  }
32
- const { isDirty: isToChainDirty, isTouched: isToChainTouched } = methods.getFieldState(SwapFormKey.ToChain, methods.formState);
33
- if (!toChain && !isToChainDirty && !isToChainTouched) {
57
+ if ((!toChain && !isToChainDirty && !isToTokenDirty) ||
58
+ !hasToChainInOrderedList) {
34
59
  methods.setValue(SwapFormKey.ToChain, account.chainId, {
35
60
  shouldDirty: false,
36
- shouldTouch: false,
61
+ });
62
+ methods.setValue(SwapFormKey.ToToken, '', {
63
+ shouldDirty: false,
37
64
  });
38
65
  }
39
- }, [account.chainId, account.isActive, fromChain, methods, toChain]);
66
+ }, [
67
+ account.chainId,
68
+ account.isActive,
69
+ fromChain,
70
+ methods,
71
+ setChain,
72
+ toChain,
73
+ ]);
40
74
  return _jsx(FormProvider, Object.assign({}, methods, { children: children }));
41
75
  };
@@ -4,7 +4,8 @@ export declare enum SwapFormKey {
4
4
  FromToken = "fromToken",
5
5
  TokenSearchFilter = "tokenSearchFilter",
6
6
  ToChain = "toChain",
7
- ToToken = "toToken"
7
+ ToToken = "toToken",
8
+ ToAddress = "toAddress"
8
9
  }
9
10
  export declare type SwapFormValues = {
10
11
  [SwapFormKey.FromAmount]: string;
@@ -13,6 +14,7 @@ export declare type SwapFormValues = {
13
14
  [SwapFormKey.TokenSearchFilter]: string;
14
15
  [SwapFormKey.ToChain]: number;
15
16
  [SwapFormKey.ToToken]: string;
17
+ [SwapFormKey.ToAddress]: string;
16
18
  };
17
19
  export declare type SwapFormDirection = 'from' | 'to';
18
20
  export declare const SwapFormKeyHelper: {
@@ -6,6 +6,7 @@ export var SwapFormKey;
6
6
  SwapFormKey["TokenSearchFilter"] = "tokenSearchFilter";
7
7
  SwapFormKey["ToChain"] = "toChain";
8
8
  SwapFormKey["ToToken"] = "toToken";
9
+ SwapFormKey["ToAddress"] = "toAddress";
9
10
  })(SwapFormKey || (SwapFormKey = {}));
10
11
  export const SwapFormKeyHelper = {
11
12
  getChainKey: (formType) => `${formType}Chain`,
@@ -24,7 +24,7 @@ const initialContext = {
24
24
  const WalletContext = createContext(initialContext);
25
25
  export const useWallet = () => useContext(WalletContext);
26
26
  export const WalletProvider = ({ children, walletManagement }) => {
27
- const { connect: walletManagementConnect, disconnect: walletManagementDisconnect, signer, } = useLiFiWalletManagement();
27
+ const { connect: walletManagementConnect, disconnect: walletManagementDisconnect, signer, provider, } = useLiFiWalletManagement();
28
28
  const [account, setAccount] = useState({});
29
29
  const connect = useCallback((wallet) => __awaiter(void 0, void 0, void 0, function* () {
30
30
  if (walletManagement) {
@@ -68,8 +68,13 @@ export const WalletProvider = ({ children, walletManagement }) => {
68
68
  // keep account information up to date
69
69
  useEffect(() => {
70
70
  const updateAccount = () => __awaiter(void 0, void 0, void 0, function* () {
71
- var _a;
72
- const account = yield extractAccountFromSigner((_a = walletManagement === null || walletManagement === void 0 ? void 0 : walletManagement.signer) !== null && _a !== void 0 ? _a : signer);
71
+ let account;
72
+ if (walletManagement) {
73
+ account = yield extractAccountFromSigner(walletManagement === null || walletManagement === void 0 ? void 0 : walletManagement.signer);
74
+ }
75
+ else {
76
+ account = yield extractAccountFromSigner(signer);
77
+ }
73
78
  setAccount(account);
74
79
  });
75
80
  updateAccount();
@@ -81,7 +86,8 @@ export const WalletProvider = ({ children, walletManagement }) => {
81
86
  addChain,
82
87
  addToken,
83
88
  account,
84
- }), [account, addChain, addToken, connect, disconnect, switchChain]);
89
+ provider,
90
+ }), [account, addChain, addToken, connect, disconnect, provider, switchChain]);
85
91
  return (_jsx(WalletContext.Provider, Object.assign({ value: value }, { children: children })));
86
92
  };
87
93
  export const extractAccountFromSigner = (signer) => __awaiter(void 0, void 0, void 0, function* () {
@@ -1,8 +1,10 @@
1
+ import type { Web3Provider } from '@ethersproject/providers';
1
2
  import type { Token } from '@lifi/sdk';
2
3
  import type { Wallet } from '@lifi/wallet-management';
3
4
  import type { Signer } from 'ethers';
4
5
  export interface WalletContextProps {
5
6
  account: WalletAccount;
7
+ provider?: Web3Provider;
6
8
  addChain(chainId: number): Promise<boolean>;
7
9
  addToken(chainId: number, token: Token): Promise<void>;
8
10
  disconnect(): void;
@@ -10,8 +12,8 @@ export interface WalletContextProps {
10
12
  connect(wallet?: Wallet | undefined): Promise<void>;
11
13
  }
12
14
  export interface WalletAccount {
13
- address?: string;
14
15
  isActive?: boolean;
15
- signer?: Signer;
16
16
  chainId?: number;
17
+ address?: string;
18
+ signer?: Signer;
17
19
  }
@@ -23,7 +23,7 @@ const initialContext = {
23
23
  const WidgetContext = createContext(initialContext);
24
24
  export const useWidgetConfig = () => useContext(WidgetContext);
25
25
  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"]);
26
+ var { children } = _a, _b = _a.config, _c = _b === void 0 ? {} : _b, { fromChain, fromToken, toChain, toToken, fromAmount, integrator, sdkConfig } = _c, config = __rest(_c, ["fromChain", "fromToken", "toChain", "toToken", "fromAmount", "integrator", "sdkConfig"]);
27
27
  const value = useMemo(() => {
28
28
  var _a, _b, _c, _d;
29
29
  try {
@@ -54,12 +54,8 @@ export const WidgetProvider = (_a) => {
54
54
  }
55
55
  }, [config, fromAmount, fromChain, fromToken, toChain, toToken]);
56
56
  useEffect(() => {
57
- updateLiFiConfig({
58
- defaultRouteOptions: {
59
- integrator: integrator !== null && integrator !== void 0 ? integrator : window.location.hostname,
60
- },
61
- });
62
- }, [integrator]);
57
+ updateLiFiConfig(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 }) }));
58
+ }, [integrator, sdkConfig]);
63
59
  useEffect(() => {
64
60
  checkPackageUpdates(name, version);
65
61
  }, []);
@@ -0,0 +1,4 @@
1
+ export * from './SwapFormProvider';
2
+ export * from './ThemeProvider';
3
+ export * from './WalletProvider';
4
+ export * from './WidgetProvider';
@@ -0,0 +1,4 @@
1
+ export * from './SwapFormProvider';
2
+ export * from './ThemeProvider';
3
+ export * from './WalletProvider';
4
+ export * from './WidgetProvider';
@@ -0,0 +1,4 @@
1
+ export * from './types';
2
+ export * from './useChainOrder';
3
+ export * from './useChainOrderStore';
4
+ export * from './useInitializeChainOrder';
@@ -0,0 +1,4 @@
1
+ export * from './types';
2
+ export * from './useChainOrder';
3
+ export * from './useChainOrderStore';
4
+ export * from './useInitializeChainOrder';
@@ -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[]): void;
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,36 @@
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) => ({
7
+ chainOrder: [],
8
+ availableChains: [],
9
+ initializeChains: (chainIds) => set((state) => {
10
+ state.availableChains = chainIds;
11
+ state.chainOrder = state.chainOrder.filter((chainId) => chainIds.includes(chainId));
12
+ const chainsToAdd = chainIds.filter((chainId) => !state.chainOrder.includes(chainId));
13
+ if (state.chainOrder.length === maxChainToOrder ||
14
+ !chainsToAdd.length) {
15
+ return;
16
+ }
17
+ const chainsToAddLength = maxChainToOrder - state.chainOrder.length;
18
+ for (let index = 0; index < chainsToAddLength; index++) {
19
+ state.chainOrder.push(chainsToAdd[index]);
20
+ }
21
+ }),
22
+ setChain: (chainId) => set((state) => {
23
+ if (state.chainOrder.includes(chainId) ||
24
+ !state.availableChains.includes(chainId)) {
25
+ return;
26
+ }
27
+ state.chainOrder.unshift(chainId);
28
+ if (state.chainOrder.length > maxChainToOrder) {
29
+ state.chainOrder.pop();
30
+ }
31
+ }),
32
+ })), {
33
+ name: 'li.fi-widget-chains-order',
34
+ version: 0,
35
+ partialize: (state) => ({ chainOrder: state.chainOrder }),
36
+ }));
@@ -0,0 +1 @@
1
+ export declare const useSetChainOrder: () => [(chainId: number) => void, (chainIds: number[]) => void];
@@ -0,0 +1,5 @@
1
+ import shallow from 'zustand/shallow';
2
+ import { useChainOrderStore } from './useChainOrderStore';
3
+ export const useSetChainOrder = () => {
4
+ return useChainOrderStore((state) => [state.setChain, state.initializeChains], shallow);
5
+ };
@@ -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
+ };