@lifi/widget 1.18.2 → 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/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/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
package/AppRoutes.js
CHANGED
|
@@ -56,10 +56,14 @@ export const AppRoutes = () => {
|
|
|
56
56
|
path: navigationRoutes.swapHistory,
|
|
57
57
|
element: _jsx(SwapHistoryPage, {}),
|
|
58
58
|
},
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
...[
|
|
60
|
+
`${navigationRoutes.swapHistory}/${navigationRoutes.swapDetails}`,
|
|
61
|
+
`${navigationRoutes.swapExecution}/${navigationRoutes.swapDetails}`,
|
|
62
|
+
`${navigationRoutes.swapRoutes}/${navigationRoutes.swapExecution}/${navigationRoutes.swapDetails}`,
|
|
63
|
+
].map((path) => ({
|
|
64
|
+
path,
|
|
61
65
|
element: _jsx(SwapDetailsPage, {}),
|
|
62
|
-
},
|
|
66
|
+
})),
|
|
63
67
|
...[
|
|
64
68
|
navigationRoutes.selectWallet,
|
|
65
69
|
`${navigationRoutes.swapExecution}/${navigationRoutes.selectWallet}`,
|
package/cjs/AppRoutes.js
CHANGED
|
@@ -59,10 +59,14 @@ const AppRoutes = () => {
|
|
|
59
59
|
path: utils_1.navigationRoutes.swapHistory,
|
|
60
60
|
element: (0, jsx_runtime_1.jsx)(SwapHistoryPage_1.SwapHistoryPage, {}),
|
|
61
61
|
},
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
...[
|
|
63
|
+
`${utils_1.navigationRoutes.swapHistory}/${utils_1.navigationRoutes.swapDetails}`,
|
|
64
|
+
`${utils_1.navigationRoutes.swapExecution}/${utils_1.navigationRoutes.swapDetails}`,
|
|
65
|
+
`${utils_1.navigationRoutes.swapRoutes}/${utils_1.navigationRoutes.swapExecution}/${utils_1.navigationRoutes.swapDetails}`,
|
|
66
|
+
].map((path) => ({
|
|
67
|
+
path,
|
|
64
68
|
element: (0, jsx_runtime_1.jsx)(SwapDetailsPage_1.SwapDetailsPage, {}),
|
|
65
|
-
},
|
|
69
|
+
})),
|
|
66
70
|
...[
|
|
67
71
|
utils_1.navigationRoutes.selectWallet,
|
|
68
72
|
`${utils_1.navigationRoutes.swapExecution}/${utils_1.navigationRoutes.selectWallet}`,
|
|
@@ -11,9 +11,11 @@ exports.BottomSheet = (0, react_1.forwardRef)(({ elementRef, children, open }, r
|
|
|
11
11
|
const containerElement = (0, hooks_1.useScrollableContainer)();
|
|
12
12
|
const openDrawer = (0, react_1.useCallback)(() => {
|
|
13
13
|
setDrawerOpen(true);
|
|
14
|
+
openRef.current = true;
|
|
14
15
|
}, []);
|
|
15
16
|
const closeDrawer = (0, react_1.useCallback)(() => {
|
|
16
17
|
setDrawerOpen(false);
|
|
18
|
+
openRef.current = false;
|
|
17
19
|
}, []);
|
|
18
20
|
(0, react_1.useImperativeHandle)(ref, () => ({
|
|
19
21
|
isOpen: () => openRef.current,
|
|
@@ -25,7 +25,7 @@ const ChainSelect = ({ formType }) => {
|
|
|
25
25
|
const chainsToHide = ((_a = chains === null || chains === void 0 ? void 0 : chains.length) !== null && _a !== void 0 ? _a : 0) - stores_1.maxChainToOrder;
|
|
26
26
|
return ((0, jsx_runtime_1.jsxs)(ChainSelect_style_1.ChainContainer, { children: [isLoading
|
|
27
27
|
? Array.from({ length: stores_1.maxChainToOrder + 1 }).map((_, index) => ((0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "rectangular", width: 56, height: 56, sx: { borderRadius: 1 } }, index)))
|
|
28
|
-
: getChains().map((chain) => ((0, jsx_runtime_1.jsx)(ChainSelect_style_1.ChainCard, Object.assign({ onClick: () => setCurrentChain(chain.id), variant: chainId === chain.id ? 'selected' : 'default' }, { children: (0, jsx_runtime_1.jsx)(material_1.Avatar, Object.assign({ src: chain.logoURI, alt: chain.key, sx: { width: 40, height: 40 } }, { children: chain.name[0] })) }), chain.id))), chainsToHide > 0 ? ((0, jsx_runtime_1.jsx)(ChainSelect_style_1.ChainCard, Object.assign({ onClick: showAllChains }, { children: (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ sx: {
|
|
28
|
+
: getChains().map((chain) => ((0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: chain.name, placement: "top", enterDelay: 500, enterNextDelay: 500, arrow: true }, { children: (0, jsx_runtime_1.jsx)(ChainSelect_style_1.ChainCard, Object.assign({ onClick: () => setCurrentChain(chain.id), variant: chainId === chain.id ? 'selected' : 'default' }, { children: (0, jsx_runtime_1.jsx)(material_1.Avatar, Object.assign({ src: chain.logoURI, alt: chain.key, sx: { width: 40, height: 40 } }, { children: chain.name[0] })) })) }), chain.id))), chainsToHide > 0 ? ((0, jsx_runtime_1.jsx)(ChainSelect_style_1.ChainCard, Object.assign({ onClick: showAllChains }, { children: (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ sx: {
|
|
29
29
|
width: 40,
|
|
30
30
|
height: 40,
|
|
31
31
|
display: 'grid',
|
|
@@ -21,9 +21,7 @@ const Header_style_1 = require("./Header.style");
|
|
|
21
21
|
const WalletHeader = () => {
|
|
22
22
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
23
23
|
const { account, disconnect } = (0, providers_1.useWallet)();
|
|
24
|
-
const walletAddress = account.address
|
|
25
|
-
? `${account.address.substring(0, 7)}...${account.address.substring(account.address.length - 7)}`
|
|
26
|
-
: null;
|
|
24
|
+
const walletAddress = (0, utils_1.shortenWalletAddress)(account.address);
|
|
27
25
|
return ((0, jsx_runtime_1.jsx)(Header_style_1.HeaderAppBar, Object.assign({ elevation: 0 }, { children: walletAddress ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ sx: {
|
|
28
26
|
display: 'flex',
|
|
29
27
|
flex: 1,
|
|
@@ -45,5 +45,5 @@ exports.SendToWallet = (0, react_1.forwardRef)((props, ref) => {
|
|
|
45
45
|
}),
|
|
46
46
|
onBlur: () => trigger(providers_1.SwapFormKey.ToAddress),
|
|
47
47
|
});
|
|
48
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Collapse, Object.assign({ timeout: 225, in: showSendToWallet }, { children: (0, jsx_runtime_1.jsxs)(Card_1.Card, Object.assign({}, props, { ref: ref }, { children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, { children: t('swap.sendToWallet') }), (0, jsx_runtime_1.jsxs)(SendToWallet_style_1.FormControl, Object.assign({ fullWidth: true, sx: { paddingTop: '6px', paddingBottom: '5px' } }, { children: [(0, jsx_runtime_1.jsx)(SendToWallet_style_1.Input, { ref: inputRef, size: "small", autoComplete: "off", autoCorrect: "off", autoCapitalize: "off", spellCheck: "false", onChange: onChange, onBlur: onBlur, name: name, placeholder: t('swap.walletAddressOrEns') }), (0, jsx_runtime_1.jsx)(material_1.FormHelperText, Object.assign({ error: !!errors.toAddress }, { children: (_a = errors.toAddress) === null || _a === void 0 ? void 0 : _a.message }))] }))] })) })));
|
|
48
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Collapse, Object.assign({ timeout: 225, unmountOnExit: true, mountOnEnter: true, in: showSendToWallet }, { children: (0, jsx_runtime_1.jsxs)(Card_1.Card, Object.assign({}, props, { ref: ref }, { children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, { children: t('swap.sendToWallet') }), (0, jsx_runtime_1.jsxs)(SendToWallet_style_1.FormControl, Object.assign({ fullWidth: true, sx: { paddingTop: '6px', paddingBottom: '5px' } }, { children: [(0, jsx_runtime_1.jsx)(SendToWallet_style_1.Input, { ref: inputRef, size: "small", autoComplete: "off", autoCorrect: "off", autoCapitalize: "off", spellCheck: "false", onChange: onChange, onBlur: onBlur, name: name, placeholder: t('swap.walletAddressOrEns'), autoFocus: true }), (0, jsx_runtime_1.jsx)(material_1.FormHelperText, Object.assign({ error: !!errors.toAddress }, { children: (_a = errors.toAddress) === null || _a === void 0 ? void 0 : _a.message }))] }))] })) })));
|
|
49
49
|
});
|
|
@@ -4,6 +4,7 @@ exports.SendToWalletButton = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const icons_material_1 = require("@mui/icons-material");
|
|
6
6
|
const material_1 = require("@mui/material");
|
|
7
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
7
8
|
const react_i18next_1 = require("react-i18next");
|
|
8
9
|
const providers_1 = require("../../providers");
|
|
9
10
|
const stores_1 = require("../../stores");
|
|
@@ -11,12 +12,19 @@ const store_1 = require("./store");
|
|
|
11
12
|
const SendToWalletButton = () => {
|
|
12
13
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
13
14
|
const { account } = (0, providers_1.useWallet)();
|
|
15
|
+
const { setValue } = (0, react_hook_form_1.useFormContext)();
|
|
14
16
|
const { showDestinationWallet } = (0, stores_1.useSettings)(['showDestinationWallet']);
|
|
15
17
|
const { showSendToWallet, toggleSendToWallet } = (0, store_1.useSendToWalletStore)();
|
|
16
18
|
if (!showDestinationWallet || !account.isActive) {
|
|
17
19
|
return null;
|
|
18
20
|
}
|
|
19
|
-
|
|
21
|
+
const handleClick = () => {
|
|
22
|
+
if (showSendToWallet) {
|
|
23
|
+
setValue(providers_1.SwapFormKey.ToAddress, '');
|
|
24
|
+
}
|
|
25
|
+
toggleSendToWallet();
|
|
26
|
+
};
|
|
27
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: t('swap.sendToWallet'), placement: "bottom-end", enterDelay: 500, enterNextDelay: 500, arrow: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ variant: showSendToWallet ? 'contained' : 'text', onClick: handleClick, sx: {
|
|
20
28
|
minWidth: 48,
|
|
21
29
|
marginLeft: 1,
|
|
22
30
|
} }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.WalletOutlined, {}) })) })));
|
|
@@ -17,7 +17,7 @@ const FormPriceHelperText = ({ formType, selected }) => {
|
|
|
17
17
|
providers_1.SwapFormKeyHelper.getTokenKey(formType),
|
|
18
18
|
],
|
|
19
19
|
});
|
|
20
|
-
const { token, isLoading } = (0, hooks_1.
|
|
20
|
+
const { token, isLoading } = (0, hooks_1.useTokenAddressBalance)(chainId, tokenAddress);
|
|
21
21
|
const fromAmountTokenPrice = (0, utils_1.formatTokenPrice)(amount, token === null || token === void 0 ? void 0 : token.priceUSD);
|
|
22
22
|
return ((0, jsx_runtime_1.jsxs)(material_1.FormHelperText, Object.assign({ component: "div", sx: { display: 'flex', justifyContent: 'space-between', margin: 0 } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ color: fromAmountTokenPrice ? 'text.secondary' : 'grey.600', fontWeight: 400, fontSize: 12, marginLeft: selected ? 8 : 2, lineHeight: 1.3334, flex: 1, sx: {
|
|
23
23
|
wordBreak: 'break-word',
|
|
@@ -17,7 +17,7 @@ const SwapInputAdornment = ({ formType }) => {
|
|
|
17
17
|
providers_1.SwapFormKeyHelper.getTokenKey(formType),
|
|
18
18
|
],
|
|
19
19
|
});
|
|
20
|
-
const { token, isLoading } = (0, hooks_1.
|
|
20
|
+
const { token, isLoading } = (0, hooks_1.useTokenAddressBalance)(chainId, tokenAddress);
|
|
21
21
|
const handleMax = () => {
|
|
22
22
|
var _a;
|
|
23
23
|
setValue(providers_1.SwapFormKeyHelper.getAmountKey(formType), (_a = token === null || token === void 0 ? void 0 : token.amount) !== null && _a !== void 0 ? _a : '');
|
package/cjs/config/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/widget";
|
|
2
|
-
export declare const version = "1.18.
|
|
2
|
+
export declare const version = "1.18.3";
|
package/cjs/config/version.js
CHANGED
package/cjs/hooks/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * from './useChain';
|
|
2
2
|
export * from './useChains';
|
|
3
|
-
export * from './useContentHeight';
|
|
4
3
|
export * from './useDebouncedWatch';
|
|
5
4
|
export * from './useFeaturedTokens';
|
|
6
5
|
export * from './useGasSufficiency';
|
|
@@ -12,6 +11,7 @@ export * from './useScrollableContainer';
|
|
|
12
11
|
export * from './useSwapRoutes';
|
|
13
12
|
export * from './useTelemetry';
|
|
14
13
|
export * from './useToken';
|
|
14
|
+
export * from './useTokenAddressBalance';
|
|
15
15
|
export * from './useTokenBalance';
|
|
16
16
|
export * from './useTokenBalances';
|
|
17
17
|
export * from './useTokens';
|
package/cjs/hooks/index.js
CHANGED
|
@@ -16,7 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./useChain"), exports);
|
|
18
18
|
__exportStar(require("./useChains"), exports);
|
|
19
|
-
__exportStar(require("./useContentHeight"), exports);
|
|
20
19
|
__exportStar(require("./useDebouncedWatch"), exports);
|
|
21
20
|
__exportStar(require("./useFeaturedTokens"), exports);
|
|
22
21
|
__exportStar(require("./useGasSufficiency"), exports);
|
|
@@ -28,6 +27,7 @@ __exportStar(require("./useScrollableContainer"), exports);
|
|
|
28
27
|
__exportStar(require("./useSwapRoutes"), exports);
|
|
29
28
|
__exportStar(require("./useTelemetry"), exports);
|
|
30
29
|
__exportStar(require("./useToken"), exports);
|
|
30
|
+
__exportStar(require("./useTokenAddressBalance"), exports);
|
|
31
31
|
__exportStar(require("./useTokenBalance"), exports);
|
|
32
32
|
__exportStar(require("./useTokenBalances"), exports);
|
|
33
33
|
__exportStar(require("./useTokens"), exports);
|
|
@@ -14,16 +14,15 @@ const big_js_1 = require("big.js");
|
|
|
14
14
|
const react_1 = require("react");
|
|
15
15
|
const _1 = require(".");
|
|
16
16
|
const providers_1 = require("../providers");
|
|
17
|
-
const
|
|
17
|
+
const useTokenBalance_1 = require("./useTokenBalance");
|
|
18
18
|
const useGasSufficiency = (route) => {
|
|
19
|
-
const lifi = (0, providers_1.useLiFi)();
|
|
20
19
|
const { account } = (0, providers_1.useWallet)();
|
|
21
20
|
const { getChainById } = (0, _1.useChains)();
|
|
22
|
-
const {
|
|
21
|
+
const { token: fromToken, getTokenBalancesWithRetry } = (0, useTokenBalance_1.useTokenBalance)(route === null || route === void 0 ? void 0 : route.fromToken);
|
|
23
22
|
const [insufficientGas, setInsufficientGas] = (0, react_1.useState)();
|
|
24
23
|
const checkInsufficientGas = (0, react_1.useCallback)(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
24
|
var _a, _b;
|
|
26
|
-
if (!account.
|
|
25
|
+
if (!account.address || !route) {
|
|
27
26
|
setInsufficientGas(undefined);
|
|
28
27
|
return;
|
|
29
28
|
}
|
|
@@ -50,7 +49,7 @@ const useGasSufficiency = (route) => {
|
|
|
50
49
|
if (route.fromToken.address === ((_a = gasCosts[route.fromChainId]) === null || _a === void 0 ? void 0 : _a.token.address)) {
|
|
51
50
|
gasCosts[route.fromChainId].tokenAmount = (_b = gasCosts[route.fromChainId]) === null || _b === void 0 ? void 0 : _b.gasAmount.plus((0, big_js_1.default)(route.fromAmount).div(Math.pow(10, route.fromToken.decimals)));
|
|
52
51
|
}
|
|
53
|
-
const tokenBalances = yield
|
|
52
|
+
const tokenBalances = yield getTokenBalancesWithRetry(account.address, Object.values(gasCosts).map((item) => item.token));
|
|
54
53
|
if (!(tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.length)) {
|
|
55
54
|
setInsufficientGas(undefined);
|
|
56
55
|
return;
|
|
@@ -66,22 +65,22 @@ const useGasSufficiency = (route) => {
|
|
|
66
65
|
const insufficientFromChainGasAmount = insufficientFromChainGas
|
|
67
66
|
? (_f = (_e = gasCosts[chainId].tokenAmount) === null || _e === void 0 ? void 0 : _e.minus(gasTokenBalance)) !== null && _f !== void 0 ? _f : gasCosts[chainId].gasAmount.minus(gasTokenBalance)
|
|
68
67
|
: undefined;
|
|
69
|
-
gasCosts[chainId] = Object.assign(Object.assign({}, gasCosts[chainId]), { insufficient: insufficientFromChainGas, insufficientAmount: insufficientFromChainGasAmount });
|
|
68
|
+
gasCosts[chainId] = Object.assign(Object.assign({}, gasCosts[chainId]), { insufficient: insufficientFromChainGas, insufficientAmount: insufficientFromChainGasAmount === null || insufficientFromChainGasAmount === void 0 ? void 0 : insufficientFromChainGasAmount.round(5, big_js_1.default.roundUp) });
|
|
70
69
|
}
|
|
71
70
|
});
|
|
72
71
|
const gasCostResult = Object.values(gasCosts).filter((gasCost) => gasCost.insufficient);
|
|
73
72
|
setInsufficientGas(gasCostResult);
|
|
74
|
-
}), [account.address,
|
|
73
|
+
}), [account.address, getChainById, getTokenBalancesWithRetry, route]);
|
|
75
74
|
const insufficientFunds = (0, react_1.useMemo)(() => {
|
|
76
|
-
var _a
|
|
77
|
-
if (!account.isActive || !
|
|
75
|
+
var _a;
|
|
76
|
+
if (!account.isActive || !fromToken || !route) {
|
|
78
77
|
return false;
|
|
79
78
|
}
|
|
80
|
-
const balance = (0, big_js_1.default)((
|
|
79
|
+
const balance = (0, big_js_1.default)((_a = fromToken === null || fromToken === void 0 ? void 0 : fromToken.amount) !== null && _a !== void 0 ? _a : 0);
|
|
81
80
|
return (0, big_js_1.default)(route.fromAmount)
|
|
82
81
|
.div(Math.pow(10, route.fromToken.decimals))
|
|
83
82
|
.gt(balance);
|
|
84
|
-
}, [account.isActive,
|
|
83
|
+
}, [account.isActive, fromToken, route]);
|
|
85
84
|
(0, react_1.useEffect)(() => {
|
|
86
85
|
checkInsufficientGas();
|
|
87
86
|
}, [checkInsufficientGas]);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.useScrollableContainer = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
6
|
const useScrollableContainer = () => {
|
|
@@ -13,17 +13,3 @@ const useScrollableContainer = () => {
|
|
|
13
13
|
return containerElement;
|
|
14
14
|
};
|
|
15
15
|
exports.useScrollableContainer = useScrollableContainer;
|
|
16
|
-
const useScrollableOverflowHidden = () => {
|
|
17
|
-
(0, react_1.useLayoutEffect)(() => {
|
|
18
|
-
const element = document.getElementById(utils_1.ElementId.ScrollableContainer);
|
|
19
|
-
if (element) {
|
|
20
|
-
element.style.overflowY = 'hidden';
|
|
21
|
-
}
|
|
22
|
-
return () => {
|
|
23
|
-
if (element) {
|
|
24
|
-
element.style.overflowY = 'auto';
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
}, []);
|
|
28
|
-
};
|
|
29
|
-
exports.useScrollableOverflowHidden = useScrollableOverflowHidden;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const useTokenAddressBalance: (chainId?: number, tokenAddress?: string) => {
|
|
2
|
+
token: import("..").Token | undefined;
|
|
3
|
+
isLoading: boolean;
|
|
4
|
+
refetch: <TPageData>(options?: (import("@tanstack/query-core").RefetchOptions & import("@tanstack/query-core").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/query-core").QueryObserverResult<import("..").Token[], unknown>>;
|
|
5
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useTokenAddressBalance = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const useTokenBalances_1 = require("./useTokenBalances");
|
|
6
|
+
const useTokenAddressBalance = (chainId, tokenAddress) => {
|
|
7
|
+
const { tokens, tokensWithBalance, isBalanceLoading, refetch } = (0, useTokenBalances_1.useTokenBalances)(chainId);
|
|
8
|
+
const token = (0, react_1.useMemo)(() => {
|
|
9
|
+
var _a;
|
|
10
|
+
const token = (_a = (tokensWithBalance !== null && tokensWithBalance !== void 0 ? tokensWithBalance : tokens)) === null || _a === void 0 ? void 0 : _a.find((token) => token.address === tokenAddress && token.chainId === chainId);
|
|
11
|
+
return token;
|
|
12
|
+
}, [chainId, tokenAddress, tokens, tokensWithBalance]);
|
|
13
|
+
return {
|
|
14
|
+
token,
|
|
15
|
+
isLoading: isBalanceLoading,
|
|
16
|
+
refetch,
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
exports.useTokenAddressBalance = useTokenAddressBalance;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import type { Token, TokenAmount } from '@lifi/sdk';
|
|
2
|
+
export declare const useTokenBalance: (token?: Token, accountAddress?: string) => {
|
|
3
|
+
token: TokenAmount | undefined;
|
|
3
4
|
isLoading: boolean;
|
|
4
|
-
refetch: <TPageData>(options?: (import("@tanstack/query
|
|
5
|
+
refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<TokenAmount, unknown>>;
|
|
6
|
+
refetchNewBalance: () => void;
|
|
7
|
+
refetchAllBalances: () => void;
|
|
8
|
+
getTokenBalancesWithRetry: (accountAddress: string, tokens: Token[], depth?: number) => Promise<TokenAmount[] | undefined>;
|
|
5
9
|
};
|
|
@@ -1,19 +1,97 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.useTokenBalance = void 0;
|
|
13
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
4
14
|
const react_1 = require("react");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
15
|
+
const providers_1 = require("../providers");
|
|
16
|
+
const utils_1 = require("../utils");
|
|
17
|
+
const defaultRefetchInterval = 60000;
|
|
18
|
+
const useTokenBalance = (token, accountAddress) => {
|
|
19
|
+
const lifi = (0, providers_1.useLiFi)();
|
|
20
|
+
const { account } = (0, providers_1.useWallet)();
|
|
21
|
+
const queryClient = (0, react_query_1.useQueryClient)();
|
|
22
|
+
const walletAddress = accountAddress !== null && accountAddress !== void 0 ? accountAddress : account.address;
|
|
23
|
+
const getTokenBalancesWithRetry = (0, react_1.useCallback)((accountAddress, tokens, depth = 0) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
|
+
const tokenBalances = yield lifi.getTokenBalances(accountAddress, tokens);
|
|
25
|
+
if (!tokenBalances.every((token) => token.blockNumber)) {
|
|
26
|
+
if (depth > 5) {
|
|
27
|
+
console.warn('Token balance backoff depth exceeded.');
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
yield new Promise((resolve) => {
|
|
31
|
+
setTimeout(resolve, depth * 100);
|
|
32
|
+
});
|
|
33
|
+
return getTokenBalancesWithRetry(accountAddress, tokens, depth + 1);
|
|
34
|
+
}
|
|
35
|
+
return tokenBalances;
|
|
36
|
+
}), [lifi]);
|
|
37
|
+
const tokenBalanceQueryKey = (0, react_1.useMemo)(() => ['token-balance', walletAddress, token === null || token === void 0 ? void 0 : token.chainId, token === null || token === void 0 ? void 0 : token.address], [token === null || token === void 0 ? void 0 : token.address, token === null || token === void 0 ? void 0 : token.chainId, walletAddress]);
|
|
38
|
+
const { data, isLoading, refetch } = (0, react_query_1.useQuery)(tokenBalanceQueryKey, ({ queryKey: [, accountAddress] }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
9
39
|
var _a;
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
40
|
+
const cachedToken = (_a = queryClient
|
|
41
|
+
.getQueryData([
|
|
42
|
+
'token-balances',
|
|
43
|
+
accountAddress,
|
|
44
|
+
token.chainId,
|
|
45
|
+
])) === null || _a === void 0 ? void 0 : _a.find((t) => t.address === token.address);
|
|
46
|
+
if (cachedToken) {
|
|
47
|
+
return cachedToken;
|
|
48
|
+
}
|
|
49
|
+
const tokenBalances = yield getTokenBalancesWithRetry(accountAddress, [token]);
|
|
50
|
+
if (!(tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.length)) {
|
|
51
|
+
throw Error('Could not get tokens balance.');
|
|
52
|
+
}
|
|
53
|
+
const cachedTokenAmount = queryClient.getQueryData(tokenBalanceQueryKey);
|
|
54
|
+
const formattedAmount = (0, utils_1.formatTokenAmount)(tokenBalances[0].amount);
|
|
55
|
+
if ((cachedTokenAmount === null || cachedTokenAmount === void 0 ? void 0 : cachedTokenAmount.amount) !== formattedAmount) {
|
|
56
|
+
queryClient.setQueryDefaults(tokenBalanceQueryKey, {
|
|
57
|
+
refetchInterval: defaultRefetchInterval,
|
|
58
|
+
staleTime: defaultRefetchInterval,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
queryClient.setQueryData(['token-balances', accountAddress, token.chainId], (data) => {
|
|
62
|
+
if (data) {
|
|
63
|
+
const index = data.findIndex((dataToken) => dataToken.address === token.address);
|
|
64
|
+
data[index] = Object.assign(Object.assign({}, data[index]), { amount: formattedAmount });
|
|
65
|
+
}
|
|
66
|
+
return data;
|
|
67
|
+
});
|
|
68
|
+
return Object.assign(Object.assign({}, tokenBalances[0]), { amount: formattedAmount });
|
|
69
|
+
}), {
|
|
70
|
+
enabled: Boolean(walletAddress && token),
|
|
71
|
+
refetchIntervalInBackground: true,
|
|
72
|
+
refetchInterval: defaultRefetchInterval,
|
|
73
|
+
staleTime: defaultRefetchInterval,
|
|
74
|
+
});
|
|
75
|
+
const refetchAllBalances = () => {
|
|
76
|
+
queryClient.refetchQueries([
|
|
77
|
+
'token-balances',
|
|
78
|
+
token === null || token === void 0 ? void 0 : token.chainId,
|
|
79
|
+
accountAddress,
|
|
80
|
+
]);
|
|
81
|
+
};
|
|
82
|
+
const refetchNewBalance = (0, react_1.useCallback)(() => {
|
|
83
|
+
queryClient.setQueryDefaults(tokenBalanceQueryKey, {
|
|
84
|
+
refetchInterval: 500,
|
|
85
|
+
staleTime: 500,
|
|
86
|
+
});
|
|
87
|
+
}, [queryClient, tokenBalanceQueryKey]);
|
|
13
88
|
return {
|
|
14
|
-
token,
|
|
15
|
-
isLoading
|
|
89
|
+
token: data,
|
|
90
|
+
isLoading,
|
|
16
91
|
refetch,
|
|
92
|
+
refetchNewBalance,
|
|
93
|
+
refetchAllBalances,
|
|
94
|
+
getTokenBalancesWithRetry,
|
|
17
95
|
};
|
|
18
96
|
};
|
|
19
97
|
exports.useTokenBalance = useTokenBalance;
|
|
@@ -5,5 +5,5 @@ export declare const useTokenBalances: (selectedChainId?: number) => {
|
|
|
5
5
|
featuredTokens: import("@lifi/types").Token[];
|
|
6
6
|
isLoading: boolean;
|
|
7
7
|
isBalanceLoading: boolean;
|
|
8
|
-
refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<Token[]
|
|
8
|
+
refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<Token[], unknown>>;
|
|
9
9
|
};
|
|
@@ -29,9 +29,6 @@ const useTokenBalances = (selectedChainId) => {
|
|
|
29
29
|
Boolean(tokens === null || tokens === void 0 ? void 0 : tokens.length) &&
|
|
30
30
|
Boolean(selectedChainId);
|
|
31
31
|
const { data: tokensWithBalance, isLoading: isBalanceLoading, refetch, } = (0, react_query_1.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* () {
|
|
32
|
-
if (!accountAddress || !tokens) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
32
|
const tokenBalances = yield lifi.getTokenBalances(accountAddress, tokens);
|
|
36
33
|
if (!(tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.length)) {
|
|
37
34
|
// Sometimes RPCs (e.g. Arbitrum) don't return balances on first call
|
|
@@ -39,7 +36,7 @@ const useTokenBalances = (selectedChainId) => {
|
|
|
39
36
|
setRefetchInterval((interval) => interval === defaultRefetchInterval
|
|
40
37
|
? minRefetchInterval
|
|
41
38
|
: interval * 2);
|
|
42
|
-
|
|
39
|
+
throw Error('Could not get tokens balance.');
|
|
43
40
|
}
|
|
44
41
|
const featuredTokenAddresses = new Set(featuredTokens === null || featuredTokens === void 0 ? void 0 : featuredTokens.map((token) => token.address));
|
|
45
42
|
const sortFn = (a, b) => {
|
|
@@ -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": {
|
|
@@ -3,22 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SelectTokenPage = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const material_1 = require("@mui/material");
|
|
6
|
-
const react_1 = require("react");
|
|
7
6
|
const ChainSelect_1 = require("../../components/ChainSelect");
|
|
8
7
|
const TokenList_1 = require("../../components/TokenList");
|
|
9
8
|
const hooks_1 = require("../../hooks");
|
|
10
9
|
const SearchTokenInput_1 = require("./SearchTokenInput");
|
|
11
|
-
const minTokenListHeight = 330;
|
|
12
10
|
const SelectTokenPage = ({ formType }) => {
|
|
13
|
-
(0, hooks_1.useScrollableOverflowHidden)();
|
|
14
11
|
const { navigateBack } = (0, hooks_1.useNavigateBack)();
|
|
15
|
-
|
|
16
|
-
const contentHeight = (0, hooks_1.useContentHeight)();
|
|
17
|
-
const [tokenListHeight, setTokenListHeight] = (0, react_1.useState)(0);
|
|
18
|
-
(0, react_1.useLayoutEffect)(() => {
|
|
19
|
-
var _a, _b;
|
|
20
|
-
setTokenListHeight(Math.max(contentHeight - ((_b = (_a = headerRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) !== null && _b !== void 0 ? _b : 0), minTokenListHeight));
|
|
21
|
-
}, [contentHeight]);
|
|
22
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.Container, Object.assign({ disableGutters: true }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ pt: 1, pb: 2, px: 3, ref: headerRef }, { children: [(0, jsx_runtime_1.jsx)(ChainSelect_1.ChainSelect, { formType: formType }), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mt: 2 }, { children: (0, jsx_runtime_1.jsx)(SearchTokenInput_1.SearchTokenInput, {}) }))] })), (0, jsx_runtime_1.jsx)(TokenList_1.TokenList, { height: tokenListHeight, onClick: navigateBack, formType: formType })] })));
|
|
12
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Container, Object.assign({ disableGutters: true }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ pt: 1, pb: 2, px: 3 }, { children: [(0, jsx_runtime_1.jsx)(ChainSelect_1.ChainSelect, { formType: formType }), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mt: 2 }, { children: (0, jsx_runtime_1.jsx)(SearchTokenInput_1.SearchTokenInput, {}) }))] })), (0, jsx_runtime_1.jsx)(TokenList_1.TokenList, { height: 360, onClick: navigateBack, formType: formType })] })));
|
|
23
13
|
};
|
|
24
14
|
exports.SelectTokenPage = SelectTokenPage;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StatusBottomSheet = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
/* eslint-disable consistent-return */
|
|
5
6
|
const icons_material_1 = require("@mui/icons-material");
|
|
6
7
|
const material_1 = require("@mui/material");
|
|
7
8
|
const react_1 = require("react");
|
|
@@ -11,17 +12,18 @@ const BottomSheet_1 = require("../../components/BottomSheet");
|
|
|
11
12
|
const Token_1 = require("../../components/Token");
|
|
12
13
|
const hooks_1 = require("../../hooks");
|
|
13
14
|
const providers_1 = require("../../providers");
|
|
15
|
+
const utils_1 = require("../../utils");
|
|
14
16
|
const StatusBottomSheet_style_1 = require("./StatusBottomSheet.style");
|
|
15
17
|
const StatusBottomSheet = ({ status, route, }) => {
|
|
16
18
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
17
19
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
18
|
-
const { navigateBack } = (0, hooks_1.useNavigateBack)();
|
|
20
|
+
const { navigateBack, navigate } = (0, hooks_1.useNavigateBack)();
|
|
19
21
|
const ref = (0, react_1.useRef)(null);
|
|
20
22
|
const { getChainById } = (0, hooks_1.useChains)();
|
|
21
|
-
const { token, refetch
|
|
23
|
+
const { token, refetch, refetchNewBalance, refetchAllBalances } = (0, hooks_1.useTokenBalance)(route.toToken, route.toAddress);
|
|
22
24
|
const { setValue } = (0, react_hook_form_1.useFormContext)();
|
|
23
25
|
const clearFromAmount = () => {
|
|
24
|
-
|
|
26
|
+
refetchAllBalances();
|
|
25
27
|
setValue(providers_1.SwapFormKey.FromAmount, '');
|
|
26
28
|
};
|
|
27
29
|
const handleDone = () => {
|
|
@@ -33,6 +35,13 @@ const StatusBottomSheet = ({ status, route, }) => {
|
|
|
33
35
|
clearFromAmount();
|
|
34
36
|
(_a = ref.current) === null || _a === void 0 ? void 0 : _a.closeDrawer();
|
|
35
37
|
};
|
|
38
|
+
const handleSeeDetails = () => {
|
|
39
|
+
handleClose();
|
|
40
|
+
navigate(utils_1.navigationRoutes.swapDetails, {
|
|
41
|
+
state: { routeId: route.id },
|
|
42
|
+
replace: true,
|
|
43
|
+
});
|
|
44
|
+
};
|
|
36
45
|
let title;
|
|
37
46
|
let message;
|
|
38
47
|
switch (status) {
|
|
@@ -42,6 +51,7 @@ const StatusBottomSheet = ({ status, route, }) => {
|
|
|
42
51
|
amount: token === null || token === void 0 ? void 0 : token.amount,
|
|
43
52
|
tokenSymbol: token === null || token === void 0 ? void 0 : token.symbol,
|
|
44
53
|
chainName: (_a = getChainById(route.toChainId)) === null || _a === void 0 ? void 0 : _a.name,
|
|
54
|
+
walletAddress: (0, utils_1.shortenWalletAddress)(route.toAddress),
|
|
45
55
|
});
|
|
46
56
|
break;
|
|
47
57
|
case 'error': {
|
|
@@ -62,10 +72,13 @@ const StatusBottomSheet = ({ status, route, }) => {
|
|
|
62
72
|
var _a, _b;
|
|
63
73
|
if ((status === 'success' || status === 'error') &&
|
|
64
74
|
!((_a = ref.current) === null || _a === void 0 ? void 0 : _a.isOpen())) {
|
|
65
|
-
|
|
75
|
+
if (status === 'success') {
|
|
76
|
+
refetchNewBalance();
|
|
77
|
+
refetch();
|
|
78
|
+
}
|
|
66
79
|
(_b = ref.current) === null || _b === void 0 ? void 0 : _b.openDrawer();
|
|
67
80
|
}
|
|
68
|
-
}, [
|
|
69
|
-
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 === 'idle' ? ((0, jsx_runtime_1.jsx)(icons_material_1.Info, { color: "primary", sx: StatusBottomSheet_style_1.iconStyles })) : null, status === 'success' ? ((0, jsx_runtime_1.jsx)(icons_material_1.Done, { color: "success", sx: StatusBottomSheet_style_1.iconStyles })) : null, status === 'error' ? ((0, jsx_runtime_1.jsx)(icons_material_1.Warning, { color: "error", sx: StatusBottomSheet_style_1.iconStyles })) : null] })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ py: 1, fontSize: 18, fontWeight: 700 }, { children: title })), status === 'success' ? ((0, jsx_runtime_1.jsx)(Token_1.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] }), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ pt: 2, pb: 1 }, { children: message })), (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: 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' ? ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mt: 2 }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ variant: "outlined", fullWidth: true, onClick:
|
|
81
|
+
}, [refetch, refetchNewBalance, status]);
|
|
82
|
+
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 === 'idle' ? ((0, jsx_runtime_1.jsx)(icons_material_1.Info, { color: "primary", sx: StatusBottomSheet_style_1.iconStyles })) : null, status === 'success' ? ((0, jsx_runtime_1.jsx)(icons_material_1.Done, { color: "success", sx: StatusBottomSheet_style_1.iconStyles })) : null, status === 'error' ? ((0, jsx_runtime_1.jsx)(icons_material_1.Warning, { color: "error", sx: StatusBottomSheet_style_1.iconStyles })) : null] })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ py: 1, fontSize: 18, fontWeight: 700 }, { children: title })), status === 'success' ? ((0, jsx_runtime_1.jsx)(Token_1.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] }), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ pt: 2, pb: 1 }, { children: message })), (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: 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' ? ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mt: 2 }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ variant: "outlined", fullWidth: true, onClick: handleSeeDetails }, { children: t('button.seeDetails') })) }))) : null] })) })));
|
|
70
83
|
};
|
|
71
84
|
exports.StatusBottomSheet = StatusBottomSheet;
|
package/cjs/utils/index.d.ts
CHANGED
package/cjs/utils/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const shortenWalletAddress: (address?: string) => string | null;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.shortenWalletAddress = void 0;
|
|
4
|
+
const shortenWalletAddress = (address) => address
|
|
5
|
+
? `${address.substring(0, 5)}...${address.substring(address.length - 4)}`
|
|
6
|
+
: null;
|
|
7
|
+
exports.shortenWalletAddress = shortenWalletAddress;
|
|
@@ -8,9 +8,11 @@ export const BottomSheet = forwardRef(({ elementRef, children, open }, ref) => {
|
|
|
8
8
|
const containerElement = useScrollableContainer();
|
|
9
9
|
const openDrawer = useCallback(() => {
|
|
10
10
|
setDrawerOpen(true);
|
|
11
|
+
openRef.current = true;
|
|
11
12
|
}, []);
|
|
12
13
|
const closeDrawer = useCallback(() => {
|
|
13
14
|
setDrawerOpen(false);
|
|
15
|
+
openRef.current = false;
|
|
14
16
|
}, []);
|
|
15
17
|
useImperativeHandle(ref, () => ({
|
|
16
18
|
isOpen: () => openRef.current,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Avatar, Box, Skeleton, Typography } from '@mui/material';
|
|
2
|
+
import { Avatar, Box, Skeleton, Tooltip, Typography } from '@mui/material';
|
|
3
3
|
import { useWatch } from 'react-hook-form';
|
|
4
4
|
import { useNavigate } from 'react-router-dom';
|
|
5
5
|
import { SwapFormKeyHelper } from '../../providers';
|
|
@@ -22,7 +22,7 @@ export const ChainSelect = ({ formType }) => {
|
|
|
22
22
|
const chainsToHide = ((_a = chains === null || chains === void 0 ? void 0 : chains.length) !== null && _a !== void 0 ? _a : 0) - maxChainToOrder;
|
|
23
23
|
return (_jsxs(ChainContainer, { children: [isLoading
|
|
24
24
|
? Array.from({ length: maxChainToOrder + 1 }).map((_, index) => (_jsx(Skeleton, { variant: "rectangular", width: 56, height: 56, sx: { borderRadius: 1 } }, index)))
|
|
25
|
-
: getChains().map((chain) => (_jsx(ChainCard, Object.assign({ onClick: () => setCurrentChain(chain.id), variant: chainId === chain.id ? 'selected' : 'default' }, { children: _jsx(Avatar, Object.assign({ src: chain.logoURI, alt: chain.key, sx: { width: 40, height: 40 } }, { children: chain.name[0] })) }), chain.id))), chainsToHide > 0 ? (_jsx(ChainCard, Object.assign({ onClick: showAllChains }, { children: _jsx(Box, Object.assign({ sx: {
|
|
25
|
+
: getChains().map((chain) => (_jsx(Tooltip, Object.assign({ title: chain.name, placement: "top", enterDelay: 500, enterNextDelay: 500, arrow: true }, { children: _jsx(ChainCard, Object.assign({ onClick: () => setCurrentChain(chain.id), variant: chainId === chain.id ? 'selected' : 'default' }, { children: _jsx(Avatar, Object.assign({ src: chain.logoURI, alt: chain.key, sx: { width: 40, height: 40 } }, { children: chain.name[0] })) })) }), chain.id))), chainsToHide > 0 ? (_jsx(ChainCard, Object.assign({ onClick: showAllChains }, { children: _jsx(Box, Object.assign({ sx: {
|
|
26
26
|
width: 40,
|
|
27
27
|
height: 40,
|
|
28
28
|
display: 'grid',
|