@lifi/widget 3.6.1 → 3.7.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/AppProvider.tsx +4 -4
- package/AppRoutes.tsx +2 -14
- package/CHANGELOG.md +0 -7
- package/_esm/AppProvider.js +1 -1
- package/_esm/AppProvider.js.map +1 -1
- package/_esm/AppRoutes.js +2 -9
- package/_esm/AppRoutes.js.map +1 -1
- package/_esm/components/ActiveTransactions/ActiveTransactions.style.js +1 -1
- package/_esm/components/ActiveTransactions/ActiveTransactions.style.js.map +1 -1
- package/_esm/components/AmountInput/AmountInputEndAdornment.js +1 -3
- package/_esm/components/AmountInput/AmountInputEndAdornment.js.map +1 -1
- package/_esm/components/Avatar/AccountAvatar.d.ts +1 -1
- package/_esm/components/Avatar/AccountAvatar.js +1 -1
- package/_esm/components/Avatar/AccountAvatar.js.map +1 -1
- package/_esm/components/Avatar/Avatar.d.ts +1 -0
- package/_esm/components/Avatar/Avatar.js +7 -4
- package/_esm/components/Avatar/Avatar.js.map +1 -1
- package/_esm/components/Avatar/Avatar.style.d.ts +6 -3
- package/_esm/components/Avatar/Avatar.style.js +19 -6
- package/_esm/components/Avatar/Avatar.style.js.map +1 -1
- package/_esm/components/Avatar/SmallAvatar.d.ts +4 -0
- package/_esm/components/Avatar/SmallAvatar.js +12 -0
- package/_esm/components/Avatar/SmallAvatar.js.map +1 -0
- package/_esm/components/Avatar/TokenAvatar.js +1 -1
- package/_esm/components/Avatar/TokenAvatar.js.map +1 -1
- package/_esm/components/BaseTransactionButton/BaseTransactionButton.js +3 -5
- package/_esm/components/BaseTransactionButton/BaseTransactionButton.js.map +1 -1
- package/_esm/components/ChainSelect/useChainSelect.js +5 -1
- package/_esm/components/ChainSelect/useChainSelect.js.map +1 -1
- package/_esm/components/FeeBreakdownTooltip.js +4 -1
- package/_esm/components/FeeBreakdownTooltip.js.map +1 -1
- package/_esm/components/Header/EVMDisconnectIconButton.js +5 -4
- package/_esm/components/Header/EVMDisconnectIconButton.js.map +1 -1
- package/_esm/components/Header/NavigationHeader.js +1 -1
- package/_esm/components/Header/NavigationHeader.js.map +1 -1
- package/_esm/components/Header/UTXODisconnectIconButton.d.ts +4 -0
- package/_esm/components/Header/UTXODisconnectIconButton.js +13 -0
- package/_esm/components/Header/UTXODisconnectIconButton.js.map +1 -0
- package/_esm/components/Header/WalletHeader.js +5 -9
- package/_esm/components/Header/WalletHeader.js.map +1 -1
- package/_esm/components/Header/WalletMenu.js +10 -15
- package/_esm/components/Header/WalletMenu.js.map +1 -1
- package/_esm/components/Header/WalletMenu.style.js +5 -1
- package/_esm/components/Header/WalletMenu.style.js.map +1 -1
- package/_esm/components/Routes/RoutesExpanded.js +1 -1
- package/_esm/components/Routes/RoutesExpanded.js.map +1 -1
- package/_esm/components/SendToWallet/SendToWalletButton.js +1 -1
- package/_esm/components/SendToWallet/SendToWalletButton.js.map +1 -1
- package/_esm/components/StepActions/StepActions.js +1 -1
- package/_esm/components/StepActions/StepActions.js.map +1 -1
- package/_esm/components/Tabs/Tabs.style.d.ts +1 -1
- package/_esm/components/Token/Token.js +1 -1
- package/_esm/components/Token/Token.js.map +1 -1
- package/_esm/components/TokenList/TokenList.js +1 -1
- package/_esm/components/TokenList/TokenList.js.map +1 -1
- package/_esm/components/TokenList/TokenListItem.js +11 -5
- package/_esm/components/TokenList/TokenListItem.js.map +1 -1
- package/_esm/components/TokenList/VirtualizedTokenList.js +1 -1
- package/_esm/components/TokenList/VirtualizedTokenList.js.map +1 -1
- package/_esm/components/TokenList/types.d.ts +3 -3
- package/_esm/components/TokenRate/TokenRate.js +2 -2
- package/_esm/components/TokenRate/TokenRate.js.map +1 -1
- 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/hooks/useAvailableChains.d.ts +2 -1
- package/_esm/hooks/useAvailableChains.js +9 -8
- package/_esm/hooks/useAvailableChains.js.map +1 -1
- package/_esm/hooks/useChains.d.ts +4 -3
- package/_esm/hooks/useChains.js +5 -3
- package/_esm/hooks/useChains.js.map +1 -1
- package/_esm/hooks/useFromTokenSufficiency.js +1 -1
- package/_esm/hooks/useFromTokenSufficiency.js.map +1 -1
- package/_esm/hooks/useGasSufficiency.js +3 -3
- package/_esm/hooks/useGasSufficiency.js.map +1 -1
- package/_esm/hooks/useProcessMessage.js +4 -0
- package/_esm/hooks/useProcessMessage.js.map +1 -1
- package/_esm/hooks/useRouteExecution.js +1 -1
- package/_esm/hooks/useRouteExecution.js.map +1 -1
- package/_esm/hooks/useRoutes.js +1 -1
- package/_esm/hooks/useRoutes.js.map +1 -1
- package/_esm/hooks/useTokenBalance.js +1 -1
- package/_esm/hooks/useTokenBalance.js.map +1 -1
- package/_esm/hooks/useTokenBalances.js +1 -1
- package/_esm/hooks/useTokenBalances.js.map +1 -1
- package/_esm/hooks/useTokens.js +1 -1
- package/_esm/hooks/useTokens.js.map +1 -1
- package/_esm/hooks/useTransactionDetails.js +1 -1
- package/_esm/hooks/useTransactionDetails.js.map +1 -1
- package/_esm/hooks/useTransactionHistory.js +1 -1
- package/_esm/hooks/useTransactionHistory.js.map +1 -1
- package/_esm/i18n/en.json +3 -4
- package/_esm/index.d.ts +0 -2
- package/_esm/index.js +0 -2
- package/_esm/index.js.map +1 -1
- package/_esm/pages/RoutesPage/RoutesPage.js +1 -1
- package/_esm/pages/RoutesPage/RoutesPage.js.map +1 -1
- package/_esm/pages/SendToWallet/ConnectedWalletsPage.js +1 -1
- package/_esm/pages/SendToWallet/ConnectedWalletsPage.js.map +1 -1
- package/_esm/pages/SendToWallet/SendToWalletPage.js +1 -1
- package/_esm/pages/SendToWallet/SendToWalletPage.js.map +1 -1
- package/_esm/providers/I18nProvider/types.d.ts +2 -2
- package/_esm/providers/WalletProvider/SDKProviders.js +15 -7
- package/_esm/providers/WalletProvider/SDKProviders.js.map +1 -1
- package/_esm/providers/WalletProvider/UTXOBaseProvider.d.ts +2 -0
- package/_esm/providers/WalletProvider/UTXOBaseProvider.js +17 -0
- package/_esm/providers/WalletProvider/UTXOBaseProvider.js.map +1 -0
- package/_esm/providers/WalletProvider/UTXOExternalContext.d.ts +1 -0
- package/_esm/providers/WalletProvider/UTXOExternalContext.js +3 -0
- package/_esm/providers/WalletProvider/UTXOExternalContext.js.map +1 -0
- package/_esm/providers/WalletProvider/UTXOProvider.d.ts +3 -0
- package/_esm/providers/WalletProvider/UTXOProvider.js +18 -0
- package/_esm/providers/WalletProvider/UTXOProvider.js.map +1 -0
- package/_esm/providers/WalletProvider/WalletProvider.d.ts +1 -0
- package/_esm/providers/WalletProvider/WalletProvider.js +14 -1
- package/_esm/providers/WalletProvider/WalletProvider.js.map +1 -1
- package/_esm/providers/WalletProvider/useHasExternalWalletProvider.d.ts +1 -1
- package/_esm/providers/WalletProvider/useHasExternalWalletProvider.js +8 -3
- package/_esm/providers/WalletProvider/useHasExternalWalletProvider.js.map +1 -1
- package/_esm/providers/WidgetProvider/WidgetProvider.js +2 -1
- package/_esm/providers/WidgetProvider/WidgetProvider.js.map +1 -1
- package/_esm/providers/WidgetProvider/types.d.ts +0 -2
- package/_esm/stores/form/FormUpdater.js +1 -1
- package/_esm/stores/form/FormUpdater.js.map +1 -1
- package/_esm/stores/form/types.d.ts +4 -4
- package/_esm/stores/routes/useExecutingRoutesIds.js +1 -1
- package/_esm/stores/routes/useExecutingRoutesIds.js.map +1 -1
- package/_esm/themes/createTheme.js +2 -1
- package/_esm/themes/createTheme.js.map +1 -1
- package/_esm/types/events.d.ts +6 -0
- package/_esm/types/events.js +3 -0
- package/_esm/types/events.js.map +1 -1
- package/_esm/utils/chainType.js +2 -3
- package/_esm/utils/chainType.js.map +1 -1
- package/_esm/utils/fees.js +9 -5
- package/_esm/utils/fees.js.map +1 -1
- package/_esm/utils/format.js +1 -1
- package/_esm/utils/format.js.map +1 -1
- package/_esm/utils/navigationRoutes.d.ts +0 -1
- package/_esm/utils/navigationRoutes.js +0 -3
- package/_esm/utils/navigationRoutes.js.map +1 -1
- package/_esm/utils/wallet.js +1 -1
- package/components/ActiveTransactions/ActiveTransactions.style.ts +1 -1
- package/components/AmountInput/AmountInputEndAdornment.tsx +1 -5
- package/components/Avatar/AccountAvatar.tsx +2 -2
- package/components/Avatar/Avatar.style.tsx +20 -7
- package/components/Avatar/Avatar.tsx +12 -4
- package/components/Avatar/SmallAvatar.tsx +16 -0
- package/components/Avatar/TokenAvatar.tsx +1 -1
- package/components/BaseTransactionButton/BaseTransactionButton.tsx +3 -5
- package/components/ChainSelect/useChainSelect.ts +10 -1
- package/components/FeeBreakdownTooltip.tsx +4 -1
- package/components/Header/EVMDisconnectIconButton.tsx +5 -5
- package/components/Header/NavigationHeader.tsx +1 -1
- package/components/Header/UTXODisconnectIconButton.tsx +24 -0
- package/components/Header/WalletHeader.tsx +11 -12
- package/components/Header/WalletMenu.style.tsx +5 -1
- package/components/Header/WalletMenu.tsx +23 -24
- package/components/Routes/RoutesExpanded.tsx +1 -2
- package/components/SendToWallet/SendToWalletButton.tsx +1 -1
- package/components/StepActions/StepActions.tsx +1 -1
- package/components/Token/Token.tsx +1 -1
- package/components/TokenList/TokenList.tsx +1 -1
- package/components/TokenList/TokenListItem.tsx +15 -7
- package/components/TokenList/VirtualizedTokenList.tsx +1 -1
- package/components/TokenList/types.ts +3 -3
- package/components/TokenRate/TokenRate.tsx +2 -2
- package/config/version.ts +1 -1
- package/hooks/useAvailableChains.ts +9 -10
- package/hooks/useChains.ts +6 -3
- package/hooks/useFromTokenSufficiency.ts +1 -1
- package/hooks/useGasSufficiency.ts +5 -3
- package/hooks/useProcessMessage.ts +4 -0
- package/hooks/useRouteExecution.ts +1 -1
- package/hooks/useRoutes.ts +1 -1
- package/hooks/useTokenBalance.ts +1 -1
- package/hooks/useTokenBalances.ts +1 -1
- package/hooks/useTokens.ts +2 -1
- package/hooks/useTransactionDetails.ts +1 -1
- package/hooks/useTransactionHistory.ts +1 -1
- package/i18n/en.json +3 -4
- package/index.ts +0 -2
- package/package.json +5 -5
- package/pages/RoutesPage/RoutesPage.tsx +1 -1
- package/pages/SendToWallet/ConnectedWalletsPage.tsx +2 -2
- package/pages/SendToWallet/SendToWalletPage.tsx +1 -1
- package/providers/I18nProvider/types.ts +2 -2
- package/providers/WalletProvider/SDKProviders.tsx +25 -7
- package/providers/WalletProvider/UTXOBaseProvider.tsx +28 -0
- package/providers/WalletProvider/UTXOExternalContext.ts +3 -0
- package/providers/WalletProvider/UTXOProvider.tsx +26 -0
- package/providers/WalletProvider/WalletProvider.tsx +24 -3
- package/providers/WalletProvider/useHasExternalWalletProvider.ts +11 -5
- package/providers/WidgetProvider/WidgetProvider.tsx +2 -1
- package/providers/WidgetProvider/types.ts +0 -2
- package/stores/form/FormUpdater.tsx +1 -1
- package/stores/form/types.ts +4 -4
- package/stores/routes/useExecutingRoutesIds.ts +1 -1
- package/themes/createTheme.ts +3 -1
- package/types/events.ts +6 -0
- package/utils/chainType.ts +2 -3
- package/utils/fees.ts +15 -13
- package/utils/format.ts +1 -1
- package/utils/navigationRoutes.ts +0 -3
- package/utils/wallet.ts +1 -1
- package/_esm/components/SmallAvatar.d.ts +0 -10
- package/_esm/components/SmallAvatar.js +0 -19
- package/_esm/components/SmallAvatar.js.map +0 -1
- package/_esm/hooks/useAccount.d.ts +0 -45
- package/_esm/hooks/useAccount.js +0 -56
- package/_esm/hooks/useAccount.js.map +0 -1
- package/_esm/hooks/useWallets.d.ts +0 -6
- package/_esm/hooks/useWallets.js +0 -80
- package/_esm/hooks/useWallets.js.map +0 -1
- package/_esm/pages/SelectWalletPage/EVMListItemButton.d.ts +0 -9
- package/_esm/pages/SelectWalletPage/EVMListItemButton.js +0 -39
- package/_esm/pages/SelectWalletPage/EVMListItemButton.js.map +0 -1
- package/_esm/pages/SelectWalletPage/SVMListItemButton.d.ts +0 -6
- package/_esm/pages/SelectWalletPage/SVMListItemButton.js +0 -32
- package/_esm/pages/SelectWalletPage/SVMListItemButton.js.map +0 -1
- package/_esm/pages/SelectWalletPage/SelectWalletPage.d.ts +0 -1
- package/_esm/pages/SelectWalletPage/SelectWalletPage.js +0 -41
- package/_esm/pages/SelectWalletPage/SelectWalletPage.js.map +0 -1
- package/_esm/utils/svm.d.ts +0 -1
- package/_esm/utils/svm.js +0 -11
- package/_esm/utils/svm.js.map +0 -1
- package/components/SmallAvatar.tsx +0 -25
- package/hooks/useAccount.ts +0 -109
- package/hooks/useWallets.ts +0 -147
- package/pages/SelectWalletPage/EVMListItemButton.tsx +0 -74
- package/pages/SelectWalletPage/SVMListItemButton.tsx +0 -47
- package/pages/SelectWalletPage/SelectWalletPage.tsx +0 -90
- package/utils/svm.ts +0 -10
package/hooks/useAccount.ts
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { ChainId, ChainType } from '@lifi/sdk';
|
|
2
|
-
import type { WalletAdapter } from '@solana/wallet-adapter-base';
|
|
3
|
-
import { useWallet } from '@solana/wallet-adapter-react';
|
|
4
|
-
import { useMemo } from 'react';
|
|
5
|
-
import type { Chain } from 'viem';
|
|
6
|
-
import type { Connector } from 'wagmi';
|
|
7
|
-
import { useAccount as useWagmiAccount } from 'wagmi';
|
|
8
|
-
|
|
9
|
-
export interface AccountBase {
|
|
10
|
-
address?: string;
|
|
11
|
-
addresses?: readonly string[];
|
|
12
|
-
chain?: Chain;
|
|
13
|
-
chainId?: number;
|
|
14
|
-
chainType?: ChainType;
|
|
15
|
-
isConnected: boolean;
|
|
16
|
-
isConnecting: boolean;
|
|
17
|
-
isDisconnected: boolean;
|
|
18
|
-
isReconnecting: boolean;
|
|
19
|
-
status: 'connected' | 'reconnecting' | 'connecting' | 'disconnected';
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface EVMAccount extends AccountBase {
|
|
23
|
-
chainType: ChainType.EVM;
|
|
24
|
-
connector?: Connector;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface SVMAccount extends AccountBase {
|
|
28
|
-
chainType: ChainType.SVM;
|
|
29
|
-
connector?: WalletAdapter;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface DefaultAccount extends AccountBase {
|
|
33
|
-
connector?: never;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export type Account = EVMAccount | SVMAccount | DefaultAccount;
|
|
37
|
-
|
|
38
|
-
export interface AccountResult {
|
|
39
|
-
account: Account;
|
|
40
|
-
/**
|
|
41
|
-
* Connected accounts
|
|
42
|
-
*/
|
|
43
|
-
accounts: Account[];
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
interface UseAccountArgs {
|
|
47
|
-
chainType?: ChainType;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const defaultAccount: AccountBase = {
|
|
51
|
-
isConnected: false,
|
|
52
|
-
isConnecting: false,
|
|
53
|
-
isReconnecting: false,
|
|
54
|
-
isDisconnected: true,
|
|
55
|
-
status: 'disconnected',
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
*
|
|
60
|
-
* @param args When we provide args we want to return either account with corresponding chainType or default disconnected one
|
|
61
|
-
* @returns - Account result
|
|
62
|
-
*/
|
|
63
|
-
export const useAccount = (args?: UseAccountArgs): AccountResult => {
|
|
64
|
-
const account = useWagmiAccount();
|
|
65
|
-
const { wallet } = useWallet();
|
|
66
|
-
|
|
67
|
-
// We create a simple variable from the args object
|
|
68
|
-
// to avoid re-render useMemo on every object reference change.
|
|
69
|
-
const hasChainTypeArgs = Boolean(args);
|
|
70
|
-
|
|
71
|
-
return useMemo(() => {
|
|
72
|
-
const svm: Account = wallet?.adapter.publicKey
|
|
73
|
-
? {
|
|
74
|
-
address: wallet?.adapter.publicKey.toString(),
|
|
75
|
-
chainId: ChainId.SOL,
|
|
76
|
-
chainType: ChainType.SVM,
|
|
77
|
-
connector: wallet?.adapter,
|
|
78
|
-
isConnected: Boolean(wallet?.adapter.publicKey),
|
|
79
|
-
isConnecting: false,
|
|
80
|
-
isReconnecting: false,
|
|
81
|
-
isDisconnected: !wallet,
|
|
82
|
-
status: 'connected',
|
|
83
|
-
}
|
|
84
|
-
: {
|
|
85
|
-
chainType: ChainType.SVM,
|
|
86
|
-
isConnected: false,
|
|
87
|
-
isConnecting: false,
|
|
88
|
-
isReconnecting: false,
|
|
89
|
-
isDisconnected: true,
|
|
90
|
-
status: 'disconnected',
|
|
91
|
-
};
|
|
92
|
-
const evm: Account = { ...account, chainType: ChainType.EVM };
|
|
93
|
-
const accounts = [evm, svm];
|
|
94
|
-
const connectedAccounts = [evm, svm].filter(
|
|
95
|
-
(account) => account.isConnected && account.address,
|
|
96
|
-
);
|
|
97
|
-
return {
|
|
98
|
-
account:
|
|
99
|
-
accounts.find(
|
|
100
|
-
(account) =>
|
|
101
|
-
(!hasChainTypeArgs || account.chainType === args?.chainType) &&
|
|
102
|
-
account.isConnected &&
|
|
103
|
-
account.address,
|
|
104
|
-
) ?? defaultAccount,
|
|
105
|
-
// We need to return only connected account list
|
|
106
|
-
accounts: connectedAccounts,
|
|
107
|
-
};
|
|
108
|
-
}, [account, args?.chainType, hasChainTypeArgs, wallet]);
|
|
109
|
-
};
|
package/hooks/useWallets.ts
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import { ChainType } from '@lifi/sdk';
|
|
2
|
-
import type { CreateConnectorFnExtended } from '@lifi/wallet-management';
|
|
3
|
-
import {
|
|
4
|
-
createCoinbaseConnector,
|
|
5
|
-
createMetaMaskConnector,
|
|
6
|
-
createWalletConnectConnector,
|
|
7
|
-
getWalletPriority,
|
|
8
|
-
isWalletInstalled,
|
|
9
|
-
} from '@lifi/wallet-management';
|
|
10
|
-
import type { Theme } from '@mui/material';
|
|
11
|
-
import { useMediaQuery } from '@mui/material';
|
|
12
|
-
import { WalletReadyState } from '@solana/wallet-adapter-base';
|
|
13
|
-
import type { Wallet } from '@solana/wallet-adapter-react';
|
|
14
|
-
import { useWallet } from '@solana/wallet-adapter-react';
|
|
15
|
-
import { useMemo } from 'react';
|
|
16
|
-
import type { Connector } from 'wagmi';
|
|
17
|
-
import { useConnect, useAccount as useWagmiAccount } from 'wagmi';
|
|
18
|
-
import { defaultCoinbaseConfig } from '../config/coinbase.js';
|
|
19
|
-
import { defaultMetaMaskConfig } from '../config/metaMask.js';
|
|
20
|
-
import { defaultWalletConnectConfig } from '../config/walletConnect.js';
|
|
21
|
-
import type { WidgetChains, WidgetWalletConfig } from '../types/widget.js';
|
|
22
|
-
import { isItemAllowed } from '../utils/item.js';
|
|
23
|
-
|
|
24
|
-
export const useWallets = (
|
|
25
|
-
walletConfig?: WidgetWalletConfig,
|
|
26
|
-
chains?: WidgetChains,
|
|
27
|
-
) => {
|
|
28
|
-
const account = useWagmiAccount();
|
|
29
|
-
const { connectors } = useConnect();
|
|
30
|
-
const { wallets: solanaWallets } = useWallet();
|
|
31
|
-
|
|
32
|
-
const isDesktopView = useMediaQuery((theme: Theme) =>
|
|
33
|
-
theme.breakpoints.up('sm'),
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
const wallets = useMemo(() => {
|
|
37
|
-
const evmConnectors: (CreateConnectorFnExtended | Connector)[] =
|
|
38
|
-
Array.from(connectors);
|
|
39
|
-
if (
|
|
40
|
-
!connectors.some((connector) =>
|
|
41
|
-
connector.id.toLowerCase().includes('walletconnect'),
|
|
42
|
-
)
|
|
43
|
-
) {
|
|
44
|
-
evmConnectors.unshift(
|
|
45
|
-
createWalletConnectConnector(
|
|
46
|
-
walletConfig?.walletConnect ?? defaultWalletConnectConfig,
|
|
47
|
-
),
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
if (
|
|
51
|
-
!connectors.some((connector) =>
|
|
52
|
-
connector.id.toLowerCase().includes('coinbase'),
|
|
53
|
-
) &&
|
|
54
|
-
!isWalletInstalled('coinbase')
|
|
55
|
-
) {
|
|
56
|
-
evmConnectors.unshift(
|
|
57
|
-
createCoinbaseConnector(
|
|
58
|
-
walletConfig?.coinbase ?? defaultCoinbaseConfig,
|
|
59
|
-
),
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
if (
|
|
63
|
-
!connectors.some((connector) =>
|
|
64
|
-
connector.id.toLowerCase().includes('metamask'),
|
|
65
|
-
) &&
|
|
66
|
-
!isWalletInstalled('metaMask')
|
|
67
|
-
) {
|
|
68
|
-
evmConnectors.unshift(
|
|
69
|
-
createMetaMaskConnector(
|
|
70
|
-
walletConfig?.metaMask ?? defaultMetaMaskConfig,
|
|
71
|
-
),
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
const evmInstalled = isItemAllowed(ChainType.EVM, chains?.types)
|
|
75
|
-
? evmConnectors.filter(
|
|
76
|
-
(connector) =>
|
|
77
|
-
isWalletInstalled(connector.id!) &&
|
|
78
|
-
// We should not show already connected connectors
|
|
79
|
-
account.connector?.id !== connector.id,
|
|
80
|
-
)
|
|
81
|
-
: [];
|
|
82
|
-
const evmNotDetected = isItemAllowed(ChainType.EVM, chains?.types)
|
|
83
|
-
? evmConnectors.filter((connector) => !isWalletInstalled(connector.id!))
|
|
84
|
-
: [];
|
|
85
|
-
const svmInstalled = isItemAllowed(ChainType.SVM, chains?.types)
|
|
86
|
-
? solanaWallets?.filter(
|
|
87
|
-
(connector) =>
|
|
88
|
-
connector.adapter.readyState === WalletReadyState.Installed &&
|
|
89
|
-
// We should not show already connected connectors
|
|
90
|
-
!connector.adapter.connected,
|
|
91
|
-
)
|
|
92
|
-
: [];
|
|
93
|
-
const svmNotDetected = isItemAllowed(ChainType.SVM, chains?.types)
|
|
94
|
-
? solanaWallets?.filter(
|
|
95
|
-
(connector) =>
|
|
96
|
-
connector.adapter.readyState !== WalletReadyState.Installed,
|
|
97
|
-
)
|
|
98
|
-
: [];
|
|
99
|
-
|
|
100
|
-
const installedWallets = [...evmInstalled, ...svmInstalled].sort(
|
|
101
|
-
walletComparator,
|
|
102
|
-
);
|
|
103
|
-
|
|
104
|
-
if (isDesktopView) {
|
|
105
|
-
const notDetectedWallets = [...evmNotDetected, ...svmNotDetected].sort(
|
|
106
|
-
walletComparator,
|
|
107
|
-
);
|
|
108
|
-
installedWallets.push(...notDetectedWallets);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return installedWallets;
|
|
112
|
-
}, [
|
|
113
|
-
account.connector?.id,
|
|
114
|
-
chains?.types,
|
|
115
|
-
connectors,
|
|
116
|
-
isDesktopView,
|
|
117
|
-
solanaWallets,
|
|
118
|
-
walletConfig?.coinbase,
|
|
119
|
-
walletConfig?.metaMask,
|
|
120
|
-
walletConfig?.walletConnect,
|
|
121
|
-
]);
|
|
122
|
-
|
|
123
|
-
return wallets;
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
export const walletComparator = (
|
|
127
|
-
a: CreateConnectorFnExtended | Connector | Wallet,
|
|
128
|
-
b: CreateConnectorFnExtended | Connector | Wallet,
|
|
129
|
-
) => {
|
|
130
|
-
let aId = (a as Connector).id || (a as Wallet).adapter?.name;
|
|
131
|
-
let bId = (b as Connector).id || (b as Wallet).adapter?.name;
|
|
132
|
-
|
|
133
|
-
const priorityA = getWalletPriority(aId);
|
|
134
|
-
const priorityB = getWalletPriority(bId);
|
|
135
|
-
|
|
136
|
-
if (priorityA !== priorityB) {
|
|
137
|
-
return priorityA - priorityB;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if (aId < bId) {
|
|
141
|
-
return -1;
|
|
142
|
-
}
|
|
143
|
-
if (aId > bId) {
|
|
144
|
-
return 1;
|
|
145
|
-
}
|
|
146
|
-
return 0;
|
|
147
|
-
};
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { ChainType } from '@lifi/sdk';
|
|
2
|
-
import type { CreateConnectorFnExtended } from '@lifi/wallet-management';
|
|
3
|
-
import {
|
|
4
|
-
getConnectorIcon,
|
|
5
|
-
isWalletInstalledAsync,
|
|
6
|
-
} from '@lifi/wallet-management';
|
|
7
|
-
import { Avatar, ListItemAvatar } from '@mui/material';
|
|
8
|
-
import type { Connector } from 'wagmi';
|
|
9
|
-
import { useConnect, useDisconnect } from 'wagmi';
|
|
10
|
-
import { ListItemButton } from '../../components/ListItemButton.js';
|
|
11
|
-
import { ListItemText } from '../../components/ListItemText.js';
|
|
12
|
-
import { useNavigateBack } from '../../hooks/useNavigateBack.js';
|
|
13
|
-
import { useWidgetEvents } from '../../hooks/useWidgetEvents.js';
|
|
14
|
-
import { WidgetEvent } from '../../types/events.js';
|
|
15
|
-
|
|
16
|
-
interface EVMListItemButtonProps {
|
|
17
|
-
connectedConnector?: Connector;
|
|
18
|
-
connector: CreateConnectorFnExtended | Connector;
|
|
19
|
-
onNotInstalled(connector: Connector): void;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const EVMListItemButton = ({
|
|
23
|
-
connectedConnector,
|
|
24
|
-
connector,
|
|
25
|
-
onNotInstalled,
|
|
26
|
-
}: EVMListItemButtonProps) => {
|
|
27
|
-
const { navigateBack } = useNavigateBack();
|
|
28
|
-
const emitter = useWidgetEvents();
|
|
29
|
-
const { connectAsync } = useConnect();
|
|
30
|
-
const { disconnectAsync } = useDisconnect();
|
|
31
|
-
|
|
32
|
-
const handleEVMConnect = async () => {
|
|
33
|
-
const identityCheckPassed = await isWalletInstalledAsync(
|
|
34
|
-
(connector as Connector).id,
|
|
35
|
-
);
|
|
36
|
-
if (!identityCheckPassed) {
|
|
37
|
-
onNotInstalled(connector as Connector);
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
if (connectedConnector) {
|
|
41
|
-
await disconnectAsync({ connector: connectedConnector });
|
|
42
|
-
}
|
|
43
|
-
await connectAsync(
|
|
44
|
-
{ connector },
|
|
45
|
-
{
|
|
46
|
-
onSuccess(data) {
|
|
47
|
-
emitter.emit(WidgetEvent.WalletConnected, {
|
|
48
|
-
address: data.accounts[0],
|
|
49
|
-
chainId: data.chainId,
|
|
50
|
-
chainType: ChainType.EVM,
|
|
51
|
-
});
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
);
|
|
55
|
-
navigateBack();
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const connectorName: string =
|
|
59
|
-
(connector as CreateConnectorFnExtended).displayName || connector.name;
|
|
60
|
-
|
|
61
|
-
return (
|
|
62
|
-
<ListItemButton key={connector.id} onClick={handleEVMConnect}>
|
|
63
|
-
<ListItemAvatar>
|
|
64
|
-
<Avatar
|
|
65
|
-
src={getConnectorIcon(connector as Connector)}
|
|
66
|
-
alt={connectorName}
|
|
67
|
-
>
|
|
68
|
-
{connectorName?.[0]}
|
|
69
|
-
</Avatar>
|
|
70
|
-
</ListItemAvatar>
|
|
71
|
-
<ListItemText primary={connectorName} />
|
|
72
|
-
</ListItemButton>
|
|
73
|
-
);
|
|
74
|
-
};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { ChainId, ChainType } from '@lifi/sdk';
|
|
2
|
-
import { Avatar, ListItemAvatar } from '@mui/material';
|
|
3
|
-
import type { Wallet } from '@solana/wallet-adapter-react';
|
|
4
|
-
import { useWallet } from '@solana/wallet-adapter-react';
|
|
5
|
-
import { ListItemButton } from '../../components/ListItemButton.js';
|
|
6
|
-
import { ListItemText } from '../../components/ListItemText.js';
|
|
7
|
-
import { useNavigateBack } from '../../hooks/useNavigateBack.js';
|
|
8
|
-
import { useWidgetEvents } from '../../hooks/useWidgetEvents.js';
|
|
9
|
-
import { WidgetEvent } from '../../types/events.js';
|
|
10
|
-
|
|
11
|
-
interface SVMListItemButtonProps {
|
|
12
|
-
wallet: Wallet;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const SVMListItemButton = ({ wallet }: SVMListItemButtonProps) => {
|
|
16
|
-
const { navigateBack } = useNavigateBack();
|
|
17
|
-
const emitter = useWidgetEvents();
|
|
18
|
-
const { select, disconnect, connected } = useWallet();
|
|
19
|
-
|
|
20
|
-
const connect = async () => {
|
|
21
|
-
if (connected) {
|
|
22
|
-
await disconnect();
|
|
23
|
-
}
|
|
24
|
-
select(wallet.adapter.name);
|
|
25
|
-
// We use autoConnect on wallet selection
|
|
26
|
-
// await solanaConnect();
|
|
27
|
-
wallet.adapter.once('connect', (publicKey) => {
|
|
28
|
-
emitter.emit(WidgetEvent.WalletConnected, {
|
|
29
|
-
address: publicKey?.toString(),
|
|
30
|
-
chainId: ChainId.SOL,
|
|
31
|
-
chainType: ChainType.SVM,
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
navigateBack();
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<ListItemButton key={wallet.adapter.name} onClick={connect}>
|
|
39
|
-
<ListItemAvatar>
|
|
40
|
-
<Avatar src={wallet.adapter.icon} alt={wallet.adapter.name}>
|
|
41
|
-
{wallet.adapter.name[0]}
|
|
42
|
-
</Avatar>
|
|
43
|
-
</ListItemAvatar>
|
|
44
|
-
<ListItemText primary={`${wallet.adapter.name} (Solana)`} />
|
|
45
|
-
</ListItemButton>
|
|
46
|
-
);
|
|
47
|
-
};
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Button,
|
|
3
|
-
DialogActions,
|
|
4
|
-
DialogContent,
|
|
5
|
-
DialogContentText,
|
|
6
|
-
List,
|
|
7
|
-
} from '@mui/material';
|
|
8
|
-
import type { Wallet } from '@solana/wallet-adapter-react';
|
|
9
|
-
import { useCallback, useState } from 'react';
|
|
10
|
-
import { useTranslation } from 'react-i18next';
|
|
11
|
-
import type { Connector } from 'wagmi';
|
|
12
|
-
import { useAccount as useWagmiAccount } from 'wagmi';
|
|
13
|
-
import { Dialog } from '../../components/Dialog.js';
|
|
14
|
-
import { PageContainer } from '../../components/PageContainer.js';
|
|
15
|
-
import { useHeader } from '../../hooks/useHeader.js';
|
|
16
|
-
import { useWallets } from '../../hooks/useWallets.js';
|
|
17
|
-
import { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js';
|
|
18
|
-
import { EVMListItemButton } from './EVMListItemButton.js';
|
|
19
|
-
import { SVMListItemButton } from './SVMListItemButton.js';
|
|
20
|
-
|
|
21
|
-
export const SelectWalletPage = () => {
|
|
22
|
-
const { t } = useTranslation();
|
|
23
|
-
const { chains, walletConfig } = useWidgetConfig();
|
|
24
|
-
const account = useWagmiAccount();
|
|
25
|
-
const [walletIdentity, setWalletIdentity] = useState<{
|
|
26
|
-
show: boolean;
|
|
27
|
-
connector?: Connector;
|
|
28
|
-
}>({ show: false });
|
|
29
|
-
|
|
30
|
-
useHeader(t(`header.selectWallet`));
|
|
31
|
-
|
|
32
|
-
const closeDialog = () => {
|
|
33
|
-
setWalletIdentity((state) => ({
|
|
34
|
-
...state,
|
|
35
|
-
show: false,
|
|
36
|
-
}));
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const handleNotInstalled = useCallback(async (connector: Connector) => {
|
|
40
|
-
setWalletIdentity({
|
|
41
|
-
show: true,
|
|
42
|
-
connector,
|
|
43
|
-
});
|
|
44
|
-
}, []);
|
|
45
|
-
|
|
46
|
-
const wallets = useWallets(walletConfig, chains);
|
|
47
|
-
|
|
48
|
-
return (
|
|
49
|
-
<PageContainer disableGutters>
|
|
50
|
-
<List
|
|
51
|
-
sx={{
|
|
52
|
-
paddingTop: 0,
|
|
53
|
-
paddingLeft: 1.5,
|
|
54
|
-
paddingRight: 1.5,
|
|
55
|
-
paddingBottom: 1.5,
|
|
56
|
-
}}
|
|
57
|
-
>
|
|
58
|
-
{wallets?.map((connector) =>
|
|
59
|
-
(connector as Connector).id ? (
|
|
60
|
-
<EVMListItemButton
|
|
61
|
-
key={(connector as Connector).id}
|
|
62
|
-
connector={connector as Connector}
|
|
63
|
-
connectedConnector={account.connector}
|
|
64
|
-
onNotInstalled={handleNotInstalled}
|
|
65
|
-
/>
|
|
66
|
-
) : (
|
|
67
|
-
<SVMListItemButton
|
|
68
|
-
key={(connector as Wallet).adapter.name}
|
|
69
|
-
wallet={connector as Wallet}
|
|
70
|
-
/>
|
|
71
|
-
),
|
|
72
|
-
)}
|
|
73
|
-
</List>
|
|
74
|
-
<Dialog open={walletIdentity.show} onClose={closeDialog}>
|
|
75
|
-
<DialogContent>
|
|
76
|
-
<DialogContentText>
|
|
77
|
-
{t('wallet.extensionNotFound', {
|
|
78
|
-
name: walletIdentity.connector?.name,
|
|
79
|
-
})}
|
|
80
|
-
</DialogContentText>
|
|
81
|
-
</DialogContent>
|
|
82
|
-
<DialogActions>
|
|
83
|
-
<Button variant="contained" onClick={closeDialog} autoFocus>
|
|
84
|
-
{t('button.ok')}
|
|
85
|
-
</Button>
|
|
86
|
-
</DialogActions>
|
|
87
|
-
</Dialog>
|
|
88
|
-
</PageContainer>
|
|
89
|
-
);
|
|
90
|
-
};
|