@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,29 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
+ import { Avatar, Container, List, ListItemAvatar } from '@mui/material';
12
+ import { useLocation } from 'react-router-dom';
13
+ import { useChainSelect } from '../../components/ChainSelect';
14
+ import { useNavigateBack } from '../../hooks';
15
+ import { ListItemButton, ListItemText } from './SelectChainPage.style';
16
+ export const SelectChainPage = ({ formType, }) => {
17
+ const { navigateBack } = useNavigateBack();
18
+ const { state } = useLocation();
19
+ const formTypeState = (state === null || state === void 0 ? void 0 : state.formType) || formType;
20
+ const { chains, setCurrentChain } = useChainSelect(formTypeState);
21
+ const handleClick = (chainId) => __awaiter(void 0, void 0, void 0, function* () {
22
+ setCurrentChain(chainId);
23
+ navigateBack();
24
+ });
25
+ return (_jsx(Container, Object.assign({ disableGutters: true }, { children: _jsx(List, Object.assign({ sx: {
26
+ paddingLeft: 1.5,
27
+ paddingRight: 1.5,
28
+ } }, { children: chains === null || chains === void 0 ? void 0 : chains.map((chain) => (_jsxs(ListItemButton, Object.assign({ onClick: () => handleClick(chain.id), disableRipple: true }, { children: [_jsx(ListItemAvatar, { children: _jsx(Avatar, Object.assign({ src: chain.logoURI, alt: chain.name }, { children: chain.name[0] })) }), _jsx(ListItemText, { primary: chain.name })] }), chain.id))) })) })));
29
+ };
@@ -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,17 @@
1
+ import { ListItemButton as MuiListItemButton, ListItemText as MuiListItemText, } from '@mui/material';
2
+ import { listItemTextClasses } from '@mui/material/ListItemText';
3
+ import { styled } from '@mui/material/styles';
4
+ import { getContrastAlphaColor } from '../../utils';
5
+ export const ListItemButton = styled(MuiListItemButton)(({ theme }) => ({
6
+ borderRadius: theme.shape.borderRadiusSecondary,
7
+ paddingLeft: theme.spacing(1.5),
8
+ height: 56,
9
+ '&:hover': {
10
+ backgroundColor: getContrastAlphaColor(theme, '4%'),
11
+ },
12
+ }));
13
+ export const ListItemText = styled(MuiListItemText)(({ theme }) => ({
14
+ [`.${listItemTextClasses.primary}`]: {
15
+ fontWeight: 400,
16
+ },
17
+ }));
@@ -0,0 +1 @@
1
+ export * from './SelectChainPage';
@@ -0,0 +1 @@
1
+ export * from './SelectChainPage';
@@ -1,5 +1,3 @@
1
1
  import type { FC } from 'react';
2
- import type { SwapFormDirection } from '../../providers';
3
- export declare const SelectTokenPage: FC<{
4
- formType: SwapFormDirection;
5
- }>;
2
+ import type { SwapFormTypeProps } from '../../providers';
3
+ export declare const SelectTokenPage: FC<SwapFormTypeProps>;
@@ -1,11 +1,11 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Box, Container } from '@mui/material';
3
3
  import { useLayoutEffect, useRef, useState } from 'react';
4
+ import { ChainSelect } from '../../components/ChainSelect';
4
5
  import { TokenList } from '../../components/TokenList';
5
6
  import { useContentHeight, useNavigateBack, useScrollableOverflowHidden, } from '../../hooks';
6
- import { ChainSelect } from './ChainSelect';
7
7
  import { SearchTokenInput } from './SearchTokenInput';
8
- export const SelectTokenPage = ({ formType, }) => {
8
+ export const SelectTokenPage = ({ formType }) => {
9
9
  useScrollableOverflowHidden();
10
10
  const { navigateBack } = useNavigateBack();
11
11
  const headerRef = useRef(null);
@@ -15,7 +15,7 @@ import { useTranslation } from 'react-i18next';
15
15
  import { Dialog } from '../../components/Dialog';
16
16
  import { useNavigateBack } from '../../hooks';
17
17
  import { useWallet } from '../../providers';
18
- import { WalletListItemButton, WalletListItemText, } from './SelectWalletPage.style';
18
+ import { ListItemButton, ListItemText } from './SelectWalletPage.style';
19
19
  export const SelectWalletPage = () => {
20
20
  var _a;
21
21
  const { t } = useTranslation();
@@ -25,7 +25,7 @@ export const SelectWalletPage = () => {
25
25
  const closeDialog = () => {
26
26
  setWalletIdentity((state) => (Object.assign(Object.assign({}, state), { show: false })));
27
27
  };
28
- const handleConnect = useCallback((event, wallet) => __awaiter(void 0, void 0, void 0, function* () {
28
+ const handleConnect = useCallback((wallet) => __awaiter(void 0, void 0, void 0, function* () {
29
29
  const { ethereum } = window;
30
30
  const identityCheckPassed = wallet.checkProviderIdentity({
31
31
  provider: ethereum,
@@ -41,9 +41,9 @@ export const SelectWalletPage = () => {
41
41
  yield connect(wallet);
42
42
  }), [connect, navigateBack]);
43
43
  return (_jsxs(Container, Object.assign({ disableGutters: true }, { children: [_jsx(List, Object.assign({ sx: {
44
- paddingLeft: 2,
45
- paddingRight: 2,
46
- } }, { children: supportedWallets.map((wallet) => (_jsxs(WalletListItemButton, Object.assign({ onClick: (event) => handleConnect(event, wallet), disableRipple: true }, { children: [_jsx(ListItemAvatar, { children: _jsx(Avatar, Object.assign({ src: wallet.icon.src || wallet.icon, alt: wallet.name }, { children: wallet.name[0] })) }), _jsx(WalletListItemText, { primary: wallet.name })] }), wallet.name))) })), _jsxs(Dialog, Object.assign({ open: walletIdentity.show, onClose: closeDialog }, { children: [_jsx(DialogContent, { children: _jsx(DialogContentText, { children: t('wallet.extensionNotFound', {
44
+ paddingLeft: 1.5,
45
+ paddingRight: 1.5,
46
+ } }, { children: supportedWallets.map((wallet) => (_jsxs(ListItemButton, Object.assign({ onClick: () => handleConnect(wallet), disableRipple: true }, { children: [_jsx(ListItemAvatar, { children: _jsx(Avatar, Object.assign({ src: wallet.icon.src || wallet.icon, alt: wallet.name }, { children: wallet.name[0] })) }), _jsx(ListItemText, { primary: wallet.name })] }), wallet.name))) })), _jsxs(Dialog, Object.assign({ open: walletIdentity.show, onClose: closeDialog }, { children: [_jsx(DialogContent, { children: _jsx(DialogContentText, { children: t('wallet.extensionNotFound', {
47
47
  name: (_a = walletIdentity.wallet) === null || _a === void 0 ? void 0 : _a.name,
48
48
  }) }) }), _jsx(DialogActions, { children: _jsx(Button, Object.assign({ onClick: closeDialog, autoFocus: true }, { children: t('button.ok') })) })] }))] })));
49
49
  };
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- export declare const WalletListItemButton: import("@emotion/styled").StyledComponent<import("@mui/material").ListItemButtonBaseProps & Omit<{
2
+ export declare const ListItemButton: import("@emotion/styled").StyledComponent<import("@mui/material").ListItemButtonBaseProps & Omit<{
3
3
  action?: import("react").Ref<import("@mui/material").ButtonBaseActions> | undefined;
4
4
  centerRipple?: boolean | undefined;
5
5
  children?: import("react").ReactNode;
@@ -18,29 +18,4 @@ export declare const WalletListItemButton: import("@emotion/styled").StyledCompo
18
18
  }, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
19
19
  ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
20
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 WalletListItem: import("@emotion/styled").StyledComponent<{
22
- button?: false | undefined;
23
- } & import("@mui/material").ListItemBaseProps & {
24
- components?: {
25
- Root?: import("react").ElementType<any> | undefined;
26
- } | undefined;
27
- componentsProps?: {
28
- root?: (import("react").HTMLAttributes<HTMLDivElement> & import("@mui/material").ListItemComponentsPropsOverrides) | undefined;
29
- } | undefined;
30
- } & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "key" | keyof import("react").LiHTMLAttributes<HTMLLIElement>> & {
31
- ref?: ((instance: HTMLLIElement | null) => void) | import("react").RefObject<HTMLLIElement> | null | undefined;
32
- }, "button" | "className" | "style" | "classes" | "children" | "disabled" | "sx" | "alignItems" | "autoFocus" | "dense" | "divider" | "components" | "componentsProps" | "selected" | "disableGutters" | "ContainerComponent" | "ContainerProps" | "disablePadding" | "secondaryAction"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
33
- export declare const WalletListItemText: import("@emotion/styled").StyledComponent<import("@mui/material").ListItemTextProps<import("react").ElementType<any>, import("react").ElementType<any>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
34
- export declare const WalletIdentityPopoverContent: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
35
- align?: "inherit" | "left" | "right" | "center" | "justify" | undefined;
36
- children?: import("react").ReactNode;
37
- classes?: Partial<import("@mui/material").TypographyClasses> | undefined;
38
- gutterBottom?: boolean | undefined;
39
- noWrap?: boolean | undefined;
40
- paragraph?: boolean | undefined;
41
- sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
42
- variant?: "button" | "caption" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "inherit" | "subtitle1" | "subtitle2" | "body1" | "body2" | "overline" | "@supports (font-variation-settings: normal)" | undefined;
43
- variantMapping?: Partial<Record<"button" | "caption" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "inherit" | "subtitle1" | "subtitle2" | "body1" | "body2" | "overline" | "@supports (font-variation-settings: normal)", string>> | undefined;
44
- } & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "key" | keyof import("react").HTMLAttributes<HTMLSpanElement>> & {
45
- ref?: ((instance: HTMLSpanElement | null) => void) | import("react").RefObject<HTMLSpanElement> | null | undefined;
46
- }, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "variant" | ("p" | "color" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint") | "align" | "gutterBottom" | "noWrap" | "paragraph" | "variantMapping"> & 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>, {}, {}>;
@@ -1,27 +1,17 @@
1
- import { ListItem, ListItemButton, ListItemText, Typography, } from '@mui/material';
2
- import { listItemSecondaryActionClasses } from '@mui/material/ListItemSecondaryAction';
1
+ import { ListItemButton as MuiListItemButton, ListItemText as MuiListItemText, } from '@mui/material';
3
2
  import { listItemTextClasses } from '@mui/material/ListItemText';
4
3
  import { styled } from '@mui/material/styles';
5
4
  import { getContrastAlphaColor } from '../../utils';
6
- export const WalletListItemButton = styled(ListItemButton)(({ theme }) => ({
5
+ export const ListItemButton = styled(MuiListItemButton)(({ theme }) => ({
7
6
  borderRadius: theme.shape.borderRadiusSecondary,
8
7
  paddingLeft: theme.spacing(1.5),
9
- height: 64,
8
+ height: 56,
10
9
  '&:hover': {
11
10
  backgroundColor: getContrastAlphaColor(theme, '4%'),
12
11
  },
13
12
  }));
14
- export const WalletListItem = styled(ListItem)(({ theme }) => ({
15
- padding: theme.spacing(1.5),
16
- [`.${listItemSecondaryActionClasses.root}`]: {
17
- right: theme.spacing(3),
18
- },
19
- }));
20
- export const WalletListItemText = styled(ListItemText)(({ theme }) => ({
13
+ export const ListItemText = styled(MuiListItemText)(({ theme }) => ({
21
14
  [`.${listItemTextClasses.primary}`]: {
22
15
  fontWeight: 400,
23
16
  },
24
17
  }));
25
- export const WalletIdentityPopoverContent = styled(Typography)({
26
- maxWidth: 400,
27
- });
@@ -11,7 +11,7 @@ export declare const ToggleButton: import("@emotion/styled").StyledComponent<{
11
11
  selected?: boolean | undefined;
12
12
  size?: "small" | "medium" | "large" | undefined;
13
13
  sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
14
- value: unknown;
14
+ value: {};
15
15
  } & Omit<{
16
16
  action?: import("react").Ref<import("@mui/material").ButtonBaseActions> | undefined;
17
17
  centerRipple?: boolean | undefined;
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { KeyboardArrowDown as KeyboardArrowDownIcon } from '@mui/icons-material';
3
- import { Box, Chip, FormControl, MenuItem, Skeleton } from '@mui/material';
3
+ import { Box, Checkbox, Chip, FormControl, MenuItem, Skeleton, } from '@mui/material';
4
4
  import { useTranslation } from 'react-i18next';
5
5
  import shallow from 'zustand/shallow';
6
6
  import { Card, CardTitle } from '../../components/Card';
@@ -8,16 +8,13 @@ import { Select } from '../../components/Select';
8
8
  import { useTools } from '../../hooks';
9
9
  import { useSettingsStore } from '../../stores';
10
10
  export const EnabledBridgesSelect = () => {
11
- var _a;
12
11
  const { t } = useTranslation();
13
12
  const { tools, formattedTools } = useTools();
14
13
  const [enabledBridges, setTools] = useSettingsStore((state) => [state.enabledBridges, state.setTools], shallow);
15
- return (tools === null || tools === void 0 ? void 0 : tools.bridges.length) ? (_jsxs(Card, { children: [_jsx(CardTitle, { children: t(`settings.enabledBridges`) }), _jsx(FormControl, Object.assign({ fullWidth: true }, { children: _jsx(Select, Object.assign({ multiple: true, placeholder: t(`settings.selectEnabledBridges`), MenuProps: { elevation: 2 }, IconComponent: KeyboardArrowDownIcon, value: enabledBridges !== null && enabledBridges !== void 0 ? enabledBridges : [], onChange: (event) => {
16
- if (tools === null || tools === void 0 ? void 0 : tools.bridges) {
17
- setTools('Bridges', event.target.value, tools.bridges);
18
- }
14
+ return (tools === null || tools === void 0 ? void 0 : tools.bridges.length) ? (_jsxs(Card, { children: [_jsx(CardTitle, { children: t(`settings.enabledBridges`) }), _jsx(FormControl, Object.assign({ fullWidth: true }, { children: _jsx(Select, Object.assign({ multiple: true, placeholder: t(`settings.selectEnabledBridges`), MenuProps: { elevation: 2, PaperProps: { sx: { maxHeight: 320 } } }, IconComponent: KeyboardArrowDownIcon, value: enabledBridges !== null && enabledBridges !== void 0 ? enabledBridges : [], onChange: (event) => {
15
+ setTools('Bridges', event.target.value, tools.bridges);
19
16
  }, renderValue: (selected) => (_jsx(Box, Object.assign({ sx: { display: 'flex', flexWrap: 'wrap', gap: 0.5 } }, { children: selected.map((value) => {
20
17
  var _a, _b, _c;
21
18
  return (_jsx(Chip, { label: (_c = (_b = (_a = formattedTools.bridges) === null || _a === void 0 ? void 0 : _a[value]) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : value }, value));
22
- }) }))) }, { children: (_a = tools === null || tools === void 0 ? void 0 : tools.bridges) === null || _a === void 0 ? void 0 : _a.map((bridge) => (_jsx(MenuItem, Object.assign({ value: bridge.key }, { children: bridge.name }), bridge.key))) })) }))] })) : (_jsx(Skeleton, { variant: "rectangular", width: "100%", height: 134, sx: { borderRadius: 1 } }));
19
+ }) }))) }, { children: tools.bridges.map((bridge) => (_jsxs(MenuItem, Object.assign({ value: bridge.key, sx: { paddingTop: 0, paddingBottom: 0 } }, { children: [_jsx(Checkbox, { checked: enabledBridges === null || enabledBridges === void 0 ? void 0 : enabledBridges.includes(bridge.key) }), bridge.name] }), bridge.key))) })) }))] })) : (_jsx(Skeleton, { variant: "rectangular", width: "100%", height: 134, sx: { borderRadius: 1 } }));
23
20
  };
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { KeyboardArrowDown as KeyboardArrowDownIcon } from '@mui/icons-material';
3
- import { Box, Chip, FormControl, MenuItem, Skeleton } from '@mui/material';
3
+ import { Box, Checkbox, Chip, FormControl, MenuItem, Skeleton, } from '@mui/material';
4
4
  import { useTranslation } from 'react-i18next';
5
5
  import shallow from 'zustand/shallow';
6
6
  import { Card, CardTitle } from '../../components/Card';
@@ -12,11 +12,9 @@ export const EnabledExchangesSelect = () => {
12
12
  const { tools, formattedTools } = useTools();
13
13
  const [enabledExchanges, setTools] = useSettingsStore((state) => [state.enabledExchanges, state.setTools], shallow);
14
14
  return (tools === null || tools === void 0 ? void 0 : tools.exchanges.length) ? (_jsxs(Card, { children: [_jsx(CardTitle, { children: t(`settings.enabledExchanges`) }), _jsx(FormControl, Object.assign({ fullWidth: true }, { children: _jsx(Select, Object.assign({ multiple: true, placeholder: t(`settings.selectEnabledExchanges`), value: enabledExchanges !== null && enabledExchanges !== void 0 ? enabledExchanges : [], onChange: (event) => {
15
- if (tools === null || tools === void 0 ? void 0 : tools.exchanges) {
16
- setTools('Exchanges', event.target.value, tools.exchanges);
17
- }
18
- }, MenuProps: { elevation: 2 }, IconComponent: KeyboardArrowDownIcon, renderValue: (selected) => (_jsx(Box, Object.assign({ sx: { display: 'flex', flexWrap: 'wrap', gap: 0.5 } }, { children: selected.map((value) => {
15
+ setTools('Exchanges', event.target.value, tools.exchanges);
16
+ }, MenuProps: { elevation: 2, PaperProps: { sx: { maxHeight: 320 } } }, IconComponent: KeyboardArrowDownIcon, renderValue: (selected) => (_jsx(Box, Object.assign({ sx: { display: 'flex', flexWrap: 'wrap', gap: 0.5 } }, { children: selected.map((value) => {
19
17
  var _a, _b, _c;
20
18
  return (_jsx(Chip, { label: (_c = (_b = (_a = formattedTools.exchanges) === null || _a === void 0 ? void 0 : _a[value]) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : value }, value));
21
- }) }))) }, { children: tools === null || tools === void 0 ? void 0 : tools.exchanges.map((exchange) => (_jsx(MenuItem, Object.assign({ value: exchange.key }, { children: exchange.key }), exchange.key))) })) }))] })) : (_jsx(Skeleton, { variant: "rectangular", width: "100%", height: 206, sx: { borderRadius: 1 } }));
19
+ }) }))) }, { children: tools.exchanges.map((exchange) => (_jsxs(MenuItem, Object.assign({ value: exchange.key, sx: { paddingTop: 0, paddingBottom: 0 } }, { children: [_jsx(Checkbox, { checked: enabledExchanges === null || enabledExchanges === void 0 ? void 0 : enabledExchanges.includes(exchange.key) }), exchange.name] }), exchange.key))) })) }))] })) : (_jsx(Skeleton, { variant: "rectangular", width: "100%", height: 206, sx: { borderRadius: 1 } }));
22
20
  };
@@ -10,5 +10,9 @@ export const RoutePrioritySelect = () => {
10
10
  const { t } = useTranslation();
11
11
  const [setValue] = useSetSettings();
12
12
  const { routePriority } = useSettings(['routePriority']);
13
- return (_jsxs(Card, { children: [_jsx(CardTitle, { children: t(`settings.routePriority`) }), _jsx(FormControl, Object.assign({ fullWidth: true }, { children: _jsx(Select, Object.assign({ MenuProps: { elevation: 2 }, value: routePriority, onChange: (event) => setValue('routePriority', event.target.value), IconComponent: KeyboardArrowDownIcon, dense: true }, { children: Orders.map((order) => (_jsx(MenuItem, Object.assign({ value: order }, { children: t(`swap.tags.${order.toLowerCase()}`) }), order))) })) }))] }));
13
+ return (_jsxs(Card, { children: [_jsx(CardTitle, { children: t(`settings.routePriority`) }), _jsx(FormControl, Object.assign({ fullWidth: true }, { children: _jsx(Select, Object.assign({ MenuProps: { elevation: 2 }, value: routePriority, onChange: (event) => setValue('routePriority', event.target.value), IconComponent: KeyboardArrowDownIcon, dense: true }, { children: Orders.map((order) => {
14
+ const tag = t(`swap.tags.${order.toUpperCase()}`);
15
+ const tagName = `${tag[0]}${tag.slice(1).toLowerCase()}`;
16
+ return (_jsx(MenuItem, Object.assign({ value: order }, { children: tagName }), order));
17
+ }) })) }))] }));
14
18
  };
@@ -59,5 +59,5 @@ export const SwapDetailsPage = () => {
59
59
  }), _jsxs(Card, Object.assign({ mt: 2 }, { children: [_jsxs(Box, Object.assign({ sx: {
60
60
  display: 'flex',
61
61
  flex: 1,
62
- } }, { children: [_jsx(CardTitle, Object.assign({ flex: 1 }, { children: t('swap.routeId') })), _jsx(Box, Object.assign({ mr: 1, mt: 1 }, { children: _jsx(IconButton, Object.assign({ size: "medium", "aria-label": "settings", onClick: copyRouteId }, { children: _jsx(ContentCopyIcon, { fontSize: "small" }) })) }))] })), _jsx(Typography, Object.assign({ variant: "body2", pt: 1, pb: 2, px: 2, sx: { wordBreak: 'break-all' } }, { children: routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route.id }))] })), _jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(Button, Object.assign({ variant: "contained", href: "https://discord.com/channels/849912621360218112/863689862514343946", target: "_blank", rel: "nofollow noreferrer", fullWidth: true }, { children: t('button.contactSupport') })) })), _jsxs(Dialog, Object.assign({ open: open, onClose: toggleDialog }, { children: [_jsx(DialogTitle, { children: t('swap.warning.title.deleteSwap') }), _jsx(DialogContent, { children: _jsx(DialogContentText, { children: t('swap.warning.message.deleteSwap') }) }), _jsxs(DialogActions, { children: [_jsx(Button, Object.assign({ onClick: toggleDialog }, { children: t('button.cancel') })), _jsx(Button, Object.assign({ onClick: handleDeleteRoute, autoFocus: true }, { children: t('button.delete') }))] })] }))] }));
62
+ } }, { children: [_jsx(CardTitle, Object.assign({ flex: 1 }, { children: t('swap.supportId') })), _jsx(Box, Object.assign({ mr: 1, mt: 1 }, { children: _jsx(IconButton, Object.assign({ size: "medium", "aria-label": "settings", onClick: copyRouteId }, { children: _jsx(ContentCopyIcon, { fontSize: "small" }) })) }))] })), _jsx(Typography, Object.assign({ variant: "body2", pt: 1, pb: 2, px: 2, sx: { wordBreak: 'break-all' } }, { children: routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route.id }))] })), _jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(Button, Object.assign({ variant: "contained", href: "https://discord.com/channels/849912621360218112/863689862514343946", target: "_blank", rel: "nofollow noreferrer", fullWidth: true }, { children: t('button.contactSupport') })) })), _jsxs(Dialog, Object.assign({ open: open, onClose: toggleDialog }, { children: [_jsx(DialogTitle, { children: t('swap.warning.title.deleteSwap') }), _jsx(DialogContent, { children: _jsx(DialogContentText, { children: t('swap.warning.message.deleteSwap') }) }), _jsxs(DialogActions, { children: [_jsx(Button, Object.assign({ onClick: toggleDialog }, { children: t('button.cancel') })), _jsx(Button, Object.assign({ onClick: handleDeleteRoute, autoFocus: true }, { children: t('button.delete') }))] })] }))] }));
63
63
  };
@@ -1,17 +1,16 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Done as DoneIcon, Info as InfoIcon, Warning as WarningIcon, } from '@mui/icons-material';
3
3
  import { Box, Button, Typography } from '@mui/material';
4
- import { useEffect, useMemo, useRef } from 'react';
4
+ import { useEffect, useRef } from 'react';
5
5
  import { useFormContext } from 'react-hook-form';
6
6
  import { useTranslation } from 'react-i18next';
7
7
  import { BottomSheet } from '../../components/BottomSheet';
8
8
  import { Token } from '../../components/Token';
9
- import { useChains, useNavigateBack, useTokenBalance } from '../../hooks';
9
+ import { getProcessMessage, useChains, useNavigateBack, useTokenBalance, } from '../../hooks';
10
10
  import { SwapFormKey } from '../../providers';
11
11
  import { IconCircle, IconContainer, iconStyles, } from './StatusBottomSheet.style';
12
- import { getProcessMessage } from './utils';
13
12
  export const StatusBottomSheet = ({ status, route, }) => {
14
- var _a, _b, _c, _d, _e;
13
+ var _a, _b, _c, _d, _e, _f, _g;
15
14
  const { t } = useTranslation();
16
15
  const { navigateBack } = useNavigateBack();
17
16
  const ref = useRef(null);
@@ -31,41 +30,31 @@ export const StatusBottomSheet = ({ status, route, }) => {
31
30
  clearFromAmount();
32
31
  (_a = ref.current) === null || _a === void 0 ? void 0 : _a.closeDrawer();
33
32
  };
34
- const { title, message } = useMemo(() => {
35
- var _a, _b;
36
- switch (status) {
37
- case 'success':
38
- return {
39
- title: t('swap.success.title.fundsReceived'),
40
- message: t('swap.success.message.fundsReceived', {
41
- amount: token === null || token === void 0 ? void 0 : token.amount,
42
- tokenSymbol: token === null || token === void 0 ? void 0 : token.symbol,
43
- chainName: (_a = getChainById(route.toChainId)) === null || _a === void 0 ? void 0 : _a.name,
44
- }),
45
- };
46
- case 'error': {
47
- const step = route.steps.find((step) => {
48
- var _a;
49
- return (_a = step.execution) === null || _a === void 0 ? void 0 : _a.process.some((process) => process.status === 'FAILED');
50
- });
51
- const process = (_b = step === null || step === void 0 ? void 0 : step.execution) === null || _b === void 0 ? void 0 : _b.process.find((process) => process.status === 'FAILED');
52
- if (!step || !process) {
53
- return {};
54
- }
55
- return getProcessMessage(t, getChainById, step, process);
33
+ let title;
34
+ let message;
35
+ switch (status) {
36
+ case 'success':
37
+ title = t('swap.success.title.fundsReceived');
38
+ message = t('swap.success.message.fundsReceived', {
39
+ amount: token === null || token === void 0 ? void 0 : token.amount,
40
+ tokenSymbol: token === null || token === void 0 ? void 0 : token.symbol,
41
+ chainName: (_a = getChainById(route.toChainId)) === null || _a === void 0 ? void 0 : _a.name,
42
+ });
43
+ break;
44
+ case 'error': {
45
+ const step = route.steps.find((step) => { var _a; return ((_a = step.execution) === null || _a === void 0 ? void 0 : _a.status) === 'FAILED'; });
46
+ const process = (_b = step === null || step === void 0 ? void 0 : step.execution) === null || _b === void 0 ? void 0 : _b.process.find((process) => process.status === 'FAILED');
47
+ if (!step || !process) {
48
+ break;
56
49
  }
57
- default:
58
- return {};
50
+ const processMessage = getProcessMessage(t, getChainById, step, process);
51
+ title = processMessage.title;
52
+ message = processMessage.message;
53
+ break;
59
54
  }
60
- }, [
61
- getChainById,
62
- route.steps,
63
- route.toChainId,
64
- status,
65
- t,
66
- token === null || token === void 0 ? void 0 : token.amount,
67
- token === null || token === void 0 ? void 0 : token.symbol,
68
- ]);
55
+ default:
56
+ break;
57
+ }
69
58
  useEffect(() => {
70
59
  var _a, _b;
71
60
  if ((status === 'success' || status === 'error') &&
@@ -74,5 +63,5 @@ export const StatusBottomSheet = ({ status, route, }) => {
74
63
  (_b = ref.current) === null || _b === void 0 ? void 0 : _b.openDrawer();
75
64
  }
76
65
  }, [refetchBalance, status]);
77
- return (_jsx(BottomSheet, Object.assign({ ref: ref }, { children: _jsxs(Box, Object.assign({ p: 3 }, { children: [_jsxs(IconContainer, { children: [_jsxs(IconCircle, Object.assign({ status: status, mb: 1 }, { children: [status === 'idle' ? (_jsx(InfoIcon, { color: "primary", sx: iconStyles })) : null, status === 'success' ? (_jsx(DoneIcon, { color: "success", sx: iconStyles })) : null, status === 'error' ? (_jsx(WarningIcon, { color: "error", sx: iconStyles })) : null] })), _jsx(Typography, Object.assign({ py: 1, fontSize: 18, fontWeight: 700 }, { children: title })), status === 'success' ? (_jsx(Token, { token: Object.assign(Object.assign({}, route.toToken), { amount: (_e = (_c = (_b = (_a = route.steps.at(-1)) === null || _a === void 0 ? void 0 : _a.execution) === null || _b === void 0 ? void 0 : _b.toAmount) !== null && _c !== void 0 ? _c : (_d = route.steps.at(-1)) === null || _d === void 0 ? void 0 : _d.estimate.toAmount) !== null && _e !== void 0 ? _e : route.toAmount }), py: 1 })) : null] }), _jsx(Typography, Object.assign({ pt: 2, pb: 1 }, { children: message })), _jsx(Box, Object.assign({ mt: 2 }, { children: _jsxs(Button, Object.assign({ variant: "contained", fullWidth: true, onClick: status === 'success' ? handleDone : handleClose }, { children: [status === 'idle' ? t('button.okay') : null, status === 'success' ? t('button.done') : null, status === 'error' ? t('button.tryAgain') : null] })) })), status === 'success' ? (_jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(Button, Object.assign({ variant: "outlined", fullWidth: true, onClick: handleClose }, { children: t('button.seeDetails') })) }))) : null] })) })));
66
+ return (_jsx(BottomSheet, Object.assign({ ref: ref }, { children: _jsxs(Box, Object.assign({ p: 3 }, { children: [_jsxs(IconContainer, { children: [_jsxs(IconCircle, Object.assign({ status: status, mb: 1 }, { children: [status === 'idle' ? (_jsx(InfoIcon, { color: "primary", sx: iconStyles })) : null, status === 'success' ? (_jsx(DoneIcon, { color: "success", sx: iconStyles })) : null, status === 'error' ? (_jsx(WarningIcon, { color: "error", sx: iconStyles })) : null] })), _jsx(Typography, Object.assign({ py: 1, fontSize: 18, fontWeight: 700 }, { children: title })), status === 'success' ? (_jsx(Token, { token: Object.assign(Object.assign({}, route.toToken), { amount: (_g = (_e = (_d = (_c = route.steps.at(-1)) === null || _c === void 0 ? void 0 : _c.execution) === null || _d === void 0 ? void 0 : _d.toAmount) !== null && _e !== void 0 ? _e : (_f = route.steps.at(-1)) === null || _f === void 0 ? void 0 : _f.estimate.toAmount) !== null && _g !== void 0 ? _g : route.toAmount }), py: 1 })) : null] }), _jsx(Typography, Object.assign({ pt: 2, pb: 1 }, { children: message })), _jsx(Box, Object.assign({ mt: 2 }, { children: _jsxs(Button, Object.assign({ variant: "contained", fullWidth: true, onClick: status === 'success' ? handleDone : handleClose }, { children: [status === 'idle' ? t('button.okay') : null, status === 'success' ? t('button.done') : null, status === 'error' ? t('button.tryAgain') : null] })) })), status === 'success' ? (_jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(Button, Object.assign({ variant: "outlined", fullWidth: true, onClick: handleClose }, { children: t('button.seeDetails') })) }))) : null] })) })));
78
67
  };
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Box, Button } from '@mui/material';
3
3
  import { Fragment } from 'react';
4
+ import { useFormContext } from 'react-hook-form';
4
5
  import { useTranslation } from 'react-i18next';
5
6
  import { useLocation } from 'react-router-dom';
6
7
  import { GasSufficiencyMessage } from '../../components/GasSufficiencyMessage';
@@ -8,12 +9,14 @@ import { Step } from '../../components/Step';
8
9
  import { StepDivider } from '../../components/StepDivider';
9
10
  import { SwapButton } from '../../components/SwapButton';
10
11
  import { useNavigateBack, useRouteExecution } from '../../hooks';
12
+ import { SwapFormKey } from '../../providers';
11
13
  import { StatusBottomSheet } from './StatusBottomSheet';
12
14
  import { Container } from './SwapPage.style';
13
15
  export const SwapPage = () => {
14
16
  const { t } = useTranslation();
15
17
  const { state } = useLocation();
16
18
  const { navigateBack } = useNavigateBack();
19
+ const { setValue, formState: { isValid, isValidating }, } = useFormContext();
17
20
  const { route, status, executeRoute, restartRoute, deleteRoute } = useRouteExecution(state === null || state === void 0 ? void 0 : state.routeId);
18
21
  const handleRemoveRoute = () => {
19
22
  navigateBack();
@@ -22,6 +25,7 @@ export const SwapPage = () => {
22
25
  const handleSwapClick = () => {
23
26
  if (status === 'idle') {
24
27
  executeRoute();
28
+ setValue(SwapFormKey.FromAmount, '');
25
29
  }
26
30
  if (status === 'error') {
27
31
  restartRoute();
@@ -41,5 +45,5 @@ export const SwapPage = () => {
41
45
  return (_jsxs(Fragment, { children: [_jsx(Step, { step: step, fromToken: index === 0
42
46
  ? Object.assign(Object.assign({}, step.action.fromToken), { amount: step.action.fromAmount }) : undefined, toToken: index === steps.length - 1
43
47
  ? Object.assign(Object.assign({}, step.action.toToken), { amount: (_b = (_a = step.execution) === null || _a === void 0 ? void 0 : _a.toAmount) !== null && _b !== void 0 ? _b : step.estimate.toAmount }) : undefined }), steps.length > 1 && index !== steps.length - 1 ? (_jsx(StepDivider, {})) : null] }, step.id));
44
- }), status === 'idle' ? (_jsx(GasSufficiencyMessage, { route: route, mt: 2 })) : null, status === 'idle' || status === 'error' ? (_jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(SwapButton, { text: getSwapButtonText(), onClick: handleSwapClick, currentRoute: route }) }))) : null, status === 'error' ? (_jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(Button, Object.assign({ variant: "outlined", onClick: handleRemoveRoute, fullWidth: true }, { children: t('button.removeSwap') })) }))) : null, route && status ? (_jsx(StatusBottomSheet, { status: status, route: route })) : null] }));
48
+ }), status === 'idle' ? (_jsx(GasSufficiencyMessage, { route: route, mt: 2 })) : null, status === 'idle' || status === 'error' ? (_jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(SwapButton, { text: getSwapButtonText(), onClick: handleSwapClick, currentRoute: route, disable: status === 'idle' && (isValidating || !isValid) }) }))) : null, status === 'error' ? (_jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(Button, Object.assign({ variant: "outlined", onClick: handleRemoveRoute, fullWidth: true }, { children: t('button.removeSwap') })) }))) : null, route && status ? (_jsx(StatusBottomSheet, { status: status, route: route })) : null] }));
45
49
  };
@@ -2,6 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { ChainId } from '@lifi/sdk';
3
3
  import { useEffect } from 'react';
4
4
  import { FormProvider, useForm } from 'react-hook-form';
5
+ import { useChainOrderStore, useSetChainOrder } from '../../stores/chains';
5
6
  import { useWallet } from '../WalletProvider';
6
7
  import { useWidgetConfig } from '../WidgetProvider';
7
8
  import { SwapFormKey } from './types';
@@ -11,6 +12,7 @@ export const formDefaultValues = {
11
12
  [SwapFormKey.TokenSearchFilter]: '',
12
13
  };
13
14
  export const SwapFormProvider = ({ children, }) => {
15
+ const [setChain] = useSetChainOrder();
14
16
  const { account } = useWallet();
15
17
  const { fromChain, fromToken, fromAmount, toChain, toToken, toAddress } = useWidgetConfig();
16
18
  const methods = useForm({
@@ -24,24 +26,50 @@ export const SwapFormProvider = ({ children, }) => {
24
26
  if (!account.isActive || !account.chainId) {
25
27
  return;
26
28
  }
27
- const { isDirty: isFromChainDirty, isTouched: isFromChainTouched } = methods.getFieldState(SwapFormKey.FromChain, methods.formState);
28
- const { isDirty: isToChainDirty, isTouched: isToChainTouched } = methods.getFieldState(SwapFormKey.ToChain, methods.formState);
29
- if (!fromChain && !isFromChainDirty && !isFromChainTouched) {
29
+ const [fromChainValue, toChainValue] = methods.getValues([
30
+ SwapFormKey.FromChain,
31
+ SwapFormKey.ToChain,
32
+ ]);
33
+ const { isDirty: isFromChainDirty } = methods.getFieldState(SwapFormKey.FromChain, methods.formState);
34
+ const { isDirty: isToChainDirty } = methods.getFieldState(SwapFormKey.ToChain, methods.formState);
35
+ const { isDirty: isFromTokenDirty } = methods.getFieldState(SwapFormKey.FromToken, methods.formState);
36
+ const { isDirty: isToTokenDirty } = methods.getFieldState(SwapFormKey.ToToken, methods.formState);
37
+ // Users can switch chains in the wallet.
38
+ // If we don't have a chain in the ordered chain list we should add it.
39
+ setChain(account.chainId);
40
+ // If we ran out of slots for the ordered chain list and the current chain isn't there
41
+ // we should make a recently switched chain as current.
42
+ const { chainOrder } = useChainOrderStore.getState();
43
+ const hasFromChainInOrderedList = chainOrder.includes(fromChainValue);
44
+ const hasToChainInOrderedList = chainOrder.includes(toChainValue);
45
+ if ((!fromChain && !isFromChainDirty && !isFromTokenDirty) ||
46
+ !hasFromChainInOrderedList) {
30
47
  methods.setValue(SwapFormKey.FromChain, account.chainId, {
31
48
  shouldDirty: false,
32
- shouldTouch: false,
49
+ });
50
+ methods.setValue(SwapFormKey.FromToken, '', {
51
+ shouldDirty: false,
52
+ });
53
+ methods.setValue(SwapFormKey.FromAmount, '', {
54
+ shouldDirty: false,
33
55
  });
34
56
  }
35
- if (!toChain &&
36
- !isToChainDirty &&
37
- !isToChainTouched &&
38
- !isFromChainDirty &&
39
- !isFromChainTouched) {
57
+ if ((!toChain && !isToChainDirty && !isToTokenDirty) ||
58
+ !hasToChainInOrderedList) {
40
59
  methods.setValue(SwapFormKey.ToChain, account.chainId, {
41
60
  shouldDirty: false,
42
- shouldTouch: false,
61
+ });
62
+ methods.setValue(SwapFormKey.ToToken, '', {
63
+ shouldDirty: false,
43
64
  });
44
65
  }
45
- }, [account.chainId, account.isActive, fromChain, methods, toChain]);
66
+ }, [
67
+ account.chainId,
68
+ account.isActive,
69
+ fromChain,
70
+ methods,
71
+ setChain,
72
+ toChain,
73
+ ]);
46
74
  return _jsx(FormProvider, Object.assign({}, methods, { children: children }));
47
75
  };
@@ -23,7 +23,7 @@ const initialContext = {
23
23
  const WidgetContext = createContext(initialContext);
24
24
  export const useWidgetConfig = () => useContext(WidgetContext);
25
25
  export const WidgetProvider = (_a) => {
26
- var { children } = _a, _b = _a.config, _c = _b === void 0 ? {} : _b, { fromChain, fromToken, toChain, toToken, fromAmount, integrator } = _c, config = __rest(_c, ["fromChain", "fromToken", "toChain", "toToken", "fromAmount", "integrator"]);
26
+ var { children } = _a, _b = _a.config, _c = _b === void 0 ? {} : _b, { fromChain, fromToken, toChain, toToken, fromAmount, integrator, sdkConfig } = _c, config = __rest(_c, ["fromChain", "fromToken", "toChain", "toToken", "fromAmount", "integrator", "sdkConfig"]);
27
27
  const value = useMemo(() => {
28
28
  var _a, _b, _c, _d;
29
29
  try {
@@ -54,12 +54,8 @@ export const WidgetProvider = (_a) => {
54
54
  }
55
55
  }, [config, fromAmount, fromChain, fromToken, toChain, toToken]);
56
56
  useEffect(() => {
57
- updateLiFiConfig({
58
- defaultRouteOptions: {
59
- integrator: integrator !== null && integrator !== void 0 ? integrator : window.location.hostname,
60
- },
61
- });
62
- }, [integrator]);
57
+ updateLiFiConfig(Object.assign(Object.assign({}, sdkConfig), { defaultRouteOptions: Object.assign(Object.assign({}, sdkConfig === null || sdkConfig === void 0 ? void 0 : sdkConfig.defaultRouteOptions), { integrator: integrator !== null && integrator !== void 0 ? integrator : window.location.hostname }) }));
58
+ }, [integrator, sdkConfig]);
63
59
  useEffect(() => {
64
60
  checkPackageUpdates(name, version);
65
61
  }, []);
@@ -0,0 +1,4 @@
1
+ export * from './types';
2
+ export * from './useChainOrder';
3
+ export * from './useChainOrderStore';
4
+ export * from './useInitializeChainOrder';
@@ -0,0 +1,4 @@
1
+ export * from './types';
2
+ export * from './useChainOrder';
3
+ export * from './useChainOrderStore';
4
+ export * from './useInitializeChainOrder';
@@ -0,0 +1,8 @@
1
+ export interface ChainOrderState {
2
+ chainOrder: number[];
3
+ availableChains: number[];
4
+ }
5
+ export interface ChainOrderStore extends ChainOrderState {
6
+ initializeChains(chainIds: number[]): void;
7
+ setChain(chainId: number): void;
8
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare const useChainOrder: () => [number[], (chainId: number) => void];
@@ -0,0 +1,5 @@
1
+ import shallow from 'zustand/shallow';
2
+ import { useChainOrderStore } from './useChainOrderStore';
3
+ export const useChainOrder = () => {
4
+ return useChainOrderStore((state) => [state.chainOrder, state.setChain], shallow);
5
+ };
@@ -0,0 +1,19 @@
1
+ import type { ChainOrderStore } from './types';
2
+ export declare const maxChainToOrder = 9;
3
+ export declare const useChainOrderStore: import("zustand").UseBoundStore<Omit<Omit<import("zustand").StoreApi<ChainOrderStore>, "persist"> & {
4
+ persist: {
5
+ setOptions: (options: Partial<import("zustand/middleware").PersistOptions<ChainOrderStore, {
6
+ chainOrder: number[];
7
+ }>>) => void;
8
+ clearStorage: () => void;
9
+ rehydrate: () => Promise<void>;
10
+ hasHydrated: () => boolean;
11
+ onHydrate: (fn: (state: ChainOrderStore) => void) => () => void;
12
+ onFinishHydration: (fn: (state: ChainOrderStore) => void) => () => void;
13
+ getOptions: () => Partial<import("zustand/middleware").PersistOptions<ChainOrderStore, {
14
+ chainOrder: number[];
15
+ }>>;
16
+ };
17
+ }, "setState"> & {
18
+ setState(nextStateOrUpdater: ChainOrderStore | Partial<ChainOrderStore> | ((state: import("immer/dist/internal").WritableDraft<ChainOrderStore>) => void), shouldReplace?: boolean | undefined): void;
19
+ }>;