@lifi/widget 2.0.0-alpha.4 → 2.0.0-beta.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 (46) hide show
  1. package/cjs/components/ChainSelect/ChainSelect.d.ts +0 -1
  2. package/cjs/components/GasMessage/FundsSufficiencyMessage.d.ts +0 -1
  3. package/cjs/components/Insurance/Insurance.js +2 -2
  4. package/cjs/components/Insurance/InsuranceCard.js +8 -2
  5. package/cjs/components/Insurance/InsuranceCollapsed.d.ts +2 -2
  6. package/cjs/components/Insurance/InsuranceCollapsed.js +2 -2
  7. package/cjs/components/Insurance/types.d.ts +2 -0
  8. package/cjs/components/Step/CircularProgress.d.ts +0 -1
  9. package/cjs/components/Step/StepList.d.ts +0 -1
  10. package/cjs/components/SwapInput/SwapInputEndAdornment.d.ts +0 -1
  11. package/cjs/components/SwapRoutes/SwapRoutesExpanded.d.ts +0 -1
  12. package/cjs/config/version.d.ts +1 -1
  13. package/cjs/config/version.js +1 -1
  14. package/cjs/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +0 -1
  15. package/cjs/pages/SelectTokenPage/SearchTokenInput.d.ts +0 -1
  16. package/cjs/pages/SelectWalletPage/SelectWalletPage.d.ts +0 -1
  17. package/cjs/pages/SettingsPage/GasPriceSelect.d.ts +0 -1
  18. package/cjs/pages/SettingsPage/SettingsPage.d.ts +0 -1
  19. package/cjs/pages/SettingsPage/ShowDestinationWallet.d.ts +0 -1
  20. package/cjs/pages/SettingsPage/SlippageInput.d.ts +0 -1
  21. package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +6 -4
  22. package/cjs/pages/SwapPage/SwapPage.js +4 -1
  23. package/components/ChainSelect/ChainSelect.d.ts +0 -1
  24. package/components/GasMessage/FundsSufficiencyMessage.d.ts +0 -1
  25. package/components/Insurance/Insurance.js +2 -2
  26. package/components/Insurance/InsuranceCard.js +9 -3
  27. package/components/Insurance/InsuranceCollapsed.d.ts +2 -2
  28. package/components/Insurance/InsuranceCollapsed.js +2 -2
  29. package/components/Insurance/types.d.ts +2 -0
  30. package/components/Step/CircularProgress.d.ts +0 -1
  31. package/components/Step/StepList.d.ts +0 -1
  32. package/components/SwapInput/SwapInputEndAdornment.d.ts +0 -1
  33. package/components/SwapRoutes/SwapRoutesExpanded.d.ts +0 -1
  34. package/config/version.d.ts +1 -1
  35. package/config/version.js +1 -1
  36. package/package.json +5 -5
  37. package/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +0 -1
  38. package/pages/SelectTokenPage/SearchTokenInput.d.ts +0 -1
  39. package/pages/SelectWalletPage/SelectWalletPage.d.ts +0 -1
  40. package/pages/SettingsPage/GasPriceSelect.d.ts +0 -1
  41. package/pages/SettingsPage/SettingsPage.d.ts +0 -1
  42. package/pages/SettingsPage/ShowDestinationWallet.d.ts +0 -1
  43. package/pages/SettingsPage/SlippageInput.d.ts +0 -1
  44. package/pages/SwapDetailsPage/SwapDetailsPage.js +6 -4
  45. package/pages/SwapPage/SwapPage.js +4 -1
  46. package/tsconfig.cjs.tsbuildinfo +1 -1
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type { SwapFormTypeProps } from '../../providers';
3
2
  export declare const ChainSelect: ({ formType }: SwapFormTypeProps) => JSX.Element;
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
1
  export declare const FundsSufficiencyMessage: () => JSX.Element;
@@ -5,7 +5,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const stores_1 = require("../../stores");
6
6
  const InsuranceCard_1 = require("./InsuranceCard");
7
7
  const InsuranceCollapsed_1 = require("./InsuranceCollapsed");
8
- const Insurance = ({ status, insurableRouteId, feeAmountUsd, onChange, ...props }) => {
9
- return status === stores_1.RouteExecutionStatus.Idle ? ((0, jsx_runtime_1.jsx)(InsuranceCollapsed_1.InsuranceCollapsed, { insurableRouteId: insurableRouteId, feeAmountUsd: feeAmountUsd, status: status, onChange: onChange, ...props })) : ((0, jsx_runtime_1.jsx)(InsuranceCard_1.InsuranceCard, { feeAmountUsd: feeAmountUsd, status: status, ...props }));
8
+ const Insurance = ({ status, insurableRouteId, feeAmountUsd, insuranceCoverageId, onChange, ...props }) => {
9
+ return status === stores_1.RouteExecutionStatus.Idle ? ((0, jsx_runtime_1.jsx)(InsuranceCollapsed_1.InsuranceCollapsed, { insurableRouteId: insurableRouteId, feeAmountUsd: feeAmountUsd, insuranceCoverageId: insuranceCoverageId, status: status, onChange: onChange, ...props })) : ((0, jsx_runtime_1.jsx)(InsuranceCard_1.InsuranceCard, { feeAmountUsd: feeAmountUsd, status: status, insuranceCoverageId: insuranceCoverageId, ...props }));
10
10
  };
11
11
  exports.Insurance = Insurance;
@@ -9,12 +9,18 @@ const icons_1 = require("../../icons");
9
9
  const stores_1 = require("../../stores");
10
10
  const Card_1 = require("../Card");
11
11
  const Switch_1 = require("../Switch");
12
- const InsuranceCard = ({ status, feeAmountUsd, onChange, ...props }) => {
12
+ const InsuranceCard = ({ status, feeAmountUsd, insuranceCoverageId, onChange, ...props }) => {
13
13
  const { t } = (0, react_i18next_1.useTranslation)();
14
14
  return ((0, jsx_runtime_1.jsxs)(Card_1.Card, { selectionColor: "secondary", indented: true, ...props, children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", alignItems: "center", justifyContent: "space-between", mb: 2, children: [(0, jsx_runtime_1.jsxs)(Card_1.CardLabel, { type: 'insurance', children: [(0, jsx_runtime_1.jsx)(VerifiedUser_1.default, { fontSize: "inherit" }), (0, jsx_runtime_1.jsx)(Card_1.CardLabelTypography, { type: "icon", children: status === stores_1.RouteExecutionStatus.Idle
15
15
  ? t(`swap.tags.insurance`)
16
16
  : t(`swap.tags.insured`) })] }), (0, jsx_runtime_1.jsx)(icons_1.InsuraceLogo, {})] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", alignItems: "center", justifyContent: "space-between", mb: 2, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 24, fontWeight: 700, lineHeight: 1, children: t('format.currency', {
17
17
  value: feeAmountUsd,
18
- }) }), status === stores_1.RouteExecutionStatus.Idle ? ((0, jsx_runtime_1.jsx)(Switch_1.Switch, { onChange: onChange })) : null] }), (0, jsx_runtime_1.jsx)(material_1.Box, { display: "flex", alignItems: "center", justifyContent: "space-between", children: (0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 12, children: "Get 100% coverage for lost tokens." }) })] }));
18
+ }) }), status === stores_1.RouteExecutionStatus.Idle ? ((0, jsx_runtime_1.jsx)(Switch_1.Switch, { onChange: onChange })) : null] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", alignItems: "center", children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 12, children: status === stores_1.RouteExecutionStatus.Idle
19
+ ? 'Get 100% coverage for lost tokens.'
20
+ : '100% coverage for lost tokens.' }), (0, jsx_runtime_1.jsx)(material_1.Link, { href: status === stores_1.RouteExecutionStatus.Idle
21
+ ? 'https://docs.insurace.io/landing-page/documentation/cover-products/bridge-cover/li.fi'
22
+ : `https://app.insurace.io/bridge-cover?search=${insuranceCoverageId}`, target: "_blank", underline: "none", color: "text.primary", children: (0, jsx_runtime_1.jsx)(material_1.Typography, { px: 0.5, color: "primary", fontSize: 12, fontWeight: 600, children: status === stores_1.RouteExecutionStatus.Idle
23
+ ? 'Learn more'
24
+ : 'View coverage' }) })] })] }));
19
25
  };
20
26
  exports.InsuranceCard = InsuranceCard;
@@ -1,3 +1,3 @@
1
- import type { PropsWithChildren } from 'react';
1
+ /// <reference types="react" />
2
2
  import type { InsuranceProps } from './types';
3
- export declare const InsuranceCollapsed: React.FC<PropsWithChildren<InsuranceProps>>;
3
+ export declare const InsuranceCollapsed: React.FC<InsuranceProps>;
@@ -7,7 +7,7 @@ const react_1 = require("react");
7
7
  const hooks_1 = require("../../hooks");
8
8
  const stores_1 = require("../../stores");
9
9
  const InsuranceCard_1 = require("./InsuranceCard");
10
- const InsuranceCollapsed = ({ status, insurableRouteId, feeAmountUsd, onChange, children, ...props }) => {
10
+ const InsuranceCollapsed = ({ status, insurableRouteId, insuranceCoverageId, feeAmountUsd, onChange, ...props }) => {
11
11
  const [insuredRoute, setInsuredRoute] = (0, react_1.useState)();
12
12
  const setExecutableRoute = (0, stores_1.useSetExecutableRoute)();
13
13
  const routeExecution = (0, stores_1.useRouteExecutionStore)((state) => state.routes[insurableRouteId]);
@@ -27,6 +27,6 @@ const InsuranceCollapsed = ({ status, insurableRouteId, feeAmountUsd, onChange,
27
27
  onChange?.(checked ? insuredRoute.id : insurableRouteId);
28
28
  }
29
29
  };
30
- return ((0, jsx_runtime_1.jsx)(material_1.Collapse, { timeout: 225, in: insuredRoute?.insurance?.state === 'INSURED', unmountOnExit: true, mountOnEnter: true, appear: status === stores_1.RouteExecutionStatus.Idle, children: (0, jsx_runtime_1.jsx)(InsuranceCard_1.InsuranceCard, { feeAmountUsd: feeAmountUsd, status: status, onChange: toggleInsurance, ...props }) }));
30
+ return ((0, jsx_runtime_1.jsx)(material_1.Collapse, { timeout: 225, in: insuredRoute?.insurance?.state === 'INSURED', unmountOnExit: true, mountOnEnter: true, appear: status === stores_1.RouteExecutionStatus.Idle, children: (0, jsx_runtime_1.jsx)(InsuranceCard_1.InsuranceCard, { feeAmountUsd: feeAmountUsd, status: status, insuranceCoverageId: insuranceCoverageId, onChange: toggleInsurance, ...props }) }));
31
31
  };
32
32
  exports.InsuranceCollapsed = InsuranceCollapsed;
@@ -4,11 +4,13 @@ import type { RouteExecutionStatus } from '../../stores';
4
4
  export interface InsuranceProps extends Omit<BoxProps, 'onChange'> {
5
5
  insurableRouteId: string;
6
6
  feeAmountUsd?: string;
7
+ insuranceCoverageId?: string;
7
8
  status?: RouteExecutionStatus;
8
9
  onChange?: (routeId: string) => void;
9
10
  }
10
11
  export interface InsuranceCardProps {
11
12
  feeAmountUsd?: string;
12
13
  status?: RouteExecutionStatus;
14
+ insuranceCoverageId?: string;
13
15
  onChange?: (_: React.ChangeEvent<HTMLInputElement>, checked: boolean) => void;
14
16
  }
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { Process } from '@lifi/sdk';
3
2
  export declare function CircularProgress({ process }: {
4
3
  process: Process;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type { Route } from '@lifi/sdk';
3
2
  export declare const getStepList: (route?: Route) => JSX.Element[] | undefined;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type { SwapFormTypeProps } from '../../providers';
3
2
  export declare const SwapInputEndAdornment: ({ formType }: SwapFormTypeProps) => JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  export declare const SwapRoutesExpanded: () => JSX.Element;
3
2
  export declare const SwapRoutesExpandedElement: () => JSX.Element;
@@ -1,2 +1,2 @@
1
1
  export declare const name = "@lifi/widget";
2
- export declare const version = "2.0.0-alpha.4";
2
+ export declare const version = "2.0.0-beta.0";
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = exports.name = void 0;
4
4
  exports.name = '@lifi/widget';
5
- exports.version = '2.0.0-alpha.4';
5
+ exports.version = '2.0.0-beta.0';
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
1
  export declare const ActiveSwapsPage: () => JSX.Element;
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
1
  export declare const SearchTokenInput: () => JSX.Element;
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
1
  export declare const SelectWalletPage: () => JSX.Element;
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
1
  export declare const GasPriceSelect: () => JSX.Element;
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
1
  export declare const SettingsPage: () => JSX.Element;
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
1
  export declare const ShowDestinationWallet: () => JSX.Element | null;
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
1
  export declare const SlippageInput: () => JSX.Element;
@@ -32,9 +32,11 @@ const SwapDetailsPage = () => {
32
32
  deleteRoute(routeExecution.route.id);
33
33
  }
34
34
  };
35
- let supportId = routeExecution?.route.steps[0].execution?.process.find((process) => process.txHash)?.txHash ??
36
- routeExecution?.route.id ??
37
- '';
35
+ const sourceTxHash = routeExecution?.route.steps[0].execution?.process
36
+ .filter((process) => process.type !== 'TOKEN_ALLOWANCE')
37
+ .find((process) => process.txHash)?.txHash;
38
+ const insuranceCoverageId = sourceTxHash ?? routeExecution?.route.fromAddress;
39
+ let supportId = sourceTxHash ?? routeExecution?.route.id ?? '';
38
40
  if (process.env.NODE_ENV === 'development') {
39
41
  supportId += `_${routeExecution?.route.id}`;
40
42
  }
@@ -51,7 +53,7 @@ const SwapDetailsPage = () => {
51
53
  justifyContent: 'space-between',
52
54
  }, pb: 1, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 12, children: new Intl.DateTimeFormat(i18n.language, { dateStyle: 'long' }).format(startedAt) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 12, children: new Intl.DateTimeFormat(i18n.language, {
53
55
  timeStyle: 'short',
54
- }).format(startedAt) })] }), (0, Step_1.getStepList)(routeExecution?.route), routeExecution?.route?.insurance?.state === 'INSURED' ? ((0, jsx_runtime_1.jsx)(Insurance_1.Insurance, { mt: 2, status: routeExecution.status, feeAmountUsd: routeExecution.route.insurance.feeAmountUsd, insurableRouteId: routeExecution.route.id })) : null, (0, jsx_runtime_1.jsxs)(Card_1.Card, { mt: 2, children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
56
+ }).format(startedAt) })] }), (0, Step_1.getStepList)(routeExecution?.route), routeExecution?.route?.insurance?.state === 'INSURED' ? ((0, jsx_runtime_1.jsx)(Insurance_1.Insurance, { mt: 2, status: routeExecution.status, feeAmountUsd: routeExecution.route.insurance.feeAmountUsd, insurableRouteId: routeExecution.route.id, insuranceCoverageId: insuranceCoverageId })) : null, (0, jsx_runtime_1.jsxs)(Card_1.Card, { mt: 2, children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
55
57
  display: 'flex',
56
58
  flex: 1,
57
59
  }, children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, { flex: 1, children: t('swap.supportId') }), (0, jsx_runtime_1.jsx)(material_1.Box, { mr: 1, mt: 1, children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { size: "medium", onClick: copySupportId, children: (0, jsx_runtime_1.jsx)(ContentCopyRounded_1.default, { fontSize: "small" }) }) })] }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", pt: 1, pb: 2, px: 2, sx: { wordBreak: 'break-all' }, children: supportId })] }), (0, jsx_runtime_1.jsx)(material_1.Box, { mt: 2, children: (0, jsx_runtime_1.jsx)(material_1.Button, { href: "https://discord.com/channels/849912621360218112/863689862514343946", target: "_blank", rel: "nofollow noreferrer", fullWidth: true, children: t('button.contactSupport') }) }), (0, jsx_runtime_1.jsxs)(Dialog_1.Dialog, { open: open, onClose: toggleDialog, children: [(0, jsx_runtime_1.jsx)(material_1.DialogTitle, { children: t('swap.warning.title.deleteSwap') }), (0, jsx_runtime_1.jsx)(material_1.DialogContent, { children: (0, jsx_runtime_1.jsx)(material_1.DialogContentText, { children: t('swap.warning.message.deleteSwapHistory') }) }), (0, jsx_runtime_1.jsxs)(material_1.DialogActions, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, { onClick: toggleDialog, children: t('button.cancel') }), (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", onClick: handleDeleteRoute, autoFocus: true, children: t('button.delete') })] })] })] }));
@@ -78,7 +78,10 @@ const SwapPage = () => {
78
78
  (route?.insurance?.state === 'INSURED' ||
79
79
  (status === stores_1.RouteExecutionStatus.Idle &&
80
80
  route?.insurance?.state === 'INSURABLE'));
81
- return ((0, jsx_runtime_1.jsxs)(SwapPage_style_1.Container, { children: [(0, Step_1.getStepList)(route), insuranceAvailable ? ((0, jsx_runtime_1.jsx)(Insurance_1.Insurance, { mt: 2, status: status, insurableRouteId: stateRouteId, feeAmountUsd: route?.insurance.feeAmountUsd, onChange: setRouteId })) : null, status === stores_1.RouteExecutionStatus.Idle ||
81
+ const insuranceCoverageId = route?.steps[0].execution?.process
82
+ .filter((process) => process.type !== 'TOKEN_ALLOWANCE')
83
+ .find((process) => process.txHash)?.txHash ?? route?.fromAddress;
84
+ return ((0, jsx_runtime_1.jsxs)(SwapPage_style_1.Container, { children: [(0, Step_1.getStepList)(route), insuranceAvailable ? ((0, jsx_runtime_1.jsx)(Insurance_1.Insurance, { mt: 2, status: status, insurableRouteId: stateRouteId, feeAmountUsd: route?.insurance.feeAmountUsd, insuranceCoverageId: insuranceCoverageId, onChange: setRouteId })) : null, status === stores_1.RouteExecutionStatus.Idle ||
82
85
  status === stores_1.RouteExecutionStatus.Failed ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(GasMessage_1.GasMessage, { mt: 2, route: route }), (0, jsx_runtime_1.jsxs)(material_1.Box, { mt: 2, display: "flex", children: [(0, jsx_runtime_1.jsx)(SwapButton, { text: getSwapButtonText(), onClick: handleSwapClick, route: route, insurableRouteId: stateRouteId }), status === stores_1.RouteExecutionStatus.Failed ? ((0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: t('button.removeSwap'), placement: "bottom-end", enterDelay: 400, arrow: true, children: (0, jsx_runtime_1.jsx)(material_1.Button, { onClick: handleRemoveRoute, sx: {
83
86
  minWidth: 48,
84
87
  marginLeft: 1,
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type { SwapFormTypeProps } from '../../providers';
3
2
  export declare const ChainSelect: ({ formType }: SwapFormTypeProps) => JSX.Element;
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
1
  export declare const FundsSufficiencyMessage: () => JSX.Element;
@@ -2,6 +2,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { RouteExecutionStatus } from '../../stores';
3
3
  import { InsuranceCard } from './InsuranceCard';
4
4
  import { InsuranceCollapsed } from './InsuranceCollapsed';
5
- export const Insurance = ({ status, insurableRouteId, feeAmountUsd, onChange, ...props }) => {
6
- return status === RouteExecutionStatus.Idle ? (_jsx(InsuranceCollapsed, { insurableRouteId: insurableRouteId, feeAmountUsd: feeAmountUsd, status: status, onChange: onChange, ...props })) : (_jsx(InsuranceCard, { feeAmountUsd: feeAmountUsd, status: status, ...props }));
5
+ export const Insurance = ({ status, insurableRouteId, feeAmountUsd, insuranceCoverageId, onChange, ...props }) => {
6
+ return status === RouteExecutionStatus.Idle ? (_jsx(InsuranceCollapsed, { insurableRouteId: insurableRouteId, feeAmountUsd: feeAmountUsd, insuranceCoverageId: insuranceCoverageId, status: status, onChange: onChange, ...props })) : (_jsx(InsuranceCard, { feeAmountUsd: feeAmountUsd, status: status, insuranceCoverageId: insuranceCoverageId, ...props }));
7
7
  };
@@ -1,16 +1,22 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import VerifiedUserIcon from '@mui/icons-material/VerifiedUser';
3
- import { Box, Typography } from '@mui/material';
3
+ import { Box, Link, Typography } from '@mui/material';
4
4
  import { useTranslation } from 'react-i18next';
5
5
  import { InsuraceLogo } from '../../icons';
6
6
  import { RouteExecutionStatus } from '../../stores';
7
7
  import { Card, CardLabel, CardLabelTypography } from '../Card';
8
8
  import { Switch } from '../Switch';
9
- export const InsuranceCard = ({ status, feeAmountUsd, onChange, ...props }) => {
9
+ export const InsuranceCard = ({ status, feeAmountUsd, insuranceCoverageId, onChange, ...props }) => {
10
10
  const { t } = useTranslation();
11
11
  return (_jsxs(Card, { selectionColor: "secondary", indented: true, ...props, children: [_jsxs(Box, { display: "flex", alignItems: "center", justifyContent: "space-between", mb: 2, children: [_jsxs(CardLabel, { type: 'insurance', children: [_jsx(VerifiedUserIcon, { fontSize: "inherit" }), _jsx(CardLabelTypography, { type: "icon", children: status === RouteExecutionStatus.Idle
12
12
  ? t(`swap.tags.insurance`)
13
13
  : t(`swap.tags.insured`) })] }), _jsx(InsuraceLogo, {})] }), _jsxs(Box, { display: "flex", alignItems: "center", justifyContent: "space-between", mb: 2, children: [_jsx(Typography, { fontSize: 24, fontWeight: 700, lineHeight: 1, children: t('format.currency', {
14
14
  value: feeAmountUsd,
15
- }) }), status === RouteExecutionStatus.Idle ? (_jsx(Switch, { onChange: onChange })) : null] }), _jsx(Box, { display: "flex", alignItems: "center", justifyContent: "space-between", children: _jsx(Typography, { fontSize: 12, children: "Get 100% coverage for lost tokens." }) })] }));
15
+ }) }), status === RouteExecutionStatus.Idle ? (_jsx(Switch, { onChange: onChange })) : null] }), _jsxs(Box, { display: "flex", alignItems: "center", children: [_jsx(Typography, { fontSize: 12, children: status === RouteExecutionStatus.Idle
16
+ ? 'Get 100% coverage for lost tokens.'
17
+ : '100% coverage for lost tokens.' }), _jsx(Link, { href: status === RouteExecutionStatus.Idle
18
+ ? 'https://docs.insurace.io/landing-page/documentation/cover-products/bridge-cover/li.fi'
19
+ : `https://app.insurace.io/bridge-cover?search=${insuranceCoverageId}`, target: "_blank", underline: "none", color: "text.primary", children: _jsx(Typography, { px: 0.5, color: "primary", fontSize: 12, fontWeight: 600, children: status === RouteExecutionStatus.Idle
20
+ ? 'Learn more'
21
+ : 'View coverage' }) })] })] }));
16
22
  };
@@ -1,3 +1,3 @@
1
- import type { PropsWithChildren } from 'react';
1
+ /// <reference types="react" />
2
2
  import type { InsuranceProps } from './types';
3
- export declare const InsuranceCollapsed: React.FC<PropsWithChildren<InsuranceProps>>;
3
+ export declare const InsuranceCollapsed: React.FC<InsuranceProps>;
@@ -4,7 +4,7 @@ import { useState } from 'react';
4
4
  import { useSwapRoutes } from '../../hooks';
5
5
  import { RouteExecutionStatus, useRouteExecutionStore, useSetExecutableRoute, } from '../../stores';
6
6
  import { InsuranceCard } from './InsuranceCard';
7
- export const InsuranceCollapsed = ({ status, insurableRouteId, feeAmountUsd, onChange, children, ...props }) => {
7
+ export const InsuranceCollapsed = ({ status, insurableRouteId, insuranceCoverageId, feeAmountUsd, onChange, ...props }) => {
8
8
  const [insuredRoute, setInsuredRoute] = useState();
9
9
  const setExecutableRoute = useSetExecutableRoute();
10
10
  const routeExecution = useRouteExecutionStore((state) => state.routes[insurableRouteId]);
@@ -24,5 +24,5 @@ export const InsuranceCollapsed = ({ status, insurableRouteId, feeAmountUsd, onC
24
24
  onChange?.(checked ? insuredRoute.id : insurableRouteId);
25
25
  }
26
26
  };
27
- return (_jsx(Collapse, { timeout: 225, in: insuredRoute?.insurance?.state === 'INSURED', unmountOnExit: true, mountOnEnter: true, appear: status === RouteExecutionStatus.Idle, children: _jsx(InsuranceCard, { feeAmountUsd: feeAmountUsd, status: status, onChange: toggleInsurance, ...props }) }));
27
+ return (_jsx(Collapse, { timeout: 225, in: insuredRoute?.insurance?.state === 'INSURED', unmountOnExit: true, mountOnEnter: true, appear: status === RouteExecutionStatus.Idle, children: _jsx(InsuranceCard, { feeAmountUsd: feeAmountUsd, status: status, insuranceCoverageId: insuranceCoverageId, onChange: toggleInsurance, ...props }) }));
28
28
  };
@@ -4,11 +4,13 @@ import type { RouteExecutionStatus } from '../../stores';
4
4
  export interface InsuranceProps extends Omit<BoxProps, 'onChange'> {
5
5
  insurableRouteId: string;
6
6
  feeAmountUsd?: string;
7
+ insuranceCoverageId?: string;
7
8
  status?: RouteExecutionStatus;
8
9
  onChange?: (routeId: string) => void;
9
10
  }
10
11
  export interface InsuranceCardProps {
11
12
  feeAmountUsd?: string;
12
13
  status?: RouteExecutionStatus;
14
+ insuranceCoverageId?: string;
13
15
  onChange?: (_: React.ChangeEvent<HTMLInputElement>, checked: boolean) => void;
14
16
  }
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { Process } from '@lifi/sdk';
3
2
  export declare function CircularProgress({ process }: {
4
3
  process: Process;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type { Route } from '@lifi/sdk';
3
2
  export declare const getStepList: (route?: Route) => JSX.Element[] | undefined;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type { SwapFormTypeProps } from '../../providers';
3
2
  export declare const SwapInputEndAdornment: ({ formType }: SwapFormTypeProps) => JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  export declare const SwapRoutesExpanded: () => JSX.Element;
3
2
  export declare const SwapRoutesExpandedElement: () => JSX.Element;
@@ -1,2 +1,2 @@
1
1
  export declare const name = "@lifi/widget";
2
- export declare const version = "2.0.0-alpha.4";
2
+ export declare const version = "2.0.0-beta.0";
package/config/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/widget';
2
- export const version = '2.0.0-alpha.4';
2
+ export const version = '2.0.0-beta.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifi/widget",
3
- "version": "2.0.0-alpha.4",
3
+ "version": "2.0.0-beta.0",
4
4
  "description": "LI.FI Widget for cross-chain bridging and swapping. It will drive your multi-chain strategy and attract new users from everywhere.",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./index.js",
@@ -46,14 +46,14 @@
46
46
  "@lifi/sdk": "^2.0.0-beta.8",
47
47
  "@lifi/wallet-management": "^1.2.11",
48
48
  "@mui/icons-material": "^5.11.16",
49
- "@mui/lab": "^5.0.0-alpha.126",
50
- "@mui/material": "^5.12.0",
51
- "@tanstack/react-query": "^4.29.1",
49
+ "@mui/lab": "^5.0.0-alpha.127",
50
+ "@mui/material": "^5.12.1",
51
+ "@tanstack/react-query": "^4.29.3",
52
52
  "@tanstack/react-virtual": "^3.0.0-beta.54",
53
53
  "big.js": "^6.2.1",
54
54
  "i18next": "^22.4.14",
55
55
  "i18next-browser-languagedetector": "^7.0.1",
56
- "microdiff": "^1.3.1",
56
+ "microdiff": "^1.3.2",
57
57
  "mitt": "^3.0.0",
58
58
  "react": "^18.2.0",
59
59
  "react-dom": "^18.2.0",
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
1
  export declare const ActiveSwapsPage: () => JSX.Element;
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
1
  export declare const SearchTokenInput: () => JSX.Element;
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
1
  export declare const SelectWalletPage: () => JSX.Element;
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
1
  export declare const GasPriceSelect: () => JSX.Element;
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
1
  export declare const SettingsPage: () => JSX.Element;
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
1
  export declare const ShowDestinationWallet: () => JSX.Element | null;
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
1
  export declare const SlippageInput: () => JSX.Element;
@@ -29,9 +29,11 @@ export const SwapDetailsPage = () => {
29
29
  deleteRoute(routeExecution.route.id);
30
30
  }
31
31
  };
32
- let supportId = routeExecution?.route.steps[0].execution?.process.find((process) => process.txHash)?.txHash ??
33
- routeExecution?.route.id ??
34
- '';
32
+ const sourceTxHash = routeExecution?.route.steps[0].execution?.process
33
+ .filter((process) => process.type !== 'TOKEN_ALLOWANCE')
34
+ .find((process) => process.txHash)?.txHash;
35
+ const insuranceCoverageId = sourceTxHash ?? routeExecution?.route.fromAddress;
36
+ let supportId = sourceTxHash ?? routeExecution?.route.id ?? '';
35
37
  if (process.env.NODE_ENV === 'development') {
36
38
  supportId += `_${routeExecution?.route.id}`;
37
39
  }
@@ -48,7 +50,7 @@ export const SwapDetailsPage = () => {
48
50
  justifyContent: 'space-between',
49
51
  }, pb: 1, children: [_jsx(Typography, { fontSize: 12, children: new Intl.DateTimeFormat(i18n.language, { dateStyle: 'long' }).format(startedAt) }), _jsx(Typography, { fontSize: 12, children: new Intl.DateTimeFormat(i18n.language, {
50
52
  timeStyle: 'short',
51
- }).format(startedAt) })] }), getStepList(routeExecution?.route), routeExecution?.route?.insurance?.state === 'INSURED' ? (_jsx(Insurance, { mt: 2, status: routeExecution.status, feeAmountUsd: routeExecution.route.insurance.feeAmountUsd, insurableRouteId: routeExecution.route.id })) : null, _jsxs(Card, { mt: 2, children: [_jsxs(Box, { sx: {
53
+ }).format(startedAt) })] }), getStepList(routeExecution?.route), routeExecution?.route?.insurance?.state === 'INSURED' ? (_jsx(Insurance, { mt: 2, status: routeExecution.status, feeAmountUsd: routeExecution.route.insurance.feeAmountUsd, insurableRouteId: routeExecution.route.id, insuranceCoverageId: insuranceCoverageId })) : null, _jsxs(Card, { mt: 2, children: [_jsxs(Box, { sx: {
52
54
  display: 'flex',
53
55
  flex: 1,
54
56
  }, children: [_jsx(CardTitle, { flex: 1, children: t('swap.supportId') }), _jsx(Box, { mr: 1, mt: 1, children: _jsx(IconButton, { size: "medium", onClick: copySupportId, children: _jsx(ContentCopyIcon, { fontSize: "small" }) }) })] }), _jsx(Typography, { variant: "body2", pt: 1, pb: 2, px: 2, sx: { wordBreak: 'break-all' }, children: supportId })] }), _jsx(Box, { mt: 2, children: _jsx(Button, { href: "https://discord.com/channels/849912621360218112/863689862514343946", target: "_blank", rel: "nofollow noreferrer", fullWidth: true, children: t('button.contactSupport') }) }), _jsxs(Dialog, { open: open, onClose: toggleDialog, children: [_jsx(DialogTitle, { children: t('swap.warning.title.deleteSwap') }), _jsx(DialogContent, { children: _jsx(DialogContentText, { children: t('swap.warning.message.deleteSwapHistory') }) }), _jsxs(DialogActions, { children: [_jsx(Button, { onClick: toggleDialog, children: t('button.cancel') }), _jsx(Button, { variant: "contained", onClick: handleDeleteRoute, autoFocus: true, children: t('button.delete') })] })] })] }));
@@ -75,7 +75,10 @@ export const SwapPage = () => {
75
75
  (route?.insurance?.state === 'INSURED' ||
76
76
  (status === RouteExecutionStatus.Idle &&
77
77
  route?.insurance?.state === 'INSURABLE'));
78
- return (_jsxs(Container, { children: [getStepList(route), insuranceAvailable ? (_jsx(Insurance, { mt: 2, status: status, insurableRouteId: stateRouteId, feeAmountUsd: route?.insurance.feeAmountUsd, onChange: setRouteId })) : null, status === RouteExecutionStatus.Idle ||
78
+ const insuranceCoverageId = route?.steps[0].execution?.process
79
+ .filter((process) => process.type !== 'TOKEN_ALLOWANCE')
80
+ .find((process) => process.txHash)?.txHash ?? route?.fromAddress;
81
+ return (_jsxs(Container, { children: [getStepList(route), insuranceAvailable ? (_jsx(Insurance, { mt: 2, status: status, insurableRouteId: stateRouteId, feeAmountUsd: route?.insurance.feeAmountUsd, insuranceCoverageId: insuranceCoverageId, onChange: setRouteId })) : null, status === RouteExecutionStatus.Idle ||
79
82
  status === RouteExecutionStatus.Failed ? (_jsxs(_Fragment, { children: [_jsx(GasMessage, { mt: 2, route: route }), _jsxs(Box, { mt: 2, display: "flex", children: [_jsx(SwapButton, { text: getSwapButtonText(), onClick: handleSwapClick, route: route, insurableRouteId: stateRouteId }), status === RouteExecutionStatus.Failed ? (_jsx(Tooltip, { title: t('button.removeSwap'), placement: "bottom-end", enterDelay: 400, arrow: true, children: _jsx(Button, { onClick: handleRemoveRoute, sx: {
80
83
  minWidth: 48,
81
84
  marginLeft: 1,