@lifi/widget 1.22.0 → 1.23.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 (110) hide show
  1. package/AppRoutes.js +1 -2
  2. package/cjs/AppRoutes.js +1 -2
  3. package/cjs/components/ActiveSwaps/ActiveSwaps.style.d.ts +7 -1
  4. package/cjs/components/BottomSheet/BottomSheet.d.ts +1 -1
  5. package/cjs/components/ChainSelect/ChainSelect.d.ts +1 -0
  6. package/cjs/components/Header/Header.style.d.ts +1 -1
  7. package/cjs/components/Header/NavigationHeader.js +3 -2
  8. package/cjs/components/PoweredBy/PoweredBy.style.d.ts +1 -1
  9. package/cjs/components/SelectTokenButton/SelectTokenButton.js +4 -2
  10. package/cjs/components/SelectTokenButton/SelectTokenButton.style.js +2 -2
  11. package/cjs/components/Step/CircularProgress.d.ts +1 -0
  12. package/cjs/components/Step/StepProcess.style.d.ts +1 -1
  13. package/cjs/components/StepActions/StepActions.js +2 -2
  14. package/cjs/components/SwapButton/SwapButton.js +9 -4
  15. package/cjs/components/SwapInput/FormPriceHelperText.js +1 -1
  16. package/cjs/components/SwapInput/SwapInput.js +1 -1
  17. package/cjs/components/SwapInput/SwapInputAdornment.d.ts +1 -0
  18. package/cjs/components/SwapRouteCard/SwapRouteCard.js +2 -1
  19. package/cjs/components/SwapRouteCard/SwapRouteCardSkeleton.js +2 -1
  20. package/cjs/components/SwapRoutes/SwapRoutesExpanded.d.ts +1 -0
  21. package/cjs/components/Token/Token.d.ts +5 -2
  22. package/cjs/components/Token/Token.js +11 -7
  23. package/cjs/components/Token/Token.style.d.ts +1 -0
  24. package/cjs/components/Token/Token.style.js +3 -3
  25. package/cjs/components/TokenAvatar/TokenAvatar.d.ts +8 -0
  26. package/cjs/components/TokenAvatar/TokenAvatar.js +12 -3
  27. package/cjs/components/TokenAvatar/TokenAvatar.style.d.ts +17 -0
  28. package/cjs/components/TokenAvatar/TokenAvatar.style.js +14 -1
  29. package/cjs/components/TokenList/TokenList.style.d.ts +7 -1
  30. package/cjs/config/version.d.ts +1 -1
  31. package/cjs/config/version.js +1 -1
  32. package/cjs/hooks/useGasSufficiency.js +0 -2
  33. package/cjs/hooks/useSwapRoutes.js +0 -1
  34. package/cjs/hooks/useTokenBalance.js +0 -1
  35. package/cjs/hooks/useTokenBalances.js +0 -1
  36. package/cjs/i18n/en.json +5 -0
  37. package/cjs/i18n/es.json +1 -0
  38. package/cjs/i18n/fr.json +2 -2
  39. package/cjs/i18n/uk.json +5 -5
  40. package/cjs/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +1 -0
  41. package/cjs/pages/SelectChainPage/SelectChainPage.d.ts +2 -2
  42. package/cjs/pages/SelectChainPage/SelectChainPage.js +12 -5
  43. package/cjs/pages/SelectChainPage/types.d.ts +4 -0
  44. package/cjs/pages/SelectChainPage/types.js +2 -0
  45. package/cjs/pages/SelectTokenPage/SearchTokenInput.d.ts +1 -0
  46. package/cjs/pages/SelectWalletPage/SelectWalletPage.d.ts +1 -0
  47. package/cjs/pages/SettingsPage/AdvancedPreferences.d.ts +1 -0
  48. package/cjs/pages/SettingsPage/GasPriceSelect.d.ts +1 -0
  49. package/cjs/pages/SettingsPage/SettingsPage.d.ts +1 -0
  50. package/cjs/pages/SettingsPage/ShowDestinationWallet.d.ts +1 -0
  51. package/cjs/pages/SettingsPage/SlippageInput.d.ts +1 -0
  52. package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +6 -4
  53. package/cjs/pages/SwapPage/StatusBottomSheet.js +1 -1
  54. package/cjs/pages/SwapPage/SwapPage.js +7 -7
  55. package/cjs/utils/input.js +3 -1
  56. package/components/ActiveSwaps/ActiveSwaps.style.d.ts +7 -1
  57. package/components/BottomSheet/BottomSheet.d.ts +1 -1
  58. package/components/ChainSelect/ChainSelect.d.ts +1 -0
  59. package/components/Header/Header.style.d.ts +1 -1
  60. package/components/Header/NavigationHeader.js +4 -3
  61. package/components/PoweredBy/PoweredBy.style.d.ts +1 -1
  62. package/components/SelectTokenButton/SelectTokenButton.js +5 -3
  63. package/components/SelectTokenButton/SelectTokenButton.style.js +2 -2
  64. package/components/Step/CircularProgress.d.ts +1 -0
  65. package/components/Step/StepProcess.style.d.ts +1 -1
  66. package/components/StepActions/StepActions.js +2 -2
  67. package/components/SwapButton/SwapButton.js +9 -4
  68. package/components/SwapInput/FormPriceHelperText.js +1 -1
  69. package/components/SwapInput/SwapInput.js +2 -2
  70. package/components/SwapInput/SwapInputAdornment.d.ts +1 -0
  71. package/components/SwapRouteCard/SwapRouteCard.js +2 -1
  72. package/components/SwapRouteCard/SwapRouteCardSkeleton.js +2 -1
  73. package/components/SwapRoutes/SwapRoutesExpanded.d.ts +1 -0
  74. package/components/Token/Token.d.ts +5 -2
  75. package/components/Token/Token.js +14 -10
  76. package/components/Token/Token.style.d.ts +1 -0
  77. package/components/Token/Token.style.js +3 -3
  78. package/components/TokenAvatar/TokenAvatar.d.ts +8 -0
  79. package/components/TokenAvatar/TokenAvatar.js +9 -2
  80. package/components/TokenAvatar/TokenAvatar.style.d.ts +17 -0
  81. package/components/TokenAvatar/TokenAvatar.style.js +14 -1
  82. package/components/TokenList/TokenList.style.d.ts +7 -1
  83. package/config/version.d.ts +1 -1
  84. package/config/version.js +1 -1
  85. package/hooks/useGasSufficiency.js +0 -2
  86. package/hooks/useSwapRoutes.js +0 -1
  87. package/hooks/useTokenBalance.js +0 -1
  88. package/hooks/useTokenBalances.js +0 -1
  89. package/i18n/en.json +5 -0
  90. package/i18n/es.json +1 -0
  91. package/i18n/fr.json +2 -2
  92. package/i18n/uk.json +5 -5
  93. package/package.json +14 -14
  94. package/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +1 -0
  95. package/pages/SelectChainPage/SelectChainPage.d.ts +2 -2
  96. package/pages/SelectChainPage/SelectChainPage.js +12 -5
  97. package/pages/SelectChainPage/types.d.ts +4 -0
  98. package/pages/SelectChainPage/types.js +1 -0
  99. package/pages/SelectTokenPage/SearchTokenInput.d.ts +1 -0
  100. package/pages/SelectWalletPage/SelectWalletPage.d.ts +1 -0
  101. package/pages/SettingsPage/AdvancedPreferences.d.ts +1 -0
  102. package/pages/SettingsPage/GasPriceSelect.d.ts +1 -0
  103. package/pages/SettingsPage/SettingsPage.d.ts +1 -0
  104. package/pages/SettingsPage/ShowDestinationWallet.d.ts +1 -0
  105. package/pages/SettingsPage/SlippageInput.d.ts +1 -0
  106. package/pages/SwapDetailsPage/SwapDetailsPage.js +6 -4
  107. package/pages/SwapPage/StatusBottomSheet.js +1 -1
  108. package/pages/SwapPage/SwapPage.js +7 -7
  109. package/tsconfig.cjs.tsbuildinfo +1 -1
  110. package/utils/input.js +3 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifi/widget",
3
- "version": "1.22.0",
3
+ "version": "1.23.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",
@@ -43,28 +43,28 @@
43
43
  "@ethersproject/experimental": "^5.7.0",
44
44
  "@ethersproject/providers": "^5.7.2",
45
45
  "@lifi/sdk": "^1.6.3",
46
- "@lifi/wallet-management": "^1.1.11",
46
+ "@lifi/wallet-management": "^1.1.12",
47
47
  "@mui/icons-material": "^5.10.9",
48
- "@mui/lab": "^5.0.0-alpha.105",
49
- "@mui/material": "^5.10.11",
50
- "@sentry/integrations": "^7.16.0",
51
- "@sentry/react": "^7.16.0",
52
- "@sentry/tracing": "^7.16.0",
53
- "@tanstack/react-query": "^4.13.0",
54
- "@tanstack/react-virtual": "^3.0.0-beta.18",
48
+ "@mui/lab": "^5.0.0-alpha.107",
49
+ "@mui/material": "^5.10.13",
50
+ "@sentry/integrations": "^7.18.0",
51
+ "@sentry/react": "^7.18.0",
52
+ "@sentry/tracing": "^7.18.0",
53
+ "@tanstack/react-query": "^4.14.5",
54
+ "@tanstack/react-virtual": "^3.0.0-beta.22",
55
55
  "big.js": "^6.2.1",
56
- "i18next": "^22.0.3",
57
- "i18next-browser-languagedetector": "^7.0.0",
56
+ "i18next": "^22.0.4",
57
+ "i18next-browser-languagedetector": "^7.0.1",
58
58
  "immer": "^9.0.16",
59
59
  "microdiff": "^1.3.1",
60
60
  "mitt": "^3.0.0",
61
61
  "react": "^18.2.0",
62
62
  "react-dom": "^18.2.0",
63
- "react-hook-form": "^7.38.0",
63
+ "react-hook-form": "^7.39.1",
64
64
  "react-i18next": "^12.0.0",
65
- "react-router-dom": "^6.4.2",
65
+ "react-router-dom": "^6.4.3",
66
66
  "react-timer-hook": "^3.0.5",
67
- "zustand": "^4.1.3"
67
+ "zustand": "^4.1.4"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "@types/react": "^18.0.0",
@@ -1 +1,2 @@
1
+ /// <reference types="react" />
1
2
  export declare const ActiveSwapsPage: () => JSX.Element;
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
- import type { SwapFormTypeProps } from '../../providers';
3
- export declare const SelectChainPage: React.FC<SwapFormTypeProps>;
2
+ import type { SelectChainPageProps } from './types';
3
+ export declare const SelectChainPage: React.FC<SelectChainPageProps>;
@@ -10,17 +10,24 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
11
  import { Avatar, Container, List, ListItemAvatar } from '@mui/material';
12
12
  import { useChainSelect } from '../../components/ChainSelect';
13
+ import { useTokenSelect } from '../../components/TokenList';
13
14
  import { useNavigateBack } from '../../hooks';
14
15
  import { ListItemButton, ListItemText } from './SelectChainPage.style';
15
- export const SelectChainPage = ({ formType }) => {
16
+ export const SelectChainPage = ({ formType, selectNativeToken, }) => {
16
17
  const { navigateBack } = useNavigateBack();
17
18
  const { chains, setCurrentChain } = useChainSelect(formType);
18
- const handleClick = (chainId) => __awaiter(void 0, void 0, void 0, function* () {
19
- setCurrentChain(chainId);
20
- navigateBack();
19
+ const selectToken = useTokenSelect(formType, navigateBack);
20
+ const handleClick = (chain) => __awaiter(void 0, void 0, void 0, function* () {
21
+ if (selectNativeToken) {
22
+ selectToken(chain.nativeToken.address, chain.id);
23
+ }
24
+ else {
25
+ setCurrentChain(chain.id);
26
+ navigateBack();
27
+ }
21
28
  });
22
29
  return (_jsx(Container, Object.assign({ disableGutters: true }, { children: _jsx(List, Object.assign({ sx: {
23
30
  paddingLeft: 1.5,
24
31
  paddingRight: 1.5,
25
- } }, { 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))) })) })));
32
+ } }, { children: chains === null || chains === void 0 ? void 0 : chains.map((chain) => (_jsxs(ListItemButton, Object.assign({ onClick: () => handleClick(chain), 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))) })) })));
26
33
  };
@@ -0,0 +1,4 @@
1
+ import type { SwapFormTypeProps } from '../../providers';
2
+ export interface SelectChainPageProps extends SwapFormTypeProps {
3
+ selectNativeToken?: boolean;
4
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1 +1,2 @@
1
+ /// <reference types="react" />
1
2
  export declare const SearchTokenInput: () => JSX.Element;
@@ -1 +1,2 @@
1
+ /// <reference types="react" />
1
2
  export declare const SelectWalletPage: () => JSX.Element;
@@ -1 +1,2 @@
1
+ /// <reference types="react" />
1
2
  export declare const AdvancedPreferences: () => JSX.Element;
@@ -1 +1,2 @@
1
+ /// <reference types="react" />
1
2
  export declare const GasPriceSelect: () => JSX.Element;
@@ -1 +1,2 @@
1
+ /// <reference types="react" />
1
2
  export declare const SettingsPage: () => JSX.Element;
@@ -1 +1,2 @@
1
+ /// <reference types="react" />
1
2
  export declare const ShowDestinationWallet: () => JSX.Element | null;
@@ -1 +1,2 @@
1
+ /// <reference types="react" />
1
2
  export declare const SlippageInput: () => JSX.Element;
@@ -53,10 +53,12 @@ export const SwapDetailsPage = () => {
53
53
  }, pb: 1 }, { children: [_jsx(Typography, Object.assign({ fontSize: 12 }, { children: new Intl.DateTimeFormat(i18n.language, { dateStyle: 'long' }).format(startedAt) })), _jsx(Typography, Object.assign({ fontSize: 12 }, { children: new Intl.DateTimeFormat(i18n.language, {
54
54
  timeStyle: 'short',
55
55
  }).format(startedAt) }))] })), routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route.steps.map((step, index, steps) => {
56
- var _a, _b;
57
- return (_jsxs(Fragment, { children: [_jsx(Step, { step: step, fromToken: index === 0
58
- ? Object.assign(Object.assign({}, step.action.fromToken), { amount: step.action.fromAmount }) : undefined, toToken: index === steps.length - 1
59
- ? 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));
56
+ var _a, _b, _c, _d, _e;
57
+ const fromToken = index === 0
58
+ ? Object.assign(Object.assign({}, step.action.fromToken), { amount: step.action.fromAmount }) : undefined;
59
+ const toToken = index === steps.length - 1
60
+ ? 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;
61
+ return (_jsxs(Fragment, { children: [_jsx(Step, { step: step, fromToken: fromToken, toToken: toToken }), steps.length > 1 && index !== steps.length - 1 ? (_jsx(StepDivider, {})) : null] }, step.id));
60
62
  }), _jsxs(Card, Object.assign({ mt: 2 }, { children: [_jsxs(Box, Object.assign({ sx: {
61
63
  display: 'flex',
62
64
  flex: 1,
@@ -76,5 +76,5 @@ export const StatusBottomSheet = ({ status, route, }) => {
76
76
  (_b = ref.current) === null || _b === void 0 ? void 0 : _b.open();
77
77
  }
78
78
  }, [refetch, refetchNewBalance, status]);
79
- 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" }) : null, status === 'success' ? _jsx(DoneIcon, { color: "success" }) : null, status === 'error' ? _jsx(WarningIcon, { color: "error" }) : 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({ py: 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.ok') : null, status === 'success' ? t('button.done') : null, status === 'error' ? t('button.seeDetails') : null] })) })), status === 'success' ? (_jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(Button, Object.assign({ variant: "text", fullWidth: true, onClick: handleSeeDetails }, { children: t('button.seeDetails') })) }))) : null] })) })));
79
+ 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" }) : null, status === 'success' ? _jsx(DoneIcon, { color: "success" }) : null, status === 'error' ? _jsx(WarningIcon, { color: "error" }) : 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, disableDescription: true })) : null] }), _jsx(Typography, Object.assign({ py: 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.ok') : null, status === 'success' ? t('button.done') : null, status === 'error' ? t('button.seeDetails') : null] })) })), status === 'success' ? (_jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(Button, Object.assign({ variant: "text", fullWidth: true, onClick: handleSeeDetails }, { children: t('button.seeDetails') })) }))) : null] })) })));
80
80
  };
@@ -28,9 +28,7 @@ export const SwapPage = () => {
28
28
  const { state } = useLocation();
29
29
  const { navigateBack } = useNavigateBack();
30
30
  const tokenValueBottomSheetRef = useRef(null);
31
- const { setValue,
32
- // formState: { isValid, isValidating },
33
- } = useFormContext();
31
+ const { setValue } = useFormContext();
34
32
  const { route, status, executeRoute, restartRoute, deleteRoute } = useRouteExecution(state === null || state === void 0 ? void 0 : state.routeId);
35
33
  const handleExecuteRoute = useCallback(() => {
36
34
  var _a, _b;
@@ -70,10 +68,12 @@ export const SwapPage = () => {
70
68
  }
71
69
  };
72
70
  return (_jsxs(Container, { children: [route === null || route === void 0 ? void 0 : route.steps.map((step, index, steps) => {
73
- var _a, _b;
74
- return (_jsxs(Fragment, { children: [_jsx(Step, { step: step, fromToken: index === 0
75
- ? Object.assign(Object.assign({}, step.action.fromToken), { amount: step.action.fromAmount }) : undefined, toToken: index === steps.length - 1
76
- ? 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));
71
+ var _a, _b, _c, _d, _e;
72
+ const fromToken = index === 0
73
+ ? Object.assign(Object.assign({}, step.action.fromToken), { amount: step.action.fromAmount }) : undefined;
74
+ const toToken = index === steps.length - 1
75
+ ? 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;
76
+ return (_jsxs(Fragment, { children: [_jsx(Step, { step: step, fromToken: fromToken, toToken: toToken }), steps.length > 1 && index !== steps.length - 1 ? (_jsx(StepDivider, {})) : null] }, step.id));
77
77
  }), status === 'idle' || status === 'error' ? (_jsxs(_Fragment, { children: [_jsx(GasSufficiencyMessage, { route: route, mt: 2 }), _jsxs(Box, Object.assign({ mt: 2, display: "flex" }, { children: [_jsx(SwapButton, { text: getSwapButtonText(), onClick: handleSwapClick, currentRoute: route,
78
78
  // disable={status === 'idle' && (isValidating || !isValid)}
79
79
  enableLoading: true }), status === 'error' ? (_jsx(Tooltip, Object.assign({ title: t('button.removeSwap'), placement: "bottom-end", enterDelay: 400, arrow: true }, { children: _jsx(Button, Object.assign({ onClick: handleRemoveRoute, sx: {