@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
@@ -1,13 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getProcessMessage = void 0;
3
+ exports.getProcessMessage = exports.useProcessMessage = void 0;
4
4
  const sdk_1 = require("@lifi/sdk");
5
- const utils_1 = require("../../utils");
6
- const formatProcessMessage = (initialMessage, args = {}) => {
7
- return Object.keys(args).reduce((message, key) => {
8
- return message.replace(`{${key}}`, args[key]);
9
- }, initialMessage);
5
+ const react_i18next_1 = require("react-i18next");
6
+ const utils_1 = require("../utils");
7
+ const useChains_1 = require("./useChains");
8
+ const useProcessMessage = (step, process) => {
9
+ const { t } = (0, react_i18next_1.useTranslation)();
10
+ const { getChainById } = (0, useChains_1.useChains)();
11
+ if (!step || !process) {
12
+ return {};
13
+ }
14
+ return getProcessMessage(t, getChainById, step, process);
10
15
  };
16
+ exports.useProcessMessage = useProcessMessage;
11
17
  const processMessages = {
12
18
  TOKEN_ALLOWANCE: {
13
19
  STARTED: (t) => t(`swap.process.tokenAllowance.started`),
@@ -15,7 +21,7 @@ const processMessages = {
15
21
  DONE: (t) => t(`swap.process.tokenAllowance.done`),
16
22
  },
17
23
  SWITCH_CHAIN: {
18
- PENDING: (t) => t(`swap.process.switchChain.pending`),
24
+ ACTION_REQUIRED: (t) => t(`swap.process.switchChain.actionRequired`),
19
25
  DONE: (t) => t(`swap.process.switchChain.done`),
20
26
  },
21
27
  SWAP: {
@@ -70,9 +76,9 @@ function getProcessMessage(t, getChainById, step, process) {
70
76
  title = t(`swap.error.title.slippageTooLarge`);
71
77
  message = t(`swap.error.message.slippageTooLarge`);
72
78
  break;
73
- case sdk_1.MetaMaskProviderErrorCode.userRejectedRequest:
74
- title = t(`swap.error.title.userRejectedSignatureRequest`);
75
- message = t(`swap.error.message.signatureRequired`, {
79
+ case sdk_1.LifiErrorCode.TransactionRejected:
80
+ title = t(`swap.error.title.transactionRejected`);
81
+ message = t(`swap.error.message.transactionRejected`, {
76
82
  amount: (0, utils_1.formatTokenAmount)(step.action.fromAmount, step.action.fromToken.decimals),
77
83
  tokenSymbol: step.action.fromToken.symbol,
78
84
  chainName: (_b = (_a = getChainById(step.action.fromChainId)) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : '',
@@ -1,5 +1,5 @@
1
1
  import type { Route } from '@lifi/sdk';
2
- export declare const useRouteExecution: (routeId: string) => {
2
+ export declare const useRouteExecution: (routeId: string, executeInBackground?: boolean) => {
3
3
  executeRoute: () => void;
4
4
  restartRoute: () => void;
5
5
  deleteRoute: () => void;
@@ -19,16 +19,25 @@ const shallow_1 = __importDefault(require("zustand/shallow"));
19
19
  const lifi_1 = require("../config/lifi");
20
20
  const WalletProvider_1 = require("../providers/WalletProvider");
21
21
  const stores_1 = require("../stores");
22
+ const events_1 = require("../types/events");
22
23
  const utils_1 = require("../utils");
23
- const useRouteExecution = (routeId) => {
24
+ const useWidgetEvents_1 = require("./useWidgetEvents");
25
+ const useRouteExecution = (routeId, executeInBackground) => {
24
26
  const { account, switchChain } = (0, WalletProvider_1.useWallet)();
25
27
  const resumedAfterMount = (0, react_1.useRef)(false);
28
+ const emitter = (0, useWidgetEvents_1.useWidgetEvents)();
26
29
  const routeExecution = (0, stores_1.useRouteStore)((state) => state.routes[routeId]);
27
30
  const [updateRoute, restartRoute, deleteRoute] = (0, stores_1.useRouteStore)((state) => [state.updateRoute, state.restartRoute, state.deleteRoute], shallow_1.default);
28
31
  const updateCallback = (updatedRoute) => {
29
32
  const clonedUpdatedRoute = (0, utils_1.deepClone)(updatedRoute);
30
33
  console.log('Route updated.', clonedUpdatedRoute);
31
34
  updateRoute(clonedUpdatedRoute);
35
+ if ((0, stores_1.isRouteCompleted)(clonedUpdatedRoute)) {
36
+ emitter.emit(events_1.WidgetEvent.SwapCompleted);
37
+ }
38
+ if ((0, stores_1.isRouteFailed)(clonedUpdatedRoute)) {
39
+ emitter.emit(events_1.WidgetEvent.SwapFailed);
40
+ }
32
41
  };
33
42
  const switchChainHook = (requiredChainId) => __awaiter(void 0, void 0, void 0, function* () {
34
43
  if (!account.isActive || !account.signer) {
@@ -54,16 +63,12 @@ const useRouteExecution = (routeId) => {
54
63
  updateCallback,
55
64
  switchChainHook,
56
65
  infiniteApproval: false,
66
+ executeInBackground,
57
67
  });
58
68
  }, {
59
69
  onMutate: () => {
60
70
  console.log('Execution started.', routeId);
61
- },
62
- onError: () => {
63
- console.warn('Execution failed.', routeId);
64
- },
65
- onSuccess: (route) => {
66
- console.log('Executed successfully.', routeId);
71
+ emitter.emit(events_1.WidgetEvent.SwapStarted);
67
72
  },
68
73
  });
69
74
  const resumeRouteMutation = (0, react_query_1.useMutation)((resumedRoute) => {
@@ -77,26 +82,21 @@ const useRouteExecution = (routeId) => {
77
82
  updateCallback,
78
83
  switchChainHook,
79
84
  infiniteApproval: false,
85
+ executeInBackground,
80
86
  });
81
87
  }, {
82
88
  onMutate: () => {
83
89
  console.log('Resumed to execution.', routeId);
84
90
  },
85
- onError: () => {
86
- console.warn('Resumed execution failed.', routeId);
87
- },
88
- onSuccess: (route) => {
89
- console.log('Resumed execution successful.', route);
90
- },
91
91
  });
92
92
  const executeRoute = (0, react_1.useCallback)(() => {
93
93
  executeRouteMutation.mutateAsync(undefined, {
94
94
  onError: () => {
95
- console.warn('Real execution failed!', routeId);
95
+ console.warn('Execution failed!', routeId);
96
96
  // Notification.showNotification(NotificationType.SwapExecution_ERROR);
97
97
  },
98
98
  onSuccess: (route) => {
99
- console.log('Real execution successfully!', route);
99
+ console.log('Executed successfully!', route);
100
100
  // Notification.showNotification(NotificationType.TRANSACTION_SUCCESSFULL);
101
101
  },
102
102
  });
@@ -104,10 +104,10 @@ const useRouteExecution = (routeId) => {
104
104
  const resumeRoute = (0, react_1.useCallback)((route) => {
105
105
  resumeRouteMutation.mutateAsync(route, {
106
106
  onError: () => {
107
- console.warn('Real resumed execution failed.', routeId);
107
+ console.warn('Resumed execution failed.', routeId);
108
108
  },
109
109
  onSuccess: (route) => {
110
- console.log('Real resumed execution successful.', route);
110
+ console.log('Resumed execution successful.', route);
111
111
  },
112
112
  });
113
113
  }, [resumeRouteMutation, routeId]);
@@ -123,7 +123,7 @@ const useRouteExecution = (routeId) => {
123
123
  // Resume route execution after page reload
124
124
  (0, react_1.useEffect)(() => {
125
125
  // Check if route is eligible for automatic resuming
126
- if (isActiveRoute(routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route) &&
126
+ if ((0, stores_1.isRouteActive)(routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route) &&
127
127
  account.isActive &&
128
128
  !resumedAfterMount.current) {
129
129
  resumedAfterMount.current = true;
@@ -135,10 +135,10 @@ const useRouteExecution = (routeId) => {
135
135
  return () => {
136
136
  var _a;
137
137
  const route = (_a = stores_1.useRouteStore.getState().routes[routeId]) === null || _a === void 0 ? void 0 : _a.route;
138
- if (!route || !isActiveRoute(route)) {
138
+ if (!route || !(0, stores_1.isRouteActive)(route)) {
139
139
  return;
140
140
  }
141
- lifi_1.LiFi.moveExecutionToBackground(route);
141
+ lifi_1.LiFi.updateRouteExecution(route, { executeInBackground: true });
142
142
  console.log('Move route execution to background.', routeId);
143
143
  resumedAfterMount.current = false;
144
144
  };
@@ -152,12 +152,3 @@ const useRouteExecution = (routeId) => {
152
152
  };
153
153
  };
154
154
  exports.useRouteExecution = useRouteExecution;
155
- const isActiveRoute = (route) => {
156
- if (!route) {
157
- return false;
158
- }
159
- const allDone = route.steps.every((step) => { var _a; return ((_a = step.execution) === null || _a === void 0 ? void 0 : _a.status) === 'DONE'; });
160
- const isFailed = route.steps.some((step) => { var _a; return ((_a = step.execution) === null || _a === void 0 ? void 0 : _a.status) === 'FAILED'; });
161
- const alreadyStarted = route.steps.some((step) => step.execution);
162
- return !allDone && !isFailed && alreadyStarted;
163
- };
@@ -0,0 +1,3 @@
1
+ /// <reference types="node" />
2
+ import { EventEmitter } from 'events';
3
+ export declare const useWidgetEvents: () => EventEmitter;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.useWidgetEvents = void 0;
7
+ const events_1 = require("events");
8
+ const zustand_1 = __importDefault(require("zustand"));
9
+ const emitterStore = (0, zustand_1.default)()(() => new events_1.EventEmitter());
10
+ const useWidgetEvents = () => {
11
+ return emitterStore();
12
+ };
13
+ exports.useWidgetEvents = useWidgetEvents;
@@ -6,10 +6,12 @@
6
6
  "swap": "Swap",
7
7
  "from": "Swap from",
8
8
  "to": "Swap to",
9
+ "selectChain": "Select chain",
9
10
  "settings": "Settings",
10
11
  "routes": "You get",
11
12
  "swapHistory": "Swap history",
12
- "swapDetails": "Swap details"
13
+ "swapDetails": "Swap details",
14
+ "activeSwaps": "Active swaps"
13
15
  },
14
16
  "button": {
15
17
  "connectWallet": "Connect wallet",
@@ -31,6 +33,7 @@
31
33
  "delete": "Delete",
32
34
  "hide": "Hide",
33
35
  "max": "max",
36
+ "showAll": "Show all",
34
37
  "contactSupport": "Contact support",
35
38
  "lifiSwap": "LI.FI Swap"
36
39
  },
@@ -53,7 +56,6 @@
53
56
  "featuredTokens": "Featured tokens",
54
57
  "otherTokens": "Other tokens",
55
58
  "inProgress": "in progress",
56
- "activeTransfers": "Active transfers",
57
59
  "couldntFindTokens": "We couldn't find tokens on this chain or you don't have any.",
58
60
  "stepSwap": "Swap",
59
61
  "stepBridge": "Bridge",
@@ -63,7 +65,7 @@
63
65
  "swapStepDetails": "Swap on {{chain}} via {{tool}}",
64
66
  "tokenOnChain": "{{tokenSymbol}} on {{chainName}}",
65
67
  "tokenOnChainAmount": "{{amount}} {{tokenSymbol}} on {{chainName}}",
66
- "routeId": "Route ID",
68
+ "supportId": "Support ID",
67
69
  "sendToWallet": "Send to a different wallet",
68
70
  "walletAddressOrEns": "Wallet address or ENS name",
69
71
  "tags": {
@@ -84,11 +86,13 @@
84
86
  "info": {
85
87
  "title": {
86
88
  "routeNotFound": "No routes available",
87
- "emptySwapHistory": "No recent swaps"
89
+ "emptySwapHistory": "No recent swaps",
90
+ "emptyActiveSwaps": "No active swaps"
88
91
  },
89
92
  "message": {
90
93
  "routeNotFound": "Try another token combination.",
91
- "emptySwapHistory": "Swap history is only stored locally and will be deleted if you clear your browser data."
94
+ "emptySwapHistory": "Swap history is only stored locally and will be deleted if you clear your browser data.",
95
+ "emptyActiveSwaps": "Swaps in progress will appear here. Once completed, find them in swap history."
92
96
  }
93
97
  },
94
98
  "warning": {
@@ -105,18 +109,19 @@
105
109
  },
106
110
  "error": {
107
111
  "title": {
112
+ "failed": "Swap failed.",
108
113
  "chainSwitch": "Chain switch required.",
109
114
  "transactionFailed": "Transaction has failed.",
110
115
  "transactionUnderpriced": "Transaction is underpriced.",
111
116
  "transactionUnprepared": "Unable to prepare transaction.",
117
+ "transactionRejected": "Signature required.",
112
118
  "unknown": "Something went wrong.",
113
- "userRejectedSignatureRequest": "Signature required.",
114
119
  "slippageTooLarge": "Slippage too large.",
115
120
  "walletAddressInvalid": "Wallet address is invalid.",
116
121
  "walletEnsAddressInvalid": "Wallet address is invalid or network doesn't support ENS."
117
122
  },
118
123
  "message": {
119
- "signatureRequired": "Your signature is required to complete the transaction. {{amount}} {{tokenSymbol}} on {{chainName}} remain in your wallet.",
124
+ "transactionRejected": "Your signature is required to complete the transaction. {{amount}} {{tokenSymbol}} on {{chainName}} remain in your wallet.",
120
125
  "transactionFailed": "Please check the block explorer for more information.",
121
126
  "transactionNotSent": "Transaction was not sent, your funds are still in your wallet ({{amount}} {{tokenSymbol}} on {{chainName}}).",
122
127
  "slippageTooLarge": "The slippage is larger than the defined threshold. Please request a new route to get a fresh quote."
@@ -129,7 +134,7 @@
129
134
  "done": "Token allowance approved."
130
135
  },
131
136
  "switchChain": {
132
- "pending": "Chain switch required.",
137
+ "actionRequired": "Chain switch required.",
133
138
  "done": "Chain switched successfully."
134
139
  },
135
140
  "swap": {
@@ -9,10 +9,12 @@ export declare const resources: {
9
9
  swap: string;
10
10
  from: string;
11
11
  to: string;
12
+ selectChain: string;
12
13
  settings: string;
13
14
  routes: string;
14
15
  swapHistory: string;
15
16
  swapDetails: string;
17
+ activeSwaps: string;
16
18
  };
17
19
  button: {
18
20
  connectWallet: string;
@@ -34,6 +36,7 @@ export declare const resources: {
34
36
  delete: string;
35
37
  hide: string;
36
38
  max: string;
39
+ showAll: string;
37
40
  contactSupport: string;
38
41
  lifiSwap: string;
39
42
  };
@@ -56,7 +59,6 @@ export declare const resources: {
56
59
  featuredTokens: string;
57
60
  otherTokens: string;
58
61
  inProgress: string;
59
- activeTransfers: string;
60
62
  couldntFindTokens: string;
61
63
  stepSwap: string;
62
64
  stepBridge: string;
@@ -66,7 +68,7 @@ export declare const resources: {
66
68
  swapStepDetails: string;
67
69
  tokenOnChain: string;
68
70
  tokenOnChainAmount: string;
69
- routeId: string;
71
+ supportId: string;
70
72
  sendToWallet: string;
71
73
  walletAddressOrEns: string;
72
74
  tags: {
@@ -88,10 +90,12 @@ export declare const resources: {
88
90
  title: {
89
91
  routeNotFound: string;
90
92
  emptySwapHistory: string;
93
+ emptyActiveSwaps: string;
91
94
  };
92
95
  message: {
93
96
  routeNotFound: string;
94
97
  emptySwapHistory: string;
98
+ emptyActiveSwaps: string;
95
99
  };
96
100
  };
97
101
  warning: {
@@ -108,18 +112,19 @@ export declare const resources: {
108
112
  };
109
113
  error: {
110
114
  title: {
115
+ failed: string;
111
116
  chainSwitch: string;
112
117
  transactionFailed: string;
113
118
  transactionUnderpriced: string;
114
119
  transactionUnprepared: string;
120
+ transactionRejected: string;
115
121
  unknown: string;
116
- userRejectedSignatureRequest: string;
117
122
  slippageTooLarge: string;
118
123
  walletAddressInvalid: string;
119
124
  walletEnsAddressInvalid: string;
120
125
  };
121
126
  message: {
122
- signatureRequired: string;
127
+ transactionRejected: string;
123
128
  transactionFailed: string;
124
129
  transactionNotSent: string;
125
130
  slippageTooLarge: string;
@@ -132,7 +137,7 @@ export declare const resources: {
132
137
  done: string;
133
138
  };
134
139
  switchChain: {
135
- pending: string;
140
+ actionRequired: string;
136
141
  done: string;
137
142
  };
138
143
  swap: {
package/cjs/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import './fonts/inter.css';
3
+ export { useWidgetEvents } from './hooks';
3
4
  export * from './types';
4
5
  export declare const LiFiWidget: import("react").FC<import("./AppProvider").AppProps>;
5
6
  export declare const LiFiWidgetDrawer: import("react").ForwardRefExoticComponent<Pick<import("./AppDrawer").AppDrawerProps, "className" | "style" | "classes" | "slot" | "title" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "children" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "sx" | "key" | "transitionDuration" | "variant" | "open" | "anchor" | "elementRef" | "components" | "componentsProps" | "BackdropComponent" | "BackdropProps" | "closeAfterTransition" | "container" | "disableAutoFocus" | "disableEnforceFocus" | "disableEscapeKeyDown" | "disablePortal" | "disableRestoreFocus" | "disableScrollLock" | "hideBackdrop" | "keepMounted" | "onBackdropClick" | "onClose" | "config" | "elevation" | "ModalProps" | "PaperProps" | "SlideProps"> & import("react").RefAttributes<import("./AppDrawer").AppDrawerBase>>;
package/cjs/index.js CHANGED
@@ -14,11 +14,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.LiFiWidgetDrawer = exports.LiFiWidget = void 0;
17
+ exports.LiFiWidgetDrawer = exports.LiFiWidget = exports.useWidgetEvents = void 0;
18
18
  const App_1 = require("./App");
19
19
  const AppDrawer_1 = require("./AppDrawer");
20
20
  require("./fonts/inter.css");
21
21
  const i18n_1 = require("./i18n");
22
+ var hooks_1 = require("./hooks");
23
+ Object.defineProperty(exports, "useWidgetEvents", { enumerable: true, get: function () { return hooks_1.useWidgetEvents; } });
22
24
  __exportStar(require("./types"), exports);
23
25
  (0, i18n_1.configureReactI18next)();
24
26
  // ClassNameGenerator.configure((componentName) =>
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const ActiveSwapsEmpty: React.FC;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ActiveSwapsEmpty = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const icons_material_1 = require("@mui/icons-material");
6
+ const material_1 = require("@mui/material");
7
+ const react_i18next_1 = require("react-i18next");
8
+ const ActiveSwapsEmpty = () => {
9
+ const { t } = (0, react_i18next_1.useTranslation)();
10
+ return ((0, jsx_runtime_1.jsxs)(material_1.Container, Object.assign({ sx: {
11
+ display: 'flex',
12
+ flex: 1,
13
+ flexDirection: 'column',
14
+ alignItems: 'center',
15
+ justifyContent: 'center',
16
+ } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: 48 }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.SwapHoriz, { fontSize: "inherit" }) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: 18, fontWeight: 700 }, { children: t('swap.info.title.emptyActiveSwaps') })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: 14, color: "text.secondary", textAlign: "center", mt: 2 }, { children: t('swap.info.message.emptyActiveSwaps') }))] })));
17
+ };
18
+ exports.ActiveSwapsEmpty = ActiveSwapsEmpty;
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const ActiveSwapsPage: () => JSX.Element;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ActiveSwapsPage = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const material_1 = require("@mui/material");
6
+ const ActiveSwaps_1 = require("../../components/ActiveSwaps");
7
+ const providers_1 = require("../../providers");
8
+ const stores_1 = require("../../stores");
9
+ const ActiveSwapsEmpty_1 = require("./ActiveSwapsEmpty");
10
+ const ActiveSwapsPage = () => {
11
+ const { account } = (0, providers_1.useWallet)();
12
+ const executingRoutes = (0, stores_1.useExecutingRoutesIds)(account.address);
13
+ if (!executingRoutes.length) {
14
+ return (0, jsx_runtime_1.jsx)(ActiveSwapsEmpty_1.ActiveSwapsEmpty, {});
15
+ }
16
+ return ((0, jsx_runtime_1.jsx)(material_1.Container, Object.assign({ disableGutters: true }, { children: (0, jsx_runtime_1.jsx)(material_1.List, Object.assign({ sx: {
17
+ paddingLeft: 1.5,
18
+ paddingRight: 1.5,
19
+ } }, { children: executingRoutes.map((routeId) => ((0, jsx_runtime_1.jsx)(ActiveSwaps_1.ActiveSwapItem, { routeId: routeId }, routeId))) })) })));
20
+ };
21
+ exports.ActiveSwapsPage = ActiveSwapsPage;
@@ -0,0 +1 @@
1
+ export * from './ActiveSwapsPage';
@@ -14,4 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./SwapsInProgress"), exports);
17
+ __exportStar(require("./ActiveSwapsPage"), exports);
@@ -3,14 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MainPage = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const material_1 = require("@mui/material");
6
+ const ActiveSwaps_1 = require("../../components/ActiveSwaps");
6
7
  const SelectChainAndToken_1 = require("../../components/SelectChainAndToken");
7
- const SendToWallet_1 = require("../../components/SendToWallet");
8
8
  const SwapInput_1 = require("../../components/SwapInput");
9
- const SwapsInProgress_1 = require("../../components/SwapsInProgress");
10
9
  const MainPage_style_1 = require("./MainPage.style");
11
10
  const MainSwapButton_1 = require("./MainSwapButton");
12
11
  const SwapRoutes_1 = require("./SwapRoutes");
13
12
  const MainPage = () => {
14
- return ((0, jsx_runtime_1.jsxs)(MainPage_style_1.FormContainer, Object.assign({ disableGutters: true }, { children: [(0, jsx_runtime_1.jsx)(SwapsInProgress_1.SwapsInProgress, { mx: 3, mt: 1, mb: 2 }), (0, jsx_runtime_1.jsx)(SelectChainAndToken_1.SelectChainAndToken, { mt: 1, mx: 3, mb: 3 }), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mx: 3, mb: 3 }, { children: (0, jsx_runtime_1.jsx)(SwapInput_1.SwapInput, { formType: "from" }) })), (0, jsx_runtime_1.jsx)(SendToWallet_1.SendToWallet, { mx: 3, mb: 3 }), (0, jsx_runtime_1.jsx)(SwapRoutes_1.SwapRoutes, { mx: 3, mb: 3 }), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mx: 3, mb: 1 }, { children: (0, jsx_runtime_1.jsx)(MainSwapButton_1.MainSwapButton, {}) }))] })));
13
+ return ((0, jsx_runtime_1.jsxs)(MainPage_style_1.FormContainer, Object.assign({ disableGutters: true }, { children: [(0, jsx_runtime_1.jsx)(ActiveSwaps_1.ActiveSwaps, { mx: 3, mt: 1, mb: 2 }), (0, jsx_runtime_1.jsx)(SelectChainAndToken_1.SelectChainAndToken, { mt: 1, mx: 3, mb: 3 }), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mx: 3, mb: 3 }, { children: (0, jsx_runtime_1.jsx)(SwapInput_1.SwapInput, { formType: "from" }) })), (0, jsx_runtime_1.jsx)(SwapRoutes_1.SwapRoutes, { mx: 3, mb: 3 }), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mx: 3, mb: 1 }, { children: (0, jsx_runtime_1.jsx)(MainSwapButton_1.MainSwapButton, {}) }))] })));
15
14
  };
16
15
  exports.MainPage = MainPage;
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.MainSwapButton = void 0;
13
13
  const jsx_runtime_1 = require("react/jsx-runtime");
14
+ const react_hook_form_1 = require("react-hook-form");
14
15
  const react_router_dom_1 = require("react-router-dom");
15
16
  const SwapButton_1 = require("../../components/SwapButton");
16
17
  const hooks_1 = require("../../hooks");
@@ -18,6 +19,7 @@ const stores_1 = require("../../stores");
18
19
  const utils_1 = require("../../utils");
19
20
  const MainSwapButton = () => {
20
21
  const navigate = (0, react_router_dom_1.useNavigate)();
22
+ const { isValid, isValidating } = (0, react_hook_form_1.useFormState)();
21
23
  const setExecutableRoute = (0, stores_1.useSetExecutableRoute)();
22
24
  const { routes: swapRoutes, isLoading, isFetching } = (0, hooks_1.useSwapRoutes)();
23
25
  const currentRoute = swapRoutes === null || swapRoutes === void 0 ? void 0 : swapRoutes[0];
@@ -29,6 +31,6 @@ const MainSwapButton = () => {
29
31
  });
30
32
  }
31
33
  });
32
- return ((0, jsx_runtime_1.jsx)(SwapButton_1.SwapButton, { onClick: handleClick, currentRoute: currentRoute, loading: isLoading || isFetching || !currentRoute }));
34
+ return ((0, jsx_runtime_1.jsx)(SwapButton_1.SwapButton, { onClick: handleClick, currentRoute: currentRoute, disable: isLoading || isFetching || !currentRoute || isValidating || !isValid }));
33
35
  };
34
36
  exports.MainSwapButton = MainSwapButton;
@@ -6,11 +6,13 @@ const jsx_runtime_1 = require("react/jsx-runtime");
6
6
  const icons_material_1 = require("@mui/icons-material");
7
7
  const material_1 = require("@mui/material");
8
8
  const react_1 = require("react");
9
+ const react_hook_form_1 = require("react-hook-form");
9
10
  const react_i18next_1 = require("react-i18next");
10
11
  const react_router_dom_1 = require("react-router-dom");
11
12
  const Card_1 = require("../../components/Card");
12
13
  const GasSufficiencyMessage_1 = require("../../components/GasSufficiencyMessage");
13
14
  const ProgressToNextUpdate_1 = require("../../components/ProgressToNextUpdate");
15
+ const SendToWallet_1 = require("../../components/SendToWallet");
14
16
  const SwapRouteCard_1 = require("../../components/SwapRouteCard");
15
17
  const hooks_1 = require("../../hooks");
16
18
  const utils_1 = require("../../utils");
@@ -18,6 +20,7 @@ const SwapRoutes_style_1 = require("./SwapRoutes.style");
18
20
  const SwapRoutes = (props) => {
19
21
  const { t } = (0, react_i18next_1.useTranslation)();
20
22
  const navigate = (0, react_router_dom_1.useNavigate)();
23
+ const { isValid, isValidating } = (0, react_hook_form_1.useFormState)();
21
24
  const { routes, isLoading, isFetching, isFetched, dataUpdatedAt, refetchTime, refetch, } = (0, hooks_1.useSwapRoutes)();
22
25
  const handleCardClick = (0, react_1.useCallback)(() => {
23
26
  navigate(utils_1.navigationRoutes.swapRoutes);
@@ -35,6 +38,6 @@ const SwapRoutes = (props) => {
35
38
  borderWidth: !routeNotFound && (isFetching || (routes && routes.length > 1))
36
39
  ? 1
37
40
  : 0,
38
- } }, { children: isLoading || isFetching ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCardSkeleton, { minWidth: "80%", dense: true }), (0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCardSkeleton, { minWidth: "80%", dense: true })] })) : !currentRoute ? ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteNotFoundCard, { minWidth: "100%", dense: true })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCard, { minWidth: routes.length > 1 ? '80%' : '100%', route: currentRoute, active: true, dense: true }), routes.length > 1 ? ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCard, { minWidth: "80%", route: routes[1], dense: true })) : null] })) })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' } }, { children: !routeNotFound ? ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ py: 1, pr: 1 }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ onClick: handleCardClick, size: "medium", "aria-label": "swap-routes" }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.KeyboardArrowRight, {}) })) }))) : null }))] }))] })), (0, jsx_runtime_1.jsx)(GasSufficiencyMessage_1.GasSufficiencyMessage, Object.assign({ route: !isFetching ? currentRoute : undefined }, props))] }));
41
+ } }, { children: isLoading || isFetching ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCardSkeleton, { minWidth: "80%", dense: true }), (0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCardSkeleton, { minWidth: "80%", dense: true })] })) : !currentRoute ? ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteNotFoundCard, { minWidth: "100%", dense: true })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCard, { minWidth: routes.length > 1 ? '80%' : '100%', route: currentRoute, active: true, dense: true }), routes.length > 1 ? ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCard, { minWidth: "80%", route: routes[1], dense: true })) : null] })) })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' } }, { children: !routeNotFound ? ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ py: 1, pr: 1 }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ onClick: handleCardClick, size: "medium", "aria-label": "swap-routes", disabled: isValidating || !isValid }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.KeyboardArrowRight, {}) })) }))) : null }))] }))] })), (0, jsx_runtime_1.jsx)(GasSufficiencyMessage_1.GasSufficiencyMessage, Object.assign({ route: !isFetching ? currentRoute : undefined }, props)), (0, jsx_runtime_1.jsx)(SendToWallet_1.SendToWallet, { mx: 3, mb: 3 })] }));
39
42
  };
40
43
  exports.SwapRoutes = SwapRoutes;
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import type { SwapFormTypeProps } from '../../providers';
3
+ export declare const SelectChainPage: React.FC<Partial<SwapFormTypeProps>>;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.SelectChainPage = void 0;
13
+ const jsx_runtime_1 = require("react/jsx-runtime");
14
+ const material_1 = require("@mui/material");
15
+ const react_router_dom_1 = require("react-router-dom");
16
+ const ChainSelect_1 = require("../../components/ChainSelect");
17
+ const hooks_1 = require("../../hooks");
18
+ const SelectChainPage_style_1 = require("./SelectChainPage.style");
19
+ const SelectChainPage = ({ formType, }) => {
20
+ const { navigateBack } = (0, hooks_1.useNavigateBack)();
21
+ const { state } = (0, react_router_dom_1.useLocation)();
22
+ const formTypeState = (state === null || state === void 0 ? void 0 : state.formType) || formType;
23
+ const { chains, setCurrentChain } = (0, ChainSelect_1.useChainSelect)(formTypeState);
24
+ const handleClick = (chainId) => __awaiter(void 0, void 0, void 0, function* () {
25
+ setCurrentChain(chainId);
26
+ navigateBack();
27
+ });
28
+ return ((0, jsx_runtime_1.jsx)(material_1.Container, Object.assign({ disableGutters: true }, { children: (0, jsx_runtime_1.jsx)(material_1.List, Object.assign({ sx: {
29
+ paddingLeft: 1.5,
30
+ paddingRight: 1.5,
31
+ } }, { children: chains === null || chains === void 0 ? void 0 : chains.map((chain) => ((0, jsx_runtime_1.jsxs)(SelectChainPage_style_1.ListItemButton, Object.assign({ onClick: () => handleClick(chain.id), disableRipple: true }, { children: [(0, jsx_runtime_1.jsx)(material_1.ListItemAvatar, { children: (0, jsx_runtime_1.jsx)(material_1.Avatar, Object.assign({ src: chain.logoURI, alt: chain.name }, { children: chain.name[0] })) }), (0, jsx_runtime_1.jsx)(SelectChainPage_style_1.ListItemText, { primary: chain.name })] }), chain.id))) })) })));
32
+ };
33
+ exports.SelectChainPage = SelectChainPage;
@@ -0,0 +1,21 @@
1
+ /// <reference types="react" />
2
+ export declare const ListItemButton: import("@emotion/styled").StyledComponent<import("@mui/material").ListItemButtonBaseProps & Omit<{
3
+ action?: import("react").Ref<import("@mui/material").ButtonBaseActions> | undefined;
4
+ centerRipple?: boolean | undefined;
5
+ children?: import("react").ReactNode;
6
+ classes?: Partial<import("@mui/material").ButtonBaseClasses> | undefined;
7
+ disabled?: boolean | undefined;
8
+ disableRipple?: boolean | undefined;
9
+ disableTouchRipple?: boolean | undefined;
10
+ focusRipple?: boolean | undefined;
11
+ focusVisibleClassName?: string | undefined;
12
+ LinkComponent?: import("react").ElementType<any> | undefined;
13
+ onFocusVisible?: import("react").FocusEventHandler<any> | undefined;
14
+ sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
15
+ tabIndex?: number | undefined;
16
+ TouchRippleProps?: Partial<import("@mui/material/ButtonBase/TouchRipple").TouchRippleProps> | undefined;
17
+ touchRippleRef?: import("react").Ref<import("@mui/material/ButtonBase/TouchRipple").TouchRippleActions> | undefined;
18
+ }, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
19
+ ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
20
+ }, "className" | "style" | "classes" | "tabIndex" | "children" | "action" | "centerRipple" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "TouchRippleProps" | "touchRippleRef" | "alignItems" | "autoFocus" | "dense" | "divider" | "selected" | "disableGutters"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
21
+ export declare const ListItemText: import("@emotion/styled").StyledComponent<import("@mui/material").ListItemTextProps<import("react").ElementType<any>, import("react").ElementType<any>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ListItemText = exports.ListItemButton = void 0;
4
+ const material_1 = require("@mui/material");
5
+ const ListItemText_1 = require("@mui/material/ListItemText");
6
+ const styles_1 = require("@mui/material/styles");
7
+ const utils_1 = require("../../utils");
8
+ exports.ListItemButton = (0, styles_1.styled)(material_1.ListItemButton)(({ theme }) => ({
9
+ borderRadius: theme.shape.borderRadiusSecondary,
10
+ paddingLeft: theme.spacing(1.5),
11
+ height: 56,
12
+ '&:hover': {
13
+ backgroundColor: (0, utils_1.getContrastAlphaColor)(theme, '4%'),
14
+ },
15
+ }));
16
+ exports.ListItemText = (0, styles_1.styled)(material_1.ListItemText)(({ theme }) => ({
17
+ [`.${ListItemText_1.listItemTextClasses.primary}`]: {
18
+ fontWeight: 400,
19
+ },
20
+ }));
@@ -0,0 +1 @@
1
+ export * from './SelectChainPage';