@lifi/widget 2.1.2 → 2.2.0-beta.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/cjs/components/GasMessage/GasMessage.js +5 -1
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/i18n/id.json +2 -2
- package/cjs/i18n/zh.json +63 -62
- package/cjs/pages/SelectWalletPage/SelectWalletPage.js +12 -5
- package/cjs/pages/TransactionPage/StartTransactionButton.js +5 -1
- package/components/GasMessage/GasMessage.js +5 -1
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/i18n/id.json +2 -2
- package/i18n/zh.json +63 -62
- package/package.json +9 -9
- package/pages/SelectWalletPage/SelectWalletPage.js +13 -6
- package/pages/TransactionPage/StartTransactionButton.js +5 -1
- package/tsconfig.cjs.tsbuildinfo +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/widget",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0-beta.0",
|
|
4
4
|
"description": "LI.FI Widget for cross-chain bridging and swapping. It will drive your multi-chain strategy and attract new users from everywhere.",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -43,15 +43,15 @@
|
|
|
43
43
|
"@ethersproject/address": "^5.7.0",
|
|
44
44
|
"@ethersproject/experimental": "^5.7.0",
|
|
45
45
|
"@ethersproject/providers": "^5.7.2",
|
|
46
|
-
"@lifi/sdk": "^2.1.0",
|
|
47
|
-
"@lifi/wallet-management": "^2.
|
|
48
|
-
"@mui/icons-material": "^5.
|
|
49
|
-
"@mui/lab": "^5.0.0-alpha.
|
|
50
|
-
"@mui/material": "^5.13.
|
|
46
|
+
"@lifi/sdk": "^2.1.3-beta.0",
|
|
47
|
+
"@lifi/wallet-management": "^2.2.0-beta.0",
|
|
48
|
+
"@mui/icons-material": "^5.13.7",
|
|
49
|
+
"@mui/lab": "^5.0.0-alpha.135",
|
|
50
|
+
"@mui/material": "^5.13.7",
|
|
51
51
|
"@tanstack/react-query": "^4.29.19",
|
|
52
52
|
"@tanstack/react-virtual": "^3.0.0-beta.54",
|
|
53
53
|
"big.js": "^6.2.1",
|
|
54
|
-
"i18next": "^23.2.
|
|
54
|
+
"i18next": "^23.2.7",
|
|
55
55
|
"i18next-browser-languagedetector": "^7.1.0",
|
|
56
56
|
"microdiff": "^1.3.2",
|
|
57
57
|
"mitt": "^3.0.0",
|
|
@@ -60,10 +60,10 @@
|
|
|
60
60
|
"react-hook-form": "^7.45.1",
|
|
61
61
|
"react-i18next": "^13.0.1",
|
|
62
62
|
"react-intersection-observer": "^9.5.2",
|
|
63
|
-
"react-router-dom": "^6.14.
|
|
63
|
+
"react-router-dom": "^6.14.1",
|
|
64
64
|
"react-timer-hook": "^3.0.6",
|
|
65
65
|
"uuid": "^9.0.0",
|
|
66
|
-
"zustand": "^4.3.
|
|
66
|
+
"zustand": "^4.3.9"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
69
|
"@types/react": "^18.0.0",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { supportedWallets } from '@lifi/wallet-management';
|
|
3
3
|
import { Avatar, Button, Container, DialogActions, DialogContent, DialogContentText, List, ListItemAvatar, } from '@mui/material';
|
|
4
|
-
import { useCallback, useState } from 'react';
|
|
4
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
6
6
|
import { Dialog } from '../../components/Dialog';
|
|
7
7
|
import { ListItemButton } from '../../components/ListItemButton';
|
|
@@ -13,9 +13,7 @@ export const SelectWalletPage = () => {
|
|
|
13
13
|
const { navigateBack } = useNavigateBack();
|
|
14
14
|
const { connect } = useWallet();
|
|
15
15
|
const [walletIdentity, setWalletIdentity] = useState({ show: false });
|
|
16
|
-
|
|
17
|
-
const installedWallets = supportedWallets.filter((wallet) => wallet.installed());
|
|
18
|
-
const notInstalledWallets = supportedWallets.filter((wallet) => !wallet.installed() && wallet.name !== 'Default Wallet');
|
|
16
|
+
const [wallets, setWallets] = useState();
|
|
19
17
|
const closeDialog = () => {
|
|
20
18
|
setWalletIdentity((state) => ({
|
|
21
19
|
...state,
|
|
@@ -23,7 +21,7 @@ export const SelectWalletPage = () => {
|
|
|
23
21
|
}));
|
|
24
22
|
};
|
|
25
23
|
const handleConnect = useCallback(async (wallet) => {
|
|
26
|
-
const identityCheckPassed = wallet.installed();
|
|
24
|
+
const identityCheckPassed = await wallet.installed();
|
|
27
25
|
if (!identityCheckPassed) {
|
|
28
26
|
setWalletIdentity({
|
|
29
27
|
show: true,
|
|
@@ -34,10 +32,19 @@ export const SelectWalletPage = () => {
|
|
|
34
32
|
navigateBack();
|
|
35
33
|
await connect(wallet);
|
|
36
34
|
}, [connect, navigateBack]);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
Promise.all(supportedWallets.map((wallet) => wallet.installed())).then((installed) => {
|
|
37
|
+
// separate into installed and not installed wallets
|
|
38
|
+
const installedWallets = supportedWallets.filter((_, index) => installed[index]);
|
|
39
|
+
// always remove Default Wallet from not installed Wallets
|
|
40
|
+
const notInstalledWallets = supportedWallets.filter((wallet, index) => !installed[index] && wallet.name !== 'Default Wallet');
|
|
41
|
+
setWallets([...installedWallets, ...notInstalledWallets]);
|
|
42
|
+
});
|
|
43
|
+
}, []);
|
|
37
44
|
return (_jsxs(Container, { disableGutters: true, children: [_jsx(List, { sx: {
|
|
38
45
|
paddingLeft: 1.5,
|
|
39
46
|
paddingRight: 1.5,
|
|
40
|
-
}, children:
|
|
47
|
+
}, children: wallets?.map((wallet) => (_jsxs(ListItemButton, { onClick: () => handleConnect(wallet), children: [_jsx(ListItemAvatar, { children: _jsx(Avatar, { src: wallet.icon.src || wallet.icon, alt: wallet.name, children: wallet.name[0] }) }), _jsx(ListItemText, { primary: wallet.name })] }, wallet.name))) }), _jsxs(Dialog, { open: walletIdentity.show, onClose: closeDialog, children: [_jsx(DialogContent, { children: _jsx(DialogContentText, { children: t('wallet.extensionNotFound', {
|
|
41
48
|
name: walletIdentity.wallet?.name,
|
|
42
49
|
}) }) }), _jsx(DialogActions, { children: _jsx(Button, { variant: "contained", onClick: closeDialog, autoFocus: true, children: t('button.ok') }) })] })] }));
|
|
43
50
|
};
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useWidgetConfig } from '../../providers';
|
|
2
3
|
import { DefaultTransactionButton } from '../../components/DefaultTransactionButton';
|
|
3
4
|
import { useFundsSufficiency, useGasSufficiency, useRoutes } from '../../hooks';
|
|
4
5
|
import { useRouteExecutionStore } from '../../stores';
|
|
5
6
|
export const StartTransactionButton = ({ onClick, route, text, loading, }) => {
|
|
7
|
+
const { sdkConfig } = useWidgetConfig();
|
|
8
|
+
const isMultisigSigner = sdkConfig?.multisigConfig?.isMultisigSigner;
|
|
6
9
|
const { insufficientGas, isInitialLoading: isGasSufficiencyLoading } = useGasSufficiency(route);
|
|
7
10
|
const { insufficientFunds, isInitialLoading: isFundsSufficiencyLoading } = useFundsSufficiency(route);
|
|
8
|
-
|
|
11
|
+
const shouldDisableButton = !isMultisigSigner && (insufficientFunds || !!insufficientGas?.length);
|
|
12
|
+
return (_jsx(DefaultTransactionButton, { onClick: onClick, text: text, disabled: shouldDisableButton, loading: isFundsSufficiencyLoading || isGasSufficiencyLoading || loading }));
|
|
9
13
|
};
|
|
10
14
|
export const StartInsurableTransactionButton = ({ onClick, text, route, loading, disabled, insurableRouteId }) => {
|
|
11
15
|
const routeExecution = useRouteExecutionStore((state) => state.routes[insurableRouteId]);
|