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.4 => 2.24.5 (patch) #11401

Merged
merged 4 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.4",
"version": "2.24.5",
"private": true,
"license": "AGPL-3.0-or-later",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Services from '#services'
import { encodeByNetwork } from '@masknet/encryption'
import { PluginID, PostIdentifier, Sniffings, SOCIAL_MEDIA_NAME } from '@masknet/shared-base'
import { PluginID, Sniffings, SOCIAL_MEDIA_NAME } from '@masknet/shared-base'
import type { Meta } from '@masknet/typed-message'
import { Telemetry } from '@masknet/web3-telemetry'
import { EventID, EventType } from '@masknet/web3-telemetry/types'
Expand Down Expand Up @@ -51,42 +51,19 @@ export function useSubmit(onClose: () => void, reason: 'timeline' | 'popup' | 'r
await SteganographyPayload(typeof rawEncrypted === 'string' ? encrypted : rawEncrypted)
: undefined

if (activatedSiteAdaptorUI?.automation.endpoint?.publishPost && reason === 'timeline') {
const postId = await activatedSiteAdaptorUI.automation.endpoint.publishPost(
mediaObject ? [decoratedText || defaultText, mediaObject] : [decoratedText || defaultText],
{
reason,
},
)
const postIdentifier =
lastRecognizedIdentity.identifier && postId ?
new PostIdentifier(lastRecognizedIdentity.identifier, postId)
: undefined

if (postIdentifier) {
const postUrl = activatedSiteAdaptorUI.utils.getPostURL?.(postIdentifier)
if (postUrl) location.assign(postUrl)
} else if (postId) {
location.reload()
}
if (encode === 'image') {
if (!mediaObject) throw new Error('Failed to create image payload.')
// Don't await this, otherwise the dialog won't disappear
activatedSiteAdaptorUI?.automation.nativeCompositionDialog?.attachImage?.(mediaObject, {
recover: true,
relatedTextPayload: decoratedText || defaultText,
reason,
})
} else {
if (encode === 'image') {
if (!mediaObject) throw new Error('Failed to create image payload.')
// Don't await this, otherwise the dialog won't disappear
activatedSiteAdaptorUI?.automation.nativeCompositionDialog?.attachImage?.(mediaObject, {
recover: true,
relatedTextPayload: decoratedText || defaultText,
reason,
})
} else {
activatedSiteAdaptorUI?.automation.nativeCompositionDialog?.attachText?.(
decoratedText || defaultText,
{
recover: true,
reason,
},
)
}
activatedSiteAdaptorUI?.automation.nativeCompositionDialog?.attachText?.(decoratedText || defaultText, {
recover: true,
reason,
})
}

if (content.meta?.has(`${PluginID.RedPacket}:1`) || content.meta?.has(`${PluginID.RedPacket}_nft:1`))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
* Otherwise, if a pathname not in this list the keyword will be cleaned and remove relative components from DOM.
*/
const SAFE_PATHNAMES_ON_TWITTER = [
// redirect to /compose/post
'/compose/tweet',
'/compose/post',
'/search-advanced',
'/settings/trends',
'/settings/search',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function injectBannerAtTwitter(signal: AbortSignal) {
})
injectBanner(
postEditorInPopupSelector().map((x) => (isCompose() && hasEditor() ? x : emptyNode)),
{ signal, missingReportRule: { name: 'Setup prompt', rule: 'https://twitter.com/compose/tweet' } },
{ signal, missingReportRule: { name: 'Setup prompt', rule: 'https://twitter.com/compose/post' } },
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ 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/tweet' },
missingReportRule: { name: 'PostDialog popup', rule: 'https://twitter.com/compose/post' },
})
renderPostDialogTo('timeline', rootSelector(), {
signal,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function injectPostDialogHintAtTwitter(signal: AbortSignal) {
signal,
missingReportRule: {
name: 'PostDialog hint popup',
rule: 'https://twitter.com/compose/tweet',
rule: 'https://twitter.com/compose/post',
},
},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function getEditorContent() {
}

export function isCompose() {
return globalThis.location.pathname === '/compose/tweet'
return globalThis.location.pathname === '/compose/post'
}

export function hasFocus(x: LiveSelector<HTMLElement, true>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ export function rootSelector() {
export function composeAnchorSelector() {
return querySelector<HTMLAnchorElement>(
[
'header[role=banner] a[href="/compose/tweet"]',
'aside a[href="/compose/tweet"]',
'header[role=banner] a[href="/compose/post"]',
'aside a[href="/compose/post"]',
// can't see the compose button on share popup, use the tweetButton instead
'[role=main] [role=button][data-testid=tweetButton]',
].join(','),
Expand Down Expand Up @@ -123,7 +123,7 @@ export function isReplyPageSelector() {
return !!location.pathname.match(/^\/\w+\/status\/\d+$/)
}
export function postEditorDraftContentSelector() {
if (location.pathname === '/compose/tweet') {
if (location.pathname === '/compose/post') {
return querySelector<HTMLDivElement>(
'[contenteditable][aria-label][spellcheck],textarea[aria-label][spellcheck]',
)
Expand Down
8 changes: 3 additions & 5 deletions packages/mask/popups/components/NetworkSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ import { Box, MenuItem, Typography } from '@mui/material'
import { makeStyles } from '@masknet/theme'
import type { ChainId, NetworkType, SchemaType } from '@masknet/web3-shared-evm'
import { useChainContext, useNetworks, useWeb3State } from '@masknet/web3-hooks-base'
import { ImageIcon, NetworkIcon, useMenuConfig } from '@masknet/shared'
import { ImageIcon, NetworkIcon, TRADER_WEB3_CONFIG, useMenuConfig } from '@masknet/shared'
import { Icons } from '@masknet/icons'
import type { ReasonableNetwork } from '@masknet/web3-shared-base'
import { NetworkPluginID, PluginID } from '@masknet/shared-base'
import { NetworkPluginID } from '@masknet/shared-base'
import { EVMWeb3 } from '@masknet/web3-providers'
import { useActivatedPluginSiteAdaptor } from '@masknet/plugin-infra/content-script'
import { first } from 'lodash-es'

const useStyles = makeStyles()((theme) => ({
Expand Down Expand Up @@ -42,8 +41,7 @@ export const NetworkSelector = memo(() => {
const networks = useNetworks(NetworkPluginID.PLUGIN_EVM)
const { Network } = useWeb3State(NetworkPluginID.PLUGIN_EVM)

const traderDefinition = useActivatedPluginSiteAdaptor.visibility.useAnyMode(PluginID.Trader)
const chainIdList = traderDefinition?.enableRequirement.web3?.[NetworkPluginID.PLUGIN_EVM]?.supportedChainIds ?? []
const chainIdList = TRADER_WEB3_CONFIG[NetworkPluginID.PLUGIN_EVM]?.supportedChainIds ?? []

const actualNetworks = useMemo(
() => networks.filter((x) => chainIdList.includes(x.chainId)),
Expand Down
12 changes: 11 additions & 1 deletion packages/plugin-infra/src/manager/site-adaptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useMemo } from 'react'
import { isEqual } from 'lodash-es'
import { unreachable } from '@masknet/kit'
import { useValueRef } from '@masknet/shared-base-ui'
import { type EnhanceableSite, ValueRefWithReady } from '@masknet/shared-base'
import { type EnhanceableSite, ValueRefWithReady, Sniffings } from '@masknet/shared-base'
import { createManager } from './manage.js'
import { getPluginDefine } from './store.js'
import type { Plugin } from '../types.js'
Expand All @@ -17,6 +17,16 @@ events.on('activateChanged', () => (activatedSub.value = [...activated.plugins])
const minimalModeSub = new ValueRefWithReady<string[]>([], isEqual)
events.on('minimalModeChanged', () => (minimalModeSub.value = [...minimalMode]))

/**
* On the popup page, the plugin is not loaded.
* So in order for the valueRef not to remain pending,
* manually assigning the value solves this problem
*/
if (Sniffings.is_popup_page) {
activatedSub.value = []
minimalModeSub.value = []
}

export function useActivatedPluginsSiteAdaptor(minimalModeEqualsTo: 'any' | boolean) {
const minimalMode = useValueRef(minimalModeSub)
const result = useValueRef(activatedSub)
Expand Down
7 changes: 4 additions & 3 deletions packages/web3-providers/src/RedPacket/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import urlcat from 'urlcat'
import { mapKeys } from 'lodash-es'
import { mapKeys, sortBy } from 'lodash-es'
import type { AbiItem } from 'web3-utils'
import { createIndicator, createPageable, type PageIndicator, type Pageable } from '@masknet/shared-base'
import { type Transaction, attemptUntil, type NonFungibleCollection } from '@masknet/web3-shared-base'
Expand Down Expand Up @@ -46,16 +46,17 @@ class RedPacketAPI implements RedPacketBaseAPI.Provider<ChainId, SchemaType> {
)
return this.parseRedPacketCreationTransactions(transactions, senderAddress)
},
() => {
async () => {
// block range might be too large
return ContractRedPacket.getHistories(
const results = await ContractRedPacket.getHistories(
chainId,
senderAddress,
contractAddress,
methodId,
fromBlock,
endBlock,
)
return sortBy(results, (x) => -x.block_number!)
},
],
[],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function getComputedUserSettings(): TwitterBaseAPI.UserSettings {
}

const getThemeColor = () => {
const tweetButton = document.querySelector('a[href="/compose/tweet"][data-testid="SideNav_NewTweet_Button"]')
const tweetButton = document.querySelector('a[href="/compose/post"][data-testid="SideNav_NewTweet_Button"]')
if (!tweetButton) return

const { backgroundColor } = getComputedStyle(tweetButton)
Expand Down