@lifi/widget 1.18.1 → 1.18.3
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/AppRoutes.js +7 -3
- package/cjs/AppRoutes.js +7 -3
- package/cjs/components/BottomSheet/BottomSheet.js +2 -0
- package/cjs/components/ChainSelect/ChainSelect.js +1 -1
- package/cjs/components/Header/WalletHeader.js +1 -3
- package/cjs/components/SendToWallet/SendToWallet.js +1 -1
- package/cjs/components/SendToWallet/SendToWalletButton.js +9 -1
- package/cjs/components/SwapInput/FormPriceHelperText.js +1 -1
- package/cjs/components/SwapInput/SwapInputAdornment.js +1 -1
- package/cjs/components/SwapRouteCard/SwapRouteCard.js +4 -4
- package/cjs/components/SwapRouteCard/SwapRouteCardSkeleton.js +1 -1
- package/cjs/components/SwapRouteCard/types.d.ts +3 -2
- package/cjs/components/SwapRoutes/SwapRoutesExpanded.js +9 -5
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/hooks/index.d.ts +1 -1
- package/cjs/hooks/index.js +1 -1
- package/cjs/hooks/useGasSufficiency.js +10 -11
- package/cjs/hooks/useScrollableContainer.d.ts +0 -1
- package/cjs/hooks/useScrollableContainer.js +1 -15
- package/cjs/hooks/useTokenAddressBalance.d.ts +5 -0
- package/cjs/hooks/useTokenAddressBalance.js +19 -0
- package/cjs/hooks/useTokenBalance.d.ts +7 -3
- package/cjs/hooks/useTokenBalance.js +87 -9
- package/cjs/hooks/useTokenBalances.d.ts +1 -1
- package/cjs/hooks/useTokenBalances.js +1 -4
- package/cjs/i18n/en/translation.json +1 -1
- package/cjs/pages/SelectTokenPage/SelectTokenPage.js +1 -11
- package/cjs/pages/SwapPage/StatusBottomSheet.js +19 -6
- package/cjs/utils/index.d.ts +1 -0
- package/cjs/utils/index.js +1 -0
- package/cjs/utils/wallet.d.ts +1 -0
- package/cjs/utils/wallet.js +7 -0
- package/components/BottomSheet/BottomSheet.js +2 -0
- package/components/ChainSelect/ChainSelect.js +2 -2
- package/components/Header/WalletHeader.js +2 -4
- package/components/SendToWallet/SendToWallet.js +1 -1
- package/components/SendToWallet/SendToWalletButton.js +10 -2
- package/components/SwapInput/FormPriceHelperText.js +2 -2
- package/components/SwapInput/SwapInputAdornment.js +2 -2
- package/components/SwapRouteCard/SwapRouteCard.js +4 -4
- package/components/SwapRouteCard/SwapRouteCardSkeleton.js +1 -1
- package/components/SwapRouteCard/types.d.ts +3 -2
- package/components/SwapRoutes/SwapRoutesExpanded.js +9 -5
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/index.d.ts +1 -1
- package/hooks/index.js +1 -1
- package/hooks/useGasSufficiency.js +11 -12
- package/hooks/useScrollableContainer.d.ts +0 -1
- package/hooks/useScrollableContainer.js +0 -13
- package/hooks/useTokenAddressBalance.d.ts +5 -0
- package/hooks/useTokenAddressBalance.js +15 -0
- package/hooks/useTokenBalance.d.ts +7 -3
- package/hooks/useTokenBalance.js +88 -10
- package/hooks/useTokenBalances.d.ts +1 -1
- package/hooks/useTokenBalances.js +1 -4
- package/i18n/en/translation.json +1 -1
- package/package.json +5 -5
- package/pages/SelectTokenPage/SelectTokenPage.js +2 -12
- package/pages/SwapPage/StatusBottomSheet.js +19 -6
- package/tsconfig.cjs.tsbuildinfo +1 -1
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
- package/utils/wallet.d.ts +1 -0
- package/utils/wallet.js +3 -0
- package/cjs/components/SwapButton/ButtonTooltip.d.ts +0 -5
- package/cjs/components/SwapButton/ButtonTooltip.js +0 -7
- package/cjs/hooks/useContentHeight.d.ts +0 -1
- package/cjs/hooks/useContentHeight.js +0 -27
- package/components/SwapButton/ButtonTooltip.d.ts +0 -5
- package/components/SwapButton/ButtonTooltip.js +0 -3
- package/hooks/useContentHeight.d.ts +0 -1
- package/hooks/useContentHeight.js +0 -23
|
@@ -26,9 +26,6 @@ export const useTokenBalances = (selectedChainId) => {
|
|
|
26
26
|
Boolean(tokens === null || tokens === void 0 ? void 0 : tokens.length) &&
|
|
27
27
|
Boolean(selectedChainId);
|
|
28
28
|
const { data: tokensWithBalance, isLoading: isBalanceLoading, refetch, } = useQuery(['token-balances', account.address, selectedChainId, tokens === null || tokens === void 0 ? void 0 : tokens.length], ({ queryKey: [, accountAddress] }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
29
|
-
if (!accountAddress || !tokens) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
29
|
const tokenBalances = yield lifi.getTokenBalances(accountAddress, tokens);
|
|
33
30
|
if (!(tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.length)) {
|
|
34
31
|
// Sometimes RPCs (e.g. Arbitrum) don't return balances on first call
|
|
@@ -36,7 +33,7 @@ export const useTokenBalances = (selectedChainId) => {
|
|
|
36
33
|
setRefetchInterval((interval) => interval === defaultRefetchInterval
|
|
37
34
|
? minRefetchInterval
|
|
38
35
|
: interval * 2);
|
|
39
|
-
|
|
36
|
+
throw Error('Could not get tokens balance.');
|
|
40
37
|
}
|
|
41
38
|
const featuredTokenAddresses = new Set(featuredTokens === null || featuredTokens === void 0 ? void 0 : featuredTokens.map((token) => token.address));
|
|
42
39
|
const sortFn = (a, b) => {
|
package/i18n/en/translation.json
CHANGED
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"fundsReceived": "Funds received"
|
|
79
79
|
},
|
|
80
80
|
"message": {
|
|
81
|
-
"fundsReceived": "
|
|
81
|
+
"fundsReceived": "There are now {{amount}} {{tokenSymbol}} in wallet {{walletAddress}} on {{chainName}} chain."
|
|
82
82
|
}
|
|
83
83
|
},
|
|
84
84
|
"info": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/widget",
|
|
3
|
-
"version": "1.18.
|
|
3
|
+
"version": "1.18.3",
|
|
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",
|
|
@@ -45,12 +45,12 @@
|
|
|
45
45
|
"@lifi/sdk": "^1.6.0",
|
|
46
46
|
"@lifi/wallet-management": "^1.1.10",
|
|
47
47
|
"@mui/icons-material": "^5.10.6",
|
|
48
|
-
"@mui/lab": "^5.0.0-alpha.
|
|
49
|
-
"@mui/material": "^5.10.
|
|
48
|
+
"@mui/lab": "^5.0.0-alpha.101",
|
|
49
|
+
"@mui/material": "^5.10.7",
|
|
50
50
|
"@sentry/integrations": "^7.13.0",
|
|
51
51
|
"@sentry/react": "^7.13.0",
|
|
52
52
|
"@sentry/tracing": "^7.13.0",
|
|
53
|
-
"@tanstack/react-query": "^4.
|
|
53
|
+
"@tanstack/react-query": "^4.6.1",
|
|
54
54
|
"@tanstack/react-virtual": "^3.0.0-beta.18",
|
|
55
55
|
"big.js": "^6.2.1",
|
|
56
56
|
"i18next": "^21.9.2",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"mitt": "^3.0.0",
|
|
60
60
|
"react": "^18.2.0",
|
|
61
61
|
"react-dom": "^18.2.0",
|
|
62
|
-
"react-hook-form": "^7.36.
|
|
62
|
+
"react-hook-form": "^7.36.1",
|
|
63
63
|
"react-i18next": "^11.18.6",
|
|
64
64
|
"react-router-dom": "^6.4.1",
|
|
65
65
|
"react-timer-hook": "^3.0.5",
|
|
@@ -1,20 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Box, Container } from '@mui/material';
|
|
3
|
-
import { useLayoutEffect, useRef, useState } from 'react';
|
|
4
3
|
import { ChainSelect } from '../../components/ChainSelect';
|
|
5
4
|
import { TokenList } from '../../components/TokenList';
|
|
6
|
-
import {
|
|
5
|
+
import { useNavigateBack } from '../../hooks';
|
|
7
6
|
import { SearchTokenInput } from './SearchTokenInput';
|
|
8
|
-
const minTokenListHeight = 330;
|
|
9
7
|
export const SelectTokenPage = ({ formType }) => {
|
|
10
|
-
useScrollableOverflowHidden();
|
|
11
8
|
const { navigateBack } = useNavigateBack();
|
|
12
|
-
|
|
13
|
-
const contentHeight = useContentHeight();
|
|
14
|
-
const [tokenListHeight, setTokenListHeight] = useState(0);
|
|
15
|
-
useLayoutEffect(() => {
|
|
16
|
-
var _a, _b;
|
|
17
|
-
setTokenListHeight(Math.max(contentHeight - ((_b = (_a = headerRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) !== null && _b !== void 0 ? _b : 0), minTokenListHeight));
|
|
18
|
-
}, [contentHeight]);
|
|
19
|
-
return (_jsxs(Container, Object.assign({ disableGutters: true }, { children: [_jsxs(Box, Object.assign({ pt: 1, pb: 2, px: 3, ref: headerRef }, { children: [_jsx(ChainSelect, { formType: formType }), _jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(SearchTokenInput, {}) }))] })), _jsx(TokenList, { height: tokenListHeight, onClick: navigateBack, formType: formType })] })));
|
|
9
|
+
return (_jsxs(Container, Object.assign({ disableGutters: true }, { children: [_jsxs(Box, Object.assign({ pt: 1, pb: 2, px: 3 }, { children: [_jsx(ChainSelect, { formType: formType }), _jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(SearchTokenInput, {}) }))] })), _jsx(TokenList, { height: 360, onClick: navigateBack, formType: formType })] })));
|
|
20
10
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/* eslint-disable consistent-return */
|
|
2
3
|
import { Done as DoneIcon, Info as InfoIcon, Warning as WarningIcon, } from '@mui/icons-material';
|
|
3
4
|
import { Box, Button, Typography } from '@mui/material';
|
|
4
5
|
import { useEffect, useRef } from 'react';
|
|
@@ -8,17 +9,18 @@ import { BottomSheet } from '../../components/BottomSheet';
|
|
|
8
9
|
import { Token } from '../../components/Token';
|
|
9
10
|
import { getProcessMessage, useChains, useNavigateBack, useTokenBalance, } from '../../hooks';
|
|
10
11
|
import { SwapFormKey } from '../../providers';
|
|
12
|
+
import { navigationRoutes, shortenWalletAddress } from '../../utils';
|
|
11
13
|
import { IconCircle, IconContainer, iconStyles, } from './StatusBottomSheet.style';
|
|
12
14
|
export const StatusBottomSheet = ({ status, route, }) => {
|
|
13
15
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
14
16
|
const { t } = useTranslation();
|
|
15
|
-
const { navigateBack } = useNavigateBack();
|
|
17
|
+
const { navigateBack, navigate } = useNavigateBack();
|
|
16
18
|
const ref = useRef(null);
|
|
17
19
|
const { getChainById } = useChains();
|
|
18
|
-
const { token, refetch
|
|
20
|
+
const { token, refetch, refetchNewBalance, refetchAllBalances } = useTokenBalance(route.toToken, route.toAddress);
|
|
19
21
|
const { setValue } = useFormContext();
|
|
20
22
|
const clearFromAmount = () => {
|
|
21
|
-
|
|
23
|
+
refetchAllBalances();
|
|
22
24
|
setValue(SwapFormKey.FromAmount, '');
|
|
23
25
|
};
|
|
24
26
|
const handleDone = () => {
|
|
@@ -30,6 +32,13 @@ export const StatusBottomSheet = ({ status, route, }) => {
|
|
|
30
32
|
clearFromAmount();
|
|
31
33
|
(_a = ref.current) === null || _a === void 0 ? void 0 : _a.closeDrawer();
|
|
32
34
|
};
|
|
35
|
+
const handleSeeDetails = () => {
|
|
36
|
+
handleClose();
|
|
37
|
+
navigate(navigationRoutes.swapDetails, {
|
|
38
|
+
state: { routeId: route.id },
|
|
39
|
+
replace: true,
|
|
40
|
+
});
|
|
41
|
+
};
|
|
33
42
|
let title;
|
|
34
43
|
let message;
|
|
35
44
|
switch (status) {
|
|
@@ -39,6 +48,7 @@ export const StatusBottomSheet = ({ status, route, }) => {
|
|
|
39
48
|
amount: token === null || token === void 0 ? void 0 : token.amount,
|
|
40
49
|
tokenSymbol: token === null || token === void 0 ? void 0 : token.symbol,
|
|
41
50
|
chainName: (_a = getChainById(route.toChainId)) === null || _a === void 0 ? void 0 : _a.name,
|
|
51
|
+
walletAddress: shortenWalletAddress(route.toAddress),
|
|
42
52
|
});
|
|
43
53
|
break;
|
|
44
54
|
case 'error': {
|
|
@@ -59,9 +69,12 @@ export const StatusBottomSheet = ({ status, route, }) => {
|
|
|
59
69
|
var _a, _b;
|
|
60
70
|
if ((status === 'success' || status === 'error') &&
|
|
61
71
|
!((_a = ref.current) === null || _a === void 0 ? void 0 : _a.isOpen())) {
|
|
62
|
-
|
|
72
|
+
if (status === 'success') {
|
|
73
|
+
refetchNewBalance();
|
|
74
|
+
refetch();
|
|
75
|
+
}
|
|
63
76
|
(_b = ref.current) === null || _b === void 0 ? void 0 : _b.openDrawer();
|
|
64
77
|
}
|
|
65
|
-
}, [
|
|
66
|
-
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", sx: iconStyles })) : null, status === 'success' ? (_jsx(DoneIcon, { color: "success", sx: iconStyles })) : null, status === 'error' ? (_jsx(WarningIcon, { color: "error", sx: iconStyles })) : 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({ pt: 2, pb: 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.okay') : null, status === 'success' ? t('button.done') : null, status === 'error' ? t('button.tryAgain') : null] })) })), status === 'success' ? (_jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(Button, Object.assign({ variant: "outlined", fullWidth: true, onClick:
|
|
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", sx: iconStyles })) : null, status === 'success' ? (_jsx(DoneIcon, { color: "success", sx: iconStyles })) : null, status === 'error' ? (_jsx(WarningIcon, { color: "error", sx: iconStyles })) : 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({ pt: 2, pb: 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.okay') : null, status === 'success' ? t('button.done') : null, status === 'error' ? t('button.tryAgain') : null] })) })), status === 'success' ? (_jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(Button, Object.assign({ variant: "outlined", fullWidth: true, onClick: handleSeeDetails }, { children: t('button.seeDetails') })) }))) : null] })) })));
|
|
67
80
|
};
|