@lifi/widget 1.24.0 → 1.25.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/AppDrawer.style.d.ts +1 -1
- package/AppProvider.js +1 -1
- package/cjs/AppDrawer.style.d.ts +1 -1
- package/cjs/AppProvider.js +1 -1
- package/cjs/components/ActiveSwaps/ActiveSwapItem.js +2 -1
- package/cjs/components/BottomSheet/types.d.ts +1 -1
- package/cjs/components/Card/Card.d.ts +2 -2
- package/cjs/components/Card/CardTitle.d.ts +1 -1
- package/cjs/components/ChainSelect/ChainSelect.js +6 -1
- package/cjs/components/ChainSelect/useChainSelect.d.ts +3 -1
- package/cjs/components/ChainSelect/useChainSelect.js +12 -3
- package/cjs/components/SendToWallet/SendToWallet.style.d.ts +1 -1
- package/cjs/components/SwapInput/FitInputText.d.ts +3 -0
- package/cjs/components/SwapInput/FitInputText.js +19 -0
- package/cjs/components/SwapInput/FormPriceHelperText.d.ts +1 -3
- package/cjs/components/SwapInput/FormPriceHelperText.js +1 -1
- package/cjs/components/SwapInput/SwapInput.js +12 -24
- package/cjs/components/SwapInput/SwapInput.style.d.ts +1 -1
- package/cjs/components/SwapInput/SwapInputEndAdornment.d.ts +3 -0
- package/cjs/components/SwapInput/{SwapInputAdornment.js → SwapInputEndAdornment.js} +3 -3
- package/cjs/components/SwapInput/SwapInputStartAdornment.d.ts +3 -0
- package/cjs/components/SwapInput/SwapInputStartAdornment.js +21 -0
- package/cjs/components/SwapRouteCard/SwapRouteCard.style.d.ts +1 -1
- package/cjs/components/SwapRoutes/SwapRoutes.style.d.ts +1 -1
- package/cjs/components/Token/Token.style.d.ts +1 -1
- package/cjs/components/TokenList/useTokenSelect.js +7 -4
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/hooks/useGasSufficiency.js +1 -1
- package/cjs/hooks/useRouteExecution.js +1 -1
- package/cjs/hooks/useSwapRoutes.js +12 -9
- package/cjs/hooks/useTools.d.ts +1 -1
- package/cjs/i18n/en.json +3 -1
- package/cjs/pages/SettingsPage/RoutePrioritySelect.js +2 -1
- package/cjs/pages/SettingsPage/SlippageInput.js +2 -1
- package/cjs/pages/SwapPage/StatusBottomSheet.js +61 -14
- package/cjs/pages/SwapPage/StatusBottomSheet.style.d.ts +4 -2
- package/cjs/pages/SwapPage/StatusBottomSheet.style.js +5 -2
- package/cjs/pages/SwapPage/SwapPage.js +8 -6
- package/cjs/pages/SwapRoutesPage/SwapRoutesPage.style.d.ts +1 -1
- package/cjs/providers/I18nProvider/types.d.ts +5 -5
- package/cjs/providers/SDKProvider/SDKProvider.js +4 -3
- package/cjs/providers/SwapFormProvider/FormUpdater.d.ts +5 -0
- package/cjs/providers/{WalletProvider/WalletFormUpdate.js → SwapFormProvider/FormUpdater.js} +24 -21
- package/cjs/providers/SwapFormProvider/SwapFormProvider.js +12 -7
- package/cjs/providers/SwapFormProvider/types.d.ts +2 -2
- package/cjs/providers/WalletProvider/WalletProvider.d.ts +1 -1
- package/cjs/providers/WalletProvider/WalletProvider.js +1 -2
- package/cjs/providers/WalletProvider/types.d.ts +3 -3
- package/cjs/providers/WidgetProvider/WidgetProvider.js +4 -0
- package/cjs/providers/WidgetProvider/types.d.ts +1 -1
- package/cjs/stores/routes/types.d.ts +8 -1
- package/cjs/stores/routes/types.js +10 -0
- package/cjs/stores/routes/useExecutingRoutesIds.js +3 -1
- package/cjs/stores/routes/useRouteExecutionStore.js +53 -18
- package/cjs/stores/routes/useSwapHistory.js +4 -1
- package/cjs/stores/routes/utils.d.ts +3 -1
- package/cjs/stores/routes/utils.js +12 -4
- package/cjs/stores/settings/types.d.ts +6 -6
- package/cjs/stores/settings/useSettingsStore.d.ts +12 -9
- package/cjs/stores/settings/useSettingsStore.js +22 -5
- package/cjs/types/events.d.ts +1 -1
- package/cjs/types/widget.d.ts +14 -8
- package/cjs/utils/enum.d.ts +1 -0
- package/cjs/utils/enum.js +5 -0
- package/cjs/utils/index.d.ts +1 -0
- package/cjs/utils/index.js +1 -0
- package/cjs/utils/navigationRoutes.d.ts +1 -1
- package/components/ActiveSwaps/ActiveSwapItem.js +2 -1
- package/components/BottomSheet/types.d.ts +1 -1
- package/components/Card/Card.d.ts +2 -2
- package/components/Card/CardTitle.d.ts +1 -1
- package/components/ChainSelect/ChainSelect.js +6 -1
- package/components/ChainSelect/useChainSelect.d.ts +3 -1
- package/components/ChainSelect/useChainSelect.js +13 -4
- package/components/SendToWallet/SendToWallet.style.d.ts +1 -1
- package/components/SwapInput/FitInputText.d.ts +3 -0
- package/components/SwapInput/FitInputText.js +16 -0
- package/components/SwapInput/FormPriceHelperText.d.ts +1 -3
- package/components/SwapInput/FormPriceHelperText.js +1 -1
- package/components/SwapInput/SwapInput.js +16 -28
- package/components/SwapInput/SwapInput.style.d.ts +1 -1
- package/components/SwapInput/SwapInputEndAdornment.d.ts +3 -0
- package/components/SwapInput/{SwapInputAdornment.js → SwapInputEndAdornment.js} +1 -1
- package/components/SwapInput/SwapInputStartAdornment.d.ts +3 -0
- package/components/SwapInput/SwapInputStartAdornment.js +17 -0
- package/components/SwapRouteCard/SwapRouteCard.style.d.ts +1 -1
- package/components/SwapRoutes/SwapRoutes.style.d.ts +1 -1
- package/components/Token/Token.style.d.ts +1 -1
- package/components/TokenList/useTokenSelect.js +8 -5
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/useGasSufficiency.js +2 -2
- package/hooks/useRouteExecution.js +2 -2
- package/hooks/useSwapRoutes.js +12 -9
- package/hooks/useTools.d.ts +1 -1
- package/i18n/en.json +3 -1
- package/package.json +13 -13
- package/pages/SettingsPage/RoutePrioritySelect.js +2 -1
- package/pages/SettingsPage/SlippageInput.js +2 -1
- package/pages/SwapPage/StatusBottomSheet.js +62 -15
- package/pages/SwapPage/StatusBottomSheet.style.d.ts +4 -2
- package/pages/SwapPage/StatusBottomSheet.style.js +5 -2
- package/pages/SwapPage/SwapPage.js +8 -6
- package/pages/SwapRoutesPage/SwapRoutesPage.style.d.ts +1 -1
- package/providers/I18nProvider/types.d.ts +5 -5
- package/providers/SDKProvider/SDKProvider.js +4 -3
- package/providers/SwapFormProvider/FormUpdater.d.ts +5 -0
- package/providers/{WalletProvider/WalletFormUpdate.js → SwapFormProvider/FormUpdater.js} +23 -20
- package/providers/SwapFormProvider/SwapFormProvider.js +12 -7
- package/providers/SwapFormProvider/types.d.ts +2 -2
- package/providers/WalletProvider/WalletProvider.d.ts +1 -1
- package/providers/WalletProvider/WalletProvider.js +2 -3
- package/providers/WalletProvider/types.d.ts +3 -3
- package/providers/WidgetProvider/WidgetProvider.js +5 -1
- package/providers/WidgetProvider/types.d.ts +1 -1
- package/stores/routes/types.d.ts +8 -1
- package/stores/routes/types.js +9 -1
- package/stores/routes/useExecutingRoutesIds.js +3 -1
- package/stores/routes/useRouteExecutionStore.js +51 -16
- package/stores/routes/useSwapHistory.js +4 -1
- package/stores/routes/utils.d.ts +3 -1
- package/stores/routes/utils.js +8 -2
- package/stores/settings/types.d.ts +6 -6
- package/stores/settings/useSettingsStore.d.ts +12 -9
- package/stores/settings/useSettingsStore.js +20 -4
- package/tsconfig.cjs.tsbuildinfo +1 -1
- package/types/events.d.ts +1 -1
- package/types/widget.d.ts +14 -8
- package/utils/enum.d.ts +1 -0
- package/utils/enum.js +1 -0
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
- package/utils/navigationRoutes.d.ts +1 -1
- package/cjs/components/SwapInput/SwapInputAdornment.d.ts +0 -3
- package/cjs/providers/WalletProvider/WalletFormUpdate.d.ts +0 -5
- package/components/SwapInput/SwapInputAdornment.d.ts +0 -3
- package/providers/WalletProvider/WalletFormUpdate.d.ts +0 -5
|
@@ -12,10 +12,11 @@ const BottomSheet_1 = require("../../components/BottomSheet");
|
|
|
12
12
|
const Token_1 = require("../../components/Token");
|
|
13
13
|
const hooks_1 = require("../../hooks");
|
|
14
14
|
const providers_1 = require("../../providers");
|
|
15
|
+
const stores_1 = require("../../stores");
|
|
15
16
|
const utils_1 = require("../../utils");
|
|
16
17
|
const StatusBottomSheet_style_1 = require("./StatusBottomSheet.style");
|
|
17
18
|
const StatusBottomSheet = ({ status, route, }) => {
|
|
18
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
19
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
19
20
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
20
21
|
const { navigateBack, navigate } = (0, hooks_1.useNavigateBack)();
|
|
21
22
|
const ref = (0, react_1.useRef)(null);
|
|
@@ -31,6 +32,22 @@ const StatusBottomSheet = ({ status, route, }) => {
|
|
|
31
32
|
clearFromAmount();
|
|
32
33
|
navigateBack();
|
|
33
34
|
};
|
|
35
|
+
const handlePartialDone = () => {
|
|
36
|
+
clearFromAmount();
|
|
37
|
+
if (toToken.chainId !== route.toToken.chainId &&
|
|
38
|
+
toToken.address !== route.toToken.address) {
|
|
39
|
+
setValue(providers_1.SwapFormKey.FromAmount, (0, utils_1.formatTokenAmount)(toToken.amount, toToken.decimals), { shouldTouch: true });
|
|
40
|
+
setValue(providers_1.SwapFormKey.FromChain, toToken.chainId, { shouldTouch: true });
|
|
41
|
+
setValue(providers_1.SwapFormKey.FromToken, toToken.address, { shouldTouch: true });
|
|
42
|
+
setValue(providers_1.SwapFormKey.ToChain, route.toToken.chainId, {
|
|
43
|
+
shouldTouch: true,
|
|
44
|
+
});
|
|
45
|
+
setValue(providers_1.SwapFormKey.ToToken, route.toToken.address, {
|
|
46
|
+
shouldTouch: true,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
navigateBack();
|
|
50
|
+
};
|
|
34
51
|
const handleClose = () => {
|
|
35
52
|
var _a;
|
|
36
53
|
clearFromAmount();
|
|
@@ -44,26 +61,50 @@ const StatusBottomSheet = ({ status, route, }) => {
|
|
|
44
61
|
});
|
|
45
62
|
};
|
|
46
63
|
let title;
|
|
47
|
-
let
|
|
64
|
+
let primaryMessage;
|
|
65
|
+
let secondaryMessage;
|
|
66
|
+
let handlePrimaryButton = handleDone;
|
|
48
67
|
switch (status) {
|
|
49
|
-
case
|
|
68
|
+
case stores_1.RouteExecutionStatus.Done: {
|
|
50
69
|
title = t('swap.success.title.swapSuccessful');
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
70
|
+
if (token) {
|
|
71
|
+
primaryMessage = t('swap.success.message.swapSuccessful', {
|
|
72
|
+
amount: token.amount,
|
|
73
|
+
tokenSymbol: token.symbol,
|
|
74
|
+
chainName: (_j = getChainById(token.chainId)) === null || _j === void 0 ? void 0 : _j.name,
|
|
75
|
+
walletAddress: (0, utils_1.shortenWalletAddress)(route.toAddress),
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
handlePrimaryButton = handleDone;
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
case stores_1.RouteExecutionStatus.Done | stores_1.RouteExecutionStatus.Partial: {
|
|
82
|
+
title = t('swap.success.title.swapPartiallySuccessful');
|
|
83
|
+
primaryMessage = t('swap.success.message.swapPartiallySuccessful', {
|
|
84
|
+
tool: (_k = route.steps.at(-1)) === null || _k === void 0 ? void 0 : _k.toolDetails.name,
|
|
85
|
+
tokenSymbol: (_l = route.steps.at(-1)) === null || _l === void 0 ? void 0 : _l.action.toToken.symbol,
|
|
56
86
|
});
|
|
87
|
+
if (token) {
|
|
88
|
+
secondaryMessage = t('swap.success.message.swapSuccessful', {
|
|
89
|
+
amount: token.amount,
|
|
90
|
+
tokenSymbol: token.symbol,
|
|
91
|
+
chainName: (_m = getChainById(token.chainId)) === null || _m === void 0 ? void 0 : _m.name,
|
|
92
|
+
walletAddress: (0, utils_1.shortenWalletAddress)(route.toAddress),
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
handlePrimaryButton = handlePartialDone;
|
|
57
96
|
break;
|
|
58
|
-
|
|
97
|
+
}
|
|
98
|
+
case stores_1.RouteExecutionStatus.Failed: {
|
|
59
99
|
const step = route.steps.find((step) => { var _a; return ((_a = step.execution) === null || _a === void 0 ? void 0 : _a.status) === 'FAILED'; });
|
|
60
|
-
const process = (
|
|
100
|
+
const process = (_o = step === null || step === void 0 ? void 0 : step.execution) === null || _o === void 0 ? void 0 : _o.process.find((process) => process.status === 'FAILED');
|
|
61
101
|
if (!step || !process) {
|
|
62
102
|
break;
|
|
63
103
|
}
|
|
64
104
|
const processMessage = (0, hooks_1.getProcessMessage)(t, getChainById, step, process);
|
|
65
105
|
title = processMessage.title;
|
|
66
|
-
|
|
106
|
+
primaryMessage = processMessage.message;
|
|
107
|
+
handlePrimaryButton = handleClose;
|
|
67
108
|
break;
|
|
68
109
|
}
|
|
69
110
|
default:
|
|
@@ -71,15 +112,21 @@ const StatusBottomSheet = ({ status, route, }) => {
|
|
|
71
112
|
}
|
|
72
113
|
(0, react_1.useEffect)(() => {
|
|
73
114
|
var _a, _b;
|
|
74
|
-
|
|
115
|
+
const hasSuccessFlag = (0, utils_1.hasEnumFlag)(status, stores_1.RouteExecutionStatus.Done);
|
|
116
|
+
if ((hasSuccessFlag || (0, utils_1.hasEnumFlag)(status, stores_1.RouteExecutionStatus.Failed)) &&
|
|
75
117
|
!((_a = ref.current) === null || _a === void 0 ? void 0 : _a.isOpen())) {
|
|
76
|
-
if (
|
|
118
|
+
if (hasSuccessFlag) {
|
|
77
119
|
refetchNewBalance();
|
|
78
120
|
refetch();
|
|
79
121
|
}
|
|
80
122
|
(_b = ref.current) === null || _b === void 0 ? void 0 : _b.open();
|
|
81
123
|
}
|
|
82
124
|
}, [refetch, refetchNewBalance, status]);
|
|
83
|
-
return ((0, jsx_runtime_1.jsx)(BottomSheet_1.BottomSheet, Object.assign({ ref: ref }, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ p: 3 }, { children: [(0, jsx_runtime_1.jsxs)(StatusBottomSheet_style_1.IconContainer, { children: [(0, jsx_runtime_1.jsxs)(StatusBottomSheet_style_1.IconCircle, Object.assign({ status: status, mb: 1 }, { children: [status ===
|
|
125
|
+
return ((0, jsx_runtime_1.jsx)(BottomSheet_1.BottomSheet, Object.assign({ ref: ref }, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ p: 3 }, { children: [(0, jsx_runtime_1.jsxs)(StatusBottomSheet_style_1.IconContainer, { children: [(0, jsx_runtime_1.jsxs)(StatusBottomSheet_style_1.IconCircle, Object.assign({ status: status, mb: 1 }, { children: [status === stores_1.RouteExecutionStatus.Idle ? ((0, jsx_runtime_1.jsx)(icons_material_1.Info, { color: "primary" })) : null, status === stores_1.RouteExecutionStatus.Done ? ((0, jsx_runtime_1.jsx)(icons_material_1.Done, { color: "success" })) : null, (0, utils_1.hasEnumFlag)(status, stores_1.RouteExecutionStatus.Partial) ||
|
|
126
|
+
(0, utils_1.hasEnumFlag)(status, stores_1.RouteExecutionStatus.Refunded) ? ((0, jsx_runtime_1.jsx)(icons_material_1.Warning, { color: "warning" })) : null, (0, utils_1.hasEnumFlag)(status, stores_1.RouteExecutionStatus.Failed) ? ((0, jsx_runtime_1.jsx)(icons_material_1.Warning, { color: "error" })) : null] })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ py: 1, fontSize: 18, fontWeight: 700 }, { children: title })), (0, utils_1.hasEnumFlag)(status, stores_1.RouteExecutionStatus.Done) ? ((0, jsx_runtime_1.jsx)(Token_1.Token, { token: toToken, py: 1, disableDescription: true })) : null] }), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ py: 1 }, { children: primaryMessage })), secondaryMessage ? ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ py: 1 }, { children: secondaryMessage }))) : null, (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mt: 2 }, { children: (0, jsx_runtime_1.jsxs)(material_1.Button, Object.assign({ variant: "contained", fullWidth: true, onClick: handlePrimaryButton }, { children: [status === stores_1.RouteExecutionStatus.Idle ? t('button.ok') : null, (0, utils_1.hasEnumFlag)(status, stores_1.RouteExecutionStatus.Done)
|
|
127
|
+
? t('button.done')
|
|
128
|
+
: null, status === stores_1.RouteExecutionStatus.Failed
|
|
129
|
+
? t('button.seeDetails')
|
|
130
|
+
: null] })) })), (0, utils_1.hasEnumFlag)(status, stores_1.RouteExecutionStatus.Done) ? ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mt: 2 }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ variant: "text", onClick: handleSeeDetails, fullWidth: true }, { children: t('button.seeDetails') })) }))) : null] })) })));
|
|
84
131
|
};
|
|
85
132
|
exports.StatusBottomSheet = StatusBottomSheet;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { Theme } from '@mui/material';
|
|
3
|
-
import
|
|
3
|
+
import { RouteExecutionStatus } from '../../stores';
|
|
4
|
+
type StatusColor = RouteExecutionStatus | 'warning';
|
|
4
5
|
export declare const IconContainer: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<Theme> & {
|
|
5
6
|
children?: import("react").ReactNode;
|
|
6
7
|
component?: import("react").ElementType<any> | undefined;
|
|
@@ -17,5 +18,6 @@ export declare const IconCircle: import("@emotion/styled").StyledComponent<impor
|
|
|
17
18
|
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
18
19
|
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
19
20
|
}, 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> & {
|
|
20
|
-
status:
|
|
21
|
+
status: StatusColor;
|
|
21
22
|
}, {}, {}>;
|
|
23
|
+
export {};
|
|
@@ -3,12 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.IconCircle = exports.IconContainer = void 0;
|
|
4
4
|
const material_1 = require("@mui/material");
|
|
5
5
|
const styles_1 = require("@mui/material/styles");
|
|
6
|
+
const stores_1 = require("../../stores");
|
|
6
7
|
const getStatusColor = (status, theme) => {
|
|
7
8
|
switch (status) {
|
|
8
|
-
case
|
|
9
|
+
case stores_1.RouteExecutionStatus.Done:
|
|
9
10
|
return { color: theme.palette.success.main, alpha: 0.15, darken: 0 };
|
|
10
|
-
case
|
|
11
|
+
case stores_1.RouteExecutionStatus.Failed:
|
|
11
12
|
return { color: theme.palette.error.main, alpha: 0.2, darken: 0 };
|
|
13
|
+
case stores_1.RouteExecutionStatus.Done | stores_1.RouteExecutionStatus.Partial:
|
|
14
|
+
case stores_1.RouteExecutionStatus.Done | stores_1.RouteExecutionStatus.Refunded:
|
|
12
15
|
case 'warning':
|
|
13
16
|
return { color: theme.palette.warning.main, alpha: 0.7, darken: 0.4 };
|
|
14
17
|
default:
|
|
@@ -23,6 +23,7 @@ const StepDivider_1 = require("../../components/StepDivider");
|
|
|
23
23
|
const SwapButton_1 = require("../../components/SwapButton");
|
|
24
24
|
const hooks_1 = require("../../hooks");
|
|
25
25
|
const providers_1 = require("../../providers");
|
|
26
|
+
const stores_1 = require("../../stores");
|
|
26
27
|
const StatusBottomSheet_1 = require("./StatusBottomSheet");
|
|
27
28
|
const SwapPage_style_1 = require("./SwapPage.style");
|
|
28
29
|
const TokenValueBottomSheet_1 = require("./TokenValueBottomSheet");
|
|
@@ -43,7 +44,7 @@ const SwapPage = () => {
|
|
|
43
44
|
}, [executeRoute, setValue]);
|
|
44
45
|
const handleSwapClick = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
45
46
|
var _a;
|
|
46
|
-
if (status ===
|
|
47
|
+
if (status === stores_1.RouteExecutionStatus.Idle) {
|
|
47
48
|
const thresholdExceeded = (0, TokenValueBottomSheet_1.getTokenValueLossThreshold)(route);
|
|
48
49
|
if (thresholdExceeded) {
|
|
49
50
|
(_a = tokenValueBottomSheetRef.current) === null || _a === void 0 ? void 0 : _a.open();
|
|
@@ -52,7 +53,7 @@ const SwapPage = () => {
|
|
|
52
53
|
handleExecuteRoute();
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
|
-
if (status ===
|
|
56
|
+
if (status === stores_1.RouteExecutionStatus.Failed) {
|
|
56
57
|
restartRoute();
|
|
57
58
|
}
|
|
58
59
|
});
|
|
@@ -62,9 +63,9 @@ const SwapPage = () => {
|
|
|
62
63
|
};
|
|
63
64
|
const getSwapButtonText = () => {
|
|
64
65
|
switch (status) {
|
|
65
|
-
case
|
|
66
|
+
case stores_1.RouteExecutionStatus.Idle:
|
|
66
67
|
return t('button.startSwap');
|
|
67
|
-
case
|
|
68
|
+
case stores_1.RouteExecutionStatus.Failed:
|
|
68
69
|
return t('button.restartSwap');
|
|
69
70
|
default:
|
|
70
71
|
return '';
|
|
@@ -77,9 +78,10 @@ const SwapPage = () => {
|
|
|
77
78
|
const toToken = index === steps.length - 1
|
|
78
79
|
? 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;
|
|
79
80
|
return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Step_1.Step, { step: step, fromToken: fromToken, toToken: toToken }), steps.length > 1 && index !== steps.length - 1 ? ((0, jsx_runtime_1.jsx)(StepDivider_1.StepDivider, {})) : null] }, step.id));
|
|
80
|
-
}), status ===
|
|
81
|
+
}), status === stores_1.RouteExecutionStatus.Idle ||
|
|
82
|
+
status === stores_1.RouteExecutionStatus.Failed ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(GasSufficiencyMessage_1.GasSufficiencyMessage, { route: route, mt: 2 }), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ mt: 2, display: "flex" }, { children: [(0, jsx_runtime_1.jsx)(SwapButton_1.SwapButton, { text: getSwapButtonText(), onClick: handleSwapClick, currentRoute: route,
|
|
81
83
|
// disable={status === 'idle' && (isValidating || !isValid)}
|
|
82
|
-
enableLoading: true }), status ===
|
|
84
|
+
enableLoading: true }), status === stores_1.RouteExecutionStatus.Failed ? ((0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: t('button.removeSwap'), placement: "bottom-end", enterDelay: 400, arrow: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ onClick: handleRemoveRoute, sx: {
|
|
83
85
|
minWidth: 48,
|
|
84
86
|
marginLeft: 1,
|
|
85
87
|
} }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.Delete, {}) })) }))) : null] }))] })) : null, route && status ? ((0, jsx_runtime_1.jsx)(StatusBottomSheet_1.StatusBottomSheet, { status: status, route: route })) : null, route ? ((0, jsx_runtime_1.jsx)(TokenValueBottomSheet_1.TokenValueBottomSheet, { route: route, ref: tokenValueBottomSheetRef, onContinue: handleExecuteRoute })) : null] }));
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export declare const Stack: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
|
|
3
3
|
ref?: import("react").Ref<unknown> | undefined;
|
|
4
4
|
children?: import("react").ReactNode;
|
|
5
|
-
direction?: import("@mui/system").ResponsiveStyleValue<"
|
|
5
|
+
direction?: import("@mui/system").ResponsiveStyleValue<"column" | "column-reverse" | "row" | "row-reverse"> | undefined;
|
|
6
6
|
spacing?: import("@mui/system").ResponsiveStyleValue<string | number> | undefined;
|
|
7
7
|
divider?: import("react").ReactNode;
|
|
8
8
|
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import type * as languages from '../../i18n';
|
|
2
|
-
export
|
|
2
|
+
export type PartialResource<T> = T extends object ? {
|
|
3
3
|
[P in keyof T]?: PartialResource<T[P]>;
|
|
4
4
|
} : T;
|
|
5
|
-
export
|
|
6
|
-
export
|
|
5
|
+
export type LanguageKey = keyof typeof languages;
|
|
6
|
+
export type LanguageResources = {
|
|
7
7
|
[language in LanguageKey]?: PartialResource<typeof languages.en>;
|
|
8
8
|
} | {
|
|
9
9
|
[language: string]: PartialResource<typeof languages.en>;
|
|
10
10
|
};
|
|
11
|
-
export
|
|
11
|
+
export type LanguageTranslationResource = {
|
|
12
12
|
[namespace in 'translation']: PartialResource<typeof languages.en>;
|
|
13
13
|
};
|
|
14
|
-
export
|
|
14
|
+
export type LanguageTranslationResources = {
|
|
15
15
|
[language: string]: LanguageTranslationResource;
|
|
16
16
|
};
|
|
@@ -10,15 +10,16 @@ const SDKContext = (0, react_1.createContext)(null);
|
|
|
10
10
|
const useLiFi = () => (0, react_1.useContext)(SDKContext);
|
|
11
11
|
exports.useLiFi = useLiFi;
|
|
12
12
|
const SDKProvider = ({ children, }) => {
|
|
13
|
-
const { sdkConfig, integrator } = (0, WidgetProvider_1.useWidgetConfig)();
|
|
13
|
+
const { sdkConfig, fee, integrator, routePriority, slippage } = (0, WidgetProvider_1.useWidgetConfig)();
|
|
14
14
|
const value = (0, react_1.useMemo)(() => {
|
|
15
|
-
const config = Object.assign(Object.assign({}, sdkConfig), { defaultRouteOptions: Object.assign({ integrator: integrator !== null && integrator !== void 0 ? integrator : window.location.hostname
|
|
15
|
+
const config = Object.assign(Object.assign({}, sdkConfig), { defaultRouteOptions: Object.assign({ fee, integrator: integrator !== null && integrator !== void 0 ? integrator : window.location.hostname, routePriority,
|
|
16
|
+
slippage }, sdkConfig === null || sdkConfig === void 0 ? void 0 : sdkConfig.defaultRouteOptions) });
|
|
16
17
|
if (!lifi) {
|
|
17
18
|
lifi = new sdk_1.default(Object.assign({ disableVersionCheck: true }, config));
|
|
18
19
|
}
|
|
19
20
|
lifi.setConfig(config);
|
|
20
21
|
return lifi;
|
|
21
|
-
}, [integrator, sdkConfig]);
|
|
22
|
+
}, [fee, integrator, routePriority, sdkConfig, slippage]);
|
|
22
23
|
return (0, jsx_runtime_1.jsx)(SDKContext.Provider, Object.assign({ value: value }, { children: children }));
|
|
23
24
|
};
|
|
24
25
|
exports.SDKProvider = SDKProvider;
|
package/cjs/providers/{WalletProvider/WalletFormUpdate.js → SwapFormProvider/FormUpdater.js}
RENAMED
|
@@ -1,50 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.FormUpdater = void 0;
|
|
4
4
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const react_hook_form_1 = require("react-hook-form");
|
|
7
|
-
const stores_1 = require("../../stores");
|
|
8
7
|
const SwapFormProvider_1 = require("../SwapFormProvider");
|
|
8
|
+
const WalletProvider_1 = require("../WalletProvider");
|
|
9
9
|
const WidgetProvider_1 = require("../WidgetProvider");
|
|
10
|
-
const
|
|
10
|
+
const FormUpdater = ({ defaultValues }) => {
|
|
11
11
|
const { fromChain, toChain, chains, disabledChains } = (0, WidgetProvider_1.useWidgetConfig)();
|
|
12
|
-
const {
|
|
12
|
+
const { account } = (0, WalletProvider_1.useWallet)();
|
|
13
|
+
const { setValue, getValues, getFieldState, resetField,
|
|
13
14
|
// Subscription to touchedFields is required by getFieldState to work
|
|
14
15
|
formState: { touchedFields }, } = (0, react_hook_form_1.useFormContext)();
|
|
16
|
+
const previousDefaultValues = (0, react_1.useRef)(defaultValues);
|
|
15
17
|
// Set wallet chain as default if no chains are provided by config and if they were not changed during widget usage
|
|
16
18
|
(0, react_1.useEffect)(() => {
|
|
17
19
|
const chainAllowed = account.chainId && (0, WidgetProvider_1.isItemAllowed)(account.chainId, chains, disabledChains);
|
|
18
20
|
if (!account.isActive || !account.chainId || !chainAllowed) {
|
|
19
21
|
return;
|
|
20
22
|
}
|
|
21
|
-
const [fromChainValue, toChainValue] = getValues([
|
|
22
|
-
SwapFormProvider_1.SwapFormKey.FromChain,
|
|
23
|
-
SwapFormProvider_1.SwapFormKey.ToChain,
|
|
24
|
-
]);
|
|
25
23
|
const { isTouched: isFromChainTouched } = getFieldState(SwapFormProvider_1.SwapFormKey.FromChain);
|
|
26
24
|
const { isTouched: isToChainTouched } = getFieldState(SwapFormProvider_1.SwapFormKey.ToChain);
|
|
27
25
|
const { isTouched: isFromTokenTouched } = getFieldState(SwapFormProvider_1.SwapFormKey.FromToken);
|
|
28
26
|
const { isTouched: isToTokenTouched } = getFieldState(SwapFormProvider_1.SwapFormKey.ToToken);
|
|
29
27
|
const { isTouched: isFromAmountTouched } = getFieldState(SwapFormProvider_1.SwapFormKey.FromAmount);
|
|
30
|
-
|
|
31
|
-
// Users can switch chains in the wallet.
|
|
32
|
-
// If we don't have a chain in the ordered chain list we should add it.
|
|
33
|
-
setChain(account.chainId);
|
|
34
|
-
// If we ran out of slots for the ordered chain list and the current chain isn't there
|
|
35
|
-
// we should make a recently switched chain as current.
|
|
36
|
-
const hasFromChainInOrderedList = chainOrder.includes(fromChainValue);
|
|
37
|
-
const hasToChainInOrderedList = chainOrder.includes(toChainValue);
|
|
38
|
-
if ((!fromChain && !isFromChainTouched && !isFromTokenTouched) ||
|
|
39
|
-
!hasFromChainInOrderedList) {
|
|
28
|
+
if (!fromChain && !isFromChainTouched && !isFromTokenTouched) {
|
|
40
29
|
setValue(SwapFormProvider_1.SwapFormKey.FromChain, account.chainId);
|
|
41
30
|
setValue(SwapFormProvider_1.SwapFormKey.FromToken, '');
|
|
42
31
|
if (isFromAmountTouched) {
|
|
43
32
|
setValue(SwapFormProvider_1.SwapFormKey.FromAmount, '');
|
|
44
33
|
}
|
|
45
34
|
}
|
|
46
|
-
if (
|
|
47
|
-
!hasToChainInOrderedList) {
|
|
35
|
+
if (!toChain && !isToChainTouched && !isToTokenTouched) {
|
|
48
36
|
setValue(SwapFormProvider_1.SwapFormKey.ToChain, account.chainId);
|
|
49
37
|
setValue(SwapFormProvider_1.SwapFormKey.ToToken, '');
|
|
50
38
|
}
|
|
@@ -59,6 +47,21 @@ const WalletFormUpdate = ({ account, }) => {
|
|
|
59
47
|
setValue,
|
|
60
48
|
toChain,
|
|
61
49
|
]);
|
|
50
|
+
(0, react_1.useEffect)(() => {
|
|
51
|
+
Object.keys(defaultValues).forEach((key) => {
|
|
52
|
+
if (previousDefaultValues.current[key] !== defaultValues[key]) {
|
|
53
|
+
const value = defaultValues[key] ||
|
|
54
|
+
// set the chain to the current user one if it is not present in the config
|
|
55
|
+
(key === SwapFormProvider_1.SwapFormKey.FromChain || key === SwapFormProvider_1.SwapFormKey.ToChain
|
|
56
|
+
? account.chainId || ''
|
|
57
|
+
: '');
|
|
58
|
+
setValue(key, value);
|
|
59
|
+
resetField(key, { defaultValue: value });
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
previousDefaultValues.current = defaultValues;
|
|
63
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
64
|
+
}, [defaultValues, getValues, resetField, setValue]);
|
|
62
65
|
return null;
|
|
63
66
|
};
|
|
64
|
-
exports.
|
|
67
|
+
exports.FormUpdater = FormUpdater;
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SwapFormProvider = exports.formDefaultValues = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
5
6
|
const react_hook_form_1 = require("react-hook-form");
|
|
6
7
|
const WidgetProvider_1 = require("../WidgetProvider");
|
|
8
|
+
const FormUpdater_1 = require("./FormUpdater");
|
|
7
9
|
const types_1 = require("./types");
|
|
8
10
|
const URLSearchParamsBuilder_1 = require("./URLSearchParamsBuilder");
|
|
9
11
|
exports.formDefaultValues = {
|
|
@@ -13,14 +15,17 @@ exports.formDefaultValues = {
|
|
|
13
15
|
};
|
|
14
16
|
const SwapFormProvider = ({ children, }) => {
|
|
15
17
|
const { fromChain, fromToken, fromAmount, toChain, toToken, toAddress, buildSwapUrl, } = (0, WidgetProvider_1.useWidgetConfig)();
|
|
18
|
+
const defaultValues = (0, react_1.useMemo)(() => (Object.assign(Object.assign({}, exports.formDefaultValues), { fromChain,
|
|
19
|
+
fromToken, fromAmount: (typeof fromAmount === 'number'
|
|
20
|
+
? fromAmount === null || fromAmount === void 0 ? void 0 : fromAmount.toPrecision()
|
|
21
|
+
: fromAmount) || exports.formDefaultValues.fromAmount, toChain,
|
|
22
|
+
toToken,
|
|
23
|
+
toAddress })), [fromAmount, fromChain, fromToken, toAddress, toChain, toToken]);
|
|
16
24
|
const methods = (0, react_hook_form_1.useForm)({
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
: fromAmount) || exports.formDefaultValues.fromAmount, toChain,
|
|
21
|
-
toToken,
|
|
22
|
-
toAddress }),
|
|
25
|
+
// TODO: revisit after RHF release values support
|
|
26
|
+
// values,
|
|
27
|
+
defaultValues,
|
|
23
28
|
});
|
|
24
|
-
return ((0, jsx_runtime_1.jsxs)(react_hook_form_1.FormProvider, Object.assign({}, methods, { children: [buildSwapUrl ? (0, jsx_runtime_1.jsx)(URLSearchParamsBuilder_1.URLSearchParamsBuilder, {}) : null, children] })));
|
|
29
|
+
return ((0, jsx_runtime_1.jsxs)(react_hook_form_1.FormProvider, Object.assign({}, methods, { children: [(0, jsx_runtime_1.jsx)(FormUpdater_1.FormUpdater, { defaultValues: defaultValues }), buildSwapUrl ? (0, jsx_runtime_1.jsx)(URLSearchParamsBuilder_1.URLSearchParamsBuilder, {}) : null, children] })));
|
|
25
30
|
};
|
|
26
31
|
exports.SwapFormProvider = SwapFormProvider;
|
|
@@ -7,7 +7,7 @@ export declare enum SwapFormKey {
|
|
|
7
7
|
ToToken = "toToken",
|
|
8
8
|
TokenSearchFilter = "tokenSearchFilter"
|
|
9
9
|
}
|
|
10
|
-
export
|
|
10
|
+
export type SwapFormValues = {
|
|
11
11
|
[SwapFormKey.FromAmount]: string;
|
|
12
12
|
[SwapFormKey.FromChain]: number;
|
|
13
13
|
[SwapFormKey.FromToken]: string;
|
|
@@ -16,7 +16,7 @@ export declare type SwapFormValues = {
|
|
|
16
16
|
[SwapFormKey.ToToken]: string;
|
|
17
17
|
[SwapFormKey.TokenSearchFilter]: string;
|
|
18
18
|
};
|
|
19
|
-
export
|
|
19
|
+
export type SwapFormType = 'from' | 'to';
|
|
20
20
|
export declare const SwapFormKeyHelper: {
|
|
21
21
|
getChainKey: (formType: SwapFormType) => 'fromChain' | 'toChain';
|
|
22
22
|
getTokenKey: (formType: SwapFormType) => 'fromToken' | 'toToken';
|
|
@@ -14,7 +14,6 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
14
14
|
const wallet_management_1 = require("@lifi/wallet-management");
|
|
15
15
|
const react_1 = require("react");
|
|
16
16
|
const WidgetProvider_1 = require("../WidgetProvider");
|
|
17
|
-
const WalletFormUpdate_1 = require("./WalletFormUpdate");
|
|
18
17
|
const stub = () => {
|
|
19
18
|
throw new Error('You forgot to wrap your component in <WalletProvider>.');
|
|
20
19
|
};
|
|
@@ -95,7 +94,7 @@ const WalletProvider = ({ children }) => {
|
|
|
95
94
|
account,
|
|
96
95
|
provider,
|
|
97
96
|
}), [account, addChain, addToken, connect, disconnect, provider, switchChain]);
|
|
98
|
-
return ((0, jsx_runtime_1.
|
|
97
|
+
return ((0, jsx_runtime_1.jsx)(WalletContext.Provider, Object.assign({ value: value }, { children: children })));
|
|
99
98
|
};
|
|
100
99
|
exports.WalletProvider = WalletProvider;
|
|
101
100
|
const extractAccountFromSigner = (signer) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Signer } from '@ethersproject/abstract-signer';
|
|
2
|
+
import type { Provider } from '@ethersproject/providers';
|
|
2
3
|
import type { Token } from '@lifi/sdk';
|
|
3
4
|
import type { Wallet } from '@lifi/wallet-management';
|
|
4
|
-
import type { Signer } from 'ethers';
|
|
5
5
|
export interface WalletContextProps {
|
|
6
6
|
account: WalletAccount;
|
|
7
|
-
provider?:
|
|
7
|
+
provider?: Provider;
|
|
8
8
|
addChain(chainId: number): Promise<boolean>;
|
|
9
9
|
addToken(chainId: number, token: Token): Promise<void>;
|
|
10
10
|
disconnect(): void;
|
|
@@ -15,6 +15,7 @@ exports.WidgetProvider = exports.useWidgetConfig = void 0;
|
|
|
15
15
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
16
|
const sdk_1 = require("@lifi/sdk");
|
|
17
17
|
const react_1 = require("react");
|
|
18
|
+
const stores_1 = require("../../stores");
|
|
18
19
|
const utils_1 = require("../../utils");
|
|
19
20
|
const initialContext = {
|
|
20
21
|
disabledChains: [],
|
|
@@ -59,6 +60,9 @@ const WidgetProvider = (_a) => {
|
|
|
59
60
|
return config;
|
|
60
61
|
}
|
|
61
62
|
}, [config, fromAmount, fromChain, fromToken, toChain, toToken]);
|
|
63
|
+
(0, react_1.useEffect)(() => {
|
|
64
|
+
(0, stores_1.setDefaultSettings)(value);
|
|
65
|
+
}, [value]);
|
|
62
66
|
return ((0, jsx_runtime_1.jsx)(WidgetContext.Provider, Object.assign({ value: value }, { children: children })));
|
|
63
67
|
};
|
|
64
68
|
exports.WidgetProvider = WidgetProvider;
|
|
@@ -7,7 +7,14 @@ export interface RouteExecutionStore {
|
|
|
7
7
|
deleteRoute: (routeId: string) => void;
|
|
8
8
|
deleteRoutes: (type: 'completed' | 'active') => void;
|
|
9
9
|
}
|
|
10
|
-
export declare
|
|
10
|
+
export declare enum RouteExecutionStatus {
|
|
11
|
+
Idle = 0,
|
|
12
|
+
Pending = 1,
|
|
13
|
+
Done = 2,
|
|
14
|
+
Failed = 4,
|
|
15
|
+
Partial = 8,
|
|
16
|
+
Refunded = 16
|
|
17
|
+
}
|
|
11
18
|
export interface RouteExecution {
|
|
12
19
|
route: Route;
|
|
13
20
|
status: RouteExecutionStatus;
|
|
@@ -1,2 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RouteExecutionStatus = void 0;
|
|
4
|
+
var RouteExecutionStatus;
|
|
5
|
+
(function (RouteExecutionStatus) {
|
|
6
|
+
RouteExecutionStatus[RouteExecutionStatus["Idle"] = 0] = "Idle";
|
|
7
|
+
RouteExecutionStatus[RouteExecutionStatus["Pending"] = 1] = "Pending";
|
|
8
|
+
RouteExecutionStatus[RouteExecutionStatus["Done"] = 2] = "Done";
|
|
9
|
+
RouteExecutionStatus[RouteExecutionStatus["Failed"] = 4] = "Failed";
|
|
10
|
+
RouteExecutionStatus[RouteExecutionStatus["Partial"] = 8] = "Partial";
|
|
11
|
+
RouteExecutionStatus[RouteExecutionStatus["Refunded"] = 16] = "Refunded";
|
|
12
|
+
})(RouteExecutionStatus = exports.RouteExecutionStatus || (exports.RouteExecutionStatus = {}));
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useExecutingRoutesIds = void 0;
|
|
4
4
|
const shallow_1 = require("zustand/shallow");
|
|
5
|
+
const types_1 = require("./types");
|
|
5
6
|
const useRouteExecutionStore_1 = require("./useRouteExecutionStore");
|
|
6
7
|
const useExecutingRoutesIds = (address) => {
|
|
7
8
|
return (0, useRouteExecutionStore_1.useRouteExecutionStore)((state) => Object.values(state.routes)
|
|
8
9
|
.filter((item) => item.route.fromAddress === address &&
|
|
9
|
-
(item.status ===
|
|
10
|
+
(item.status === types_1.RouteExecutionStatus.Pending ||
|
|
11
|
+
item.status === types_1.RouteExecutionStatus.Failed))
|
|
10
12
|
.sort((a, b) => {
|
|
11
13
|
var _a, _b, _c, _d;
|
|
12
14
|
return ((_b = (_a = b === null || b === void 0 ? void 0 : b.route.steps[0].execution) === null || _a === void 0 ? void 0 : _a.process[0].startedAt) !== null && _b !== void 0 ? _b : 0) -
|