diff --git a/packages/mask/content-script/components/InjectedComponents/SelectPeopleDialog.tsx b/packages/mask/content-script/components/InjectedComponents/SelectPeopleDialog.tsx
index f9198b093ed1..767076f85aaf 100644
--- a/packages/mask/content-script/components/InjectedComponents/SelectPeopleDialog.tsx
+++ b/packages/mask/content-script/components/InjectedComponents/SelectPeopleDialog.tsx
@@ -1,12 +1,11 @@
import { useCallback, useEffect, useMemo, useState } from 'react'
import { ActionButton, makeStyles } from '@masknet/theme'
import { Button, DialogActions, DialogContent, alpha } from '@mui/material'
-import { InjectedDialog, resolveNextIDPlatform, resolveValueToSearch, usePersonasFromNextID } from '@masknet/shared'
-import { EMPTY_LIST, NextIDPlatform, type ProfileInformation as Profile } from '@masknet/shared-base'
+import { InjectedDialog } from '@masknet/shared'
+import { EMPTY_LIST, type ProfileInformation as Profile } from '@masknet/shared-base'
import { uniqBy } from 'lodash-es'
import { useCurrentIdentity } from '../DataSource/useActivatedUI.js'
import { useRecipientsList } from '../CompositionDialog/useRecipientsList.js'
-import { useTwitterIdByWalletSearch } from '../shared/SelectRecipients/useTwitterIdByWalletSearch.js'
import { SelectProfileUI } from '../shared/SelectProfileUI/index.js'
import { Telemetry } from '@masknet/web3-telemetry'
import { EventType, EventID } from '@masknet/web3-telemetry/types'
@@ -86,26 +85,13 @@ export function SelectProfileDialog({ open, profiles, selectedProfiles, onClose,
})
}, [handleClose, people, selectedProfiles, onSelect])
- const [valueToSearch, setValueToSearch] = useState('')
const currentIdentity = useCurrentIdentity()
- const type = resolveNextIDPlatform(valueToSearch)
-
- const value = resolveValueToSearch(valueToSearch)
- const { isPending: searchLoading, data: NextIDResults } = usePersonasFromNextID(
- value,
- type ?? NextIDPlatform.NextID,
- false,
- )
-
- const NextIDItems = useTwitterIdByWalletSearch(NextIDResults, value, type)
const myUserId = currentIdentity?.identifier.userId
const searchedList = useMemo(() => {
if (!recipientsList?.recipients) return EMPTY_LIST
const profileItems = recipientsList.recipients.filter((x) => x.identifier.userId !== myUserId)
- // Selected might contain profiles that fetched asynchronously from
- // Next.ID, which are not stored locally
- return uniqBy(profileItems.concat(NextIDItems, profiles), ({ linkedPersona }) => linkedPersona?.rawPublicKey)
- }, [NextIDItems, profiles, recipientsList.recipients, myUserId])
+ return uniqBy(profileItems.concat(profiles), ({ linkedPersona }) => linkedPersona?.rawPublicKey)
+ }, [profiles, recipientsList.recipients, myUserId])
useEffect(() => {
if (!open) return
@@ -128,8 +114,8 @@ export function SelectProfileDialog({ open, profiles, selectedProfiles, onClose,
items={searchedList}
selected={people}
onSetSelected={select}
- onSearch={setValueToSearch}
- loading={searchLoading}
+ onSearch={() => {}}
+ loading={false}
/>
{rejection ?
diff --git a/packages/mask/content-script/components/InjectedComponents/SetupGuide/AccountConnectStatus.tsx b/packages/mask/content-script/components/InjectedComponents/SetupGuide/AccountConnectStatus.tsx
index 77099aab16ec..1b65b3e567bc 100644
--- a/packages/mask/content-script/components/InjectedComponents/SetupGuide/AccountConnectStatus.tsx
+++ b/packages/mask/content-script/components/InjectedComponents/SetupGuide/AccountConnectStatus.tsx
@@ -75,7 +75,7 @@ export const AccountConnectStatus = memo
(function AccountConnectStatus({
const site = activatedSiteAdaptorUI!.networkIdentifier
const siteName = SOCIAL_MEDIA_NAME[site] || ''
- const { connected, isFirstConnection, isFirstVerification } = SetupGuideContext.useContainer()
+ const { connected, isFirstConnection } = SetupGuideContext.useContainer()
if (loading)
return (
@@ -86,7 +86,7 @@ export const AccountConnectStatus = memo(function AccountConnectStatus({
)
- if (isFirstConnection || isFirstVerification) {
+ if (isFirstConnection) {
if (Sniffings.is_twitter_page) {
return (
diff --git a/packages/mask/content-script/components/InjectedComponents/SetupGuide/SetupGuideContext.tsx b/packages/mask/content-script/components/InjectedComponents/SetupGuide/SetupGuideContext.tsx
index 877665f71a4c..ab8bc52905cd 100644
--- a/packages/mask/content-script/components/InjectedComponents/SetupGuide/SetupGuideContext.tsx
+++ b/packages/mask/content-script/components/InjectedComponents/SetupGuide/SetupGuideContext.tsx
@@ -13,7 +13,6 @@ import { activatedSiteAdaptorUI } from '../../../site-adaptor-infra/index.js'
import { useLastRecognizedIdentity } from '../../DataSource/useActivatedUI.js'
import { useSetupGuideStatus } from '../../GuideStep/useSetupGuideStatus.js'
import { useCurrentUserId } from './hooks/useCurrentUserId.js'
-import { useConnectedVerified } from './hooks/useConnectedVerified.js'
export function useSetupGuideStepInfo(persona?: PersonaIdentifier) {
// #region parse setup status
@@ -41,9 +40,7 @@ export function useSetupGuideStepInfo(persona?: PersonaIdentifier) {
queryFn: async () => Services.Helper.getActiveTab().then((x) => x?.id || null),
refetchOnWindowFocus: true,
})
- const { networkIdentifier: site, configuration } = activatedSiteAdaptorUI!
- const nextIdPlatform = configuration.nextIDConfig?.platform
- const [checkingVerified, verified] = useConnectedVerified(personaInfo?.identifier?.publicKeyAsHex, userId)
+ const { networkIdentifier: site } = activatedSiteAdaptorUI!
const connected = personaInfo?.linkedProfiles.some(
(x) => x.identifier.network === site && x.identifier.userId === userId,
)
@@ -63,7 +60,6 @@ export function useSetupGuideStepInfo(persona?: PersonaIdentifier) {
}, [userId])
const [isFirstConnection, setIsFirstConnection] = useState(false)
- const [isFirstVerification, setIsFirstVerification] = useState(false)
const step = useMemo(() => {
if (!setupGuide.status) {
// Should show pin extension when not set
@@ -73,23 +69,14 @@ export function useSetupGuideStepInfo(persona?: PersonaIdentifier) {
return SetupGuideStep.Close
}
}
- const nextStep = isFirstConnection ? SetupGuideStep.VerifyOnNextID : SetupGuideStep.CheckConnection
- if (checkingVerified || checkingConnected || loadingCurrentUserId) return nextStep
- if (!connected || (nextIdPlatform && !verified)) {
- return SetupGuideStep.VerifyOnNextID
+ const nextStep = isFirstConnection ? SetupGuideStep.CheckConnection : SetupGuideStep.CheckConnection
+ if (checkingConnected || loadingCurrentUserId) return nextStep
+ if (!connected) {
+ return SetupGuideStep.CheckConnection
}
return nextStep
- }, [
- setupGuide.status,
- checkingVerified,
- checkingConnected,
- connected,
- verified,
- isFirstConnection,
- loadingCurrentUserId,
- ])
+ }, [setupGuide.status, checkingConnected, connected, isFirstConnection, loadingCurrentUserId])
const skip = !personaInfo || currentTabId !== setupGuide.tabId
- // Will show connect result the first time for sites that don't need to verify nextId.
return {
step: skip ? SetupGuideStep.Close : step,
userId,
@@ -99,11 +86,7 @@ export function useSetupGuideStepInfo(persona?: PersonaIdentifier) {
personaInfo,
isFirstConnection,
setIsFirstConnection,
- isFirstVerification,
- setIsFirstVerification,
checkingConnected,
- checkingVerified,
- verified,
connected,
}
}
diff --git a/packages/mask/content-script/components/InjectedComponents/SetupGuide/VerifyNextID.tsx b/packages/mask/content-script/components/InjectedComponents/SetupGuide/VerifyNextID.tsx
deleted file mode 100644
index 15632e2b7a6a..000000000000
--- a/packages/mask/content-script/components/InjectedComponents/SetupGuide/VerifyNextID.tsx
+++ /dev/null
@@ -1,374 +0,0 @@
-import { Trans } from '@lingui/react/macro'
-import { Icons } from '@masknet/icons'
-import { delay } from '@masknet/kit'
-import {
- BindingDialog,
- EmojiAvatar,
- useBaseUIRuntime,
- useVerifyContent,
- useVerifyNextID,
- type BindingDialogProps,
-} from '@masknet/shared'
-import {
- MaskMessages,
- currentSetupGuideStatus,
- formatPersonaFingerprint,
- resolveNetworkToNextIDPlatform,
-} from '@masknet/shared-base'
-import { ActionButton, MaskColorVar, MaskTextField, makeStyles } from '@masknet/theme'
-import { NextIDProof } from '@masknet/web3-providers'
-import { Telemetry } from '@masknet/web3-telemetry'
-import { EventID, EventType } from '@masknet/web3-telemetry/types'
-import { Box, Link, Skeleton, Typography } from '@mui/material'
-import { useQuery, useQueryClient } from '@tanstack/react-query'
-import { useCallback, useMemo, useState } from 'react'
-import { useAsyncFn } from 'react-use'
-import Services from '../../../../shared-ui/service.js'
-import { AccountConnectStatus } from './AccountConnectStatus.js'
-import { SetupGuideContext } from './SetupGuideContext.js'
-import { useConnectPersona } from './hooks/useConnectPersona.js'
-import { useNotifyConnected } from './hooks/useNotifyConnected.js'
-
-const useStyles = makeStyles()((theme) => ({
- body: {
- display: 'flex',
- flexDirection: 'column',
- height: '100%',
- overflow: 'auto',
- },
- main: {
- '&::-webkit-scrollbar': {
- display: 'none',
- },
- },
- avatar: {
- display: 'block',
- width: 36,
- height: 36,
- borderRadius: '50%',
- border: `solid 1px ${MaskColorVar.border}`,
- '&.connected': {
- borderColor: MaskColorVar.success,
- },
- },
- button: {
- minWidth: 150,
- height: 40,
- minHeight: 40,
- marginLeft: 0,
- marginTop: 0,
- [theme.breakpoints.down('sm')]: {
- width: '100%',
- },
- fontSize: 14,
- wordBreak: 'keep-all',
- '&,&:hover': {
- color: `${MaskColorVar.twitterButtonText} !important`,
- background: `${MaskColorVar.twitterButton} !important`,
- },
- },
- tip: {
- fontSize: 12,
- fontWeight: 500,
- lineHeight: '16px',
- color: theme.palette.maskColor.second,
- marginTop: theme.spacing(2),
- },
- connection: {
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'center',
- padding: theme.spacing(1.5),
- gap: theme.spacing(1.5),
- color: theme.palette.maskColor.main,
- },
- connectItem: {
- flex: 1,
- width: 148,
- flexShrink: 0,
- display: 'flex',
- alignItems: 'center',
- gap: theme.spacing(0.5),
- },
- input: {
- width: 136,
- },
- postContentTitle: {
- fontSize: 12,
- color: theme.palette.maskColor.main,
- fontWeight: 700,
- },
- postContent: {
- color: theme.palette.maskColor.main,
- fontSize: 12,
- backgroundColor: theme.palette.maskColor.bg,
- borderRadius: 12,
- padding: theme.spacing(1),
- marginTop: theme.spacing(1.5),
- whiteSpace: 'pre-line',
- wordBreak: 'break-all',
- },
- text: {
- fontSize: 12,
- fontWeight: 400,
- color: theme.palette.maskColor.second,
- },
- info: {
- overflow: 'auto',
- },
- name: {
- display: 'block',
- fontSize: 14,
- fontWeight: 500,
- textOverflow: 'ellipsis',
- overflow: 'hidden',
- whiteSpace: 'nowrap',
- },
- second: {
- color: theme.palette.maskColor.second,
- fontSize: 12,
- display: 'block',
- alignItems: 'center',
- marginTop: theme.spacing(0.5),
- textOverflow: 'ellipsis',
- overflow: 'hidden',
- whiteSpace: 'nowrap',
- },
- linkIcon: {
- fontSize: 0,
- color: theme.palette.maskColor.second,
- marginLeft: 2,
- },
- send: {
- marginRight: theme.spacing(1),
- },
- footer: {
- borderRadius: 12,
- backdropFilter: 'blur(8px)',
- boxShadow: theme.palette.maskColor.bottomBg,
- padding: theme.spacing(2),
- marginTop: 'auto',
- },
-}))
-
-interface VerifyNextIDProps extends BindingDialogProps {}
-
-export function VerifyNextID({ onClose }: VerifyNextIDProps) {
- const { classes, cx } = useStyles()
- const queryClient = useQueryClient()
-
- const {
- userId,
- myIdentity,
- personaInfo,
- checkingVerified,
- verified,
- loadingCurrentUserId,
- currentUserId,
- setIsFirstVerification,
- } = SetupGuideContext.useContainer()
- const { nickname: username, avatar } = myIdentity
- const personaName = personaInfo?.nickname
- const personaIdentifier = personaInfo?.identifier
-
- const [customUserId, setCustomUserId] = useState('')
- const { data: verifyInfo, isPending: creatingPostContent } = useVerifyContent(
- personaIdentifier,
- userId || customUserId,
- )
- const { networkIdentifier } = useBaseUIRuntime()
- const nextIdPlatform = resolveNetworkToNextIDPlatform(networkIdentifier)
-
- const { data: personaAvatar } = useQuery({
- queryKey: ['@@my-own-persona-info'],
- queryFn: () => Services.Identity.queryOwnedPersonaInformation(false),
- refetchOnMount: true,
- networkMode: 'always',
- select(data) {
- const pubkey = personaInfo?.identifier.publicKeyAsHex
- const info = data.find((x) => x.identifier.publicKeyAsHex === pubkey)
- return info?.avatar
- },
- })
-
- const disableVerify = useMemo(() => {
- return !myIdentity?.identifier || !userId ? false : myIdentity.identifier.userId !== userId
- }, [myIdentity, userId])
- // Show connect result for the first time.
- const { loading: connecting } = useConnectPersona()
-
- const [, handleVerifyNextID] = useVerifyNextID()
- const [{ loading: verifying, error, value: verifiedSuccess }, onVerify] = useAsyncFn(async () => {
- if (!userId) return
- if (!personaInfo) return
- if (!nextIdPlatform) return
-
- const isBound = await NextIDProof.queryIsBound(personaInfo.identifier.publicKeyAsHex, nextIdPlatform, userId)
- if (!isBound) {
- setIsFirstVerification(true)
- await handleVerifyNextID(personaInfo, userId)
- Telemetry.captureEvent(EventType.Access, EventID.EntryPopupSocialAccountVerifyTwitter)
- }
- await queryClient.invalidateQueries({
- queryKey: ['@@next-id', 'bindings-by-persona', personaInfo.identifier.publicKeyAsHex],
- })
-
- await delay(1000)
-
- MaskMessages.events.ownProofChanged.sendToAll()
- return true
- }, [userId, personaInfo, queryClient])
-
- const notify = useNotifyConnected()
-
- const onConfirm = useCallback(() => {
- currentSetupGuideStatus[networkIdentifier].value = ''
- notify()
- }, [nextIdPlatform, notify])
-
- // Need to verify for next id platform
- if (currentUserId !== userId || loadingCurrentUserId || connecting) {
- return (
-
- )
- }
-
- if (!personaIdentifier) return null
-
- const disabled = !(userId || customUserId) || !personaName || disableVerify || checkingVerified
-
- return (
-
-
-
-
- {userId ?
-
-
-
-
-
- {username}
- @{userId}
-
-
- :
-
-
- {
- setCustomUserId(e.target.value.trim())
- }}
- />
-
-
- }
-
-
- {personaAvatar ?
-
- : }
-
- {personaName}
-
- {formatPersonaFingerprint(personaIdentifier.rawPublicKey, 4)}
-
-
-
-
-
-
-
- {!nextIdPlatform || verified || verifiedSuccess ?
-
- {nextIdPlatform ?
-
- The verification post sent.
-
-
- You could check the verification result on the Mask Pop-up after few minutes. If it
- failed, try to send another verification post later.
-
- :
- Account connected.
-
-
- Try to explore more features powered by Mask Network.
-
- }
-
- : creatingPostContent ?
- <>
-
- Post content:
-
-
-
-
-
-
-
-
-
-
-
- To verify your X account and record it on the NextID, you will need to send a post
- for the verification.
-
-
- >
- : verifyInfo ?
- <>
-
- Post content:
-
- {verifyInfo.post}
-
-
- To verify your X account and record it on the NextID, please send this post for the
- verification.
-
-
- >
- : null}
-
-
-
- {!nextIdPlatform || (nextIdPlatform && (verified || verifiedSuccess)) ?
-
- OK
-
- :
-
- {error ?
- Resend
- : Send }
-
- }
-
-
-
- )
-}
diff --git a/packages/mask/content-script/components/InjectedComponents/SetupGuide/hooks/useConnectedVerified.ts b/packages/mask/content-script/components/InjectedComponents/SetupGuide/hooks/useConnectedVerified.ts
deleted file mode 100644
index 1dd177af478e..000000000000
--- a/packages/mask/content-script/components/InjectedComponents/SetupGuide/hooks/useConnectedVerified.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import { usePersonaProofs } from '@masknet/shared'
-import { activatedSiteAdaptorUI } from '../../../../site-adaptor-infra/ui.js'
-
-export function useConnectedVerified(pubkey: string | undefined, userId: string) {
- const { data: proofs, isLoading } = usePersonaProofs(pubkey)
- const platform = activatedSiteAdaptorUI!.configuration.nextIDConfig?.platform
- const checking = isLoading
- if (!platform || !proofs?.length) return [checking, false]
- const verified = proofs.some((x) => x.platform === platform && x.identity === userId.toLowerCase() && x.is_valid)
- return [checking, verified] as const
-}
diff --git a/packages/mask/content-script/components/InjectedComponents/SetupGuide/hooks/useNotifyConnected.ts b/packages/mask/content-script/components/InjectedComponents/SetupGuide/hooks/useNotifyConnected.ts
index 74087d902900..f5ce066c0fb0 100644
--- a/packages/mask/content-script/components/InjectedComponents/SetupGuide/hooks/useNotifyConnected.ts
+++ b/packages/mask/content-script/components/InjectedComponents/SetupGuide/hooks/useNotifyConnected.ts
@@ -1,16 +1,12 @@
import { useCallback } from 'react'
import { useCustomSnackbar } from '@masknet/theme'
-import { activatedSiteAdaptorUI } from '../../../../site-adaptor-infra/ui.js'
import { msg } from '@lingui/core/macro'
import { useLingui } from '@lingui/react'
export function useNotifyConnected() {
const { _ } = useLingui()
const { showSnackbar } = useCustomSnackbar()
- const { configuration } = activatedSiteAdaptorUI!
- const platform = configuration.nextIDConfig?.platform
const notify = useCallback(() => {
- if (!platform) return
showSnackbar(_(msg`Verify Account`), {
variant: 'success',
message: _(msg`Account successfully connected to persona`),
diff --git a/packages/mask/content-script/components/InjectedComponents/SetupGuide/index.tsx b/packages/mask/content-script/components/InjectedComponents/SetupGuide/index.tsx
index e20e90f57ec0..382b4664c2ba 100644
--- a/packages/mask/content-script/components/InjectedComponents/SetupGuide/index.tsx
+++ b/packages/mask/content-script/components/InjectedComponents/SetupGuide/index.tsx
@@ -14,7 +14,6 @@ import { memo, useCallback } from 'react'
import { activatedSiteAdaptorUI } from '../../../site-adaptor-infra/index.js'
import { PinExtension } from './PinExtension.js'
import { SetupGuideContext } from './SetupGuideContext.js'
-import { VerifyNextID } from './VerifyNextID.js'
import { CheckConnection } from './CheckConnection.js'
import { msg } from '@lingui/core/macro'
import { useLingui } from '@lingui/react'
@@ -67,8 +66,6 @@ function SetupGuideUI() {
switch (step) {
case SetupGuideStep.CheckConnection:
return
- case SetupGuideStep.VerifyOnNextID:
- return
case SetupGuideStep.PinExtension:
return
default:
diff --git a/packages/mask/content-script/components/shared/SelectProfileUI/SelectProfileUI.tsx b/packages/mask/content-script/components/shared/SelectProfileUI/SelectProfileUI.tsx
index 3e4f05ba5881..ce6a14ecd3b9 100644
--- a/packages/mask/content-script/components/shared/SelectProfileUI/SelectProfileUI.tsx
+++ b/packages/mask/content-script/components/shared/SelectProfileUI/SelectProfileUI.tsx
@@ -1,6 +1,6 @@
import { Icons } from '@masknet/icons'
import { EmptyStatus, LoadingStatus } from '@masknet/shared'
-import { EMPTY_LIST, type ProfileInformation as Profile, type ProfileInformationFromNextID } from '@masknet/shared-base'
+import { EMPTY_LIST, type ProfileInformation as Profile } from '@masknet/shared-base'
import { Boundary, makeStyles } from '@masknet/theme'
import { useLookupAddress } from '@masknet/web3-hooks-base'
import Fuse from 'fuse.js'
@@ -177,7 +177,7 @@ export function SelectProfileUI(props: SelectProfileUIProps) {
return (
({
root: {
@@ -34,11 +30,6 @@ const useStyles = makeStyles()((theme) => ({
cursor: 'pointer',
marginLeft: theme.spacing(0.5),
},
- badge: {
- width: 32,
- height: 18,
- marginLeft: theme.spacing(0.5),
- },
highLightBg: {
background: theme.palette.maskColor.bg,
},
@@ -61,11 +52,6 @@ const useStyles = makeStyles()((theme) => ({
listItemRoot: {
margin: '4px 0',
},
- columnReverse: {
- margin: '4px 0',
- display: 'flex',
- flexDirection: 'column-reverse',
- },
toolTip: {
fontSize: 14,
lineHeight: '18px',
@@ -78,37 +64,21 @@ const useStyles = makeStyles()((theme) => ({
}))
interface ProfileInListProps {
- profile: ProfileInformationFromNextID
+ profile: ProfileInformation
highlightText?: string
selected?: boolean
disabled?: boolean
- onChange: (profile: ProfileInformationFromNextID, checked: boolean) => void
+ onChange: (profile: ProfileInformation, checked: boolean) => void
}
export const ProfileInList = memo(function ProfileInList(props: ProfileInListProps) {
- const { i18n } = useLingui()
const { classes, cx } = useStyles()
const { profile, selected, disabled, highlightText, onChange } = props
const searchWords = useMemo(() => (highlightText ? [highlightText] : EMPTY_LIST), [highlightText])
const rawPublicKey = profile.linkedPersona?.rawPublicKey
- const primaryText = (() => {
- if (!profile.fromNextID) return `@${profile.identifier.userId || profile.nickname}`
- const mentions = profile.linkedTwitterNames?.map((x) => '@' + x).join(' ') ?? ''
- if (mentions.length < 15) return mentions
- const len = profile.linkedTwitterNames?.length ?? 0
- return truncate(mentions, { length: 15 }) + (len > 1 ? `(${len})` : '')
- })()
-
- const tooltipTitle = (() => {
- const linkedNames = profile.linkedTwitterNames ?? []
- if (linkedNames.length === 0) return The Persona is not connected to any accounts.
- if (linkedNames.length === 1)
- return The Persona is connected to the account @${profile.identifier.userId}.
- const mentions = profile.linkedTwitterNames?.map((username) => '@' + username) ?? []
- const list = new Intl.ListFormat(i18n.locale).format(mentions)
- return The Persona is connected to the following accounts: {list}
- })()
+ const primaryText = `@${profile.identifier.userId || profile.nickname}`
+ const tooltipTitle = `@${profile.identifier.userId || ''}`
const handleClick = useCallback(() => onChange(profile, !selected), [onChange, selected])
const secondaryText = formatPersonaFingerprint(profile.linkedPersona?.rawPublicKey?.toUpperCase() ?? '', 3)
@@ -130,7 +100,7 @@ export const ProfileInList = memo(function ProfileInList(props: ProfileInListPro
: null}
- {profile.fromNextID ?
-
- : null}
}
/>
diff --git a/packages/mask/content-script/components/shared/SelectRecipients/SelectRecipients.tsx b/packages/mask/content-script/components/shared/SelectRecipients/SelectRecipients.tsx
index 8d43ce5a15e7..d05d5e3ee948 100644
--- a/packages/mask/content-script/components/shared/SelectRecipients/SelectRecipients.tsx
+++ b/packages/mask/content-script/components/shared/SelectRecipients/SelectRecipients.tsx
@@ -1,11 +1,9 @@
import { uniqBy } from 'lodash-es'
import { useEffect, useMemo, useState } from 'react'
-import { EMPTY_LIST, NextIDPlatform, type ProfileInformation as Profile } from '@masknet/shared-base'
+import { EMPTY_LIST, type ProfileInformation as Profile } from '@masknet/shared-base'
import type { LazyRecipients } from '../../CompositionDialog/CompositionUI.js'
import { useCurrentIdentity } from '../../DataSource/useActivatedUI.js'
import { SelectRecipientsDialogUI } from './SelectRecipientsDialog.js'
-import { useTwitterIdByWalletSearch } from './useTwitterIdByWalletSearch.js'
-import { resolveNextIDPlatform, resolveValueToSearch, usePersonasFromNextID } from '@masknet/shared'
import { useContacts } from './useContacts.js'
import { Trans } from '@lingui/react/macro'
@@ -24,23 +22,13 @@ export function SelectRecipientsUI(props: SelectRecipientsUIProps) {
const { items, selected, onSetSelected, open, onClose } = props
const [valueToSearch, setValueToSearch] = useState('')
const currentIdentity = useCurrentIdentity()
- const type = resolveNextIDPlatform(valueToSearch)
- const _value = resolveValueToSearch(valueToSearch)
- const { isLoading: searchLoading, data: NextIDResults } = usePersonasFromNextID(
- _value,
- type ?? NextIDPlatform.NextID,
- false,
- )
- const NextIDItems = useTwitterIdByWalletSearch(NextIDResults, _value, type)
const myUserId = currentIdentity?.identifier.userId
const searchedList = useMemo(() => {
if (!items.recipients) return EMPTY_LIST
const profileItems = items.recipients.filter((x) => x.identifier.userId !== myUserId)
- // Selected might contain profiles that fetched asynchronously from
- // Next.ID, which are not stored locally
- return uniqBy(profileItems.concat(NextIDItems, selected), ({ linkedPersona }) => linkedPersona?.rawPublicKey)
- }, [NextIDItems, selected, items.recipients, myUserId])
+ return uniqBy(profileItems.concat(selected), ({ linkedPersona }) => linkedPersona?.rawPublicKey)
+ }, [selected, items.recipients, myUserId])
const { value = EMPTY_LIST } = useContacts(currentIdentity?.identifier.network)
@@ -51,7 +39,7 @@ export function SelectRecipientsUI(props: SelectRecipientsUIProps) {
return (
No results : undefined}
- loading={searchLoading}
+ loading={false}
onSearch={setValueToSearch}
open={open}
items={uniqBy([...searchedList, ...value], (x) => x.linkedPersona?.publicKeyAsHex)}
diff --git a/packages/mask/content-script/components/shared/SelectRecipients/SelectRecipientsDialog.tsx b/packages/mask/content-script/components/shared/SelectRecipients/SelectRecipientsDialog.tsx
index 3b64d0ebdef6..ca59268c246c 100644
--- a/packages/mask/content-script/components/shared/SelectRecipients/SelectRecipientsDialog.tsx
+++ b/packages/mask/content-script/components/shared/SelectRecipients/SelectRecipientsDialog.tsx
@@ -2,7 +2,7 @@ import { startTransition, useCallback, useDeferredValue, useMemo, useState, type
import { compact } from 'lodash-es'
import { Icons } from '@masknet/icons'
import { ActionButtonPromise, EmptyStatus, InjectedDialog } from '@masknet/shared'
-import type { ProfileInformation as Profile, ProfileInformationFromNextID } from '@masknet/shared-base'
+import type { ProfileInformation as Profile } from '@masknet/shared-base'
import { Boundary, LoadingBase, makeStyles } from '@masknet/theme'
import { useLookupAddress } from '@masknet/web3-hooks-base'
import Fuse from 'fuse.js'
@@ -17,7 +17,6 @@ import {
Typography,
alpha,
} from '@mui/material'
-import { attachNextIDToProfile } from '../../../../shared-ui/index.js'
import { ProfileInList } from './ProfileInList.js'
import { Trans, useLingui } from '@lingui/react/macro'
@@ -171,9 +170,6 @@ export function SelectRecipientsDialogUI(props: SelectRecipientsDialogUIProps) {
const handleSubmit = useCallback(async () => {
props.onSetSelected([...selectedAllProfiles])
- for (const item of selectedAllProfiles) {
- await attachNextIDToProfile(item as ProfileInformationFromNextID)
- }
props.onSubmit()
setSearchInput('')
onSearch('')
@@ -247,7 +243,7 @@ export function SelectRecipientsDialogUI(props: SelectRecipientsDialogUIProps) {
return (
{
- const proofs = uniqBy(
- binding.proofs.filter((x) => x.platform === NextIDPlatform.Twitter),
- (proof) => proof.identity,
- )
- if (!proofs.length) return null
- const linkedTwitterNames = proofs.map((x) => x.identity)
- return {
- nickname: proofs[0].identity,
- identifier: ProfileIdentifier.of('twitter.com', proofs[0].identity).expect(
- `${proofs[0].identity} should be a valid user id`,
- ),
- walletAddress: type === NextIDPlatform.Ethereum ? value : undefined,
- fromNextID: true,
- linkedTwitterNames,
- linkedPersona: ECKeyIdentifier.fromHexPublicKeyK256(binding.persona).expect(
- `${binding.persona} should be a valid hex public key in k256`,
- ),
- }
- })
- return compact(nextIdAccounts)
+/**
+ * @deprecated NextID functionality removed. Returns empty list.
+ */
+export function useTwitterIdByWalletSearch() {
+ return EMPTY_LIST
}
diff --git a/packages/mask/content-script/site-adaptor-infra/ui.ts b/packages/mask/content-script/site-adaptor-infra/ui.ts
index b715b9843cc8..2fa33e95c893 100644
--- a/packages/mask/content-script/site-adaptor-infra/ui.ts
+++ b/packages/mask/content-script/site-adaptor-infra/ui.ts
@@ -139,12 +139,11 @@ export async function activateSiteAdaptorUIInner(ui_deferred: SiteAdaptorUI.Defe
__setSiteAdaptorContext__({
lastRecognizedProfile: lastRecognizedSub,
currentVisitingProfile: currentVisitingSub,
- currentNextIDPlatform: ui.configuration.nextIDConfig?.platform,
currentPersonaIdentifier: createSubscriptionFromValueRef(currentPersonaIdentifier, signal),
getPostURL: ui.utils.getPostURL || (() => null),
getProfileURL: ui.utils.getProfileURL || (() => null),
share: ui.utils.share,
- getPostIdFromNewPostToast: ui.configuration.nextIDConfig?.getPostIdFromNewPostToast,
+ getPostIdFromNewPostToast: undefined,
connectPersona,
postMessage: ui.automation?.nativeCompositionDialog?.attachText,
publishPost: ui.automation.endpoint?.publishPost,
diff --git a/packages/mask/content-script/site-adaptors/twitter.com/ui-provider.ts b/packages/mask/content-script/site-adaptors/twitter.com/ui-provider.ts
index 51b0729ad00d..bb603ca49377 100644
--- a/packages/mask/content-script/site-adaptors/twitter.com/ui-provider.ts
+++ b/packages/mask/content-script/site-adaptors/twitter.com/ui-provider.ts
@@ -1,6 +1,6 @@
/* eslint-disable tss-unused-classes/unused-classes */
import type { SiteAdaptorUI } from '@masknet/types'
-import { EnhanceableSite, NextIDPlatform, ProfileIdentifier } from '@masknet/shared-base'
+import { EnhanceableSite, ProfileIdentifier } from '@masknet/shared-base'
import { makeStyles } from '@masknet/theme'
import { FontSize, ThemeColor, ThemeMode } from '@masknet/web3-shared-base'
import { activatedSiteAdaptor_state, stateCreator } from '../../site-adaptor-infra/index.js'
@@ -14,7 +14,7 @@ import { pasteImageToCompositionTwitter } from './automation/pasteImageToComposi
import { publishPostTwitter } from './automation/publishPost.js'
import { IdentityProviderTwitter, CurrentVisitingIdentityProviderTwitter } from './collecting/identity.js'
import { ThemeSettingsProviderTwitter } from './collecting/theme.js'
-import { collectVerificationPost, PostProviderTwitter, getPostIdFromNewPostToast } from './collecting/post.js'
+import { PostProviderTwitter } from './collecting/post.js'
import { useThemeTwitterVariant } from './customization/custom.js'
import { injectToolboxHintAtTwitter } from './injection/ToolboxHint.js'
import { i18NOverwriteTwitter } from './customization/i18n.js'
@@ -205,12 +205,6 @@ const twitterUI: SiteAdaptorUI.Definition = {
mode: ThemeMode.Light,
isDim: false,
},
- nextIDConfig: {
- enable: true,
- platform: NextIDPlatform.Twitter,
- collectVerificationPost,
- getPostIdFromNewPostToast,
- },
steganography: {
// ! Change this is a breaking change !
password() {
diff --git a/packages/mask/package.json b/packages/mask/package.json
index 69dab61cdde6..832441ed62af 100644
--- a/packages/mask/package.json
+++ b/packages/mask/package.json
@@ -50,7 +50,6 @@
"@masknet/plugin-go-plus-security": "workspace:^",
"@masknet/plugin-handle": "workspace:^",
"@masknet/plugin-infra": "workspace:^",
- "@masknet/plugin-nextid": "workspace:^",
"@masknet/plugin-profilecard": "workspace:^",
"@masknet/plugin-redpacket": "workspace:^",
"@masknet/plugin-rss3": "workspace:^",
diff --git a/packages/mask/popups/components/ConnectedWallet/index.tsx b/packages/mask/popups/components/ConnectedWallet/index.tsx
index 9cdd196af62c..ec410f8fb48b 100644
--- a/packages/mask/popups/components/ConnectedWallet/index.tsx
+++ b/packages/mask/popups/components/ConnectedWallet/index.tsx
@@ -1,25 +1,13 @@
-import Services from '#services'
import { Trans } from '@lingui/react/macro'
import { Icons } from '@masknet/icons'
-import { ConfirmDialog, FormattedAddress, PersonaContext, ProgressiveText } from '@masknet/shared'
-import {
- MaskMessages,
- NetworkPluginID,
- NextIDAction,
- PopupModalRoutes,
- SignType,
- type BindingProof,
- type PersonaInformation,
-} from '@masknet/shared-base'
-import { makeStyles, usePopupCustomSnackbar } from '@masknet/theme'
+import { FormattedAddress, ProgressiveText } from '@masknet/shared'
+import { NetworkPluginID, PopupModalRoutes } from '@masknet/shared-base'
+import { makeStyles } from '@masknet/theme'
import { useChainContext, useWallets, useWeb3State } from '@masknet/web3-hooks-base'
-import { EVMExplorerResolver, NextIDProof } from '@masknet/web3-providers'
-import { isSameAddress, resolveNextIDPlatformWalletName } from '@masknet/web3-shared-base'
+import { EVMExplorerResolver } from '@masknet/web3-providers'
import { formatDomainName, formatEthereumAddress } from '@masknet/web3-shared-evm'
import { Box, Link, Typography, useTheme } from '@mui/material'
-import { useQueries } from '@tanstack/react-query'
-import { memo, useCallback } from 'react'
-import { useVerifiedWallets } from '../../hooks/index.js'
+import { memo } from 'react'
import { useModalNavigate } from '../ActionModal/index.js'
import { WalletAvatar } from '../WalletAvatar/index.js'
@@ -86,96 +74,35 @@ export const ConnectedWallet = memo(function ConnectedWallet() {
const { chainId } = useChainContext()
const localWallets = useWallets()
- const { showSnackbar } = usePopupCustomSnackbar()
- const { currentPersona, proofs } = PersonaContext.useContainer()
const modalNavigate = useModalNavigate()
const { NameService } = useWeb3State(NetworkPluginID.PLUGIN_EVM)
- const wallets = useVerifiedWallets(proofs)
-
- const queries = useQueries({
- queries: wallets.map((wallet) => ({
- enabled: !!NameService,
- queryKey: ['persona-connected-wallet', wallet.identity],
- queryFn: async () => {
- const domain = await NameService?.reverse?.(wallet.identity)
- if (domain) return domain
- const localWallet = localWallets.find((x) => isSameAddress(x.address, wallet.identity))?.name
- return localWallet || null
- },
- })),
- })
-
- const handleConfirmDisconnect = useCallback(async (wallet: BindingProof, persona: PersonaInformation) => {
- try {
- const result = await NextIDProof.createPersonaPayload(
- persona.identifier.publicKeyAsHex,
- NextIDAction.Delete,
- wallet.identity,
- wallet.platform,
- )
-
- if (!result) return
-
- const signature = await Services.Identity.signWithPersona(
- { type: SignType.Message, data: result.signPayload },
- persona.identifier,
- location.origin,
- true,
- )
-
- if (!signature) return
-
- await NextIDProof.bindProof(
- result.uuid,
- persona.identifier.publicKeyAsHex,
- NextIDAction.Delete,
- wallet.platform,
- wallet.identity,
- result.createdAt,
- { signature },
- )
-
- // Broadcast updates.
- MaskMessages.events.ownProofChanged.sendToAll()
- showSnackbar(Wallet disconnected )
- } catch {
- showSnackbar(Failed to disconnect wallet , {
- variant: 'error',
- })
- }
- }, [])
return (
- {wallets.map((wallet, index) => {
- const query = queries[index]
- let walletName = query.data || ''
- if (!walletName && !query.isPending) {
- walletName = `${resolveNextIDPlatformWalletName(wallet.platform)} ${wallets.length - index}`
- }
+ {localWallets.map((wallet, index) => {
return (
-
+
- {formatDomainName(walletName, 13)}
+ loading={false}>
+ {formatDomainName(wallet.name || '', 13)}
@@ -183,26 +110,6 @@ export const ConnectedWallet = memo(function ConnectedWallet() {
- {
- if (!currentPersona) return
- const confirmed = await ConfirmDialog.openAndWaitForClose({
- title: Disconnect Wallet? ,
- confirmVariant: 'warning',
- message: (
-
- Are you sure to remove the connected wallet{' '}
-
- {formatEthereumAddress(wallet.identity, 4)}
-
- ?
-
- ),
- })
- if (confirmed) return handleConfirmDisconnect(wallet, currentPersona)
- }}
- />
)
})}
diff --git a/packages/mask/popups/components/PersonaPublicKey/index.tsx b/packages/mask/popups/components/PersonaPublicKey/index.tsx
index 2cfd700778d6..ffa6ebc89067 100644
--- a/packages/mask/popups/components/PersonaPublicKey/index.tsx
+++ b/packages/mask/popups/components/PersonaPublicKey/index.tsx
@@ -1,8 +1,7 @@
-import { Icons } from '@masknet/icons'
import { CopyButton } from '@masknet/shared'
import { formatPersonaFingerprint } from '@masknet/shared-base'
import { makeStyles } from '@masknet/theme'
-import { Link, Typography } from '@mui/material'
+import { Typography } from '@mui/material'
import { memo } from 'react'
const useStyles = makeStyles<{ iconSize: number }>()((theme, { iconSize }) => ({
@@ -42,14 +41,6 @@ export const PersonaPublicKey = memo(function PersonaPubl
{formatPersonaFingerprint(rawPublicKey, 4)}
-
-
-
)
})
diff --git a/packages/mask/popups/components/SocialAccounts/index.tsx b/packages/mask/popups/components/SocialAccounts/index.tsx
index 6cd9b81a1698..2f37d51f5c89 100644
--- a/packages/mask/popups/components/SocialAccounts/index.tsx
+++ b/packages/mask/popups/components/SocialAccounts/index.tsx
@@ -92,13 +92,12 @@ export const SocialAccounts = memo(function SocialAccounts(
- {/* identity could mistakenly start with an `@` */}
- {account.identity?.startsWith('@') ? '' : '@'}
- {account.identity}
+ {/* userId could mistakenly start with an `@` */}
+ {account.identifier.userId?.startsWith('@') ? '' : '@'}
+ {account.identifier.userId}
))}
diff --git a/packages/mask/popups/components/WalletSettingList/index.tsx b/packages/mask/popups/components/WalletSettingList/index.tsx
index dfae6174bae4..74f84bf1e1c8 100644
--- a/packages/mask/popups/components/WalletSettingList/index.tsx
+++ b/packages/mask/popups/components/WalletSettingList/index.tsx
@@ -1,127 +1,27 @@
import { Icons } from '@masknet/icons'
-import { WalletIcon, FormattedBalance, PopupHomeTabType } from '@masknet/shared'
-import { PopupRoutes, type BindingProof } from '@masknet/shared-base'
-import {
- useWallets,
- useDefaultChainId,
- useNetworkDescriptor,
- useWeb3Utils,
- useReverseAddress,
- useNativeTokenBalance,
- useNativeToken,
-} from '@masknet/web3-hooks-base'
-import { resolveNextID_NetworkPluginID, isSameAddress, formatBalance } from '@masknet/web3-shared-base'
-import {
- ListItem,
- ListItemButton,
- ListItemIcon,
- ListItemText,
- Typography,
- useTheme,
- Link,
- Box,
- List,
-} from '@mui/material'
-import { useMemo, memo } from 'react'
+import { PopupRoutes } from '@masknet/shared-base'
+import { PopupHomeTabType } from '@masknet/shared'
+import { useTheme, Typography, Box } from '@mui/material'
+import { memo } from 'react'
import { Link as RouterLink } from 'react-router-dom'
import urlcat from 'urlcat'
import { Trans } from '@lingui/react/macro'
-interface WalletItemProps {
- proof: BindingProof
-}
-
-function WalletItem({ proof }: WalletItemProps) {
- const theme = useTheme()
- const wallets = useWallets()
- const networkPluginId = resolveNextID_NetworkPluginID(proof.platform)
- const chainId = useDefaultChainId(networkPluginId)
- const networkDescriptor = useNetworkDescriptor(networkPluginId, chainId)
- const Utils = useWeb3Utils(networkPluginId)
- const { data: domain } = useReverseAddress(networkPluginId, proof.identity)
-
- const formattedAddress = Utils.formatAddress(proof.identity, 4)
- const addressLink = Utils.explorerResolver.addressLink(chainId, proof.identity)
-
- const balance = useNativeTokenBalance(networkPluginId, { account: proof.identity, chainId })
- const { data: nativeToken } = useNativeToken(networkPluginId, { chainId })
-
- const walletName = useMemo(() => {
- if (domain) return domain
- const walletAtDB = wallets.find((x) => isSameAddress(proof.identity, x.address))
- if (walletAtDB) return walletAtDB.name
- return formattedAddress
- }, [domain, wallets, proof.identity, formattedAddress])
-
- return (
-
-
-
-
-
-
- {walletName}
-
-
-
-
- }
- secondary={
-
-
-
- }
- />
-
-
- )
-}
-
-interface WalletListProps {
- isValid?: boolean
- walletProofs?: BindingProof[]
-}
-
-export const WalletList = memo(function WalletList({ walletProofs, isValid }) {
+export const WalletList = memo(function WalletList() {
const theme = useTheme()
- if (!isValid) return null
-
- if (!walletProofs?.length)
- return (
-
-
-
-
- No associated wallet.{' '}
-
- Add Wallet.
-
-
-
-
- )
-
return (
-
- {walletProofs.map((proof, index) => (
-
- ))}
-
+
+
+
+
+ No associated wallet.{' '}
+
+ Add Wallet.
+
+
+
+
)
})
diff --git a/packages/mask/popups/hooks/index.ts b/packages/mask/popups/hooks/index.ts
index b9803ca6d7cd..1485017a43d2 100644
--- a/packages/mask/popups/hooks/index.ts
+++ b/packages/mask/popups/hooks/index.ts
@@ -9,4 +9,3 @@ export * from './useSearchValue.js'
export * from './useSupportSocialNetworks.js'
export * from './useTitle.js'
export * from './useTokenParams.js'
-export * from './useVerifiedWallets.js'
diff --git a/packages/mask/popups/hooks/useFriendProfiles.ts b/packages/mask/popups/hooks/useFriendProfiles.ts
index 18aa380494a0..a55bed4a6f63 100644
--- a/packages/mask/popups/hooks/useFriendProfiles.ts
+++ b/packages/mask/popups/hooks/useFriendProfiles.ts
@@ -1,62 +1,7 @@
-import { EMPTY_LIST, type EnhanceableSite, NextIDPlatform, type ProfileIdentifier } from '@masknet/shared-base'
-import { Web3Bio } from '@masknet/web3-providers'
-import { useQuery } from '@tanstack/react-query'
+import { EMPTY_LIST, type ProfileIdentifier } from '@masknet/shared-base'
import { useMemo } from 'react'
-import { useCurrentPersona } from '../../shared-ui/hooks/index.js'
-import { PlatformSort, UnsupportedPlatforms, type Profile } from '../pages/Friends/common.js'
+import type { Profile } from '../pages/Friends/common.js'
-export function profilesFilter(x: Profile) {
- return (
- (x.platform === NextIDPlatform.ENS && x.name.endsWith('.eth')) ||
- !UnsupportedPlatforms.includes(x.platform as NextIDPlatform)
- )
-}
-
-export function useFriendProfiles(seen: boolean, nextId?: string, profile?: ProfileIdentifier): Profile[] {
- const currentPersona = useCurrentPersona()
-
- const { data: profiles = EMPTY_LIST } = useQuery({
- enabled: seen && !!nextId,
- queryKey: ['profiles', currentPersona?.identifier.publicKeyAsHex, nextId],
- queryFn: async () => {
- if (!nextId) return EMPTY_LIST
- try {
- return await Web3Bio.getProfilesByNextId(nextId)
- } catch (error) {
- return EMPTY_LIST
- }
- },
- select(profiles) {
- return profiles.map((profile) => ({
- platform: profile.platform,
- identity: profile.identity,
- is_valid: true,
- last_checked_at: '',
- name: profile.displayName,
- created_at: '',
- }))
- },
- })
- return useMemo(() => {
- if (profiles.length === 0) {
- if (profile?.userId) {
- return [
- {
- platform: profile.network as
- | EnhanceableSite.Twitter
- | EnhanceableSite.Facebook
- | EnhanceableSite.Instagram,
- identity: profile.userId,
- is_valid: true,
- last_checked_at: '',
- name: profile.userId,
- created_at: '',
- },
- ]
- } else {
- return EMPTY_LIST
- }
- }
- return profiles.sort((a, b) => PlatformSort[a.platform] - PlatformSort[b.platform])
- }, [profiles])
+export function useFriendProfiles(_seen: boolean, _nextId?: string, profile?: ProfileIdentifier): Profile[] {
+ return useMemo(() => EMPTY_LIST as Profile[], [profile])
}
diff --git a/packages/mask/popups/hooks/useFriendsFromSearch.tsx b/packages/mask/popups/hooks/useFriendsFromSearch.tsx
index 134968b7b961..71343bf47866 100644
--- a/packages/mask/popups/hooks/useFriendsFromSearch.tsx
+++ b/packages/mask/popups/hooks/useFriendsFromSearch.tsx
@@ -1,28 +1,30 @@
import { useMemo } from 'react'
-import { uniqBy } from 'lodash-es'
-import { ECKeyIdentifier, EMPTY_LIST, type NextIDPersonaBindings } from '@masknet/shared-base'
+import { type ECKeyIdentifier, EMPTY_LIST } from '@masknet/shared-base'
import { useCurrentLinkedPersona } from '@masknet/shared'
import type { Friend } from './useFriends.js'
-import { profilesFilter } from './useFriendProfiles.js'
-import { PlatformSort, type FriendNetwork, type Profile } from '../pages/Friends/common.js'
+import type { FriendNetwork } from '../pages/Friends/common.js'
-export type NextIDPersonaBindingsWithIdentifier = Omit & {
- proofs: Profile[]
+export type NextIDPersonaBindingsWithIdentifier = {
+ proofs: Array<{
+ platform: FriendNetwork
+ identity: string
+ is_valid: boolean
+ last_checked_at: string
+ name: string
+ created_at: string
+ }>
linkedPersona: ECKeyIdentifier
+ activated_at: string
+ persona: string
isLocal?: boolean
avatar?: string
}
-export function useFriendsFromSearch(
- localSearchedResult: Friend[],
- searchResult?: NextIDPersonaBindings[],
- localList?: Friend[],
- searchValue?: string,
-): NextIDPersonaBindingsWithIdentifier[] {
+export function useFriendsFromSearch(localSearchedResult: Friend[]): NextIDPersonaBindingsWithIdentifier[] {
const currentIdentifier = useCurrentLinkedPersona()
return useMemo(() => {
- if (!searchResult?.length && !localSearchedResult?.length) return EMPTY_LIST
- const localProfiles: NextIDPersonaBindingsWithIdentifier[] = localSearchedResult
+ if (!localSearchedResult?.length) return EMPTY_LIST
+ return localSearchedResult
.filter((x) => x.persona.publicKeyAsHex !== currentIdentifier?.identifier.publicKeyAsHex && x.profile)
.map((item) => {
const profile = item.profile!
@@ -44,35 +46,5 @@ export function useFriendsFromSearch(
avatar: item.avatar,
}
})
- const profiles: NextIDPersonaBindingsWithIdentifier[] =
- searchResult ?
- searchResult
- .filter((x) => x.persona !== currentIdentifier?.identifier.publicKeyAsHex)
- .map((item) => {
- const filtered = item.proofs.filter(profilesFilter)
- const identifier = ECKeyIdentifier.fromHexPublicKeyK256(item.persona).expect(
- `${item.persona} should be a valid hex public key in k256`,
- )
- filtered.sort((a, b) => PlatformSort[a.platform] - PlatformSort[b.platform])
- const searchItem = filtered.findIndex(
- (x) => x.identity === searchValue || x.name === searchValue,
- )
- if (searchItem !== -1) filtered.unshift(filtered.splice(searchItem, 1)[0])
- return {
- proofs: uniqBy(filtered, ({ identity }) => identity),
- linkedPersona: identifier,
- activated_at: item.activated_at,
- persona: item.persona,
- isLocal:
- localList ?
- localList.some((x) => x.persona.publicKeyAsHex === identifier.publicKeyAsHex)
- : false,
- }
- })
- : EMPTY_LIST
- return uniqBy(
- localProfiles ? localProfiles.concat(profiles) : profiles,
- ({ linkedPersona }) => linkedPersona.publicKeyAsHex,
- )
- }, [searchResult, localList, currentIdentifier, localSearchedResult])
+ }, [localSearchedResult, currentIdentifier])
}
diff --git a/packages/mask/popups/hooks/useVerifiedWallets.ts b/packages/mask/popups/hooks/useVerifiedWallets.ts
deleted file mode 100644
index 6629838c057f..000000000000
--- a/packages/mask/popups/hooks/useVerifiedWallets.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { type BindingProof, NextIDPlatform, EMPTY_LIST } from '@masknet/shared-base'
-import { isGreaterThan } from '@masknet/web3-shared-base'
-import { useMemo } from 'react'
-
-export function useVerifiedWallets(proofs?: BindingProof[]) {
- return useMemo(() => {
- if (!proofs?.length) return EMPTY_LIST
- return proofs
- .filter((x) => x.platform === NextIDPlatform.Ethereum)
- .sort((a, z) => (isGreaterThan(a.last_checked_at, z.last_checked_at) ? -1 : 1))
- }, [proofs])
-}
diff --git a/packages/mask/popups/pages/Friends/ContactCard/index.tsx b/packages/mask/popups/pages/Friends/ContactCard/index.tsx
index 262dfdbeb35e..6f18e61c5501 100644
--- a/packages/mask/popups/pages/Friends/ContactCard/index.tsx
+++ b/packages/mask/popups/pages/Friends/ContactCard/index.tsx
@@ -1,23 +1,14 @@
-import { memo, useState, useCallback, useMemo } from 'react'
+import { memo, useState, useCallback } from 'react'
import { useNavigate } from 'react-router-dom'
import { useEverSeen } from '@masknet/shared-base-ui'
import { useMutation, useQueryClient, type InfiniteData } from '@tanstack/react-query'
import { Icons } from '@masknet/icons'
import { ActionButton, makeStyles, usePopupCustomSnackbar } from '@masknet/theme'
-import { Box, Typography, Link, useTheme, ButtonBase as Button, Avatar } from '@mui/material'
-import {
- formatPersonaFingerprint,
- PopupRoutes,
- ProfileIdentifier,
- ECKeyIdentifier,
- NextIDPlatform,
-} from '@masknet/shared-base'
-import { CopyButton, PersonaContext } from '@masknet/shared'
+import { Box, Typography, Avatar, useTheme, ButtonBase as Button } from '@mui/material'
+import { formatPersonaFingerprint, PopupRoutes } from '@masknet/shared-base'
+import { PersonaContext } from '@masknet/shared'
import Services from '#services'
-import { ConnectedAccounts } from './ConnectedAccounts/index.js'
-import { attachNextIDToProfile } from '../../../../shared-ui/index.js'
-import { type Friend, useFriendProfiles } from '../../../hooks/index.js'
-import type { Profile } from '../common.js'
+import type { Friend } from '../../../hooks/index.js'
import { Trans } from '@lingui/react/macro'
const useStyles = makeStyles()((theme) => ({
@@ -48,33 +39,15 @@ const useStyles = makeStyles()((theme) => ({
width: 40,
height: 40,
},
- icon: {
- width: 12,
- height: 12,
- fontSize: 12,
- color: theme.palette.maskColor.second,
- },
}))
interface ContactCardProps {
+ friend: Friend
avatar?: string
- proofProfiles?: Profile[]
- nextId?: string
- publicKey?: string
- isLocal?: boolean
- profile?: ProfileIdentifier
refetch?: () => void
}
-export const ContactCard = memo(function ContactCard({
- avatar,
- nextId,
- publicKey,
- isLocal,
- profile,
- refetch,
- proofProfiles,
-}) {
+export const ContactCard = memo(function ContactCard({ friend, avatar, refetch }) {
const theme = useTheme()
const { classes } = useStyles()
const navigate = useNavigate()
@@ -82,48 +55,18 @@ export const ContactCard = memo(function ContactCard({
const [local, setLocal] = useState(false)
const [seen, ref] = useEverSeen()
const { currentPersona } = PersonaContext.useContainer()
- const profiles = useFriendProfiles(seen, nextId, profile)
+ const publicKey = friend.persona.publicKeyAsHex
const rawPublicKey = currentPersona?.identifier.rawPublicKey
const queryClient = useQueryClient()
- const friendInfo = useMemo(() => {
- if (!rawPublicKey) return
- const twitter = proofProfiles?.find((p) => p.platform === NextIDPlatform.Twitter)
- const personaIdentifier = ECKeyIdentifier.fromHexPublicKeyK256(nextId).expect(
- `${nextId} should be a valid hex public key in k256`,
- )
- if (!twitter) {
- return {
- persona: personaIdentifier,
- }
- } else {
- const profileIdentifier = ProfileIdentifier.of('twitter.com', twitter.identity).unwrap()
- return {
- persona: personaIdentifier,
- profile: profileIdentifier,
- }
- }
- }, [nextId, rawPublicKey])
-
const handleAddFriend = useCallback(async () => {
- if (!friendInfo || !currentPersona) return
- const { persona, profile } = friendInfo
- if (!profile) {
- await Services.Identity.createNewRelation(persona, currentPersona.identifier)
- } else {
- await attachNextIDToProfile({
- identifier: profile,
- linkedPersona: persona,
- fromNextID: true,
- linkedTwitterNames: [profile.userId],
- })
- }
- }, [nextId, queryClient, currentPersona, refetch, friendInfo])
+ if (!currentPersona) return
+ await Services.Identity.createNewRelation(friend.persona, currentPersona.identifier)
+ }, [friend.persona, currentPersona])
const { mutate: onAdd, isPending } = useMutation({
mutationFn: handleAddFriend,
- onMutate: async (friend: Friend | undefined) => {
- if (!friend) return
+ onMutate: async () => {
await queryClient.cancelQueries({ queryKey: ['relation-records', rawPublicKey] })
await queryClient.cancelQueries({ queryKey: ['friends', rawPublicKey] })
queryClient.setQueryData(
@@ -165,42 +108,20 @@ export const ContactCard = memo(function ContactCard({
{avatar ?
- : }
+ : }
{publicKey ? formatPersonaFingerprint(publicKey) : null}
-
- {nextId ? formatPersonaFingerprint(nextId, 4) : null}
-
-
-
-
-
- {isLocal || local ?
+ {local ?
- navigate(`${PopupRoutes.FriendsDetail}/${nextId}`, {
+ navigate(`${PopupRoutes.FriendsDetail}/${publicKey}`, {
state: {
avatar,
- publicKey,
- nextId,
- profiles: proofProfiles ?? profiles,
- isLocal,
- localProfile: profile,
+ friend,
},
})
}
@@ -210,21 +131,13 @@ export const ContactCard = memo(function ContactCard({
: onAdd(friendInfo)}
+ onClick={() => onAdd()}
loading={isPending}
disabled={isPending}>
Add
}
-
)
})
diff --git a/packages/mask/popups/pages/Friends/Contacts/index.tsx b/packages/mask/popups/pages/Friends/Contacts/index.tsx
index 7c6f9db7e6f1..f1634e5d18a9 100644
--- a/packages/mask/popups/pages/Friends/Contacts/index.tsx
+++ b/packages/mask/popups/pages/Friends/Contacts/index.tsx
@@ -48,14 +48,7 @@ export const Contacts = memo(function Contacts({ friendsArray, fe
:
{friendsArray.map(({ friends }) => {
return friends.map((friend) => (
-
+
))
})}
fetchNextPage()} height={10} />
diff --git a/packages/mask/popups/pages/Friends/Detail/UI.tsx b/packages/mask/popups/pages/Friends/Detail/UI.tsx
index 122251c35ff9..a9d64337ef68 100644
--- a/packages/mask/popups/pages/Friends/Detail/UI.tsx
+++ b/packages/mask/popups/pages/Friends/Detail/UI.tsx
@@ -1,6 +1,6 @@
import { makeStyles } from '@masknet/theme'
import { memo, useCallback } from 'react'
-import { Box, Avatar, Typography, Link } from '@mui/material'
+import { Box, Avatar, Typography } from '@mui/material'
import { Icons } from '@masknet/icons'
import { useNavigate } from 'react-router-dom'
import { type ProfileIdentifier, formatPersonaFingerprint } from '@masknet/shared-base'
@@ -115,7 +115,7 @@ export const FriendsDetailUI = memo(function FriendsDetail
{avatar ?
- : }
+ : }
{publicKey ? formatPersonaFingerprint(publicKey) : null}
@@ -129,14 +129,6 @@ export const FriendsDetailUI = memo(function FriendsDetail
columnGap="2px">
{formatPersonaFingerprint(nextId, 4)}
-
-
-
diff --git a/packages/mask/popups/pages/Friends/Home/UI.tsx b/packages/mask/popups/pages/Friends/Home/UI.tsx
index 116bf0e8ebb5..7c0890f3e16d 100644
--- a/packages/mask/popups/pages/Friends/Home/UI.tsx
+++ b/packages/mask/popups/pages/Friends/Home/UI.tsx
@@ -2,7 +2,7 @@ import { makeStyles, LoadingBase } from '@masknet/theme'
import { memo } from 'react'
import { Box, Typography } from '@mui/material'
import { Search } from '../Search/index.js'
-import type { NextIDPersonaBindingsWithIdentifier, Friend } from '../../../hooks/index.js'
+import type { Friend } from '../../../hooks/index.js'
import { Contacts } from '../Contacts/index.js'
import { SearchList } from '../SearchList/index.js'
import { Trans } from '@lingui/react/macro'
@@ -35,7 +35,7 @@ const useStyles = makeStyles()((theme) => ({
interface FriendsHomeUIProps {
searchValue: string
- searchResult: NextIDPersonaBindingsWithIdentifier[]
+ searchResult: Friend[]
loading: boolean
friends: Array<{ friends: Friend[]; nextPageOffset: number }>
setSearchValue: (v: string) => void
diff --git a/packages/mask/popups/pages/Friends/Home/index.tsx b/packages/mask/popups/pages/Friends/Home/index.tsx
index 3f63fef83eb5..86aaca6f1927 100644
--- a/packages/mask/popups/pages/Friends/Home/index.tsx
+++ b/packages/mask/popups/pages/Friends/Home/index.tsx
@@ -1,76 +1,25 @@
import { useLingui } from '@lingui/react/macro'
-import { resolveNextIDPlatform } from '@masknet/shared'
-import { EMPTY_LIST, NextIDPlatform } from '@masknet/shared-base'
-import { NextIDProof } from '@masknet/web3-providers'
-import { useInfiniteQuery } from '@tanstack/react-query'
-import Fuse from 'fuse.js'
-import { memo, useMemo, useState } from 'react'
-import {
- useFriendFromList,
- useFriendsFromSearch,
- useFriendsPaged,
- useSearchValue,
- useTitle,
-} from '../../../hooks/index.js'
+import { EMPTY_LIST } from '@masknet/shared-base'
+import { memo, useState } from 'react'
+import { useFriendsPaged, useTitle } from '../../../hooks/index.js'
import { FriendsHomeUI } from './UI.js'
export const Component = memo(function FriendsHome() {
const { t } = useLingui()
useTitle(t`Contacts`)
- const [{ isPending, refetch, records }, , { data, fetchNextPage }] = useFriendsPaged()
- const friends = useMemo(() => data?.pages.flatMap((x) => x.friends) ?? EMPTY_LIST, [data])
+ const [{ isPending, refetch }, , { data, fetchNextPage }] = useFriendsPaged()
const [searchValue, setSearchValue] = useState('')
- const type = resolveNextIDPlatform(searchValue)
- const { isLoading: resolveLoading, data: keyword = '' } = useSearchValue(searchValue, type)
- const fuse = useMemo(() => {
- return new Fuse(records, {
- keys: ['profile.userId'],
- isCaseSensitive: false,
- ignoreLocation: true,
- threshold: 0,
- })
- }, [records])
- const searchedRecords = useMemo(() => {
- if (!keyword || type !== NextIDPlatform.Twitter) return EMPTY_LIST
- return fuse.search(keyword).map((item) => item.item)
- }, [fuse, keyword, type])
- const { isPending: isSearchRecordLoading, data: localSearchedList = EMPTY_LIST } =
- useFriendFromList(searchedRecords)
- const {
- isPending: searchLoading,
- isLoading,
- data: searchResultArray,
- fetchNextPage: fetchNextSearchPage,
- } = useInfiniteQuery({
- queryKey: ['search-personas', keyword, type],
- initialPageParam: undefined as number | undefined,
- queryFn: async ({ pageParam }) => {
- if (!type) return EMPTY_LIST
- return NextIDProof.queryExistedBindingByPlatform(type, keyword, pageParam ?? 1, false)
- },
- enabled: !!keyword && !!type,
- getNextPageParam: (lastPage, allPages) => {
- if (lastPage.length === 0) return undefined
- return allPages.length + 1
- },
- })
- const searchResult = useMemo(() => searchResultArray?.pages.flat() ?? EMPTY_LIST, [searchResultArray])
- const searchedList = useFriendsFromSearch(localSearchedList, searchResult, friends, keyword)
return (
{}}
refetch={refetch}
/>
)
diff --git a/packages/mask/popups/pages/Friends/SearchList/index.tsx b/packages/mask/popups/pages/Friends/SearchList/index.tsx
index 96b40fd7a425..79ad872769ba 100644
--- a/packages/mask/popups/pages/Friends/SearchList/index.tsx
+++ b/packages/mask/popups/pages/Friends/SearchList/index.tsx
@@ -3,7 +3,7 @@ import { memo } from 'react'
import { ContactCard } from '../ContactCard/index.js'
import { Box } from '@mui/material'
import { EmptyStatus, RestorableScroll, ElementAnchor } from '@masknet/shared'
-import type { NextIDPersonaBindingsWithIdentifier } from '../../../hooks/index.js'
+import type { Friend } from '../../../hooks/index.js'
import { Trans } from '@lingui/react/macro'
const useStyles = makeStyles()((theme) => ({
@@ -16,7 +16,7 @@ const useStyles = makeStyles()((theme) => ({
alignItems: 'center',
flexDirection: 'column',
gap: 12,
- color: theme.palette.text.secondary,
+ color: theme.palette.maskColor.second,
whiteSpace: 'nowrap',
},
cardContainer: {
@@ -34,7 +34,7 @@ const useStyles = makeStyles()((theme) => ({
}))
interface SearchListProps {
- searchResult: NextIDPersonaBindingsWithIdentifier[]
+ searchResult: Friend[]
fetchNextPage: () => void
refetch: () => void
}
@@ -50,11 +50,8 @@ export const SearchList = memo(function SearchList({ searchResu
{searchResult.map((friend) => {
return (
diff --git a/packages/mask/popups/pages/Personas/AccountDetail/UI.tsx b/packages/mask/popups/pages/Personas/AccountDetail/UI.tsx
index 4b4f0ca7c9cd..67a0f3cfd293 100644
--- a/packages/mask/popups/pages/Personas/AccountDetail/UI.tsx
+++ b/packages/mask/popups/pages/Personas/AccountDetail/UI.tsx
@@ -1,5 +1,5 @@
import { Trans } from '@lingui/react/macro'
-import type { BindingProof, ProfileAccount } from '@masknet/shared-base'
+import type { ProfileAccount } from '@masknet/shared-base'
import { makeStyles } from '@masknet/theme'
import { Box, Button, Typography } from '@mui/material'
import { memo, useCallback } from 'react'
@@ -33,15 +33,9 @@ const useStyles = makeStyles()((theme) => ({
interface AccountDetailUIProps {
account: ProfileAccount
- isSupportNextDotID: boolean
- walletProofs?: BindingProof[]
}
-export const AccountDetailUI = memo(function AccountDetailUI({
- account,
- isSupportNextDotID,
- walletProofs,
-}) {
+export const AccountDetailUI = memo(function AccountDetailUI({ account }) {
const { classes } = useStyles()
const navigate = useNavigate()
const handleBack = useCallback(() => navigate(-1), [])
@@ -53,43 +47,22 @@ export const AccountDetailUI = memo(function AccountDetail
- @{account.identity}
+ @{account.nickname}
- {account.is_valid ?
-
- Display the following address on your Web3 profile page and use it to receive tips.
-
- : isSupportNextDotID ?
-
- After connecting and verifying your persona, you can set up associated address for
- displaying your web3 footprints or receiving tips.
-
- :
- Other social networking platforms, such as Instagram,
- Facebook, and Minds, do not have a verified relationship
- like X's Next.ID verified connection.
-
-
- When connecting a persona with an account on these platforms, they only support sending
- encrypted posts.
-
- }
+ Display the following address on your Web3 profile page and use it to receive tips.
-
+
- {isSupportNextDotID ?
-
-
- Back
-
-
- : null}
+
+
+ Back
+
+
)
})
diff --git a/packages/mask/popups/pages/Personas/AccountDetail/index.tsx b/packages/mask/popups/pages/Personas/AccountDetail/index.tsx
index 70f4f608f0a8..944aa3e301d9 100644
--- a/packages/mask/popups/pages/Personas/AccountDetail/index.tsx
+++ b/packages/mask/popups/pages/Personas/AccountDetail/index.tsx
@@ -2,21 +2,11 @@ import Service from '#services'
import { Trans, useLingui } from '@lingui/react/macro'
import { Icons } from '@masknet/icons'
import { delay } from '@masknet/kit'
-import { ConfirmDialog, PersonaContext } from '@masknet/shared'
-import {
- MaskMessages,
- NextIDAction,
- PopupRoutes,
- SOCIAL_MEDIA_SUPPORTING_NEXT_DOT_ID,
- SignType,
- currentSetupGuideStatus,
- type EnhanceableSite,
-} from '@masknet/shared-base'
+import { PersonaContext } from '@masknet/shared'
+import { MaskMessages, PopupRoutes, currentSetupGuideStatus } from '@masknet/shared-base'
import { usePopupCustomSnackbar } from '@masknet/theme'
-import { NextIDProof } from '@masknet/web3-providers'
import { Telemetry } from '@masknet/web3-telemetry'
import { EventType } from '@masknet/web3-telemetry/types'
-import { useTheme } from '@mui/material'
import { useQueryClient } from '@tanstack/react-query'
import { memo, useCallback, useContext, useEffect } from 'react'
import { useNavigate } from 'react-router-dom'
@@ -27,17 +17,11 @@ import { AccountDetailUI } from './UI.js'
export const Component = memo(() => {
const { t } = useLingui()
const navigate = useNavigate()
- const theme = useTheme()
- const { selectedAccount, currentPersona, walletProofs } = PersonaContext.useContainer()
+ const { selectedAccount, currentPersona } = PersonaContext.useContainer()
const { setExtension } = useContext(PageTitleContext)
const { showSnackbar } = usePopupCustomSnackbar()
- const isSupportNextDotID =
- selectedAccount ?
- SOCIAL_MEDIA_SUPPORTING_NEXT_DOT_ID.includes(selectedAccount.identifier.network as EnhanceableSite)
- : false
-
const queryClient = useQueryClient()
const handleDetachProfile = useCallback(async () => {
try {
@@ -47,7 +31,6 @@ export const Component = memo(() => {
currentSetupGuideStatus[selectedAccount.identifier.network].value = ''
await Service.Identity.detachProfile(selectedAccount.identifier)
MaskMessages.events.ownPersonaChanged.sendToAll()
- queryClient.removeQueries({ queryKey: ['@@next-id', 'bindings-by-persona', pubkey] })
queryClient.removeQueries({ queryKey: ['@@my-own-persona-info'] })
showSnackbar(Disconnected. , {
variant: 'success',
@@ -62,100 +45,20 @@ export const Component = memo(() => {
}
}, [selectedAccount, queryClient])
- const pubkey = currentPersona?.identifier.publicKeyAsHex
- const releaseBinding = useCallback(async () => {
- try {
- if (!pubkey || !selectedAccount?.identity || !selectedAccount.platform) return
-
- const result = await NextIDProof.createPersonaPayload(
- pubkey,
- NextIDAction.Delete,
- selectedAccount.identity,
- selectedAccount.platform,
- )
-
- if (!result) return
-
- const signature = await Service.Identity.signWithPersona(
- { type: SignType.Message, data: result.signPayload },
- currentPersona.identifier,
- location.origin,
- true,
- )
-
- if (!signature) return
-
- await Service.Identity.detachProfileWithNextID(
- result.uuid,
- pubkey,
- selectedAccount.platform,
- selectedAccount.identity,
- result.createdAt,
- { signature },
- )
-
- await Service.Identity.detachProfile(selectedAccount.identifier)
- currentSetupGuideStatus[selectedAccount.identifier.network].value = ''
- await delay(1000)
-
- // Broadcast updates
- MaskMessages.events.ownProofChanged.sendToAll()
- MaskMessages.events.ownPersonaChanged.sendToAll()
- await queryClient.refetchQueries({ queryKey: ['@@next-id', 'bindings-by-persona', pubkey] })
- await queryClient.refetchQueries({ queryKey: ['@@my-own-persona-info'] })
-
- showSnackbar(Disconnected. , {
- variant: 'success',
- })
- navigate(-1)
- } catch {
- showSnackbar(Disconnect failed. , {
- variant: 'error',
- })
- }
- }, [selectedAccount, currentPersona])
-
useTitle(t`Social Account`)
useEffect(() => {
if (!selectedAccount) navigate(PopupRoutes.Personas, { replace: true })
setExtension(
- !selectedAccount?.is_valid && selectedAccount?.linkedPersona ?
+ selectedAccount?.linkedPersona ?
- : {
- if (!currentPersona) return
- const confirmed = await ConfirmDialog.openAndWaitForClose({
- title: Disconnect Social Account? ,
- confirmVariant: 'warning',
- message: (
-
- Do you want to remove the verified association between the X account @
-
- {selectedAccount?.identifier.userId}
- {' '}
- and {currentPersona.nickname}?
-
- ),
- })
- if (confirmed) {
- await releaseBinding()
- }
- }}
- />,
+ : ,
)
return () => setExtension(undefined)
- }, [selectedAccount, handleDetachProfile, currentPersona, releaseBinding])
+ }, [selectedAccount, handleDetachProfile, currentPersona])
if (!selectedAccount) return null
- return (
-
- )
+ return
})
Component.displayName = 'AccountDetail'
diff --git a/packages/mask/popups/pages/Personas/ConnectWallet/index.tsx b/packages/mask/popups/pages/Personas/ConnectWallet/index.tsx
index 469844309e39..19690d2c48e3 100644
--- a/packages/mask/popups/pages/Personas/ConnectWallet/index.tsx
+++ b/packages/mask/popups/pages/Personas/ConnectWallet/index.tsx
@@ -1,37 +1,20 @@
import { Icons } from '@masknet/icons'
-import { FormattedAddress, PersonaContext, PopupHomeTabType } from '@masknet/shared'
-import {
- MaskMessages,
- NextIDAction,
- NextIDPlatform,
- PopupModalRoutes,
- PopupRoutes,
- SignType,
- type NetworkPluginID,
- type NextIDPayload,
-} from '@masknet/shared-base'
-import { ActionButton, makeStyles, usePopupCustomSnackbar } from '@masknet/theme'
-import {
- useChainContext,
- useNetworkContext,
- usePrivyWallet,
- useReverseAddress,
- useWallets,
-} from '@masknet/web3-hooks-base'
-import { EVMExplorerResolver, EVMProviderResolver, EVMWeb3, NextIDProof } from '@masknet/web3-providers'
+import { FormattedAddress, PopupHomeTabType } from '@masknet/shared'
+import { PopupModalRoutes, PopupRoutes, type NetworkPluginID } from '@masknet/shared-base'
+import { ActionButton, makeStyles } from '@masknet/theme'
+import { useChainContext, useNetworkContext, useReverseAddress, useWallets } from '@masknet/web3-hooks-base'
+import { EVMExplorerResolver, EVMProviderResolver, EVMWeb3 } from '@masknet/web3-providers'
import { isSameAddress } from '@masknet/web3-shared-base'
-import { EthereumMethodType, formatDomainName, formatEthereumAddress, ProviderType } from '@masknet/web3-shared-evm'
-import { Avatar, Box, Button, Link, Typography } from '@mui/material'
+import { formatDomainName, formatEthereumAddress, ProviderType } from '@masknet/web3-shared-evm'
+import { Box, Button, Link, Typography } from '@mui/material'
import { memo, useCallback } from 'react'
import { useNavigate } from 'react-router-dom'
-import { useAsync, useAsyncFn } from 'react-use'
import urlcat from 'urlcat'
import Services from '#services'
import { Trans, useLingui } from '@lingui/react/macro'
import { BottomController } from '../../../components/BottomController/index.js'
import { useModalNavigate } from '../../../components/index.js'
-import { LoadingMask } from '../../../components/LoadingMask/index.js'
import { useTitle } from '../../../hooks/index.js'
import { WalletAvatar } from '../../../components/WalletAvatar/index.js'
@@ -66,31 +49,6 @@ const useStyles = makeStyles()((theme) => ({
lineHeight: '16px',
color: theme.palette.maskColor.second,
},
- bounded: {
- fontSize: 14,
- lineHeight: '18px',
- color: theme.palette.maskColor.danger,
- marginTop: theme.spacing(1.5),
- },
- congratulation: {
- fontSize: 14,
- lineHeight: '18px',
- color: theme.palette.maskColor.second,
- fontWeight: 700,
- },
- info: {
- display: 'flex',
- flexDirection: 'column',
- justifyContent: 'center',
- alignItems: 'center',
- width: 160,
- rowGap: 4,
- },
- name: {
- fontSize: 14,
- lineHeight: '18px',
- fontWeight: 700,
- },
}))
export const Component = memo(function ConnectWalletPage() {
@@ -99,7 +57,6 @@ export const Component = memo(function ConnectWalletPage() {
const { classes } = useStyles()
const navigate = useNavigate()
const modalNavigate = useModalNavigate()
- const { showSnackbar } = usePopupCustomSnackbar()
const { pluginID } = useNetworkContext()
@@ -107,12 +64,6 @@ export const Component = memo(function ConnectWalletPage() {
const wallets = useWallets()
const { data: domain } = useReverseAddress(pluginID, account)
- const { currentPersona } = PersonaContext.useContainer()
-
- const { value: isBound } = useAsync(async () => {
- if (!account || !currentPersona?.identifier.publicKeyAsHex) return false
- return NextIDProof.queryIsBound(currentPersona.identifier.publicKeyAsHex, NextIDPlatform.Ethereum, account)
- }, [account, currentPersona?.identifier.publicKeyAsHex])
const walletAlias = (() => {
if (domain) return formatDomainName(domain)
@@ -120,95 +71,6 @@ export const Component = memo(function ConnectWalletPage() {
return wallets.find((x) => isSameAddress(x.address, account))?.name ?? formatEthereumAddress(account, 4)
})()
- const walletName = (() => {
- if (providerType === ProviderType.MaskWallet)
- return (
- wallets.find((x) => isSameAddress(x.address, account))?.name ??
- (domain || formatEthereumAddress(account, 4))
- )
-
- return domain || formatEthereumAddress(account, 4)
- })()
-
- const bindProof = useCallback(
- async (payload: NextIDPayload, walletSignature: string, signature: string) => {
- if (!currentPersona) return
- try {
- await NextIDProof.bindProof(
- payload.uuid,
- currentPersona.identifier.publicKeyAsHex,
- NextIDAction.Create,
- NextIDPlatform.Ethereum,
- account,
- payload.createdAt,
- {
- walletSignature,
- signature,
- },
- )
-
- return true
- } catch {
- showSnackbar(Failed to add the wallet, please try again. , {
- variant: 'error',
- })
- return false
- }
- },
- [account, currentPersona],
- )
-
- const privyWallet = usePrivyWallet(account)
- const [{ value: signResult, loading }, handleSign] = useAsyncFn(async () => {
- try {
- if (!currentPersona?.identifier || !account) return
- const payload = await NextIDProof.createPersonaPayload(
- currentPersona.identifier.publicKeyAsHex,
- NextIDAction.Create,
- account,
- NextIDPlatform.Ethereum,
- 'default',
- )
-
- if (!payload) return
- const personaSignature = await Services.Identity.signWithPersona(
- { type: SignType.Message, data: payload.signPayload },
- currentPersona.identifier,
- location.origin,
- true,
- )
-
- let walletSignature = ''
- if (privyWallet?.isConnected) {
- const provider = await privyWallet.getEthereumProvider()
- walletSignature = await provider.request({
- method: EthereumMethodType.personal_sign,
- params: [payload.signPayload, account],
- })
- } else {
- walletSignature = await EVMWeb3.signMessage('message', payload.signPayload, {
- chainId,
- account,
- providerType,
- silent: providerType === ProviderType.MaskWallet,
- })
- }
-
- const result = await bindProof(payload, walletSignature, personaSignature)
-
- if (result) showSnackbar(You have signed with your wallet. )
-
- // Broadcast updates
- MaskMessages.events.ownProofChanged.sendToAll()
- return true
- } catch (error) {
- showSnackbar(Sorry, signature failed! Please try signing again. , {
- variant: 'error',
- })
- return false
- }
- }, [currentPersona, account, chainId, account, providerType, bindProof])
-
const handleCancel = useCallback(async () => {
if (providerType === ProviderType.MaskWallet || providerType === ProviderType.WalletConnect) {
navigate(-1)
@@ -221,7 +83,7 @@ export const Component = memo(function ConnectWalletPage() {
account: maskAccount,
})
await Services.Helper.removePopupWindow()
- }, [signResult, wallets, account, navigate, providerType])
+ }, [wallets, account, navigate, providerType])
const handleChooseAnotherWallet = useCallback(() => {
modalNavigate(PopupModalRoutes.SelectProvider)
@@ -250,90 +112,44 @@ export const Component = memo(function ConnectWalletPage() {
useTitle(t`Connect Wallet`, handleBack)
return (
-
- {!signResult ?
-
-
-
-
-
-
- {walletAlias}
-
-
-
-
-
-
-
-
-
-
- Change
-
-
- {isBound ?
-
-
- This wallet is connected to current persona {String(currentPersona?.nickname)}.
-
+
+
+
+
+
+
+ {walletAlias}
+
+
+
+
+
+
- : null}
-
-
- Adding your wallets will allow you to own, view, and utilize your digital identities via
- Next.ID service. Note that you will be required to sign and authenticate the transaction to
- prove ownership of your wallet.
-
-
- {loading ?
- Signing ...} />
- : null}
-
- :
-
- 🎉
-
-
- Congratulations
-
-
-
- Connected {currentPersona?.nickname} with {walletName}.
-
-
-
-
- {currentPersona?.avatar ?
-
- : }
- {currentPersona?.nickname}
-
-
-
-
- {walletName}
-
- }
+
+ Change
+
+
+
+
+ Adding your wallets will allow you to own, view, and utilize your digital identities. Note that you
+ will be required to sign and authenticate the transaction to prove ownership of your wallet.
+
+
Cancel
- {!signResult ?
-
- Sign
-
- :
- Done
-
- }
+
+ Done
+
)
diff --git a/packages/mask/popups/pages/Personas/Home/index.tsx b/packages/mask/popups/pages/Personas/Home/index.tsx
index d6166d2e06f5..db0da74b3118 100644
--- a/packages/mask/popups/pages/Personas/Home/index.tsx
+++ b/packages/mask/popups/pages/Personas/Home/index.tsx
@@ -1,4 +1,4 @@
-import { memo, useCallback, useMemo } from 'react'
+import { memo, useCallback } from 'react'
import { useNavigate } from 'react-router-dom'
import { PersonaContext } from '@masknet/shared'
import {
@@ -7,7 +7,6 @@ import {
PopupRoutes,
type EnhanceableSite,
type ProfileAccount,
- NextIDPlatform,
} from '@masknet/shared-base'
import { PersonaHomeUI } from './UI.js'
import Services from '#services'
@@ -16,10 +15,9 @@ import { requestPermissionFromExtensionPage } from '../../../../shared-ui/index.
export const Component = memo(function PersonaHome() {
const navigate = useNavigate()
- const { avatar, currentPersona, setSelectedAccount, personas, accounts, proofs } = PersonaContext.useContainer()
+ const { avatar, currentPersona, setSelectedAccount, personas, accounts } = PersonaContext.useContainer()
const { data: definedSocialNetworks = EMPTY_LIST } = useSupportSocialNetworks()
- const bindingWallets = useMemo(() => proofs?.filter((x) => x.platform === NextIDPlatform.Ethereum), [proofs])
const { hasPassword } = useHasPassword()
const onCreatePersona = useCallback(() => {
@@ -60,7 +58,6 @@ export const Component = memo(function PersonaHome() {
return (
('')
const [selected, setSelected] = useState()
const personas = usePersonasFromDB()
- const { currentPersona } = PersonaContext.useContainer()
const source = params.get('source') || undefined
@@ -48,57 +44,15 @@ export const Component = memo(function PersonaSignRequest() {
selectedPersona,
})
- const method = params.get('method') as MethodAfterPersonaSign | undefined
+ const method = params.get('method')
if (!method) {
window.close()
return
}
- // sign request from popup
- switch (method) {
- case MethodAfterPersonaSign.DISCONNECT_NEXT_ID:
- if (!message) break
- const signature = await Services.Identity.signWithPersona(
- { type: SignType.Message, data: message },
- selectedPersona,
- location.origin,
- true,
- )
-
- const profileIdentifier = params.get('profileIdentifier')
- const platform = params.get('platform')
- const identity = params.get('identity')
- const createdAt = params.get('createdAt')
- const uuid = params.get('uuid')
-
- if (
- !signature ||
- !profileIdentifier ||
- !platform ||
- !identity ||
- !createdAt ||
- !uuid ||
- !currentPersona?.identifier.publicKeyAsHex
- )
- break
- await Services.Identity.detachProfileWithNextID(
- uuid,
- currentPersona.identifier.publicKeyAsHex,
- platform,
- identity,
- createdAt,
- {
- signature,
- },
- )
- const profile = currentPersona.linkedProfiles.find((x) => x.identifier.toText() === profileIdentifier)
- if (!profile) break
- await Services.Identity.detachProfile(profile.identifier)
- break
- }
navigate(-1)
- }, [params, selected, requestID, message, currentPersona])
+ }, [params, selected, requestID, message])
const [{ loading: cancelLoading }, handleCancel] = useAsyncFn(async () => {
if (!requestID) return
diff --git a/packages/mask/popups/pages/Personas/components/PersonaHeader/UI.tsx b/packages/mask/popups/pages/Personas/components/PersonaHeader/UI.tsx
index 4f95c88aa57a..f7cb255489fc 100644
--- a/packages/mask/popups/pages/Personas/components/PersonaHeader/UI.tsx
+++ b/packages/mask/popups/pages/Personas/components/PersonaHeader/UI.tsx
@@ -1,6 +1,6 @@
import { memo } from 'react'
import { makeStyles } from '@masknet/theme'
-import { Avatar, Box, Link, Typography } from '@mui/material'
+import { Avatar, Box, Typography } from '@mui/material'
import { Icons } from '@masknet/icons'
import { formatPersonaFingerprint, formatPersonaName } from '@masknet/shared-base'
@@ -46,13 +46,6 @@ const useStyles = makeStyles()((theme) => ({
display: 'flex',
alignItems: 'center',
},
- icon: {
- width: 12,
- height: 12,
- color: theme.palette.maskColor.main,
- cursor: 'pointer',
- marginLeft: 4,
- },
}))
interface PersonaHeaderUIProps {
@@ -75,14 +68,6 @@ export const PersonaHeaderUI = memo(({ avatar, fingerprint
{formatPersonaName(nickname)}
{formatPersonaFingerprint(fingerprint ?? '', 4)}
-
-
-