From fb053bd69791419f48b20e333e90e3b2deb7b528 Mon Sep 17 00:00:00 2001 From: guanbinrui Date: Sun, 24 Apr 2022 17:25:24 +0800 Subject: [PATCH 01/23] chore: bump version to 2.7.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 24a08d3ebd2c..635e18267e5c 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "yarn": ">=999.0.0", "npm": ">=999.0.0" }, - "version": "2.6.0", + "version": "2.7.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 f436056eeecf..20ea95ae94eb 100644 --- a/packages/mask/src/manifest.json +++ b/packages/mask/src/manifest.json @@ -1,6 +1,6 @@ { "name": "Mask Network", - "version": "2.6.0", + "version": "2.7.0", "manifest_version": 2, "permissions": ["storage", "downloads", "webNavigation", "activeTab"], "optional_permissions": ["", "notifications", "clipboardRead"], From b62f66989090ecb29f261868e3356c605c2419dd Mon Sep 17 00:00:00 2001 From: nuanyang233 Date: Sun, 24 Apr 2022 19:39:28 +0800 Subject: [PATCH 02/23] fix: hidden opensea --- .../src/extension/popups/pages/Personas/Accounts/index.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/mask/src/extension/popups/pages/Personas/Accounts/index.tsx b/packages/mask/src/extension/popups/pages/Personas/Accounts/index.tsx index 35a18aaf4483..4e54a830aae4 100644 --- a/packages/mask/src/extension/popups/pages/Personas/Accounts/index.tsx +++ b/packages/mask/src/extension/popups/pages/Personas/Accounts/index.tsx @@ -42,13 +42,11 @@ const Accounts = memo(() => { const definedSocialNetworks = compact( getEnumAsArray(EnhanceableSite).map((x) => { - if (x.value === EnhanceableSite.Localhost) return null + if (x.value === EnhanceableSite.Localhost || x.value === EnhanceableSite.OpenSea) return null return x.value }), ) - console.log(definedSocialNetworks) - const [, onConnect] = useAsyncFn( async (networkIdentifier: EnhanceableSite) => { if (currentPersona) { From 9b1c4c4e24838343b263930aa11fd663b71cb55b Mon Sep 17 00:00:00 2001 From: nuanyang233 Date: Sun, 24 Apr 2022 21:11:25 +0800 Subject: [PATCH 03/23] fix: ui style --- .../src/extension/popups/pages/Personas/SelectPersona/index.tsx | 1 + .../popups/pages/Personas/components/PersonaList/index.tsx | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mask/src/extension/popups/pages/Personas/SelectPersona/index.tsx b/packages/mask/src/extension/popups/pages/Personas/SelectPersona/index.tsx index 720256949375..eeade60ec5df 100644 --- a/packages/mask/src/extension/popups/pages/Personas/SelectPersona/index.tsx +++ b/packages/mask/src/extension/popups/pages/Personas/SelectPersona/index.tsx @@ -14,6 +14,7 @@ const useStyles = makeStyles()({ backgroundColor: '#F7F9FA', display: 'flex', flexDirection: 'column', + paddingBottom: 72, }, controller: { padding: 16, diff --git a/packages/mask/src/extension/popups/pages/Personas/components/PersonaList/index.tsx b/packages/mask/src/extension/popups/pages/Personas/components/PersonaList/index.tsx index 14e5995eaa32..4639e3c2fdff 100644 --- a/packages/mask/src/extension/popups/pages/Personas/components/PersonaList/index.tsx +++ b/packages/mask/src/extension/popups/pages/Personas/components/PersonaList/index.tsx @@ -19,7 +19,6 @@ import { Trash2 } from 'react-feather' const useStyles = makeStyles()({ list: { padding: 0, - height: 'calc(100vh - 185px)', overflow: 'auto', }, item: { From fb016ede55df26f93b8d91623a510f322f9b0723 Mon Sep 17 00:00:00 2001 From: nuanyang233 Date: Sun, 24 Apr 2022 22:51:22 +0800 Subject: [PATCH 04/23] fix: fill public when wallet backup only have private key --- packages/backup-format/package.json | 4 ++- .../backup-format/src/utils/hex2buffer.ts | 36 +++++++++++++++++++ packages/backup-format/src/version-2/index.ts | 13 +++++++ pnpm-lock.yaml | 4 +++ 4 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 packages/backup-format/src/utils/hex2buffer.ts diff --git a/packages/backup-format/package.json b/packages/backup-format/package.json index 3620d67d6237..3df974bb0291 100644 --- a/packages/backup-format/package.json +++ b/packages/backup-format/package.json @@ -11,6 +11,8 @@ "type": "module", "dependencies": { "@masknet/shared-base": "workspace:*", - "@msgpack/msgpack": "^2.7.2" + "@msgpack/msgpack": "^2.7.2", + "elliptic": "^6.5.3", + "pvtsutils": "^1.2.2" } } diff --git a/packages/backup-format/src/utils/hex2buffer.ts b/packages/backup-format/src/utils/hex2buffer.ts new file mode 100644 index 000000000000..c56fcf6172ba --- /dev/null +++ b/packages/backup-format/src/utils/hex2buffer.ts @@ -0,0 +1,36 @@ +/** @internal */ +export function hex2buffer(hexString: string, padded?: boolean) { + if (hexString.length % 2) { + hexString = '0' + hexString + } + let res = new Uint8Array(hexString.length / 2) + // eslint-disable-next-line no-plusplus + for (let i = 0; i < hexString.length; i++) { + // eslint-disable-next-line no-plusplus + const c = hexString.slice(i, ++i + 1) + res[(i - 1) / 2] = Number.parseInt(c, 16) + } + // BN padding + if (padded) { + let len = res.length + len = len > 32 ? (len > 48 ? 66 : 48) : 32 + if (res.length < len) { + res = concat(new Uint8Array(len - res.length), res) + } + } + return res +} + +/** @internal */ +function concat(...buf: (Uint8Array | number[])[]) { + const res = new Uint8Array(buf.map((item) => item.length).reduce((prev, cur) => prev + cur)) + let offset = 0 + buf.forEach((item, index) => { + // eslint-disable-next-line no-plusplus + for (let i = 0; i < item.length; i++) { + res[offset + i] = item[i] + } + offset += item.length + }) + return res +} diff --git a/packages/backup-format/src/version-2/index.ts b/packages/backup-format/src/version-2/index.ts index 46aa0b0ecb93..75b51b55a310 100644 --- a/packages/backup-format/src/version-2/index.ts +++ b/packages/backup-format/src/version-2/index.ts @@ -10,10 +10,13 @@ import { ProfileIdentifier, RelationFavor, } from '@masknet/shared-base' +import __ from 'elliptic' +import { Convert } from 'pvtsutils' import { decode, encode } from '@msgpack/msgpack' import { Err, None, Some } from 'ts-results' import { createEmptyNormalizedBackup } from '../normalize' import type { NormalizedBackup } from '../normalize/type' +import { hex2buffer } from '../utils/hex2buffer' export function isBackupVersion2(item: unknown): item is BackupJSONFileVersion2 { try { @@ -146,6 +149,16 @@ export function normalizeBackupVersion2(item: BackupJSONFileVersion2): Normalize } for (const wallet of wallets || []) { + if (wallet.privateKey?.d && !wallet.publicKey) { + // @ts-ignore + const ec = new (__.ec || __.default.ec)('secp256k1') as __.ec + const key = ec.keyFromPrivate(wallet.privateKey.d) + const hexPub = key.getPublic('hex').slice(2) + const hexX = hexPub.slice(0, hexPub.length / 2) + const hexY = hexPub.slice(hexPub.length / 2, hexPub.length) + wallet.privateKey.x = Convert.ToBase64Url(hex2buffer(hexX)) + wallet.privateKey.y = Convert.ToBase64Url(hex2buffer(hexY)) + } const normalizedWallet: NormalizedBackup.WalletBackup = { address: wallet.address, name: wallet.name, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 120932998b63..8d9e0b50eb13 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -124,9 +124,13 @@ importers: specifiers: '@masknet/shared-base': workspace:* '@msgpack/msgpack': ^2.7.2 + elliptic: ^6.5.3 + pvtsutils: ^1.2.2 dependencies: '@masknet/shared-base': link:../shared-base '@msgpack/msgpack': 2.7.2 + elliptic: 6.5.4 + pvtsutils: 1.2.2 packages/configuration: specifiers: From 95173fe4aa5d3198281d30e63a8eee16719befc5 Mon Sep 17 00:00:00 2001 From: zhouhanseng Date: Mon, 25 Apr 2022 09:51:13 +0800 Subject: [PATCH 05/23] fix: application board scroll bar --- packages/mask/src/components/shared/ApplicationBoard.tsx | 3 +-- .../src/plugins/Wallet/SNSAdaptor/WalletStatusDialog/index.tsx | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/mask/src/components/shared/ApplicationBoard.tsx b/packages/mask/src/components/shared/ApplicationBoard.tsx index e9f01cef7f1f..52513d6ba1e3 100644 --- a/packages/mask/src/components/shared/ApplicationBoard.tsx +++ b/packages/mask/src/components/shared/ApplicationBoard.tsx @@ -32,13 +32,12 @@ const useStyles = makeStyles()((theme) => { return { applicationWrapper: { padding: theme.spacing(1, 0.25), - overflowY: 'scroll', display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gridTemplateRows: '100px', gridGap: theme.spacing(2), justifyContent: 'space-between', - height: 340, + height: 310, '&::-webkit-scrollbar': { display: 'none', }, diff --git a/packages/mask/src/plugins/Wallet/SNSAdaptor/WalletStatusDialog/index.tsx b/packages/mask/src/plugins/Wallet/SNSAdaptor/WalletStatusDialog/index.tsx index 5369a8dc9170..868ee4810f4a 100644 --- a/packages/mask/src/plugins/Wallet/SNSAdaptor/WalletStatusDialog/index.tsx +++ b/packages/mask/src/plugins/Wallet/SNSAdaptor/WalletStatusDialog/index.tsx @@ -14,6 +14,7 @@ import { ApplicationBoard } from '../../../../components/shared/ApplicationBoard const useStyles = makeStyles()((theme) => ({ content: { padding: theme.spacing(2.5), + marginBottom: theme.spacing(1.5), }, footer: { fontSize: 12, From 9b134849e30e9b2362fb86cb922a76b497321b2f Mon Sep 17 00:00:00 2001 From: zhouhanseng Date: Mon, 25 Apr 2022 11:15:01 +0800 Subject: [PATCH 06/23] fix: lucky drop symbol decimal --- .../RedPacket/SNSAdaptor/RedPacketInHistoryList.tsx | 10 +++++----- .../mask/src/plugins/RedPacket/SNSAdaptor/index.tsx | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacketInHistoryList.tsx b/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacketInHistoryList.tsx index df7cfeaff2ac..aaa68e0a2d17 100644 --- a/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacketInHistoryList.tsx +++ b/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacketInHistoryList.tsx @@ -4,7 +4,7 @@ import classNames from 'classnames' import { Box, ListItem, Typography, Popper, useMediaQuery, Theme } from '@mui/material' import { makeStyles } from '@masknet/theme' import { Trans } from 'react-i18next' -import { omit } from 'lodash-unified' +import { omit, pick } from 'lodash-unified' import { RedPacketJSONPayload, RedPacketStatus, RedPacketJSONPayloadFromChain } from '../types' import { TokenIcon } from '@masknet/shared' import { useRemoteControlledDialog } from '@masknet/shared-base-ui' @@ -210,10 +210,10 @@ export function RedPacketInHistoryList(props: RedPacketInHistoryListProps) { tokenAddress ?? '', ) - const historyToken = - (history as RedPacketJSONPayload).token ?? - tokenDetailed ?? - ({ address: history.token_address } as ERC20TokenDetailed | NativeTokenDetailed) + const historyToken = { + ...pick((tokenDetailed ?? (history as RedPacketJSONPayload)).token, ['decimals', 'symbol']), + address: tokenAddress, + } as ERC20TokenDetailed | NativeTokenDetailed // #region remote controlled transaction dialog const { setDialog: setTransactionDialog } = useRemoteControlledDialog( diff --git a/packages/mask/src/plugins/RedPacket/SNSAdaptor/index.tsx b/packages/mask/src/plugins/RedPacket/SNSAdaptor/index.tsx index c811a8b0ef41..c277bfc6cf09 100644 --- a/packages/mask/src/plugins/RedPacket/SNSAdaptor/index.tsx +++ b/packages/mask/src/plugins/RedPacket/SNSAdaptor/index.tsx @@ -137,7 +137,8 @@ function ERC20RedpacketBadge(props: ERC20RedpacketBadgeProps) { const chainId = getChainIdFromName(payload.network ?? '') ?? ChainId.Mainnet const chainDetailed = getChainDetailed(chainId) const tokenDetailed = - payload.token?.type === EthereumTokenType.Native ? chainDetailed?.nativeCurrency : payload.token ?? fetchedToken + payload.token?.type === EthereumTokenType.Native ? chainDetailed?.nativeCurrency : fetchedToken ?? payload.token + return (
A Lucky Drop with{' '} From fb91877255e6b0233228fd88b4ee511d72080835 Mon Sep 17 00:00:00 2001 From: zhouhanseng Date: Mon, 25 Apr 2022 11:18:19 +0800 Subject: [PATCH 07/23] fix: lucky drop symbol decimal --- .../src/plugins/RedPacket/SNSAdaptor/RedPacketInHistoryList.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacketInHistoryList.tsx b/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacketInHistoryList.tsx index aaa68e0a2d17..c60e2942897d 100644 --- a/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacketInHistoryList.tsx +++ b/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacketInHistoryList.tsx @@ -211,7 +211,7 @@ export function RedPacketInHistoryList(props: RedPacketInHistoryListProps) { ) const historyToken = { - ...pick((tokenDetailed ?? (history as RedPacketJSONPayload)).token, ['decimals', 'symbol']), + ...pick(tokenDetailed ?? (history as RedPacketJSONPayload).token, ['decimals', 'symbol']), address: tokenAddress, } as ERC20TokenDetailed | NativeTokenDetailed From 92e67adbae585bc4be6e37fa0dd03fda26b170c8 Mon Sep 17 00:00:00 2001 From: zhouhanseng Date: Mon, 25 Apr 2022 12:13:42 +0800 Subject: [PATCH 08/23] fix: application board scroll bar --- .../src/components/shared/ApplicationBoard.tsx | 15 ++++++++++++--- .../SNSAdaptor/WalletStatusDialog/index.tsx | 1 - 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/mask/src/components/shared/ApplicationBoard.tsx b/packages/mask/src/components/shared/ApplicationBoard.tsx index 52513d6ba1e3..6af53afcd706 100644 --- a/packages/mask/src/components/shared/ApplicationBoard.tsx +++ b/packages/mask/src/components/shared/ApplicationBoard.tsx @@ -34,12 +34,21 @@ const useStyles = makeStyles()((theme) => { padding: theme.spacing(1, 0.25), display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', + overflowY: 'auto', gridTemplateRows: '100px', gridGap: theme.spacing(2), justifyContent: 'space-between', - height: 310, - '&::-webkit-scrollbar': { - display: 'none', + height: 340, + '::-webkit-scrollbar': { + backgroundColor: 'transparent', + width: 5, + }, + '::-webkit-scrollbar-thumb': { + borderRadius: '6px', + width: 5, + border: '2px solid rgba(0, 0, 0, 0)', + backgroundColor: theme.palette.mode === 'dark' ? 'rgba(250, 250, 250, 0.2)' : 'rgba(0, 0, 0, 0.2)', + backgroundClip: 'padding-box', }, [smallQuery]: { overflow: 'auto', diff --git a/packages/mask/src/plugins/Wallet/SNSAdaptor/WalletStatusDialog/index.tsx b/packages/mask/src/plugins/Wallet/SNSAdaptor/WalletStatusDialog/index.tsx index 868ee4810f4a..5369a8dc9170 100644 --- a/packages/mask/src/plugins/Wallet/SNSAdaptor/WalletStatusDialog/index.tsx +++ b/packages/mask/src/plugins/Wallet/SNSAdaptor/WalletStatusDialog/index.tsx @@ -14,7 +14,6 @@ import { ApplicationBoard } from '../../../../components/shared/ApplicationBoard const useStyles = makeStyles()((theme) => ({ content: { padding: theme.spacing(2.5), - marginBottom: theme.spacing(1.5), }, footer: { fontSize: 12, From 91cba677e608b4c65d4f77e27ed8a7d61996f4c0 Mon Sep 17 00:00:00 2001 From: UncleBill Date: Mon, 25 Apr 2022 14:54:08 +0800 Subject: [PATCH 09/23] fix(transation): cancelled detection (#6149) closes #MF-553 --- .../src/plugins/Wallet/services/transaction/helpers.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/packages/mask/src/plugins/Wallet/services/transaction/helpers.ts b/packages/mask/src/plugins/Wallet/services/transaction/helpers.ts index d7840b9331de..00c624ecec12 100644 --- a/packages/mask/src/plugins/Wallet/services/transaction/helpers.ts +++ b/packages/mask/src/plugins/Wallet/services/transaction/helpers.ts @@ -2,7 +2,6 @@ import { sha3, toHex } from 'web3-utils' import type { JsonRpcPayload } from 'web3-core-helpers' import type { Transaction, TransactionConfig, TransactionReceipt } from 'web3-core' import { - isSameAddress, TransactionState, TransactionStateType, TransactionStatusType, @@ -59,7 +58,6 @@ export function getReceiptStatus(receipt: TransactionReceipt | null) { const status = receipt.status as unknown as string if (receipt.status === false || ['0', '0x', '0x0'].includes(status)) return TransactionStatusType.FAILED if (receipt.status === true || ['1', '0x1'].includes(status)) { - if (isSameAddress(receipt.from, receipt.to)) return TransactionStatusType.CANCELLED return TransactionStatusType.SUCCEED } return TransactionStatusType.NOT_DEPEND @@ -87,12 +85,6 @@ export function getTransactionState(receipt: TransactionReceipt): TransactionSta receipt, error: new Error('Invalid transaction status.'), } - case TransactionStatusType.CANCELLED: - return { - type: TransactionStateType.FAILED, - receipt, - error: new Error('CANCELLED'), - } default: unreachable(status) } From 92ca6769f7b27f21c1362a415e5ec7df5d5f7169 Mon Sep 17 00:00:00 2001 From: zhouhanseng Date: Mon, 25 Apr 2022 15:05:29 +0800 Subject: [PATCH 10/23] fix: application board scroll bar --- .../CreateMaskWallet/components/Welcome/index.tsx | 1 - .../mask/src/components/shared/ApplicationBoard.tsx | 12 +++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/dashboard/src/pages/CreateMaskWallet/components/Welcome/index.tsx b/packages/dashboard/src/pages/CreateMaskWallet/components/Welcome/index.tsx index bb1065d382b4..b6f2a4d25c0f 100644 --- a/packages/dashboard/src/pages/CreateMaskWallet/components/Welcome/index.tsx +++ b/packages/dashboard/src/pages/CreateMaskWallet/components/Welcome/index.tsx @@ -83,7 +83,6 @@ const Welcome = memo(() => { } body::-webkit-scrollbar-thumb { border-radius: 4px; - } ` iframeDocument.head?.appendChild(style) diff --git a/packages/mask/src/components/shared/ApplicationBoard.tsx b/packages/mask/src/components/shared/ApplicationBoard.tsx index 6af53afcd706..2b6e0e20f57a 100644 --- a/packages/mask/src/components/shared/ApplicationBoard.tsx +++ b/packages/mask/src/components/shared/ApplicationBoard.tsx @@ -27,7 +27,7 @@ import { useMyPersonas } from '../DataSource/useMyPersonas' import { WalletMessages } from '../../plugins/Wallet/messages' import { PersonaContext } from '../../extension/popups/pages/Personas/hooks/usePersonaContext' -const useStyles = makeStyles()((theme) => { +const useStyles = makeStyles<{ shouldScroll: boolean }>()((theme, props) => { const smallQuery = `@media (max-width: ${theme.breakpoints.values.sm}px)` return { applicationWrapper: { @@ -35,18 +35,20 @@ const useStyles = makeStyles()((theme) => { display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', overflowY: 'auto', + overflowX: 'hidden', gridTemplateRows: '100px', gridGap: theme.spacing(2), justifyContent: 'space-between', height: 340, + width: props.shouldScroll ? 575 : 560, '::-webkit-scrollbar': { backgroundColor: 'transparent', - width: 5, + width: 20, }, '::-webkit-scrollbar-thumb': { - borderRadius: '6px', + borderRadius: '20px', width: 5, - border: '2px solid rgba(0, 0, 0, 0)', + border: '7px solid rgba(0, 0, 0, 0)', backgroundColor: theme.palette.mode === 'dark' ? 'rgba(250, 250, 250, 0.2)' : 'rgba(0, 0, 0, 0.2)', backgroundClip: 'padding-box', }, @@ -100,7 +102,6 @@ export function ApplicationBoard() { ) } function ApplicationBoardContent() { - const { classes } = useStyles() const theme = useTheme() const { t } = useI18N() const [openSettings, setOpenSettings] = useState(false) @@ -143,6 +144,7 @@ function ApplicationBoardContent() { [snsAdaptorPlugins, currentWeb3Network, chainId, account], ) const listedAppList = applicationList.filter((x) => !getUnlistedApp(x)) + const { classes } = useStyles({ shouldScroll: listedAppList.length > 12 }) return ( <>
From 30b28fd9da5ccfb02c7e5acbd67bba6b097255ee Mon Sep 17 00:00:00 2001 From: zhouhanseng Date: Mon, 25 Apr 2022 19:56:41 +0800 Subject: [PATCH 11/23] fix: tips entry no wallet connect required --- packages/mask/src/plugins/Tips/base.ts | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/packages/mask/src/plugins/Tips/base.ts b/packages/mask/src/plugins/Tips/base.ts index c055f214de2a..88de9a4c5c47 100644 --- a/packages/mask/src/plugins/Tips/base.ts +++ b/packages/mask/src/plugins/Tips/base.ts @@ -1,6 +1,4 @@ import { Plugin, PluginId } from '@masknet/plugin-infra' -import { NetworkPluginID } from '@masknet/plugin-infra/web3' -import { ChainId } from '@masknet/web3-shared-evm' import { languages } from './locales/languages' export const base: Plugin.Shared.Definition = { @@ -17,21 +15,7 @@ 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.Conflux, - ], - }, - }, + web3: {}, }, i18n: languages, } From 378c7ea6be10d7f0bd7b3d8516fa4cae24c942b6 Mon Sep 17 00:00:00 2001 From: Hom Date: Mon, 25 Apr 2022 20:59:36 +0800 Subject: [PATCH 12/23] fix: plugin switch not showing in timeline (#6158) (cherry picked from commit 5cfe26dc7440ad166572815ca9a2ac947c79694b) --- .../components/InjectedComponents/DisabledPluginSuggestion.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/mask/src/components/InjectedComponents/DisabledPluginSuggestion.tsx b/packages/mask/src/components/InjectedComponents/DisabledPluginSuggestion.tsx index 11ba18790aca..a018a42e6b65 100644 --- a/packages/mask/src/components/InjectedComponents/DisabledPluginSuggestion.tsx +++ b/packages/mask/src/components/InjectedComponents/DisabledPluginSuggestion.tsx @@ -60,6 +60,7 @@ export function PossiblePluginSuggestionUI(props: { plugins: Plugin.DeferredDefi <> {plugins.map((x) => ( Date: Mon, 25 Apr 2022 14:45:23 +0800 Subject: [PATCH 13/23] fix: cannot load vcent plugin --- packages/mask/src/plugins/VCent/SNSAdaptor/TweetDialog.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/mask/src/plugins/VCent/SNSAdaptor/TweetDialog.tsx b/packages/mask/src/plugins/VCent/SNSAdaptor/TweetDialog.tsx index e5d41cb662e7..4eb7e479e18f 100644 --- a/packages/mask/src/plugins/VCent/SNSAdaptor/TweetDialog.tsx +++ b/packages/mask/src/plugins/VCent/SNSAdaptor/TweetDialog.tsx @@ -8,6 +8,7 @@ import { VALUABLES_VCENT_URL } from '../constants' import { useAsync } from 'react-use' import { PluginVCentRPC } from '../messages' import { useI18N } from '../../../utils' +import { usePluginWrapper } from '@masknet/plugin-infra/content-script' const useStyle = makeStyles()((theme) => ({ root: { @@ -78,7 +79,7 @@ export default function VCentDialog({ tweetAddress }: { tweetAddress: string }) const { t } = useI18N() const { value: tweets } = useAsync(() => PluginVCentRPC.getTweetData(tweetAddress), [tweetAddress]) const tweet = first(tweets) - + usePluginWrapper(tweet?.type === 'Offer') // only offer tweets if (tweet?.type !== 'Offer') return null From b040733d55aadf7a9eb6578a82df2c87ca2d05cb Mon Sep 17 00:00:00 2001 From: nuanyang233 Date: Mon, 25 Apr 2022 21:57:59 +0800 Subject: [PATCH 14/23] fix: add loading and emtpy placeholder at savings plugin (#6152) * fix: add loading and emtpy placeholder at savings plugin * fix: bugfix --- packages/icons/general/CircleLoading.tsx | 8 +- packages/icons/general/Direct.tsx | 19 +++ packages/icons/general/index.ts | 1 + packages/mask/shared-ui/locales/en-US.json | 1 - packages/mask/shared-ui/locales/qya-AA.json | 1 - packages/mask/shared-ui/locales/zh-CN.json | 1 - .../Savings/SNSAdaptor/SavingsDialog.tsx | 50 +++--- .../Savings/SNSAdaptor/SavingsTable.tsx | 147 +++++++++++------- 8 files changed, 133 insertions(+), 95 deletions(-) create mode 100644 packages/icons/general/Direct.tsx diff --git a/packages/icons/general/CircleLoading.tsx b/packages/icons/general/CircleLoading.tsx index 5f74f5282038..1ea37627a945 100644 --- a/packages/icons/general/CircleLoading.tsx +++ b/packages/icons/general/CircleLoading.tsx @@ -3,16 +3,12 @@ import type { SvgIcon } from '@mui/material' export const CircleLoadingIcon: typeof SvgIcon = createIcon( 'CircleLoadingIcon', - + - + , '0 0 36 36', ) diff --git a/packages/icons/general/Direct.tsx b/packages/icons/general/Direct.tsx new file mode 100644 index 000000000000..506d05e8ea5a --- /dev/null +++ b/packages/icons/general/Direct.tsx @@ -0,0 +1,19 @@ +import { createIcon } from '../utils' +import type { SvgIcon } from '@mui/material' + +export const DirectIcon: typeof SvgIcon = createIcon( + 'DirectIcon', + + + + , + '0 0 34 34', +) diff --git a/packages/icons/general/index.ts b/packages/icons/general/index.ts index fd2d27ebcc9c..cd2c70610e69 100644 --- a/packages/icons/general/index.ts +++ b/packages/icons/general/index.ts @@ -112,3 +112,4 @@ export * from './MindsRound' export * from './CircleLoading' export * from './AddUser' export * from './PopupRestore' +export * from './Direct' diff --git a/packages/mask/shared-ui/locales/en-US.json b/packages/mask/shared-ui/locales/en-US.json index 267f8955f62b..c1e032da924c 100644 --- a/packages/mask/shared-ui/locales/en-US.json +++ b/packages/mask/shared-ui/locales/en-US.json @@ -431,7 +431,6 @@ "plugin_trader_price_updated": "Price Updated", "plugin_savings": "Savings", "plugin_savings_asset": "Asset", - "plugin_no_protocol_available": "No savings protocols available on this network", "plugin_savings_apr": "APR", "plugin_savings_wallet": "Wallet", "plugin_savings_operation": "Operation", diff --git a/packages/mask/shared-ui/locales/qya-AA.json b/packages/mask/shared-ui/locales/qya-AA.json index 184e070b1d4d..e553ae559f6e 100644 --- a/packages/mask/shared-ui/locales/qya-AA.json +++ b/packages/mask/shared-ui/locales/qya-AA.json @@ -430,7 +430,6 @@ "plugin_trader_price_updated": "crwdns10237:0crwdne10237:0", "plugin_savings": "crwdns13250:0crwdne13250:0", "plugin_savings_asset": "crwdns14804:0crwdne14804:0", - "plugin_no_protocol_available": "crwdns13254:0crwdne13254:0", "plugin_savings_apr": "crwdns13256:0crwdne13256:0", "plugin_savings_wallet": "crwdns13258:0crwdne13258:0", "plugin_savings_operation": "crwdns13260:0crwdne13260:0", diff --git a/packages/mask/shared-ui/locales/zh-CN.json b/packages/mask/shared-ui/locales/zh-CN.json index 091bf5aa756e..0e3e1a234dfe 100644 --- a/packages/mask/shared-ui/locales/zh-CN.json +++ b/packages/mask/shared-ui/locales/zh-CN.json @@ -393,7 +393,6 @@ "plugin_trader_data_source": "数据源", "plugin_trader_price_updated": "价格已更新", "plugin_savings": "储蓄", - "plugin_no_protocol_available": "储蓄功能尚未在此网络支持。", "plugin_savings_wallet": "钱包", "plugin_savings_operation": "操作", "plugin_savings_amount": "数额", diff --git a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsDialog.tsx b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsDialog.tsx index e6e4c606c614..797928a50a45 100644 --- a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsDialog.tsx +++ b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsDialog.tsx @@ -1,6 +1,6 @@ import { useMemo, useState } from 'react' import { useAsync, useUpdateEffect } from 'react-use' -import { Typography, DialogContent } from '@mui/material' +import { DialogContent } from '@mui/material' import { isDashboardPage, EMPTY_LIST } from '@masknet/shared-base' import { FolderTabPanel, FolderTabs } from '@masknet/theme' import { @@ -102,7 +102,7 @@ export function SavingsDialog({ open, onClose }: SavingsDialogProps) { ...LDO_PAIRS.filter((x) => x[0].chainId === chainId).map((pair) => new LidoProtocol(pair)), ...splitToPair(detailedAaveTokens).map((pair: any) => new AAVEProtocol(pair)), ], - [chainId, detailedAaveTokens], + [chainId, detailedAaveTokens, tab], ) useUpdateEffect(() => { @@ -142,32 +142,26 @@ export function SavingsDialog({ open, onClose }: SavingsDialogProps) { />
- {protocols.length === 0 ? ( - - {t('plugin_no_protocol_available')} - - ) : ( - - - - - - !x.balance.isZero())} - setTab={setTab} - setSelectedProtocol={setSelectedProtocol} - /> - - - )} + + + + + + + +
)} diff --git a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsTable.tsx b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsTable.tsx index a47db0bcf228..59a2ae0c39d3 100644 --- a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsTable.tsx +++ b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsTable.tsx @@ -1,12 +1,13 @@ import { useAsync } from 'react-use' import { makeStyles } from '@masknet/theme' -import { Box, Button, Grid, Typography, CircularProgress } from '@mui/material' +import { Box, Button, Grid, Typography } from '@mui/material' import { FormattedBalance, TokenIcon } from '@masknet/shared' import { isZero, rightShift } from '@masknet/web3-shared-base' import { ChainId, formatBalance, isSameAddress, useAccount, useAssets, useWeb3 } from '@masknet/web3-shared-evm' import { ProviderIconURLs } from './IconURL' import { useI18N } from '../../../utils' import { SavingsProtocol, TabType } from '../types' +import { CircleLoadingIcon, DirectIcon } from '@masknet/icons' const useStyles = makeStyles()((theme, props) => ({ containerWrap: { @@ -58,13 +59,36 @@ const useStyles = makeStyles()((theme, props) => ({ right: '-5px', }, protocolLabel: {}, - loading: { + placeholder: { display: 'flex', + flexDirection: 'column', justifyContent: 'center', alignItems: 'center', minHeight: 300, width: '100%', }, + loading: { + fontSize: 14, + color: theme.palette.text.primary, + lineHeight: '18px', + marginTop: 12, + }, + animated: { + fontSize: 36, + '@keyframes loadingAnimation': { + '0%': { + transform: 'rotate(0deg)', + }, + '100%': { + transform: 'rotate(360deg)', + }, + }, + animation: 'loadingAnimation 1s linear infinite', + }, + direct: { + fill: theme.palette.secondaryDivider, + fontSize: 36, + }, })) export interface SavingsTableProps { @@ -118,67 +142,74 @@ export function SavingsTable({ chainId, tab, protocols, setTab, setSelectedProto {loading || getAssetsLoading ? ( -
- +
+ + {t('popups_loading')}
- ) : ( + ) : protocols.length ? (
- {protocols.map((protocol, index) => ( - - -
- - -
-
- - {protocol.bareToken.symbol} + {protocols + .filter((x) => !x.balance.isZero()) + .map((protocol, index) => ( + + +
+ + +
+
+ + {protocol.bareToken.symbol} + +
+
+ {tab === TabType.Deposit ? ( + + {protocol.apr}% + + ) : null} + + + + isSameAddress(x.token.address, protocol.bareToken.address), + )?.balance + : protocol.balance + } + decimals={protocol.bareToken.decimals} + significant={6} + minimumBalance={rightShift(10, protocol.bareToken.decimals - 6)} + formatter={formatBalance} + /> -
-
- {tab === TabType.Deposit ? ( - - {protocol.apr}% - ) : null} - - - - isSameAddress(x.token.address, protocol.bareToken.address), - )?.balance - : protocol.balance - } - decimals={protocol.bareToken.decimals} - significant={6} - minimumBalance={rightShift(10, protocol.bareToken.decimals - 6)} - formatter={formatBalance} - /> - - - - + + + -
- ))} + ))} +
+ ) : ( +
+
)} From 8ca9cd9f50bc50b8958dfc0a242d042e347b74c4 Mon Sep 17 00:00:00 2001 From: zhouhanseng Date: Tue, 26 Apr 2022 11:54:42 +0800 Subject: [PATCH 15/23] fix: swap icon --- packages/icons/general/Swap.tsx | 15 +++++++++++---- packages/icons/general/SwapColorfulIcon.tsx | 14 ++++++++++++++ packages/icons/general/index.ts | 1 + .../mask/src/plugins/Trader/SNSAdaptor/index.tsx | 4 ++-- 4 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 packages/icons/general/SwapColorfulIcon.tsx diff --git a/packages/icons/general/Swap.tsx b/packages/icons/general/Swap.tsx index 97fb772fc770..701a709ff660 100644 --- a/packages/icons/general/Swap.tsx +++ b/packages/icons/general/Swap.tsx @@ -4,11 +4,18 @@ import type { SvgIcon } from '@mui/material' export const SwapIcon: typeof SvgIcon = createIcon( 'SwapIcon', - + , - '0 0 37 36', + '0 0 16 16', ) diff --git a/packages/icons/general/SwapColorfulIcon.tsx b/packages/icons/general/SwapColorfulIcon.tsx new file mode 100644 index 000000000000..eda80c5f5f95 --- /dev/null +++ b/packages/icons/general/SwapColorfulIcon.tsx @@ -0,0 +1,14 @@ +import { createIcon } from '../utils' +import type { SvgIcon } from '@mui/material' + +export const SwapColorfulIcon: typeof SvgIcon = createIcon( + 'SwapColorfulIcon', + + + + , + '0 0 37 36', +) diff --git a/packages/icons/general/index.ts b/packages/icons/general/index.ts index cd2c70610e69..11dccb0a5fa0 100644 --- a/packages/icons/general/index.ts +++ b/packages/icons/general/index.ts @@ -7,6 +7,7 @@ export * from './Airdrop' export * from './Send' export * from './Card' export * from './Swap' +export * from './SwapColorfulIcon' export * from './Download' export * from './Link' export * from './Author' diff --git a/packages/mask/src/plugins/Trader/SNSAdaptor/index.tsx b/packages/mask/src/plugins/Trader/SNSAdaptor/index.tsx index 8b6a6bb5d173..9f9b676b6bc7 100644 --- a/packages/mask/src/plugins/Trader/SNSAdaptor/index.tsx +++ b/packages/mask/src/plugins/Trader/SNSAdaptor/index.tsx @@ -7,7 +7,7 @@ import { Trans } from 'react-i18next' import { TagInspector } from './trending/TagInspector' import { enhanceTag } from './cashTag' import { ApplicationEntry } from '@masknet/shared' -import { SwapIcon } from '@masknet/icons' +import { SwapColorfulIcon } from '@masknet/icons' import { PluginTraderMessages } from '../messages' const sns: Plugin.SNSAdaptor.Definition = { @@ -25,7 +25,7 @@ const sns: Plugin.SNSAdaptor.Definition = { enhanceTag, ApplicationEntries: [ (() => { - const icon = + const icon = const name = return { ApplicationEntryID: base.ID, From e78d7b11da4ed744150eacffac442d05012c4259 Mon Sep 17 00:00:00 2001 From: zhouhanseng Date: Tue, 26 Apr 2022 12:50:09 +0800 Subject: [PATCH 16/23] chore: remove empty object define --- packages/mask/src/plugins/Tips/base.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/mask/src/plugins/Tips/base.ts b/packages/mask/src/plugins/Tips/base.ts index 88de9a4c5c47..b8acc7702403 100644 --- a/packages/mask/src/plugins/Tips/base.ts +++ b/packages/mask/src/plugins/Tips/base.ts @@ -15,7 +15,6 @@ export const base: Plugin.Shared.Definition = { networks: {}, }, target: 'stable', - web3: {}, }, i18n: languages, } From 1e126f4e917ccf475342569bed1d8bd3e5b07fbe Mon Sep 17 00:00:00 2001 From: UncleBill Date: Tue, 26 Apr 2022 17:34:50 +0800 Subject: [PATCH 17/23] fix: ui issues of pending transactions (#6162) --- .../shared/WalletStatusBox/TransactionList.tsx | 10 ++++++++-- .../shared/WalletStatusBox/usePendingTransactions.tsx | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/mask/src/components/shared/WalletStatusBox/TransactionList.tsx b/packages/mask/src/components/shared/WalletStatusBox/TransactionList.tsx index 9b82106b994d..cd328e98de8d 100644 --- a/packages/mask/src/components/shared/WalletStatusBox/TransactionList.tsx +++ b/packages/mask/src/components/shared/WalletStatusBox/TransactionList.tsx @@ -46,6 +46,9 @@ const useStyles = makeStyles()((theme) => ({ overflow: 'hidden', whiteSpace: 'nowrap', }, + timestamp: { + fontSize: 12, + }, cell: { fontSize: 14, display: 'flex', @@ -63,6 +66,9 @@ const useStyles = makeStyles()((theme) => ({ height: 12, marginLeft: theme.spacing(0.5), }, + clear: { + fontSize: 14, + }, })) const statusTextColorMap: Record = { @@ -141,7 +147,7 @@ const Transaction: FC = ({ chainId, transaction: tx, onClear = component="strong"> {functionName} - + {format(tx.at, 'yyyy.MM.dd hh:mm')} @@ -167,7 +173,7 @@ const Transaction: FC = ({ chainId, transaction: tx, onClear = {txStatus === TransactionStatusType.NOT_DEPEND ? ( - ) : null} diff --git a/packages/mask/src/components/shared/WalletStatusBox/usePendingTransactions.tsx b/packages/mask/src/components/shared/WalletStatusBox/usePendingTransactions.tsx index 2c1ac060c7c1..5d55a6d8deaa 100644 --- a/packages/mask/src/components/shared/WalletStatusBox/usePendingTransactions.tsx +++ b/packages/mask/src/components/shared/WalletStatusBox/usePendingTransactions.tsx @@ -55,7 +55,7 @@ export function usePendingTransactions() { const frozenTxes = useRef([]) const [meltedTxHashes, setMeltedTxHashes] = useState([]) useEffect(() => { - frozenTxes.current = pendingTransactions.slice(0, 2) + frozenTxes.current = pendingTransactions.slice(0, 5) setMeltedTxHashes([]) }, [showRecentTransactions]) const clearRecentTxes = useClearRecentTransactions() From adbb9db1ebc5e5cdd0466ab470ff07217090f9ff Mon Sep 17 00:00:00 2001 From: BillyS Date: Tue, 26 Apr 2022 11:00:39 +0800 Subject: [PATCH 18/23] fix: hotfix release tips issues (#6157) * fix: connect wallet show solana flow * fix: fix * fix: wont disable && kv prod base url * fix: types * fix: clean --- .../components/shared/VerifyWallet/Steps.tsx | 12 +-------- .../pages/Personas/VerifyWallet/index.tsx | 1 + .../Tips/SNSAdaptor/TipsEntranceDialog.tsx | 26 ++++++++----------- .../Tips/SNSAdaptor/bodyViews/Setting.tsx | 2 +- .../Tips/SNSAdaptor/bodyViews/Wallets.tsx | 2 +- .../components/DisconnectDialog.tsx | 2 +- .../SNSAdaptor/SelectProviderDialog/index.tsx | 4 +-- .../web3-providers/src/NextID/constants.ts | 2 +- 8 files changed, 19 insertions(+), 32 deletions(-) diff --git a/packages/mask/src/components/shared/VerifyWallet/Steps.tsx b/packages/mask/src/components/shared/VerifyWallet/Steps.tsx index 3d2ffb0db91e..eca3dae53f21 100644 --- a/packages/mask/src/components/shared/VerifyWallet/Steps.tsx +++ b/packages/mask/src/components/shared/VerifyWallet/Steps.tsx @@ -11,7 +11,6 @@ import { } from './constants' import { ImageIcon } from '@masknet/shared' import { Button, Typography } from '@mui/material' -import { useNavigate } from 'react-router-dom' import classNames from 'classnames' import { useEffect } from 'react' import { useI18N } from '../../../utils' @@ -109,7 +108,6 @@ interface StepsProps { export function Steps(props: StepsProps) { const { t } = useI18N() const { classes } = useStyles() - const navigate = useNavigate() const { changeWallet, nickname, @@ -151,14 +149,6 @@ export function Steps(props: StepsProps) { } }, [disableConfirm]) - const onCancel = () => { - if (notInPop && onCustomCancel !== undefined) { - onCustomCancel() - return - } - navigate(-1) - } - return (
@@ -204,7 +194,7 @@ export function Steps(props: StepsProps) { size="large" fullWidth color="primary" - onClick={onCancel}> + onClick={onCustomCancel}> {t('cancel')} { changeWallet={changeWallet} onConfirm={handleConfirm} confirmLoading={confirmLoading} + onCustomCancel={() => navigate(-1)} />
) diff --git a/packages/mask/src/plugins/Tips/SNSAdaptor/TipsEntranceDialog.tsx b/packages/mask/src/plugins/Tips/SNSAdaptor/TipsEntranceDialog.tsx index 5ff2f176e802..2fe304b0bbdd 100644 --- a/packages/mask/src/plugins/Tips/SNSAdaptor/TipsEntranceDialog.tsx +++ b/packages/mask/src/plugins/Tips/SNSAdaptor/TipsEntranceDialog.tsx @@ -1,5 +1,3 @@ -import { PluginId } from '@masknet/plugin-infra' -import { useActivatedPlugin } from '@masknet/plugin-infra/content-script' import { NetworkPluginID } from '@masknet/plugin-infra/web3' import { WalletMessages } from '@masknet/plugin-wallet' import { InjectedDialog, LoadingAnimation } from '@masknet/shared' @@ -102,10 +100,7 @@ export function TipsEntranceDialog({ open, onClose }: TipsEntranceDialogProps) { const [hasChanged, setHasChanged] = useState(false) const [rawPatchData, setRawPatchData] = useState([]) const [rawWalletList, setRawWalletList] = useState([]) - const plugin = useActivatedPlugin(PluginId.Tips, 'any') - const supportedNetworks = useSupportedNetworks( - Object.keys(plugin?.enableRequirement.web3 ?? {}) as NetworkPluginID[], - ) + const supportedNetworks = useSupportedNetworks([NetworkPluginID.PLUGIN_EVM]) const { showSnackbar } = useCustomSnackbar() const account = useAccount() @@ -176,15 +171,14 @@ export function TipsEntranceDialog({ open, onClose }: TipsEntranceDialogProps) { ) if (!signResult) throw new Error('sign error') await setKvPatchData(payload.val, signResult.signature.signature, rawPatchData) - showSnackbar('Persona signed successfully.', { + showSnackbar(t('plugin_tips_persona_sign_success'), { variant: 'success', message: nowTime, }) - retryProof() retryKv() return true } catch (error) { - showSnackbar('Persona Signature failed.', { + showSnackbar(t('plugin_tips_persona_sign_error'), { variant: 'error', message: nowTime, }) @@ -239,18 +233,20 @@ export function TipsEntranceDialog({ open, onClose }: TipsEntranceDialogProps) { result.createdAt, { signature: signature.signature.signature }, ) - retryProof() - retryKv() - return true + showSnackbar(t('plugin_tips_persona_sign_success'), { + variant: 'success', + message: nowTime, + }) } catch (error) { - showSnackbar('Persona Signature failed.', { + showSnackbar(t('plugin_tips_persona_sign_error'), { variant: 'error', message: nowTime, }) - return false + } finally { + retryProof() } }, - [currentPersona], + [currentPersona, proofRes], ) return ( diff --git a/packages/mask/src/plugins/Tips/SNSAdaptor/bodyViews/Setting.tsx b/packages/mask/src/plugins/Tips/SNSAdaptor/bodyViews/Setting.tsx index 6ecc016cdc5a..4d34e01a91fb 100644 --- a/packages/mask/src/plugins/Tips/SNSAdaptor/bodyViews/Setting.tsx +++ b/packages/mask/src/plugins/Tips/SNSAdaptor/bodyViews/Setting.tsx @@ -28,7 +28,7 @@ const useStyles = makeStyles()((theme) => ({ interface SettingPageProp { wallets: BindingProof[] - onSwitchChange: (idx: number, v: boolean) => void + onSwitchChange(idx: number, v: boolean): void } const SettingPage = memo(({ wallets, onSwitchChange }: SettingPageProp) => { diff --git a/packages/mask/src/plugins/Tips/SNSAdaptor/bodyViews/Wallets.tsx b/packages/mask/src/plugins/Tips/SNSAdaptor/bodyViews/Wallets.tsx index 5eda05aada19..06a21b043dfd 100644 --- a/packages/mask/src/plugins/Tips/SNSAdaptor/bodyViews/Wallets.tsx +++ b/packages/mask/src/plugins/Tips/SNSAdaptor/bodyViews/Wallets.tsx @@ -26,7 +26,7 @@ const useStyles = makeStyles()((theme) => ({ interface WalletsPageProp { wallets: BindingProof[] releaseLoading: boolean - onRelease: (wallet?: BindingProof) => Promise + onRelease(wallet?: BindingProof): Promise personaName: string | undefined } diff --git a/packages/mask/src/plugins/Tips/SNSAdaptor/components/DisconnectDialog.tsx b/packages/mask/src/plugins/Tips/SNSAdaptor/components/DisconnectDialog.tsx index 0810d03315de..7da9500f0c77 100644 --- a/packages/mask/src/plugins/Tips/SNSAdaptor/components/DisconnectDialog.tsx +++ b/packages/mask/src/plugins/Tips/SNSAdaptor/components/DisconnectDialog.tsx @@ -71,7 +71,7 @@ const useStyles = makeStyles()((theme) => ({ export interface DisconnectWalletDialogProps extends DialogProps { confirmLoading: boolean - onConfirmDisconnect: () => Promise + onConfirmDisconnect: () => Promise address?: string onClose: () => void personaName: string | undefined diff --git a/packages/mask/src/plugins/Wallet/SNSAdaptor/SelectProviderDialog/index.tsx b/packages/mask/src/plugins/Wallet/SNSAdaptor/SelectProviderDialog/index.tsx index e2dab72d2ff7..c55166e43d31 100644 --- a/packages/mask/src/plugins/Wallet/SNSAdaptor/SelectProviderDialog/index.tsx +++ b/packages/mask/src/plugins/Wallet/SNSAdaptor/SelectProviderDialog/index.tsx @@ -35,14 +35,14 @@ export interface SelectProviderDialogProps {} export function SelectProviderDialog(props: SelectProviderDialogProps) { const { t } = useI18N() const { classes } = useStyles() - const [underPluginID, setUnderPluginID] = useState() + const [underPluginID, setUnderPluginID] = useState() // #region remote controlled dialog logic // #endregion const { open, closeDialog } = useRemoteControlledDialog( WalletMessages.events.selectProviderDialogUpdated, (ev?) => { if (!ev?.open) return - setUnderPluginID(ev?.pluginID ?? NetworkPluginID.PLUGIN_EVM) + setUnderPluginID(ev?.pluginID) }, ) // #region native app diff --git a/packages/web3-providers/src/NextID/constants.ts b/packages/web3-providers/src/NextID/constants.ts index ccaf51f87774..ce365d697888 100644 --- a/packages/web3-providers/src/NextID/constants.ts +++ b/packages/web3-providers/src/NextID/constants.ts @@ -1,5 +1,5 @@ export const MASK_STORAGE_KEY = 'com.mask.plugin' export const KV_BASE_URL_DEV = 'https://kv-service.nextnext.id' -export const KV_BASE_URL_PROD = '' +export const KV_BASE_URL_PROD = 'https://kv-service.next.id' export const PROOF_BASE_URL_DEV = 'https://proof-service.nextnext.id/' export const PROOF_BASE_URL_PROD = 'https://proof-service.next.id/' From da1afddbab079e4d6a4881b99e976f8ab9f51f29 Mon Sep 17 00:00:00 2001 From: Lantt Date: Tue, 26 Apr 2022 18:30:55 +0800 Subject: [PATCH 19/23] fix: remove duplicate profile in linked profile when restore (#6160) * fix: remove duplicate profile in linked profile when retore * fix: remove duplicate profile in linked profile when retore --- .../mask/background/database/persona/web.ts | 36 +++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/packages/mask/background/database/persona/web.ts b/packages/mask/background/database/persona/web.ts index ba1a0b7ca297..a2fa40905202 100644 --- a/packages/mask/background/database/persona/web.ts +++ b/packages/mask/background/database/persona/web.ts @@ -452,11 +452,43 @@ const fuse = new Fuse([] as ProfileRecord[], { */ export async function updateProfileDB( updating: Partial & Pick, - t: ProfileTransaction<'readwrite'>, + t: FullPersonaDBTransaction<'readwrite'>, ): Promise { const old = await t.objectStore('profiles').get(updating.identifier.toText()) if (!old) throw new Error('Updating a non exists record') + if (old.linkedPersona && updating.linkedPersona && old.linkedPersona !== updating.linkedPersona) { + const oldIdentifier = Identifier.fromString(old.identifier, ProfileIdentifier).unwrap() + const oldLinkedPersona = await queryPersonaByProfileDB(oldIdentifier, t) + + if (oldLinkedPersona) { + oldLinkedPersona.linkedProfiles.delete(oldIdentifier) + await updatePersonaDB( + oldLinkedPersona, + { + linkedProfiles: 'replace', + explicitUndefinedField: 'ignore', + }, + t, + ) + } + } + + if (updating.linkedPersona && old.linkedPersona !== updating.linkedPersona) { + const linkedPersona = await queryPersonaDB(updating.linkedPersona, t) + if (linkedPersona) { + linkedPersona.linkedProfiles.set(updating.identifier, { connectionConfirmState: 'confirmed' }) + await updatePersonaDB( + linkedPersona, + { + linkedProfiles: 'replace', + explicitUndefinedField: 'ignore', + }, + t, + ) + } + } + const nextRecord: ProfileRecordDB = profileToDB({ ...profileOutDB(old), ...updating, @@ -464,7 +496,7 @@ export async function updateProfileDB( await t.objectStore('profiles').put(nextRecord) MaskMessages.events.profilesChanged.sendToAll([{ reason: 'update', of: updating.identifier }]) } -export async function createOrUpdateProfileDB(rec: ProfileRecord, t: ProfileTransaction<'readwrite'>) { +export async function createOrUpdateProfileDB(rec: ProfileRecord, t: FullPersonaDBTransaction<'readwrite'>) { if (await queryProfileDB(rec.identifier, t)) return updateProfileDB(rec, t) else return createProfileDB(rec, t) } From 5a9ed84b86e9fb219e433e528ea441de68bb9fb7 Mon Sep 17 00:00:00 2001 From: Lantt Date: Tue, 26 Apr 2022 19:51:29 +0800 Subject: [PATCH 20/23] fix: should show tip on other chain --- .../pages/Wallets/components/FungibleTokenTableRow/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/dashboard/src/pages/Wallets/components/FungibleTokenTableRow/index.tsx b/packages/dashboard/src/pages/Wallets/components/FungibleTokenTableRow/index.tsx index 91dad838d11a..90edd2545002 100644 --- a/packages/dashboard/src/pages/Wallets/components/FungibleTokenTableRow/index.tsx +++ b/packages/dashboard/src/pages/Wallets/components/FungibleTokenTableRow/index.tsx @@ -152,7 +152,7 @@ export const FungibleTokenTableRow = memo(({ asset, onSend, } placement="top" From ea4a8026b211b9127a969842289c2b9d4e2bc42b Mon Sep 17 00:00:00 2001 From: nuanyang233 Date: Tue, 26 Apr 2022 20:33:30 +0800 Subject: [PATCH 21/23] fix: bugfix for NFT description --- .../Wallet/ContractInteraction/index.tsx | 19 ++++++++++++++----- .../TransactionDescription.tsx | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/packages/mask/src/extension/popups/pages/Wallet/ContractInteraction/index.tsx b/packages/mask/src/extension/popups/pages/Wallet/ContractInteraction/index.tsx index 7a17f025d57e..119e6d2836a0 100644 --- a/packages/mask/src/extension/popups/pages/Wallet/ContractInteraction/index.tsx +++ b/packages/mask/src/extension/popups/pages/Wallet/ContractInteraction/index.tsx @@ -1,10 +1,11 @@ import { memo, useMemo, useState } from 'react' import { useAsync, useAsyncFn, useUpdateEffect } from 'react-use' -import { useNavigate, useLocation } from 'react-router-dom' +import { useLocation, useNavigate } from 'react-router-dom' import { makeStyles } from '@masknet/theme' import { useUnconfirmedRequest } from '../hooks/useUnConfirmedRequest' import { EthereumRpcType, + EthereumTokenType, formatBalance, formatCurrency, formatGweiToWei, @@ -13,6 +14,7 @@ import { isEIP1559Supported, useChainId, useERC20TokenDetailed, + useEthereumTokenType, useNativeTokenDetailed, useNetworkType, } from '@masknet/web3-shared-evm' @@ -29,7 +31,7 @@ import { useNativeTokenPrice, useTokenPrice } from '../../../../../plugins/Walle import { LoadingPlaceholder } from '../../../components/LoadingPlaceholder' import { toHex } from 'web3-utils' import { NetworkPluginID, useReverseAddress, useWeb3State } from '@masknet/plugin-infra/web3' -import { isGreaterThan, leftShift, pow10 } from '@masknet/web3-shared-base' +import { isGreaterThan, leftShift, pow10, ZERO } from '@masknet/web3-shared-base' import { CopyIconButton } from '../../../components/CopyIconButton' import { useTitle } from '../../../hook/useTitle' @@ -159,6 +161,7 @@ const ContractInteraction = memo(() => { maxPriorityFeePerGas, amount, isNativeTokenInteraction, + contractAddress, } = useMemo(() => { const type = request?.computedPayload?.type if (!type) return {} @@ -190,6 +193,7 @@ const ContractInteraction = memo(() => { maxFeePerGas: request.computedPayload._tx.maxFeePerGas, maxPriorityFeePerGas: request.computedPayload._tx.maxPriorityFeePerGas, amount: request.computedPayload.parameters?.value, + contractAddress: request.computedPayload._tx.to, } default: return { @@ -231,6 +235,8 @@ const ContractInteraction = memo(() => { } }, [request, t]) + const contractType = useEthereumTokenType(contractAddress) + // token detailed const { value: nativeToken } = useNativeTokenDetailed() const { value: token } = useERC20TokenDetailed(isNativeTokenInteraction ? '' : tokenAddress) @@ -289,9 +295,12 @@ const ContractInteraction = memo(() => { // token estimated value const tokenPrice = useTokenPrice(chainId, !isNativeTokenInteraction ? token?.address : undefined) const nativeTokenPrice = useNativeTokenPrice(nativeToken?.chainId) - const tokenValueUSD = leftShift(tokenAmount, tokenDecimals) - .times((!isNativeTokenInteraction ? tokenPrice : nativeTokenPrice) ?? 0) - .toString() + const tokenValueUSD = + contractType && [EthereumTokenType.ERC721, EthereumTokenType.ERC1155].includes(contractType) + ? ZERO + : leftShift(tokenAmount, tokenDecimals) + .times((!isNativeTokenInteraction ? tokenPrice : nativeTokenPrice) ?? 0) + .toString() const totalUSD = new BigNumber(formatWeiToEther(gasFee)).times(nativeTokenPrice).plus(tokenValueUSD).toString() // diff --git a/packages/mask/src/plugins/Wallet/SNSAdaptor/WalletStatusDialog/TransactionDescription.tsx b/packages/mask/src/plugins/Wallet/SNSAdaptor/WalletStatusDialog/TransactionDescription.tsx index b6dd022a1c9d..876f383f8569 100644 --- a/packages/mask/src/plugins/Wallet/SNSAdaptor/WalletStatusDialog/TransactionDescription.tsx +++ b/packages/mask/src/plugins/Wallet/SNSAdaptor/WalletStatusDialog/TransactionDescription.tsx @@ -21,7 +21,7 @@ function getTokenAmountDescription(amount = '0', tokenDetailed?: FungibleTokenDe ? formatBalance(amount, tokenDetailed?.decimals ?? 0, 4) : 'infinite' const token = tokenDetailed?.symbol?.trim() - return `${symbol}${value} ${token}` + return `${symbol}${value} ${token ?? ''}` } function getTransactionDescription( From 361375e7ba167df510ee6d8d4cbd46593259e205 Mon Sep 17 00:00:00 2001 From: lelenei <72531217+lelenei@users.noreply.github.com> Date: Wed, 27 Apr 2022 01:02:06 +0800 Subject: [PATCH 22/23] fix(ins): keep refreshing the web3 page (#6165) --- .../components/InjectedComponents/ProfileTabContent.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx index cfe42258a49b..e2943e969864 100644 --- a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx +++ b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx @@ -103,19 +103,19 @@ export function ProfileTabContent(props: ProfileTabContentProps) { useUpdateEffect(() => { setSelectedTab(undefined) - }, [identity.identifier]) + }, [identity.identifier.userId]) useEffect(() => { return MaskMessages.events.profileTabHidden.on((data) => { if (data.hidden) setHidden(data.hidden) }) - }, [identity]) + }, [identity.identifier.userId]) useEffect(() => { return MaskMessages.events.profileTabUpdated.on((data) => { setHidden(!data.show) }) - }, [identity]) + }, [identity.identifier.userId]) const ContentComponent = useMemo(() => { const tabId = @@ -123,7 +123,7 @@ export function ProfileTabContent(props: ProfileTabContentProps) { ? displayPlugins?.find((tab) => tab?.pluginID === PluginId.NextID)?.ID : selectedTabId return getTabContent(tabId ?? '') - }, [selectedTabId, identity.identifier.userId, tabs]) + }, [selectedTabId, identity.identifier.userId]) if (hidden) return null From e3435110e171f4fec923a6fc873a6bd4562f71b2 Mon Sep 17 00:00:00 2001 From: Lantt Date: Wed, 27 Apr 2022 17:40:36 +0800 Subject: [PATCH 23/23] fix: merge --- .../mask/background/database/persona/web.ts | 32 ------------------- .../InjectedComponents/ProfileTabContent.tsx | 8 ++--- 2 files changed, 4 insertions(+), 36 deletions(-) diff --git a/packages/mask/background/database/persona/web.ts b/packages/mask/background/database/persona/web.ts index dcb3b1182c14..e686637f6e72 100644 --- a/packages/mask/background/database/persona/web.ts +++ b/packages/mask/background/database/persona/web.ts @@ -494,38 +494,6 @@ export async function updateProfileDB( } } - if (old.linkedPersona && updating.linkedPersona && old.linkedPersona !== updating.linkedPersona) { - const oldIdentifier = Identifier.fromString(old.identifier, ProfileIdentifier).unwrap() - const oldLinkedPersona = await queryPersonaByProfileDB(oldIdentifier, t) - - if (oldLinkedPersona) { - oldLinkedPersona.linkedProfiles.delete(oldIdentifier) - await updatePersonaDB( - oldLinkedPersona, - { - linkedProfiles: 'replace', - explicitUndefinedField: 'ignore', - }, - t, - ) - } - } - - if (updating.linkedPersona && old.linkedPersona !== updating.linkedPersona) { - const linkedPersona = await queryPersonaDB(updating.linkedPersona, t) - if (linkedPersona) { - linkedPersona.linkedProfiles.set(updating.identifier, { connectionConfirmState: 'confirmed' }) - await updatePersonaDB( - linkedPersona, - { - linkedProfiles: 'replace', - explicitUndefinedField: 'ignore', - }, - t, - ) - } - } - const nextRecord: ProfileRecordDB = profileToDB({ ...profileOutDB(old), ...updating, diff --git a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx index a2e497e5cbb0..f99b8354c404 100644 --- a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx +++ b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx @@ -103,19 +103,19 @@ export function ProfileTabContent(props: ProfileTabContentProps) { useUpdateEffect(() => { setSelectedTab(undefined) - }, [identity.identifier.userId]) + }, [identity.identifier?.userId]) useEffect(() => { return MaskMessages.events.profileTabHidden.on((data) => { if (data.hidden) setHidden(data.hidden) }) - }, [identity.identifier.userId]) + }, [identity.identifier?.userId]) useEffect(() => { return MaskMessages.events.profileTabUpdated.on((data) => { setHidden(!data.show) }) - }, [identity.identifier.userId]) + }, [identity.identifier?.userId]) const ContentComponent = useMemo(() => { const tabId = @@ -123,7 +123,7 @@ export function ProfileTabContent(props: ProfileTabContentProps) { ? displayPlugins?.find((tab) => tab?.pluginID === PluginId.NextID)?.ID : selectedTabId return getTabContent(tabId ?? '') - }, [selectedTabId, identity.identifier.userId]) + }, [selectedTabId, identity.identifier?.userId]) if (hidden) return null