Skip to content

Commit 75a86b0

Browse files
[Release] Hotfix 2.19.1 => 2.19.2 (patch) (#9427)
* chore: bump version to 2.19.2 * refactor: mf-4047 migrate lens api to firefly (#9428) * refactor: mf-4047 migrate lens api to firefly * fixup! refactor: mf-4047 migrate lens api to firefly * refactor: code style (#9432) * feat: mf-4061 show lens icon in more places (#9437) * refactor: ab simplehash (#9438) * refactor: remove flag --------- Co-authored-by: UncleBill <[email protected]>
1 parent c9de5cc commit 75a86b0

File tree

15 files changed

+101
-48
lines changed

15 files changed

+101
-48
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"yarn": ">=999.0.0",
99
"npm": ">=999.0.0"
1010
},
11-
"version": "2.19.1",
11+
"version": "2.19.2",
1212
"private": true,
1313
"license": "AGPL-3.0-or-later",
1414
"scripts": {

packages/flags/src/flags/index.ts

-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ export const flags = {
3939
i18nTranslationHotUpdate: true,
4040
sandboxedPluginRuntime: insiderOnly,
4141

42-
simplehash_ab_percentage: 50,
43-
4442
/** The earliest version for the sentry to watch events and exceptions. */
4543
sentry_earliest_version: process.env.VERSION,
4644
sentry_sample_rate: 0.1,

packages/mask/src/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Mask Network",
3-
"version": "2.19.1",
3+
"version": "2.19.2",
44
"manifest_version": 2,
55
"permissions": ["storage", "downloads", "webNavigation", "activeTab"],
66
"optional_permissions": ["<all_urls>", "notifications", "clipboardRead"],

packages/mask/src/social-network-adaptor/twitter.com/injection/Lens/injectLensOnUserCell.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { attachReactTreeToGlobalContainer } from '../../../../utils/index.js'
1010
const selector = () => {
1111
// [href^="/search"] is a hash tag
1212
return querySelectorAll<HTMLElement>(
13-
'[data-testid=sidebarColumn] [data-testid=UserCell] div > a[role=link]:not([tabindex]):not([href^="/search"]) [dir]:last-of-type',
13+
'[data-testid=UserCell] div > a[role=link]:not([tabindex]):not([href^="/search"]) [dir]:last-of-type',
1414
)
1515
}
1616

packages/plugins/EVM/src/state/Hub/hub.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { EMPTY_LIST, isDeviceOnWhitelist, mixin } from '@masknet/shared-base'
2-
import { Flags } from '@masknet/flags'
1+
import { EMPTY_LIST, mixin } from '@masknet/shared-base'
32
import { HubStateBaseClient, HubStateFungibleClient, HubStateNonFungibleClient } from '@masknet/web3-state'
43
import {
54
AlchemyEVM,
@@ -162,8 +161,8 @@ class HubNonFungibleClient extends HubStateNonFungibleClient<ChainId, SchemaType
162161
options.chainId === ChainId.Mainnet
163162
? [
164163
X2Y2,
165-
isDeviceOnWhitelist(Flags.simplehash_ab_percentage) ? NFTScanNonFungibleTokenEVM : SimpleHash,
166-
isDeviceOnWhitelist(Flags.simplehash_ab_percentage) ? SimpleHash : NFTScanNonFungibleTokenEVM,
164+
SimpleHash,
165+
NFTScanNonFungibleTokenEVM,
167166
ZerionNonFungibleToken,
168167
Rarible,
169168
OpenSea,
@@ -176,8 +175,8 @@ class HubNonFungibleClient extends HubStateNonFungibleClient<ChainId, SchemaType
176175
R2D2TokenList,
177176
]
178177
: [
179-
isDeviceOnWhitelist(Flags.simplehash_ab_percentage) ? NFTScanNonFungibleTokenEVM : SimpleHash,
180-
isDeviceOnWhitelist(Flags.simplehash_ab_percentage) ? SimpleHash : NFTScanNonFungibleTokenEVM,
178+
SimpleHash,
179+
NFTScanNonFungibleTokenEVM,
181180
ZerionNonFungibleToken,
182181
Rarible,
183182
AlchemyEVM,

packages/plugins/Web3Profile/src/SNSAdaptor/components/LensBadge.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { memo, type FC, useRef, useEffect } from 'react'
22
import { IconButton } from '@mui/material'
33
import { makeStyles } from '@masknet/theme'
4-
import { Plugin } from '@masknet/plugin-infra'
5-
import { type LensAccount } from '@masknet/web3-providers'
64
import { Icons } from '@masknet/icons'
5+
import { Plugin } from '@masknet/plugin-infra'
6+
import type { FireflyBaseAPI } from '@masknet/web3-providers/types'
77
import { openPopup } from '../emitter.js'
88

99
const LensIconSizeMap: Record<Plugin.SNSAdaptor.LensSlot, number> = {
@@ -20,7 +20,7 @@ const useStyles = makeStyles()({
2020
})
2121
interface Props {
2222
slot: Plugin.SNSAdaptor.LensSlot
23-
accounts: LensAccount[]
23+
accounts: FireflyBaseAPI.LensAccount[]
2424
}
2525

2626
export const LensBadge: FC<Props> = memo(({ slot, accounts }) => {

packages/plugins/Web3Profile/src/SNSAdaptor/components/LensList.tsx

+36-24
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import { memo, type FC } from 'react'
2-
import { Button, List, ListItem, Typography, type ListProps } from '@mui/material'
3-
import { makeStyles } from '@masknet/theme'
4-
import type { LensAccount } from '@masknet/web3-providers'
5-
import { useI18N } from '../../locales/i18n_generated.js'
61
import { Icons } from '@masknet/icons'
2+
import { Image } from '@masknet/shared'
73
import { CrossIsolationMessages } from '@masknet/shared-base'
4+
import { makeStyles } from '@masknet/theme'
5+
import type { FireflyBaseAPI } from '@masknet/web3-providers/types'
6+
import { Button, List, ListItem, Typography, type ListProps } from '@mui/material'
7+
import { memo, type FC } from 'react'
8+
import { useI18N } from '../../locales/i18n_generated.js'
89

910
const useStyles = makeStyles()((theme) => {
1011
const isDark = theme.palette.mode === 'dark'
@@ -38,6 +39,9 @@ const useStyles = makeStyles()((theme) => {
3839
marginBottom: 0,
3940
},
4041
},
42+
avatar: {
43+
borderRadius: '50%',
44+
},
4145
name: {
4246
color: theme.palette.maskColor.main,
4347
fontWeight: 400,
@@ -64,32 +68,40 @@ const useStyles = makeStyles()((theme) => {
6468
}
6569
})
6670
interface Props extends ListProps {
67-
accounts: LensAccount[]
71+
accounts: FireflyBaseAPI.LensAccount[]
6872
}
6973

7074
export const LensList: FC<Props> = memo(({ className, accounts, ...rest }) => {
7175
const { classes, cx } = useStyles()
7276
const t = useI18N()
7377
return (
7478
<List className={cx(classes.list, className)} {...rest}>
75-
{accounts.map((account) => (
76-
<ListItem className={classes.listItem} key={account.displayName}>
77-
<Icons.Lens size={20} />
78-
<Typography className={classes.name}>{account.displayName || account.handle}</Typography>
79-
<Button
80-
variant="text"
81-
className={classes.followButton}
82-
disableElevation
83-
onClick={() => {
84-
CrossIsolationMessages.events.followLensDialogEvent.sendToLocal({
85-
open: true,
86-
handle: account.handle,
87-
})
88-
}}>
89-
{t.follow()}
90-
</Button>
91-
</ListItem>
92-
))}
79+
{accounts.map((account) => {
80+
const profileUri = account.profileUri.filter(Boolean)
81+
const lensIcon = <Icons.Lens size={20} />
82+
return (
83+
<ListItem className={classes.listItem} key={account.handle}>
84+
{profileUri.length ? (
85+
<Image size={20} src={profileUri[0]} className={classes.avatar} fallback={lensIcon} />
86+
) : (
87+
lensIcon
88+
)}
89+
<Typography className={classes.name}>{account.name || account.handle}</Typography>
90+
<Button
91+
variant="text"
92+
className={classes.followButton}
93+
disableElevation
94+
onClick={() => {
95+
CrossIsolationMessages.events.followLensDialogEvent.sendToLocal({
96+
open: true,
97+
handle: account.handle,
98+
})
99+
}}>
100+
{t.follow()}
101+
</Button>
102+
</ListItem>
103+
)
104+
})}
93105
</List>
94106
)
95107
})

packages/plugins/Web3Profile/src/SNSAdaptor/components/LensPopup.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
import { isEqual } from 'lodash-es'
12
import { memo, useEffect, useState, useRef } from 'react'
3+
import { Fade } from '@mui/material'
24
import { makeStyles } from '@masknet/theme'
3-
import type { LensAccount } from '@masknet/web3-providers'
5+
import type { FireflyBaseAPI } from '@masknet/web3-providers/types'
46
import { emitter } from '../emitter.js'
5-
import { isEqual } from 'lodash-es'
67
import { LensList } from './LensList.js'
78
import { useControlLensPopup } from '../hooks/Lens/useControlLensPopup.js'
8-
import { Fade } from '@mui/material'
99

1010
const useStyles = makeStyles()((theme) => ({
1111
popup: {
@@ -21,7 +21,7 @@ const useStyles = makeStyles()((theme) => ({
2121
export const LensPopup = memo(() => {
2222
const { classes } = useStyles()
2323
const holderRef = useRef<HTMLDivElement>(null)
24-
const [lens, setLens] = useState<LensAccount[]>([])
24+
const [lens, setLens] = useState<FireflyBaseAPI.LensAccount[]>([])
2525
const { style, active } = useControlLensPopup(holderRef)
2626

2727
useEffect(() => {

packages/plugins/Web3Profile/src/SNSAdaptor/emitter.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1+
import type { FireflyBaseAPI } from '@masknet/web3-providers/types'
12
import { Emitter } from '@servie/events'
23
import type { BadgeBounding } from './types.js'
3-
import type { LensAccount } from '@masknet/web3-providers'
44

55
export const emitter = new Emitter<{
6-
open: [{ badgeBounding: BadgeBounding; lensAccounts: LensAccount[] }]
6+
open: [{ badgeBounding: BadgeBounding; lensAccounts: FireflyBaseAPI.LensAccount[] }]
77
close: []
88
}>()
99

10-
export function openPopup(badgeBounding: BadgeBounding, lensAccounts: LensAccount[]) {
10+
export function openPopup(badgeBounding: BadgeBounding, lensAccounts: FireflyBaseAPI.LensAccount[]) {
1111
emitter.emit('open', { badgeBounding, lensAccounts })
1212
}
1313

packages/plugins/Web3Profile/src/SNSAdaptor/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { context, setupContext, setupStorage } from './context.js'
1010
import { Web3ProfileDialog } from './components/Web3ProfileDialog.js'
1111
import { FollowLensDialog } from './components/FollowLensDialog.js'
1212
import { useAsync } from 'react-use'
13-
import { NextIDProof } from '@masknet/web3-providers'
13+
import { Firefly } from '@masknet/web3-providers'
1414
import { LensBadge } from './components/LensBadge.js'
1515
import { LensPopup } from './components/LensPopup.js'
1616
import { ChainContextProvider } from '@masknet/web3-hooks-base'
@@ -113,7 +113,7 @@ const sns: Plugin.SNSAdaptor.Definition = {
113113
Content({ identity, slot, onStatusUpdate }) {
114114
const { value: accounts = EMPTY_LIST } = useAsync(async () => {
115115
if (!identity?.userId) return
116-
return NextIDProof.queryAllLens(identity?.userId)
116+
return Firefly.getLensByTwitterId(identity.userId)
117117
}, [identity?.userId])
118118

119119
const hasLens = !accounts.length
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const BASE_URL = 'https://mask-network.firefly.land/v1'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import urlcat from 'urlcat'
2+
import { BASE_URL } from './constants.js'
3+
import { fetchJSON } from '../entry-helpers.js'
4+
import type { FireflyBaseAPI } from '../entry-types.js'
5+
6+
export class FireflyAPI implements FireflyBaseAPI.Provider {
7+
async getLensByTwitterId(twitterHandle: string): Promise<FireflyBaseAPI.LensAccount[]> {
8+
const result = await fetchJSON<FireflyBaseAPI.LensResult>(
9+
urlcat(BASE_URL, '/account/lens', {
10+
twitterHandle,
11+
}),
12+
)
13+
if (result.code !== 200) return []
14+
return result.data
15+
}
16+
}

packages/web3-providers/src/entry-types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export * from './types/Bundler.js'
55
export * from './types/DSearch.js'
66
export * from './types/Domain.js'
77
export * from './types/Explorer.js'
8+
export * from './types/Firefly.js'
89
export * from './types/FungibleToken.js'
910
export * from './types/Funder.js'
1011
export * from './types/Fuse.js'

packages/web3-providers/src/entry.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ import { SmartPayOwnerAPI } from './SmartPay/apis/OwnerAPI.js'
6767
import { SimpleHashProviderAPI } from './SimpleHash/index.js'
6868
import { RSS3API } from './RSS3/index.js'
6969
import { LidoAPI } from './Lido/index.js'
70+
import { FireflyAPI } from './Firefly/index.js'
7071

7172
export const OpenSea = new OpenSeaAPI()
7273
export const Lido = new LidoAPI()
@@ -187,4 +188,6 @@ export * from './Storage/index.js'
187188

188189
// RSS3
189190
export const RSS3 = new RSS3API()
190-
export * from './helpers/parseJSON.js'
191+
192+
// Firefly
193+
export const Firefly = new FireflyAPI()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
export namespace FireflyBaseAPI {
2+
export type Result<T> = {
3+
code: number
4+
reason: string
5+
message: string
6+
data: T
7+
}
8+
9+
export interface LensAccount {
10+
address: string
11+
name: string
12+
handle: string
13+
bio: string
14+
url: string
15+
profileUri: string[]
16+
}
17+
18+
export type LensResult = Result<LensAccount[]>
19+
20+
export interface Provider {
21+
getLensByTwitterId(twitterHandle: string): Promise<LensAccount[]>
22+
}
23+
}

0 commit comments

Comments
 (0)