@lifi/widget 2.1.3 → 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.
@@ -6,9 +6,13 @@ const material_1 = require("@mui/material");
6
6
  const hooks_1 = require("../../hooks");
7
7
  const FundsSufficiencyMessage_1 = require("./FundsSufficiencyMessage");
8
8
  const GasSufficiencyMessage_1 = require("./GasSufficiencyMessage");
9
+ const providers_1 = require("../../providers");
9
10
  const GasMessage = ({ route, ...props }) => {
10
11
  const { insufficientGas } = (0, hooks_1.useGasSufficiency)(route);
11
12
  const { insufficientFunds } = (0, hooks_1.useFundsSufficiency)(route);
12
- return ((0, jsx_runtime_1.jsx)(material_1.Collapse, { timeout: 225, in: Boolean(insufficientFunds || insufficientGas?.length), unmountOnExit: true, mountOnEnter: true, children: (0, jsx_runtime_1.jsx)(material_1.Box, { ...props, children: insufficientFunds ? ((0, jsx_runtime_1.jsx)(FundsSufficiencyMessage_1.FundsSufficiencyMessage, {})) : insufficientGas?.length ? ((0, jsx_runtime_1.jsx)(GasSufficiencyMessage_1.GasSufficiencyMessage, { insufficientGas: insufficientGas })) : null }) }));
13
+ const { sdkConfig } = (0, providers_1.useWidgetConfig)();
14
+ const isMultisigSigner = sdkConfig?.multisigConfig?.isMultisigSigner;
15
+ const validInsufficientGas = insufficientGas?.length && !isMultisigSigner;
16
+ return ((0, jsx_runtime_1.jsx)(material_1.Collapse, { timeout: 225, in: Boolean(insufficientFunds || validInsufficientGas), unmountOnExit: true, mountOnEnter: true, children: (0, jsx_runtime_1.jsx)(material_1.Box, { ...props, children: insufficientFunds ? ((0, jsx_runtime_1.jsx)(FundsSufficiencyMessage_1.FundsSufficiencyMessage, {})) : validInsufficientGas ? ((0, jsx_runtime_1.jsx)(GasSufficiencyMessage_1.GasSufficiencyMessage, { insufficientGas: insufficientGas })) : null }) }));
13
17
  };
14
18
  exports.GasMessage = GasMessage;
@@ -1,2 +1,2 @@
1
1
  export declare const name = "@lifi/widget";
2
- export declare const version = "2.1.3";
2
+ export declare const version = "2.2.0-beta.0";
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = exports.name = void 0;
4
4
  exports.name = '@lifi/widget';
5
- exports.version = '2.1.3';
5
+ exports.version = '2.2.0-beta.0';
@@ -16,9 +16,7 @@ const SelectWalletPage = () => {
16
16
  const { navigateBack } = (0, hooks_1.useNavigateBack)();
17
17
  const { connect } = (0, providers_1.useWallet)();
18
18
  const [walletIdentity, setWalletIdentity] = (0, react_1.useState)({ show: false });
19
- // separate into installed and not installed wallets
20
- const installedWallets = wallet_management_1.supportedWallets.filter((wallet) => wallet.installed());
21
- const notInstalledWallets = wallet_management_1.supportedWallets.filter((wallet) => !wallet.installed() && wallet.name !== 'Default Wallet');
19
+ const [wallets, setWallets] = (0, react_1.useState)();
22
20
  const closeDialog = () => {
23
21
  setWalletIdentity((state) => ({
24
22
  ...state,
@@ -26,7 +24,7 @@ const SelectWalletPage = () => {
26
24
  }));
27
25
  };
28
26
  const handleConnect = (0, react_1.useCallback)(async (wallet) => {
29
- const identityCheckPassed = wallet.installed();
27
+ const identityCheckPassed = await wallet.installed();
30
28
  if (!identityCheckPassed) {
31
29
  setWalletIdentity({
32
30
  show: true,
@@ -37,10 +35,19 @@ const SelectWalletPage = () => {
37
35
  navigateBack();
38
36
  await connect(wallet);
39
37
  }, [connect, navigateBack]);
38
+ (0, react_1.useEffect)(() => {
39
+ Promise.all(wallet_management_1.supportedWallets.map((wallet) => wallet.installed())).then((installed) => {
40
+ // separate into installed and not installed wallets
41
+ const installedWallets = wallet_management_1.supportedWallets.filter((_, index) => installed[index]);
42
+ // always remove Default Wallet from not installed Wallets
43
+ const notInstalledWallets = wallet_management_1.supportedWallets.filter((wallet, index) => !installed[index] && wallet.name !== 'Default Wallet');
44
+ setWallets([...installedWallets, ...notInstalledWallets]);
45
+ });
46
+ }, []);
40
47
  return ((0, jsx_runtime_1.jsxs)(material_1.Container, { disableGutters: true, children: [(0, jsx_runtime_1.jsx)(material_1.List, { sx: {
41
48
  paddingLeft: 1.5,
42
49
  paddingRight: 1.5,
43
- }, children: [...installedWallets, ...notInstalledWallets].map((wallet) => ((0, jsx_runtime_1.jsxs)(ListItemButton_1.ListItemButton, { onClick: () => handleConnect(wallet), children: [(0, jsx_runtime_1.jsx)(material_1.ListItemAvatar, { children: (0, jsx_runtime_1.jsx)(material_1.Avatar, { src: wallet.icon.src || wallet.icon, alt: wallet.name, children: wallet.name[0] }) }), (0, jsx_runtime_1.jsx)(ListItemText_1.ListItemText, { primary: wallet.name })] }, wallet.name))) }), (0, jsx_runtime_1.jsxs)(Dialog_1.Dialog, { open: walletIdentity.show, onClose: closeDialog, children: [(0, jsx_runtime_1.jsx)(material_1.DialogContent, { children: (0, jsx_runtime_1.jsx)(material_1.DialogContentText, { children: t('wallet.extensionNotFound', {
50
+ }, children: wallets?.map((wallet) => ((0, jsx_runtime_1.jsxs)(ListItemButton_1.ListItemButton, { onClick: () => handleConnect(wallet), children: [(0, jsx_runtime_1.jsx)(material_1.ListItemAvatar, { children: (0, jsx_runtime_1.jsx)(material_1.Avatar, { src: wallet.icon.src || wallet.icon, alt: wallet.name, children: wallet.name[0] }) }), (0, jsx_runtime_1.jsx)(ListItemText_1.ListItemText, { primary: wallet.name })] }, wallet.name))) }), (0, jsx_runtime_1.jsxs)(Dialog_1.Dialog, { open: walletIdentity.show, onClose: closeDialog, children: [(0, jsx_runtime_1.jsx)(material_1.DialogContent, { children: (0, jsx_runtime_1.jsx)(material_1.DialogContentText, { children: t('wallet.extensionNotFound', {
44
51
  name: walletIdentity.wallet?.name,
45
52
  }) }) }), (0, jsx_runtime_1.jsx)(material_1.DialogActions, { children: (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", onClick: closeDialog, autoFocus: true, children: t('button.ok') }) })] })] }));
46
53
  };
@@ -2,13 +2,17 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StartInsurableTransactionButton = exports.StartTransactionButton = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const providers_1 = require("../../providers");
5
6
  const DefaultTransactionButton_1 = require("../../components/DefaultTransactionButton");
6
7
  const hooks_1 = require("../../hooks");
7
8
  const stores_1 = require("../../stores");
8
9
  const StartTransactionButton = ({ onClick, route, text, loading, }) => {
10
+ const { sdkConfig } = (0, providers_1.useWidgetConfig)();
11
+ const isMultisigSigner = sdkConfig?.multisigConfig?.isMultisigSigner;
9
12
  const { insufficientGas, isInitialLoading: isGasSufficiencyLoading } = (0, hooks_1.useGasSufficiency)(route);
10
13
  const { insufficientFunds, isInitialLoading: isFundsSufficiencyLoading } = (0, hooks_1.useFundsSufficiency)(route);
11
- return ((0, jsx_runtime_1.jsx)(DefaultTransactionButton_1.DefaultTransactionButton, { onClick: onClick, text: text, disabled: insufficientFunds || !!insufficientGas?.length, loading: isFundsSufficiencyLoading || isGasSufficiencyLoading || loading }));
14
+ const shouldDisableButton = !isMultisigSigner && (insufficientFunds || !!insufficientGas?.length);
15
+ return ((0, jsx_runtime_1.jsx)(DefaultTransactionButton_1.DefaultTransactionButton, { onClick: onClick, text: text, disabled: shouldDisableButton, loading: isFundsSufficiencyLoading || isGasSufficiencyLoading || loading }));
12
16
  };
13
17
  exports.StartTransactionButton = StartTransactionButton;
14
18
  const StartInsurableTransactionButton = ({ onClick, text, route, loading, disabled, insurableRouteId }) => {
@@ -3,8 +3,12 @@ import { Box, Collapse } from '@mui/material';
3
3
  import { useFundsSufficiency, useGasSufficiency } from '../../hooks';
4
4
  import { FundsSufficiencyMessage } from './FundsSufficiencyMessage';
5
5
  import { GasSufficiencyMessage } from './GasSufficiencyMessage';
6
+ import { useWidgetConfig } from '../../providers';
6
7
  export const GasMessage = ({ route, ...props }) => {
7
8
  const { insufficientGas } = useGasSufficiency(route);
8
9
  const { insufficientFunds } = useFundsSufficiency(route);
9
- return (_jsx(Collapse, { timeout: 225, in: Boolean(insufficientFunds || insufficientGas?.length), unmountOnExit: true, mountOnEnter: true, children: _jsx(Box, { ...props, children: insufficientFunds ? (_jsx(FundsSufficiencyMessage, {})) : insufficientGas?.length ? (_jsx(GasSufficiencyMessage, { insufficientGas: insufficientGas })) : null }) }));
10
+ const { sdkConfig } = useWidgetConfig();
11
+ const isMultisigSigner = sdkConfig?.multisigConfig?.isMultisigSigner;
12
+ const validInsufficientGas = insufficientGas?.length && !isMultisigSigner;
13
+ return (_jsx(Collapse, { timeout: 225, in: Boolean(insufficientFunds || validInsufficientGas), unmountOnExit: true, mountOnEnter: true, children: _jsx(Box, { ...props, children: insufficientFunds ? (_jsx(FundsSufficiencyMessage, {})) : validInsufficientGas ? (_jsx(GasSufficiencyMessage, { insufficientGas: insufficientGas })) : null }) }));
10
14
  };
@@ -1,2 +1,2 @@
1
1
  export declare const name = "@lifi/widget";
2
- export declare const version = "2.1.3";
2
+ export declare const version = "2.2.0-beta.0";
package/config/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/widget';
2
- export const version = '2.1.3';
2
+ export const version = '2.2.0-beta.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifi/widget",
3
- "version": "2.1.3",
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.1",
47
- "@lifi/wallet-management": "^2.1.3",
48
- "@mui/icons-material": "^5.11.16",
49
- "@mui/lab": "^5.0.0-alpha.134",
50
- "@mui/material": "^5.13.6",
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.6",
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",
@@ -63,7 +63,7 @@
63
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.8"
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
- // separate into installed and not installed wallets
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: [...installedWallets, ...notInstalledWallets].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', {
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
- return (_jsx(DefaultTransactionButton, { onClick: onClick, text: text, disabled: insufficientFunds || !!insufficientGas?.length, loading: isFundsSufficiencyLoading || isGasSufficiencyLoading || loading }));
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]);