@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.
- package/cjs/components/ActiveSwaps/ActiveSwapItem.js +6 -3
- package/cjs/components/BottomSheet/BottomSheet.js +2 -1
- package/cjs/components/BottomSheet/types.d.ts +2 -1
- package/cjs/components/GasSufficiencyMessage/GasSufficiencyMessage.js +1 -1
- package/cjs/components/Header/NavigationHeader.js +1 -1
- package/cjs/components/Header/WalletHeader.js +1 -1
- package/cjs/components/ReverseTokensButton/ReverseTokensButton.style.js +1 -1
- package/cjs/components/Step/CircularProgress.d.ts +3 -3
- package/cjs/components/Step/CircularProgress.js +10 -9
- package/cjs/components/Step/CircularProgress.style.d.ts +12 -3
- package/cjs/components/Step/CircularProgress.style.js +26 -10
- package/cjs/components/Step/DestinationWalletAddress.d.ts +7 -0
- package/cjs/components/Step/DestinationWalletAddress.js +32 -0
- package/cjs/components/Step/GasStepProcess.d.ts +5 -0
- package/cjs/components/Step/GasStepProcess.js +24 -0
- package/cjs/components/Step/Step.d.ts +1 -0
- package/cjs/components/Step/Step.js +18 -6
- package/cjs/components/Step/StepList.d.ts +3 -0
- package/cjs/components/Step/StepList.js +20 -0
- package/cjs/components/Step/StepProcess.js +2 -2
- package/cjs/components/Step/index.d.ts +1 -0
- package/cjs/components/Step/index.js +1 -0
- package/cjs/components/SwapButton/SwapButton.js +1 -1
- package/cjs/components/SwapRouteCard/SwapRouteNotFoundCard.js +1 -1
- package/cjs/config/sentry.js +1 -1
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/hooks/useChains.js +4 -1
- package/cjs/hooks/useProcessMessage.js +47 -5
- package/cjs/hooks/useRouteExecution.d.ts +8 -2
- package/cjs/hooks/useRouteExecution.js +14 -5
- package/cjs/hooks/useSwapRoutes.d.ts +2 -2
- package/cjs/hooks/useSwapRoutes.js +7 -0
- package/cjs/hooks/useTokenBalance.js +2 -2
- package/cjs/hooks/useTools.js +2 -0
- package/cjs/i18n/en.json +44 -28
- package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +10 -15
- package/cjs/pages/SwapHistoryPage/SwapHistoryEmpty.js +1 -1
- package/cjs/pages/SwapPage/ExchangeRateBottomSheet.d.ts +15 -0
- package/cjs/pages/SwapPage/ExchangeRateBottomSheet.js +71 -0
- package/cjs/pages/SwapPage/StatusBottomSheet.js +20 -4
- package/cjs/pages/SwapPage/StatusBottomSheet.style.js +4 -4
- package/cjs/pages/SwapPage/SwapPage.js +12 -14
- package/cjs/pages/SwapPage/TokenValueBottomSheet.js +6 -5
- package/cjs/utils/navigationRoutes.js +1 -0
- package/components/ActiveSwaps/ActiveSwapItem.js +6 -3
- package/components/BottomSheet/BottomSheet.js +3 -2
- package/components/BottomSheet/types.d.ts +2 -1
- package/components/GasSufficiencyMessage/GasSufficiencyMessage.js +1 -1
- package/components/Header/NavigationHeader.js +2 -2
- package/components/Header/WalletHeader.js +1 -1
- package/components/ReverseTokensButton/ReverseTokensButton.style.js +1 -1
- package/components/Step/CircularProgress.d.ts +3 -3
- package/components/Step/CircularProgress.js +12 -11
- package/components/Step/CircularProgress.style.d.ts +12 -3
- package/components/Step/CircularProgress.style.js +27 -11
- package/components/Step/DestinationWalletAddress.d.ts +7 -0
- package/components/Step/DestinationWalletAddress.js +28 -0
- package/components/Step/GasStepProcess.d.ts +5 -0
- package/components/Step/GasStepProcess.js +20 -0
- package/components/Step/Step.d.ts +1 -0
- package/components/Step/Step.js +18 -6
- package/components/Step/StepList.d.ts +3 -0
- package/components/Step/StepList.js +16 -0
- package/components/Step/StepProcess.js +2 -2
- package/components/Step/index.d.ts +1 -0
- package/components/Step/index.js +1 -0
- package/components/SwapButton/SwapButton.js +1 -1
- package/components/SwapRouteCard/SwapRouteNotFoundCard.js +1 -1
- package/config/sentry.js +1 -1
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/useChains.js +5 -2
- package/hooks/useProcessMessage.js +47 -5
- package/hooks/useRouteExecution.d.ts +8 -2
- package/hooks/useRouteExecution.js +15 -6
- package/hooks/useSwapRoutes.d.ts +2 -2
- package/hooks/useSwapRoutes.js +7 -0
- package/hooks/useTokenBalance.js +2 -2
- package/hooks/useTools.js +2 -0
- package/i18n/en.json +44 -28
- package/package.json +9 -9
- package/pages/SwapDetailsPage/SwapDetailsPage.js +14 -19
- package/pages/SwapHistoryPage/SwapHistoryEmpty.js +1 -1
- package/pages/SwapPage/ExchangeRateBottomSheet.d.ts +15 -0
- package/pages/SwapPage/ExchangeRateBottomSheet.js +67 -0
- package/pages/SwapPage/StatusBottomSheet.js +22 -6
- package/pages/SwapPage/StatusBottomSheet.style.js +4 -4
- package/pages/SwapPage/SwapPage.js +15 -17
- package/pages/SwapPage/TokenValueBottomSheet.js +7 -6
- package/tsconfig.cjs.tsbuildinfo +1 -1
- package/utils/navigationRoutes.js +1 -0
|
@@ -10,27 +10,32 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
11
11
|
import { Delete as DeleteIcon } from '@mui/icons-material';
|
|
12
12
|
import { Box, Button, Tooltip } from '@mui/material';
|
|
13
|
-
import {
|
|
13
|
+
import { useCallback, useRef } from 'react';
|
|
14
14
|
import { useFormContext } from 'react-hook-form';
|
|
15
15
|
import { useTranslation } from 'react-i18next';
|
|
16
16
|
import { useLocation } from 'react-router-dom';
|
|
17
17
|
import { GasSufficiencyMessage } from '../../components/GasSufficiencyMessage';
|
|
18
|
-
import {
|
|
19
|
-
import { StepDivider } from '../../components/StepDivider';
|
|
18
|
+
import { getStepList } from '../../components/Step';
|
|
20
19
|
import { SwapButton } from '../../components/SwapButton';
|
|
21
20
|
import { useNavigateBack, useRouteExecution } from '../../hooks';
|
|
22
21
|
import { SwapFormKey } from '../../providers';
|
|
23
22
|
import { RouteExecutionStatus } from '../../stores';
|
|
23
|
+
import { ExchangeRateBottomSheet } from './ExchangeRateBottomSheet';
|
|
24
24
|
import { StatusBottomSheet } from './StatusBottomSheet';
|
|
25
25
|
import { Container } from './SwapPage.style';
|
|
26
|
-
import { getTokenValueLossThreshold, TokenValueBottomSheet
|
|
26
|
+
import { getTokenValueLossThreshold, TokenValueBottomSheet } from './TokenValueBottomSheet';
|
|
27
27
|
export const SwapPage = () => {
|
|
28
|
+
var _a;
|
|
28
29
|
const { t } = useTranslation();
|
|
29
30
|
const { state } = useLocation();
|
|
30
31
|
const { navigateBack } = useNavigateBack();
|
|
31
32
|
const tokenValueBottomSheetRef = useRef(null);
|
|
33
|
+
const exchangeRateBottomSheetRef = useRef(null);
|
|
32
34
|
const { setValue } = useFormContext();
|
|
33
|
-
const { route, status, executeRoute, restartRoute, deleteRoute } = useRouteExecution(
|
|
35
|
+
const { route, status, executeRoute, restartRoute, deleteRoute } = useRouteExecution({
|
|
36
|
+
routeId: state === null || state === void 0 ? void 0 : state.routeId,
|
|
37
|
+
onAcceptExchangeRateUpdate: (_a = exchangeRateBottomSheetRef.current) === null || _a === void 0 ? void 0 : _a.open,
|
|
38
|
+
});
|
|
34
39
|
const handleExecuteRoute = useCallback(() => {
|
|
35
40
|
var _a, _b;
|
|
36
41
|
if ((_a = tokenValueBottomSheetRef.current) === null || _a === void 0 ? void 0 : _a.isOpen()) {
|
|
@@ -40,11 +45,11 @@ export const SwapPage = () => {
|
|
|
40
45
|
setValue(SwapFormKey.FromAmount, '');
|
|
41
46
|
}, [executeRoute, setValue]);
|
|
42
47
|
const handleSwapClick = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
|
-
var
|
|
48
|
+
var _b;
|
|
44
49
|
if (status === RouteExecutionStatus.Idle) {
|
|
45
50
|
const thresholdExceeded = getTokenValueLossThreshold(route);
|
|
46
51
|
if (thresholdExceeded) {
|
|
47
|
-
(
|
|
52
|
+
(_b = tokenValueBottomSheetRef.current) === null || _b === void 0 ? void 0 : _b.open();
|
|
48
53
|
}
|
|
49
54
|
else {
|
|
50
55
|
handleExecuteRoute();
|
|
@@ -63,23 +68,16 @@ export const SwapPage = () => {
|
|
|
63
68
|
case RouteExecutionStatus.Idle:
|
|
64
69
|
return t('button.startSwap');
|
|
65
70
|
case RouteExecutionStatus.Failed:
|
|
66
|
-
return t('button.
|
|
71
|
+
return t('button.tryAgain');
|
|
67
72
|
default:
|
|
68
73
|
return '';
|
|
69
74
|
}
|
|
70
75
|
};
|
|
71
|
-
return (_jsxs(Container, { children: [route
|
|
72
|
-
var _a, _b, _c, _d, _e;
|
|
73
|
-
const fromToken = index === 0
|
|
74
|
-
? Object.assign(Object.assign({}, step.action.fromToken), { amount: step.action.fromAmount }) : undefined;
|
|
75
|
-
const toToken = index === steps.length - 1
|
|
76
|
-
? 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;
|
|
77
|
-
return (_jsxs(Fragment, { children: [_jsx(Step, { step: step, fromToken: fromToken, toToken: toToken }), steps.length > 1 && index !== steps.length - 1 ? (_jsx(StepDivider, {})) : null] }, step.id));
|
|
78
|
-
}), status === RouteExecutionStatus.Idle ||
|
|
76
|
+
return (_jsxs(Container, { children: [getStepList(route), status === RouteExecutionStatus.Idle ||
|
|
79
77
|
status === RouteExecutionStatus.Failed ? (_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,
|
|
80
78
|
// disable={status === 'idle' && (isValidating || !isValid)}
|
|
81
79
|
enableLoading: true }), status === RouteExecutionStatus.Failed ? (_jsx(Tooltip, Object.assign({ title: t('button.removeSwap'), placement: "bottom-end", enterDelay: 400, arrow: true }, { children: _jsx(Button, Object.assign({ onClick: handleRemoveRoute, sx: {
|
|
82
80
|
minWidth: 48,
|
|
83
81
|
marginLeft: 1,
|
|
84
|
-
} }, { children: _jsx(DeleteIcon, {}) })) }))) : null] }))] })) : null, route && status ? (_jsx(StatusBottomSheet, { status: status, route: route })) : null, route ? (_jsx(TokenValueBottomSheet, { route: route, ref: tokenValueBottomSheetRef, onContinue: handleExecuteRoute })) : null] }));
|
|
82
|
+
} }, { children: _jsx(DeleteIcon, {}) })) }))) : null] }))] })) : null, route && status ? (_jsx(StatusBottomSheet, { status: status, route: route })) : null, route ? (_jsx(TokenValueBottomSheet, { route: route, ref: tokenValueBottomSheetRef, onContinue: handleExecuteRoute })) : null, route ? _jsx(ExchangeRateBottomSheet, { ref: exchangeRateBottomSheetRef }) : null] }));
|
|
85
83
|
};
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { WarningRounded as WarningIcon } from '@mui/icons-material';
|
|
3
3
|
import { Box, Button, Typography } from '@mui/material';
|
|
4
4
|
import Big from 'big.js';
|
|
5
|
-
import { forwardRef, useRef } from 'react';
|
|
5
|
+
import { forwardRef, useCallback, useRef } from 'react';
|
|
6
6
|
import { useTranslation } from 'react-i18next';
|
|
7
7
|
import { BottomSheet } from '../../components/BottomSheet';
|
|
8
8
|
import { useSetContentHeight } from '../../hooks';
|
|
9
9
|
import { IconCircle, IconContainer } from './StatusBottomSheet.style';
|
|
10
10
|
export const TokenValueBottomSheet = forwardRef(({ route, onContinue, onCancel }, ref) => {
|
|
11
|
-
const handleCancel = () => {
|
|
11
|
+
const handleCancel = useCallback(() => {
|
|
12
12
|
var _a;
|
|
13
13
|
(_a = ref.current) === null || _a === void 0 ? void 0 : _a.close();
|
|
14
14
|
onCancel === null || onCancel === void 0 ? void 0 : onCancel();
|
|
15
|
-
};
|
|
16
|
-
return (_jsx(BottomSheet, Object.assign({ ref: ref }, { children: _jsx(TokenValueBottomSheetContent, { route: route, onContinue: onContinue, onCancel: handleCancel }) })));
|
|
15
|
+
}, []);
|
|
16
|
+
return (_jsx(BottomSheet, Object.assign({ ref: ref, onClose: handleCancel }, { children: _jsx(TokenValueBottomSheetContent, { route: route, onContinue: onContinue, onCancel: handleCancel }) })));
|
|
17
17
|
});
|
|
18
18
|
const TokenValueBottomSheetContent = ({ route, onCancel, onContinue, }) => {
|
|
19
19
|
const { t } = useTranslation();
|
|
@@ -23,7 +23,8 @@ const TokenValueBottomSheetContent = ({ route, onCancel, onContinue, }) => {
|
|
|
23
23
|
.div(Big(route.fromAmountUSD || 0).plus(Big(route.gasCostUSD || 0)))
|
|
24
24
|
.minus(1)
|
|
25
25
|
.mul(100)
|
|
26
|
-
.
|
|
26
|
+
.round(2, Big.roundUp)
|
|
27
|
+
.toString(), "%"] }))] })), _jsxs(Box, Object.assign({ display: "flex", mt: 3 }, { children: [_jsx(Button, Object.assign({ variant: "text", onClick: onCancel, fullWidth: true }, { children: t('button.cancel') })), _jsx(Box, { display: "flex", p: 1 }), _jsx(Button, Object.assign({ variant: "contained", onClick: onContinue, fullWidth: true }, { children: t('button.continue') }))] }))] })));
|
|
27
28
|
};
|
|
28
29
|
export const getTokenValueLossThreshold = (route) => {
|
|
29
30
|
if (!route) {
|