From bf5110af721d7da5c221abb81156c08e914377c3 Mon Sep 17 00:00:00 2001 From: guanbinrui Date: Tue, 17 May 2022 20:46:58 +0800 Subject: [PATCH 01/54] chore: bump version to 2.8.0 --- package.json | 2 +- packages/mask/src/manifest.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f3673747e6e7..671aa07fea2e 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "yarn": ">=999.0.0", "npm": ">=999.0.0" }, - "version": "2.7.0", + "version": "2.8.0", "private": true, "license": "AGPL-3.0-or-later", "scripts": { diff --git a/packages/mask/src/manifest.json b/packages/mask/src/manifest.json index 20ea95ae94eb..9f1dfefa71f5 100644 --- a/packages/mask/src/manifest.json +++ b/packages/mask/src/manifest.json @@ -1,6 +1,6 @@ { "name": "Mask Network", - "version": "2.7.0", + "version": "2.8.0", "manifest_version": 2, "permissions": ["storage", "downloads", "webNavigation", "activeTab"], "optional_permissions": ["", "notifications", "clipboardRead"], From 8035aac65f46cf7069c9f802b35676dc181095bd Mon Sep 17 00:00:00 2001 From: Jack Works Date: Wed, 18 May 2022 15:06:06 +0800 Subject: [PATCH 02/54] fix: persona sign length (#6277) --- packages/mask/background/services/identity/persona/sign.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/mask/background/services/identity/persona/sign.ts b/packages/mask/background/services/identity/persona/sign.ts index c9df9f86e9c2..0874941e056b 100644 --- a/packages/mask/background/services/identity/persona/sign.ts +++ b/packages/mask/background/services/identity/persona/sign.ts @@ -12,7 +12,7 @@ import { MaskMessages } from '../../../../shared' import { PersonaIdentifier, fromBase64URL, PopupRoutes, ECKeyIdentifier } from '@masknet/shared-base' import { queryPersonasWithPrivateKey } from '../../../../background/database/persona/db' import { openPopupWindow } from '../../../../background/services/helper' -import { delay } from '@dimensiondev/kit' +import { delay, encodeText } from '@dimensiondev/kit' export interface SignRequest { /** Use that who to sign this message. */ identifier?: PersonaIdentifier @@ -56,8 +56,7 @@ export async function generateSignResult(signer: ECKeyIdentifier, message: strin const persona = (await queryPersonasWithPrivateKey()).find((x) => x.identifier === signer) if (!persona) throw new Error('Persona not found') - // will have problem with UTF-8? - const length = message.length + const length = encodeText(message).length const messageHash = keccakFromString(`\x19Ethereum Signed Message:\n${length}${message}`, 256) const privateKey = Buffer.from(fromBase64URL(persona.privateKey.d!)) const signature = ecsign(messageHash, privateKey) From aed19b541aae9d69cb67a2df20df41668fefcde9 Mon Sep 17 00:00:00 2001 From: Jack Works Date: Wed, 18 May 2022 15:06:15 +0800 Subject: [PATCH 03/54] fix: serializer bug (#6278) --- packages/shared-base/src/serializer/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/shared-base/src/serializer/index.ts b/packages/shared-base/src/serializer/index.ts index ce0800de0d53..291c57d4c345 100644 --- a/packages/shared-base/src/serializer/index.ts +++ b/packages/shared-base/src/serializer/index.ts @@ -12,7 +12,8 @@ const pendingRegister = new Set<() => void>() let typeson: Typeson | undefined function setup() { const { default: BigNumber } = BN - typeson = new Typeson({}) + // https://github.com/dfahlander/typeson-registry/issues/27 + typeson = new Typeson({ cyclic: false }) typeson.register(builtin) typeson.register(specialNumbers) typeson.register([blob, file, filelist, imagebitmap]) From 4f98f53331b1c2b42d4829ca67765feb6869342f Mon Sep 17 00:00:00 2001 From: Hancheng Zhou Date: Wed, 18 May 2022 15:06:27 +0800 Subject: [PATCH 04/54] fix: twitter id selector (#6279) * fix: twitter id selector * fix: next id status * fix: no need use state --- packages/mask/src/components/DataSource/useNextID.ts | 5 ++--- .../twitter.com/collecting/identity.ts | 9 ++++++--- .../social-network-adaptor/twitter.com/utils/selector.ts | 2 +- packages/web3-providers/src/NextID/proof.ts | 6 +++--- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/packages/mask/src/components/DataSource/useNextID.ts b/packages/mask/src/components/DataSource/useNextID.ts index 7988024e2b59..c68873a46e22 100644 --- a/packages/mask/src/components/DataSource/useNextID.ts +++ b/packages/mask/src/components/DataSource/useNextID.ts @@ -65,8 +65,7 @@ export function useNextIDConnectStatus() { const personaConnectStatus = usePersonaConnectStatus() const lastState = useSetupGuideStatusState() const lastRecognized = useLastRecognizedIdentity() - const [username] = useState(lastState.username || lastRecognized.identifier?.userId || '') - + const username = lastRecognized.identifier?.userId || lastState.username || '' const { value: VerificationStatus = NextIDVerificationStatus.Other, retry, @@ -117,7 +116,7 @@ export function useNextIDConnectStatus() { isOpenedVerifyDialog = true isOpenedFromButton = false return NextIDVerificationStatus.WaitingVerify - }, [username, enableNextID, isOpenedVerifyDialog, currentPersonaIdentifier.value]) + }, [username, enableNextID, isOpenedVerifyDialog, personaConnectStatus, currentPersonaIdentifier.value]) return { isVerified: VerificationStatus === NextIDVerificationStatus.Verified, diff --git a/packages/mask/src/social-network-adaptor/twitter.com/collecting/identity.ts b/packages/mask/src/social-network-adaptor/twitter.com/collecting/identity.ts index 3eca2d3fb5c0..d04e71b26bc5 100644 --- a/packages/mask/src/social-network-adaptor/twitter.com/collecting/identity.ts +++ b/packages/mask/src/social-network-adaptor/twitter.com/collecting/identity.ts @@ -51,9 +51,12 @@ function resolveLastRecognizedIdentityInner( ) { const assign = async () => { await delay(5000) - const avatar = searchSelfAvatarSelector().evaluate()?.getAttribute('src') ?? '' - const handle = searchSelfHandleSelector().evaluate()?.textContent?.trim()?.replace(/^@/, '') - const nickname = searchSelfNicknameSelector().evaluate()?.textContent?.trim() ?? '' + const { collect } = recognizeDesktop() + const dataFromScript = collect() + const avatar = (searchSelfAvatarSelector().evaluate()?.getAttribute('src') || dataFromScript.avatar) ?? '' + const handle = + searchSelfHandleSelector().evaluate()?.textContent?.trim()?.replace(/^@/, '') || dataFromScript.handle + const nickname = (searchSelfNicknameSelector().evaluate()?.textContent?.trim() || dataFromScript.nickname) ?? '' if (handle) { ref.value = { diff --git a/packages/mask/src/social-network-adaptor/twitter.com/utils/selector.ts b/packages/mask/src/social-network-adaptor/twitter.com/utils/selector.ts index 197b49efeb03..34847bbda5b6 100644 --- a/packages/mask/src/social-network-adaptor/twitter.com/utils/selector.ts +++ b/packages/mask/src/social-network-adaptor/twitter.com/utils/selector.ts @@ -217,7 +217,7 @@ export const postsContentSelector = () => export const postAvatarsContentSelector = () => querySelectorAll('[data-testid="tweet"] > div > div > div > :nth-child(2)') -const base = querySelector('#react-root + script') +const base = querySelector('#react-root ~ script') const handle = /"screen_name":"(.*?)"/ const name = /"name":"(.*?)"/ const bio = /"description":"(.*?)"/ diff --git a/packages/web3-providers/src/NextID/proof.ts b/packages/web3-providers/src/NextID/proof.ts index 7e3e156d09ef..af86f21422b3 100644 --- a/packages/web3-providers/src/NextID/proof.ts +++ b/packages/web3-providers/src/NextID/proof.ts @@ -38,7 +38,7 @@ const getPersonaQueryURL = (platform: string, identity: string) => identity, }) -const geyExistedBindingQueryURL = (platform: string, identity: string, personaPublicKey: string) => +const getExistedBindingQueryURL = (platform: string, identity: string, personaPublicKey: string) => urlcat(BASE_URL, '/v1/proof/exists', { platform, identity, @@ -81,7 +81,7 @@ export class NextIDProofAPI implements NextIDBaseAPI.Proof { // Should delete cache when proof status changed const cacheKeyOfQueryPersona = getPersonaQueryURL(NextIDPlatform.NextID, personaPublicKey) - const cacheKeyOfExistedBinding = geyExistedBindingQueryURL(platform, identity, personaPublicKey) + const cacheKeyOfExistedBinding = getExistedBindingQueryURL(platform, identity, personaPublicKey) deleteCache(cacheKeyOfQueryPersona) deleteCache(cacheKeyOfExistedBinding) @@ -107,7 +107,7 @@ export class NextIDProofAPI implements NextIDBaseAPI.Proof { async queryIsBound(personaPublicKey: string, platform: NextIDPlatform, identity: string, enableCache?: boolean) { if (!platform && !identity) return false - const url = geyExistedBindingQueryURL(platform, identity, personaPublicKey) + const url = getExistedBindingQueryURL(platform, identity, personaPublicKey) const result = await fetchJSON(url, {}, enableCache) return result.map(() => true).unwrapOr(false) From 195ed03b09c62043927fc9289b1f03b60ab46c30 Mon Sep 17 00:00:00 2001 From: Jack Works Date: Wed, 18 May 2022 15:12:14 +0800 Subject: [PATCH 05/54] fix: wrong call order of localeCompare (#6286) --- .../mask/src/plugins/ITO/SNSAdaptor/ExchangeTokenPanel.tsx | 4 ++-- packages/mask/src/plugins/ITO/SNSAdaptor/SwapDialog.tsx | 2 +- packages/shared/src/UI/components/ERC20TokenList/index.tsx | 2 +- .../evm/hooks/useERC20TokensDetailedFromTokenLists.ts | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/mask/src/plugins/ITO/SNSAdaptor/ExchangeTokenPanel.tsx b/packages/mask/src/plugins/ITO/SNSAdaptor/ExchangeTokenPanel.tsx index f2755ef39927..130a27b8411c 100644 --- a/packages/mask/src/plugins/ITO/SNSAdaptor/ExchangeTokenPanel.tsx +++ b/packages/mask/src/plugins/ITO/SNSAdaptor/ExchangeTokenPanel.tsx @@ -91,8 +91,8 @@ export function ExchangeTokenPanel(props: ExchangeTokenPanelProps) { isSell, dataIndex, exchangeToken?.address, - excludeTokensAddress.sort((a, b) => a.localeCompare('en-US', b)).join(), - selectedTokensAddress.sort((a, b) => a.localeCompare('en-US', b)).join(), + excludeTokensAddress.sort((a, b) => a.localeCompare(b, 'en-US')).join(), + selectedTokensAddress.sort((a, b) => a.localeCompare(b, 'en-US')).join(), ]) // #endregion diff --git a/packages/mask/src/plugins/ITO/SNSAdaptor/SwapDialog.tsx b/packages/mask/src/plugins/ITO/SNSAdaptor/SwapDialog.tsx index e9ce38bd599b..279a7d27f868 100644 --- a/packages/mask/src/plugins/ITO/SNSAdaptor/SwapDialog.tsx +++ b/packages/mask/src/plugins/ITO/SNSAdaptor/SwapDialog.tsx @@ -159,7 +159,7 @@ export function SwapDialog(props: SwapDialogProps) { pickToken, exchangeTokens .map((x) => x.address) - .sort((a, b) => a.localeCompare('en-US', b)) + .sort((a, b) => a.localeCompare(b, 'en-US')) .join(), ]) // #endregion diff --git a/packages/shared/src/UI/components/ERC20TokenList/index.tsx b/packages/shared/src/UI/components/ERC20TokenList/index.tsx index 6d216633cbc4..1e68efe335c7 100644 --- a/packages/shared/src/UI/components/ERC20TokenList/index.tsx +++ b/packages/shared/src/UI/components/ERC20TokenList/index.tsx @@ -115,7 +115,7 @@ export const ERC20TokenList = memo((props) => { assetsLoading, assets .map((x) => x.token.address) - .sort((a, b) => a.localeCompare('en-US', b)) + .sort((a, b) => a.localeCompare(b, 'en-US')) .join(), ]) diff --git a/packages/web3-shared/evm/hooks/useERC20TokensDetailedFromTokenLists.ts b/packages/web3-shared/evm/hooks/useERC20TokensDetailedFromTokenLists.ts index 93e933e1c887..81a63449bb6c 100644 --- a/packages/web3-shared/evm/hooks/useERC20TokensDetailedFromTokenLists.ts +++ b/packages/web3-shared/evm/hooks/useERC20TokensDetailedFromTokenLists.ts @@ -21,7 +21,7 @@ export function useERC20TokensDetailedFromTokenLists( const { fetchERC20TokensFromTokenLists } = useWeb3Context() const { value: tokensFromList = EMPTY_LIST, ...asyncResult } = useAsyncRetry( async () => (!lists || lists.length === 0 ? [] : fetchERC20TokensFromTokenLists(lists, chainId)), - [chainId, lists?.sort((a, b) => a.localeCompare('en-US', b)).join()], + [chainId, lists?.sort((a, b) => a.localeCompare(b, 'en-US')).join()], ) // #endregion // #region fuse From ed6ab9c27b5e1c04c94050406ae3bf258b612f4f Mon Sep 17 00:00:00 2001 From: lelenei <72531217+lelenei@users.noreply.github.com> Date: Wed, 18 May 2022 19:54:03 +0800 Subject: [PATCH 06/54] fix: css style (#6292) * fix: padding * fix: watcher Co-authored-by: Jack Works --- .../Collectible/SNSAdaptor/MakeOfferDialog.tsx | 3 ++- .../Collectible/SNSAdaptor/PostListingDialog.tsx | 1 + .../plugins/PoolTogether/UI/PoolTogetherView.tsx | 10 ++++++---- .../twitter.com/collecting/identity.ts | 14 ++++---------- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/packages/mask/src/plugins/Collectible/SNSAdaptor/MakeOfferDialog.tsx b/packages/mask/src/plugins/Collectible/SNSAdaptor/MakeOfferDialog.tsx index c87ac106b624..3fa81e9a5a0e 100644 --- a/packages/mask/src/plugins/Collectible/SNSAdaptor/MakeOfferDialog.tsx +++ b/packages/mask/src/plugins/Collectible/SNSAdaptor/MakeOfferDialog.tsx @@ -43,6 +43,7 @@ const useStyles = makeStyles()((theme) => { return { content: { padding: 0, + borderRadius: 0, }, footer: { display: 'flex', @@ -168,7 +169,7 @@ export function MakeOfferDialog(props: MakeOfferDialogProps) { open={open} onClose={onClose}> - + {isVerified ? null : ( diff --git a/packages/mask/src/plugins/Collectible/SNSAdaptor/PostListingDialog.tsx b/packages/mask/src/plugins/Collectible/SNSAdaptor/PostListingDialog.tsx index 524573ebd2ad..d49080160c56 100644 --- a/packages/mask/src/plugins/Collectible/SNSAdaptor/PostListingDialog.tsx +++ b/packages/mask/src/plugins/Collectible/SNSAdaptor/PostListingDialog.tsx @@ -13,6 +13,7 @@ const useStyles = makeStyles()((theme) => { return { content: { padding: 0, + borderRadius: 0, }, footer: { display: 'flex', diff --git a/packages/mask/src/plugins/PoolTogether/UI/PoolTogetherView.tsx b/packages/mask/src/plugins/PoolTogether/UI/PoolTogetherView.tsx index c97b4f92f9f9..beeef1783f14 100644 --- a/packages/mask/src/plugins/PoolTogether/UI/PoolTogetherView.tsx +++ b/packages/mask/src/plugins/PoolTogether/UI/PoolTogetherView.tsx @@ -61,9 +61,7 @@ const useStyles = makeStyles()((theme) => ({ minWidth: 'unset', }, progress: { - bottom: theme.spacing(1), - right: theme.spacing(1), - padding: theme.spacing(1), + padding: 12, }, })) @@ -106,7 +104,11 @@ export function PoolTogetherView(props: PoolTogetherViewProps) { }, [_pools, maskPool]) if (loading || loadingMask) { - return + return ( + + + + ) } if (error || errorMask) { diff --git a/packages/mask/src/social-network-adaptor/twitter.com/collecting/identity.ts b/packages/mask/src/social-network-adaptor/twitter.com/collecting/identity.ts index d04e71b26bc5..97535cbe94aa 100644 --- a/packages/mask/src/social-network-adaptor/twitter.com/collecting/identity.ts +++ b/packages/mask/src/social-network-adaptor/twitter.com/collecting/identity.ts @@ -78,11 +78,8 @@ function resolveLastRecognizedIdentityInner( attributeFilter: ['src'], }) - window.addEventListener('locationchange', assign) - cancel.addEventListener('abort', () => { - window.removeEventListener('locationchange', assign) - watcher.stopWatch() - }) + window.addEventListener('locationchange', assign, { signal: cancel }) + cancel.addEventListener('abort', () => watcher.stopWatch(), { signal: cancel }) } assign() @@ -152,11 +149,8 @@ function resolveCurrentVisitingIdentityInner( attributeFilter: ['src', 'content'], }) - window.addEventListener('locationchange', assign) - cancel.addEventListener('abort', () => { - window.removeEventListener('locationchange', assign) - watcher.stopWatch() - }) + window.addEventListener('locationchange', assign, { signal: cancel }) + cancel.addEventListener('abort', () => watcher.stopWatch(), { signal: cancel }) } assign() From 77c13508a0c03f5d26ec65a035262c6e292b330b Mon Sep 17 00:00:00 2001 From: lelenei <72531217+lelenei@users.noreply.github.com> Date: Wed, 18 May 2022 20:29:31 +0800 Subject: [PATCH 07/54] fix: show switch chainid button (#6295) --- .../mask/src/plugins/Collectible/SNSAdaptor/ActionBar.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/mask/src/plugins/Collectible/SNSAdaptor/ActionBar.tsx b/packages/mask/src/plugins/Collectible/SNSAdaptor/ActionBar.tsx index d17cb3043318..e6ac9aff09ac 100644 --- a/packages/mask/src/plugins/Collectible/SNSAdaptor/ActionBar.tsx +++ b/packages/mask/src/plugins/Collectible/SNSAdaptor/ActionBar.tsx @@ -8,7 +8,7 @@ import { MakeOfferDialog } from './MakeOfferDialog' import { PostListingDialog } from './PostListingDialog' import { CheckoutDialog } from './CheckoutDialog' import { EthereumChainBoundary } from '../../../web3/UI/EthereumChainBoundary' -import { useChainId } from '@masknet/web3-shared-evm' +import { ChainId } from '@masknet/web3-shared-evm' const useStyles = makeStyles()((theme) => { return { @@ -33,7 +33,6 @@ export function ActionBar(props: ActionBarProps) { const { classes } = useStyles() const { asset, assetOrder } = CollectibleState.useContainer() const assets = asset.value - const chainId = useChainId() const { open: openCheckoutDialog, @@ -50,7 +49,7 @@ export function ActionBar(props: ActionBarProps) { if (!asset.value) return null return ( - + {!asset.value.isOwner && asset.value.is_auction && assetOrder.value ? ( Date: Wed, 18 May 2022 20:29:44 +0800 Subject: [PATCH 08/54] fix: css style (#6297) --- packages/mask/src/plugins/MaskPluginWrapper.tsx | 11 +++++------ packages/plugins/FileService/src/locales/en-US.json | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/mask/src/plugins/MaskPluginWrapper.tsx b/packages/mask/src/plugins/MaskPluginWrapper.tsx index 82f6f215d111..6c077e4634b0 100644 --- a/packages/mask/src/plugins/MaskPluginWrapper.tsx +++ b/packages/mask/src/plugins/MaskPluginWrapper.tsx @@ -83,6 +83,10 @@ const useStyles = makeStyles<{ backgroundGradient?: string }>()((theme, props) = }, borderRadius: 9999, }, + providerBy: { + marginRight: theme.spacing(0.5), + color: theme.palette.mode === 'dark' ? '#536471' : theme.palette.text.secondary, + }, } }) @@ -101,12 +105,7 @@ export default function MaskPostExtraInfoWrapper(props: PluginWrapperProps) { ) return ( - + {t('plugin_provider_by')} {main} diff --git a/packages/plugins/FileService/src/locales/en-US.json b/packages/plugins/FileService/src/locales/en-US.json index bc4b3c489cf5..c692f4d4435b 100644 --- a/packages/plugins/FileService/src/locales/en-US.json +++ b/packages/plugins/FileService/src/locales/en-US.json @@ -1,5 +1,5 @@ { - "__display_name": "Plugin: File Service", + "__display_name": "File Service", "__description": "Upload and share files on top of Arweave network. Store data, permanently.", "__composition_entry": "📃 File Service", "on_insert": "Use the file", From 4562da6d0492d9af0fb699d85bfe2dce966849cd Mon Sep 17 00:00:00 2001 From: Randolph314 <97870249+Randolph314@users.noreply.github.com> Date: Wed, 18 May 2022 21:32:54 +0800 Subject: [PATCH 09/54] fix: chain name of okex (#6298) * fix: chain name of okex chain * feat: change comment style * feat: change chain name Co-authored-by: Randolph <840094513@qq.com> --- cspell.json | 1 + packages/web3-shared/evm/assets/chains.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cspell.json b/cspell.json index b26de3d954c0..aad883a441e1 100644 --- a/cspell.json +++ b/cspell.json @@ -275,6 +275,7 @@ "nrge", "nrgt", "nyfi", + "okex", "openocean", "pausable", "pkts", diff --git a/packages/web3-shared/evm/assets/chains.json b/packages/web3-shared/evm/assets/chains.json index e870a59de6fc..4c8a00736ca8 100644 --- a/packages/web3-shared/evm/assets/chains.json +++ b/packages/web3-shared/evm/assets/chains.json @@ -814,7 +814,7 @@ }, { "name": "OKExChain Mainnet", - "chain": "okexchain", + "chain": "OKEx", "network": "mainnet", "features": [], "nativeCurrency": { From 946ad0306b8f0cf99aadcf0d21d5df91f7bf7c38 Mon Sep 17 00:00:00 2001 From: BillyS Date: Wed, 18 May 2022 18:45:49 +0800 Subject: [PATCH 10/54] fix: support publicHex & rawPublickey in compose share search (#6273) * fix: support publicHex & rawPublickey * fix: fix * fix: close pop when to share --- .../CompositionDialog/EncryptionTargetSelector.tsx | 5 ++++- .../shared/SelectRecipients/ProfileInList.tsx | 8 ++++---- .../shared/SelectRecipients/SelectRecipients.tsx | 14 ++++++++++---- .../SelectRecipients/SelectRecipientsDialog.tsx | 8 +++++++- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/packages/mask/src/components/CompositionDialog/EncryptionTargetSelector.tsx b/packages/mask/src/components/CompositionDialog/EncryptionTargetSelector.tsx index 761a2bd490a4..50fba1981300 100644 --- a/packages/mask/src/components/CompositionDialog/EncryptionTargetSelector.tsx +++ b/packages/mask/src/components/CompositionDialog/EncryptionTargetSelector.tsx @@ -147,7 +147,10 @@ export function EncryptionTargetSelector(props: EncryptionTargetSelectorProps) { {e2eDisabledMessage} {noLocalKeyMessage} props.onChange(EncryptionTargetType.E2E)} + onItemClick={() => { + props.onChange(EncryptionTargetType.E2E) + setAnchorEl(null) + }} itemTail={} disabled={!!props.e2eDisabled} value={EncryptionTargetType.E2E} diff --git a/packages/mask/src/components/shared/SelectRecipients/ProfileInList.tsx b/packages/mask/src/components/shared/SelectRecipients/ProfileInList.tsx index 8be4ab514fc4..1b57fde505a1 100644 --- a/packages/mask/src/components/shared/SelectRecipients/ProfileInList.tsx +++ b/packages/mask/src/components/shared/SelectRecipients/ProfileInList.tsx @@ -112,7 +112,7 @@ export function ProfileInList(props: ProfileInListProps) { (ev: React.MouseEvent) => props.onChange(ev, !props.selected), [props], ) - const textToHighlight = formatPersonaPublicKey(profile.linkedPersona?.publicKeyAsHex?.toUpperCase() ?? '', 4) + const textToHighlight = formatPersonaPublicKey(profile.linkedPersona?.rawPublicKey?.toUpperCase() ?? '', 4) return ( { - const publicHexKey = profile.linkedPersona?.publicKeyAsHex - if (!publicHexKey) return - copyToClipboard(publicHexKey.toUpperCase()) + const rawPublicKey = profile.linkedPersona?.rawPublicKey + if (!rawPublicKey) return + copyToClipboard(rawPublicKey.toUpperCase()) }} /> {profile.fromNextID &&
Next.ID
} diff --git a/packages/mask/src/components/shared/SelectRecipients/SelectRecipients.tsx b/packages/mask/src/components/shared/SelectRecipients/SelectRecipients.tsx index 1109596e0435..142868c4d93b 100644 --- a/packages/mask/src/components/shared/SelectRecipients/SelectRecipients.tsx +++ b/packages/mask/src/components/shared/SelectRecipients/SelectRecipients.tsx @@ -1,5 +1,5 @@ import { useEffect, useState } from 'react' -import { ProfileInformation as Profile, EMPTY_LIST, NextIDPlatform } from '@masknet/shared-base' +import { ProfileInformation as Profile, EMPTY_LIST, NextIDPlatform, ECKeyIdentifier } from '@masknet/shared-base' import type { LazyRecipients } from '../../CompositionDialog/CompositionUI' import { SelectRecipientsDialogUI } from './SelectRecipientsDialog' import { useCurrentIdentity } from '../../DataSource/useActivatedUI' @@ -23,7 +23,12 @@ const resolveNextIDPlatform = (value: string) => { if (isValidAddress(value)) return NextIDPlatform.Ethereum if (value.length >= 44) return NextIDPlatform.NextID if (/^\w{1,15}$/.test(value)) return NextIDPlatform.Twitter - return undefined + return +} + +const resolveValueToSearch = (value: string) => { + if (value.length === 44) return new ECKeyIdentifier('secp256k1', value).publicKeyAsHex ?? value + return value.toLowerCase() } export function SelectRecipientsUI(props: SelectRecipientsUIProps) { @@ -32,11 +37,12 @@ export function SelectRecipientsUI(props: SelectRecipientsUIProps) { const [valueToSearch, setValueToSearch] = useState('') const currentIdentity = useCurrentIdentity() const type = resolveNextIDPlatform(valueToSearch) + const value = resolveValueToSearch(valueToSearch) const { loading: searchLoading, value: NextIDResults } = useNextIDBoundByPlatform( type ?? NextIDPlatform.NextID, - valueToSearch.toLowerCase(), + value, ) - const NextIDItems = useTwitterIdByWalletSearch(NextIDResults, valueToSearch, type) + const NextIDItems = useTwitterIdByWalletSearch(NextIDResults, value, type) const profileItems = items.recipients?.filter((x) => x.identifier !== currentIdentity?.identifier) const searchedList = uniqBy( profileItems?.concat(NextIDItems) ?? [], diff --git a/packages/mask/src/components/shared/SelectRecipients/SelectRecipientsDialog.tsx b/packages/mask/src/components/shared/SelectRecipients/SelectRecipientsDialog.tsx index 2b18c7fa2ffd..291f14d9658d 100644 --- a/packages/mask/src/components/shared/SelectRecipients/SelectRecipientsDialog.tsx +++ b/packages/mask/src/components/shared/SelectRecipients/SelectRecipientsDialog.tsx @@ -100,7 +100,13 @@ export function SelectRecipientsDialogUI(props: SelectRecipientsDialogUIProps) { }, [props.open]) const itemsAfterSearch = useMemo(() => { const fuse = new Fuse(items, { - keys: ['identifier.userId', 'nickname', 'walletAddress', 'linkedPersona.publicKeyAsHex'], + keys: [ + 'identifier.userId', + 'nickname', + 'walletAddress', + 'linkedPersona.rawPublicKey', + 'linkedPersona.publicKeyAsHex', + ], isCaseSensitive: false, ignoreLocation: true, threshold: 0, From ad9306125c949b015369290bdab3bfbe5a6d4370 Mon Sep 17 00:00:00 2001 From: billy Date: Wed, 18 May 2022 23:12:30 +0800 Subject: [PATCH 11/54] fix: 752 --- packages/mask/shared-ui/locales/en-US.json | 1 + .../CompositionDialog/EncryptionTargetSelector.tsx | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/mask/shared-ui/locales/en-US.json b/packages/mask/shared-ui/locales/en-US.json index 5471db0b8fa6..0647587c06f7 100644 --- a/packages/mask/shared-ui/locales/en-US.json +++ b/packages/mask/shared-ui/locales/en-US.json @@ -65,6 +65,7 @@ "compose_encrypt_visible_to_private": "Private", "compose_encrypt_visible_to_private_sub": "Just Me", "compose_shared_friends": "1 friend", + "compose_shared_friends_other": "{{count}} friends", "compose_encrypt_visible_to_share": "Share with", "compose_encrypt_visible_to_share_sub": "Just Selected Contacts", "compose_encrypt_share_dialog_empty": "No encrypted friends, you can try searching.", diff --git a/packages/mask/src/components/CompositionDialog/EncryptionTargetSelector.tsx b/packages/mask/src/components/CompositionDialog/EncryptionTargetSelector.tsx index 50fba1981300..2d3cc54451dc 100644 --- a/packages/mask/src/components/CompositionDialog/EncryptionTargetSelector.tsx +++ b/packages/mask/src/components/CompositionDialog/EncryptionTargetSelector.tsx @@ -114,7 +114,10 @@ export function EncryptionTargetSelector(props: EncryptionTargetSelectorProps) { const selectedTitle = () => { const selected = props.target const shareWithNum = props.selectedRecipientLength - if (selected === EncryptionTargetType.E2E) return t('compose_shared_friends', { count: shareWithNum }) + if (selected === EncryptionTargetType.E2E) + return shareWithNum > 1 + ? t('compose_shared_friends_other', { count: shareWithNum }) + : t('compose_shared_friends') else if (selected === EncryptionTargetType.Public) return t('compose_encrypt_visible_to_all') else if (selected === EncryptionTargetType.Self) return t('compose_encrypt_visible_to_private') unreachable(selected) From 34b2672e99c4e3b0a096fddd7dd9aa225d0a1d29 Mon Sep 17 00:00:00 2001 From: lelenei <72531217+lelenei@users.noreply.github.com> Date: Thu, 19 May 2022 02:15:46 +0800 Subject: [PATCH 12/54] fix: css style (#6300) * fix: css style * fix: css style * fix: redpacket nft --- .../InjectedComponents/SearchResultBox.tsx | 2 +- .../FindTruman/SNSAdaptor/FindTruman.tsx | 13 +++++- .../mask/src/plugins/ITO/SNSAdaptor/ITO.tsx | 9 ++-- .../SNSAdaptor/components/PreviewCard.tsx | 15 ++++++- .../SNSAdaptor/RedPacket/OperationFooter.tsx | 2 +- .../SNSAdaptor/RedPacket/useStyles.ts | 10 +++++ .../RedPacket/SNSAdaptor/RedPacketNft.tsx | 42 +++++++++++++------ .../hooks/useAvailabilityNftRedPacket.ts | 5 ++- .../hooks/useNftRedPacketContract.ts | 8 ++-- .../UI/EthereumWalletConnectedBoundary.tsx | 14 +------ 10 files changed, 78 insertions(+), 42 deletions(-) diff --git a/packages/mask/src/components/InjectedComponents/SearchResultBox.tsx b/packages/mask/src/components/InjectedComponents/SearchResultBox.tsx index 5d09af03a749..c917be2bf891 100644 --- a/packages/mask/src/components/InjectedComponents/SearchResultBox.tsx +++ b/packages/mask/src/components/InjectedComponents/SearchResultBox.tsx @@ -1,7 +1,7 @@ import { createInjectHooksRenderer, useActivatedPluginsSNSAdaptor } from '@masknet/plugin-infra/content-script' const PluginRenderer = createInjectHooksRenderer( - useActivatedPluginsSNSAdaptor.visibility.useAnyMode, + useActivatedPluginsSNSAdaptor.visibility.useNotMinimalMode, (x) => x.SearchResultBox, ) diff --git a/packages/mask/src/plugins/FindTruman/SNSAdaptor/FindTruman.tsx b/packages/mask/src/plugins/FindTruman/SNSAdaptor/FindTruman.tsx index fd870fe64ebf..d8f268c5ef00 100644 --- a/packages/mask/src/plugins/FindTruman/SNSAdaptor/FindTruman.tsx +++ b/packages/mask/src/plugins/FindTruman/SNSAdaptor/FindTruman.tsx @@ -102,6 +102,17 @@ const useStyles = makeStyles()((theme) => { backgroundColor: theme.palette.primary.main, }, }, + button: { + backgroundColor: theme.palette.maskColor.dark, + color: 'white', + fontSize: 14, + fontWeight: 700, + width: '100%', + '&:hover': { + backgroundColor: theme.palette.maskColor.dark, + }, + margin: '0 !important', + }, } }) @@ -263,8 +274,8 @@ export function FindTruman(props: FindTrumanProps) { } + classes={{ button: classes.button }} /> diff --git a/packages/mask/src/plugins/ITO/SNSAdaptor/ITO.tsx b/packages/mask/src/plugins/ITO/SNSAdaptor/ITO.tsx index fb5df44e3024..01c864243c8e 100644 --- a/packages/mask/src/plugins/ITO/SNSAdaptor/ITO.tsx +++ b/packages/mask/src/plugins/ITO/SNSAdaptor/ITO.tsx @@ -185,7 +185,9 @@ const useStyles = makeStyles()((theme, props) => ({ minHeight: 35, '&:hover': { background: 'none', + borderColor: '#fff !important', }, + background: 'none', }, loadingWrap: { display: 'flex', @@ -916,12 +918,7 @@ export function ITO_Error({ retryPoolPayload }: { retryPoolPayload: () => void } {t('loading_failed')} - + {t('try_again')}
diff --git a/packages/mask/src/plugins/MaskBox/SNSAdaptor/components/PreviewCard.tsx b/packages/mask/src/plugins/MaskBox/SNSAdaptor/components/PreviewCard.tsx index bded23df3d24..2c362a380d13 100644 --- a/packages/mask/src/plugins/MaskBox/SNSAdaptor/components/PreviewCard.tsx +++ b/packages/mask/src/plugins/MaskBox/SNSAdaptor/components/PreviewCard.tsx @@ -39,6 +39,17 @@ const useTabsStyles = makeStyles()((theme) => ({ tabPanel: { marginTop: `${theme.spacing(2)} !important`, }, + button: { + backgroundColor: theme.palette.maskColor.dark, + color: 'white', + fontSize: 14, + fontWeight: 700, + width: '100%', + '&:hover': { + backgroundColor: theme.palette.maskColor.dark, + }, + margin: '0 !important', + }, })) export interface PreviewCardProps {} @@ -239,7 +250,9 @@ export function PreviewCard(props: PreviewCardProps) { - + } classes={{ - connectWallet: classes.connectWallet, + button: classes.walletButton, }}> {canRefund ? null : ( diff --git a/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacket/useStyles.ts b/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacket/useStyles.ts index b05f09cec7e1..33db3b03a390 100644 --- a/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacket/useStyles.ts +++ b/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacket/useStyles.ts @@ -166,5 +166,15 @@ to { fontSize: 24, marginTop: 210, }, + walletButton: { + backgroundColor: theme.palette.maskColor.dark, + color: 'white', + fontSize: 14, + fontWeight: 700, + width: '100%', + '&:hover': { + backgroundColor: theme.palette.maskColor.dark, + }, + }, } }) diff --git a/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacketNft.tsx b/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacketNft.tsx index 7ed8a172141f..112fb49b69df 100644 --- a/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacketNft.tsx +++ b/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacketNft.tsx @@ -8,7 +8,7 @@ import { TransactionStateType, } from '@masknet/web3-shared-evm' import LaunchIcon from '@mui/icons-material/Launch' -import { Grid, Card, CardHeader, Typography, Link, CardMedia, CardContent, Button, Box, Skeleton } from '@mui/material' +import { Card, CardHeader, Typography, Link, CardMedia, CardContent, Button, Box, Skeleton } from '@mui/material' import { useCallback, useEffect, useState } from 'react' import ActionButton from '../../../extension/options-page/DashboardComponents/ActionButton' import { useI18N } from '../../../utils' @@ -23,7 +23,7 @@ import { isTwitter } from '../../../social-network-adaptor/twitter.com/base' import { isFacebook } from '../../../social-network-adaptor/facebook.com/base' import { NFTCardStyledAssetPlayer } from '@masknet/shared' import { openWindow } from '@masknet/shared-base-ui' -import { PluginWalletConnectIcon } from '@masknet/icons' +import { PluginWalletConnectIcon, SharedIcon } from '@masknet/icons' import { EthereumChainBoundary } from '../../../web3/UI/EthereumChainBoundary' const useStyles = makeStyles()((theme) => ({ @@ -81,9 +81,18 @@ const useStyles = makeStyles()((theme) => ({ marginTop: theme.spacing(1), }, button: { - marginTop: '0 !important', - minHeight: 38, - height: 38, + minHeight: 40, + height: 40, + + backgroundColor: theme.palette.maskColor.dark, + color: 'white', + fontSize: 14, + fontWeight: 700, + width: '100%', + '&:hover': { + backgroundColor: theme.palette.maskColor.dark, + }, + margin: '0 !important', }, footer: { display: 'flex', @@ -102,6 +111,7 @@ const useStyles = makeStyles()((theme) => ({ }, buttonWrapper: { marginTop: 0, + display: 'flex', }, loadingBox: { borderRadius: theme.spacing(1), @@ -255,7 +265,7 @@ export function RedPacketNft({ payload }: RedPacketNftProps) { loading, retry: retryAvailability, error: availabilityError, - } = useAvailabilityNftRedPacket(payload.id, account) + } = useAvailabilityNftRedPacket(payload.id, account, payload.chainId) const [claimState, claimCallback, resetCallback] = useClaimNftRedpacketCallback( payload.id, availability?.totalAmount, @@ -427,14 +437,20 @@ export function RedPacketNft({ payload }: RedPacketNftProps) {
) : availability.isClaimedAll || availability.isCompleted ? null : ( - - - - + {availability.isClaimed ? null : ( - + } @@ -454,9 +470,9 @@ export function RedPacketNft({ payload }: RedPacketNftProps) { - + )} - + )} ) diff --git a/packages/mask/src/plugins/RedPacket/SNSAdaptor/hooks/useAvailabilityNftRedPacket.ts b/packages/mask/src/plugins/RedPacket/SNSAdaptor/hooks/useAvailabilityNftRedPacket.ts index 1537455aa3d1..7e09ff373c0d 100644 --- a/packages/mask/src/plugins/RedPacket/SNSAdaptor/hooks/useAvailabilityNftRedPacket.ts +++ b/packages/mask/src/plugins/RedPacket/SNSAdaptor/hooks/useAvailabilityNftRedPacket.ts @@ -1,9 +1,10 @@ +import type { ChainId } from '@masknet/web3-shared-evm' import BigNumber from 'bignumber.js' import { useAsyncRetry } from 'react-use' import { useNftRedPacketContract } from './useNftRedPacketContract' -export function useAvailabilityNftRedPacket(id: string, from: string) { - const nftRedPacketContract = useNftRedPacketContract() +export function useAvailabilityNftRedPacket(id: string, from: string, chainId?: ChainId) { + const nftRedPacketContract = useNftRedPacketContract(chainId) return useAsyncRetry(async () => { if (!id || !nftRedPacketContract) return null const availability = await nftRedPacketContract.methods.check_availability(id).call({ diff --git a/packages/mask/src/plugins/RedPacket/SNSAdaptor/hooks/useNftRedPacketContract.ts b/packages/mask/src/plugins/RedPacket/SNSAdaptor/hooks/useNftRedPacketContract.ts index f61aad97f449..14dabadf3fe6 100644 --- a/packages/mask/src/plugins/RedPacket/SNSAdaptor/hooks/useNftRedPacketContract.ts +++ b/packages/mask/src/plugins/RedPacket/SNSAdaptor/hooks/useNftRedPacketContract.ts @@ -1,10 +1,10 @@ import NftRedPacketABI from '@masknet/web3-contracts/abis/NftRedPacket.json' -import { useContract, useNftRedPacketConstants } from '@masknet/web3-shared-evm' +import { ChainId, useContract, useNftRedPacketConstants } from '@masknet/web3-shared-evm' import type { NftRedPacket } from '@masknet/web3-contracts/types/NftRedPacket' import type { AbiItem } from 'web3-utils' -export function useNftRedPacketContract() { - const { RED_PACKET_NFT_ADDRESS } = useNftRedPacketConstants() - const contract = useContract(RED_PACKET_NFT_ADDRESS, NftRedPacketABI as AbiItem[]) +export function useNftRedPacketContract(chainId?: ChainId) { + const { RED_PACKET_NFT_ADDRESS } = useNftRedPacketConstants(chainId) + const contract = useContract(RED_PACKET_NFT_ADDRESS, NftRedPacketABI as AbiItem[], chainId) return contract } diff --git a/packages/mask/src/web3/UI/EthereumWalletConnectedBoundary.tsx b/packages/mask/src/web3/UI/EthereumWalletConnectedBoundary.tsx index 1f5a08c3e18d..9a73cc3071fd 100644 --- a/packages/mask/src/web3/UI/EthereumWalletConnectedBoundary.tsx +++ b/packages/mask/src/web3/UI/EthereumWalletConnectedBoundary.tsx @@ -10,19 +10,7 @@ import { useWalletRiskWarningDialog } from '../../plugins/Wallet/hooks/useWallet const useStyles = makeStyles()((theme) => ({ button: { - backgroundColor: theme.palette.maskColor.dark, - color: 'white', - fontSize: 14, - fontWeight: 700, - width: '100%', - '&:hover': { - backgroundColor: theme.palette.maskColor.dark, - }, - margin: 0, - }, - grid: { - justifyContent: 'center', - padding: 8, + marginTop: theme.spacing(1.5), }, })) From 645aa8c305b570b0aa7bb680f0659a189cfff1a5 Mon Sep 17 00:00:00 2001 From: lelenei <72531217+lelenei@users.noreply.github.com> Date: Thu, 19 May 2022 02:16:31 +0800 Subject: [PATCH 13/54] fix(ins): css style (#6301) --- .../src/plugins/Avatar/SNSAdaptor/NFTAvatarButton.tsx | 8 ++++---- packages/mask/src/plugins/Avatar/assets/application.tsx | 5 ++++- .../instagram.com/injection/NFT/NFTAvatarEditProfile.tsx | 3 +++ 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/mask/src/plugins/Avatar/SNSAdaptor/NFTAvatarButton.tsx b/packages/mask/src/plugins/Avatar/SNSAdaptor/NFTAvatarButton.tsx index 17c4115fe58f..c12c6c864ef4 100644 --- a/packages/mask/src/plugins/Avatar/SNSAdaptor/NFTAvatarButton.tsx +++ b/packages/mask/src/plugins/Avatar/SNSAdaptor/NFTAvatarButton.tsx @@ -17,7 +17,7 @@ const useStyles = makeStyles()((theme) => ({ color: theme.palette.text.primary, cursor: 'pointer', }, - icon: { + setIcon: { width: 14, height: 14, marginLeft: 2, @@ -29,7 +29,7 @@ const useStyles = makeStyles()((theme) => ({ }, })) -interface NFTAvatarButtonProps extends withClasses<'root' | 'text'> { +interface NFTAvatarButtonProps extends withClasses<'root' | 'text' | 'icon'> { onClick: () => void showSetting?: boolean } @@ -41,10 +41,10 @@ export function NFTAvatarButton(props: NFTAvatarButtonProps) { return (
- + {t('nft_avatar')} - {props.showSetting ? : null} + {props.showSetting ? : null}
) diff --git a/packages/mask/src/plugins/Avatar/assets/application.tsx b/packages/mask/src/plugins/Avatar/assets/application.tsx index 7dc9378ccd8a..25e5dbb38573 100644 --- a/packages/mask/src/plugins/Avatar/assets/application.tsx +++ b/packages/mask/src/plugins/Avatar/assets/application.tsx @@ -57,7 +57,10 @@ export const ApplicationRoundIcon = createIcon( export const ApplicationSmallIcon = createIcon( 'ApplicationSmallIcon', - + , '0 0 21 20', ) diff --git a/packages/mask/src/social-network-adaptor/instagram.com/injection/NFT/NFTAvatarEditProfile.tsx b/packages/mask/src/social-network-adaptor/instagram.com/injection/NFT/NFTAvatarEditProfile.tsx index b925601314d6..51e407b01eb8 100644 --- a/packages/mask/src/social-network-adaptor/instagram.com/injection/NFT/NFTAvatarEditProfile.tsx +++ b/packages/mask/src/social-network-adaptor/instagram.com/injection/NFT/NFTAvatarEditProfile.tsx @@ -38,6 +38,9 @@ const useStyles = makeStyles()(() => ({ color: '#ffffff', lineHeight: '12px', }, + icon: { + color: 'white', + }, })) export function openNFTAvatarSettingDialog() { From 38e33123e5d466613d7d684308bd432a60afaef6 Mon Sep 17 00:00:00 2001 From: zhouhanseng Date: Thu, 19 May 2022 10:44:34 +0800 Subject: [PATCH 14/54] fix: no need to check is contract --- packages/mask/src/components/shared/DraggableDiv.tsx | 1 - packages/web3-shared/evm/hooks/useERC20TokenDetailed.ts | 6 ++---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/mask/src/components/shared/DraggableDiv.tsx b/packages/mask/src/components/shared/DraggableDiv.tsx index ca2cf87eec02..f30c9a7bbe4f 100644 --- a/packages/mask/src/components/shared/DraggableDiv.tsx +++ b/packages/mask/src/components/shared/DraggableDiv.tsx @@ -39,7 +39,6 @@ export function DraggableDiv({ cancel="p, h1, input, button, address" handle="nav" {...DraggableProps} - // @ts-expect-error @types/react 18 children={
} />
diff --git a/packages/web3-shared/evm/hooks/useERC20TokenDetailed.ts b/packages/web3-shared/evm/hooks/useERC20TokenDetailed.ts index c6f3234250a8..c14018b38fc1 100644 --- a/packages/web3-shared/evm/hooks/useERC20TokenDetailed.ts +++ b/packages/web3-shared/evm/hooks/useERC20TokenDetailed.ts @@ -8,21 +8,19 @@ import type { ERC20Bytes32 } from '@masknet/web3-contracts/types/ERC20Bytes32' import { useERC20TokenContract, useERC20TokenContracts } from '../contracts/useERC20TokenContract' import { useERC20TokenBytes32Contract, useERC20TokenBytes32Contracts } from '../contracts/useERC20TokenBytes32Contract' import { parseStringOrBytes32, createERC20Token, createNativeToken } from '../utils' -import { useEthereumTokenType } from './useEthereumTokenType' export function useERC20TokenDetailed(address?: string, token?: Partial, targetChainId?: ChainId) { const currentChainId = useChainId() const chainId = targetChainId ?? currentChainId const erc20TokenContract = useERC20TokenContract(address, chainId) const erc20TokenBytes32Contract = useERC20TokenBytes32Contract(address, chainId) - const tokenType = useEthereumTokenType(address) return useAsyncRetry(async () => { if (!address) return if (!EthereumAddress.isValid(address)) return - if (tokenType !== EthereumTokenType.ERC20) return + return getERC20TokenDetailed(address, chainId, erc20TokenContract, erc20TokenBytes32Contract, token) - }, [chainId, token, erc20TokenContract, erc20TokenBytes32Contract, address, tokenType]) + }, [chainId, token, erc20TokenContract, erc20TokenBytes32Contract, address]) } export function useFungibleTokensDetailed(listOfToken: Pick[], _chainId?: ChainId) { From 9f9b39716692ba2d6caf071528c046cfea4cddf3 Mon Sep 17 00:00:00 2001 From: zhouhanseng Date: Thu, 19 May 2022 11:02:19 +0800 Subject: [PATCH 15/54] fix: ts type --- packages/mask/src/components/shared/DraggableDiv.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/mask/src/components/shared/DraggableDiv.tsx b/packages/mask/src/components/shared/DraggableDiv.tsx index f30c9a7bbe4f..ca2cf87eec02 100644 --- a/packages/mask/src/components/shared/DraggableDiv.tsx +++ b/packages/mask/src/components/shared/DraggableDiv.tsx @@ -39,6 +39,7 @@ export function DraggableDiv({ cancel="p, h1, input, button, address" handle="nav" {...DraggableProps} + // @ts-expect-error @types/react 18 children={
} />
From 4ce209cee76d10330f7203b43b1c7c0d294781a5 Mon Sep 17 00:00:00 2001 From: Randolph314 <97870249+Randolph314@users.noreply.github.com> Date: Thu, 19 May 2022 11:51:02 +0800 Subject: [PATCH 16/54] feat: use Cross-chain in production environment (#6303) Co-authored-by: Randolph <840094513@qq.com> --- packages/plugins/CrossChainBridge/src/base.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/plugins/CrossChainBridge/src/base.ts b/packages/plugins/CrossChainBridge/src/base.ts index 7625b7388e5b..2c83e4ed8e50 100644 --- a/packages/plugins/CrossChainBridge/src/base.ts +++ b/packages/plugins/CrossChainBridge/src/base.ts @@ -10,8 +10,7 @@ export const base: Plugin.Shared.Definition = { enableRequirement: { architecture: { app: false, web: true }, networks: { type: 'opt-out', networks: {} }, - target: 'beta', + target: 'stable', }, - experimentalMark: true, i18n: languages, } From 952f498ae1c0ed0cf9e269b65712ea5dffa420b3 Mon Sep 17 00:00:00 2001 From: zhouhanseng Date: Thu, 19 May 2022 11:53:55 +0800 Subject: [PATCH 17/54] fix: ito fetch availability when no connect --- .../src/plugins/ITO/SNSAdaptor/hooks/useAvailability.ts | 9 ++++----- .../ITO/SNSAdaptor/hooks/useAvailabilityComputed.ts | 2 +- .../src/plugins/ITO/Worker/apis/checkAvailability.ts | 9 ++++++++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/mask/src/plugins/ITO/SNSAdaptor/hooks/useAvailability.ts b/packages/mask/src/plugins/ITO/SNSAdaptor/hooks/useAvailability.ts index 360546fee49f..025f0de90334 100644 --- a/packages/mask/src/plugins/ITO/SNSAdaptor/hooks/useAvailability.ts +++ b/packages/mask/src/plugins/ITO/SNSAdaptor/hooks/useAvailability.ts @@ -1,17 +1,16 @@ import { useAsyncRetry } from 'react-use' -import { useAccount, useITOConstants, useChainId, isSameAddress, ChainId } from '@masknet/web3-shared-evm' +import { useAccount, useITOConstants, isSameAddress, ChainId } from '@masknet/web3-shared-evm' import { checkAvailability } from '../../Worker/apis/checkAvailability' -export function useAvailability(id: string, contract_address: string, from?: string, chainId?: ChainId) { +export function useAvailability(id: string, contract_address: string, chainId: ChainId, from?: string) { const account = useAccount() const fromAccount = from ?? account - const _chainId = useChainId() const { ITO_CONTRACT_ADDRESS } = useITOConstants() const isV1 = isSameAddress(contract_address ?? '', ITO_CONTRACT_ADDRESS) return useAsyncRetry(async () => { if (!id || !contract_address) return null - return checkAvailability(id, account ?? fromAccount, contract_address, chainId ?? _chainId, isV1) - }, [id, account, fromAccount, _chainId, chainId]) + return checkAvailability(id, account || fromAccount, contract_address, chainId, isV1) + }, [id, account, fromAccount, chainId]) } diff --git a/packages/mask/src/plugins/ITO/SNSAdaptor/hooks/useAvailabilityComputed.ts b/packages/mask/src/plugins/ITO/SNSAdaptor/hooks/useAvailabilityComputed.ts index d8df7c1a0b77..1682c08a1010 100644 --- a/packages/mask/src/plugins/ITO/SNSAdaptor/hooks/useAvailabilityComputed.ts +++ b/packages/mask/src/plugins/ITO/SNSAdaptor/hooks/useAvailabilityComputed.ts @@ -12,8 +12,8 @@ export function useAvailabilityComputed(payload: JSON_PayloadInMask | JSON_Paylo const asyncResult = useAvailability( payload.pid, payload.contract_address, - payload.seller.address, payload.chain_id ?? chainId, + payload.seller.address, ) const { value: availability, loading: loadingITO } = asyncResult const qualificationAddress = diff --git a/packages/mask/src/plugins/ITO/Worker/apis/checkAvailability.ts b/packages/mask/src/plugins/ITO/Worker/apis/checkAvailability.ts index b2d4491c5ae5..ebc4b89e617d 100644 --- a/packages/mask/src/plugins/ITO/Worker/apis/checkAvailability.ts +++ b/packages/mask/src/plugins/ITO/Worker/apis/checkAvailability.ts @@ -11,7 +11,14 @@ const interFaceV2 = new Interface(ITO2_ABI) // ITO Contract readonly method, read it no matter on whatever chains you are. export async function checkAvailability(pid: string, from: string, to: string, chainId: ChainId, isV1 = false) { const callData = (isV1 ? interFaceV1 : interFaceV2).encodeFunctionData('check_availability', [pid]) - const data = await Services.Ethereum.call({ to, from, data: callData }, { chainId }) + const data = await Services.Ethereum.call( + { + to, + from, + data: callData, + }, + { chainId }, + ) return decodeResult(data, isV1) } From 2a838def65edd47acfa287440f09e1abc46bdbb5 Mon Sep 17 00:00:00 2001 From: BillyS Date: Thu, 19 May 2022 13:24:38 +0800 Subject: [PATCH 18/54] fix: 765 (#6304) --- .../src/pages/Wallets/components/Balance/index.tsx | 7 +++++-- .../src/components/CompositionDialog/CompositionUI.tsx | 7 ++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/dashboard/src/pages/Wallets/components/Balance/index.tsx b/packages/dashboard/src/pages/Wallets/components/Balance/index.tsx index d782c2df2c3c..88763228ff6d 100644 --- a/packages/dashboard/src/pages/Wallets/components/Balance/index.tsx +++ b/packages/dashboard/src/pages/Wallets/components/Balance/index.tsx @@ -122,10 +122,13 @@ export const Balance = memo( {showOperations && ( - - - - diff --git a/packages/mask/src/web3/UI/EthereumChainBoundary.tsx b/packages/mask/src/web3/UI/EthereumChainBoundary.tsx index 03596762dc52..9626dece8fd5 100644 --- a/packages/mask/src/web3/UI/EthereumChainBoundary.tsx +++ b/packages/mask/src/web3/UI/EthereumChainBoundary.tsx @@ -1,4 +1,4 @@ -import React, { useCallback } from 'react' +import React, { useCallback, useMemo } from 'react' import { Box, Typography, Theme, useTheme } from '@mui/material' import { makeStyles, MaskColorVar, ShadowRootTooltip, useStylesExtends } from '@masknet/theme' import type { SxProps } from '@mui/system' @@ -59,13 +59,13 @@ export interface EthereumChainBoundaryProps extends withClasses<'switchButton'> switchButtonStyle?: SxProps children?: React.ReactNode isValidChainId?: (actualChainId: ChainId, expectedChainId: ChainId) => boolean + renderInTimeline?: boolean ActionButtonPromiseProps?: Partial } export function EthereumChainBoundary(props: EthereumChainBoundaryProps) { const { t } = useI18N() const theme = useTheme() - const pluginID = useCurrentWeb3NetworkPluginID() const plugin = useActivatedPlugin(pluginID, 'any') @@ -162,6 +162,26 @@ export function EthereumChainBoundary(props: EthereumChainBoundaryProps) { if (!isChainMatched) await switchToChain() }, [account, isAllowed, isChainMatched, isPluginMatched, providerType, expectedChainId]) + // TODO: will remove this and extract new boundary for timeline + const buttonProps = useMemo(() => { + return { + ...(props.renderInTimeline + ? { + variant: 'contained', + fullWidth: true, + sx: { + backgroundColor: theme.palette.maskColor.dark, + color: theme.palette.maskColor.white, + '&:hover': { + backgroundColor: theme.palette.maskColor.dark, + }, + }, + } + : {}), + ...props.ActionButtonPromiseProps, + } as Partial + }, [props.ActionButtonPromiseProps, props.renderInTimeline]) + const renderBox = (children?: React.ReactNode, tips?: string) => { return ( @@ -182,11 +202,13 @@ export function EthereumChainBoundary(props: EthereumChainBoundaryProps) { <> {!props.hiddenConnectButton ? ( } + fullWidth + startIcon={} variant="contained" size={props.ActionButtonPromiseProps?.size} sx={{ marginTop: 1.5 }} - onClick={openSelectProviderDialog}> + onClick={openSelectProviderDialog} + {...buttonProps}> {t('plugin_wallet_connect_wallet')} ) : null} @@ -225,10 +247,10 @@ export function EthereumChainBoundary(props: EthereumChainBoundaryProps) { } sx={props.switchButtonStyle} - style={{ borderRadius: 10 }} init={ {t('plugin_wallet_connect_network', { @@ -246,7 +268,8 @@ export function EthereumChainBoundary(props: EthereumChainBoundaryProps) { executor={onSwitchChain} completeOnClick={onSwitchChain} failedOnClick="use executor" - {...props.ActionButtonPromiseProps} + fullWidth + {...buttonProps} /> ) : null} , @@ -274,7 +297,6 @@ export function EthereumChainBoundary(props: EthereumChainBoundaryProps) { /> } sx={props.switchButtonStyle} - style={{ borderRadius: 10, paddingTop: 11, paddingBottom: 11 }} init={ {t('plugin_wallet_switch_network', { network: expectedNetwork.replace('Mainnet', '') })} @@ -288,7 +310,8 @@ export function EthereumChainBoundary(props: EthereumChainBoundaryProps) { executor={onSwitchChain} completeOnClick={onSwitchChain} failedOnClick="use executor" - {...props.ActionButtonPromiseProps} + fullWidth + {...buttonProps} /> ) : null} , From 571a718f080de1f3f1bf964fa7b1fb6d38fa6260 Mon Sep 17 00:00:00 2001 From: lelenei <72531217+lelenei@users.noreply.github.com> Date: Thu, 19 May 2022 23:39:26 +0800 Subject: [PATCH 29/54] fix: timeline plugin render (#6310) * fix: show ito at other chainnet * fix: revert code * fix: typo * fix: revert code * fix: revert code * fix: 769 * refactor: remove unused code Co-authored-by: zhouhanseng --- packages/mask/src/plugins/FindTruman/base.ts | 13 +++++++++++- packages/mask/src/plugins/Gitcoin/base.ts | 9 +++++++++ .../RedPacket/SNSAdaptor/RedPacketDialog.tsx | 11 +++++++--- packages/mask/src/plugins/RedPacket/base.ts | 20 +++++++++++++++++++ .../src/hooks/useAvailablePlugins.ts | 16 +-------------- packages/plugins/CyberConnect/src/base.tsx | 13 ++++++++++++ 6 files changed, 63 insertions(+), 19 deletions(-) diff --git a/packages/mask/src/plugins/FindTruman/base.ts b/packages/mask/src/plugins/FindTruman/base.ts index 42e34c04365c..ad23830b6f09 100644 --- a/packages/mask/src/plugins/FindTruman/base.ts +++ b/packages/mask/src/plugins/FindTruman/base.ts @@ -16,7 +16,18 @@ export const base: Plugin.Shared.Definition = { target: 'stable', web3: { [NetworkPluginID.PLUGIN_EVM]: { - supportedChainIds: [ChainId.Mainnet], + supportedChainIds: [ + ChainId.Mainnet, + ChainId.BSC, + ChainId.Matic, + ChainId.Arbitrum, + ChainId.xDai, + ChainId.Fantom, + ChainId.Avalanche, + ChainId.Aurora, + ChainId.Conflux, + ChainId.Harmony, + ], }, [NetworkPluginID.PLUGIN_FLOW]: { supportedChainIds: [] }, [NetworkPluginID.PLUGIN_SOLANA]: { supportedChainIds: [] }, diff --git a/packages/mask/src/plugins/Gitcoin/base.ts b/packages/mask/src/plugins/Gitcoin/base.ts index 65995d21a8a0..2ba903193d15 100644 --- a/packages/mask/src/plugins/Gitcoin/base.ts +++ b/packages/mask/src/plugins/Gitcoin/base.ts @@ -1,4 +1,6 @@ import type { Plugin } from '@masknet/plugin-infra' +import { NetworkPluginID } from '@masknet/plugin-infra/web3' +import { ChainId } from '@masknet/web3-shared-evm' import { PLUGIN_ID, PLUGIN_NAME, PLUGIN_DESCRIPTION } from './constants' export const base: Plugin.Shared.Definition = { @@ -10,6 +12,13 @@ export const base: Plugin.Shared.Definition = { architecture: { app: true, web: true }, networks: { type: 'opt-out', networks: {} }, target: 'stable', + web3: { + [NetworkPluginID.PLUGIN_EVM]: { + supportedChainIds: [ChainId.Mainnet, ChainId.Rinkeby, ChainId.Matic, ChainId.Mumbai], + }, + [NetworkPluginID.PLUGIN_FLOW]: { supportedChainIds: [] }, + [NetworkPluginID.PLUGIN_SOLANA]: { supportedChainIds: [] }, + }, }, contribution: { postContent: new Set([/https:\/\/gitcoin.co\/grants\/\d+/]) }, } diff --git a/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacketDialog.tsx b/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacketDialog.tsx index af9afe3ca609..08c406c5469d 100644 --- a/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacketDialog.tsx +++ b/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacketDialog.tsx @@ -15,7 +15,11 @@ import { import { DialogContent } from '@mui/material' import { useCallback, useEffect, useMemo, useRef, useState } from 'react' import Web3Utils from 'web3-utils' -import { useCurrentIdentity, useCurrentLinkedPersona } from '../../../components/DataSource/useActivatedUI' +import { + useCurrentIdentity, + useCurrentLinkedPersona, + useLastRecognizedIdentity, +} from '../../../components/DataSource/useActivatedUI' import AbstractTab, { AbstractTabProps } from '../../../components/shared/AbstractTab' import Services from '../../../extension/service' import { useI18N } from '../../../utils' @@ -95,8 +99,9 @@ export default function RedPacketDialog(props: RedPacketDialogProps) { const currentIdentity = useCurrentIdentity() const { value: linkedPersona } = useCurrentLinkedPersona() - - const senderName = currentIdentity?.identifier.userId ?? linkedPersona?.nickname + const lastRecognized = useLastRecognizedIdentity() + const senderName = + lastRecognized.identifier?.userId ?? currentIdentity?.identifier.userId ?? linkedPersona?.nickname const { closeDialog: closeApplicationBoardDialog } = useRemoteControlledDialog( WalletMessages.events.ApplicationDialogUpdated, ) diff --git a/packages/mask/src/plugins/RedPacket/base.ts b/packages/mask/src/plugins/RedPacket/base.ts index 017b71a9a04b..cb9aeeea4ca9 100644 --- a/packages/mask/src/plugins/RedPacket/base.ts +++ b/packages/mask/src/plugins/RedPacket/base.ts @@ -1,4 +1,6 @@ import type { Plugin } from '@masknet/plugin-infra' +import { NetworkPluginID } from '@masknet/plugin-infra/web3' +import { ChainId } from '@masknet/web3-shared-evm' import { RedPacketMetaKey, RedPacketNftMetaKey, RedPacketPluginID } from './constants' export const base: Plugin.Shared.Definition = { @@ -16,6 +18,24 @@ export const base: Plugin.Shared.Definition = { networks: {}, }, target: 'stable', + web3: { + [NetworkPluginID.PLUGIN_EVM]: { + supportedChainIds: [ + ChainId.Mainnet, + ChainId.BSC, + ChainId.Matic, + ChainId.Arbitrum, + ChainId.xDai, + ChainId.Fantom, + ChainId.Avalanche, + ChainId.Aurora, + ChainId.Harmony, + ChainId.Conflux, + ], + }, + [NetworkPluginID.PLUGIN_FLOW]: { supportedChainIds: [] }, + [NetworkPluginID.PLUGIN_SOLANA]: { supportedChainIds: [] }, + }, }, contribution: { metadataKeys: new Set([RedPacketMetaKey, RedPacketNftMetaKey]), diff --git a/packages/plugin-infra/src/hooks/useAvailablePlugins.ts b/packages/plugin-infra/src/hooks/useAvailablePlugins.ts index 46f3776e6c81..eb2db2196c27 100644 --- a/packages/plugin-infra/src/hooks/useAvailablePlugins.ts +++ b/packages/plugin-infra/src/hooks/useAvailablePlugins.ts @@ -1,21 +1,7 @@ -import { useMemo } from 'react' import type { Plugin } from '../types' -import { useChainId, useCurrentWeb3NetworkPluginID } from '../web3' -import type { NetworkPluginID } from '../web3-types' type HasRequirement = { enableRequirement: Plugin.Shared.Definition['enableRequirement'] } -function checkPluginAvailable(plugin: HasRequirement, pluginId: NetworkPluginID, chainId: number) { - const supportedChainIds = plugin.enableRequirement.web3?.[pluginId]?.supportedChainIds - if (!supportedChainIds) return true - return supportedChainIds.includes(chainId) -} - export function useAvailablePlugins(plugins: T[]) { - const networkPluginId = useCurrentWeb3NetworkPluginID() - const chainId = useChainId(networkPluginId) - return useMemo( - () => plugins.filter((plugin) => checkPluginAvailable(plugin, networkPluginId, chainId)), - [plugins, networkPluginId, chainId], - ) + return plugins } diff --git a/packages/plugins/CyberConnect/src/base.tsx b/packages/plugins/CyberConnect/src/base.tsx index 83a0be124b1d..1d133b171379 100644 --- a/packages/plugins/CyberConnect/src/base.tsx +++ b/packages/plugins/CyberConnect/src/base.tsx @@ -1,4 +1,6 @@ import type { Plugin } from '@masknet/plugin-infra' +import { NetworkPluginID } from '@masknet/plugin-infra/web3' +import { ChainId } from '@masknet/web3-shared-evm' import { CYBERCONNECT_PLUGIN_ID } from './constants' export const base: Plugin.Shared.Definition = { @@ -12,6 +14,17 @@ export const base: Plugin.Shared.Definition = { architecture: { app: false, web: true }, networks: { type: 'opt-out', networks: {} }, target: 'stable', + web3: { + [NetworkPluginID.PLUGIN_EVM]: { + supportedChainIds: [ChainId.Mainnet, ChainId.BSC, ChainId.Matic, ChainId.Arbitrum, ChainId.xDai], + }, + [NetworkPluginID.PLUGIN_SOLANA]: { + supportedChainIds: [], + }, + [NetworkPluginID.PLUGIN_FLOW]: { + supportedChainIds: [], + }, + }, }, contribution: { postContent: new Set([/https:\/\/app.cyberconnect.me/]) }, } From d90254484db0990438995a4c1ab570c9109d5876 Mon Sep 17 00:00:00 2001 From: nuanyang233 Date: Fri, 20 May 2022 00:12:02 +0800 Subject: [PATCH 30/54] fix: bugfix for git coin boundary --- packages/mask/src/plugins/Gitcoin/SNSAdaptor/PreviewCard.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/mask/src/plugins/Gitcoin/SNSAdaptor/PreviewCard.tsx b/packages/mask/src/plugins/Gitcoin/SNSAdaptor/PreviewCard.tsx index 2ff3844d10a8..154c34876ab4 100644 --- a/packages/mask/src/plugins/Gitcoin/SNSAdaptor/PreviewCard.tsx +++ b/packages/mask/src/plugins/Gitcoin/SNSAdaptor/PreviewCard.tsx @@ -185,7 +185,9 @@ export function PreviewCard(props: PreviewCardProps) { - +