@lifi/widget 3.4.0-beta.4 → 3.4.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/CHANGELOG.md +15 -0
- package/_esm/components/AppContainer.d.ts +0 -1
- package/_esm/components/AppContainer.js +53 -24
- package/_esm/components/AppContainer.js.map +1 -1
- package/_esm/components/ChainSelect/useChainSelect.js +10 -2
- package/_esm/components/ChainSelect/useChainSelect.js.map +1 -1
- package/_esm/components/Header/Header.d.ts +2 -0
- package/_esm/components/Header/Header.js +8 -1
- package/_esm/components/Header/Header.js.map +1 -1
- package/_esm/components/Header/Header.style.d.ts +3 -0
- package/_esm/components/Header/Header.style.js +27 -11
- package/_esm/components/Header/Header.style.js.map +1 -1
- package/_esm/components/Routes/RoutesExpanded.js +3 -3
- package/_esm/components/Routes/RoutesExpanded.js.map +1 -1
- package/_esm/components/Routes/RoutesExpanded.style.d.ts +8 -1
- package/_esm/components/Routes/RoutesExpanded.style.js +22 -5
- package/_esm/components/Routes/RoutesExpanded.style.js.map +1 -1
- package/_esm/components/TokenList/TokenList.js +1 -3
- package/_esm/components/TokenList/TokenList.js.map +1 -1
- package/_esm/components/TokenList/types.d.ts +1 -0
- package/_esm/components/TokenList/useTokenSelect.js +7 -2
- package/_esm/components/TokenList/useTokenSelect.js.map +1 -1
- package/_esm/config/coinbase.d.ts +2 -0
- package/_esm/config/coinbase.js +6 -0
- package/_esm/config/coinbase.js.map +1 -0
- package/_esm/config/constants.d.ts +1 -0
- package/_esm/config/constants.js +2 -0
- package/_esm/config/constants.js.map +1 -0
- package/_esm/config/metaMask.d.ts +2 -0
- package/_esm/config/metaMask.js +11 -0
- package/_esm/config/metaMask.js.map +1 -0
- package/_esm/config/version.d.ts +1 -1
- package/_esm/config/version.js +1 -1
- package/_esm/config/version.js.map +1 -1
- package/_esm/config/walletConnect.d.ts +2 -1
- package/_esm/config/walletConnect.js +3 -1
- package/_esm/config/walletConnect.js.map +1 -1
- package/_esm/hooks/{useContentHeight.d.ts → useSetContentHeight.d.ts} +0 -1
- package/_esm/hooks/useSetContentHeight.js +19 -0
- package/_esm/hooks/useSetContentHeight.js.map +1 -0
- package/_esm/hooks/useWallets.d.ts +6 -0
- package/_esm/hooks/useWallets.js +80 -0
- package/_esm/hooks/useWallets.js.map +1 -0
- package/_esm/i18n/en.json +1 -0
- package/_esm/index.d.ts +2 -0
- package/_esm/index.js +2 -0
- package/_esm/index.js.map +1 -1
- package/_esm/pages/MainPage/MainPage.js +2 -2
- package/_esm/pages/MainPage/MainPage.js.map +1 -1
- package/_esm/pages/SelectTokenPage/SelectTokenPage.js +8 -9
- package/_esm/pages/SelectTokenPage/SelectTokenPage.js.map +1 -1
- package/_esm/pages/SelectTokenPage/useTokenListHeight.d.ts +12 -0
- package/_esm/pages/SelectTokenPage/useTokenListHeight.js +70 -0
- package/_esm/pages/SelectTokenPage/useTokenListHeight.js.map +1 -0
- package/_esm/pages/SelectWalletPage/EVMListItemButton.d.ts +2 -1
- package/_esm/pages/SelectWalletPage/EVMListItemButton.js +2 -1
- package/_esm/pages/SelectWalletPage/EVMListItemButton.js.map +1 -1
- package/_esm/pages/SelectWalletPage/SelectWalletPage.js +7 -44
- package/_esm/pages/SelectWalletPage/SelectWalletPage.js.map +1 -1
- package/_esm/pages/SendToWallet/BookmarksPage.js +4 -2
- package/_esm/pages/SendToWallet/BookmarksPage.js.map +1 -1
- package/_esm/pages/SendToWallet/SendToWalletPage.js +6 -4
- package/_esm/pages/SendToWallet/SendToWalletPage.js.map +1 -1
- package/_esm/pages/SendToWallet/SendToWalletPage.style.d.ts +10 -0
- package/_esm/pages/SendToWallet/SendToWalletPage.style.js +17 -5
- package/_esm/pages/SendToWallet/SendToWalletPage.style.js.map +1 -1
- package/_esm/pages/TransactionDetailsPage/TransactionDetailsPage.js +0 -1
- package/_esm/pages/TransactionDetailsPage/TransactionDetailsPage.js.map +1 -1
- package/_esm/pages/TransactionPage/ExchangeRateBottomSheet.js +1 -1
- package/_esm/pages/TransactionPage/ExchangeRateBottomSheet.js.map +1 -1
- package/_esm/pages/TransactionPage/StatusBottomSheet.js +1 -1
- package/_esm/pages/TransactionPage/StatusBottomSheet.js.map +1 -1
- package/_esm/pages/TransactionPage/TokenValueBottomSheet.js +1 -1
- package/_esm/pages/TransactionPage/TokenValueBottomSheet.js.map +1 -1
- package/_esm/providers/WalletProvider/EVMBaseProvider.js +7 -9
- package/_esm/providers/WalletProvider/EVMBaseProvider.js.map +1 -1
- package/_esm/themes/createTheme.js +1 -0
- package/_esm/themes/createTheme.js.map +1 -1
- package/_esm/themes/types.d.ts +2 -0
- package/_esm/types/widget.d.ts +20 -15
- package/_esm/types/widget.js.map +1 -1
- package/components/AppContainer.tsx +70 -24
- package/components/ChainSelect/useChainSelect.ts +11 -3
- package/components/Header/Header.style.ts +28 -11
- package/components/Header/Header.tsx +11 -0
- package/components/Routes/RoutesExpanded.style.ts +30 -5
- package/components/Routes/RoutesExpanded.tsx +12 -5
- package/components/TokenList/TokenList.tsx +1 -2
- package/components/TokenList/types.ts +1 -0
- package/components/TokenList/useTokenSelect.ts +8 -2
- package/config/coinbase.ts +7 -0
- package/config/constants.ts +1 -0
- package/config/metaMask.ts +13 -0
- package/config/version.ts +1 -1
- package/config/walletConnect.ts +5 -1
- package/hooks/useSetContentHeight.ts +24 -0
- package/hooks/useWallets.ts +147 -0
- package/i18n/en.json +1 -0
- package/index.ts +2 -0
- package/package.json +11 -11
- package/pages/MainPage/MainPage.tsx +3 -2
- package/pages/SelectTokenPage/SelectTokenPage.tsx +16 -20
- package/pages/SelectTokenPage/useTokenListHeight.ts +112 -0
- package/pages/SelectWalletPage/EVMListItemButton.tsx +16 -7
- package/pages/SelectWalletPage/SelectWalletPage.tsx +7 -65
- package/pages/SendToWallet/BookmarksPage.tsx +12 -6
- package/pages/SendToWallet/SendToWalletPage.style.tsx +25 -5
- package/pages/SendToWallet/SendToWalletPage.tsx +42 -33
- package/pages/TransactionDetailsPage/TransactionDetailsPage.tsx +0 -1
- package/pages/TransactionPage/ExchangeRateBottomSheet.tsx +1 -1
- package/pages/TransactionPage/StatusBottomSheet.tsx +1 -1
- package/pages/TransactionPage/TokenValueBottomSheet.tsx +1 -1
- package/providers/WalletProvider/EVMBaseProvider.tsx +7 -9
- package/themes/createTheme.ts +1 -0
- package/themes/types.ts +2 -0
- package/types/widget.ts +24 -14
- package/_esm/hooks/useContentHeight.js +0 -40
- package/_esm/hooks/useContentHeight.js.map +0 -1
- package/_esm/pages/SelectWalletPage/utils.d.ts +0 -3
- package/_esm/pages/SelectWalletPage/utils.js +0 -18
- package/_esm/pages/SelectWalletPage/utils.js.map +0 -1
- package/hooks/useContentHeight.ts +0 -53
- package/pages/SelectWalletPage/utils.ts +0 -26
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/widget",
|
|
3
|
-
"version": "3.4.0
|
|
3
|
+
"version": "3.4.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
|
"type": "module",
|
|
6
6
|
"main": "./_esm/index.js",
|
|
@@ -34,27 +34,27 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@emotion/react": "^11.13.0",
|
|
36
36
|
"@emotion/styled": "^11.13.0",
|
|
37
|
-
"@lifi/sdk": "^3.1.
|
|
38
|
-
"@lifi/wallet-management": "^3.0
|
|
39
|
-
"@mui/icons-material": "^5.16.
|
|
37
|
+
"@lifi/sdk": "^3.1.5",
|
|
38
|
+
"@lifi/wallet-management": "^3.1.0",
|
|
39
|
+
"@mui/icons-material": "^5.16.7",
|
|
40
40
|
"@mui/lab": "^5.0.0-alpha.173",
|
|
41
|
-
"@mui/material": "^5.16.
|
|
41
|
+
"@mui/material": "^5.16.7",
|
|
42
42
|
"@solana/wallet-adapter-base": "^0.9.23",
|
|
43
43
|
"@solana/wallet-adapter-react": "^0.15.35",
|
|
44
44
|
"@solana/web3.js": "^1.95.2",
|
|
45
|
-
"@tanstack/react-query": "^5.51.
|
|
46
|
-
"@tanstack/react-virtual": "^3.
|
|
47
|
-
"i18next": "^23.12.
|
|
45
|
+
"@tanstack/react-query": "^5.51.23",
|
|
46
|
+
"@tanstack/react-virtual": "^3.9.0",
|
|
47
|
+
"i18next": "^23.12.3",
|
|
48
48
|
"microdiff": "^1.4.0",
|
|
49
49
|
"mitt": "^3.0.1",
|
|
50
50
|
"react": "^18.3.1",
|
|
51
51
|
"react-dom": "^18.3.1",
|
|
52
|
-
"react-i18next": "^15.0.
|
|
52
|
+
"react-i18next": "^15.0.1",
|
|
53
53
|
"react-intersection-observer": "^9.13.0",
|
|
54
54
|
"react-router-dom": "^6.26.0",
|
|
55
55
|
"uuid": "^10.0.0",
|
|
56
|
-
"viem": "^2.
|
|
57
|
-
"wagmi": "^2.12.
|
|
56
|
+
"viem": "^2.19.4",
|
|
57
|
+
"wagmi": "^2.12.5",
|
|
58
58
|
"zustand": "^4.5.4"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
@@ -20,13 +20,14 @@ import { ReviewButton } from './ReviewButton.js';
|
|
|
20
20
|
export const MainPage: React.FC = () => {
|
|
21
21
|
const { t } = useTranslation();
|
|
22
22
|
const wideVariant = useWideVariant();
|
|
23
|
-
const { subvariant, contractComponent, hiddenUI } =
|
|
23
|
+
const { subvariant, subvariantOptions, contractComponent, hiddenUI } =
|
|
24
|
+
useWidgetConfig();
|
|
24
25
|
const custom = subvariant === 'custom';
|
|
25
26
|
const showPoweredBy = !hiddenUI?.includes(HiddenUI.PoweredBy);
|
|
26
27
|
|
|
27
28
|
const title =
|
|
28
29
|
subvariant === 'custom'
|
|
29
|
-
? t(`header
|
|
30
|
+
? t(`header.${subvariantOptions?.custom ?? 'checkout'}`)
|
|
30
31
|
: subvariant === 'refuel'
|
|
31
32
|
? t(`header.gas`)
|
|
32
33
|
: t(`header.exchange`);
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { Box } from '@mui/material';
|
|
2
2
|
import type { FC } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { useRef } from 'react';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
5
|
import { ChainSelect } from '../../components/ChainSelect/ChainSelect.js';
|
|
6
6
|
import { PageContainer } from '../../components/PageContainer.js';
|
|
7
7
|
import { TokenList } from '../../components/TokenList/TokenList.js';
|
|
8
|
-
import { useContentHeight } from '../../hooks/useContentHeight.js';
|
|
9
8
|
import { useHeader } from '../../hooks/useHeader.js';
|
|
10
9
|
import { useNavigateBack } from '../../hooks/useNavigateBack.js';
|
|
11
10
|
import { useScrollableOverflowHidden } from '../../hooks/useScrollableContainer.js';
|
|
@@ -13,15 +12,18 @@ import { useSwapOnly } from '../../hooks/useSwapOnly.js';
|
|
|
13
12
|
import { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js';
|
|
14
13
|
import type { FormTypeProps } from '../../stores/form/types.js';
|
|
15
14
|
import { SearchTokenInput } from './SearchTokenInput.js';
|
|
16
|
-
|
|
17
|
-
const minTokenListHeight = 360;
|
|
15
|
+
import { useTokenListHeight } from './useTokenListHeight.js';
|
|
18
16
|
|
|
19
17
|
export const SelectTokenPage: FC<FormTypeProps> = ({ formType }) => {
|
|
20
18
|
useScrollableOverflowHidden();
|
|
21
19
|
const { navigateBack } = useNavigateBack();
|
|
22
20
|
const headerRef = useRef<HTMLElement>(null);
|
|
23
|
-
const
|
|
24
|
-
const
|
|
21
|
+
const listParentRef = useRef<HTMLUListElement | null>(null);
|
|
22
|
+
const { tokenListHeight, minListHeight } = useTokenListHeight({
|
|
23
|
+
listParentRef,
|
|
24
|
+
headerRef,
|
|
25
|
+
});
|
|
26
|
+
|
|
25
27
|
const swapOnly = useSwapOnly();
|
|
26
28
|
|
|
27
29
|
const { subvariant } = useWidgetConfig();
|
|
@@ -35,15 +37,6 @@ export const SelectTokenPage: FC<FormTypeProps> = ({ formType }) => {
|
|
|
35
37
|
|
|
36
38
|
useHeader(title);
|
|
37
39
|
|
|
38
|
-
useLayoutEffect(() => {
|
|
39
|
-
setTokenListHeight(
|
|
40
|
-
Math.max(
|
|
41
|
-
contentHeight - (headerRef.current?.offsetHeight ?? 0),
|
|
42
|
-
minTokenListHeight,
|
|
43
|
-
),
|
|
44
|
-
);
|
|
45
|
-
}, [contentHeight]);
|
|
46
|
-
|
|
47
40
|
const hideChainSelect = swapOnly && formType === 'to';
|
|
48
41
|
|
|
49
42
|
return (
|
|
@@ -54,11 +47,14 @@ export const SelectTokenPage: FC<FormTypeProps> = ({ formType }) => {
|
|
|
54
47
|
<SearchTokenInput />
|
|
55
48
|
</Box>
|
|
56
49
|
</Box>
|
|
57
|
-
<
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
50
|
+
<Box height={minListHeight}>
|
|
51
|
+
<TokenList
|
|
52
|
+
parentRef={listParentRef}
|
|
53
|
+
height={tokenListHeight}
|
|
54
|
+
onClick={navigateBack}
|
|
55
|
+
formType={formType}
|
|
56
|
+
/>
|
|
57
|
+
</Box>
|
|
62
58
|
</PageContainer>
|
|
63
59
|
);
|
|
64
60
|
};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { useTheme } from '@mui/material';
|
|
2
|
+
import type { MutableRefObject } from 'react';
|
|
3
|
+
import { useLayoutEffect, useState } from 'react';
|
|
4
|
+
import { useDefaultElementId } from '../../hooks/useDefaultElementId.js';
|
|
5
|
+
import { ElementId, createElementId } from '../../utils/elements.js';
|
|
6
|
+
|
|
7
|
+
const debounce = (func: Function, timeout = 300) => {
|
|
8
|
+
let timer: ReturnType<typeof setTimeout>;
|
|
9
|
+
return (...args: any[]) => {
|
|
10
|
+
clearTimeout(timer);
|
|
11
|
+
timer = setTimeout(() => {
|
|
12
|
+
func.apply(this, args);
|
|
13
|
+
}, timeout);
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const getContentHeight = (
|
|
18
|
+
elementId: string,
|
|
19
|
+
listParentRef: MutableRefObject<HTMLUListElement | null>,
|
|
20
|
+
) => {
|
|
21
|
+
const containerElement = document.getElementById(
|
|
22
|
+
createElementId(ElementId.ScrollableContainer, elementId),
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
const headerElement = document.getElementById(
|
|
26
|
+
createElementId(ElementId.Header, elementId),
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const listParentElement = listParentRef?.current;
|
|
30
|
+
|
|
31
|
+
let oldHeight;
|
|
32
|
+
|
|
33
|
+
// This covers the case where in full height flex mode when the browser height is reduced
|
|
34
|
+
// - this allows the virtualised token list to be made smaller
|
|
35
|
+
if (listParentElement) {
|
|
36
|
+
oldHeight = listParentElement.style.height;
|
|
37
|
+
listParentElement.style.height = '0';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (!containerElement || !headerElement) {
|
|
41
|
+
console.warn(
|
|
42
|
+
`Can't find ${ElementId.ScrollableContainer} or ${ElementId.Header} id.`,
|
|
43
|
+
);
|
|
44
|
+
return 0;
|
|
45
|
+
}
|
|
46
|
+
const { height: containerHeight } = containerElement.getBoundingClientRect();
|
|
47
|
+
const { height: headerHeight } = headerElement.getBoundingClientRect();
|
|
48
|
+
|
|
49
|
+
// This covers the case where in full height flex mode when the browser height is reduced the
|
|
50
|
+
// - this allows the virtualised token list to be set to minimum size
|
|
51
|
+
if (listParentElement && oldHeight) {
|
|
52
|
+
listParentElement.style.height = oldHeight;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return containerHeight - headerHeight;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
interface UseContentHeightProps {
|
|
59
|
+
listParentRef: MutableRefObject<HTMLUListElement | null>;
|
|
60
|
+
headerRef: MutableRefObject<HTMLElement | null>;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const minTokenListHeight = 360;
|
|
64
|
+
export const minMobileTokenListHeight = 160;
|
|
65
|
+
|
|
66
|
+
export const useTokenListHeight = ({
|
|
67
|
+
listParentRef,
|
|
68
|
+
headerRef,
|
|
69
|
+
}: UseContentHeightProps) => {
|
|
70
|
+
const elementId = useDefaultElementId();
|
|
71
|
+
const [contentHeight, setContentHeight] = useState<number>(0);
|
|
72
|
+
const theme = useTheme();
|
|
73
|
+
|
|
74
|
+
useLayoutEffect(() => {
|
|
75
|
+
const handleResize = () => {
|
|
76
|
+
setContentHeight(getContentHeight(elementId, listParentRef));
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const processResize = debounce(() => handleResize(), 40);
|
|
80
|
+
|
|
81
|
+
const appContainer = document.getElementById(
|
|
82
|
+
createElementId(ElementId.AppExpandedContainer, elementId),
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
let resizeObserver: ResizeObserver;
|
|
86
|
+
if (appContainer) {
|
|
87
|
+
resizeObserver = new ResizeObserver(processResize);
|
|
88
|
+
resizeObserver.observe(appContainer);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return () => {
|
|
92
|
+
if (resizeObserver) {
|
|
93
|
+
resizeObserver.disconnect();
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}, [elementId, listParentRef]);
|
|
97
|
+
|
|
98
|
+
const minListHeight =
|
|
99
|
+
theme.container?.height === '100%'
|
|
100
|
+
? minMobileTokenListHeight
|
|
101
|
+
: minTokenListHeight;
|
|
102
|
+
|
|
103
|
+
const tokenListHeight = Math.max(
|
|
104
|
+
contentHeight - (headerRef.current?.offsetHeight ?? 0),
|
|
105
|
+
minListHeight,
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
return {
|
|
109
|
+
minListHeight,
|
|
110
|
+
tokenListHeight,
|
|
111
|
+
};
|
|
112
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ChainType } from '@lifi/sdk';
|
|
2
|
+
import type { CreateConnectorFnExtended } from '@lifi/wallet-management';
|
|
2
3
|
import {
|
|
3
4
|
getConnectorIcon,
|
|
4
5
|
isWalletInstalledAsync,
|
|
@@ -14,7 +15,7 @@ import { WidgetEvent } from '../../types/events.js';
|
|
|
14
15
|
|
|
15
16
|
interface EVMListItemButtonProps {
|
|
16
17
|
connectedConnector?: Connector;
|
|
17
|
-
connector: Connector;
|
|
18
|
+
connector: CreateConnectorFnExtended | Connector;
|
|
18
19
|
onNotInstalled(connector: Connector): void;
|
|
19
20
|
}
|
|
20
21
|
|
|
@@ -29,9 +30,11 @@ export const EVMListItemButton = ({
|
|
|
29
30
|
const { disconnectAsync } = useDisconnect();
|
|
30
31
|
|
|
31
32
|
const handleEVMConnect = async () => {
|
|
32
|
-
const identityCheckPassed = await isWalletInstalledAsync(
|
|
33
|
+
const identityCheckPassed = await isWalletInstalledAsync(
|
|
34
|
+
(connector as Connector).id,
|
|
35
|
+
);
|
|
33
36
|
if (!identityCheckPassed) {
|
|
34
|
-
onNotInstalled(connector);
|
|
37
|
+
onNotInstalled(connector as Connector);
|
|
35
38
|
return;
|
|
36
39
|
}
|
|
37
40
|
if (connectedConnector) {
|
|
@@ -52,14 +55,20 @@ export const EVMListItemButton = ({
|
|
|
52
55
|
navigateBack();
|
|
53
56
|
};
|
|
54
57
|
|
|
58
|
+
const connectorName: string =
|
|
59
|
+
(connector as CreateConnectorFnExtended).displayName || connector.name;
|
|
60
|
+
|
|
55
61
|
return (
|
|
56
|
-
<ListItemButton key={connector.
|
|
62
|
+
<ListItemButton key={connector.id} onClick={handleEVMConnect}>
|
|
57
63
|
<ListItemAvatar>
|
|
58
|
-
<Avatar
|
|
59
|
-
{connector
|
|
64
|
+
<Avatar
|
|
65
|
+
src={getConnectorIcon(connector as Connector)}
|
|
66
|
+
alt={connectorName}
|
|
67
|
+
>
|
|
68
|
+
{connectorName?.[0]}
|
|
60
69
|
</Avatar>
|
|
61
70
|
</ListItemAvatar>
|
|
62
|
-
<ListItemText primary={
|
|
71
|
+
<ListItemText primary={connectorName} />
|
|
63
72
|
</ListItemButton>
|
|
64
73
|
);
|
|
65
74
|
};
|
|
@@ -1,47 +1,34 @@
|
|
|
1
|
-
import { ChainType } from '@lifi/sdk';
|
|
2
|
-
import { isWalletInstalled } from '@lifi/wallet-management';
|
|
3
|
-
import type { Theme } from '@mui/material';
|
|
4
1
|
import {
|
|
5
2
|
Button,
|
|
6
3
|
DialogActions,
|
|
7
4
|
DialogContent,
|
|
8
5
|
DialogContentText,
|
|
9
6
|
List,
|
|
10
|
-
useMediaQuery,
|
|
11
7
|
} from '@mui/material';
|
|
12
|
-
import { WalletReadyState } from '@solana/wallet-adapter-base';
|
|
13
8
|
import type { Wallet } from '@solana/wallet-adapter-react';
|
|
14
|
-
import {
|
|
15
|
-
import { useCallback, useMemo, useState } from 'react';
|
|
9
|
+
import { useCallback, useState } from 'react';
|
|
16
10
|
import { useTranslation } from 'react-i18next';
|
|
17
11
|
import type { Connector } from 'wagmi';
|
|
18
|
-
import {
|
|
12
|
+
import { useAccount as useWagmiAccount } from 'wagmi';
|
|
19
13
|
import { Dialog } from '../../components/Dialog.js';
|
|
20
14
|
import { PageContainer } from '../../components/PageContainer.js';
|
|
21
15
|
import { useHeader } from '../../hooks/useHeader.js';
|
|
16
|
+
import { useWallets } from '../../hooks/useWallets.js';
|
|
22
17
|
import { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js';
|
|
23
|
-
import { isItemAllowed } from '../../utils/item.js';
|
|
24
18
|
import { EVMListItemButton } from './EVMListItemButton.js';
|
|
25
19
|
import { SVMListItemButton } from './SVMListItemButton.js';
|
|
26
|
-
import { walletComparator } from './utils.js';
|
|
27
20
|
|
|
28
21
|
export const SelectWalletPage = () => {
|
|
29
22
|
const { t } = useTranslation();
|
|
30
|
-
const { chains } = useWidgetConfig();
|
|
23
|
+
const { chains, walletConfig } = useWidgetConfig();
|
|
31
24
|
const account = useWagmiAccount();
|
|
32
|
-
const { connectors } = useConnect();
|
|
33
25
|
const [walletIdentity, setWalletIdentity] = useState<{
|
|
34
26
|
show: boolean;
|
|
35
27
|
connector?: Connector;
|
|
36
28
|
}>({ show: false });
|
|
37
|
-
const { wallets: solanaWallets } = useWallet();
|
|
38
29
|
|
|
39
30
|
useHeader(t(`header.selectWallet`));
|
|
40
31
|
|
|
41
|
-
const isDesktopView = useMediaQuery((theme: Theme) =>
|
|
42
|
-
theme.breakpoints.up('sm'),
|
|
43
|
-
);
|
|
44
|
-
|
|
45
32
|
const closeDialog = () => {
|
|
46
33
|
setWalletIdentity((state) => ({
|
|
47
34
|
...state,
|
|
@@ -56,52 +43,7 @@ export const SelectWalletPage = () => {
|
|
|
56
43
|
});
|
|
57
44
|
}, []);
|
|
58
45
|
|
|
59
|
-
const wallets =
|
|
60
|
-
const evmInstalled = isItemAllowed(ChainType.EVM, chains?.types)
|
|
61
|
-
? connectors.filter(
|
|
62
|
-
(connector) =>
|
|
63
|
-
isWalletInstalled(connector.id) &&
|
|
64
|
-
// We should not show already connected connectors
|
|
65
|
-
account.connector?.id !== connector.id,
|
|
66
|
-
)
|
|
67
|
-
: [];
|
|
68
|
-
const evmNotDetected = isItemAllowed(ChainType.EVM, chains?.types)
|
|
69
|
-
? connectors.filter((connector) => !isWalletInstalled(connector.id))
|
|
70
|
-
: [];
|
|
71
|
-
const svmInstalled = isItemAllowed(ChainType.SVM, chains?.types)
|
|
72
|
-
? solanaWallets?.filter(
|
|
73
|
-
(connector) =>
|
|
74
|
-
connector.adapter.readyState === WalletReadyState.Installed &&
|
|
75
|
-
// We should not show already connected connectors
|
|
76
|
-
!connector.adapter.connected,
|
|
77
|
-
)
|
|
78
|
-
: [];
|
|
79
|
-
const svmNotDetected = isItemAllowed(ChainType.SVM, chains?.types)
|
|
80
|
-
? solanaWallets?.filter(
|
|
81
|
-
(connector) =>
|
|
82
|
-
connector.adapter.readyState !== WalletReadyState.Installed,
|
|
83
|
-
)
|
|
84
|
-
: [];
|
|
85
|
-
|
|
86
|
-
const installedWallets = [...evmInstalled, ...svmInstalled].sort(
|
|
87
|
-
walletComparator,
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
if (isDesktopView) {
|
|
91
|
-
const notDetectedWallets = [...evmNotDetected, ...svmNotDetected].sort(
|
|
92
|
-
walletComparator,
|
|
93
|
-
);
|
|
94
|
-
installedWallets.push(...notDetectedWallets);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return installedWallets;
|
|
98
|
-
}, [
|
|
99
|
-
account.connector?.id,
|
|
100
|
-
chains?.types,
|
|
101
|
-
connectors,
|
|
102
|
-
isDesktopView,
|
|
103
|
-
solanaWallets,
|
|
104
|
-
]);
|
|
46
|
+
const wallets = useWallets(walletConfig, chains);
|
|
105
47
|
|
|
106
48
|
return (
|
|
107
49
|
<PageContainer disableGutters>
|
|
@@ -114,9 +56,9 @@ export const SelectWalletPage = () => {
|
|
|
114
56
|
}}
|
|
115
57
|
>
|
|
116
58
|
{wallets?.map((connector) =>
|
|
117
|
-
(connector as Connector).
|
|
59
|
+
(connector as Connector).id ? (
|
|
118
60
|
<EVMListItemButton
|
|
119
|
-
key={(connector as Connector).
|
|
61
|
+
key={(connector as Connector).id}
|
|
120
62
|
connector={connector as Connector}
|
|
121
63
|
connectedConnector={account.connector}
|
|
122
64
|
onNotInstalled={handleNotInstalled}
|
|
@@ -9,6 +9,7 @@ import { Button, ListItemAvatar, ListItemText, MenuItem } from '@mui/material';
|
|
|
9
9
|
import { useId, useRef, useState } from 'react';
|
|
10
10
|
import { useTranslation } from 'react-i18next';
|
|
11
11
|
import { useNavigate } from 'react-router-dom';
|
|
12
|
+
|
|
12
13
|
import { AccountAvatar } from '../../components/Avatar/AccountAvatar.js';
|
|
13
14
|
import type { BottomSheetBase } from '../../components/BottomSheet/types.js';
|
|
14
15
|
import { ListItemButton } from '../../components/ListItem//ListItemButton.js';
|
|
@@ -17,6 +18,7 @@ import { Menu } from '../../components/Menu.js';
|
|
|
17
18
|
import { useChains } from '../../hooks/useChains.js';
|
|
18
19
|
import { useHeader } from '../../hooks/useHeader.js';
|
|
19
20
|
import { useToAddressRequirements } from '../../hooks/useToAddressRequirements.js';
|
|
21
|
+
import { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js';
|
|
20
22
|
import type { Bookmark } from '../../stores/bookmarks/types.js';
|
|
21
23
|
import { useBookmarkActions } from '../../stores/bookmarks/useBookmarkActions.js';
|
|
22
24
|
import { useBookmarks } from '../../stores/bookmarks/useBookmarks.js';
|
|
@@ -28,9 +30,9 @@ import { BookmarkAddressSheet } from './BookmarkAddressSheet.js';
|
|
|
28
30
|
import { EmptyListIndicator } from './EmptyListIndicator.js';
|
|
29
31
|
import {
|
|
30
32
|
BookmarkButtonContainer,
|
|
31
|
-
|
|
33
|
+
BookmarksListContainer,
|
|
34
|
+
FullHeightAdjustablePageContainer,
|
|
32
35
|
OptionsMenuButton,
|
|
33
|
-
SendToWalletPageContainer,
|
|
34
36
|
} from './SendToWalletPage.style.js';
|
|
35
37
|
|
|
36
38
|
export const BookmarksPage = () => {
|
|
@@ -45,6 +47,7 @@ export const BookmarksPage = () => {
|
|
|
45
47
|
const navigate = useNavigate();
|
|
46
48
|
const { setFieldValue } = useFieldActions();
|
|
47
49
|
const { setSendToWallet } = useSendToWalletActions();
|
|
50
|
+
const { variant } = useWidgetConfig();
|
|
48
51
|
|
|
49
52
|
useHeader(t(`header.bookmarkedWallets`));
|
|
50
53
|
|
|
@@ -102,8 +105,11 @@ export const BookmarksPage = () => {
|
|
|
102
105
|
};
|
|
103
106
|
|
|
104
107
|
return (
|
|
105
|
-
<
|
|
106
|
-
|
|
108
|
+
<FullHeightAdjustablePageContainer
|
|
109
|
+
disableGutters
|
|
110
|
+
enableFullHeight={variant !== 'drawer'}
|
|
111
|
+
>
|
|
112
|
+
<BookmarksListContainer>
|
|
107
113
|
{bookmarks.map((bookmark) => (
|
|
108
114
|
<ListItem key={bookmark.address} sx={{ position: 'relative' }}>
|
|
109
115
|
<ListItemButton
|
|
@@ -178,7 +184,7 @@ export const BookmarksPage = () => {
|
|
|
178
184
|
{t('button.delete')}
|
|
179
185
|
</MenuItem>
|
|
180
186
|
</Menu>
|
|
181
|
-
</
|
|
187
|
+
</BookmarksListContainer>
|
|
182
188
|
<BookmarkButtonContainer>
|
|
183
189
|
<Button variant="contained" onClick={handleAddBookmark}>
|
|
184
190
|
{t('sendToWallet.addBookmark')}
|
|
@@ -188,6 +194,6 @@ export const BookmarksPage = () => {
|
|
|
188
194
|
ref={bookmarkAddressSheetRef}
|
|
189
195
|
onAddBookmark={addBookmark}
|
|
190
196
|
/>
|
|
191
|
-
</
|
|
197
|
+
</FullHeightAdjustablePageContainer>
|
|
192
198
|
);
|
|
193
199
|
};
|
|
@@ -38,6 +38,22 @@ export const SendToWalletPageContainer = styled(
|
|
|
38
38
|
gap: theme.spacing(1),
|
|
39
39
|
}));
|
|
40
40
|
|
|
41
|
+
interface FullHeightAdjustablePageContainerProps extends PageContainerProps {
|
|
42
|
+
enableFullHeight?: boolean;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const FullHeightAdjustablePageContainer = styled(
|
|
46
|
+
SendToWalletPageContainer,
|
|
47
|
+
)<FullHeightAdjustablePageContainerProps>(({ theme, enableFullHeight }) => ({
|
|
48
|
+
justifyContent: 'space-between',
|
|
49
|
+
...(enableFullHeight && theme.container?.height === '100%'
|
|
50
|
+
? {
|
|
51
|
+
justifyContent: 'space-between',
|
|
52
|
+
height: '100%',
|
|
53
|
+
}
|
|
54
|
+
: {}),
|
|
55
|
+
}));
|
|
56
|
+
|
|
41
57
|
export const SendToWalletCard = styled(InputCard)({
|
|
42
58
|
display: 'flex',
|
|
43
59
|
flexDirection: 'column',
|
|
@@ -92,21 +108,25 @@ export const SheetAddressContainer = styled(Box)(() => ({
|
|
|
92
108
|
export const ListContainer = styled(List)(({ theme }) => ({
|
|
93
109
|
display: 'flex',
|
|
94
110
|
flexDirection: 'column',
|
|
111
|
+
padding: 0,
|
|
95
112
|
minHeight: 400,
|
|
96
|
-
|
|
97
|
-
|
|
113
|
+
}));
|
|
114
|
+
|
|
115
|
+
export const BookmarksListContainer = styled(ListContainer)(({ theme }) => ({
|
|
116
|
+
...(theme.container?.height === '100%'
|
|
117
|
+
? { minHeight: 360, height: 360, flexGrow: 1, overflow: 'auto' }
|
|
118
|
+
: { minHeight: 440 }),
|
|
98
119
|
}));
|
|
99
120
|
|
|
100
121
|
export const BookmarkButtonContainer = styled(Box)(({ theme }) => ({
|
|
101
122
|
background: theme.palette.background.default,
|
|
102
123
|
display: 'flex',
|
|
103
124
|
flexDirection: 'column',
|
|
104
|
-
flexGrow: 1,
|
|
105
|
-
position: 'sticky',
|
|
106
125
|
bottom: 0,
|
|
107
126
|
padding: theme.spacing(0, 3, 3),
|
|
108
|
-
marginBottom: theme.spacing(-5.25),
|
|
109
127
|
zIndex: 2,
|
|
128
|
+
position: 'sticky',
|
|
129
|
+
width: '100%',
|
|
110
130
|
}));
|
|
111
131
|
|
|
112
132
|
export const EmptyContainer = styled(Box)(({ theme }) => ({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Error, History, TurnedIn, Wallet } from '@mui/icons-material';
|
|
2
|
-
import { Tooltip, Typography } from '@mui/material';
|
|
2
|
+
import { Box, Tooltip, Typography } from '@mui/material';
|
|
3
3
|
import type { ChangeEvent } from 'react';
|
|
4
4
|
import { useRef, useState } from 'react';
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
import { useChain } from '../../hooks/useChain.js';
|
|
16
16
|
import { useHeader } from '../../hooks/useHeader.js';
|
|
17
17
|
import { useToAddressRequirements } from '../../hooks/useToAddressRequirements.js';
|
|
18
|
+
import { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js';
|
|
18
19
|
import type { Bookmark } from '../../stores/bookmarks/types.js';
|
|
19
20
|
import { useBookmarkActions } from '../../stores/bookmarks/useBookmarkActions.js';
|
|
20
21
|
import { useBookmarks } from '../../stores/bookmarks/useBookmarks.js';
|
|
@@ -25,10 +26,10 @@ import { BookmarkAddressSheet } from './BookmarkAddressSheet.js';
|
|
|
25
26
|
import { ConfirmAddressSheet } from './ConfirmAddressSheet.js';
|
|
26
27
|
import {
|
|
27
28
|
AddressInput,
|
|
29
|
+
FullHeightAdjustablePageContainer,
|
|
28
30
|
SendToWalletButtonRow,
|
|
29
31
|
SendToWalletCard,
|
|
30
32
|
SendToWalletIconButton,
|
|
31
|
-
SendToWalletPageContainer,
|
|
32
33
|
ValidationAlert,
|
|
33
34
|
} from './SendToWalletPage.style.js';
|
|
34
35
|
|
|
@@ -59,6 +60,7 @@ export const SendToWalletPage = () => {
|
|
|
59
60
|
const { chain: toChain } = useChain(toChainId);
|
|
60
61
|
const [isDoneButtonLoading, setIsDoneButtonLoading] = useState(false);
|
|
61
62
|
const [isBookmarkButtonLoading, setIsBookmarkButtonLoading] = useState(false);
|
|
63
|
+
const { variant } = useWidgetConfig();
|
|
62
64
|
|
|
63
65
|
useHeader(t(`header.sendToWallet`));
|
|
64
66
|
|
|
@@ -181,7 +183,10 @@ export const SendToWalletPage = () => {
|
|
|
181
183
|
});
|
|
182
184
|
|
|
183
185
|
return (
|
|
184
|
-
<
|
|
186
|
+
<FullHeightAdjustablePageContainer
|
|
187
|
+
bottomGutters
|
|
188
|
+
enableFullHeight={variant !== 'drawer'}
|
|
189
|
+
>
|
|
185
190
|
<SendToWalletCard
|
|
186
191
|
type={errorMessage ? 'error' : 'default'}
|
|
187
192
|
sx={{
|
|
@@ -238,35 +243,39 @@ export const SendToWalletPage = () => {
|
|
|
238
243
|
onAddBookmark={handleAddBookmark}
|
|
239
244
|
/>
|
|
240
245
|
</SendToWalletCard>
|
|
241
|
-
<
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
246
|
+
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 1 }}>
|
|
247
|
+
<CardButton
|
|
248
|
+
title={t('header.recentWallets')}
|
|
249
|
+
icon={<History />}
|
|
250
|
+
onClick={handleRecentWalletsClick}
|
|
251
|
+
>
|
|
252
|
+
{!!recentWallets.length && (
|
|
253
|
+
<Typography color="text.secondary">
|
|
254
|
+
{recentWallets.length}
|
|
255
|
+
</Typography>
|
|
256
|
+
)}
|
|
257
|
+
</CardButton>
|
|
258
|
+
<CardButton
|
|
259
|
+
title={t('sendToWallet.connectedWallets')}
|
|
260
|
+
icon={<Wallet />}
|
|
261
|
+
onClick={handleConnectedWalletsClick}
|
|
262
|
+
>
|
|
263
|
+
{!!connectedWallets.length && (
|
|
264
|
+
<Typography color="text.secondary">
|
|
265
|
+
{connectedWallets.length}
|
|
266
|
+
</Typography>
|
|
267
|
+
)}
|
|
268
|
+
</CardButton>
|
|
269
|
+
<CardButton
|
|
270
|
+
title={t('header.bookmarkedWallets')}
|
|
271
|
+
icon={<TurnedIn />}
|
|
272
|
+
onClick={handleBookmarkedWalletsClick}
|
|
273
|
+
>
|
|
274
|
+
{!!bookmarks.length && (
|
|
275
|
+
<Typography color="text.secondary">{bookmarks.length}</Typography>
|
|
276
|
+
)}
|
|
277
|
+
</CardButton>
|
|
278
|
+
</Box>
|
|
279
|
+
</FullHeightAdjustablePageContainer>
|
|
271
280
|
);
|
|
272
281
|
};
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
import { useTranslation } from 'react-i18next';
|
|
13
13
|
import { BottomSheet } from '../../components/BottomSheet/BottomSheet.js';
|
|
14
14
|
import type { BottomSheetBase } from '../../components/BottomSheet/types.js';
|
|
15
|
-
import { useSetContentHeight } from '../../hooks/
|
|
15
|
+
import { useSetContentHeight } from '../../hooks/useSetContentHeight.js';
|
|
16
16
|
import { formatTokenAmount } from '../../utils/format.js';
|
|
17
17
|
import { CenterContainer, IconCircle } from './StatusBottomSheet.style.js';
|
|
18
18
|
|