@@ -12,17 +12,7 @@ import {
12
12
type SocialAddress ,
13
13
type SocialIdentity ,
14
14
} from '@masknet/shared-base'
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'
15
+ import { ENS , Lens , MaskX , NextIDProof , NextIDStorageProvider , RSS3 , SpaceID , Twitter } from '@masknet/web3-providers'
26
16
import { captureAsyncTransaction } from '@masknet/web3-providers/helpers'
27
17
import { MaskX_BaseAPI } from '@masknet/web3-providers/types'
28
18
import { ChainId , isValidAddress , isZeroAddress } from '@masknet/web3-shared-evm'
@@ -148,7 +138,7 @@ export class IdentityService extends IdentityServiceState<ChainId> {
148
138
return this . createSocialAddress ( SocialAddressType . Crossbell , info . address , info . crossbell )
149
139
} ) ,
150
140
)
151
- return compact ( allSettled . map ( ( x ) => ( x . status === 'fulfilled' ? x . value : undefined ) ) . filter ( Boolean ) )
141
+ return compact ( allSettled . map ( ( x ) => ( x . status === 'fulfilled' ? x . value : undefined ) ) )
152
142
}
153
143
154
144
/** Read a social address from avatar NextID storage. */
@@ -228,22 +218,7 @@ export class IdentityService extends IdentityServiceState<ChainId> {
228
218
return this . createSocialAddress ( SocialAddressType . Lens , profile . ownedBy , name )
229
219
} ) ,
230
220
)
231
- return compact ( allSettled . map ( ( x ) => ( x . status === 'fulfilled' ? x . value : undefined ) ) . filter ( Boolean ) )
232
- }
233
-
234
- private async getSocialAddressFromFirefly ( { identifier } : SocialIdentity ) {
235
- const lensAccounts = await Firefly . getLensByTwitterId ( identifier ?. userId )
236
- const names = lensAccounts . map ( ( x ) => x . handle )
237
- if ( ! names . length ) return
238
-
239
- const allSettled = await Promise . allSettled (
240
- names . map ( async ( name ) => {
241
- const profile = await Lens . getProfileByHandle ( name )
242
- if ( ! profile ) return
243
- return this . createSocialAddress ( SocialAddressType . Firefly , profile . ownedBy , name )
244
- } ) ,
245
- )
246
- return compact ( allSettled . map ( ( x ) => ( x . status === 'fulfilled' ? x . value : undefined ) ) . filter ( Boolean ) )
221
+ return compact ( allSettled . map ( ( x ) => ( x . status === 'fulfilled' ? x . value : undefined ) ) )
247
222
}
248
223
249
224
/** Read a social address from Twitter Blue. */
@@ -273,6 +248,7 @@ export class IdentityService extends IdentityServiceState<ChainId> {
273
248
MaskX_BaseAPI . SourceType . Leaderboard ,
274
249
MaskX_BaseAPI . SourceType . OpenSea ,
275
250
MaskX_BaseAPI . SourceType . Sybil ,
251
+ MaskX_BaseAPI . SourceType . RSS3 ,
276
252
]
277
253
const results = response . records . filter ( ( x ) => {
278
254
if ( ! isValidAddress ( x . web3_addr ) || ! sourceTypes . includes ( x . source ) ) return false
@@ -305,7 +281,7 @@ export class IdentityService extends IdentityServiceState<ChainId> {
305
281
}
306
282
307
283
override async getFromRemote ( identity : SocialIdentity , includes ?: SocialAddressType [ ] ) {
308
- const socialAddressFromFirefly = this . getSocialAddressFromFirefly ( identity )
284
+ const socialAddressFromMaskX = this . getSocialAddressesFromMaskX ( identity )
309
285
const allSettled = await Promise . allSettled ( [
310
286
captureAsyncTransaction ( 'getSocialAddressFromBio' , this . getSocialAddressFromBio ( identity ) ) ,
311
287
captureAsyncTransaction ( 'getSocialAddressFromENS' , this . getSocialAddressFromENS ( identity ) ) ,
@@ -317,40 +293,25 @@ export class IdentityService extends IdentityServiceState<ChainId> {
317
293
captureAsyncTransaction ( 'getSocialAddressFromCrossbell' , this . getSocialAddressFromCrossbell ( identity ) ) ,
318
294
captureAsyncTransaction ( 'getSocialAddressFromTwitterBlue' , this . getSocialAddressFromTwitterBlue ( identity ) ) ,
319
295
captureAsyncTransaction ( 'getSocialAddressesFromNextID' , this . getSocialAddressesFromNextID ( identity ) ) ,
320
- captureAsyncTransaction ( 'getSocialAddressesFromMaskX' , this . getSocialAddressesFromMaskX ( identity ) ) ,
296
+ captureAsyncTransaction ( 'getSocialAddressesFromMaskX' , socialAddressFromMaskX ) ,
321
297
captureAsyncTransaction ( 'getSocialAddressFromLens' , this . getSocialAddressFromLens ( identity ) ) ,
322
- captureAsyncTransaction ( 'getSocialAddressFromFirefly' , socialAddressFromFirefly ) ,
323
298
] )
324
- const identities_ = allSettled
325
- . flatMap ( ( x ) => ( x . status === 'fulfilled' ? x . value : [ ] ) )
326
- . filter ( Boolean ) as Array < SocialAddress < ChainId > >
299
+ const identities_ = compact ( allSettled . flatMap ( ( x ) => ( x . status === 'fulfilled' ? x . value : [ ] ) ) )
327
300
328
301
const identities = uniqBy ( identities_ , ( x ) => [ x . type , x . label , x . address . toLowerCase ( ) ] . join ( '_' ) )
329
- if ( ! getNextIDPlatform ( ) || ! ( process . env . channel === 'stable' && process . env . NODE_ENV === 'production' ) ) {
330
- return identities
331
- }
332
- const [ identitiesFromNextID , lensAccounts ] = await Promise . all ( [
302
+ const [ identitiesFromNextID , trustedAccounts ] = await Promise . all ( [
333
303
this . getSocialAddressesFromNextID ( identity ) ,
334
- socialAddressFromFirefly ,
304
+ socialAddressFromMaskX ,
335
305
] )
336
- const lensAddresses = lensAccounts ?. map ( ( x ) => x . address . toLowerCase ( ) ) ?? [ ]
306
+ const trustedAddresses = trustedAccounts ?. map ( ( x ) => x . address . toLowerCase ( ) ) ?? [ ]
337
307
const identitiesAddressesFromNextID = identitiesFromNextID . map ( ( y ) => y . address . toLowerCase ( ) )
338
- const allSettledTrustedIdentities = await Promise . allSettled (
339
- uniqBy ( identities , ( x ) => x . address . toLowerCase ( ) ) . map ( async ( x ) => {
340
- const trusted =
341
- lensAddresses . includes ( x . address . toLowerCase ( ) ) ||
342
- ( await NextIDProof . verifyTwitterHandlerByAddress ( x . address , identity . identifier ?. userId ?? '' ) )
343
- return { ...x , trusted }
344
- } ) ,
345
- )
346
308
347
309
return uniqBy (
348
- (
349
- allSettledTrustedIdentities
350
- . flatMap ( ( x ) => ( x . status === 'fulfilled' && x . value . trusted ? x . value : undefined ) )
351
- . filter ( Boolean ) as Array < SocialAddress < ChainId > >
352
- )
353
- . filter ( ( x ) => ! identitiesAddressesFromNextID . includes ( x . address . toLowerCase ( ) ) )
310
+ identities
311
+ . filter ( ( x ) => {
312
+ const address = x . address . toLowerCase ( )
313
+ return ! identitiesAddressesFromNextID . includes ( address ) && trustedAddresses . includes ( address )
314
+ } )
354
315
. concat ( identitiesFromNextID ) ,
355
316
( x ) => x . address . toLowerCase ( ) ,
356
317
)
0 commit comments