@lifi/widget 1.15.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 (235) 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/{SwapsInProgress/SwapsInProgress.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 +0 -0
  14. package/cjs/components/ChainSelect/ChainSelect.js +35 -0
  15. package/cjs/components/{SwapsInProgress/SwapsInProgress.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 +1 -9
  22. package/cjs/components/Header/NavigationHeader.js +6 -11
  23. package/cjs/components/PoweredBy/PoweredBy.style.d.ts +1 -1
  24. package/cjs/components/PoweredBy/PoweredBy.style.js +1 -0
  25. package/cjs/components/SendToWallet/SendToWallet.js +6 -6
  26. package/cjs/components/Step/CircularProgress.js +1 -1
  27. package/cjs/components/Step/CircularProgress.style.js +1 -1
  28. package/cjs/components/Step/StepProcess.js +1 -5
  29. package/cjs/components/Step/StepProcess.style.d.ts +1 -1
  30. package/cjs/components/Step/StepTimer.d.ts +1 -0
  31. package/cjs/components/Step/StepTimer.js +6 -6
  32. package/cjs/components/SwapButton/SwapButton.js +5 -12
  33. package/cjs/components/SwapButton/types.d.ts +2 -2
  34. package/cjs/components/SwapRouteCard/SwapRouteCard.js +1 -1
  35. package/cjs/components/TokenAvatar/TokenAvatar.style.js +0 -3
  36. package/cjs/components/TokenList/TokenList.js +6 -2
  37. package/cjs/config/theme.js +24 -23
  38. package/cjs/config/version.d.ts +1 -1
  39. package/cjs/config/version.js +1 -1
  40. package/cjs/hooks/index.d.ts +2 -0
  41. package/cjs/hooks/index.js +2 -0
  42. package/cjs/hooks/useChains.d.ts +1 -97
  43. package/cjs/hooks/useChains.js +8 -15
  44. package/cjs/{components/Step/utils.d.ts → hooks/useProcessMessage.d.ts} +4 -0
  45. package/cjs/{components/Step/utils.js → hooks/useProcessMessage.js} +16 -10
  46. package/cjs/hooks/useRouteExecution.d.ts +1 -1
  47. package/cjs/hooks/useRouteExecution.js +20 -29
  48. package/cjs/hooks/useWidgetEvents.d.ts +3 -0
  49. package/cjs/hooks/useWidgetEvents.js +13 -0
  50. package/cjs/i18n/en/translation.json +13 -8
  51. package/cjs/i18n/index.d.ts +10 -5
  52. package/cjs/index.d.ts +1 -0
  53. package/cjs/index.js +3 -1
  54. package/cjs/pages/ActiveSwapsPage/ActiveSwapsEmpty.d.ts +2 -0
  55. package/cjs/pages/ActiveSwapsPage/ActiveSwapsEmpty.js +18 -0
  56. package/cjs/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +2 -0
  57. package/cjs/pages/ActiveSwapsPage/ActiveSwapsPage.js +21 -0
  58. package/cjs/pages/ActiveSwapsPage/index.d.ts +1 -0
  59. package/cjs/{components/SwapsInProgress → pages/ActiveSwapsPage}/index.js +1 -1
  60. package/cjs/pages/MainPage/MainPage.js +2 -3
  61. package/cjs/pages/MainPage/MainSwapButton.js +3 -1
  62. package/cjs/pages/MainPage/SwapRoutes.js +4 -1
  63. package/cjs/pages/SelectChainPage/SelectChainPage.d.ts +3 -0
  64. package/cjs/pages/SelectChainPage/SelectChainPage.js +33 -0
  65. package/cjs/pages/SelectChainPage/SelectChainPage.style.d.ts +21 -0
  66. package/cjs/pages/SelectChainPage/SelectChainPage.style.js +20 -0
  67. package/cjs/pages/SelectChainPage/index.d.ts +1 -0
  68. package/cjs/pages/SelectChainPage/index.js +17 -0
  69. package/cjs/pages/SelectTokenPage/SelectTokenPage.d.ts +2 -4
  70. package/cjs/pages/SelectTokenPage/SelectTokenPage.js +2 -2
  71. package/cjs/pages/SelectWalletPage/SelectWalletPage.js +4 -4
  72. package/cjs/pages/SelectWalletPage/SelectWalletPage.style.d.ts +2 -27
  73. package/cjs/pages/SelectWalletPage/SelectWalletPage.style.js +4 -14
  74. package/cjs/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +1 -1
  75. package/cjs/pages/SettingsPage/EnabledBridgesSelect.js +3 -6
  76. package/cjs/pages/SettingsPage/EnabledExchangesSelect.js +3 -5
  77. package/cjs/pages/SettingsPage/RoutePrioritySelect.js +5 -1
  78. package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +1 -1
  79. package/cjs/pages/SwapPage/StatusBottomSheet.js +25 -36
  80. package/cjs/pages/SwapPage/SwapPage.js +5 -1
  81. package/cjs/providers/SwapFormProvider/SwapFormProvider.js +39 -11
  82. package/cjs/providers/WidgetProvider/WidgetProvider.js +3 -7
  83. package/cjs/stores/chains/index.d.ts +4 -0
  84. package/cjs/stores/chains/index.js +20 -0
  85. package/cjs/stores/chains/types.d.ts +8 -0
  86. package/cjs/stores/chains/types.js +2 -0
  87. package/cjs/stores/chains/useChainOrder.d.ts +1 -0
  88. package/cjs/stores/chains/useChainOrder.js +12 -0
  89. package/cjs/stores/chains/useChainOrderStore.d.ts +19 -0
  90. package/cjs/stores/chains/useChainOrderStore.js +42 -0
  91. package/cjs/stores/chains/useInitializeChainOrder.d.ts +1 -0
  92. package/cjs/stores/chains/useInitializeChainOrder.js +12 -0
  93. package/cjs/stores/route/index.d.ts +2 -1
  94. package/cjs/stores/route/index.js +2 -1
  95. package/cjs/stores/route/useExecutingRoutesIds.d.ts +1 -0
  96. package/cjs/stores/route/useExecutingRoutesIds.js +20 -0
  97. package/cjs/stores/route/useRouteStore.js +5 -4
  98. package/cjs/stores/route/utils.d.ts +4 -0
  99. package/cjs/stores/route/utils.js +21 -0
  100. package/cjs/stores/settings/useSettingsStore.js +5 -2
  101. package/cjs/types/events.d.ts +5 -0
  102. package/cjs/types/events.js +9 -0
  103. package/cjs/types/index.d.ts +1 -0
  104. package/cjs/types/index.js +1 -0
  105. package/cjs/types/widget.d.ts +2 -1
  106. package/cjs/utils/navigationRoutes.d.ts +5 -0
  107. package/cjs/utils/navigationRoutes.js +31 -4
  108. package/components/ActiveSwaps/ActiveSwapItem.d.ts +5 -0
  109. package/components/ActiveSwaps/ActiveSwapItem.js +41 -0
  110. package/components/{SwapsInProgress/SwapsInProgress.d.ts → ActiveSwaps/ActiveSwaps.d.ts} +1 -1
  111. package/components/ActiveSwaps/ActiveSwaps.js +26 -0
  112. package/components/ActiveSwaps/ActiveSwaps.style.d.ts +78 -0
  113. package/components/ActiveSwaps/ActiveSwaps.style.js +37 -0
  114. package/components/ActiveSwaps/index.d.ts +2 -0
  115. package/components/ActiveSwaps/index.js +2 -0
  116. package/components/Card/Card.d.ts +7 -4
  117. package/components/Card/Card.js +39 -29
  118. package/{pages/SelectTokenPage → components/ChainSelect}/ChainSelect.d.ts +0 -0
  119. package/components/ChainSelect/ChainSelect.js +31 -0
  120. package/components/{SwapsInProgress/SwapsInProgress.style.d.ts → ChainSelect/ChainSelect.style.d.ts} +10 -19
  121. package/components/ChainSelect/ChainSelect.style.js +16 -0
  122. package/components/ChainSelect/index.d.ts +2 -0
  123. package/components/ChainSelect/index.js +2 -0
  124. package/components/ChainSelect/useChainSelect.d.ts +8 -0
  125. package/components/ChainSelect/useChainSelect.js +29 -0
  126. package/components/Header/Header.js +1 -9
  127. package/components/Header/NavigationHeader.js +6 -11
  128. package/components/PoweredBy/PoweredBy.style.d.ts +1 -1
  129. package/components/PoweredBy/PoweredBy.style.js +1 -0
  130. package/components/SendToWallet/SendToWallet.js +6 -6
  131. package/components/Step/CircularProgress.js +3 -3
  132. package/components/Step/CircularProgress.style.js +1 -1
  133. package/components/Step/StepProcess.js +2 -6
  134. package/components/Step/StepProcess.style.d.ts +1 -1
  135. package/components/Step/StepTimer.d.ts +1 -0
  136. package/components/Step/StepTimer.js +6 -6
  137. package/components/SwapButton/SwapButton.js +6 -13
  138. package/components/SwapButton/types.d.ts +2 -2
  139. package/components/SwapRouteCard/SwapRouteCard.js +1 -1
  140. package/components/TokenAvatar/TokenAvatar.style.js +0 -3
  141. package/components/TokenList/TokenList.js +6 -2
  142. package/config/theme.js +24 -23
  143. package/config/version.d.ts +1 -1
  144. package/config/version.js +1 -1
  145. package/hooks/index.d.ts +2 -0
  146. package/hooks/index.js +2 -0
  147. package/hooks/useChains.d.ts +1 -97
  148. package/hooks/useChains.js +8 -15
  149. package/{components/Step/utils.d.ts → hooks/useProcessMessage.d.ts} +4 -0
  150. package/{pages/SwapPage/utils.js → hooks/useProcessMessage.js} +15 -10
  151. package/hooks/useRouteExecution.d.ts +1 -1
  152. package/hooks/useRouteExecution.js +21 -30
  153. package/hooks/useWidgetEvents.d.ts +3 -0
  154. package/hooks/useWidgetEvents.js +6 -0
  155. package/i18n/en/translation.json +13 -8
  156. package/i18n/index.d.ts +10 -5
  157. package/index.d.ts +1 -0
  158. package/index.js +1 -0
  159. package/package.json +14 -13
  160. package/pages/ActiveSwapsPage/ActiveSwapsEmpty.d.ts +2 -0
  161. package/pages/ActiveSwapsPage/ActiveSwapsEmpty.js +14 -0
  162. package/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +2 -0
  163. package/pages/ActiveSwapsPage/ActiveSwapsPage.js +17 -0
  164. package/pages/ActiveSwapsPage/index.d.ts +1 -0
  165. package/pages/ActiveSwapsPage/index.js +1 -0
  166. package/pages/MainPage/MainPage.js +2 -3
  167. package/pages/MainPage/MainSwapButton.js +3 -1
  168. package/pages/MainPage/SwapRoutes.js +4 -1
  169. package/pages/SelectChainPage/SelectChainPage.d.ts +3 -0
  170. package/pages/SelectChainPage/SelectChainPage.js +29 -0
  171. package/pages/SelectChainPage/SelectChainPage.style.d.ts +21 -0
  172. package/pages/SelectChainPage/SelectChainPage.style.js +17 -0
  173. package/pages/SelectChainPage/index.d.ts +1 -0
  174. package/pages/SelectChainPage/index.js +1 -0
  175. package/pages/SelectTokenPage/SelectTokenPage.d.ts +2 -4
  176. package/pages/SelectTokenPage/SelectTokenPage.js +2 -2
  177. package/pages/SelectWalletPage/SelectWalletPage.js +5 -5
  178. package/pages/SelectWalletPage/SelectWalletPage.style.d.ts +2 -27
  179. package/pages/SelectWalletPage/SelectWalletPage.style.js +4 -14
  180. package/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +1 -1
  181. package/pages/SettingsPage/EnabledBridgesSelect.js +4 -7
  182. package/pages/SettingsPage/EnabledExchangesSelect.js +4 -6
  183. package/pages/SettingsPage/RoutePrioritySelect.js +5 -1
  184. package/pages/SwapDetailsPage/SwapDetailsPage.js +1 -1
  185. package/pages/SwapPage/StatusBottomSheet.js +27 -38
  186. package/pages/SwapPage/SwapPage.js +5 -1
  187. package/providers/SwapFormProvider/SwapFormProvider.js +39 -11
  188. package/providers/WidgetProvider/WidgetProvider.js +3 -7
  189. package/stores/chains/index.d.ts +4 -0
  190. package/stores/chains/index.js +4 -0
  191. package/stores/chains/types.d.ts +8 -0
  192. package/stores/chains/types.js +1 -0
  193. package/stores/chains/useChainOrder.d.ts +1 -0
  194. package/stores/chains/useChainOrder.js +5 -0
  195. package/stores/chains/useChainOrderStore.d.ts +19 -0
  196. package/stores/chains/useChainOrderStore.js +36 -0
  197. package/stores/chains/useInitializeChainOrder.d.ts +1 -0
  198. package/stores/chains/useInitializeChainOrder.js +5 -0
  199. package/stores/route/index.d.ts +2 -1
  200. package/stores/route/index.js +2 -1
  201. package/stores/route/useExecutingRoutesIds.d.ts +1 -0
  202. package/stores/route/useExecutingRoutesIds.js +13 -0
  203. package/stores/route/useRouteStore.js +5 -4
  204. package/stores/route/utils.d.ts +4 -0
  205. package/stores/route/utils.js +15 -0
  206. package/stores/settings/useSettingsStore.js +5 -2
  207. package/tsconfig.cjs.tsbuildinfo +1 -1
  208. package/types/events.d.ts +5 -0
  209. package/types/events.js +6 -0
  210. package/types/index.d.ts +1 -0
  211. package/types/index.js +1 -0
  212. package/types/widget.d.ts +2 -1
  213. package/utils/navigationRoutes.d.ts +5 -0
  214. package/utils/navigationRoutes.js +30 -3
  215. package/cjs/components/SwapButton/SwapButton.style.d.ts +0 -65
  216. package/cjs/components/SwapButton/SwapButton.style.js +0 -15
  217. package/cjs/components/SwapsInProgress/SwapsInProgress.js +0 -29
  218. package/cjs/components/SwapsInProgress/SwapsInProgress.style.js +0 -17
  219. package/cjs/components/SwapsInProgress/index.d.ts +0 -1
  220. package/cjs/pages/SelectTokenPage/ChainSelect.js +0 -31
  221. package/cjs/pages/SwapPage/utils.d.ts +0 -6
  222. package/cjs/pages/SwapPage/utils.js +0 -93
  223. package/cjs/stores/route/useExecutingRoutes.d.ts +0 -2
  224. package/cjs/stores/route/useExecutingRoutes.js +0 -13
  225. package/components/Step/utils.js +0 -89
  226. package/components/SwapButton/SwapButton.style.d.ts +0 -65
  227. package/components/SwapButton/SwapButton.style.js +0 -12
  228. package/components/SwapsInProgress/SwapsInProgress.js +0 -25
  229. package/components/SwapsInProgress/SwapsInProgress.style.js +0 -14
  230. package/components/SwapsInProgress/index.d.ts +0 -1
  231. package/components/SwapsInProgress/index.js +0 -1
  232. package/pages/SelectTokenPage/ChainSelect.js +0 -27
  233. package/pages/SwapPage/utils.d.ts +0 -6
  234. package/stores/route/useExecutingRoutes.d.ts +0 -2
  235. package/stores/route/useExecutingRoutes.js +0 -6
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useChainSelect = void 0;
4
+ const react_hook_form_1 = require("react-hook-form");
5
+ const hooks_1 = require("../../hooks");
6
+ const providers_1 = require("../../providers");
7
+ const chains_1 = require("../../stores/chains");
8
+ const useChainSelect = (formType) => {
9
+ const { setValue } = (0, react_hook_form_1.useFormContext)();
10
+ const { chains, isLoading } = (0, hooks_1.useChains)();
11
+ const [chainOrder, setChainOrder] = (0, chains_1.useChainOrder)();
12
+ const chainKey = providers_1.SwapFormKeyHelper.getChainKey(formType);
13
+ const getChains = () => {
14
+ if (!chains) {
15
+ return [];
16
+ }
17
+ const selectedChains = chainOrder
18
+ .map((chainId) => chains.find((chain) => chain.id === chainId))
19
+ .filter((chain) => chain);
20
+ return selectedChains;
21
+ };
22
+ const setCurrentChain = (chainId) => {
23
+ setValue(chainKey, chainId, { shouldDirty: true });
24
+ setValue(providers_1.SwapFormKeyHelper.getTokenKey(formType), '', {
25
+ shouldDirty: false,
26
+ });
27
+ setValue(providers_1.SwapFormKeyHelper.getAmountKey(formType), '');
28
+ setValue(providers_1.SwapFormKey.TokenSearchFilter, '');
29
+ setChainOrder(chainId);
30
+ };
31
+ return { chains, getChains, setCurrentChain, isLoading };
32
+ };
33
+ exports.useChainSelect = useChainSelect;
@@ -8,17 +8,9 @@ const utils_1 = require("../../utils");
8
8
  const Header_style_1 = require("./Header.style");
9
9
  const NavigationHeader_1 = require("./NavigationHeader");
10
10
  const WalletHeader_1 = require("./WalletHeader");
11
- const stickyHeaderRoutes = [
12
- utils_1.navigationRoutes.selectWallet,
13
- utils_1.navigationRoutes.settings,
14
- utils_1.navigationRoutes.swapRoutes,
15
- utils_1.navigationRoutes.swapExecution,
16
- utils_1.navigationRoutes.swapHistory,
17
- utils_1.navigationRoutes.swapDetails,
18
- ];
19
11
  const HeaderContainer = ({ children }) => {
20
12
  const { pathname } = (0, react_router_dom_1.useLocation)();
21
- return ((0, jsx_runtime_1.jsx)(Header_style_1.Container, Object.assign({ id: utils_1.ElementId.Header, sticky: stickyHeaderRoutes.some((route) => pathname.includes(route)) }, { children: children })));
13
+ return ((0, jsx_runtime_1.jsx)(Header_style_1.Container, Object.assign({ id: utils_1.ElementId.Header, sticky: utils_1.stickyHeaderRoutes.some((route) => pathname.includes(route)) }, { children: children })));
22
14
  };
23
15
  const Header = () => {
24
16
  const { walletManagement } = (0, providers_1.useWidgetConfig)();
@@ -11,16 +11,6 @@ const providers_1 = require("../../providers");
11
11
  const utils_1 = require("../../utils");
12
12
  const Header_style_1 = require("./Header.style");
13
13
  const useHeaderActionStore_1 = require("./useHeaderActionStore");
14
- const backButtonRoutes = [
15
- utils_1.navigationRoutes.selectWallet,
16
- utils_1.navigationRoutes.settings,
17
- utils_1.navigationRoutes.swapHistory,
18
- utils_1.navigationRoutes.fromToken,
19
- utils_1.navigationRoutes.toToken,
20
- utils_1.navigationRoutes.swapRoutes,
21
- utils_1.navigationRoutes.swapExecution,
22
- utils_1.navigationRoutes.swapDetails,
23
- ];
24
14
  const NavigationHeader = () => {
25
15
  const { t } = (0, react_i18next_1.useTranslation)();
26
16
  const { navigate, navigateBack } = (0, hooks_1.useNavigateBack)();
@@ -41,8 +31,13 @@ const NavigationHeader = () => {
41
31
  return t(`header.from`);
42
32
  case utils_1.navigationRoutes.toToken:
43
33
  return t(`header.to`);
34
+ case utils_1.navigationRoutes.fromChain:
35
+ case utils_1.navigationRoutes.toChain:
36
+ return t(`header.selectChain`);
44
37
  case utils_1.navigationRoutes.swapRoutes:
45
38
  return t(`header.routes`);
39
+ case utils_1.navigationRoutes.activeSwaps:
40
+ return t(`header.activeSwaps`);
46
41
  case utils_1.navigationRoutes.swapExecution:
47
42
  return t(`header.swap`);
48
43
  case utils_1.navigationRoutes.swapDetails:
@@ -51,6 +46,6 @@ const NavigationHeader = () => {
51
46
  return t(`header.swap`);
52
47
  }
53
48
  };
54
- return ((0, jsx_runtime_1.jsxs)(Header_style_1.HeaderAppBar, Object.assign({ elevation: 0 }, { children: [backButtonRoutes.includes(path) ? ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ size: "medium", "aria-label": "settings", edge: "start", onClick: navigateBack }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.ArrowBack, {}) }))) : null, (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: hasPath ? 18 : 24, align: hasPath ? 'center' : 'left', fontWeight: "700", flex: 1, noWrap: true }, { children: handleHeaderTitle() })), (0, jsx_runtime_1.jsxs)(react_router_dom_1.Routes, { children: [(0, jsx_runtime_1.jsx)(react_router_dom_1.Route, { path: utils_1.navigationRoutes.home, element: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [account.isActive ? ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ size: "medium", "aria-label": "swap-history", edge: "start", onClick: () => navigate(utils_1.navigationRoutes.swapHistory) }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.History, {}) }))) : null, (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ size: "medium", "aria-label": "settings", edge: "end", onClick: () => navigate(utils_1.navigationRoutes.settings) }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.SettingsOutlined, {}) }))] }) }), (0, jsx_runtime_1.jsx)(react_router_dom_1.Route, { path: "*", element: element || (0, jsx_runtime_1.jsx)(material_1.Box, { width: 28, height: 40 }) })] })] })));
49
+ return ((0, jsx_runtime_1.jsxs)(Header_style_1.HeaderAppBar, Object.assign({ elevation: 0 }, { children: [utils_1.backButtonRoutes.includes(path) ? ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ size: "medium", "aria-label": "settings", edge: "start", onClick: navigateBack }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.ArrowBack, {}) }))) : null, (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: hasPath ? 18 : 24, align: hasPath ? 'center' : 'left', fontWeight: "700", flex: 1, noWrap: true }, { children: handleHeaderTitle() })), (0, jsx_runtime_1.jsxs)(react_router_dom_1.Routes, { children: [(0, jsx_runtime_1.jsx)(react_router_dom_1.Route, { path: utils_1.navigationRoutes.home, element: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [account.isActive ? ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ size: "medium", "aria-label": "swap-history", edge: "start", onClick: () => navigate(utils_1.navigationRoutes.swapHistory) }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.History, {}) }))) : null, (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ size: "medium", "aria-label": "settings", edge: "end", onClick: () => navigate(utils_1.navigationRoutes.settings) }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.SettingsOutlined, {}) }))] }) }), (0, jsx_runtime_1.jsx)(react_router_dom_1.Route, { path: "*", element: element || (0, jsx_runtime_1.jsx)(material_1.Box, { width: 28, height: 40 }) })] })] })));
55
50
  };
56
51
  exports.NavigationHeader = NavigationHeader;
@@ -2,7 +2,7 @@
2
2
  export declare const Link: import("@emotion/styled").StyledComponent<Omit<import("@mui/material").LinkBaseProps, "classes"> & {
3
3
  children?: import("react").ReactNode;
4
4
  classes?: Partial<import("@mui/material").LinkClasses> | undefined;
5
- color?: import("@mui/system/styleFunctionSx").ResponsiveStyleValue<import("csstype").Property.Color | import("csstype").Property.Color[] | undefined> | ((theme: import("@mui/material").Theme) => import("@mui/system/styleFunctionSx").ResponsiveStyleValue<import("csstype").Property.Color | import("csstype").Property.Color[] | undefined>);
5
+ color?: import("@mui/system/styleFunctionSx").ResponsiveStyleValue<string[] | import("csstype").Property.Color | undefined> | ((theme: import("@mui/material").Theme) => import("@mui/system/styleFunctionSx").ResponsiveStyleValue<string[] | import("csstype").Property.Color | undefined>);
6
6
  sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
7
7
  TypographyClasses?: (Partial<import("@mui/material").TypographyClasses> & Partial<import("@mui/material").ClassNameMap<never>>) | undefined;
8
8
  underline?: "none" | "always" | "hover" | undefined;
@@ -6,6 +6,7 @@ const styles_1 = require("@mui/material/styles");
6
6
  exports.Link = (0, styles_1.styled)(material_1.Link)(({ theme }) => ({
7
7
  display: 'flex',
8
8
  alignItems: 'center',
9
+ border: 'none',
9
10
  ':hover': {
10
11
  color: theme.palette.primary.main,
11
12
  },
@@ -26,6 +26,12 @@ const SendToWallet = (props) => {
26
26
  const { showDestinationWallet } = (0, stores_1.useSettings)(['showDestinationWallet']);
27
27
  const { account, provider } = (0, providers_1.useWallet)();
28
28
  const { register, trigger, formState: { errors }, } = (0, react_hook_form_1.useFormContext)();
29
+ (0, react_1.useEffect)(() => {
30
+ trigger(providers_1.SwapFormKey.ToAddress);
31
+ }, [account.chainId, trigger]);
32
+ if (!showDestinationWallet) {
33
+ return null;
34
+ }
29
35
  const { onChange, onBlur, name, ref } = register(providers_1.SwapFormKey.ToAddress, {
30
36
  validate: (value) => __awaiter(void 0, void 0, void 0, function* () {
31
37
  try {
@@ -42,12 +48,6 @@ const SendToWallet = (props) => {
42
48
  }),
43
49
  onBlur: () => trigger(providers_1.SwapFormKey.ToAddress),
44
50
  });
45
- (0, react_1.useEffect)(() => {
46
- trigger(providers_1.SwapFormKey.ToAddress);
47
- }, [account.chainId, trigger]);
48
- if (!showDestinationWallet) {
49
- return null;
50
- }
51
51
  return ((0, jsx_runtime_1.jsxs)(Card_1.Card, Object.assign({}, props, { children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, { children: t('swap.sendToWallet') }), (0, jsx_runtime_1.jsxs)(SendToWallet_style_1.FormControl, Object.assign({ fullWidth: true }, { children: [(0, jsx_runtime_1.jsx)(SendToWallet_style_1.Input, { ref: ref, size: "small", autoComplete: "off", autoCorrect: "off", autoCapitalize: "off", spellCheck: "false", onChange: onChange, onBlur: onBlur, name: name, placeholder: t('swap.walletAddressOrEns') }), (0, jsx_runtime_1.jsx)(material_1.FormHelperText, Object.assign({ error: !!errors.toAddress }, { children: (_a = errors.toAddress) === null || _a === void 0 ? void 0 : _a.message }))] }))] })));
52
52
  };
53
53
  exports.SendToWallet = SendToWallet;
@@ -10,7 +10,7 @@ function CircularProgress({ status }) {
10
10
  display: 'grid',
11
11
  position: 'relative',
12
12
  placeItems: 'center',
13
- } }, { children: [(0, jsx_runtime_1.jsx)(CircularProgress_style_1.CircularProgress, { variant: "determinate", status: status, size: 32, thickness: 3, value: 100 }), status === 'STARTED' || status === 'PENDING' ? ((0, jsx_runtime_1.jsx)(CircularProgress_style_1.CircularProgressPending, { size: 32, thickness: 3 })) : null, status === 'ACTION_REQUIRED' ? ((0, jsx_runtime_1.jsx)(icons_material_1.Info, { color: "primary", sx: {
13
+ } }, { children: [(0, jsx_runtime_1.jsx)(CircularProgress_style_1.CircularProgress, { variant: "determinate", status: status, size: 32, thickness: 3, value: 100 }), status === 'STARTED' || status === 'PENDING' ? ((0, jsx_runtime_1.jsx)(CircularProgress_style_1.CircularProgressPending, { size: 32, thickness: 3 })) : null, status === 'ACTION_REQUIRED' ? ((0, jsx_runtime_1.jsx)(icons_material_1.Info, { color: "info", sx: {
14
14
  position: 'absolute',
15
15
  fontSize: '1rem',
16
16
  } })) : null, status === 'DONE' ? ((0, jsx_runtime_1.jsx)(icons_material_1.Done, { color: "success", sx: {
@@ -21,7 +21,7 @@ const circleAnimation = (0, styles_1.keyframes)({
21
21
  const getStatusColor = (status, theme) => {
22
22
  switch (status) {
23
23
  case 'ACTION_REQUIRED':
24
- return theme.palette.primary.main;
24
+ return theme.palette.info.main;
25
25
  case 'DONE':
26
26
  return theme.palette.success.main;
27
27
  case 'FAILED':
@@ -4,15 +4,11 @@ exports.StepProcess = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const icons_material_1 = require("@mui/icons-material");
6
6
  const material_1 = require("@mui/material");
7
- const react_i18next_1 = require("react-i18next");
8
7
  const hooks_1 = require("../../hooks");
9
8
  const CircularProgress_1 = require("./CircularProgress");
10
9
  const StepProcess_style_1 = require("./StepProcess.style");
11
- const utils_1 = require("./utils");
12
10
  const StepProcess = ({ step, process }) => {
13
- const { t } = (0, react_i18next_1.useTranslation)();
14
- const { getChainById } = (0, hooks_1.useChains)();
15
- const { title, message } = (0, utils_1.getProcessMessage)(t, getChainById, step, process);
11
+ const { title, message } = (0, hooks_1.useProcessMessage)(step, process);
16
12
  return ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ px: 2, py: 1 }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ sx: {
17
13
  display: 'flex',
18
14
  alignItems: 'center',
@@ -29,7 +29,7 @@ export declare const LinkButton: import("@emotion/styled").StyledComponent<{
29
29
  }, keyof import("@mui/material/OverridableComponent").CommonProps | "tabIndex" | "color" | "children" | "action" | "centerRipple" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "TouchRippleProps" | "touchRippleRef" | "disableFocusRipple" | "size" | "edge"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & Omit<import("@mui/material").LinkBaseProps, "classes"> & {
30
30
  children?: import("react").ReactNode;
31
31
  classes?: Partial<import("@mui/material").LinkClasses> | undefined;
32
- color?: import("@mui/system/styleFunctionSx").ResponsiveStyleValue<import("csstype").Property.Color | import("csstype").Property.Color[] | undefined> | ((theme: import("@mui/material").Theme) => import("@mui/system/styleFunctionSx").ResponsiveStyleValue<import("csstype").Property.Color | import("csstype").Property.Color[] | undefined>);
32
+ color?: import("@mui/system/styleFunctionSx").ResponsiveStyleValue<string[] | import("csstype").Property.Color | undefined> | ((theme: import("@mui/material").Theme) => import("@mui/system/styleFunctionSx").ResponsiveStyleValue<string[] | import("csstype").Property.Color | undefined>);
33
33
  sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
34
34
  TypographyClasses?: (Partial<import("@mui/material").TypographyClasses> & Partial<import("@mui/material").ClassNameMap<never>>) | undefined;
35
35
  underline?: "none" | "always" | "hover" | undefined;
@@ -2,4 +2,5 @@
2
2
  import type { Step } from '@lifi/sdk';
3
3
  export declare const StepTimer: React.FC<{
4
4
  step: Step;
5
+ hideInProgress?: boolean;
5
6
  }>;
@@ -10,7 +10,7 @@ const getExpiryTimestamp = (step) => {
10
10
  return new Date(((_c = (_b = (_a = step.execution) === null || _a === void 0 ? void 0 : _a.process[0]) === null || _b === void 0 ? void 0 : _b.startedAt) !== null && _c !== void 0 ? _c : Date.now()) +
11
11
  step.estimate.executionDuration * 1000);
12
12
  };
13
- const StepTimer = ({ step }) => {
13
+ const StepTimer = ({ step, hideInProgress, }) => {
14
14
  var _a, _b;
15
15
  const { t } = (0, react_i18next_1.useTranslation)();
16
16
  const [isExpired, setExpired] = (0, react_1.useState)(false);
@@ -29,9 +29,7 @@ const StepTimer = ({ step }) => {
29
29
  setExecutionStarted(true);
30
30
  restart(getExpiryTimestamp(step));
31
31
  }
32
- const shouldBePaused = step.execution.process.some((process) => process.status === 'ACTION_REQUIRED' ||
33
- process.status === 'CHAIN_SWITCH_REQUIRED' ||
34
- process.status === 'FAILED');
32
+ const shouldBePaused = step.execution.process.some((process) => process.status === 'ACTION_REQUIRED' || process.status === 'FAILED');
35
33
  if (isRunning && shouldBePaused) {
36
34
  pause();
37
35
  }
@@ -53,11 +51,13 @@ const StepTimer = ({ step }) => {
53
51
  value: (step.estimate.executionDuration / 60).toFixed(0),
54
52
  }) }));
55
53
  }
54
+ const isTimerExpired = isExpired || (!minutes && !seconds);
56
55
  if (((_a = step.execution) === null || _a === void 0 ? void 0 : _a.status) === 'DONE' ||
57
- ((_b = step.execution) === null || _b === void 0 ? void 0 : _b.status) === 'FAILED') {
56
+ ((_b = step.execution) === null || _b === void 0 ? void 0 : _b.status) === 'FAILED' ||
57
+ (isTimerExpired && hideInProgress)) {
58
58
  return null;
59
59
  }
60
- return isExpired ? ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: t('swap.inProgress') })) : (
60
+ return isTimerExpired ? ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: t('swap.inProgress') })) : (
61
61
  // eslint-disable-next-line react/jsx-no-useless-fragment
62
62
  (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: `${minutes}:${seconds < 10 ? `0${seconds}` : seconds}` }));
63
63
  };
@@ -12,18 +12,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.SwapButton = void 0;
13
13
  const jsx_runtime_1 = require("react/jsx-runtime");
14
14
  const sdk_1 = require("@lifi/sdk");
15
+ const material_1 = require("@mui/material");
15
16
  const react_hook_form_1 = require("react-hook-form");
16
17
  const react_i18next_1 = require("react-i18next");
17
18
  const react_router_dom_1 = require("react-router-dom");
18
19
  const hooks_1 = require("../../hooks");
19
20
  const providers_1 = require("../../providers");
20
21
  const utils_1 = require("../../utils");
21
- const SwapButton_style_1 = require("./SwapButton.style");
22
- const SwapButton = ({ onClick, currentRoute, text, loading, }) => {
22
+ const SwapButton = ({ onClick, currentRoute, text, disable, }) => {
23
23
  var _a;
24
24
  const { t } = (0, react_i18next_1.useTranslation)();
25
25
  const navigate = (0, react_router_dom_1.useNavigate)();
26
- const { isValid, isValidating } = (0, react_hook_form_1.useFormState)();
27
26
  const { getChainById } = (0, hooks_1.useChains)();
28
27
  const config = (0, providers_1.useWidgetConfig)();
29
28
  const { account, switchChain, connect: walletConnect } = (0, providers_1.useWallet)();
@@ -64,14 +63,8 @@ const SwapButton = ({ onClick, currentRoute, text, loading, }) => {
64
63
  }
65
64
  return t(`button.connectWallet`);
66
65
  };
67
- return ((0, jsx_runtime_1.jsx)(SwapButton_style_1.Button, Object.assign({ variant: "contained", color: account.isActive ? 'primary' : 'success', onClick: handleSwapButtonClick,
68
- // loading={isLoading || isFetching}
69
- disabled: (insufficientFunds ||
70
- !!insufficientGas.length ||
71
- loading ||
72
- isValidating ||
73
- !isValid) &&
74
- currentRoute &&
75
- !switchChainAllowed, fullWidth: true }, { children: getButtonText() })));
66
+ return ((0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ variant: "contained", color: account.isActive ? 'primary' : 'success', onClick: handleSwapButtonClick, disabled: currentRoute &&
67
+ !switchChainAllowed &&
68
+ (insufficientFunds || !!insufficientGas.length || disable), fullWidth: true }, { children: getButtonText() })));
76
69
  };
77
70
  exports.SwapButton = SwapButton;
@@ -1,7 +1,7 @@
1
- import { Route } from '@lifi/sdk';
1
+ import type { Route } from '@lifi/sdk';
2
2
  export interface SwapButtonProps {
3
3
  onClick?(): void;
4
4
  currentRoute?: Route;
5
5
  text?: string;
6
- loading?: boolean;
6
+ disable?: boolean;
7
7
  }
@@ -38,6 +38,6 @@ const SwapRouteCard = (_a) => {
38
38
  justifyContent: 'space-between',
39
39
  } }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: 18, fontWeight: "500", lineHeight: 1, pt: 0.25 }, { children: t(`swap.currency`, { value: (_c = route.gasCostUSD) !== null && _c !== void 0 ? _c : 0 }) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: 12, color: "text.secondary", lineHeight: 1, mt: 0.5 }, { children: t(`swap.gas`) }))] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ fontSize: 18, fontWeight: "500", display: "flex", justifyContent: "flex-end", lineHeight: 1, pt: 0.25 }, { children: ["~", (route.steps
40
40
  .map((step) => step.estimate.executionDuration)
41
- .reduce((cumulated, x) => cumulated + x) / 60).toFixed(0)] })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: 12, color: "text.secondary", textAlign: "end", lineHeight: 1, mt: 0.5 }, { children: t(`swap.minutes`) }))] })] }))] })));
41
+ .reduce((duration, x) => duration + x) / 60).toFixed(0)] })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: 12, color: "text.secondary", textAlign: "end", lineHeight: 1, mt: 0.5 }, { children: t(`swap.minutes`) }))] })] }))] })));
42
42
  };
43
43
  exports.SwapRouteCard = SwapRouteCard;
@@ -6,9 +6,6 @@ const Avatar_1 = require("@mui/material/Avatar");
6
6
  const Badge_1 = require("@mui/material/Badge");
7
7
  const styles_1 = require("@mui/material/styles");
8
8
  exports.TokenAvatarGroup = (0, styles_1.styled)(material_1.AvatarGroup)(({ theme }) => ({
9
- [`& .${Avatar_1.avatarClasses.root}`]: {
10
- background: theme.palette.background.paper,
11
- },
12
9
  [`& .${Badge_1.badgeClasses.badge}:last-child .${Avatar_1.avatarClasses.root}`]: {
13
10
  marginLeft: theme.spacing(-1),
14
11
  boxSizing: 'border-box',
@@ -35,7 +35,9 @@ const TokenList = ({ formType, height, onClick, }) => {
35
35
  ? [searchedToken]
36
36
  : filteredTokens;
37
37
  const handleTokenClick = (0, react_1.useCallback)((tokenAddress) => {
38
- setValue(providers_1.SwapFormKeyHelper.getTokenKey(formType), tokenAddress);
38
+ setValue(providers_1.SwapFormKeyHelper.getTokenKey(formType), tokenAddress, {
39
+ shouldDirty: true,
40
+ });
39
41
  setValue(providers_1.SwapFormKeyHelper.getAmountKey(formType), '');
40
42
  const oppositeFormType = formType === 'from' ? 'to' : 'from';
41
43
  const [selectedOppositeToken, selectedOppositeChain, selectedChain] = getValues([
@@ -45,7 +47,9 @@ const TokenList = ({ formType, height, onClick, }) => {
45
47
  ]);
46
48
  if (selectedOppositeToken === tokenAddress &&
47
49
  selectedOppositeChain === selectedChain) {
48
- setValue(providers_1.SwapFormKeyHelper.getTokenKey(oppositeFormType), '');
50
+ setValue(providers_1.SwapFormKeyHelper.getTokenKey(oppositeFormType), '', {
51
+ shouldDirty: false,
52
+ });
49
53
  }
50
54
  onClick === null || onClick === void 0 ? void 0 : onClick();
51
55
  }, [formType, getValues, onClick, setValue]);
@@ -88,7 +88,29 @@ const createTheme = (mode, theme = {}) => {
88
88
  defaultProps: {
89
89
  disableElevation: true,
90
90
  },
91
- styleOverrides: Object.assign(Object.assign({}, (mode === 'dark'
91
+ styleOverrides: Object.assign({ root: {
92
+ borderRadius: (_v = (_u = theme.shape) === null || _u === void 0 ? void 0 : _u.borderRadiusSecondary) !== null && _v !== void 0 ? _v : shape.borderRadiusSecondary,
93
+ textTransform: 'none',
94
+ fontSize: '1rem',
95
+ '&.Mui-disabled, &.Mui-disabled:hover': {
96
+ color: mode === 'light'
97
+ ? 'rgb(0 0 0 / 70%)'
98
+ : 'rgb(255 255 255 / 70%)',
99
+ cursor: 'not-allowed',
100
+ pointerEvents: 'auto',
101
+ },
102
+ }, contained: {
103
+ '&:hover': {
104
+ color: (0, styles_1.getContrastRatio)(colors_1.common.white, primaryMainColor) >= 3
105
+ ? colors_1.common.white
106
+ : colors_1.common.black,
107
+ },
108
+ }, sizeMedium: {
109
+ padding: '10px 16px',
110
+ [`.${DialogActions_1.dialogActionsClasses.root} &`]: {
111
+ padding: '6px 12px',
112
+ },
113
+ } }, (mode === 'dark'
92
114
  ? {
93
115
  outlined: {
94
116
  color: primaryLightColor,
@@ -106,28 +128,7 @@ const createTheme = (mode, theme = {}) => {
106
128
  },
107
129
  },
108
130
  }
109
- : {})), { root: {
110
- borderRadius: (_v = (_u = theme.shape) === null || _u === void 0 ? void 0 : _u.borderRadiusSecondary) !== null && _v !== void 0 ? _v : shape.borderRadiusSecondary,
111
- textTransform: 'none',
112
- fontSize: '1rem',
113
- padding: '10px 16px',
114
- [`.${DialogActions_1.dialogActionsClasses.root} &`]: {
115
- padding: '6px 12px',
116
- },
117
- '&.Mui-disabled, &.Mui-disabled:hover': {
118
- color: mode === 'light'
119
- ? 'rgb(0 0 0 / 70%)'
120
- : 'rgb(255 255 255 / 70%)',
121
- cursor: 'not-allowed',
122
- pointerEvents: 'auto',
123
- },
124
- }, contained: {
125
- '&:hover': {
126
- color: (0, styles_1.getContrastRatio)(colors_1.common.white, primaryMainColor) >= 3
127
- ? colors_1.common.white
128
- : colors_1.common.black,
129
- },
130
- } }),
131
+ : {})),
131
132
  },
132
133
  MuiIconButton: {
133
134
  styleOverrides: {
@@ -1,2 +1,2 @@
1
1
  export declare const name = "@lifi/widget";
2
- export declare const version = "1.15.1";
2
+ export declare const version = "1.16.0";
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = exports.name = void 0;
4
4
  exports.name = '@lifi/widget';
5
- exports.version = '1.15.1';
5
+ exports.version = '1.16.0';
@@ -6,6 +6,7 @@ export * from './useFeaturedTokens';
6
6
  export * from './useGasSufficiency';
7
7
  export * from './useInitializer';
8
8
  export * from './useNavigateBack';
9
+ export * from './useProcessMessage';
9
10
  export * from './useRouteExecution';
10
11
  export * from './useScrollableContainer';
11
12
  export * from './useSwapRoutes';
@@ -16,3 +17,4 @@ export * from './useTokenBalances';
16
17
  export * from './useTokens';
17
18
  export * from './useTokenSearch';
18
19
  export * from './useTools';
20
+ export * from './useWidgetEvents';
@@ -22,6 +22,7 @@ __exportStar(require("./useFeaturedTokens"), exports);
22
22
  __exportStar(require("./useGasSufficiency"), exports);
23
23
  __exportStar(require("./useInitializer"), exports);
24
24
  __exportStar(require("./useNavigateBack"), exports);
25
+ __exportStar(require("./useProcessMessage"), exports);
25
26
  __exportStar(require("./useRouteExecution"), exports);
26
27
  __exportStar(require("./useScrollableContainer"), exports);
27
28
  __exportStar(require("./useSwapRoutes"), exports);
@@ -32,3 +33,4 @@ __exportStar(require("./useTokenBalances"), exports);
32
33
  __exportStar(require("./useTokens"), exports);
33
34
  __exportStar(require("./useTokenSearch"), exports);
34
35
  __exportStar(require("./useTools"), exports);
36
+ __exportStar(require("./useWidgetEvents"), exports);
@@ -1,101 +1,5 @@
1
1
  export declare const useChains: () => {
2
- error: unknown;
3
- isError: true;
4
- isLoading: false;
5
- isLoadingError: false;
6
- isRefetchError: true;
7
- isSuccess: false;
8
- status: "error";
9
- dataUpdatedAt: number;
10
- errorUpdatedAt: number;
11
- failureCount: number;
12
- errorUpdateCount: number;
13
- isFetched: boolean;
14
- isFetchedAfterMount: boolean;
15
- isFetching: boolean;
16
- isPaused: boolean;
17
- isPlaceholderData: boolean;
18
- isPreviousData: boolean;
19
- isRefetching: boolean;
20
- isStale: boolean;
21
- refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@lifi/types").EVMChain[], unknown>>;
22
- remove: () => void;
23
- fetchStatus: import("@tanstack/react-query").FetchStatus;
24
- chains: import("@lifi/types").EVMChain[] | undefined;
25
- getChainById: (chainId: number) => import("@lifi/types").EVMChain | undefined;
26
- } | {
27
- error: null;
28
- isError: false;
29
- isLoading: false;
30
- isLoadingError: false;
31
- isRefetchError: false;
32
- isSuccess: true;
33
- status: "success";
34
- dataUpdatedAt: number;
35
- errorUpdatedAt: number;
36
- failureCount: number;
37
- errorUpdateCount: number;
38
- isFetched: boolean;
39
- isFetchedAfterMount: boolean;
40
- isFetching: boolean;
41
- isPaused: boolean;
42
- isPlaceholderData: boolean;
43
- isPreviousData: boolean;
44
- isRefetching: boolean;
45
- isStale: boolean;
46
- refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@lifi/types").EVMChain[], unknown>>;
47
- remove: () => void;
48
- fetchStatus: import("@tanstack/react-query").FetchStatus;
49
- chains: import("@lifi/types").EVMChain[] | undefined;
50
- getChainById: (chainId: number) => import("@lifi/types").EVMChain | undefined;
51
- } | {
52
- error: unknown;
53
- isError: true;
54
- isLoading: false;
55
- isLoadingError: true;
56
- isRefetchError: false;
57
- isSuccess: false;
58
- status: "error";
59
- dataUpdatedAt: number;
60
- errorUpdatedAt: number;
61
- failureCount: number;
62
- errorUpdateCount: number;
63
- isFetched: boolean;
64
- isFetchedAfterMount: boolean;
65
- isFetching: boolean;
66
- isPaused: boolean;
67
- isPlaceholderData: boolean;
68
- isPreviousData: boolean;
69
- isRefetching: boolean;
70
- isStale: boolean;
71
- refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@lifi/types").EVMChain[], unknown>>;
72
- remove: () => void;
73
- fetchStatus: import("@tanstack/react-query").FetchStatus;
74
- chains: import("@lifi/types").EVMChain[] | undefined;
75
- getChainById: (chainId: number) => import("@lifi/types").EVMChain | undefined;
76
- } | {
77
- error: null;
78
- isError: false;
79
- isLoading: true;
80
- isLoadingError: false;
81
- isRefetchError: false;
82
- isSuccess: false;
83
- status: "loading";
84
- dataUpdatedAt: number;
85
- errorUpdatedAt: number;
86
- failureCount: number;
87
- errorUpdateCount: number;
88
- isFetched: boolean;
89
- isFetchedAfterMount: boolean;
90
- isFetching: boolean;
91
- isPaused: boolean;
92
- isPlaceholderData: boolean;
93
- isPreviousData: boolean;
94
- isRefetching: boolean;
95
- isStale: boolean;
96
- refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@lifi/types").EVMChain[], unknown>>;
97
- remove: () => void;
98
- fetchStatus: import("@tanstack/react-query").FetchStatus;
99
2
  chains: import("@lifi/types").EVMChain[] | undefined;
100
3
  getChainById: (chainId: number) => import("@lifi/types").EVMChain | undefined;
4
+ isLoading: boolean;
101
5
  };
@@ -8,29 +8,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __rest = (this && this.__rest) || function (s, e) {
12
- var t = {};
13
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
- t[p] = s[p];
15
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
- t[p[i]] = s[p[i]];
19
- }
20
- return t;
21
- };
22
11
  Object.defineProperty(exports, "__esModule", { value: true });
23
12
  exports.useChains = void 0;
24
13
  const react_query_1 = require("@tanstack/react-query");
25
14
  const react_1 = require("react");
26
15
  const lifi_1 = require("../config/lifi");
27
16
  const WidgetProvider_1 = require("../providers/WidgetProvider");
17
+ const chains_1 = require("../stores/chains");
28
18
  const useChains = () => {
29
19
  const { disabledChains } = (0, WidgetProvider_1.useWidgetConfig)();
30
- const _a = (0, react_query_1.useQuery)(['chains'], () => __awaiter(void 0, void 0, void 0, function* () {
20
+ const [, initializeChains] = (0, chains_1.useSetChainOrder)();
21
+ const { data, isLoading } = (0, react_query_1.useQuery)(['chains'], () => __awaiter(void 0, void 0, void 0, function* () {
31
22
  const chains = yield lifi_1.LiFi.getChains();
32
- return chains.filter((chain) => !(disabledChains === null || disabledChains === void 0 ? void 0 : disabledChains.includes(chain.id)));
33
- })), { data } = _a, other = __rest(_a, ["data"]);
23
+ const filteredChains = chains.filter((chain) => !(disabledChains === null || disabledChains === void 0 ? void 0 : disabledChains.includes(chain.id)));
24
+ initializeChains(filteredChains.map((chain) => chain.id));
25
+ return filteredChains;
26
+ }));
34
27
  const getChainById = (0, react_1.useCallback)((chainId) => {
35
28
  const chain = data === null || data === void 0 ? void 0 : data.find((chain) => chain.id === chainId);
36
29
  // if (!chain) {
@@ -38,6 +31,6 @@ const useChains = () => {
38
31
  // }
39
32
  return chain;
40
33
  }, [data]);
41
- return Object.assign({ chains: data, getChainById }, other);
34
+ return { chains: data, getChainById, isLoading };
42
35
  };
43
36
  exports.useChains = useChains;
@@ -1,5 +1,9 @@
1
1
  import type { EVMChain, Process, Step } from '@lifi/sdk';
2
2
  import type { TFunction } from 'react-i18next';
3
+ export declare const useProcessMessage: (step?: Step, process?: Process) => {
4
+ title?: string | undefined;
5
+ message?: string | undefined;
6
+ };
3
7
  export declare function getProcessMessage(t: TFunction<'translation', undefined>, getChainById: (chainId: number) => EVMChain | undefined, step: Step, process: Process): {
4
8
  title?: string;
5
9
  message?: string;