Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Release] Hotfix 2.24.5 => 2.24.6 (patch) #11450

Merged
merged 10 commits into from
Mar 29, 2024
3 changes: 3 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@
"resizer",
"rhonin",
"rindexed",
"ronin",
"roninchain",
"rpid",
"sablier",
"sbch",
Expand All @@ -265,6 +267,7 @@
"scrl",
"scroller",
"secp",
"sepolia",
"serializers",
"shiden",
"siddomains",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"yarn": ">=999.0.0",
"npm": ">=999.0.0"
},
"version": "2.24.5",
"version": "2.24.6",
"private": true,
"license": "AGPL-3.0-or-later",
"scripts": {
Expand Down
6 changes: 5 additions & 1 deletion packages/mask/background/services/identity/persona/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,12 @@ export async function querySocialIdentity(
identity: IdentityResolved | undefined,
): Promise<SocialIdentity | undefined> {
if (!identity?.identifier) return
const bindings = await queryPersonasFromNextID(platform, identity)
const persona = await queryPersonaByProfile(identity.identifier)
if (!persona) return identity

const bindings = await queryPersonasFromNextID(platform, identity)
if (!bindings) return identity

const personaBindings =
bindings?.filter((x) => x.persona === persona?.identifier.publicKeyAsHex.toLowerCase()) ?? []
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ async function queryPersonaFromDB(identityResolved: IdentityResolved) {

async function queryPersonasFromNextID(identityResolved: IdentityResolved) {
if (!identityResolved.identifier) return
if (!activatedSiteAdaptorUI!.configuration.nextIDConfig?.platform) return
if (!activatedSiteAdaptorUI?.configuration.nextIDConfig?.platform) return
return NextIDProof.queryAllExistedBindingsByPlatform(
activatedSiteAdaptorUI!.configuration.nextIDConfig?.platform,
activatedSiteAdaptorUI.configuration.nextIDConfig.platform,
identityResolved.identifier.userId,
)
}
Expand Down Expand Up @@ -68,10 +68,15 @@ export function useSocialIdentity(identity: IdentityResolved | null | undefined)
enabled: !!identity,
queryKey: ['social-identity', identity],
queryFn: async () => {
if (!identity) return null
try {
const bindings = await queryPersonasFromNextID(identity)
if (!identity) return null

const persona = await queryPersonaFromDB(identity)
if (!persona) return identity

const bindings = await queryPersonasFromNextID(identity)
if (!bindings) return identity

const personaBindings =
bindings?.filter((x) => x.persona === persona?.identifier.publicKeyAsHex.toLowerCase()) ?? []
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ export const IdentityProviderFacebook: SiteAdaptorUI.CollectingCapabilities.Iden
}

function resolveLastRecognizedIdentityFacebookInner(ref: ValueRef<IdentityResolved>, signal: AbortSignal) {
const self = (isMobileFacebook ? myUsernameLiveSelectorMobile : myUsernameLiveSelectorPC)
.clone()
.map((x) => getProfileIdentifierAtFacebook(x, false))
const self = myUsernameLiveSelectorPC.clone().map((x) => getProfileIdentifierAtFacebook(x, false))
new MutationObserverWatcher(self)
.addListener('onAdd', (e) => assign(e.value))
.addListener('onChange', (e) => assign(e.newValue))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
import { LiveSelector, MutationObserverWatcher } from '@dimensiondev/holoflows-kit'
import { attachReactTreeWithContainer } from '../../../utils/shadow-root/renderInShadowRoot.js'
import { startWatch } from '../../../utils/startWatch.js'
import { isMobileFacebook } from '../utils/isMobile.js'
import { Banner } from '../../../components/Welcomes/Banner.js'

let composeBox: LiveSelector<Element>
if (isMobileFacebook) {
composeBox = new LiveSelector().querySelector('#structured_composer_form')
} else {
composeBox = new LiveSelector()
.querySelector('[role="dialog"] form')
.querySelectorAll('[role="button"][tabindex="0"], [role="button"][tabindex="-1"]')
.map((x) => x.parentElement)
.at(-1)
}
const composeBox: LiveSelector<Element> = new LiveSelector()
.querySelectorAll(
'[role="dialog"] form [role="button"][tabindex="0"], [role="dialog"] form [role="button"][tabindex="-1"]',
)
.map((x) => x.parentElement)
.at(-1)

export function injectBannerAtFacebook(signal: AbortSignal) {
const watcher = new MutationObserverWatcher(composeBox.clone())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function getNickname(nickname?: string) {

function resolveLastRecognizedIdentityInner(
ref: SiteAdaptorUI.CollectingCapabilities.IdentityResolveProvider['recognized'],
cancel: AbortSignal,
signal: AbortSignal,
) {
const assign = async () => {
await delay(2000)
Expand Down Expand Up @@ -78,13 +78,13 @@ function resolveLastRecognizedIdentityInner(
attributes: true,
attributeFilter: ['src'],
},
cancel,
signal,
)
}

assign()

window.addEventListener('locationchange', assign, { signal: cancel })
window.addEventListener('locationchange', assign, { signal })
createWatcher(searchSelfHandleSelector())
createWatcher(searchWatcherAvatarSelector())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,15 @@ export function injectBannerAtTwitter(signal: AbortSignal) {
const emptyNode = document.createElement('div')
injectBanner(postEditorInTimelineSelector(), {
signal,
missingReportRule: { name: 'Setup prompt', rule: 'https://twitter.com/home' },
})
injectBanner(
postEditorInPopupSelector().map((x) => (isCompose() && hasEditor() ? x : emptyNode)),
{ signal, missingReportRule: { name: 'Setup prompt', rule: 'https://twitter.com/compose/post' } },
{ signal },
)
}

function injectBanner<T>(ls: LiveSelector<T, true>, options: WatchOptions) {
const watcher = new MutationObserverWatcher(ls)
startWatch(watcher, options)

attachReactTreeWithContainer(watcher.firstDOMProxy.afterShadow, { signal: options.signal }).render(<Banner />)
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ import { Flags } from '@masknet/flags'
import Services from '#services'
import { startWatch, type WatchOptions } from '../../../utils/startWatch.js'
import { attachReactTreeWithContainer } from '../../../utils/shadow-root/renderInShadowRoot.js'
import {
bioPageUserIDSelector,
bioPageUserNickNameSelector,
floatingBioCardSelector,
isProfilePageLike,
} from '../utils/selector.js'
import { bioPageUserIDSelector, bioPageUserNickNameSelector, floatingBioCardSelector } from '../utils/selector.js'

function Icon(props: { size: number }) {
return (
Expand Down Expand Up @@ -54,7 +49,7 @@ function _(main: () => LiveSelector<HTMLElement, true>, size: number, options: W

export function injectMaskUserBadgeAtTwitter(signal: AbortSignal) {
// profile
_(bioPageUserNickNameSelector, 24, { signal, missingReportRule: { name: 'User badge', rule: isProfilePageLike } })
_(bioPageUserNickNameSelector, 24, { signal })
// floating bio
_(floatingBioCardSelector, 20, { signal })
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ function renderPostDialogTo<T>(reason: 'timeline' | 'popup', ls: LiveSelector<T,
export function injectPostDialogAtTwitter(signal: AbortSignal) {
renderPostDialogTo('popup', postEditorContentInPopupSelector(), {
signal,
missingReportRule: { name: 'PostDialog popup', rule: 'https://twitter.com/compose/post' },
})
renderPostDialogTo('timeline', rootSelector(), {
signal,
missingReportRule: { name: 'PostDialog timeline', rule: 'https://twitter.com/home' },
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,13 @@ export function injectPostDialogHintAtTwitter(signal: AbortSignal) {

renderPostDialogHintTo('timeline', searchReplyToolbarSelector(), {
signal,
missingReportRule: { name: 'PostDialog hint timeline', rule: 'https://twitter.com/home' },
})

renderPostDialogHintTo(
'popup',
postEditorInPopupSelector().map((x) => (isCompose() && hasEditor() ? x : emptyNode)),
{
signal,
missingReportRule: {
name: 'PostDialog hint popup',
rule: 'https://twitter.com/compose/post',
},
},
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MutationObserverWatcher } from '@dimensiondev/holoflows-kit'
import { isProfilePageLike, searchProfileCoverSelector } from '../utils/selector.js'
import { searchProfileCoverSelector } from '../utils/selector.js'
import { attachReactTreeWithContainer } from '../../../utils/shadow-root/renderInShadowRoot.js'
import { startWatch } from '../../../utils/startWatch.js'
import { ProfileCover } from '../../../components/InjectedComponents/ProfileCover.js'
Expand All @@ -8,10 +8,6 @@ export function injectProfileCover(signal: AbortSignal) {
const watcher = new MutationObserverWatcher(searchProfileCoverSelector())
startWatch(watcher, {
signal,
missingReportRule: {
name: 'profile page cover',
rule: isProfilePageLike,
},
})
attachReactTreeWithContainer(watcher.firstDOMProxy.afterShadow, { signal }).render(<ProfileCoverAtTwitter />)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
searchProfileTabSelector,
searchProfileTabLoseConnectionPageSelector,
searchNameTag,
isProfilePageLike,
nextTabListSelector,
} from '../utils/selector.js'
import { useCurrentVisitingIdentity } from '../../../components/DataSource/useActivatedUI.js'
Expand Down Expand Up @@ -283,10 +282,6 @@ export function injectProfileTabAtTwitter(signal: AbortSignal) {
const watcher = new MutationObserverWatcher(searchProfileTabListLastChildSelector())
startWatch(watcher, {
signal,
missingReportRule: {
name: 'Last tab in the profile page',
rule: isProfilePageLike,
},
shadowRootDelegatesFocus: false,
})
attachReactTreeWithContainer(watcher.firstDOMProxy.afterShadow, { signal }).render(<InjectProfileTab />)
Expand All @@ -296,7 +291,6 @@ export function injectProfileTabAtTwitter(signal: AbortSignal) {

startWatch(contentWatcher, {
signal,
missingReportRule: { name: 'ProfileTab', rule: isProfilePageLike },
shadowRootDelegatesFocus: false,
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ export function injectSearchResultInspectorAtTwitter(signal: AbortSignal) {
const watcher = new MutationObserverWatcher(searchResultHeadingSelector())
startWatch(watcher, {
signal,
missingReportRule: {
name: 'SearchResultInspector',
rule: 'https://twitter.com/search?q=',
},
})
attachReactTreeWithContainer(watcher.firstDOMProxy.beforeShadow, { signal }).render(<SearchResultInspector />)
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@ export function injectToolboxHintAtTwitter(signal: AbortSignal, category: 'walle

startWatch(watcher, {
signal,
missingReportRule: {
name: 'Sidebar toolbox',
rule() {
// return false where the page should not match. maybe on mobile size?
return true
},
},
})
attachReactTreeWithContainer(watcher.firstDOMProxy.afterShadow, { signal }).render(
<RootWeb3ContextProvider>
Expand Down
4 changes: 0 additions & 4 deletions packages/mask/shared-ui/initialization/react-query.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { queryClient } from '@masknet/shared-base-ui'
import { broadcastQueryClient } from '../utils/broadcastQueryClient.js'
import { setInitData } from '../utils/persistOptions.js'

broadcastQueryClient({ queryClient })

browser.storage.local.get('react-query').then(({ 'react-query': data }) => {
setInitData('react-query', data)
})
4 changes: 4 additions & 0 deletions packages/mask/shared-ui/utils/broadcastQueryClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ interface BroadcastQueryClientOptions {
queryClient: QueryClient
}

/**
* @deprecated
* Broadcasting cache changes might decrease performance, freezes web page sometimes
*/
export function broadcastQueryClient({ queryClient }: BroadcastQueryClientOptions) {
let transaction = false
const tx = (cb: () => void) => {
Expand Down
5 changes: 2 additions & 3 deletions packages/plugins/Avatar/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,12 @@ export async function getNFTAvatarByUserId(
): Promise<NextIDAvatarMeta | undefined> {
const platform = getSiteType() === EnhanceableSite.Twitter ? NextIDPlatform.Twitter : undefined
if (!platform) return

const bindings = await NextIDProof.queryAllExistedBindingsByPlatform(platform, userId)

if (persona) {
const binding = bindings.filter((x) => x.persona.toLowerCase() === persona.toLowerCase())?.[0]
if (binding) {
return getAvatarFromNextIDStorage(binding.persona, platform, userId, avatarId)
}
if (binding) return getAvatarFromNextIDStorage(binding.persona, platform, userId, avatarId)
}
for (const binding of bindings.sort((a, b) => sortPersonaBindings(a, b, userId))) {
const avatar = await getAvatarFromNextIDStorage(binding.persona, platform, userId, avatarId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const useStyles = makeStyles()((theme) => {
width: '100%',
padding: 0,
},
scrollbarWidth: 'none',
'&::-webkit-scrollbar': {
display: 'none',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const useStyles = makeStyles()((theme) => {
[smallQuery]: {
padding: 0,
},
scrollbarWidth: 'none',
'&::-webkit-scrollbar': {
display: 'none',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
type RedPacketJSONPayloadFromChain,
} from '@masknet/web3-providers/types'
import { formatBalance, minus, type FungibleToken } from '@masknet/web3-shared-base'
import { type ChainId, type SchemaType } from '@masknet/web3-shared-evm'
import { ChainId, type SchemaType, NETWORK_DESCRIPTORS } from '@masknet/web3-shared-evm'
import { Box, ListItem, Typography, useMediaQuery, type Theme } from '@mui/material'
import { intervalToDuration, nextDay } from 'date-fns'
import { memo, useCallback, useMemo } from 'react'
Expand All @@ -19,6 +19,7 @@ import { useCreateRedPacketReceipt } from './hooks/useCreateRedPacketReceipt.js'
import { useRefundCallback } from './hooks/useRefundCallback.js'
import { dateTimeFormat } from './utils/formatDate.js'

const DEFAULT_BACKGROUND = NETWORK_DESCRIPTORS.find((x) => x.chainId === ChainId.Mainnet)!.backgroundGradient!
const useStyles = makeStyles<{ listItemBackground?: string; listItemBackgroundIcon?: string }>()((
theme,
{ listItemBackground, listItemBackgroundIcon },
Expand Down Expand Up @@ -49,7 +50,7 @@ const useStyles = makeStyles<{ listItemBackground?: string; listItemBackgroundIc
position: 'static !important' as any,
height: 'auto !important',
padding: theme.spacing(1.5),
background: listItemBackground ?? theme.palette.background.default,
background: listItemBackground || DEFAULT_BACKGROUND,
[smallQuery]: {
padding: theme.spacing(2, 1.5),
},
Expand Down Expand Up @@ -179,6 +180,7 @@ interface RedPacketInHistoryListProps {
history: RedPacketJSONPayload | RedPacketJSONPayloadFromChain
onSelect: (payload: RedPacketJSONPayload) => void
}

export const RedPacketInHistoryList = memo(function RedPacketInHistoryList(props: RedPacketInHistoryListProps) {
const { history, onSelect } = props
const t = useRedPacketTrans()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,15 @@ function useCreateParamsCallback(
const seed = Math.random().toString()
const tokenType = token!.schema === SchemaType.Native ? 0 : 1
const tokenAddress = token!.schema === SchemaType.Native ? NATIVE_TOKEN_ADDRESS : token!.address
if (!tokenAddress) return null
if (!tokenAddress) {
if (process.env.NODE_ENV === 'development' && !NATIVE_TOKEN_ADDRESS) {
console.error(
'Not native token address for chain %s. Do you forget to configure it in token.json file?',
token!.chainId,
)
}
return null
}

const paramsObj: ParamsObjType = {
publicKey,
Expand Down
1 change: 1 addition & 0 deletions packages/plugins/RedPacket/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const base: Plugin.Shared.Definition = {
ChainId.Conflux,
ChainId.Astar,
ChainId.Scroll,
ChainId.Metis,
ChainId.X1_Testnet,
],
},
Expand Down