Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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[]
Expand Down
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -138,7 +135,7 @@ const DeleteWallet = memo(() => {
</div>
<div className={classes.info}>
<div className={classes.iconContainer}>
<WalletIcon networkIcon={networkDescriptor?.icon} providerIcon={providerDescriptor?.icon} />
<WalletIcon />
Comment thread
guanbinrui marked this conversation as resolved.
</div>
<div>
<Typography className={classes.name}>{wallet?.name}</Typography>
Expand Down
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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'
Expand Down Expand Up @@ -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)

Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion packages/mask/src/plugins/Wallet/services/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment on lines +80 to 81

@hanszhoou hanszhoou Nov 23, 2021

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!account) currentMaskWalletAccountSettings.value = ''
if (account && EthereumAddress.isValid(account)) currentMaskWalletAccountSettings.value = account
if (account && EthereumAddress.isValid(account)) {
currentMaskWalletAccountSettings.value = account
} else {
currentMaskWalletAccountSettings.value = ''
}

}

Expand Down