@lifi/widget 1.25.1 → 1.26.1

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 (92) hide show
  1. package/cjs/components/ActiveSwaps/ActiveSwapItem.js +6 -3
  2. package/cjs/components/BottomSheet/BottomSheet.js +2 -1
  3. package/cjs/components/BottomSheet/types.d.ts +2 -1
  4. package/cjs/components/GasSufficiencyMessage/GasSufficiencyMessage.js +1 -1
  5. package/cjs/components/Header/NavigationHeader.js +1 -1
  6. package/cjs/components/Header/WalletHeader.js +1 -1
  7. package/cjs/components/ReverseTokensButton/ReverseTokensButton.style.js +1 -1
  8. package/cjs/components/Step/CircularProgress.d.ts +3 -3
  9. package/cjs/components/Step/CircularProgress.js +10 -9
  10. package/cjs/components/Step/CircularProgress.style.d.ts +12 -3
  11. package/cjs/components/Step/CircularProgress.style.js +26 -10
  12. package/cjs/components/Step/DestinationWalletAddress.d.ts +7 -0
  13. package/cjs/components/Step/DestinationWalletAddress.js +32 -0
  14. package/cjs/components/Step/GasStepProcess.d.ts +5 -0
  15. package/cjs/components/Step/GasStepProcess.js +24 -0
  16. package/cjs/components/Step/Step.d.ts +1 -0
  17. package/cjs/components/Step/Step.js +18 -6
  18. package/cjs/components/Step/StepList.d.ts +3 -0
  19. package/cjs/components/Step/StepList.js +20 -0
  20. package/cjs/components/Step/StepProcess.js +2 -2
  21. package/cjs/components/Step/index.d.ts +1 -0
  22. package/cjs/components/Step/index.js +1 -0
  23. package/cjs/components/SwapButton/SwapButton.js +1 -1
  24. package/cjs/components/SwapRouteCard/SwapRouteNotFoundCard.js +1 -1
  25. package/cjs/config/sentry.js +1 -1
  26. package/cjs/config/version.d.ts +1 -1
  27. package/cjs/config/version.js +1 -1
  28. package/cjs/hooks/useChains.js +4 -1
  29. package/cjs/hooks/useProcessMessage.js +47 -5
  30. package/cjs/hooks/useRouteExecution.d.ts +8 -2
  31. package/cjs/hooks/useRouteExecution.js +14 -5
  32. package/cjs/hooks/useSwapRoutes.d.ts +2 -2
  33. package/cjs/hooks/useSwapRoutes.js +7 -0
  34. package/cjs/hooks/useTokenBalance.js +2 -2
  35. package/cjs/hooks/useTools.js +2 -0
  36. package/cjs/i18n/en.json +44 -28
  37. package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +10 -15
  38. package/cjs/pages/SwapHistoryPage/SwapHistoryEmpty.js +1 -1
  39. package/cjs/pages/SwapPage/ExchangeRateBottomSheet.d.ts +15 -0
  40. package/cjs/pages/SwapPage/ExchangeRateBottomSheet.js +71 -0
  41. package/cjs/pages/SwapPage/StatusBottomSheet.js +20 -4
  42. package/cjs/pages/SwapPage/StatusBottomSheet.style.js +4 -4
  43. package/cjs/pages/SwapPage/SwapPage.js +12 -14
  44. package/cjs/pages/SwapPage/TokenValueBottomSheet.js +6 -5
  45. package/cjs/utils/navigationRoutes.js +1 -0
  46. package/components/ActiveSwaps/ActiveSwapItem.js +6 -3
  47. package/components/BottomSheet/BottomSheet.js +3 -2
  48. package/components/BottomSheet/types.d.ts +2 -1
  49. package/components/GasSufficiencyMessage/GasSufficiencyMessage.js +1 -1
  50. package/components/Header/NavigationHeader.js +2 -2
  51. package/components/Header/WalletHeader.js +1 -1
  52. package/components/ReverseTokensButton/ReverseTokensButton.style.js +1 -1
  53. package/components/Step/CircularProgress.d.ts +3 -3
  54. package/components/Step/CircularProgress.js +12 -11
  55. package/components/Step/CircularProgress.style.d.ts +12 -3
  56. package/components/Step/CircularProgress.style.js +27 -11
  57. package/components/Step/DestinationWalletAddress.d.ts +7 -0
  58. package/components/Step/DestinationWalletAddress.js +28 -0
  59. package/components/Step/GasStepProcess.d.ts +5 -0
  60. package/components/Step/GasStepProcess.js +20 -0
  61. package/components/Step/Step.d.ts +1 -0
  62. package/components/Step/Step.js +18 -6
  63. package/components/Step/StepList.d.ts +3 -0
  64. package/components/Step/StepList.js +16 -0
  65. package/components/Step/StepProcess.js +2 -2
  66. package/components/Step/index.d.ts +1 -0
  67. package/components/Step/index.js +1 -0
  68. package/components/SwapButton/SwapButton.js +1 -1
  69. package/components/SwapRouteCard/SwapRouteNotFoundCard.js +1 -1
  70. package/config/sentry.js +1 -1
  71. package/config/version.d.ts +1 -1
  72. package/config/version.js +1 -1
  73. package/hooks/useChains.js +5 -2
  74. package/hooks/useProcessMessage.js +47 -5
  75. package/hooks/useRouteExecution.d.ts +8 -2
  76. package/hooks/useRouteExecution.js +15 -6
  77. package/hooks/useSwapRoutes.d.ts +2 -2
  78. package/hooks/useSwapRoutes.js +7 -0
  79. package/hooks/useTokenBalance.js +2 -2
  80. package/hooks/useTools.js +2 -0
  81. package/i18n/en.json +44 -28
  82. package/package.json +9 -9
  83. package/pages/SwapDetailsPage/SwapDetailsPage.js +14 -19
  84. package/pages/SwapHistoryPage/SwapHistoryEmpty.js +1 -1
  85. package/pages/SwapPage/ExchangeRateBottomSheet.d.ts +15 -0
  86. package/pages/SwapPage/ExchangeRateBottomSheet.js +67 -0
  87. package/pages/SwapPage/StatusBottomSheet.js +22 -6
  88. package/pages/SwapPage/StatusBottomSheet.style.js +4 -4
  89. package/pages/SwapPage/SwapPage.js +15 -17
  90. package/pages/SwapPage/TokenValueBottomSheet.js +7 -6
  91. package/tsconfig.cjs.tsbuildinfo +1 -1
  92. package/utils/navigationRoutes.js +1 -0
@@ -14,7 +14,10 @@ const ActiveSwaps_style_1 = require("./ActiveSwaps.style");
14
14
  const ActiveSwapItem = ({ routeId, dense }) => {
15
15
  var _a;
16
16
  const navigate = (0, react_router_dom_1.useNavigate)();
17
- const { route, status } = (0, hooks_1.useRouteExecution)(routeId, true);
17
+ const { route, status } = (0, hooks_1.useRouteExecution)({
18
+ routeId,
19
+ executeInBackground: true,
20
+ });
18
21
  // TODO: replace with ES2023 findLast
19
22
  const lastActiveStep = route === null || route === void 0 ? void 0 : route.steps.slice().reverse().find((step) => step.execution);
20
23
  const lastActiveProcess = (_a = lastActiveStep === null || lastActiveStep === void 0 ? void 0 : lastActiveStep.execution) === null || _a === void 0 ? void 0 : _a.process.at(-1);
@@ -28,9 +31,9 @@ const ActiveSwapItem = ({ routeId, dense }) => {
28
31
  const getStatusComponent = () => {
29
32
  switch (lastActiveProcess === null || lastActiveProcess === void 0 ? void 0 : lastActiveProcess.status) {
30
33
  case 'ACTION_REQUIRED':
31
- return (0, jsx_runtime_1.jsx)(icons_material_1.Info, { color: "info", fontSize: "small" });
34
+ return (0, jsx_runtime_1.jsx)(icons_material_1.InfoRounded, { color: "info", fontSize: "small" });
32
35
  case 'FAILED':
33
- return (0, jsx_runtime_1.jsx)(icons_material_1.Warning, { color: "error", fontSize: "small" });
36
+ return (0, jsx_runtime_1.jsx)(icons_material_1.ErrorRounded, { color: "error", fontSize: "small" });
34
37
  default:
35
38
  return ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: 14, fontWeight: 500 }, { children: (0, jsx_runtime_1.jsx)(StepTimer_1.StepTimer, { step: lastActiveStep, hideInProgress: true }) })));
36
39
  }
@@ -6,12 +6,13 @@ const material_1 = require("@mui/material");
6
6
  const react_1 = require("react");
7
7
  const hooks_1 = require("../../hooks");
8
8
  const Dialog_1 = require("../Dialog");
9
- exports.BottomSheet = (0, react_1.forwardRef)(({ elementRef, children, open }, ref) => {
9
+ exports.BottomSheet = (0, react_1.forwardRef)(({ elementRef, children, open, onClose }, ref) => {
10
10
  const openRef = (0, react_1.useRef)(open);
11
11
  const [drawerOpen, setDrawerOpen] = (0, react_1.useState)(open);
12
12
  const close = (0, react_1.useCallback)(() => {
13
13
  setDrawerOpen(false);
14
14
  openRef.current = false;
15
+ onClose === null || onClose === void 0 ? void 0 : onClose();
15
16
  }, []);
16
17
  (0, react_1.useImperativeHandle)(ref, () => ({
17
18
  isOpen: () => openRef.current,
@@ -1,7 +1,8 @@
1
1
  import type { DrawerProps } from '@mui/material';
2
2
  import type { RefObject } from 'react';
3
- export type BottomSheetProps = DrawerProps & {
3
+ export type BottomSheetProps = Omit<DrawerProps, 'onClose'> & {
4
4
  elementRef?: RefObject<HTMLDivElement>;
5
+ onClose?(): void;
5
6
  };
6
7
  export interface BottomSheetBase {
7
8
  isOpen(): void;
@@ -25,7 +25,7 @@ const GasSufficiencyMessage = (_a) => {
25
25
  const { t } = (0, react_i18next_1.useTranslation)();
26
26
  const recommendedRoute = (0, stores_1.useRecommendedRouteStore)((state) => state.recommendedRoute);
27
27
  const { insufficientFunds, insufficientGas } = (0, hooks_1.useGasSufficiency)(route !== null && route !== void 0 ? route : recommendedRoute);
28
- return ((0, jsx_runtime_1.jsx)(material_1.Collapse, Object.assign({ timeout: 225, in: Boolean(insufficientFunds || (insufficientGas === null || insufficientGas === void 0 ? void 0 : insufficientGas.length)), unmountOnExit: true, mountOnEnter: true, appear: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({}, props, { children: (0, jsx_runtime_1.jsxs)(GasSufficiencyMessage_style_1.MessageCard, { children: [(0, jsx_runtime_1.jsx)(icons_material_1.WarningAmber, { sx: {
28
+ return ((0, jsx_runtime_1.jsx)(material_1.Collapse, Object.assign({ timeout: 225, in: Boolean(insufficientFunds || (insufficientGas === null || insufficientGas === void 0 ? void 0 : insufficientGas.length)), unmountOnExit: true, mountOnEnter: true, appear: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({}, props, { children: (0, jsx_runtime_1.jsxs)(GasSufficiencyMessage_style_1.MessageCard, { children: [(0, jsx_runtime_1.jsx)(icons_material_1.WarningAmberRounded, { sx: {
29
29
  marginTop: 2,
30
30
  marginLeft: 2,
31
31
  } }), (0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(insufficientGas === null || insufficientGas === void 0 ? void 0 : insufficientGas.length) ? ((0, jsx_runtime_1.jsx)(Card_1.CardTitle, { children: t(`swap.warning.title.insufficientGas`) })) : null, insufficientFunds ? ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2", px: 2, pb: (insufficientGas === null || insufficientGas === void 0 ? void 0 : insufficientGas.length) ? 0 : 2, pt: (insufficientGas === null || insufficientGas === void 0 ? void 0 : insufficientGas.length) ? 1 : 2 }, { children: insufficientFunds
@@ -51,7 +51,7 @@ const NavigationHeader = () => {
51
51
  return variant !== 'refuel' ? t(`header.swap`) : t(`header.gas`);
52
52
  }
53
53
  };
54
- return ((0, jsx_runtime_1.jsxs)(Header_style_1.HeaderAppBar, Object.assign({ elevation: 0 }, { children: [utils_1.backButtonRoutes.includes(path) ? ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ size: "medium", edge: "start", onClick: navigateBack }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.ArrowBack, {}) }))) : null, (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: hasPath ? 18 : 24, align: hasPath ? 'center' : 'left', fontWeight: "700", flex: 1, noWrap: true }, { children: handleHeaderTitle() })), (0, jsx_runtime_1.jsxs)(react_router_dom_1.Routes, { children: [(0, jsx_runtime_1.jsx)(react_router_dom_1.Route, { path: utils_1.navigationRoutes.home, element: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [account.isActive ? ((0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: t(`header.swapHistory`), enterDelay: 400, arrow: true }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ size: "medium", edge: "start", onClick: () => navigate(utils_1.navigationRoutes.swapHistory) }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.History, {}) })) }))) : null, (0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: t(`header.settings`), enterDelay: 400, arrow: true }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ size: "medium", onClick: () => navigate(utils_1.navigationRoutes.settings), sx: {
54
+ return ((0, jsx_runtime_1.jsxs)(Header_style_1.HeaderAppBar, Object.assign({ elevation: 0 }, { children: [utils_1.backButtonRoutes.includes(path) ? ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ size: "medium", edge: "start", onClick: navigateBack }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.ArrowBack, {}) }))) : null, (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: hasPath ? 18 : 24, align: hasPath ? 'center' : 'left', fontWeight: "700", flex: 1, noWrap: true }, { children: handleHeaderTitle() })), (0, jsx_runtime_1.jsxs)(react_router_dom_1.Routes, { children: [(0, jsx_runtime_1.jsx)(react_router_dom_1.Route, { path: utils_1.navigationRoutes.home, element: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [account.isActive ? ((0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: t(`header.swapHistory`), enterDelay: 400, arrow: true }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ size: "medium", edge: "start", onClick: () => navigate(utils_1.navigationRoutes.swapHistory) }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.ReceiptLongRounded, {}) })) }))) : null, (0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: t(`header.settings`), enterDelay: 400, arrow: true }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ size: "medium", onClick: () => navigate(utils_1.navigationRoutes.settings), sx: {
55
55
  marginRight: -1.25,
56
56
  } }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.SettingsOutlined, {}) })) }))] }) }), (0, jsx_runtime_1.jsx)(react_router_dom_1.Route, { path: "*", element: element || (0, jsx_runtime_1.jsx)(material_1.Box, { width: 28, height: 40 }) })] })] })));
57
57
  };
@@ -66,5 +66,5 @@ const ConnectedButton = () => {
66
66
  });
67
67
  return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Header_style_1.WalletButton, Object.assign({ endIcon: (0, jsx_runtime_1.jsx)(icons_material_1.ExpandMore, {}), startIcon: (0, jsx_runtime_1.jsx)(material_1.Avatar, Object.assign({ src: chain === null || chain === void 0 ? void 0 : chain.logoURI, alt: chain === null || chain === void 0 ? void 0 : chain.key, sx: { width: 24, height: 24 } }, { children: chain === null || chain === void 0 ? void 0 : chain.name[0] })), sx: {
68
68
  marginRight: -1.25,
69
- }, onClick: handleClick }, { children: walletAddress })), (0, jsx_runtime_1.jsxs)(Menu_1.Menu, Object.assign({ elevation: 2, anchorEl: anchorEl, open: Boolean(anchorEl), onClose: handleClose }, { children: [(0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ onClick: handleCopyAddress, disableRipple: true, dense: true }, { children: [(0, jsx_runtime_1.jsx)(icons_material_1.ContentCopy, {}), t(`button.copyAddress`)] })), (0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ onClick: handleDisconnect, disableRipple: true, dense: true }, { children: [(0, jsx_runtime_1.jsx)(icons_material_1.PowerSettingsNew, {}), t(`button.disconnectWallet`)] }))] }))] }));
69
+ }, onClick: handleClick }, { children: walletAddress })), (0, jsx_runtime_1.jsxs)(Menu_1.Menu, Object.assign({ elevation: 2, anchorEl: anchorEl, open: Boolean(anchorEl), onClose: handleClose }, { children: [(0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ onClick: handleCopyAddress, disableRipple: true, dense: true }, { children: [(0, jsx_runtime_1.jsx)(icons_material_1.ContentCopy, {}), t(`button.copyAddress`)] })), (0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ onClick: handleDisconnect, disableRipple: true, dense: true }, { children: [(0, jsx_runtime_1.jsx)(icons_material_1.PowerSettingsNewRounded, {}), t(`button.disconnectWallet`)] }))] }))] }));
70
70
  };
@@ -9,7 +9,7 @@ exports.IconButton = (0, styles_1.styled)(material_1.IconButton)(({ theme }) =>
9
9
  borderColor: theme.palette.mode === 'light'
10
10
  ? theme.palette.grey[300]
11
11
  : theme.palette.grey[800],
12
- zIndex: 1200,
12
+ zIndex: 1100,
13
13
  padding: theme.spacing(0.5),
14
14
  '&:hover': {
15
15
  backgroundColor: theme.palette.mode === 'light'
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import type { Status } from '@lifi/sdk';
3
- export declare function CircularProgress({ status }: {
4
- status: Status;
2
+ import type { Process } from '@lifi/sdk';
3
+ export declare function CircularProgress({ process }: {
4
+ process: Process;
5
5
  }): JSX.Element;
@@ -3,20 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CircularProgress = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const icons_material_1 = require("@mui/icons-material");
6
- const material_1 = require("@mui/material");
6
+ const styles_1 = require("@mui/material/styles");
7
7
  const CircularProgress_style_1 = require("./CircularProgress.style");
8
- function CircularProgress({ status }) {
9
- return ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ sx: {
10
- display: 'grid',
11
- position: 'relative',
12
- placeItems: 'center',
13
- } }, { children: [(0, jsx_runtime_1.jsx)(CircularProgress_style_1.CircularProgress, { variant: "determinate", status: status, size: 32, thickness: 3, value: 100 }), status === 'STARTED' || status === 'PENDING' ? ((0, jsx_runtime_1.jsx)(CircularProgress_style_1.CircularProgressPending, { size: 32, thickness: 3 })) : null, status === 'ACTION_REQUIRED' ? ((0, jsx_runtime_1.jsx)(icons_material_1.Info, { color: "info", sx: {
8
+ function CircularProgress({ process }) {
9
+ return ((0, jsx_runtime_1.jsxs)(CircularProgress_style_1.CircularIcon, Object.assign({ status: process.status, substatus: process.substatus }, { children: [process.status === 'STARTED' || process.status === 'PENDING' ? ((0, jsx_runtime_1.jsx)(CircularProgress_style_1.CircularProgressPending, { size: 32, thickness: 3 })) : null, process.status === 'ACTION_REQUIRED' ? ((0, jsx_runtime_1.jsx)(icons_material_1.InfoRounded, { color: "info", sx: {
14
10
  position: 'absolute',
15
11
  fontSize: '1rem',
16
- } })) : null, status === 'DONE' ? ((0, jsx_runtime_1.jsx)(icons_material_1.Done, { color: "success", sx: {
12
+ } })) : null, process.status === 'DONE' &&
13
+ (process.substatus === 'PARTIAL' || process.substatus === 'REFUNDED') ? ((0, jsx_runtime_1.jsx)(icons_material_1.WarningRounded, { sx: (theme) => ({
17
14
  position: 'absolute',
18
15
  fontSize: '1rem',
19
- } })) : null, status === 'FAILED' ? ((0, jsx_runtime_1.jsx)(icons_material_1.Warning, { color: "error", sx: {
16
+ color: (0, styles_1.darken)(theme.palette.warning.main, 0.32),
17
+ }) })) : process.status === 'DONE' ? ((0, jsx_runtime_1.jsx)(icons_material_1.Done, { color: "success", sx: {
18
+ position: 'absolute',
19
+ fontSize: '1rem',
20
+ } })) : null, process.status === 'FAILED' ? ((0, jsx_runtime_1.jsx)(icons_material_1.ErrorRounded, { color: "error", sx: {
20
21
  position: 'absolute',
21
22
  fontSize: '1rem',
22
23
  } })) : null] })));
@@ -1,6 +1,15 @@
1
- import type { Status } from '@lifi/sdk';
2
- import type { Theme } from '@mui/material';
3
- export declare const CircularProgress: import("@emotion/styled").StyledComponent<import("@mui/material").CircularProgressProps & import("@mui/system").MUIStyledCommonProps<Theme> & {
1
+ /// <reference types="react" />
2
+ import type { Status, Substatus } from '@lifi/sdk';
3
+ import { Theme } from '@mui/material';
4
+ export declare const CircularIcon: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<Theme> & {
5
+ children?: import("react").ReactNode;
6
+ component?: import("react").ElementType<any> | undefined;
7
+ ref?: import("react").Ref<unknown> | undefined;
8
+ sx?: import("@mui/material").SxProps<Theme> | undefined;
9
+ } & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
10
+ ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
11
+ }, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "ref" | ("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") | "component"> & import("@mui/system").MUIStyledCommonProps<Theme> & {
4
12
  status: Status;
13
+ substatus?: Substatus | undefined;
5
14
  }, {}, {}>;
6
15
  export declare const CircularProgressPending: import("@emotion/styled").StyledComponent<import("@mui/material").CircularProgressProps & import("@mui/system").MUIStyledCommonProps<Theme>, {}, {}>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CircularProgressPending = exports.CircularProgress = void 0;
3
+ exports.CircularProgressPending = exports.CircularIcon = void 0;
4
4
  const material_1 = require("@mui/material");
5
5
  const CircularProgress_1 = require("@mui/material/CircularProgress");
6
6
  const styles_1 = require("@mui/material/styles");
@@ -18,22 +18,38 @@ const circleAnimation = (0, styles_1.keyframes)({
18
18
  transform: 'rotate(360deg)',
19
19
  },
20
20
  });
21
- const getStatusColor = (status, theme) => {
21
+ const getStatusColor = (theme, status, substatus) => {
22
22
  switch (status) {
23
23
  case 'ACTION_REQUIRED':
24
- return theme.palette.info.main;
24
+ return (0, styles_1.alpha)(theme.palette.info.main, 0.12);
25
25
  case 'DONE':
26
- return theme.palette.success.main;
26
+ if (substatus === 'PARTIAL' || substatus === 'REFUNDED') {
27
+ return (0, styles_1.alpha)(theme.palette.warning.main, 0.48);
28
+ }
29
+ return (0, styles_1.alpha)(theme.palette.success.main, 0.12);
27
30
  case 'FAILED':
28
- return theme.palette.error.main;
31
+ return (0, styles_1.alpha)(theme.palette.error.main, 0.12);
29
32
  default:
30
33
  return theme.palette.grey[theme.palette.mode === 'light' ? 300 : 800];
31
34
  }
32
35
  };
33
- exports.CircularProgress = (0, styles_1.styled)(material_1.CircularProgress, {
34
- shouldForwardProp: (prop) => prop !== 'status',
35
- })(({ theme, status }) => ({
36
- color: getStatusColor(status, theme),
36
+ exports.CircularIcon = (0, styles_1.styled)(material_1.Box, {
37
+ shouldForwardProp: (prop) => !['status', 'substatus'].includes(prop),
38
+ })(({ theme, status, substatus }) => ({
39
+ backgroundColor: ['ACTION_REQUIRED', 'DONE', 'FAILED'].includes(status)
40
+ ? getStatusColor(theme, status, substatus)
41
+ : theme.palette.background.paper,
42
+ borderStyle: 'solid',
43
+ borderColor: getStatusColor(theme, status, substatus),
44
+ borderWidth: !['ACTION_REQUIRED', 'DONE', 'FAILED'].includes(status)
45
+ ? 2
46
+ : 0,
47
+ display: 'grid',
48
+ position: 'relative',
49
+ placeItems: 'center',
50
+ width: 32,
51
+ height: 32,
52
+ borderRadius: '50%',
37
53
  }));
38
54
  exports.CircularProgressPending = (0, styles_1.styled)(material_1.CircularProgress)(({ theme }) => ({
39
55
  color: theme.palette.mode === 'light'
@@ -41,7 +57,7 @@ exports.CircularProgressPending = (0, styles_1.styled)(material_1.CircularProgre
41
57
  : theme.palette.primary.light,
42
58
  animationDuration: '3s',
43
59
  position: 'absolute',
44
- left: 0,
60
+ left: '-2px',
45
61
  [`.${CircularProgress_1.circularProgressClasses.circle}`]: {
46
62
  animationDuration: '2s',
47
63
  animationTimingFunction: 'linear',
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import type { Step } from '@lifi/sdk';
3
+ export declare const DestinationWalletAddress: React.FC<{
4
+ step: Step;
5
+ toAddress: string;
6
+ toAddressLink: string;
7
+ }>;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DestinationWalletAddress = 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 CircularProgress_style_1 = require("./CircularProgress.style");
9
+ const StepProcess_style_1 = require("./StepProcess.style");
10
+ const DestinationWalletAddress = ({ step, toAddress, toAddressLink }) => {
11
+ var _a;
12
+ const { t } = (0, react_i18next_1.useTranslation)();
13
+ const isDone = ((_a = step.execution) === null || _a === void 0 ? void 0 : _a.status) === 'DONE';
14
+ return ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ px: 2, py: 1 }, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ sx: {
15
+ display: 'flex',
16
+ alignItems: 'center',
17
+ } }, { children: [(0, jsx_runtime_1.jsx)(CircularProgress_style_1.CircularIcon, Object.assign({ status: isDone ? 'DONE' : 'NOT_STARTED' }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.WalletOutlined, { color: isDone ? 'success' : 'inherit', sx: {
18
+ position: 'absolute',
19
+ fontSize: '1rem',
20
+ } }) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ ml: 2, fontSize: 14, fontWeight: 400 }, { children: isDone
21
+ ? t('swap.sentToAddress', {
22
+ address: toAddress,
23
+ })
24
+ : t('swap.sendToAddress', {
25
+ address: toAddress,
26
+ }) })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ ml: 2, sx: {
27
+ display: 'flex',
28
+ flex: 1,
29
+ justifyContent: 'flex-end',
30
+ } }, { children: (0, jsx_runtime_1.jsx)(StepProcess_style_1.LinkButton, Object.assign({ size: "small", edge: "end", LinkComponent: material_1.Link, href: toAddressLink, target: "_blank", rel: "nofollow noreferrer" }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.LinkRounded, {}) })) }))] })) })));
31
+ };
32
+ exports.DestinationWalletAddress = DestinationWalletAddress;
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import type { Step } from '@lifi/sdk';
3
+ export declare const GasStepProcess: React.FC<{
4
+ step: Step;
5
+ }>;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GasStepProcess = 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 CircularProgress_style_1 = require("./CircularProgress.style");
9
+ const GasStepProcess = ({ step }) => {
10
+ var _a, _b, _c, _d;
11
+ const { t } = (0, react_i18next_1.useTranslation)();
12
+ const isDone = ((_a = step.execution) === null || _a === void 0 ? void 0 : _a.status) === 'DONE';
13
+ return ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ px: 2, py: 1 }, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ sx: {
14
+ display: 'flex',
15
+ alignItems: 'center',
16
+ } }, { children: [(0, jsx_runtime_1.jsx)(CircularProgress_style_1.CircularIcon, Object.assign({ status: isDone ? 'DONE' : 'NOT_STARTED' }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.EvStationOutlined, { color: isDone ? 'success' : 'inherit', sx: {
17
+ position: 'absolute',
18
+ fontSize: '1rem',
19
+ } }) })), (0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ ml: 2, fontSize: 14, fontWeight: 400 }, { children: [t('format.currency', {
20
+ value: (_d = (((_b = step.execution) === null || _b === void 0 ? void 0 : _b.gasAmountUSD) ||
21
+ ((_c = step.estimate.gasCosts) === null || _c === void 0 ? void 0 : _c.reduce((amount, gasCost) => amount + parseFloat(gasCost.amountUSD || '0'), 0)))) !== null && _d !== void 0 ? _d : 0,
22
+ }), ' ', isDone ? t('swap.gasFeePaid') : t('swap.gasFeeEstimated')] }))] })) })));
23
+ };
24
+ exports.GasStepProcess = GasStepProcess;
@@ -4,4 +4,5 @@ export declare const Step: React.FC<{
4
4
  step: StepType;
5
5
  fromToken?: TokenAmount;
6
6
  toToken?: TokenAmount;
7
+ toAddress?: string;
7
8
  }>;
@@ -7,19 +7,27 @@ const react_i18next_1 = require("react-i18next");
7
7
  const Card_1 = require("../../components/Card");
8
8
  const StepActions_1 = require("../../components/StepActions");
9
9
  const Token_1 = require("../../components/Token");
10
+ const hooks_1 = require("../../hooks");
11
+ const utils_1 = require("../../utils");
12
+ const DestinationWalletAddress_1 = require("./DestinationWalletAddress");
13
+ const GasStepProcess_1 = require("./GasStepProcess");
10
14
  const StepProcess_1 = require("./StepProcess");
11
15
  const StepTimer_1 = require("./StepTimer");
12
- const Step = ({ step, fromToken, toToken }) => {
13
- var _a, _b;
16
+ const Step = ({ step, fromToken, toToken, toAddress }) => {
17
+ var _a, _b, _c;
14
18
  const { t } = (0, react_i18next_1.useTranslation)();
19
+ const { getChainById } = (0, hooks_1.useChains)();
15
20
  const stepHasError = (_a = step.execution) === null || _a === void 0 ? void 0 : _a.process.some((process) => process.status === 'FAILED');
16
21
  const getCardTitle = () => {
17
22
  switch (step.type) {
18
23
  case 'lifi':
19
- if (step.includedSteps.some((step) => step.type === 'cross')) {
20
- return t('swap.stepSwapAndBridge');
24
+ if (step.includedSteps.every((step) => step.type === 'cross')) {
25
+ return t('swap.stepBridge');
21
26
  }
22
- return t('swap.stepSwap');
27
+ if (step.includedSteps.every((step) => step.type === 'swap')) {
28
+ return t('swap.stepSwap');
29
+ }
30
+ return t('swap.stepSwapAndBridge');
23
31
  case 'swap':
24
32
  return t('swap.stepSwap');
25
33
  case 'cross':
@@ -28,9 +36,13 @@ const Step = ({ step, fromToken, toToken }) => {
28
36
  return t('swap.stepSwap');
29
37
  }
30
38
  };
39
+ const formattedToAddress = (0, utils_1.shortenWalletAddress)(toAddress);
40
+ const toAddressLink = toAddress
41
+ ? `${(_b = getChainById(step.action.toChainId)) === null || _b === void 0 ? void 0 : _b.metamask.blockExplorerUrls[0]}address/${toAddress}`
42
+ : undefined;
31
43
  return ((0, jsx_runtime_1.jsxs)(Card_1.Card, Object.assign({ variant: stepHasError ? 'error' : 'default' }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ sx: {
32
44
  display: 'flex',
33
45
  flex: 1,
34
- } }, { children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, Object.assign({ flex: 1 }, { children: getCardTitle() })), (0, jsx_runtime_1.jsx)(Card_1.CardTitle, Object.assign({ sx: { fontWeight: 500 } }, { children: (0, jsx_runtime_1.jsx)(StepTimer_1.StepTimer, { step: step }) }))] })), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ py: 1 }, { children: [fromToken ? (0, jsx_runtime_1.jsx)(Token_1.Token, { token: fromToken, px: 2, py: 1 }) : null, (0, jsx_runtime_1.jsx)(StepActions_1.StepActions, { step: step, px: 2, py: 1, dense: true }), (_b = step.execution) === null || _b === void 0 ? void 0 : _b.process.map((process, index) => ((0, jsx_runtime_1.jsx)(StepProcess_1.StepProcess, { step: step, process: process }, index))), toToken ? (0, jsx_runtime_1.jsx)(Token_1.Token, { token: toToken, px: 2, py: 1 }) : null] }))] })));
46
+ } }, { children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, Object.assign({ flex: 1 }, { children: getCardTitle() })), (0, jsx_runtime_1.jsx)(Card_1.CardTitle, Object.assign({ sx: { fontWeight: 500 } }, { children: (0, jsx_runtime_1.jsx)(StepTimer_1.StepTimer, { step: step }) }))] })), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ py: 1 }, { children: [fromToken ? (0, jsx_runtime_1.jsx)(Token_1.Token, { token: fromToken, px: 2, py: 1 }) : null, (0, jsx_runtime_1.jsx)(StepActions_1.StepActions, { step: step, px: 2, py: 1, dense: true }), (_c = step.execution) === null || _c === void 0 ? void 0 : _c.process.map((process, index) => ((0, jsx_runtime_1.jsx)(StepProcess_1.StepProcess, { step: step, process: process }, index))), (0, jsx_runtime_1.jsx)(GasStepProcess_1.GasStepProcess, { step: step }), formattedToAddress && toAddressLink ? ((0, jsx_runtime_1.jsx)(DestinationWalletAddress_1.DestinationWalletAddress, { step: step, toAddress: formattedToAddress, toAddressLink: toAddressLink })) : null, toToken ? (0, jsx_runtime_1.jsx)(Token_1.Token, { token: toToken, px: 2, py: 1 }) : null] }))] })));
35
47
  };
36
48
  exports.Step = Step;
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { Route } from '@lifi/sdk';
3
+ export declare const getStepList: (route?: Route) => JSX.Element[] | undefined;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getStepList = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const StepDivider_1 = require("../../components/StepDivider");
7
+ const Step_1 = require("./Step");
8
+ const getStepList = (route) => route === null || route === void 0 ? void 0 : route.steps.map((step, index, steps) => {
9
+ var _a, _b, _c, _d, _e;
10
+ const lastIndex = steps.length - 1;
11
+ const fromToken = index === 0
12
+ ? Object.assign(Object.assign({}, step.action.fromToken), { amount: step.action.fromAmount }) : undefined;
13
+ const toToken = index === lastIndex
14
+ ? Object.assign(Object.assign({}, ((_b = (_a = step.execution) === null || _a === void 0 ? void 0 : _a.toToken) !== null && _b !== void 0 ? _b : (_c = step.action) === null || _c === void 0 ? void 0 : _c.toToken)), { amount: (_e = (_d = step.execution) === null || _d === void 0 ? void 0 : _d.toAmount) !== null && _e !== void 0 ? _e : step.estimate.toAmount }) : undefined;
15
+ const toAddress = index === lastIndex && route.fromAddress !== route.toAddress
16
+ ? route.toAddress
17
+ : undefined;
18
+ return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Step_1.Step, { step: step, fromToken: fromToken, toToken: toToken, toAddress: toAddress }), steps.length > 1 && index !== steps.length - 1 ? ((0, jsx_runtime_1.jsx)(StepDivider_1.StepDivider, {})) : null] }, step.id));
19
+ });
20
+ exports.getStepList = getStepList;
@@ -12,10 +12,10 @@ const StepProcess = ({ step, process }) => {
12
12
  return ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ px: 2, py: 1 }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ sx: {
13
13
  display: 'flex',
14
14
  alignItems: 'center',
15
- } }, { children: [(0, jsx_runtime_1.jsx)(CircularProgress_1.CircularProgress, { status: process.status }), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ ml: 2, fontSize: 14, fontWeight: process.error ? 600 : 400 }, { children: title })), process.txLink ? ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ ml: 2, sx: {
15
+ } }, { children: [(0, jsx_runtime_1.jsx)(CircularProgress_1.CircularProgress, { process: process }), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ ml: 2, fontSize: 14, fontWeight: process.error ? 600 : 400 }, { children: title })), process.txLink ? ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ ml: 2, sx: {
16
16
  display: 'flex',
17
17
  flex: 1,
18
18
  justifyContent: 'flex-end',
19
- } }, { children: (0, jsx_runtime_1.jsx)(StepProcess_style_1.LinkButton, Object.assign({ size: "small", edge: "end", LinkComponent: material_1.Link, href: process.txLink, target: "_blank", rel: "nofollow noreferrer" }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.Link, {}) })) }))) : null] })), message ? ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ ml: 6, fontSize: 14, fontWeight: 500, color: "text.secondary" }, { children: message }))) : null] })));
19
+ } }, { children: (0, jsx_runtime_1.jsx)(StepProcess_style_1.LinkButton, Object.assign({ size: "small", edge: "end", LinkComponent: material_1.Link, href: process.txLink, target: "_blank", rel: "nofollow noreferrer" }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.LinkRounded, {}) })) }))) : null] })), message ? ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ ml: 6, fontSize: 14, fontWeight: 500, color: "text.secondary" }, { children: message }))) : null] })));
20
20
  };
21
21
  exports.StepProcess = StepProcess;
@@ -1 +1,2 @@
1
1
  export * from './Step';
2
+ export * from './StepList';
@@ -15,3 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./Step"), exports);
18
+ __exportStar(require("./StepList"), exports);
@@ -51,5 +51,5 @@ exports.SwapButton = (0, react_1.forwardRef)(({ onClick, currentRoute, text, dis
51
51
  }
52
52
  return t(`button.connectWallet`);
53
53
  };
54
- return ((0, jsx_runtime_1.jsx)(lab_1.LoadingButton, Object.assign({ variant: "contained", color: account.isActive ? 'primary' : 'success', onClick: handleSwapButtonClick, disabled: insufficientFunds || !!(insufficientGas === null || insufficientGas === void 0 ? void 0 : insufficientGas.length) || disable, loading: enableLoading && (loading || isGasSufficiencyLoading), loadingPosition: "center", fullWidth: true, ref: ref }, { children: getButtonText() })));
54
+ return ((0, jsx_runtime_1.jsx)(lab_1.LoadingButton, Object.assign({ variant: "contained", color: "primary", onClick: handleSwapButtonClick, disabled: insufficientFunds || !!(insufficientGas === null || insufficientGas === void 0 ? void 0 : insufficientGas.length) || disable, loading: enableLoading && (loading || isGasSufficiencyLoading), loadingPosition: "center", fullWidth: true, ref: ref }, { children: getButtonText() })));
55
55
  });
@@ -13,6 +13,6 @@ const SwapRouteNotFoundCard = () => {
13
13
  justifyContent: 'center',
14
14
  flexDirection: 'column',
15
15
  flex: 1,
16
- }, py: 2.375 }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: 48 }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.Route, { fontSize: "inherit" }) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: 18, fontWeight: 700 }, { children: t('swap.info.title.routeNotFound') })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: 14, color: "text.secondary", textAlign: "center", mt: 2 }, { children: t('swap.info.message.routeNotFound') }))] })));
16
+ }, py: 1.625 }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: 48 }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.Route, { fontSize: "inherit" }) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: 18, fontWeight: 700 }, { children: t('swap.info.title.routeNotFound') })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: 14, color: "text.secondary", textAlign: "center", mt: 2 }, { children: t('swap.info.message.routeNotFound') }))] })));
17
17
  };
18
18
  exports.SwapRouteNotFoundCard = SwapRouteNotFoundCard;
@@ -30,7 +30,7 @@ const initSentry = (enabled) => __awaiter(void 0, void 0, void 0, function* () {
30
30
  levels: ['error'],
31
31
  }),
32
32
  ],
33
- sampleRate: 1,
33
+ sampleRate: 0.25,
34
34
  tracesSampleRate: 0.2,
35
35
  enabled,
36
36
  environment: process.env.NODE_ENV,
@@ -1,2 +1,2 @@
1
1
  export declare const name = "@lifi/widget";
2
- export declare const version = "1.25.1";
2
+ export declare const version = "1.26.1";
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = exports.name = void 0;
4
4
  exports.name = '@lifi/widget';
5
- exports.version = '1.25.1';
5
+ exports.version = '1.26.1';
@@ -36,7 +36,10 @@ const useChains = () => {
36
36
  setValue(providers_1.SwapFormKey.ToChain, chainOrder[0]);
37
37
  }
38
38
  return { availableChains, filteredChains };
39
- }));
39
+ }), {
40
+ refetchInterval: 180000,
41
+ staleTime: 180000,
42
+ });
40
43
  const getChainById = (0, react_1.useCallback)((chainId) => {
41
44
  const chain = data === null || data === void 0 ? void 0 : data.availableChains.find((chain) => chain.id === chainId);
42
45
  // if (!chain) {
@@ -14,7 +14,7 @@ const useProcessMessage = (step, process) => {
14
14
  return getProcessMessage(t, getChainById, step, process);
15
15
  };
16
16
  exports.useProcessMessage = useProcessMessage;
17
- const processMessages = {
17
+ const processStatusMessages = {
18
18
  TOKEN_ALLOWANCE: {
19
19
  STARTED: (t) => t(`swap.process.tokenAllowance.started`),
20
20
  PENDING: (t) => t(`swap.process.tokenAllowance.pending`),
@@ -42,8 +42,34 @@ const processMessages = {
42
42
  },
43
43
  TRANSACTION: {},
44
44
  };
45
+ const processSubstatusMessages = {
46
+ PENDING: {
47
+ // BRIDGE_NOT_AVAILABLE: 'Bridge communication is temporarily unavailable.',
48
+ // CHAIN_NOT_AVAILABLE: 'RPC communication is temporarily unavailable.',
49
+ // REFUND_IN_PROGRESS:
50
+ // "The refund has been requested and it's being processed",
51
+ // WAIT_DESTINATION_TRANSACTION:
52
+ // 'The bridge off-chain logic is being executed. Wait for the transaction to appear on the destination chain.',
53
+ // WAIT_SOURCE_CONFIRMATIONS:
54
+ // 'The bridge deposit has been received. The bridge is waiting for more confirmations to start the off-chain logic.',
55
+ },
56
+ DONE: {
57
+ // COMPLETED: 'The transfer is complete.',
58
+ PARTIAL: (t) => t(`swap.process.receivingChain.partial`),
59
+ REFUNDED: (t) => t(`swap.process.receivingChain.partial`),
60
+ },
61
+ FAILED: {
62
+ // TODO: should be moved to failed status
63
+ // NOT_PROCESSABLE_REFUND_NEEDED:
64
+ // 'The transfer cannot be completed successfully. A refund operation is required.',
65
+ // UNKNOWN_ERROR:
66
+ // 'An unexpected error occurred. Please seek assistance in the LI.FI discord server.',
67
+ },
68
+ INVALID: {},
69
+ NOT_FOUND: {},
70
+ };
45
71
  function getProcessMessage(t, getChainById, step, process) {
46
- var _a, _b, _c, _d;
72
+ var _a, _b, _c, _d, _e, _f, _g;
47
73
  if (process.error && process.status === 'FAILED') {
48
74
  const getTransactionNotSentMessage = () => {
49
75
  var _a, _b;
@@ -56,10 +82,18 @@ function getProcessMessage(t, getChainById, step, process) {
56
82
  let title = '';
57
83
  let message = '';
58
84
  switch (process.error.code) {
85
+ case sdk_1.LifiErrorCode.BalanceError:
86
+ title = t(`swap.error.title.balanceIsTooLow`);
87
+ message = getTransactionNotSentMessage();
88
+ break;
59
89
  case sdk_1.LifiErrorCode.ChainSwitchError:
60
90
  title = t(`swap.error.title.chainSwitch`);
61
91
  message = getTransactionNotSentMessage();
62
92
  break;
93
+ case sdk_1.LifiErrorCode.GasLimitError:
94
+ title = t(`swap.error.title.gasLimitIsTooLow`);
95
+ message = getTransactionNotSentMessage();
96
+ break;
63
97
  case sdk_1.LifiErrorCode.TransactionFailed:
64
98
  title = t(`swap.error.title.transactionFailed`);
65
99
  message = t(`swap.error.message.transactionFailed`);
@@ -72,9 +106,13 @@ function getProcessMessage(t, getChainById, step, process) {
72
106
  title = t(`swap.error.title.transactionUnprepared`);
73
107
  message = getTransactionNotSentMessage();
74
108
  break;
109
+ case sdk_1.LifiErrorCode.TransactionCanceled:
110
+ title = t(`swap.error.title.transactionCanceled`);
111
+ message = getTransactionNotSentMessage();
112
+ break;
75
113
  case sdk_1.LifiErrorCode.SlippageError:
76
- title = t(`swap.error.title.slippageTooLarge`);
77
- message = t(`swap.error.message.slippageTooLarge`);
114
+ title = t(`swap.error.title.slippageNotMet`);
115
+ message = t(`swap.error.message.slippageThreshold`);
78
116
  break;
79
117
  case sdk_1.LifiErrorCode.TransactionRejected:
80
118
  title = t(`swap.error.title.transactionRejected`);
@@ -84,16 +122,20 @@ function getProcessMessage(t, getChainById, step, process) {
84
122
  chainName: (_b = (_a = getChainById(step.action.fromChainId)) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : '',
85
123
  });
86
124
  break;
125
+ case sdk_1.LifiErrorCode.ProviderUnavailable:
87
126
  default:
88
127
  title = t(`swap.error.title.unknown`);
89
128
  if (process.txLink) {
90
129
  message = t(`swap.error.message.transactionFailed`);
91
130
  }
131
+ else {
132
+ message = t(`swap.error.message.unknown`);
133
+ }
92
134
  break;
93
135
  }
94
136
  return { title, message };
95
137
  }
96
- const title = (_d = (_c = processMessages[process.type]) === null || _c === void 0 ? void 0 : _c[process.status]) === null || _d === void 0 ? void 0 : _d.call(_c, t);
138
+ const title = (_e = (_d = (_c = processSubstatusMessages[process.status]) === null || _c === void 0 ? void 0 : _c[process.substatus]) === null || _d === void 0 ? void 0 : _d.call(_c, t)) !== null && _e !== void 0 ? _e : (_g = (_f = processStatusMessages[process.type]) === null || _f === void 0 ? void 0 : _f[process.status]) === null || _g === void 0 ? void 0 : _g.call(_f, t);
97
139
  return { title };
98
140
  }
99
141
  exports.getProcessMessage = getProcessMessage;
@@ -1,8 +1,14 @@
1
- import type { Route } from '@lifi/sdk';
2
- export declare const useRouteExecution: (routeId: string, executeInBackground?: boolean) => {
1
+ import type { ExchangeRateUpdateParams, Route } from '@lifi/sdk';
2
+ interface RouteExecutionProps {
3
+ routeId: string;
4
+ executeInBackground?: boolean;
5
+ onAcceptExchangeRateUpdate?(resolver: (value: boolean) => void, data: ExchangeRateUpdateParams): void;
6
+ }
7
+ export declare const useRouteExecution: ({ routeId, executeInBackground, onAcceptExchangeRateUpdate, }: RouteExecutionProps) => {
3
8
  executeRoute: () => void;
4
9
  restartRoute: () => void;
5
10
  deleteRoute: () => void;
6
11
  route: Route | undefined;
7
12
  status: import("../stores").RouteExecutionStatus | undefined;
8
13
  };
14
+ export {};