@lifi/widget 1.23.1 → 1.25.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.
- 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/StepActions/StepActions.js +2 -2
- 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 +12 -9
- 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/useTelemetry.js +3 -1
- package/cjs/hooks/useTools.d.ts +5 -2
- package/cjs/i18n/en.json +3 -1
- package/cjs/i18n/uk.json +11 -6
- package/cjs/pages/SettingsPage/RoutePrioritySelect.js +2 -1
- package/cjs/pages/SettingsPage/SlippageInput.js +2 -1
- package/cjs/pages/SwapHistoryPage/SwapHistoryItem.js +4 -2
- package/cjs/pages/SwapPage/StatusBottomSheet.js +63 -15
- 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/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 +13 -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/StepActions/StepActions.js +2 -2
- 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 +13 -10
- 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/useTelemetry.js +3 -1
- package/hooks/useTools.d.ts +5 -2
- package/i18n/en.json +3 -1
- package/i18n/uk.json +11 -6
- package/package.json +13 -13
- package/pages/SettingsPage/RoutePrioritySelect.js +2 -1
- package/pages/SettingsPage/SlippageInput.js +2 -1
- package/pages/SwapHistoryPage/SwapHistoryItem.js +4 -2
- package/pages/SwapPage/StatusBottomSheet.js +64 -16
- 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/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 +13 -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
|
@@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
5
5
|
import { useTokenAddressBalance } from '../../hooks';
|
|
6
6
|
import { SwapFormKeyHelper } from '../../providers';
|
|
7
7
|
import { formatTokenPrice } from '../../utils';
|
|
8
|
-
export const FormPriceHelperText = ({ formType,
|
|
8
|
+
export const FormPriceHelperText = ({ formType, }) => {
|
|
9
9
|
const { t } = useTranslation();
|
|
10
10
|
const [amount, chainId, tokenAddress] = useWatch({
|
|
11
11
|
name: [
|
|
@@ -1,49 +1,37 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { useRef } from 'react';
|
|
3
|
+
import { useController } from 'react-hook-form';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
|
-
import { useChain, useToken } from '../../hooks';
|
|
6
5
|
import { SwapFormKeyHelper, useWidgetConfig } from '../../providers';
|
|
7
6
|
import { DisabledUI } from '../../types';
|
|
8
|
-
import {
|
|
7
|
+
import { formatAmount } from '../../utils';
|
|
9
8
|
import { Card, CardTitle } from '../Card';
|
|
10
|
-
import {
|
|
9
|
+
import { FitInputText } from './FitInputText';
|
|
11
10
|
import { FormPriceHelperText } from './FormPriceHelperText';
|
|
12
|
-
import { FormControl, Input
|
|
13
|
-
import {
|
|
11
|
+
import { FormControl, Input } from './SwapInput.style';
|
|
12
|
+
import { SwapInputEndAdornment } from './SwapInputEndAdornment';
|
|
13
|
+
import { SwapInputStartAdornment } from './SwapInputStartAdornment';
|
|
14
14
|
export const SwapInput = ({ formType }) => {
|
|
15
15
|
const { t } = useTranslation();
|
|
16
|
-
const { setValue } = useFormContext();
|
|
17
|
-
const { disabledUI } = useWidgetConfig();
|
|
18
|
-
const ref = useRef(null);
|
|
19
16
|
const amountKey = SwapFormKeyHelper.getAmountKey(formType);
|
|
20
|
-
const
|
|
21
|
-
name:
|
|
22
|
-
amountKey,
|
|
23
|
-
SwapFormKeyHelper.getChainKey(formType),
|
|
24
|
-
SwapFormKeyHelper.getTokenKey(formType),
|
|
25
|
-
],
|
|
17
|
+
const { field: { onChange, onBlur, value }, } = useController({
|
|
18
|
+
name: amountKey,
|
|
26
19
|
});
|
|
27
|
-
const {
|
|
28
|
-
const
|
|
29
|
-
const isSelected = !!(chain && token);
|
|
20
|
+
const { disabledUI } = useWidgetConfig();
|
|
21
|
+
const ref = useRef(null);
|
|
30
22
|
const handleChange = (event) => {
|
|
31
23
|
const { value } = event.target;
|
|
32
24
|
const formattedAmount = formatAmount(value, true);
|
|
33
|
-
|
|
34
|
-
shouldTouch: true,
|
|
35
|
-
});
|
|
25
|
+
onChange(formattedAmount);
|
|
36
26
|
};
|
|
37
27
|
const handleBlur = (event) => {
|
|
38
28
|
const { value } = event.target;
|
|
39
29
|
const formattedAmount = formatAmount(value);
|
|
40
|
-
|
|
30
|
+
onChange(formattedAmount);
|
|
31
|
+
onBlur();
|
|
41
32
|
};
|
|
42
|
-
useLayoutEffect(() => {
|
|
43
|
-
fitInputText(maxInputFontSize, minInputFontSize, ref.current);
|
|
44
|
-
}, [amount]);
|
|
45
33
|
const disabled = disabledUI === null || disabledUI === void 0 ? void 0 : disabledUI.includes(DisabledUI.FromAmount);
|
|
46
|
-
return (_jsxs(Card, { children: [_jsx(CardTitle, { children: t('swap.fromAmount') }), _jsxs(FormControl, Object.assign({ fullWidth: true }, { children: [_jsx(Input, { inputRef: ref, size: "small", autoComplete: "off", placeholder: "0", startAdornment:
|
|
34
|
+
return (_jsxs(Card, { children: [_jsx(CardTitle, { children: t('swap.fromAmount') }), _jsxs(FormControl, Object.assign({ fullWidth: true }, { children: [_jsx(Input, { inputRef: ref, size: "small", autoComplete: "off", placeholder: "0", startAdornment: _jsx(SwapInputStartAdornment, { formType: formType }), endAdornment: !disabled ? (_jsx(SwapInputEndAdornment, { formType: formType })) : undefined, inputProps: {
|
|
47
35
|
inputMode: 'decimal',
|
|
48
|
-
}, onChange: handleChange, onBlur: handleBlur, value:
|
|
36
|
+
}, onChange: handleChange, onBlur: handleBlur, value: value, name: amountKey, disabled: disabled, required: true }), _jsx(FormPriceHelperText, { formType: formType })] })), _jsx(FitInputText, { ref: ref, formType: formType })] }));
|
|
49
37
|
};
|
|
@@ -10,7 +10,7 @@ export declare const FormControl: import("@emotion/styled").StyledComponent<{
|
|
|
10
10
|
fullWidth?: boolean | undefined;
|
|
11
11
|
focused?: boolean | undefined;
|
|
12
12
|
hiddenLabel?: boolean | undefined;
|
|
13
|
-
margin?: "
|
|
13
|
+
margin?: "normal" | "none" | "dense" | undefined;
|
|
14
14
|
required?: boolean | undefined;
|
|
15
15
|
size?: "small" | "medium" | undefined;
|
|
16
16
|
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
@@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
5
5
|
import { useTokenAddressBalance } from '../../hooks';
|
|
6
6
|
import { SwapFormKeyHelper } from '../../providers';
|
|
7
7
|
import { Button } from './SwapInputAdornment.style';
|
|
8
|
-
export const
|
|
8
|
+
export const SwapInputEndAdornment = ({ formType }) => {
|
|
9
9
|
const { t } = useTranslation();
|
|
10
10
|
const { setValue } = useFormContext();
|
|
11
11
|
const [chainId, tokenAddress] = useWatch({
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useWatch } from 'react-hook-form';
|
|
3
|
+
import { useChain, useToken } from '../../hooks';
|
|
4
|
+
import { SwapFormKeyHelper } from '../../providers';
|
|
5
|
+
import { TokenAvatar, TokenAvatarSkeleton } from '../TokenAvatar';
|
|
6
|
+
export const SwapInputStartAdornment = ({ formType, }) => {
|
|
7
|
+
const [chainId, tokenAddress] = useWatch({
|
|
8
|
+
name: [
|
|
9
|
+
SwapFormKeyHelper.getChainKey(formType),
|
|
10
|
+
SwapFormKeyHelper.getTokenKey(formType),
|
|
11
|
+
],
|
|
12
|
+
});
|
|
13
|
+
const { chain } = useChain(chainId);
|
|
14
|
+
const { token } = useToken(chainId, tokenAddress);
|
|
15
|
+
const isSelected = !!(chain && token);
|
|
16
|
+
return isSelected ? (_jsx(TokenAvatar, { token: token, chain: chain, sx: { marginLeft: 2 } })) : (_jsx(TokenAvatarSkeleton, { sx: { marginLeft: 2 } }));
|
|
17
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
export declare const Label: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
|
|
3
|
-
align?: "
|
|
3
|
+
align?: "left" | "right" | "inherit" | "center" | "justify" | undefined;
|
|
4
4
|
children?: import("react").ReactNode;
|
|
5
5
|
classes?: Partial<import("@mui/material").TypographyClasses> | undefined;
|
|
6
6
|
gutterBottom?: boolean | undefined;
|
|
@@ -34,7 +34,7 @@ export declare const Header: import("@emotion/styled").StyledComponent<import("@
|
|
|
34
34
|
export declare const Stack: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
|
|
35
35
|
ref?: import("react").Ref<unknown> | undefined;
|
|
36
36
|
children?: import("react").ReactNode;
|
|
37
|
-
direction?: import("@mui/system").ResponsiveStyleValue<"
|
|
37
|
+
direction?: import("@mui/system").ResponsiveStyleValue<"column" | "column-reverse" | "row" | "row-reverse"> | undefined;
|
|
38
38
|
spacing?: import("@mui/system").ResponsiveStyleValue<string | number> | undefined;
|
|
39
39
|
divider?: import("react").ReactNode;
|
|
40
40
|
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
@@ -10,7 +10,7 @@ export declare const TextSecondaryContainer: import("@emotion/styled").StyledCom
|
|
|
10
10
|
connected?: boolean | undefined;
|
|
11
11
|
}, {}, {}>;
|
|
12
12
|
export declare const TextSecondary: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
|
|
13
|
-
align?: "
|
|
13
|
+
align?: "left" | "right" | "inherit" | "center" | "justify" | undefined;
|
|
14
14
|
children?: import("react").ReactNode;
|
|
15
15
|
classes?: Partial<import("@mui/material").TypographyClasses> | undefined;
|
|
16
16
|
gutterBottom?: boolean | undefined;
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
import { useCallback } from 'react';
|
|
2
|
-
import { useFormContext } from 'react-hook-form';
|
|
2
|
+
import { useController, useFormContext } from 'react-hook-form';
|
|
3
3
|
import { SwapFormKeyHelper } from '../../providers';
|
|
4
4
|
export const useTokenSelect = (formType, onClick) => {
|
|
5
|
+
const tokenKey = SwapFormKeyHelper.getTokenKey(formType);
|
|
6
|
+
const { field: { onChange, onBlur }, } = useController({ name: tokenKey });
|
|
5
7
|
const { setValue, getValues } = useFormContext();
|
|
6
8
|
return useCallback((tokenAddress, chainId) => {
|
|
9
|
+
onChange(tokenAddress);
|
|
10
|
+
onBlur();
|
|
7
11
|
const selectedChainId = chainId !== null && chainId !== void 0 ? chainId : getValues(SwapFormKeyHelper.getChainKey(formType));
|
|
8
|
-
setValue(SwapFormKeyHelper.getTokenKey(formType), tokenAddress, {
|
|
9
|
-
shouldTouch: true,
|
|
10
|
-
});
|
|
11
|
-
// Set chain again to trigger URL builder update
|
|
12
|
-
setValue(SwapFormKeyHelper.getChainKey(formType), selectedChainId, {
|
|
13
|
-
shouldTouch: true,
|
|
14
|
-
});
|
|
15
|
-
setValue(SwapFormKeyHelper.getAmountKey(formType), '');
|
|
16
12
|
const oppositeFormType = formType === 'from' ? 'to' : 'from';
|
|
17
13
|
const [selectedOppositeToken, selectedOppositeChainId] = getValues([
|
|
18
14
|
SwapFormKeyHelper.getTokenKey(oppositeFormType),
|
|
@@ -21,9 +17,16 @@ export const useTokenSelect = (formType, onClick) => {
|
|
|
21
17
|
if (selectedOppositeToken === tokenAddress &&
|
|
22
18
|
selectedOppositeChainId === selectedChainId) {
|
|
23
19
|
setValue(SwapFormKeyHelper.getTokenKey(oppositeFormType), '', {
|
|
20
|
+
shouldDirty: true,
|
|
24
21
|
shouldTouch: true,
|
|
25
22
|
});
|
|
26
23
|
}
|
|
24
|
+
// Set chain again to trigger URL builder update
|
|
25
|
+
setValue(SwapFormKeyHelper.getChainKey(formType), selectedChainId, {
|
|
26
|
+
shouldDirty: true,
|
|
27
|
+
shouldTouch: true,
|
|
28
|
+
});
|
|
29
|
+
setValue(SwapFormKeyHelper.getAmountKey(formType), '');
|
|
27
30
|
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
28
|
-
}, [formType, getValues, onClick, setValue]);
|
|
31
|
+
}, [formType, getValues, onBlur, onChange, onClick, setValue]);
|
|
29
32
|
};
|
package/config/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/widget";
|
|
2
|
-
export declare const version = "1.
|
|
2
|
+
export declare const version = "1.25.0";
|
package/config/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/widget';
|
|
2
|
-
export const version = '1.
|
|
2
|
+
export const version = '1.25.0';
|
|
@@ -11,7 +11,7 @@ import { useQuery } from '@tanstack/react-query';
|
|
|
11
11
|
import Big from 'big.js';
|
|
12
12
|
import { useChains } from '.';
|
|
13
13
|
import { useWallet } from '../providers';
|
|
14
|
-
import {
|
|
14
|
+
import { isRouteDone } from '../stores';
|
|
15
15
|
import { useTokenBalance } from './useTokenBalance';
|
|
16
16
|
const refetchInterval = 30000;
|
|
17
17
|
export const useGasSufficiency = (route) => {
|
|
@@ -75,7 +75,7 @@ export const useGasSufficiency = (route) => {
|
|
|
75
75
|
});
|
|
76
76
|
const { data: insufficientFunds, isInitialLoading: insufficientFundsLoading, } = useQuery(['funds-sufficiency-check', account.address, route === null || route === void 0 ? void 0 : route.id], () => __awaiter(void 0, void 0, void 0, function* () {
|
|
77
77
|
var _c, _d, _e, _f;
|
|
78
|
-
if (!account.address || !fromToken || !route ||
|
|
78
|
+
if (!account.address || !fromToken || !route || isRouteDone(route)) {
|
|
79
79
|
return null;
|
|
80
80
|
}
|
|
81
81
|
let currentTokenBalance = Big((_c = fromToken === null || fromToken === void 0 ? void 0 : fromToken.amount) !== null && _c !== void 0 ? _c : 0);
|
|
@@ -11,7 +11,7 @@ import { useMutation } from '@tanstack/react-query';
|
|
|
11
11
|
import { useCallback, useEffect, useRef } from 'react';
|
|
12
12
|
import shallow from 'zustand/shallow';
|
|
13
13
|
import { useLiFi, useWallet } from '../providers';
|
|
14
|
-
import { getUpdatedProcess, isRouteActive,
|
|
14
|
+
import { getUpdatedProcess, isRouteActive, isRouteDone, isRouteFailed, useRouteExecutionStore, } from '../stores';
|
|
15
15
|
import { WidgetEvent } from '../types/events';
|
|
16
16
|
import { deepClone } from '../utils';
|
|
17
17
|
import { useWidgetEvents } from './useWidgetEvents';
|
|
@@ -36,7 +36,7 @@ export const useRouteExecution = (routeId, executeInBackground) => {
|
|
|
36
36
|
process,
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
-
if (
|
|
39
|
+
if (isRouteDone(clonedUpdatedRoute)) {
|
|
40
40
|
emitter.emit(WidgetEvent.RouteExecutionCompleted, clonedUpdatedRoute);
|
|
41
41
|
}
|
|
42
42
|
if (isRouteFailed(clonedUpdatedRoute) && process) {
|
package/hooks/useSwapRoutes.js
CHANGED
|
@@ -16,9 +16,9 @@ import { SwapFormKey, useLiFi, useWallet, useWidgetConfig } from '../providers';
|
|
|
16
16
|
import { useSettings } from '../stores';
|
|
17
17
|
const refetchTime = 60000;
|
|
18
18
|
export const useSwapRoutes = () => {
|
|
19
|
-
var _a;
|
|
19
|
+
var _a, _b;
|
|
20
20
|
const lifi = useLiFi();
|
|
21
|
-
const { variant } = useWidgetConfig();
|
|
21
|
+
const { variant, sdkConfig } = useWidgetConfig();
|
|
22
22
|
const { account, provider } = useWallet();
|
|
23
23
|
const queryClient = useQueryClient();
|
|
24
24
|
const { slippage, enabledBridges, enabledExchanges, routePriority } = useSettings([
|
|
@@ -62,22 +62,25 @@ export const useSwapRoutes = () => {
|
|
|
62
62
|
enabledExchanges,
|
|
63
63
|
routePriority,
|
|
64
64
|
variant,
|
|
65
|
+
(_a = sdkConfig === null || sdkConfig === void 0 ? void 0 : sdkConfig.defaultRouteOptions) === null || _a === void 0 ? void 0 : _a.allowSwitchChain,
|
|
65
66
|
];
|
|
66
|
-
const previousDataUpdatedAt = (
|
|
67
|
+
const previousDataUpdatedAt = (_b = queryClient.getQueryState(queryKey)) === null || _b === void 0 ? void 0 : _b.dataUpdatedAt;
|
|
67
68
|
const refetchInterval = previousDataUpdatedAt
|
|
68
69
|
? Math.min(Math.abs(refetchTime - (Date.now() - previousDataUpdatedAt)), refetchTime)
|
|
69
70
|
: refetchTime;
|
|
70
|
-
const { data, isLoading, isFetching, isFetched, dataUpdatedAt, refetch } = useQuery(queryKey, ({ queryKey: [_, fromAddress, fromChainId, fromTokenAddress, fromTokenAmount, toChainId, toTokenAddress, toAddress, slippage, enabledBridges, enabledExchanges, routePriority, variant,], signal, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
71
|
-
var
|
|
71
|
+
const { data, isLoading, isFetching, isFetched, dataUpdatedAt, refetch } = useQuery(queryKey, ({ queryKey: [_, fromAddress, fromChainId, fromTokenAddress, fromTokenAmount, toChainId, toTokenAddress, toAddress, slippage, enabledBridges, enabledExchanges, routePriority, variant, allowSwitchChain,], signal, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
72
|
+
var _c, _d;
|
|
72
73
|
let toWalletAddress;
|
|
73
74
|
try {
|
|
74
75
|
toWalletAddress =
|
|
75
|
-
(
|
|
76
|
+
(_c = (yield (provider === null || provider === void 0 ? void 0 : provider.resolveName(toAddress)))) !== null && _c !== void 0 ? _c : (isAddress(toAddress) ? toAddress : fromAddress);
|
|
76
77
|
}
|
|
77
|
-
catch (
|
|
78
|
+
catch (_e) {
|
|
78
79
|
toWalletAddress = isAddress(toAddress) ? toAddress : fromAddress;
|
|
79
80
|
}
|
|
80
|
-
const fromAmount = Big(
|
|
81
|
+
const fromAmount = Big(fromTokenAmount)
|
|
82
|
+
.mul(Math.pow(10, ((_d = fromToken === null || fromToken === void 0 ? void 0 : fromToken.decimals) !== null && _d !== void 0 ? _d : 0)))
|
|
83
|
+
.toString();
|
|
81
84
|
const formattedSlippage = parseFloat(slippage) / 100;
|
|
82
85
|
return lifi.getRoutes({
|
|
83
86
|
fromChainId,
|
|
@@ -96,7 +99,7 @@ export const useSwapRoutes = () => {
|
|
|
96
99
|
allow: enabledExchanges,
|
|
97
100
|
},
|
|
98
101
|
order: routePriority,
|
|
99
|
-
allowSwitchChain: variant
|
|
102
|
+
allowSwitchChain: variant === 'refuel' ? false : allowSwitchChain,
|
|
100
103
|
},
|
|
101
104
|
}, { signal });
|
|
102
105
|
}), {
|
package/hooks/useTelemetry.js
CHANGED
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
import { useEffect } from 'react';
|
|
3
3
|
import { initSentry } from '../config/sentry';
|
|
4
4
|
import { name } from '../config/version';
|
|
5
|
+
let warningLogged = false;
|
|
5
6
|
export const useTelemetry = (disabled) => {
|
|
6
7
|
useEffect(() => {
|
|
7
8
|
if (disabled) {
|
|
8
|
-
if (process.env.NODE_ENV === 'development') {
|
|
9
|
+
if (process.env.NODE_ENV === 'development' && !warningLogged) {
|
|
10
|
+
warningLogged = true;
|
|
9
11
|
console.warn(`[${name}] Enable crash reports and diagnostic data to be collected. This helps us to better understand how the widget is performing and where improvements need to be made.`);
|
|
10
12
|
}
|
|
11
13
|
}
|
package/hooks/useTools.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import type { Bridge, Exchange } from '@lifi/sdk';
|
|
2
|
-
|
|
2
|
+
interface WidgetBridge extends Omit<Bridge, 'key'> {
|
|
3
|
+
key: string;
|
|
4
|
+
}
|
|
5
|
+
type FormattedTool<T, K extends keyof T> = Record<string, Pick<T, K>>;
|
|
3
6
|
export declare const useTools: () => {
|
|
4
7
|
tools: import("@lifi/sdk").ToolsResponse | undefined;
|
|
5
8
|
formattedTools: {
|
|
6
|
-
bridges: FormattedTool<
|
|
9
|
+
bridges: FormattedTool<WidgetBridge, "key" | "name" | "logoURI"> | undefined;
|
|
7
10
|
exchanges: FormattedTool<Exchange, "key" | "name" | "logoURI"> | undefined;
|
|
8
11
|
};
|
|
9
12
|
};
|
package/i18n/en.json
CHANGED
|
@@ -148,10 +148,12 @@
|
|
|
148
148
|
"stepSwapAndBridge": "Swap and bridge",
|
|
149
149
|
"success": {
|
|
150
150
|
"message": {
|
|
151
|
-
"
|
|
151
|
+
"swapPartiallySuccessful": "We've tried to complete the swap, but {{tool}} ran out of liquidity for {{tokenSymbol}} token.",
|
|
152
|
+
"swapSuccessful": "There are now {{amount, number(maximumFractionDigits: 4)}} {{tokenSymbol}} in {{walletAddress}} wallet on {{chainName}} chain."
|
|
152
153
|
},
|
|
153
154
|
"title": {
|
|
154
155
|
"gasSwapSuccessful": "Gas swap successful",
|
|
156
|
+
"swapPartiallySuccessful": "Swap partially successful",
|
|
155
157
|
"swapSuccessful": "Swap successful"
|
|
156
158
|
}
|
|
157
159
|
},
|
package/i18n/uk.json
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"delete": "Видалити",
|
|
11
11
|
"disconnectWallet": "Відключити гаманець",
|
|
12
12
|
"done": "Готово",
|
|
13
|
+
"getGas": "Отримати газ",
|
|
13
14
|
"hide": "Сховати",
|
|
14
15
|
"lifiSwap": "LI.FI Swap",
|
|
15
16
|
"light": "Світла",
|
|
@@ -21,6 +22,7 @@
|
|
|
21
22
|
"reviewSwap": "Переглянути своп",
|
|
22
23
|
"seeDetails": "Детальніше",
|
|
23
24
|
"showAll": "Показати всі",
|
|
25
|
+
"startGasSwap": "Почати своп газу",
|
|
24
26
|
"startSwap": "Почати своп",
|
|
25
27
|
"swap": "Своп",
|
|
26
28
|
"tryAgain": "Спробувати ще раз"
|
|
@@ -32,6 +34,8 @@
|
|
|
32
34
|
"header": {
|
|
33
35
|
"activeSwaps": "Активні свопи",
|
|
34
36
|
"from": "Своп з",
|
|
37
|
+
"gas": "Газ",
|
|
38
|
+
"gasSwap": "Своп газу",
|
|
35
39
|
"routes": "Ви отримуєте",
|
|
36
40
|
"selectChain": "Оберіть чейн",
|
|
37
41
|
"selectWallet": "Виберіть свій гаманець",
|
|
@@ -64,7 +68,7 @@
|
|
|
64
68
|
"slippage": "Прослизання"
|
|
65
69
|
},
|
|
66
70
|
"swap": {
|
|
67
|
-
"crossStepDetails": "
|
|
71
|
+
"crossStepDetails": "Брідж з {{from}} до {{to}} через {{tool}}",
|
|
68
72
|
"error": {
|
|
69
73
|
"message": {
|
|
70
74
|
"slippageTooLarge": "Прослизання більше визначеного порогу. Будь ласка, оберіть новий маршрут, щоб отримати свіжу пропозицію.",
|
|
@@ -85,7 +89,7 @@
|
|
|
85
89
|
"walletEnsAddressInvalid": "Адреса гаманця недійсна або мережа не підтримує ENS."
|
|
86
90
|
}
|
|
87
91
|
},
|
|
88
|
-
"estimatedTime": "{{value}}
|
|
92
|
+
"estimatedTime": "{{value}}х",
|
|
89
93
|
"featuredTokens": "Рекомендовані токени",
|
|
90
94
|
"from": "З",
|
|
91
95
|
"fromAmount": "Ви платите",
|
|
@@ -139,14 +143,15 @@
|
|
|
139
143
|
"selectChainAndToken": "Виберіть чейн і токен",
|
|
140
144
|
"selectToken": "Токен",
|
|
141
145
|
"sendToWallet": "Надіслати на інший гаманець",
|
|
142
|
-
"stepBridge": "
|
|
146
|
+
"stepBridge": "Брідж",
|
|
143
147
|
"stepSwap": "Своп",
|
|
144
|
-
"stepSwapAndBridge": "Своп
|
|
148
|
+
"stepSwapAndBridge": "Своп та брідж",
|
|
145
149
|
"success": {
|
|
146
150
|
"message": {
|
|
147
151
|
"swapSuccessful": "Зараз у гаманці {{walletAddress}} на чейні {{chainName}} є {{amount, number(maximumFractionDigits: 4)}} {{tokenSymbol}}."
|
|
148
152
|
},
|
|
149
153
|
"title": {
|
|
154
|
+
"gasSwapSuccessful": "Своп газу успішний",
|
|
150
155
|
"swapSuccessful": "Своп успішний"
|
|
151
156
|
}
|
|
152
157
|
},
|
|
@@ -154,10 +159,10 @@
|
|
|
154
159
|
"swapStepDetails": "Своп на {{chain}} через {{tool}}",
|
|
155
160
|
"swapping": "Обмін",
|
|
156
161
|
"tags": {
|
|
157
|
-
"ALTERNATIVE": "
|
|
162
|
+
"ALTERNATIVE": "АЛЬТЕРНАТИВА",
|
|
158
163
|
"CHEAPEST": "ДЕШЕВИЙ",
|
|
159
164
|
"FASTEST": "ШВИДКИЙ",
|
|
160
|
-
"RECOMMENDED": "
|
|
165
|
+
"RECOMMENDED": "РЕКОМЕНДУЄМО",
|
|
161
166
|
"SAFEST": "БЕЗПЕЧНИЙ"
|
|
162
167
|
},
|
|
163
168
|
"to": "До",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/widget",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.25.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",
|
|
@@ -42,25 +42,25 @@
|
|
|
42
42
|
"@ethersproject/address": "^5.7.0",
|
|
43
43
|
"@ethersproject/experimental": "^5.7.0",
|
|
44
44
|
"@ethersproject/providers": "^5.7.2",
|
|
45
|
-
"@lifi/sdk": "^1.6.
|
|
46
|
-
"@lifi/wallet-management": "^1.1
|
|
47
|
-
"@mui/icons-material": "^5.10.
|
|
48
|
-
"@mui/lab": "^5.0.0-alpha.
|
|
49
|
-
"@mui/material": "^5.10.
|
|
50
|
-
"@sentry/integrations": "^7.
|
|
51
|
-
"@sentry/react": "^7.
|
|
52
|
-
"@sentry/tracing": "^7.
|
|
53
|
-
"@tanstack/react-query": "^4.
|
|
54
|
-
"@tanstack/react-virtual": "^3.0.0-beta.
|
|
45
|
+
"@lifi/sdk": "^1.6.4",
|
|
46
|
+
"@lifi/wallet-management": "^1.2.1",
|
|
47
|
+
"@mui/icons-material": "^5.10.14",
|
|
48
|
+
"@mui/lab": "^5.0.0-alpha.108",
|
|
49
|
+
"@mui/material": "^5.10.14",
|
|
50
|
+
"@sentry/integrations": "^7.19.0",
|
|
51
|
+
"@sentry/react": "^7.19.0",
|
|
52
|
+
"@sentry/tracing": "^7.19.0",
|
|
53
|
+
"@tanstack/react-query": "^4.16.1",
|
|
54
|
+
"@tanstack/react-virtual": "^3.0.0-beta.23",
|
|
55
55
|
"big.js": "^6.2.1",
|
|
56
|
-
"i18next": "
|
|
56
|
+
"i18next": "22.0.4",
|
|
57
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.39.
|
|
63
|
+
"react-hook-form": "^7.39.4",
|
|
64
64
|
"react-i18next": "^12.0.0",
|
|
65
65
|
"react-router-dom": "^6.4.3",
|
|
66
66
|
"react-timer-hook": "^3.0.5",
|
|
@@ -10,7 +10,8 @@ export const RoutePrioritySelect = () => {
|
|
|
10
10
|
const { t } = useTranslation();
|
|
11
11
|
const setValue = useSettingsStore((state) => state.setValue);
|
|
12
12
|
const { routePriority } = useSettings(['routePriority']);
|
|
13
|
-
|
|
13
|
+
const value = routePriority !== null && routePriority !== void 0 ? routePriority : '';
|
|
14
|
+
return (_jsxs(Card, { children: [_jsx(CardTitle, { children: t(`settings.routePriority`) }), _jsx(FormControl, Object.assign({ fullWidth: true }, { children: _jsx(Select, Object.assign({ MenuProps: { elevation: 2 }, value: value, onChange: (event) => setValue('routePriority', event.target.value), IconComponent: KeyboardArrowDownIcon, dense: true }, { children: Orders.map((order) => {
|
|
14
15
|
const tag = t(`swap.tags.${order.toUpperCase()}`);
|
|
15
16
|
const tagName = `${tag[0]}${tag.slice(1).toLowerCase()}`;
|
|
16
17
|
return (_jsx(MenuItem, Object.assign({ value: order }, { children: tagName }), order));
|
|
@@ -19,7 +19,8 @@ export const SlippageInput = () => {
|
|
|
19
19
|
const { value } = event.target;
|
|
20
20
|
setValue('slippage', formatSlippage(value, defaultValue.current));
|
|
21
21
|
};
|
|
22
|
+
const value = slippage !== null && slippage !== void 0 ? slippage : '';
|
|
22
23
|
return (_jsxs(Card, { children: [_jsx(CardTitle, { children: t(`settings.slippage`) }), _jsx(FormControl, Object.assign({ fullWidth: true }, { children: _jsx(Input, { size: "small", placeholder: t(`settings.slippage`), endAdornment: _jsx(InputAdornment, Object.assign({ position: "end" }, { children: "%" })), autoComplete: "off", inputProps: {
|
|
23
24
|
inputMode: 'decimal',
|
|
24
|
-
}, onChange: handleChange, onBlur: handleBlur, value:
|
|
25
|
+
}, onChange: handleChange, onBlur: handleBlur, value: value }) }))] }));
|
|
25
26
|
};
|
|
@@ -6,7 +6,7 @@ import { Card } from '../../components/Card';
|
|
|
6
6
|
import { Token, TokenDivider } from '../../components/Token';
|
|
7
7
|
import { navigationRoutes } from '../../utils';
|
|
8
8
|
export const SwapHistoryItem = ({ route }) => {
|
|
9
|
-
var _a, _b, _c, _d, _e;
|
|
9
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
10
10
|
const { i18n } = useTranslation();
|
|
11
11
|
const navigate = useNavigate();
|
|
12
12
|
const handleClick = () => {
|
|
@@ -15,11 +15,13 @@ export const SwapHistoryItem = ({ route }) => {
|
|
|
15
15
|
});
|
|
16
16
|
};
|
|
17
17
|
const startedAt = new Date((_b = (_a = route.steps[0].execution) === null || _a === void 0 ? void 0 : _a.process[0].startedAt) !== null && _b !== void 0 ? _b : 0);
|
|
18
|
+
const fromToken = Object.assign(Object.assign({}, route.fromToken), { amount: route.fromAmount });
|
|
19
|
+
const toToken = Object.assign(Object.assign({}, ((_e = (_d = (_c = route.steps.at(-1)) === null || _c === void 0 ? void 0 : _c.execution) === null || _d === void 0 ? void 0 : _d.toToken) !== null && _e !== void 0 ? _e : route.toToken)), { amount: (_h = (_g = (_f = route.steps.at(-1)) === null || _f === void 0 ? void 0 : _f.execution) === null || _g === void 0 ? void 0 : _g.toAmount) !== null && _h !== void 0 ? _h : route.toAmount });
|
|
18
20
|
return (_jsxs(Card, Object.assign({ onClick: handleClick }, { children: [_jsxs(Box, Object.assign({ sx: {
|
|
19
21
|
display: 'flex',
|
|
20
22
|
flex: 1,
|
|
21
23
|
justifyContent: 'space-between',
|
|
22
24
|
}, pt: 1.75, px: 2 }, { 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, {
|
|
23
25
|
timeStyle: 'short',
|
|
24
|
-
}).format(startedAt) }))] })), _jsxs(Box, Object.assign({ py: 1 }, { children: [_jsx(Token, { token:
|
|
26
|
+
}).format(startedAt) }))] })), _jsxs(Box, Object.assign({ py: 1 }, { children: [_jsx(Token, { token: fromToken, px: 2, pt: 1, connected: true }), _jsx(TokenDivider, {}), _jsx(Token, { token: toToken, px: 2, pt: 0.5, pb: 1 })] }))] })));
|
|
25
27
|
};
|