@@ -12,7 +12,17 @@ import {
12
12
type SocialAddress ,
13
13
type SocialIdentity ,
14
14
} from '@masknet/shared-base'
15
- import { ENS , Lens , MaskX , NextIDProof , NextIDStorageProvider , RSS3 , SpaceID , Twitter } from '@masknet/web3-providers'
15
+ import {
16
+ ENS ,
17
+ Firefly ,
18
+ Lens ,
19
+ MaskX ,
20
+ NextIDProof ,
21
+ NextIDStorageProvider ,
22
+ RSS3 ,
23
+ SpaceID ,
24
+ Twitter ,
25
+ } from '@masknet/web3-providers'
16
26
import { captureAsyncTransaction } from '@masknet/web3-providers/helpers'
17
27
import { MaskX_BaseAPI } from '@masknet/web3-providers/types'
18
28
import { ChainId , isValidAddress , isZeroAddress } from '@masknet/web3-shared-evm'
@@ -82,10 +92,13 @@ const resolveMaskXAddressType = createLookupTableResolver<MaskX_BaseAPI.SourceTy
82
92
{
83
93
[ MaskX_BaseAPI . SourceType . CyberConnect ] : SocialAddressType . CyberConnect ,
84
94
[ MaskX_BaseAPI . SourceType . Firefly ] : SocialAddressType . Firefly ,
95
+ [ MaskX_BaseAPI . SourceType . HandWriting ] : SocialAddressType . Firefly ,
85
96
[ MaskX_BaseAPI . SourceType . Leaderboard ] : SocialAddressType . Leaderboard ,
86
97
[ MaskX_BaseAPI . SourceType . OpenSea ] : SocialAddressType . OpenSea ,
87
98
[ MaskX_BaseAPI . SourceType . Sybil ] : SocialAddressType . Sybil ,
99
+ [ MaskX_BaseAPI . SourceType . Uniswap ] : SocialAddressType . Sybil ,
88
100
[ MaskX_BaseAPI . SourceType . RSS3 ] : SocialAddressType . RSS3 ,
101
+ [ MaskX_BaseAPI . SourceType . TwitterHexagon ] : SocialAddressType . TwitterBlue ,
89
102
} ,
90
103
( x ) => {
91
104
throw new Error ( `Unknown source type: ${ x } ` )
@@ -242,16 +255,8 @@ export class IdentityService extends IdentityServiceState<ChainId> {
242
255
if ( ! userId ) return
243
256
244
257
const response = await MaskX . getIdentitiesExact ( userId , MaskX_BaseAPI . PlatformType . Twitter )
245
- const sourceTypes = [
246
- MaskX_BaseAPI . SourceType . CyberConnect ,
247
- MaskX_BaseAPI . SourceType . Firefly ,
248
- MaskX_BaseAPI . SourceType . Leaderboard ,
249
- MaskX_BaseAPI . SourceType . OpenSea ,
250
- MaskX_BaseAPI . SourceType . Sybil ,
251
- MaskX_BaseAPI . SourceType . RSS3 ,
252
- ]
253
258
const results = response . records . filter ( ( x ) => {
254
- if ( ! isValidAddress ( x . web3_addr ) || ! sourceTypes . includes ( x . source ) ) return false
259
+ if ( ! isValidAddress ( x . web3_addr ) || ! x . is_verified ) return false
255
260
256
261
try {
257
262
// detect if a valid data source
@@ -267,13 +272,9 @@ export class IdentityService extends IdentityServiceState<ChainId> {
267
272
try {
268
273
const name = await ENS . reverse ( y . web3_addr )
269
274
270
- return this . createSocialAddress (
271
- resolveMaskXAddressType ( y . source ) ,
272
- y . web3_addr ,
273
- name ?? y . sns_handle ,
274
- )
275
+ return this . createSocialAddress ( resolveMaskXAddressType ( y . source ) , y . web3_addr , name )
275
276
} catch {
276
- return this . createSocialAddress ( resolveMaskXAddressType ( y . source ) , y . web3_addr , y . sns_handle )
277
+ return this . createSocialAddress ( resolveMaskXAddressType ( y . source ) , y . web3_addr )
277
278
}
278
279
} ) ,
279
280
)
@@ -282,6 +283,7 @@ export class IdentityService extends IdentityServiceState<ChainId> {
282
283
283
284
override async getFromRemote ( identity : SocialIdentity , includes ?: SocialAddressType [ ] ) {
284
285
const socialAddressFromMaskX = this . getSocialAddressesFromMaskX ( identity )
286
+ const socialAddressFromNextID = this . getSocialAddressesFromNextID ( identity )
285
287
const allSettled = await Promise . allSettled ( [
286
288
captureAsyncTransaction ( 'getSocialAddressFromBio' , this . getSocialAddressFromBio ( identity ) ) ,
287
289
captureAsyncTransaction ( 'getSocialAddressFromENS' , this . getSocialAddressFromENS ( identity ) ) ,
@@ -292,28 +294,25 @@ export class IdentityService extends IdentityServiceState<ChainId> {
292
294
) ,
293
295
captureAsyncTransaction ( 'getSocialAddressFromCrossbell' , this . getSocialAddressFromCrossbell ( identity ) ) ,
294
296
captureAsyncTransaction ( 'getSocialAddressFromTwitterBlue' , this . getSocialAddressFromTwitterBlue ( identity ) ) ,
295
- captureAsyncTransaction ( 'getSocialAddressesFromNextID' , this . getSocialAddressesFromNextID ( identity ) ) ,
297
+ captureAsyncTransaction ( 'getSocialAddressesFromNextID' , socialAddressFromNextID ) ,
296
298
captureAsyncTransaction ( 'getSocialAddressesFromMaskX' , socialAddressFromMaskX ) ,
297
299
captureAsyncTransaction ( 'getSocialAddressFromLens' , this . getSocialAddressFromLens ( identity ) ) ,
298
300
] )
299
301
const identities_ = compact ( allSettled . flatMap ( ( x ) => ( x . status === 'fulfilled' ? x . value : [ ] ) ) )
300
302
301
303
const identities = uniqBy ( identities_ , ( x ) => [ x . type , x . label , x . address . toLowerCase ( ) ] . join ( '_' ) )
302
- const [ identitiesFromNextID , trustedAccounts ] = await Promise . all ( [
303
- this . getSocialAddressesFromNextID ( identity ) ,
304
- socialAddressFromMaskX ,
305
- ] )
306
- const trustedAddresses = trustedAccounts ?. map ( ( x ) => x . address . toLowerCase ( ) ) ?? [ ]
307
- const identitiesAddressesFromNextID = identitiesFromNextID . map ( ( y ) => y . address . toLowerCase ( ) )
308
-
309
- return uniqBy (
310
- identities
311
- . filter ( ( x ) => {
312
- const address = x . address . toLowerCase ( )
313
- return ! identitiesAddressesFromNextID . includes ( address ) && trustedAddresses . includes ( address )
314
- } )
315
- . concat ( identitiesFromNextID ) ,
316
- ( x ) => x . address . toLowerCase ( ) ,
304
+ const identitiesFromNextID = await socialAddressFromNextID
305
+
306
+ const handle = identity . identifier ?. userId
307
+ const verifiedResult = await Promise . allSettled (
308
+ uniqBy ( identities , ( x ) => x . address . toLowerCase ( ) ) . map ( async ( x ) => {
309
+ const address = x . address . toLowerCase ( )
310
+ const isReliable = await Firefly . verifyTwitterHandlerByAddress ( address , handle )
311
+ return isReliable ? address : null
312
+ } ) ,
317
313
)
314
+ const trustedAddresses = compact ( verifiedResult . map ( ( x ) => ( x . status === 'fulfilled' ? x . value : null ) ) )
315
+
316
+ return identities . filter ( ( x ) => trustedAddresses . includes ( x . address . toLowerCase ( ) ) ) . concat ( identitiesFromNextID )
318
317
}
319
318
}
0 commit comments