Skip to content

Commit

Permalink
fix: mf-5253 social address from social info (#10806)
Browse files Browse the repository at this point in the history
  • Loading branch information
UncleBill authored and guanbinrui committed Sep 22, 2023
1 parent 61ceb53 commit c5ef1c4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 18 deletions.
11 changes: 8 additions & 3 deletions packages/shared/src/UI/components/AccountIcon/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,14 @@ export function AccountIcon({ socialAccount, classes: externalClasses }: Account
}
: undefined

const fromTwitter = [SocialAddressType.Address, SocialAddressType.ENS, SocialAddressType.TwitterBlue].find((x) =>
supportedAddressTypes.includes(x),
)
const fromTwitter = [
SocialAddressType.ENS,
SocialAddressType.SPACE_ID,
SocialAddressType.ARBID,
SocialAddressType.Lens,
SocialAddressType.TwitterBlue,
SocialAddressType.Address,
].find((x) => supportedAddressTypes.includes(x))

return (
<>
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-providers/src/Web3/Base/state/Identity.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { LRUCache } from 'lru-cache'
import { groupBy, first, compact, uniq } from 'lodash-es'
import { groupBy, compact, uniq, first } from 'lodash-es'
import {
type SocialAddress,
type SocialIdentity,
Expand Down
34 changes: 20 additions & 14 deletions packages/web3-providers/src/Web3/EVM/state/IdentityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,13 @@ export class IdentityService extends IdentityServiceState<ChainId> {
names.map(async (name) => {
const address = await ENS.lookup(name)
if (!address) return
return this.createSocialAddress(SocialAddressType.ENS, address, name)
return [
this.createSocialAddress(SocialAddressType.ENS, address, name),
this.createSocialAddress(SocialAddressType.Address, address, name),
]
}),
)
return uniqBy(compact(allSettled.map((x) => (x.status === 'fulfilled' ? x.value : undefined))), (x) =>
x.address.toLowerCase(),
)
return compact(allSettled.flatMap((x) => (x.status === 'fulfilled' ? x.value : undefined)))
}

private async getSocialAddressFromARBID({ identifier, nickname = '', bio = '' }: SocialIdentity) {
Expand All @@ -228,12 +229,13 @@ export class IdentityService extends IdentityServiceState<ChainId> {
names.map(async (name) => {
const address = await ARBID.lookup(name)
if (!address) return
return this.createSocialAddress(SocialAddressType.SPACE_ID, address, name, ChainId.Arbitrum)
return [
this.createSocialAddress(SocialAddressType.ARBID, address, name, ChainId.Arbitrum),
this.createSocialAddress(SocialAddressType.Address, address, name, ChainId.Arbitrum),
]
}),
)
return uniqBy(compact(allSettled.map((x) => (x.status === 'fulfilled' ? x.value : undefined))), (x) =>
x.address.toLowerCase(),
)
return compact(allSettled.flatMap((x) => (x.status === 'fulfilled' ? x.value : undefined)))
}

private async getSocialAddressFromSpaceID({ identifier, nickname = '', bio = '' }: SocialIdentity) {
Expand All @@ -244,12 +246,13 @@ export class IdentityService extends IdentityServiceState<ChainId> {
names.map(async (name) => {
const address = await SpaceID.lookup(name)
if (!address) return
return this.createSocialAddress(SocialAddressType.SPACE_ID, address, name, ChainId.BSC)
return [
this.createSocialAddress(SocialAddressType.SPACE_ID, address, name, ChainId.BSC),
this.createSocialAddress(SocialAddressType.Address, address, name, ChainId.BSC),
]
}),
)
return uniqBy(compact(allSettled.map((x) => (x.status === 'fulfilled' ? x.value : undefined))), (x) =>
x.address.toLowerCase(),
)
return compact(allSettled.flatMap((x) => (x.status === 'fulfilled' ? x.value : undefined)))
}

private async getSocialAddressFromLens({ nickname = '', bio = '', homepage = '' }: SocialIdentity) {
Expand All @@ -260,10 +263,13 @@ export class IdentityService extends IdentityServiceState<ChainId> {
names.map(async (name) => {
const profile = await Lens.getProfileByHandle(name)
if (!profile) return
return this.createSocialAddress(SocialAddressType.Lens, profile.ownedBy, name)
return [
this.createSocialAddress(SocialAddressType.Lens, profile.ownedBy, name),
this.createSocialAddress(SocialAddressType.Address, profile.ownedBy, name),
]
}),
)
return compact(allSettled.map((x) => (x.status === 'fulfilled' ? x.value : undefined)))
return compact(allSettled.flatMap((x) => (x.status === 'fulfilled' ? x.value : undefined)))
}

/** Read a social address from Twitter Blue. */
Expand Down

0 comments on commit c5ef1c4

Please sign in to comment.