Skip to content

Commit 6be4640

Browse files
authored
fix: mf-6667 support related twitters (#12207)
1 parent a88b07d commit 6be4640

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

packages/web3-providers/src/DSearch/index.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -404,17 +404,22 @@ class DSearchAPI<ChainId = Web3Helper.ChainIdAll, SchemaType = Web3Helper.Schema
404404
>,
405405
)
406406
.filter((x) => {
407-
const resultTwitterHandle =
407+
const resultTwitter =
408408
(x as NonFungibleCollectionResult<ChainId, SchemaType>).collection?.socialLinks?.twitter ||
409409
(x as FungibleTokenResult<ChainId, SchemaType>).socialLinks?.twitter
410-
if (!resultTwitterHandle) return false
410+
const relatedTwitters =
411+
(x as NonFungibleCollectionResult<ChainId, SchemaType>).collection?.relatedTwitters ||
412+
(x as FungibleTokenResult<ChainId, SchemaType>).relatedTwitters ||
413+
[]
411414
const handle = twitterHandle.toLowerCase()
412-
return (
413-
[handle, `https://twitter.com/${handle}`, `https://x.com/${handle}`].includes(
414-
resultTwitterHandle.toLowerCase(),
415-
) &&
416-
((x.rank && x.rank <= 500) || x.id === 'mask-network')
417-
)
415+
const isMatched =
416+
resultTwitter ?
417+
[handle, `https://twitter.com/${handle}`, `https://x.com/${handle}`].includes(
418+
resultTwitter.toLowerCase(),
419+
)
420+
: false
421+
const isRelated = relatedTwitters.includes(handle) || isMatched
422+
return isRelated && ((x.rank && x.rank <= 500) || x.id === 'mask-network')
418423
})
419424
.sort((a, b) => (a.rank || 0) - (b.rank || 0)),
420425
(a, b) => a.id === b.id,

packages/web3-shared/base/src/specs/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@ export interface NonFungibleCollection<ChainId, SchemaType> {
406406
source?: SourceType
407407
assets?: Array<NonFungibleAsset<ChainId, SchemaType>>
408408
socialLinks?: SocialLinks
409+
relatedTwitters?: string[]
409410
floorPrices?: Array<{
410411
marketplace_id: LiteralUnion<'blur' | 'looksrare' | 'opensea' | 'x2y2'>
411412
marketplace_name: LiteralUnion<'Blur' | 'LooksRare' | 'OpenSea' | 'X2Y2'>
@@ -708,6 +709,7 @@ export interface FungibleTokenResult<ChainId, SchemaType> extends Result<ChainId
708709
source: SourceType
709710
token?: FungibleToken<ChainId, SchemaType>
710711
socialLinks?: SocialLinks
712+
relatedTwitters?: string[]
711713
}
712714

713715
export interface NonFungibleTokenResult<ChainId, SchemaType> extends Result<ChainId> {

0 commit comments

Comments
 (0)