diff --git a/packages/mask/popups/modals/WalletRenameModal/index.tsx b/packages/mask/popups/modals/WalletRenameModal/index.tsx index 0b306f79337..826aa62f04a 100644 --- a/packages/mask/popups/modals/WalletRenameModal/index.tsx +++ b/packages/mask/popups/modals/WalletRenameModal/index.tsx @@ -22,7 +22,7 @@ function WalletRenameDrawer({ wallet, walletName, ...rest }: WalletRenameDrawerP const [error, setError] = useState() const contacts = useContacts() - const [{ loading }, handleClick] = useAsyncFn(async () => { + const [{ loading }, handleConfirm] = useAsyncFn(async () => { if (!name || !wallet) return const _name = name.trim() if (_name.length > 18 || _name.length < 3) { @@ -92,7 +92,7 @@ function WalletRenameDrawer({ wallet, walletName, ...rest }: WalletRenameDrawerP Confirm diff --git a/packages/mask/popups/pages/Wallet/SwitchWallet/index.tsx b/packages/mask/popups/pages/Wallet/SwitchWallet/index.tsx index f6b8f1d4018..ec11feea55f 100644 --- a/packages/mask/popups/pages/Wallet/SwitchWallet/index.tsx +++ b/packages/mask/popups/pages/Wallet/SwitchWallet/index.tsx @@ -1,3 +1,5 @@ +import Services from '#services' +import { Trans } from '@lingui/react/macro' import { Icons } from '@masknet/icons' import { DashboardRoutes, ECKeyIdentifier, NetworkPluginID, PopupRoutes, type Wallet } from '@masknet/shared-base' import { ActionButton, makeStyles } from '@masknet/theme' @@ -8,10 +10,8 @@ import { ProviderType } from '@masknet/web3-shared-evm' import { Box, List, Typography } from '@mui/material' import { memo, useCallback } from 'react' import { useNavigate } from 'react-router-dom' -import Services from '#services' import { ActionModal, useActionModal } from '../../../components/index.js' import { WalletItem } from '../../../components/WalletItem/index.js' -import { Trans } from '@lingui/react/macro' const useStyles = makeStyles()((theme) => ({ content: { @@ -49,24 +49,6 @@ const SwitchWallet = memo(function SwitchWallet() { const wallets = useWallets() const { chainId } = useChainContext() - const handleClickCreate = useCallback(async () => { - if (!wallets.some((x) => !x.configurable)) { - const hasPaymentPassword = await Services.Wallet.hasPassword() - await browser.tabs.create({ - active: true, - url: browser.runtime.getURL( - `/dashboard.html#${ - hasPaymentPassword ? - DashboardRoutes.CreateMaskWalletMnemonic - : DashboardRoutes.CreateMaskWalletForm - }`, - ), - }) - } else { - navigate(PopupRoutes.CreateWallet) - } - }, [wallets]) - const handleImport = useCallback(async () => { await browser.tabs.create({ active: true, @@ -107,7 +89,9 @@ const SwitchWallet = memo(function SwitchWallet() { fullWidth size="small" variant="outlined" - onClick={handleClickCreate}> + onClick={() => { + navigate(PopupRoutes.CreateWallet) + }}> Add Wallet diff --git a/packages/mask/popups/pages/Wallet/WalletSettings/Rename.tsx b/packages/mask/popups/pages/Wallet/WalletSettings/Rename.tsx index a59d2a4bc12..3cfc67a703d 100644 --- a/packages/mask/popups/pages/Wallet/WalletSettings/Rename.tsx +++ b/packages/mask/popups/pages/Wallet/WalletSettings/Rename.tsx @@ -1,14 +1,14 @@ +import { Trans } from '@lingui/react/macro' import { Icons } from '@masknet/icons' +import { PersistentStorages } from '@masknet/shared-base' import { useWallet } from '@masknet/web3-hooks-base' +import { isSameAddress } from '@masknet/web3-shared-base' import { Box, ListItem, Typography } from '@mui/material' -import { useStyles } from './useStyles.js' -import { WalletRenameModal } from '../../../modals/modal-controls.js' -import { Trans } from '@lingui/react/macro' import { useWallets } from '@privy-io/react-auth' import { useMemo } from 'react' -import { isSameAddress } from '@masknet/web3-shared-base' import { useSubscription } from 'use-subscription' -import { PersistentStorages } from '@masknet/shared-base' +import { WalletRenameModal } from '../../../modals/modal-controls.js' +import { useStyles } from './useStyles.js' export function Rename() { const wallet = useWallet() @@ -22,13 +22,14 @@ export function Rename() { if (!wallet) return null + const walletName = wallet.name || (isFireflyWallet ? fireflyAccount.displayName : wallet.name) return ( WalletRenameModal.open({ wallet, - walletName: wallet.name || (isFireflyWallet ? fireflyAccount.displayName : wallet.name), + walletName, title: Rename, }) }> @@ -39,9 +40,7 @@ export function Rename() { - - {isFireflyWallet ? fireflyAccount.displayName : wallet.name} - + {walletName} diff --git a/packages/mask/popups/pages/Wallet/WalletSettings/index.tsx b/packages/mask/popups/pages/Wallet/WalletSettings/index.tsx index 2fc7e08eb73..c7e7d6b11b1 100644 --- a/packages/mask/popups/pages/Wallet/WalletSettings/index.tsx +++ b/packages/mask/popups/pages/Wallet/WalletSettings/index.tsx @@ -1,13 +1,16 @@ +import { Trans, useLingui } from '@lingui/react/macro' import { Icons } from '@masknet/icons' import { EMPTY_LIST, PersistentStorages, PopupModalRoutes } from '@masknet/shared-base' import { ActionButton } from '@masknet/theme' import { useWallet, useWallets } from '@masknet/web3-hooks-base' -import { useWallets as usePrivyWallets } from '@privy-io/react-auth' import { isSameAddress } from '@masknet/web3-shared-base' import { Box, List, Typography } from '@mui/material' +import { useWallets as usePrivyWallets } from '@privy-io/react-auth' import { first } from 'lodash-es' import { memo, useCallback, useMemo } from 'react' +import { useSubscription } from 'use-subscription' import { useModalNavigate } from '../../../components/index.js' +import { WalletAvatar } from '../../../components/WalletAvatar/index.js' import { useTitle } from '../../../hooks/index.js' import { WalletRemoveModal } from '../../../modals/modal-controls.js' import { AutoLock } from './AutoLock.js' @@ -16,14 +19,11 @@ import { ChangeNetwork } from './ChangeNetwork.js' import { ChangePaymentPassword } from './ChangePaymentPassword.js' import { ConnectedOrigins } from './ConnectedOrigins.js' import { Contacts } from './Contacts.js' +import { DisablePermit } from './DisablePermit.js' +import { HidingScamTx } from './HidingScamTx.js' import { Rename } from './Rename.js' import { ShowPrivateKey } from './ShowPrivateKey.js' import { useStyles } from './useStyles.js' -import { HidingScamTx } from './HidingScamTx.js' -import { Trans, useLingui } from '@lingui/react/macro' -import { DisablePermit } from './DisablePermit.js' -import { useSubscription } from 'use-subscription' -import { WalletAvatar } from '../../../components/WalletAvatar/index.js' function getPathIndex(path?: string) { const rawIndex = path?.split('/').pop() @@ -66,6 +66,7 @@ export const Component = memo(function WalletSettings() { }, [allWallets, wallet?.mnemonicId]) if (!wallet) return null + const walletName = wallet.name || (isFireflyWallet ? fireflyAccount.displayName : wallet.name) // The wallet has derivationPath is also the one with minimum derivation path const isTheFirstWallet = wallet.mnemonicId ? isSameAddress(first(siblingWallets)?.address, wallet.address) : false @@ -76,9 +77,7 @@ export const Component = memo(function WalletSettings() {
- - {isFireflyWallet ? fireflyAccount.displayName : wallet.name} - + {walletName} {wallet.address}
diff --git a/packages/mask/popups/pages/Wallet/components/WalletHeader/UI.tsx b/packages/mask/popups/pages/Wallet/components/WalletHeader/UI.tsx index eaebd8b3ee9..254ef4a3c1b 100644 --- a/packages/mask/popups/pages/Wallet/components/WalletHeader/UI.tsx +++ b/packages/mask/popups/pages/Wallet/components/WalletHeader/UI.tsx @@ -157,6 +157,7 @@ export const WalletHeaderUI = memo(function WalletHeaderUI( const addressLink = EVMExplorerResolver.addressLink(chainId, wallet.address) const networkName = currentNetwork?.name || currentNetwork?.fullName + const walletName = wallet.name || (isFireflyWallet ? fireflyAccount.displayName : wallet.name) return (
@@ -211,9 +212,7 @@ export const WalletHeaderUI = memo(function WalletHeaderUI( - - {isFireflyWallet ? fireflyAccount.displayName : wallet.name} - + {walletName} diff --git a/packages/web3-providers/src/Web3/EVM/providers/MaskWallet.ts b/packages/web3-providers/src/Web3/EVM/providers/MaskWallet.ts index 2847cc09770..534d611f093 100644 --- a/packages/web3-providers/src/Web3/EVM/providers/MaskWallet.ts +++ b/packages/web3-providers/src/Web3/EVM/providers/MaskWallet.ts @@ -52,7 +52,7 @@ export class MaskWalletProvider extends BaseHostedProvider { const privyWallets = await Privy.getEvmWallets() const formattedPrivyWallets: Wallet[] = privyWallets.map((wallet) => ({ id: wallet.address, - name: '', + name: this.walletStorage.wallets.value.find((w) => isSameAddress(w.address, wallet.address))?.name || '', source: ImportSource.Privy, address: wallet.address, configurable: false,