From 97d9788d83aafc09acfbee6c9e5f537727d31766 Mon Sep 17 00:00:00 2001 From: nuanyang233 Date: Tue, 23 Nov 2021 03:13:26 +0800 Subject: [PATCH] fix: select wallet page is empty --- .../EthereumServices/providers/MaskWallet.ts | 4 ++-- .../popups/pages/Wallet/DeleteWallet/index.tsx | 9 +++------ .../popups/pages/Wallet/SelectWallet/index.tsx | 11 ----------- packages/mask/src/plugins/Wallet/services/account.ts | 2 +- 4 files changed, 6 insertions(+), 20 deletions(-) diff --git a/packages/mask/src/extension/background-script/EthereumServices/providers/MaskWallet.ts b/packages/mask/src/extension/background-script/EthereumServices/providers/MaskWallet.ts index a3b00273ff8f..7b9f28bfa0b2 100644 --- a/packages/mask/src/extension/background-script/EthereumServices/providers/MaskWallet.ts +++ b/packages/mask/src/extension/background-script/EthereumServices/providers/MaskWallet.ts @@ -1,7 +1,7 @@ import MaskWallet from 'web3' import type { HttpProvider } from 'web3-core' import { PopupRoutes } from '@masknet/shared-base' -import { ChainId, getChainIdFromNetworkType, getChainRPC, NetworkType } from '@masknet/web3-shared-evm' +import { ChainId, getChainIdFromNetworkType, getChainRPC, NetworkType, ProviderType } from '@masknet/web3-shared-evm' import { currentChainIdSettings } from '../../../../plugins/Wallet/settings' import { getWallets, selectAccountPrepare } from '../../../../plugins/Wallet/services' import { openPopupWindow } from '../../HelperService' @@ -67,7 +67,7 @@ export function createWeb3({ //#endregion export async function requestAccounts(networkType: NetworkType) { - const wallets = await getWallets() + const wallets = await getWallets(ProviderType.MaskWallet) return new Promise<{ chainId: ChainId accounts: string[] diff --git a/packages/mask/src/extension/popups/pages/Wallet/DeleteWallet/index.tsx b/packages/mask/src/extension/popups/pages/Wallet/DeleteWallet/index.tsx index 5dc544c7676c..47edfa39e692 100644 --- a/packages/mask/src/extension/popups/pages/Wallet/DeleteWallet/index.tsx +++ b/packages/mask/src/extension/popups/pages/Wallet/DeleteWallet/index.tsx @@ -1,13 +1,12 @@ import { memo, useCallback, useState } from 'react' import { Button, Typography } from '@mui/material' import { makeStyles } from '@masknet/theme' -import { WarningIcon } from '@masknet/icons' +import { WalletIcon, WarningIcon } from '@masknet/icons' import { useHistory } from 'react-router-dom' import { ProviderType, useWallet, formatEthereumAddress } from '@masknet/web3-shared-evm' import { PopupRoutes } from '@masknet/shared-base' import { first } from 'lodash-unified' -import { FormattedAddress, WalletIcon } from '@masknet/shared' -import { NetworkPluginID, useNetworkDescriptor, useProviderDescriptor } from '@masknet/plugin-infra' +import { FormattedAddress } from '@masknet/shared' import { WalletRPC } from '../../../../../plugins/Wallet/messages' import { useI18N } from '../../../../../utils' import { PasswordField } from '../../../components/PasswordField' @@ -101,8 +100,6 @@ const DeleteWallet = memo(() => { const { classes } = useStyles() const [password, setPassword] = useState('') const [errorMessage, setErrorMessage] = useState('') - const networkDescriptor = useNetworkDescriptor(NetworkPluginID.PLUGIN_EVM) - const providerDescriptor = useProviderDescriptor(NetworkPluginID.PLUGIN_EVM) const onConfirm = useCallback(async () => { if (wallet?.address) { @@ -138,7 +135,7 @@ const DeleteWallet = memo(() => {
- +
{wallet?.name} diff --git a/packages/mask/src/extension/popups/pages/Wallet/SelectWallet/index.tsx b/packages/mask/src/extension/popups/pages/Wallet/SelectWallet/index.tsx index d7881be216c2..29ed72a887b6 100644 --- a/packages/mask/src/extension/popups/pages/Wallet/SelectWallet/index.tsx +++ b/packages/mask/src/extension/popups/pages/Wallet/SelectWallet/index.tsx @@ -1,6 +1,5 @@ import { memo, useCallback, useEffect, useState } from 'react' import { useLocation } from 'react-router-dom' -import { useCopyToClipboard } from 'react-use' import { first } from 'lodash-unified' import { MaskWalletIcon, SuccessIcon } from '@masknet/icons' import { FormattedAddress } from '@masknet/shared' @@ -16,7 +15,6 @@ import { formatEthereumAddress, } from '@masknet/web3-shared-evm' import { Button, List, ListItem, ListItemText, Typography } from '@mui/material' -import { NetworkPluginID, useNetworkDescriptor } from '@masknet/plugin-infra' import { WalletRPC } from '../../../../../plugins/Wallet/messages' import { CopyIconButton } from '../../../components/CopyIconButton' import { currentProviderSettings } from '../../../../../plugins/Wallet/settings' @@ -124,10 +122,8 @@ const SelectWallet = memo(() => { const location = useLocation() const wallet = useAccount() const wallets = useWallets(ProviderType.MaskWallet) - const networkDescriptor = useNetworkDescriptor(NetworkPluginID.PLUGIN_EVM) const [selected, setSelected] = useState(wallet) - const [, copyToClipboard] = useCopyToClipboard() const search = new URLSearchParams(location.search) @@ -140,13 +136,6 @@ const SelectWallet = memo(() => { const chainIdValid = useChainIdValid() - const onCopy = useCallback( - (address: string) => { - copyToClipboard(address) - }, - [copyToClipboard], - ) - const handleCancel = useCallback(async () => { await WalletRPC.selectAccount([], ChainId.Mainnet) await Services.Helper.removePopupWindow() diff --git a/packages/mask/src/plugins/Wallet/services/account.ts b/packages/mask/src/plugins/Wallet/services/account.ts index 5ced85b373a8..4dd462edebdb 100644 --- a/packages/mask/src/plugins/Wallet/services/account.ts +++ b/packages/mask/src/plugins/Wallet/services/account.ts @@ -75,9 +75,9 @@ export async function updateMaskAccount(options: { account?: string; chainId?: C if (!options.chainId && options.networkType) options.chainId = getChainIdFromNetworkType(options.networkType) const { account, chainId, networkType } = options - if (chainId) currentMaskWalletChainIdSettings.value = chainId if (networkType) currentMaskWalletNetworkSettings.value = networkType + if (!account) currentMaskWalletAccountSettings.value = '' if (account && EthereumAddress.isValid(account)) currentMaskWalletAccountSettings.value = account }