From 585ef6a5e6a74114ef444d885f8336b04f284629 Mon Sep 17 00:00:00 2001 From: guanbinrui Date: Fri, 8 Jul 2022 16:10:09 +0800 Subject: [PATCH 001/179] chore: bump version to 2.10.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 c4567ffe0f0b..886f798f5ffc 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "yarn": ">=999.0.0", "npm": ">=999.0.0" }, - "version": "2.9.0", + "version": "2.10.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 965d53c21d67..31d049c54961 100644 --- a/packages/mask/src/manifest.json +++ b/packages/mask/src/manifest.json @@ -1,6 +1,6 @@ { "name": "Mask Network", - "version": "2.9.0", + "version": "2.10.0", "manifest_version": 2, "permissions": ["storage", "downloads", "webNavigation", "activeTab"], "optional_permissions": ["", "notifications", "clipboardRead"], From 965bc479ef4d7579a53d830a6d71ee6d8cb261d6 Mon Sep 17 00:00:00 2001 From: UncleBill Date: Fri, 8 Jul 2022 16:16:22 +0800 Subject: [PATCH 002/179] fix: get current visiting identity at initialization (#6718) --- packages/injected-script/main/index.ts | 2 +- .../main/sceneChange/twitter.ts | 42 ++++--------------- packages/injected-script/package.json | 4 ++ packages/injected-script/shared/index.ts | 1 + packages/injected-script/shared/tsconfig.json | 2 +- packages/injected-script/shared/twitter.ts | 30 +++++++++++++ .../twitter.com/collecting/identity.ts | 38 ++++++++++++----- packages/polyfills/types/global.d.ts | 7 +--- 8 files changed, 73 insertions(+), 53 deletions(-) create mode 100644 packages/injected-script/shared/twitter.ts diff --git a/packages/injected-script/main/index.ts b/packages/injected-script/main/index.ts index 03c3e225ecd0..ebaea3479a51 100644 --- a/packages/injected-script/main/index.ts +++ b/packages/injected-script/main/index.ts @@ -1,7 +1,7 @@ /// import './communicate' -import './locationChange' import './sceneChange' +import './locationChange' if (document.currentScript) document.currentScript.remove() diff --git a/packages/injected-script/main/sceneChange/twitter.ts b/packages/injected-script/main/sceneChange/twitter.ts index 906ef3102c60..b8497f2ab688 100644 --- a/packages/injected-script/main/sceneChange/twitter.ts +++ b/packages/injected-script/main/sceneChange/twitter.ts @@ -1,36 +1,6 @@ +import { TWITTER_RESERVED_SLUGS } from '../../shared' import { apply, dispatchEvent, no_xray_CustomEvent } from '../intrinsic' -// Collect from main js of Twitter's web client. -const RESERVED_SLUGS = [ - '404', - 'account', - 'download', - 'explore', - 'follower_requests', - 'hashtag', - 'home', - 'i', - 'intent', - 'lists', - 'login', - 'logout', - 'mentions', - 'messages', - 'notifications', - 'personalization', - 'search', - 'search-advanced', - 'search-home', - 'session', - 'settings', - 'share', - 'signup', - 'twitterblue', - 'webview', - 'welcome', - 'your_twitter_data', -] - const { split } = String.prototype const { filter, includes } = Array.prototype const { Boolean } = globalThis @@ -41,11 +11,11 @@ function getFirstSlug() { } export function setupWatcherForTwitter() { - let firstSlug = getFirstSlug() - window.addEventListener('locationchange', () => { + let firstSlug = '' + const update = () => { const newFirstSlug = getFirstSlug() // reset to void wrong value - if (!firstSlug || apply(includes, RESERVED_SLUGS, [firstSlug])) { + if (!firstSlug || apply(includes, TWITTER_RESERVED_SLUGS, [firstSlug])) { const event = new no_xray_CustomEvent('scenechange', { detail: { scene: 'unknown' }, }) as WindowEventMap['scenechange'] @@ -55,6 +25,7 @@ export function setupWatcherForTwitter() { if (firstSlug !== newFirstSlug) { firstSlug = newFirstSlug const event = new no_xray_CustomEvent('scenechange', { + cancelable: true, detail: { scene: 'profile', value: newFirstSlug, @@ -62,5 +33,6 @@ export function setupWatcherForTwitter() { }) apply(dispatchEvent, window, [event]) } - }) + } + window.addEventListener('locationchange', update) } diff --git a/packages/injected-script/package.json b/packages/injected-script/package.json index d8da8dfdaad7..50e4d70b8a3c 100644 --- a/packages/injected-script/package.json +++ b/packages/injected-script/package.json @@ -6,6 +6,10 @@ ".": { "webpack": "./sdk/index.ts", "default": "./dist/sdk/index.js" + }, + "./shared": { + "webpack": "./shared/index.ts", + "default": "./dist/shared/index.js" } }, "types": "./dist/sdk/index.d.ts", diff --git a/packages/injected-script/shared/index.ts b/packages/injected-script/shared/index.ts index 57f27c34a406..64cd167fef70 100644 --- a/packages/injected-script/shared/index.ts +++ b/packages/injected-script/shared/index.ts @@ -81,3 +81,4 @@ function isEventItemBeforeSerialization(data: unknown): data is EventItemBeforeS if (!isArray(data[1])) return false return true } +export * from './twitter' diff --git a/packages/injected-script/shared/tsconfig.json b/packages/injected-script/shared/tsconfig.json index 63aa902d948f..9cff811e50fc 100644 --- a/packages/injected-script/shared/tsconfig.json +++ b/packages/injected-script/shared/tsconfig.json @@ -5,6 +5,6 @@ "outDir": "../dist/shared", "tsBuildInfoFile": "../dist/shared.tsbuildinfo" }, - "files": ["./index.ts"], + "files": ["./index.ts", "./twitter.ts"], "references": [] } diff --git a/packages/injected-script/shared/twitter.ts b/packages/injected-script/shared/twitter.ts new file mode 100644 index 000000000000..5dcb44f510ce --- /dev/null +++ b/packages/injected-script/shared/twitter.ts @@ -0,0 +1,30 @@ +// Collect from main js of Twitter's web client. +export const TWITTER_RESERVED_SLUGS = [ + '404', + 'account', + 'download', + 'explore', + 'follower_requests', + 'hashtag', + 'home', + 'i', + 'intent', + 'lists', + 'login', + 'logout', + 'mentions', + 'messages', + 'notifications', + 'personalization', + 'search', + 'search-advanced', + 'search-home', + 'session', + 'settings', + 'share', + 'signup', + 'twitterblue', + 'webview', + 'welcome', + 'your_twitter_data', +] 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 fa07a7a2609f..d394351bf86b 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 @@ -1,17 +1,19 @@ -import { delay } from '@dimensiondev/kit' import { LiveSelector, MutationObserverWatcher } from '@dimensiondev/holoflows-kit' -import { Twitter } from '@masknet/web3-providers' +import { delay } from '@dimensiondev/kit' +import { TWITTER_RESERVED_SLUGS } from '@masknet/injected-script/shared' import { ProfileIdentifier } from '@masknet/shared-base' +import { Twitter } from '@masknet/web3-providers' +import { first } from 'lodash-unified' +import { creator, SocialNetworkUI as Next } from '../../../social-network' +import { twitterBase } from '../base' +import { isMobileTwitter } from '../utils/isMobile' import { + searchSelfAvatarSelector, searchSelfHandleSelector, searchSelfNicknameSelector, - searchSelfAvatarSelector, searchWatcherAvatarSelector, selfInfoSelectors, } from '../utils/selector' -import { creator, SocialNetworkUI as Next } from '../../../social-network' -import { twitterBase } from '../base' -import { isMobileTwitter } from '../utils/isMobile' function recognizeDesktop() { const collect = () => { @@ -111,13 +113,16 @@ function resolveLastRecognizedIdentityMobileInner( window.addEventListener('locationchange', onLocationChange, { signal: cancel }) } +function getFirstSlug() { + const slugs: string[] = location.pathname.split('/').filter(Boolean) + return first(slugs) +} + function resolveCurrentVisitingIdentityInner( ref: Next.CollectingCapabilities.IdentityResolveProvider['recognized'], cancel: AbortSignal, ) { - const update = async (event: WindowEventMap['scenechange']) => { - if (event.detail.scene !== 'profile' || !event.detail.value) return - const twitterId = event.detail.value + const update = async (twitterId: string) => { const user = await Twitter.getUserByScreenName(twitterId) const bio = user.legacy.description @@ -135,7 +140,20 @@ function resolveCurrentVisitingIdentityInner( } } - window.addEventListener('scenechange', update, { signal: cancel }) + const slug = getFirstSlug() + if (slug && !TWITTER_RESERVED_SLUGS.includes(slug)) { + update(slug) + } + + window.addEventListener( + 'scenechange', + (event) => { + if (event.detail.scene !== 'profile') return + const twitterId = event.detail.value + update(twitterId) + }, + { signal: cancel }, + ) } export const IdentityProviderTwitter: Next.CollectingCapabilities.IdentityResolveProvider = { diff --git a/packages/polyfills/types/global.d.ts b/packages/polyfills/types/global.d.ts index 27468229cb44..23fca567fef3 100644 --- a/packages/polyfills/types/global.d.ts +++ b/packages/polyfills/types/global.d.ts @@ -1,10 +1,5 @@ declare function r2d2Fetch(url: RequestInfo, init?: RequestInit): Promise -type SceneTypes = 'profile' | 'unknown' - interface WindowEventMap { - scenechange: CustomEvent<{ - scene: SceneTypes - value?: string - }> + scenechange: CustomEvent<{ scene: 'profile'; value: string }> | CustomEvent<{ scene: 'unknown' }> } From b1eb5e116168331c015794d8813786a6e7fa4a3b Mon Sep 17 00:00:00 2001 From: nuanyang233 Date: Fri, 8 Jul 2022 16:39:48 +0800 Subject: [PATCH 003/179] fix: bugfix for connect wallet --- .../extension/popups/pages/Wallet/ConnectWallet/index.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/mask/src/extension/popups/pages/Wallet/ConnectWallet/index.tsx b/packages/mask/src/extension/popups/pages/Wallet/ConnectWallet/index.tsx index b3d93c7d20cf..530d0c256ca4 100644 --- a/packages/mask/src/extension/popups/pages/Wallet/ConnectWallet/index.tsx +++ b/packages/mask/src/extension/popups/pages/Wallet/ConnectWallet/index.tsx @@ -89,7 +89,10 @@ const ConnectWalletPage = memo(() => { return } - if (!wallets.length) navigate(PopupRoutes.Wallet, { replace: true }) + if (!wallets.length) { + navigate(PopupRoutes.Wallet, { replace: true }) + return + } navigate( urlcat(PopupRoutes.SelectWallet, { From 39bb72ddb2eacc4326b3e64e93b688d669563066 Mon Sep 17 00:00:00 2001 From: Lantt Date: Fri, 8 Jul 2022 16:57:05 +0800 Subject: [PATCH 004/179] style: fix tab component style --- .../mask/src/plugins/Approval/SNSAdaptor/ApprovalDialog.tsx | 6 +++--- packages/theme/src/Components/Tabs/BaseTab.tsx | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/mask/src/plugins/Approval/SNSAdaptor/ApprovalDialog.tsx b/packages/mask/src/plugins/Approval/SNSAdaptor/ApprovalDialog.tsx index 71bd3d54657a..343586690b46 100644 --- a/packages/mask/src/plugins/Approval/SNSAdaptor/ApprovalDialog.tsx +++ b/packages/mask/src/plugins/Approval/SNSAdaptor/ApprovalDialog.tsx @@ -1,4 +1,4 @@ -import { DialogContent, Button, Tab, Typography } from '@mui/material' +import { DialogContent, Button, Tab } from '@mui/material' import { MaskTabList, useTabs } from '@masknet/theme' import { TargetChainIdContext } from '@masknet/plugin-infra/web3-evm' import { useState } from 'react' @@ -45,8 +45,8 @@ export function ApprovalDialog({ open, onClose }: ApprovalDialogProps) { classes={{ paper: classes.dialogRoot, dialogTitle: classes.dialogTitle }} titleTabs={ - {t.tokens()}} value={t.tokens()} /> - {t.collectibles()}} value={t.collectibles()} /> + + }> diff --git a/packages/theme/src/Components/Tabs/BaseTab.tsx b/packages/theme/src/Components/Tabs/BaseTab.tsx index 0ab28eab4c8b..f0987e722af7 100644 --- a/packages/theme/src/Components/Tabs/BaseTab.tsx +++ b/packages/theme/src/Components/Tabs/BaseTab.tsx @@ -21,6 +21,7 @@ const BaseTabWrap = styled(Button, { '&:hover': { boxShadow: activated ? '0 0 20px rgba(0, 0, 0, 0.05)' : 'none', background: activated ? theme.palette.maskColor.bottom : 'transparent', + color: theme.palette.maskColor.main, }, })) From 3b7a5b6c69ec1eb498f80ccdb702cd89ba5702fa Mon Sep 17 00:00:00 2001 From: nuanyang233 Date: Fri, 8 Jul 2022 17:04:48 +0800 Subject: [PATCH 005/179] fix: bugfix for status bar --- packages/mask/src/plugins/Pets/SNSAdaptor/PetSetDialog.tsx | 5 ----- packages/mask/src/web3/UI/ChainBoundary.tsx | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/packages/mask/src/plugins/Pets/SNSAdaptor/PetSetDialog.tsx b/packages/mask/src/plugins/Pets/SNSAdaptor/PetSetDialog.tsx index 58a140552f9d..d14752768911 100644 --- a/packages/mask/src/plugins/Pets/SNSAdaptor/PetSetDialog.tsx +++ b/packages/mask/src/plugins/Pets/SNSAdaptor/PetSetDialog.tsx @@ -385,11 +385,6 @@ export function PetSetDialog({ configNFTs, onClose }: PetSetDialogProps) { noSwitchNetworkTip ActionButtonPromiseProps={{ fullWidth: true, - sx: { - height: 40, - padding: 0, - margin: 0, - }, }}> (props: ChainBoundaryPro const renderBox = (children?: React.ReactNode, tips?: string) => { return ( - + {children} From 497031be4e177e4ad5b4bc584730452e54ca482b Mon Sep 17 00:00:00 2001 From: nuanyang233 Date: Fri, 8 Jul 2022 17:32:15 +0800 Subject: [PATCH 006/179] fix: link out icon --- .../Wallets/components/HistoryTableRow/index.tsx | 2 +- packages/icons/general/PopupLink.tsx | 15 +++++++++++++++ packages/icons/general/index.ts | 1 + .../components/shared/WalletStatusBox/index.tsx | 2 +- .../pages/Personas/ConnectedWallets/UI.tsx | 4 ++-- .../pages/Wallet/components/WalletHeader/UI.tsx | 4 ++-- .../trader/components/InputTokenPanelUI.tsx | 2 +- .../utils/components/PluginWalletStatusBar.tsx | 16 ++++++++-------- .../src/SNSAdaptor/components/WalletAssets.tsx | 2 +- .../src/SNSAdaptor/components/WalletSwitch.tsx | 2 +- 10 files changed, 33 insertions(+), 17 deletions(-) create mode 100644 packages/icons/general/PopupLink.tsx diff --git a/packages/dashboard/src/pages/Wallets/components/HistoryTableRow/index.tsx b/packages/dashboard/src/pages/Wallets/components/HistoryTableRow/index.tsx index 56604e38f0d6..3167b610b9a9 100644 --- a/packages/dashboard/src/pages/Wallets/components/HistoryTableRow/index.tsx +++ b/packages/dashboard/src/pages/Wallets/components/HistoryTableRow/index.tsx @@ -33,7 +33,7 @@ const useStyles = makeStyles()((theme) => ({ }, linkIcon: { // TODO: replace with theme color - fill: theme.palette.mode === 'dark' ? '#F5F5F5' : '#07101B', + color: theme.palette.mode === 'dark' ? '#F5F5F5' : '#07101B', fontSize: 16, marginLeft: 10, }, diff --git a/packages/icons/general/PopupLink.tsx b/packages/icons/general/PopupLink.tsx new file mode 100644 index 000000000000..d59676c01546 --- /dev/null +++ b/packages/icons/general/PopupLink.tsx @@ -0,0 +1,15 @@ +import { createIcon } from '../utils' +import type { SvgIcon } from '@mui/material' + +export const PopupLinkIcon: typeof SvgIcon = createIcon( + 'PopupLinkIcon', + + + , + '0 0 12 12', +) diff --git a/packages/icons/general/index.ts b/packages/icons/general/index.ts index 7437955acca7..580a192f706c 100644 --- a/packages/icons/general/index.ts +++ b/packages/icons/general/index.ts @@ -139,3 +139,4 @@ export * from './CheckCircle' export * from './SuccessForSnackBar' export * from './MaskAvatarIcon' export * from './ArrowDownward' +export * from './PopupLink' diff --git a/packages/mask/src/components/shared/WalletStatusBox/index.tsx b/packages/mask/src/components/shared/WalletStatusBox/index.tsx index f43abb3ec3bd..89b03e2646f4 100644 --- a/packages/mask/src/components/shared/WalletStatusBox/index.tsx +++ b/packages/mask/src/components/shared/WalletStatusBox/index.tsx @@ -103,7 +103,7 @@ const useStyles = makeStyles<{ contentBackground?: string }>()((theme, { content fill: isDashboardPage() ? theme.palette.text.primary : theme.palette.maskColor.dark, }, linkIcon: { - fill: isDashboardPage() ? theme.palette.text.primary : theme.palette.maskColor?.dark, + color: isDashboardPage() ? theme.palette.text.primary : theme.palette.maskColor?.dark, }, statusBox: { position: 'relative', diff --git a/packages/mask/src/extension/popups/pages/Personas/ConnectedWallets/UI.tsx b/packages/mask/src/extension/popups/pages/Personas/ConnectedWallets/UI.tsx index 1a653ac1b1cb..8f927e07195f 100644 --- a/packages/mask/src/extension/popups/pages/Personas/ConnectedWallets/UI.tsx +++ b/packages/mask/src/extension/popups/pages/Personas/ConnectedWallets/UI.tsx @@ -5,7 +5,7 @@ import { useNetworkDescriptor } from '@masknet/plugin-infra/web3' import { FormattedAddress, ImageIcon } from '@masknet/shared' import { Button, Link, Typography } from '@mui/material' import { CopyIconButton } from '../../../components/CopyIconButton' -import { CircleLoadingIcon, DeleteIcon, EmptyIcon, LinkOutIcon } from '@masknet/icons' +import { CircleLoadingIcon, DeleteIcon, EmptyIcon, PopupLinkIcon } from '@masknet/icons' import type { ConnectedWalletInfo } from '../type' import { DisconnectWalletDialog } from '../components/DisconnectWalletDialog' import { useI18N } from '../../../../../utils' @@ -157,7 +157,7 @@ export const ConnectedWalletsUI = memo( href={explorerResolver.addressLink(chainId, wallet.identity ?? '')} target="_blank" rel="noopener noreferrer"> - + diff --git a/packages/mask/src/extension/popups/pages/Wallet/components/WalletHeader/UI.tsx b/packages/mask/src/extension/popups/pages/Wallet/components/WalletHeader/UI.tsx index 654ef9a2ba55..0ced616ee3fa 100644 --- a/packages/mask/src/extension/popups/pages/Wallet/components/WalletHeader/UI.tsx +++ b/packages/mask/src/extension/popups/pages/Wallet/components/WalletHeader/UI.tsx @@ -4,7 +4,7 @@ import { Box, Link, Typography } from '@mui/material' import { CopyIconButton } from '../../../../components/CopyIconButton' import { ChainIcon, FormattedAddress, WalletIcon } from '@masknet/shared' import { ChainId, formatEthereumAddress, explorerResolver, NetworkType } from '@masknet/web3-shared-evm' -import { ArrowDropIcon, LinkOutIcon, MaskBlueIcon } from '@masknet/icons' +import { ArrowDropIcon, MaskBlueIcon, PopupLinkIcon } from '@masknet/icons' import type { NetworkDescriptor, Wallet } from '@masknet/web3-shared-base' const useStyles = makeStyles()(() => ({ @@ -136,7 +136,7 @@ export const WalletHeaderUI = memo( href={explorerResolver.addressLink(chainId, wallet.address ?? '')} target="_blank" rel="noopener noreferrer"> - + diff --git a/packages/mask/src/plugins/Trader/SNSAdaptor/trader/components/InputTokenPanelUI.tsx b/packages/mask/src/plugins/Trader/SNSAdaptor/trader/components/InputTokenPanelUI.tsx index 3da3cd075fcd..0ff62d9e3d13 100644 --- a/packages/mask/src/plugins/Trader/SNSAdaptor/trader/components/InputTokenPanelUI.tsx +++ b/packages/mask/src/plugins/Trader/SNSAdaptor/trader/components/InputTokenPanelUI.tsx @@ -43,7 +43,7 @@ const useStyles = makeStyles<{ isDashboard: boolean }>()((theme, { isDashboard } height: 20, backgroundColor: !isDashboard ? theme.palette.maskColor?.primary : undefined, '&:hover': { - backgroundColor: !isDashboard ? lighten(theme.palette.maskColor?.primary, 0.1) : undefined, + backgroundColor: !isDashboard ? `${lighten(theme.palette.maskColor?.primary, 0.1)}!important` : undefined, }, }, chipLabel: { diff --git a/packages/mask/src/utils/components/PluginWalletStatusBar.tsx b/packages/mask/src/utils/components/PluginWalletStatusBar.tsx index 4a420c5c9d2a..aee5db39142f 100644 --- a/packages/mask/src/utils/components/PluginWalletStatusBar.tsx +++ b/packages/mask/src/utils/components/PluginWalletStatusBar.tsx @@ -37,8 +37,8 @@ interface WalletStatusBarProps extends PropsWithChildren<{}> { const useStyles = makeStyles()((theme) => ({ root: { display: 'flex', - backgroundColor: parseColor(theme.palette.maskColor?.bottom).setAlpha(0.8).toRgbString(), - boxShadow: `0 0 20px ${parseColor(theme.palette.maskColor?.highlight).setAlpha(0.05).toRgbString()}`, + backgroundColor: parseColor(theme.palette.maskColor.bottom).setAlpha(0.8).toRgbString(), + boxShadow: `0 0 20px ${parseColor(theme.palette.maskColor.highlight).setAlpha(0.05).toRgbString()}`, backdropFilter: 'blur(16px)', padding: theme.spacing(2), borderRadius: '0 0 12px 12px', @@ -60,13 +60,13 @@ const useStyles = makeStyles()((theme) => ({ display: 'flex', alignItems: 'center', columnGap: 4, - color: theme.palette.maskColor?.main, + color: theme.palette.maskColor.main, fontWeight: 700, fontSize: 14, lineHeight: '18px', }, address: { - color: theme.palette.maskColor?.second, + color: theme.palette.maskColor.second, fontSize: 14, lineHeight: '18px', display: 'flex', @@ -79,19 +79,19 @@ const useStyles = makeStyles()((theme) => ({ gap: 2, borderRadius: 2, padding: '2px 4px', - backgroundColor: parseColor(theme.palette.maskColor?.warn).setAlpha(0.1).toRgbString(), - color: theme.palette.maskColor?.warn, + backgroundColor: parseColor(theme.palette.maskColor.warn).setAlpha(0.1).toRgbString(), + color: theme.palette.maskColor.warn, fontSize: 14, lineHeight: '18px', }, progress: { - color: theme.palette.maskColor?.warn, + color: theme.palette.maskColor.warn, }, linkIcon: { width: 14, height: 14, fontSize: 14, - fill: theme.palette.maskColor?.second, + color: theme.palette.maskColor.second, cursor: 'pointer', }, action: { diff --git a/packages/plugins/Web3Profile/src/SNSAdaptor/components/WalletAssets.tsx b/packages/plugins/Web3Profile/src/SNSAdaptor/components/WalletAssets.tsx index 04a41965fa87..38f839a74630 100644 --- a/packages/plugins/Web3Profile/src/SNSAdaptor/components/WalletAssets.tsx +++ b/packages/plugins/Web3Profile/src/SNSAdaptor/components/WalletAssets.tsx @@ -45,7 +45,7 @@ const useStyles = makeStyles()((theme) => { }, }, linkIcon: { - fill: theme.palette.maskColor.second, + color: theme.palette.maskColor.second, height: 20, width: 20, marginLeft: theme.spacing(0.5), diff --git a/packages/plugins/Web3Profile/src/SNSAdaptor/components/WalletSwitch.tsx b/packages/plugins/Web3Profile/src/SNSAdaptor/components/WalletSwitch.tsx index b1cf6d81d2a1..6443bd11b57e 100644 --- a/packages/plugins/Web3Profile/src/SNSAdaptor/components/WalletSwitch.tsx +++ b/packages/plugins/Web3Profile/src/SNSAdaptor/components/WalletSwitch.tsx @@ -45,7 +45,7 @@ const useStyles = makeStyles()((theme) => ({ alignItems: 'center', }, linkIcon: { - fill: theme.palette.maskColor.second, + color: theme.palette.maskColor.second, height: 15, width: 15, marginTop: '1px', From 73a5a898b6a53526d353e3d69afab32e1388f462 Mon Sep 17 00:00:00 2001 From: nuanyang233 Date: Fri, 8 Jul 2022 17:39:28 +0800 Subject: [PATCH 007/179] fix: primary color don't flow twitter --- .../social-network-adaptor/twitter.com/customization/custom.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/mask/src/social-network-adaptor/twitter.com/customization/custom.ts b/packages/mask/src/social-network-adaptor/twitter.com/customization/custom.ts index 6ce8b5973fed..126aef156d7f 100644 --- a/packages/mask/src/social-network-adaptor/twitter.com/customization/custom.ts +++ b/packages/mask/src/social-network-adaptor/twitter.com/customization/custom.ts @@ -8,6 +8,7 @@ import type { SocialNetworkUI } from '../../../social-network' import { fromRGB, getBackgroundColor, getForegroundColor, isDark, shade, toRGB } from '../../../utils/theme' import { isMobileTwitter } from '../utils/isMobile' import { composeAnchorSelector, composeAnchorTextSelector, headingTextSelector } from '../utils/selector' +import { parseColor } from '@masknet/theme' const themeColorRef = new ValueRef('rgb(29, 161, 242)') const textColorRef = new ValueRef('rgb(255, 255, 255)') @@ -50,7 +51,7 @@ export function useThemeTwitterVariant(baseTheme: Theme) { const primaryContrastColor = useValueRef(textColorRef) const backgroundColor = useValueRef(backgroundColorRef) return useMemo(() => { - const primaryColorRGB = fromRGB(primaryColor)! + const primaryColorRGB = fromRGB(parseColor(baseTheme.palette.maskColor.primary).toRgbString())! const primaryContrastColorRGB = fromRGB(primaryContrastColor) setAutoFreeze(false) From 70bc9e5ce277d3f6cbe50fda206e362f363e013c Mon Sep 17 00:00:00 2001 From: Lantt Date: Fri, 8 Jul 2022 17:45:51 +0800 Subject: [PATCH 008/179] fix: trending maximum value format --- .../plugins/Trader/SNSAdaptor/trending/CoinMarketTable.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/mask/src/plugins/Trader/SNSAdaptor/trending/CoinMarketTable.tsx b/packages/mask/src/plugins/Trader/SNSAdaptor/trending/CoinMarketTable.tsx index 89fece8be549..8abe13fd5316 100644 --- a/packages/mask/src/plugins/Trader/SNSAdaptor/trending/CoinMarketTable.tsx +++ b/packages/mask/src/plugins/Trader/SNSAdaptor/trending/CoinMarketTable.tsx @@ -62,7 +62,7 @@ export function FungibleCoinMarketTable(props: CoinMarketTableProps) { - + {market?.market_cap ? `$${formatSupply(market.market_cap)}` : '--'} ) : null} @@ -85,7 +85,7 @@ export function FungibleCoinMarketTable(props: CoinMarketTableProps) { - + {market?.total_volume ? `$${formatSupply(market.total_volume)}` : '--'} {dataProvider !== DataProvider.UNISWAP_INFO ? ( From 206227f86be81ec5b578bc9958007f5d66e8397c Mon Sep 17 00:00:00 2001 From: Lantt Date: Fri, 8 Jul 2022 17:54:21 +0800 Subject: [PATCH 009/179] feat: remove short name for bnb chain --- packages/web3-shared/evm/constants/descriptors.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/web3-shared/evm/constants/descriptors.ts b/packages/web3-shared/evm/constants/descriptors.ts index 0fd7557101ec..e0f468c7ac04 100644 --- a/packages/web3-shared/evm/constants/descriptors.ts +++ b/packages/web3-shared/evm/constants/descriptors.ts @@ -93,7 +93,6 @@ export const NETWORK_DESCRIPTORS: Array> chainId: ChainId.BSC, type: NetworkType.Binance, name: 'BNB Chain', - shortName: 'BNB', icon: new URL('../assets/binance.png', import.meta.url), iconColor: 'rgb(240, 185, 10)', backgroundGradient: 'linear-gradient(180deg, rgba(243, 186, 47, 0.15) 0%, rgba(243, 186, 47, 0.05) 100%)', From a50260be6b0302ff4587ae15cb325f5fd2b4a672 Mon Sep 17 00:00:00 2001 From: Randolph314 <97870249+Randolph314@users.noreply.github.com> Date: Fri, 8 Jul 2022 18:07:38 +0800 Subject: [PATCH 010/179] feat: change RSS3 icon style (#6723) Co-authored-by: Randolph <840094513@qq.com> --- .../plugins/Pets/SNSAdaptor/PetSetDialog.tsx | 6 +++++- .../mask/src/plugins/Pets/assets/rss3.tsx | 20 ++++--------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/packages/mask/src/plugins/Pets/SNSAdaptor/PetSetDialog.tsx b/packages/mask/src/plugins/Pets/SNSAdaptor/PetSetDialog.tsx index d14752768911..3e9a81a7f8b1 100644 --- a/packages/mask/src/plugins/Pets/SNSAdaptor/PetSetDialog.tsx +++ b/packages/mask/src/plugins/Pets/SNSAdaptor/PetSetDialog.tsx @@ -115,6 +115,10 @@ const useStyles = makeStyles()((theme) => ({ logo: { height: 21, }, + RSS3Icon: { + fontSize: 24, + fill: theme.palette.mode === 'light' ? '#000' : '#fff', + }, })) interface PetSetDialogProps { @@ -373,7 +377,7 @@ export function PetSetDialog({ configNFTs, onClose }: PetSetDialogProps) { RSS3 - + diff --git a/packages/mask/src/plugins/Pets/assets/rss3.tsx b/packages/mask/src/plugins/Pets/assets/rss3.tsx index e06bb99fef38..7778f2d9a0a7 100644 --- a/packages/mask/src/plugins/Pets/assets/rss3.tsx +++ b/packages/mask/src/plugins/Pets/assets/rss3.tsx @@ -2,22 +2,10 @@ import { createIcon } from '@masknet/icons' export const RSS3Icon = createIcon( 'RSS3Icon', - - - - + + + + , From d906ea5b9ee7e4f65f4f503f76717160f700f773 Mon Sep 17 00:00:00 2001 From: nuanyang233 Date: Fri, 8 Jul 2022 18:06:07 +0800 Subject: [PATCH 011/179] fix: snackbar --- .../twitter.com/customization/custom.ts | 3 +-- .../SNSAdaptor/components/ConsoleContent.tsx | 19 ++++++++++++++++++- .../theme/src/Components/Snackbar/index.tsx | 8 ++++---- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/packages/mask/src/social-network-adaptor/twitter.com/customization/custom.ts b/packages/mask/src/social-network-adaptor/twitter.com/customization/custom.ts index 126aef156d7f..6ce8b5973fed 100644 --- a/packages/mask/src/social-network-adaptor/twitter.com/customization/custom.ts +++ b/packages/mask/src/social-network-adaptor/twitter.com/customization/custom.ts @@ -8,7 +8,6 @@ import type { SocialNetworkUI } from '../../../social-network' import { fromRGB, getBackgroundColor, getForegroundColor, isDark, shade, toRGB } from '../../../utils/theme' import { isMobileTwitter } from '../utils/isMobile' import { composeAnchorSelector, composeAnchorTextSelector, headingTextSelector } from '../utils/selector' -import { parseColor } from '@masknet/theme' const themeColorRef = new ValueRef('rgb(29, 161, 242)') const textColorRef = new ValueRef('rgb(255, 255, 255)') @@ -51,7 +50,7 @@ export function useThemeTwitterVariant(baseTheme: Theme) { const primaryContrastColor = useValueRef(textColorRef) const backgroundColor = useValueRef(backgroundColorRef) return useMemo(() => { - const primaryColorRGB = fromRGB(parseColor(baseTheme.palette.maskColor.primary).toRgbString())! + const primaryColorRGB = fromRGB(primaryColor)! const primaryContrastColorRGB = fromRGB(primaryContrastColor) setAutoFreeze(false) diff --git a/packages/plugins/Debugger/src/SNSAdaptor/components/ConsoleContent.tsx b/packages/plugins/Debugger/src/SNSAdaptor/components/ConsoleContent.tsx index 39fc5a22876d..fe36f6c370e7 100644 --- a/packages/plugins/Debugger/src/SNSAdaptor/components/ConsoleContent.tsx +++ b/packages/plugins/Debugger/src/SNSAdaptor/components/ConsoleContent.tsx @@ -11,7 +11,7 @@ import { useWeb3State, Web3Helper, } from '@masknet/plugin-infra/web3' -import { makeStyles } from '@masknet/theme' +import { makeStyles, useCustomSnackbar } from '@masknet/theme' import { NetworkPluginID, SourceType } from '@masknet/web3-shared-base' import { ChainId, @@ -152,6 +152,8 @@ export function ConsoleContent(props: ConsoleContentProps) { const onSelectFungibleToken = useSelectFungibleToken() const onSelectGasSettings = useSelectAdvancedSettings(NetworkPluginID.PLUGIN_EVM) + const { showSnackbar, closeSnackbar } = useCustomSnackbar() + return (
@@ -487,6 +489,21 @@ export function ConsoleContent(props: ConsoleContentProps) { + + Test Snackbar + + + +
diff --git a/packages/theme/src/Components/Snackbar/index.tsx b/packages/theme/src/Components/Snackbar/index.tsx index df9fcdedf173..2ec07f0ba924 100644 --- a/packages/theme/src/Components/Snackbar/index.tsx +++ b/packages/theme/src/Components/Snackbar/index.tsx @@ -11,7 +11,7 @@ import { SnackbarAction, OptionsObject, } from 'notistack' -import { Typography, IconButton } from '@mui/material' +import { Typography, IconButton, alpha } from '@mui/material' import classnames from 'classnames' import { Close as CloseIcon } from '@mui/icons-material' import WarningIcon from '@mui/icons-material/Warning' @@ -64,15 +64,15 @@ to { }, } const success = { - backgroundColor: MaskColorVar.greenMain, + backgroundColor: theme.palette.maskColor.success, color: '#ffffff', [`& .${refs.title}`]: { color: 'inherit', }, [`& .${refs.message}`]: { - color: MaskColorVar.normalTextLight, + color: alpha(theme.palette.maskColor.white, 0.8), '& svg': { - color: MaskColorVar.white, + color: theme.palette.maskColor.white, }, }, } as const From d0ca0ddef1c3cbf03abad61d98764880e75b881e Mon Sep 17 00:00:00 2001 From: nuanyang233 Date: Fri, 8 Jul 2022 19:07:52 +0800 Subject: [PATCH 012/179] fix: bugfix for application --- packages/mask/src/components/shared/ApplicationBoard.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/mask/src/components/shared/ApplicationBoard.tsx b/packages/mask/src/components/shared/ApplicationBoard.tsx index d13712e340fc..0cc6a1221167 100644 --- a/packages/mask/src/components/shared/ApplicationBoard.tsx +++ b/packages/mask/src/components/shared/ApplicationBoard.tsx @@ -235,8 +235,10 @@ function RenderEntryComponent({ application }: { application: Application }) { }, []) const clickHandler = useMemo(() => { - if (application.isWalletConnectedRequired || application.isWalletConnectedEVMRequired) - return () => setSelectProviderDialog({ open: true }) + if (application.isWalletConnectedRequired || application.isWalletConnectedEVMRequired) { + return (walletConnectedCallback?: () => void) => + setSelectProviderDialog({ open: true, walletConnectedCallback }) + } if (!application.entry.nextIdRequired) return if (ApplicationEntryStatus.isPersonaConnected === false || ApplicationEntryStatus.isPersonaCreated === false) return createOrConnectPersona From ccafbf31d17e8f818f6f504b310065245cad9873 Mon Sep 17 00:00:00 2001 From: Lantt Date: Fri, 8 Jul 2022 19:11:04 +0800 Subject: [PATCH 013/179] feat: format token security supply format --- .../src/SNSAdaptor/components/TokenPanel.tsx | 6 +++--- .../UI/components/TokenSecurity/components/TokenPanel.tsx | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/plugins/GoPlusSecurity/src/SNSAdaptor/components/TokenPanel.tsx b/packages/plugins/GoPlusSecurity/src/SNSAdaptor/components/TokenPanel.tsx index bf36eced894d..59812b63163e 100644 --- a/packages/plugins/GoPlusSecurity/src/SNSAdaptor/components/TokenPanel.tsx +++ b/packages/plugins/GoPlusSecurity/src/SNSAdaptor/components/TokenPanel.tsx @@ -5,7 +5,7 @@ import React from 'react' import { useTheme } from '@mui/system' import { makeStyles, usePortalShadowRoot } from '@masknet/theme' import { explorerResolver, formatEthereumAddress } from '@masknet/web3-shared-evm' -import { formatCurrency } from '@masknet/web3-shared-base' +import { formatCurrency, formatSupply } from '@masknet/web3-shared-base' import { LinkOutIcon } from '@masknet/icons' const useStyles = makeStyles()((theme) => ({ @@ -57,7 +57,7 @@ export const TokenPanel = React.forwardRef(({ tokenSecurity, tokenMarketCap }: T arrow title={ theme.palette.text.buttonText} className={classes.tooltip}> - {tokenSecurity.total_supply} + {tokenSecurity.total_supply ? formatSupply(tokenSecurity.total_supply) : DEFAULT_PLACEHOLDER} }> {formatTotalSupply(tokenSecurity.total_supply)} @@ -140,7 +140,7 @@ export const TokenPanel = React.forwardRef(({ tokenSecurity, tokenMarketCap }: T {t.token_market_cap()} - {tokenMarketCap ? formatCurrency(tokenMarketCap) : DEFAULT_PLACEHOLDER} + {tokenMarketCap ? `$${formatSupply(tokenMarketCap)}` : DEFAULT_PLACEHOLDER} diff --git a/packages/shared/src/UI/components/TokenSecurity/components/TokenPanel.tsx b/packages/shared/src/UI/components/TokenSecurity/components/TokenPanel.tsx index d5817705696d..86485c104399 100644 --- a/packages/shared/src/UI/components/TokenSecurity/components/TokenPanel.tsx +++ b/packages/shared/src/UI/components/TokenSecurity/components/TokenPanel.tsx @@ -6,7 +6,7 @@ import { useTheme } from '@mui/system' import { ExternalLink } from 'react-feather' import { makeStyles, usePortalShadowRoot } from '@masknet/theme' import { explorerResolver, formatEthereumAddress } from '@masknet/web3-shared-evm' -import { formatCurrency } from '@masknet/web3-shared-base' +import { formatCurrency, formatSupply } from '@masknet/web3-shared-base' const useStyles = makeStyles()((theme) => ({ card: { @@ -56,7 +56,7 @@ export const TokenPanel = React.forwardRef(({ tokenSecurity, tokenMarketCap }: T arrow title={ theme.palette.info.contrastText} className={classes.tooltip}> - {tokenSecurity.total_supply} + {tokenSecurity.total_supply ? formatSupply(tokenSecurity.total_supply) : DEFAULT_PLACEHOLDER} }> {formatTotalSupply(tokenSecurity.total_supply)} @@ -139,8 +139,7 @@ export const TokenPanel = React.forwardRef(({ tokenSecurity, tokenMarketCap }: T {t.token_info_market_cap()} - {' '} - {tokenMarketCap ? formatCurrency(tokenMarketCap) : DEFAULT_PLACEHOLDER}{' '} + {tokenMarketCap ? `$${formatSupply(tokenMarketCap)}` : DEFAULT_PLACEHOLDER} From 92c7791ac4355101fd3836270f8f16bafcb10896 Mon Sep 17 00:00:00 2001 From: nuanyang233 Date: Fri, 8 Jul 2022 19:12:58 +0800 Subject: [PATCH 014/179] fix: issue #6725 --- .../src/utils/theme/useClassicMaskFullPageTheme.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/mask/src/utils/theme/useClassicMaskFullPageTheme.ts b/packages/mask/src/utils/theme/useClassicMaskFullPageTheme.ts index 8a0da1724299..3854232ac03b 100644 --- a/packages/mask/src/utils/theme/useClassicMaskFullPageTheme.ts +++ b/packages/mask/src/utils/theme/useClassicMaskFullPageTheme.ts @@ -1,10 +1,11 @@ // ! This file is used during SSR. DO NOT import new files that does not work in SSR import type { LanguageOptions } from '@masknet/public-api' -import { Appearance } from '@masknet/theme' +import { Appearance, MaskColors } from '@masknet/theme' import { PaletteMode, unstable_createMuiStrictModeTheme } from '@mui/material' import { MaskDarkTheme, MaskLightTheme } from './MaskTheme' import { useThemeLanguage } from './useThemeLanguage' +import produce, { setAutoFreeze } from 'immer' /** * @deprecated Should migrate to \@masknet/theme @@ -15,7 +16,13 @@ export function useClassicMaskFullPageTheme(userPreference: Appearance, language const finalPalette: PaletteMode = userPreference === Appearance.default ? systemPreference : userPreference const baseTheme = finalPalette === 'dark' ? MaskDarkTheme : MaskLightTheme - return unstable_createMuiStrictModeTheme(baseTheme, useThemeLanguage(language)) + setAutoFreeze(false) + const maskTheme = produce(baseTheme, (theme) => { + const colorSchema = MaskColors[theme.palette.mode] + theme.palette.maskColor = colorSchema.maskColor + }) + setAutoFreeze(true) + return unstable_createMuiStrictModeTheme(maskTheme, useThemeLanguage(language)) } /** From 9ca3e02c5538c3124d95477764a5bf72f3c8cefd Mon Sep 17 00:00:00 2001 From: nuanyang233 Date: Fri, 8 Jul 2022 20:00:54 +0800 Subject: [PATCH 015/179] fix: bugfix for mask textfield --- packages/theme/src/Components/TextField/index.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/theme/src/Components/TextField/index.tsx b/packages/theme/src/Components/TextField/index.tsx index 83bbd4cf47f5..907c22c31b80 100644 --- a/packages/theme/src/Components/TextField/index.tsx +++ b/packages/theme/src/Components/TextField/index.tsx @@ -2,6 +2,9 @@ import { ForwardedRef, forwardRef } from 'react' import { Box, formHelperTextClasses, TextField, StandardTextFieldProps, InputProps, Typography } from '@mui/material' import { makeStyles } from '../../UIHelper/makeStyles' import { getMaskColor, MaskColorVar } from '../../CSSVariables/vars' +import { isDashboardPage } from '@masknet/shared-base' + +const isDashboard = isDashboardPage() const useStyles = makeStyles()((theme) => ({ label: { @@ -27,12 +30,16 @@ const useStyles = makeStyles()((theme) => ({ lineHeight: '16px', }, '& input::-webkit-input-placeholder': { - color: theme.palette.maskColor.second, + color: !isDashboard ? theme.palette.maskColor.second : undefined, }, }, input: { padding: theme.spacing(1), - background: theme.palette.maskColor.input, + background: !isDashboard + ? theme.palette.maskColor.input + : theme.palette.mode === 'dark' + ? '#2B2E4C' + : '#F6F6F8', fontSize: 13, lineHeight: '16px', borderRadius: 6, @@ -46,7 +53,7 @@ const useStyles = makeStyles()((theme) => ({ color: 'rgba(255, 255, 255, 0.4)', }, inputFocused: { - backgroundColor: theme.palette.maskColor.input, + backgroundColor: !isDashboard ? theme.palette.maskColor.input : MaskColorVar.primaryBackground, boxShadow: `0 0 0 2px ${theme.palette.mode === 'dark' ? '#4F5378' : 'rgba(28, 104, 243, 0.2)'}`, }, })) From 6be4c13a7ad444ae67b46cd84f4577bb5de51cee Mon Sep 17 00:00:00 2001 From: nuanyang233 Date: Fri, 8 Jul 2022 21:14:44 +0800 Subject: [PATCH 016/179] fix: popup --- .../src/extension/popups/pages/Wallet/SignRequest/index.tsx | 2 +- packages/plugin-infra/src/web3-state/Provider.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/mask/src/extension/popups/pages/Wallet/SignRequest/index.tsx b/packages/mask/src/extension/popups/pages/Wallet/SignRequest/index.tsx index 23ad029712bb..8cf87df86127 100644 --- a/packages/mask/src/extension/popups/pages/Wallet/SignRequest/index.tsx +++ b/packages/mask/src/extension/popups/pages/Wallet/SignRequest/index.tsx @@ -155,7 +155,7 @@ const SignRequest = memo(() => { {t('popups_wallet_signature_request')} {wallet?.name ?? ''} - {address} + {typeof address === 'string' ? address : undefined} diff --git a/packages/plugin-infra/src/web3-state/Provider.ts b/packages/plugin-infra/src/web3-state/Provider.ts index 080adc4b39ef..d42bb5c9538b 100644 --- a/packages/plugin-infra/src/web3-state/Provider.ts +++ b/packages/plugin-infra/src/web3-state/Provider.ts @@ -109,7 +109,7 @@ export class ProviderState< const siteType = getSiteType() if (!siteType) return - this.storage.providerType.setValue(this.options.getDefaultProviderType()) + this.storage.providerType.setValue(this.options.getDefaultProviderType(siteType)) }) }) } From a9f0fc5318c918f3a55ed804013d465b9cdbc0e8 Mon Sep 17 00:00:00 2001 From: nuanyang233 Date: Fri, 8 Jul 2022 21:28:17 +0800 Subject: [PATCH 017/179] fix: ui style --- .../src/plugins/MaskBox/SNSAdaptor/components/DetailsTab.tsx | 2 ++ packages/mask/src/utils/components/PluginWalletStatusBar.tsx | 1 + 2 files changed, 3 insertions(+) diff --git a/packages/mask/src/plugins/MaskBox/SNSAdaptor/components/DetailsTab.tsx b/packages/mask/src/plugins/MaskBox/SNSAdaptor/components/DetailsTab.tsx index 2424d5bbd90c..7ce607cb793f 100644 --- a/packages/mask/src/plugins/MaskBox/SNSAdaptor/components/DetailsTab.tsx +++ b/packages/mask/src/plugins/MaskBox/SNSAdaptor/components/DetailsTab.tsx @@ -26,11 +26,13 @@ const useStyles = makeStyles()((theme) => ({ fontWeight: 500, lineHeight: '24px', marginBottom: theme.spacing(4), + color: theme.palette.maskColor.dark, }, content: { fontSize: 14, lineHeight: '24px', whiteSpace: 'pre-line', + color: theme.palette.maskColor.dark, }, })) diff --git a/packages/mask/src/utils/components/PluginWalletStatusBar.tsx b/packages/mask/src/utils/components/PluginWalletStatusBar.tsx index aee5db39142f..cb25fbf6494c 100644 --- a/packages/mask/src/utils/components/PluginWalletStatusBar.tsx +++ b/packages/mask/src/utils/components/PluginWalletStatusBar.tsx @@ -36,6 +36,7 @@ interface WalletStatusBarProps extends PropsWithChildren<{}> { const useStyles = makeStyles()((theme) => ({ root: { + boxSizing: 'content-box', display: 'flex', backgroundColor: parseColor(theme.palette.maskColor.bottom).setAlpha(0.8).toRgbString(), boxShadow: `0 0 20px ${parseColor(theme.palette.maskColor.highlight).setAlpha(0.05).toRgbString()}`, From 183344afb935d39f8933f691eeccda14de08a1bf Mon Sep 17 00:00:00 2001 From: nuanyang233 Date: Fri, 8 Jul 2022 21:45:47 +0800 Subject: [PATCH 018/179] fix: add tooltip to game plugin --- packages/mask/src/plugins/Game/SNSAdaptor/index.tsx | 12 ++++++++++-- .../web3/UI/EthereumERC721TokenApprovedBoundary.tsx | 5 ----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/mask/src/plugins/Game/SNSAdaptor/index.tsx b/packages/mask/src/plugins/Game/SNSAdaptor/index.tsx index 2019b5b5dbd8..4347fb83b272 100644 --- a/packages/mask/src/plugins/Game/SNSAdaptor/index.tsx +++ b/packages/mask/src/plugins/Game/SNSAdaptor/index.tsx @@ -22,10 +22,18 @@ const sns: Plugin.SNSAdaptor.Definition = { const name = return { ApplicationEntryID: base.ID, - RenderEntryComponent({ disabled }) { + RenderEntryComponent({ disabled, ...props }) { const { openDialog } = useRemoteControlledDialog(PluginGameMessages.events.gameDialogUpdated) - return + return ( + + ) }, appBoardSortingDefaultPriority: 11, marketListSortingPriority: 12, diff --git a/packages/mask/src/web3/UI/EthereumERC721TokenApprovedBoundary.tsx b/packages/mask/src/web3/UI/EthereumERC721TokenApprovedBoundary.tsx index 261a0bcacc17..99168f60dcc9 100644 --- a/packages/mask/src/web3/UI/EthereumERC721TokenApprovedBoundary.tsx +++ b/packages/mask/src/web3/UI/EthereumERC721TokenApprovedBoundary.tsx @@ -65,7 +65,6 @@ export function EthereumERC721TokenApprovedBoundary(props: EthereumERC712TokenAp @@ -96,7 +94,6 @@ export function EthereumERC721TokenApprovedBoundary(props: EthereumERC712TokenAp @@ -126,7 +122,6 @@ export function EthereumERC721TokenApprovedBoundary(props: EthereumERC712TokenAp From cd11fc1db51b12df225964146f3247c68dd23947 Mon Sep 17 00:00:00 2001 From: nuanyang233 Date: Fri, 8 Jul 2022 22:01:00 +0800 Subject: [PATCH 019/179] fix: remove startIcon --- .../options-page/DashboardComponents/ActionButton.tsx | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/packages/mask/src/extension/options-page/DashboardComponents/ActionButton.tsx b/packages/mask/src/extension/options-page/DashboardComponents/ActionButton.tsx index 438a889dc2cf..9f58f86bd127 100644 --- a/packages/mask/src/extension/options-page/DashboardComponents/ActionButton.tsx +++ b/packages/mask/src/extension/options-page/DashboardComponents/ActionButton.tsx @@ -169,16 +169,7 @@ export function ActionButtonPromise(props: ActionButtonPromiseProps) { }, [executor, noUpdateEffect]) if (state === 'wait') - return ( - - ) + return if (state === 'complete') return ( Date: Fri, 8 Jul 2022 22:23:00 +0800 Subject: [PATCH 020/179] fix: open select wallet dialog when click game without wallet --- packages/mask/src/plugins/Game/SNSAdaptor/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mask/src/plugins/Game/SNSAdaptor/index.tsx b/packages/mask/src/plugins/Game/SNSAdaptor/index.tsx index 4347fb83b272..0cf4b93930ab 100644 --- a/packages/mask/src/plugins/Game/SNSAdaptor/index.tsx +++ b/packages/mask/src/plugins/Game/SNSAdaptor/index.tsx @@ -31,7 +31,7 @@ const sns: Plugin.SNSAdaptor.Definition = { disabled={disabled} title={name} icon={icon} - onClick={openDialog} + onClick={props.onClick ? () => props.onClick?.(openDialog) : openDialog} /> ) }, From 77fdeb409139e0af2e027e26340235277a406956 Mon Sep 17 00:00:00 2001 From: nuanyang233 Date: Fri, 8 Jul 2022 23:01:53 +0800 Subject: [PATCH 021/179] fix: button style at referral --- .../mask/src/plugins/Referral/SNSAdaptor/FarmPost.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/mask/src/plugins/Referral/SNSAdaptor/FarmPost.tsx b/packages/mask/src/plugins/Referral/SNSAdaptor/FarmPost.tsx index 8b8e4a214ccf..baf5da7165de 100644 --- a/packages/mask/src/plugins/Referral/SNSAdaptor/FarmPost.tsx +++ b/packages/mask/src/plugins/Referral/SNSAdaptor/FarmPost.tsx @@ -192,15 +192,18 @@ export function FarmPost(props: FarmPostProps) { )} - - + + - - From b7c3af918116a20fccb404d28c6599701c56dbde Mon Sep 17 00:00:00 2001 From: lelenei <72531217+lelenei@users.noreply.github.com> Date: Fri, 8 Jul 2022 23:11:25 +0800 Subject: [PATCH 022/179] fix: css style (#6730) --- packages/mask/src/plugins/CryptoartAI/SNSAdaptor/ActionBar.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/mask/src/plugins/CryptoartAI/SNSAdaptor/ActionBar.tsx b/packages/mask/src/plugins/CryptoartAI/SNSAdaptor/ActionBar.tsx index cc898a98a4f3..6051dbc657e2 100644 --- a/packages/mask/src/plugins/CryptoartAI/SNSAdaptor/ActionBar.tsx +++ b/packages/mask/src/plugins/CryptoartAI/SNSAdaptor/ActionBar.tsx @@ -59,6 +59,7 @@ export function ActionBar(props: ActionBarProps) { assetSource?.trade?.is_auction ? ( { onOpenOfferDialog() }}> @@ -70,7 +71,7 @@ export function ActionBar(props: ActionBarProps) { !assetSource?.is24Auction && assetSource?.priceInEth < 100000 && assetSource?.trade?.isCanBuy ? ( - + {t('plugin_collectible_buy_now')} ) : null} From 7776fcc2532b02d7dbb30b62699cca52226cc78b Mon Sep 17 00:00:00 2001 From: UncleBill Date: Fri, 8 Jul 2022 23:17:55 +0800 Subject: [PATCH 023/179] fix: link link on by coingecko is incorrect (#6731) --- .../web3-providers/src/coingecko/index.ts | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/packages/web3-providers/src/coingecko/index.ts b/packages/web3-providers/src/coingecko/index.ts index cc99f155024c..c88a29637929 100644 --- a/packages/web3-providers/src/coingecko/index.ts +++ b/packages/web3-providers/src/coingecko/index.ts @@ -2,7 +2,7 @@ import { DataProvider } from '@masknet/public-api' import { CurrencyType, Price } from '@masknet/web3-shared-base' import type { ChainId } from '@masknet/web3-shared-evm' import urlcat from 'urlcat' -import { uniq } from 'lodash-unified' +import { uniq, uniqBy } from 'lodash-unified' import { getCommunityLink, isMirroredKeyword, resolveChainId, resolveCoinAddress } from '../CoinMarketCap/helper' import { fetchJSON } from '../helpers' import { PriceAPI, TrendingAPI, TrendingCoinType } from '../types' @@ -57,7 +57,7 @@ export class CoinGeckoAPI implements PriceAPI.Provider, TrendingAPI.Provider x.toLowerCase(), + ), ), source_code_urls: Object.values(info.links.repos_url).flatMap((x) => x), home_urls: info.links.homepage.filter(Boolean), From f14b8e4f238380f2c07aed84023417ad9a50c53f Mon Sep 17 00:00:00 2001 From: Randolph314 <97870249+Randolph314@users.noreply.github.com> Date: Fri, 8 Jul 2022 23:18:07 +0800 Subject: [PATCH 024/179] fix: web3 profile bug (#6727) * feat: delete LinkOutIcon initial fill color * feat: refresh wallet setting date when wallets change * feat: change button name and collection style Co-authored-by: Randolph <840094513@qq.com> --- packages/icons/general/LinkOut.tsx | 1 - .../Web3Profile/src/SNSAdaptor/components/ImageManagement.tsx | 2 +- .../Web3Profile/src/SNSAdaptor/components/WalletSetting.tsx | 2 +- packages/plugins/Web3Profile/src/locales/en-US.json | 3 ++- packages/shared/src/UI/components/NFTCard/index.tsx | 1 + 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/icons/general/LinkOut.tsx b/packages/icons/general/LinkOut.tsx index 3dfd945cc774..7d42b718ffe5 100644 --- a/packages/icons/general/LinkOut.tsx +++ b/packages/icons/general/LinkOut.tsx @@ -7,7 +7,6 @@ export const LinkOutIcon: typeof SvgIcon = createIcon( , diff --git a/packages/plugins/Web3Profile/src/SNSAdaptor/components/ImageManagement.tsx b/packages/plugins/Web3Profile/src/SNSAdaptor/components/ImageManagement.tsx index 69da446dd5e5..380c3f181f16 100644 --- a/packages/plugins/Web3Profile/src/SNSAdaptor/components/ImageManagement.tsx +++ b/packages/plugins/Web3Profile/src/SNSAdaptor/components/ImageManagement.tsx @@ -127,7 +127,7 @@ export function ImageManagement(props: ImageManagementProps) { )) ) : ( - + )} {!hasConnectedWallets && ( diff --git a/packages/plugins/Web3Profile/src/SNSAdaptor/components/WalletSetting.tsx b/packages/plugins/Web3Profile/src/SNSAdaptor/components/WalletSetting.tsx index fc28d84146cc..7a30bda13bbc 100644 --- a/packages/plugins/Web3Profile/src/SNSAdaptor/components/WalletSetting.tsx +++ b/packages/plugins/Web3Profile/src/SNSAdaptor/components/WalletSetting.tsx @@ -156,7 +156,7 @@ const WalletSetting = memo( -1, ), ) - }, [open]) + }, [open, wallets]) useEffect(() => { if (confirmButtonDisabled) setConfirmButtonDisabled(false) diff --git a/packages/plugins/Web3Profile/src/locales/en-US.json b/packages/plugins/Web3Profile/src/locales/en-US.json index b99a368308a5..8116d5297dfd 100644 --- a/packages/plugins/Web3Profile/src/locales/en-US.json +++ b/packages/plugins/Web3Profile/src/locales/en-US.json @@ -26,7 +26,8 @@ "copied": "Copied", "listed": "Listed", "unlisted": "Unlisted", - "add_wallet": "No connected wallet, pleae add wallet.", + "add_wallet": "Add Wallet", + "add_wallet_to_connected": "No connected wallet, pleae add wallet.", "open_wallet": "You’ve switched off all wallets. Please go to settings to active.", "tip_persona_sign_success": "Persona signed successfully.", "tip_wallet_sign_error": "Wallet connection failed.", diff --git a/packages/shared/src/UI/components/NFTCard/index.tsx b/packages/shared/src/UI/components/NFTCard/index.tsx index b9303adc712a..241ea284d505 100644 --- a/packages/shared/src/UI/components/NFTCard/index.tsx +++ b/packages/shared/src/UI/components/NFTCard/index.tsx @@ -67,6 +67,7 @@ const useStyles = makeStyles<{ networkPluginID: NetworkPluginID }>()((theme, pro display: 'flex', justifyContent: 'center', alignItems: 'center', + borderRadius: 12, }, image: { width: 126, From 6258961e6eeae90d7696dce9f1c7cdb6cfca1a37 Mon Sep 17 00:00:00 2001 From: lelenei <72531217+lelenei@users.noreply.github.com> Date: Fri, 8 Jul 2022 23:18:13 +0800 Subject: [PATCH 025/179] fix: add collectible dialog (#6729) --- packages/mask/src/components/shared/ApplicationBoard.tsx | 5 ++--- .../mask/src/components/shared/ApplicationRecommendArea.tsx | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/mask/src/components/shared/ApplicationBoard.tsx b/packages/mask/src/components/shared/ApplicationBoard.tsx index 0cc6a1221167..7780fc90ed7a 100644 --- a/packages/mask/src/components/shared/ApplicationBoard.tsx +++ b/packages/mask/src/components/shared/ApplicationBoard.tsx @@ -1,6 +1,5 @@ import { useState, useContext, createContext, PropsWithChildren, useMemo, useCallback, useEffect } from 'react' import { makeStyles, getMaskColor } from '@masknet/theme' -import { useTimeout } from 'react-use' import { Typography } from '@mui/material' import { useActivatedPluginsSNSAdaptor } from '@masknet/plugin-infra/content-script' import { useCurrentWeb3NetworkPluginID, useAccount, useChainId } from '@masknet/plugin-infra/web3' @@ -18,6 +17,7 @@ import { usePersonaAgainstSNSConnectStatus } from '../DataSource/usePersonaAgain import { WalletMessages } from '../../plugins/Wallet/messages' import { PersonaContext } from '../../extension/popups/pages/Personas/hooks/usePersonaContext' import { MaskMessages } from '../../../shared' +import { useTimeout } from 'react-use' const useStyles = makeStyles<{ shouldScroll: boolean; isCarouselReady: boolean }>()((theme, props) => { const smallQuery = `@media (max-width: ${theme.breakpoints.values.sm}px)` @@ -168,9 +168,8 @@ function ApplicationBoardContent(props: Props) { setIsHoveringCarousel(hover)} + setIsHoveringCarousel={setIsHoveringCarousel} /> {listedAppList.length > 0 ? ( diff --git a/packages/mask/src/components/shared/ApplicationRecommendArea.tsx b/packages/mask/src/components/shared/ApplicationRecommendArea.tsx index 2dbde990ff38..d09b82f690ed 100644 --- a/packages/mask/src/components/shared/ApplicationRecommendArea.tsx +++ b/packages/mask/src/components/shared/ApplicationRecommendArea.tsx @@ -42,7 +42,7 @@ const useStyles = makeStyles()(() => { interface Props { recommendFeatureAppList: Application[] RenderEntryComponent: (props: { application: Application }) => JSX.Element - isCarouselReady: () => boolean | null + isCarouselReady?: () => boolean | null setIsHoveringCarousel: (hover: boolean) => void isHoveringCarousel: boolean } @@ -61,7 +61,7 @@ export function ApplicationRecommendArea(props: Props) { return ( <> - {recommendFeatureAppList.length > 2 && isCarouselReady() ? ( + {recommendFeatureAppList.length > 2 && isCarouselReady?.() ? ( Date: Sat, 9 Jul 2022 09:17:19 +0800 Subject: [PATCH 026/179] fix: share button at pets dialog --- packages/mask/src/plugins/Pets/SNSAdaptor/PetDialog.tsx | 2 +- packages/mask/src/plugins/Pets/SNSAdaptor/PetShareDialog.tsx | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/mask/src/plugins/Pets/SNSAdaptor/PetDialog.tsx b/packages/mask/src/plugins/Pets/SNSAdaptor/PetDialog.tsx index 77ca0256bbc0..bad57c29ff2c 100644 --- a/packages/mask/src/plugins/Pets/SNSAdaptor/PetDialog.tsx +++ b/packages/mask/src/plugins/Pets/SNSAdaptor/PetDialog.tsx @@ -42,7 +42,7 @@ export function PetDialog() { onClose={handleClose} title={step === PetFriendNFTStep.SetFriendNFT ? t.pets_dialog_title() : t.pets_dialog_title_share()} titleBarIconStyle="back"> - + {step === PetFriendNFTStep.SetFriendNFT ? ( ) : ( diff --git a/packages/mask/src/plugins/Pets/SNSAdaptor/PetShareDialog.tsx b/packages/mask/src/plugins/Pets/SNSAdaptor/PetShareDialog.tsx index 7eeac16a1104..70b515a07ed7 100644 --- a/packages/mask/src/plugins/Pets/SNSAdaptor/PetShareDialog.tsx +++ b/packages/mask/src/plugins/Pets/SNSAdaptor/PetShareDialog.tsx @@ -8,6 +8,10 @@ import { Share_Twitter_TXT } from '../constants' const useStyles = makeStyles()((theme) => ({ root: { margin: theme.spacing(0, 2.5), + flex: 1, + display: 'flex', + flexDirection: 'column', + justifyContent: 'space-between', }, shareNotice: { color: theme.palette.maskColor.main, From 7d8c66c80230ddc846c0443fd3da74ed3c504344 Mon Sep 17 00:00:00 2001 From: UncleBill Date: Sat, 9 Jul 2022 11:00:18 +0800 Subject: [PATCH 027/179] fix: detecting scenechange (#6724) * fix: detecting scenechange * fix: follow up reviews * add useSceneChange hook --- .../main/sceneChange/twitter.ts | 2 +- .../twitter.com/collecting/identity.ts | 1 + .../mask/src/utils/hooks/useSceneChange.ts | 8 ++++ packages/web3-providers/src/twitter/index.ts | 37 +++++++++++++------ packages/web3-providers/src/types.ts | 2 +- 5 files changed, 37 insertions(+), 13 deletions(-) create mode 100644 packages/mask/src/utils/hooks/useSceneChange.ts diff --git a/packages/injected-script/main/sceneChange/twitter.ts b/packages/injected-script/main/sceneChange/twitter.ts index b8497f2ab688..5ff16de8d4c8 100644 --- a/packages/injected-script/main/sceneChange/twitter.ts +++ b/packages/injected-script/main/sceneChange/twitter.ts @@ -15,7 +15,7 @@ export function setupWatcherForTwitter() { const update = () => { const newFirstSlug = getFirstSlug() // reset to void wrong value - if (!firstSlug || apply(includes, TWITTER_RESERVED_SLUGS, [firstSlug])) { + if (!newFirstSlug || apply(includes, TWITTER_RESERVED_SLUGS, [newFirstSlug])) { const event = new no_xray_CustomEvent('scenechange', { detail: { scene: 'unknown' }, }) as WindowEventMap['scenechange'] 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 d394351bf86b..b0fabd0fb176 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 @@ -124,6 +124,7 @@ function resolveCurrentVisitingIdentityInner( ) { const update = async (twitterId: string) => { const user = await Twitter.getUserByScreenName(twitterId) + if (!user) return const bio = user.legacy.description const nickname = user.legacy.name diff --git a/packages/mask/src/utils/hooks/useSceneChange.ts b/packages/mask/src/utils/hooks/useSceneChange.ts new file mode 100644 index 000000000000..fd912c98c6ac --- /dev/null +++ b/packages/mask/src/utils/hooks/useSceneChange.ts @@ -0,0 +1,8 @@ +import { useEffect } from 'react' + +export function useSceneChange(handler: (event: WindowEventMap['scenechange']) => void) { + useEffect(() => { + window.addEventListener('scenechange', handler) + return () => window.removeEventListener('scenechange', handler) + }, [handler]) +} diff --git a/packages/web3-providers/src/twitter/index.ts b/packages/web3-providers/src/twitter/index.ts index f589576f5a7a..c0b8e02ec7c5 100644 --- a/packages/web3-providers/src/twitter/index.ts +++ b/packages/web3-providers/src/twitter/index.ts @@ -1,5 +1,6 @@ import { escapeRegExp } from 'lodash-unified' import urlcat from 'urlcat' +import LRUCache from 'lru-cache' import type { TwitterBaseAPI } from '../types' const UPLOAD_AVATAR_URL = 'https://upload.twitter.com/i/media/upload.json' @@ -117,6 +118,11 @@ async function getSettings(bearerToken: string, csrfToken: string): Promise({ + max: 20, + ttl: 300_000, +}) + export class TwitterAPI implements TwitterBaseAPI.Provider { async getSettings() { const { bearerToken, queryToken, csrfToken } = await getTokens() @@ -197,7 +203,7 @@ export class TwitterAPI implements TwitterBaseAPI.Provider { } } - async getUserByScreenName(screenName: string): Promise { + async getUserByScreenName(screenName: string): Promise { const { bearerToken, csrfToken, queryId } = await getTokens('UserByScreenName') const url = urlcat('https://twitter.com/i/api/graphql/:queryId/UserByScreenName', { queryId, @@ -207,17 +213,26 @@ export class TwitterAPI implements TwitterBaseAPI.Provider { withSuperFollowsUserFields: true, }), }) + const cacheKey = `${bearerToken}/${csrfToken}/${url}` + const fetchingTask: Promise = + cache.get(cacheKey) ?? + fetch(url, { + headers: { + authorization: `Bearer ${bearerToken}`, + 'x-csrf-token': csrfToken, + 'content-type': 'application/json', + 'x-twitter-auth-type': 'OAuth2Session', + 'x-twitter-active-user': 'yes', + referer: `https://twitter.com/${screenName}`, + }, + }) - const response = await fetch(url, { - headers: { - authorization: `Bearer ${bearerToken}`, - 'x-csrf-token': csrfToken, - 'content-type': 'application/json', - 'x-twitter-auth-type': 'OAuth2Session', - 'x-twitter-active-user': 'yes', - referer: `https://twitter.com/${screenName}`, - }, - }) + cache.set(cacheKey, fetchingTask) + const response = (await fetchingTask).clone() + if (!response.ok) { + cache.delete(cacheKey) + return null + } const userResponse: TwitterBaseAPI.UserByScreenNameResponse = await response.json() return userResponse.data.user.result } diff --git a/packages/web3-providers/src/types.ts b/packages/web3-providers/src/types.ts index a8150e067e8b..e6cbfc9ef785 100644 --- a/packages/web3-providers/src/types.ts +++ b/packages/web3-providers/src/types.ts @@ -531,7 +531,7 @@ export namespace TwitterBaseAPI { > uploadUserAvatar: (screenName: string, image: Blob | File) => Promise updateProfileImage: (screenName: string, media_id_str: string) => Promise - getUserByScreenName: (screenName: string) => Promise + getUserByScreenName: (screenName: string) => Promise } } From 1cd2c71945e2543d5a5702c6241eff7e1a689afb Mon Sep 17 00:00:00 2001 From: UncleBill Date: Sun, 10 Jul 2022 15:51:16 +0800 Subject: [PATCH 028/179] fix(tip): remove link and click to select on NFT item (#6736) --- .../Tips/components/NFTSection/NFTList.tsx | 33 +++++++------------ 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/packages/mask/src/plugins/Tips/components/NFTSection/NFTList.tsx b/packages/mask/src/plugins/Tips/components/NFTSection/NFTList.tsx index c3296c95f061..9a3db51223c5 100644 --- a/packages/mask/src/plugins/Tips/components/NFTSection/NFTList.tsx +++ b/packages/mask/src/plugins/Tips/components/NFTSection/NFTList.tsx @@ -2,9 +2,8 @@ import { useChainId, useCurrentWeb3NetworkPluginID, useWeb3State, Web3Helper } f import { ElementAnchor, NFTCardStyledAssetPlayer, RetryHint } from '@masknet/shared' import { LoadingBase, makeStyles } from '@masknet/theme' import { isSameAddress, NetworkPluginID, NonFungibleToken } from '@masknet/web3-shared-base' -import { Checkbox, Link, List, ListItem, Radio, Stack, Tooltip } from '@mui/material' +import { Checkbox, List, ListItem, Radio, Stack, Tooltip } from '@mui/material' import classnames from 'classnames' -import { noop } from 'lodash-unified' import { FC, useCallback } from 'react' import type { TipNFTKeyPair } from '../../types' @@ -153,13 +152,6 @@ export const NFTList: FC = ({ {tokens.map((token) => { const selected = includes(selectedPairs, [token.contract?.address!, token.tokenId]) const disabled = !isRadio && reachedLimit && !selected - const link = token.contract - ? Others?.explorerResolver?.nonFungibleTokenLink( - token.contract.chainId, - token.contract.address, - token.tokenId, - ) - : undefined const name = token.collection?.name || token.contract?.name const title = `${name} ${Others?.formatTokenId(token.tokenId, 2)}` return ( @@ -181,22 +173,19 @@ export const NFTList: FC = ({ [classes.disabled]: disabled, [classes.selected]: selected, [classes.unselected]: selectedPairs.length > 0 && !selected, - })}> - - - + })} + onClick={() => { + if (disabled) return + if (selected) { + toggleItem(null, '') + } else { + toggleItem(token.tokenId, token.contract?.address) + } + }}> + { - if (disabled) return - if (selected) { - toggleItem(null, '') - } else { - toggleItem(token.tokenId, token.contract?.address) - } - }} className={classes.checkbox} checked={selected} /> From c450676ba0ca47966d0ae6baac0c747d944b7f09 Mon Sep 17 00:00:00 2001 From: UncleBill Date: Sun, 10 Jul 2022 15:51:28 +0800 Subject: [PATCH 029/179] fix(Connection): use promise instead of function that return promise (#6740) --- packages/plugins/EVM/src/state/Connection/connection.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/plugins/EVM/src/state/Connection/connection.ts b/packages/plugins/EVM/src/state/Connection/connection.ts index 0da7171ec6e0..9516ddbf3c50 100644 --- a/packages/plugins/EVM/src/state/Connection/connection.ts +++ b/packages/plugins/EVM/src/state/Connection/connection.ts @@ -60,8 +60,8 @@ import { getReceiptStatus } from './utils' import { Web3StateSettings } from '../../settings' import { getSubscriptionCurrentValue, PartialRequired } from '@masknet/shared-base' -const EMPTY_STRING = () => Promise.resolve('') -const ZERO = () => Promise.resolve(0) +const EMPTY_STRING = Promise.resolve('') +const ZERO = Promise.resolve(0) export function isReadOnlyMethod(method: EthereumMethodType) { return [ From b384b093183b294505f1d60e0b57130586122bbf Mon Sep 17 00:00:00 2001 From: UncleBill Date: Sun, 10 Jul 2022 15:59:58 +0800 Subject: [PATCH 030/179] fix: some fixes for pending transaction (#6737) --- packages/mask/shared-ui/locales/en-US.json | 7 ++++--- .../src/components/InjectedComponents/ToolboxUnstyled.tsx | 2 -- .../components/shared/WalletStatusBox/TransactionList.tsx | 4 ++-- .../shared/WalletStatusBox/usePendingTransactions.tsx | 5 +---- packages/plugins/Web3Profile/src/locales/languages.ts | 4 +--- 5 files changed, 8 insertions(+), 14 deletions(-) diff --git a/packages/mask/shared-ui/locales/en-US.json b/packages/mask/shared-ui/locales/en-US.json index 901f2b8d58de..818f0871562b 100644 --- a/packages/mask/shared-ui/locales/en-US.json +++ b/packages/mask/shared-ui/locales/en-US.json @@ -212,7 +212,6 @@ "export": "Export", "wallet_status_bar_pending": "Pending", "wallet_load_retry": "Failed to load {{symbol}}. Click to retry.", - "wallet_status_bar_pending": "Pending", "wallet_name": "Wallet Name", "wallet_rename": "Rename Wallet", "wallet_loading_nft_contract": "Loading NFT contract...", @@ -252,7 +251,8 @@ "wallet_balance": "Balance", "wallet_balance_eth": "Balance(ETH)", "wallet_new": "New Wallet", - "wallet_status_pending": "Pending{{plural}}", + "wallet_status_pending_one": "{{count}} Pending", + "wallet_status_pending_other": "{{count}} Pendings", "wallet_status_pending_clear_all": "Clear All", "wallet_status_pending_clear": "Clear", "wallet_status_button_change": "Change", @@ -340,7 +340,8 @@ "plugin_wallet_on_create": "Create Wallet", "plugin_wallet_on_connect": "Connect Wallet", "plugin_wallet_wrong_network": "Wrong Network", - "plugin_wallet_pending_transactions": "{{count}} Pending{{plural}}", + "plugin_wallet_pending_transactions_one": "{{count}} Pending", + "plugin_wallet_pending_transactions_other": "{{count}} Pendings", "plugin_wallet_import_wallet": "Import Wallet", "plugin_wallet_select_provider_dialog_title": "Connect Wallet", "plugin_wallet_qr_code_with_wallet_connect": "Scan QR code with a WalletConnect-compatible wallet", diff --git a/packages/mask/src/components/InjectedComponents/ToolboxUnstyled.tsx b/packages/mask/src/components/InjectedComponents/ToolboxUnstyled.tsx index d86f569fe75a..a844efcda9cb 100644 --- a/packages/mask/src/components/InjectedComponents/ToolboxUnstyled.tsx +++ b/packages/mask/src/components/InjectedComponents/ToolboxUnstyled.tsx @@ -95,7 +95,6 @@ export function ToolboxHintUnstyled(props: ToolboxHintProps) { function ToolboxHintForApplication(props: ToolboxHintProps) { const { ListItemButton = MuiListItemButton, - ListItemIcon = MuiListItemIcon, Container = 'div', Typography = MuiTypography, iconSize = 24, @@ -243,7 +242,6 @@ function useToolbox() { {t('plugin_wallet_pending_transactions', { count: pendingTransactions.length, - plural: pendingTransactions.length > 1 ? 's' : '', })} diff --git a/packages/mask/src/components/shared/WalletStatusBox/TransactionList.tsx b/packages/mask/src/components/shared/WalletStatusBox/TransactionList.tsx index fdc4582e8cc4..b47affa9ce6c 100644 --- a/packages/mask/src/components/shared/WalletStatusBox/TransactionList.tsx +++ b/packages/mask/src/components/shared/WalletStatusBox/TransactionList.tsx @@ -58,14 +58,14 @@ const useStyles = makeStyles()((theme) => ({ }, linkIcon: { // TODO: replace with theme color - fill: theme.palette.mode === 'dark' ? '#F5F5F5' : '#07101B', + color: theme.palette.mode === 'dark' ? '#F5F5F5' : '#07101B', width: 17.5, height: 17.5, marginLeft: theme.spacing(0.5), }, clear: { fontSize: 14, - color: theme.palette.mode === 'light' ? MaskColorVar.blue : theme.palette.common.white, + color: MaskColorVar.blue, cursor: 'pointer', }, })) diff --git a/packages/mask/src/components/shared/WalletStatusBox/usePendingTransactions.tsx b/packages/mask/src/components/shared/WalletStatusBox/usePendingTransactions.tsx index 3ef54106328d..6ca4a8ba109c 100644 --- a/packages/mask/src/components/shared/WalletStatusBox/usePendingTransactions.tsx +++ b/packages/mask/src/components/shared/WalletStatusBox/usePendingTransactions.tsx @@ -59,10 +59,7 @@ export function usePendingTransactions() {
{pendingTransactions.length ? ( - {pendingTransactions.length}{' '} - {t('wallet_status_pending', { - plural: pendingTransactions.length > 1 ? 's' : '', - })} + {t('wallet_status_pending', { count: pendingTransactions.length })} ) : null}
diff --git a/packages/plugins/Web3Profile/src/locales/languages.ts b/packages/plugins/Web3Profile/src/locales/languages.ts index cff1155ab4cb..48c9a26a18f7 100644 --- a/packages/plugins/Web3Profile/src/locales/languages.ts +++ b/packages/plugins/Web3Profile/src/locales/languages.ts @@ -16,8 +16,6 @@ export const languages = { 'zh-CN': zh_CN, zh: zh_TW, } -import { createI18NBundle } from '@masknet/shared-base' -export const add__template__I18N = createI18NBundle('__template__', languages) // @ts-ignore if (import.meta.webpackHot) { // @ts-ignore @@ -27,7 +25,7 @@ if (import.meta.webpackHot) { globalThis.dispatchEvent?.( new CustomEvent('MASK_I18N_HMR', { detail: [ - '__template__', + 'io.mask.web3-profile', { en: en_US, ja: ja_JP, ko: ko_KR, qy: qya_AA, 'zh-CN': zh_CN, zh: zh_TW }, ], }), From d34c7a0bb6385f1cd3530c75ad5bbc00de62af20 Mon Sep 17 00:00:00 2001 From: Randolph314 <97870249+Randolph314@users.noreply.github.com> Date: Sun, 10 Jul 2022 17:02:34 +0800 Subject: [PATCH 031/179] fix: web3 profile bug (#6741) * feat: delete LinkOutIcon initial fill color * feat: refresh wallet setting date when wallets change * feat: change button name and collection style * feat: change nextId UI under web3 tab * fix: address display of menu * fix: copywriting of FindTruman * fix: donations and footprints display * feat: chang fundtruman copywriting Co-authored-by: Randolph <840094513@qq.com> --- packages/mask/shared-ui/locales/en-US.json | 3 ++- .../FindTruman/SNSAdaptor/FindTrumanDialog.tsx | 9 ++++----- .../src/plugins/FindTruman/locales/en-US.json | 3 ++- .../src/plugins/NextID/components/NextIdPage.tsx | 15 --------------- packages/plugins/RSS3/src/SNSAdaptor/TabCard.tsx | 10 ++++++---- packages/plugins/RSS3/src/SNSAdaptor/index.tsx | 8 +------- 6 files changed, 15 insertions(+), 33 deletions(-) diff --git a/packages/mask/shared-ui/locales/en-US.json b/packages/mask/shared-ui/locales/en-US.json index 818f0871562b..7fd4b4a393a2 100644 --- a/packages/mask/shared-ui/locales/en-US.json +++ b/packages/mask/shared-ui/locales/en-US.json @@ -210,7 +210,6 @@ "sharing": "Sharing", "transfer": "Transfer", "export": "Export", - "wallet_status_bar_pending": "Pending", "wallet_load_retry": "Failed to load {{symbol}}. Click to retry.", "wallet_name": "Wallet Name", "wallet_rename": "Rename Wallet", @@ -423,6 +422,8 @@ "plugin_savings_withdraw": "Withdraw", "plugin_savings_process_deposit": "Processing Deposit", "plugin_savings_process_withdraw": "Processing Withdrawal", + "plugin_findtruman_powered_by": "Powered By", + "plugin_findtruman_find_truman": "FindTruman", "plugin_trader_swap": "Swap", "plugin_trader_wrap": "Wrap", "plugin_trader_swap_from": "You sell", diff --git a/packages/mask/src/plugins/FindTruman/SNSAdaptor/FindTrumanDialog.tsx b/packages/mask/src/plugins/FindTruman/SNSAdaptor/FindTrumanDialog.tsx index 6fe99aa90272..6f2d69701e93 100644 --- a/packages/mask/src/plugins/FindTruman/SNSAdaptor/FindTrumanDialog.tsx +++ b/packages/mask/src/plugins/FindTruman/SNSAdaptor/FindTrumanDialog.tsx @@ -10,10 +10,9 @@ import { FindTrumanContext } from '../context' import { useAccount, useChainId } from '@masknet/plugin-infra/web3' import { useConst } from './hooks/useConst' import IntroductionPanel from './IntroductionPanel' -import { PluginWalletStatusBar } from '../../../utils' +import { PluginWalletStatusBar, useI18N } from '../../../utils' import { ChainBoundary } from '../../../web3/UI/ChainBoundary' import { NetworkPluginID } from '@masknet/web3-shared-base' -import { useI18N } from '../locales' const useStyles = makeStyles()((theme, props) => ({ wrapper: { @@ -77,7 +76,7 @@ interface FindTrumanDialogProps { } export function FindTrumanDialog(props: FindTrumanDialogProps) { - const i18N = useI18N() + const { t: i18N } = useI18N() const { open, onClose } = props const { classes } = useStyles() const account = useAccount() @@ -126,10 +125,10 @@ export function FindTrumanDialog(props: FindTrumanDialogProps) { color="textSecondary" fontSize={14} fontWeight={700}> - {i18N.powered_by()} + {i18N('plugin_findtruman_powered_by')}
- FindTruman + {i18N('plugin_findtruman_find_truman')} - - {t.verify_Twitter_ID_intro()} - {t.verify_Twitter_ID()} - - - - - - - ) - } - return ( <> diff --git a/packages/plugins/RSS3/src/SNSAdaptor/TabCard.tsx b/packages/plugins/RSS3/src/SNSAdaptor/TabCard.tsx index 247dca396a53..888796c26d09 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/TabCard.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/TabCard.tsx @@ -108,7 +108,10 @@ export function TabCard({ type, socialAddressList, persona }: TabCardProps) { className={classes.button}> {selectedAddress?.type === SocialAddressType.KV || selectedAddress?.type === SocialAddressType.ADDRESS ? ( - + ) : ( selectedAddress.label )} @@ -123,9 +126,8 @@ export function TabCard({ type, socialAddressList, persona }: TabCardProps) { {uniqBy(socialAddressList ?? [], (x) => x.address.toLowerCase()).map((x) => { return ( onSelect(x)}> - {selectedAddress?.type === SocialAddressType.KV || - selectedAddress?.type === SocialAddressType.ADDRESS ? ( - + {x?.type === SocialAddressType.KV || x?.type === SocialAddressType.ADDRESS ? ( + ) : ( x.label )} diff --git a/packages/plugins/RSS3/src/SNSAdaptor/index.tsx b/packages/plugins/RSS3/src/SNSAdaptor/index.tsx index 454adf7a5020..1d3e40b7a429 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/index.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/index.tsx @@ -12,13 +12,7 @@ function sorter(a: SocialAddress, z: SocialAddress>) { - return ( - addressNames?.some( - (x) => - (x.type === SocialAddressType.RSS3 || x.type === SocialAddressType.KV) && - x.networkSupporterPluginID === NetworkPluginID.PLUGIN_EVM, - ) ?? false - ) + return !!addressNames?.some((x) => x.networkSupporterPluginID === NetworkPluginID.PLUGIN_EVM) } const sns: Plugin.SNSAdaptor.Definition = { From ca30ba2603f98b9b16f7c94d4b0cab166a41f039 Mon Sep 17 00:00:00 2001 From: nuanyang233 Date: Mon, 11 Jul 2022 01:19:33 +0800 Subject: [PATCH 032/179] fix: incorrect gas config --- .../plugin-infra/src/web3/EVM/useGasConfig.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/plugin-infra/src/web3/EVM/useGasConfig.ts b/packages/plugin-infra/src/web3/EVM/useGasConfig.ts index 8846b45668e8..29c2648ad867 100644 --- a/packages/plugin-infra/src/web3/EVM/useGasConfig.ts +++ b/packages/plugin-infra/src/web3/EVM/useGasConfig.ts @@ -3,10 +3,14 @@ import { useAsync } from 'react-use' import { GasOptionConfig, formatGweiToWei, ChainId } from '@masknet/web3-shared-evm' import { GasOptionType, NetworkPluginID } from '@masknet/web3-shared-base' import { useGasOptions } from '../useGasOptions' +import { useWeb3State } from '../useWeb3State' // TODO: support multiple chain export function useGasConfig(chainId: ChainId) { const [gasConfig, setGasConfig] = useState() + const { Others } = useWeb3State(NetworkPluginID.PLUGIN_EVM) + const isEIP1559 = Others?.chainResolver.isSupport(chainId, 'EIP1559') + const { value: gasOptions_ } = useGasOptions(NetworkPluginID.PLUGIN_EVM) const { value: gasPrice } = useAsync(async () => { try { @@ -17,10 +21,16 @@ export function useGasConfig(chainId: ChainId) { gasOptions_?.[GasOptionType.NORMAL]?.suggestedMaxPriorityFeePerGas ?? 0, ).toFixed(0) - setGasConfig({ - maxFeePerGas, - maxPriorityFeePerGas, - }) + setGasConfig( + isEIP1559 + ? { + maxFeePerGas, + maxPriorityFeePerGas, + } + : { + gasPrice: maxFeePerGas, + }, + ) return maxFeePerGas } catch (err) { setGasConfig(undefined) From 1dac99a4e8c48004a8217e166c63668462ebc307 Mon Sep 17 00:00:00 2001 From: zhouhanseng Date: Mon, 11 Jul 2022 08:39:39 +0800 Subject: [PATCH 033/179] fix: mf 1404 --- .../plugins/Furucombo/UI/FurucomboView.tsx | 22 ++++--------------- 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/packages/mask/src/plugins/Furucombo/UI/FurucomboView.tsx b/packages/mask/src/plugins/Furucombo/UI/FurucomboView.tsx index 9db48c74425d..2b93051ef30c 100644 --- a/packages/mask/src/plugins/Furucombo/UI/FurucomboView.tsx +++ b/packages/mask/src/plugins/Furucombo/UI/FurucomboView.tsx @@ -1,10 +1,9 @@ import { useChainId } from '@masknet/plugin-infra/web3' import { isSameAddress, NetworkPluginID } from '@masknet/web3-shared-base' import { makeStyles, MaskColorVar } from '@masknet/theme' -import { Card, CardContent, Tabs, Tab, Typography, Paper, CircularProgress, Button, Stack, Box } from '@mui/material' +import { Card, CardContent, Tabs, Tab, Typography, Paper, CircularProgress, Button, Stack } from '@mui/material' import { useState } from 'react' import { useI18N } from '../../../utils/i18n-next-ui' -import { ChainBoundary } from '../../../web3/UI/ChainBoundary' import { useFetchPools } from '../hooks/usePool' import type { Investable } from '../types' import { InvestmentsView } from './InvestmentsView' @@ -88,19 +87,9 @@ export function FurucomboView(props: PoolViewProps) { if (!investable) return ( - <> - - {t('plugin_furucombo_pool_not_found')} - - - - - - + + {t('plugin_furucombo_pool_not_found')} + ) return ( @@ -123,9 +112,6 @@ export function FurucomboView(props: PoolViewProps) { - - - ) } From 41d50649e825688d377f1e263dd1a11778051911 Mon Sep 17 00:00:00 2001 From: zhouhanseng Date: Mon, 11 Jul 2022 08:43:49 +0800 Subject: [PATCH 034/179] chore: remove undefined locale key --- packages/mask/shared-ui/locales/qya-AA.json | 1 - packages/mask/src/utils/components/PluginWalletStatusBar.tsx | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/mask/shared-ui/locales/qya-AA.json b/packages/mask/shared-ui/locales/qya-AA.json index 0c61af603c7c..e6cb343c82ed 100644 --- a/packages/mask/shared-ui/locales/qya-AA.json +++ b/packages/mask/shared-ui/locales/qya-AA.json @@ -205,7 +205,6 @@ "sharing": "crwdns4469:0crwdne4469:0", "transfer": "crwdns4471:0crwdne4471:0", "export": "crwdns9305:0crwdne9305:0", - "wallet_status_bar_pending": "crwdns17546:0crwdne17546:0", "wallet_load_retry": "crwdns10135:0{{symbol}}crwdne10135:0", "wallet_name": "crwdns4487:0crwdne4487:0", "wallet_rename": "crwdns4489:0crwdne4489:0", diff --git a/packages/mask/src/utils/components/PluginWalletStatusBar.tsx b/packages/mask/src/utils/components/PluginWalletStatusBar.tsx index cb25fbf6494c..d6a43e5da0f0 100644 --- a/packages/mask/src/utils/components/PluginWalletStatusBar.tsx +++ b/packages/mask/src/utils/components/PluginWalletStatusBar.tsx @@ -212,7 +212,7 @@ export function PluginWalletStatusBar({ e.stopPropagation() openWalletStatusDialog() }}> - {t('wallet_status_bar_pending')} + {t('recent_transaction_pending')} ) : null} From fa631a17ce74dcbc8fc380d40869837bf2a1d92e Mon Sep 17 00:00:00 2001 From: zhouhanseng Date: Mon, 11 Jul 2022 08:58:44 +0800 Subject: [PATCH 035/179] fix: type error --- packages/mask/src/components/shared/ApplicationBoard.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/mask/src/components/shared/ApplicationBoard.tsx b/packages/mask/src/components/shared/ApplicationBoard.tsx index 7780fc90ed7a..df1df8a44f8d 100644 --- a/packages/mask/src/components/shared/ApplicationBoard.tsx +++ b/packages/mask/src/components/shared/ApplicationBoard.tsx @@ -235,8 +235,7 @@ function RenderEntryComponent({ application }: { application: Application }) { const clickHandler = useMemo(() => { if (application.isWalletConnectedRequired || application.isWalletConnectedEVMRequired) { - return (walletConnectedCallback?: () => void) => - setSelectProviderDialog({ open: true, walletConnectedCallback }) + return (walletConnectedCallback?: () => void) => setSelectProviderDialog({ open: true }) } if (!application.entry.nextIdRequired) return if (ApplicationEntryStatus.isPersonaConnected === false || ApplicationEntryStatus.isPersonaCreated === false) From 31e31c637dbe170978d2d8377ff69472de0416c8 Mon Sep 17 00:00:00 2001 From: zhouhanseng Date: Mon, 11 Jul 2022 10:06:02 +0800 Subject: [PATCH 036/179] fix: mf 1365 --- packages/mask/src/plugins/RedPacket/SNSAdaptor/index.tsx | 1 + packages/plugin-infra/src/types.ts | 1 + .../shared/src/UI/components/ApplicationEntry/index.tsx | 9 ++++++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/mask/src/plugins/RedPacket/SNSAdaptor/index.tsx b/packages/mask/src/plugins/RedPacket/SNSAdaptor/index.tsx index b052fd414538..ab225bc6139c 100644 --- a/packages/mask/src/plugins/RedPacket/SNSAdaptor/index.tsx +++ b/packages/mask/src/plugins/RedPacket/SNSAdaptor/index.tsx @@ -93,6 +93,7 @@ const sns: Plugin.SNSAdaptor.Definition = { const recommendFeature = { description: , backgroundGradient: 'linear-gradient(180.54deg, #FF9A9E 0.71%, #FECFEF 98.79%, #FECFEF 99.78%)', + isFirst: true, } return { ApplicationEntryID: base.ID, diff --git a/packages/plugin-infra/src/types.ts b/packages/plugin-infra/src/types.ts index 35c32492029d..de1241da56ee 100644 --- a/packages/plugin-infra/src/types.ts +++ b/packages/plugin-infra/src/types.ts @@ -547,6 +547,7 @@ export namespace Plugin.SNSAdaptor { recommendFeature?: { description: React.ReactNode backgroundGradient: string + isFirst?: boolean } } diff --git a/packages/shared/src/UI/components/ApplicationEntry/index.tsx b/packages/shared/src/UI/components/ApplicationEntry/index.tsx index faaf122c198d..b7cffde3258c 100644 --- a/packages/shared/src/UI/components/ApplicationEntry/index.tsx +++ b/packages/shared/src/UI/components/ApplicationEntry/index.tsx @@ -55,8 +55,12 @@ const useStyles = makeStyles<{ disabled: boolean; iconFilterColor?: string }>()( color: theme.palette.mode === 'light' ? theme.palette.common.white : theme.palette.common.black, }, arrow: { + marginLeft: '-12px', color: theme.palette.mode === 'light' ? theme.palette.common.black : theme.palette.common.white, }, + firstAreaArrow: { + marginLeft: '12px !important', + }, recommendFeatureApplicationBox: { width: 220, minWidth: 220, @@ -139,7 +143,10 @@ export function ApplicationEntry(props: ApplicationEntryProps) { disablePortal: true, placement: recommendFeature ? 'bottom' : 'top', }} - classes={{ tooltip: classes.tooltip, arrow: classes.arrow }} + classes={{ + tooltip: classes.tooltip, + arrow: classNames(classes.arrow, recommendFeature?.isFirst ? classes.firstAreaArrow : ''), + }} placement={recommendFeature ? 'bottom' : 'top'} arrow disableHoverListener={!tooltipHint} From e918990e84bacd4cdb4ae47fa6be1bd562a211a6 Mon Sep 17 00:00:00 2001 From: Lantt Date: Mon, 11 Jul 2022 11:16:52 +0800 Subject: [PATCH 037/179] fix: token id maybe is string in alchemy --- packages/web3-providers/src/alchemy/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/web3-providers/src/alchemy/index.ts b/packages/web3-providers/src/alchemy/index.ts index fd8a9599c3a6..f9b841b335d0 100644 --- a/packages/web3-providers/src/alchemy/index.ts +++ b/packages/web3-providers/src/alchemy/index.ts @@ -146,7 +146,7 @@ function createNftToken_EVM( asset: AlchemyNFT_EVM, ): NonFungibleAsset { const contractAddress = asset.contract?.address - const tokenId = Number.parseInt(asset.id?.tokenId, 16).toString() + const tokenId = asset.id?.tokenId ?? '' return { id: `${contractAddress}_${tokenId}`, @@ -257,7 +257,7 @@ function createNftToken_FLOW( chainId, type: TokenType.NonFungible, schema: SchemaType_FLOW.NonFungible, - tokenId: Number.parseInt(asset.id?.tokenId, 16).toString(), + tokenId: asset.id?.tokenId ?? '', address: asset.contract?.address, metadata: { chainId, @@ -300,7 +300,7 @@ function createNFTAsset_FLOW( chainId, type: TokenType.NonFungible, schema: SchemaType_FLOW.NonFungible, - tokenId: Number.parseInt(metaDataResponse.id?.tokenId, 16).toString(), + tokenId: metaDataResponse.id?.tokenId ?? '', address: metaDataResponse.contract?.address, metadata: { chainId, From f84a883a5957fa0b4510b21c4852473b07473203 Mon Sep 17 00:00:00 2001 From: UncleBill Date: Mon, 11 Jul 2022 11:22:37 +0800 Subject: [PATCH 038/179] fix: hide buy button on NFT trending (#6738) --- .../plugins/Trader/SNSAdaptor/trending/TrendingViewDeck.tsx | 4 ++-- packages/mask/src/plugins/Trader/trending/useTrending.ts | 2 +- packages/plugins/GoPlusSecurity/src/SNSAdaptor/index.tsx | 2 +- packages/web3-providers/src/coingecko/base-api.ts | 2 +- packages/web3-providers/src/coingecko/index.ts | 2 ++ 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/mask/src/plugins/Trader/SNSAdaptor/trending/TrendingViewDeck.tsx b/packages/mask/src/plugins/Trader/SNSAdaptor/trending/TrendingViewDeck.tsx index 45179cb1a0bf..549f9909e4ae 100644 --- a/packages/mask/src/plugins/Trader/SNSAdaptor/trending/TrendingViewDeck.tsx +++ b/packages/mask/src/plugins/Trader/SNSAdaptor/trending/TrendingViewDeck.tsx @@ -157,10 +157,10 @@ export function TrendingViewDeck(props: TrendingViewDeckProps) { isTokenSecurityEnable, ) + const isBuyable = !isNFT && transakPluginEnabled && !transakIsMinimalMode && trending.coin.symbol && isAllowanceCoin const onBuyButtonClicked = useCallback(() => { setBuyDialog({ open: true, - // @ts-ignore code: coin.symbol, address: account, }) @@ -293,7 +293,7 @@ export function TrendingViewDeck(props: TrendingViewDeckProps) { - {transakPluginEnabled && !transakIsMinimalMode && trending.coin.symbol && isAllowanceCoin ? ( + {isBuyable ? ( + ) : null} @@ -292,21 +308,6 @@ export function TrendingViewDeck(props: TrendingViewDeckProps) { - - {isBuyable ? ( - - ) : null} - From 378da47f601be1c0c6818bff168869dc64a6d8ae Mon Sep 17 00:00:00 2001 From: Lantt Date: Mon, 11 Jul 2022 14:30:37 +0800 Subject: [PATCH 042/179] fix: tab text hover color --- packages/theme/src/Components/Tabs/BaseTab.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/theme/src/Components/Tabs/BaseTab.tsx b/packages/theme/src/Components/Tabs/BaseTab.tsx index f0987e722af7..0ab28eab4c8b 100644 --- a/packages/theme/src/Components/Tabs/BaseTab.tsx +++ b/packages/theme/src/Components/Tabs/BaseTab.tsx @@ -21,7 +21,6 @@ const BaseTabWrap = styled(Button, { '&:hover': { boxShadow: activated ? '0 0 20px rgba(0, 0, 0, 0.05)' : 'none', background: activated ? theme.palette.maskColor.bottom : 'transparent', - color: theme.palette.maskColor.main, }, })) From ba5820c1ed7f1dd2e8cfd987b9f47096263f3453 Mon Sep 17 00:00:00 2001 From: UncleBill Date: Mon, 11 Jul 2022 14:54:12 +0800 Subject: [PATCH 043/179] fix: mf-1409 style of scrollbar (#6746) --- .../components/SelectTokenDialog/index.tsx | 26 ------------------- .../components/shared/ApplicationBoard.tsx | 4 +-- .../twitter.com/customization/custom.ts | 18 +++++++++++++ .../components/SelectFungibleTokenDialog.tsx | 3 +++ .../SearchableList/SearchableList.tsx | 5 +++- 5 files changed, 27 insertions(+), 29 deletions(-) delete mode 100644 packages/dashboard/src/pages/Wallets/components/SelectTokenDialog/index.tsx diff --git a/packages/dashboard/src/pages/Wallets/components/SelectTokenDialog/index.tsx b/packages/dashboard/src/pages/Wallets/components/SelectTokenDialog/index.tsx deleted file mode 100644 index 10528de822ea..000000000000 --- a/packages/dashboard/src/pages/Wallets/components/SelectTokenDialog/index.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import { memo } from 'react' -import { MaskDialog } from '@masknet/theme' -import { useDashboardI18N } from '../../../../locales' -import { FungibleTokenList } from '@masknet/shared' -import { DialogContent } from '@mui/material' -import type { FungibleToken } from '@masknet/web3-shared-base' -import type { ChainId, SchemaType } from '@masknet/web3-shared-evm' - -export interface SelectTokenDialogProps { - open: boolean - onClose: () => void - onSelect?(token: FungibleToken | null): void -} - -// todo use remote dialog for add token list dialog -export const SelectTokenDialog = memo(({ open, onClose, onSelect }) => { - const t = useDashboardI18N() - - return ( - - - - - - ) -}) diff --git a/packages/mask/src/components/shared/ApplicationBoard.tsx b/packages/mask/src/components/shared/ApplicationBoard.tsx index df1df8a44f8d..a00dfbb31f7c 100644 --- a/packages/mask/src/components/shared/ApplicationBoard.tsx +++ b/packages/mask/src/components/shared/ApplicationBoard.tsx @@ -23,7 +23,7 @@ const useStyles = makeStyles<{ shouldScroll: boolean; isCarouselReady: boolean } const smallQuery = `@media (max-width: ${theme.breakpoints.values.sm}px)` return { applicationWrapper: { - padding: theme.spacing(props.isCarouselReady ? 0 : 1, 0.25, 1), + paddingTop: theme.spacing(1), display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', overflowY: 'auto', @@ -38,7 +38,7 @@ const useStyles = makeStyles<{ shouldScroll: boolean; isCarouselReady: boolean } width: 20, }, '::-webkit-scrollbar-thumb': { - borderRadius: '20px', + borderRadius: 20, width: 5, border: '7px solid rgba(0, 0, 0, 0)', backgroundColor: theme.palette.maskColor.secondaryLine, diff --git a/packages/mask/src/social-network-adaptor/twitter.com/customization/custom.ts b/packages/mask/src/social-network-adaptor/twitter.com/customization/custom.ts index 6ce8b5973fed..e837f65e9c85 100644 --- a/packages/mask/src/social-network-adaptor/twitter.com/customization/custom.ts +++ b/packages/mask/src/social-network-adaptor/twitter.com/customization/custom.ts @@ -118,6 +118,24 @@ export function useThemeTwitterVariant(baseTheme: Theme) { }, }, } + theme.components.MuiDialogContent = { + styleOverrides: { + root: { + paddingRight: 4, + '::-webkit-scrollbar': { + backgroundColor: 'transparent', + width: 20, + }, + '::-webkit-scrollbar-thumb': { + borderRadius: 20, + width: 5, + border: '7px solid rgba(0, 0, 0, 0)', + backgroundColor: theme.palette.maskColor.secondaryLine, + backgroundClip: 'padding-box', + }, + }, + }, + } theme.components.MuiSnackbar = { styleOverrides: { root: { diff --git a/packages/shared/src/contexts/components/SelectFungibleTokenDialog.tsx b/packages/shared/src/contexts/components/SelectFungibleTokenDialog.tsx index 3c12d01f9382..b580e4363ba3 100644 --- a/packages/shared/src/contexts/components/SelectFungibleTokenDialog.tsx +++ b/packages/shared/src/contexts/components/SelectFungibleTokenDialog.tsx @@ -19,6 +19,9 @@ const useStyles = makeStyles()((theme, { compact, disablePaddingTop ...(compact ? { minWidth: 552 } : {}), padding: theme.spacing(3), paddingTop: disablePaddingTop ? 0 : theme.spacing(2.8), + display: 'flex', + flexDirection: 'column', + overflow: 'auto', }, list: { scrollbarWidth: 'none', diff --git a/packages/theme/src/Components/SearchableList/SearchableList.tsx b/packages/theme/src/Components/SearchableList/SearchableList.tsx index 28f642d090dd..e5f4c91c21db 100644 --- a/packages/theme/src/Components/SearchableList/SearchableList.tsx +++ b/packages/theme/src/Components/SearchableList/SearchableList.tsx @@ -136,8 +136,11 @@ export function SearchableList({ ) } const useStyles = makeStyles()((theme) => ({ - container: {}, + container: { + overflow: 'hidden', + }, list: { + overflow: 'auto', marginTop: theme.spacing(1.5), '& > div::-webkit-scrollbar': { width: '7px', From a1c9f304584ea03e9fca77d968ba7fc7c3f94530 Mon Sep 17 00:00:00 2001 From: Lantt Date: Mon, 11 Jul 2022 14:59:35 +0800 Subject: [PATCH 044/179] style: dashboard swap background --- .../plugins/Trader/SNSAdaptor/trader/TraderDialog.tsx | 8 +++++++- .../mask/src/utils/components/PluginWalletStatusBar.tsx | 9 +++++++-- packages/theme/src/Components/Tabs/index.tsx | 1 + 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/mask/src/plugins/Trader/SNSAdaptor/trader/TraderDialog.tsx b/packages/mask/src/plugins/Trader/SNSAdaptor/trader/TraderDialog.tsx index 349fc3be830f..d76c6f43180e 100644 --- a/packages/mask/src/plugins/Trader/SNSAdaptor/trader/TraderDialog.tsx +++ b/packages/mask/src/plugins/Trader/SNSAdaptor/trader/TraderDialog.tsx @@ -11,7 +11,7 @@ import { TargetChainIdContext } from '@masknet/plugin-infra/web3-evm' import { PluginTraderMessages } from '../../messages' import { Trader, TraderRef, TraderProps } from './Trader' import { useI18N } from '../../../../utils' -import { makeStyles } from '@masknet/theme' +import { makeStyles, MaskColorVar } from '@masknet/theme' import { NetworkTab } from '../../../../components/shared/NetworkTab' import { useUpdateEffect } from 'react-use' import { NetworkPluginID } from '@masknet/web3-shared-base' @@ -28,6 +28,12 @@ const useStyles = makeStyles()((theme) => ({ position: 'sticky', top: 0, zIndex: 2, + + '& > div .MuiBox-root': isDashboard + ? { + background: MaskColorVar.mainBackground, + } + : {}, }, indicator: { display: 'none', diff --git a/packages/mask/src/utils/components/PluginWalletStatusBar.tsx b/packages/mask/src/utils/components/PluginWalletStatusBar.tsx index d6a43e5da0f0..ba08a4d784c3 100644 --- a/packages/mask/src/utils/components/PluginWalletStatusBar.tsx +++ b/packages/mask/src/utils/components/PluginWalletStatusBar.tsx @@ -14,13 +14,14 @@ import { import { WalletMessages } from '@masknet/plugin-wallet' import { ImageIcon, WalletIcon } from '@masknet/shared' import { useRemoteControlledDialog } from '@masknet/shared-base-ui' -import { makeStyles, parseColor } from '@masknet/theme' +import { makeStyles, MaskColorVar, parseColor } from '@masknet/theme' import { NetworkPluginID, TransactionStatusType, Wallet } from '@masknet/web3-shared-base' import { Box, Button, CircularProgress, Link, Typography } from '@mui/material' import { useI18N } from '../i18n-next-ui' import { LinkOutIcon, ArrowDropIcon, PluginWalletConnectIcon } from '@masknet/icons' import { useLayoutEffect, useRef, useState, PropsWithChildren } from 'react' import { ChainId, ProviderType } from '@masknet/web3-shared-evm' +import { isDashboardPage } from '@masknet/shared-base' interface WalletStatusBarProps extends PropsWithChildren<{}> { className?: string @@ -34,11 +35,15 @@ interface WalletStatusBarProps extends PropsWithChildren<{}> { expectedChainIdOrNetworkTypeOrID?: string | number } +const isDashboard = isDashboardPage() + const useStyles = makeStyles()((theme) => ({ root: { boxSizing: 'content-box', display: 'flex', - backgroundColor: parseColor(theme.palette.maskColor.bottom).setAlpha(0.8).toRgbString(), + backgroundColor: isDashboard + ? MaskColorVar.mainBackground + : parseColor(theme.palette.maskColor.bottom).setAlpha(0.8).toRgbString(), boxShadow: `0 0 20px ${parseColor(theme.palette.maskColor.highlight).setAlpha(0.05).toRgbString()}`, backdropFilter: 'blur(16px)', padding: theme.spacing(2), diff --git a/packages/theme/src/Components/Tabs/index.tsx b/packages/theme/src/Components/Tabs/index.tsx index 07bcbdf88252..85561051ca00 100644 --- a/packages/theme/src/Components/Tabs/index.tsx +++ b/packages/theme/src/Components/Tabs/index.tsx @@ -63,6 +63,7 @@ const FlexibleButtonGroupPanel = styled(Box, { : 'none', backdropFilter: 'blur(20px)', background: theme.palette.mode === 'dark' ? 'rgba(0, 0, 0, 0.8)' : 'rgba(255, 255, 255, 0.8)', + boxSizing: 'content-box', })) const ButtonGroupWrap = styled(ButtonGroup, { From d57daf5fb10fdc84437dc93d6651d3cdf380586d Mon Sep 17 00:00:00 2001 From: nuanyang233 Date: Mon, 11 Jul 2022 15:08:08 +0800 Subject: [PATCH 045/179] fix: wallet connect callback --- packages/mask/src/components/shared/ApplicationBoard.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/mask/src/components/shared/ApplicationBoard.tsx b/packages/mask/src/components/shared/ApplicationBoard.tsx index a00dfbb31f7c..ebb9f4500f28 100644 --- a/packages/mask/src/components/shared/ApplicationBoard.tsx +++ b/packages/mask/src/components/shared/ApplicationBoard.tsx @@ -235,7 +235,8 @@ function RenderEntryComponent({ application }: { application: Application }) { const clickHandler = useMemo(() => { if (application.isWalletConnectedRequired || application.isWalletConnectedEVMRequired) { - return (walletConnectedCallback?: () => void) => setSelectProviderDialog({ open: true }) + return (walletConnectedCallback?: () => void) => + setSelectProviderDialog({ open: true, walletConnectedCallback }) } if (!application.entry.nextIdRequired) return if (ApplicationEntryStatus.isPersonaConnected === false || ApplicationEntryStatus.isPersonaCreated === false) From 09f728e4969e48854714f9d8eee3dbcc51563c78 Mon Sep 17 00:00:00 2001 From: nuanyang233 Date: Mon, 11 Jul 2022 15:33:02 +0800 Subject: [PATCH 046/179] fix: replace web3 to connection (#6751) * fix: replace web3 to connection in trader plugin * fix: bugfix --- .../trader/components/ConfirmDialogUI.tsx | 4 +- .../Trader/trader/0x/useTradeCallback.ts | 31 +++---- .../trader/balancer/useTradeCallback.ts | 71 ++++++++-------- .../Trader/trader/bancor/useTradeCallback.ts | 32 +++---- .../Trader/trader/dodo/useTradeCallback.ts | 28 +++---- .../trader/openocean/useTradeCallback.ts | 27 +++--- .../Trader/trader/uniswap/useTradeCallback.ts | 84 ++++++++++--------- packages/web3-constants/evm/trader.json | 4 +- packages/web3-shared/base/src/specs/index.ts | 45 +++++++--- 9 files changed, 163 insertions(+), 163 deletions(-) diff --git a/packages/mask/src/plugins/Trader/SNSAdaptor/trader/components/ConfirmDialogUI.tsx b/packages/mask/src/plugins/Trader/SNSAdaptor/trader/components/ConfirmDialogUI.tsx index 3e4fa376cc4b..559890b48140 100644 --- a/packages/mask/src/plugins/Trader/SNSAdaptor/trader/components/ConfirmDialogUI.tsx +++ b/packages/mask/src/plugins/Trader/SNSAdaptor/trader/components/ConfirmDialogUI.tsx @@ -323,7 +323,7 @@ export const ConfirmDialogUI = memo( - + ( - + | null, gasConfig?: GasOptionConfig) { const { targetChainId: chainId } = TargetChainIdContext.useContainer() const account = useAccount(NetworkPluginID.PLUGIN_EVM) - const web3 = useWeb3(NetworkPluginID.PLUGIN_EVM, { chainId }) + const connection = useWeb3Connection(NetworkPluginID.PLUGIN_EVM, { chainId }) // compose transaction config const config = useMemo(() => { @@ -27,28 +27,23 @@ export function useTradeCallback(tradeComputed: TradeComputed return useAsyncFn(async () => { // validate config - if (!web3 || !account || !config || !tradeComputed) { + if (!account || !config || !tradeComputed || !connection) { return } const config_ = { ...config, - gas: await web3.eth - .estimateGas({ + gas: + (await connection.estimateTransaction?.({ from: account, ...pick(tradeComputed.trade_, ['to', 'data', 'value']), - }) - .catch(() => 0), + })) ?? ZERO.toString(), } // send transaction and wait for hash - return new Promise((resolve, reject) => { - web3.eth - .sendTransaction(config_) - .on(TransactionEventType.CONFIRMATION, (_, receipt) => { - resolve(receipt.transactionHash) - }) - .on(TransactionEventType.ERROR, reject) - }) - }, [web3, account, chainId, stringify(config), gasConfig]) + const hash = await connection.sendTransaction(config_) + const receipt = await connection.getTransactionReceipt(hash) + + return receipt?.transactionHash + }, [connection, account, chainId, stringify(config), gasConfig]) } diff --git a/packages/mask/src/plugins/Trader/trader/balancer/useTradeCallback.ts b/packages/mask/src/plugins/Trader/trader/balancer/useTradeCallback.ts index da77ea446aac..b777653083d6 100644 --- a/packages/mask/src/plugins/Trader/trader/balancer/useTradeCallback.ts +++ b/packages/mask/src/plugins/Trader/trader/balancer/useTradeCallback.ts @@ -1,12 +1,16 @@ import type { ExchangeProxy } from '@masknet/web3-contracts/types/ExchangeProxy' -import type { PayableTx } from '@masknet/web3-contracts/types/types' -import { SchemaType, GasOptionConfig, TransactionEventType, useTraderConstants } from '@masknet/web3-shared-evm' +import { + SchemaType, + GasOptionConfig, + useTraderConstants, + encodeContractTransaction +} from '@masknet/web3-shared-evm' import { useAsyncFn } from 'react-use' import { SLIPPAGE_DEFAULT } from '../../constants' import { SwapResponse, TradeComputed, TradeStrategy } from '../../types' import { TargetChainIdContext } from '@masknet/plugin-infra/web3-evm' -import { useAccount } from '@masknet/plugin-infra/web3' -import { NetworkPluginID } from '@masknet/web3-shared-base' +import { useAccount, useWeb3Connection } from '@masknet/plugin-infra/web3' +import { NetworkPluginID, ZERO } from '@masknet/web3-shared-base' import { useTradeAmount } from './useTradeAmount' export function useTradeCallback( @@ -18,7 +22,7 @@ export function useTradeCallback( const account = useAccount(NetworkPluginID.PLUGIN_EVM) const { targetChainId: chainId } = TargetChainIdContext.useContainer() const { BALANCER_ETH_ADDRESS } = useTraderConstants(chainId) - + const connection = useWeb3Connection() const tradeAmount = useTradeAmount(trade, allowedSlippage) return useAsyncFn(async () => { @@ -51,21 +55,6 @@ export function useTradeCallback( const outputTokenAddress = trade.outputToken.schema === SchemaType.Native ? BALANCER_ETH_ADDRESS : trade.outputToken.address - const tx = - trade.strategy === TradeStrategy.ExactIn - ? exchangeProxyContract.methods.multihopBatchSwapExactIn( - swap_, - inputTokenAddress, - outputTokenAddress, - trade.inputAmount.toFixed(), - tradeAmount.toFixed(), - ) - : exchangeProxyContract.methods.multihopBatchSwapExactOut( - swap_, - inputTokenAddress, - outputTokenAddress, - tradeAmount.toFixed(), - ) // trade with the native token let transactionValue = '0' @@ -77,27 +66,37 @@ export function useTradeCallback( // send transaction and wait for hash const config = { from: account, - gas: await tx - .estimateGas({ + gas: await connection + .estimateTransaction?.({ from: account, value: transactionValue, - }) - .catch((error: Error) => { - throw error - }), + }) ?? ZERO.toString(), value: transactionValue, ...gasConfig, } + + const tx = await encodeContractTransaction(exchangeProxyContract, trade.strategy === TradeStrategy.ExactIn + ? exchangeProxyContract.methods.multihopBatchSwapExactIn( + swap_, + inputTokenAddress, + outputTokenAddress, + trade.inputAmount.toFixed(), + tradeAmount.toFixed(), + ) + : exchangeProxyContract.methods.multihopBatchSwapExactOut( + swap_, + inputTokenAddress, + outputTokenAddress, + tradeAmount.toFixed(), + ), config) + + + // send transaction and wait for hash - return new Promise((resolve, reject) => { - tx.send(config as PayableTx) - .on(TransactionEventType.CONFIRMATION, (_, receipt) => { - resolve(receipt.transactionHash) - }) - .on(TransactionEventType.ERROR, (error) => { - reject(error) - }) - }) - }, [chainId, trade, tradeAmount, exchangeProxyContract, BALANCER_ETH_ADDRESS]) + const hash = await connection.sendTransaction(tx) + const receipt = await connection.getTransactionReceipt(hash) + + return receipt?.transactionHash + }, [chainId, trade, tradeAmount, exchangeProxyContract, BALANCER_ETH_ADDRESS, connection]) } diff --git a/packages/mask/src/plugins/Trader/trader/bancor/useTradeCallback.ts b/packages/mask/src/plugins/Trader/trader/bancor/useTradeCallback.ts index 3df5e15598d4..f7d91416aa61 100644 --- a/packages/mask/src/plugins/Trader/trader/bancor/useTradeCallback.ts +++ b/packages/mask/src/plugins/Trader/trader/bancor/useTradeCallback.ts @@ -2,16 +2,16 @@ import { pick } from 'lodash-unified' import { useMemo } from 'react' import { useAsyncFn } from 'react-use' import stringify from 'json-stable-stringify' -import { NetworkPluginID } from '@masknet/web3-shared-base' -import { useAccount, useWeb3 } from '@masknet/plugin-infra/web3' -import { GasOptionConfig, TransactionEventType } from '@masknet/web3-shared-evm' +import { NetworkPluginID, ZERO } from '@masknet/web3-shared-base' +import { useAccount, useWeb3Connection } from '@masknet/plugin-infra/web3' +import type { GasOptionConfig } from '@masknet/web3-shared-evm' import { PluginTraderRPC } from '../../messages' import type { SwapBancorRequest, TradeComputed } from '../../types' import { TargetChainIdContext } from '@masknet/plugin-infra/web3-evm' export function useTradeCallback(tradeComputed: TradeComputed | null, gasConfig?: GasOptionConfig) { const { targetChainId: chainId } = TargetChainIdContext.useContainer() - const web3 = useWeb3(NetworkPluginID.PLUGIN_EVM, { chainId }) + const connection = useWeb3Connection(NetworkPluginID.PLUGIN_EVM, { chainId }) const account = useAccount(NetworkPluginID.PLUGIN_EVM) const trade: SwapBancorRequest | null = useMemo(() => { @@ -20,14 +20,13 @@ export function useTradeCallback(tradeComputed: TradeComputed }, [account, tradeComputed]) return useAsyncFn(async () => { - if (!account || !trade || !web3) { + if (!account || !trade || !connection) { return } const [data, err] = await PluginTraderRPC.swapTransactionBancor(trade) if (err) { - const error = new Error(err.error.messages?.[0] || 'Unknown Error') - throw error + throw new Error(err.error.messages?.[0] || 'Unknown Error') } // Note that if approval is required, the API will also return the necessary approval transaction. @@ -36,20 +35,15 @@ export function useTradeCallback(tradeComputed: TradeComputed const config = pick(tradeTransaction.transaction, ['to', 'data', 'value', 'from']) const config_ = { ...config, - gas: await web3.eth.estimateGas(config).catch((error) => { - throw error - }), + gas: (await connection.estimateTransaction?.(config)) ?? ZERO.toString(), ...gasConfig, } // send transaction and wait for hash - return new Promise((resolve, reject) => { - web3.eth - .sendTransaction(config_) - .on(TransactionEventType.ERROR, reject) - .on(TransactionEventType.CONFIRMATION, (_, receipt) => { - resolve(receipt.transactionHash) - }) - }) - }, [web3, account, chainId, stringify(trade), gasConfig]) + + const hash = await connection.sendTransaction(config_) + const receipt = await connection.getTransactionReceipt(hash) + + return receipt?.transactionHash + }, [connection, account, chainId, stringify(trade), gasConfig]) } diff --git a/packages/mask/src/plugins/Trader/trader/dodo/useTradeCallback.ts b/packages/mask/src/plugins/Trader/trader/dodo/useTradeCallback.ts index da5fbc34b972..f446521c02af 100644 --- a/packages/mask/src/plugins/Trader/trader/dodo/useTradeCallback.ts +++ b/packages/mask/src/plugins/Trader/trader/dodo/useTradeCallback.ts @@ -1,4 +1,4 @@ -import { useAccount, useWeb3 } from '@masknet/plugin-infra/web3' +import { useAccount, useWeb3Connection } from '@masknet/plugin-infra/web3' import stringify from 'json-stable-stringify' import { pick } from 'lodash-unified' import { useMemo } from 'react' @@ -6,7 +6,7 @@ import { useAsyncFn } from 'react-use' import type { TransactionConfig } from 'web3-core' import type { SwapRouteSuccessResponse, TradeComputed } from '../../types' import { TargetChainIdContext } from '@masknet/plugin-infra/web3-evm' -import { NetworkPluginID } from '@masknet/web3-shared-base' +import { NetworkPluginID, ZERO } from '@masknet/web3-shared-base' import type { GasOptionConfig } from '@masknet/web3-shared-evm' export function useTradeCallback( @@ -15,7 +15,7 @@ export function useTradeCallback( ) { const { targetChainId: chainId } = TargetChainIdContext.useContainer() const account = useAccount(NetworkPluginID.PLUGIN_EVM) - const web3 = useWeb3(NetworkPluginID.PLUGIN_EVM, { chainId }) + const connection = useWeb3Connection(NetworkPluginID.PLUGIN_EVM, { chainId }) // compose transaction config const config = useMemo(() => { @@ -28,28 +28,22 @@ export function useTradeCallback( return useAsyncFn(async () => { // validate config - if (!account || !config || !web3) { + if (!account || !config || !connection) { return } // compose transaction config const config_ = { ...config, - gas: await web3.eth.estimateGas(config).catch((error) => { - throw error - }), + gas: (await connection.estimateTransaction?.(config)) ?? ZERO.toString(), ...gasConfig, } // send transaction and wait for hash - return new Promise((resolve, reject) => { - web3.eth.sendTransaction(config_, (error, hash) => { - if (error) { - reject(error) - } else { - resolve(hash) - } - }) - }) - }, [web3, account, chainId, stringify(config), gasConfig]) + + const hash = await connection.sendTransaction(config_) + const receipt = await connection.getTransactionReceipt(hash) + + return receipt?.transactionHash + }, [connection, account, chainId, stringify(config), gasConfig]) } diff --git a/packages/mask/src/plugins/Trader/trader/openocean/useTradeCallback.ts b/packages/mask/src/plugins/Trader/trader/openocean/useTradeCallback.ts index af16b1aa1588..3b081653bdec 100644 --- a/packages/mask/src/plugins/Trader/trader/openocean/useTradeCallback.ts +++ b/packages/mask/src/plugins/Trader/trader/openocean/useTradeCallback.ts @@ -5,14 +5,14 @@ import { useAsyncFn } from 'react-use' import type { TransactionConfig } from 'web3-core' import type { GasOptionConfig } from '@masknet/web3-shared-evm' import type { SwapOOSuccessResponse, TradeComputed } from '../../types' -import { NetworkPluginID } from '@masknet/web3-shared-base' -import { useAccount, useChainId, useWeb3 } from '@masknet/plugin-infra/web3' +import { NetworkPluginID, ZERO } from '@masknet/web3-shared-base' +import { useAccount, useChainId, useWeb3Connection } from '@masknet/plugin-infra/web3' export function useTradeCallback( tradeComputed: TradeComputed | null, gasConfig?: GasOptionConfig, ) { - const web3 = useWeb3(NetworkPluginID.PLUGIN_EVM) + const connection = useWeb3Connection(NetworkPluginID.PLUGIN_EVM) const account = useAccount(NetworkPluginID.PLUGIN_EVM) const chainId = useChainId(NetworkPluginID.PLUGIN_EVM) @@ -27,28 +27,21 @@ export function useTradeCallback( return useAsyncFn(async () => { // validate config - if (!account || !config || !web3) { + if (!account || !config || !connection) { return } // compose transaction config const config_ = { ...config, - gas: await web3.eth.estimateGas(config).catch((error) => { - throw error - }), + gas: (await connection.estimateTransaction?.(config)) ?? ZERO.toString(), ...gasConfig, } // send transaction and wait for hash - return new Promise((resolve, reject) => { - web3.eth.sendTransaction(config_, (error, hash) => { - if (error) { - reject(error) - } else { - resolve(hash) - } - }) - }) - }, [web3, account, chainId, stringify(config)]) + + const hash = await connection.sendTransaction(config_) + const receipt = await connection.getTransactionReceipt(hash) + return receipt?.transactionHash + }, [connection, account, chainId, stringify(config)]) } diff --git a/packages/mask/src/plugins/Trader/trader/uniswap/useTradeCallback.ts b/packages/mask/src/plugins/Trader/trader/uniswap/useTradeCallback.ts index 52edd6456174..749987845bf3 100644 --- a/packages/mask/src/plugins/Trader/trader/uniswap/useTradeCallback.ts +++ b/packages/mask/src/plugins/Trader/trader/uniswap/useTradeCallback.ts @@ -2,13 +2,13 @@ import { useAsyncFn } from 'react-use' import BigNumber from 'bignumber.js' import type { TradeProvider } from '@masknet/public-api' import type { SwapParameters } from '@uniswap/v2-sdk' -import { GasOptionConfig, TransactionEventType } from '@masknet/web3-shared-evm' +import type { GasOptionConfig } from '@masknet/web3-shared-evm' import { useSwapParameters as useTradeParameters } from './useTradeParameters' import { swapErrorToUserReadableMessage } from '../../helpers' import type { SwapCall, Trade, TradeComputed } from '../../types' import { TargetChainIdContext } from '@masknet/plugin-infra/web3-evm' -import { useAccount, useWeb3 } from '@masknet/plugin-infra/web3' -import { NetworkPluginID } from '@masknet/web3-shared-base' +import { useAccount, useWeb3Connection } from '@masknet/plugin-infra/web3' +import { NetworkPluginID, ZERO } from '@masknet/web3-shared-base' interface FailedCall { parameters: SwapParameters @@ -36,15 +36,16 @@ export function useTradeCallback( allowedSlippage?: number, ) { const { targetChainId } = TargetChainIdContext.useContainer() - const web3 = useWeb3(NetworkPluginID.PLUGIN_EVM, { chainId: targetChainId }) + // const web3 = useWeb3(NetworkPluginID.PLUGIN_EVM, { chainId: targetChainId }) + const connection = useWeb3Connection(NetworkPluginID.PLUGIN_EVM, { chainId: targetChainId }) const account = useAccount(NetworkPluginID.PLUGIN_EVM) const tradeParameters = useTradeParameters(trade, tradeProvider, allowedSlippage) return useAsyncFn(async () => { - if (!tradeParameters.length || !web3) { + if (!tradeParameters.length || !connection) { return } - + const web3 = await connection.getWeb3() // step 1: estimate each trade parameter const estimatedCalls: SwapCallEstimate[] = await Promise.all( tradeParameters.map(async (x) => { @@ -58,8 +59,14 @@ export function useTradeCallback( : { value: `0x${Number.parseInt(value, 16).toString(16)}` }), } - return web3.eth - .estimateGas(config) + if (!connection.estimateTransaction) { + return { + call: x, + gasEstimate: ZERO, + } + } + return connection + .estimateTransaction(config) .then((gasEstimate) => { return { call: x, @@ -104,39 +111,34 @@ export function useTradeCallback( bestCallOption = firstNoErrorCall } - return new Promise(async (resolve, reject) => { - if (!bestCallOption) { - return - } + if (!bestCallOption) { + return + } - const { - call: { address, calldata, value }, - } = bestCallOption + const { + call: { address, calldata, value }, + } = bestCallOption - web3.eth - .sendTransaction({ - from: account, - to: address, - data: calldata, - ...('gasEstimate' in bestCallOption ? { gas: bestCallOption.gasEstimate.toFixed() } : {}), - ...(!value || /^0x0*$/.test(value) ? {} : { value }), - ...gasConfig, - }) - .on(TransactionEventType.CONFIRMATION, (_, receipt) => { - resolve(receipt.transactionHash) - }) - .on(TransactionEventType.ERROR, (error) => { - if (!(error as any)?.code) { - reject(error) - return - } - const error_ = new Error( - error?.message === 'Unable to add more requests.' - ? 'Unable to add more requests.' - : 'Transaction rejected.', - ) - reject(error_) - }) - }) - }, [web3, account, tradeParameters, gasConfig]) + try { + const hash = await connection.sendTransaction({ + from: account, + to: address, + data: calldata, + ...('gasEstimate' in bestCallOption ? { gas: bestCallOption.gasEstimate.toFixed() } : {}), + ...(!value || /^0x0*$/.test(value) ? {} : { value }), + ...gasConfig, + }) + const receipt = await connection.getTransactionReceipt(hash) + return receipt?.transactionHash + } catch (error: any) { + if (!(error as any)?.code) { + throw error + } + throw new Error( + error?.message === 'Unable to add more requests.' + ? 'Unable to add more requests.' + : 'Transaction rejected.', + ) + } + }, [connection, account, tradeParameters, gasConfig]) } diff --git a/packages/web3-constants/evm/trader.json b/packages/web3-constants/evm/trader.json index 3b20c45fa677..277cb75b4d7e 100644 --- a/packages/web3-constants/evm/trader.json +++ b/packages/web3-constants/evm/trader.json @@ -653,8 +653,8 @@ "BSCT": "", "Matic": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", "Mumbai": "", - "Arbitrum": "", - "Arbitrum_Rinkeby": "", + "Arbitrum": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", + "Arbitrum_Rinkeby": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", "xDai": "", "Avalanche": "", "Avalanche_Fuji": "", diff --git a/packages/web3-shared/base/src/specs/index.ts b/packages/web3-shared/base/src/specs/index.ts index 2181e27b3da8..7d188f04d76d 100644 --- a/packages/web3-shared/base/src/specs/index.ts +++ b/packages/web3-shared/base/src/specs/index.ts @@ -66,7 +66,7 @@ export enum SourceType { LooksRare = 'looksrare', NFTScan = 'NFTScan', Alchemy_EVM = 'Alchemy_EVM', - Alchemy_FLOW = 'Alchemy_FLOW' + Alchemy_FLOW = 'Alchemy_FLOW', } export enum TransactionStatusType { @@ -387,7 +387,7 @@ export interface FungibleTokenAuthorization { /** * Authorization about a non-fungible token. */ - export interface NonFungibleTokenAuthorization { +export interface NonFungibleTokenAuthorization { all: boolean recipient: string tokens: NonFungibleToken @@ -552,7 +552,6 @@ export interface Account { chainId: ChainId } - export interface BalanceEvent { /** Emit if the balance of the account updated. */ update: [Account] @@ -682,7 +681,12 @@ export interface Connection< /** Get fungible token balance */ getFungibleTokenBalance(address: string, initial?: Web3ConnectionOptions): Promise /** Get non-fungible token balance */ - getNonFungibleTokenBalance(address: string, tokenId?: string, schema?: SchemaType, initial?: Web3ConnectionOptions): Promise + getNonFungibleTokenBalance( + address: string, + tokenId?: string, + schema?: SchemaType, + initial?: Web3ConnectionOptions, + ): Promise /** Get fungible token balance */ getFungibleTokensBalance(listOfAddress: string[], initial?: Web3ConnectionOptions): Promise> /** Get non-fungible token balance */ @@ -728,7 +732,7 @@ export interface Connection< address: string, recipient: string, amount: string, - initial?: Web3ConnectionOptions + initial?: Web3ConnectionOptions, ): Promise /** Approve a recipient for using a non-fungible token. */ approveNonFungibleToken( @@ -736,7 +740,7 @@ export interface Connection< recipient: string, tokenId: string, schema?: SchemaType, - initial?: Web3ConnectionOptions + initial?: Web3ConnectionOptions, ): Promise /** Approve a recipient for using all non-fungible tokens. */ approveAllNonFungibleTokens( @@ -744,7 +748,7 @@ export interface Connection< recipient: string, approved: boolean, schema?: SchemaType, - initial?: Web3ConnectionOptions + initial?: Web3ConnectionOptions, ): Promise /** Transfer fungible token to */ transferFungibleToken( @@ -771,6 +775,12 @@ export interface Connection< callTransaction(transaction: Transaction, initial?: Web3ConnectionOptions): Promise /** Send a transaction and wait for mining */ sendTransaction(transaction: Transaction, initial?: Web3ConnectionOptions): Promise + /** Estimate a transaction */ + estimateTransaction?: ( + transaction: Transaction, + fallback?: number, + initial?: Web3ConnectionOptions, + ) => Promise /** Send a signed transaction */ sendSignedTransaction(signature: TransactionSignature, initial?: Web3ConnectionOptions): Promise /** Build connection */ @@ -817,9 +827,17 @@ export interface Hub Promise>> /** Get security diagnosis about a fungible token */ - getFungibleTokenSecurity?: (chainId: ChainId, address: string, initial?: Web3HubOptions) => Promise + getFungibleTokenSecurity?: ( + chainId: ChainId, + address: string, + initial?: Web3HubOptions, + ) => Promise /** Get security diagnosis about a non-fungible token */ - getNonFungibleTokenSecurity?: (chainId: ChainId, address: string, initial?: Web3HubOptions) => Promise + getNonFungibleTokenSecurity?: ( + chainId: ChainId, + address: string, + initial?: Web3HubOptions, + ) => Promise /** Get the fungible from built-in token list */ getFungibleTokensFromTokenList?: ( chainId: ChainId, @@ -897,7 +915,7 @@ export interface Hub Promise>> } @@ -1025,7 +1043,12 @@ export interface TransactionWatcherState { /** Notify error */ notifyError: (error: Error) => Promise /** Notify transaction status */ - notifyTransaction: (chainId: ChainId, id: string, transaction: Transaction, status: TransactionStatusType) => Promise + notifyTransaction: ( + chainId: ChainId, + id: string, + transaction: Transaction, + status: TransactionStatusType, + ) => Promise } export interface ProviderState { /** The account of the currently visiting site. */ From 175c67abb30052ecdb4b9b4a71be0c566b172dfc Mon Sep 17 00:00:00 2001 From: zhouhanseng Date: Mon, 11 Jul 2022 15:45:09 +0800 Subject: [PATCH 047/179] fix: mf 1408 app board verify --- packages/mask/src/components/shared/ApplicationBoard.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/mask/src/components/shared/ApplicationBoard.tsx b/packages/mask/src/components/shared/ApplicationBoard.tsx index ebb9f4500f28..ae551276fdad 100644 --- a/packages/mask/src/components/shared/ApplicationBoard.tsx +++ b/packages/mask/src/components/shared/ApplicationBoard.tsx @@ -316,7 +316,6 @@ function ApplicationEntryStatusProvider(props: PropsWithChildren<{}>) { useEffect(() => { retry() - nextIDConnectStatus.reset() return MaskMessages.events.currentPersonaIdentifier.on(() => { retry() nextIDConnectStatus.reset() From 15ba9288b1630e7ef35d74ba25446d7a727ad2c8 Mon Sep 17 00:00:00 2001 From: Randolph314 <97870249+Randolph314@users.noreply.github.com> Date: Mon, 11 Jul 2022 16:21:13 +0800 Subject: [PATCH 048/179] fix: token security UI (#6755) * fix: profile content component computed dependency * fix: token security ui * fix: copy ui Co-authored-by: Randolph <840094513@qq.com> --- .../InjectedComponents/ProfileTabContent.tsx | 7 ++- .../trader/balancer/useTradeCallback.ts | 49 +++++++++---------- .../src/SNSAdaptor/components/Common.tsx | 6 +-- .../src/SNSAdaptor/components/RiskCard.tsx | 7 ++- .../SNSAdaptor/components/SecurityPanel.tsx | 45 +++++++---------- .../GoPlusSecurity/src/SNSAdaptor/index.tsx | 1 - packages/plugins/GoPlusSecurity/src/base.ts | 1 - .../SNSAdaptor/components/PersonaAction.tsx | 47 ++++++++++-------- .../TokenSecurity/components/RiskCard.tsx | 7 ++- .../components/SecurityPanel.tsx | 32 +++++++----- .../TokenSecurity/components/TokenPanel.tsx | 14 ++++-- 11 files changed, 114 insertions(+), 102 deletions(-) diff --git a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx index 204d5dcfb855..15f556b7f6ce 100644 --- a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx +++ b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx @@ -102,7 +102,7 @@ export function ProfileTabContent(props: ProfileTabContentProps) { } }) return [...socialAddressList, ...addresses] - }, [socialAddressList, wallets, isOwn]) + }, [socialAddressList, wallets?.map((x) => x.identity).join(), isOwn]) const activatedPlugins = useActivatedPluginsSNSAdaptor('any') const availablePlugins = useAvailablePlugins(activatedPlugins) @@ -163,9 +163,10 @@ export function ProfileTabContent(props: ProfileTabContentProps) { ) }, [ componentTabId, + personaPublicKey, displayPlugins.map((x) => x.ID).join(), personaList.join(), - socialAddressList.map((x) => x.address).join(), + addressList.map((x) => x.address).join(), ]) useLocationChange(() => { @@ -188,6 +189,8 @@ export function ProfileTabContent(props: ProfileTabContentProps) { }) }, [identity.identifier?.userId]) + // console.log({ identity, socialAddressList, addressList, wallets }) + if (hidden) return null if (!identity.identifier?.userId || loadingSocialAddressList || loadingPersonaList) diff --git a/packages/mask/src/plugins/Trader/trader/balancer/useTradeCallback.ts b/packages/mask/src/plugins/Trader/trader/balancer/useTradeCallback.ts index b777653083d6..51dee6e2d4f0 100644 --- a/packages/mask/src/plugins/Trader/trader/balancer/useTradeCallback.ts +++ b/packages/mask/src/plugins/Trader/trader/balancer/useTradeCallback.ts @@ -1,10 +1,5 @@ import type { ExchangeProxy } from '@masknet/web3-contracts/types/ExchangeProxy' -import { - SchemaType, - GasOptionConfig, - useTraderConstants, - encodeContractTransaction -} from '@masknet/web3-shared-evm' +import { SchemaType, GasOptionConfig, useTraderConstants, encodeContractTransaction } from '@masknet/web3-shared-evm' import { useAsyncFn } from 'react-use' import { SLIPPAGE_DEFAULT } from '../../constants' import { SwapResponse, TradeComputed, TradeStrategy } from '../../types' @@ -55,7 +50,6 @@ export function useTradeCallback( const outputTokenAddress = trade.outputToken.schema === SchemaType.Native ? BALANCER_ETH_ADDRESS : trade.outputToken.address - // trade with the native token let transactionValue = '0' if (trade.strategy === TradeStrategy.ExactIn && trade.inputToken.schema === SchemaType.Native) @@ -66,32 +60,33 @@ export function useTradeCallback( // send transaction and wait for hash const config = { from: account, - gas: await connection - .estimateTransaction?.({ + gas: + (await connection.estimateTransaction?.({ from: account, value: transactionValue, - }) ?? ZERO.toString(), + })) ?? ZERO.toString(), value: transactionValue, ...gasConfig, } - - const tx = await encodeContractTransaction(exchangeProxyContract, trade.strategy === TradeStrategy.ExactIn - ? exchangeProxyContract.methods.multihopBatchSwapExactIn( - swap_, - inputTokenAddress, - outputTokenAddress, - trade.inputAmount.toFixed(), - tradeAmount.toFixed(), - ) - : exchangeProxyContract.methods.multihopBatchSwapExactOut( - swap_, - inputTokenAddress, - outputTokenAddress, - tradeAmount.toFixed(), - ), config) - - + const tx = await encodeContractTransaction( + exchangeProxyContract, + trade.strategy === TradeStrategy.ExactIn + ? exchangeProxyContract.methods.multihopBatchSwapExactIn( + swap_, + inputTokenAddress, + outputTokenAddress, + trade.inputAmount.toFixed(), + tradeAmount.toFixed(), + ) + : exchangeProxyContract.methods.multihopBatchSwapExactOut( + swap_, + inputTokenAddress, + outputTokenAddress, + tradeAmount.toFixed(), + ), + config, + ) // send transaction and wait for hash const hash = await connection.sendTransaction(tx) diff --git a/packages/plugins/GoPlusSecurity/src/SNSAdaptor/components/Common.tsx b/packages/plugins/GoPlusSecurity/src/SNSAdaptor/components/Common.tsx index f20033875d53..403cd516e158 100644 --- a/packages/plugins/GoPlusSecurity/src/SNSAdaptor/components/Common.tsx +++ b/packages/plugins/GoPlusSecurity/src/SNSAdaptor/components/Common.tsx @@ -34,13 +34,13 @@ export const DefineMapping: DefineMapping = { [SecurityMessageLevel.High]: { i18nKey: 'high_risk', titleColor: '#FF5F5F', - bgColor: 'rgba(255, 95, 95, 0.1)', + bgColor: 'rgba(255, 53, 69, 0.1)', icon: (size: number) => , }, [SecurityMessageLevel.Medium]: { i18nKey: 'medium_risk', - titleColor: '#FFB915', - bgColor: 'rgba(255, 177, 0, 0.2)', + titleColor: '#FFB100', + bgColor: 'rgba(255, 177, 0, 0.1)', // TODO: Merge duplicate icon in a another PR. icon: (size: number) => , }, diff --git a/packages/plugins/GoPlusSecurity/src/SNSAdaptor/components/RiskCard.tsx b/packages/plugins/GoPlusSecurity/src/SNSAdaptor/components/RiskCard.tsx index 971b3342e68b..a9efe262cbb2 100644 --- a/packages/plugins/GoPlusSecurity/src/SNSAdaptor/components/RiskCard.tsx +++ b/packages/plugins/GoPlusSecurity/src/SNSAdaptor/components/RiskCard.tsx @@ -22,11 +22,14 @@ const useStyles = makeStyles()((theme) => ({ alignItems: 'center', }, header: { - fontSize: 14, + fontSize: 16, + fontWeight: 700, lineHeight: '22px', }, description: { - fontSize: 12, + fontSize: 16, + fontWeight: 400, + color: theme.palette.maskColor.second, }, })) diff --git a/packages/plugins/GoPlusSecurity/src/SNSAdaptor/components/SecurityPanel.tsx b/packages/plugins/GoPlusSecurity/src/SNSAdaptor/components/SecurityPanel.tsx index 060233f8aa36..9b8f59753155 100644 --- a/packages/plugins/GoPlusSecurity/src/SNSAdaptor/components/SecurityPanel.tsx +++ b/packages/plugins/GoPlusSecurity/src/SNSAdaptor/components/SecurityPanel.tsx @@ -23,7 +23,7 @@ interface TokenCardProps { const useStyles = makeStyles()((theme) => ({ header: { - fontWeight: 500, + fontWeight: 700, fontSize: 18, }, root: { @@ -43,13 +43,14 @@ const useStyles = makeStyles()((theme) => ({ height: '48px', }, tokenName: { - fontSize: '16px', + fontSize: '18px', fontWeight: 700, + color: theme.palette.maskColor.main, }, tokenPrice: { - fontSize: '16px', + fontSize: '18px', fontWeight: 700, - color: theme.palette.text.secondary, + color: theme.palette.maskColor.main, }, itemTitle: { color: theme.palette.maskColor.second, @@ -160,7 +161,7 @@ export const SecurityPanel = memo(({ tokenSecurity, tokenInfo, t /> - + {t.more_details()} (({ tokenSecurity, tokenInfo, t )} - - - {makeMessageList.map((x, i) => ( - - ))} - {(!makeMessageList.length || securityMessageLevel === SecurityMessageLevel.Safe) && ( - - )} - - + + {makeMessageList.map((x, i) => ( + + ))} + {(!makeMessageList.length || securityMessageLevel === SecurityMessageLevel.Safe) && ( + + )} + ) diff --git a/packages/plugins/GoPlusSecurity/src/SNSAdaptor/index.tsx b/packages/plugins/GoPlusSecurity/src/SNSAdaptor/index.tsx index f68bdcc78cf6..eb29fee2a06a 100644 --- a/packages/plugins/GoPlusSecurity/src/SNSAdaptor/index.tsx +++ b/packages/plugins/GoPlusSecurity/src/SNSAdaptor/index.tsx @@ -33,7 +33,6 @@ const sns: Plugin.SNSAdaptor.Definition = { }, name, icon, - iconFilterColor: '', appBoardSortingDefaultPriority: 14, category: 'dapp', marketListSortingPriority: 16, diff --git a/packages/plugins/GoPlusSecurity/src/base.ts b/packages/plugins/GoPlusSecurity/src/base.ts index c19fe3023fe1..2c83e4ed8e50 100644 --- a/packages/plugins/GoPlusSecurity/src/base.ts +++ b/packages/plugins/GoPlusSecurity/src/base.ts @@ -4,7 +4,6 @@ import { languages } from './locales/languages' export const base: Plugin.Shared.Definition = { ID: PLUGIN_ID, - icon: '', name: { fallback: PLUGIN_NAME }, description: { fallback: PLUGIN_DESCRIPTION }, publisher: { name: { fallback: 'Mask Network' }, link: 'https://mask.io/' }, diff --git a/packages/plugins/Web3Profile/src/SNSAdaptor/components/PersonaAction.tsx b/packages/plugins/Web3Profile/src/SNSAdaptor/components/PersonaAction.tsx index 556bb8f52be3..972e3ef5751b 100644 --- a/packages/plugins/Web3Profile/src/SNSAdaptor/components/PersonaAction.tsx +++ b/packages/plugins/Web3Profile/src/SNSAdaptor/components/PersonaAction.tsx @@ -1,14 +1,14 @@ -import { useStylesExtends, makeStyles } from '@masknet/theme' -import { Box, Link, Typography } from '@mui/material' -import { Copy } from 'react-feather' +import { useStylesExtends, makeStyles, ShadowRootTooltip } from '@masknet/theme' +import { Box, Typography } from '@mui/material' import { useAsyncRetry, useCopyToClipboard } from 'react-use' import { useI18N } from '../../locales' import { PlatformAvatar } from './PlatformAvatar' -import { useSnackbarCallback } from '@masknet/shared' import { formatPublicKey } from '../utils' import type { PersonaInformation } from '@masknet/shared-base' import type { IdentityResolved } from '@masknet/plugin-infra' import { context } from '../context' +import { CopyIcon } from '@masknet/icons' +import { useCallback, useState } from 'react' const useStyles = makeStyles()((theme) => ({ bottomFixed: { @@ -27,6 +27,7 @@ const useStyles = makeStyles()((theme) => ({ linkIcon: { marginRight: theme.spacing(1), color: theme.palette.maskColor.second, + cursor: 'pointer', }, personaKey: { fontSize: '12px', @@ -45,22 +46,27 @@ export function PersonaAction(props: PersonaActionProps) { const { currentPersona, currentVisitingProfile } = props const t = useI18N() + const [open, setOpen] = useState(false) + const { value: avatar } = useAsyncRetry(async () => { const avatar = await context.getPersonaAvatar(currentPersona?.identifier) if (!avatar) return undefined return avatar }) const [, copyToClipboard] = useCopyToClipboard() - const onCopy = useSnackbarCallback( - async (ev: React.MouseEvent) => { - ev.stopPropagation() + + const onCopy = useCallback( + (e: React.MouseEvent) => { + e.preventDefault() + e.stopPropagation() copyToClipboard(currentPersona?.identifier?.rawPublicKey ?? '') + setOpen(true) + // Close tooltip after five seconds of copying + setTimeout(() => { + setOpen(false) + }, 5000) }, - [], - undefined, - undefined, - undefined, - t.copied(), + [currentPersona?.identifier?.rawPublicKey, copyToClipboard], ) return ( @@ -74,14 +80,15 @@ export function PersonaAction(props: PersonaActionProps) { {currentPersona?.identifier ? formatPublicKey(currentPersona?.identifier?.rawPublicKey) : '--'} - - - + setOpen(false)} + disableFocusListener + disableTouchListener> + + diff --git a/packages/shared/src/UI/components/TokenSecurity/components/RiskCard.tsx b/packages/shared/src/UI/components/TokenSecurity/components/RiskCard.tsx index 7c3e61369a15..62071b3981d1 100644 --- a/packages/shared/src/UI/components/TokenSecurity/components/RiskCard.tsx +++ b/packages/shared/src/UI/components/TokenSecurity/components/RiskCard.tsx @@ -22,11 +22,14 @@ const useStyles = makeStyles()((theme) => ({ alignItems: 'center', }, header: { - fontSize: 14, + fontSize: 16, + fontWeight: 700, lineHeight: '22px', }, description: { - fontSize: 12, + fontSize: 16, + fontWeight: 400, + color: theme.palette.maskColor.second, }, })) diff --git a/packages/shared/src/UI/components/TokenSecurity/components/SecurityPanel.tsx b/packages/shared/src/UI/components/TokenSecurity/components/SecurityPanel.tsx index 250ea2402b6e..7935137dde87 100644 --- a/packages/shared/src/UI/components/TokenSecurity/components/SecurityPanel.tsx +++ b/packages/shared/src/UI/components/TokenSecurity/components/SecurityPanel.tsx @@ -1,6 +1,5 @@ import { Collapse, Link, Stack, Typography } from '@mui/material' import { useSharedI18N } from '../../../../locales' -import { ExternalLink } from 'react-feather' import { makeStyles } from '@masknet/theme' import { memo, useMemo, useState } from 'react' import { DefineMapping, SecurityMessageLevel, TokenSecurity } from './Common' @@ -14,6 +13,7 @@ import type { ChainId, SchemaType } from '@masknet/web3-shared-evm' import urlcat from 'urlcat' import type { TokenAPI } from '@masknet/web3-providers' import { formatCurrency, FungibleToken } from '@masknet/web3-shared-base' +import { LinkOutIcon } from '@masknet/icons' interface TokenCardProps { tokenSecurity: TokenSecurity @@ -24,7 +24,7 @@ interface TokenCardProps { const useStyles = makeStyles()((theme) => ({ header: { - fontWeight: 500, + fontWeight: 700, fontSize: 18, }, root: { @@ -44,13 +44,24 @@ const useStyles = makeStyles()((theme) => ({ height: '48px', }, tokenName: { - fontSize: '16px', + fontSize: '18px', fontWeight: 700, + color: theme.palette.maskColor.main, }, tokenPrice: { - fontSize: '16px', + fontSize: '18px', fontWeight: 700, - color: theme.palette.text.secondary, + color: theme.palette.maskColor.main, + }, + arrowIcon: { + fontSize: 15, + cursor: 'pointer', + fill: theme.palette.maskColor.second, + }, + linkIcon: { + fill: theme.palette.maskColor.main, + width: 18, + height: 18, }, })) @@ -150,13 +161,8 @@ export const SecurityPanel = memo(({ tokenSecurity, tokenInfo, t - - {t.token_info()} - - setCollapse(!isCollapse)} - sx={{ fontSize: 15, cursor: 'pointer' }} - /> + {t.token_info()} + setCollapse(!isCollapse)} className={classes.arrowIcon} /> @@ -167,7 +173,7 @@ export const SecurityPanel = memo(({ tokenSecurity, tokenInfo, t href={resolveGoLabLink(tokenSecurity.chainId, tokenSecurity.contract)} target="_blank" rel="noopener noreferrer"> - + diff --git a/packages/shared/src/UI/components/TokenSecurity/components/TokenPanel.tsx b/packages/shared/src/UI/components/TokenSecurity/components/TokenPanel.tsx index a8ead2961df9..4e2cd24f5598 100644 --- a/packages/shared/src/UI/components/TokenSecurity/components/TokenPanel.tsx +++ b/packages/shared/src/UI/components/TokenSecurity/components/TokenPanel.tsx @@ -7,6 +7,7 @@ import { ExternalLink } from 'react-feather' import { makeStyles, usePortalShadowRoot } from '@masknet/theme' import { explorerResolver, formatEthereumAddress } from '@masknet/web3-shared-evm' import { formatCurrency, formatSupply } from '@masknet/web3-shared-base' +import { LinkOutIcon } from '@masknet/icons' const useStyles = makeStyles()((theme) => ({ card: { @@ -18,18 +19,23 @@ const useStyles = makeStyles()((theme) => ({ : '0px 0px 20px rgba(255, 255, 255, 0.12)', }, subtitle: { - color: theme.palette.text.secondary, + color: theme.palette.maskColor.second, fontWeight: 400, fontSize: 16, }, cardValue: { - color: theme.palette.text.primary, + color: theme.palette.maskColor.main, fontSize: 16, fontWeight: 700, }, tooltip: { fontSize: 12, }, + linkIcon: { + fill: theme.palette.maskColor.main, + width: 16, + height: 16, + }, })) const DEFAULT_PLACEHOLDER = '--' @@ -88,7 +94,7 @@ export const TokenPanel = React.forwardRef(({ tokenSecurity, tokenMarketCap }: T href={explorerResolver.fungibleTokenLink(tokenSecurity.chainId, tokenSecurity.contract)} target="_blank" rel="noopener noreferrer"> - + @@ -109,7 +115,7 @@ export const TokenPanel = React.forwardRef(({ tokenSecurity, tokenMarketCap }: T )} target="_blank" rel="noopener noreferrer"> - + )} From f43b5124df17f1a478a52db7733c30bf850cd47e Mon Sep 17 00:00:00 2001 From: UncleBill Date: Mon, 11 Jul 2022 16:54:07 +0800 Subject: [PATCH 049/179] fix: mf-1443 crash on persona searching (#6753) * fix: mf-1443 crash on persona searching * fixup! add reaction to copy --- .../shared/SelectRecipients/ProfileInList.tsx | 36 +++++++++++-------- .../SelectRecipients/SelectRecipients.tsx | 16 ++++----- .../SelectRecipientsDialog.tsx | 6 ++-- .../useTwitterIdByWalletSearch.tsx | 8 +++-- 4 files changed, 36 insertions(+), 30 deletions(-) diff --git a/packages/mask/src/components/shared/SelectRecipients/ProfileInList.tsx b/packages/mask/src/components/shared/SelectRecipients/ProfileInList.tsx index 3f2a3f62be39..e2daa87d4761 100644 --- a/packages/mask/src/components/shared/SelectRecipients/ProfileInList.tsx +++ b/packages/mask/src/components/shared/SelectRecipients/ProfileInList.tsx @@ -1,13 +1,14 @@ -import { useCallback } from 'react' -import { ListItemText, Checkbox, ListItemAvatar, ListItem } from '@mui/material' -import { makeStyles, ShadowRootTooltip } from '@masknet/theme' -import Highlighter from 'react-highlight-words' -import { formatPersonaFingerprint, ProfileInformationFromNextID } from '@masknet/shared-base' -import { Avatar } from '../../../utils/components/Avatar' import { CopyIcon } from '@masknet/icons' +import { useSnackbarCallback } from '@masknet/shared' +import { formatPersonaFingerprint, ProfileInformationFromNextID } from '@masknet/shared-base' +import { makeStyles, ShadowRootTooltip } from '@masknet/theme' +import { Checkbox, ListItem, ListItemAvatar, ListItemText } from '@mui/material' import { truncate } from 'lodash-unified' -import { useI18N } from '../../../utils' +import { useCallback } from 'react' +import Highlighter from 'react-highlight-words' import { useCopyToClipboard } from 'react-use' +import { useI18N } from '../../../utils' +import { Avatar } from '../../../utils/components/Avatar' const useStyles = makeStyles()((theme) => ({ root: { @@ -93,6 +94,18 @@ export function ProfileInList(props: ProfileInListProps) { const profile = props.item const [, copyToClipboard] = useCopyToClipboard() + const rawPublicKey = profile.linkedPersona?.rawPublicKey + const onCopyPubkey = useSnackbarCallback( + async () => { + if (!rawPublicKey) return + copyToClipboard(rawPublicKey) + }, + [rawPublicKey], + undefined, + undefined, + undefined, + t('copied'), + ) const highlightText = (() => { if (!profile.fromNextID) return `@${profile.identifier.userId || profile.nickname}` const mentions = profile.linkedTwitterNames.map((x) => '@' + x).join(' ') @@ -150,14 +163,7 @@ export function ProfileInList(props: ProfileInListProps) { autoEscape textToHighlight={textToHighlight} /> - { - 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 c6efd4dbbb04..615fb1a854dc 100644 --- a/packages/mask/src/components/shared/SelectRecipients/SelectRecipients.tsx +++ b/packages/mask/src/components/shared/SelectRecipients/SelectRecipients.tsx @@ -1,7 +1,6 @@ -import { useEffect, useState } from 'react' +import { useEffect, useMemo, useState } from 'react' import { ProfileInformation as Profile, - EMPTY_LIST, NextIDPlatform, ECKeyIdentifier, ProfileInformationFromNextID, @@ -51,13 +50,12 @@ export function SelectRecipientsUI(props: SelectRecipientsUIProps) { type ?? NextIDPlatform.NextID, value, ) - const NextIDItems = useTwitterIdByWalletSearch(NextIDResults, value, type) - const profileItems = items.recipients?.filter((x) => x.identifier !== currentIdentity?.identifier) - const searchedList = uniqBy( - profileItems?.concat(NextIDItems) ?? [], - ({ linkedPersona }) => linkedPersona?.rawPublicKey, - ) + const NextIDItems = useTwitterIdByWalletSearch(NextIDResults, value, type) + const searchedList = useMemo(() => { + const profileItems = items.recipients?.filter((x) => x.identifier !== currentIdentity?.identifier) + return uniqBy(profileItems?.concat(NextIDItems) ?? [], ({ linkedPersona }) => linkedPersona?.rawPublicKey) + }, [NextIDItems, items.recipients]) const onSelect = async (item: ProfileInformationFromNextID) => { onSetSelected([...selected, item]) @@ -85,7 +83,7 @@ export function SelectRecipientsUI(props: SelectRecipientsUIProps) { setValueToSearch(v) }} open={open} - items={searchedList || EMPTY_LIST} + items={searchedList} selected={selected} disabled={false} submitDisabled={false} diff --git a/packages/mask/src/components/shared/SelectRecipients/SelectRecipientsDialog.tsx b/packages/mask/src/components/shared/SelectRecipients/SelectRecipientsDialog.tsx index 814b6e9182bf..0cb974da13ed 100644 --- a/packages/mask/src/components/shared/SelectRecipients/SelectRecipientsDialog.tsx +++ b/packages/mask/src/components/shared/SelectRecipients/SelectRecipientsDialog.tsx @@ -102,7 +102,7 @@ export function SelectRecipientsDialogUI(props: SelectRecipientsDialogUIProps) { setSearch('') onSearch('') }, [props.open]) - const itemsAfterSearch = useMemo(() => { + const searchedItems = useMemo(() => { const fuse = new Fuse(items, { keys: [ 'identifier.userId', @@ -151,7 +151,7 @@ export function SelectRecipientsDialogUI(props: SelectRecipientsDialogUIProps) { ) : (
- {itemsAfterSearch.length === 0 ? ( + {searchedItems.length === 0 ? (
@@ -159,7 +159,7 @@ export function SelectRecipientsDialogUI(props: SelectRecipientsDialogUIProps) {
) : ( - itemsAfterSearch.map((item, idx) => ( + searchedItems.map((item, idx) => ( { + const nextIdAccounts = bindings.map((binding) => { const proofs = uniqBy( binding.proofs.filter((x) => x.platform === NextIDPlatform.Twitter), (proof) => proof.identity, ) + if (!proofs.length) return null const linkedTwitterNames = proofs.map((x) => x.identity) return { nickname: proofs[0].identity, @@ -29,4 +30,5 @@ export function useTwitterIdByWalletSearch( linkedPersona: ECKeyIdentifier.fromHexPublicKeyK256(binding.persona).unwrap(), } }) + return compact(nextIdAccounts) } From 3e01462e6289eb6cf9c9a055f796e8d2be4996cc Mon Sep 17 00:00:00 2001 From: zhouhanseng Date: Mon, 11 Jul 2022 17:01:55 +0800 Subject: [PATCH 050/179] fix: mf 1435 --- .../EVM/src/state/TransactionFormatter/descriptors/ERC20.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugins/EVM/src/state/TransactionFormatter/descriptors/ERC20.ts b/packages/plugins/EVM/src/state/TransactionFormatter/descriptors/ERC20.ts index ab391b45b151..cd6a08c79c1d 100644 --- a/packages/plugins/EVM/src/state/TransactionFormatter/descriptors/ERC20.ts +++ b/packages/plugins/EVM/src/state/TransactionFormatter/descriptors/ERC20.ts @@ -18,7 +18,7 @@ export class ERC20Descriptor implements TransactionDescriptor { case 'approve': if (parameters?.spender === undefined || parameters?.value === undefined) break - if (isZero(context.value)) { + if (isZero(parameters?.value)) { return { chainId: context.chainId, title: 'Revoke', From ddea985ad5c1790cb4b9b1e054ae452ccdcc5b13 Mon Sep 17 00:00:00 2001 From: nuanyang233 Date: Mon, 11 Jul 2022 17:05:36 +0800 Subject: [PATCH 051/179] fix: patch for swap (#6756) * fix: bugfix for swap callback * fix: bugfix --- .../Wallet/ContractInteraction/index.tsx | 30 ++++++++++--------- .../trader/balancer/useTradeCallback.ts | 7 +---- .../EVM/src/state/Connection/connection.ts | 1 + .../web3-shared/evm/constants/chains.json | 6 ++-- 4 files changed, 21 insertions(+), 23 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 51fd41a3fd22..5271c1b4515f 100644 --- a/packages/mask/src/extension/popups/pages/Wallet/ContractInteraction/index.tsx +++ b/packages/mask/src/extension/popups/pages/Wallet/ContractInteraction/index.tsx @@ -173,11 +173,22 @@ const ContractInteraction = memo(() => { const type = request?.formatterTransaction?.type if (!type) return {} - const methods = request.transactionContext?.methods - if (!methods?.length) return {} - switch (type) { case TransactionDescriptorType.INTERACTION: + const methods = request.transactionContext?.methods + if (!methods?.length) + return { + isNativeTokenInteraction: true, + typeName: t('popups_wallet_contract_interaction'), + tokenAddress: request.computedPayload?.to, + to: request.computedPayload?.to, + gas: request.computedPayload?.gas, + gasPrice: request.computedPayload?.gasPrice, + maxFeePerGas: request.computedPayload?.maxFeePerGas, + maxPriorityFeePerGas: request.computedPayload?.maxPriorityFeePerGas, + amount: request.computedPayload?.value, + } + for (const method of methods) { const parameters = method.parameters @@ -214,17 +225,8 @@ const ContractInteraction = memo(() => { } } } - return { - isNativeTokenInteraction: true, - typeName: t('popups_wallet_contract_interaction'), - tokenAddress: request.computedPayload?.to, - to: request.computedPayload?.to, - gas: request.computedPayload?.gas, - gasPrice: request.computedPayload?.gasPrice, - maxFeePerGas: request.computedPayload?.maxFeePerGas, - maxPriorityFeePerGas: request.computedPayload?.maxPriorityFeePerGas, - amount: request.computedPayload?.value, - } + + return {} case TransactionDescriptorType.TRANSFER: return { isNativeTokenInteraction: true, diff --git a/packages/mask/src/plugins/Trader/trader/balancer/useTradeCallback.ts b/packages/mask/src/plugins/Trader/trader/balancer/useTradeCallback.ts index 51dee6e2d4f0..fc3059a63ccc 100644 --- a/packages/mask/src/plugins/Trader/trader/balancer/useTradeCallback.ts +++ b/packages/mask/src/plugins/Trader/trader/balancer/useTradeCallback.ts @@ -5,7 +5,7 @@ import { SLIPPAGE_DEFAULT } from '../../constants' import { SwapResponse, TradeComputed, TradeStrategy } from '../../types' import { TargetChainIdContext } from '@masknet/plugin-infra/web3-evm' import { useAccount, useWeb3Connection } from '@masknet/plugin-infra/web3' -import { NetworkPluginID, ZERO } from '@masknet/web3-shared-base' +import { NetworkPluginID } from '@masknet/web3-shared-base' import { useTradeAmount } from './useTradeAmount' export function useTradeCallback( @@ -60,11 +60,6 @@ export function useTradeCallback( // send transaction and wait for hash const config = { from: account, - gas: - (await connection.estimateTransaction?.({ - from: account, - value: transactionValue, - })) ?? ZERO.toString(), value: transactionValue, ...gasConfig, } diff --git a/packages/plugins/EVM/src/state/Connection/connection.ts b/packages/plugins/EVM/src/state/Connection/connection.ts index 9516ddbf3c50..cd439da4730d 100644 --- a/packages/plugins/EVM/src/state/Connection/connection.ts +++ b/packages/plugins/EVM/src/state/Connection/connection.ts @@ -794,6 +794,7 @@ class Connection implements EVM_Connection { { from: options.account, ...transaction, + value: transaction.value ? toHex(transaction.value) : undefined, }, ], }, diff --git a/packages/web3-shared/evm/constants/chains.json b/packages/web3-shared/evm/constants/chains.json index 70abf0d8c5cb..c157fb2120df 100644 --- a/packages/web3-shared/evm/constants/chains.json +++ b/packages/web3-shared/evm/constants/chains.json @@ -2782,7 +2782,7 @@ "nativeCurrency": { "chainId": 1313161554, "name": "Ether", - "symbol": "aETH", + "symbol": "AETH", "decimals": 18 }, "infoURL": "https://aurora.dev", @@ -2805,7 +2805,7 @@ "nativeCurrency": { "chainId": 1313161555, "name": "Ether", - "symbol": "aETH", + "symbol": "AETH", "decimals": 18 }, "infoURL": "https://aurora.dev" @@ -2821,7 +2821,7 @@ "nativeCurrency": { "chainId": 1313161556, "name": "Ether", - "symbol": "aETH", + "symbol": "AETH", "decimals": 18 }, "infoURL": "https://aurora.dev" From 4748603e38b65768e4bdec089b515e0cb4ceaca6 Mon Sep 17 00:00:00 2001 From: UncleBill Date: Mon, 11 Jul 2022 17:15:21 +0800 Subject: [PATCH 052/179] fix: turn off annoying isVisitable props warning (#6748) --- packages/theme/src/Components/Tabs/index.tsx | 31 ++++++++++---------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/packages/theme/src/Components/Tabs/index.tsx b/packages/theme/src/Components/Tabs/index.tsx index 85561051ca00..7568459c66ae 100644 --- a/packages/theme/src/Components/Tabs/index.tsx +++ b/packages/theme/src/Components/Tabs/index.tsx @@ -2,7 +2,6 @@ import { Box, Button, ButtonGroup, ButtonGroupProps, styled, Tab } from '@mui/ma import { useTabContext, getPanelId, getTabId } from '@mui/lab/TabContext' import { forwardRef, - cloneElement, Children, isValidElement, useState, @@ -177,11 +176,6 @@ export const MaskTabList = forwardRef((props, 'aria-controls': getPanelId(context, child.props.value), id: getTabId(context, child.props.value), selected: child.props.value === context.value, - // if move tab to first in flexible tabs - isVisitable: (top: number, right: number) => { - const anchor = anchorRef.current?.getBoundingClientRect() - return right <= (anchor?.right ?? 0) - defaultTabSize && top - (anchor?.top ?? 0) < defaultTabSize - }, onChange: (event: object, value: string, visitable?: boolean) => { handleToggle(false) props.onChange(event, value) @@ -191,16 +185,23 @@ export const MaskTabList = forwardRef((props, }, } - if (child.type === Tab) { - const C = tabMapping[variant] - return ( - - {child.props.label} - - ) - } + if (child.type !== Tab) return child - return cloneElement(child, extra) + if (variant === 'flexible') { + Object.assign(extra, { + // if move tab to first in flexible tabs + isVisitable: (top: number, right: number) => { + const anchor = anchorRef.current?.getBoundingClientRect() + return right <= (anchor?.right ?? 0) - defaultTabSize && top - (anchor?.top ?? 0) < defaultTabSize + }, + }) + } + const C = tabMapping[variant] + return ( + + {child.props.label} + + ) }) // #region hide tab should up to first when chick From f2a44fed60ca778f2c6640450de2ff5ca6aaf754 Mon Sep 17 00:00:00 2001 From: zhouhanseng Date: Mon, 11 Jul 2022 17:26:14 +0800 Subject: [PATCH 053/179] fix: mf 1416 --- .../src/plugins/Approval/SNSAdaptor/ApprovalNFTContent.tsx | 1 + .../src/plugins/Approval/SNSAdaptor/ApprovalTokenContent.tsx | 1 + packages/mask/src/plugins/Approval/SNSAdaptor/useStyles.tsx | 3 +++ 3 files changed, 5 insertions(+) diff --git a/packages/mask/src/plugins/Approval/SNSAdaptor/ApprovalNFTContent.tsx b/packages/mask/src/plugins/Approval/SNSAdaptor/ApprovalNFTContent.tsx index c4c5ca648f89..8eaeacea0207 100644 --- a/packages/mask/src/plugins/Approval/SNSAdaptor/ApprovalNFTContent.tsx +++ b/packages/mask/src/plugins/Approval/SNSAdaptor/ApprovalNFTContent.tsx @@ -116,6 +116,7 @@ function ApprovalNFTItem(props: ApprovalNFTItemProps) { expectedChainId={chainId} switchChainWithoutPopup expectedPluginID={NetworkPluginID.PLUGIN_EVM} + className={classes.chainBoundary} classes={{ switchButton: classes.button }} expectedChainIdSwitchedCallback={() => approveCallback()} ActionButtonPromiseProps={{ diff --git a/packages/mask/src/plugins/Approval/SNSAdaptor/ApprovalTokenContent.tsx b/packages/mask/src/plugins/Approval/SNSAdaptor/ApprovalTokenContent.tsx index beb9545e552e..9e03fe19feed 100644 --- a/packages/mask/src/plugins/Approval/SNSAdaptor/ApprovalTokenContent.tsx +++ b/packages/mask/src/plugins/Approval/SNSAdaptor/ApprovalTokenContent.tsx @@ -98,6 +98,7 @@ function ApprovalTokenItem(props: ApprovalTokenItemProps) { expectedChainId={chainId} switchChainWithoutPopup expectedPluginID={NetworkPluginID.PLUGIN_EVM} + className={classes.chainBoundary} classes={{ switchButton: classes.button }} expectedChainIdSwitchedCallback={() => approveCallback(true, true)} ActionButtonPromiseProps={{ diff --git a/packages/mask/src/plugins/Approval/SNSAdaptor/useStyles.tsx b/packages/mask/src/plugins/Approval/SNSAdaptor/useStyles.tsx index 310559562782..97a8f57616f3 100644 --- a/packages/mask/src/plugins/Approval/SNSAdaptor/useStyles.tsx +++ b/packages/mask/src/plugins/Approval/SNSAdaptor/useStyles.tsx @@ -219,5 +219,8 @@ export const useStyles = makeStyles<{ listItemBackground?: string; listItemBackg boxShadow: `0 8px 25px ${parseColor(theme.palette.common.black).setAlpha(0.3).toRgbString()}`, }, }, + chainBoundary: { + width: 'auto !important', + }, }), ) From 58d0c2ebf59b83d2b93390ba78076a566195e8a1 Mon Sep 17 00:00:00 2001 From: zhouhanseng Date: Mon, 11 Jul 2022 17:31:13 +0800 Subject: [PATCH 054/179] fix: mf 1419 --- packages/mask/src/components/shared/ApplicationBoardDialog.tsx | 2 +- .../mask/src/components/shared/ApplicationRecommendArea.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/mask/src/components/shared/ApplicationBoardDialog.tsx b/packages/mask/src/components/shared/ApplicationBoardDialog.tsx index fddee13004aa..0a248df29a93 100644 --- a/packages/mask/src/components/shared/ApplicationBoardDialog.tsx +++ b/packages/mask/src/components/shared/ApplicationBoardDialog.tsx @@ -13,7 +13,7 @@ import { GearIcon } from '@masknet/icons' const useStyles = makeStyles()((theme) => { return { content: { - padding: theme.spacing(1.5, 2, 2), + padding: theme.spacing(1.5, 2, '6px'), height: 470, overflow: 'hidden', }, diff --git a/packages/mask/src/components/shared/ApplicationRecommendArea.tsx b/packages/mask/src/components/shared/ApplicationRecommendArea.tsx index d09b82f690ed..7fe0c3f16de3 100644 --- a/packages/mask/src/components/shared/ApplicationRecommendArea.tsx +++ b/packages/mask/src/components/shared/ApplicationRecommendArea.tsx @@ -9,7 +9,7 @@ const useStyles = makeStyles()(() => { recommendFeatureAppListWrapper: { display: 'flex', overflowX: 'scroll', - margin: '0 2px 5px 2px', + margin: '0 2px 4px 2px', padding: '8px 2px 0 2px', '&::-webkit-scrollbar': { display: 'none', From 740734520e8e1e085fd9fb27111c2714eddac2cc Mon Sep 17 00:00:00 2001 From: zhouhanseng Date: Mon, 11 Jul 2022 17:35:55 +0800 Subject: [PATCH 055/179] fix: mf 1404 --- packages/mask/src/plugins/Furucombo/UI/FurucomboView.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/mask/src/plugins/Furucombo/UI/FurucomboView.tsx b/packages/mask/src/plugins/Furucombo/UI/FurucomboView.tsx index 2b93051ef30c..ff56b8967a64 100644 --- a/packages/mask/src/plugins/Furucombo/UI/FurucomboView.tsx +++ b/packages/mask/src/plugins/Furucombo/UI/FurucomboView.tsx @@ -80,9 +80,7 @@ export function FurucomboView(props: PoolViewProps) { const investable = investables.find( (investable: Investable) => - isSameAddress(investable.address, props.address) && - investable.chainId === currentChainId && - investable.category === props.category, + isSameAddress(investable.address, props.address) && investable.category === props.category, ) if (!investable) From 92808aa08a6772789ccb33cc8322627de7ae6fbc Mon Sep 17 00:00:00 2001 From: nuanyang233 Date: Mon, 11 Jul 2022 17:36:53 +0800 Subject: [PATCH 056/179] fix: bugfix for unknow contract --- .../Wallet/ContractInteraction/index.tsx | 87 +++++++++---------- 1 file changed, 43 insertions(+), 44 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 5271c1b4515f..1f1b915f7a3d 100644 --- a/packages/mask/src/extension/popups/pages/Wallet/ContractInteraction/index.tsx +++ b/packages/mask/src/extension/popups/pages/Wallet/ContractInteraction/index.tsx @@ -176,57 +176,56 @@ const ContractInteraction = memo(() => { switch (type) { case TransactionDescriptorType.INTERACTION: const methods = request.transactionContext?.methods - if (!methods?.length) - return { - isNativeTokenInteraction: true, - typeName: t('popups_wallet_contract_interaction'), - tokenAddress: request.computedPayload?.to, - to: request.computedPayload?.to, - gas: request.computedPayload?.gas, - gasPrice: request.computedPayload?.gasPrice, - maxFeePerGas: request.computedPayload?.maxFeePerGas, - maxPriorityFeePerGas: request.computedPayload?.maxPriorityFeePerGas, - amount: request.computedPayload?.value, - } - for (const method of methods) { - const parameters = method.parameters + if (methods?.length) { + for (const method of methods) { + const parameters = method.parameters - if (method.name === 'approve' && parameters?.value) { - return { - isNativeTokenInteraction: false, - typeName: request.formatterTransaction?.title, - tokenAddress: request.computedPayload?.to, - to: request.computedPayload?.to, - gas: request.computedPayload?.gas, - gasPrice: request.computedPayload?.gasPrice, - maxFeePerGas: request.computedPayload?.maxFeePerGas, - maxPriorityFeePerGas: request.computedPayload?.maxPriorityFeePerGas, - amount: parameters?.value, + if (method.name === 'approve' && parameters?.value) { + return { + isNativeTokenInteraction: false, + typeName: request.formatterTransaction?.title, + tokenAddress: request.computedPayload?.to, + to: request.computedPayload?.to, + gas: request.computedPayload?.gas, + gasPrice: request.computedPayload?.gasPrice, + maxFeePerGas: request.computedPayload?.maxFeePerGas, + maxPriorityFeePerGas: request.computedPayload?.maxPriorityFeePerGas, + amount: parameters?.value, + } } - } - if ( - (method.name === 'transfer' || method.name === 'transferFrom') && - parameters?.to && - parameters?.value - ) { - return { - isNativeTokenInteraction: false, - typeName: t('popups_wallet_contract_interaction_transfer'), - tokenAddress: request.computedPayload?.to, - to: parameters?.to as string, - gas: request.computedPayload?.gas, - gasPrice: request.computedPayload?.gasPrice, - maxFeePerGas: request.computedPayload?.maxFeePerGas, - maxPriorityFeePerGas: request.computedPayload?.maxPriorityFeePerGas, - amount: parameters?.value, - contractAddress: request.computedPayload?.to, + if ( + (method.name === 'transfer' || method.name === 'transferFrom') && + parameters?.to && + parameters?.value + ) { + return { + isNativeTokenInteraction: false, + typeName: t('popups_wallet_contract_interaction_transfer'), + tokenAddress: request.computedPayload?.to, + to: parameters?.to as string, + gas: request.computedPayload?.gas, + gasPrice: request.computedPayload?.gasPrice, + maxFeePerGas: request.computedPayload?.maxFeePerGas, + maxPriorityFeePerGas: request.computedPayload?.maxPriorityFeePerGas, + amount: parameters?.value, + contractAddress: request.computedPayload?.to, + } } } } - - return {} + return { + isNativeTokenInteraction: true, + typeName: t('popups_wallet_contract_interaction'), + tokenAddress: request.computedPayload?.to, + to: request.computedPayload?.to, + gas: request.computedPayload?.gas, + gasPrice: request.computedPayload?.gasPrice, + maxFeePerGas: request.computedPayload?.maxFeePerGas, + maxPriorityFeePerGas: request.computedPayload?.maxPriorityFeePerGas, + amount: request.computedPayload?.value, + } case TransactionDescriptorType.TRANSFER: return { isNativeTokenInteraction: true, From ac74a6dd14e7000e5e9fe8a94b4e4fba51b0098c Mon Sep 17 00:00:00 2001 From: zhouhanseng Date: Mon, 11 Jul 2022 17:50:23 +0800 Subject: [PATCH 057/179] fix: mf 1373 --- packages/mask/src/components/shared/ApplicationBoard.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/mask/src/components/shared/ApplicationBoard.tsx b/packages/mask/src/components/shared/ApplicationBoard.tsx index ae551276fdad..7206ac544d1e 100644 --- a/packages/mask/src/components/shared/ApplicationBoard.tsx +++ b/packages/mask/src/components/shared/ApplicationBoard.tsx @@ -185,7 +185,13 @@ function ApplicationBoardContent(props: Props) { ))} ) : ( -
+
2 && isCarouselReady() && isHoveringCarousel + ? classes.applicationWrapperWithCarousel + : '', + )}> {t('application_display_tab_plug_app-unlisted-placeholder')} From 00979875e63be0160b9715dc7dc6389f06bfbbb6 Mon Sep 17 00:00:00 2001 From: BillyS Date: Mon, 11 Jul 2022 18:00:27 +0800 Subject: [PATCH 058/179] fix: rebase (#6754) --- .../shared/SelectRecipients/SelectRecipientsDialog.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mask/src/components/shared/SelectRecipients/SelectRecipientsDialog.tsx b/packages/mask/src/components/shared/SelectRecipients/SelectRecipientsDialog.tsx index 0cb974da13ed..d9445566b182 100644 --- a/packages/mask/src/components/shared/SelectRecipients/SelectRecipientsDialog.tsx +++ b/packages/mask/src/components/shared/SelectRecipients/SelectRecipientsDialog.tsx @@ -116,7 +116,7 @@ export function SelectRecipientsDialogUI(props: SelectRecipientsDialogUIProps) { ignoreLocation: true, threshold: 0, }) - return (search === '' ? items : fuse.search(search).map((item) => item.item)).concat(props.selected) + return search === '' ? items : fuse.search(search).map((item) => item.item) }, [search, items]) return ( Date: Mon, 11 Jul 2022 18:11:41 +0800 Subject: [PATCH 059/179] fix: mf 1397 --- .../mask/src/web3/UI/EthereumERC721TokenApprovedBoundary.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/mask/src/web3/UI/EthereumERC721TokenApprovedBoundary.tsx b/packages/mask/src/web3/UI/EthereumERC721TokenApprovedBoundary.tsx index 99168f60dcc9..163dbb33cbf8 100644 --- a/packages/mask/src/web3/UI/EthereumERC721TokenApprovedBoundary.tsx +++ b/packages/mask/src/web3/UI/EthereumERC721TokenApprovedBoundary.tsx @@ -49,6 +49,7 @@ export function EthereumERC721TokenApprovedBoundary(props: EthereumERC712TokenAp contractDetailed?.address, operator, true, + retry, ) const validationMessage = useMemo(() => { From a99327851782deb7ca6f6b6b1c4c3ca72643a60f Mon Sep 17 00:00:00 2001 From: nuanyang233 Date: Mon, 11 Jul 2022 18:22:51 +0800 Subject: [PATCH 060/179] fix: incorrect chain id with formatter context (#6758) --- .../popups/pages/Wallet/hooks/useUnConfirmedRequest.ts | 2 +- packages/plugins/EVM/src/state/TransactionFormatter.ts | 2 +- packages/web3-shared/evm/utils/contract.ts | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/mask/src/extension/popups/pages/Wallet/hooks/useUnConfirmedRequest.ts b/packages/mask/src/extension/popups/pages/Wallet/hooks/useUnConfirmedRequest.ts index c3f8a2ce4189..8642a7bee4cc 100644 --- a/packages/mask/src/extension/popups/pages/Wallet/hooks/useUnConfirmedRequest.ts +++ b/packages/mask/src/extension/popups/pages/Wallet/hooks/useUnConfirmedRequest.ts @@ -24,7 +24,7 @@ export const useUnconfirmedRequest = () => { formatterTransaction, transactionContext, } - }, []) + }, [chainId, TransactionFormatter]) useEffect(() => { return WalletMessages.events.requestsUpdated.on(result.retry) diff --git a/packages/plugins/EVM/src/state/TransactionFormatter.ts b/packages/plugins/EVM/src/state/TransactionFormatter.ts index 8101f61a3f80..1d8b33eb99d4 100644 --- a/packages/plugins/EVM/src/state/TransactionFormatter.ts +++ b/packages/plugins/EVM/src/state/TransactionFormatter.ts @@ -106,7 +106,7 @@ export class TransactionFormatter extends TransactionFormatterState Date: Mon, 11 Jul 2022 18:37:01 +0800 Subject: [PATCH 061/179] fix: mf 1423 --- packages/mask/src/components/shared/ApplicationBoard.tsx | 2 ++ .../plugins/RedPacket/SNSAdaptor/RedPacketConfirmDialog.tsx | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/packages/mask/src/components/shared/ApplicationBoard.tsx b/packages/mask/src/components/shared/ApplicationBoard.tsx index 7206ac544d1e..0cf6f9bcd276 100644 --- a/packages/mask/src/components/shared/ApplicationBoard.tsx +++ b/packages/mask/src/components/shared/ApplicationBoard.tsx @@ -167,6 +167,7 @@ function ApplicationBoardContent(props: Props) { <> ) { } = usePersonaAgainstSNSConnectStatus() useEffect(() => { + nextIDConnectStatus.reset() retry() return MaskMessages.events.currentPersonaIdentifier.on(() => { retry() diff --git a/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacketConfirmDialog.tsx b/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacketConfirmDialog.tsx index d3d9353d8e76..646a83313ea8 100644 --- a/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacketConfirmDialog.tsx +++ b/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacketConfirmDialog.tsx @@ -119,6 +119,10 @@ export function RedPacketConfirmDialog(props: ConfirmRedPacketFormProps) { token_address: string total: string } + + // the events log is not available + if (!events?.CreationSuccess.returnValues.id) return + payload.current.sender = { address: account, name: settings.name, From 35a60ce0b94564093ce35f4309b8d99d4168d2a2 Mon Sep 17 00:00:00 2001 From: zhouhanseng Date: Mon, 11 Jul 2022 19:24:00 +0800 Subject: [PATCH 062/179] fix: workaround for pure react carousel issue --- packages/mask/src/plugins/Avatar/SNSAdaptor/AddNFT.tsx | 4 ++++ .../Web3Profile/src/SNSAdaptor/components/AddCollectibles.tsx | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/packages/mask/src/plugins/Avatar/SNSAdaptor/AddNFT.tsx b/packages/mask/src/plugins/Avatar/SNSAdaptor/AddNFT.tsx index 75eb06b8b45b..e638cefe3763 100644 --- a/packages/mask/src/plugins/Avatar/SNSAdaptor/AddNFT.tsx +++ b/packages/mask/src/plugins/Avatar/SNSAdaptor/AddNFT.tsx @@ -147,6 +147,9 @@ export function AddNFT(props: AddNFTProps) {
e.currentTarget.getElementsByTagName('input')[0].focus()} sx={{ width: '100%' }} placeholder={t('plugin_avatar_input_token_address')} onChange={(e) => onAddressChange(e.target.value)} @@ -154,6 +157,7 @@ export function AddNFT(props: AddNFTProps) {
e.currentTarget.getElementsByTagName('input')[0].focus()} sx={{ width: '100%' }} placeholder={t('plugin_avatar_input_token_id')} onChange={(e) => onTokenIdChange(e.target.value)} diff --git a/packages/plugins/Web3Profile/src/SNSAdaptor/components/AddCollectibles.tsx b/packages/plugins/Web3Profile/src/SNSAdaptor/components/AddCollectibles.tsx index 2ef64203701d..a4b02a112376 100644 --- a/packages/plugins/Web3Profile/src/SNSAdaptor/components/AddCollectibles.tsx +++ b/packages/plugins/Web3Profile/src/SNSAdaptor/components/AddCollectibles.tsx @@ -145,6 +145,9 @@ export function AddNFT(props: AddNFTProps) {
e.currentTarget.getElementsByTagName('input')[0].focus()} sx={{ width: '100%' }} placeholder={t.plugin_avatar_input_token_address()} onChange={(e) => onAddressChange(e.target.value)} @@ -152,6 +155,7 @@ export function AddNFT(props: AddNFTProps) {
e.currentTarget.getElementsByTagName('input')[0].focus()} sx={{ width: '100%' }} placeholder={t.plugin_avatar_input_token_id()} onChange={(e) => onTokenIdChange(e.target.value)} From db85d26589e7bbdbaa08194f589c29530f7c56c1 Mon Sep 17 00:00:00 2001 From: nuanyang233 Date: Mon, 11 Jul 2022 20:05:03 +0800 Subject: [PATCH 063/179] fix: add explore link at harmony --- .../Trader/trader/uniswap/useTradeCallback.ts | 1 - .../web3-shared/evm/constants/chains.json | 36 ++++++++++++++++--- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/packages/mask/src/plugins/Trader/trader/uniswap/useTradeCallback.ts b/packages/mask/src/plugins/Trader/trader/uniswap/useTradeCallback.ts index 749987845bf3..5bdacb1555ef 100644 --- a/packages/mask/src/plugins/Trader/trader/uniswap/useTradeCallback.ts +++ b/packages/mask/src/plugins/Trader/trader/uniswap/useTradeCallback.ts @@ -36,7 +36,6 @@ export function useTradeCallback( allowedSlippage?: number, ) { const { targetChainId } = TargetChainIdContext.useContainer() - // const web3 = useWeb3(NetworkPluginID.PLUGIN_EVM, { chainId: targetChainId }) const connection = useWeb3Connection(NetworkPluginID.PLUGIN_EVM, { chainId: targetChainId }) const account = useAccount(NetworkPluginID.PLUGIN_EVM) const tradeParameters = useTradeParameters(trade, tradeProvider, allowedSlippage) diff --git a/packages/web3-shared/evm/constants/chains.json b/packages/web3-shared/evm/constants/chains.json index c157fb2120df..725cccd2906c 100644 --- a/packages/web3-shared/evm/constants/chains.json +++ b/packages/web3-shared/evm/constants/chains.json @@ -2839,7 +2839,14 @@ "symbol": "ONE", "decimals": 18 }, - "infoURL": "https://www.harmony.one/" + "infoURL": "https://www.harmony.one/", + "explorers": [ + { + "name": "harmony", + "url": "https://explorer.harmony.one", + "standard": "EIP3091" + } + ] }, { "chainId": 1666600001, @@ -2854,7 +2861,14 @@ "symbol": "ONE", "decimals": 18 }, - "infoURL": "https://www.harmony.one/" + "infoURL": "https://www.harmony.one/", + "explorers": [ + { + "name": "harmony", + "url": "https://explorer.harmony.one", + "standard": "EIP3091" + } + ] }, { "chainId": 1666600002, @@ -2869,7 +2883,14 @@ "symbol": "ONE", "decimals": 18 }, - "infoURL": "https://www.harmony.one/" + "infoURL": "https://www.harmony.one/", + "explorers": [ + { + "name": "harmony", + "url": "https://explorer.harmony.one", + "standard": "EIP3091" + } + ] }, { "chainId": 1666600003, @@ -2884,7 +2905,14 @@ "symbol": "ONE", "decimals": 18 }, - "infoURL": "https://www.harmony.one/" + "infoURL": "https://www.harmony.one/", + "explorers": [ + { + "name": "harmony", + "url": "https://explorer.harmony.one", + "standard": "EIP3091" + } + ] }, { "chainId": 1666700000, From 905a6baadf89ef16909ca8a909e8a1efce6403eb Mon Sep 17 00:00:00 2001 From: UncleBill Date: Mon, 11 Jul 2022 20:51:55 +0800 Subject: [PATCH 064/179] fix: mf-1418 some places fail to get icon of token (#6759) * fix: mf-1418 some places fail to get icon of token * fixup! fix: mf-1418 some places fail to get icon of token --- .../trending/components/CoinIcon.tsx | 6 +- packages/shared/package.json | 2 + .../src/UI/components/TokenIcon/index.tsx | 30 +- packages/shared/src/hooks/useImageBase64.ts | 40 ++- pnpm-lock.yaml | 266 ++++++++---------- 5 files changed, 175 insertions(+), 169 deletions(-) diff --git a/packages/mask/src/plugins/Trader/SNSAdaptor/trending/components/CoinIcon.tsx b/packages/mask/src/plugins/Trader/SNSAdaptor/trending/components/CoinIcon.tsx index 79792183527d..ff3df111f8f8 100644 --- a/packages/mask/src/plugins/Trader/SNSAdaptor/trending/components/CoinIcon.tsx +++ b/packages/mask/src/plugins/Trader/SNSAdaptor/trending/components/CoinIcon.tsx @@ -21,7 +21,7 @@ export const CoinIcon: FC = ({ type, address, logoUrl, name, size }, }, } - if (address && type === TrendingCoinType.Fungible) return - if (type === TrendingCoinType.NonFungible) return - return null + if (address && type === TrendingCoinType.Fungible) + return + return } diff --git a/packages/shared/package.json b/packages/shared/package.json index 39d4d7a053d3..47dd621944b6 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -24,6 +24,8 @@ "@types/qrcode": "^1.4.2", "@solana/web3.js": "^1.30.2", "anchorme": "^2.1.2", + "lru-cache": "^7.10.1", + "@types/lru-cache": "^7.10.10", "bignumber.js": "^9.0.2", "classnames": "^2.3.1", "date-fns": "2.28.0", diff --git a/packages/shared/src/UI/components/TokenIcon/index.tsx b/packages/shared/src/UI/components/TokenIcon/index.tsx index a200c0e49d15..de06e60dd17e 100644 --- a/packages/shared/src/UI/components/TokenIcon/index.tsx +++ b/packages/shared/src/UI/components/TokenIcon/index.tsx @@ -1,17 +1,16 @@ import { memo } from 'react' import { useAsyncRetry } from 'react-use' import { first } from 'lodash-unified' -import { Avatar, AvatarProps } from '@mui/material' +import { Avatar, AvatarProps, useTheme } from '@mui/material' import { makeStyles, useStylesExtends } from '@masknet/theme' import NO_IMAGE_COLOR from './constants' import { useChainId, useWeb3Hub, Web3Helper } from '@masknet/plugin-infra/web3' import type { NetworkPluginID } from '@masknet/web3-shared-base' import { EMPTY_LIST } from '@masknet/shared-base' -import { useImageBase64 } from '../../../hooks/useImageBase64' +import { useAccessibleUrl } from '../../../hooks/useImageBase64' const useStyles = makeStyles()((theme) => ({ icon: { - backgroundColor: theme.palette.common.white, margin: 0, }, })) @@ -31,18 +30,25 @@ export function TokenIcon(props: TokenIconProps) { const chainId = useChainId(props.pluginID, props.chainId) const hub = useWeb3Hub(props.pluginID) - const { value } = useAsyncRetry(async () => { - const logoURLs = await hub?.getFungibleTokenIconURLs?.(chainId, address) + const logoURLs = await hub?.getFungibleTokenIconURLs?.(chainId, address).catch(() => []) + const key = address ? [chainId, address].join('/') : logoURL return { - key: [chainId, address, logoURL].join('/'), + key, urls: [logoURL, ...(logoURLs ?? [])].filter(Boolean) as string[], } }, [chainId, address, logoURL, hub]) const { urls = EMPTY_LIST, key } = value ?? {} - const base64 = useImageBase64(key, first(urls)) + const accessibleUrl = useAccessibleUrl(key, first(urls)) - return + return ( + + ) } export interface TokenIconUIProps extends withClasses<'icon'> { @@ -61,13 +67,17 @@ export const TokenIconUI = memo((props) => { : undefined const classes = useStylesExtends(useStyles(), props) + const theme = useTheme() return ( + {...AvatarProps} + sx={{ + ...AvatarProps?.sx, + backgroundColor: logoURL ? theme.palette.common.white : defaultBackgroundColor, + }}> {name?.slice(0, 1).toUpperCase()} ) diff --git a/packages/shared/src/hooks/useImageBase64.ts b/packages/shared/src/hooks/useImageBase64.ts index 609dbe819606..81867e1726a9 100644 --- a/packages/shared/src/hooks/useImageBase64.ts +++ b/packages/shared/src/hooks/useImageBase64.ts @@ -1,4 +1,5 @@ import { useState } from 'react' +import LRUCache from 'lru-cache' import { useAsyncRetry } from 'react-use' function readAsDataURL(blob: Blob) { @@ -10,35 +11,54 @@ function readAsDataURL(blob: Blob) { }) } -const cache = new Map() +const cache = new LRUCache>({ + max: 500, + ttl: 300_000, +}) +const responseToBase64 = async (response: Response) => { + const blob = await response.blob() + const dataURL = await readAsDataURL(blob) + return dataURL +} -export function useImageBase64( - key?: string, +export function useAccessibleUrl( + key = '', url?: string, options?: { fetch: typeof globalThis.fetch }, ) { const fetch = options?.fetch ?? globalThis.fetch - const [base64, setBase64] = useState(cache.get(key ?? '') ?? '') + const [avaliableUrl, setAvaliableUrl] = useState(() => { + const hit = cache.get(key) + return typeof hit === 'string' ? hit : '' + }) useAsyncRetry(async () => { if (!key) return const hit = cache.get(key) - if (hit) { - setBase64(hit) + if (typeof hit === 'string') { + setAvaliableUrl(hit) + return + } else if (hit instanceof Promise) { + setAvaliableUrl(await responseToBase64((await hit).clone())) return } if (!url || !fetch) return - const response = await fetch(`https://cors.r2d2.to/?${url}`) - if (!response) return + const fetchingTask = fetch(`https://cors.r2d2.to/?${url}`) + cache.set(key, fetchingTask) + const response = await fetchingTask + if (!response.ok) { + cache.delete(key) + return + } const blob = await response.blob() const dataURL = await readAsDataURL(blob) cache.set(key, dataURL) - setBase64(dataURL) + setAvaliableUrl(dataURL) }, [key, url]) - return base64 + return avaliableUrl } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d9551915fa10..c1861175333a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1312,6 +1312,7 @@ importers: '@masknet/web3-shared-solana': workspace:* '@react-hookz/web': ^14.2.2 '@solana/web3.js': ^1.30.2 + '@types/lru-cache': ^7.10.10 '@types/qrcode': ^1.4.2 anchorme: ^2.1.2 bignumber.js: ^9.0.2 @@ -1319,6 +1320,7 @@ importers: date-fns: 2.28.0 iframe-resizer-react: ^1.1.0 lodash-es: ^4.17.21 + lru-cache: ^7.10.1 qrcode: ^1.5.0 react-feather: ^2.0.9 react-hook-form: ^7.31.1 @@ -1342,6 +1344,7 @@ importers: '@masknet/web3-shared-solana': link:../web3-shared/solana '@react-hookz/web': 14.2.2 '@solana/web3.js': 1.44.2 + '@types/lru-cache': 7.10.10 '@types/qrcode': 1.4.2 anchorme: 2.1.2 bignumber.js: 9.0.2 @@ -1349,6 +1352,7 @@ importers: date-fns: 2.28.0 iframe-resizer-react: 1.1.0 lodash-es: 4.17.21 + lru-cache: 7.10.1 qrcode: 1.5.0 react-feather: 2.0.9 react-hook-form: 7.31.1 @@ -1838,11 +1842,11 @@ packages: dev: false /@0xproject/json-schemas/0.7.24: - resolution: {integrity: sha1-IaErQ6sKtKowLQLEiRZozaNrbGQ=} + resolution: {integrity: sha512-20MeFHMptuv0e58mjSLmW84m2HbYdmuxFeeXqGZjv047zBawONe2aXKqLX266XYjgNSif/cDVzdgh7/46J9MVQ==} engines: {node: '>=6.12'} dependencies: '@0xproject/typescript-typings': 0.3.2 - '@types/node': 17.0.34 + '@types/node': 17.0.45 jsonschema: 1.4.0 lodash.values: 4.3.0 dev: false @@ -1855,15 +1859,15 @@ packages: dev: false /@0xproject/types/0.7.0: - resolution: {integrity: sha1-+tE5Je6SrU7hmAZopcsr7U3Kq48=} + resolution: {integrity: sha512-LlTnq7raPnCioCokNy5CLDxZJeg3KtcHT4PBJD6BDiXYtNJxBWvL7/jr6JiwdjReNg7ihGi1265VKfFX7qukRw==} engines: {node: '>=6.12'} dependencies: - '@types/node': 17.0.34 + '@types/node': 17.0.45 bignumber.js: 4.1.0 dev: false /@0xproject/typescript-typings/0.3.2: - resolution: {integrity: sha1-q8NgtEGv2pkxAEUMqDad+r91k2s=} + resolution: {integrity: sha512-sHwGTxerREyQhyXFHhZRHvy7PlbBUjsoVbxhf5f+9JasC+IhQ2Nv4uJFjOo16uUPPp7l+lsRUvK/ZwrdGRbFBA==} engines: {node: '>=6.12'} dependencies: '@0xproject/types': 0.7.0 @@ -9953,7 +9957,6 @@ packages: deprecated: This is a stub types definition. lru-cache provides its own type definitions, so you do not need this installed. dependencies: lru-cache: 7.10.1 - dev: true /@types/mdast/3.0.10: resolution: {integrity: sha512-W864tg/Osz1+9f4lrGTZpCSO5/z4608eUp19tbozkq2HJK6i3z1kT0H9tlADXuYIb1YYOBByU4Jsqkk75q48qA==} @@ -11703,7 +11706,7 @@ packages: dev: false /axios/0.17.1: - resolution: {integrity: sha1-LY4+XQvb1zJ/kbyBT1xXZg+Bgk0=} + resolution: {integrity: sha512-mZzWRyJeJ0rtK7e1/6iYBUzmeXjzei+1h1IvbedyU0sB52++tU5AU6r6TLXpwNVR0ebXIpvTVW+9CpWNyc1n8w==} deprecated: Critical security vulnerability fixed in v0.21.1. For more information, see https://github.com/axios/axios/pull/3410 dependencies: follow-redirects: 1.14.9 @@ -11737,7 +11740,7 @@ packages: dev: false /babel-code-frame/6.26.0: - resolution: {integrity: sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=} + resolution: {integrity: sha512-XqYMR2dfdGMW+hd0IUZ2PwK+fGeFkOxZJ0wY+JaQAHzt1Zx8LcvpiZD2NiGkEG8qx0CfkAOr5xt76d1e8vG90g==} dependencies: chalk: 1.1.3 esutils: 2.0.3 @@ -11784,7 +11787,7 @@ packages: dev: false /babel-helper-builder-binary-assignment-operator-visitor/6.24.1: - resolution: {integrity: sha1-zORReto1b0IgvK6KAsKzRvmlZmQ=} + resolution: {integrity: sha512-gCtfYORSG1fUMX4kKraymq607FWgMWg+j42IFPc18kFQEsmtaibP4UrqsXt8FlEJle25HUd4tsoDR7H2wDhe9Q==} dependencies: babel-helper-explode-assignable-expression: 6.24.1 babel-runtime: 6.26.0 @@ -11794,7 +11797,7 @@ packages: dev: false /babel-helper-call-delegate/6.24.1: - resolution: {integrity: sha1-7Oaqzdx25Bw0YfiL/Fdb0Nqi340=} + resolution: {integrity: sha512-RL8n2NiEj+kKztlrVJM9JT1cXzzAdvWFh76xh/H1I4nKwunzE4INBXn8ieCZ+wh4zWszZk7NBS1s/8HR5jDkzQ==} dependencies: babel-helper-hoist-variables: 6.24.1 babel-runtime: 6.26.0 @@ -11805,7 +11808,7 @@ packages: dev: false /babel-helper-define-map/6.26.0: - resolution: {integrity: sha1-pfVtq0GiX5fstJjH66ypgZ+Vvl8=} + resolution: {integrity: sha512-bHkmjcC9lM1kmZcVpA5t2om2nzT/xiZpo6TJq7UlZ3wqKfzia4veeXbIhKvJXAMzhhEBd3cR1IElL5AenWEUpA==} dependencies: babel-helper-function-name: 6.24.1 babel-runtime: 6.26.0 @@ -11816,7 +11819,7 @@ packages: dev: false /babel-helper-explode-assignable-expression/6.24.1: - resolution: {integrity: sha1-8luCz33BBDPFX3BZLVdGQArCLKo=} + resolution: {integrity: sha512-qe5csbhbvq6ccry9G7tkXbzNtcDiH4r51rrPUbwwoTzZ18AqxWYRZT6AOmxrpxKnQBW0pYlBI/8vh73Z//78nQ==} dependencies: babel-runtime: 6.26.0 babel-traverse: 6.26.0 @@ -11826,7 +11829,7 @@ packages: dev: false /babel-helper-function-name/6.24.1: - resolution: {integrity: sha1-00dbjAPtmCQqJbSDUasYOZ01gKk=} + resolution: {integrity: sha512-Oo6+e2iX+o9eVvJ9Y5eKL5iryeRdsIkwRYheCuhYdVHsdEQysbc2z2QkqCLIYnNxkT5Ss3ggrHdXiDI7Dhrn4Q==} dependencies: babel-helper-get-function-arity: 6.24.1 babel-runtime: 6.26.0 @@ -11838,28 +11841,28 @@ packages: dev: false /babel-helper-get-function-arity/6.24.1: - resolution: {integrity: sha1-j3eCqpNAfEHTqlCQj4mwMbG2hT0=} + resolution: {integrity: sha512-WfgKFX6swFB1jS2vo+DwivRN4NB8XUdM3ij0Y1gnC21y1tdBoe6xjVnd7NSI6alv+gZXCtJqvrTeMW3fR/c0ng==} dependencies: babel-runtime: 6.26.0 babel-types: 6.26.0 dev: false /babel-helper-hoist-variables/6.24.1: - resolution: {integrity: sha1-HssnaJydJVE+rbyZFKc/VAi+enY=} + resolution: {integrity: sha512-zAYl3tqerLItvG5cKYw7f1SpvIxS9zi7ohyGHaI9cgDUjAT6YcY9jIEH5CstetP5wHIVSceXwNS7Z5BpJg+rOw==} dependencies: babel-runtime: 6.26.0 babel-types: 6.26.0 dev: false /babel-helper-optimise-call-expression/6.24.1: - resolution: {integrity: sha1-96E0J7qfc/j0+pk8VKl4gtEkQlc=} + resolution: {integrity: sha512-Op9IhEaxhbRT8MDXx2iNuMgciu2V8lDvYCNQbDGjdBNCjaMvyLf4wl4A3b8IgndCyQF8TwfgsQ8T3VD8aX1/pA==} dependencies: babel-runtime: 6.26.0 babel-types: 6.26.0 dev: false /babel-helper-regex/6.26.0: - resolution: {integrity: sha1-MlxZ+QL4LyS3T6zu0DY5VPZJXnI=} + resolution: {integrity: sha512-VlPiWmqmGJp0x0oK27Out1D+71nVVCTSdlbhIVoaBAj2lUgrNjBCRR9+llO4lTSb2O4r7PJg+RobRkhBrf6ofg==} dependencies: babel-runtime: 6.26.0 babel-types: 6.26.0 @@ -11867,7 +11870,7 @@ packages: dev: false /babel-helper-remap-async-to-generator/6.24.1: - resolution: {integrity: sha1-XsWBgnrXI/7N04HxySg5BnbkVRs=} + resolution: {integrity: sha512-RYqaPD0mQyQIFRu7Ho5wE2yvA/5jxqCIj/Lv4BXNq23mHYu/vxikOy2JueLiBxQknwapwrJeNCesvY0ZcfnlHg==} dependencies: babel-helper-function-name: 6.24.1 babel-runtime: 6.26.0 @@ -11879,7 +11882,7 @@ packages: dev: false /babel-helper-replace-supers/6.24.1: - resolution: {integrity: sha1-v22/5Dk40XNpohPKiov3S2qQqxo=} + resolution: {integrity: sha512-sLI+u7sXJh6+ToqDr57Bv973kCepItDhMou0xCP2YPVmR1jkHSCY+p1no8xErbV1Siz5QE8qKT1WIwybSWlqjw==} dependencies: babel-helper-optimise-call-expression: 6.24.1 babel-messages: 6.23.0 @@ -11892,7 +11895,7 @@ packages: dev: false /babel-helpers/6.24.1: - resolution: {integrity: sha1-NHHenK7DiOXIUOWX5Yom3fN2ArI=} + resolution: {integrity: sha512-n7pFrqQm44TCYvrCDb0MqabAF+JUBq+ijBvNMUxpkLjJaAu32faIexewMumrH5KLLJ1HDyT0PTEqRyAe/GwwuQ==} dependencies: babel-runtime: 6.26.0 babel-template: 6.26.0 @@ -11975,7 +11978,7 @@ packages: dev: true /babel-messages/6.23.0: - resolution: {integrity: sha1-8830cDhYA1sqKVHG7F7fbGLyYw4=} + resolution: {integrity: sha512-Bl3ZiA+LjqaMtNYopA9TYE9HP1tQ+E5dLxE0XrAzcIJeK2UqF0/EaqXwBn9esd4UmTfEab+P+UYQ1GnioFIb/w==} dependencies: babel-runtime: 6.26.0 dev: false @@ -11998,7 +12001,7 @@ packages: dev: true /babel-plugin-check-es2015-constants/6.22.0: - resolution: {integrity: sha1-NRV7EBQm/S/9PaP3XH0ekYNbv4o=} + resolution: {integrity: sha512-B1M5KBP29248dViEo1owyY32lk1ZSH2DaNNrXLGt8lyjjHm7pBqAdQ7VKUPR6EEDO323+OvT3MQXbCin8ooWdA==} dependencies: babel-runtime: 6.26.0 dev: false @@ -12169,19 +12172,19 @@ packages: dev: true /babel-plugin-syntax-async-functions/6.13.0: - resolution: {integrity: sha1-ytnK0RkbWtY0vzCuCHI5HgZHvpU=} + resolution: {integrity: sha512-4Zp4unmHgw30A1eWI5EpACji2qMocisdXhAftfhXoSV9j0Tvj6nRFE3tOmRY912E0FMRm/L5xWE7MGVT2FoLnw==} dev: false /babel-plugin-syntax-exponentiation-operator/6.13.0: - resolution: {integrity: sha1-nufoM3KQ2pUoggGmpX9BcDF4MN4=} + resolution: {integrity: sha512-Z/flU+T9ta0aIEKl1tGEmN/pZiI1uXmCiGFRegKacQfEJzp7iNsKloZmyJlQr+75FCJtiFfGIK03SiCvCt9cPQ==} dev: false /babel-plugin-syntax-trailing-function-commas/6.22.0: - resolution: {integrity: sha1-ugNgk3+NBuQBgKQ/4NVhb/9TLPM=} + resolution: {integrity: sha512-Gx9CH3Q/3GKbhs07Bszw5fPTlU+ygrOGfAhEt7W2JICwufpC4SuO0mG0+4NykPBSYPMJhqvVlDBU17qB1D+hMQ==} dev: false /babel-plugin-transform-async-to-generator/6.24.1: - resolution: {integrity: sha1-ZTbjeK/2yx1VF6wOQOs+n8jQh2E=} + resolution: {integrity: sha512-7BgYJujNCg0Ti3x0c/DL3tStvnKS6ktIYOmo9wginv/dfZOrbSZ+qG4IRRHMBOzZ5Awb1skTiAsQXg/+IWkZYw==} dependencies: babel-helper-remap-async-to-generator: 6.24.1 babel-plugin-syntax-async-functions: 6.13.0 @@ -12191,19 +12194,19 @@ packages: dev: false /babel-plugin-transform-es2015-arrow-functions/6.22.0: - resolution: {integrity: sha1-RSaSy3EdX3ncf4XkQM5BufJE0iE=} + resolution: {integrity: sha512-PCqwwzODXW7JMrzu+yZIaYbPQSKjDTAsNNlK2l5Gg9g4rz2VzLnZsStvp/3c46GfXpwkyufb3NCyG9+50FF1Vg==} dependencies: babel-runtime: 6.26.0 dev: false /babel-plugin-transform-es2015-block-scoped-functions/6.22.0: - resolution: {integrity: sha1-u8UbSflk1wy42OC5ToICRs46YUE=} + resolution: {integrity: sha512-2+ujAT2UMBzYFm7tidUsYh+ZoIutxJ3pN9IYrF1/H6dCKtECfhmB8UkHVpyxDwkj0CYbQG35ykoz925TUnBc3A==} dependencies: babel-runtime: 6.26.0 dev: false /babel-plugin-transform-es2015-block-scoping/6.26.0: - resolution: {integrity: sha1-1w9SmcEwjQXBL0Y4E7CgnnOxiV8=} + resolution: {integrity: sha512-YiN6sFAQ5lML8JjCmr7uerS5Yc/EMbgg9G8ZNmk2E3nYX4ckHR01wrkeeMijEf5WHNK5TW0Sl0Uu3pv3EdOJWw==} dependencies: babel-runtime: 6.26.0 babel-template: 6.26.0 @@ -12215,7 +12218,7 @@ packages: dev: false /babel-plugin-transform-es2015-classes/6.24.1: - resolution: {integrity: sha1-WkxYpQyclGHlZLSyo7+ryXolhNs=} + resolution: {integrity: sha512-5Dy7ZbRinGrNtmWpquZKZ3EGY8sDgIVB4CU8Om8q8tnMLrD/m94cKglVcHps0BCTdZ0TJeeAWOq2TK9MIY6cag==} dependencies: babel-helper-define-map: 6.26.0 babel-helper-function-name: 6.24.1 @@ -12231,7 +12234,7 @@ packages: dev: false /babel-plugin-transform-es2015-computed-properties/6.24.1: - resolution: {integrity: sha1-b+Ko0WiV1WNPTNmZttNICjCBWbM=} + resolution: {integrity: sha512-C/uAv4ktFP/Hmh01gMTvYvICrKze0XVX9f2PdIXuriCSvUmV9j+u+BB9f5fJK3+878yMK6dkdcq+Ymr9mrcLzw==} dependencies: babel-runtime: 6.26.0 babel-template: 6.26.0 @@ -12240,26 +12243,26 @@ packages: dev: false /babel-plugin-transform-es2015-destructuring/6.23.0: - resolution: {integrity: sha1-mXux8auWf2gtKwh2/jWNYOdlxW0=} + resolution: {integrity: sha512-aNv/GDAW0j/f4Uy1OEPZn1mqD+Nfy9viFGBfQ5bZyT35YqOiqx7/tXdyfZkJ1sC21NyEsBdfDY6PYmLHF4r5iA==} dependencies: babel-runtime: 6.26.0 dev: false /babel-plugin-transform-es2015-duplicate-keys/6.24.1: - resolution: {integrity: sha1-c+s9MQypaePvnskcU3QabxV2Qj4=} + resolution: {integrity: sha512-ossocTuPOssfxO2h+Z3/Ea1Vo1wWx31Uqy9vIiJusOP4TbF7tPs9U0sJ9pX9OJPf4lXRGj5+6Gkl/HHKiAP5ug==} dependencies: babel-runtime: 6.26.0 babel-types: 6.26.0 dev: false /babel-plugin-transform-es2015-for-of/6.23.0: - resolution: {integrity: sha1-9HyVsrYT3x0+zC/bdXNiPHUkhpE=} + resolution: {integrity: sha512-DLuRwoygCoXx+YfxHLkVx5/NpeSbVwfoTeBykpJK7JhYWlL/O8hgAK/reforUnZDlxasOrVPPJVI/guE3dCwkw==} dependencies: babel-runtime: 6.26.0 dev: false /babel-plugin-transform-es2015-function-name/6.24.1: - resolution: {integrity: sha1-g0yJhTvDaxrw86TF26qU/Y6sqos=} + resolution: {integrity: sha512-iFp5KIcorf11iBqu/y/a7DK3MN5di3pNCzto61FqCNnUX4qeBwcV1SLqe10oXNnCaxBUImX3SckX2/o1nsrTcg==} dependencies: babel-helper-function-name: 6.24.1 babel-runtime: 6.26.0 @@ -12269,13 +12272,13 @@ packages: dev: false /babel-plugin-transform-es2015-literals/6.22.0: - resolution: {integrity: sha1-T1SgLWzWbPkVKAAZox0xklN3yi4=} + resolution: {integrity: sha512-tjFl0cwMPpDYyoqYA9li1/7mGFit39XiNX5DKC/uCNjBctMxyL1/PT/l4rSlbvBG1pOKI88STRdUsWXB3/Q9hQ==} dependencies: babel-runtime: 6.26.0 dev: false /babel-plugin-transform-es2015-modules-amd/6.24.1: - resolution: {integrity: sha1-Oz5UAXI5hC1tGcMBHEvS8AoA0VQ=} + resolution: {integrity: sha512-LnIIdGWIKdw7zwckqx+eGjcS8/cl8D74A3BpJbGjKTFFNJSMrjN4bIh22HY1AlkUbeLG6X6OZj56BDvWD+OeFA==} dependencies: babel-plugin-transform-es2015-modules-commonjs: 6.26.2 babel-runtime: 6.26.0 @@ -12296,7 +12299,7 @@ packages: dev: false /babel-plugin-transform-es2015-modules-systemjs/6.24.1: - resolution: {integrity: sha1-/4mhQrkRmpBhlfXxBuzzBdlAfSM=} + resolution: {integrity: sha512-ONFIPsq8y4bls5PPsAWYXH/21Hqv64TBxdje0FvU3MhIV6QM2j5YS7KvAzg/nTIVLot2D2fmFQrFWCbgHlFEjg==} dependencies: babel-helper-hoist-variables: 6.24.1 babel-runtime: 6.26.0 @@ -12306,7 +12309,7 @@ packages: dev: false /babel-plugin-transform-es2015-modules-umd/6.24.1: - resolution: {integrity: sha1-rJl+YoXNGO1hdq22B9YCNErThGg=} + resolution: {integrity: sha512-LpVbiT9CLsuAIp3IG0tfbVo81QIhn6pE8xBJ7XSeCtFlMltuar5VuBV6y6Q45tpui9QWcy5i0vLQfCfrnF7Kiw==} dependencies: babel-plugin-transform-es2015-modules-amd: 6.24.1 babel-runtime: 6.26.0 @@ -12316,7 +12319,7 @@ packages: dev: false /babel-plugin-transform-es2015-object-super/6.24.1: - resolution: {integrity: sha1-JM72muIcuDp/hgPa0CH1cusnj40=} + resolution: {integrity: sha512-8G5hpZMecb53vpD3mjs64NhI1au24TAmokQ4B+TBFBjN9cVoGoOvotdrMMRmHvVZUEvqGUPWL514woru1ChZMA==} dependencies: babel-helper-replace-supers: 6.24.1 babel-runtime: 6.26.0 @@ -12325,7 +12328,7 @@ packages: dev: false /babel-plugin-transform-es2015-parameters/6.24.1: - resolution: {integrity: sha1-V6w1GrScrxSpfNE7CfZv3wpiXys=} + resolution: {integrity: sha512-8HxlW+BB5HqniD+nLkQ4xSAVq3bR/pcYW9IigY+2y0dI+Y7INFeTbfAQr+63T3E4UDsZGjyb+l9txUnABWxlOQ==} dependencies: babel-helper-call-delegate: 6.24.1 babel-helper-get-function-arity: 6.24.1 @@ -12338,20 +12341,20 @@ packages: dev: false /babel-plugin-transform-es2015-shorthand-properties/6.24.1: - resolution: {integrity: sha1-JPh11nIch2YbvZmkYi5R8U3jiqA=} + resolution: {integrity: sha512-mDdocSfUVm1/7Jw/FIRNw9vPrBQNePy6wZJlR8HAUBLybNp1w/6lr6zZ2pjMShee65t/ybR5pT8ulkLzD1xwiw==} dependencies: babel-runtime: 6.26.0 babel-types: 6.26.0 dev: false /babel-plugin-transform-es2015-spread/6.22.0: - resolution: {integrity: sha1-1taKmfia7cRTbIGlQujdnxdG+NE=} + resolution: {integrity: sha512-3Ghhi26r4l3d0Js933E5+IhHwk0A1yiutj9gwvzmFbVV0sPMYk2lekhOufHBswX7NCoSeF4Xrl3sCIuSIa+zOg==} dependencies: babel-runtime: 6.26.0 dev: false /babel-plugin-transform-es2015-sticky-regex/6.24.1: - resolution: {integrity: sha1-AMHNsaynERLN8M9hJsLta0V8zbw=} + resolution: {integrity: sha512-CYP359ADryTo3pCsH0oxRo/0yn6UsEZLqYohHmvLQdfS9xkf+MbCzE3/Kolw9OYIY4ZMilH25z/5CbQbwDD+lQ==} dependencies: babel-helper-regex: 6.26.0 babel-runtime: 6.26.0 @@ -12359,19 +12362,19 @@ packages: dev: false /babel-plugin-transform-es2015-template-literals/6.22.0: - resolution: {integrity: sha1-qEs0UPfp+PH2g51taH2oS7EjbY0=} + resolution: {integrity: sha512-x8b9W0ngnKzDMHimVtTfn5ryimars1ByTqsfBDwAqLibmuuQY6pgBQi5z1ErIsUOWBdw1bW9FSz5RZUojM4apg==} dependencies: babel-runtime: 6.26.0 dev: false /babel-plugin-transform-es2015-typeof-symbol/6.23.0: - resolution: {integrity: sha1-3sCfHN3/lLUqxz1QXITfWdzOs3I=} + resolution: {integrity: sha512-fz6J2Sf4gYN6gWgRZaoFXmq93X+Li/8vf+fb0sGDVtdeWvxC9y5/bTD7bvfWMEq6zetGEHpWjtzRGSugt5kNqw==} dependencies: babel-runtime: 6.26.0 dev: false /babel-plugin-transform-es2015-unicode-regex/6.24.1: - resolution: {integrity: sha1-04sS9C6nMj9yk4fxinxa4frrNek=} + resolution: {integrity: sha512-v61Dbbihf5XxnYjtBN04B/JBvsScY37R1cZT5r9permN1cp+b70DY3Ib3fIkgn1DI9U3tGgBJZVD8p/mE/4JbQ==} dependencies: babel-helper-regex: 6.26.0 babel-runtime: 6.26.0 @@ -12379,7 +12382,7 @@ packages: dev: false /babel-plugin-transform-exponentiation-operator/6.24.1: - resolution: {integrity: sha1-KrDJx/MJj6SJB3cruBP+QejeOg4=} + resolution: {integrity: sha512-LzXDmbMkklvNhprr20//RStKVcT8Cu+SQtX18eMHLhjHf2yFzwtQ0S2f0jQ+89rokoNdmwoSqYzAhq86FxlLSQ==} dependencies: babel-helper-builder-binary-assignment-operator-visitor: 6.24.1 babel-plugin-syntax-exponentiation-operator: 6.13.0 @@ -12389,13 +12392,13 @@ packages: dev: false /babel-plugin-transform-regenerator/6.26.0: - resolution: {integrity: sha1-4HA2lvveJ/Cj78rPi03KL3s6jy8=} + resolution: {integrity: sha512-LS+dBkUGlNR15/5WHKe/8Neawx663qttS6AGqoOUhICc9d1KciBvtrQSuc0PI+CxQ2Q/S1aKuJ+u64GtLdcEZg==} dependencies: regenerator-transform: 0.10.1 dev: false /babel-plugin-transform-strict-mode/6.24.1: - resolution: {integrity: sha1-1fr3qleKZbvlkc9e2uBKDGcCB1g=} + resolution: {integrity: sha512-j3KtSpjyLSJxNoCDrhwiJad8kw0gJ9REGj8/CqL0HeRyLnvUNYV9zcqluL6QJSXh3nfsLEmSLvwRfGzrgR96Pw==} dependencies: babel-runtime: 6.26.0 babel-types: 6.26.0 @@ -12476,7 +12479,7 @@ packages: dev: true /babel-register/6.26.0: - resolution: {integrity: sha1-btAhFz4vy0htestFxgCahW9kcHE=} + resolution: {integrity: sha512-veliHlHX06wjaeY8xNITbveXSiI+ASFnOqvne/LaIJIqOWi2Ogmj91KOugEz/hoh/fwMhXNBJPCv8Xaz5CyM4A==} dependencies: babel-core: 6.26.3 babel-runtime: 6.26.0 @@ -12490,14 +12493,14 @@ packages: dev: false /babel-runtime/6.26.0: - resolution: {integrity: sha1-llxwWGaOgrVde/4E/yM3vItWR/4=} + resolution: {integrity: sha512-ITKNuq2wKlW1fJg9sSW52eepoYgZBggvOAHC0u/CYu/qxQ9EVzThCgR69BnSXLHjy2f7SY5zaQ4yt7H9ZVxY2g==} dependencies: core-js: 2.6.12 regenerator-runtime: 0.11.1 dev: false /babel-template/6.26.0: - resolution: {integrity: sha1-3gPi0WOWsGn0bdn/+FIfsaDjXgI=} + resolution: {integrity: sha512-PCOcLFW7/eazGUKIoqH97sO9A2UYMahsn/yRQ7uOk37iutwjq7ODtcTNF+iFDSHNfkctqsLRjLP7URnOx0T1fg==} dependencies: babel-runtime: 6.26.0 babel-traverse: 6.26.0 @@ -12509,7 +12512,7 @@ packages: dev: false /babel-traverse/6.26.0: - resolution: {integrity: sha1-RqnL1+3MYsjlwGTi0tjQ9ANXZu4=} + resolution: {integrity: sha512-iSxeXx7apsjCHe9c7n8VtRXGzI2Bk1rBSOJgCCjfyXb6v1aCqE1KSEpq/8SXuVN8Ka/Rh1WDTF0MDzkvTA4MIA==} dependencies: babel-code-frame: 6.26.0 babel-messages: 6.23.0 @@ -12525,7 +12528,7 @@ packages: dev: false /babel-types/6.26.0: - resolution: {integrity: sha1-o7Bz+Uq0nrb6Vc1lInozQ4BjJJc=} + resolution: {integrity: sha512-zhe3V/26rCWsEZK8kZN+HaQj5yQ1CilTObixFzKW1UWjqG7618Twz6YEsCnjfg5gBcJh02DrpCkS9h98ZqDY+g==} dependencies: babel-runtime: 6.26.0 esutils: 2.0.3 @@ -12534,7 +12537,7 @@ packages: dev: false /babelify/7.3.0: - resolution: {integrity: sha1-qlau3nBn/XvVSWZu4W3ChQh+iOU=} + resolution: {integrity: sha512-vID8Fz6pPN5pJMdlUnNFSfrlcx5MUule4k9aKs/zbZPyXxMTcRrB0M4Tarw22L8afr8eYSWxDPYCob3TdrqtlA==} dependencies: babel-core: 6.26.3 object-assign: 4.1.1 @@ -12698,7 +12701,7 @@ packages: file-uri-to-path: 1.0.0 /bintrees/1.0.2: - resolution: {integrity: sha1-SfiW1uhYpKSZ34XDj7OZua/4QPg=} + resolution: {integrity: sha512-VOMgTMwjAaUG580SXn3LacVgjurrbMme7ZZNYGSSV7mmtY6QQRh0Eg3pwIcntQ77DErK1L0NxkbetjcoXzVwKw==} dev: false /bip32/2.0.6: @@ -13039,8 +13042,8 @@ packages: resolution: {integrity: sha512-WHVocJYavUwVgVViC0ORikPHQquXwVh939TaelZ4WDqpWgTX/FsGhl/+P4qBUAGcRvtOgDgC+xftNWWp2RUTAQ==} hasBin: true dependencies: - caniuse-lite: 1.0.30001341 - electron-to-chromium: 1.4.137 + caniuse-lite: 1.0.30001359 + electron-to-chromium: 1.4.168 dev: false /browserslist/4.20.3: @@ -13181,7 +13184,7 @@ packages: node-gyp-build: 4.3.0 /builtin-modules/1.1.1: - resolution: {integrity: sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=} + resolution: {integrity: sha512-wxXCdllwGhI2kCC0MnvTGYTMvnVZTvqgypkiTI8Pa5tcz2i6VqsqwYGgqwXji+4RgCzms6EajE4IxiUH6HH8nQ==} engines: {node: '>=0.10.0'} dev: false @@ -13380,7 +13383,6 @@ packages: /caniuse-lite/1.0.30001359: resolution: {integrity: sha512-Xln/BAsPzEuiVLgJ2/45IaqD9jShtk3Y33anKb4+yLwQzws3+v6odKfpgES/cDEaZMLzSChpIGdbOYtH9MyuHw==} - dev: true /canonicalize/1.0.8: resolution: {integrity: sha512-0CNTVCLZggSh7bc5VkX5WWPWO+cyZbNd07IHIsSXLia/eAq+r836hgk+8BKoEh7949Mda87VUOitx5OddVj64A==} @@ -13477,7 +13479,7 @@ packages: dev: false /checkpoint-store/1.1.0: - resolution: {integrity: sha1-BOTLUWuRQziTWB5tRgGnjpVS6gY=} + resolution: {integrity: sha512-J/NdY2WvIx654cc6LWSq/IYFFCUf75fFTgwzFnmbqyORH4MwgiQCgswLLKBGzmsyTI5V7i5bp/So6sMbDWhedg==} dependencies: functional-red-black-tree: 1.0.1 dev: false @@ -14215,7 +14217,7 @@ packages: /core-js/2.6.12: resolution: {integrity: sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==} - deprecated: core-js@<3.4 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js. + deprecated: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js. dev: false /core-js/3.23.1: @@ -15201,7 +15203,7 @@ packages: isobject: 3.0.1 /defined/1.0.0: - resolution: {integrity: sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=} + resolution: {integrity: sha512-Y2caI5+ZwS5c3RiNDJ6u53VhQHv+hHKwhkI1iHvceKUHw9Df6EK2zRLfjejRgMuCuxK7PfSWIMwWecceVvThjQ==} dev: false /del/4.1.1: @@ -15272,7 +15274,7 @@ packages: dev: true /detect-indent/4.0.0: - resolution: {integrity: sha1-920GQ1LN9Docts5hnE7jqUdd4gg=} + resolution: {integrity: sha512-BDKtmHlOzwI7iRuEkhzsnPoi5ypEhWAJB5RvHWe1kMr06js3uK5B3734i3ui5Yd+wOJV1cpE4JnivPD283GU/A==} engines: {node: '>=0.10.0'} dependencies: repeating: 2.0.1 @@ -15424,7 +15426,7 @@ packages: dev: false /doctrine/0.7.2: - resolution: {integrity: sha1-fLhgNZujvpDgQLJrcpzkv6ZUxSM=} + resolution: {integrity: sha512-qiB/Rir6Un6Ad/TIgTRzsremsTGWzs8j7woXvp14jgq00676uBiBT5eUOi+FgRywZFVy5Us/c04ISRpZhRbS6w==} engines: {node: '>=0.10.0'} dependencies: esutils: 1.1.6 @@ -15625,7 +15627,6 @@ packages: /electron-to-chromium/1.4.168: resolution: {integrity: sha512-yz247hclRBaP8ABB1hf9kL7AMfa+yC2hB9F3XF8Y87VWMnYgq4QYvV6acRACcDkTDxfGQ4GYK/aZPQiuFMGbaA==} - dev: true /elliptic/6.5.4: resolution: {integrity: sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==} @@ -15653,7 +15654,7 @@ packages: optional: true /emailjs/2.2.0: - resolution: {integrity: sha1-ulsj5KSwpFEPZS6HOxVOlAe2ygM=} + resolution: {integrity: sha512-J9HNx13GA5DnJma10YxsSqYCErTyB0KoVflTddPTyKlEVHM0MckZXn/zDqovdacwWkHCxqC9AKVY8GMPaGvaGQ==} dependencies: addressparser: 0.3.2 emailjs-mime-codec: 2.0.9 @@ -15899,35 +15900,6 @@ packages: unbox-primitive: 1.0.1 dev: true - /es-abstract/1.20.0: - resolution: {integrity: sha512-URbD8tgRthKD3YcC39vbvSDrX23upXnPcnGAjQfgxXF5ID75YcENawc9ZX/9iTP9ptUyfCLIxTTuMYoRfiOVKA==} - engines: {node: '>= 0.4'} - dependencies: - call-bind: 1.0.2 - es-to-primitive: 1.2.1 - function-bind: 1.1.1 - function.prototype.name: 1.1.5 - get-intrinsic: 1.1.1 - get-symbol-description: 1.0.0 - has: 1.0.3 - has-property-descriptors: 1.0.0 - has-symbols: 1.0.3 - internal-slot: 1.0.3 - is-callable: 1.2.4 - is-negative-zero: 2.0.2 - is-regex: 1.1.4 - is-shared-array-buffer: 1.0.2 - is-string: 1.0.7 - is-weakref: 1.0.2 - object-inspect: 1.12.0 - object-keys: 1.1.1 - object.assign: 4.1.2 - regexp.prototype.flags: 1.4.3 - string.prototype.trimend: 1.0.5 - string.prototype.trimstart: 1.0.5 - unbox-primitive: 1.0.2 - dev: false - /es-abstract/1.20.1: resolution: {integrity: sha512-WEm2oBhfoI2sImeM4OF2zE2V3BYdSF+KnSi9Sidz51fQHd7+JuF8Xgcj9/0o+OWeIeIS/MiuNnlruQrJf16GQA==} engines: {node: '>= 0.4'} @@ -16401,7 +16373,7 @@ packages: resolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==} /esutils/1.1.6: - resolution: {integrity: sha1-wBzKqa5LiXxtDD4hCuUvPHqEQ3U=} + resolution: {integrity: sha512-RG1ZkUT7iFJG9LSHr7KDuuMSlujfeTtMNIcInURxKAxhMtwQhI3NrQhz26gZQYlsYZQKzsnwtpKrFKj9K9Qu1A==} engines: {node: '>=0.10.0'} dev: false @@ -16466,7 +16438,7 @@ packages: dev: false /eth-query/2.1.2: - resolution: {integrity: sha1-1nQdkAAQa1FRDHLbktY2VFam2l4=} + resolution: {integrity: sha512-srES0ZcvwkR/wd5OQBRA1bIJMww1skfGS0s8wlwK3/oNP4+wnds60krvu5R1QbpRQjMmpG5OMIWro5s7gvDPsA==} dependencies: json-rpc-random-id: 1.0.1 xtend: 4.0.2 @@ -16479,7 +16451,7 @@ packages: dev: false /eth-sig-util/1.4.2: - resolution: {integrity: sha1-jZWCAsftuq6Dlwf7pvCf8ydgYhA=} + resolution: {integrity: sha512-iNZ576iTOGcfllftB73cPB5AN+XUQAT/T8xzsILsghXC1o8gJUqe3RHlcDqagu+biFpYQ61KQrZZJza8eRSYqw==} deprecated: Deprecated in favor of '@metamask/eth-sig-util' dependencies: ethereumjs-abi: github.com/ethereumjs/ethereumjs-abi/ee3994657fa7a427238e6ba92a84d0b529bbcde0 @@ -16496,7 +16468,7 @@ packages: js-sha3: 0.8.0 /ethereum-common/0.0.18: - resolution: {integrity: sha1-L9w1dvIykDNYl26znaeDIT/5Uj8=} + resolution: {integrity: sha512-EoltVQTRNg2Uy4o84qpa2aXymXDJhxm7eos/ACOg0DG4baAbMjhbdAEsx9GeE8sC3XCxnYvrrzZDH8D8MtA2iQ==} dev: false /ethereum-common/0.2.0: @@ -17141,7 +17113,7 @@ packages: dev: false /fake-merkle-patricia-tree/1.0.1: - resolution: {integrity: sha1-S4w6z7Ugr635hgsfFM2M40As3dM=} + resolution: {integrity: sha512-Tgq37lkc9pUIgIKw5uitNUKcgcYL3R6JvXtKQbOf/ZSavXbidsksgp/pAY6p//uhw0I4yoMsvTSovvVIsk/qxA==} dependencies: checkpoint-store: 1.1.0 dev: false @@ -17294,7 +17266,7 @@ packages: dev: false /fetch-ponyfill/4.1.0: - resolution: {integrity: sha1-rjzl9zLGReq4fkroeTQUcJsjmJM=} + resolution: {integrity: sha512-knK9sGskIg2T7OnYLdZ2hZXn0CtDrAIBxYQLpmEf0BqfdWnwmM1weccUl5+4EdA44tzNSFAuxITPbXtPehUB3g==} dependencies: node-fetch: 1.7.3 dev: false @@ -17448,7 +17420,7 @@ packages: path-exists: 4.0.0 /find-versions/2.0.0: - resolution: {integrity: sha1-KtkNSQ9oKMGqQCks9wmsMxghDDw=} + resolution: {integrity: sha512-nzvoTkgyiTcXOT9PNHYWP2wlAoNbXanK/FnlHnB6v2yA1HoyDNTxN08+NobUIXL0qnBZPtegjXgohsQa8YiT+Q==} engines: {node: '>=0.10.0'} dependencies: array-uniq: 1.0.3 @@ -17757,7 +17729,7 @@ packages: dev: true /fs-extra/0.30.0: - resolution: {integrity: sha1-8jP/zAjU2n1DLapEl3aYnbHfk/A=} + resolution: {integrity: sha512-UvSPKyhMn6LEd/WpUaV9C9t3zATuqoqfWc3QdPhPLb58prN9tqYPlPWi8Krxi44loBoUzlobqZ3+8tGpxxSzwA==} dependencies: graceful-fs: 4.2.10 jsonfile: 2.4.0 @@ -17916,6 +17888,7 @@ packages: function-bind: 1.1.1 has: 1.0.3 has-symbols: 1.0.3 + dev: true /get-intrinsic/1.1.2: resolution: {integrity: sha512-Jfm3OyCxHh9DJyc28qGk+JmfkpO41A4XkneDSujN9MDXrm4oDKdHvndhZ2dN94+ERNfkYJWDclW6k2L/ZGHjXA==} @@ -18424,7 +18397,7 @@ packages: engines: {node: '>=6'} /has-ansi/2.0.0: - resolution: {integrity: sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=} + resolution: {integrity: sha512-C8vBJ8DwUCx19vhm7urhTuUsr4/IyP6l4VzNQDv+ryHQObW3TTTp9yB68WpYgRe2bbaGuZ/se74IqFeVnMnLZg==} engines: {node: '>=0.10.0'} dependencies: ansi-regex: 2.1.1 @@ -18647,7 +18620,7 @@ packages: dev: false /home-or-tmp/2.0.0: - resolution: {integrity: sha1-42w/LSyufXRqhX440Y1fMqeILbg=} + resolution: {integrity: sha512-ycURW7oUxE2sNiPVw1HVEFsW+ecOpJ5zaj7eC0RlwhibhRBod20muUN8qu/gzx956YrLolVvs1MTXwKgC2rVEg==} engines: {node: '>=0.10.0'} dependencies: os-homedir: 1.0.2 @@ -19477,7 +19450,7 @@ packages: engines: {node: '>=0.10.0'} /is-fn/1.0.0: - resolution: {integrity: sha1-lUPV3nvPWwiiLsiiC65uKG1RDYw=} + resolution: {integrity: sha512-XoFPJQmsAShb3jEQRfzf2rqXavq7fIqF/jOekp308JlThqrODnMpweVSGilKTCXELfLhltGP2AGgbQGVP8F1dg==} engines: {node: '>=0.10.0'} dev: false @@ -20554,7 +20527,7 @@ packages: dev: false /js-sha3/0.6.1: - resolution: {integrity: sha1-W4n3enR3Z5h39YxKB1JAk0sflcA=} + resolution: {integrity: sha512-2OHj7sAZ9gnJS4lQsgIsTslmqVrNQdDC99bvwYGQKU1w6k/gwsTLeGBfWt8yHCuTOGqk7DXzuVlK8J+dDXnG7A==} dev: false /js-sha3/0.7.0: @@ -20653,7 +20626,7 @@ packages: dev: false /json-rpc-error/2.0.0: - resolution: {integrity: sha1-p6+cICg4tekFxyUOVH8a/3cligI=} + resolution: {integrity: sha512-EwUeWP+KgAZ/xqFpaP6YDAXMtCJi+o/QQpCQFIYyxr01AdADi2y413eM8hSqJcoQym9WMePAJWoaODEJufC4Ug==} dependencies: inherits: 2.0.4 dev: false @@ -20730,7 +20703,7 @@ packages: hasBin: true /jsonfile/2.4.0: - resolution: {integrity: sha1-NzaitCi4e72gzIO1P6PWM6NcKug=} + resolution: {integrity: sha512-PKllAqbgLgxHaj8TElYymKCAgrASebJrWpTnEkOaTowt23VKXXN0sUeriJ+eh7y6ufb/CC5ap11pz71/cM0hUw==} optionalDependencies: graceful-fs: 4.2.10 dev: false @@ -20850,7 +20823,7 @@ packages: engines: {node: '>=0.10.0'} /klaw/1.3.1: - resolution: {integrity: sha1-QIhDO0azsbolnXh4XY6W9zugJDk=} + resolution: {integrity: sha512-TED5xi9gGQjGpNnvRWknrwAB1eL5GciPfVFOt3Vk1OJCVDQbzuSfrF3hkUQKlsgKrG1F+0t5W0m+Fje1jIt8rw==} optionalDependencies: graceful-fs: 4.2.10 dev: false @@ -20948,7 +20921,7 @@ packages: dev: false /level-iterator-stream/1.3.1: - resolution: {integrity: sha1-5Dt4sagUPm+pek9IXrjqUwNS8u0=} + resolution: {integrity: sha512-1qua0RHNtr4nrZBgYlpV0qHHeHpcRRWTxEZJ8xsemoHAXNL5tbooh4tPEEqIqsbWCAJBmUmkwYK/sW5OrFjWWw==} dependencies: inherits: 2.0.4 level-errors: 1.0.5 @@ -21158,7 +21131,7 @@ packages: dev: false /lodash.assign/4.2.0: - resolution: {integrity: sha1-DZnzzNem0mHRm9rrkkUAXShYCOc=} + resolution: {integrity: sha512-hFuH8TY+Yji7Eja3mGiuAxBqLagejScbG8GbG0j6o9vzn0YL14My+ktnqtZgFTosKymC9/44wP6s7xyuLfnClw==} dev: false /lodash.clonedeep/4.5.0: @@ -21195,7 +21168,7 @@ packages: dev: true /lodash.values/4.3.0: - resolution: {integrity: sha1-o6bCsOvsxcLLocF+bmIP6BtT00c=} + resolution: {integrity: sha512-r0RwvdCv8id9TUblb/O7rYPwVy6lerCbcawrfdo9iC/1t1wsNMJknO79WNBgwkH0hIeJ08jmvvESbFpNb4jH0Q==} dev: false /lodash/4.17.21: @@ -21304,7 +21277,7 @@ packages: dev: false /ltgt/2.2.1: - resolution: {integrity: sha1-81ypHEk/e3PaDgdJUwTxezH4fuU=} + resolution: {integrity: sha512-AI2r85+4MquTw9ZYqabu4nMwy9Oftlfa/e/52t9IjtfG+mGBbTNdAoZ3RQKLHR6r0wQnwZnPIEh/Ya6XTWAKNA==} dev: false /magic-string/0.25.9: @@ -21462,7 +21435,7 @@ packages: dev: true /memdown/1.4.1: - resolution: {integrity: sha1-tOThkhdGZP+65BNhqlAPMRnv4hU=} + resolution: {integrity: sha512-iVrGHZB8i4OQfM155xx8akvG9FIj+ht14DX5CQkCTG4EHzZ3d3sgckIf/Lm9ivZalEsFuEVnWv2B2WZvbrro2w==} dependencies: abstract-leveldown: 2.7.2 functional-red-black-tree: 1.0.1 @@ -21507,7 +21480,7 @@ packages: dev: true /memorystream/0.3.1: - resolution: {integrity: sha1-htcJCzDORV1j+64S3aUaR93K+bI=} + resolution: {integrity: sha512-S3UwM3yj5mtUSEfP41UZmt/0SCoVYUcU1rkXv+BQ5Ig8ndL4sPoJNBUJERafdPb5jjHJGuMgytgKvKIf58XNBw==} engines: {node: '>= 0.10.0'} dev: false @@ -22516,6 +22489,7 @@ packages: /object-inspect/1.12.0: resolution: {integrity: sha512-Ho2z80bVIvJloH+YzRmpZVQe87+qASmBUKZDWgx9cu+KDrX2ZDH/3tMy+gXbZETVGs2M8YdxObOh7XAtim9Y0g==} + dev: true /object-inspect/1.12.2: resolution: {integrity: sha512-z+cPxW0QGUp0mcqcsgQyLVRDoXFQbXOwBaqyF7VIgI4TWNQsDHrBpUQslRmIfAoYWdYzs6UlKJtB2XJpTaNSpQ==} @@ -23538,7 +23512,7 @@ packages: dev: true /promise-to-callback/1.0.0: - resolution: {integrity: sha1-XSp0kBC/tn2WNZj805YHRqaP7vc=} + resolution: {integrity: sha512-uhMIZmKM5ZteDMfLgJnoSq9GCwsNKrYau73Awf1jIy6/eUcuuZ3P+CD9zUv0kJsIUbU+x6uLNIhXhLHDs1pNPA==} engines: {node: '>=0.10.0'} dependencies: is-fn: 1.0.0 @@ -24575,7 +24549,7 @@ packages: dev: true /regexpu-core/2.0.0: - resolution: {integrity: sha1-SdA4g3uNz4v6W5pCE5k45uoq4kA=} + resolution: {integrity: sha512-tJ9+S4oKjxY8IZ9jmjnp/mtytu1u3iyIQAfmI51IKWH6bFf7XR1ybtaO6j7INhZKXOTYADk7V5qxaqLkmNxiZQ==} dependencies: regenerate: 1.4.2 regjsgen: 0.2.0 @@ -24595,7 +24569,7 @@ packages: dev: true /regjsgen/0.2.0: - resolution: {integrity: sha1-bAFq3qxVT3WCP+N6wFuS1aTtsfc=} + resolution: {integrity: sha512-x+Y3yA24uF68m5GA+tBjbGYo64xXVJpbToBaWCoSNSc1hdk6dfctaRWrNFTVJZIIhL5GxW8zwjoixbnifnK59g==} dev: false /regjsgen/0.6.0: @@ -24603,7 +24577,7 @@ packages: dev: true /regjsparser/0.1.5: - resolution: {integrity: sha1-fuj4Tcb6eS0/0K4ijSS9lJ6tIFw=} + resolution: {integrity: sha512-jlQ9gYLfk2p3V5Ag5fYhA7fv7OHzd1KUH0PRP46xc3TgwjwgROIW572AfYg/X9kaNq/LJnu6oJcFRXlIrGoTRw==} hasBin: true dependencies: jsesc: 0.5.0 @@ -24793,7 +24767,7 @@ packages: engines: {node: '>=0.10.0'} /require-from-string/1.2.1: - resolution: {integrity: sha1-UpyczvJzgK3+yaL5ZbZJu+5jZBg=} + resolution: {integrity: sha512-H7AkJWMobeskkttHyhTVtS0fxpFLjxhbfMa6Bk3wimP7sdPRGL3EyCg3sAQenFfAe+xQ+oAc85Nmtvq0ROM83Q==} engines: {node: '>=0.10.0'} dev: false @@ -24911,7 +24885,7 @@ packages: dev: true /resumer/0.0.0: - resolution: {integrity: sha1-8ej0YeQGS6Oegq883CqMiT0HZ1k=} + resolution: {integrity: sha512-Fn9X8rX8yYF4m81rZCK/5VmrmsSbqS/i3rDLl6ZZHAXgC2nTAx3dhwG8q8odP/RmdLa2YrybDJaAMg+X1ajY3w==} dependencies: through: 2.3.8 dev: false @@ -25281,7 +25255,7 @@ packages: dev: true /semver-regex/1.0.0: - resolution: {integrity: sha1-kqSWkGX5xwxpR1PVUkj8aPj2Usk=} + resolution: {integrity: sha512-1vZcoRC+LPtHFkLUPyrabsATDSHerxW+hJBN8h04HZOZBuewbXaNROtUVdEPrTdZsWNq6sfsXDhd48GB2xTG4g==} engines: {node: '>=0.10.0'} dev: false @@ -25477,7 +25451,7 @@ packages: dev: false /set-immediate-shim/1.0.1: - resolution: {integrity: sha1-SysbJ+uAip+NzEgaWOXlb1mfP2E=} + resolution: {integrity: sha512-Li5AOqrZWCVA2n5kryzEmqai6bKSIvpz5oUJHPVj6+dsbD3X1ixtsY5tEnsaNpH3pFAHmG8eIHUrtEtohrg+UQ==} engines: {node: '>=0.10.0'} dev: false @@ -25585,7 +25559,7 @@ packages: dev: true /slash/1.0.0: - resolution: {integrity: sha1-xB8vbDn8FtHNF61LXYlhFK5HDVU=} + resolution: {integrity: sha512-3TYDR7xWt4dIqV2JauJr+EJeW356RXijHeUlO+8djJ+uBXPn8/2dpzBc8yQhh583sVvc9CvFAeQVgijsH+PNNg==} engines: {node: '>=0.10.0'} dev: false @@ -26240,7 +26214,7 @@ packages: dependencies: call-bind: 1.0.2 define-properties: 1.1.4 - es-abstract: 1.20.0 + es-abstract: 1.20.1 dev: false /string.prototype.trimend/1.0.4: @@ -26566,7 +26540,7 @@ packages: inherits: 2.0.4 is-regex: 1.1.4 minimist: 1.2.6 - object-inspect: 1.12.0 + object-inspect: 1.12.2 resolve: 1.22.0 resumer: 0.0.0 string.prototype.trim: 1.2.6 @@ -26923,7 +26897,7 @@ packages: engines: {node: '>=4'} /to-no-case/1.0.2: - resolution: {integrity: sha1-xyKQcWTvaxeBMsjmmTAhLRtKoWo=} + resolution: {integrity: sha512-Z3g735FxuZY8rodxV4gH7LxClE4H0hTIyHNIHdk+vpQxjLm0cwnKXq/OFVZ76SOQmto7txVcwSCwkU5kqp+FKg==} dev: false /to-object-path/0.3.0: @@ -26960,13 +26934,13 @@ packages: safe-regex: 1.1.0 /to-snake-case/1.0.0: - resolution: {integrity: sha1-znRpE4l5RgGah+Yu366upMYIq4w=} + resolution: {integrity: sha512-joRpzBAk1Bhi2eGEYBjukEWHOe/IvclOkiJl3DtA91jV6NwQ3MwXA4FHYeqk8BNp/D8bmi9tcNbRu/SozP0jbQ==} dependencies: to-space-case: 1.0.0 dev: false /to-space-case/1.0.0: - resolution: {integrity: sha1-sFLar7Gysp3HcM6gFj5ewOvJ/Bc=} + resolution: {integrity: sha512-rLdvwXZ39VOn1IxGL3V6ZstoTbwLRckQmn/U8ZDLuWwIXNpuZDhQ3AiRUlhTbOXFVE9C+dR51wM0CBDhk31VcA==} dependencies: to-no-case: 1.0.2 dev: false @@ -27019,7 +26993,7 @@ packages: engines: {node: '>=8'} /trim-right/1.0.1: - resolution: {integrity: sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM=} + resolution: {integrity: sha512-WZGXGstmCWgeevgTL54hrCuw1dyMQIzWy7ZfqRJfSmJZBwklI15egmQytFP6bPidmw3M8d5yEowl1niq4vmqZw==} engines: {node: '>=0.10.0'} dev: false @@ -27306,7 +27280,7 @@ packages: resolution: {integrity: sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==} /tslint-eslint-rules/4.1.1_ew7ikuw7vzbxz2yx5mufkmltai: - resolution: {integrity: sha1-fDDniC8mvCdr/5HSOEl1xp2viLo=} + resolution: {integrity: sha512-QS9o6vNZ2XwWxW+DE5uXde1dhQ2ebNuvebjfF/P4b9uACPdzxQCkaHjNU5GO+0UqPuOmZNR7mwsBaSlWQfCgVg==} peerDependencies: tslint: ^5.0.0 dependencies: @@ -27362,9 +27336,9 @@ packages: dev: false /tsutils/1.9.1_typescript@2.9.2: - resolution: {integrity: sha1-ufmrROVa+WgYMdXyjQrur1x1DLA=} + resolution: {integrity: sha512-Z4MMpdLvxER0Wz+l9TM71URBKGoHKBzArEraOFmTp44jxzdqiG8oTCtpjiZ9YtFXNwWQfMv+g8VAxTlBEVS6yw==} peerDependencies: - typescript: '>=2.0.0 || >=2.0.0-dev || >=2.1.0-dev || >=2.2.0-dev || >=2.3.0-dev || >= 2.4.0-dev || 4' + typescript: '>=2.0.0 || >=2.0.0-dev || >=2.1.0-dev || >=2.2.0-dev || >=2.3.0-dev || >= 2.4.0-dev' peerDependenciesMeta: typescript: optional: true @@ -27375,7 +27349,7 @@ packages: /tsutils/2.29.0_typescript@2.9.2: resolution: {integrity: sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==} peerDependencies: - typescript: '>=2.1.0 || >=2.1.0-dev || >=2.2.0-dev || >=2.3.0-dev || >=2.4.0-dev || >=2.5.0-dev || >=2.6.0-dev || >=2.7.0-dev || >=2.8.0-dev || >=2.9.0-dev || >= 3.0.0-dev || >= 3.1.0-dev || 4' + typescript: '>=2.1.0 || >=2.1.0-dev || >=2.2.0-dev || >=2.3.0-dev || >=2.4.0-dev || >=2.5.0-dev || >=2.6.0-dev || >=2.7.0-dev || >=2.8.0-dev || >=2.9.0-dev || >= 3.0.0-dev || >= 3.1.0-dev' peerDependenciesMeta: typescript: optional: true @@ -27510,7 +27484,7 @@ packages: dev: false /typed-promisify/0.4.0: - resolution: {integrity: sha1-reHT0yEwdnuk71OFFixyBpgQXQ8=} + resolution: {integrity: sha512-Nhj1AwKD59L/vW+gqobaeyrxERI9p1FWCjGif1cPvZwYXOXkbyQehe7Rt92++a/WMw6BebxdplhZYaLkUH8NQQ==} dev: false /typedarray-to-buffer/3.1.5: @@ -27635,7 +27609,7 @@ packages: optional: true /uglify-to-browserify/1.0.2: - resolution: {integrity: sha1-bgkk1r2mta/jSeOabWMoUKD4grc=} + resolution: {integrity: sha512-vb2s1lYx2xBtUgy+ta+b2J/GLVUR+wmpINwHePmPRhOsIVCG2wDzKJ0n14GslH1BifsqVzSOwQhRaCAsZ/nI4Q==} dev: false optional: true @@ -28063,7 +28037,7 @@ packages: dev: true /uuid/3.0.1: - resolution: {integrity: sha1-ZUS7ot/ajBzxfmKaOjBeK7H+5sE=} + resolution: {integrity: sha512-tyhM7iisckwwmyHVFcjTzISz/R1ss/bRudNgHFYsgeu7j4JbhRvjE+Hbcpr9y5xh+b+HxeFjuToDT4i9kQNrtA==} deprecated: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details. hasBin: true dev: false @@ -28107,7 +28081,7 @@ packages: dev: true /valid-url/1.0.9: - resolution: {integrity: sha1-HBRHm0DxOXp1eC8RXkCGRHQzogA=} + resolution: {integrity: sha512-QQDsV8OnSf5Uc30CKSwG9lnhMPe6exHtTXLRYX8uMwKENy640pU+2BgBL0LRbDh/eYRahNCS7aewCx0wf3NYVA==} dev: false /validate-npm-package-license/3.0.4: @@ -29218,7 +29192,7 @@ packages: dev: false /window-size/0.2.0: - resolution: {integrity: sha1-tDFbtCFKPXBY6+7okuE/ok2YsHU=} + resolution: {integrity: sha512-UD7d8HFA2+PZsbKyaOCEy8gMh1oDtHgJh1LfgjQ4zVXmYjAT/kvz3PueITKuqDiIXQe7yzpPnxX3lNc+AhQMyw==} engines: {node: '>= 0.10.0'} hasBin: true dev: false @@ -29555,7 +29529,7 @@ packages: dev: false /yargs-parser/2.4.1: - resolution: {integrity: sha1-hVaN488VD/SfpRgl8DqMiA3cxcQ=} + resolution: {integrity: sha512-9pIKIJhnI5tonzG6OnCFlz/yln8xHYcGl+pn3xR0Vzff0vzN1PbNRaelgfgRUwZ3s4i3jvxT9WhmUGL4whnasA==} dependencies: camelcase: 3.0.0 lodash.assign: 4.2.0 @@ -29685,7 +29659,7 @@ packages: dev: false /yargs/4.8.1: - resolution: {integrity: sha1-wMQpJMpKqmsObaFznfshZDn53cA=} + resolution: {integrity: sha512-LqodLrnIDM3IFT+Hf/5sxBnEGECrfdC1uIbgZeJmESCSo4HoCAaKEus8MylXHAkdacGc0ye+Qa+dpkuom8uVYA==} dependencies: cliui: 3.2.0 decamelize: 1.2.0 @@ -29750,7 +29724,7 @@ packages: dev: false /yn/2.0.0: - resolution: {integrity: sha1-5a2ryKz0CPY4X8dklWhMiOavaJo=} + resolution: {integrity: sha512-uTv8J/wiWTgUTg+9vLTi//leUl5vDQS6uii/emeTb2ssY7vl6QWf2fFbIIGjnhjvbdKlU0ed7QPgY1htTC86jQ==} engines: {node: '>=4'} dev: false @@ -29815,7 +29789,7 @@ packages: '@0xproject/utils': 0.1.3 '@0xproject/web3-wrapper': 0.1.14 '@types/lodash': 4.14.182 - '@types/node': 17.0.34 + '@types/node': 17.0.45 0x.js: 0.29.2 awesome-typescript-loader: 3.5.0_typescript@2.9.2 bn.js: 4.12.0 From 2ca96669e59c8106f58f33dfe02e819104afce89 Mon Sep 17 00:00:00 2001 From: lelenei <72531217+lelenei@users.noreply.github.com> Date: Mon, 11 Jul 2022 21:39:54 +0800 Subject: [PATCH 065/179] fix: css style for retry button atnsnapshot (#6747) * fix: css style at snapshot * fix: margin size --- .../Snapshot/SNSAdaptor/LoadingFailCard.tsx | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/packages/mask/src/plugins/Snapshot/SNSAdaptor/LoadingFailCard.tsx b/packages/mask/src/plugins/Snapshot/SNSAdaptor/LoadingFailCard.tsx index 26b3473ea946..840ea0002b8c 100644 --- a/packages/mask/src/plugins/Snapshot/SNSAdaptor/LoadingFailCard.tsx +++ b/packages/mask/src/plugins/Snapshot/SNSAdaptor/LoadingFailCard.tsx @@ -36,15 +36,28 @@ export class LoadingFailCard extends Component< ) : ( - Loading fails due to Snapshot API service breakdown. - + + + Loading fails due to Snapshot API service breakdown. + + + ) } From d9552441297225bcf0e20c08a3a2c1ed2c2c4232 Mon Sep 17 00:00:00 2001 From: guanbinrui Date: Mon, 11 Jul 2022 21:56:14 +0800 Subject: [PATCH 066/179] fix: typo --- packages/shared/src/hooks/useImageBase64.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/shared/src/hooks/useImageBase64.ts b/packages/shared/src/hooks/useImageBase64.ts index 81867e1726a9..0a6935afc1b5 100644 --- a/packages/shared/src/hooks/useImageBase64.ts +++ b/packages/shared/src/hooks/useImageBase64.ts @@ -29,7 +29,7 @@ export function useAccessibleUrl( }, ) { const fetch = options?.fetch ?? globalThis.fetch - const [avaliableUrl, setAvaliableUrl] = useState(() => { + const [availableUrl, setAvailableUrl] = useState(() => { const hit = cache.get(key) return typeof hit === 'string' ? hit : '' }) @@ -38,10 +38,10 @@ export function useAccessibleUrl( if (!key) return const hit = cache.get(key) if (typeof hit === 'string') { - setAvaliableUrl(hit) + setAvailableUrl(hit) return } else if (hit instanceof Promise) { - setAvaliableUrl(await responseToBase64((await hit).clone())) + setAvailableUrl(await responseToBase64((await hit).clone())) return } @@ -57,8 +57,8 @@ export function useAccessibleUrl( const blob = await response.blob() const dataURL = await readAsDataURL(blob) cache.set(key, dataURL) - setAvaliableUrl(dataURL) + setAvailableUrl(dataURL) }, [key, url]) - return avaliableUrl + return availableUrl } From 5f2d90e5ca8465bc26bb165e54209c974143cce0 Mon Sep 17 00:00:00 2001 From: Randolph314 <97870249+Randolph314@users.noreply.github.com> Date: Tue, 12 Jul 2022 10:09:17 +0800 Subject: [PATCH 067/179] fix: copy audit (#6763) * fix: mf 1441 * feat: change linkIcon UI Co-authored-by: Randolph <840094513@qq.com> --- packages/dashboard/src/locales/en-US.json | 6 +++--- packages/mask/shared-ui/locales/en-US.json | 2 +- packages/mask/src/plugins/Avatar/locales/en-US.json | 2 +- .../src/SNSAdaptor/components/SecurityPanel.tsx | 4 +++- .../src/SNSAdaptor/components/TokenPanel.tsx | 8 ++++++-- .../UI/components/TokenSecurity/components/TokenPanel.tsx | 4 ++-- 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/packages/dashboard/src/locales/en-US.json b/packages/dashboard/src/locales/en-US.json index 057814034962..a9a0a674284b 100644 --- a/packages/dashboard/src/locales/en-US.json +++ b/packages/dashboard/src/locales/en-US.json @@ -33,7 +33,7 @@ "about_dialog_touch": "Get in touch", "about_dialog_description": "Mask Network is the portal to the new, open internet. Mask allows you to send encrypted posts on social networks. We provide more functions such as sending encrypted lucky drops, purchasing cryptocurrencies, file service, etc.", "setup_page_title": "Welcome to Mask Network", - "setup_page_description": "Encrypt your posts & chats on social networks, allow only your friends to decrypt.", + "setup_page_description": "Encrypt your posts on social medias, only your friends can decrypt it.", "setup_page_create_account_title": "Create an Identity", "setup_page_create_account_subtitle": "Create your digital identity system, explore Web 3.0", "setup_page_create_account_button": "Create", @@ -52,7 +52,7 @@ "create_account_connect_social_media_button": "Create", "create_account_connect_social_media": "Connect to {{type}}", "create_account_persona_title": "Welcome to Mask Network", - "create_account_persona_subtitle": "You can create personas and connect social accounts", + "create_account_persona_subtitle": "Connect to social media accounts with your personas.", "create_account_persona_successfully": "Persona created successfully.", "create_account_connect_social_media_title": "Connect Social Media", "create_account_failed": "Create Account Failed", @@ -197,7 +197,7 @@ "wallets_empty_history_tips": "No transaction history", "wallets_loading_token": "Loading Token", "personas_setup_connect_tips": "Please connect to your {{type}} account.", - "personas_setup_tip": "Please to create/restore persona.", + "personas_setup_tip": "Please create/restore persona.", "personas_setup_connect": "Connect", "personas_name_maximum_tips": "Maximum length is {{length}} characters long.", "personas_name_existed": "The persona name already exists", diff --git a/packages/mask/shared-ui/locales/en-US.json b/packages/mask/shared-ui/locales/en-US.json index 7fd4b4a393a2..3c8652e6d9a5 100644 --- a/packages/mask/shared-ui/locales/en-US.json +++ b/packages/mask/shared-ui/locales/en-US.json @@ -369,7 +369,7 @@ "plugin_wallet_cancel_sign": "Signature canceled.", "plugin_web3_profile_recommend_feature_description": "Choose and showcase your Web3 footprints on Twitter.", "plugin_nft_avatar_recommend_feature_description": "Set your NFT as profile picture with exclusive aura.", - "application_hint": "Socialize and show off your NFTs. People can bid,buy, view your valuable NFTs without leaving Twitter.", + "application_hint": "Socialize and show off your NFTs. People can bid, buy and view your valuable NFTs without leaving Twitter.", "plugin_goPlusSecurity_description": "Provide you with fast, reliable and convenient security services", "plugin_red_packet_create": "Create a Lucky Drop", "plugin_red_packet_claimed": "Claimed", diff --git a/packages/mask/src/plugins/Avatar/locales/en-US.json b/packages/mask/src/plugins/Avatar/locales/en-US.json index 52e185d34e2a..ea1a90515d65 100644 --- a/packages/mask/src/plugins/Avatar/locales/en-US.json +++ b/packages/mask/src/plugins/Avatar/locales/en-US.json @@ -22,7 +22,7 @@ "collectible_no_collectible": "No any collectible is available to preview.", "no_collectible_found": "No collectible found.", "retry": "Retry", - "application_hint": "Socialize and show off your NFTs. People can bid,buy, view your valuable NFTs without leaving Twitter.", + "application_hint": "Socialize and show off your NFTs. People can bid, buy and view your valuable NFTs without leaving Twitter.", "provider_by": "Provided by", "downloading_image": "Downloading image...", "saving": "Saving...", diff --git a/packages/plugins/GoPlusSecurity/src/SNSAdaptor/components/SecurityPanel.tsx b/packages/plugins/GoPlusSecurity/src/SNSAdaptor/components/SecurityPanel.tsx index 9b8f59753155..12a067f6c7d9 100644 --- a/packages/plugins/GoPlusSecurity/src/SNSAdaptor/components/SecurityPanel.tsx +++ b/packages/plugins/GoPlusSecurity/src/SNSAdaptor/components/SecurityPanel.tsx @@ -169,7 +169,9 @@ export const SecurityPanel = memo(({ tokenSecurity, tokenInfo, t href={resolveGoLabLink(tokenSecurity.chainId, tokenSecurity.contract)} target="_blank" rel="noopener noreferrer"> - + diff --git a/packages/plugins/GoPlusSecurity/src/SNSAdaptor/components/TokenPanel.tsx b/packages/plugins/GoPlusSecurity/src/SNSAdaptor/components/TokenPanel.tsx index 8d5dcaf51b40..b7c57869d857 100644 --- a/packages/plugins/GoPlusSecurity/src/SNSAdaptor/components/TokenPanel.tsx +++ b/packages/plugins/GoPlusSecurity/src/SNSAdaptor/components/TokenPanel.tsx @@ -89,7 +89,9 @@ export const TokenPanel = React.forwardRef(({ tokenSecurity, tokenMarketCap }: T href={explorerResolver.fungibleTokenLink(tokenSecurity.chainId, tokenSecurity.contract)} target="_blank" rel="noopener noreferrer"> - {' '} + @@ -110,7 +112,9 @@ export const TokenPanel = React.forwardRef(({ tokenSecurity, tokenMarketCap }: T )} target="_blank" rel="noopener noreferrer"> - + )} diff --git a/packages/shared/src/UI/components/TokenSecurity/components/TokenPanel.tsx b/packages/shared/src/UI/components/TokenSecurity/components/TokenPanel.tsx index 4e2cd24f5598..b9aef2cc6deb 100644 --- a/packages/shared/src/UI/components/TokenSecurity/components/TokenPanel.tsx +++ b/packages/shared/src/UI/components/TokenSecurity/components/TokenPanel.tsx @@ -33,8 +33,8 @@ const useStyles = makeStyles()((theme) => ({ }, linkIcon: { fill: theme.palette.maskColor.main, - width: 16, - height: 16, + width: 18, + height: 18, }, })) From 3f3c30dd54adaf8ecb121522f2fc12b2d81deb0d Mon Sep 17 00:00:00 2001 From: guanbinrui <52657989+guanbinrui@users.noreply.github.com> Date: Tue, 12 Jul 2022 10:09:36 +0800 Subject: [PATCH 068/179] fix: switch chain with fortmatic (#6762) --- packages/mask/src/web3/UI/ChainBoundary.tsx | 13 ++++---- .../SNSAdaptor/components/ConsoleContent.tsx | 4 +-- .../state/Connection/providers/Fortmatic.ts | 30 +++++++++++++++++-- 3 files changed, 35 insertions(+), 12 deletions(-) diff --git a/packages/mask/src/web3/UI/ChainBoundary.tsx b/packages/mask/src/web3/UI/ChainBoundary.tsx index 2b6ca3010826..9d1db522a87a 100644 --- a/packages/mask/src/web3/UI/ChainBoundary.tsx +++ b/packages/mask/src/web3/UI/ChainBoundary.tsx @@ -12,6 +12,7 @@ import { useWeb3State, useWeb3Connection, useChainIdValid, + useProviderDescriptor, } from '@masknet/plugin-infra/web3' import { ChainId, ProviderType } from '@masknet/web3-shared-evm' import { useRemoteControlledDialog } from '@masknet/shared-base-ui' @@ -83,6 +84,7 @@ export function ChainBoundary(props: ChainBoundaryPro const { Others: actualOthers } = useWeb3State(actualPluginID) const actualChainId = useChainId(actualPluginID) const actualProviderType = useProviderType(actualPluginID) + const actualProviderDescriptor = useProviderDescriptor(actualPluginID) const actualChainName = actualOthers?.chainResolver.chainName(actualChainId) const account = useAccount(actualPluginID) @@ -135,10 +137,9 @@ export function ChainBoundary(props: ChainBoundaryPro openSelectProviderDialog, ]) - const fortmaticDisabled = useMemo(() => { - if (actualProviderType !== ProviderType.Fortmatic) return false - return !(expectedChainId === ChainId.Mainnet || expectedChainId === ChainId.BSC) - }, [actualProviderType, expectedChainId]) + const switchButtonDisabled = useMemo(() => { + return !(actualProviderDescriptor.enableRequirements?.supportedChainIds?.includes(expectedChainId) ?? false) + }, [expectedChainId, actualProviderDescriptor]) const renderBox = (children?: React.ReactNode, tips?: string) => { return ( @@ -251,7 +252,7 @@ export function ChainBoundary(props: ChainBoundaryPro size={18} /> } - disabled={actualProviderType === ProviderType.WalletConnect || fortmaticDisabled} + disabled={actualProviderType === ProviderType.WalletConnect || switchButtonDisabled} sx={props.ActionButtonPromiseProps?.sx} init={{t('plugin_wallet_switch_network', { network: expectedChainName })}} waiting={t('plugin_wallet_switch_network_under_going', { @@ -268,7 +269,7 @@ export function ChainBoundary(props: ChainBoundaryPro , actualProviderType === ProviderType.WalletConnect ? t('plugin_wallet_connect_tips') - : fortmaticDisabled + : switchButtonDisabled ? t('plugin_wallet_not_support_network') : '', ) diff --git a/packages/plugins/Debugger/src/SNSAdaptor/components/ConsoleContent.tsx b/packages/plugins/Debugger/src/SNSAdaptor/components/ConsoleContent.tsx index fe36f6c370e7..c9e158ea9ec3 100644 --- a/packages/plugins/Debugger/src/SNSAdaptor/components/ConsoleContent.tsx +++ b/packages/plugins/Debugger/src/SNSAdaptor/components/ConsoleContent.tsx @@ -268,9 +268,7 @@ export function ConsoleContent(props: ConsoleContentProps) { switch (pluginID) { case NetworkPluginID.PLUGIN_EVM: await onSwitchChain( - chainId === EVM_ChainId.Mainnet - ? EVM_ChainId.Matic - : EVM_ChainId.Mainnet, + chainId === EVM_ChainId.Mainnet ? EVM_ChainId.BSC : EVM_ChainId.Mainnet, ) break default: diff --git a/packages/plugins/EVM/src/state/Connection/providers/Fortmatic.ts b/packages/plugins/EVM/src/state/Connection/providers/Fortmatic.ts index 5db1b1dc093e..868d5ba3d1c0 100644 --- a/packages/plugins/EVM/src/state/Connection/providers/Fortmatic.ts +++ b/packages/plugins/EVM/src/state/Connection/providers/Fortmatic.ts @@ -1,8 +1,9 @@ import Fortmatic from 'fortmatic' +import { toHex } from 'web3-utils' import type { RequestArguments } from 'web3-core' import { first } from 'lodash-unified' import type { FmProvider } from 'fortmatic/dist/cjs/src/core/fm-provider' -import { ChainId, chainResolver, getRPCConstants } from '@masknet/web3-shared-evm' +import { ChainId, chainResolver, getRPCConstants, ProviderType } from '@masknet/web3-shared-evm' import { createLookupTableResolver } from '@masknet/web3-shared-base' import type { EVM_Provider } from '../types' import { BaseProvider } from './Base' @@ -50,16 +51,28 @@ export default class FortmaticProvider extends BaseProvider implements EVM_Provi private get chainId(): ChainIdFortmatic { const chainId = this.chainId_ if (!chainId) throw new Error('No connection.') - if (!isFortmaticSupported(chainId)) throw new Error(`Chain id ${chainId} is not supported.`) + if (!isFortmaticSupported(chainId)) throw new Error(`The chain id ${chainId} is not supported.`) return chainId } private set chainId(newChainId: ChainId) { const chainId = newChainId - if (!isFortmaticSupported(chainId)) throw new Error(`Chain id ${chainId} is not supported.`) + if (!isFortmaticSupported(chainId)) throw new Error(`The chain id ${chainId} is not supported.`) this.chainId_ = chainId } + protected onAccountsChanged(accounts: string[]) { + this.emitter.emit('accounts', accounts) + } + + protected onChainChanged(chainId: string) { + this.emitter.emit('chainId', chainId) + } + + protected onDisconnect() { + this.emitter.emit('disconnect', ProviderType.Fortmatic) + } + private createFortmatic(chainId: ChainIdFortmatic) { const rpcUrl = first(getRPCConstants(chainId).RPC_URLS) if (!rpcUrl) throw new Error('Failed to create provider.') @@ -85,11 +98,21 @@ export default class FortmaticProvider extends BaseProvider implements EVM_Provi return fm.user.logout() } + override async switchChain(chainId?: ChainId): Promise { + if (chainId) { + await this.connect(chainId) + return + } + throw new Error(`Failed to switch to ${chainResolver.chainFullName(chainId)}.`) + } + override async connect(chainId: ChainId) { try { this.chainId = chainId const accounts = await this.login() if (!accounts.length) throw new Error(`Failed to connect to ${chainResolver.chainFullName(this.chainId)}.`) + this.onAccountsChanged(accounts) + this.onChainChanged(toHex(chainId)) return { account: first(accounts)!, chainId, @@ -103,6 +126,7 @@ export default class FortmaticProvider extends BaseProvider implements EVM_Provi override async disconnect() { await this.logout() this.chainId_ = null + this.onDisconnect() } override request(requestArguments: RequestArguments) { From 000ca1b283fa54d2ef2d0de2ce277afc127c18e3 Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Tue, 12 Jul 2022 13:43:18 +0800 Subject: [PATCH 069/179] fix: typo --- packages/dashboard/src/locales/en-US.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/dashboard/src/locales/en-US.json b/packages/dashboard/src/locales/en-US.json index a9a0a674284b..75a8d98817a0 100644 --- a/packages/dashboard/src/locales/en-US.json +++ b/packages/dashboard/src/locales/en-US.json @@ -33,7 +33,7 @@ "about_dialog_touch": "Get in touch", "about_dialog_description": "Mask Network is the portal to the new, open internet. Mask allows you to send encrypted posts on social networks. We provide more functions such as sending encrypted lucky drops, purchasing cryptocurrencies, file service, etc.", "setup_page_title": "Welcome to Mask Network", - "setup_page_description": "Encrypt your posts on social medias, only your friends can decrypt it.", + "setup_page_description": "Encrypt your posts on social media, only your friends can decrypt it.", "setup_page_create_account_title": "Create an Identity", "setup_page_create_account_subtitle": "Create your digital identity system, explore Web 3.0", "setup_page_create_account_button": "Create", From 8d1ca3b290c2a807fc7b41d3352803c4e4f8b1e2 Mon Sep 17 00:00:00 2001 From: BillyS Date: Tue, 12 Jul 2022 13:47:40 +0800 Subject: [PATCH 070/179] fix: some fix issues (#6764) * fix: some fix issues * fix: account when not evm --- .../CyberConnect/src/SNSAdaptor/ConnectButton.tsx | 10 ++++++++-- .../plugins/CyberConnect/src/SNSAdaptor/FollowTab.tsx | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/plugins/CyberConnect/src/SNSAdaptor/ConnectButton.tsx b/packages/plugins/CyberConnect/src/SNSAdaptor/ConnectButton.tsx index 545e4a667a55..1cc4b27e21e7 100644 --- a/packages/plugins/CyberConnect/src/SNSAdaptor/ConnectButton.tsx +++ b/packages/plugins/CyberConnect/src/SNSAdaptor/ConnectButton.tsx @@ -92,7 +92,7 @@ export default function ConnectButton({ }) { const { classes, cx } = useStyles() const web3 = useWeb3(NetworkPluginID.PLUGIN_EVM) - const myAddress = useAccount(NetworkPluginID.PLUGIN_EVM) + const myAddress = useAccount() const [cc, setCC] = useState(null) const [isFollowing, setFollowing] = useState(false) const [isLoading, setLoading] = useState(false) @@ -134,9 +134,15 @@ export default function ConnectButton({ } }, [cc, myAddress, isFollowing]) + if (!myAddress) + return ( + + Please connect your wallet first + + ) if (blockChainNetwork !== NetworkPluginID.PLUGIN_EVM) { return ( - + Please switch to EVM-based wallet to follow ) diff --git a/packages/plugins/CyberConnect/src/SNSAdaptor/FollowTab.tsx b/packages/plugins/CyberConnect/src/SNSAdaptor/FollowTab.tsx index ea74e6be060d..7fe5a1371463 100644 --- a/packages/plugins/CyberConnect/src/SNSAdaptor/FollowTab.tsx +++ b/packages/plugins/CyberConnect/src/SNSAdaptor/FollowTab.tsx @@ -89,6 +89,7 @@ export default function FollowTab({ sx={{ color: 'black', width: '100%', + boxSizing: 'border-box', }}> {followingList.map((f: IFollowIdentity) => { return @@ -100,6 +101,7 @@ export default function FollowTab({ sx={{ color: 'black', width: '100%', + boxSizing: 'border-box', }}> {followerList.map((f: IFollowIdentity) => { return From 2aff9a9621a4cec506c1430c9de88c00a7f3a099 Mon Sep 17 00:00:00 2001 From: BillyS Date: Tue, 12 Jul 2022 13:48:13 +0800 Subject: [PATCH 071/179] fix: fix history tab loading ui (#6765) --- .../src/plugins/Collectible/SNSAdaptor/HistoryTab/index.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/mask/src/plugins/Collectible/SNSAdaptor/HistoryTab/index.tsx b/packages/mask/src/plugins/Collectible/SNSAdaptor/HistoryTab/index.tsx index 3833fa7786fd..18e99a08d994 100644 --- a/packages/mask/src/plugins/Collectible/SNSAdaptor/HistoryTab/index.tsx +++ b/packages/mask/src/plugins/Collectible/SNSAdaptor/HistoryTab/index.tsx @@ -58,7 +58,8 @@ export function HistoryTab(props: HistoryTabProps) {
) - if (events.length) + + if (!asset.value || asset.error || !events.length) return ( From b1d876365f37345d08b20f41a701c2cfd3062816 Mon Sep 17 00:00:00 2001 From: BillyS Date: Tue, 12 Jul 2022 14:08:43 +0800 Subject: [PATCH 072/179] fix: 2.1.0 Savings issues (#6766) * fix: some Saving ui issues * fix: withdraw reject + code style * fix: eth to seth --- .../Savings/SNSAdaptor/SavingsForm.tsx | 63 ++++--------------- .../Savings/SNSAdaptor/SavingsTable.tsx | 39 +++++++++++- .../plugins/Savings/protocols/AAVEProtocol.ts | 3 +- .../components/PluginWalletStatusBar.tsx | 2 +- 4 files changed, 53 insertions(+), 54 deletions(-) diff --git a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsForm.tsx b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsForm.tsx index 1b5da7267f83..555c8abe7ed7 100644 --- a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsForm.tsx +++ b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsForm.tsx @@ -1,8 +1,7 @@ -import { useState, useCallback, useMemo } from 'react' +import { useState, useMemo } from 'react' import { useAsync, useAsyncFn } from 'react-use' import type { AbiItem } from 'web3-utils' import BigNumber from 'bignumber.js' -import { unreachable } from '@dimensiondev/kit' import { isLessThan, rightShift, @@ -38,7 +37,6 @@ import { PluginWalletStatusBar, useI18N } from '../../../utils' import { WalletConnectedBoundary } from '../../../web3/UI/WalletConnectedBoundary' import { ChainBoundary } from '../../../web3/UI/ChainBoundary' import { PluginTraderMessages } from '../../Trader/messages' -import type { Coin } from '../../Trader/types' import { ProtocolType, SavingsProtocol, TabType } from '../types' import { useStyles } from './SavingsFormStyles' import { EthereumERC20TokenApprovedBoundary } from '../../../web3/UI/EthereumERC20TokenApprovedBoundary' @@ -76,22 +74,6 @@ export function SavingsFormDialog({ chainId, protocol, tab, onClose }: SavingsFo const { setDialog: openSwapDialog } = useRemoteControlledDialog(PluginTraderMessages.swapDialogUpdated) - const onConvertClick = useCallback(() => { - const token = protocol.stakeToken - openSwapDialog({ - open: true, - traderProps: { - defaultInputCoin: { - id: token.address, - name: token.name ?? '', - symbol: token.symbol ?? '', - contract_address: token.address, - decimals: token.decimals, - } as Coin, - }, - }) - }, [protocol, openSwapDialog]) - // #region form variables const { value: inputTokenBalance } = useFungibleTokenBalance( NetworkPluginID.PLUGIN_EVM, @@ -182,38 +164,19 @@ export function SavingsFormDialog({ chainId, protocol, tab, onClose }: SavingsFo }) const [, executor] = useAsyncFn(async () => { if (!web3) return - switch (tab) { - case TabType.Deposit: - const hash = await protocol.deposit(account, chainId, web3, tokenAmount) - if (typeof hash !== 'string') { - throw new Error('Failed to deposit token.') - } else { - await protocol.updateBalance(chainId, web3, account) - } - openShareTxDialog({ - hash, - onShare() { - activatedSocialNetworkUI.utils.share?.(shareText) - }, - }) - break - case TabType.Withdraw: - switch (protocol.type) { - case ProtocolType.Lido: - onClose?.() - onConvertClick() - return - default: - if (!(await protocol.withdraw(account, chainId, web3, tokenAmount))) { - throw new Error('Failed to withdraw token.') - } else { - await protocol.updateBalance(chainId, web3, account) - } - return - } - default: - unreachable(tab) + const methodName = tab === TabType.Deposit ? 'deposit' : 'withdraw' + const hash = await protocol[methodName](account, chainId, web3, tokenAmount) + if (typeof hash !== 'string') { + throw new Error('Failed to deposit token.') + } else { + await protocol.updateBalance(chainId, web3, account) } + openShareTxDialog({ + hash, + onShare() { + activatedSocialNetworkUI.utils.share?.(shareText) + }, + }) }, [tab, protocol, account, chainId, web3, tokenAmount, openShareTxDialog]) const buttonDom = useMemo(() => { diff --git a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsTable.tsx b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsTable.tsx index f94dbd776e62..bb8e112ae82f 100644 --- a/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsTable.tsx +++ b/packages/mask/src/plugins/Savings/SNSAdaptor/SavingsTable.tsx @@ -7,8 +7,13 @@ import { isZero, rightShift, formatBalance, isSameAddress, NetworkPluginID } fro import type { ChainId, Web3 } from '@masknet/web3-shared-evm' import { ProviderIconURLs } from './IconURL' import { useI18N } from '../../../utils' -import { SavingsProtocol, TabType } from '../types' +import { ProtocolType, SavingsProtocol, TabType } from '../types' import { useAccount, useWeb3, useFungibleAssets } from '@masknet/plugin-infra/web3' +import { useRemoteControlledDialog } from '@masknet/shared-base-ui' +import { useCallback } from 'react' +import { PluginTraderMessages } from '../../Trader/messages' +import { LDO_PAIRS } from '../constants' +import { TrendingCoinType } from '@masknet/web3-providers' const useStyles = makeStyles()((theme, props) => ({ containerWrap: { @@ -105,7 +110,7 @@ export function SavingsTable({ chainId, tab, protocols, setTab, setSelectedProto const account = useAccount(NetworkPluginID.PLUGIN_EVM) const { value: assets, loading: getAssetsLoading } = useFungibleAssets(NetworkPluginID.PLUGIN_EVM) - + const { setDialog: openSwapDialog } = useRemoteControlledDialog(PluginTraderMessages.swapDialogUpdated) // Only fetch protocol APR and Balance on chainId change const { loading } = useAsync(async () => { await Promise.all( @@ -115,6 +120,32 @@ export function SavingsTable({ chainId, tab, protocols, setTab, setSelectedProto }), ) }, [chainId, web3, account, protocols]) + + const onConvertClick = useCallback(() => { + const ETH = LDO_PAIRS[0][0] + const sETH = LDO_PAIRS[0][1] + openSwapDialog({ + open: true, + traderProps: { + defaultInputCoin: { + id: sETH.address, + name: sETH.name ?? '', + symbol: sETH.symbol ?? '', + contract_address: sETH.address, + decimals: sETH.decimals, + type: TrendingCoinType.Fungible, + }, + defaultOutputCoin: { + id: ETH.address, + name: ETH.name ?? '', + symbol: ETH.symbol ?? '', + contract_address: ETH.address, + decimals: ETH.decimals, + type: TrendingCoinType.Fungible, + }, + }, + }) + }, [openSwapDialog]) return ( @@ -188,6 +219,10 @@ export function SavingsTable({ chainId, tab, protocols, setTab, setSelectedProto color="primary" disabled={tab === TabType.Withdraw ? isZero(protocol.balance) : false} onClick={() => { + if (tab === TabType.Withdraw && protocol.type === ProtocolType.Lido) { + onConvertClick() + return + } setTab(tab) setSelectedProtocol(protocol) }}> diff --git a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts index 4c1ddaf1e699..9d55bb937ef0 100644 --- a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts +++ b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts @@ -239,13 +239,14 @@ export class AAVEProtocol implements SavingsProtocol { poolAddress || ZERO_ADDRESS, AaveLendingPoolABI as AbiItem[], ) - return new Promise((resolve) => + return new Promise((resolve, reject) => contract?.methods .withdraw(this.bareToken.address, new BigNumber(value).toFixed(), account) .send({ from: account, gas: gasEstimate.toNumber(), }) + .once(TransactionEventType.ERROR, reject) .once(TransactionEventType.CONFIRMATION, (_, receipt) => { resolve(receipt.transactionHash) }), diff --git a/packages/mask/src/utils/components/PluginWalletStatusBar.tsx b/packages/mask/src/utils/components/PluginWalletStatusBar.tsx index ba08a4d784c3..69a4eb73975c 100644 --- a/packages/mask/src/utils/components/PluginWalletStatusBar.tsx +++ b/packages/mask/src/utils/components/PluginWalletStatusBar.tsx @@ -44,7 +44,7 @@ const useStyles = makeStyles()((theme) => ({ backgroundColor: isDashboard ? MaskColorVar.mainBackground : parseColor(theme.palette.maskColor.bottom).setAlpha(0.8).toRgbString(), - boxShadow: `0 0 20px ${parseColor(theme.palette.maskColor.highlight).setAlpha(0.05).toRgbString()}`, + boxShadow: `0 0 20px ${parseColor(theme.palette.maskColor.highlight).setAlpha(0.2).toRgbString()}`, backdropFilter: 'blur(16px)', padding: theme.spacing(2), borderRadius: '0 0 12px 12px', From a790da92095e08a02cf55c37c89322a0bcb86a00 Mon Sep 17 00:00:00 2001 From: nuanyang233 Date: Tue, 12 Jul 2022 14:09:01 +0800 Subject: [PATCH 073/179] fix: bugfix for token icon --- .../mask/src/web3/UI/EthereumERC20TokenApprovedBoundary.tsx | 1 + .../src/web3/EVM/useERC20TokenApproveCallback.ts | 2 +- packages/shared/src/UI/components/TokenIcon/index.tsx | 5 ++++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/mask/src/web3/UI/EthereumERC20TokenApprovedBoundary.tsx b/packages/mask/src/web3/UI/EthereumERC20TokenApprovedBoundary.tsx index 5e33d87e5156..e146566acc85 100644 --- a/packages/mask/src/web3/UI/EthereumERC20TokenApprovedBoundary.tsx +++ b/packages/mask/src/web3/UI/EthereumERC20TokenApprovedBoundary.tsx @@ -117,6 +117,7 @@ export function EthereumERC20TokenApprovedBoundary(props: EthereumERC20TokenAppr address={token.address} chainId={token.chainId} name={token.name} + disableDefaultIcon classes={{ icon: classes.icon }} /> } diff --git a/packages/plugin-infra/src/web3/EVM/useERC20TokenApproveCallback.ts b/packages/plugin-infra/src/web3/EVM/useERC20TokenApproveCallback.ts index c55e74a3b219..e3c5c44fb269 100644 --- a/packages/plugin-infra/src/web3/EVM/useERC20TokenApproveCallback.ts +++ b/packages/plugin-infra/src/web3/EVM/useERC20TokenApproveCallback.ts @@ -48,7 +48,7 @@ export function useERC20TokenApproveCallback( // the computed approve state const approveStateType = useMemo(() => { - if (!amount || !spender) return ApproveStateType.UNKNOWN + if (isZero(amount) || !spender) return ApproveStateType.UNKNOWN if (loadingBalance || loadingAllowance) return ApproveStateType.UPDATING if (errorBalance || errorAllowance) return ApproveStateType.FAILED return isLessThan(allowance, amount) || (allowance === amount && isZero(amount)) diff --git a/packages/shared/src/UI/components/TokenIcon/index.tsx b/packages/shared/src/UI/components/TokenIcon/index.tsx index de06e60dd17e..7d0dc7fde8e9 100644 --- a/packages/shared/src/UI/components/TokenIcon/index.tsx +++ b/packages/shared/src/UI/components/TokenIcon/index.tsx @@ -22,11 +22,12 @@ export interface TokenIconProps extends withClasses<'icon'> { name?: string logoURL?: string isERC721?: boolean + disableDefaultIcon?: boolean AvatarProps?: Partial } export function TokenIcon(props: TokenIconProps) { - const { address, logoURL, name, AvatarProps, classes, isERC721 } = props + const { address, logoURL, name, AvatarProps, classes, isERC721, disableDefaultIcon } = props const chainId = useChainId(props.pluginID, props.chainId) const hub = useWeb3Hub(props.pluginID) @@ -41,6 +42,8 @@ export function TokenIcon(props: TokenIconProps) { const { urls = EMPTY_LIST, key } = value ?? {} const accessibleUrl = useAccessibleUrl(key, first(urls)) + if (!accessibleUrl && disableDefaultIcon) return null + return ( Date: Tue, 12 Jul 2022 14:17:46 +0800 Subject: [PATCH 074/179] fix: eslint --- packages/mask/src/web3/UI/ChainBoundary.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mask/src/web3/UI/ChainBoundary.tsx b/packages/mask/src/web3/UI/ChainBoundary.tsx index 9d1db522a87a..18ce218c767a 100644 --- a/packages/mask/src/web3/UI/ChainBoundary.tsx +++ b/packages/mask/src/web3/UI/ChainBoundary.tsx @@ -14,7 +14,7 @@ import { useChainIdValid, useProviderDescriptor, } from '@masknet/plugin-infra/web3' -import { ChainId, ProviderType } from '@masknet/web3-shared-evm' +import { ProviderType } from '@masknet/web3-shared-evm' import { useRemoteControlledDialog } from '@masknet/shared-base-ui' import { delay } from '@dimensiondev/kit' import ActionButton, { From 445a4de4199516bdce09de31fa0e259d44573ad5 Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Tue, 12 Jul 2022 14:34:08 +0800 Subject: [PATCH 075/179] feat: change cpoywriting of welcome page --- packages/dashboard/src/locales/en-US.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/dashboard/src/locales/en-US.json b/packages/dashboard/src/locales/en-US.json index 75a8d98817a0..c8da88af397d 100644 --- a/packages/dashboard/src/locales/en-US.json +++ b/packages/dashboard/src/locales/en-US.json @@ -33,7 +33,7 @@ "about_dialog_touch": "Get in touch", "about_dialog_description": "Mask Network is the portal to the new, open internet. Mask allows you to send encrypted posts on social networks. We provide more functions such as sending encrypted lucky drops, purchasing cryptocurrencies, file service, etc.", "setup_page_title": "Welcome to Mask Network", - "setup_page_description": "Encrypt your posts on social media, only your friends can decrypt it.", + "setup_page_description": "Encrypt your posts on social media and only your friends on Mask can decrypt them.", "setup_page_create_account_title": "Create an Identity", "setup_page_create_account_subtitle": "Create your digital identity system, explore Web 3.0", "setup_page_create_account_button": "Create", From 1e93c33c6dc5acb6c8f8b859ff09e36b81b18b50 Mon Sep 17 00:00:00 2001 From: Hancheng Zhou Date: Tue, 12 Jul 2022 13:12:09 +0800 Subject: [PATCH 076/179] feat(lucky drop): pre gas minus (#6467) * feat(lucky drop): pre gas minus * chore: reply code review * chore: solve error * fix: solve conflict * chore: format balance * chore: apply confition apply only sum of gas and total greater than balance * chore: increase estimate gas * chore: format significant * chore: reply code review * chore: format significant * chore: i18n * chore: reply code review * chore: use big number * chore: add useTransactionValue hook --- .../RedPacket/SNSAdaptor/RedPacket/index.tsx | 6 +- .../SNSAdaptor/RedPacketConfirmDialog.tsx | 88 ++++++++++++++----- .../SNSAdaptor/hooks/useCreateCallback.tsx | 17 +++- .../plugins/RedPacket/SNSAdaptor/index.tsx | 24 ++++- .../src/plugins/RedPacket/locales/en-US.json | 3 + packages/plugin-infra/src/web3/EVM/index.ts | 1 + .../src/web3/EVM/useTransactionValue.ts | 27 ++++++ .../descriptors/RedPacket.ts | 7 +- 8 files changed, 140 insertions(+), 33 deletions(-) create mode 100644 packages/plugin-infra/src/web3/EVM/useTransactionValue.ts diff --git a/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacket/index.tsx b/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacket/index.tsx index a5506723eb41..9dd91b337411 100644 --- a/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacket/index.tsx +++ b/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacket/index.tsx @@ -109,7 +109,7 @@ export function RedPacket(props: RedPacketProps) { return t.description_claimed( availability.claimed_amount ? { - amount: formatBalance(availability.claimed_amount, token.decimals, 8), + amount: formatBalance(availability.claimed_amount, token.decimals, 2), symbol: token.symbol, } : { amount: '-', symbol: '-' }, @@ -122,7 +122,7 @@ export function RedPacket(props: RedPacketProps) { if (listOfStatus.includes(RedPacketStatus.expired) && canRefund) return t.description_refund({ - balance: formatBalance(availability.balance, token.decimals), + balance: formatBalance(availability.balance, token.decimals, 2), symbol: token.symbol ?? '-', }) if (listOfStatus.includes(RedPacketStatus.refunded)) return t.description_refunded() @@ -130,7 +130,7 @@ export function RedPacket(props: RedPacketProps) { if (listOfStatus.includes(RedPacketStatus.empty)) return t.description_empty() if (!payload.password) return t.description_broken() return t.description_failover({ - total: formatBalance(payload.total, token.decimals), + total: formatBalance(payload.total, token.decimals, 2), symbol: token.symbol ?? '-', shares: payload.shares.toString() ?? '-', }) diff --git a/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacketConfirmDialog.tsx b/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacketConfirmDialog.tsx index 646a83313ea8..b0bfe5d634e1 100644 --- a/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacketConfirmDialog.tsx +++ b/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacketConfirmDialog.tsx @@ -1,19 +1,28 @@ import BigNumber from 'bignumber.js' import classNames from 'classnames' import { useCallback, useEffect, useMemo, useRef } from 'react' +import { + useAccount, + useChainId, + useBalance, + useNetworkType, + useWeb3, + useNativeToken, + useNativeTokenAddress, +} from '@masknet/plugin-infra/web3' import { chainResolver, explorerResolver, isNativeTokenAddress, useRedPacketConstants } from '@masknet/web3-shared-evm' import { Grid, Link, Paper, Typography } from '@mui/material' import { makeStyles } from '@masknet/theme' import LaunchIcon from '@mui/icons-material/Launch' import { FormattedBalance, useOpenShareTxDialog } from '@masknet/shared' +import ActionButton from '../../../extension/options-page/DashboardComponents/ActionButton' import { useI18N } from '../locales' -import { RedPacketSettings, useCreateCallback } from './hooks/useCreateCallback' -import { useAccount, useChainId, useNetworkType, useWeb3 } from '@masknet/plugin-infra/web3' -import { NetworkPluginID, formatBalance } from '@masknet/web3-shared-base' +import { RedPacketSettings, useCreateCallback, useCreateParams } from './hooks/useCreateCallback' +import { useTransactionValue } from '@masknet/plugin-infra/web3-evm' +import { NetworkPluginID, formatBalance, isSameAddress } from '@masknet/web3-shared-base' import type { RedPacketJSONPayload, RedPacketRecord } from '../types' import { RedPacketRPC } from '../messages' import { PluginWalletStatusBar } from '../../../utils' -import ActionButton from '../../../extension/options-page/DashboardComponents/ActionButton' import { ChainBoundary } from '../../../web3/UI/ChainBoundary' const useStyles = makeStyles()((theme) => ({ @@ -81,6 +90,7 @@ export function RedPacketConfirmDialog(props: ConfirmRedPacketFormProps) { const t = useI18N() const { onBack, settings, onCreated, onClose } = props const { classes } = useStyles() + const { value: balance = '0', loading: loadingBalance } = useBalance(NetworkPluginID.PLUGIN_EVM) const chainId = useChainId(NetworkPluginID.PLUGIN_EVM) useEffect(() => { if (settings?.token?.chainId !== chainId) onClose() @@ -93,11 +103,27 @@ export function RedPacketConfirmDialog(props: ConfirmRedPacketFormProps) { const web3 = useWeb3(NetworkPluginID.PLUGIN_EVM) const account = useAccount(NetworkPluginID.PLUGIN_EVM) const networkType = useNetworkType(NetworkPluginID.PLUGIN_EVM) + const nativeTokenAddress = useNativeTokenAddress(NetworkPluginID.PLUGIN_EVM) const { address: publicKey, privateKey } = useMemo( () => web3?.eth.accounts.create() ?? { address: '', privateKey: '' }, [web3], )! - const [{ loading: isCreating }, createCallback] = useCreateCallback(settings!, contract_version, publicKey) + const { value: nativeToken } = useNativeToken(NetworkPluginID.PLUGIN_EVM) + + // #region amount minus estimate gas fee + const { value: createParams } = useCreateParams(settings!, contract_version, publicKey) + const isNativeToken = isSameAddress(settings?.token?.address, nativeTokenAddress) + const { transactionValue, estimateGasFee } = useTransactionValue(settings?.total, createParams?.gas) + const isWaitGasBeMinus = (!estimateGasFee || loadingBalance) && isNativeToken + const isBalanceInsufficient = new BigNumber(transactionValue).isLessThanOrEqualTo(0) + const total = isNativeToken ? (isBalanceInsufficient ? '0' : transactionValue) : (settings?.total as string) + const formatTotal = formatBalance(total, settings?.token?.decimals ?? 18, isNativeToken ? 3 : 0) + const [{ loading: isCreating }, createCallback] = useCreateCallback( + { ...settings!, total }, + contract_version, + publicKey, + ) + // #endregion const openShareTxDialog = useOpenShareTxDialog() const createRedpacket = useCallback(async () => { const result = await createCallback() @@ -220,26 +246,45 @@ export function RedPacketConfirmDialog(props: ConfirmRedPacketFormProps) { - {settings?.isRandom ? null : ( + {!estimateGasFee ? null : ( <> - {t.amount_per_share()} + {t.estimate_gas_fee()} )} + {settings?.isRandom ? null : ( + <> + + + {t.amount_per_share()} + + + + + {isBalanceInsufficient + ? '0' + : new BigNumber(formatTotal).div(settings?.shares ?? 1).toFixed(6)}{' '} + {settings?.token?.symbol} + + + + )} + {t.total_amount()} @@ -247,12 +292,7 @@ export function RedPacketConfirmDialog(props: ConfirmRedPacketFormProps) { - + {formatTotal} {settings?.token?.symbol} @@ -265,11 +305,17 @@ export function RedPacketConfirmDialog(props: ConfirmRedPacketFormProps) { - - {t.send_symbol({ - amount: formatBalance(settings?.total, settings?.token?.decimals ?? 0), - symbol: settings?.token?.symbol ?? '-', - })} + + {!isBalanceInsufficient + ? t.send_symbol({ + amount: formatTotal, + symbol: settings?.token?.symbol ?? '-', + }) + : t.insufficient_balance()} diff --git a/packages/mask/src/plugins/RedPacket/SNSAdaptor/hooks/useCreateCallback.tsx b/packages/mask/src/plugins/RedPacket/SNSAdaptor/hooks/useCreateCallback.tsx index dd57a2476f68..9fef50607064 100644 --- a/packages/mask/src/plugins/RedPacket/SNSAdaptor/hooks/useCreateCallback.tsx +++ b/packages/mask/src/plugins/RedPacket/SNSAdaptor/hooks/useCreateCallback.tsx @@ -1,5 +1,5 @@ import { useCallback } from 'react' -import { useAsyncFn } from 'react-use' +import { useAsync, useAsyncFn } from 'react-use' import Web3Utils from 'web3-utils' import { omit } from 'lodash-unified' import { useAccount, useChainId, useWeb3Connection, useWeb3 } from '@masknet/plugin-infra/web3' @@ -58,7 +58,11 @@ interface CreateParams { gasError: Error | null } -export function useCreateParams(redPacketSettings: RedPacketSettings | undefined, version: number, publicKey: string) { +export function useCreateParamsCallback( + redPacketSettings: RedPacketSettings | undefined, + version: number, + publicKey: string, +) { const account = useAccount(NetworkPluginID.PLUGIN_EVM) const chainId = useChainId(NetworkPluginID.PLUGIN_EVM) const { NATIVE_TOKEN_ADDRESS } = useTokenConstants(chainId) @@ -111,11 +115,16 @@ export function useCreateParams(redPacketSettings: RedPacketSettings | undefined return getCreateParams } +export function useCreateParams(redPacketSettings: RedPacketSettings, version: number, publicKey: string) { + const getCreateParams = useCreateParamsCallback(redPacketSettings, version, publicKey) + return useAsync(() => getCreateParams(), [redPacketSettings, version, publicKey]) +} + export function useCreateCallback(redPacketSettings: RedPacketSettings, version: number, publicKey: string) { const account = useAccount(NetworkPluginID.PLUGIN_EVM) const chainId = useChainId(NetworkPluginID.PLUGIN_EVM) const redPacketContract = useRedPacketContract(chainId, version) - const getCreateParams = useCreateParams(redPacketSettings, version, publicKey) + const getCreateParams = useCreateParamsCallback(redPacketSettings, version, publicKey) const connection = useWeb3Connection(NetworkPluginID.PLUGIN_EVM) const web3 = useWeb3(NetworkPluginID.PLUGIN_EVM) @@ -162,5 +171,5 @@ export function useCreateCallback(redPacketSettings: RedPacketSettings, version: } } return { hash, receipt } - }, [account, connection, redPacketContract, redPacketSettings, chainId, getCreateParams]) + }, [account, connection, redPacketContract, redPacketSettings, chainId]) } diff --git a/packages/mask/src/plugins/RedPacket/SNSAdaptor/index.tsx b/packages/mask/src/plugins/RedPacket/SNSAdaptor/index.tsx index ab225bc6139c..caf55e2f65fa 100644 --- a/packages/mask/src/plugins/RedPacket/SNSAdaptor/index.tsx +++ b/packages/mask/src/plugins/RedPacket/SNSAdaptor/index.tsx @@ -1,5 +1,12 @@ import { type Plugin, usePluginWrapper, PluginId } from '@masknet/plugin-infra/content-script' -import { ChainId, SchemaType, chainResolver, networkResolver, NetworkType } from '@masknet/web3-shared-evm' +import { + ChainId, + SchemaType, + chainResolver, + networkResolver, + NetworkType, + isNativeTokenAddress, +} from '@masknet/web3-shared-evm' import { base } from '../base' import { RedPacketMetaKey, RedPacketNftMetaKey } from '../constants' import { @@ -8,6 +15,7 @@ import { renderWithRedPacketMetadata, renderWithRedPacketNftMetadata, } from './helpers' +import { useI18N } from '../locales' import type { RedPacketJSONPayload, RedPacketNftJSONPayload } from '../types' import RedPacketDialog from './RedPacketDialog' import { RedPacketInPost } from './RedPacketInPost' @@ -148,6 +156,7 @@ interface ERC20RedpacketBadgeProps { function ERC20RedpacketBadge(props: ERC20RedpacketBadgeProps) { const { payload } = props + const t = useI18N() const { value: fetchedToken } = useFungibleToken( NetworkPluginID.PLUGIN_EVM, payload.token?.address ?? payload.token?.address, @@ -157,9 +166,16 @@ function ERC20RedpacketBadge(props: ERC20RedpacketBadgeProps) { const tokenDetailed = payload.token?.schema === SchemaType.Native ? nativeCurrency : payload.token ?? fetchedToken return (
- A Lucky Drop with{' '} - {formatBalance(payload.total, tokenDetailed?.decimals ?? 0)} $ - {tokenDetailed?.symbol ?? tokenDetailed?.name ?? 'Token'} from {payload.sender.name} + + {t.badge({ + balance: formatBalance( + payload.total, + tokenDetailed?.decimals ?? 0, + isNativeTokenAddress(payload.token?.address) ? 6 : 0, + ), + tokenName: tokenDetailed?.symbol ?? tokenDetailed?.name ?? 'Token', + sender: payload.sender.name, + })}
) } diff --git a/packages/mask/src/plugins/RedPacket/locales/en-US.json b/packages/mask/src/plugins/RedPacket/locales/en-US.json index fb7fb85fe4c0..8f79904442b5 100644 --- a/packages/mask/src/plugins/RedPacket/locales/en-US.json +++ b/packages/mask/src/plugins/RedPacket/locales/en-US.json @@ -2,6 +2,7 @@ "promote": "🧧🧧🧧 Try sending Lucky Drop to your friends with tokens or NFTs to share the joy now! Install Mask.io to send your first Lucky Drop.", "promote_short": "🧧🧧🧧 Try sending Lucky Drop to your friends with Mask.io.", "nft_shift_select_tip": "You can also use {{text}} to select multiple NFTs.", + "badge": "A Lucky Drop with {{balance}} {{tokenName}} from {{sender}}", "collections": "Collections", "select_a_token": "Select a Token", "search": "Search", @@ -53,10 +54,12 @@ "select_existing": "History", "create_new": "New", "send_symbol": "Send {{amount}} {{symbol}}", + "insufficient_balance": "Insufficient Balance", "back": "Back", "hint": "You can withdraw the remaining balance 24 hours after the Lucky Drop is sent.", "total_amount": "Total Amount", "amount_per_share": "Amount per Share", + "estimate_gas_fee": "Estimate gas fee", "shares": "Shares", "average": "Average", "random": "Random", diff --git a/packages/plugin-infra/src/web3/EVM/index.ts b/packages/plugin-infra/src/web3/EVM/index.ts index edb258a194ec..9076bf6a2163 100644 --- a/packages/plugin-infra/src/web3/EVM/index.ts +++ b/packages/plugin-infra/src/web3/EVM/index.ts @@ -8,6 +8,7 @@ export * from './useERC721ContractIsApproveForAll' export * from './useERC721ContractSetApproveForAllCallback' export * from './useERC721TokenTransferCallback' export * from './useGasConfig' +export * from './useTransactionValue' export * from './useMulticall' export * from './useNativeTokenTransferCallback' export * from './useNativeTokenWrapperCallback' diff --git a/packages/plugin-infra/src/web3/EVM/useTransactionValue.ts b/packages/plugin-infra/src/web3/EVM/useTransactionValue.ts new file mode 100644 index 000000000000..a3e53b2f9ec1 --- /dev/null +++ b/packages/plugin-infra/src/web3/EVM/useTransactionValue.ts @@ -0,0 +1,27 @@ +import { useBalance } from '../useBalance' +import BigNumber from 'bignumber.js' +import { useGasConfig } from './useGasConfig' +import { useChainId } from '../useChainId' +import { NetworkPluginID } from '@masknet/web3-shared-base' + +export function useTransactionValue(originalValue: BigNumber.Value | undefined, gas: number | undefined) { + const { value: balance = '0' } = useBalance(NetworkPluginID.PLUGIN_EVM) + const chainId = useChainId(NetworkPluginID.PLUGIN_EVM) + + // #region amount minus estimate gas fee + const { gasPrice } = useGasConfig(chainId) + + const estimateGasFee = !gas + ? undefined + : gasPrice && gasPrice !== '0' + ? new BigNumber(gasPrice).multipliedBy(gas * 1.5).toFixed() + : undefined + + const transactionValue = new BigNumber(balance).isLessThan( + new BigNumber(originalValue ?? '0').plus(new BigNumber(estimateGasFee ?? '0')), + ) + ? new BigNumber(originalValue ?? '0').minus(estimateGasFee ?? '0').toFixed() + : (originalValue as string) + + return { transactionValue, estimateGasFee } +} diff --git a/packages/plugins/EVM/src/state/TransactionFormatter/descriptors/RedPacket.ts b/packages/plugins/EVM/src/state/TransactionFormatter/descriptors/RedPacket.ts index 3023490d64fe..72a305dbf3ab 100644 --- a/packages/plugins/EVM/src/state/TransactionFormatter/descriptors/RedPacket.ts +++ b/packages/plugins/EVM/src/state/TransactionFormatter/descriptors/RedPacket.ts @@ -3,6 +3,7 @@ import { ChainId, getNftRedPacketConstants, getRedPacketConstants, + isNativeTokenAddress, TransactionParameter, } from '@masknet/web3-shared-evm' import type { TransactionDescriptor } from '../types' @@ -26,7 +27,11 @@ export class RedPacketDescriptor implements TransactionDescriptor { }) const token = await connection?.getFungibleToken(parameters?._token_addr ?? '') - const amount = formatBalance(parameters?._total_tokens, token?.decimals) + const amount = formatBalance( + parameters?._total_tokens, + token?.decimals, + isNativeTokenAddress(parameters?._token_addr) ? 6 : 0, + ) return { chainId: context.chainId, From 179e465aba758df21be4a357551b7e76e0a345e2 Mon Sep 17 00:00:00 2001 From: zhouhanseng Date: Tue, 12 Jul 2022 15:21:12 +0800 Subject: [PATCH 077/179] fix: switch chain then revoke --- .../src/plugins/Approval/SNSAdaptor/ApprovalNFTContent.tsx | 4 +++- .../src/plugins/Approval/SNSAdaptor/ApprovalTokenContent.tsx | 4 +++- packages/mask/src/web3/UI/ChainBoundary.tsx | 4 ++-- .../plugin-infra/src/web3/EVM/useERC20TokenApproveCallback.ts | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/mask/src/plugins/Approval/SNSAdaptor/ApprovalNFTContent.tsx b/packages/mask/src/plugins/Approval/SNSAdaptor/ApprovalNFTContent.tsx index 8eaeacea0207..8e8c03b43d29 100644 --- a/packages/mask/src/plugins/Approval/SNSAdaptor/ApprovalNFTContent.tsx +++ b/packages/mask/src/plugins/Approval/SNSAdaptor/ApprovalNFTContent.tsx @@ -118,7 +118,9 @@ function ApprovalNFTItem(props: ApprovalNFTItemProps) { expectedPluginID={NetworkPluginID.PLUGIN_EVM} className={classes.chainBoundary} classes={{ switchButton: classes.button }} - expectedChainIdSwitchedCallback={() => approveCallback()} + expectedChainIdSwitchedCallback={async () => { + await approveCallback() + }} ActionButtonPromiseProps={{ fullWidth: false, init: t.revoke(), diff --git a/packages/mask/src/plugins/Approval/SNSAdaptor/ApprovalTokenContent.tsx b/packages/mask/src/plugins/Approval/SNSAdaptor/ApprovalTokenContent.tsx index 9e03fe19feed..af3554ab4305 100644 --- a/packages/mask/src/plugins/Approval/SNSAdaptor/ApprovalTokenContent.tsx +++ b/packages/mask/src/plugins/Approval/SNSAdaptor/ApprovalTokenContent.tsx @@ -100,7 +100,9 @@ function ApprovalTokenItem(props: ApprovalTokenItemProps) { expectedPluginID={NetworkPluginID.PLUGIN_EVM} className={classes.chainBoundary} classes={{ switchButton: classes.button }} - expectedChainIdSwitchedCallback={() => approveCallback(true, true)} + expectedChainIdSwitchedCallback={async () => { + await approveCallback(true, true) + }} ActionButtonPromiseProps={{ fullWidth: false, init: t.revoke(), diff --git a/packages/mask/src/web3/UI/ChainBoundary.tsx b/packages/mask/src/web3/UI/ChainBoundary.tsx index 18ce218c767a..980e66977df1 100644 --- a/packages/mask/src/web3/UI/ChainBoundary.tsx +++ b/packages/mask/src/web3/UI/ChainBoundary.tsx @@ -60,7 +60,7 @@ export interface ChainBoundaryProps extends withClass noSwitchNetworkTip?: boolean hiddenConnectButton?: boolean children?: React.ReactNode - expectedChainIdSwitchedCallback?: () => void + expectedChainIdSwitchedCallback?: () => Promise ActionButtonPromiseProps?: Partial } @@ -124,7 +124,7 @@ export function ChainBoundary(props: ChainBoundaryPro }) } - expectedChainIdSwitchedCallback?.() + await expectedChainIdSwitchedCallback?.() } return }, [ diff --git a/packages/plugin-infra/src/web3/EVM/useERC20TokenApproveCallback.ts b/packages/plugin-infra/src/web3/EVM/useERC20TokenApproveCallback.ts index e3c5c44fb269..c55e74a3b219 100644 --- a/packages/plugin-infra/src/web3/EVM/useERC20TokenApproveCallback.ts +++ b/packages/plugin-infra/src/web3/EVM/useERC20TokenApproveCallback.ts @@ -48,7 +48,7 @@ export function useERC20TokenApproveCallback( // the computed approve state const approveStateType = useMemo(() => { - if (isZero(amount) || !spender) return ApproveStateType.UNKNOWN + if (!amount || !spender) return ApproveStateType.UNKNOWN if (loadingBalance || loadingAllowance) return ApproveStateType.UPDATING if (errorBalance || errorAllowance) return ApproveStateType.FAILED return isLessThan(allowance, amount) || (allowance === amount && isZero(amount)) From 8e6da5bb96daa680690cedea4ebe2e3d0fca70b1 Mon Sep 17 00:00:00 2001 From: zhouhanseng Date: Tue, 12 Jul 2022 15:23:33 +0800 Subject: [PATCH 078/179] fix: switch chain then revoke --- .../src/plugins/Approval/SNSAdaptor/ApprovalNFTContent.tsx | 4 +--- .../src/plugins/Approval/SNSAdaptor/ApprovalTokenContent.tsx | 4 +--- packages/mask/src/web3/UI/ChainBoundary.tsx | 4 ++-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/packages/mask/src/plugins/Approval/SNSAdaptor/ApprovalNFTContent.tsx b/packages/mask/src/plugins/Approval/SNSAdaptor/ApprovalNFTContent.tsx index 8e8c03b43d29..8eaeacea0207 100644 --- a/packages/mask/src/plugins/Approval/SNSAdaptor/ApprovalNFTContent.tsx +++ b/packages/mask/src/plugins/Approval/SNSAdaptor/ApprovalNFTContent.tsx @@ -118,9 +118,7 @@ function ApprovalNFTItem(props: ApprovalNFTItemProps) { expectedPluginID={NetworkPluginID.PLUGIN_EVM} className={classes.chainBoundary} classes={{ switchButton: classes.button }} - expectedChainIdSwitchedCallback={async () => { - await approveCallback() - }} + expectedChainIdSwitchedCallback={() => approveCallback()} ActionButtonPromiseProps={{ fullWidth: false, init: t.revoke(), diff --git a/packages/mask/src/plugins/Approval/SNSAdaptor/ApprovalTokenContent.tsx b/packages/mask/src/plugins/Approval/SNSAdaptor/ApprovalTokenContent.tsx index af3554ab4305..9e03fe19feed 100644 --- a/packages/mask/src/plugins/Approval/SNSAdaptor/ApprovalTokenContent.tsx +++ b/packages/mask/src/plugins/Approval/SNSAdaptor/ApprovalTokenContent.tsx @@ -100,9 +100,7 @@ function ApprovalTokenItem(props: ApprovalTokenItemProps) { expectedPluginID={NetworkPluginID.PLUGIN_EVM} className={classes.chainBoundary} classes={{ switchButton: classes.button }} - expectedChainIdSwitchedCallback={async () => { - await approveCallback(true, true) - }} + expectedChainIdSwitchedCallback={() => approveCallback(true, true)} ActionButtonPromiseProps={{ fullWidth: false, init: t.revoke(), diff --git a/packages/mask/src/web3/UI/ChainBoundary.tsx b/packages/mask/src/web3/UI/ChainBoundary.tsx index 980e66977df1..18ce218c767a 100644 --- a/packages/mask/src/web3/UI/ChainBoundary.tsx +++ b/packages/mask/src/web3/UI/ChainBoundary.tsx @@ -60,7 +60,7 @@ export interface ChainBoundaryProps extends withClass noSwitchNetworkTip?: boolean hiddenConnectButton?: boolean children?: React.ReactNode - expectedChainIdSwitchedCallback?: () => Promise + expectedChainIdSwitchedCallback?: () => void ActionButtonPromiseProps?: Partial } @@ -124,7 +124,7 @@ export function ChainBoundary(props: ChainBoundaryPro }) } - await expectedChainIdSwitchedCallback?.() + expectedChainIdSwitchedCallback?.() } return }, [ From f6b20b0fd0a8399ea5575a79e82ed127124ddd65 Mon Sep 17 00:00:00 2001 From: lelenei <72531217+lelenei@users.noreply.github.com> Date: Tue, 12 Jul 2022 15:37:08 +0800 Subject: [PATCH 079/179] fix: add cache for getting avatar meta from kv at avatar plugin (#6733) * fix: add cache for getting avatar meta from kv at avatar plugin * fix: reply review * fix: pnpm-lock.yaml * refactor: reply review * fix: revert code * fix: reply review * fix: build error --- packages/mask/package.json | 2 + .../Avatar/hooks/usePersonaNFTAvatar.ts | 52 ++++++++++++++----- pnpm-lock.yaml | 4 ++ 3 files changed, 45 insertions(+), 13 deletions(-) diff --git a/packages/mask/package.json b/packages/mask/package.json index bf8b312f4f1f..7116a3c103d4 100644 --- a/packages/mask/package.json +++ b/packages/mask/package.json @@ -97,6 +97,7 @@ "jsbi": "3.1.4", "json-stable-stringify": "^1.0.1", "json2csv": "^5.0.6", + "lru-cache": "^7.10.1", "millify": "^4.0.0", "next-tick": "^1.0.0", "opensea-js": "^1.2.7", @@ -143,6 +144,7 @@ "@nice-labs/emit-file-webpack-plugin": "^1.1.2", "@pmmmwh/react-refresh-webpack-plugin": "^0.5.7", "@types/color": "^3.0.3", + "@types/lru-cache": "^7.10.10", "binaryen": "^107.0.0", "copy-webpack-plugin": "^11.0.0", "html-webpack-plugin": "^5.5.0", diff --git a/packages/mask/src/plugins/Avatar/hooks/usePersonaNFTAvatar.ts b/packages/mask/src/plugins/Avatar/hooks/usePersonaNFTAvatar.ts index d9fc5c6ee05d..fa34402cb68d 100644 --- a/packages/mask/src/plugins/Avatar/hooks/usePersonaNFTAvatar.ts +++ b/packages/mask/src/plugins/Avatar/hooks/usePersonaNFTAvatar.ts @@ -3,23 +3,49 @@ import { NetworkPluginID } from '@masknet/web3-shared-base' import { useAsyncRetry } from 'react-use' import { activatedSocialNetworkUI } from '../../../social-network' import type { RSS3_KEY_SNS } from '../constants' +import type { AvatarMetaDB, NextIDAvatarMeta } from '../types' import { getNFTAvatarByUserId } from '../utils' import { useGetNFTAvatar } from './useGetNFTAvatar' +import LRU from 'lru-cache' + +const cache = new LRU>({ + max: 500, + maxAge: 60 * 1000, +}) + +type GetNFTAvatar = ( + userId?: string, + network?: EnhanceableSite, + snsKey?: RSS3_KEY_SNS, +) => Promise export function usePersonaNFTAvatar(userId: string, avatarId: string, snsKey: RSS3_KEY_SNS) { const [, getNFTAvatar] = useGetNFTAvatar() + return useAsyncRetry(async () => { - const avatarMetaFromPersona = await getNFTAvatarByUserId(userId, avatarId) - if (avatarMetaFromPersona) return avatarMetaFromPersona - const avatarMeta = await getNFTAvatar( - userId, - activatedSocialNetworkUI.networkIdentifier as EnhanceableSite, - snsKey, - ) - if (!avatarMeta) return - if (avatarMeta.pluginId === NetworkPluginID.PLUGIN_SOLANA) { - return { imageUrl: '', nickname: '', ...avatarMeta, address: avatarMeta.tokenId } - } - return { imageUrl: '', nickname: '', ...avatarMeta } - }, [userId, getNFTAvatar, avatarId, snsKey]) + if (!userId) return + const key = `${userId}-${activatedSocialNetworkUI.networkIdentifier}` + if (!cache.has(key)) cache.set(key, getNFTAvatarForCache(userId, snsKey, avatarId, getNFTAvatar)) + const v = cache.get(key) + return v + }, [ + userId, + getNFTAvatar, + avatarId, + activatedSocialNetworkUI.networkIdentifier, + snsKey, + cache, + getNFTAvatarForCache, + ]) +} + +async function getNFTAvatarForCache(userId: string, snsKey: RSS3_KEY_SNS, avatarId: string, fn: GetNFTAvatar) { + const avatarMetaFromPersona = await getNFTAvatarByUserId(userId, avatarId) + if (avatarMetaFromPersona) return avatarMetaFromPersona + const avatarMeta = await fn(userId, activatedSocialNetworkUI.networkIdentifier as EnhanceableSite, snsKey) + if (!avatarMeta) return + if (avatarMeta.pluginId === NetworkPluginID.PLUGIN_SOLANA) { + return { imageUrl: '', nickname: '', ...avatarMeta, address: avatarMeta.tokenId } + } + return { imageUrl: '', nickname: '', ...avatarMeta } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c1861175333a..144ef7e10c0b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -421,6 +421,7 @@ importers: '@types/elliptic': ^6.4.14 '@types/json-stable-stringify': ^1.0.34 '@types/json2csv': ^5.0.3 + '@types/lru-cache': ^7.10.10 '@types/node': ^17.0.34 '@types/react-avatar-editor': ^12.0.0 '@types/react-highlight-words': ^0.16.4 @@ -461,6 +462,7 @@ importers: jsbi: 3.1.4 json-stable-stringify: ^1.0.1 json2csv: ^5.0.6 + lru-cache: ^7.10.1 millify: ^4.0.0 next-tick: ^1.0.0 opensea-js: ^1.2.7 @@ -605,6 +607,7 @@ importers: jsbi: 3.1.4 json-stable-stringify: 1.0.1 json2csv: 5.0.6 + lru-cache: 7.10.1 millify: 4.0.0 next-tick: 1.1.0 opensea-js: 1.2.7_webpack-cli@4.10.0 @@ -650,6 +653,7 @@ importers: '@nice-labs/emit-file-webpack-plugin': 1.1.2_webpack@5.73.0 '@pmmmwh/react-refresh-webpack-plugin': 0.5.7_g5otyhka3xgu4m6o2r25nvx6tm '@types/color': 3.0.3 + '@types/lru-cache': 7.10.10 binaryen: 107.0.0 copy-webpack-plugin: 11.0.0_webpack@5.73.0 html-webpack-plugin: 5.5.0_webpack@5.73.0 From 807ec9706b5c782526b014e0653e847da1bd12e8 Mon Sep 17 00:00:00 2001 From: lelenei <72531217+lelenei@users.noreply.github.com> Date: Tue, 12 Jul 2022 15:56:54 +0800 Subject: [PATCH 080/179] fix: tokenId at alchemy (#6742) * fix: tokenId at alchemy * fix: long long number to string * fix: use web3.utils.hexToNumberString --- packages/web3-providers/src/alchemy/index.ts | 25 ++++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/packages/web3-providers/src/alchemy/index.ts b/packages/web3-providers/src/alchemy/index.ts index f9b841b335d0..ad132d316f34 100644 --- a/packages/web3-providers/src/alchemy/index.ts +++ b/packages/web3-providers/src/alchemy/index.ts @@ -17,6 +17,7 @@ import { import { ChainId as ChainId_FLOW, SchemaType as SchemaType_FLOW } from '@masknet/web3-shared-flow' import { first } from 'lodash-unified' import urlcat from 'urlcat' +import { hexToNumberString, isHex } from 'web3-utils' import type { NonFungibleTokenAPI } from '..' import { fetchJSON } from '../helpers' import { Alchemy_EVM_NetworkMap, Alchemy_FLOW_NetworkMap, FILTER_WORDS } from './constants' @@ -146,8 +147,10 @@ function createNftToken_EVM( asset: AlchemyNFT_EVM, ): NonFungibleAsset { const contractAddress = asset.contract?.address - const tokenId = asset.id?.tokenId ?? '' - + let tokenId = asset.id.tokenId + if (isHex(asset.id.tokenId)) { + tokenId = hexToNumberString(asset.id.tokenId) + } return { id: `${contractAddress}_${tokenId}`, chainId, @@ -198,6 +201,10 @@ function createNFTAsset_EVM( contractMetadataResponse?: AlchemyResponse_EVM_Contact_Metadata, ownersResponse?: AlchemyResponse_EVM_Owners, ): NonFungibleAsset { + let tokenId = metaDataResponse.id.tokenId + if (isHex(metaDataResponse.id.tokenId)) { + tokenId = hexToNumberString(metaDataResponse.id.tokenId) + } return { id: metaDataResponse.contract?.address, chainId, @@ -206,7 +213,7 @@ function createNFTAsset_EVM( metaDataResponse?.id?.tokenMetadata?.tokenType === 'ERC721' ? SchemaType_EVM.ERC721 : SchemaType_EVM.ERC1155, - tokenId: metaDataResponse.id?.tokenId, + tokenId, address: metaDataResponse.contract?.address, metadata: { chainId, @@ -252,12 +259,16 @@ function createNftToken_FLOW( chainId: ChainId_FLOW, asset: AlchemyNFT_FLOW, ): NonFungibleAsset { + let tokenId = asset.id.tokenId + if (isHex(asset.id.tokenId)) { + tokenId = hexToNumberString(asset.id.tokenId) + } return { id: asset.contract?.address, chainId, type: TokenType.NonFungible, schema: SchemaType_FLOW.NonFungible, - tokenId: asset.id?.tokenId ?? '', + tokenId, address: asset.contract?.address, metadata: { chainId, @@ -295,12 +306,16 @@ function createNFTAsset_FLOW( ownerAddress: string, metaDataResponse: AlchemyResponse_FLOW_Metadata, ): NonFungibleAsset { + let tokenId = metaDataResponse.id.tokenId + if (isHex(metaDataResponse.id.tokenId)) { + tokenId = hexToNumberString(metaDataResponse.id.tokenId) + } return { id: metaDataResponse.contract?.address, chainId, type: TokenType.NonFungible, schema: SchemaType_FLOW.NonFungible, - tokenId: metaDataResponse.id?.tokenId ?? '', + tokenId, address: metaDataResponse.contract?.address, metadata: { chainId, From d9df9e35d6ffe23a7f953e1615279a06f76abe52 Mon Sep 17 00:00:00 2001 From: guanbinrui <52657989+guanbinrui@users.noreply.github.com> Date: Tue, 12 Jul 2022 16:22:04 +0800 Subject: [PATCH 081/179] fix: sign transaction (#6752) * fix: failed to sign tx * fix: tx gas * fix: error message * chore: wip * refactor: revoke changes * fix: sign payload --- .../mask/src/plugins/Wallet/services/send.ts | 30 ++++++++++--------- packages/web3-shared/evm/utils/contract.ts | 4 +-- packages/web3-shared/evm/utils/payload.ts | 25 +++++++++++++++- packages/web3-shared/evm/utils/provider.ts | 9 ++++++ 4 files changed, 51 insertions(+), 17 deletions(-) diff --git a/packages/mask/src/plugins/Wallet/services/send.ts b/packages/mask/src/plugins/Wallet/services/send.ts index 30c627ddb7bd..1f79b681d5c0 100644 --- a/packages/mask/src/plugins/Wallet/services/send.ts +++ b/packages/mask/src/plugins/Wallet/services/send.ts @@ -1,11 +1,14 @@ import Web3 from 'web3' import type { HttpProvider } from 'web3-core' +import { isHex, hexToNumber } from 'web3-utils' import type { JsonRpcPayload, JsonRpcResponse } from 'web3-core-helpers' +import { isNil } from 'lodash-unified' import { defer } from '@dimensiondev/kit' import { ChainId, + createWeb3, EthereumMethodType, - getPayloadConfig, + getSignablePayloadConfig, getPayloadId, getRPCConstants, isRiskMethod, @@ -13,7 +16,6 @@ import { import { openPopupWindow, removePopupWindow } from '../../../../background/services/helper' import { nativeAPI } from '../../../../shared/native-rpc' import { WalletRPC } from '../messages' -import { isNil } from 'lodash-unified' enum JSON_RPC_ERROR_CODE { INVALID_REQUEST = -32600, @@ -119,34 +121,34 @@ export async function send( options?: Options, ) { const provider = await createProvider(options?.chainId) - const computedPayload = getPayloadConfig(payload) + switch (payload.method) { case EthereumMethodType.ETH_SEND_TRANSACTION: case EthereumMethodType.MASK_REPLACE_TRANSACTION: + const computedPayload = getSignablePayloadConfig(payload) if (!computedPayload?.from || !computedPayload.to || !options?.chainId) return - const rawTransaction = await WalletRPC.signTransaction(computedPayload.from as string, { - ...computedPayload, - chainId: options.chainId, - }) - if (!rawTransaction) break + const privateKey = await WalletRPC.exportPrivateKey(computedPayload.from as string) + const web3 = createWeb3(provider) + const transactionSigned = await web3.eth.accounts.signTransaction(computedPayload, `0x${privateKey}`) + if (!transactionSigned.rawTransaction) break return provider.send( { ...payload, method: EthereumMethodType.ETH_SEND_RAW_TRANSACTION, - params: [rawTransaction], + params: [transactionSigned.rawTransaction], }, callback, ) case EthereumMethodType.ETH_SIGN_TYPED_DATA: const [address, dataToSign] = payload.params as [string, string] - const signed = await WalletRPC.signTypedData(address, dataToSign) + const dataSigned = await WalletRPC.signTypedData(address, dataToSign) try { callback(null, { jsonrpc: '2.0', id: payload.id as number, - result: signed, + result: dataSigned, }) } catch (error) { callback(getError(error, null, 'Failed to sign message.')) @@ -154,12 +156,12 @@ export async function send( break case EthereumMethodType.PERSONAL_SIGN: const [data, account] = payload.params as [string, string] - const personalSigned = await WalletRPC.signPersonalMessage(data, account) + const messageSigned = await WalletRPC.signPersonalMessage(data, account) try { callback(null, { jsonrpc: '2.0', id: payload.id as number, - result: personalSigned, + result: messageSigned, }) } catch (error) { callback(getError(error, null, 'Failed to sign message.')) @@ -219,7 +221,7 @@ export async function confirmRequest(payload: JsonRpcPayload, options?: Options) return } if (response?.error) { - reject(new Error(`Failed to send transaction: ${response.error}`)) + reject(new Error(`Failed to send transaction: ${response.error?.message ?? response.error}`)) return } WalletRPC.deleteUnconfirmedRequest(payload) diff --git a/packages/web3-shared/evm/utils/contract.ts b/packages/web3-shared/evm/utils/contract.ts index 19d935af9259..46d2c0e53caf 100644 --- a/packages/web3-shared/evm/utils/contract.ts +++ b/packages/web3-shared/evm/utils/contract.ts @@ -57,9 +57,9 @@ export async function encodeContractTransaction( if (!tx.gas) { tx.gas = await transaction.estimateGas({ from: tx.from as string | undefined, - value: tx.value, - data: tx.data as string | undefined, to: tx.to as string | undefined, + data: tx.data as string | undefined, + value: tx.value, }) } diff --git a/packages/web3-shared/evm/utils/payload.ts b/packages/web3-shared/evm/utils/payload.ts index 58c2e282ac65..b4073caa5b22 100644 --- a/packages/web3-shared/evm/utils/payload.ts +++ b/packages/web3-shared/evm/utils/payload.ts @@ -1,6 +1,7 @@ import BigNumber from 'bignumber.js' -import { first } from 'lodash-unified' +import { first, isUndefined, omitBy } from 'lodash-unified' import type { JsonRpcPayload } from 'web3-core-helpers' +import { hexToNumber } from 'web3-utils' import { EthereumMethodType, Transaction } from '../types' export function addGasMargin(value: BigNumber.Value, scale = 3000) { @@ -56,3 +57,25 @@ export function getPayloadConfig(payload: JsonRpcPayload) { return } } + +export function getSignablePayloadConfig(payload: JsonRpcPayload) { + const raw = getPayloadConfig(payload) + if (!raw) return + + const parseHexNumber = (hex: string | number | undefined) => + typeof hex !== 'undefined' ? hexToNumber(hex ?? '0x0') : undefined + + return omitBy( + { + ...raw, + value: parseHexNumber(raw.value as string | undefined), + gas: parseHexNumber(raw.gas), + gasPrice: parseHexNumber(raw.gasPrice as string | undefined), + maxFeePerGas: parseHexNumber(raw.maxFeePerGas as string | undefined), + maxPriorityFeePerGas: parseHexNumber(raw.maxPriorityFeePerGas as string | undefined), + chainId: parseHexNumber(raw.chainId), + nonce: parseHexNumber(raw.nonce), + }, + isUndefined, + ) as Transaction +} diff --git a/packages/web3-shared/evm/utils/provider.ts b/packages/web3-shared/evm/utils/provider.ts index 4ec56364cdc1..2367e25a3568 100644 --- a/packages/web3-shared/evm/utils/provider.ts +++ b/packages/web3-shared/evm/utils/provider.ts @@ -12,6 +12,15 @@ export function createWeb3(provider: Provider) { return web3 } +export function createSignableWeb3(provider: Provider, keys: string[]) { + const web3 = createWeb3(provider) + if (keys.length) { + web3.eth.accounts.wallet.clear() + keys.forEach((k) => k && ['0x', '0x0'].includes(k) && web3.eth.accounts.wallet.add(k)) + } + return web3 +} + export function createWeb3Provider(request: (requestArguments: RequestArguments) => Promise): Web3Provider { const provider: Web3Provider = { on() { From 45d73f1a25a6b1912e03105c0a78b6355383515a Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Tue, 12 Jul 2022 16:47:52 +0800 Subject: [PATCH 082/179] feat: welcome copywriting --- packages/dashboard/src/locales/en-US.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/dashboard/src/locales/en-US.json b/packages/dashboard/src/locales/en-US.json index c8da88af397d..38f9884ec87d 100644 --- a/packages/dashboard/src/locales/en-US.json +++ b/packages/dashboard/src/locales/en-US.json @@ -197,7 +197,7 @@ "wallets_empty_history_tips": "No transaction history", "wallets_loading_token": "Loading Token", "personas_setup_connect_tips": "Please connect to your {{type}} account.", - "personas_setup_tip": "Please create/restore persona.", + "personas_setup_tip": "Please create or restore a Mask identity.", "personas_setup_connect": "Connect", "personas_name_maximum_tips": "Maximum length is {{length}} characters long.", "personas_name_existed": "The persona name already exists", From 9ea5a803cdb680fc8b9c64fb8589b5d308c8bc07 Mon Sep 17 00:00:00 2001 From: nuanyang233 Date: Tue, 12 Jul 2022 16:44:17 +0800 Subject: [PATCH 083/179] fix: arbitrum symbol --- packages/web3-providers/src/debank/index.ts | 2 +- packages/web3-shared/evm/constants/chains.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/web3-providers/src/debank/index.ts b/packages/web3-providers/src/debank/index.ts index 33f5f2e85d31..c6f073203f76 100644 --- a/packages/web3-providers/src/debank/index.ts +++ b/packages/web3-providers/src/debank/index.ts @@ -89,7 +89,7 @@ export class DeBankAPI options?.chainId, ), getAllEVMNativeAssets(), - (a, z) => a.symbol === z.symbol, + (a, z) => a.symbol === z.symbol && a.chainId === z.chainId, ), createIndicator(options?.indicator), ) diff --git a/packages/web3-shared/evm/constants/chains.json b/packages/web3-shared/evm/constants/chains.json index 725cccd2906c..010afa11552b 100644 --- a/packages/web3-shared/evm/constants/chains.json +++ b/packages/web3-shared/evm/constants/chains.json @@ -233,7 +233,7 @@ "nativeCurrency": { "chainId": 42161, "name": "Arbitrum Ether", - "symbol": "ARETH", + "symbol": "ETH", "decimals": 18, "logoURL": "https://assets.debank.com/static/media/arbitrum.8e326f58.svg" }, @@ -258,7 +258,7 @@ "nativeCurrency": { "chainId": 421611, "name": "Arbitrum Rinkeby Ether", - "symbol": "ARETH", + "symbol": "ETH", "decimals": 18 }, "infoURL": "https://arbitrum.io", From b6bca940fcaea4914d82bca54118cc1ed51d9c1f Mon Sep 17 00:00:00 2001 From: nuanyang233 Date: Tue, 12 Jul 2022 16:59:56 +0800 Subject: [PATCH 084/179] fix: eslint --- packages/mask/src/plugins/Wallet/services/send.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/mask/src/plugins/Wallet/services/send.ts b/packages/mask/src/plugins/Wallet/services/send.ts index 1f79b681d5c0..6177c84dc303 100644 --- a/packages/mask/src/plugins/Wallet/services/send.ts +++ b/packages/mask/src/plugins/Wallet/services/send.ts @@ -1,6 +1,5 @@ import Web3 from 'web3' import type { HttpProvider } from 'web3-core' -import { isHex, hexToNumber } from 'web3-utils' import type { JsonRpcPayload, JsonRpcResponse } from 'web3-core-helpers' import { isNil } from 'lodash-unified' import { defer } from '@dimensiondev/kit' From adb3475dfb67e254f9bd485492e33012dfc32537 Mon Sep 17 00:00:00 2001 From: nuanyang233 Date: Tue, 12 Jul 2022 17:15:18 +0800 Subject: [PATCH 085/179] fix: prefix areth --- packages/web3-providers/src/debank/index.ts | 6 ++++++ packages/web3-shared/evm/constants/chains.json | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/web3-providers/src/debank/index.ts b/packages/web3-providers/src/debank/index.ts index c6f073203f76..c0e63f2ab71b 100644 --- a/packages/web3-providers/src/debank/index.ts +++ b/packages/web3-providers/src/debank/index.ts @@ -85,6 +85,12 @@ export class DeBankAPI // rename bsc to bnb id: x.id === 'bsc' ? 'bnb' : x.id, chain: x.chain === 'bsc' ? 'bnb' : x.chain, + // prefix ARETH + symbol: x.chain === 'arb' && x.symbol === 'ETH' ? 'ARETH' : x.symbol, + logo_url: + x.chain === 'arb' && x.symbol === 'ETH' + ? 'https://assets.debank.com/static/media/arbitrum.8e326f58.svg' + : x.logo_url, })), options?.chainId, ), diff --git a/packages/web3-shared/evm/constants/chains.json b/packages/web3-shared/evm/constants/chains.json index 010afa11552b..725cccd2906c 100644 --- a/packages/web3-shared/evm/constants/chains.json +++ b/packages/web3-shared/evm/constants/chains.json @@ -233,7 +233,7 @@ "nativeCurrency": { "chainId": 42161, "name": "Arbitrum Ether", - "symbol": "ETH", + "symbol": "ARETH", "decimals": 18, "logoURL": "https://assets.debank.com/static/media/arbitrum.8e326f58.svg" }, @@ -258,7 +258,7 @@ "nativeCurrency": { "chainId": 421611, "name": "Arbitrum Rinkeby Ether", - "symbol": "ETH", + "symbol": "ARETH", "decimals": 18 }, "infoURL": "https://arbitrum.io", From 897d58245d0a68cc3fd36f4871d94539a7e01327 Mon Sep 17 00:00:00 2001 From: zhouhanseng Date: Tue, 12 Jul 2022 17:21:16 +0800 Subject: [PATCH 086/179] fix: next id app board --- .../mask/src/components/DataSource/useNextID.ts | 15 +++++++++++---- .../components/InjectedComponents/SetupGuide.tsx | 7 ------- .../InjectedComponents/ToolboxUnstyled.tsx | 12 +----------- .../src/components/shared/ApplicationBoard.tsx | 13 +++++++++---- packages/shared-base/src/Messages/Shared.ts | 1 - 5 files changed, 21 insertions(+), 27 deletions(-) diff --git a/packages/mask/src/components/DataSource/useNextID.ts b/packages/mask/src/components/DataSource/useNextID.ts index 8cfb9cb81e85..2783debe1bab 100644 --- a/packages/mask/src/components/DataSource/useNextID.ts +++ b/packages/mask/src/components/DataSource/useNextID.ts @@ -22,7 +22,7 @@ export const usePersonaBoundPlatform = (personaPublicKey: string) => { let isOpenedVerifyDialog = false let isOpenedFromButton = false -const verifyPersona = (personaIdentifier?: PersonaIdentifier, username?: string) => async () => { +export const verifyPersona = (personaIdentifier?: PersonaIdentifier, username?: string) => async () => { if (!personaIdentifier) return currentSetupGuideStatus[activatedSocialNetworkUI.networkIdentifier].value = stringify({ status: SetupGuideStep.VerifyOnNextID, @@ -59,7 +59,7 @@ export function useSetupGuideStatusState() { }, [lastState_]) } -export function useNextIDConnectStatus() { +export function useNextIDConnectStatus(disableInitialVerify = false) { const ui = activatedSocialNetworkUI const [enableNextID] = useState(ui.configuration.nextIDConfig?.enable) const personaConnectStatus = usePersonaConnectStatus() @@ -110,13 +110,20 @@ export function useNextIDConnectStatus() { ) if (isBound) return NextIDVerificationStatus.Verified - if (isOpenedFromButton) { + if (isOpenedFromButton && !disableInitialVerify) { verifyPersona(personaConnectStatus.currentConnectedPersona?.identifier)() } isOpenedVerifyDialog = true isOpenedFromButton = false return NextIDVerificationStatus.WaitingVerify - }, [username, enableNextID, isOpenedVerifyDialog, personaConnectStatus, currentPersonaIdentifier.value]) + }, [ + username, + enableNextID, + isOpenedVerifyDialog, + personaConnectStatus, + currentPersonaIdentifier.value, + disableInitialVerify, + ]) return { isVerified: VerificationStatus === NextIDVerificationStatus.Verified, diff --git a/packages/mask/src/components/InjectedComponents/SetupGuide.tsx b/packages/mask/src/components/InjectedComponents/SetupGuide.tsx index 04d5aac23cc1..c8481c53408d 100644 --- a/packages/mask/src/components/InjectedComponents/SetupGuide.tsx +++ b/packages/mask/src/components/InjectedComponents/SetupGuide.tsx @@ -20,7 +20,6 @@ import { fromHex, NextIDAction, EnhanceableSite, - CrossIsolationMessages, EncryptionTargetType, } from '@masknet/shared-base' import Services from '../../extension/service' @@ -101,12 +100,6 @@ function SetupGuideUI(props: SetupGuideUIProps) { return Services.Identity.queryPersona(persona) }, [persona]) - useEffect(() => { - return CrossIsolationMessages.events.verifyNextID.on(() => { - setStep(SetupGuideStep.VerifyOnNextID) - }) - }, []) - const onConnect = async () => { const id = ProfileIdentifier.of(ui.networkIdentifier, username) if (!id.some) return diff --git a/packages/mask/src/components/InjectedComponents/ToolboxUnstyled.tsx b/packages/mask/src/components/InjectedComponents/ToolboxUnstyled.tsx index a844efcda9cb..0de1e96c52ee 100644 --- a/packages/mask/src/components/InjectedComponents/ToolboxUnstyled.tsx +++ b/packages/mask/src/components/InjectedComponents/ToolboxUnstyled.tsx @@ -23,7 +23,7 @@ import { useChainIdMainnet, useRecentTransactions, } from '@masknet/plugin-infra/web3' -import { useCallback, useEffect } from 'react' +import { useCallback } from 'react' import { WalletIcon } from '@masknet/shared' import { useRemoteControlledDialog } from '@masknet/shared-base-ui' import { WalletMessages } from '../../plugins/Wallet/messages' @@ -33,7 +33,6 @@ import GuideStep from '../GuideStep' import { AccountBalanceWalletIcon } from '@masknet/icons' import { makeStyles } from '@masknet/theme' import FiberManualRecordIcon from '@mui/icons-material/FiberManualRecord' -import { NextIDVerificationStatus, useNextIDConnectStatus } from '../DataSource/useNextID' import { MaskIcon } from '../../resources/MaskIcon' const useStyles = makeStyles<{ iconFontSize?: string }>()((theme, { iconFontSize = '1.5rem' }) => ({ @@ -135,7 +134,6 @@ function ToolboxHintForApplication(props: ToolboxHintProps) { function ToolboxHintForWallet(props: ToolboxHintProps) { const { t } = useI18N() - const nextIDConnectStatus = useNextIDConnectStatus() const { ListItemButton = MuiListItemButton, ListItemText = MuiListItemText, @@ -154,14 +152,6 @@ function ToolboxHintForWallet(props: ToolboxHintProps) { const networkDescriptor = useNetworkDescriptor() const providerDescriptor = useProviderDescriptor() - useEffect(() => { - const { status, isVerified, action } = nextIDConnectStatus - if (isVerified || status === NextIDVerificationStatus.WaitingLocalConnect) return - if (action) { - action() - } - }, [nextIDConnectStatus.status]) - return ( diff --git a/packages/mask/src/components/shared/ApplicationBoard.tsx b/packages/mask/src/components/shared/ApplicationBoard.tsx index 0cf6f9bcd276..ca22e70fe9ea 100644 --- a/packages/mask/src/components/shared/ApplicationBoard.tsx +++ b/packages/mask/src/components/shared/ApplicationBoard.tsx @@ -11,7 +11,7 @@ import { useI18N } from '../../utils' import { Application, getUnlistedApp } from './ApplicationSettingPluginList' import { ApplicationRecommendArea } from './ApplicationRecommendArea' import { useRemoteControlledDialog } from '@masknet/shared-base-ui' -import { useNextIDConnectStatus } from '../DataSource/useNextID' +import { useNextIDConnectStatus, verifyPersona } from '../DataSource/useNextID' import { usePersonaConnectStatus } from '../DataSource/usePersonaConnectStatus' import { usePersonaAgainstSNSConnectStatus } from '../DataSource/usePersonaAgainstSNSConnectStatus' import { WalletMessages } from '../../plugins/Wallet/messages' @@ -313,7 +313,7 @@ const ApplicationEntryStatusContext = createContext) { const personaConnectStatus = usePersonaConnectStatus() - const nextIDConnectStatus = useNextIDConnectStatus() + const nextIDConnectStatus = useNextIDConnectStatus(true) const { value: ApplicationCurrentStatus, @@ -322,14 +322,19 @@ function ApplicationEntryStatusProvider(props: PropsWithChildren<{}>) { } = usePersonaAgainstSNSConnectStatus() useEffect(() => { - nextIDConnectStatus.reset() retry() + nextIDConnectStatus.reset() return MaskMessages.events.currentPersonaIdentifier.on(() => { retry() nextIDConnectStatus.reset() }) }, []) + const personaNextIDReset = useCallback(() => { + nextIDConnectStatus.reset() + verifyPersona(personaConnectStatus.currentConnectedPersona?.identifier)() + }, [nextIDConnectStatus, personaConnectStatus]) + const { isSNSConnectToCurrentPersona, currentPersonaPublicKey, currentSNSConnectedPersonaPublicKey } = ApplicationCurrentStatus ?? {} @@ -337,7 +342,7 @@ function ApplicationEntryStatusProvider(props: PropsWithChildren<{}>) { Date: Tue, 12 Jul 2022 17:42:38 +0800 Subject: [PATCH 087/179] fix: add priceToken property at FungibleToken (#6768) --- packages/mask/src/plugins/Avatar/hooks/useNFT.ts | 2 +- packages/web3-providers/src/opensea/index.ts | 6 ++++++ packages/web3-providers/src/opensea/types.ts | 1 + packages/web3-shared/base/src/specs/index.ts | 1 + 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/mask/src/plugins/Avatar/hooks/useNFT.ts b/packages/mask/src/plugins/Avatar/hooks/useNFT.ts index 6df8705b0501..292cdd076893 100644 --- a/packages/mask/src/plugins/Avatar/hooks/useNFT.ts +++ b/packages/mask/src/plugins/Avatar/hooks/useNFT.ts @@ -24,7 +24,7 @@ export function useNFT( return { amount: asset?.price?.[CurrencyType.USD] ?? '0', name: asset?.contract?.name ?? '', - symbol: asset?.paymentTokens?.[0].symbol ?? 'ETH', + symbol: asset?.priceToken?.symbol ?? asset?.paymentTokens?.[0].symbol ?? 'ETH', image: asset?.metadata?.imageURL ?? '', owner: asset?.owner?.address ?? asset?.ownerId ?? '', slug: asset?.collection?.slug ?? '', diff --git a/packages/web3-providers/src/opensea/index.ts b/packages/web3-providers/src/opensea/index.ts index 5794f4d74f5d..a5ddde231e6f 100644 --- a/packages/web3-providers/src/opensea/index.ts +++ b/packages/web3-providers/src/opensea/index.ts @@ -169,6 +169,12 @@ function createNFTAsset(chainId: ChainId, asset: OpenSeaResponse): NonFungibleAs asset.last_sale?.payment_token.decimals, )?.toString(), }, + priceToken: createTokenDetailed(chainId, { + address: asset.last_sale?.payment_token.address ?? '', + decimals: Number(asset.last_sale?.payment_token.decimals ?? '0'), + name: '', + symbol: asset.last_sale?.payment_token.symbol ?? '', + }), orders: asset.orders ?.sort((a, z) => new BigNumber(getOrderUSDPrice(z.current_price, z.payment_token_contract?.usd_price) ?? 0) diff --git a/packages/web3-providers/src/opensea/types.ts b/packages/web3-providers/src/opensea/types.ts index 5a32c0d2484a..b42f69ddc804 100644 --- a/packages/web3-providers/src/opensea/types.ts +++ b/packages/web3-providers/src/opensea/types.ts @@ -61,6 +61,7 @@ export interface AssetEvent { decimals: number symbol: string usd_price: string + address: string } quantity: string } diff --git a/packages/web3-shared/base/src/specs/index.ts b/packages/web3-shared/base/src/specs/index.ts index 7d188f04d76d..8f43731cfae3 100644 --- a/packages/web3-shared/base/src/specs/index.ts +++ b/packages/web3-shared/base/src/specs/index.ts @@ -373,6 +373,7 @@ export interface NonFungibleAsset extends NonFungibleToken< orders?: Array> events?: Array> paymentTokens?: Array> + priceToken?: FungibleToken } /** From d4f23a6d9c080a0d47ea96340ee305f4aee362d0 Mon Sep 17 00:00:00 2001 From: Randolph314 <97870249+Randolph314@users.noreply.github.com> Date: Tue, 12 Jul 2022 18:02:38 +0800 Subject: [PATCH 088/179] fix : token security dialog width (#6770) * feat: change dialog width * feat: delete useless code Co-authored-by: Randolph <840094513@qq.com> --- .../TokenSecurity/CheckSecurityDialog.tsx | 21 +++++++------------ .../components/SecurityPanel.tsx | 8 +------ 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/packages/shared/src/UI/components/TokenSecurity/CheckSecurityDialog.tsx b/packages/shared/src/UI/components/TokenSecurity/CheckSecurityDialog.tsx index 868420c0fc9d..a47eb982e03d 100644 --- a/packages/shared/src/UI/components/TokenSecurity/CheckSecurityDialog.tsx +++ b/packages/shared/src/UI/components/TokenSecurity/CheckSecurityDialog.tsx @@ -12,13 +12,12 @@ import { useFungibleToken, useFungibleTokenPrice } from '@masknet/plugin-infra/w import { NetworkPluginID } from '@masknet/web3-shared-base' const useStyles = makeStyles()((theme) => ({ - root: { - width: 600, - }, content: { - height: 510, - maxHeight: 510, - padding: 16, + margin: 0, + padding: '0px !important', + '::-webkit-scrollbar': { + display: 'none', + }, }, footer: { boxShadow: @@ -30,7 +29,7 @@ const useStyles = makeStyles()((theme) => ({ }, })) -export interface BuyTokenDialogProps extends withClasses { +export interface BuyTokenDialogProps { open: boolean onClose(): void tokenSecurity: TokenSecurity @@ -53,13 +52,9 @@ export function CheckSecurityDialog(props: BuyTokenDialogProps) { }, [tokenSecurity]) return ( - + - + {loadingToken && (
diff --git a/packages/shared/src/UI/components/TokenSecurity/components/SecurityPanel.tsx b/packages/shared/src/UI/components/TokenSecurity/components/SecurityPanel.tsx index 7935137dde87..b2f55f3a569b 100644 --- a/packages/shared/src/UI/components/TokenSecurity/components/SecurityPanel.tsx +++ b/packages/shared/src/UI/components/TokenSecurity/components/SecurityPanel.tsx @@ -27,17 +27,11 @@ const useStyles = makeStyles()((theme) => ({ fontWeight: 700, fontSize: 18, }, - root: { - width: '600px', - }, detectionCard: { backgroundColor: theme.palette.background.default, }, detectionCollection: { overflowY: 'auto', - '&::-webkit-scrollbar': { - display: 'none', - }, }, icon: { width: '48px', @@ -101,7 +95,7 @@ export const SecurityPanel = memo(({ tokenSecurity, tokenInfo, t }, [riskyFactors, attentionFactors]) return ( - + Date: Tue, 12 Jul 2022 19:00:25 +0800 Subject: [PATCH 089/179] fix: crash --- packages/mask/src/web3/UI/ChainBoundary.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mask/src/web3/UI/ChainBoundary.tsx b/packages/mask/src/web3/UI/ChainBoundary.tsx index 18ce218c767a..9b385174ecfb 100644 --- a/packages/mask/src/web3/UI/ChainBoundary.tsx +++ b/packages/mask/src/web3/UI/ChainBoundary.tsx @@ -138,7 +138,7 @@ export function ChainBoundary(props: ChainBoundaryPro ]) const switchButtonDisabled = useMemo(() => { - return !(actualProviderDescriptor.enableRequirements?.supportedChainIds?.includes(expectedChainId) ?? false) + return !(actualProviderDescriptor?.enableRequirements?.supportedChainIds?.includes(expectedChainId) ?? false) }, [expectedChainId, actualProviderDescriptor]) const renderBox = (children?: React.ReactNode, tips?: string) => { From 8cd373452ba99bf2b0dd227cae08cab78fbdaac7 Mon Sep 17 00:00:00 2001 From: zhouhanseng Date: Tue, 12 Jul 2022 19:07:30 +0800 Subject: [PATCH 090/179] fix: lucky drop infinite loading --- .../plugins/RedPacket/SNSAdaptor/RedPacketInHistoryList.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacketInHistoryList.tsx b/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacketInHistoryList.tsx index 6a8665b28fa0..90acf6bfc52f 100644 --- a/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacketInHistoryList.tsx +++ b/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacketInHistoryList.tsx @@ -12,7 +12,6 @@ import REDPACKET_ABI from '@masknet/web3-contracts/abis/HappyRedPacketV4.json' import intervalToDuration from 'date-fns/intervalToDuration' import nextDay from 'date-fns/nextDay' import ActionButton from '../../../extension/options-page/DashboardComponents/ActionButton' -import { useI18N as useBaseI18N } from '../../../utils' import { Translate, useI18N } from '../locales' import { dateTimeFormat } from '../../ITO/assets/formatDate' import { StyledLinearProgress } from '../../ITO/SNSAdaptor/StyledLinearProgress' @@ -181,7 +180,6 @@ export interface RedPacketInHistoryListProps { } export function RedPacketInHistoryList(props: RedPacketInHistoryListProps) { const { history, onSelect } = props - const i18n = useBaseI18N() const t = useI18N() const { classes } = useStyles() const account = useAccount(NetworkPluginID.PLUGIN_EVM) @@ -245,7 +243,7 @@ export function RedPacketInHistoryList(props: RedPacketInHistoryListProps) { await refundCallback() revalidateAvailability() } - if (canSend) onSelect(removeUselessSendParams({ ...history, token: historyToken })) + if (canSend) onSelect(removeUselessSendParams({ ...history, token: historyToken, rpid })) }, [onSelect, refundCallback, canRefund, canSend, history, historyToken]) // #region password lost tips From a2a00b3ff52db21ab351a45440456c6ba36ee3fd Mon Sep 17 00:00:00 2001 From: Randolph314 <97870249+Randolph314@users.noreply.github.com> Date: Tue, 12 Jul 2022 19:09:24 +0800 Subject: [PATCH 091/179] feat: add empty status of main page (#6772) Co-authored-by: Randolph <840094513@qq.com> --- .../InjectedComponents/ProfileTabContent.tsx | 8 ++------ .../mask/src/plugins/NextID/components/NextIdPage.tsx | 4 ++-- .../Web3Profile/src/SNSAdaptor/components/Main.tsx | 10 +++++++++- packages/plugins/Web3Profile/src/locales/en-US.json | 3 ++- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx index 15f556b7f6ce..361db94198cc 100644 --- a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx +++ b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx @@ -12,7 +12,7 @@ import { useSocialAddressListAll, useAvailablePlugins } from '@masknet/plugin-in import { ConcealableTabs } from '@masknet/shared' import { CrossIsolationMessages, EMPTY_LIST, NextIDPlatform } from '@masknet/shared-base' import { makeStyles, useStylesExtends } from '@masknet/theme' -import { Box, CircularProgress, Typography } from '@mui/material' +import { Box, CircularProgress } from '@mui/material' import { activatedSocialNetworkUI } from '../../social-network' import { isTwitter } from '../../social-network-adaptor/twitter.com/base' import { MaskMessages, sortPersonaBindings, useI18N } from '../../utils' @@ -209,17 +209,13 @@ export function ProfileTabContent(props: ProfileTabContentProps) { return (
- {tabs.length ? ( + {tabs.length && ( tabs={tabs} selectedId={selectedTabId} onChange={setSelectedTab} tail={isOwn && } /> - ) : ( - - {t('web3_tab_hint')} - )}
{component}
diff --git a/packages/mask/src/plugins/NextID/components/NextIdPage.tsx b/packages/mask/src/plugins/NextID/components/NextIdPage.tsx index 5d4bf79ba397..9ce8a11f2529 100644 --- a/packages/mask/src/plugins/NextID/components/NextIdPage.tsx +++ b/packages/mask/src/plugins/NextID/components/NextIdPage.tsx @@ -94,12 +94,12 @@ const useStyles = makeStyles()((theme) => ({ marginTop: 2, }, item1: { - color: theme.palette.maskColor.second, + color: '#767f8d', fontSize: '14', fontWeight: 400, }, item2: { - color: theme.palette.maskColor.main, + color: '#07101B', fontSize: '14', fontWeight: 500, marginLeft: '2px', diff --git a/packages/plugins/Web3Profile/src/SNSAdaptor/components/Main.tsx b/packages/plugins/Web3Profile/src/SNSAdaptor/components/Main.tsx index bc5e7a4e03ad..528c8fd39ea9 100644 --- a/packages/plugins/Web3Profile/src/SNSAdaptor/components/Main.tsx +++ b/packages/plugins/Web3Profile/src/SNSAdaptor/components/Main.tsx @@ -3,6 +3,9 @@ import type { PersonaInformation } from '@masknet/shared-base' import type { IdentityResolved } from '@masknet/plugin-infra' import type { AccountType } from '../types' import type { CURRENT_STATUS } from '../../constants' +import { Empty } from './Empty' +import { Box } from '@mui/material' +import { useI18N } from '../../locales' interface MainProps { persona?: PersonaInformation openImageSetting: (status: CURRENT_STATUS, accountId: string) => void @@ -10,6 +13,7 @@ interface MainProps { accountList?: AccountType[] } export function Main(props: MainProps) { + const t = useI18N() const { openImageSetting, currentVisitingProfile, accountList } = props return (
@@ -23,7 +27,11 @@ export function Main(props: MainProps) { currentPersona={currentVisitingProfile} isCurrent={account?.identity === currentVisitingProfile?.identifier?.userId?.toLowerCase()} /> - ))} + )) ?? ( + + + + )}
) } diff --git a/packages/plugins/Web3Profile/src/locales/en-US.json b/packages/plugins/Web3Profile/src/locales/en-US.json index 8116d5297dfd..f2adcfa8b843 100644 --- a/packages/plugins/Web3Profile/src/locales/en-US.json +++ b/packages/plugins/Web3Profile/src/locales/en-US.json @@ -52,5 +52,6 @@ "no_unlisted_collection": " Click to show your {{collection}} on Web3 profile.", "wallet_setting_hint": "Toggle the button to manage wallet display settings.", "no_authenticated_wallet": "That hasn't been authenticated yet.", - "no_items_found": "No Items found." + "no_items_found": "No Items found.", + "account_empty": "Please verify this persona to set your Web3 profile." } From 931da3c09d314ebaf9ce960bac4e427179e5128e Mon Sep 17 00:00:00 2001 From: BillyS Date: Tue, 12 Jul 2022 19:25:49 +0800 Subject: [PATCH 092/179] fix: add padding to dialog content (#6773) --- .../mask/src/components/CompositionDialog/Composition.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/mask/src/components/CompositionDialog/Composition.tsx b/packages/mask/src/components/CompositionDialog/Composition.tsx index 9098d7c87131..1dabce46e0c6 100644 --- a/packages/mask/src/components/CompositionDialog/Composition.tsx +++ b/packages/mask/src/components/CompositionDialog/Composition.tsx @@ -26,6 +26,9 @@ const useStyles = makeStyles()({ hideDialogRoot: { visibility: 'hidden', }, + dialogContent: { + padding: '20px 24px', + }, }) export interface PostDialogProps { type?: 'popup' | 'timeline' @@ -114,7 +117,7 @@ export function Composition({ type = 'timeline', requireClipboardPermission }: P open={open} onClose={onClose} title={t('post_dialog__title')}> - + Date: Tue, 12 Jul 2022 19:33:50 +0800 Subject: [PATCH 093/179] fix: plugin close dialog ui --- .../shared/CheckSecurityConfirmDialog.tsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/mask/src/components/shared/CheckSecurityConfirmDialog.tsx b/packages/mask/src/components/shared/CheckSecurityConfirmDialog.tsx index e168e3bcb314..af7dd35fd930 100644 --- a/packages/mask/src/components/shared/CheckSecurityConfirmDialog.tsx +++ b/packages/mask/src/components/shared/CheckSecurityConfirmDialog.tsx @@ -6,13 +6,10 @@ import { useI18N } from '../../utils' const useStyles = makeStyles()((theme) => ({ paper: { maxWidth: '320px !important', - padding: '24px', + padding: 0, }, content: { - marginLeft: 12, - marginRight: 12, - paddingLeft: 0, - paddingRight: 0, + padding: '48px 24px', '&::-webkit-scrollbar': { display: 'none', }, @@ -29,7 +26,7 @@ const useStyles = makeStyles()((theme) => ({ }, })) -interface CheckSecurityConfirmDialogProps extends withClasses { +interface CheckSecurityConfirmDialogProps { open: boolean onConfirm: () => void onClose: () => void @@ -41,7 +38,10 @@ function CheckSecurityConfirmDialog(props: CheckSecurityConfirmDialogProps) { const { classes } = useStyles() return ( - + {t('close_check_security')} From d351dd446ca65f9b580515c1809c9e78539215f1 Mon Sep 17 00:00:00 2001 From: zhouhanseng Date: Tue, 12 Jul 2022 19:46:03 +0800 Subject: [PATCH 094/179] chore: nft lucky drop history --- .../RedPacket/SNSAdaptor/hooks/useNftAvailabilityComputed.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mask/src/plugins/RedPacket/SNSAdaptor/hooks/useNftAvailabilityComputed.ts b/packages/mask/src/plugins/RedPacket/SNSAdaptor/hooks/useNftAvailabilityComputed.ts index c2f1ffd50d5c..2fbf18f4a9ce 100644 --- a/packages/mask/src/plugins/RedPacket/SNSAdaptor/hooks/useNftAvailabilityComputed.ts +++ b/packages/mask/src/plugins/RedPacket/SNSAdaptor/hooks/useNftAvailabilityComputed.ts @@ -12,7 +12,7 @@ import { useAvailabilityNftRedPacket } from './useAvailabilityNftRedPacket' */ export function useNftAvailabilityComputed(account: string, payload: NftRedPacketJSONPayload) { const chainId = useChainId(NetworkPluginID.PLUGIN_EVM) - const asyncResult = useAvailabilityNftRedPacket(payload?.rpid, account) + const asyncResult = useAvailabilityNftRedPacket(payload?.rpid, account, chainId) const result = asyncResult const availability = result.value From 1c971b6aa12de0df6e7d846ed55ef1598701a69c Mon Sep 17 00:00:00 2001 From: guanbinrui <52657989+guanbinrui@users.noreply.github.com> Date: Tue, 12 Jul 2022 20:07:12 +0800 Subject: [PATCH 095/179] fix: nonce confliction (#6771) * feat(lucky drop): pre gas minus (#6467) * feat(lucky drop): pre gas minus * chore: reply code review * chore: solve error * fix: solve conflict * chore: format balance * chore: apply confition apply only sum of gas and total greater than balance * chore: increase estimate gas * chore: format significant * chore: reply code review * chore: format significant * chore: i18n * chore: reply code review * chore: use big number * chore: add useTransactionValue hook * refactor: unlock nft Co-authored-by: Hancheng Zhou --- .../TransactionFormatter/descriptors/ERC20.ts | 1 + .../TransactionFormatter/descriptors/ERC721.ts | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/packages/plugins/EVM/src/state/TransactionFormatter/descriptors/ERC20.ts b/packages/plugins/EVM/src/state/TransactionFormatter/descriptors/ERC20.ts index cd6a08c79c1d..6ce497bb421d 100644 --- a/packages/plugins/EVM/src/state/TransactionFormatter/descriptors/ERC20.ts +++ b/packages/plugins/EVM/src/state/TransactionFormatter/descriptors/ERC20.ts @@ -14,6 +14,7 @@ export class ERC20Descriptor implements TransactionDescriptor { }) for (const method of context.methods) { const parameters = method.parameters + switch (method.name) { case 'approve': if (parameters?.spender === undefined || parameters?.value === undefined) break diff --git a/packages/plugins/EVM/src/state/TransactionFormatter/descriptors/ERC721.ts b/packages/plugins/EVM/src/state/TransactionFormatter/descriptors/ERC721.ts index bcbf4dea0356..0048b51af5a8 100644 --- a/packages/plugins/EVM/src/state/TransactionFormatter/descriptors/ERC721.ts +++ b/packages/plugins/EVM/src/state/TransactionFormatter/descriptors/ERC721.ts @@ -1,5 +1,6 @@ import type { TransactionContext } from '@masknet/web3-shared-base' import type { ChainId, TransactionParameter } from '@masknet/web3-shared-evm' +import { Web3StateSettings } from '../../../settings' import type { TransactionDescriptor } from '../types' export class ERC721Descriptor implements TransactionDescriptor { @@ -10,6 +11,20 @@ export class ERC721Descriptor implements TransactionDescriptor { const parameters = method.parameters switch (method.name) { + case 'approve': + if (parameters?.to === undefined || parameters?.tokenId === undefined) break + + const connection = await Web3StateSettings.value.Connection?.getConnection?.({ + chainId: context.chainId, + }) + const contract = await connection?.getNonFungibleTokenContract(context.to) + + return { + chainId: context.chainId, + title: `Unlock ${contract?.symbol ?? 'token'} contract`, + description: `Unlock ${contract?.symbol ?? 'token'} contract`, + successfulDescription: `${contract?.symbol ?? 'token'} is unlocked successfully.`, + } case 'setApprovalForAll': if (parameters?.operator === undefined || parameters?.approved === undefined) break return { From 4f8b0ca55c2f28f818d09e8a5409055d8d9862cb Mon Sep 17 00:00:00 2001 From: guanbinrui <52657989+guanbinrui@users.noreply.github.com> Date: Tue, 12 Jul 2022 20:08:39 +0800 Subject: [PATCH 096/179] Revert "fix: nonce confliction (#6771)" (#6774) This reverts commit 1c971b6aa12de0df6e7d846ed55ef1598701a69c. --- .../TransactionFormatter/descriptors/ERC20.ts | 1 - .../TransactionFormatter/descriptors/ERC721.ts | 15 --------------- 2 files changed, 16 deletions(-) diff --git a/packages/plugins/EVM/src/state/TransactionFormatter/descriptors/ERC20.ts b/packages/plugins/EVM/src/state/TransactionFormatter/descriptors/ERC20.ts index 6ce497bb421d..cd6a08c79c1d 100644 --- a/packages/plugins/EVM/src/state/TransactionFormatter/descriptors/ERC20.ts +++ b/packages/plugins/EVM/src/state/TransactionFormatter/descriptors/ERC20.ts @@ -14,7 +14,6 @@ export class ERC20Descriptor implements TransactionDescriptor { }) for (const method of context.methods) { const parameters = method.parameters - switch (method.name) { case 'approve': if (parameters?.spender === undefined || parameters?.value === undefined) break diff --git a/packages/plugins/EVM/src/state/TransactionFormatter/descriptors/ERC721.ts b/packages/plugins/EVM/src/state/TransactionFormatter/descriptors/ERC721.ts index 0048b51af5a8..bcbf4dea0356 100644 --- a/packages/plugins/EVM/src/state/TransactionFormatter/descriptors/ERC721.ts +++ b/packages/plugins/EVM/src/state/TransactionFormatter/descriptors/ERC721.ts @@ -1,6 +1,5 @@ import type { TransactionContext } from '@masknet/web3-shared-base' import type { ChainId, TransactionParameter } from '@masknet/web3-shared-evm' -import { Web3StateSettings } from '../../../settings' import type { TransactionDescriptor } from '../types' export class ERC721Descriptor implements TransactionDescriptor { @@ -11,20 +10,6 @@ export class ERC721Descriptor implements TransactionDescriptor { const parameters = method.parameters switch (method.name) { - case 'approve': - if (parameters?.to === undefined || parameters?.tokenId === undefined) break - - const connection = await Web3StateSettings.value.Connection?.getConnection?.({ - chainId: context.chainId, - }) - const contract = await connection?.getNonFungibleTokenContract(context.to) - - return { - chainId: context.chainId, - title: `Unlock ${contract?.symbol ?? 'token'} contract`, - description: `Unlock ${contract?.symbol ?? 'token'} contract`, - successfulDescription: `${contract?.symbol ?? 'token'} is unlocked successfully.`, - } case 'setApprovalForAll': if (parameters?.operator === undefined || parameters?.approved === undefined) break return { From d6cd069887ff88f4fc3c580ecf90d43987e22680 Mon Sep 17 00:00:00 2001 From: guanbinrui <52657989+guanbinrui@users.noreply.github.com> Date: Tue, 12 Jul 2022 20:21:53 +0800 Subject: [PATCH 097/179] refactor: unlock nft (#6769) --- .../Wallet/ContractInteraction/index.tsx | 2 +- .../SNSAdaptor/components/ConsoleContent.tsx | 45 +++++++++++++++++++ .../EVM/src/state/Connection/connection.ts | 34 +++++++------- .../TransactionFormatter/descriptors/ERC20.ts | 1 + .../descriptors/ERC721.ts | 36 ++++++++++++--- 5 files changed, 96 insertions(+), 22 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 1f1b915f7a3d..b3d8ffcf90dc 100644 --- a/packages/mask/src/extension/popups/pages/Wallet/ContractInteraction/index.tsx +++ b/packages/mask/src/extension/popups/pages/Wallet/ContractInteraction/index.tsx @@ -181,7 +181,7 @@ const ContractInteraction = memo(() => { for (const method of methods) { const parameters = method.parameters - if (method.name === 'approve' && parameters?.value) { + if (method.name === 'approve' || method.name === 'setApprovalForAll') { return { isNativeTokenInteraction: false, typeName: request.formatterTransaction?.title, diff --git a/packages/plugins/Debugger/src/SNSAdaptor/components/ConsoleContent.tsx b/packages/plugins/Debugger/src/SNSAdaptor/components/ConsoleContent.tsx index c9e158ea9ec3..c94174ec8b38 100644 --- a/packages/plugins/Debugger/src/SNSAdaptor/components/ConsoleContent.tsx +++ b/packages/plugins/Debugger/src/SNSAdaptor/components/ConsoleContent.tsx @@ -61,6 +61,7 @@ export function ConsoleContent(props: ConsoleContentProps) { const { value: balance = '0' } = useBalance() const { value: blockNumber = 0 } = useBlockNumber() const { value: blockTimestamp = 0 } = useBlockTimestamp() + const onTransferCallback = useCallback(() => { if (!NATIVE_TOKEN_ADDRESS) return return connection.transferFungibleToken( @@ -70,6 +71,26 @@ export function ConsoleContent(props: ConsoleContentProps) { ) }, [connection]) + const onApproveFungibleTokenCallback = useCallback(() => { + if (pluginID !== NetworkPluginID.PLUGIN_EVM) return + if (chainId !== ChainId.Mainnet) return + return connection.approveFungibleToken( + '0x6B175474E89094C44Da98b954EedeAC495271d0F', + '0x31f42841c2db5173425b5223809cf3a38fede360', + '1', + ) + }, [pluginID, connection]) + + const onApproveNonFungibleTokenCallback = useCallback(() => { + if (pluginID !== NetworkPluginID.PLUGIN_EVM) return + if (chainId !== ChainId.Mainnet) return + return connection.approveNonFungibleToken( + '0xd945f759d422ae30a6166838317b937de08380e3', + '0x31f42841c2db5173425b5223809cf3a38fede360', + '71050', + ) + }, [pluginID, connection]) + const onSignMessage = useCallback( async (type?: string) => { const message = 'Hello World' @@ -210,6 +231,30 @@ export function ConsoleContent(props: ConsoleContentProps) { + + + + Approve Fungible Token + + + + + + + + + + Approve Non-Fungible Token + + + + + + diff --git a/packages/plugins/EVM/src/state/Connection/connection.ts b/packages/plugins/EVM/src/state/Connection/connection.ts index cd439da4730d..56f6d443bbb8 100644 --- a/packages/plugins/EVM/src/state/Connection/connection.ts +++ b/packages/plugins/EVM/src/state/Connection/connection.ts @@ -337,26 +337,30 @@ class Connection implements EVM_Connection { const ERC721_ENUMERABLE_INTERFACE_ID = '0x780e9d63' const ERC1155_ENUMERABLE_INTERFACE_ID = '0xd9b67a26' - const erc165Contract = await this.getWeb3Contract(address, ERC165ABI as AbiItem[], options) + try { + const erc165Contract = await this.getWeb3Contract(address, ERC165ABI as AbiItem[], options) - const isERC165 = await erc165Contract?.methods - .supportsInterface(ERC165_INTERFACE_ID) - .call({ from: options.account }) + const isERC165 = await erc165Contract?.methods + .supportsInterface(ERC165_INTERFACE_ID) + .call({ from: options.account }) - const isERC721 = await erc165Contract?.methods - .supportsInterface(ERC721_ENUMERABLE_INTERFACE_ID) - .call({ from: options.account }) - if (isERC165 && isERC721) return SchemaType.ERC721 + const isERC721 = await erc165Contract?.methods + .supportsInterface(ERC721_ENUMERABLE_INTERFACE_ID) + .call({ from: options.account }) + if (isERC165 && isERC721) return SchemaType.ERC721 - const isERC1155 = await erc165Contract?.methods - .supportsInterface(ERC1155_ENUMERABLE_INTERFACE_ID) - .call({ from: options.account }) - if (isERC165 && isERC1155) return SchemaType.ERC1155 + const isERC1155 = await erc165Contract?.methods + .supportsInterface(ERC1155_ENUMERABLE_INTERFACE_ID) + .call({ from: options.account }) + if (isERC165 && isERC1155) return SchemaType.ERC1155 - const isERC20 = (await this.getCode(address, options)) !== '0x' - if (isERC20) return SchemaType.ERC20 + const isERC20 = (await this.getCode(address, options)) !== '0x' + if (isERC20) return SchemaType.ERC20 - return + return + } catch { + return + } } async getNonFungibleToken( address: string, diff --git a/packages/plugins/EVM/src/state/TransactionFormatter/descriptors/ERC20.ts b/packages/plugins/EVM/src/state/TransactionFormatter/descriptors/ERC20.ts index cd6a08c79c1d..6ce497bb421d 100644 --- a/packages/plugins/EVM/src/state/TransactionFormatter/descriptors/ERC20.ts +++ b/packages/plugins/EVM/src/state/TransactionFormatter/descriptors/ERC20.ts @@ -14,6 +14,7 @@ export class ERC20Descriptor implements TransactionDescriptor { }) for (const method of context.methods) { const parameters = method.parameters + switch (method.name) { case 'approve': if (parameters?.spender === undefined || parameters?.value === undefined) break diff --git a/packages/plugins/EVM/src/state/TransactionFormatter/descriptors/ERC721.ts b/packages/plugins/EVM/src/state/TransactionFormatter/descriptors/ERC721.ts index bcbf4dea0356..71e6cb0eb5cf 100644 --- a/packages/plugins/EVM/src/state/TransactionFormatter/descriptors/ERC721.ts +++ b/packages/plugins/EVM/src/state/TransactionFormatter/descriptors/ERC721.ts @@ -1,8 +1,17 @@ import type { TransactionContext } from '@masknet/web3-shared-base' import type { ChainId, TransactionParameter } from '@masknet/web3-shared-evm' +import { Web3StateSettings } from '../../../settings' import type { TransactionDescriptor } from '../types' export class ERC721Descriptor implements TransactionDescriptor { + async getContractSymbol(chainId: ChainId, address: string) { + const connection = await Web3StateSettings.value.Connection?.getConnection?.({ + chainId: chainId, + }) + const contract = await connection?.getNonFungibleTokenContract(address) + return contract?.symbol + } + async compute(context: TransactionContext) { if (!context.methods?.length) return @@ -10,16 +19,31 @@ export class ERC721Descriptor implements TransactionDescriptor { const parameters = method.parameters switch (method.name) { - case 'setApprovalForAll': + case 'approve': { + if (parameters?.to === undefined || parameters?.tokenId === undefined) break + + const symbol = await this.getContractSymbol(context.chainId, context.to) + + return { + chainId: context.chainId, + title: `Unlock ${symbol ?? 'token'} contract`, + description: `Unlock ${symbol ?? 'token'} contract`, + successfulDescription: `${symbol ?? 'token'} is unlocked successfully.`, + } + } + case 'setApprovalForAll': { if (parameters?.operator === undefined || parameters?.approved === undefined) break + + const action = parameters?.approved === false ? 'Revoke' : 'Unlock' + const symbol = await this.getContractSymbol(context.chainId, context.to) + return { chainId: context.chainId, - title: parameters?.approved === false ? 'Revoke' : 'Unlock', - description: `${ - parameters?.approved === false ? 'Revoke the approval for' : 'Unlock' - } the token.`, - successfulDescription: 'Revoke the approval successfully.', + title: `${action} ${symbol ?? 'token'} contract`, + description: `${action} ${symbol ?? 'token'} contract`, + successfulDescription: `${action} the approval successfully.`, } + } default: return From 53d4625a1ece281c5684e96fd39a09b0d565ff21 Mon Sep 17 00:00:00 2001 From: zhouhanseng Date: Tue, 12 Jul 2022 20:59:27 +0800 Subject: [PATCH 098/179] fix: nft red packet button ui --- packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacketNft.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacketNft.tsx b/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacketNft.tsx index f1c3695a0283..0f2fe36b4a7f 100644 --- a/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacketNft.tsx +++ b/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacketNft.tsx @@ -417,6 +417,7 @@ export function RedPacketNft({ payload }: RedPacketNftProps) { + return ( + + ) }, [personaConnectStatus, t]) const { value: currentPersona, loading: loadingPersona } = useAsyncRetry(async () => { From 5a88f1a77fefb8f59b7b1359fb02b921c0e15351 Mon Sep 17 00:00:00 2001 From: guanbinrui <52657989+guanbinrui@users.noreply.github.com> Date: Tue, 12 Jul 2022 22:32:32 +0800 Subject: [PATCH 103/179] refactor: remove legacy payload (#6776) --- .../encryption/src/image-steganography/index.ts | 3 +-- .../components/CompositionDialog/useSubmit.ts | 2 +- .../mask/src/resources/image-payload/index.ts | 1 - .../image-payload/wallet/payload-eth.png | Bin 58027 -> 0 bytes 4 files changed, 2 insertions(+), 4 deletions(-) delete mode 100644 packages/mask/src/resources/image-payload/wallet/payload-eth.png diff --git a/packages/encryption/src/image-steganography/index.ts b/packages/encryption/src/image-steganography/index.ts index baf1a29d041d..1a17b02459e0 100644 --- a/packages/encryption/src/image-steganography/index.ts +++ b/packages/encryption/src/image-steganography/index.ts @@ -6,7 +6,7 @@ import { omit } from 'lodash-unified' import { getDimension } from './utils' export { GrayscaleAlgorithm } from '@dimensiondev/stego-js/cjs/grayscale.js' -export type ImageTemplateTypes = 'v2' | 'eth' +export type ImageTemplateTypes = 'v2' interface Dimension { width: number @@ -34,7 +34,6 @@ const dimensionPreset: Preset[] = [ { width: 1200, height: 680, - template: 'eth', mask: new URL('./masks/mask-transparent.png', import.meta.url).toString(), options: { cropEdgePixels: true, diff --git a/packages/mask/src/components/CompositionDialog/useSubmit.ts b/packages/mask/src/components/CompositionDialog/useSubmit.ts index 398411a21650..0556fcc621aa 100644 --- a/packages/mask/src/components/CompositionDialog/useSubmit.ts +++ b/packages/mask/src/components/CompositionDialog/useSubmit.ts @@ -85,7 +85,7 @@ function decorateEncryptedText( if (RedPacketMetadataReader(meta).ok || RedPacketNftMetadataReader(meta).ok) { return [ - 'eth', + 'v2', hasOfficialAccount ? t('additional_post_box__encrypted_post_pre_red_packet_twitter_official_account', { encrypted, diff --git a/packages/mask/src/resources/image-payload/index.ts b/packages/mask/src/resources/image-payload/index.ts index 5657f8a46107..ea5d95676b1a 100644 --- a/packages/mask/src/resources/image-payload/index.ts +++ b/packages/mask/src/resources/image-payload/index.ts @@ -2,5 +2,4 @@ import type { ImageTemplateTypes } from '@masknet/encryption' export const ImagePayloadURLs: Readonly> = { v2: new URL('./normal/payload-v2.png', import.meta.url).toString(), - eth: new URL('./wallet/payload-eth.png', import.meta.url).toString(), } diff --git a/packages/mask/src/resources/image-payload/wallet/payload-eth.png b/packages/mask/src/resources/image-payload/wallet/payload-eth.png deleted file mode 100644 index e9f6d6a2614e180f226ea678b886717b328d52af..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 58027 zcmc$Dhf`C}_cnr{1W^zY=?EWsf`uv|AWe`aH3XEF08#{{_fF`&DZTelLX{>EdM`qh zk|4bkdKLKbegBE~&Y7LLcV>5X&vW)U&p9_tLtT*)zyKg3BBFe!B(Ft8bhnC#h`9JZ z$?X@7(vz3BFQ*!+ItsI70ytXnzpph`KYiYe4ccqS+Uw0fSghGDi{A+JT2lEq|NPzl z0{URFdVit%;MNvv_oq-h-=miG&G2k8`+w2z2(v5hjWb zm+LoDk^A$Nhbs+hPL4a6^u77Y{lAq53+VZ0@Al>^4woAauoZjwTPt7lby?Cg-ovAI z$MQCdqV{ko0uF_HDzlAAUyJl1;L6q`y;tn*7Nv9ub7h3N(zQtMg_mkeZ}iq}> z^LV3mcQlVMTYNNAbG+Vqy3~F!Sh_n?c)Z@cJ6(9R*1S;_wKH9~H(7eL+O(b$bhOsA zQ4qc}U2wG8xP(Bggt#27G#;+}Sn;yooi5nT%Jx*& zdS1}R`1fsW?%Htt`f$Sb?;ISf)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zaF&{~Cx?ByR&UuI$>6O87KoT5oOkcyil0))P0V#;~Xd3ImZP)vcd$khPiTQn3HAwDq zV{dZ2iSw{amd1H#F7m)@u~QE;@VHVzc9PPBbheVL_aISZQ^=sn!8c2CRVq1m93s;K zU3rP)Kc8I<6_Kkpg3IchILayr4#YtZ!exbJr&Ajge~^=q(X|RCbdhZd$q3NWz#B&9 zOBJu9A0l5W&yBt?5>G1R#=XTY(b}0 zNg_6@UnXJNCsH(_i^$*H&z-i<5P1x~5v1r0?ltsMAR7;QpMO%Qci~4>%j5d%_l8e3 z+qRz<<}OMJpGgR->$KZ~U(4%;XohZAsX6xM3O*=2+3`|%OP8T=RsC6T-v;ls{+jE` zP-f1vwvYLsHj(EnazE37peAJcTbhzS>%$vWtbW9LNapb+TlRR)9=vU`uvW| z+d$QFs)y~Yj(QGW&G(-TtV&9KEQfNZn3-S(k`Sg=MLmuv7K+HP@*C9g#@1J~NZL%* znF09Y-<*BP6rJXPPH)M6F^YW7&_BgHq&Xoy=XMdiBG4wwNK{EL{Cu}##THR;2>`Q8 zs>85iy>e|oIG~o+OhDTJ;b20n!H!6}g>046)eVg&ZhgOZ`RnNqR( z5DE>_ZP38W+h=h_>kWF#LFd>*%$>7ZKabjYDjd(1?CTyE;N=%A-3ClO=2GNRi=L{FmR@Yn9r zM7L8w|NA@a|1bxV!>FF56G`(!Zv#a58e$Ojf8Hbs1kzX{Br%?Z0rCV(n1HDHNNYI4 Vf9bj;djChNp`M9uJ Date: Tue, 12 Jul 2022 22:56:31 +0800 Subject: [PATCH 104/179] fix: rounded dark button style --- .../InjectedComponents/DisabledPluginSuggestion.tsx | 2 +- .../mask/src/plugins/RedPacket/SNSAdaptor/RedPacketNft.tsx | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/mask/src/components/InjectedComponents/DisabledPluginSuggestion.tsx b/packages/mask/src/components/InjectedComponents/DisabledPluginSuggestion.tsx index 68a9c33a14b4..01f7a6f0c4c8 100644 --- a/packages/mask/src/components/InjectedComponents/DisabledPluginSuggestion.tsx +++ b/packages/mask/src/components/InjectedComponents/DisabledPluginSuggestion.tsx @@ -80,7 +80,7 @@ export function PossiblePluginSuggestionUI(props: { plugins: Plugin.DeferredDefi ) @@ -202,7 +222,7 @@ export function NextIdPage({ persona }: NextIdPageProps) { if (!isAccountVerified) { return ( ) @@ -250,16 +270,16 @@ export function NextIdPage({ persona }: NextIdPageProps) { href="https://mask.io/" width="22px" height="22px" - style={{ alignSelf: 'center' }}> + style={{ alignSelf: 'center', marginTop: '2px' }}>
-
+ {/*
-
+
*/} {getButton()} From 960fe8e073cee2c73f2f7fe2d3e1d60dc73af885 Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Wed, 13 Jul 2022 16:05:43 +0800 Subject: [PATCH 113/179] feat: own persona must connect at least 1 wallet --- .../src/components/InjectedComponents/ProfileTabContent.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx index 6a230558e4b8..4cd9416cd947 100644 --- a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx +++ b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx @@ -146,7 +146,10 @@ export function ProfileTabContent(props: ProfileTabContentProps) { const selectedTabId = selectedTab ?? first(tabs)?.id const showNextID = isTwitter(activatedSocialNetworkUI) && - ((isOwn && addressList?.length === 0) || isWeb3ProfileDisable || (isOwn && !isCurrentConnectedPersonaBind)) + ((isOwn && addressList?.length === 0) || + isWeb3ProfileDisable || + (isOwn && !isCurrentConnectedPersonaBind) || + (isOwn && !wallets?.length)) const componentTabId = showNextID ? displayPlugins?.find((tab) => tab?.pluginID === PluginId.NextID)?.ID : selectedTabId From 23054fa49fc49f0cc9b4e98554b49d1816f77d9d Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Fri, 15 Jul 2022 10:54:34 +0800 Subject: [PATCH 114/179] feat: move RSS3 icon to public file --- .../plugins/Pets/assets/rss3.tsx => icons/general/RSS3.tsx} | 3 ++- packages/icons/general/index.ts | 1 + packages/mask/src/plugins/Pets/SNSAdaptor/PetSetDialog.tsx | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) rename packages/{mask/src/plugins/Pets/assets/rss3.tsx => icons/general/RSS3.tsx} (99%) diff --git a/packages/mask/src/plugins/Pets/assets/rss3.tsx b/packages/icons/general/RSS3.tsx similarity index 99% rename from packages/mask/src/plugins/Pets/assets/rss3.tsx rename to packages/icons/general/RSS3.tsx index 7778f2d9a0a7..7cc221305204 100644 --- a/packages/mask/src/plugins/Pets/assets/rss3.tsx +++ b/packages/icons/general/RSS3.tsx @@ -1,4 +1,5 @@ -import { createIcon } from '@masknet/icons' +import { createIcon } from '../utils' + export const RSS3Icon = createIcon( 'RSS3Icon', diff --git a/packages/icons/general/index.ts b/packages/icons/general/index.ts index 1cb2a2dd7bc4..8b0578e1188e 100644 --- a/packages/icons/general/index.ts +++ b/packages/icons/general/index.ts @@ -142,3 +142,4 @@ export * from './ArrowDownward' export * from './PopupLink' export * from './Identity' export * from './Connect' +export * from './RSS3' diff --git a/packages/mask/src/plugins/Pets/SNSAdaptor/PetSetDialog.tsx b/packages/mask/src/plugins/Pets/SNSAdaptor/PetSetDialog.tsx index 3e9a81a7f8b1..579f9a9275d9 100644 --- a/packages/mask/src/plugins/Pets/SNSAdaptor/PetSetDialog.tsx +++ b/packages/mask/src/plugins/Pets/SNSAdaptor/PetSetDialog.tsx @@ -29,7 +29,7 @@ import { petShowSettings } from '../settings' import { ChainBoundary } from '../../../web3/UI/ChainBoundary' import { useWeb3Connection } from '@masknet/plugin-infra/web3' import { saveCustomEssayToRSS } from '../Services/rss3' -import { RSS3Icon } from '../assets/rss3' +import { RSS3Icon } from '@masknet/icons' import ActionButton from '../../../extension/options-page/DashboardComponents/ActionButton' const useStyles = makeStyles()((theme) => ({ From 37e0dc30611c9c988bbf1ddb2634dcd257c22d92 Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Fri, 15 Jul 2022 14:50:36 +0800 Subject: [PATCH 115/179] feat: delete icon default fill param --- .../Personas/components/PersonaLine/index.tsx | 2 +- packages/icons/general/ArrowDrop.tsx | 5 +-- packages/icons/general/CheckCircle.tsx | 43 +++++++++++++------ .../icons/general/NextIdPersonaVerified.tsx | 5 +-- packages/icons/general/Selected.tsx | 8 ++-- .../Personas/components/PersonaHeader/UI.tsx | 2 +- .../Wallet/components/WalletHeader/UI.tsx | 4 +- .../SNSAdaptor/trending/PriceChanged.tsx | 4 +- .../SNSAdaptor/trending/TrendingViewDeck.tsx | 2 +- .../PluginProviderRender.tsx | 1 + .../components/PluginWalletStatusBar.tsx | 2 +- 11 files changed, 44 insertions(+), 34 deletions(-) diff --git a/packages/dashboard/src/pages/Personas/components/PersonaLine/index.tsx b/packages/dashboard/src/pages/Personas/components/PersonaLine/index.tsx index 47fa67208e63..a06d9bde6ccb 100644 --- a/packages/dashboard/src/pages/Personas/components/PersonaLine/index.tsx +++ b/packages/dashboard/src/pages/Personas/components/PersonaLine/index.tsx @@ -142,7 +142,7 @@ export const ConnectedPersonaLine = memo( {proof.loading ? ( ) : isProved?.is_valid ? ( - + ) : ( )} diff --git a/packages/icons/general/ArrowDrop.tsx b/packages/icons/general/ArrowDrop.tsx index 90cf326f2671..4c9aec0d19c8 100644 --- a/packages/icons/general/ArrowDrop.tsx +++ b/packages/icons/general/ArrowDrop.tsx @@ -4,10 +4,7 @@ import type { SvgIcon } from '@mui/material' export const ArrowDropIcon: typeof SvgIcon = createIcon( 'ArrowDropIcon', - + , '0 0 24 24', ) diff --git a/packages/icons/general/CheckCircle.tsx b/packages/icons/general/CheckCircle.tsx index c59be1edf5f6..a67adae701af 100644 --- a/packages/icons/general/CheckCircle.tsx +++ b/packages/icons/general/CheckCircle.tsx @@ -4,20 +4,35 @@ import type { SvgIcon } from '@mui/material' export const CheckCircleIcon: typeof SvgIcon = createIcon( 'CheckCircleIcon', - - + + + + + + + + + + + + + + + + , '0 0 20 20', ) diff --git a/packages/icons/general/NextIdPersonaVerified.tsx b/packages/icons/general/NextIdPersonaVerified.tsx index 471d84f8416a..f8950998097c 100644 --- a/packages/icons/general/NextIdPersonaVerified.tsx +++ b/packages/icons/general/NextIdPersonaVerified.tsx @@ -4,10 +4,7 @@ import type { SvgIcon } from '@mui/material' export const NextIdPersonaVerifiedIcon: typeof SvgIcon = createIcon( 'NextIdPersonaVerified', - + + - + , - + - + (
diff --git a/packages/mask/src/extension/popups/pages/Wallet/components/WalletHeader/UI.tsx b/packages/mask/src/extension/popups/pages/Wallet/components/WalletHeader/UI.tsx index 0ced616ee3fa..a53c9bc7bbe9 100644 --- a/packages/mask/src/extension/popups/pages/Wallet/components/WalletHeader/UI.tsx +++ b/packages/mask/src/extension/popups/pages/Wallet/components/WalletHeader/UI.tsx @@ -113,7 +113,7 @@ export const WalletHeaderUI = memo( {!disabled ? ( ) : null} @@ -143,7 +143,7 @@ export const WalletHeaderUI = memo( {!disabled ? ( ) : null}
diff --git a/packages/mask/src/plugins/Trader/SNSAdaptor/trending/PriceChanged.tsx b/packages/mask/src/plugins/Trader/SNSAdaptor/trending/PriceChanged.tsx index 9e710730e5c2..1a9e14d18d14 100644 --- a/packages/mask/src/plugins/Trader/SNSAdaptor/trending/PriceChanged.tsx +++ b/packages/mask/src/plugins/Trader/SNSAdaptor/trending/PriceChanged.tsx @@ -31,8 +31,8 @@ export function PriceChanged(props: PriceChangedProps) { if (props.amount === 0) return null return ( - {props.amount > 0 ? : null} - {props.amount < 0 ? : null} + {props.amount > 0 ? : null} + {props.amount < 0 ? : null} 0 ? colors?.success : colors?.danger}> {props.amount.toFixed(2)}% diff --git a/packages/mask/src/plugins/Trader/SNSAdaptor/trending/TrendingViewDeck.tsx b/packages/mask/src/plugins/Trader/SNSAdaptor/trending/TrendingViewDeck.tsx index 3a7962684fe7..c4f039a54985 100644 --- a/packages/mask/src/plugins/Trader/SNSAdaptor/trending/TrendingViewDeck.tsx +++ b/packages/mask/src/plugins/Trader/SNSAdaptor/trending/TrendingViewDeck.tsx @@ -248,7 +248,7 @@ export function TrendingViewDeck(props: TrendingViewDeckProps) { sx={{ padding: 0 }} size="small" onClick={() => setCoinMenuOpen((v) => !v)}> - + { height: 12, background: theme.palette.background.paper, borderRadius: '50%', + fill: theme.palette.maskColor.success, }, alert: { fontSize: 12, diff --git a/packages/mask/src/utils/components/PluginWalletStatusBar.tsx b/packages/mask/src/utils/components/PluginWalletStatusBar.tsx index 69a4eb73975c..7a70dd70a7eb 100644 --- a/packages/mask/src/utils/components/PluginWalletStatusBar.tsx +++ b/packages/mask/src/utils/components/PluginWalletStatusBar.tsx @@ -198,7 +198,7 @@ export function PluginWalletStatusBar({ : domain ?? providerDescriptor?.name ?? Others?.formatAddress(account, 4)} - + {Others?.formatAddress(account, 4)} From 9f565d48d5cd43e95d24bc05c5b95bb962f20fd6 Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Fri, 15 Jul 2022 14:56:43 +0800 Subject: [PATCH 116/179] feat: change web3 tabs UI --- .../InjectedComponents/ProfileTabContent.tsx | 19 +- .../UI/components/ConcealableTabs/index.tsx | 301 +++++++++++++----- .../UI/components/ReversedAddress/index.tsx | 26 +- packages/shared/src/locales/en-US.json | 1 + 4 files changed, 255 insertions(+), 92 deletions(-) diff --git a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx index 4cd9416cd947..b6919a76d2ee 100644 --- a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx +++ b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx @@ -10,7 +10,7 @@ import { } from '@masknet/plugin-infra/content-script' import { useSocialAddressListAll, useAvailablePlugins } from '@masknet/plugin-infra/web3' import { ConcealableTabs } from '@masknet/shared' -import { CrossIsolationMessages, EMPTY_LIST, NextIDPlatform } from '@masknet/shared-base' +import { EMPTY_LIST, NextIDPlatform } from '@masknet/shared-base' import { makeStyles, useStylesExtends } from '@masknet/theme' import { Box, CircularProgress } from '@mui/material' import { activatedSocialNetworkUI } from '../../social-network' @@ -21,7 +21,6 @@ import { useCurrentVisitingIdentity, useLastRecognizedIdentity } from '../DataSo import { useNextIDBoundByPlatform } from '../DataSource/useNextID' import { usePersonaConnectStatus } from '../DataSource/usePersonaConnectStatus' import { NetworkPluginID, SocialAddressType } from '@masknet/web3-shared-base' -import { GearIcon } from '@masknet/icons' import { NextIDProof } from '@masknet/web3-providers' function getTabContent(tabId?: string) { @@ -37,11 +36,6 @@ const useStyles = makeStyles()((theme) => ({ position: 'relative', padding: theme.spacing(2, 1), }, - settingIcon: { - cursor: 'pointer', - fill: theme.palette.maskColor.main, - margin: '0 6px', - }, })) export interface ProfileTabContentProps extends withClasses<'text' | 'button' | 'root'> {} @@ -105,7 +99,7 @@ export function ProfileTabContent(props: ProfileTabContentProps) { address: proof?.identity, } }) - return [...socialAddressList, ...addresses] + return [...addresses, ...socialAddressList] }, [socialAddressList, wallets?.map((x) => x.identity).join(), isOwn]) const activatedPlugins = useActivatedPluginsSNSAdaptor('any') @@ -154,11 +148,6 @@ export function ProfileTabContent(props: ProfileTabContentProps) { ? displayPlugins?.find((tab) => tab?.pluginID === PluginId.NextID)?.ID : selectedTabId - const handleOpenDialog = () => { - CrossIsolationMessages.events.requestWeb3ProfileDialog.sendToAll({ - open: true, - }) - } const component = useMemo(() => { const Component = getTabContent(componentTabId) const Utils = displayPlugins.find((x) => x.ID === selectedTabId)?.Utils @@ -200,6 +189,8 @@ export function ProfileTabContent(props: ProfileTabContentProps) { if (hidden) return null + console.log({ identity, isOwn, addressList, personaPublicKey, personaList }) + if (!identity.identifier?.userId || loadingSocialAddressList || loadingPersonaList) return (
@@ -221,7 +212,7 @@ export function ProfileTabContent(props: ProfileTabContentProps) { tabs={tabs} selectedId={selectedTabId} onChange={setSelectedTab} - tail={isOwn && } + addressList={addressList} /> )}
diff --git a/packages/shared/src/UI/components/ConcealableTabs/index.tsx b/packages/shared/src/UI/components/ConcealableTabs/index.tsx index 405928a12ca6..07bbfb7e7b66 100644 --- a/packages/shared/src/UI/components/ConcealableTabs/index.tsx +++ b/packages/shared/src/UI/components/ConcealableTabs/index.tsx @@ -1,26 +1,40 @@ -import { LeftArrowIcon, RightArrowIcon } from '@masknet/icons' -import { makeStyles } from '@masknet/theme' -import { Button } from '@mui/material' +import { + GearIcon, + ArrowDropIcon, + LinkOutIcon, + RightArrowIcon, + RSS3Icon, + NextIdPersonaVerifiedIcon, + SelectedIcon, + LeftArrowIcon, +} from '@masknet/icons' +import { ReversedAddress } from '@masknet/shared' +import { CrossIsolationMessages } from '@masknet/shared-base' +import { makeStyles, ShadowRootMenu } from '@masknet/theme' +import { isSameAddress, NetworkPluginID, SocialAddress, SocialAddressType } from '@masknet/web3-shared-base' +import { ChainId, explorerResolver } from '@masknet/web3-shared-evm' +import { Button, Link, MenuItem, Typography } from '@mui/material' import classnames from 'classnames' -import { throttle } from 'lodash-unified' +import { first, throttle, uniqBy } from 'lodash-unified' import { HTMLProps, ReactNode, useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react' +import { useSharedI18N } from '../../../locales' const TAB_WIDTH = 126 const useStyles = makeStyles()((theme) => ({ container: { + background: + 'linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.8) 100%), linear-gradient(90deg, rgba(28, 104, 243, 0.2) 0%, rgba(69, 163, 251, 0.2) 100%), #FFFFFF;', + padding: '16px 16px 0 16px', + }, + title: { + display: 'flex', + justifyContent: 'space-between', + alignItems: 'center', + marginBottom: '16px', + }, + tabs: { display: 'flex', position: 'relative', - backgroundColor: theme.palette.background.default, - '&::after': { - content: '""', - position: 'absolute', - left: 0, - right: 0, - bottom: 0, - height: 1, - backgroundColor: theme.palette.divider, - zIndex: 0, - }, }, track: { flexGrow: 1, @@ -35,32 +49,24 @@ const useStyles = makeStyles()((theme) => ({ height: 35, minWidth: TAB_WIDTH, padding: theme.spacing(0, 2.5), - borderRadius: 0, + borderRadius: '12px 12px 0px 0px', flexShrink: 0, border: '1px solid transparent', + background: 'none', + '&:hover': { + backgroundColor: '#fff', + }, }, normal: { boxSizing: 'border-box', color: `${theme.palette.text.secondary} !important`, - backgroundColor: theme.palette.background.default, border: '1px solid transparent', - '&:hover': { - color: `${theme.palette.text.primary} !important`, - backgroundColor: theme.palette.background.default, - }, }, selected: { - color: `${theme.palette.text.primary} !important`, - backgroundColor: theme.palette.background.paper, - border: '1px solid', - borderColor: theme.palette.background.paper, - borderBottomColor: theme.palette.background.paper, - '&:hover': { - borderBottomColor: theme.palette.background.paper, - backgroundColor: theme.palette.background.paper, - }, position: 'relative', + backgroundColor: '#fff', zIndex: 10, + color: '#07101b', '&::after': { content: '""', position: 'absolute', @@ -68,7 +74,6 @@ const useStyles = makeStyles()((theme) => ({ right: 0, bottom: 0, height: 1, - backgroundColor: theme.palette.background.paper, }, }, controllers: { @@ -98,6 +103,42 @@ const useStyles = makeStyles()((theme) => ({ backgroundColor: theme.palette.background.default, }, }, + walletButton: { + padding: 0, + fontSize: '18px', + minWidth: 0, + background: 'transparent', + '&:hover': { + background: 'none', + }, + }, + settingItem: { + display: 'flex', + }, + walletItem: { + display: 'flex', + alignItems: 'center', + fontSize: 18, + fontWeight: 700, + }, + menuItem: { + display: 'flex', + alignItems: 'center', + flexGrow: 1, + justifyContent: 'space-between', + }, + addressItem: { + display: 'flex', + alignItems: 'center', + }, + link: { + cursor: 'pointer', + marginTop: 2, + zIndex: 1, + '&:hover': { + textDecoration: 'none', + }, + }, })) interface TabOption { @@ -110,6 +151,7 @@ export interface ConcealableTabsProps extends Omit, selectedId?: T onChange?(id: T): void tail?: ReactNode + addressList: Array> } export function ConcealableTabs({ @@ -118,14 +160,19 @@ export function ConcealableTabs({ selectedId, tail, onChange, + addressList, ...rest }: ConcealableTabsProps) { const { classes } = useStyles() + const t = useSharedI18N() + const [overflow, setOverflow] = useState(false) const trackRef = useRef(null) const [reachedLeftEdge, setReachedLeftEdge] = useState(false) const [reachedRightEdge, setReachedRightEdge] = useState(false) + const [anchorEl, setAnchorEl] = useState(null) + const [selectedAddress, setSelectedAddress] = useState(first(addressList)) useLayoutEffect(() => { const tabList = trackRef.current @@ -161,52 +208,162 @@ export function ConcealableTabs({ tabList.scrollTo({ left: TAB_WIDTH * (scrolled + (toLeft ? 1 : -1)), behavior: 'smooth' }) }, []) + const onClose = () => setAnchorEl(null) + + const onSelect = (option: SocialAddress) => { + setSelectedAddress(option) + onClose() + } + + const handleOpenDialog = () => { + CrossIsolationMessages.events.requestWeb3ProfileDialog.sendToAll({ + open: true, + }) + } + + const onOpen = (event: React.MouseEvent) => setAnchorEl(event.currentTarget) + return ( -
-
- {tabs.map((tab) => ( +
+
+
- ))} + setAnchorEl(null)}> + {uniqBy(addressList ?? [], (x) => x.address.toLowerCase()).map((x) => { + return ( + onSelect(x)}> +
+
+ {x?.type === SocialAddressType.KV || + x?.type === SocialAddressType.ADDRESS ? ( + + ) : ( + + {x.label} + + )} + + + + {x?.type === SocialAddressType.KV && ( + + )} +
+ {isSameAddress(selectedAddress?.address, x.address) && ( + + )} +
+
+ ) + })} +
+
+
+ + {t.powered_by()} + + + {t.rss3()} + + + +
- {overflow || tail ? ( -
- {overflow ? ( - <> - - - - ) : null} - {tail} +
+
+ {tabs.map((tab) => ( + + ))}
- ) : null} + {overflow || tail ? ( +
+ {overflow ? ( + <> + + + + ) : null} + {tail} +
+ ) : null} +
) } diff --git a/packages/shared/src/UI/components/ReversedAddress/index.tsx b/packages/shared/src/UI/components/ReversedAddress/index.tsx index 5431612c4113..51a2690752a0 100644 --- a/packages/shared/src/UI/components/ReversedAddress/index.tsx +++ b/packages/shared/src/UI/components/ReversedAddress/index.tsx @@ -1,19 +1,33 @@ import { memo } from 'react' import type { NetworkPluginID } from '@masknet/web3-shared-base' import { useReverseAddress, useWeb3State } from '@masknet/plugin-infra/web3' +import { Typography } from '@mui/material' export interface ReverseAddressProps { address: string pluginId?: NetworkPluginID domainSize?: number size?: number + fontSize?: string + fontWeight?: number } -export const ReversedAddress = memo(({ address, pluginId, domainSize, size = 5 }) => { - const { value: domain } = useReverseAddress(pluginId, address) - const { Others } = useWeb3State(pluginId) +export const ReversedAddress = memo( + ({ address, pluginId, domainSize, size = 5, fontSize = '14px', fontWeight = 700 }) => { + const { value: domain } = useReverseAddress(pluginId, address) + const { Others } = useWeb3State(pluginId) - if (!domain || !Others?.formatDomainName) return <>{Others?.formatAddress?.(address, size) ?? address} + if (!domain || !Others?.formatDomainName) + return ( + + {Others?.formatAddress?.(address, size) ?? address} + + ) - return <>{Others.formatDomainName(domain, domainSize)} -}) + return ( + + {Others.formatDomainName(domain, domainSize)} + + ) + }, +) diff --git a/packages/shared/src/locales/en-US.json b/packages/shared/src/locales/en-US.json index dff481cfe823..9085edfa5f2a 100644 --- a/packages/shared/src/locales/en-US.json +++ b/packages/shared/src/locales/en-US.json @@ -32,6 +32,7 @@ "load_retry": "Reload", "powered_by": "Powered by", "go_plus": "GO+", + "rss3": "RSS3", "high_risk": "High Risk", "low_risk": "Low Risk", "medium_risk": "Medium Risk", From a6932333d5ded24a05fe9c7f3a236a227b805c22 Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Fri, 15 Jul 2022 15:45:09 +0800 Subject: [PATCH 117/179] feat: change icon --- packages/icons/general/CheckCircle.tsx | 43 ++++++------------- packages/icons/general/RSS3.tsx | 8 +--- .../UI/components/ConcealableTabs/index.tsx | 29 ++++++++----- 3 files changed, 35 insertions(+), 45 deletions(-) diff --git a/packages/icons/general/CheckCircle.tsx b/packages/icons/general/CheckCircle.tsx index a67adae701af..c59be1edf5f6 100644 --- a/packages/icons/general/CheckCircle.tsx +++ b/packages/icons/general/CheckCircle.tsx @@ -4,35 +4,20 @@ import type { SvgIcon } from '@mui/material' export const CheckCircleIcon: typeof SvgIcon = createIcon( 'CheckCircleIcon', - - - - - - - - - - - - - - - - + + , '0 0 20 20', ) diff --git a/packages/icons/general/RSS3.tsx b/packages/icons/general/RSS3.tsx index 7cc221305204..22540627fedd 100644 --- a/packages/icons/general/RSS3.tsx +++ b/packages/icons/general/RSS3.tsx @@ -3,12 +3,8 @@ import { createIcon } from '../utils' export const RSS3Icon = createIcon( 'RSS3Icon', - - - - - - + + , '0 0 24 24', ) diff --git a/packages/shared/src/UI/components/ConcealableTabs/index.tsx b/packages/shared/src/UI/components/ConcealableTabs/index.tsx index 07bbfb7e7b66..abd1d0f17cc6 100644 --- a/packages/shared/src/UI/components/ConcealableTabs/index.tsx +++ b/packages/shared/src/UI/components/ConcealableTabs/index.tsx @@ -54,19 +54,19 @@ const useStyles = makeStyles()((theme) => ({ border: '1px solid transparent', background: 'none', '&:hover': { - backgroundColor: '#fff', + backgroundColor: theme.palette.maskColor.bottom, }, }, normal: { boxSizing: 'border-box', - color: `${theme.palette.text.secondary} !important`, + color: theme.palette.maskColor.secondaryDark, border: '1px solid transparent', }, selected: { position: 'relative', - backgroundColor: '#fff', + backgroundColor: theme.palette.maskColor.bottom, zIndex: 10, - color: '#07101b', + color: theme.palette.maskColor.main, '&::after': { content: '""', position: 'absolute', @@ -114,6 +114,7 @@ const useStyles = makeStyles()((theme) => ({ }, settingItem: { display: 'flex', + alignItems: 'center', }, walletItem: { display: 'flex', @@ -139,6 +140,11 @@ const useStyles = makeStyles()((theme) => ({ textDecoration: 'none', }, }, + linkIcon: { + fill: theme.palette.maskColor.second, + fontSize: '20px', + margin: '4px 2px 0 2px', + }, })) interface TabOption { @@ -233,7 +239,7 @@ export function ConcealableTabs({ size="small" onClick={onOpen} className={classes.walletButton}> - + {selectedAddress?.type === SocialAddressType.KV || selectedAddress?.type === SocialAddressType.ADDRESS ? ( ({ setAnchorEl(null)}> {uniqBy(addressList ?? [], (x) => x.address.toLowerCase()).map((x) => { @@ -290,9 +301,7 @@ export function ConcealableTabs({ } target="_blank" rel="noopener noreferrer"> - + {x?.type === SocialAddressType.KV && ( @@ -314,7 +323,7 @@ export function ConcealableTabs({ {t.rss3()} - +
From 932991b013e7b795952f22c74bb6ceec8de57c7d Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Fri, 15 Jul 2022 16:26:27 +0800 Subject: [PATCH 118/179] feat: add description for some web3 status --- .../InjectedComponents/ProfileTabContent.tsx | 3 +- .../plugins/NextID/components/NextIdPage.tsx | 31 +++++++++++++------ .../src/plugins/NextID/locales/en-US.json | 5 ++- packages/web3-providers/src/types.ts | 1 + 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx index 81ba4802d72c..462ec0cdb8e9 100644 --- a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx +++ b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx @@ -143,7 +143,8 @@ export function ProfileTabContent(props: ProfileTabContentProps) { ((isOwn && addressList?.length === 0) || isWeb3ProfileDisable || (isOwn && !isCurrentConnectedPersonaBind) || - (isOwn && !wallets?.length)) + (isOwn && !wallets?.length) || + !addressList?.length) const componentTabId = showNextID ? displayPlugins?.find((tab) => tab?.pluginID === PluginId.NextID)?.ID : selectedTabId diff --git a/packages/mask/src/plugins/NextID/components/NextIdPage.tsx b/packages/mask/src/plugins/NextID/components/NextIdPage.tsx index d4373b2e75a3..38bd7f7137e6 100644 --- a/packages/mask/src/plugins/NextID/components/NextIdPage.tsx +++ b/packages/mask/src/plugins/NextID/components/NextIdPage.tsx @@ -126,6 +126,13 @@ const useStyles = makeStyles()((theme) => ({ backgroundColor: '#07101b', }, }, + content: { + display: 'flex', + justifyContent: 'center', + alignItems: 'center', + fontSize: '14px', + fontWeight: 400, + }, })) interface NextIdPageProps { @@ -135,6 +142,8 @@ interface NextIdPageProps { export function NextIdPage({ persona }: NextIdPageProps) { const t = useI18N() const { classes } = useStyles() + + const [description, setDescription] = useState('') const currentProfileIdentifier = useLastRecognizedIdentity() const visitingPersonaIdentifier = useCurrentVisitingIdentity() const personaConnectStatus = usePersonaConnectStatus() @@ -148,6 +157,7 @@ export function NextIdPage({ persona }: NextIdPageProps) { const personaActionButton = useMemo(() => { if (!personaConnectStatus.action) return null const button = personaConnectStatus.hasPersona ? t.connect_persona() : t.create_persona() + setDescription(personaConnectStatus.hasPersona ? '' : t.create_persona_intro()) const icon = personaConnectStatus.hasPersona ? ( ) : ( @@ -207,7 +217,11 @@ export function NextIdPage({ persona }: NextIdPageProps) { }) } - const getButton = () => { + const getButton = useMemo(() => { + if (!isOwn) { + setDescription(t.others_lack_wallet()) + return + } if (isWeb3ProfileDisable) { return ( ) } + setDescription(t.add_wallet_intro()) return ( ) - } + }, [isWeb3ProfileDisable, personaActionButton, isOwn, isAccountVerified, t]) if (loadingBindings || loadingPersona || loadingVerifyInfo) { return ( @@ -275,13 +290,9 @@ export function NextIdPage({ persona }: NextIdPageProps) {
- {/*
-
-
-
-
*/} - - {getButton()} + {description} + + {getButton} {openBindDialog && currentPersona && isOwn && ( diff --git a/packages/mask/src/plugins/NextID/locales/en-US.json b/packages/mask/src/plugins/NextID/locales/en-US.json index 4e20f01487e9..07af9078bb34 100644 --- a/packages/mask/src/plugins/NextID/locales/en-US.json +++ b/packages/mask/src/plugins/NextID/locales/en-US.json @@ -54,5 +54,8 @@ "send_specific_tip_successfully": "Sent {{amount}} {{name}} tip successfully.", "search": "Search", "web3_profile": "Web3 Profile", - "mask_network": "Mask Network" + "mask_network": "Mask Network", + "create_persona_intro": "Please create your persona to use Web3 Profile.", + "add_wallet_intro": "In the Web3 tab, you can show your wallet addresses for NFT collections, donation records, and other on-chain feeds to friends who have also installed the Mask extension.", + "others_lack_wallet": "The user has not set this." } diff --git a/packages/web3-providers/src/types.ts b/packages/web3-providers/src/types.ts index 00fe55fcdd58..91d3a7d596ac 100644 --- a/packages/web3-providers/src/types.ts +++ b/packages/web3-providers/src/types.ts @@ -137,6 +137,7 @@ export namespace RSS3BaseAPI { export interface Web3Feed { attachments?: Attachments[] authors: string[] + /* cspell:disable-next-line */ backlinks: string date_created: string date_updated: string From 194aa53fa2af72affa816768e2923c4f85155fe1 Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Fri, 15 Jul 2022 17:36:55 +0800 Subject: [PATCH 119/179] feat: delete useless code --- .../InjectedComponents/ProfileTabContent.tsx | 36 ++--- .../CollectibleList/index.tsx | 56 +------- .../Collectible/SNSAdaptor/NFTPage.tsx | 88 +----------- .../plugins/Collectible/SNSAdaptor/index.tsx | 3 - packages/plugin-infra/src/types.ts | 4 +- .../plugins/RSS3/src/SNSAdaptor/TabCard.tsx | 130 +++--------------- .../plugins/RSS3/src/SNSAdaptor/index.tsx | 26 +--- .../UI/components/ConcealableTabs/index.tsx | 9 +- 8 files changed, 57 insertions(+), 295 deletions(-) diff --git a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx index 462ec0cdb8e9..c3098eeffedd 100644 --- a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx +++ b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx @@ -15,12 +15,12 @@ import { makeStyles, useStylesExtends } from '@masknet/theme' import { Box, CircularProgress } from '@mui/material' import { activatedSocialNetworkUI } from '../../social-network' import { isTwitter } from '../../social-network-adaptor/twitter.com/base' -import { MaskMessages, sortPersonaBindings, useI18N } from '../../utils' +import { MaskMessages, sortPersonaBindings } from '../../utils' import { useLocationChange } from '../../utils/hooks/useLocationChange' import { useCurrentVisitingIdentity, useLastRecognizedIdentity } from '../DataSource/useActivatedUI' import { useNextIDBoundByPlatform } from '../DataSource/useNextID' import { usePersonaConnectStatus } from '../DataSource/usePersonaConnectStatus' -import { NetworkPluginID, SocialAddressType } from '@masknet/web3-shared-base' +import { NetworkPluginID, SocialAddressType, SocialAddress } from '@masknet/web3-shared-base' import { NextIDProof } from '@masknet/web3-providers' function getTabContent(tabId?: string) { @@ -43,11 +43,11 @@ export interface ProfileTabContentProps extends withClasses<'text' | 'button' | export function ProfileTabContent(props: ProfileTabContentProps) { const classes = useStylesExtends(useStyles(), props) - const { t } = useI18N() const translate = usePluginI18NField() const [hidden, setHidden] = useState(true) const [selectedTab, setSelectedTab] = useState() + const [selectedAddress, setSelectedAddress] = useState | undefined>() const currentIdentity = useLastRecognizedIdentity() const identity = useCurrentVisitingIdentity() @@ -89,6 +89,7 @@ export function ProfileTabContent(props: ProfileTabContentProps) { const addressList = useMemo(() => { if (!wallets?.length || (!isOwn && socialAddressList?.length)) { + setSelectedAddress(first(socialAddressList)) return socialAddressList } const addresses = wallets.map((proof) => { @@ -99,7 +100,9 @@ export function ProfileTabContent(props: ProfileTabContentProps) { address: proof?.identity, } }) - return [...addresses, ...socialAddressList] + const addressList = [...addresses, ...socialAddressList] + setSelectedAddress(first(addressList)) + return addressList }, [socialAddressList, wallets?.map((x) => x.identity).join(), isOwn]) const activatedPlugins = useActivatedPluginsSNSAdaptor('any') @@ -108,8 +111,8 @@ export function ProfileTabContent(props: ProfileTabContentProps) { const displayPlugins = useMemo(() => { return availablePlugins .flatMap((x) => x.ProfileTabs?.map((y) => ({ ...y, pluginID: x.ID })) ?? EMPTY_LIST) - .filter((z) => z.Utils?.shouldDisplay?.(identity, addressList) ?? true) - }, [identity, availablePlugins.map((x) => x.ID).join(), addressList.map((x) => x.address).join()]) + .filter((z) => z.Utils?.shouldDisplay?.(identity, selectedAddress) ?? true) + }, [identity, availablePlugins.map((x) => x.ID).join(), selectedAddress]) const tabs = displayPlugins .sort((a, z) => { @@ -151,22 +154,9 @@ export function ProfileTabContent(props: ProfileTabContentProps) { const component = useMemo(() => { const Component = getTabContent(componentTabId) - const Utils = displayPlugins.find((x) => x.ID === selectedTabId)?.Utils - return ( - Utils?.filter?.(x) ?? true).sort(Utils?.sorter)} - /> - ) - }, [ - componentTabId, - personaPublicKey, - displayPlugins.map((x) => x.ID).join(), - personaList.join(), - addressList.map((x) => x.address).join(), - ]) + return + }, [componentTabId, personaPublicKey, selectedAddress]) useLocationChange(() => { setSelectedTab(undefined) @@ -190,7 +180,7 @@ export function ProfileTabContent(props: ProfileTabContentProps) { if (hidden) return null - console.log({ identity, isOwn, addressList, personaPublicKey, personaList }) + console.log({ identity, isOwn, addressList, personaPublicKey, personaList, selectedAddress }) if (!identity.identifier?.userId || loadingSocialAddressList || loadingPersonaList) return ( @@ -214,6 +204,8 @@ export function ProfileTabContent(props: ProfileTabContentProps) { selectedId={selectedTabId} onChange={setSelectedTab} addressList={addressList} + selectedAddress={selectedAddress} + onSelectAddress={setSelectedAddress} /> )}
diff --git a/packages/mask/src/extension/options-page/DashboardComponents/CollectibleList/index.tsx b/packages/mask/src/extension/options-page/DashboardComponents/CollectibleList/index.tsx index c0bb46d8e819..15b47776fb45 100644 --- a/packages/mask/src/extension/options-page/DashboardComponents/CollectibleList/index.tsx +++ b/packages/mask/src/extension/options-page/DashboardComponents/CollectibleList/index.tsx @@ -5,7 +5,6 @@ import { NonFungibleAsset, NonFungibleTokenCollection, SocialAddress, - SocialAddressType, SourceType, Wallet, } from '@masknet/web3-shared-base' @@ -15,8 +14,7 @@ import { CollectibleCard } from './CollectibleCard' import { useI18N } from '../../../../utils' import { CollectionIcon } from './CollectionIcon' import { uniqBy } from 'lodash-unified' -import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown' -import { ElementAnchor, RetryHint, ReversedAddress } from '@masknet/shared' +import { ElementAnchor, RetryHint } from '@masknet/shared' import { EMPTY_LIST } from '@masknet/shared-base' import { LoadingSkeleton } from './LoadingSkeleton' import { useNonFungibleAssets, useTrustedNonFungibleTokens, Web3Helper } from '@masknet/plugin-infra/web3' @@ -222,12 +220,10 @@ export function CollectibleList(props: CollectibleListProps) { export function CollectionList({ addressName, - onSelectAddress, persona, visitingProfile, }: { addressName: SocialAddress - onSelectAddress: (event: React.MouseEvent) => void persona?: string visitingProfile?: IdentityResolved }) { @@ -291,55 +287,15 @@ export function CollectionList({ if ((done && !allCollectibles.length) || !account) return ( - <> - {addressName && ( - - - - - - )} - - - {t('dashboard_no_collectible_found')} - - - + + + {t('dashboard_no_collectible_found')} + + ) return ( - - - - - - diff --git a/packages/mask/src/plugins/Collectible/SNSAdaptor/NFTPage.tsx b/packages/mask/src/plugins/Collectible/SNSAdaptor/NFTPage.tsx index 905141d5f620..5082937311d0 100644 --- a/packages/mask/src/plugins/Collectible/SNSAdaptor/NFTPage.tsx +++ b/packages/mask/src/plugins/Collectible/SNSAdaptor/NFTPage.tsx @@ -1,95 +1,17 @@ -import { useState } from 'react' -import { first, uniqBy } from 'lodash-unified' -import { ReversedAddress } from '@masknet/shared' -import { getMaskColor, makeStyles, ShadowRootMenu } from '@masknet/theme' -import { MenuItem } from '@mui/material' -import { SocialAddress, NetworkPluginID, SocialIdentity, SocialAddressType } from '@masknet/web3-shared-base' +import type { SocialAddress, NetworkPluginID, SocialIdentity } from '@masknet/web3-shared-base' import { CollectionList } from '../../../extension/options-page/DashboardComponents/CollectibleList' -import { EMPTY_LIST } from '@masknet/shared-base' import { useCurrentVisitingProfile } from '../hooks/useContext' -const useStyles = makeStyles()((theme) => ({ - root: { - position: 'relative', - }, - text: { - paddingTop: 36, - paddingBottom: 36, - '& > p': { - color: getMaskColor(theme).textPrimary, - }, - }, - note: { - padding: `0 ${theme.spacing(1)}`, - textAlign: 'right', - }, - icon: { - color: getMaskColor(theme).textPrimary, - }, - iconContainer: { - display: 'inherit', - }, - tipList: { - listStyleType: 'decimal', - paddingLeft: 16, - }, - button: { - border: `1px solid ${theme.palette.text.primary} !important`, - color: `${theme.palette.text.primary} !important`, - borderRadius: 9999, - background: 'transparent', - '&:hover': { - background: 'rgba(15, 20, 25, 0.1)', - }, - }, -})) - export interface NFTPageProps { persona?: string identity?: SocialIdentity - socialAddressList?: Array> + socialAddress?: SocialAddress } -export function NFTPage({ socialAddressList, persona }: NFTPageProps) { - const { classes } = useStyles() - const [anchorEl, setAnchorEl] = useState(null) - - const [selectedAddress, setSelectedAddress] = useState(first(socialAddressList)) - const onOpen = (event: React.MouseEvent) => setAnchorEl(event.currentTarget) - const onClose = () => setAnchorEl(null) - const onSelect = (option: SocialAddress) => { - setSelectedAddress(option) - onClose() - } +export function NFTPage({ socialAddress, persona }: NFTPageProps) { const currentVisitingProfile = useCurrentVisitingProfile() - if (!selectedAddress) return null + if (!socialAddress) return null - return ( -
- - {uniqBy(socialAddressList ?? EMPTY_LIST, (x) => x.address.toLowerCase()).map((x) => { - return ( - onSelect(x)}> - {x.type === SocialAddressType.ADDRESS || x.type === SocialAddressType.KV ? ( - - ) : ( - x.label - )} - - ) - })} - - -
- ) + return } diff --git a/packages/mask/src/plugins/Collectible/SNSAdaptor/index.tsx b/packages/mask/src/plugins/Collectible/SNSAdaptor/index.tsx index e2bcc6c39153..c18e6f378c91 100644 --- a/packages/mask/src/plugins/Collectible/SNSAdaptor/index.tsx +++ b/packages/mask/src/plugins/Collectible/SNSAdaptor/index.tsx @@ -40,9 +40,6 @@ const sns: Plugin.SNSAdaptor.Definition = { TabContent: NFTPage, }, Utils: { - shouldDisplay: (identity, socialAddressList) => { - return !!socialAddressList?.length - }, sorter: (a, z) => { if (a.type === SocialAddressType.ENS) return -1 if (z.type === SocialAddressType.ENS) return 1 diff --git a/packages/plugin-infra/src/types.ts b/packages/plugin-infra/src/types.ts index de1241da56ee..a8d0a053e33b 100644 --- a/packages/plugin-infra/src/types.ts +++ b/packages/plugin-infra/src/types.ts @@ -593,14 +593,14 @@ export namespace Plugin.SNSAdaptor { TabContent: InjectUI<{ identity?: SocialIdentity persona?: string - socialAddressList?: Array> + socialAddress?: SocialAddress }> } Utils?: { /** * If it returns false, this tab will not be displayed. */ - shouldDisplay?(identity?: SocialIdentity, addressNames?: Array>): boolean + shouldDisplay?(identity?: SocialIdentity, addressName?: SocialAddress): boolean /** * Filter social address. */ diff --git a/packages/plugins/RSS3/src/SNSAdaptor/TabCard.tsx b/packages/plugins/RSS3/src/SNSAdaptor/TabCard.tsx index 888796c26d09..e625daf4bd1f 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/TabCard.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/TabCard.tsx @@ -1,31 +1,12 @@ -import { ReversedAddress } from '@masknet/shared' import { EMPTY_LIST } from '@masknet/shared-base' -import { makeStyles, ShadowRootMenu } from '@masknet/theme' -import { NetworkPluginID, SocialAddress, SocialAddressType } from '@masknet/web3-shared-base' +import type { NetworkPluginID, SocialAddress } from '@masknet/web3-shared-base' import { formatEthereumAddress, ZERO_ADDRESS } from '@masknet/web3-shared-evm' -import { Button, MenuItem, Typography } from '@mui/material' -import { first, uniqBy } from 'lodash-unified' -import { useState } from 'react' -import { useI18N } from '../locales' import { useCollectionFilter, useDonations, useFootprints } from './hooks' import { DonationPage, FootprintPage } from './pages' -import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown' import { useCurrentVisitingProfile } from './hooks/useContext' import { CollectionType, KVType } from '../types' import { useKV } from './hooks/useKV' -const useStyles = makeStyles()((theme) => ({ - button: { - border: `1px solid ${theme.palette.text.primary} !important`, - color: `${theme.palette.text.primary} !important`, - borderRadius: 4, - background: 'transparent', - '&:hover': { - background: 'rgba(15, 20, 25, 0.1)', - }, - }, -})) - export enum TabCardType { Donation = 1, Footprint = 2, @@ -34,30 +15,17 @@ export enum TabCardType { export interface TabCardProps { persona?: string type: TabCardType - socialAddressList?: Array> + socialAddress?: SocialAddress } -export function TabCard({ type, socialAddressList, persona }: TabCardProps) { - const t = useI18N() - const { classes } = useStyles() - - const [selectedAddress, setSelectedAddress] = useState(first(socialAddressList)) - +export function TabCard({ type, socialAddress, persona }: TabCardProps) { const { value: donations = EMPTY_LIST, loading: loadingDonations } = useDonations( - formatEthereumAddress(selectedAddress?.address ?? ZERO_ADDRESS), + formatEthereumAddress(socialAddress?.address ?? ZERO_ADDRESS), ) const { value: footprints = EMPTY_LIST, loading: loadingFootprints } = useFootprints( - formatEthereumAddress(selectedAddress?.address ?? ZERO_ADDRESS), + formatEthereumAddress(socialAddress?.address ?? ZERO_ADDRESS), ) const currentVisitingProfile = useCurrentVisitingProfile() - const [anchorEl, setAnchorEl] = useState(null) - - const onOpen = (event: React.MouseEvent) => setAnchorEl(event.currentTarget) - const onClose = () => setAnchorEl(null) - const onSelect = (option: SocialAddress) => { - setSelectedAddress(option) - onClose() - } const { value: kvValue } = useKV(persona) const unHiddenDonations = useCollectionFilter( @@ -65,92 +33,28 @@ export function TabCard({ type, socialAddressList, persona }: TabCardProps) { donations, CollectionType.Donations, currentVisitingProfile, - selectedAddress, + socialAddress, ) const unHiddenFootprints = useCollectionFilter( (kvValue as KVType)?.proofs, footprints, CollectionType.Footprints, currentVisitingProfile, - selectedAddress, + socialAddress, ) - if (!selectedAddress) return null + if (!socialAddress) return null const isDonation = type === TabCardType.Donation - const summary = - isDonation && !loadingDonations ? ( - - {t.total_grants({ - count: donations.length.toString(), - })} - - ) : null - - return ( - <> - -
-
{summary}
-
- - setAnchorEl(null)}> - {uniqBy(socialAddressList ?? [], (x) => x.address.toLowerCase()).map((x) => { - return ( - onSelect(x)}> - {x?.type === SocialAddressType.KV || x?.type === SocialAddressType.ADDRESS ? ( - - ) : ( - x.label - )} - - ) - })} - -
-
- {isDonation ? ( - - ) : ( - - )} - + return isDonation ? ( + + ) : ( + ) } diff --git a/packages/plugins/RSS3/src/SNSAdaptor/index.tsx b/packages/plugins/RSS3/src/SNSAdaptor/index.tsx index 1d3e40b7a429..bb5b20b125d6 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/index.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/index.tsx @@ -1,18 +1,12 @@ import type { Plugin } from '@masknet/plugin-infra' -import { NetworkPluginID, SocialAddress, SocialAddressType, SocialIdentity } from '@masknet/web3-shared-base' +import { NetworkPluginID, SocialAddress, SocialIdentity } from '@masknet/web3-shared-base' import { base } from '../base' import { PLUGIN_ID } from '../constants' import { setupContext } from './context' import { TabCard, TabCardType } from './TabCard' -function sorter(a: SocialAddress, z: SocialAddress) { - if (a.type === SocialAddressType.RSS3) return -1 - if (z.type === SocialAddressType.RSS3) return 1 - return 0 -} - -function shouldDisplay(identity?: SocialIdentity, addressNames?: Array>) { - return !!addressNames?.some((x) => x.networkSupporterPluginID === NetworkPluginID.PLUGIN_EVM) +function shouldDisplay(identity?: SocialIdentity, addressName?: SocialAddress) { + return addressName?.networkSupporterPluginID === NetworkPluginID.PLUGIN_EVM } const sns: Plugin.SNSAdaptor.Definition = { @@ -26,14 +20,11 @@ const sns: Plugin.SNSAdaptor.Definition = { label: 'Donations', priority: 1, UI: { - TabContent: ({ socialAddressList = [], persona }) => { - return ( - - ) + TabContent: ({ socialAddress, persona }) => { + return }, }, Utils: { - sorter, shouldDisplay, }, }, @@ -42,14 +33,11 @@ const sns: Plugin.SNSAdaptor.Definition = { label: 'Footprints', priority: 2, UI: { - TabContent: ({ socialAddressList = [], persona }) => { - return ( - - ) + TabContent: ({ socialAddress, persona }) => { + return }, }, Utils: { - sorter, shouldDisplay, }, }, diff --git a/packages/shared/src/UI/components/ConcealableTabs/index.tsx b/packages/shared/src/UI/components/ConcealableTabs/index.tsx index abd1d0f17cc6..68ce6172b444 100644 --- a/packages/shared/src/UI/components/ConcealableTabs/index.tsx +++ b/packages/shared/src/UI/components/ConcealableTabs/index.tsx @@ -15,7 +15,7 @@ import { isSameAddress, NetworkPluginID, SocialAddress, SocialAddressType } from import { ChainId, explorerResolver } from '@masknet/web3-shared-evm' import { Button, Link, MenuItem, Typography } from '@mui/material' import classnames from 'classnames' -import { first, throttle, uniqBy } from 'lodash-unified' +import { throttle, uniqBy } from 'lodash-unified' import { HTMLProps, ReactNode, useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react' import { useSharedI18N } from '../../../locales' @@ -158,6 +158,8 @@ export interface ConcealableTabsProps extends Omit, onChange?(id: T): void tail?: ReactNode addressList: Array> + selectedAddress?: SocialAddress + onSelectAddress: (address: SocialAddress) => void } export function ConcealableTabs({ @@ -167,6 +169,8 @@ export function ConcealableTabs({ tail, onChange, addressList, + selectedAddress, + onSelectAddress, ...rest }: ConcealableTabsProps) { const { classes } = useStyles() @@ -178,7 +182,6 @@ export function ConcealableTabs({ const [reachedLeftEdge, setReachedLeftEdge] = useState(false) const [reachedRightEdge, setReachedRightEdge] = useState(false) const [anchorEl, setAnchorEl] = useState(null) - const [selectedAddress, setSelectedAddress] = useState(first(addressList)) useLayoutEffect(() => { const tabList = trackRef.current @@ -217,7 +220,7 @@ export function ConcealableTabs({ const onClose = () => setAnchorEl(null) const onSelect = (option: SocialAddress) => { - setSelectedAddress(option) + onSelectAddress(option) onClose() } From 98159eeb631e920a79c0538e20108d9dea053dfb Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Mon, 18 Jul 2022 19:01:14 +0800 Subject: [PATCH 120/179] feat: change poap ui --- .../CollectibleList/CollectibleCard.tsx | 2 +- .../CollectibleList/index.tsx | 8 ++- .../SNSAdaptor/components/DonationCard.tsx | 61 +++++++++--------- .../SNSAdaptor/components/FootprintCard.tsx | 62 ++++++++++++------- .../src/SNSAdaptor/pages/DonationsPage.tsx | 11 +--- .../src/SNSAdaptor/pages/FootprintPage.tsx | 12 +--- 6 files changed, 79 insertions(+), 77 deletions(-) diff --git a/packages/mask/src/extension/options-page/DashboardComponents/CollectibleList/CollectibleCard.tsx b/packages/mask/src/extension/options-page/DashboardComponents/CollectibleList/CollectibleCard.tsx index acaf58fd4f7d..7ca1fe186398 100644 --- a/packages/mask/src/extension/options-page/DashboardComponents/CollectibleList/CollectibleCard.tsx +++ b/packages/mask/src/extension/options-page/DashboardComponents/CollectibleList/CollectibleCard.tsx @@ -10,7 +10,7 @@ const useStyles = makeStyles()((theme) => ({ display: 'flex', alignItems: 'center', justifyContent: 'center', - borderRadius: 4, + borderRadius: '8px 8px 0 0', position: 'absolute', zIndex: 1, backgroundColor: theme.palette.mode === 'light' ? '#F7F9FA' : '#2F3336', diff --git a/packages/mask/src/extension/options-page/DashboardComponents/CollectibleList/index.tsx b/packages/mask/src/extension/options-page/DashboardComponents/CollectibleList/index.tsx index 15b47776fb45..a5385fd606ff 100644 --- a/packages/mask/src/extension/options-page/DashboardComponents/CollectibleList/index.tsx +++ b/packages/mask/src/extension/options-page/DashboardComponents/CollectibleList/index.tsx @@ -72,6 +72,7 @@ const useStyles = makeStyles()((theme) => ({ description: { background: theme.palette.mode === 'light' ? '#F7F9FA' : '#2F3336', alignSelf: 'stretch', + borderRadius: '0 0 8px 8px', }, name: { whiteSpace: 'nowrap', @@ -360,7 +361,12 @@ export function CollectionList({ key={i} alignItems="center" justifyContent="center" - sx={{ marginTop: '8px', marginBottom: '12px', minWidth: 30, maxHeight: 24 }}> + sx={{ + marginTop: '8px', + marginBottom: '12px', + minWidth: 30, + maxHeight: 24, + }}> { - imageUrl: string - name: string - contribCount: number - contribDetails: Array<{ - token: string - amount: string - }> + donation: GeneralAsset } const useStyles = makeStyles()((theme) => ({ @@ -20,14 +16,14 @@ const useStyles = makeStyles()((theme) => ({ display: 'flex', flexDirection: 'row', backgroundColor: MaskColorVar.twitterBg, - padding: theme.spacing(1), flexGrow: 1, alignItems: 'stretch', + padding: 3, }, cover: { flexShrink: 1, - height: 90, - width: 90, + height: 126, + width: 126, borderRadius: 8, objectFit: 'cover', }, @@ -40,7 +36,7 @@ const useStyles = makeStyles()((theme) => ({ }, info: { flexGrow: 1, - marginLeft: theme.spacing(1), + marginLeft: '12px', fontSize: 16, display: 'flex', overflow: 'hidden', @@ -61,43 +57,42 @@ const useStyles = makeStyles()((theme) => ({ }, })) -export const DonationCard = ({ - imageUrl, - name, - contribCount, - contribDetails, - className, - ...rest -}: DonationCardProps) => { +export const DonationCard = ({ donation, className, ...rest }: DonationCardProps) => { const { classes } = useStyles() const t = useI18N() return (
- {name} -
-
+ {donation.info.title +
+
- {name} + title={donation.info.title || t.inactive_project()}> + {donation.info.title || t.inactive_project()} -
-
- {contribCount} - {t.contribution({ count: contribCount })} -
-
- {contribDetails.map((contrib, i) => ( +
+
+ {donation.info.total_contribs || 0} + + {t.contribution({ count: donation.info.total_contribs || 0 })} + +
+
+ {(donation.info.token_contribs || []).map((contrib, i) => ( {contrib.amount} {contrib.token} ))} - - +
+
) } diff --git a/packages/plugins/RSS3/src/SNSAdaptor/components/FootprintCard.tsx b/packages/plugins/RSS3/src/SNSAdaptor/components/FootprintCard.tsx index 98a6f16245fc..9feeb591984d 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/components/FootprintCard.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/components/FootprintCard.tsx @@ -1,55 +1,73 @@ import { Typography } from '@mui/material' -import EventRoundedIcon from '@mui/icons-material/EventRounded' -import LocationOnRoundedIcon from '@mui/icons-material/LocationOnRounded' import fromUnixTime from 'date-fns/fromUnixTime' -import { ImageHolder } from './ImageHolder' +import { makeStyles } from '@masknet/theme' import { useI18N } from '../../locales' +import { RSS3_DEFAULT_IMAGE } from '../../constants' +import type { GeneralAsset } from '../../types' + +const useStyles = makeStyles()((theme) => ({ + card: { + display: 'flex', + padding: 3, + marginBottom: 16, + }, + cover: { + flexShrink: 1, + height: 126, + width: 126, + borderRadius: 8, + objectFit: 'cover', + }, + content: { + marginLeft: 12, + marginTop: 12, + }, +})) const formatDate = (ts: string): string => { return fromUnixTime(Number.parseInt(ts, 16)).toLocaleDateString('en-US') } export interface FootprintProps { - imageUrl: string - startDate: string | undefined - endDate: string | undefined - city: string | undefined - country: string | undefined username: string - activity: string + footprint: GeneralAsset } -export const FootprintCard = ({ imageUrl, startDate, endDate, city, country, activity }: FootprintProps) => { +export const FootprintCard = ({ footprint }: FootprintProps) => { const t = useI18N() + const { classes } = useStyles() + // Calc display date let displayDate: string - if (startDate && endDate) { - displayDate = formatDate(startDate) - if (endDate !== startDate) { - displayDate += ` ~ ${formatDate(endDate)}` + if (footprint.info.start_date && footprint.info.end_date) { + displayDate = formatDate(footprint.info.start_date) + if (footprint.info.start_date !== footprint.info.end_date) { + displayDate += ` ~ ${formatDate(footprint.info.end_date)}` } } else { displayDate = t.no_activity_time() } // Calc location - const location = city || country || 'Metaverse' + const location = footprint.info.city || footprint.info.country || 'Metaverse' return ( -
+
- + {t.inactive_project()}
-
+
- {displayDate}
- - {location} + @ {location}
@@ -57,7 +75,7 @@ export const FootprintCard = ({ imageUrl, startDate, endDate, city, country, act {t.attended()} - {activity} + {footprint.info.title || ''}
diff --git a/packages/plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx b/packages/plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx index 4ac47ed9d81e..b45c971db28f 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx @@ -1,7 +1,6 @@ import { makeStyles } from '@masknet/theme' import { List, ListItem } from '@mui/material' import urlcat from 'urlcat' -import { RSS3_DEFAULT_IMAGE } from '../../constants' import { useI18N } from '../../locales' import type { GeneralAsset, GeneralAssetWithTags } from '../../types' import { DonationCard, StatusBox } from '../components' @@ -25,7 +24,7 @@ const useStyles = makeStyles()((theme) => ({ }, list: { display: 'grid', - gridTemplateColumns: 'repeat(2, 1fr)', + gridTemplateColumns: 'repeat(1, 1fr)', gridGap: theme.spacing(2), }, listItem: { @@ -64,13 +63,7 @@ export function DonationPage({ donations = [], loading, addressLabel }: Donation {donations.map((donation) => ( - + ))} diff --git a/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx b/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx index a3c70b2b3b0d..b41755494a2f 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx @@ -1,6 +1,5 @@ import { makeStyles } from '@masknet/theme' import urlcat from 'urlcat' -import { RSS3_DEFAULT_IMAGE } from '../../constants' import type { GeneralAsset, GeneralAssetWithTags } from '../../types' import { FootprintCard, StatusBox } from '../components' import { useRss3Profile } from '../hooks' @@ -45,16 +44,7 @@ export function FootprintPage({ footprints = [], address, loading, addressLabel return (
{footprints.map((footprint) => ( - + ))}
) From e58b882fa5037b043e04702e544d26083a694e19 Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Wed, 20 Jul 2022 17:00:27 +0800 Subject: [PATCH 121/179] feat: change donations and footprints UI --- .../plugins/RSS3/src/SNSAdaptor/TabCard.tsx | 12 ++- .../SNSAdaptor/components/DonationCard.tsx | 82 +++++++++---------- .../SNSAdaptor/components/FootprintCard.tsx | 53 ++++-------- .../SNSAdaptor/hooks/useCollectionFilter.ts | 14 +++- .../RSS3/src/SNSAdaptor/hooks/useDonations.ts | 10 +-- .../src/SNSAdaptor/hooks/useFootprints.ts | 9 +- .../src/SNSAdaptor/pages/DonationsPage.tsx | 22 ++--- .../src/SNSAdaptor/pages/FootprintPage.tsx | 36 ++------ packages/plugins/RSS3/src/locales/en-US.json | 4 +- 9 files changed, 101 insertions(+), 141 deletions(-) diff --git a/packages/plugins/RSS3/src/SNSAdaptor/TabCard.tsx b/packages/plugins/RSS3/src/SNSAdaptor/TabCard.tsx index e625daf4bd1f..4d6c8bb0003f 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/TabCard.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/TabCard.tsx @@ -6,6 +6,7 @@ import { DonationPage, FootprintPage } from './pages' import { useCurrentVisitingProfile } from './hooks/useContext' import { CollectionType, KVType } from '../types' import { useKV } from './hooks/useKV' +import type { RSS3BaseAPI } from '@masknet/web3-providers' export enum TabCardType { Donation = 1, @@ -48,13 +49,16 @@ export function TabCard({ type, socialAddress, persona }: TabCardProps) { const isDonation = type === TabCardType.Donation return isDonation ? ( - + ) : ( ) } diff --git a/packages/plugins/RSS3/src/SNSAdaptor/components/DonationCard.tsx b/packages/plugins/RSS3/src/SNSAdaptor/components/DonationCard.tsx index 13e03f19d5c7..ca336bffae3b 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/components/DonationCard.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/components/DonationCard.tsx @@ -1,13 +1,17 @@ -import { makeStyles, MaskColorVar } from '@masknet/theme' +import { useReverseAddress, useWeb3State } from '@masknet/plugin-infra/web3' +import { makeStyles } from '@masknet/theme' +import type { RSS3BaseAPI } from '@masknet/web3-providers' +import type { NetworkPluginID, SocialAddress } from '@masknet/web3-shared-base' import { Typography } from '@mui/material' import classnames from 'classnames' -import { HTMLProps, Fragment } from 'react' +import formatDateTime from 'date-fns/format' +import type { HTMLProps } from 'react' import { RSS3_DEFAULT_IMAGE } from '../../constants' import { useI18N } from '../../locales' -import type { GeneralAsset } from '../../types' export interface DonationCardProps extends HTMLProps { - donation: GeneralAsset + donation: RSS3BaseAPI.Donation + address: SocialAddress } const useStyles = makeStyles()((theme) => ({ @@ -15,7 +19,6 @@ const useStyles = makeStyles()((theme) => ({ borderRadius: 8, display: 'flex', flexDirection: 'row', - backgroundColor: MaskColorVar.twitterBg, flexGrow: 1, alignItems: 'stretch', padding: 3, @@ -27,70 +30,67 @@ const useStyles = makeStyles()((theme) => ({ borderRadius: 8, objectFit: 'cover', }, - title: { - color: theme.palette.text.primary, - fontSize: 16, + date: { + color: theme.palette.maskColor.main, + fontSize: 14, + fontWeight: 400, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis', }, info: { - flexGrow: 1, + marginTop: 15, marginLeft: '12px', fontSize: 16, - display: 'flex', - overflow: 'hidden', - flexDirection: 'column', - justifyContent: 'space-around', - fontFamily: '-apple-system,system-ui,sans-serif', }, infoRow: { - whiteSpace: 'nowrap', + marginBottom: 8, overflow: 'hidden', textOverflow: 'ellipsis', }, - infoLabel: { - color: theme.palette.text.primary, + activity: { + fontSize: 14, + fontWeight: 400, + fontColor: theme.palette.maskColor.main, }, - infoValue: { - color: theme.palette.text.secondary, + fontColor: { + color: theme.palette.maskColor.primary, }, })) -export const DonationCard = ({ donation, className, ...rest }: DonationCardProps) => { +export const DonationCard = ({ donation, address, className, ...rest }: DonationCardProps) => { const { classes } = useStyles() const t = useI18N() + const { value: domain } = useReverseAddress(address.networkSupporterPluginID, address.address) + const { Others } = useWeb3State(address.networkSupporterPluginID) + const reversedAddress = + !domain || !Others?.formatDomainName + ? Others?.formatAddress?.(address.address, 5) ?? address.address + : Others.formatDomainName(domain) + + const date = donation.detail?.txs?.[0] + ? formatDateTime(new Date(Number(donation.detail?.txs?.[0]?.timeStamp) * 1000), 'MMM dd, yyyy') + : '--' return (
{donation.info.title
- - {donation.info.title || t.inactive_project()} + + {date}
- {donation.info.total_contribs || 0} - - {t.contribution({ count: donation.info.total_contribs || 0 })} - -
-
- {(donation.info.token_contribs || []).map((contrib, i) => ( - - {contrib.amount} - {contrib.token} - - ))} + + {reversedAddress} {t.contributed()}{' '} + {donation.detail?.txs?.[0]?.formatedAmount} + {donation.detail?.txs?.[0]?.symbol} {t.to()}{' '} + {donation.detail?.grant?.title} +
diff --git a/packages/plugins/RSS3/src/SNSAdaptor/components/FootprintCard.tsx b/packages/plugins/RSS3/src/SNSAdaptor/components/FootprintCard.tsx index 9feeb591984d..b31120db3540 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/components/FootprintCard.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/components/FootprintCard.tsx @@ -1,9 +1,10 @@ import { Typography } from '@mui/material' import fromUnixTime from 'date-fns/fromUnixTime' +import formatDateTime from 'date-fns/format' import { makeStyles } from '@masknet/theme' import { useI18N } from '../../locales' import { RSS3_DEFAULT_IMAGE } from '../../constants' -import type { GeneralAsset } from '../../types' +import type { RSS3BaseAPI } from '@masknet/web3-providers' const useStyles = makeStyles()((theme) => ({ card: { @@ -20,7 +21,13 @@ const useStyles = makeStyles()((theme) => ({ }, content: { marginLeft: 12, - marginTop: 12, + marginTop: 15, + }, + infoRow: { + marginBottom: 8, + fontSize: 14, + fontWeight: 400, + fontColor: theme.palette.maskColor.main, }, })) @@ -29,55 +36,31 @@ const formatDate = (ts: string): string => { } export interface FootprintProps { username: string - footprint: GeneralAsset + footprint: RSS3BaseAPI.Footprint } export const FootprintCard = ({ footprint }: FootprintProps) => { const t = useI18N() const { classes } = useStyles() - // Calc display date - let displayDate: string - if (footprint.info.start_date && footprint.info.end_date) { - displayDate = formatDate(footprint.info.start_date) - if (footprint.info.start_date !== footprint.info.end_date) { - displayDate += ` ~ ${formatDate(footprint.info.end_date)}` - } - } else { - displayDate = t.no_activity_time() - } - - // Calc location - const location = footprint.info.city || footprint.info.country || 'Metaverse' + const date = footprint.detail?.end_date + ? formatDateTime(new Date(footprint.detail?.end_date), 'MMM dd, yyyy') + : t.no_activity_time() + const location = footprint.detail.city || footprint.detail.country || 'Metaverse' return (
{t.inactive_project()}
-
- - {displayDate} - -
-
- - @ {location} - -
-
- - {t.attended()} - - - {footprint.info.title || ''} - -
+ {date} + @ {location} + {footprint.detail?.name || ''}
) diff --git a/packages/plugins/RSS3/src/SNSAdaptor/hooks/useCollectionFilter.ts b/packages/plugins/RSS3/src/SNSAdaptor/hooks/useCollectionFilter.ts index e47b9be71ea2..acd02b370fba 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/hooks/useCollectionFilter.ts +++ b/packages/plugins/RSS3/src/SNSAdaptor/hooks/useCollectionFilter.ts @@ -1,12 +1,13 @@ import { IdentityResolved, PluginId } from '@masknet/plugin-infra' import { NextIDPlatform } from '@masknet/shared-base' +import type { RSS3BaseAPI } from '@masknet/web3-providers' import type { NetworkPluginID, SocialAddress } from '@masknet/web3-shared-base' import { useMemo } from 'react' -import type { CollectionType, GeneralAsset, Proof } from '../../types' +import { CollectionType, Proof } from '../../types' export const useCollectionFilter = ( hiddenInfo: Proof[], - collections: GeneralAsset[], + collections: RSS3BaseAPI.Donation[] | RSS3BaseAPI.Footprint[], type: CollectionType, currentVisitingProfile?: IdentityResolved, address?: SocialAddress, @@ -21,6 +22,13 @@ export const useCollectionFilter = ( ) const hiddenList = proof?.content?.[PluginId.Web3Profile]?.unListedCollections?.[address?.address?.toLowerCase()]?.[type] ?? [] - return collections?.filter((collection) => hiddenList?.findIndex((url) => url === collection?.id) === -1) + if (type === CollectionType.Donations) { + return (collections as RSS3BaseAPI.Donation[])?.filter( + (collection: { id: string }) => hiddenList?.findIndex((url) => url === collection?.id) === -1, + ) + } + return (collections as RSS3BaseAPI.Footprint[])?.filter( + (collection: { id: string }) => hiddenList?.findIndex((url) => url === collection?.id) === -1, + ) }, [address, currentVisitingProfile?.identifier?.userId, type, hiddenInfo?.length, collections?.length]) } diff --git a/packages/plugins/RSS3/src/SNSAdaptor/hooks/useDonations.ts b/packages/plugins/RSS3/src/SNSAdaptor/hooks/useDonations.ts index 8f94c6bc52ba..196afd5738e7 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/hooks/useDonations.ts +++ b/packages/plugins/RSS3/src/SNSAdaptor/hooks/useDonations.ts @@ -1,12 +1,10 @@ import { useAsync } from 'react-use' import type { AsyncState } from 'react-use/lib/useAsync' -import { EMPTY_LIST } from '@masknet/shared-base' -import { PluginProfileRPC } from '../../messages' -import type { GeneralAsset } from '../../types' +import { RSS3, RSS3BaseAPI } from '@masknet/web3-providers' -export function useDonations(address: string): AsyncState { +export function useDonations(address: string): AsyncState { return useAsync(async () => { - const response = await PluginProfileRPC.getDonations(address) - return response.status ? response.assets : EMPTY_LIST + const response = await RSS3.getDonations(address) + return response }, [address]) } diff --git a/packages/plugins/RSS3/src/SNSAdaptor/hooks/useFootprints.ts b/packages/plugins/RSS3/src/SNSAdaptor/hooks/useFootprints.ts index 587db827ed99..ed0776223d0c 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/hooks/useFootprints.ts +++ b/packages/plugins/RSS3/src/SNSAdaptor/hooks/useFootprints.ts @@ -1,11 +1,10 @@ +import { RSS3, RSS3BaseAPI } from '@masknet/web3-providers' import { useAsync } from 'react-use' import type { AsyncState } from 'react-use/lib/useAsync' -import { PluginProfileRPC } from '../../messages' -import type { GeneralAsset } from '../../types' -export function useFootprints(address: string): AsyncState { +export function useFootprints(address: string): AsyncState { return useAsync(async () => { - const response = await PluginProfileRPC.getFootprints(address) - return response.status ? response.assets : [] + const response = await RSS3.getFootprints(address) + return response ?? [] }, [address]) } diff --git a/packages/plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx b/packages/plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx index b45c971db28f..a2f723578ec8 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx @@ -1,20 +1,10 @@ import { makeStyles } from '@masknet/theme' +import type { RSS3BaseAPI } from '@masknet/web3-providers' +import type { NetworkPluginID, SocialAddress } from '@masknet/web3-shared-base' import { List, ListItem } from '@mui/material' -import urlcat from 'urlcat' import { useI18N } from '../../locales' -import type { GeneralAsset, GeneralAssetWithTags } from '../../types' import { DonationCard, StatusBox } from '../components' -const getDonationLink = (label: string, donation: GeneralAssetWithTags) => { - const { platform, identity, id, type } = donation - return urlcat(`https://${label}.bio/singlegitcoin/:platform/:identity/:id/:type`, { - platform, - identity, - id, - type: type.replaceAll('-', '.'), - }) -} - const useStyles = makeStyles()((theme) => ({ statusBox: { display: 'flex', @@ -47,12 +37,12 @@ const useStyles = makeStyles()((theme) => ({ })) export interface DonationPageProps { - donations?: GeneralAsset[] + donations?: RSS3BaseAPI.Donation[] loading?: boolean - addressLabel: string + address: SocialAddress } -export function DonationPage({ donations = [], loading, addressLabel }: DonationPageProps) { +export function DonationPage({ donations = [], loading, address }: DonationPageProps) { const { classes } = useStyles() const t = useI18N() @@ -63,7 +53,7 @@ export function DonationPage({ donations = [], loading, addressLabel }: Donation {donations.map((donation) => ( - + ))} diff --git a/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx b/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx index b41755494a2f..5668ff094c5e 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx @@ -1,40 +1,16 @@ -import { makeStyles } from '@masknet/theme' -import urlcat from 'urlcat' -import type { GeneralAsset, GeneralAssetWithTags } from '../../types' +import type { RSS3BaseAPI } from '@masknet/web3-providers' +import type { NetworkPluginID, SocialAddress } from '@masknet/web3-shared-base' import { FootprintCard, StatusBox } from '../components' import { useRss3Profile } from '../hooks' -const useStyles = makeStyles()((theme) => ({ - address: { - color: theme.palette.primary.main, - }, - link: { - '&:hover': { - textDecoration: 'none', - }, - }, -})) - -const getFootprintLink = (label: string, footprint: GeneralAssetWithTags) => { - const { platform, identity, id, type } = footprint - return urlcat(`https://${label}.bio/singlefootprint/:platform/:identity/:id/:type`, { - platform, - identity, - id, - type: type.replaceAll('-', '.'), - }) -} - export interface FootprintPageProps { - footprints?: GeneralAsset[] + footprints?: RSS3BaseAPI.Footprint[] loading?: boolean - addressLabel: string - address?: string + address: SocialAddress } -export function FootprintPage({ footprints = [], address, loading, addressLabel }: FootprintPageProps) { - const { classes } = useStyles() - const { value: profile } = useRss3Profile(address || '') +export function FootprintPage({ footprints = [], address, loading }: FootprintPageProps) { + const { value: profile } = useRss3Profile(address.address || '') const username = profile?.name if (loading || !footprints.length) { diff --git a/packages/plugins/RSS3/src/locales/en-US.json b/packages/plugins/RSS3/src/locales/en-US.json index 757d0d9437f0..c8390d09845c 100644 --- a/packages/plugins/RSS3/src/locales/en-US.json +++ b/packages/plugins/RSS3/src/locales/en-US.json @@ -5,5 +5,7 @@ "no_data": "No data", "total_grants": "Total {{count}} Grants", "contribution": "Contribution", - "contribution_other": "Contributions" + "contribution_other": "Contributions", + "contributed": "contributed", + "to": "to" } From 471fad3f40a8348965b478cd70c9b67f53434496 Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Wed, 20 Jul 2022 17:04:31 +0800 Subject: [PATCH 122/179] feat: change copyright subject --- packages/shared/src/UI/components/ConcealableTabs/index.tsx | 5 ++--- packages/shared/src/locales/en-US.json | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/shared/src/UI/components/ConcealableTabs/index.tsx b/packages/shared/src/UI/components/ConcealableTabs/index.tsx index 32b67e0b9577..c10b13157816 100644 --- a/packages/shared/src/UI/components/ConcealableTabs/index.tsx +++ b/packages/shared/src/UI/components/ConcealableTabs/index.tsx @@ -1,4 +1,4 @@ -import { Gear, ArrowDrop, LinkOut, RightArrow, NextIdPersonaVerified, Selected, LeftArrow, Rss3 } from '@masknet/icons' +import { Gear, ArrowDrop, LinkOut, RightArrow, NextIdPersonaVerified, Selected, LeftArrow } from '@masknet/icons' import { ReversedAddress } from '@masknet/shared' import { CrossIsolationMessages } from '@masknet/shared-base' import { makeStyles, ShadowRootMenu } from '@masknet/theme' @@ -315,9 +315,8 @@ export function ConcealableTabs({ {t.powered_by()} - {t.rss3()} + {t.mask_network()} -
diff --git a/packages/shared/src/locales/en-US.json b/packages/shared/src/locales/en-US.json index 9085edfa5f2a..126a16bbbaa0 100644 --- a/packages/shared/src/locales/en-US.json +++ b/packages/shared/src/locales/en-US.json @@ -33,6 +33,7 @@ "powered_by": "Powered by", "go_plus": "GO+", "rss3": "RSS3", + "mask_network": "Mask Network", "high_risk": "High Risk", "low_risk": "Low Risk", "medium_risk": "Medium Risk", From a0397e2dc57ddc19d5dae325c44bca32a09e1877 Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Wed, 20 Jul 2022 17:46:43 +0800 Subject: [PATCH 123/179] feat: add dynamic color to icon --- .../src/pages/Personas/components/PersonaLine/index.tsx | 2 +- packages/icons/general/ArrowDrop.svg | 2 +- packages/icons/general/NextIdPersonaVerified.svg | 2 +- packages/icons/general/Selected.light.svg | 2 +- .../SNSAdaptor/SelectProviderDialog/PluginProviderRender.tsx | 3 +-- packages/shared/src/UI/components/ConcealableTabs/index.tsx | 4 ++-- 6 files changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/dashboard/src/pages/Personas/components/PersonaLine/index.tsx b/packages/dashboard/src/pages/Personas/components/PersonaLine/index.tsx index fa9eccd06c96..d75e63af3baa 100644 --- a/packages/dashboard/src/pages/Personas/components/PersonaLine/index.tsx +++ b/packages/dashboard/src/pages/Personas/components/PersonaLine/index.tsx @@ -143,7 +143,7 @@ export const ConnectedPersonaLine = memo( {proof.loading ? ( ) : isProved?.is_valid ? ( - + ) : ( )} diff --git a/packages/icons/general/ArrowDrop.svg b/packages/icons/general/ArrowDrop.svg index 3a70b8204d6d..5bf9d7999b78 100644 --- a/packages/icons/general/ArrowDrop.svg +++ b/packages/icons/general/ArrowDrop.svg @@ -2,7 +2,7 @@ diff --git a/packages/icons/general/NextIdPersonaVerified.svg b/packages/icons/general/NextIdPersonaVerified.svg index 09760109a8cb..5b712d60bbc5 100644 --- a/packages/icons/general/NextIdPersonaVerified.svg +++ b/packages/icons/general/NextIdPersonaVerified.svg @@ -2,7 +2,7 @@ - + { bottom: 0, backgroundColor: theme.palette.background.paper, borderRadius: '50%', - fill: theme.palette.maskColor.success, }, alert: { fontSize: 12, @@ -275,7 +274,7 @@ function NetworkItem({ ) : ( )} - {selected && } + {selected && } {Others?.chainResolver.chainName(network.chainId)} diff --git a/packages/shared/src/UI/components/ConcealableTabs/index.tsx b/packages/shared/src/UI/components/ConcealableTabs/index.tsx index c10b13157816..db5f48022751 100644 --- a/packages/shared/src/UI/components/ConcealableTabs/index.tsx +++ b/packages/shared/src/UI/components/ConcealableTabs/index.tsx @@ -298,11 +298,11 @@ export function ConcealableTabs({ {x?.type === SocialAddressType.KV && ( - + )} {isSameAddress(selectedAddress?.address, x.address) && ( - + )} From d7f101f298b7f434c2cd3ededf088806f060136e Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Wed, 20 Jul 2022 23:04:53 +0800 Subject: [PATCH 124/179] feat: add loading more icon for image management page --- .../SNSAdaptor/components/ImageManagement.tsx | 2 +- .../SNSAdaptor/components/WalletAssets.tsx | 82 +++++++++++++++++-- .../Web3Profile/src/locales/en-US.json | 3 +- 3 files changed, 77 insertions(+), 10 deletions(-) diff --git a/packages/plugins/Web3Profile/src/SNSAdaptor/components/ImageManagement.tsx b/packages/plugins/Web3Profile/src/SNSAdaptor/components/ImageManagement.tsx index 97b56c48e5b9..02c10f5782c0 100644 --- a/packages/plugins/Web3Profile/src/SNSAdaptor/components/ImageManagement.tsx +++ b/packages/plugins/Web3Profile/src/SNSAdaptor/components/ImageManagement.tsx @@ -40,7 +40,7 @@ const useStyles = makeStyles()((theme) => ({ flexDirection: 'column', '::-webkit-scrollbar': { backgroundColor: 'transparent', - width: 20, + width: 5, }, '::-webkit-scrollbar-thumb': { borderRadius: '20px', diff --git a/packages/plugins/Web3Profile/src/SNSAdaptor/components/WalletAssets.tsx b/packages/plugins/Web3Profile/src/SNSAdaptor/components/WalletAssets.tsx index 8d40f343fb80..e292cba2a5cd 100644 --- a/packages/plugins/Web3Profile/src/SNSAdaptor/components/WalletAssets.tsx +++ b/packages/plugins/Web3Profile/src/SNSAdaptor/components/WalletAssets.tsx @@ -1,5 +1,5 @@ import { Card, Typography, Link, Box } from '@mui/material' -import { Edit2Icon, LinkOutIcon } from '@masknet/icons' +import { ArrowUpRound, Edit2Icon, LinkOutIcon } from '@masknet/icons' import { makeStyles, useStylesExtends } from '@masknet/theme' import { useI18N } from '../../locales' import { ImageIcon } from './ImageIcon' @@ -9,6 +9,7 @@ import { ChainId, explorerResolver, NETWORK_DESCRIPTORS } from '@masknet/web3-sh import { NetworkPluginID } from '@masknet/web3-shared-base' import { Empty } from './Empty' import { CollectionList } from './CollectionList' +import { useMemo, useState } from 'react' const useStyles = makeStyles()((theme) => { return { @@ -32,10 +33,14 @@ const useStyles = makeStyles()((theme) => { display: 'flex', // overflow: 'hidden', padding: 0, - flexDirection: 'column', + width: 126, + height: 126, borderRadius: 12, userSelect: 'none', lineHeight: 0, + '&:nth-last-child(-n+4)': { + marginBottom: 0, + }, }, link: { cursor: 'pointer', @@ -62,17 +67,32 @@ const useStyles = makeStyles()((theme) => { }, list: { gridRowGap: 16, - gridColumnGap: 14, + gridColumnGap: 20, display: 'grid', justifyItems: 'center', gridTemplateColumns: 'repeat(4, 1fr)', - paddingBottom: '20px', + // display: 'flex', + // flexWrap: 'wrap', + // justifyContent: 'space-between', }, listBox: { display: 'flex', flexWrap: 'wrap', - height: 298, - overflow: 'hidden', + minHeight: 298, + justifyContent: 'center', + }, + loadIcon: { + width: 82, + height: 32, + borderRadius: 99, + display: 'flex', + justifyContent: 'center', + alignItems: 'center', + backgroundColor: theme.palette.maskColor.thirdMain, + fontSize: 12, + fontWeight: 700, + marginTop: 4, + cursor: 'pointer', }, } }) @@ -84,15 +104,55 @@ export interface WalletAssetsCardProps extends withClasses { collectionList?: CollectionTypes[] } +const enum LOAD_STATUS { + 'Unnecessary' = 1, + 'Necessary' = 2, + 'Finish' = 3, +} + export function WalletAssetsCard(props: WalletAssetsCardProps) { const { address, onSetting, collectionList } = props const t = useI18N() const classes = useStylesExtends(useStyles(), props) const chainId = ChainId.Mainnet + + const [loadStatus, setLoadStatus] = useState( + collectionList && collectionList?.filter((collection) => !collection?.hidden)?.length > 8 + ? LOAD_STATUS.Necessary + : LOAD_STATUS.Unnecessary, + ) + const { Others } = useWeb3State(address?.platform ?? NetworkPluginID.PLUGIN_EVM) const iconURL = NETWORK_DESCRIPTORS.find((network) => network?.chainId === ChainId.Mainnet)?.icon + const collections = useMemo(() => { + const filterCollections = collectionList?.filter((collection) => !collection?.hidden) + if (!filterCollections || filterCollections?.length === 0) { + return [] + } + if (filterCollections?.length > 8 && loadStatus !== LOAD_STATUS.Finish) { + return filterCollections?.slice(0, 8) + } + return filterCollections + }, [loadStatus, collectionList]) + + const loadIcon = useMemo(() => { + if (loadStatus === LOAD_STATUS.Finish) + return ( + + done + + ) + if (loadStatus === LOAD_STATUS.Necessary) + return ( + setLoadStatus(LOAD_STATUS.Finish)} className={classes.loadIcon}> + {t.load_more()} + + ) + return null + }, [loadStatus, setLoadStatus]) + const { value: domain } = useReverseAddress(NetworkPluginID.PLUGIN_EVM, address?.address) return ( @@ -111,7 +171,12 @@ export function WalletAssetsCard(props: WalletAssetsCardProps) { - +
+ {loadStatus === LOAD_STATUS.Finish && ( + setLoadStatus(LOAD_STATUS.Necessary)} /> + )} + +
{collectionList && collectionList?.filter((collection) => !collection?.hidden)?.length > 0 ? ( @@ -119,8 +184,9 @@ export function WalletAssetsCard(props: WalletAssetsCardProps) { !collection?.hidden)?.slice(0, 8)} + collections={collections} /> + {loadIcon} ) : ( diff --git a/packages/plugins/Web3Profile/src/locales/en-US.json b/packages/plugins/Web3Profile/src/locales/en-US.json index f2adcfa8b843..ed19267b6d46 100644 --- a/packages/plugins/Web3Profile/src/locales/en-US.json +++ b/packages/plugins/Web3Profile/src/locales/en-US.json @@ -53,5 +53,6 @@ "wallet_setting_hint": "Toggle the button to manage wallet display settings.", "no_authenticated_wallet": "That hasn't been authenticated yet.", "no_items_found": "No Items found.", - "account_empty": "Please verify this persona to set your Web3 profile." + "account_empty": "Please verify this persona to set your Web3 profile.", + "load_more": "load more" } From 366738ebe618577970a8fbf1d1833eed9a66af20 Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Thu, 21 Jul 2022 16:09:16 +0800 Subject: [PATCH 125/179] feat: add detail card for footprints and donations --- packages/icons/general/LinkOut.svg | 4 +- .../SNSAdaptor/TransactionSnackbar/index.tsx | 2 +- .../SNSAdaptor/components/DonationCard.tsx | 6 +- .../SNSAdaptor/components/FootprintCard.tsx | 6 +- .../src/SNSAdaptor/pages/DonationsPage.tsx | 34 +++- .../src/SNSAdaptor/pages/FootprintPage.tsx | 31 +++- .../components/CollectionDetailCard/index.tsx | 150 ++++++++++++++++++ packages/shared/src/UI/components/index.ts | 1 + packages/shared/src/locales/en-US.json | 6 + 9 files changed, 221 insertions(+), 19 deletions(-) create mode 100644 packages/shared/src/UI/components/CollectionDetailCard/index.tsx diff --git a/packages/icons/general/LinkOut.svg b/packages/icons/general/LinkOut.svg index b11d74ac371b..a1d3e5a093bd 100644 --- a/packages/icons/general/LinkOut.svg +++ b/packages/icons/general/LinkOut.svg @@ -4,8 +4,8 @@ fill-rule="evenodd" clip-rule="evenodd" d="M1.6 2.1a.5.5 0 0 1 .5-.5h3.529v.8H2.4v7.2h7.2V6.235h.8V9.9a.5.5 0 0 1-.5.5H2.1a.5.5 0 0 1-.5-.5V2.1ZM6.832 2c0-.22.18-.4.4-.4H10c.22 0 .4.18.4.4v2.747a.4.4 0 0 1-.8 0v-1.77l-4.935 5.02a.4.4 0 0 1-.57-.56L9.045 2.4H7.233a.4.4 0 0 1-.4-.4Z" - fill="#07101B" + fill="currentColor" />
- + diff --git a/packages/mask/src/plugins/Wallet/SNSAdaptor/TransactionSnackbar/index.tsx b/packages/mask/src/plugins/Wallet/SNSAdaptor/TransactionSnackbar/index.tsx index 22cbf7e66bba..8158716f3029 100644 --- a/packages/mask/src/plugins/Wallet/SNSAdaptor/TransactionSnackbar/index.tsx +++ b/packages/mask/src/plugins/Wallet/SNSAdaptor/TransactionSnackbar/index.tsx @@ -111,7 +111,7 @@ export function TransactionSnackbar({ pluginID }: Tra {progress.status === TransactionStatusType.SUCCEED ? computed.successfulDescription ?? computed.description : computed.description}{' '} - + ), }, diff --git a/packages/plugins/RSS3/src/SNSAdaptor/components/DonationCard.tsx b/packages/plugins/RSS3/src/SNSAdaptor/components/DonationCard.tsx index ca336bffae3b..6c25db404fec 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/components/DonationCard.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/components/DonationCard.tsx @@ -12,6 +12,7 @@ import { useI18N } from '../../locales' export interface DonationCardProps extends HTMLProps { donation: RSS3BaseAPI.Donation address: SocialAddress + onSelect: () => void } const useStyles = makeStyles()((theme) => ({ @@ -22,6 +23,7 @@ const useStyles = makeStyles()((theme) => ({ flexGrow: 1, alignItems: 'stretch', padding: 3, + cursor: 'pointer', }, cover: { flexShrink: 1, @@ -58,7 +60,7 @@ const useStyles = makeStyles()((theme) => ({ }, })) -export const DonationCard = ({ donation, address, className, ...rest }: DonationCardProps) => { +export const DonationCard = ({ donation, address, onSelect, className, ...rest }: DonationCardProps) => { const { classes } = useStyles() const t = useI18N() const { value: domain } = useReverseAddress(address.networkSupporterPluginID, address.address) @@ -72,7 +74,7 @@ export const DonationCard = ({ donation, address, className, ...rest }: Donation ? formatDateTime(new Date(Number(donation.detail?.txs?.[0]?.timeStamp) * 1000), 'MMM dd, yyyy') : '--' return ( -
+
({ display: 'flex', padding: 3, marginBottom: 16, + cursor: 'pointer', }, cover: { flexShrink: 1, @@ -37,9 +38,10 @@ const formatDate = (ts: string): string => { export interface FootprintProps { username: string footprint: RSS3BaseAPI.Footprint + onSelect: () => void } -export const FootprintCard = ({ footprint }: FootprintProps) => { +export const FootprintCard = ({ footprint, onSelect }: FootprintProps) => { const t = useI18N() const { classes } = useStyles() @@ -49,7 +51,7 @@ export const FootprintCard = ({ footprint }: FootprintProps) => { const location = footprint.detail.city || footprint.detail.country || 'Metaverse' return ( -
+
() + if (loading || !donations.length) { return } return ( - - {donations.map((donation) => ( - - - - ))} - + <> + + {donations.map((donation) => ( + + setSelectedDonation(donation)} + className={classes.donationCard} + donation={donation} + address={address} + /> + + ))} + + setSelectedDonation(undefined)} + img={selectedDonation?.detail?.grant?.logo} + title={selectedDonation?.detail?.grant?.title} + referenceUrl={selectedDonation?.detail?.grant?.reference_url} + description={selectedDonation?.detail?.grant?.description} + contributions={selectedDonation?.detail?.txs} + /> + ) } diff --git a/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx b/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx index 5668ff094c5e..e2bffe4eb61a 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx @@ -1,5 +1,7 @@ +import { CollectionDetailCard } from '@masknet/shared' import type { RSS3BaseAPI } from '@masknet/web3-providers' import type { NetworkPluginID, SocialAddress } from '@masknet/web3-shared-base' +import { useState } from 'react' import { FootprintCard, StatusBox } from '../components' import { useRss3Profile } from '../hooks' @@ -13,15 +15,34 @@ export function FootprintPage({ footprints = [], address, loading }: FootprintPa const { value: profile } = useRss3Profile(address.address || '') const username = profile?.name + const [selectedFootprint, setSelectedFootprint] = useState() + if (loading || !footprints.length) { return } return ( -
- {footprints.map((footprint) => ( - - ))} -
+ <> +
+ {footprints.map((footprint) => ( + setSelectedFootprint(footprint)} + username={username ?? ''} + footprint={footprint} + /> + ))} +
+ setSelectedFootprint(undefined)} + img={selectedFootprint?.detail?.image_url} + title={selectedFootprint?.detail?.name} + referenceUrl={selectedFootprint?.detail?.event_url} + description={selectedFootprint?.detail?.description} + date={selectedFootprint?.detail?.end_date} + location={selectedFootprint?.detail?.city || selectedFootprint?.detail?.country || 'Metaverse'} + /> + ) } diff --git a/packages/shared/src/UI/components/CollectionDetailCard/index.tsx b/packages/shared/src/UI/components/CollectionDetailCard/index.tsx new file mode 100644 index 000000000000..e4c75d2c82fb --- /dev/null +++ b/packages/shared/src/UI/components/CollectionDetailCard/index.tsx @@ -0,0 +1,150 @@ +import { memo } from 'react' +import { makeStyles } from '@masknet/theme' +import { InjectedDialog } from '../../../contexts' +import { useSharedI18N } from '../../../locales' +import { Box, DialogContent, Link, Typography } from '@mui/material' +import type { RSS3BaseAPI } from '@masknet/web3-providers' +import differenceInCalendarDays from 'date-fns/differenceInDays' +import differenceInCalendarHours from 'date-fns/differenceInHours' +import { LinkOut } from '@masknet/icons' +import { ChainId, explorerResolver } from '@masknet/web3-shared-evm' + +interface CollectionDetailCardProps { + img?: string + open: boolean + title?: string + referenceUrl?: string + description?: string + contributions?: RSS3BaseAPI.DonationTx[] + onClose: () => void + date?: string + location?: string +} +const useStyles = makeStyles()((theme) => ({ + img: { + flexShrink: 1, + height: 300, + width: 300, + borderRadius: 8, + objectFit: 'cover', + }, + flexItem: { + display: 'flex', + width: '100%', + justifyContent: 'center', + }, + dayBox: { + display: 'flex', + alignItems: 'center', + color: theme.palette.maskColor.highlight, + }, + linkBox: { + display: 'flex', + width: 36, + height: 36, + borderRadius: 12, + backgroundColor: theme.palette.maskColor.highlight, + justifyContent: 'center', + alignItems: 'center', + marginLeft: 24, + }, + link: { + color: theme.palette.maskColor.highlight, + }, + txItem: { + display: 'flex', + justifyContent: 'space-between', + }, + donationAmount: { + fontSize: 16, + fontWeight: 400, + display: 'flex', + alignItems: 'center', + }, + threeLine: { + display: '-webkit-box', + '-webkit-line-clamp': 3, + height: 60, + fontSize: 14, + fontWeight: 400, + width: '100%', + overflow: 'hidden', + textOverflow: 'ellipsis', + '-webkit-box-orient': 'vertical', + }, + themeColor: { + color: theme.palette.maskColor.highlight, + }, +})) + +export const CollectionDetailCard = memo( + ({ img, open, onClose, title, referenceUrl, description, contributions, date, location }) => { + const t = useSharedI18N() + const { classes } = useStyles() + + return ( + + + + + + + {title} + + + {referenceUrl} + + {date && ( + + {date} + + )} + {location && ( + + @ + {location} + + )} + + {t.description()} + +
+ {description} +
+ {contributions ? ( + + {t.contributions()} + + ) : null} + {contributions ? ( + + {contributions?.length ?? 0} + + ) : null} + {contributions?.map((contribution) => ( +
+ + {contribution.formatedAmount} {contribution.symbol} + +
+ {differenceInCalendarDays(new Date(), new Date(Number(contribution.timeStamp) * 1000))}{' '} + {t.days()}{' '} + {differenceInCalendarHours( + new Date(), + new Date(Number(contribution.timeStamp) * 1000), + ) % 24}{' '} + {t.hours()} {t.ago()} + + + +
+
+ ))} +
+
+ ) + }, +) diff --git a/packages/shared/src/UI/components/index.ts b/packages/shared/src/UI/components/index.ts index 96c46c0841d8..68d513a59e5a 100644 --- a/packages/shared/src/UI/components/index.ts +++ b/packages/shared/src/UI/components/index.ts @@ -23,3 +23,4 @@ export * from './Linking' export * from './LoadRetry' export * from './NFTCard' export * from './TokenSecurity' +export * from './CollectionDetailCard' diff --git a/packages/shared/src/locales/en-US.json b/packages/shared/src/locales/en-US.json index 126a16bbbaa0..a8a1834b8cda 100644 --- a/packages/shared/src/locales/en-US.json +++ b/packages/shared/src/locales/en-US.json @@ -43,7 +43,13 @@ "token_info": "Token info", "more_details": "More Details", "more": "More", + "details": "Details", "unnamed": "Unnamed", + "contributions": "Contributions", + "description": "Description", + "days": "days", + "hours": "hours", + "ago": "ago", "security_detection": "Security Detection", "risky_items": "{{quantity}} Risky factors", "attention_items": "{{quantity}} Attention factors", From 02d9799d7f0993d4f180d175361ec44e2e4e499c Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Thu, 21 Jul 2022 16:53:28 +0800 Subject: [PATCH 126/179] feat: create feed plugin --- packages/mask/src/plugin-infra/register.js | 1 + .../Web3Feed/SNSAdaptor/Web3FeedPage.tsx | 12 +++++++ .../src/plugins/Web3Feed/SNSAdaptor/index.tsx | 23 +++++++++++++ .../mask/src/plugins/Web3Feed/Worker/index.ts | 8 +++++ packages/mask/src/plugins/Web3Feed/base.ts | 26 ++++++++++++++ .../mask/src/plugins/Web3Feed/constants.ts | 5 +++ packages/mask/src/plugins/Web3Feed/index.ts | 16 +++++++++ .../src/plugins/Web3Feed/locales/en-US.json | 1 + .../src/plugins/Web3Feed/locales/index.ts | 6 ++++ .../src/plugins/Web3Feed/locales/ja-JP.json | 1 + .../src/plugins/Web3Feed/locales/ko-KR.json | 1 + .../src/plugins/Web3Feed/locales/languages.ts | 34 +++++++++++++++++++ .../src/plugins/Web3Feed/locales/qya-AA.json | 4 +++ .../src/plugins/Web3Feed/locales/zh-CN.json | 1 + .../src/plugins/Web3Feed/locales/zh-TW.json | 1 + packages/plugin-infra/src/types.ts | 1 + 16 files changed, 141 insertions(+) create mode 100644 packages/mask/src/plugins/Web3Feed/SNSAdaptor/Web3FeedPage.tsx create mode 100644 packages/mask/src/plugins/Web3Feed/SNSAdaptor/index.tsx create mode 100644 packages/mask/src/plugins/Web3Feed/Worker/index.ts create mode 100644 packages/mask/src/plugins/Web3Feed/base.ts create mode 100644 packages/mask/src/plugins/Web3Feed/constants.ts create mode 100644 packages/mask/src/plugins/Web3Feed/index.ts create mode 100644 packages/mask/src/plugins/Web3Feed/locales/en-US.json create mode 100644 packages/mask/src/plugins/Web3Feed/locales/index.ts create mode 100644 packages/mask/src/plugins/Web3Feed/locales/ja-JP.json create mode 100644 packages/mask/src/plugins/Web3Feed/locales/ko-KR.json create mode 100644 packages/mask/src/plugins/Web3Feed/locales/languages.ts create mode 100644 packages/mask/src/plugins/Web3Feed/locales/qya-AA.json create mode 100644 packages/mask/src/plugins/Web3Feed/locales/zh-CN.json create mode 100644 packages/mask/src/plugins/Web3Feed/locales/zh-TW.json diff --git a/packages/mask/src/plugin-infra/register.js b/packages/mask/src/plugin-infra/register.js index 40e389058eeb..dfa1ec2c9b94 100644 --- a/packages/mask/src/plugin-infra/register.js +++ b/packages/mask/src/plugin-infra/register.js @@ -35,6 +35,7 @@ import '../plugins/ArtBlocks' import '../plugins/Referral' import '../plugins/Tips' import '../plugins/Approval' +import '../plugins/Web3Feed' import '@masknet/plugin-web3-profile' // import '../plugins/dHEDGE' // import '../plugins/External' diff --git a/packages/mask/src/plugins/Web3Feed/SNSAdaptor/Web3FeedPage.tsx b/packages/mask/src/plugins/Web3Feed/SNSAdaptor/Web3FeedPage.tsx new file mode 100644 index 000000000000..848c44c0f269 --- /dev/null +++ b/packages/mask/src/plugins/Web3Feed/SNSAdaptor/Web3FeedPage.tsx @@ -0,0 +1,12 @@ +import type { NetworkPluginID, SocialAddress } from '@masknet/web3-shared-base' + +export interface Web3FeedPageProps { + persona?: string + socialAddress?: SocialAddress +} + +export function Web3FeedPage({ socialAddress, persona }: Web3FeedPageProps) { + if (!socialAddress) return null + + return
a
+} diff --git a/packages/mask/src/plugins/Web3Feed/SNSAdaptor/index.tsx b/packages/mask/src/plugins/Web3Feed/SNSAdaptor/index.tsx new file mode 100644 index 000000000000..746aa60e6916 --- /dev/null +++ b/packages/mask/src/plugins/Web3Feed/SNSAdaptor/index.tsx @@ -0,0 +1,23 @@ +import type { Plugin } from '@masknet/plugin-infra/content-script' +import { base } from '../base' +import { PLUGIN_ID } from '../constants' +import { Web3FeedPage } from './Web3FeedPage' + +const sns: Plugin.SNSAdaptor.Definition = { + ...base, + init(signal, context) {}, + ProfileTabs: [ + { + ID: `${PLUGIN_ID}_web3Feed`, + label: 'Web3Feed', + priority: 1, + UI: { + TabContent: ({ socialAddress, persona }) => { + return + }, + }, + }, + ], +} + +export default sns diff --git a/packages/mask/src/plugins/Web3Feed/Worker/index.ts b/packages/mask/src/plugins/Web3Feed/Worker/index.ts new file mode 100644 index 000000000000..2da0563bd149 --- /dev/null +++ b/packages/mask/src/plugins/Web3Feed/Worker/index.ts @@ -0,0 +1,8 @@ +import type { Plugin } from '@masknet/plugin-infra' +import { base } from '../base' + +const worker: Plugin.Worker.Definition = { + ...base, + init(signal) {}, +} +export default worker diff --git a/packages/mask/src/plugins/Web3Feed/base.ts b/packages/mask/src/plugins/Web3Feed/base.ts new file mode 100644 index 000000000000..6fdbd9edc841 --- /dev/null +++ b/packages/mask/src/plugins/Web3Feed/base.ts @@ -0,0 +1,26 @@ +import { PLUGIN_ID } from './constants' +import { languages } from './locales/languages' +import { Plugin, CurrentSNSNetwork } from '@masknet/plugin-infra' + +export const base: Plugin.Shared.Definition = { + ID: PLUGIN_ID, + name: { fallback: 'Web3Feed' }, + description: { + fallback: 'web3 user collection feed', + }, + publisher: { name: { fallback: 'Mask Network' }, link: 'https://mask.io/' }, + enableRequirement: { + architecture: { app: true, web: true }, + networks: { + type: 'opt-in', + networks: { + [CurrentSNSNetwork.Twitter]: true, + [CurrentSNSNetwork.Facebook]: false, + [CurrentSNSNetwork.Instagram]: false, + }, + }, + target: 'stable', + }, + + i18n: languages, +} diff --git a/packages/mask/src/plugins/Web3Feed/constants.ts b/packages/mask/src/plugins/Web3Feed/constants.ts new file mode 100644 index 000000000000..2210389b7d9c --- /dev/null +++ b/packages/mask/src/plugins/Web3Feed/constants.ts @@ -0,0 +1,5 @@ +import { PluginId } from '@masknet/plugin-infra' + +export const PLUGIN_ID = PluginId.Web3Feed +export const PLUGIN_NAME = 'Web3 Feed' +export const PLUGIN_DESCRIPTION = 'web3 user collection feed' diff --git a/packages/mask/src/plugins/Web3Feed/index.ts b/packages/mask/src/plugins/Web3Feed/index.ts new file mode 100644 index 000000000000..eb51ba0afe25 --- /dev/null +++ b/packages/mask/src/plugins/Web3Feed/index.ts @@ -0,0 +1,16 @@ +import { registerPlugin } from '@masknet/plugin-infra' +import { base } from './base' + +registerPlugin({ + ...base, + SNSAdaptor: { + load: () => import('./SNSAdaptor'), + hotModuleReload: (hot) => + import.meta.webpackHot && import.meta.webpackHot.accept('./SNSAdaptor', () => hot(import('./SNSAdaptor'))), + }, + Worker: { + load: () => import('./Worker'), + hotModuleReload: (hot) => + import.meta.webpackHot && import.meta.webpackHot.accept('./Worker', () => hot(import('./Worker'))), + }, +}) diff --git a/packages/mask/src/plugins/Web3Feed/locales/en-US.json b/packages/mask/src/plugins/Web3Feed/locales/en-US.json new file mode 100644 index 000000000000..0967ef424bce --- /dev/null +++ b/packages/mask/src/plugins/Web3Feed/locales/en-US.json @@ -0,0 +1 @@ +{} diff --git a/packages/mask/src/plugins/Web3Feed/locales/index.ts b/packages/mask/src/plugins/Web3Feed/locales/index.ts new file mode 100644 index 000000000000..d6ead60252e4 --- /dev/null +++ b/packages/mask/src/plugins/Web3Feed/locales/index.ts @@ -0,0 +1,6 @@ +// This file is auto generated. DO NOT EDIT +// Run `npx gulp sync-languages` to regenerate. +// Default fallback language in a family of languages are chosen by the alphabet order +// To overwrite this, please overwrite packages/scripts/src/locale-kit-next/index.ts + +export * from './i18n_generated' diff --git a/packages/mask/src/plugins/Web3Feed/locales/ja-JP.json b/packages/mask/src/plugins/Web3Feed/locales/ja-JP.json new file mode 100644 index 000000000000..0967ef424bce --- /dev/null +++ b/packages/mask/src/plugins/Web3Feed/locales/ja-JP.json @@ -0,0 +1 @@ +{} diff --git a/packages/mask/src/plugins/Web3Feed/locales/ko-KR.json b/packages/mask/src/plugins/Web3Feed/locales/ko-KR.json new file mode 100644 index 000000000000..0967ef424bce --- /dev/null +++ b/packages/mask/src/plugins/Web3Feed/locales/ko-KR.json @@ -0,0 +1 @@ +{} diff --git a/packages/mask/src/plugins/Web3Feed/locales/languages.ts b/packages/mask/src/plugins/Web3Feed/locales/languages.ts new file mode 100644 index 000000000000..143dc822172a --- /dev/null +++ b/packages/mask/src/plugins/Web3Feed/locales/languages.ts @@ -0,0 +1,34 @@ +// This file is auto generated. DO NOT EDIT +// Run `npx gulp sync-languages` to regenerate. +// Default fallback language in a family of languages are chosen by the alphabet order +// To overwrite this, please overwrite packages/scripts/src/locale-kit-next/index.ts +import en_US from './en-US.json' +import ja_JP from './ja-JP.json' +import ko_KR from './ko-KR.json' +import qya_AA from './qya-AA.json' +import zh_CN from './zh-CN.json' +import zh_TW from './zh-TW.json' +export const languages = { + en: en_US, + ja: ja_JP, + ko: ko_KR, + qy: qya_AA, + 'zh-CN': zh_CN, + zh: zh_TW, +} +// @ts-ignore +if (import.meta.webpackHot) { + // @ts-ignore + import.meta.webpackHot.accept( + ['./en-US.json', './ja-JP.json', './ko-KR.json', './qya-AA.json', './zh-CN.json', './zh-TW.json'], + () => + globalThis.dispatchEvent?.( + new CustomEvent('MASK_I18N_HMR', { + detail: [ + 'org.findtruman', + { en: en_US, ja: ja_JP, ko: ko_KR, qy: qya_AA, 'zh-CN': zh_CN, zh: zh_TW }, + ], + }), + ), + ) +} diff --git a/packages/mask/src/plugins/Web3Feed/locales/qya-AA.json b/packages/mask/src/plugins/Web3Feed/locales/qya-AA.json new file mode 100644 index 000000000000..3869bcff6c62 --- /dev/null +++ b/packages/mask/src/plugins/Web3Feed/locales/qya-AA.json @@ -0,0 +1,4 @@ +{ + "powered_by": "crwdns17544:0crwdne17544:0", + "find_truman": "crwdns18196:0crwdne18196:0" +} diff --git a/packages/mask/src/plugins/Web3Feed/locales/zh-CN.json b/packages/mask/src/plugins/Web3Feed/locales/zh-CN.json new file mode 100644 index 000000000000..0967ef424bce --- /dev/null +++ b/packages/mask/src/plugins/Web3Feed/locales/zh-CN.json @@ -0,0 +1 @@ +{} diff --git a/packages/mask/src/plugins/Web3Feed/locales/zh-TW.json b/packages/mask/src/plugins/Web3Feed/locales/zh-TW.json new file mode 100644 index 000000000000..0967ef424bce --- /dev/null +++ b/packages/mask/src/plugins/Web3Feed/locales/zh-TW.json @@ -0,0 +1 @@ +{} diff --git a/packages/plugin-infra/src/types.ts b/packages/plugin-infra/src/types.ts index a8d0a053e33b..c8387a3f3bdf 100644 --- a/packages/plugin-infra/src/types.ts +++ b/packages/plugin-infra/src/types.ts @@ -960,6 +960,7 @@ export enum PluginId { Referral = 'com.maskbook.referral', Web3Profile = 'io.mask.web3-profile', ScamSniffer = 'io.scamsniffer.mask-plugin', + Web3Feed = 'io.mask.web3-feed', // @masknet/scripts: insert-here } /** From c9880ad3ee1bd33d049facc946e44d034aa4166e Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Fri, 22 Jul 2022 09:37:32 +0800 Subject: [PATCH 127/179] feat: change web3 feed UI --- .i18n-codegen.json | 11 + packages/icons/brands/PolygonScan.svg | 1 + .../plugins/Web3Feed/SNSAdaptor/FeedCard.tsx | 242 ++++++++++++++++++ .../Web3Feed/SNSAdaptor/ReversedAddress.tsx | 26 ++ .../plugins/Web3Feed/SNSAdaptor/StatusBox.tsx | 39 +++ .../Web3Feed/SNSAdaptor/Web3FeedPage.tsx | 42 ++- .../src/plugins/Web3Feed/SNSAdaptor/index.tsx | 2 +- .../mask/src/plugins/Web3Feed/constants.ts | 7 +- .../src/plugins/Web3Feed/locales/en-US.json | 7 +- .../CollectionDetailCard/assets/etherscan.png | Bin 0 -> 4088 bytes .../components/CollectionDetailCard/index.tsx | 155 ++++++++++- packages/shared/src/locales/en-US.json | 1 + packages/web3-providers/src/rss3/constants.ts | 2 +- packages/web3-providers/src/rss3/index.ts | 22 +- packages/web3-providers/src/types.ts | 22 +- 15 files changed, 560 insertions(+), 19 deletions(-) create mode 100644 packages/icons/brands/PolygonScan.svg create mode 100644 packages/mask/src/plugins/Web3Feed/SNSAdaptor/FeedCard.tsx create mode 100644 packages/mask/src/plugins/Web3Feed/SNSAdaptor/ReversedAddress.tsx create mode 100644 packages/mask/src/plugins/Web3Feed/SNSAdaptor/StatusBox.tsx create mode 100644 packages/shared/src/UI/components/CollectionDetailCard/assets/etherscan.png diff --git a/.i18n-codegen.json b/.i18n-codegen.json index d97c47ff540f..e3882327b8bb 100644 --- a/.i18n-codegen.json +++ b/.i18n-codegen.json @@ -359,6 +359,17 @@ "trans": "Translate", "sourceMap": "inline" } + }, + { + "input": "./packages/mask/src/plugins/Web3Feed/locales/en-US.json", + "output": "./packages/mask/src/plugins/Web3Feed/locales/i18n_generated", + "parser": { "type": "i18next", "contextSeparator": "$", "pluralSeparator": "_" }, + "generator": { + "type": "i18next/react-hooks", + "hooks": "useI18N", + "namespace": "com.maskbook.web3-feed", + "trans": "Translate" + } } ] } diff --git a/packages/icons/brands/PolygonScan.svg b/packages/icons/brands/PolygonScan.svg new file mode 100644 index 000000000000..b2b865eca1c4 --- /dev/null +++ b/packages/icons/brands/PolygonScan.svg @@ -0,0 +1 @@ + diff --git a/packages/mask/src/plugins/Web3Feed/SNSAdaptor/FeedCard.tsx b/packages/mask/src/plugins/Web3Feed/SNSAdaptor/FeedCard.tsx new file mode 100644 index 000000000000..92404bf332d8 --- /dev/null +++ b/packages/mask/src/plugins/Web3Feed/SNSAdaptor/FeedCard.tsx @@ -0,0 +1,242 @@ +import { NFTCardStyledAssetPlayer, TokenIcon } from '@masknet/shared' +import { makeStyles } from '@masknet/theme' +import { Alchemy_EVM, RSS3BaseAPI } from '@masknet/web3-providers' +import { NetworkPluginID } from '@masknet/web3-shared-base' +import { resolveIPFSLinkFromURL, ZERO_ADDRESS } from '@masknet/web3-shared-evm' +import { Box, Typography } from '@mui/material' +import differenceInCalendarDays from 'date-fns/differenceInDays' +import differenceInCalendarHours from 'date-fns/differenceInHours' +import { useMemo } from 'react' +import { ChainID } from '../constants' +import { ReversedAddress } from './ReversedAddress' +import { useI18N } from '../locales' +import { useAsyncRetry } from 'react-use' + +const useStyles = makeStyles()((theme) => ({ + wrapper: { + display: 'flex', + justifyContent: 'space-between', + marginBottom: 16, + }, + img: { + width: '64px !important', + height: '64px !important', + borderRadius: 8, + objectFit: 'cover', + }, + collection: { + borderLeft: `4px solid ${theme.palette.maskColor.line}`, + paddingLeft: 12, + marginTop: 12, + marginLeft: 8, + }, + time: { + color: theme.palette.maskColor.third, + marginLeft: 10, + }, + summary: { + textOverflow: 'ellipsis', + '-webkit-line-clamp': '1', + maxWidth: '300px', + overflow: 'hidden', + display: '-webkit-box', + '-webkit-box-orient': 'vertical', + }, + defaultImage: { + background: theme.palette.maskColor.modalTitleBg, + display: 'flex', + justifyContent: 'center', + alignItems: 'center', + borderRadius: 12, + }, + loadingFailImage: { + minHeight: '0 !important', + maxWidth: 'none', + width: 64, + height: 64, + }, +})) + +export interface FeedCardProps { + feed: RSS3BaseAPI.Web3Feed + address?: string + index: number + onSelect: (feed: RSS3BaseAPI.Web3Feed) => void +} + +export function FeedCard({ feed, address, index, onSelect }: FeedCardProps) { + const { classes } = useStyles() + const t = useI18N() + + const { value: NFTMetadata } = useAsyncRetry(async () => { + if ((feed?.title && feed?.summary) || !feed?.metadata?.collection_address) return + + const res = await Alchemy_EVM.getAsset(feed?.metadata?.collection_address, feed?.metadata?.token_id ?? '', { + chainId: ChainID[feed?.metadata?.network ?? 'ethereum'], + }) + console.log({ feed, res, index }) + return res + }, [feed?.metadata?.collection_address]) + // const { value: isImageToken, loading } = useImageChecker( + // resolveIPFSLinkFromURL( + // NFTMetadata?.metadata?.imageURL || + // feed?.attachments?.find((attachment) => attachment?.type === 'preview')?.address || + // '', + // ), + // ) + + const action = useMemo(() => { + if (!feed) return + if (feed?.tags?.includes('NFT')) { + if (feed?.metadata?.from?.toLowerCase() === address) { + return ( + + sent a NFT to + + ) + } + if (feed?.metadata?.from === ZERO_ADDRESS) { + return 'minted a NFT' + } + if (feed?.metadata?.to?.toLowerCase() === address) { + return ( + + acquire a NFT from {' '} + + ) + } + } + if (feed?.tags?.includes('Token') || feed?.tags?.includes('ETH')) { + if (feed?.metadata?.from?.toLowerCase() === address) { + return ( + + sent to + + ) + } + if (feed?.metadata?.to?.toLowerCase() === address) { + return ( + + received from + + ) + } + } + if (feed?.tags?.includes('Gitcoin')) { + if (feed?.metadata?.from?.toLowerCase() === address) { + return 'donated' + } + if (feed?.metadata?.to?.toLowerCase() === address) { + return 'received donation from' + } + } + if (feed?.metadata?.from?.toLowerCase() === address) { + return 'received' + } + return 'sent' + }, [address, feed]) + + const logo = useMemo(() => { + if (feed?.tags?.includes('NFT')) { + // return isImageToken ? ( + // attachment?.type === 'preview')?.address || + // '', + // )} + // /> + // ) : ( + // + // + // + // ) + return ( +
+ attachment?.type === 'preview')?.address || + '', + )} + tokenId={feed?.metadata?.token_id} + classes={{ + loadingFailImage: classes.loadingFailImage, + wrapper: classes.img, + iframe: classes.img, + }} + /> +
+ ) + } + if (feed?.tags.includes('Token') || feed?.tags.includes('ETH')) { + return ( + + ) + } + if (feed?.tags.includes('Gitcoin')) { + return ( + attachment?.type === 'logo')?.address} + /> + ) + } + return null + }, [feed]) + + const time = useMemo(() => { + const days = differenceInCalendarDays(new Date(), new Date(feed?.date_updated)) + const hours = differenceInCalendarHours(new Date(), new Date(feed?.date_updated)) % 24 + return days ? `${days} ${t.days()} ${hours} ${t.hours()} ${t.ago()}` : `${hours} ${t.hours()} ${t.ago()}` + }, [feed?.date_updated]) + return ( + + onSelect({ + ...feed, + title: + feed?.title || + NFTMetadata?.metadata?.name || + NFTMetadata?.collection?.name || + NFTMetadata?.contract?.name || + `#${feed?.metadata?.token_id}`, + summary: + feed?.summary || NFTMetadata?.metadata?.description || NFTMetadata?.collection?.description, + imageURL: resolveIPFSLinkFromURL( + NFTMetadata?.metadata?.imageURL || + feed?.attachments?.find((attachment) => attachment?.type === 'preview')?.address || + feed?.attachments?.find((attachment) => attachment?.type === 'logo')?.address || + '', + ), + traits: NFTMetadata?.traits, + }) + }> +
+ {action} {time} + + + {feed?.title || + NFTMetadata?.metadata?.name || + NFTMetadata?.collection?.name || + NFTMetadata?.contract?.name || + ''} + + + {feed?.summary || NFTMetadata?.metadata?.description || NFTMetadata?.collection?.description} || + `#${feed?.metadata?.token_id}`{' '} + + +
+ {logo} +
+ ) +} diff --git a/packages/mask/src/plugins/Web3Feed/SNSAdaptor/ReversedAddress.tsx b/packages/mask/src/plugins/Web3Feed/SNSAdaptor/ReversedAddress.tsx new file mode 100644 index 000000000000..c292af15c4ad --- /dev/null +++ b/packages/mask/src/plugins/Web3Feed/SNSAdaptor/ReversedAddress.tsx @@ -0,0 +1,26 @@ +import { memo } from 'react' +import type { NetworkPluginID } from '@masknet/web3-shared-base' +import { useReverseAddress, useWeb3State } from '@masknet/plugin-infra/web3' +import { ZERO_ADDRESS } from '@masknet/web3-shared-evm' + +interface ReverseAddressProps { + address?: string + pluginId?: NetworkPluginID + domainSize?: number + size?: number + fontSize?: string + fontWeight?: number +} + +export const ReversedAddress = memo( + ({ address = ZERO_ADDRESS, pluginId, domainSize, size = 5, fontSize = '14px', fontWeight = 400 }) => { + const { value: domain } = useReverseAddress(pluginId, address) + const { Others } = useWeb3State(pluginId) + if (address === ZERO_ADDRESS) return null + + if (!domain || !Others?.formatDomainName) + return {Others?.formatAddress?.(address, size) ?? address} + + return {Others.formatDomainName(domain, domainSize)} + }, +) diff --git a/packages/mask/src/plugins/Web3Feed/SNSAdaptor/StatusBox.tsx b/packages/mask/src/plugins/Web3Feed/SNSAdaptor/StatusBox.tsx new file mode 100644 index 000000000000..f7c27973fcb3 --- /dev/null +++ b/packages/mask/src/plugins/Web3Feed/SNSAdaptor/StatusBox.tsx @@ -0,0 +1,39 @@ +import { makeStyles } from '@masknet/theme' +import { Box, CircularProgress, Typography } from '@mui/material' +import type { FC } from 'react' +import { useI18N } from '../locales' + +interface Props { + loading?: boolean + empty?: boolean +} + +const useStyles = makeStyles()((theme) => ({ + statusBox: { + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + marginTop: theme.spacing(6), + }, +})) + +export const StatusBox: FC = ({ loading, empty }) => { + const { classes } = useStyles() + const t = useI18N() + if (loading) { + return ( + + + + ) + } + + if (empty) { + return ( + + {t.no_data()} + + ) + } + return null +} diff --git a/packages/mask/src/plugins/Web3Feed/SNSAdaptor/Web3FeedPage.tsx b/packages/mask/src/plugins/Web3Feed/SNSAdaptor/Web3FeedPage.tsx index 848c44c0f269..81dc70a5c505 100644 --- a/packages/mask/src/plugins/Web3Feed/SNSAdaptor/Web3FeedPage.tsx +++ b/packages/mask/src/plugins/Web3Feed/SNSAdaptor/Web3FeedPage.tsx @@ -1,4 +1,10 @@ +import { CollectionDetailCard } from '@masknet/shared' +import { RSS3, RSS3BaseAPI } from '@masknet/web3-providers' import type { NetworkPluginID, SocialAddress } from '@masknet/web3-shared-base' +import { useState } from 'react' +import { useAsyncRetry } from 'react-use' +import { FeedCard } from './FeedCard' +import { StatusBox } from './StatusBox' export interface Web3FeedPageProps { persona?: string @@ -6,7 +12,41 @@ export interface Web3FeedPageProps { } export function Web3FeedPage({ socialAddress, persona }: Web3FeedPageProps) { + const [selectedFeed, setSelectedFeed] = useState() + const { value: feed, loading } = useAsyncRetry(async () => { + if (!socialAddress?.address) return + return RSS3.getWeb3Feed(socialAddress?.address) + }, [socialAddress]) + console.log({ feed, socialAddress }) + if (!socialAddress) return null + if (loading || !feed?.list?.length) { + return + } - return
a
+ return ( +
+ {feed?.list?.map((info, index) => { + return ( + setSelectedFeed(feed)} + feed={info} + address={socialAddress?.address} + /> + ) + })} + setSelectedFeed(undefined)} + img={selectedFeed?.imageURL} + title={selectedFeed?.title} + relatedURLs={selectedFeed?.related_urls} + description={selectedFeed?.summary} + metadata={selectedFeed?.metadata} + traits={selectedFeed?.traits} + /> +
+ ) } diff --git a/packages/mask/src/plugins/Web3Feed/SNSAdaptor/index.tsx b/packages/mask/src/plugins/Web3Feed/SNSAdaptor/index.tsx index 746aa60e6916..e97baea9383f 100644 --- a/packages/mask/src/plugins/Web3Feed/SNSAdaptor/index.tsx +++ b/packages/mask/src/plugins/Web3Feed/SNSAdaptor/index.tsx @@ -10,7 +10,7 @@ const sns: Plugin.SNSAdaptor.Definition = { { ID: `${PLUGIN_ID}_web3Feed`, label: 'Web3Feed', - priority: 1, + priority: 4, UI: { TabContent: ({ socialAddress, persona }) => { return diff --git a/packages/mask/src/plugins/Web3Feed/constants.ts b/packages/mask/src/plugins/Web3Feed/constants.ts index 2210389b7d9c..4b7cb0aac151 100644 --- a/packages/mask/src/plugins/Web3Feed/constants.ts +++ b/packages/mask/src/plugins/Web3Feed/constants.ts @@ -1,5 +1,10 @@ import { PluginId } from '@masknet/plugin-infra' - +import { ChainId } from '@masknet/web3-shared-evm' export const PLUGIN_ID = PluginId.Web3Feed export const PLUGIN_NAME = 'Web3 Feed' export const PLUGIN_DESCRIPTION = 'web3 user collection feed' +export const ChainID = { + ethereum: ChainId.Mainnet, + polygon: ChainId.Matic, + bnb: ChainId.BSC, +} diff --git a/packages/mask/src/plugins/Web3Feed/locales/en-US.json b/packages/mask/src/plugins/Web3Feed/locales/en-US.json index 0967ef424bce..a4c12123a73d 100644 --- a/packages/mask/src/plugins/Web3Feed/locales/en-US.json +++ b/packages/mask/src/plugins/Web3Feed/locales/en-US.json @@ -1 +1,6 @@ -{} +{ + "days": "days", + "hours": "hours", + "ago": "ago", + "no_data": "no data" +} diff --git a/packages/shared/src/UI/components/CollectionDetailCard/assets/etherscan.png b/packages/shared/src/UI/components/CollectionDetailCard/assets/etherscan.png new file mode 100644 index 0000000000000000000000000000000000000000..7561d51c5f7fd55a8429b4e3128563e4d9ed6792 GIT binary patch literal 4088 zcmV8yUV-;UsYfN3kOs#g<)!MuA3bLPKv=U0ut2_n!IVRW;Rn0S!36?|WZ$b=~Fs z?z#7zbI-kxaQvWPFeswY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tR1 void date?: string location?: string + relatedURLs?: string[] + metadata?: RSS3BaseAPI.Metadata + traits?: Array<{ + type: string + value: string + }> } const useStyles = makeStyles()((theme) => ({ img: { flexShrink: 1, - height: 300, - width: 300, + height: '300px !important', + width: '300px !important', borderRadius: 8, objectFit: 'cover', }, + loadingFailImage: { + minHeight: '0 !important', + maxWidth: 'none', + width: 300, + height: 300, + }, flexItem: { display: 'flex', width: '100%', @@ -75,22 +88,140 @@ const useStyles = makeStyles()((theme) => ({ themeColor: { color: theme.palette.maskColor.highlight, }, + linkLogo: { + width: 24, + height: 24, + }, + icons: { + margin: '16px 0 16px 0', + display: 'flex', + alignItems: 'center', + }, + traitsBox: { + marginTop: 16, + gridRowGap: 16, + gridColumnGap: 20, + display: 'grid', + gridTemplateColumns: 'repeat(3, 170px)', + }, + traitItem: { + backgroundColor: theme.palette.maskColor.bg, + borderRadius: 8, + padding: 12, + }, + traitValue: { + fontSize: 14, + fontWeight: 700, + color: theme.palette.maskColor.main, + }, + secondText: { + fontSize: 14, + fontWeight: 400, + color: theme.palette.maskColor.second, + }, })) +const ChainID = { + ethereum: ChainId.Mainnet, + polygon: ChainId.Matic, + bnb: ChainId.BSC, +} + export const CollectionDetailCard = memo( - ({ img, open, onClose, title, referenceUrl, description, contributions, date, location }) => { + ({ + img, + open, + onClose, + title, + referenceUrl, + metadata, + description, + contributions, + date, + location, + relatedURLs, + traits, + }) => { const t = useSharedI18N() const { classes } = useStyles() + const icons = relatedURLs?.map((url) => { + if (url.includes('etherscan.io')) { + return ( + + + + ) + } + // if (url.includes('polygonscan.com/tx')) { + // return ( + // + // {' '} + // Polygonscan + // + // ) + // } + if (url.includes('polygonscan.com/token')) { + return ( + + + + ) + } + if (url.includes('opensea.io')) { + return ( + + + + ) + } + if (url.includes('gitcoin.co')) { + return ( + + + + ) + } + return null + }) + return ( + {/* + {isImageToken ? ( + + ) : ( + + )} + */} - +
+ +
+ {title} +
{icons}
+ {referenceUrl} @@ -111,6 +242,7 @@ export const CollectionDetailCard = memo(
{description}
+ {contributions ? ( {t.contributions()} @@ -143,6 +275,19 @@ export const CollectionDetailCard = memo(
))} + {traits && ( + + {t.properties()} + + )} + + {traits?.map((trait) => ( +
+ {trait?.type} + {trait?.value} +
+ ))} +
) diff --git a/packages/shared/src/locales/en-US.json b/packages/shared/src/locales/en-US.json index a8a1834b8cda..dd1f8f93564c 100644 --- a/packages/shared/src/locales/en-US.json +++ b/packages/shared/src/locales/en-US.json @@ -50,6 +50,7 @@ "days": "days", "hours": "hours", "ago": "ago", + "properties": "Properties", "security_detection": "Security Detection", "risky_items": "{{quantity}} Risky factors", "attention_items": "{{quantity}} Attention factors", diff --git a/packages/web3-providers/src/rss3/constants.ts b/packages/web3-providers/src/rss3/constants.ts index ce955863566a..dbda73f602ec 100644 --- a/packages/web3-providers/src/rss3/constants.ts +++ b/packages/web3-providers/src/rss3/constants.ts @@ -1,7 +1,7 @@ import { NetworkPluginID } from '@masknet/web3-shared-base' export const RSS3_ENDPOINT = 'https://hub.pass3.me' -export const RSS3_FEED_ENDPOINT = 'https://pregod.rss3.dev/v0.4.0./' +export const RSS3_FEED_ENDPOINT = 'https://pregod.rss3.dev/v0.4.0/' export const PLATFORM = { [NetworkPluginID.PLUGIN_EVM]: 'ethereum', diff --git a/packages/web3-providers/src/rss3/index.ts b/packages/web3-providers/src/rss3/index.ts index 595423f65c0b..4f7730528db3 100644 --- a/packages/web3-providers/src/rss3/index.ts +++ b/packages/web3-providers/src/rss3/index.ts @@ -1,7 +1,7 @@ import urlcat from 'urlcat' import RSS3 from 'rss3-next' import { ChainId, SchemaType } from '@masknet/web3-shared-evm' -import { PLATFORM, RSS3_ENDPOINT, RSS3_FEED_ENDPOINT, CollectionType, NEW_RSS3_ENDPOINT } from './constants' +import { PLATFORM, RSS3_ENDPOINT, CollectionType, NEW_RSS3_ENDPOINT, RSS3_FEED_ENDPOINT } from './constants' import { NonFungibleTokenAPI, RSS3BaseAPI } from '../types' import { fetchJSON } from '../helpers' import { createIndicator, createPageable, HubOptions, NetworkPluginID, TokenType } from '@masknet/web3-shared-base' @@ -116,12 +116,18 @@ export class RSS3API implements RSS3BaseAPI.Provider, NonFungibleTokenAPI.Provid type?: RSS3BaseAPI.FeedType, ) { if (!address) return - const url = urlcat(RSS3_FEED_ENDPOINT, `account:${address}@${PLATFORM[networkPluginId]}/notes`, { - limit: 1000, - exclude_tags: 'POAP', - // TODO: add type for filtering - latest: false, - }) - return fetchJSON(url) + // const url = urlcat(RSS3_FEED_ENDPOINT, 'account::address@:platform/notes', { + // address, + // platform: PLATFORM[networkPluginId], + // limit: 100, + // tags: 'Donation/&tags=NFT&tags=ETH&tags=POAP&tags=Gitcoin', + // tags: 'kk', + // exclude_tags: 'POAP', + // latest: false, + // }) + // + const url = `${RSS3_FEED_ENDPOINT}account:${address}@${PLATFORM[networkPluginId]}/notes?limit=100&exclude_tags=POAP&tags=Gitcoin&tags=POAP&tags=NFT&tags=Donation&latest=false` + const res = fetchJSON(url) + return res } } diff --git a/packages/web3-providers/src/types.ts b/packages/web3-providers/src/types.ts index 99c8b42402da..1f81c557c888 100644 --- a/packages/web3-providers/src/types.ts +++ b/packages/web3-providers/src/types.ts @@ -220,10 +220,24 @@ export namespace RSS3BaseAPI { type?: string } - export type Tags = 'NFT' | 'Token' | 'POAP' | 'Gitcoin' | 'Mirror Entry' + export type Tags = 'NFT' | 'Token' | 'POAP' | 'Gitcoin' | 'Mirror Entry' | 'ETH' export type FeedType = 'Token' | 'Donation' | 'NFT' + export interface Metadata { + collection_address?: string + collection_name?: string + contract_type?: string + from?: string + log_index?: string + network?: 'polygon' | 'ethereum' | 'bnb' + proof?: string + to?: string + token_id?: string + token_standard?: string + token_symbol?: string + token_address?: string + } export interface Web3Feed { attachments?: Attachments[] authors: string[] @@ -239,6 +253,12 @@ export namespace RSS3BaseAPI { tags: Tags[] summary?: string title?: string + metadata?: Metadata + imageURL?: string + traits?: Array<{ + type: string + value: string + }> } export interface Web3FeedResponse { From 8fc13c84c301ce769de78e626150a5fb2975c28c Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Fri, 22 Jul 2022 10:07:13 +0800 Subject: [PATCH 128/179] feat: change nextID page UI --- packages/icons/plugins/WalletUnderTabs.svg | 4 ++++ .../InjectedComponents/ProfileTabContent.tsx | 1 - .../src/plugins/NextID/components/NextIdPage.tsx | 15 +++++---------- .../src/UI/components/ConcealableTabs/index.tsx | 14 ++++++-------- 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/packages/icons/plugins/WalletUnderTabs.svg b/packages/icons/plugins/WalletUnderTabs.svg index 01949d149918..adfe652e2ebe 100644 --- a/packages/icons/plugins/WalletUnderTabs.svg +++ b/packages/icons/plugins/WalletUnderTabs.svg @@ -1,21 +1,25 @@ ({ root: {}, content: { position: 'relative', - padding: theme.spacing(2, 1), }, })) diff --git a/packages/mask/src/plugins/NextID/components/NextIdPage.tsx b/packages/mask/src/plugins/NextID/components/NextIdPage.tsx index 54a62e4b3291..fc0140de089c 100644 --- a/packages/mask/src/plugins/NextID/components/NextIdPage.tsx +++ b/packages/mask/src/plugins/NextID/components/NextIdPage.tsx @@ -1,4 +1,4 @@ -import { NewLinkOut, Plugin, Verified, WalletUnderTabs, Web3Profile, Connect, Identity } from '@masknet/icons' +import { Plugin, WalletUnderTabs, Web3Profile, Connect, Identity, LinkOut } from '@masknet/icons' import { PluginId, useIsMinimalMode } from '@masknet/plugin-infra/content-script' import { useChainId } from '@masknet/plugin-infra/web3' import { NextIDPlatform, PopupRoutes, EMPTY_LIST } from '@masknet/shared-base' @@ -60,7 +60,6 @@ const useStyles = makeStyles()((theme) => ({ container: { background: 'linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.8) 100%), linear-gradient(90deg, rgba(28, 104, 243, 0.2) 0%, rgba(45, 41, 253, 0.2) 100%), #FFFFFF;', - borderRadius: '16px', padding: '14px 14px 16px 14px ', height: '166px', display: 'flex', @@ -89,10 +88,6 @@ const useStyles = makeStyles()((theme) => ({ backgroundColor: theme.palette.background.default, height: '196px', }, - walletIcon: { - fontSize: 18, - marginRight: 8, - }, web3Icon: { marginRight: 6, marginTop: 2, @@ -228,7 +223,7 @@ export function NextIdPage({ persona }: NextIdPageProps) { if (!isAccountVerified && isOwn) { return ( ) @@ -236,7 +231,7 @@ export function NextIdPage({ persona }: NextIdPageProps) { setDescription(t.add_wallet_intro()) return ( ) @@ -277,8 +272,8 @@ export function NextIdPage({ persona }: NextIdPageProps) { href="https://mask.io/" width="22px" height="22px" - style={{ alignSelf: 'center', marginTop: '2px' }}> - + style={{ alignSelf: 'center', marginLeft: '4px' }}> +
diff --git a/packages/shared/src/UI/components/ConcealableTabs/index.tsx b/packages/shared/src/UI/components/ConcealableTabs/index.tsx index db5f48022751..ab330a171e3b 100644 --- a/packages/shared/src/UI/components/ConcealableTabs/index.tsx +++ b/packages/shared/src/UI/components/ConcealableTabs/index.tsx @@ -71,15 +71,11 @@ const useStyles = makeStyles()((theme) => ({ display: 'flex', flexGrow: 0, alignItems: 'center', - borderLeft: `1px solid ${theme.palette.divider}`, }, controller: { display: 'flex', - minWidth: 35, - color: theme.palette.text.primary, + color: theme.palette.maskColor.second, border: 'none', - width: 35, - height: 35, borderRadius: 0, boxSizing: 'border-box', alignItems: 'center', @@ -91,7 +87,7 @@ const useStyles = makeStyles()((theme) => ({ backgroundColor: theme.palette.background.paper, }, '&[disabled]': { - backgroundColor: theme.palette.background.default, + color: theme.palette.maskColor.second, }, }, walletButton: { @@ -342,7 +338,7 @@ export function ConcealableTabs({
{overflow ? ( <> - + */} + slide(false)} /> + slide(true)} /> ) : null} {tail} From ff1afccedede1c142f09c67418e962f2b2236994 Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Fri, 22 Jul 2022 10:40:32 +0800 Subject: [PATCH 129/179] feat: delete useless code --- packages/mask/shared-ui/locales/en-US.json | 1 + .../InjectedComponents/ProfileTabContent.tsx | 2 -- .../CollectibleList/index.tsx | 2 +- .../plugins/Web3Feed/SNSAdaptor/FeedCard.tsx | 25 ++----------------- .../src/plugins/Web3Feed/locales/en-US.json | 2 +- .../src/plugins/Web3Feed/locales/qya-AA.json | 5 +--- .../SNSAdaptor/components/WalletAssets.tsx | 9 ------- .../components/CollectionDetailCard/index.tsx | 18 ++++++------- packages/web3-providers/src/rss3/index.ts | 10 -------- 9 files changed, 13 insertions(+), 61 deletions(-) diff --git a/packages/mask/shared-ui/locales/en-US.json b/packages/mask/shared-ui/locales/en-US.json index 8cd3c29e4b15..e38b578a741f 100644 --- a/packages/mask/shared-ui/locales/en-US.json +++ b/packages/mask/shared-ui/locales/en-US.json @@ -114,6 +114,7 @@ "copied": "Copied", "daily": "Daily", "dashboard_no_collectible_found": "No collectible found.", + "no_nft_found": "No NFT at the current address", "dashboard_collectible_menu_all": "All ({{count}})", "days": "Every {{days}} days", "decrypted_postbox_add_recipients": "Append recipients", diff --git a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx index 578ea7848c2b..3302f494c9fe 100644 --- a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx +++ b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx @@ -179,8 +179,6 @@ export function ProfileTabContent(props: ProfileTabContentProps) { if (hidden) return null - console.log({ identity, isOwn, addressList, personaPublicKey, personaList, selectedAddress }) - if (!identity.identifier?.userId || loadingSocialAddressList || loadingPersonaList) return (
diff --git a/packages/mask/src/extension/options-page/DashboardComponents/CollectibleList/index.tsx b/packages/mask/src/extension/options-page/DashboardComponents/CollectibleList/index.tsx index a5385fd606ff..8ef4a0c35b15 100644 --- a/packages/mask/src/extension/options-page/DashboardComponents/CollectibleList/index.tsx +++ b/packages/mask/src/extension/options-page/DashboardComponents/CollectibleList/index.tsx @@ -290,7 +290,7 @@ export function CollectionList({ return ( - {t('dashboard_no_collectible_found')} + {t('no_nft_found')} ) diff --git a/packages/mask/src/plugins/Web3Feed/SNSAdaptor/FeedCard.tsx b/packages/mask/src/plugins/Web3Feed/SNSAdaptor/FeedCard.tsx index 92404bf332d8..9124d5f6f6b0 100644 --- a/packages/mask/src/plugins/Web3Feed/SNSAdaptor/FeedCard.tsx +++ b/packages/mask/src/plugins/Web3Feed/SNSAdaptor/FeedCard.tsx @@ -77,13 +77,6 @@ export function FeedCard({ feed, address, index, onSelect }: FeedCardProps) { console.log({ feed, res, index }) return res }, [feed?.metadata?.collection_address]) - // const { value: isImageToken, loading } = useImageChecker( - // resolveIPFSLinkFromURL( - // NFTMetadata?.metadata?.imageURL || - // feed?.attachments?.find((attachment) => attachment?.type === 'preview')?.address || - // '', - // ), - // ) const action = useMemo(() => { if (!feed) return @@ -101,7 +94,7 @@ export function FeedCard({ feed, address, index, onSelect }: FeedCardProps) { if (feed?.metadata?.to?.toLowerCase() === address) { return ( - acquire a NFT from {' '} + acquire a NFT from ) } @@ -138,20 +131,6 @@ export function FeedCard({ feed, address, index, onSelect }: FeedCardProps) { const logo = useMemo(() => { if (feed?.tags?.includes('NFT')) { - // return isImageToken ? ( - // attachment?.type === 'preview')?.address || - // '', - // )} - // /> - // ) : ( - // - // - // - // ) return (
{feed?.summary || NFTMetadata?.metadata?.description || NFTMetadata?.collection?.description} || - `#${feed?.metadata?.token_id}`{' '} + `#${feed?.metadata?.token_id}`
diff --git a/packages/mask/src/plugins/Web3Feed/locales/en-US.json b/packages/mask/src/plugins/Web3Feed/locales/en-US.json index a4c12123a73d..60bea0dc36e1 100644 --- a/packages/mask/src/plugins/Web3Feed/locales/en-US.json +++ b/packages/mask/src/plugins/Web3Feed/locales/en-US.json @@ -2,5 +2,5 @@ "days": "days", "hours": "hours", "ago": "ago", - "no_data": "no data" + "no_data": "No feed at the current address" } diff --git a/packages/mask/src/plugins/Web3Feed/locales/qya-AA.json b/packages/mask/src/plugins/Web3Feed/locales/qya-AA.json index 3869bcff6c62..0967ef424bce 100644 --- a/packages/mask/src/plugins/Web3Feed/locales/qya-AA.json +++ b/packages/mask/src/plugins/Web3Feed/locales/qya-AA.json @@ -1,4 +1 @@ -{ - "powered_by": "crwdns17544:0crwdne17544:0", - "find_truman": "crwdns18196:0crwdne18196:0" -} +{} diff --git a/packages/plugins/Web3Profile/src/SNSAdaptor/components/WalletAssets.tsx b/packages/plugins/Web3Profile/src/SNSAdaptor/components/WalletAssets.tsx index e292cba2a5cd..226a0c59b7d1 100644 --- a/packages/plugins/Web3Profile/src/SNSAdaptor/components/WalletAssets.tsx +++ b/packages/plugins/Web3Profile/src/SNSAdaptor/components/WalletAssets.tsx @@ -71,9 +71,6 @@ const useStyles = makeStyles()((theme) => { display: 'grid', justifyItems: 'center', gridTemplateColumns: 'repeat(4, 1fr)', - // display: 'flex', - // flexWrap: 'wrap', - // justifyContent: 'space-between', }, listBox: { display: 'flex', @@ -138,12 +135,6 @@ export function WalletAssetsCard(props: WalletAssetsCardProps) { }, [loadStatus, collectionList]) const loadIcon = useMemo(() => { - if (loadStatus === LOAD_STATUS.Finish) - return ( - - done - - ) if (loadStatus === LOAD_STATUS.Necessary) return ( setLoadStatus(LOAD_STATUS.Finish)} className={classes.loadIcon}> diff --git a/packages/shared/src/UI/components/CollectionDetailCard/index.tsx b/packages/shared/src/UI/components/CollectionDetailCard/index.tsx index 5bf94b557eef..680bd7089418 100644 --- a/packages/shared/src/UI/components/CollectionDetailCard/index.tsx +++ b/packages/shared/src/UI/components/CollectionDetailCard/index.tsx @@ -156,17 +156,13 @@ export const CollectionDetailCard = memo( ) } - // if (url.includes('polygonscan.com/tx')) { - // return ( - // - // {' '} - // Polygonscan - // - // ) - // } + if (url.includes('polygonscan.com/tx')) { + return ( + + + + ) + } if (url.includes('polygonscan.com/token')) { return ( diff --git a/packages/web3-providers/src/rss3/index.ts b/packages/web3-providers/src/rss3/index.ts index 4f7730528db3..730156c6c6ee 100644 --- a/packages/web3-providers/src/rss3/index.ts +++ b/packages/web3-providers/src/rss3/index.ts @@ -116,16 +116,6 @@ export class RSS3API implements RSS3BaseAPI.Provider, NonFungibleTokenAPI.Provid type?: RSS3BaseAPI.FeedType, ) { if (!address) return - // const url = urlcat(RSS3_FEED_ENDPOINT, 'account::address@:platform/notes', { - // address, - // platform: PLATFORM[networkPluginId], - // limit: 100, - // tags: 'Donation/&tags=NFT&tags=ETH&tags=POAP&tags=Gitcoin', - // tags: 'kk', - // exclude_tags: 'POAP', - // latest: false, - // }) - // const url = `${RSS3_FEED_ENDPOINT}account:${address}@${PLATFORM[networkPluginId]}/notes?limit=100&exclude_tags=POAP&tags=Gitcoin&tags=POAP&tags=NFT&tags=Donation&latest=false` const res = fetchJSON(url) return res From 8cf03c0be9d953c19cb797414861eafe0b1a752c Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Fri, 22 Jul 2022 11:12:35 +0800 Subject: [PATCH 130/179] feat: change code style --- .../popups/pages/Wallet/components/WalletHeader/UI.tsx | 6 ++++-- .../plugins/Wallet/SNSAdaptor/TransactionSnackbar/index.tsx | 2 +- .../mask/src/plugins/Web3Feed/SNSAdaptor/Web3FeedPage.tsx | 1 - .../plugins/RSS3/src/SNSAdaptor/components/StatusBox.tsx | 5 +++-- .../plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx | 2 +- .../plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx | 2 +- packages/plugins/RSS3/src/locales/en-US.json | 2 +- 7 files changed, 11 insertions(+), 9 deletions(-) diff --git a/packages/mask/src/extension/popups/pages/Wallet/components/WalletHeader/UI.tsx b/packages/mask/src/extension/popups/pages/Wallet/components/WalletHeader/UI.tsx index 5eacef69adbf..354cf9d41865 100644 --- a/packages/mask/src/extension/popups/pages/Wallet/components/WalletHeader/UI.tsx +++ b/packages/mask/src/extension/popups/pages/Wallet/components/WalletHeader/UI.tsx @@ -115,7 +115,8 @@ export const WalletHeaderUI = memo( {!disabled ? ( ) : null} @@ -145,7 +146,8 @@ export const WalletHeaderUI = memo( {!disabled ? ( ) : null}
diff --git a/packages/mask/src/plugins/Wallet/SNSAdaptor/TransactionSnackbar/index.tsx b/packages/mask/src/plugins/Wallet/SNSAdaptor/TransactionSnackbar/index.tsx index 8158716f3029..9fcdec0f5963 100644 --- a/packages/mask/src/plugins/Wallet/SNSAdaptor/TransactionSnackbar/index.tsx +++ b/packages/mask/src/plugins/Wallet/SNSAdaptor/TransactionSnackbar/index.tsx @@ -111,7 +111,7 @@ export function TransactionSnackbar({ pluginID }: Tra {progress.status === TransactionStatusType.SUCCEED ? computed.successfulDescription ?? computed.description : computed.description}{' '} - + ), }, diff --git a/packages/mask/src/plugins/Web3Feed/SNSAdaptor/Web3FeedPage.tsx b/packages/mask/src/plugins/Web3Feed/SNSAdaptor/Web3FeedPage.tsx index 81dc70a5c505..b8dc80fc2534 100644 --- a/packages/mask/src/plugins/Web3Feed/SNSAdaptor/Web3FeedPage.tsx +++ b/packages/mask/src/plugins/Web3Feed/SNSAdaptor/Web3FeedPage.tsx @@ -17,7 +17,6 @@ export function Web3FeedPage({ socialAddress, persona }: Web3FeedPageProps) { if (!socialAddress?.address) return return RSS3.getWeb3Feed(socialAddress?.address) }, [socialAddress]) - console.log({ feed, socialAddress }) if (!socialAddress) return null if (loading || !feed?.list?.length) { diff --git a/packages/plugins/RSS3/src/SNSAdaptor/components/StatusBox.tsx b/packages/plugins/RSS3/src/SNSAdaptor/components/StatusBox.tsx index ddf44b0daf33..799221f4975a 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/components/StatusBox.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/components/StatusBox.tsx @@ -6,6 +6,7 @@ import { useI18N } from '../../locales' interface Props { loading?: boolean empty?: boolean + collection?: string } const useStyles = makeStyles()((theme) => ({ @@ -17,7 +18,7 @@ const useStyles = makeStyles()((theme) => ({ }, })) -export const StatusBox: FC = ({ loading, empty }) => { +export const StatusBox: FC = ({ loading, empty, collection = 'Donation' }) => { const { classes } = useStyles() const t = useI18N() if (loading) { @@ -31,7 +32,7 @@ export const StatusBox: FC = ({ loading, empty }) => { if (empty) { return ( - {t.no_data()} + {t.no_data({ collection })} ) } diff --git a/packages/plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx b/packages/plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx index 4c7b2c82c22f..c7c7726fbb5c 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx @@ -51,7 +51,7 @@ export function DonationPage({ donations = [], loading, address }: DonationPageP const [selectedDonation, setSelectedDonation] = useState() if (loading || !donations.length) { - return + return } return ( <> diff --git a/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx b/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx index e2bffe4eb61a..266b99a8b8fe 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx @@ -18,7 +18,7 @@ export function FootprintPage({ footprints = [], address, loading }: FootprintPa const [selectedFootprint, setSelectedFootprint] = useState() if (loading || !footprints.length) { - return + return } return ( diff --git a/packages/plugins/RSS3/src/locales/en-US.json b/packages/plugins/RSS3/src/locales/en-US.json index c8390d09845c..38525dd9adba 100644 --- a/packages/plugins/RSS3/src/locales/en-US.json +++ b/packages/plugins/RSS3/src/locales/en-US.json @@ -2,7 +2,7 @@ "inactive_project": "Inactive Project", "no_activity_time": "No activity time", "attended": "attended", - "no_data": "No data", + "no_data": "No {{collection}} at the current address", "total_grants": "Total {{count}} Grants", "contribution": "Contribution", "contribution_other": "Contributions", From 6fdb14d844f0cb14dc799d2e04e5b2d51c2f93d2 Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Fri, 22 Jul 2022 11:13:44 +0800 Subject: [PATCH 131/179] fix: typo --- cspell.json | 1 + 1 file changed, 1 insertion(+) diff --git a/cspell.json b/cspell.json index 2efeb3f8b3a7..d2dd760ab577 100644 --- a/cspell.json +++ b/cspell.json @@ -160,6 +160,7 @@ "perma", "pids", "plusplus", + "polygonscan", "pooltogether", "popc", "popper", From efdc13c3ac42d9ed2febc0ce55fc8dd7db8bd3ab Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Fri, 22 Jul 2022 11:29:39 +0800 Subject: [PATCH 132/179] feat: delete useless code --- .../components/CollectionDetailCard/index.tsx | 7 ------- .../UI/components/ConcealableTabs/index.tsx | 18 ------------------ 2 files changed, 25 deletions(-) diff --git a/packages/shared/src/UI/components/CollectionDetailCard/index.tsx b/packages/shared/src/UI/components/CollectionDetailCard/index.tsx index 680bd7089418..8a53bc84cad7 100644 --- a/packages/shared/src/UI/components/CollectionDetailCard/index.tsx +++ b/packages/shared/src/UI/components/CollectionDetailCard/index.tsx @@ -190,13 +190,6 @@ export const CollectionDetailCard = memo( return ( - {/* - {isImageToken ? ( - - ) : ( - - )} - */}
({
{overflow ? ( <> - {/* - */} slide(false)} /> slide(true)} /> From b826c2af0ff7f3b03c698e73dc4b05f7046532d6 Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Fri, 22 Jul 2022 11:39:54 +0800 Subject: [PATCH 133/179] feat: merge develop --- .../components/PluginWalletStatusBar.tsx | 238 ------------------ 1 file changed, 238 deletions(-) delete mode 100644 packages/mask/src/utils/components/PluginWalletStatusBar.tsx diff --git a/packages/mask/src/utils/components/PluginWalletStatusBar.tsx b/packages/mask/src/utils/components/PluginWalletStatusBar.tsx deleted file mode 100644 index bdf5c465a8fc..000000000000 --- a/packages/mask/src/utils/components/PluginWalletStatusBar.tsx +++ /dev/null @@ -1,238 +0,0 @@ -import { - useChainId, - useCurrentWeb3NetworkPluginID, - useProviderDescriptor, - useRecentTransactions, - useNetworkDescriptor, - useAccount, - useWallet, - useReverseAddress, - useWeb3State, - useProviderType, - Web3Helper, -} from '@masknet/plugin-infra/web3' -import { WalletMessages } from '@masknet/plugin-wallet' -import { ImageIcon, WalletIcon } from '@masknet/shared' -import { useRemoteControlledDialog } from '@masknet/shared-base-ui' -import { makeStyles, MaskColorVar, parseColor } from '@masknet/theme' -import { NetworkPluginID, TransactionStatusType, Wallet } from '@masknet/web3-shared-base' -import { Box, Button, CircularProgress, Link, Typography } from '@mui/material' -import { useI18N } from '../i18n-next-ui' -import { LinkOutIcon, ArrowDropIcon, WalletConnect } from '@masknet/icons' -import { useLayoutEffect, useRef, useState, PropsWithChildren } from 'react' -import { ChainId, ProviderType } from '@masknet/web3-shared-evm' -import { isDashboardPage } from '@masknet/shared-base' - -interface WalletStatusBarProps extends PropsWithChildren<{}> { - className?: string - onClick?: (ev: React.MouseEvent) => void - showConnect?: boolean - onlyNetworkIcon?: boolean - expectedAccount?: string - expectedWallet?: Wallet | null - expectedProviderType?: Web3Helper.ProviderTypeAll - expectedPluginID?: NetworkPluginID - expectedChainIdOrNetworkTypeOrID?: string | number -} - -const isDashboard = isDashboardPage() - -const useStyles = makeStyles()((theme) => ({ - root: { - boxSizing: 'content-box', - display: 'flex', - backgroundColor: isDashboard - ? MaskColorVar.mainBackground - : parseColor(theme.palette.maskColor.bottom).setAlpha(0.8).toRgbString(), - boxShadow: `0 0 20px ${parseColor(theme.palette.maskColor.highlight).setAlpha(0.2).toRgbString()}`, - backdropFilter: 'blur(16px)', - padding: theme.spacing(2), - borderRadius: '0 0 12px 12px', - alignItems: 'center', - justifyContent: 'space-between', - flex: 1, - maxHeight: 40, - }, - wallet: { - display: 'flex', - alignItems: 'center', - columnGap: 4, - cursor: 'pointer', - }, - description: { - marginLeft: 11, - }, - walletName: { - display: 'flex', - alignItems: 'center', - columnGap: 4, - color: theme.palette.maskColor.main, - fontWeight: 700, - fontSize: 14, - lineHeight: '18px', - }, - address: { - color: theme.palette.maskColor.second, - fontSize: 14, - lineHeight: '18px', - display: 'flex', - alignItems: 'center', - columnGap: 2, - }, - pending: { - display: 'flex', - alignItems: 'center', - gap: 2, - borderRadius: 2, - padding: '2px 4px', - backgroundColor: parseColor(theme.palette.maskColor.warn).setAlpha(0.1).toRgbString(), - color: theme.palette.maskColor.warn, - fontSize: 14, - lineHeight: '18px', - }, - progress: { - color: theme.palette.maskColor.warn, - }, - linkIcon: { - width: 14, - height: 14, - fontSize: 14, - color: theme.palette.maskColor.second, - cursor: 'pointer', - }, - action: { - display: 'flex', - columnGap: 16, - minWidth: 276, - }, - connection: { - width: 18, - height: 18, - marginRight: 8, - }, -})) -export function PluginWalletStatusBar({ - className, - children, - onClick, - showConnect = false, - expectedWallet, - expectedAccount, - expectedPluginID, - expectedProviderType, - onlyNetworkIcon = false, -}: WalletStatusBarProps) { - const ref = useRef() - const { t } = useI18N() - const [emptyChildren, setEmptyChildren] = useState(false) - const currentPluginId = useCurrentWeb3NetworkPluginID(expectedPluginID) - - const account = useAccount(currentPluginId, expectedAccount) - const currentWallet = useWallet(currentPluginId) - - const wallet = expectedWallet ?? currentWallet - - const chainId = useChainId(currentPluginId) - const { classes, cx } = useStyles() - - const providerDescriptor = useProviderDescriptor(expectedPluginID, expectedProviderType) - - const providerType = useProviderType(expectedPluginID) - const networkDescriptor = useNetworkDescriptor( - onlyNetworkIcon ? NetworkPluginID.PLUGIN_EVM : currentPluginId, - onlyNetworkIcon ? ChainId.Mainnet : chainId, - ) - const { value: domain } = useReverseAddress(currentPluginId, account) - const { Others } = useWeb3State<'all'>(currentPluginId) - - const { openDialog: openSelectProviderDialog } = useRemoteControlledDialog( - WalletMessages.events.selectProviderDialogUpdated, - ) - - const { openDialog: openWalletStatusDialog } = useRemoteControlledDialog( - WalletMessages.events.walletStatusDialogUpdated, - ) - - const pendingTransactions = useRecentTransactions(currentPluginId, TransactionStatusType.NOT_DEPEND) - - useLayoutEffect(() => { - if (ref.current?.children.length && ref.current.children.length > 1) { - setEmptyChildren(false) - } else { - setEmptyChildren(true) - } - }, [children]) - - if (showConnect || !account) { - return ( - - - - ) - } - - return ( - - - {onlyNetworkIcon ? ( - - ) : ( - - )} - - - - {providerType === ProviderType.MaskWallet - ? domain ?? - wallet?.name ?? - providerDescriptor?.name ?? - Others?.formatAddress(account, 4) - : domain ?? providerDescriptor?.name ?? Others?.formatAddress(account, 4)} - - - - - - {Others?.formatAddress(account, 4)} - - - - {pendingTransactions.length ? ( - { - e.stopPropagation() - openWalletStatusDialog() - }}> - {t('recent_transaction_pending')} - - - ) : null} - - - - - - {children} - - - ) -} From 49fb94ca893ee9a51bdafa544bc1ab8396fa9685 Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Fri, 22 Jul 2022 12:03:16 +0800 Subject: [PATCH 134/179] feat: change icon color --- packages/icons/general/DoubleArrowUp.svg | 1 + packages/icons/general/Edit2.svg | 5 ++--- .../pages/Wallet/SwitchWallet/WalletItem.tsx | 4 +++- .../Wallet/components/WalletInfo/index.tsx | 3 ++- .../plugins/Web3Feed/SNSAdaptor/FeedCard.tsx | 1 - .../Web3Feed/SNSAdaptor/Web3FeedPage.tsx | 2 +- .../SNSAdaptor/components/WalletAssets.tsx | 19 ++++++++++++++++--- .../UI/components/ConcealableTabs/index.tsx | 6 +++--- 8 files changed, 28 insertions(+), 13 deletions(-) create mode 100644 packages/icons/general/DoubleArrowUp.svg diff --git a/packages/icons/general/DoubleArrowUp.svg b/packages/icons/general/DoubleArrowUp.svg new file mode 100644 index 000000000000..00d9920f1671 --- /dev/null +++ b/packages/icons/general/DoubleArrowUp.svg @@ -0,0 +1 @@ + diff --git a/packages/icons/general/Edit2.svg b/packages/icons/general/Edit2.svg index 360e0bab4476..ab2ebb5fe72d 100644 --- a/packages/icons/general/Edit2.svg +++ b/packages/icons/general/Edit2.svg @@ -1,6 +1,5 @@ - + - + - \ No newline at end of file diff --git a/packages/mask/src/extension/popups/pages/Wallet/SwitchWallet/WalletItem.tsx b/packages/mask/src/extension/popups/pages/Wallet/SwitchWallet/WalletItem.tsx index 92cee516b9a5..3d3a65acd117 100644 --- a/packages/mask/src/extension/popups/pages/Wallet/SwitchWallet/WalletItem.tsx +++ b/packages/mask/src/extension/popups/pages/Wallet/SwitchWallet/WalletItem.tsx @@ -105,7 +105,9 @@ export const WalletItem = memo(({ wallet, onClick, isSelected } ({Others.formatDomainName(domain)}) ) : null} - {isHovering ? : null} + {isHovering ? ( + + ) : null} diff --git a/packages/mask/src/extension/popups/pages/Wallet/components/WalletInfo/index.tsx b/packages/mask/src/extension/popups/pages/Wallet/components/WalletInfo/index.tsx index 856f829b5747..0a44d9942b3b 100644 --- a/packages/mask/src/extension/popups/pages/Wallet/components/WalletInfo/index.tsx +++ b/packages/mask/src/extension/popups/pages/Wallet/components/WalletInfo/index.tsx @@ -109,7 +109,8 @@ export const WalletInfoUI = memo(
- {name} + {name}{' '} + {domain && formatDomainName ? ( {formatDomainName(domain)} diff --git a/packages/mask/src/plugins/Web3Feed/SNSAdaptor/FeedCard.tsx b/packages/mask/src/plugins/Web3Feed/SNSAdaptor/FeedCard.tsx index 9124d5f6f6b0..43d8ec388447 100644 --- a/packages/mask/src/plugins/Web3Feed/SNSAdaptor/FeedCard.tsx +++ b/packages/mask/src/plugins/Web3Feed/SNSAdaptor/FeedCard.tsx @@ -74,7 +74,6 @@ export function FeedCard({ feed, address, index, onSelect }: FeedCardProps) { const res = await Alchemy_EVM.getAsset(feed?.metadata?.collection_address, feed?.metadata?.token_id ?? '', { chainId: ChainID[feed?.metadata?.network ?? 'ethereum'], }) - console.log({ feed, res, index }) return res }, [feed?.metadata?.collection_address]) diff --git a/packages/mask/src/plugins/Web3Feed/SNSAdaptor/Web3FeedPage.tsx b/packages/mask/src/plugins/Web3Feed/SNSAdaptor/Web3FeedPage.tsx index b8dc80fc2534..af4548481046 100644 --- a/packages/mask/src/plugins/Web3Feed/SNSAdaptor/Web3FeedPage.tsx +++ b/packages/mask/src/plugins/Web3Feed/SNSAdaptor/Web3FeedPage.tsx @@ -24,7 +24,7 @@ export function Web3FeedPage({ socialAddress, persona }: Web3FeedPageProps) { } return ( -
+
{feed?.list?.map((info, index) => { return ( { marginTop: 4, cursor: 'pointer', }, + arrowUp: { + cursor: 'pointer', + color: theme.palette.maskColor.second, + marginRight: 10, + }, + rightIcons: { + display: 'flex', + alignItems: 'center', + }, } }) @@ -162,9 +171,13 @@ export function WalletAssetsCard(props: WalletAssetsCardProps) {
-
+
{loadStatus === LOAD_STATUS.Finish && ( - setLoadStatus(LOAD_STATUS.Necessary)} /> + setLoadStatus(LOAD_STATUS.Necessary)} + /> )}
diff --git a/packages/shared/src/UI/components/ConcealableTabs/index.tsx b/packages/shared/src/UI/components/ConcealableTabs/index.tsx index bdc312691631..cd85381f4ab7 100644 --- a/packages/shared/src/UI/components/ConcealableTabs/index.tsx +++ b/packages/shared/src/UI/components/ConcealableTabs/index.tsx @@ -128,7 +128,7 @@ const useStyles = makeStyles()((theme) => ({ }, }, linkIcon: { - fill: theme.palette.maskColor.second, + color: theme.palette.maskColor.second, fontSize: '20px', margin: '4px 2px 0 2px', }, @@ -250,9 +250,9 @@ export function ConcealableTabs({ } target="_blank" rel="noopener noreferrer"> - + - + Date: Fri, 22 Jul 2022 15:49:44 +0800 Subject: [PATCH 135/179] feat: change web3 tabs style --- .../DashboardComponents/CollectibleList/index.tsx | 2 +- .../src/plugins/Web3Feed/SNSAdaptor/FeedCard.tsx | 13 +++++++------ .../plugins/Web3Feed/SNSAdaptor/Web3FeedPage.tsx | 2 +- .../RSS3/src/SNSAdaptor/pages/DonationsPage.tsx | 6 +++--- .../RSS3/src/SNSAdaptor/pages/FootprintPage.tsx | 7 ++++--- .../UI/components/CollectionDetailCard/index.tsx | 8 ++++---- 6 files changed, 20 insertions(+), 18 deletions(-) diff --git a/packages/mask/src/extension/options-page/DashboardComponents/CollectibleList/index.tsx b/packages/mask/src/extension/options-page/DashboardComponents/CollectibleList/index.tsx index 8ef4a0c35b15..0ecb894d2e79 100644 --- a/packages/mask/src/extension/options-page/DashboardComponents/CollectibleList/index.tsx +++ b/packages/mask/src/extension/options-page/DashboardComponents/CollectibleList/index.tsx @@ -296,7 +296,7 @@ export function CollectionList({ ) return ( - + diff --git a/packages/mask/src/plugins/Web3Feed/SNSAdaptor/FeedCard.tsx b/packages/mask/src/plugins/Web3Feed/SNSAdaptor/FeedCard.tsx index 43d8ec388447..c6865c4d2b8e 100644 --- a/packages/mask/src/plugins/Web3Feed/SNSAdaptor/FeedCard.tsx +++ b/packages/mask/src/plugins/Web3Feed/SNSAdaptor/FeedCard.tsx @@ -3,7 +3,7 @@ import { makeStyles } from '@masknet/theme' import { Alchemy_EVM, RSS3BaseAPI } from '@masknet/web3-providers' import { NetworkPluginID } from '@masknet/web3-shared-base' import { resolveIPFSLinkFromURL, ZERO_ADDRESS } from '@masknet/web3-shared-evm' -import { Box, Typography } from '@mui/material' +import { Box, Typography, Card } from '@mui/material' import differenceInCalendarDays from 'date-fns/differenceInDays' import differenceInCalendarHours from 'date-fns/differenceInHours' import { useMemo } from 'react' @@ -17,11 +17,12 @@ const useStyles = makeStyles()((theme) => ({ display: 'flex', justifyContent: 'space-between', marginBottom: 16, + cursor: 'pointer', }, img: { width: '64px !important', height: '64px !important', - borderRadius: 8, + borderRadius: '8px', objectFit: 'cover', }, collection: { @@ -37,7 +38,7 @@ const useStyles = makeStyles()((theme) => ({ summary: { textOverflow: 'ellipsis', '-webkit-line-clamp': '1', - maxWidth: '300px', + maxWidth: '400px', overflow: 'hidden', display: '-webkit-box', '-webkit-box-orient': 'vertical', @@ -131,7 +132,7 @@ export function FeedCard({ feed, address, index, onSelect }: FeedCardProps) { const logo = useMemo(() => { if (feed?.tags?.includes('NFT')) { return ( -
+ -
+ ) } if (feed?.tags.includes('Token') || feed?.tags.includes('ETH')) { @@ -201,7 +202,7 @@ export function FeedCard({ feed, address, index, onSelect }: FeedCardProps) {
{action} {time} - + {feed?.title || NFTMetadata?.metadata?.name || NFTMetadata?.collection?.name || diff --git a/packages/mask/src/plugins/Web3Feed/SNSAdaptor/Web3FeedPage.tsx b/packages/mask/src/plugins/Web3Feed/SNSAdaptor/Web3FeedPage.tsx index af4548481046..fbe286b630e6 100644 --- a/packages/mask/src/plugins/Web3Feed/SNSAdaptor/Web3FeedPage.tsx +++ b/packages/mask/src/plugins/Web3Feed/SNSAdaptor/Web3FeedPage.tsx @@ -24,7 +24,7 @@ export function Web3FeedPage({ socialAddress, persona }: Web3FeedPageProps) { } return ( -
+
{feed?.list?.map((info, index) => { return ( } return ( - <> + {donations.map((donation) => ( @@ -76,6 +76,6 @@ export function DonationPage({ donations = [], loading, address }: DonationPageP description={selectedDonation?.detail?.grant?.description} contributions={selectedDonation?.detail?.txs} /> - + ) } diff --git a/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx b/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx index 266b99a8b8fe..4fafdb2009ee 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx @@ -1,6 +1,7 @@ import { CollectionDetailCard } from '@masknet/shared' import type { RSS3BaseAPI } from '@masknet/web3-providers' import type { NetworkPluginID, SocialAddress } from '@masknet/web3-shared-base' +import { Box } from '@mui/material' import { useState } from 'react' import { FootprintCard, StatusBox } from '../components' import { useRss3Profile } from '../hooks' @@ -22,8 +23,8 @@ export function FootprintPage({ footprints = [], address, loading }: FootprintPa } return ( - <> -
+ +
{footprints.map((footprint) => ( - + ) } diff --git a/packages/shared/src/UI/components/CollectionDetailCard/index.tsx b/packages/shared/src/UI/components/CollectionDetailCard/index.tsx index 8a53bc84cad7..16cfef510d35 100644 --- a/packages/shared/src/UI/components/CollectionDetailCard/index.tsx +++ b/packages/shared/src/UI/components/CollectionDetailCard/index.tsx @@ -2,7 +2,7 @@ import { memo } from 'react' import { makeStyles } from '@masknet/theme' import { InjectedDialog } from '../../../contexts' import { useSharedI18N } from '../../../locales' -import { Box, DialogContent, Link, Typography } from '@mui/material' +import { Box, Card, DialogContent, Link, Typography } from '@mui/material' import type { RSS3BaseAPI } from '@masknet/web3-providers' import differenceInCalendarDays from 'date-fns/differenceInDays' import differenceInCalendarHours from 'date-fns/differenceInHours' @@ -191,10 +191,10 @@ export const CollectionDetailCard = memo( -
+ ( iframe: classes.img, }} /> -
+
From c66b99e3c0a23c939e6dadd257d6f3a9d2200097 Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Mon, 25 Jul 2022 10:27:05 +0800 Subject: [PATCH 136/179] feat: add plugin tsconfig under mask file --- packages/mask/src/tsconfig.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/mask/src/tsconfig.json b/packages/mask/src/tsconfig.json index b46d44d5a0ba..8e999b505645 100644 --- a/packages/mask/src/tsconfig.json +++ b/packages/mask/src/tsconfig.json @@ -30,6 +30,13 @@ { "path": "../../plugins/Wallet" }, { "path": "../../plugins/DAO" }, { "path": "../../plugins/FileService" }, + { "path": "../../plugins/RSS3" }, + { "path": "../../plugins/Web3Profile" }, + { "path": "../../plugins/example" }, + { "path": "../../plugins/Debugger" }, + { "path": "../../plugins/CyberConnect" }, + { "path": "../../plugins/CrossChainBridge" }, + { "path": "../../plugins/GoPlusSecurity" }, { "path": "../../plugins/EVM" }, { "path": "../../plugins/Flow" }, { "path": "../../plugins/Solana" }, From 831ef4f54e602bcbbdb293d8987e3ab66675a8e9 Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Mon, 25 Jul 2022 10:41:02 +0800 Subject: [PATCH 137/179] fix: type error --- .../GoPlusSecurity/src/SNSAdaptor/components/Common.tsx | 2 +- .../GoPlusSecurity/src/SNSAdaptor/components/SecurityPanel.tsx | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/plugins/GoPlusSecurity/src/SNSAdaptor/components/Common.tsx b/packages/plugins/GoPlusSecurity/src/SNSAdaptor/components/Common.tsx index 403cd516e158..c9263481a078 100644 --- a/packages/plugins/GoPlusSecurity/src/SNSAdaptor/components/Common.tsx +++ b/packages/plugins/GoPlusSecurity/src/SNSAdaptor/components/Common.tsx @@ -15,7 +15,7 @@ export enum SecurityMessageLevel { Safe = 'Safe', } -export const Center = memo(({ children }) => ( +export const Center = memo(({ children }: { children: ReactNode }) => ( {children} diff --git a/packages/plugins/GoPlusSecurity/src/SNSAdaptor/components/SecurityPanel.tsx b/packages/plugins/GoPlusSecurity/src/SNSAdaptor/components/SecurityPanel.tsx index 12a067f6c7d9..7b0b595440be 100644 --- a/packages/plugins/GoPlusSecurity/src/SNSAdaptor/components/SecurityPanel.tsx +++ b/packages/plugins/GoPlusSecurity/src/SNSAdaptor/components/SecurityPanel.tsx @@ -13,6 +13,7 @@ import type { TokenAPI } from '@masknet/web3-providers' import { DefaultTokenIcon, LinkOutIcon } from '@masknet/icons' import type { ChainId, SchemaType } from '@masknet/web3-shared-evm' import { formatCurrency, FungibleToken } from '@masknet/web3-shared-base' +import type { SecurityMessage } from '../rules' interface TokenCardProps { tokenSecurity: TokenSecurity @@ -209,7 +210,7 @@ export const SecurityPanel = memo(({ tokenSecurity, tokenInfo, t {makeMessageList.map((x, i) => ( - + ))} {(!makeMessageList.length || securityMessageLevel === SecurityMessageLevel.Safe) && ( Date: Mon, 25 Jul 2022 18:15:25 +0800 Subject: [PATCH 138/179] feat: add network icon to NFT img --- .../CollectibleList/CollectibleCard.tsx | 8 +++++++- .../SNSAdaptor/components/CollectionList.tsx | 6 ++++-- .../src/SNSAdaptor/components/WalletAssets.tsx | 1 + .../Web3Profile/src/SNSAdaptor/types.ts | 2 ++ .../Web3Profile/src/SNSAdaptor/utils.ts | 2 ++ .../src/UI/components/AssetPlayer/index.tsx | 7 ++++--- .../components/CollectionDetailCard/index.tsx | 2 +- .../shared/src/UI/components/NFTCard/index.tsx | 18 +++++++++++++++--- .../NFTCardStyledAssetPlayer/index.tsx | 13 +++++++++++++ 9 files changed, 49 insertions(+), 10 deletions(-) diff --git a/packages/mask/src/extension/options-page/DashboardComponents/CollectibleList/CollectibleCard.tsx b/packages/mask/src/extension/options-page/DashboardComponents/CollectibleList/CollectibleCard.tsx index 7ca1fe186398..382a5e0a80c5 100644 --- a/packages/mask/src/extension/options-page/DashboardComponents/CollectibleList/CollectibleCard.tsx +++ b/packages/mask/src/extension/options-page/DashboardComponents/CollectibleList/CollectibleCard.tsx @@ -4,6 +4,7 @@ import { NFTCardStyledAssetPlayer } from '@masknet/shared' import { ActionsBarNFT } from '../ActionsBarNFT' import type { NonFungibleToken, SourceType, Wallet } from '@masknet/web3-shared-base' import type { Web3Helper } from '@masknet/plugin-infra/src/entry-web3' +import { resolveOpenSeaLink } from '@masknet/web3-shared-evm' const useStyles = makeStyles()((theme) => ({ root: { @@ -67,7 +68,11 @@ export function CollectibleCard(props: CollectibleCardProps) { const { classes } = useStyles() return ( - +
{readonly || !wallet ? null : ( @@ -83,6 +88,7 @@ export function CollectibleCard(props: CollectibleCardProps) { loadingFailImage: classes.loadingFailImage, wrapper: classes.wrapper, }} + showNetwork /> diff --git a/packages/plugins/Web3Profile/src/SNSAdaptor/components/CollectionList.tsx b/packages/plugins/Web3Profile/src/SNSAdaptor/components/CollectionList.tsx index 0c174f22ff1c..a8bf874f0925 100644 --- a/packages/plugins/Web3Profile/src/SNSAdaptor/components/CollectionList.tsx +++ b/packages/plugins/Web3Profile/src/SNSAdaptor/components/CollectionList.tsx @@ -11,9 +11,10 @@ interface CollectionListProps extends withClasses void size?: number + showNetwork?: boolean } export function CollectionList(props: CollectionListProps) { - const { collections, onList, size = 64 } = props + const { collections, onList, size = 64, showNetwork = false } = props const classes = useStylesExtends(useStyles(), props) return ( @@ -24,13 +25,14 @@ export function CollectionList(props: CollectionListProps) { className={classes.collectionWrap} onClick={() => onList?.(collection.key)}> {loadIcon} diff --git a/packages/plugins/Web3Profile/src/SNSAdaptor/types.ts b/packages/plugins/Web3Profile/src/SNSAdaptor/types.ts index 80c6e4464e92..7df32ca76cba 100644 --- a/packages/plugins/Web3Profile/src/SNSAdaptor/types.ts +++ b/packages/plugins/Web3Profile/src/SNSAdaptor/types.ts @@ -1,5 +1,6 @@ import type { BindingProof, NextIDPlatform, ProfileInformation } from '@masknet/shared-base' import type { NetworkPluginID } from '@masknet/web3-shared-base' +import type { ChainId } from '@masknet/web3-shared-evm' export interface GeneralAsset { platform: string @@ -53,6 +54,7 @@ export interface CollectionTypes { iconURL?: string hidden?: boolean name?: string + chainId?: ChainId } export interface Collection { diff --git a/packages/plugins/Web3Profile/src/SNSAdaptor/utils.ts b/packages/plugins/Web3Profile/src/SNSAdaptor/utils.ts index d5d6b05aac12..e2111d02ca17 100644 --- a/packages/plugins/Web3Profile/src/SNSAdaptor/utils.ts +++ b/packages/plugins/Web3Profile/src/SNSAdaptor/utils.ts @@ -192,6 +192,7 @@ export const getNFTList = async (walletList: WalletTypes[]) => { tokenId: asset.tokenId, iconURL: asset?.metadata?.imageURL, name: asset?.metadata?.name, + chainId: ChainId.Mainnet, })), } } else { @@ -218,6 +219,7 @@ export const getNFTList_Polygon = async (walletList: WalletTypes[]) => { tokenId: asset.tokenId, iconURL: asset?.metadata?.imageURL, name: asset?.metadata?.name, + chainId: ChainId.Matic, })), } } else { diff --git a/packages/shared/src/UI/components/AssetPlayer/index.tsx b/packages/shared/src/UI/components/AssetPlayer/index.tsx index 8b28e14476a1..25b952719be6 100644 --- a/packages/shared/src/UI/components/AssetPlayer/index.tsx +++ b/packages/shared/src/UI/components/AssetPlayer/index.tsx @@ -38,6 +38,7 @@ interface AssetPlayerProps fallbackResourceLoader?: JSX.Element setERC721TokenName?: (name: string) => void setSourceType?: (type: string) => void + showNetwork?: boolean } const useStyles = makeStyles()({ hidden: { @@ -55,7 +56,7 @@ enum AssetPlayerState { export const AssetPlayer = memo((props) => { const ref = useRef(null) - const { url, type, options, iconProps, isFixedIframeSize = true } = props + const { url, type, options, iconProps, isFixedIframeSize = true, showNetwork = false } = props const classes = useStylesExtends(useStyles(), props) const [hidden, setHidden] = useState(Boolean(props.renderTimeout)) const { RPC_URLS } = getRPCConstants(props.erc721Token?.chainId) @@ -188,7 +189,7 @@ export const AssetPlayer = memo((props) => { ) return ( - <> + ((props) => { : props.loadingIcon ?? } {IframeResizerMemo} - + ) }) diff --git a/packages/shared/src/UI/components/CollectionDetailCard/index.tsx b/packages/shared/src/UI/components/CollectionDetailCard/index.tsx index 16cfef510d35..d7d01bf97474 100644 --- a/packages/shared/src/UI/components/CollectionDetailCard/index.tsx +++ b/packages/shared/src/UI/components/CollectionDetailCard/index.tsx @@ -158,7 +158,7 @@ export const CollectionDetailCard = memo( } if (url.includes('polygonscan.com/tx')) { return ( - + ) diff --git a/packages/shared/src/UI/components/NFTCard/index.tsx b/packages/shared/src/UI/components/NFTCard/index.tsx index 241ea284d505..549219c934a8 100644 --- a/packages/shared/src/UI/components/NFTCard/index.tsx +++ b/packages/shared/src/UI/components/NFTCard/index.tsx @@ -1,8 +1,8 @@ import { MaskAvatarIcon, SelectedIcon } from '@masknet/icons' -import { useImageChecker } from '@masknet/shared' +import { ImageIcon, useImageChecker } from '@masknet/shared' import { makeStyles, ShadowRootTooltip } from '@masknet/theme' import { isSameAddress, NetworkPluginID, NonFungibleToken } from '@masknet/web3-shared-base' -import type { ChainId, SchemaType } from '@masknet/web3-shared-evm' +import { ChainId, NETWORK_DESCRIPTORS, SchemaType } from '@masknet/web3-shared-evm' import { Box, Skeleton } from '@mui/material' import classNames from 'classnames' @@ -81,6 +81,11 @@ const useStyles = makeStyles<{ networkPluginID: NetworkPluginID }>()((theme, pro maskIcon: { fontSize: 30, }, + networkIcon: { + position: 'absolute', + top: 6, + right: 6, + }, })) interface NFTImageCollectibleAvatarProps { @@ -89,6 +94,7 @@ interface NFTImageCollectibleAvatarProps { selectedToken?: NonFungibleToken pluginId: NetworkPluginID size?: number + showNetwork?: boolean } export function NFTImageCollectibleAvatar({ @@ -97,6 +103,7 @@ export function NFTImageCollectibleAvatar({ selectedToken, pluginId, size = 126, + showNetwork = false, }: NFTImageCollectibleAvatarProps) { const { classes } = useStyles({ networkPluginID: pluginId }) const { value: isImageToken, loading } = useImageChecker(token.metadata?.imageURL) @@ -121,6 +128,7 @@ export function NFTImageCollectibleAvatar({ token={token} selectedToken={selectedToken} onChange={onChange} + showNetwork={showNetwork} /> ) : ( @@ -138,6 +146,7 @@ interface NFTImageProps { selectedToken?: NonFungibleToken onChange?: (token: NonFungibleToken) => void size?: number + showNetwork?: boolean } function isSameNFT( @@ -154,8 +163,9 @@ function isSameNFT( } export function NFTImage(props: NFTImageProps) { - const { token, onChange, selectedToken, showBadge = false, pluginId, size = 126 } = props + const { token, onChange, selectedToken, showBadge = false, pluginId, size = 126, showNetwork = false } = props const { classes } = useStyles({ networkPluginID: pluginId }) + const iconURL = NETWORK_DESCRIPTORS.find((network) => network?.chainId === token.chainId)?.icon return ( @@ -169,6 +179,8 @@ export function NFTImage(props: NFTImageProps) { isSameNFT(pluginId, token, selectedToken) ? classes.itemSelected : '', )} /> + {showNetwork && } + {showBadge && isSameNFT(pluginId, token, selectedToken) ? ( ) : null} diff --git a/packages/shared/src/UI/components/NFTCardStyledAssetPlayer/index.tsx b/packages/shared/src/UI/components/NFTCardStyledAssetPlayer/index.tsx index fdce784ef46f..23e450d057cb 100644 --- a/packages/shared/src/UI/components/NFTCardStyledAssetPlayer/index.tsx +++ b/packages/shared/src/UI/components/NFTCardStyledAssetPlayer/index.tsx @@ -5,6 +5,8 @@ import { AssetPlayer } from '../AssetPlayer' import { useNonFungibleToken, Web3Helper } from '@masknet/plugin-infra/web3' import { NetworkPluginID } from '@masknet/web3-shared-base' import { useImageChecker } from '../../../hooks' +import { NETWORK_DESCRIPTORS } from '@masknet/web3-shared-evm' +import { ImageIcon } from '../ImageIcon' const useStyles = makeStyles()((theme) => ({ wrapper: { @@ -29,6 +31,12 @@ const useStyles = makeStyles()((theme) => ({ display: 'flex', justifyContent: 'center', alignItems: 'center', + position: 'relative', + }, + networkIcon: { + position: 'absolute', + top: 6, + right: 6, }, })) @@ -43,6 +51,7 @@ interface Props extends withClasses<'loadingFailImage' | 'iframe' | 'wrapper' | isNative?: boolean setERC721TokenName?: (name: string) => void setSourceType?: (type: string) => void + showNetwork?: boolean } const assetPlayerFallbackImageDark = new URL('./nft_token_fallback_dark.png', import.meta.url) @@ -60,6 +69,7 @@ export function NFTCardStyledAssetPlayer(props: Props) { setERC721TokenName, renderOrder, setSourceType, + showNetwork = false, } = props const classes = useStylesExtends(useStyles(), props) const theme = useTheme() @@ -79,6 +89,8 @@ export function NFTCardStyledAssetPlayer(props: Props) { const fallbackImageURL = theme.palette.mode === 'dark' ? assetPlayerFallbackImageDark : assetPlayerFallbackImageLight + const networkIcon = NETWORK_DESCRIPTORS.find((network) => network?.chainId === chainId)?.icon + return isImageToken || isNative ? (
+ {showNetwork && }
) : ( Date: Mon, 25 Jul 2022 18:16:58 +0800 Subject: [PATCH 139/179] feat: add plugin --- packages/mask/shared/plugin-infra/register.js | 1 + .../src/components/InjectedComponents/ProfileTabContent.tsx | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/mask/shared/plugin-infra/register.js b/packages/mask/shared/plugin-infra/register.js index e213700c7f1f..2bb2a9162d35 100644 --- a/packages/mask/shared/plugin-infra/register.js +++ b/packages/mask/shared/plugin-infra/register.js @@ -36,6 +36,7 @@ import '../../src/plugins/Referral' import '../../src/plugins/Tips' import '../../src/plugins/Approval' import '@masknet/plugin-web3-profile' +import '../../src/plugins/Web3Feed' // import '../../src/plugins/dHEDGE' // import '../../src/plugins/External' // import '../../src/plugins/Polls' diff --git a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx index 984d84212798..d8b15ce43e99 100644 --- a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx +++ b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx @@ -184,7 +184,8 @@ export function ProfileTabContent(props: ProfileTabContentProps) { if (hidden) return null - if (!identity.identifier?.userId || loadingSocialAddressList || loadingPersonaList) + // loadingSocialAddress + if (!identity.identifier?.userId || loadingPersonaList) return (
Date: Tue, 26 Jul 2022 10:02:45 +0800 Subject: [PATCH 140/179] fix: code usage specification --- packages/mask/shared-ui/locales/en-US.json | 2 +- .../DashboardComponents/CollectibleList/index.tsx | 2 +- .../popups/pages/Personas/components/PersonaHeader/UI.tsx | 3 ++- .../mask/src/plugins/NextID/components/NextIdPage.tsx | 2 +- .../src/UI/components/CollectionDetailCard/index.tsx | 8 ++------ .../shared/src/UI/components/ConcealableTabs/index.tsx | 2 +- 6 files changed, 8 insertions(+), 11 deletions(-) diff --git a/packages/mask/shared-ui/locales/en-US.json b/packages/mask/shared-ui/locales/en-US.json index e38b578a741f..86c3eb587f4b 100644 --- a/packages/mask/shared-ui/locales/en-US.json +++ b/packages/mask/shared-ui/locales/en-US.json @@ -114,7 +114,7 @@ "copied": "Copied", "daily": "Daily", "dashboard_no_collectible_found": "No collectible found.", - "no_nft_found": "No NFT at the current address", + "no_nft_at_current_address": "No NFT at the current address", "dashboard_collectible_menu_all": "All ({{count}})", "days": "Every {{days}} days", "decrypted_postbox_add_recipients": "Append recipients", diff --git a/packages/mask/src/extension/options-page/DashboardComponents/CollectibleList/index.tsx b/packages/mask/src/extension/options-page/DashboardComponents/CollectibleList/index.tsx index 0ecb894d2e79..c4a32e336ee9 100644 --- a/packages/mask/src/extension/options-page/DashboardComponents/CollectibleList/index.tsx +++ b/packages/mask/src/extension/options-page/DashboardComponents/CollectibleList/index.tsx @@ -290,7 +290,7 @@ export function CollectionList({ return ( - {t('no_nft_found')} + {t('no_nft_at_current_address')} ) diff --git a/packages/mask/src/extension/popups/pages/Personas/components/PersonaHeader/UI.tsx b/packages/mask/src/extension/popups/pages/Personas/components/PersonaHeader/UI.tsx index 50eb58bd8312..2a718f26957b 100644 --- a/packages/mask/src/extension/popups/pages/Personas/components/PersonaHeader/UI.tsx +++ b/packages/mask/src/extension/popups/pages/Personas/components/PersonaHeader/UI.tsx @@ -85,7 +85,8 @@ export const PersonaHeaderUI = memo(
diff --git a/packages/mask/src/plugins/NextID/components/NextIdPage.tsx b/packages/mask/src/plugins/NextID/components/NextIdPage.tsx index fc0140de089c..3ea099eda404 100644 --- a/packages/mask/src/plugins/NextID/components/NextIdPage.tsx +++ b/packages/mask/src/plugins/NextID/components/NextIdPage.tsx @@ -148,7 +148,7 @@ export function NextIdPage({ persona }: NextIdPageProps) { const icon = personaConnectStatus.hasPersona ? ( ) : ( - + ) return ( diff --git a/packages/shared/src/UI/components/CollectionDetailCard/index.tsx b/packages/shared/src/UI/components/CollectionDetailCard/index.tsx index d7d01bf97474..220ee9974b12 100644 --- a/packages/shared/src/UI/components/CollectionDetailCard/index.tsx +++ b/packages/shared/src/UI/components/CollectionDetailCard/index.tsx @@ -248,12 +248,8 @@ export const CollectionDetailCard = memo( {contribution.formatedAmount} {contribution.symbol}
- {differenceInCalendarDays(new Date(), new Date(Number(contribution.timeStamp) * 1000))}{' '} - {t.days()}{' '} - {differenceInCalendarHours( - new Date(), - new Date(Number(contribution.timeStamp) * 1000), - ) % 24}{' '} + {differenceInCalendarDays(Date.now(), Number(contribution.timeStamp) * 1000)} {t.days()}{' '} + {differenceInCalendarHours(Date.now(), Number(contribution.timeStamp) * 1000) % 24}{' '} {t.hours()} {t.ago()} ({ } target="_blank" rel="noopener noreferrer"> - + From 06acc97352f51f1efd9647365f3e06e4524ffc81 Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Tue, 26 Jul 2022 10:50:08 +0800 Subject: [PATCH 141/179] feat: use MaskTabList component --- .../InjectedComponents/ProfileTabContent.tsx | 21 ++--- .../UI/components/ConcealableTabs/index.tsx | 92 ++++--------------- 2 files changed, 26 insertions(+), 87 deletions(-) diff --git a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx index d8b15ce43e99..a7c4fed2c2c0 100644 --- a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx +++ b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx @@ -1,5 +1,5 @@ import { useEffect, useMemo, useState } from 'react' -import { useUpdateEffect, useAsyncRetry } from 'react-use' +import { useAsyncRetry, useUpdateEffect } from 'react-use' import { first } from 'lodash-unified' import { createInjectHooksRenderer, @@ -11,12 +11,11 @@ import { import { useSocialAddressListAll, useAvailablePlugins } from '@masknet/plugin-infra/web3' import { ConcealableTabs, SOCIAL_MEDIA_SUPPORTING_NEXT_DOT_ID } from '@masknet/shared' import { EMPTY_LIST, EnhanceableSite, getSiteType, NextIDPlatform } from '@masknet/shared-base' -import { makeStyles, useStylesExtends } from '@masknet/theme' +import { makeStyles, useStylesExtends, useTabs } from '@masknet/theme' import { Box, CircularProgress } from '@mui/material' import { activatedSocialNetworkUI } from '../../social-network' import { isTwitter } from '../../social-network-adaptor/twitter.com/base' -import { MaskMessages, sortPersonaBindings } from '../../utils' -import { useLocationChange } from '../../utils/hooks/useLocationChange' +import { MaskMessages, sortPersonaBindings, useLocationChange } from '../../utils' import { useCurrentVisitingIdentity, useLastRecognizedIdentity } from '../DataSource/useActivatedUI' import { useNextIDBoundByPlatform } from '../DataSource/useNextID' import { usePersonaConnectStatus } from '../DataSource/usePersonaConnectStatus' @@ -47,7 +46,6 @@ export function ProfileTabContent(props: ProfileTabContentProps) { const translate = usePluginI18NField() const [hidden, setHidden] = useState(true) - const [selectedTab, setSelectedTab] = useState() const [selectedAddress, setSelectedAddress] = useState | undefined>() const currentIdentity = useLastRecognizedIdentity() @@ -144,7 +142,8 @@ export function ProfileTabContent(props: ProfileTabContentProps) { label: typeof x.label === 'string' ? x.label : translate(x.pluginID, x.label), })) - const selectedTabId = selectedTab ?? first(tabs)?.id + const [currentTab, onChange] = useTabs(first(tabs)?.id ?? PluginId.NextID, ...tabs.map((tab) => tab.id)) + const showNextID = isTwitter(activatedSocialNetworkUI) && ((isOwn && addressList?.length === 0) || @@ -154,7 +153,7 @@ export function ProfileTabContent(props: ProfileTabContentProps) { !addressList?.length) const componentTabId = showNextID ? displayPlugins?.find((tab) => tab?.pluginID === PluginId.NextID)?.ID - : selectedTabId + : currentTab const component = useMemo(() => { const Component = getTabContent(componentTabId) @@ -163,11 +162,11 @@ export function ProfileTabContent(props: ProfileTabContentProps) { }, [componentTabId, personaPublicKey, selectedAddress]) useLocationChange(() => { - setSelectedTab(undefined) + onChange(undefined, first(tabs)?.id) }) useUpdateEffect(() => { - setSelectedTab(undefined) + onChange(undefined, first(tabs)?.id) }, [identity.identifier?.userId]) useEffect(() => { @@ -204,8 +203,8 @@ export function ProfileTabContent(props: ProfileTabContentProps) { {tabs.length > 0 && !showNextID && ( tabs={tabs} - selectedId={selectedTabId} - onChange={setSelectedTab} + currentTab={currentTab} + onChange={onChange} addressList={addressList} selectedAddress={selectedAddress} onSelectAddress={setSelectedAddress} diff --git a/packages/shared/src/UI/components/ConcealableTabs/index.tsx b/packages/shared/src/UI/components/ConcealableTabs/index.tsx index 35491bd10c0d..12e330b71036 100644 --- a/packages/shared/src/UI/components/ConcealableTabs/index.tsx +++ b/packages/shared/src/UI/components/ConcealableTabs/index.tsx @@ -1,13 +1,13 @@ -import { Gear, ArrowDrop, LinkOut, RightArrow, NextIdPersonaVerified, Selected, LeftArrow } from '@masknet/icons' +import { Gear, ArrowDrop, LinkOut, NextIdPersonaVerified, Selected } from '@masknet/icons' import { ReversedAddress } from '@masknet/shared' import { CrossIsolationMessages } from '@masknet/shared-base' -import { makeStyles, ShadowRootMenu } from '@masknet/theme' +import { makeStyles, MaskTabList, ShadowRootMenu } from '@masknet/theme' import { isSameAddress, NetworkPluginID, SocialAddress, SocialAddressType } from '@masknet/web3-shared-base' import { ChainId, explorerResolver } from '@masknet/web3-shared-evm' -import { Button, Link, MenuItem, Typography } from '@mui/material' -import classnames from 'classnames' -import { throttle, uniqBy } from 'lodash-unified' -import { HTMLProps, ReactNode, useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react' +import { TabContext } from '@mui/lab' +import { Button, Link, MenuItem, Typography, Tab } from '@mui/material' +import { uniqBy } from 'lodash-unified' +import { HTMLProps, ReactNode, useState } from 'react' import { useSharedI18N } from '../../../locales' const TAB_WIDTH = 126 @@ -141,8 +141,8 @@ interface TabOption { export interface ConcealableTabsProps extends Omit, 'onChange'> { tabs: Array> - selectedId?: T - onChange?(id: T): void + currentTab: string + onChange(event: unknown, value: string): void tail?: ReactNode addressList: Array> selectedAddress?: SocialAddress @@ -152,7 +152,7 @@ export interface ConcealableTabsProps extends Omit, export function ConcealableTabs({ className, tabs, - selectedId, + currentTab, tail, onChange, addressList, @@ -163,47 +163,8 @@ export function ConcealableTabs({ const { classes } = useStyles() const t = useSharedI18N() - const [overflow, setOverflow] = useState(false) - - const trackRef = useRef(null) - const [reachedLeftEdge, setReachedLeftEdge] = useState(false) - const [reachedRightEdge, setReachedRightEdge] = useState(false) const [anchorEl, setAnchorEl] = useState(null) - useLayoutEffect(() => { - const tabList = trackRef.current - if (!tabList) return - const isWider = tabList.scrollWidth > tabList.offsetWidth - setOverflow(isWider) - - if (!isWider) return - const detectScrollStatus = throttle(() => { - const reachedRight = tabList.scrollWidth - tabList.offsetWidth <= tabList.scrollLeft - const reachedLeft = tabList.scrollLeft === 0 - setReachedRightEdge(reachedRight) - setReachedLeftEdge(reachedLeft) - }, 100) - - detectScrollStatus() - tabList.addEventListener('scroll', detectScrollStatus) - return () => { - tabList.removeEventListener('scroll', detectScrollStatus) - } - }, []) - - useEffect(() => { - if (selectedId === undefined && tabs.length) { - onChange?.(tabs[0].id) - } - }, [selectedId, tabs.map((x) => x.id).join(), onChange]) - - const slide = useCallback((toLeft: boolean) => { - const tabList = trackRef.current - if (!tabList) return - const scrolled = Math.round(tabList.scrollLeft / TAB_WIDTH) - tabList.scrollTo({ left: TAB_WIDTH * (scrolled + (toLeft ? 1 : -1)), behavior: 'smooth' }) - }, []) - const onClose = () => setAnchorEl(null) const onSelect = (option: SocialAddress) => { @@ -317,34 +278,13 @@ export function ConcealableTabs({
-
- {tabs.map((tab) => ( - - ))} -
- {overflow || tail ? ( -
- {overflow ? ( - <> - slide(false)} /> - slide(true)} /> - - ) : null} - {tail} -
- ) : null} + + + {tabs.map((tab) => ( + + ))} + +
) From 078a933635bf6f3b59c8a780a4287a4ce95171a7 Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Tue, 26 Jul 2022 10:55:55 +0800 Subject: [PATCH 142/179] feat: merge develop --- packages/web3-providers/src/types.ts | 1010 -------------------------- 1 file changed, 1010 deletions(-) delete mode 100644 packages/web3-providers/src/types.ts diff --git a/packages/web3-providers/src/types.ts b/packages/web3-providers/src/types.ts deleted file mode 100644 index 1f81c557c888..000000000000 --- a/packages/web3-providers/src/types.ts +++ /dev/null @@ -1,1010 +0,0 @@ -import type { Result } from 'ts-results' -import type RSS3 from 'rss3-next' -import type { Transaction as Web3Transaction } from 'web3-core' -import type { api } from '@dimensiondev/mask-wallet-core/proto' -import type { - NextIDAction, - NextIDStoragePayload, - NextIDPayload, - NextIDPlatform, - NextIDPersonaBindings, -} from '@masknet/shared-base' -import type { - Transaction, - FungibleAsset, - NonFungibleToken, - NonFungibleAsset, - CurrencyType, - Pageable, - FungibleToken, - OrderSide, - NonFungibleTokenCollection, - NonFungibleTokenContract, - NonFungibleTokenOrder, - NonFungibleTokenEvent, - GasOptionType, - HubOptions, - HubIndicator, - TokenType, - NonFungibleContractSpenderAuthorization, - FungibleTokenSpenderAuthorization, -} from '@masknet/web3-shared-base' -import type { DataProvider } from '@masknet/public-api' -import type { ChainId, SchemaType } from '@masknet/web3-shared-evm' - -export namespace ExplorerAPI { - export type Transaction = Web3Transaction & { - status: '0' | '1' - confirmations: number - } - - export interface PageInfo { - offset?: number - apikey?: string - } - - export interface Provider { - getLatestTransactions(account: string, url: string, pageInfo?: PageInfo): Promise - } - - export interface TokenInfo { - contractAddress: string - tokenName: string - symbol: string - divisor: string - tokenType: string - totalSupply: string - blueCheckmark: string - description: string - website: string - email: string - blog: string - reddit: string - slack: string - facebook: string - twitter: string - bitcointalk: string - github: string - telegram: string - wechat: string - linkedin: string - discord: string - whitepaper: string - tokenPriceUSD: string - } -} -export namespace RSS3BaseAPI { - export interface GeneralAsset { - platform: string - identity: string - id: string // contractAddress-id or admin_address - type: string - info: { - collection?: string - collection_icon?: string - image_preview_url?: string | null - animation_url?: string | null - animation_original_url?: string | null - title?: string - total_contribs?: number - token_contribs?: Array<{ - token: string - amount: string - }> - start_date?: string - end_date?: string - country?: string - city?: string - } - } - - export interface GeneralAssetWithTags extends GeneralAsset { - tags?: string[] - } - - export interface GeneralAssetResponse { - status: boolean - assets: GeneralAsset[] - } - - export interface ProfileInfo { - avatar: string[] - bio: string - name: string - } - - export interface NFT_Contract { - address: string - name: string - symbol: string - } - - export interface NFT_Trait { - trait_type: string - value: string - } - export interface NFT_Type { - asset_contract: NFT_Contract - chain: string - description: string - image_preview_url: string - image_preview_url_ct: string - image_thumbnail_url: string - image_thumbnail_url_ct: string - image_url: string - image_url_ct: string - name: string - received_at: string - token_id: string - traits: NFT_Trait[] - } - - export interface NFT { - id: string - detail: NFT_Type - } - - export interface DonationTx { - adminAddr: string - amount: string - approach: string - donor: string - formatedAmount: string - symbol: string - timeStamp: string - tokenAddr: string - txHash: string - } - - export interface DonationGrant { - active: boolean - admin_address: string - contract_address: string - description: string - id: number - logo: string - reference_url: string - slug: string - title: string - token_address: string - token_symbol: string - } - - export interface DonationType { - grant: DonationGrant - txs: DonationTx[] - } - - export interface Donation { - id: string - detail: DonationType - } - - export interface FootprintType { - id: number - fancy_id: string - name: string - event_url: string - image_url: string - country: string - city: string - description: string - year: number - start_date: string - end_date: string - expiry_date: string - supply: number - } - - export interface Footprint { - id: string - detail: FootprintType - } - - export enum AssetType { - GitcoinDonation = 'Gitcoin-Donation', - POAP = 'POAP', - NFT = 'NFT', - } - - export interface NameInfo { - rnsName: string - ensName: string | null - address: string - } - - export interface Attachments { - address?: string - mime_type?: string - size_in_bytes?: string - type?: string - } - - export type Tags = 'NFT' | 'Token' | 'POAP' | 'Gitcoin' | 'Mirror Entry' | 'ETH' - - export type FeedType = 'Token' | 'Donation' | 'NFT' - - export interface Metadata { - collection_address?: string - collection_name?: string - contract_type?: string - from?: string - log_index?: string - network?: 'polygon' | 'ethereum' | 'bnb' - proof?: string - to?: string - token_id?: string - token_standard?: string - token_symbol?: string - token_address?: string - } - export interface Web3Feed { - attachments?: Attachments[] - authors: string[] - /* cspell:disable-next-line */ - backlinks: string - date_created: string - date_updated: string - identifier: string - links: string - related_urls?: string[] - // this field works different from API doc - source: string - tags: Tags[] - summary?: string - title?: string - metadata?: Metadata - imageURL?: string - traits?: Array<{ - type: string - value: string - }> - } - - export interface Web3FeedResponse { - version: string - date_updated: string - identifier: string - identifier_next?: string - total: string - list: Web3Feed[] - } - - export interface Provider { - createRSS3(address: string): RSS3 - getFileData(rss3: RSS3, address: string, key: string): Promise - setFileData(rss3: RSS3, address: string, key: string, data: T): Promise - getDonations(address: string): Promise - getFootprints(address: string): Promise - getNameInfo(id: string): Promise - getProfileInfo(address: string): Promise - getWeb3Feed( - address: string, - options?: HubOptions, - type?: FeedType, - ): Promise - } -} - -export namespace PriceAPI { - export interface Provider { - getTokenPrice(platform_id: string, address: string, currency: CurrencyType): Promise - getTokensPrice(listOfAddress: string[], currency: CurrencyType): Promise> - getTokenPriceByCoinId(coin_id: string, currency: CurrencyType): Promise - } -} - -export namespace HistoryAPI { - export interface Provider { - getTransactions( - address: string, - options?: HubOptions, - ): Promise>> - } -} - -export namespace GasOptionAPI { - export interface Provider { - getGasOptions(chainId: ChainId): Promise> - } -} - -export namespace FungibleTokenAPI { - export interface Provider { - getAssets( - address: string, - options?: HubOptions, - ): Promise, Indicator>> - } -} - -export namespace NonFungibleTokenAPI { - export interface Provider { - /** Get balance of a fungible token owned by the given account. */ - getBalance?: (account: string, options?: HubOptions) => Promise - /** Get a non-fungible contract. */ - getContract?: ( - address: string, - options?: HubOptions, - ) => Promise | undefined> - /** Get a non-fungible asset. */ - getAsset?: ( - address: string, - tokenId: string, - options?: HubOptions, - ) => Promise | undefined> - /** Get non-fungible assets owned by the given account. */ - getAssets?: ( - account: string, - options?: HubOptions, - ) => Promise>> - /** Get non-fungible assets of the given collection. */ - getAssetsByCollection?: ( - address: string, - options?: HubOptions, - ) => Promise>> - /** Get a non-fungible token. */ - getToken?: ( - address: string, - tokenId: string, - options?: HubOptions, - ) => Promise | undefined> - /** Get non-fungible tokens owned by the given account. */ - getTokens?: ( - account: string, - options?: HubOptions, - ) => Promise, Indicator>> - /** Get non-fungible tokens of the given collection. */ - getTokensByCollection?: ( - account: string, - options?: HubOptions, - ) => Promise, Indicator>> - /** Get events of a non-fungible token. */ - getEvents?: ( - address: string, - tokenId: string, - options?: HubOptions, - ) => Promise>> - /** Get listed orders of a non-fungible token. */ - getListings?: ( - address: string, - tokenId: string, - options?: HubOptions, - ) => Promise>> - /** Get offered orders of a non-fungible token. */ - getOffers?: ( - address: string, - tokenId: string, - options?: HubOptions, - ) => Promise>> - /** Get orders of a non-fungible token. */ - getOrders?: ( - address: string, - tokenId: string, - side: OrderSide, - options?: HubOptions, - ) => Promise>> - /** Get non-fungible collections owned by the given account. */ - getCollections?: ( - account: string, - options?: HubOptions, - ) => Promise, Indicator>> - - /** Place a bid on a token. */ - createBuyOrder?: (/** TODO: add parameters */) => Promise - /** Listing a token for public sell. */ - createSellOrder?: (/** TODO: add parameters */) => Promise - /** Fulfill an order. */ - fulfillOrder?: (/** TODO: add parameters */) => Promise - /** Cancel an order. */ - cancelOrder?: (/** TODO: add parameters */) => Promise - } -} - -export namespace RiskWarningBaseAPI { - export interface Provider { - approve(address: string, pluginID?: string): Promise - } -} - -export namespace StorageAPI { - export interface Storage { - get(key: string): Promise - set(key: string, value: T): Promise - delete?(key: string): Promise - } - - export interface Provider { - createJSON_Storage?(key: string): Storage - createBinaryStorage?(key: string): Storage - } -} - -export namespace NextIDBaseAPI { - export interface Storage { - set( - uuid: string, - personaPublicKey: string, - signature: string, - platform: NextIDPlatform, - identity: string, - createdAt: string, - patchData: unknown, - pluginId: string, - ): Promise> - getByIdentity( - key: string, - platform: NextIDPlatform, - identity: string, - pluginId: string, - ): Promise> - get(key: string): Promise> - getPayload( - personaPublicKey: string, - platform: NextIDPlatform, - identity: string, - patchData: unknown, - pluginId: string, - ): Promise> - } - export interface Proof { - bindProof( - uuid: string, - personaPublicKey: string, - action: NextIDAction, - platform: string, - identity: string, - createdAt: string, - options?: { - walletSignature?: string - signature?: string - proofLocation?: string - }, - ): Promise> - - queryExistedBindingByPersona(personaPublicKey: string, enableCache?: boolean): Promise - - queryExistedBindingByPlatform(platform: NextIDPlatform, identity: string, page?: number): Promise - - queryAllExistedBindingsByPlatform(platform: NextIDPlatform, identity: string): Promise - - queryIsBound( - personaPublicKey: string, - platform: NextIDPlatform, - identity: string, - enableCache?: boolean, - ): Promise - - createPersonaPayload( - personaPublicKey: string, - action: NextIDAction, - identity: string, - platform: NextIDPlatform, - language?: string, - ): Promise - } -} - -export namespace SecurityAPI { - export interface Holder { - address?: string - locked?: '0' | '1' - tag?: string - is_contract?: '0' | '1' - balance?: number - percent?: number - } - - export interface TradingSecurity { - buy_tax?: string - sell_tax?: string - slippage_modifiable?: '0' | '1' - is_honeypot?: '0' | '1' - transfer_pausable?: '0' | '1' - is_blacklisted?: '0' | '1' - is_whitelisted?: '0' | '1' - is_in_dex?: '0' | '1' - is_anti_whale?: '0' | '1' - trust_list?: '0' | '1' - } - - export interface ContractSecurity { - is_open_source?: '0' | '1' - is_proxy?: '0' | '1' - is_mintable?: '0' | '1' - owner_change_balance?: '0' | '1' - can_take_back_ownership?: '0' | '1' - owner_address?: string - creator_address?: string - } - - export interface TokenSecurity { - token_name?: string - token_symbol?: string - - holder_count?: number - total_supply?: number - holders?: Holder[] - - lp_holder_count?: number - lp_total_supply?: number - lp_holders?: Holder[] - - is_true_token?: '0' | '1' - is_verifiable_team?: '0' | '1' - is_airdrop_scam?: '0' | '1' - } - - export interface SupportedChain { - chainId: ChainId - name: string - } - - export interface Provider { - getTokenSecurity( - chainId: ChainId, - listOfAddress: string[], - ): Promise | void> - getSupportedChain(): Promise>> - } -} - -export namespace TwitterBaseAPI { - export interface NFTContainer { - has_nft_avatar: boolean - nft_avatar_metadata: AvatarMetadata - } - - export interface AvatarMetadata { - token_id: string - smart_contract: { - __typename: 'ERC721' | 'ERC1155' - __isSmartContract: 'ERC721' - network: 'Ethereum' - address: string - } - metadata: { - creator_username: string - creator_address: string - name: string - description?: string - collection: { - name: string - metadata: { - image_url: string - verified: boolean - description: string - name: string - } - } - traits: Array<{ - trait_type: string - value: string - }> - } - } - type UserUrl = { - display_url: string - expanded_url: string - /** t.co url */ - url: string - indices: [number, number] - } - export interface User { - __typename: 'User' - id: string - rest_id: string - affiliates_highlighted_label: {} - has_nft_avatar: boolean - legacy: { - blocked_by: boolean - blocking: boolean - can_dm: boolean - can_media_tag: boolean - /** ISODateTime */ - created_at: string - default_profile: boolean - default_profile_image: boolean - description: string - entities: { - description: { - urls: [] - } - url: { - urls: UserUrl[] - } - } - fast_followers_count: 0 - favourites_count: 22 - follow_request_sent: boolean - followed_by: boolean - followers_count: 35 - following: boolean - friends_count: 76 - has_custom_timelines: boolean - is_translator: boolean - listed_count: 4 - location: string - media_count: 196 - muting: boolean - name: string - normal_followers_count: 35 - notifications: boolean - pinned_tweet_ids_str: [] - possibly_sensitive: boolean - /** unused data, declare details when you need */ - profile_banner_extensions: any - profile_banner_url: string - /** unused data, declare details when you need */ - profile_image_extensions: any - profile_image_url_https: string - profile_interstitial_type: string - protected: boolean - screen_name: string - statuses_count: number - translator_type: string - /** t.co url */ - url: string - verified: boolean - want_retweets: boolean - withheld_in_countries: [] - } - smart_blocked_by: false - smart_blocking: false - super_follow_eligible: false - super_followed_by: false - super_following: false - legacy_extended_profile: {} - is_profile_translatable: boolean - } - export type Response = { - data: T - } - export type UserByScreenNameResponse = Response<{ user: { result: User } }> - export interface AvatarInfo { - nickname: string - userId: string - imageUrl: string - mediaId: string - } - - export interface Settings { - screen_name: string - } - - export interface TwitterResult { - media_id: number - media_id_string: string - size: number - image: { - image_type: string - w: number - h: number - } - } - - export interface Provider { - getSettings: () => Promise - getUserNftContainer: (screenName: string) => Promise< - | { - address: string - token_id: string - type_name: string - } - | undefined - > - uploadUserAvatar: (screenName: string, image: Blob | File) => Promise - updateProfileImage: (screenName: string, media_id_str: string) => Promise - getUserByScreenName: (screenName: string) => Promise - } -} - -export namespace InstagramBaseAPI { - export interface Provider { - uploadUserAvatar: ( - image: File | Blob, - userId: string, - ) => Promise< - | { - changed_profile: boolean - profile_pic_url_hd: string - } - | undefined - > - } -} - -export namespace TokenListBaseAPI { - export interface Token { - chainId: ChainId - address: string - name: string - symbol: string - decimals: number - logoURI?: string - } - - export interface TokenList { - keywords: string[] - logoURI: string - name: string - timestamp: string - tokens: Array> - version: { - major: number - minor: number - patch: number - } - } - - export interface TokenObject { - tokens: Record> - } - - export interface Provider { - fetchFungibleTokensFromTokenLists: ( - chainId: ChainId, - urls: string[], - ) => Promise>> - } -} - -export namespace MaskBaseAPI { - export type Input = { id: number; data: api.IMWRequest } - export type Output = { id: number; response: api.MWResponse } - - export type Request = InstanceType - export type Response = InstanceType - - export type StoredKeyInfo = api.IStoredKeyInfo - - export interface Provider {} -} - -export namespace TokenAPI { - export interface TokenInfo { - id: string - market_cap: string - price: string - } - export interface Provider { - getTokenInfo(tokenName: string): Promise - } -} - -export enum NonFungibleMarketplace { - OpenSea = 'OpenSea', - LooksRare = 'LooksRare', -} - -export namespace TrendingAPI { - export interface Settings { - currency: Currency - } - export enum TagType { - CASH = 1, - HASH = 2, - } - - export interface Currency { - id: string - name: string - symbol?: string - description?: string - } - - export interface Platform { - id: string | number - name: string - slug: string - symbol: string - } - - export type CommunityType = - | 'discord' - | 'facebook' - | 'instagram' - | 'medium' - | 'reddit' - | 'telegram' - | 'github' - | 'youtube' - | 'twitter' - | 'other' - export type CommunityUrls = Array<{ type: Partial; link: string }> - - export interface Coin { - id: string - chainId?: ChainId - name: string - symbol: string - type: TokenType - decimals?: number - is_mirrored?: boolean - platform_url?: string - tags?: string[] - tech_docs_urls?: string[] - message_board_urls?: string[] - source_code_urls?: string[] - community_urls?: CommunityUrls - home_urls?: string[] - announcement_urls?: string[] - blockchain_urls?: string[] - image_url?: string - description?: string - market_cap_rank?: number - address?: string - contract_address?: string - facebook_url?: string - twitter_url?: string - telegram_url?: string - } - - export interface Market { - current_price: number - circulating_supply?: number - market_cap?: number - max_supply?: number - total_supply?: number - total_volume?: number - price_change_percentage_1h?: number - price_change_percentage_24h?: number - price_change_percentage_1h_in_currency?: number - price_change_percentage_1y_in_currency?: number - price_change_percentage_7d_in_currency?: number - price_change_percentage_14d_in_currency?: number - price_change_percentage_24h_in_currency?: number - price_change_percentage_30d_in_currency?: number - price_change_percentage_60d_in_currency?: number - price_change_percentage_200d_in_currency?: number - /** NFT only */ - floor_price?: number - /** NFT only */ - highest_price?: number - /** NFT only */ - owners_count?: number - /** NFT only */ - royalty?: string - /** NFT only */ - total_24h?: number - /** NFT only */ - volume_24h?: number - /** NFT only */ - average_volume_24h?: number - /** NFT only */ - volume_all?: number - } - - export interface Ticker { - logo_url: string - trade_url: string - market_name: string - /** fungible token only */ - base_name?: string - /** fungible token only */ - target_name?: string - price?: number - volume?: number - score?: string - updated?: Date - /** NFT only */ - volume_24h?: number - /** NFT only */ - floor_price?: number - /** NFT only */ - sales_24?: number - } - - export interface Contract { - chainId?: ChainId - address: string - iconURL?: string - } - - export interface Trending { - currency: Currency - dataProvider: DataProvider - coin: Coin - platform?: Platform - contracts?: Contract[] - market?: Market - tickers: Ticker[] - lastUpdated: string - } - - // #region historical - export type Stat = [number | string, number] - export interface HistoricalCoinInfo { - id: number - is_active: 0 | 1 - is_fiat: 0 | 1 - name: string - quotes: [] - symbol: string - } - // #endregion - - export type HistoricalInterval = '1d' | '2h' | '1h' | '15m' | '5m' - - export type PriceStats = { - market_caps: Stat[] - prices: Stat[] - total_volumes: Stat[] - } - - export interface Provider { - getCoinTrending(chainId: ChainId, id: string, currency: Currency): Promise - - // #region get all coins - getCoins(keyword?: string): Promise - // #endregion - - // #region get all currency - getCurrencies(): Promise - // #endregion - getPriceStats(chainId: ChainId, coinId: string, currency: Currency, days: number): Promise - } -} - -export namespace RabbyTokenAPI { - interface RawTokenSpender { - id: string - address: string - amount: number - value: number - exposure_usd: number - protocol: { - id: string - name: string - logo_url: string - chain: string - } | null - is_contract: boolean - is_open_source: boolean - is_hacked: boolean - is_abandoned: boolean - } - - export interface RawTokenInfo { - id: string - address: string - name: string - symbol: string - logo_url: string - chain: string - price: number - balance: number - spenders: RawTokenSpender[] - } - - export type TokenInfo = Omit - - export type TokenSpender = Omit & { - tokenInfo: TokenInfo - name: string | undefined - logo: React.ReactNode | undefined - isMaskDapp: boolean - } - - export interface NFTInfo { - chain: string - amount: string - contract_name: string - is_erc721?: boolean - contract_id: string - isMaskDapp?: boolean - spender: Omit - } - - export interface Provider { - getApprovedNonFungibleContracts( - chainId: ChainId, - account: string, - ): Promise>> - - getApprovedFungibleTokenSpenders( - chainId: ChainId, - account: string, - ): Promise>> - } -} From 0ed117c33b7675db2f9aea92d70b033449903047 Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Tue, 26 Jul 2022 13:34:55 +0800 Subject: [PATCH 143/179] feat: add types for web3 feed --- packages/web3-providers/src/types/RSS3.ts | 58 +++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/packages/web3-providers/src/types/RSS3.ts b/packages/web3-providers/src/types/RSS3.ts index 9b0f3250f276..62122d682267 100644 --- a/packages/web3-providers/src/types/RSS3.ts +++ b/packages/web3-providers/src/types/RSS3.ts @@ -128,18 +128,76 @@ export namespace RSS3BaseAPI { detail: FootprintType } + export type FeedType = 'Token' | 'Donation' | 'NFT' + export enum AssetType { GitcoinDonation = 'Gitcoin-Donation', POAP = 'POAP', NFT = 'NFT', } + export type Tags = 'NFT' | 'Token' | 'POAP' | 'Gitcoin' | 'Mirror Entry' | 'ETH' + export interface NameInfo { rnsName: string ensName: string | null address: string } + export interface Metadata { + collection_address?: string + collection_name?: string + contract_type?: string + from?: string + log_index?: string + network?: 'polygon' | 'ethereum' | 'bnb' + proof?: string + to?: string + token_id?: string + token_standard?: string + token_symbol?: string + token_address?: string + } + + export interface Attachments { + address?: string + mime_type?: string + size_in_bytes?: string + type?: string + } + + export interface Web3Feed { + attachments?: Attachments[] + authors: string[] + /* cspell:disable-next-line */ + backlinks: string + date_created: string + date_updated: string + identifier: string + links: string + related_urls?: string[] + // this field works different from API doc + source: string + tags: Tags[] + summary?: string + title?: string + metadata?: Metadata + imageURL?: string + traits?: Array<{ + type: string + value: string + }> + } + + export interface Web3FeedResponse { + version: string + date_updated: string + identifier: string + identifier_next?: string + total: string + list: Web3Feed[] + } + export interface Provider { createRSS3(address: string): RSS3 getFileData(rss3: RSS3, address: string, key: string): Promise From 95ad2bad3ad2ea2f6c14096280e13c68b927eb4f Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Tue, 26 Jul 2022 13:49:46 +0800 Subject: [PATCH 144/179] feat: add singular for days and hours --- .../UI/components/CollectionDetailCard/index.tsx | 14 ++++++++++---- packages/shared/src/locales/en-US.json | 2 ++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/shared/src/UI/components/CollectionDetailCard/index.tsx b/packages/shared/src/UI/components/CollectionDetailCard/index.tsx index 220ee9974b12..ecfeec2f4b93 100644 --- a/packages/shared/src/UI/components/CollectionDetailCard/index.tsx +++ b/packages/shared/src/UI/components/CollectionDetailCard/index.tsx @@ -187,6 +187,12 @@ export const CollectionDetailCard = memo( return null }) + const newContributions = contributions?.map((contribution) => ({ + ...contribution, + daysFromNow: differenceInCalendarDays(Date.now(), Number(contribution.timeStamp) * 1000), + hoursFromNow: differenceInCalendarHours(Date.now(), Number(contribution.timeStamp) * 1000) % 24, + })) + return ( @@ -242,15 +248,15 @@ export const CollectionDetailCard = memo( {contributions?.length ?? 0}
) : null} - {contributions?.map((contribution) => ( + {newContributions?.map((contribution) => (
{contribution.formatedAmount} {contribution.symbol}
- {differenceInCalendarDays(Date.now(), Number(contribution.timeStamp) * 1000)} {t.days()}{' '} - {differenceInCalendarHours(Date.now(), Number(contribution.timeStamp) * 1000) % 24}{' '} - {t.hours()} {t.ago()} + {contribution?.daysFromNow} {contribution?.daysFromNow > 1 ? t.days() : t.day()}{' '} + {contribution?.hoursFromNow} {contribution?.hoursFromNow > 1 ? t.hours() : t.hour()}{' '} + {t.ago()} Date: Tue, 26 Jul 2022 13:53:48 +0800 Subject: [PATCH 145/179] feat: merge develop --- packages/mask/src/plugin-infra/register.js | 45 ---------------------- 1 file changed, 45 deletions(-) delete mode 100644 packages/mask/src/plugin-infra/register.js diff --git a/packages/mask/src/plugin-infra/register.js b/packages/mask/src/plugin-infra/register.js deleted file mode 100644 index dfa1ec2c9b94..000000000000 --- a/packages/mask/src/plugin-infra/register.js +++ /dev/null @@ -1,45 +0,0 @@ -// This file is a JavaScript file because it's reference to the plugins should not be counted as a project reference. -// If your plugin also works in isolated dashboard, please also register it in -// packages/dashboard/src/initialization/plugins.ts -import '@masknet/plugin-example' -import '@masknet/plugin-debugger' -import '@masknet/plugin-flow' -import '@masknet/plugin-file-service' -import '@masknet/plugin-rss3' -import '@masknet/plugin-dao' -import '@masknet/plugin-solana' -import '@masknet/plugin-cyberconnect' -import '@masknet/plugin-go-plus-security' -import '@masknet/plugin-cross-chain-bridge' -import '@masknet/plugin-scamsniffer' -import '../plugins/Wallet' -import '@masknet/plugin-evm' -import '../plugins/RedPacket' -import '../plugins/ITO' -import '../plugins/Snapshot' -import '../plugins/Savings' -import '../plugins/Collectible' -import '../plugins/Transak' -import '../plugins/Gitcoin' -import '../plugins/VCent' -import '../plugins/Trader' -import '../plugins/Avatar' -import '../plugins/Furucombo' -import '../plugins/MaskBox' -import '../plugins/NextID' -import '../plugins/Pets' -import '../plugins/Game' -import '../plugins/CryptoartAI' -import '../plugins/FindTruman' -import '../plugins/ArtBlocks' -import '../plugins/Referral' -import '../plugins/Tips' -import '../plugins/Approval' -import '../plugins/Web3Feed' -import '@masknet/plugin-web3-profile' -// import '../plugins/dHEDGE' -// import '../plugins/External' -// import '../plugins/Polls' -// import '../plugins/PoolTogether' -// import '../plugins/GoodGhosting' -// import '../plugins/UnlockProtocol' From a0a30878af3c2caa728bf3989053e5590391f97d Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Tue, 26 Jul 2022 14:14:08 +0800 Subject: [PATCH 146/179] feat: move component code --- .../InjectedComponents/ProfileTabContent.tsx | 206 ++++++++++++- .../UI/components/ConcealableTabs/index.tsx | 291 ------------------ packages/shared/src/UI/components/index.ts | 1 - 3 files changed, 191 insertions(+), 307 deletions(-) delete mode 100644 packages/shared/src/UI/components/ConcealableTabs/index.tsx diff --git a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx index a7c4fed2c2c0..a670bdac5237 100644 --- a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx +++ b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx @@ -1,6 +1,6 @@ import { useEffect, useMemo, useState } from 'react' import { useAsyncRetry, useUpdateEffect } from 'react-use' -import { first } from 'lodash-unified' +import { first, uniqBy } from 'lodash-unified' import { createInjectHooksRenderer, PluginId, @@ -9,18 +9,21 @@ import { usePluginI18NField, } from '@masknet/plugin-infra/content-script' import { useSocialAddressListAll, useAvailablePlugins } from '@masknet/plugin-infra/web3' -import { ConcealableTabs, SOCIAL_MEDIA_SUPPORTING_NEXT_DOT_ID } from '@masknet/shared' -import { EMPTY_LIST, EnhanceableSite, getSiteType, NextIDPlatform } from '@masknet/shared-base' -import { makeStyles, useStylesExtends, useTabs } from '@masknet/theme' -import { Box, CircularProgress } from '@mui/material' +import { ReversedAddress, SOCIAL_MEDIA_SUPPORTING_NEXT_DOT_ID, useSharedI18N } from '@masknet/shared' +import { CrossIsolationMessages, EMPTY_LIST, EnhanceableSite, getSiteType, NextIDPlatform } from '@masknet/shared-base' +import { makeStyles, MaskTabList, ShadowRootMenu, useStylesExtends, useTabs } from '@masknet/theme' +import { Box, Button, CircularProgress, Link, MenuItem, Tab, Typography } from '@mui/material' import { activatedSocialNetworkUI } from '../../social-network' import { isTwitter } from '../../social-network-adaptor/twitter.com/base' import { MaskMessages, sortPersonaBindings, useLocationChange } from '../../utils' import { useCurrentVisitingIdentity, useLastRecognizedIdentity } from '../DataSource/useActivatedUI' import { useNextIDBoundByPlatform } from '../DataSource/useNextID' import { usePersonaConnectStatus } from '../DataSource/usePersonaConnectStatus' -import { NetworkPluginID, SocialAddressType, SocialAddress } from '@masknet/web3-shared-base' +import { NetworkPluginID, SocialAddressType, SocialAddress, isSameAddress } from '@masknet/web3-shared-base' import { NextIDProof } from '@masknet/web3-providers' +import { ArrowDrop, Gear, LinkOut, NextIdPersonaVerified, Selected } from '@masknet/icons' +import { ChainId, explorerResolver } from '@masknet/web3-shared-evm' +import { TabContext } from '@mui/lab' const site = getSiteType() @@ -33,9 +36,66 @@ function getTabContent(tabId?: string) { const useStyles = makeStyles()((theme) => ({ root: {}, + container: { + background: + 'linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.8) 100%), linear-gradient(90deg, rgba(28, 104, 243, 0.2) 0%, rgba(69, 163, 251, 0.2) 100%), #FFFFFF;', + padding: '16px 16px 0 16px', + }, + title: { + display: 'flex', + justifyContent: 'space-between', + alignItems: 'center', + marginBottom: '16px', + }, + walletItem: { + display: 'flex', + alignItems: 'center', + fontSize: 18, + fontWeight: 700, + }, + menuItem: { + display: 'flex', + alignItems: 'center', + flexGrow: 1, + justifyContent: 'space-between', + }, + addressItem: { + display: 'flex', + alignItems: 'center', + }, + link: { + cursor: 'pointer', + marginTop: 2, + zIndex: 1, + '&:hover': { + textDecoration: 'none', + }, + }, + linkIcon: { + color: theme.palette.maskColor.second, + fontSize: '20px', + margin: '4px 2px 0 2px', + }, content: { position: 'relative', }, + walletButton: { + padding: 0, + fontSize: '18px', + minWidth: 0, + background: 'transparent', + '&:hover': { + background: 'none', + }, + }, + settingItem: { + display: 'flex', + alignItems: 'center', + }, + tabs: { + display: 'flex', + position: 'relative', + }, })) export interface ProfileTabContentProps extends withClasses<'text' | 'button' | 'root'> {} @@ -43,10 +103,12 @@ export interface ProfileTabContentProps extends withClasses<'text' | 'button' | export function ProfileTabContent(props: ProfileTabContentProps) { const classes = useStylesExtends(useStyles(), props) + const t = useSharedI18N() const translate = usePluginI18NField() const [hidden, setHidden] = useState(true) const [selectedAddress, setSelectedAddress] = useState | undefined>() + const [anchorEl, setAnchorEl] = useState(null) const currentIdentity = useLastRecognizedIdentity() const identity = useCurrentVisitingIdentity() @@ -180,7 +242,18 @@ export function ProfileTabContent(props: ProfileTabContentProps) { setHidden(!data.show) }) }, [identity.identifier?.userId]) - + const onClose = () => setAnchorEl(null) + + const onOpen = (event: React.MouseEvent) => setAnchorEl(event.currentTarget) + const onSelect = (option: SocialAddress) => { + setSelectedAddress(option) + onClose() + } + const handleOpenDialog = () => { + CrossIsolationMessages.events.requestWeb3ProfileDialog.sendToAll({ + open: true, + }) + } if (hidden) return null // loadingSocialAddress @@ -201,14 +274,117 @@ export function ProfileTabContent(props: ProfileTabContentProps) {
{tabs.length > 0 && !showNextID && ( - - tabs={tabs} - currentTab={currentTab} - onChange={onChange} - addressList={addressList} - selectedAddress={selectedAddress} - onSelectAddress={setSelectedAddress} - /> +
+
+
+ + setAnchorEl(null)}> + {uniqBy(addressList ?? [], (x) => x.address.toLowerCase()).map((x) => { + return ( + onSelect(x)}> +
+
+ {x?.type === SocialAddressType.KV || + x?.type === SocialAddressType.ADDRESS ? ( + + ) : ( + + {x.label} + + )} + + + + {x?.type === SocialAddressType.KV && ( + + )} +
+ {isSameAddress(selectedAddress?.address, x.address) && ( + + )} +
+
+ ) + })} +
+
+
+ + {t.powered_by()} + + + {t.mask_network()} + + +
+
+
+ + + {tabs.map((tab) => ( + + ))} + + +
+
)}
{component}
diff --git a/packages/shared/src/UI/components/ConcealableTabs/index.tsx b/packages/shared/src/UI/components/ConcealableTabs/index.tsx deleted file mode 100644 index 12e330b71036..000000000000 --- a/packages/shared/src/UI/components/ConcealableTabs/index.tsx +++ /dev/null @@ -1,291 +0,0 @@ -import { Gear, ArrowDrop, LinkOut, NextIdPersonaVerified, Selected } from '@masknet/icons' -import { ReversedAddress } from '@masknet/shared' -import { CrossIsolationMessages } from '@masknet/shared-base' -import { makeStyles, MaskTabList, ShadowRootMenu } from '@masknet/theme' -import { isSameAddress, NetworkPluginID, SocialAddress, SocialAddressType } from '@masknet/web3-shared-base' -import { ChainId, explorerResolver } from '@masknet/web3-shared-evm' -import { TabContext } from '@mui/lab' -import { Button, Link, MenuItem, Typography, Tab } from '@mui/material' -import { uniqBy } from 'lodash-unified' -import { HTMLProps, ReactNode, useState } from 'react' -import { useSharedI18N } from '../../../locales' - -const TAB_WIDTH = 126 -const useStyles = makeStyles()((theme) => ({ - container: { - background: - 'linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.8) 100%), linear-gradient(90deg, rgba(28, 104, 243, 0.2) 0%, rgba(69, 163, 251, 0.2) 100%), #FFFFFF;', - padding: '16px 16px 0 16px', - }, - title: { - display: 'flex', - justifyContent: 'space-between', - alignItems: 'center', - marginBottom: '16px', - }, - tabs: { - display: 'flex', - position: 'relative', - }, - track: { - flexGrow: 1, - display: 'flex', - overflow: 'auto', - 'scrollbar-width': 'none', - '&::-webkit-scrollbar': { - display: 'none', - }, - }, - button: { - height: 35, - minWidth: TAB_WIDTH, - padding: theme.spacing(0, 2.5), - borderRadius: '12px 12px 0px 0px', - flexShrink: 0, - border: '1px solid transparent', - background: 'none', - '&:hover': { - backgroundColor: theme.palette.maskColor.bottom, - }, - }, - normal: { - boxSizing: 'border-box', - color: theme.palette.maskColor.secondaryDark, - border: '1px solid transparent', - }, - selected: { - position: 'relative', - backgroundColor: theme.palette.maskColor.bottom, - zIndex: 10, - color: theme.palette.maskColor.main, - '&::after': { - content: '""', - position: 'absolute', - left: 0, - right: 0, - bottom: 0, - height: 1, - }, - }, - controllers: { - display: 'flex', - flexGrow: 0, - alignItems: 'center', - }, - controller: { - display: 'flex', - color: theme.palette.maskColor.second, - border: 'none', - borderRadius: 0, - boxSizing: 'border-box', - alignItems: 'center', - justifyContent: 'center', - '&:hover': { - border: 'none !important', - borderBottomColor: theme.palette.divider, - color: `${theme.palette.text.primary} !important`, - backgroundColor: theme.palette.background.paper, - }, - '&[disabled]': { - color: theme.palette.maskColor.second, - }, - }, - walletButton: { - padding: 0, - fontSize: '18px', - minWidth: 0, - background: 'transparent', - '&:hover': { - background: 'none', - }, - }, - settingItem: { - display: 'flex', - alignItems: 'center', - }, - walletItem: { - display: 'flex', - alignItems: 'center', - fontSize: 18, - fontWeight: 700, - }, - menuItem: { - display: 'flex', - alignItems: 'center', - flexGrow: 1, - justifyContent: 'space-between', - }, - addressItem: { - display: 'flex', - alignItems: 'center', - }, - link: { - cursor: 'pointer', - marginTop: 2, - zIndex: 1, - '&:hover': { - textDecoration: 'none', - }, - }, - linkIcon: { - color: theme.palette.maskColor.second, - fontSize: '20px', - margin: '4px 2px 0 2px', - }, -})) - -interface TabOption { - id: T - label: string -} - -export interface ConcealableTabsProps extends Omit, 'onChange'> { - tabs: Array> - currentTab: string - onChange(event: unknown, value: string): void - tail?: ReactNode - addressList: Array> - selectedAddress?: SocialAddress - onSelectAddress: (address: SocialAddress) => void -} - -export function ConcealableTabs({ - className, - tabs, - currentTab, - tail, - onChange, - addressList, - selectedAddress, - onSelectAddress, - ...rest -}: ConcealableTabsProps) { - const { classes } = useStyles() - const t = useSharedI18N() - - const [anchorEl, setAnchorEl] = useState(null) - - const onClose = () => setAnchorEl(null) - - const onSelect = (option: SocialAddress) => { - onSelectAddress(option) - onClose() - } - - const handleOpenDialog = () => { - CrossIsolationMessages.events.requestWeb3ProfileDialog.sendToAll({ - open: true, - }) - } - - const onOpen = (event: React.MouseEvent) => setAnchorEl(event.currentTarget) - - return ( -
-
-
- - setAnchorEl(null)}> - {uniqBy(addressList ?? [], (x) => x.address.toLowerCase()).map((x) => { - return ( - onSelect(x)}> -
-
- {x?.type === SocialAddressType.KV || - x?.type === SocialAddressType.ADDRESS ? ( - - ) : ( - - {x.label} - - )} - - - - {x?.type === SocialAddressType.KV && ( - - )} -
- {isSameAddress(selectedAddress?.address, x.address) && ( - - )} -
-
- ) - })} -
-
-
- - {t.powered_by()} - - - {t.mask_network()} - - -
-
-
- - - {tabs.map((tab) => ( - - ))} - - -
-
- ) -} diff --git a/packages/shared/src/UI/components/index.ts b/packages/shared/src/UI/components/index.ts index 8e2d7e070879..de17c3b9a517 100644 --- a/packages/shared/src/UI/components/index.ts +++ b/packages/shared/src/UI/components/index.ts @@ -2,7 +2,6 @@ export * from './AddressViewer' export * from './ApplicationEntry' export * from './AssetPlayer' export * from './ChainIcon' -export * from './ConcealableTabs' export * from './FungibleTokenList' export * from './I18NextProviderHMR' export * from './ImageIcon' From 8b6bb52a51c0d17e7b36b87d9108b5eff06d485d Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Tue, 26 Jul 2022 14:36:58 +0800 Subject: [PATCH 147/179] feat: add Etherscan icon --- packages/icons/brands/EtherScan.svg | 1 + .../src/UI/components/CollectionDetailCard/index.tsx | 7 ++----- 2 files changed, 3 insertions(+), 5 deletions(-) create mode 100644 packages/icons/brands/EtherScan.svg diff --git a/packages/icons/brands/EtherScan.svg b/packages/icons/brands/EtherScan.svg new file mode 100644 index 000000000000..0537689e1b9f --- /dev/null +++ b/packages/icons/brands/EtherScan.svg @@ -0,0 +1 @@ + diff --git a/packages/shared/src/UI/components/CollectionDetailCard/index.tsx b/packages/shared/src/UI/components/CollectionDetailCard/index.tsx index ecfeec2f4b93..d89d8a76c9be 100644 --- a/packages/shared/src/UI/components/CollectionDetailCard/index.tsx +++ b/packages/shared/src/UI/components/CollectionDetailCard/index.tsx @@ -6,7 +6,7 @@ import { Box, Card, DialogContent, Link, Typography } from '@mui/material' import type { RSS3BaseAPI } from '@masknet/web3-providers' import differenceInCalendarDays from 'date-fns/differenceInDays' import differenceInCalendarHours from 'date-fns/differenceInHours' -import { Gitcoin, LinkOut, OpenSeaColoredIcon, PolygonScan } from '@masknet/icons' +import { Gitcoin, LinkOut, OpenSeaColoredIcon, PolygonScan, EtherScan } from '@masknet/icons' import { ChainId, explorerResolver } from '@masknet/web3-shared-evm' import { NFTCardStyledAssetPlayer } from '@masknet/shared' @@ -149,10 +149,7 @@ export const CollectionDetailCard = memo( if (url.includes('etherscan.io')) { return ( - + ) } From 7db06537bbdeb2294798039f1212055064bb4f10 Mon Sep 17 00:00:00 2001 From: unclebill Date: Tue, 26 Jul 2022 15:24:43 +0800 Subject: [PATCH 148/179] fix: code style --- .../plugins/Web3Feed/SNSAdaptor/FeedCard.tsx | 90 +++++++------ .../src/plugins/Web3Feed/locales/en-US.json | 6 +- .../components/CollectionDetailCard/index.tsx | 126 ++++++++---------- packages/shared/src/locales/en-US.json | 8 +- 4 files changed, 107 insertions(+), 123 deletions(-) diff --git a/packages/mask/src/plugins/Web3Feed/SNSAdaptor/FeedCard.tsx b/packages/mask/src/plugins/Web3Feed/SNSAdaptor/FeedCard.tsx index c6865c4d2b8e..1f3891b4f273 100644 --- a/packages/mask/src/plugins/Web3Feed/SNSAdaptor/FeedCard.tsx +++ b/packages/mask/src/plugins/Web3Feed/SNSAdaptor/FeedCard.tsx @@ -61,87 +61,86 @@ const useStyles = makeStyles()((theme) => ({ export interface FeedCardProps { feed: RSS3BaseAPI.Web3Feed address?: string - index: number onSelect: (feed: RSS3BaseAPI.Web3Feed) => void } -export function FeedCard({ feed, address, index, onSelect }: FeedCardProps) { +export function FeedCard({ feed, address, onSelect }: FeedCardProps) { const { classes } = useStyles() const t = useI18N() const { value: NFTMetadata } = useAsyncRetry(async () => { - if ((feed?.title && feed?.summary) || !feed?.metadata?.collection_address) return + if ((feed.title && feed.summary) || !feed.metadata?.collection_address) return - const res = await Alchemy_EVM.getAsset(feed?.metadata?.collection_address, feed?.metadata?.token_id ?? '', { - chainId: ChainID[feed?.metadata?.network ?? 'ethereum'], + const res = await Alchemy_EVM.getAsset(feed.metadata?.collection_address, feed.metadata?.token_id ?? '', { + chainId: ChainID[feed.metadata?.network ?? 'ethereum'], }) return res - }, [feed?.metadata?.collection_address]) + }, [feed.metadata?.collection_address]) const action = useMemo(() => { if (!feed) return - if (feed?.tags?.includes('NFT')) { - if (feed?.metadata?.from?.toLowerCase() === address) { + if (feed.tags?.includes('NFT')) { + if (feed.metadata?.from?.toLowerCase() === address) { return ( - sent a NFT to + sent a NFT to ) } - if (feed?.metadata?.from === ZERO_ADDRESS) { + if (feed.metadata?.from === ZERO_ADDRESS) { return 'minted a NFT' } - if (feed?.metadata?.to?.toLowerCase() === address) { + if (feed.metadata?.to?.toLowerCase() === address) { return ( - acquire a NFT from + acquire a NFT from ) } } - if (feed?.tags?.includes('Token') || feed?.tags?.includes('ETH')) { - if (feed?.metadata?.from?.toLowerCase() === address) { + if (feed.tags?.includes('Token') || feed.tags?.includes('ETH')) { + if (feed.metadata?.from?.toLowerCase() === address) { return ( - sent to + sent to ) } - if (feed?.metadata?.to?.toLowerCase() === address) { + if (feed.metadata?.to?.toLowerCase() === address) { return ( - received from + received from ) } } - if (feed?.tags?.includes('Gitcoin')) { - if (feed?.metadata?.from?.toLowerCase() === address) { + if (feed.tags?.includes('Gitcoin')) { + if (feed.metadata?.from?.toLowerCase() === address) { return 'donated' } - if (feed?.metadata?.to?.toLowerCase() === address) { + if (feed.metadata?.to?.toLowerCase() === address) { return 'received donation from' } } - if (feed?.metadata?.from?.toLowerCase() === address) { + if (feed.metadata?.from?.toLowerCase() === address) { return 'received' } return 'sent' }, [address, feed]) const logo = useMemo(() => { - if (feed?.tags?.includes('NFT')) { + if (feed.tags?.includes('NFT')) { return ( attachment?.type === 'preview')?.address || + feed.attachments?.find((attachment) => attachment?.type === 'preview')?.address || '', )} - tokenId={feed?.metadata?.token_id} + tokenId={feed.metadata?.token_id} classes={{ loadingFailImage: classes.loadingFailImage, wrapper: classes.img, @@ -151,20 +150,20 @@ export function FeedCard({ feed, address, index, onSelect }: FeedCardProps) { ) } - if (feed?.tags.includes('Token') || feed?.tags.includes('ETH')) { + if (feed.tags.includes('Token') || feed.tags.includes('ETH')) { return ( ) } - if (feed?.tags.includes('Gitcoin')) { + if (feed.tags.includes('Gitcoin')) { return ( attachment?.type === 'logo')?.address} + src={feed.attachments?.find((attachment) => attachment?.type === 'logo')?.address} /> ) } @@ -172,10 +171,14 @@ export function FeedCard({ feed, address, index, onSelect }: FeedCardProps) { }, [feed]) const time = useMemo(() => { - const days = differenceInCalendarDays(new Date(), new Date(feed?.date_updated)) - const hours = differenceInCalendarHours(new Date(), new Date(feed?.date_updated)) % 24 - return days ? `${days} ${t.days()} ${hours} ${t.hours()} ${t.ago()}` : `${hours} ${t.hours()} ${t.ago()}` - }, [feed?.date_updated]) + const days = differenceInCalendarDays(new Date(), new Date(feed.date_updated)) + const hours = differenceInCalendarHours(new Date(), new Date(feed.date_updated)) + return [ + days > 0 ? `${days} ${t.day({ count: days })} ` : '', + hours > 0 ? `${hours} ${t.day({ count: hours })} ` : '', + t.ago(), + ].join('') + }, [feed.date_updated, t]) return ( attachment?.type === 'preview')?.address || - feed?.attachments?.find((attachment) => attachment?.type === 'logo')?.address || + feed.attachments?.find((attachment) => attachment?.type === 'preview')?.address || + feed.attachments?.find((attachment) => attachment?.type === 'logo')?.address || '', ), traits: NFTMetadata?.traits, @@ -203,15 +205,15 @@ export function FeedCard({ feed, address, index, onSelect }: FeedCardProps) { {action} {time} - {feed?.title || + {feed.title || NFTMetadata?.metadata?.name || NFTMetadata?.collection?.name || NFTMetadata?.contract?.name || ''} - {feed?.summary || NFTMetadata?.metadata?.description || NFTMetadata?.collection?.description} || - `#${feed?.metadata?.token_id}` + {feed.summary || NFTMetadata?.metadata?.description || NFTMetadata?.collection?.description} || + `#${feed.metadata?.token_id}`
diff --git a/packages/mask/src/plugins/Web3Feed/locales/en-US.json b/packages/mask/src/plugins/Web3Feed/locales/en-US.json index 60bea0dc36e1..213a84e43bb3 100644 --- a/packages/mask/src/plugins/Web3Feed/locales/en-US.json +++ b/packages/mask/src/plugins/Web3Feed/locales/en-US.json @@ -1,6 +1,8 @@ { - "days": "days", - "hours": "hours", + "day_one": "days", + "day_other": "days", + "hour_one": "hour", + "hour_other": "hours", "ago": "ago", "no_data": "No feed at the current address" } diff --git a/packages/shared/src/UI/components/CollectionDetailCard/index.tsx b/packages/shared/src/UI/components/CollectionDetailCard/index.tsx index d89d8a76c9be..b2536c289043 100644 --- a/packages/shared/src/UI/components/CollectionDetailCard/index.tsx +++ b/packages/shared/src/UI/components/CollectionDetailCard/index.tsx @@ -1,4 +1,4 @@ -import { memo } from 'react' +import { memo, ReactNode } from 'react' import { makeStyles } from '@masknet/theme' import { InjectedDialog } from '../../../contexts' import { useSharedI18N } from '../../../locales' @@ -9,6 +9,7 @@ import differenceInCalendarHours from 'date-fns/differenceInHours' import { Gitcoin, LinkOut, OpenSeaColoredIcon, PolygonScan, EtherScan } from '@masknet/icons' import { ChainId, explorerResolver } from '@masknet/web3-shared-evm' import { NFTCardStyledAssetPlayer } from '@masknet/shared' +import { EMPTY_LIST } from '@masknet/shared-base' interface CollectionDetailCardProps { img?: string @@ -136,60 +137,35 @@ export const CollectionDetailCard = memo( referenceUrl, metadata, description, - contributions, + contributions = EMPTY_LIST, date, location, - relatedURLs, + relatedURLs = EMPTY_LIST, traits, }) => { const t = useSharedI18N() const { classes } = useStyles() - const icons = relatedURLs?.map((url) => { + const icons = relatedURLs.map((url) => { + let icon: ReactNode = null if (url.includes('etherscan.io')) { - return ( - - - - ) - } - if (url.includes('polygonscan.com/tx')) { - return ( - - - - ) - } - if (url.includes('polygonscan.com/token')) { - return ( - - - - ) - } - if (url.includes('opensea.io')) { - return ( - - - - ) - } - if (url.includes('gitcoin.co')) { - return ( - - - - ) + icon = + } else if (url.includes('polygonscan.com/tx')) { + icon = + } else if (url.includes('polygonscan.com/token')) { + icon = + } else if (url.includes('opensea.io')) { + icon = + } else if (url.includes('gitcoin.co')) { + icon = } - return null + return icon ? ( + + {icon} + + ) : null }) - const newContributions = contributions?.map((contribution) => ({ - ...contribution, - daysFromNow: differenceInCalendarDays(Date.now(), Number(contribution.timeStamp) * 1000), - hoursFromNow: differenceInCalendarHours(Date.now(), Number(contribution.timeStamp) * 1000) % 24, - })) - return ( @@ -235,34 +211,38 @@ export const CollectionDetailCard = memo( {description}
- {contributions ? ( - - {t.contributions()} - - ) : null} - {contributions ? ( - - {contributions?.length ?? 0} - - ) : null} - {newContributions?.map((contribution) => ( -
- - {contribution.formatedAmount} {contribution.symbol} + {contributions.length ? ( + <> + + {t.contributions()} -
- {contribution?.daysFromNow} {contribution?.daysFromNow > 1 ? t.days() : t.day()}{' '} - {contribution?.hoursFromNow} {contribution?.hoursFromNow > 1 ? t.hours() : t.hour()}{' '} - {t.ago()} - - - + + {contributions.length} + + + ) : null} + {contributions.map((contribution) => { + const days = differenceInCalendarDays(Date.now(), Number(contribution.timeStamp) * 1000) + const hours = differenceInCalendarHours(Date.now(), Number(contribution.timeStamp) * 1000) + return ( +
+ + {contribution.formatedAmount} {contribution.symbol} + +
+ {days > 0 ? `${days} ${t.day({ count: days })} ` : ''} + {hours > 0 ? `${hours} ${t.day({ count: hours })} ` : ''} + {t.ago()} + + + +
-
- ))} + ) + })} {traits && ( {t.properties()} @@ -270,9 +250,9 @@ export const CollectionDetailCard = memo( )} {traits?.map((trait) => ( -
- {trait?.type} - {trait?.value} +
+ {trait.type} + {trait.value}
))} diff --git a/packages/shared/src/locales/en-US.json b/packages/shared/src/locales/en-US.json index c15164d7a7e8..4f767c757ee6 100644 --- a/packages/shared/src/locales/en-US.json +++ b/packages/shared/src/locales/en-US.json @@ -47,10 +47,10 @@ "unnamed": "Unnamed", "contributions": "Contributions", "description": "Description", - "days": "days", - "hours": "hours", - "day": "day", - "hour": "hour", + "day_one": "day", + "day_other": "days", + "hour_one": "hour", + "hour_other": "hours", "ago": "ago", "properties": "Properties", "security_detection": "Security Detection", From 2b12a8f5e96a6f4501ac8c1a60a6bfad1ff9a562 Mon Sep 17 00:00:00 2001 From: unclebill Date: Tue, 26 Jul 2022 15:43:19 +0800 Subject: [PATCH 149/179] fixup! fix: code style --- .../src/UI/components/TokenSecurity/components/RiskCard.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/shared/src/UI/components/TokenSecurity/components/RiskCard.tsx b/packages/shared/src/UI/components/TokenSecurity/components/RiskCard.tsx index 62071b3981d1..0dc0ef48a6a0 100644 --- a/packages/shared/src/UI/components/TokenSecurity/components/RiskCard.tsx +++ b/packages/shared/src/UI/components/TokenSecurity/components/RiskCard.tsx @@ -51,6 +51,7 @@ export const RiskCard = memo(({ info, tokenSecurity }) => { fee: '', percentage: '', distance: '', + count: 0, })} titleColor={DefineMapping[info.level].titleColor} description={t[info.messageKey]({ @@ -61,6 +62,7 @@ export const RiskCard = memo(({ info, tokenSecurity }) => { fee: '', percentage: '', distance: '', + count: 0, })} /> ) From b2d1965e6e7e6bf21e3aff0b3dfe287c69cc57c2 Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Tue, 26 Jul 2022 15:48:55 +0800 Subject: [PATCH 150/179] feat: delete useless code --- packages/mask/src/plugins/Web3Feed/SNSAdaptor/Web3FeedPage.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/mask/src/plugins/Web3Feed/SNSAdaptor/Web3FeedPage.tsx b/packages/mask/src/plugins/Web3Feed/SNSAdaptor/Web3FeedPage.tsx index fbe286b630e6..31ff671c3cbd 100644 --- a/packages/mask/src/plugins/Web3Feed/SNSAdaptor/Web3FeedPage.tsx +++ b/packages/mask/src/plugins/Web3Feed/SNSAdaptor/Web3FeedPage.tsx @@ -25,11 +25,10 @@ export function Web3FeedPage({ socialAddress, persona }: Web3FeedPageProps) { return (
- {feed?.list?.map((info, index) => { + {feed?.list?.map((info) => { return ( setSelectedFeed(feed)} feed={info} address={socialAddress?.address} From 9a492199841cc7c43f8d45065427dd316827b770 Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Wed, 27 Jul 2022 14:54:06 +0800 Subject: [PATCH 151/179] feat: use icon component correctly --- packages/mask/shared-ui/locales/en-US.json | 1 + .../InjectedComponents/ProfileTabContent.tsx | 10 +++++----- .../Trader/SNSAdaptor/trending/PriceChanged.tsx | 6 +++--- .../Trader/SNSAdaptor/trending/TrendingViewDeck.tsx | 4 ++-- .../Wallet/SNSAdaptor/TransactionSnackbar/index.tsx | 4 ++-- .../src/SNSAdaptor/components/ImageManagement.tsx | 3 +-- .../src/SNSAdaptor/components/WalletSetting.tsx | 3 +-- 7 files changed, 15 insertions(+), 16 deletions(-) diff --git a/packages/mask/shared-ui/locales/en-US.json b/packages/mask/shared-ui/locales/en-US.json index 86c3eb587f4b..9c0c84f65f57 100644 --- a/packages/mask/shared-ui/locales/en-US.json +++ b/packages/mask/shared-ui/locales/en-US.json @@ -25,6 +25,7 @@ "gas_price": "Gas Price", "redirect_to": "Redirect to", "sign": "Sign", + "powered_by": "Powered by", "reload": "Reload", "load": "Load", "load_all": "Load All", diff --git a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx index 73ae2180461c..e94a647d0c15 100644 --- a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx +++ b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx @@ -9,7 +9,7 @@ import { usePluginI18NField, } from '@masknet/plugin-infra/content-script' import { useSocialAddressListAll, useAvailablePlugins } from '@masknet/plugin-infra/web3' -import { ReversedAddress, useSharedI18N } from '@masknet/shared' +import { ReversedAddress } from '@masknet/shared' import { CrossIsolationMessages, EMPTY_LIST, NextIDPlatform } from '@masknet/shared-base' import { makeStyles, MaskTabList, ShadowRootMenu, useStylesExtends, useTabs } from '@masknet/theme' import { Box, Button, CircularProgress, Link, MenuItem, Tab, Typography } from '@mui/material' @@ -17,7 +17,7 @@ import { ArrowDrop, Gear, LinkOut, NextIdPersonaVerified, Selected } from '@mask import { isSameAddress, NetworkPluginID, SocialAddress, SocialAddressType } from '@masknet/web3-shared-base' import { activatedSocialNetworkUI } from '../../social-network' import { isTwitter } from '../../social-network-adaptor/twitter.com/base' -import { MaskMessages } from '../../utils' +import { MaskMessages, useI18N } from '../../utils' import { useLocationChange } from '../../utils/hooks/useLocationChange' import { useCurrentVisitingIdentity, @@ -112,7 +112,7 @@ export interface ProfileTabContentProps extends withClasses<'text' | 'button' | export function ProfileTabContent(props: ProfileTabContentProps) { const classes = useStylesExtends(useStyles(), props) - const t = useSharedI18N() + const { t } = useI18N() const translate = usePluginI18NField() const [hidden, setHidden] = useState(true) @@ -363,10 +363,10 @@ export function ProfileTabContent(props: ProfileTabContentProps) {
- {t.powered_by()} + {t('powered_by')} - {t.mask_network()} + {t('mask_network')} {isOwnerIdentity ? ( diff --git a/packages/mask/src/plugins/Trader/SNSAdaptor/trending/PriceChanged.tsx b/packages/mask/src/plugins/Trader/SNSAdaptor/trending/PriceChanged.tsx index 1a9e14d18d14..17b7bfa28866 100644 --- a/packages/mask/src/plugins/Trader/SNSAdaptor/trending/PriceChanged.tsx +++ b/packages/mask/src/plugins/Trader/SNSAdaptor/trending/PriceChanged.tsx @@ -1,6 +1,6 @@ import { makeStyles } from '@masknet/theme' import { Stack, Typography, useTheme } from '@mui/material' -import { ArrowDropIcon } from '@masknet/icons' +import { ArrowDrop } from '@masknet/icons' const useStyles = makeStyles()({ root: { @@ -31,8 +31,8 @@ export function PriceChanged(props: PriceChangedProps) { if (props.amount === 0) return null return ( - {props.amount > 0 ? : null} - {props.amount < 0 ? : null} + {props.amount > 0 ? : null} + {props.amount < 0 ? : null} 0 ? colors?.success : colors?.danger}> {props.amount.toFixed(2)}% diff --git a/packages/mask/src/plugins/Trader/SNSAdaptor/trending/TrendingViewDeck.tsx b/packages/mask/src/plugins/Trader/SNSAdaptor/trending/TrendingViewDeck.tsx index 37c6c94a375f..e10a31cc2f05 100644 --- a/packages/mask/src/plugins/Trader/SNSAdaptor/trending/TrendingViewDeck.tsx +++ b/packages/mask/src/plugins/Trader/SNSAdaptor/trending/TrendingViewDeck.tsx @@ -1,4 +1,4 @@ -import { ArrowDropIcon, BuyIcon } from '@masknet/icons' +import { ArrowDrop, BuyIcon } from '@masknet/icons' import { PluginId, useActivatedPluginsSNSAdaptor, useIsMinimalMode } from '@masknet/plugin-infra/content-script' import { useAccount } from '@masknet/plugin-infra/web3' import { DataProvider } from '@masknet/public-api' @@ -248,7 +248,7 @@ export function TrendingViewDeck(props: TrendingViewDeckProps) { sx={{ padding: 0 }} size="small" onClick={() => setCoinMenuOpen((v) => !v)}> - + ({ pluginID }: Tra {progress.status === TransactionStatusType.SUCCEED ? computed.successfulDescription ?? computed.description : computed.description}{' '} - + ), }, diff --git a/packages/plugins/Web3Profile/src/SNSAdaptor/components/ImageManagement.tsx b/packages/plugins/Web3Profile/src/SNSAdaptor/components/ImageManagement.tsx index 02c10f5782c0..f10710603a54 100644 --- a/packages/plugins/Web3Profile/src/SNSAdaptor/components/ImageManagement.tsx +++ b/packages/plugins/Web3Profile/src/SNSAdaptor/components/ImageManagement.tsx @@ -56,7 +56,6 @@ const useStyles = makeStyles()((theme) => ({ }, walletIcon: { marginRight: '8px', - fontSize: 16, }, emptyItem: { marginTop: 'calc(50% - 104px)', @@ -133,7 +132,7 @@ export function ImageManagement(props: ImageManagementProps) { {!hasConnectedWallets && ( diff --git a/packages/plugins/Web3Profile/src/SNSAdaptor/components/WalletSetting.tsx b/packages/plugins/Web3Profile/src/SNSAdaptor/components/WalletSetting.tsx index f750033c9d8b..bce322ea815f 100644 --- a/packages/plugins/Web3Profile/src/SNSAdaptor/components/WalletSetting.tsx +++ b/packages/plugins/Web3Profile/src/SNSAdaptor/components/WalletSetting.tsx @@ -102,7 +102,6 @@ const useStyles = makeStyles()((theme) => ({ }, walletIcon: { marginRight: '8px', - fontSize: 16, }, })) @@ -275,7 +274,7 @@ const WalletSetting = memo( ) : ( From 0193ec9d0607ebc4e95a442d3ed13eeb5f28cad1 Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Wed, 27 Jul 2022 16:14:56 +0800 Subject: [PATCH 152/179] feat: add Feed under RSS3 plugin --- packages/mask/src/plugin-infra/register.js | 1 - .../plugins/Web3Feed/SNSAdaptor/StatusBox.tsx | 39 ---------------- .../src/plugins/Web3Feed/SNSAdaptor/index.tsx | 23 ---------- .../mask/src/plugins/Web3Feed/Worker/index.ts | 8 ---- packages/mask/src/plugins/Web3Feed/base.ts | 26 ----------- .../mask/src/plugins/Web3Feed/constants.ts | 10 ----- packages/mask/src/plugins/Web3Feed/index.ts | 16 ------- .../src/plugins/Web3Feed/locales/en-US.json | 8 ---- .../src/plugins/Web3Feed/locales/index.ts | 6 --- .../src/plugins/Web3Feed/locales/ja-JP.json | 1 - .../src/plugins/Web3Feed/locales/ko-KR.json | 1 - .../src/plugins/Web3Feed/locales/languages.ts | 34 -------------- .../src/plugins/Web3Feed/locales/qya-AA.json | 8 ---- .../src/plugins/Web3Feed/locales/zh-CN.json | 1 - .../src/plugins/Web3Feed/locales/zh-TW.json | 1 - .../plugins/RSS3/src/SNSAdaptor/TabCard.tsx | 45 ++++++++++++------- .../src/SNSAdaptor/components}/FeedCard.tsx | 15 ++++--- .../components}/ReversedAddress.tsx | 0 .../plugins/RSS3/src/SNSAdaptor/index.tsx | 13 ++++++ .../src/SNSAdaptor/pages/DonationsPage.tsx | 2 +- .../RSS3/src/SNSAdaptor/pages/FeedPage.tsx} | 13 +++--- .../src/SNSAdaptor/pages/FootprintPage.tsx | 5 ++- packages/plugins/RSS3/src/locales/en-US.json | 10 ++++- 23 files changed, 74 insertions(+), 212 deletions(-) delete mode 100644 packages/mask/src/plugins/Web3Feed/SNSAdaptor/StatusBox.tsx delete mode 100644 packages/mask/src/plugins/Web3Feed/SNSAdaptor/index.tsx delete mode 100644 packages/mask/src/plugins/Web3Feed/Worker/index.ts delete mode 100644 packages/mask/src/plugins/Web3Feed/base.ts delete mode 100644 packages/mask/src/plugins/Web3Feed/constants.ts delete mode 100644 packages/mask/src/plugins/Web3Feed/index.ts delete mode 100644 packages/mask/src/plugins/Web3Feed/locales/en-US.json delete mode 100644 packages/mask/src/plugins/Web3Feed/locales/index.ts delete mode 100644 packages/mask/src/plugins/Web3Feed/locales/ja-JP.json delete mode 100644 packages/mask/src/plugins/Web3Feed/locales/ko-KR.json delete mode 100644 packages/mask/src/plugins/Web3Feed/locales/languages.ts delete mode 100644 packages/mask/src/plugins/Web3Feed/locales/qya-AA.json delete mode 100644 packages/mask/src/plugins/Web3Feed/locales/zh-CN.json delete mode 100644 packages/mask/src/plugins/Web3Feed/locales/zh-TW.json rename packages/{mask/src/plugins/Web3Feed/SNSAdaptor => plugins/RSS3/src/SNSAdaptor/components}/FeedCard.tsx (95%) rename packages/{mask/src/plugins/Web3Feed/SNSAdaptor => plugins/RSS3/src/SNSAdaptor/components}/ReversedAddress.tsx (100%) rename packages/{mask/src/plugins/Web3Feed/SNSAdaptor/Web3FeedPage.tsx => plugins/RSS3/src/SNSAdaptor/pages/FeedPage.tsx} (81%) diff --git a/packages/mask/src/plugin-infra/register.js b/packages/mask/src/plugin-infra/register.js index 4b2057d82a51..40e389058eeb 100644 --- a/packages/mask/src/plugin-infra/register.js +++ b/packages/mask/src/plugin-infra/register.js @@ -36,7 +36,6 @@ import '../plugins/Referral' import '../plugins/Tips' import '../plugins/Approval' import '@masknet/plugin-web3-profile' -import '../plugins/Web3Feed' // import '../plugins/dHEDGE' // import '../plugins/External' // import '../plugins/Polls' diff --git a/packages/mask/src/plugins/Web3Feed/SNSAdaptor/StatusBox.tsx b/packages/mask/src/plugins/Web3Feed/SNSAdaptor/StatusBox.tsx deleted file mode 100644 index f7c27973fcb3..000000000000 --- a/packages/mask/src/plugins/Web3Feed/SNSAdaptor/StatusBox.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import { makeStyles } from '@masknet/theme' -import { Box, CircularProgress, Typography } from '@mui/material' -import type { FC } from 'react' -import { useI18N } from '../locales' - -interface Props { - loading?: boolean - empty?: boolean -} - -const useStyles = makeStyles()((theme) => ({ - statusBox: { - display: 'flex', - alignItems: 'center', - justifyContent: 'center', - marginTop: theme.spacing(6), - }, -})) - -export const StatusBox: FC = ({ loading, empty }) => { - const { classes } = useStyles() - const t = useI18N() - if (loading) { - return ( - - - - ) - } - - if (empty) { - return ( - - {t.no_data()} - - ) - } - return null -} diff --git a/packages/mask/src/plugins/Web3Feed/SNSAdaptor/index.tsx b/packages/mask/src/plugins/Web3Feed/SNSAdaptor/index.tsx deleted file mode 100644 index e97baea9383f..000000000000 --- a/packages/mask/src/plugins/Web3Feed/SNSAdaptor/index.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import type { Plugin } from '@masknet/plugin-infra/content-script' -import { base } from '../base' -import { PLUGIN_ID } from '../constants' -import { Web3FeedPage } from './Web3FeedPage' - -const sns: Plugin.SNSAdaptor.Definition = { - ...base, - init(signal, context) {}, - ProfileTabs: [ - { - ID: `${PLUGIN_ID}_web3Feed`, - label: 'Web3Feed', - priority: 4, - UI: { - TabContent: ({ socialAddress, persona }) => { - return - }, - }, - }, - ], -} - -export default sns diff --git a/packages/mask/src/plugins/Web3Feed/Worker/index.ts b/packages/mask/src/plugins/Web3Feed/Worker/index.ts deleted file mode 100644 index 2da0563bd149..000000000000 --- a/packages/mask/src/plugins/Web3Feed/Worker/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -import type { Plugin } from '@masknet/plugin-infra' -import { base } from '../base' - -const worker: Plugin.Worker.Definition = { - ...base, - init(signal) {}, -} -export default worker diff --git a/packages/mask/src/plugins/Web3Feed/base.ts b/packages/mask/src/plugins/Web3Feed/base.ts deleted file mode 100644 index 6fdbd9edc841..000000000000 --- a/packages/mask/src/plugins/Web3Feed/base.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { PLUGIN_ID } from './constants' -import { languages } from './locales/languages' -import { Plugin, CurrentSNSNetwork } from '@masknet/plugin-infra' - -export const base: Plugin.Shared.Definition = { - ID: PLUGIN_ID, - name: { fallback: 'Web3Feed' }, - description: { - fallback: 'web3 user collection feed', - }, - publisher: { name: { fallback: 'Mask Network' }, link: 'https://mask.io/' }, - enableRequirement: { - architecture: { app: true, web: true }, - networks: { - type: 'opt-in', - networks: { - [CurrentSNSNetwork.Twitter]: true, - [CurrentSNSNetwork.Facebook]: false, - [CurrentSNSNetwork.Instagram]: false, - }, - }, - target: 'stable', - }, - - i18n: languages, -} diff --git a/packages/mask/src/plugins/Web3Feed/constants.ts b/packages/mask/src/plugins/Web3Feed/constants.ts deleted file mode 100644 index 4b7cb0aac151..000000000000 --- a/packages/mask/src/plugins/Web3Feed/constants.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { PluginId } from '@masknet/plugin-infra' -import { ChainId } from '@masknet/web3-shared-evm' -export const PLUGIN_ID = PluginId.Web3Feed -export const PLUGIN_NAME = 'Web3 Feed' -export const PLUGIN_DESCRIPTION = 'web3 user collection feed' -export const ChainID = { - ethereum: ChainId.Mainnet, - polygon: ChainId.Matic, - bnb: ChainId.BSC, -} diff --git a/packages/mask/src/plugins/Web3Feed/index.ts b/packages/mask/src/plugins/Web3Feed/index.ts deleted file mode 100644 index eb51ba0afe25..000000000000 --- a/packages/mask/src/plugins/Web3Feed/index.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { registerPlugin } from '@masknet/plugin-infra' -import { base } from './base' - -registerPlugin({ - ...base, - SNSAdaptor: { - load: () => import('./SNSAdaptor'), - hotModuleReload: (hot) => - import.meta.webpackHot && import.meta.webpackHot.accept('./SNSAdaptor', () => hot(import('./SNSAdaptor'))), - }, - Worker: { - load: () => import('./Worker'), - hotModuleReload: (hot) => - import.meta.webpackHot && import.meta.webpackHot.accept('./Worker', () => hot(import('./Worker'))), - }, -}) diff --git a/packages/mask/src/plugins/Web3Feed/locales/en-US.json b/packages/mask/src/plugins/Web3Feed/locales/en-US.json deleted file mode 100644 index 213a84e43bb3..000000000000 --- a/packages/mask/src/plugins/Web3Feed/locales/en-US.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "day_one": "days", - "day_other": "days", - "hour_one": "hour", - "hour_other": "hours", - "ago": "ago", - "no_data": "No feed at the current address" -} diff --git a/packages/mask/src/plugins/Web3Feed/locales/index.ts b/packages/mask/src/plugins/Web3Feed/locales/index.ts deleted file mode 100644 index d6ead60252e4..000000000000 --- a/packages/mask/src/plugins/Web3Feed/locales/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -// This file is auto generated. DO NOT EDIT -// Run `npx gulp sync-languages` to regenerate. -// Default fallback language in a family of languages are chosen by the alphabet order -// To overwrite this, please overwrite packages/scripts/src/locale-kit-next/index.ts - -export * from './i18n_generated' diff --git a/packages/mask/src/plugins/Web3Feed/locales/ja-JP.json b/packages/mask/src/plugins/Web3Feed/locales/ja-JP.json deleted file mode 100644 index 0967ef424bce..000000000000 --- a/packages/mask/src/plugins/Web3Feed/locales/ja-JP.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/packages/mask/src/plugins/Web3Feed/locales/ko-KR.json b/packages/mask/src/plugins/Web3Feed/locales/ko-KR.json deleted file mode 100644 index 0967ef424bce..000000000000 --- a/packages/mask/src/plugins/Web3Feed/locales/ko-KR.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/packages/mask/src/plugins/Web3Feed/locales/languages.ts b/packages/mask/src/plugins/Web3Feed/locales/languages.ts deleted file mode 100644 index 143dc822172a..000000000000 --- a/packages/mask/src/plugins/Web3Feed/locales/languages.ts +++ /dev/null @@ -1,34 +0,0 @@ -// This file is auto generated. DO NOT EDIT -// Run `npx gulp sync-languages` to regenerate. -// Default fallback language in a family of languages are chosen by the alphabet order -// To overwrite this, please overwrite packages/scripts/src/locale-kit-next/index.ts -import en_US from './en-US.json' -import ja_JP from './ja-JP.json' -import ko_KR from './ko-KR.json' -import qya_AA from './qya-AA.json' -import zh_CN from './zh-CN.json' -import zh_TW from './zh-TW.json' -export const languages = { - en: en_US, - ja: ja_JP, - ko: ko_KR, - qy: qya_AA, - 'zh-CN': zh_CN, - zh: zh_TW, -} -// @ts-ignore -if (import.meta.webpackHot) { - // @ts-ignore - import.meta.webpackHot.accept( - ['./en-US.json', './ja-JP.json', './ko-KR.json', './qya-AA.json', './zh-CN.json', './zh-TW.json'], - () => - globalThis.dispatchEvent?.( - new CustomEvent('MASK_I18N_HMR', { - detail: [ - 'org.findtruman', - { en: en_US, ja: ja_JP, ko: ko_KR, qy: qya_AA, 'zh-CN': zh_CN, zh: zh_TW }, - ], - }), - ), - ) -} diff --git a/packages/mask/src/plugins/Web3Feed/locales/qya-AA.json b/packages/mask/src/plugins/Web3Feed/locales/qya-AA.json deleted file mode 100644 index e0d8c3ff3ca3..000000000000 --- a/packages/mask/src/plugins/Web3Feed/locales/qya-AA.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "day_one": "crwdns18212:0crwdne18212:0", - "day_other": "crwdns18214:0crwdne18214:0", - "hour_one": "crwdns18216:0crwdne18216:0", - "hour_other": "crwdns18218:0crwdne18218:0", - "ago": "crwdns18220:0crwdne18220:0", - "no_data": "crwdns18222:0crwdne18222:0" -} diff --git a/packages/mask/src/plugins/Web3Feed/locales/zh-CN.json b/packages/mask/src/plugins/Web3Feed/locales/zh-CN.json deleted file mode 100644 index 0967ef424bce..000000000000 --- a/packages/mask/src/plugins/Web3Feed/locales/zh-CN.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/packages/mask/src/plugins/Web3Feed/locales/zh-TW.json b/packages/mask/src/plugins/Web3Feed/locales/zh-TW.json deleted file mode 100644 index 0967ef424bce..000000000000 --- a/packages/mask/src/plugins/Web3Feed/locales/zh-TW.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/packages/plugins/RSS3/src/SNSAdaptor/TabCard.tsx b/packages/plugins/RSS3/src/SNSAdaptor/TabCard.tsx index 4d6c8bb0003f..73fa169d1443 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/TabCard.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/TabCard.tsx @@ -7,10 +7,13 @@ import { useCurrentVisitingProfile } from './hooks/useContext' import { CollectionType, KVType } from '../types' import { useKV } from './hooks/useKV' import type { RSS3BaseAPI } from '@masknet/web3-providers' +import { FeedPage } from './pages/FeedPage' +import { useMemo } from 'react' export enum TabCardType { Donation = 1, Footprint = 2, + Feed = 3, } export interface TabCardProps { @@ -44,21 +47,33 @@ export function TabCard({ type, socialAddress, persona }: TabCardProps) { socialAddress, ) - if (!socialAddress) return null + const page = useMemo(() => { + if (!socialAddress) return null + if (type === TabCardType.Donation) { + return ( + + ) + } + if (type === TabCardType.Footprint) { + return ( + + ) + } + if (type === TabCardType.Feed) { + return + } + return null + }, [type, socialAddress, persona]) - const isDonation = type === TabCardType.Donation + if (!socialAddress) return null - return isDonation ? ( - - ) : ( - - ) + return page } diff --git a/packages/mask/src/plugins/Web3Feed/SNSAdaptor/FeedCard.tsx b/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx similarity index 95% rename from packages/mask/src/plugins/Web3Feed/SNSAdaptor/FeedCard.tsx rename to packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx index 1f3891b4f273..d10e1dfe32cb 100644 --- a/packages/mask/src/plugins/Web3Feed/SNSAdaptor/FeedCard.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx @@ -2,14 +2,13 @@ import { NFTCardStyledAssetPlayer, TokenIcon } from '@masknet/shared' import { makeStyles } from '@masknet/theme' import { Alchemy_EVM, RSS3BaseAPI } from '@masknet/web3-providers' import { NetworkPluginID } from '@masknet/web3-shared-base' -import { resolveIPFSLinkFromURL, ZERO_ADDRESS } from '@masknet/web3-shared-evm' +import { ChainId, resolveIPFSLinkFromURL, ZERO_ADDRESS } from '@masknet/web3-shared-evm' import { Box, Typography, Card } from '@mui/material' import differenceInCalendarDays from 'date-fns/differenceInDays' import differenceInCalendarHours from 'date-fns/differenceInHours' import { useMemo } from 'react' -import { ChainID } from '../constants' import { ReversedAddress } from './ReversedAddress' -import { useI18N } from '../locales' +import { useI18N } from '../../locales' import { useAsyncRetry } from 'react-use' const useStyles = makeStyles()((theme) => ({ @@ -58,6 +57,12 @@ const useStyles = makeStyles()((theme) => ({ }, })) +export const ChainID = { + ethereum: ChainId.Mainnet, + polygon: ChainId.Matic, + bnb: ChainId.BSC, +} + export interface FeedCardProps { feed: RSS3BaseAPI.Web3Feed address?: string @@ -174,8 +179,8 @@ export function FeedCard({ feed, address, onSelect }: FeedCardProps) { const days = differenceInCalendarDays(new Date(), new Date(feed.date_updated)) const hours = differenceInCalendarHours(new Date(), new Date(feed.date_updated)) return [ - days > 0 ? `${days} ${t.day({ count: days })} ` : '', - hours > 0 ? `${hours} ${t.day({ count: hours })} ` : '', + days > 0 ? `${days} ${days > 1 ? t.days() : t.day()} ` : '', + hours > 0 ? `${hours} ${hours > 1 ? t.hours() : t.hour()} ` : '', t.ago(), ].join('') }, [feed.date_updated, t]) diff --git a/packages/mask/src/plugins/Web3Feed/SNSAdaptor/ReversedAddress.tsx b/packages/plugins/RSS3/src/SNSAdaptor/components/ReversedAddress.tsx similarity index 100% rename from packages/mask/src/plugins/Web3Feed/SNSAdaptor/ReversedAddress.tsx rename to packages/plugins/RSS3/src/SNSAdaptor/components/ReversedAddress.tsx diff --git a/packages/plugins/RSS3/src/SNSAdaptor/index.tsx b/packages/plugins/RSS3/src/SNSAdaptor/index.tsx index bb5b20b125d6..022d144c1028 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/index.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/index.tsx @@ -41,6 +41,19 @@ const sns: Plugin.SNSAdaptor.Definition = { shouldDisplay, }, }, + { + ID: `${PLUGIN_ID}_feed`, + label: 'Feed', + priority: 3, + UI: { + TabContent: ({ socialAddress, persona }) => { + return + }, + }, + Utils: { + shouldDisplay, + }, + }, ], } diff --git a/packages/plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx b/packages/plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx index a3c233511887..16557e21b688 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx @@ -51,7 +51,7 @@ export function DonationPage({ donations = [], loading, address }: DonationPageP const [selectedDonation, setSelectedDonation] = useState() if (loading || !donations.length) { - return + return } return ( diff --git a/packages/mask/src/plugins/Web3Feed/SNSAdaptor/Web3FeedPage.tsx b/packages/plugins/RSS3/src/SNSAdaptor/pages/FeedPage.tsx similarity index 81% rename from packages/mask/src/plugins/Web3Feed/SNSAdaptor/Web3FeedPage.tsx rename to packages/plugins/RSS3/src/SNSAdaptor/pages/FeedPage.tsx index 31ff671c3cbd..582c5a9bc132 100644 --- a/packages/mask/src/plugins/Web3Feed/SNSAdaptor/Web3FeedPage.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/pages/FeedPage.tsx @@ -3,15 +3,16 @@ import { RSS3, RSS3BaseAPI } from '@masknet/web3-providers' import type { NetworkPluginID, SocialAddress } from '@masknet/web3-shared-base' import { useState } from 'react' import { useAsyncRetry } from 'react-use' -import { FeedCard } from './FeedCard' -import { StatusBox } from './StatusBox' +import { FeedCard } from '../components/FeedCard' +import { StatusBox } from '../components/StatusBox' +import { useI18N } from '../../locales' -export interface Web3FeedPageProps { - persona?: string +export interface FeedPageProps { socialAddress?: SocialAddress } -export function Web3FeedPage({ socialAddress, persona }: Web3FeedPageProps) { +export function FeedPage({ socialAddress }: FeedPageProps) { + const t = useI18N() const [selectedFeed, setSelectedFeed] = useState() const { value: feed, loading } = useAsyncRetry(async () => { if (!socialAddress?.address) return @@ -20,7 +21,7 @@ export function Web3FeedPage({ socialAddress, persona }: Web3FeedPageProps) { if (!socialAddress) return null if (loading || !feed?.list?.length) { - return + return } return ( diff --git a/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx b/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx index 4fafdb2009ee..96918e51b2de 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx @@ -5,6 +5,7 @@ import { Box } from '@mui/material' import { useState } from 'react' import { FootprintCard, StatusBox } from '../components' import { useRss3Profile } from '../hooks' +import { useI18N } from '../../locales' export interface FootprintPageProps { footprints?: RSS3BaseAPI.Footprint[] @@ -16,10 +17,12 @@ export function FootprintPage({ footprints = [], address, loading }: FootprintPa const { value: profile } = useRss3Profile(address.address || '') const username = profile?.name + const t = useI18N() + const [selectedFootprint, setSelectedFootprint] = useState() if (loading || !footprints.length) { - return + return } return ( diff --git a/packages/plugins/RSS3/src/locales/en-US.json b/packages/plugins/RSS3/src/locales/en-US.json index 38525dd9adba..a2fb8c35973f 100644 --- a/packages/plugins/RSS3/src/locales/en-US.json +++ b/packages/plugins/RSS3/src/locales/en-US.json @@ -7,5 +7,13 @@ "contribution": "Contribution", "contribution_other": "Contributions", "contributed": "contributed", - "to": "to" + "to": "to", + "feed": "feed", + "donation": "Donation", + "footprint": "Footprint", + "day": "day", + "hour": "hour", + "days": "days", + "hours": "hours", + "ago": "ago" } From 47ba4ce061c8faaeb594adad81545d91d2217095 Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Wed, 27 Jul 2022 16:53:34 +0800 Subject: [PATCH 153/179] feat: use mask color --- .../InjectedComponents/ProfileTabContent.tsx | 42 ++++++++++++++---- .../plugins/NextID/components/NextIdPage.tsx | 11 ++++- .../SNSAdaptor/trending/TrendingViewDeck.tsx | 5 ++- .../CollectionDetailCard/assets/etherscan.png | Bin 4088 -> 0 bytes 4 files changed, 46 insertions(+), 12 deletions(-) delete mode 100644 packages/shared/src/UI/components/CollectionDetailCard/assets/etherscan.png diff --git a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx index e94a647d0c15..467f9e9dfd88 100644 --- a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx +++ b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx @@ -105,6 +105,23 @@ const useStyles = makeStyles()((theme) => ({ display: 'flex', position: 'relative', }, + addressLabel: { + color: theme.palette.maskColor.dark, + fontSize: 18, + fontWeight: 700, + }, + linkoutIcon: { + color: theme.palette.maskColor.secondaryDark, + }, + arrowDropIcon: { + color: theme.palette.maskColor.dark, + }, + verifiedIcon: { + color: theme.palette.maskColor.success, + }, + selectedIcon: { + color: theme.palette.maskColor.primary, + }, })) export interface ProfileTabContentProps extends withClasses<'text' | 'button' | 'root'> {} @@ -242,7 +259,6 @@ export function ProfileTabContent(props: ProfileTabContentProps) { const onOpen = (event: React.MouseEvent) => setAnchorEl(event.currentTarget) const onSelect = (option: SocialAddress) => { setSelectedAddress(option) - // onClose() } const handleOpenDialog = () => { CrossIsolationMessages.events.requestWeb3ProfileDialog.sendToAll({ @@ -277,7 +293,7 @@ export function ProfileTabContent(props: ProfileTabContentProps) { size="small" onClick={onOpen} className={classes.walletButton}> - + {selectedAddress?.type === SocialAddressType.KV || selectedAddress?.type === SocialAddressType.ADDRESS || selectedAddress?.type === SocialAddressType.NEXT_ID ? ( @@ -302,9 +318,9 @@ export function ProfileTabContent(props: ProfileTabContentProps) { } target="_blank" rel="noopener noreferrer"> - + - + {x?.type === SocialAddressType.KV && ( - + )}
{isSameAddress(selectedAddress?.address, x.address) && ( - + )}
@@ -362,10 +378,18 @@ export function ProfileTabContent(props: ProfileTabContentProps) {
- + theme.palette.maskColor.secondaryDark}> {t('powered_by')} - + theme.palette.maskColor.dark}> {t('mask_network')} {isOwnerIdentity ? ( @@ -376,7 +400,7 @@ export function ProfileTabContent(props: ProfileTabContentProps) { href="https://mask.io" target="_blank" rel="noopener noreferrer"> - + )}
diff --git a/packages/mask/src/plugins/NextID/components/NextIdPage.tsx b/packages/mask/src/plugins/NextID/components/NextIdPage.tsx index 85b3ffce1b5d..081adeaaecbe 100644 --- a/packages/mask/src/plugins/NextID/components/NextIdPage.tsx +++ b/packages/mask/src/plugins/NextID/components/NextIdPage.tsx @@ -92,6 +92,10 @@ const useStyles = makeStyles()((theme) => ({ marginRight: 6, marginTop: 2, }, + walletIcon: { + marginRight: 8, + color: theme.palette.maskColor.white, + }, item1: { color: '#767f8d', fontSize: '14px', @@ -120,6 +124,9 @@ const useStyles = makeStyles()((theme) => ({ fontSize: '14px', fontWeight: 400, }, + linkoutIcon: { + color: theme.palette.maskColor.secondaryDark, + }, })) interface NextIdPageProps { @@ -231,7 +238,7 @@ export function NextIdPage({ persona }: NextIdPageProps) { setDescription(t.add_wallet_intro()) return ( ) @@ -273,7 +280,7 @@ export function NextIdPage({ persona }: NextIdPageProps) { width="22px" height="22px" style={{ alignSelf: 'center', marginLeft: '4px' }}> - +
diff --git a/packages/mask/src/plugins/Trader/SNSAdaptor/trending/TrendingViewDeck.tsx b/packages/mask/src/plugins/Trader/SNSAdaptor/trending/TrendingViewDeck.tsx index e10a31cc2f05..b455fd5eb446 100644 --- a/packages/mask/src/plugins/Trader/SNSAdaptor/trending/TrendingViewDeck.tsx +++ b/packages/mask/src/plugins/Trader/SNSAdaptor/trending/TrendingViewDeck.tsx @@ -110,6 +110,9 @@ const useStyles = makeStyles()((theme) => { marginLeft: 'auto', marginBottom: theme.spacing(2), }, + arrowDropIcon: { + color: theme.palette.maskColor.secondaryDark, + }, } }) @@ -248,7 +251,7 @@ export function TrendingViewDeck(props: TrendingViewDeckProps) { sx={{ padding: 0 }} size="small" onClick={() => setCoinMenuOpen((v) => !v)}> - + 8yUV-;UsYfN3kOs#g<)!MuA3bLPKv=U0ut2_n!IVRW;Rn0S!36?|WZ$b=~Fs z?z#7zbI-kxaQvWPFeswYC<8D6;ISl@Keg)Y_deV*s;<6qRCCH6oUt?KYHj*5b1$t~ z5&=>OO+<0aQinVqYj<&xe`~)pdVe(eii;~2&6!x0&gfhpA{dNNG+L%Rm7-8#kEe1l z7?jayR0Dv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-iOE&!y{Y3!=3#MZ4_P*YO_DJ47}Pj~CI zqjv4$;$jPgf1WpQ{&V48S&qEyIOrtWc6U zqV;uk_;kmo*j2d;4Gr~>Qntjw1!^?EeW$p%*vi=U%EgP9JR1syR9RV>(~4sUl?Z_N z@eaPnCk#={T`LiOGN};N%3cD&Rv48&;NTpK9hJQz`(R{Lg zzh4<`DlQs6eB8?~znpsDfd{zlwWW3>h=`e)2M->cVdj|t-V#Dw1fbiK#hjq|YZ7@= zwz|3+yLW$%eN|P6#bO{Lcsw3ABs>O<=9BgLe2UrZEbZNU+Q^Y3n?s?H=;(%Rr;Cx9 z1rZr$J_EpN02cwU0a$IxQ5y~B5R1idpt>4WReMogU5$7w2Ez=?vW`oeZRE85e!ped z?DTs5lWw@-hN_(G9hL7?V_CA2hz>II1OO2LR{+oe1Z5ev5M@Rz9>?KBhfsZ>8h<-* z0CjbBNG6j20L!xA@p|(%?#H)JVfV_Q4g>-gv-!yH3rwFgXHIn_5|KpI>E+UH&265h zJpi5tutaN(rluwxYiyLYwY4~W_z-Gq>(JQPfK)2gl5$Z>K}gwhS><@OnJ1GLM6xIl zfYxT^+2@?I^olF4XliSbJ3_aHC`(olkquyJMMcG?-JgHC2QXA6@;$;gKE_@1bFV=NO7AWulJWCppNJNetIr0~WYwN}U z^m=J&sVpfe5niuXE2VVS;2n93rDwp*teII`mL-aciliWV-RJXC+($x;FvcLAP6Mtr&s|wOj+Z=;dk;!^yFPeJ>KW@k!{<#!#0yOE|j~L z+#x&nN6wWcB4Jq;EXzVFm13pjJ07q9`MGoFzDPt)e*Z@+`*FpHZH>eWFT5~J+v(|! zHj^CN8LBK*B#5B1ad1adJ@t1~3T5oW(#tX7(9l2yics5m5?2jUd`bLT;0aJ}NFQ qSwCymtR1 Date: Thu, 28 Jul 2022 09:03:47 +0800 Subject: [PATCH 154/179] feat: add i18n --- packages/icons/{general => brands}/RSS3.svg | 0 .../InjectedComponents/ProfileTabContent.tsx | 8 +++---- .../plugins/NextID/components/NextIdPage.tsx | 4 ++-- .../src/SNSAdaptor/components/FeedCard.tsx | 22 ++++++++++--------- .../SNSAdaptor/components/ReversedAddress.tsx | 4 ++-- .../src/SNSAdaptor/hooks/useRss3Profile.ts | 2 +- .../src/SNSAdaptor/pages/DonationsPage.tsx | 2 +- .../src/SNSAdaptor/pages/FootprintPage.tsx | 6 ++--- packages/plugins/RSS3/src/locales/en-US.json | 14 +++++++++--- .../Web3Profile/src/locales/en-US.json | 2 +- .../src/UI/components/AssetPlayer/index.tsx | 2 +- .../components/CollectionDetailCard/index.tsx | 14 ++++++------ 12 files changed, 45 insertions(+), 35 deletions(-) rename packages/icons/{general => brands}/RSS3.svg (100%) diff --git a/packages/icons/general/RSS3.svg b/packages/icons/brands/RSS3.svg similarity index 100% rename from packages/icons/general/RSS3.svg rename to packages/icons/brands/RSS3.svg diff --git a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx index 467f9e9dfd88..db07d419171d 100644 --- a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx +++ b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx @@ -13,7 +13,7 @@ import { ReversedAddress } from '@masknet/shared' import { CrossIsolationMessages, EMPTY_LIST, NextIDPlatform } from '@masknet/shared-base' import { makeStyles, MaskTabList, ShadowRootMenu, useStylesExtends, useTabs } from '@masknet/theme' import { Box, Button, CircularProgress, Link, MenuItem, Tab, Typography } from '@mui/material' -import { ArrowDrop, Gear, LinkOut, NextIdPersonaVerified, Selected } from '@masknet/icons' +import { ArrowDrop, Gear, NextIdPersonaVerified, Selected, LinkOut } from '@masknet/icons' import { isSameAddress, NetworkPluginID, SocialAddress, SocialAddressType } from '@masknet/web3-shared-base' import { activatedSocialNetworkUI } from '../../social-network' import { isTwitter } from '../../social-network-adaptor/twitter.com/base' @@ -110,7 +110,7 @@ const useStyles = makeStyles()((theme) => ({ fontSize: 18, fontWeight: 700, }, - linkoutIcon: { + linkOutIcon: { color: theme.palette.maskColor.secondaryDark, }, arrowDropIcon: { @@ -318,7 +318,7 @@ export function ProfileTabContent(props: ProfileTabContentProps) { } target="_blank" rel="noopener noreferrer"> - + @@ -400,7 +400,7 @@ export function ProfileTabContent(props: ProfileTabContentProps) { href="https://mask.io" target="_blank" rel="noopener noreferrer"> - + )}
diff --git a/packages/mask/src/plugins/NextID/components/NextIdPage.tsx b/packages/mask/src/plugins/NextID/components/NextIdPage.tsx index 081adeaaecbe..70227ef2b809 100644 --- a/packages/mask/src/plugins/NextID/components/NextIdPage.tsx +++ b/packages/mask/src/plugins/NextID/components/NextIdPage.tsx @@ -124,7 +124,7 @@ const useStyles = makeStyles()((theme) => ({ fontSize: '14px', fontWeight: 400, }, - linkoutIcon: { + linkOutIcon: { color: theme.palette.maskColor.secondaryDark, }, })) @@ -280,7 +280,7 @@ export function NextIdPage({ persona }: NextIdPageProps) { width="22px" height="22px" style={{ alignSelf: 'center', marginLeft: '4px' }}> - +
diff --git a/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx b/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx index d10e1dfe32cb..e1b74920aeb6 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx @@ -88,17 +88,17 @@ export function FeedCard({ feed, address, onSelect }: FeedCardProps) { if (feed.metadata?.from?.toLowerCase() === address) { return ( - sent a NFT to + {t.sent_a_NFT_to()} ) } if (feed.metadata?.from === ZERO_ADDRESS) { - return 'minted a NFT' + return t.minted_a_NFT() } if (feed.metadata?.to?.toLowerCase() === address) { return ( - acquire a NFT from + {t.acquire_a_NFT_from()} ) } @@ -107,30 +107,30 @@ export function FeedCard({ feed, address, onSelect }: FeedCardProps) { if (feed.metadata?.from?.toLowerCase() === address) { return ( - sent to + {t.sent_to()} ) } if (feed.metadata?.to?.toLowerCase() === address) { return ( - received from + {t.received_from()} ) } } if (feed.tags?.includes('Gitcoin')) { if (feed.metadata?.from?.toLowerCase() === address) { - return 'donated' + return t.donated() } if (feed.metadata?.to?.toLowerCase() === address) { - return 'received donation from' + return t.received_donation_from() } } if (feed.metadata?.from?.toLowerCase() === address) { - return 'received' + return t.receied() } - return 'sent' + return t.sent() }, [address, feed]) const logo = useMemo(() => { @@ -207,7 +207,9 @@ export function FeedCard({ feed, address, onSelect }: FeedCardProps) { }) }>
- {action} {time} + <> + {action} {time} + {feed.title || diff --git a/packages/plugins/RSS3/src/SNSAdaptor/components/ReversedAddress.tsx b/packages/plugins/RSS3/src/SNSAdaptor/components/ReversedAddress.tsx index c292af15c4ad..554d7e80e995 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/components/ReversedAddress.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/components/ReversedAddress.tsx @@ -1,5 +1,5 @@ import { memo } from 'react' -import type { NetworkPluginID } from '@masknet/web3-shared-base' +import { isSameAddress, NetworkPluginID } from '@masknet/web3-shared-base' import { useReverseAddress, useWeb3State } from '@masknet/plugin-infra/web3' import { ZERO_ADDRESS } from '@masknet/web3-shared-evm' @@ -16,7 +16,7 @@ export const ReversedAddress = memo( ({ address = ZERO_ADDRESS, pluginId, domainSize, size = 5, fontSize = '14px', fontWeight = 400 }) => { const { value: domain } = useReverseAddress(pluginId, address) const { Others } = useWeb3State(pluginId) - if (address === ZERO_ADDRESS) return null + if (isSameAddress(address, ZERO_ADDRESS)) return null if (!domain || !Others?.formatDomainName) return {Others?.formatAddress?.(address, size) ?? address} diff --git a/packages/plugins/RSS3/src/SNSAdaptor/hooks/useRss3Profile.ts b/packages/plugins/RSS3/src/SNSAdaptor/hooks/useRss3Profile.ts index a5a18a027142..3aefc7de148e 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/hooks/useRss3Profile.ts +++ b/packages/plugins/RSS3/src/SNSAdaptor/hooks/useRss3Profile.ts @@ -3,7 +3,7 @@ import type { AsyncState } from 'react-use/lib/useAsync' import { PluginProfileRPC } from '../../messages' import type { RSS3Profile } from '../../types' -export function useRss3Profile(address: string): AsyncState { +export function useRSS3Profile(address: string): AsyncState { return useAsync(async () => { if (!address) return null return PluginProfileRPC.getRSS3ProfileByAddress(address) diff --git a/packages/plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx b/packages/plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx index 16557e21b688..aef097681f07 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx @@ -72,7 +72,7 @@ export function DonationPage({ donations = [], loading, address }: DonationPageP onClose={() => setSelectedDonation(undefined)} img={selectedDonation?.detail?.grant?.logo} title={selectedDonation?.detail?.grant?.title} - referenceUrl={selectedDonation?.detail?.grant?.reference_url} + referenceURL={selectedDonation?.detail?.grant?.reference_url} description={selectedDonation?.detail?.grant?.description} contributions={selectedDonation?.detail?.txs} /> diff --git a/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx b/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx index 96918e51b2de..af74222c90a6 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx @@ -4,7 +4,7 @@ import type { NetworkPluginID, SocialAddress } from '@masknet/web3-shared-base' import { Box } from '@mui/material' import { useState } from 'react' import { FootprintCard, StatusBox } from '../components' -import { useRss3Profile } from '../hooks' +import { useRSS3Profile } from '../hooks' import { useI18N } from '../../locales' export interface FootprintPageProps { @@ -14,7 +14,7 @@ export interface FootprintPageProps { } export function FootprintPage({ footprints = [], address, loading }: FootprintPageProps) { - const { value: profile } = useRss3Profile(address.address || '') + const { value: profile } = useRSS3Profile(address.address || '') const username = profile?.name const t = useI18N() @@ -42,7 +42,7 @@ export function FootprintPage({ footprints = [], address, loading }: FootprintPa onClose={() => setSelectedFootprint(undefined)} img={selectedFootprint?.detail?.image_url} title={selectedFootprint?.detail?.name} - referenceUrl={selectedFootprint?.detail?.event_url} + referenceURL={selectedFootprint?.detail?.event_url} description={selectedFootprint?.detail?.description} date={selectedFootprint?.detail?.end_date} location={selectedFootprint?.detail?.city || selectedFootprint?.detail?.country || 'Metaverse'} diff --git a/packages/plugins/RSS3/src/locales/en-US.json b/packages/plugins/RSS3/src/locales/en-US.json index a2fb8c35973f..01015bbb8b80 100644 --- a/packages/plugins/RSS3/src/locales/en-US.json +++ b/packages/plugins/RSS3/src/locales/en-US.json @@ -6,14 +6,22 @@ "total_grants": "Total {{count}} Grants", "contribution": "Contribution", "contribution_other": "Contributions", - "contributed": "contributed", - "to": "to", "feed": "feed", + "contributed_token_to": "contributed {{token}} to", "donation": "Donation", "footprint": "Footprint", "day": "day", "hour": "hour", "days": "days", "hours": "hours", - "ago": "ago" + "ago": "ago", + "sent_a_NFT_to": "sent a NFT to", + "minted_a_NFT": "minted a NFT", + "acquire_a_NFT_from": "acquire a NFT from", + "sent_to": "sent to", + "received_from": "received from", + "donated": "donated", + "received_donation_from": "received donation from", + "receied": "receied", + "sent": "sent" } diff --git a/packages/plugins/Web3Profile/src/locales/en-US.json b/packages/plugins/Web3Profile/src/locales/en-US.json index ed19267b6d46..4b4e50f1a808 100644 --- a/packages/plugins/Web3Profile/src/locales/en-US.json +++ b/packages/plugins/Web3Profile/src/locales/en-US.json @@ -54,5 +54,5 @@ "no_authenticated_wallet": "That hasn't been authenticated yet.", "no_items_found": "No Items found.", "account_empty": "Please verify this persona to set your Web3 profile.", - "load_more": "load more" + "load_more": "Load More" } diff --git a/packages/shared/src/UI/components/AssetPlayer/index.tsx b/packages/shared/src/UI/components/AssetPlayer/index.tsx index f96727b4481f..e338b8f1969a 100644 --- a/packages/shared/src/UI/components/AssetPlayer/index.tsx +++ b/packages/shared/src/UI/components/AssetPlayer/index.tsx @@ -40,7 +40,7 @@ interface AssetPlayerProps setERC721TokenName?: (name: string) => void setSourceType?: (type: string) => void showNetwork?: boolean - networkIcon?: URL + networkIcon?: URL | string } const useStyles = makeStyles()({ hidden: { diff --git a/packages/shared/src/UI/components/CollectionDetailCard/index.tsx b/packages/shared/src/UI/components/CollectionDetailCard/index.tsx index 86a30b336504..bc934103c047 100644 --- a/packages/shared/src/UI/components/CollectionDetailCard/index.tsx +++ b/packages/shared/src/UI/components/CollectionDetailCard/index.tsx @@ -15,7 +15,7 @@ interface CollectionDetailCardProps { img?: string open: boolean title?: string - referenceUrl?: string + referenceURL?: string description?: string contributions?: RSS3BaseAPI.DonationTx[] onClose: () => void @@ -134,7 +134,7 @@ export const CollectionDetailCard = memo( open, onClose, title, - referenceUrl, + referenceURL, metadata, description, contributions = EMPTY_LIST, @@ -188,10 +188,10 @@ export const CollectionDetailCard = memo( {title} -
{icons}
+
{icons}
- - {referenceUrl} + + {referenceURL} {date && ( @@ -251,8 +251,8 @@ export const CollectionDetailCard = memo( {traits?.map((trait) => (
- {trait.type} - {trait.value} + {trait.type} + {trait.value}
))}
From 5c0a5afc55e80010e3074e7679a6a90ffe54f228 Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Thu, 28 Jul 2022 09:46:06 +0800 Subject: [PATCH 155/179] feat: delete useless code --- packages/mask/src/tsconfig.json | 7 ------- .../RSS3/src/SNSAdaptor/components/FeedCard.tsx | 2 +- .../RSS3/src/SNSAdaptor/hooks/useFootprints.ts | 2 +- .../RSS3/src/SNSAdaptor/pages/DonationsPage.tsx | 3 ++- packages/plugins/RSS3/src/locales/en-US.json | 5 +++-- .../src/SNSAdaptor/components/WalletAssets.tsx | 9 +++++---- .../UI/components/CollectionDetailCard/index.tsx | 14 +++++++------- .../shared/src/UI/components/NFTCard/index.tsx | 2 +- 8 files changed, 20 insertions(+), 24 deletions(-) diff --git a/packages/mask/src/tsconfig.json b/packages/mask/src/tsconfig.json index 8e999b505645..b46d44d5a0ba 100644 --- a/packages/mask/src/tsconfig.json +++ b/packages/mask/src/tsconfig.json @@ -30,13 +30,6 @@ { "path": "../../plugins/Wallet" }, { "path": "../../plugins/DAO" }, { "path": "../../plugins/FileService" }, - { "path": "../../plugins/RSS3" }, - { "path": "../../plugins/Web3Profile" }, - { "path": "../../plugins/example" }, - { "path": "../../plugins/Debugger" }, - { "path": "../../plugins/CyberConnect" }, - { "path": "../../plugins/CrossChainBridge" }, - { "path": "../../plugins/GoPlusSecurity" }, { "path": "../../plugins/EVM" }, { "path": "../../plugins/Flow" }, { "path": "../../plugins/Solana" }, diff --git a/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx b/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx index e1b74920aeb6..7b41c2eb428e 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx @@ -98,7 +98,7 @@ export function FeedCard({ feed, address, onSelect }: FeedCardProps) { if (feed.metadata?.to?.toLowerCase() === address) { return ( - {t.acquire_a_NFT_from()} + {t.acquired_a_NFT_from()} ) } diff --git a/packages/plugins/RSS3/src/SNSAdaptor/hooks/useFootprints.ts b/packages/plugins/RSS3/src/SNSAdaptor/hooks/useFootprints.ts index ed0776223d0c..65ad72df3b6d 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/hooks/useFootprints.ts +++ b/packages/plugins/RSS3/src/SNSAdaptor/hooks/useFootprints.ts @@ -5,6 +5,6 @@ import type { AsyncState } from 'react-use/lib/useAsync' export function useFootprints(address: string): AsyncState { return useAsync(async () => { const response = await RSS3.getFootprints(address) - return response ?? [] + return response }, [address]) } diff --git a/packages/plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx b/packages/plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx index aef097681f07..08add4b6eeec 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx @@ -1,4 +1,5 @@ import { CollectionDetailCard } from '@masknet/shared' +import { EMPTY_LIST } from '@masknet/shared-base' import { makeStyles } from '@masknet/theme' import type { RSS3BaseAPI } from '@masknet/web3-providers' import type { NetworkPluginID, SocialAddress } from '@masknet/web3-shared-base' @@ -44,7 +45,7 @@ export interface DonationPageProps { address: SocialAddress } -export function DonationPage({ donations = [], loading, address }: DonationPageProps) { +export function DonationPage({ donations = EMPTY_LIST, loading, address }: DonationPageProps) { const { classes } = useStyles() const t = useI18N() diff --git a/packages/plugins/RSS3/src/locales/en-US.json b/packages/plugins/RSS3/src/locales/en-US.json index 01015bbb8b80..2dedb2cddae9 100644 --- a/packages/plugins/RSS3/src/locales/en-US.json +++ b/packages/plugins/RSS3/src/locales/en-US.json @@ -6,8 +6,9 @@ "total_grants": "Total {{count}} Grants", "contribution": "Contribution", "contribution_other": "Contributions", + "contributed": "contributed", + "to": "to", "feed": "feed", - "contributed_token_to": "contributed {{token}} to", "donation": "Donation", "footprint": "Footprint", "day": "day", @@ -17,7 +18,7 @@ "ago": "ago", "sent_a_NFT_to": "sent a NFT to", "minted_a_NFT": "minted a NFT", - "acquire_a_NFT_from": "acquire a NFT from", + "acquired_a_NFT_from": "acquired a NFT from", "sent_to": "sent to", "received_from": "received from", "donated": "donated", diff --git a/packages/plugins/Web3Profile/src/SNSAdaptor/components/WalletAssets.tsx b/packages/plugins/Web3Profile/src/SNSAdaptor/components/WalletAssets.tsx index 69ada0761ba7..4358e636752d 100644 --- a/packages/plugins/Web3Profile/src/SNSAdaptor/components/WalletAssets.tsx +++ b/packages/plugins/Web3Profile/src/SNSAdaptor/components/WalletAssets.tsx @@ -10,6 +10,7 @@ import { NetworkPluginID } from '@masknet/web3-shared-base' import { Empty } from './Empty' import { CollectionList } from './CollectionList' import { useMemo, useState } from 'react' +import { EMPTY_LIST } from '@masknet/shared-base' const useStyles = makeStyles()((theme) => { return { @@ -111,9 +112,9 @@ export interface WalletAssetsCardProps extends withClasses { } const enum LOAD_STATUS { - 'Unnecessary' = 1, - 'Necessary' = 2, - 'Finish' = 3, + Unnecessary = 1, + Necessary = 2, + Finish = 3, } export function WalletAssetsCard(props: WalletAssetsCardProps) { @@ -135,7 +136,7 @@ export function WalletAssetsCard(props: WalletAssetsCardProps) { const collections = useMemo(() => { const filterCollections = collectionList?.filter((collection) => !collection?.hidden) if (!filterCollections || filterCollections?.length === 0) { - return [] + return EMPTY_LIST } if (filterCollections?.length > 8 && loadStatus !== LOAD_STATUS.Finish) { return filterCollections?.slice(0, 8) diff --git a/packages/shared/src/UI/components/CollectionDetailCard/index.tsx b/packages/shared/src/UI/components/CollectionDetailCard/index.tsx index bc934103c047..1719937cba6e 100644 --- a/packages/shared/src/UI/components/CollectionDetailCard/index.tsx +++ b/packages/shared/src/UI/components/CollectionDetailCard/index.tsx @@ -6,7 +6,7 @@ import { Box, Card, DialogContent, Link, Typography } from '@mui/material' import type { RSS3BaseAPI } from '@masknet/web3-providers' import differenceInCalendarDays from 'date-fns/differenceInDays' import differenceInCalendarHours from 'date-fns/differenceInHours' -import { Gitcoin, LinkOut, OpenSeaColoredIcon, PolygonScan, EtherScan } from '@masknet/icons' +import { Icons } from '@masknet/icons' import { ChainId, explorerResolver } from '@masknet/web3-shared-evm' import { NFTCardStyledAssetPlayer } from '@masknet/shared' import { EMPTY_LIST } from '@masknet/shared-base' @@ -149,15 +149,15 @@ export const CollectionDetailCard = memo( const icons = relatedURLs.map((url) => { let icon: ReactNode = null if (url.includes('etherscan.io')) { - icon = + icon = } else if (url.includes('polygonscan.com/tx')) { - icon = + icon = } else if (url.includes('polygonscan.com/token')) { - icon = + icon = } else if (url.includes('opensea.io')) { - icon = + icon = } else if (url.includes('gitcoin.co')) { - icon = + icon = } return icon ? ( @@ -237,7 +237,7 @@ export const CollectionDetailCard = memo( className={classes.linkBox} target="_blank" href={explorerResolver.transactionLink(ChainId.Mainnet, contribution.txHash)}> - +
diff --git a/packages/shared/src/UI/components/NFTCard/index.tsx b/packages/shared/src/UI/components/NFTCard/index.tsx index 401eb3d7f8fe..b2c96c6b43e9 100644 --- a/packages/shared/src/UI/components/NFTCard/index.tsx +++ b/packages/shared/src/UI/components/NFTCard/index.tsx @@ -133,7 +133,7 @@ export function NFTImageCollectibleAvatar({ ) : ( - + ) From 5befb596d531c937816c8dc2b9a2c6c5d58102d7 Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Thu, 28 Jul 2022 10:07:29 +0800 Subject: [PATCH 156/179] fix: code style --- packages/icons/general/Selected.tsx | 27 ------------------- .../src/SNSAdaptor/components/FeedCard.tsx | 2 +- .../src/SNSAdaptor/pages/DonationsPage.tsx | 3 ++- .../RSS3/src/SNSAdaptor/pages/FeedPage.tsx | 3 ++- .../src/SNSAdaptor/pages/FootprintPage.tsx | 6 +++-- packages/plugins/RSS3/src/constants.ts | 6 +++++ packages/plugins/RSS3/src/locales/en-US.json | 5 +--- 7 files changed, 16 insertions(+), 36 deletions(-) delete mode 100644 packages/icons/general/Selected.tsx diff --git a/packages/icons/general/Selected.tsx b/packages/icons/general/Selected.tsx deleted file mode 100644 index 1c23a739b844..000000000000 --- a/packages/icons/general/Selected.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import { createPaletteAwareIcon } from '../utils' - -export const SelectedIcon = createPaletteAwareIcon( - 'SelectedIcon', - - - - - , - - - - - , - undefined, - '0 0 16 16', -) diff --git a/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx b/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx index 7b41c2eb428e..154464d32785 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx @@ -128,7 +128,7 @@ export function FeedCard({ feed, address, onSelect }: FeedCardProps) { } } if (feed.metadata?.from?.toLowerCase() === address) { - return t.receied() + return t.received() } return t.sent() }, [address, feed]) diff --git a/packages/plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx b/packages/plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx index 08add4b6eeec..785675e1c5a1 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx @@ -5,6 +5,7 @@ import type { RSS3BaseAPI } from '@masknet/web3-providers' import type { NetworkPluginID, SocialAddress } from '@masknet/web3-shared-base' import { Box, List, ListItem } from '@mui/material' import { useState } from 'react' +import { CollectionType } from '../../constants' import { useI18N } from '../../locales' import { DonationCard, StatusBox } from '../components' @@ -52,7 +53,7 @@ export function DonationPage({ donations = EMPTY_LIST, loading, address }: Donat const [selectedDonation, setSelectedDonation] = useState() if (loading || !donations.length) { - return + return } return ( diff --git a/packages/plugins/RSS3/src/SNSAdaptor/pages/FeedPage.tsx b/packages/plugins/RSS3/src/SNSAdaptor/pages/FeedPage.tsx index 582c5a9bc132..91334986f260 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/pages/FeedPage.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/pages/FeedPage.tsx @@ -6,6 +6,7 @@ import { useAsyncRetry } from 'react-use' import { FeedCard } from '../components/FeedCard' import { StatusBox } from '../components/StatusBox' import { useI18N } from '../../locales' +import { CollectionType } from '../../constants' export interface FeedPageProps { socialAddress?: SocialAddress @@ -21,7 +22,7 @@ export function FeedPage({ socialAddress }: FeedPageProps) { if (!socialAddress) return null if (loading || !feed?.list?.length) { - return + return } return ( diff --git a/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx b/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx index af74222c90a6..24a258844e41 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx @@ -6,6 +6,8 @@ import { useState } from 'react' import { FootprintCard, StatusBox } from '../components' import { useRSS3Profile } from '../hooks' import { useI18N } from '../../locales' +import { EMPTY_LIST } from '@masknet/shared-base' +import { CollectionType } from '../../constants' export interface FootprintPageProps { footprints?: RSS3BaseAPI.Footprint[] @@ -13,7 +15,7 @@ export interface FootprintPageProps { address: SocialAddress } -export function FootprintPage({ footprints = [], address, loading }: FootprintPageProps) { +export function FootprintPage({ footprints = EMPTY_LIST, address, loading }: FootprintPageProps) { const { value: profile } = useRSS3Profile(address.address || '') const username = profile?.name @@ -22,7 +24,7 @@ export function FootprintPage({ footprints = [], address, loading }: FootprintPa const [selectedFootprint, setSelectedFootprint] = useState() if (loading || !footprints.length) { - return + return } return ( diff --git a/packages/plugins/RSS3/src/constants.ts b/packages/plugins/RSS3/src/constants.ts index d393e73c3ca7..740971f2929c 100644 --- a/packages/plugins/RSS3/src/constants.ts +++ b/packages/plugins/RSS3/src/constants.ts @@ -8,3 +8,9 @@ export const PLUGIN_NAME = 'RSS3' /* cspell:disable-next-line */ export const RSS3_DEFAULT_IMAGE = resolveIPFSLink('QmVFq9qimnudPcs6QkQv8ZVEsvwD3aqETHWtS5yXgdbYY5') + +export enum CollectionType { + donation = 'Donation', + footprint = 'Footprint', + feed = 'Feed', +} diff --git a/packages/plugins/RSS3/src/locales/en-US.json b/packages/plugins/RSS3/src/locales/en-US.json index 2dedb2cddae9..703d61e9b6e4 100644 --- a/packages/plugins/RSS3/src/locales/en-US.json +++ b/packages/plugins/RSS3/src/locales/en-US.json @@ -8,9 +8,6 @@ "contribution_other": "Contributions", "contributed": "contributed", "to": "to", - "feed": "feed", - "donation": "Donation", - "footprint": "Footprint", "day": "day", "hour": "hour", "days": "days", @@ -23,6 +20,6 @@ "received_from": "received from", "donated": "donated", "received_donation_from": "received donation from", - "receied": "receied", + "received": "received", "sent": "sent" } From 099468b62570e72d3331b5c9cfb7064ec3a69aa9 Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Thu, 28 Jul 2022 10:09:43 +0800 Subject: [PATCH 157/179] feat: change icon name --- packages/mask/src/plugins/Pets/SNSAdaptor/PetSetDialog.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/mask/src/plugins/Pets/SNSAdaptor/PetSetDialog.tsx b/packages/mask/src/plugins/Pets/SNSAdaptor/PetSetDialog.tsx index 87f3d8761487..e07714c57277 100644 --- a/packages/mask/src/plugins/Pets/SNSAdaptor/PetSetDialog.tsx +++ b/packages/mask/src/plugins/Pets/SNSAdaptor/PetSetDialog.tsx @@ -29,7 +29,7 @@ import { petShowSettings } from '../settings' import { ChainBoundary } from '../../../web3/UI/ChainBoundary' import { useWeb3Connection } from '@masknet/plugin-infra/web3' import { saveCustomEssayToRSS } from '../Services/rss3' -import { Rss3 } from '@masknet/icons' +import { Icons } from '@masknet/icons' import ActionButton from '../../../extension/options-page/DashboardComponents/ActionButton' const useStyles = makeStyles()((theme) => ({ @@ -376,7 +376,7 @@ export function PetSetDialog({ configNFTs, onClose }: PetSetDialogProps) { RSS3 - +
From e42902cc07729eb5ca4b7a93a9dbbbe8f875fe68 Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Thu, 28 Jul 2022 10:30:40 +0800 Subject: [PATCH 158/179] feat: change icon color --- packages/mask/shared-ui/locales/en-US.json | 2 +- .../DashboardComponents/CollectibleList/index.tsx | 2 +- .../popups/pages/Personas/components/PersonaHeader/UI.tsx | 4 ++-- .../popups/pages/Wallet/components/WalletHeader/UI.tsx | 3 +-- .../mask/src/plugins/NextID/components/NextIdPage.tsx | 8 ++++---- .../Trader/SNSAdaptor/trending/TrendingViewDeck.tsx | 3 --- .../plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx | 2 +- packages/plugins/RSS3/src/SNSAdaptor/pages/FeedPage.tsx | 2 +- .../plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx | 2 +- packages/plugins/RSS3/src/constants.ts | 6 +++--- packages/plugins/RSS3/src/locales/en-US.json | 2 +- 11 files changed, 16 insertions(+), 20 deletions(-) diff --git a/packages/mask/shared-ui/locales/en-US.json b/packages/mask/shared-ui/locales/en-US.json index c39cf567ddb8..25aefed6d16d 100644 --- a/packages/mask/shared-ui/locales/en-US.json +++ b/packages/mask/shared-ui/locales/en-US.json @@ -115,7 +115,7 @@ "copied": "Copied", "daily": "Daily", "dashboard_no_collectible_found": "No collectible found.", - "no_nft_at_current_address": "No NFT at the current address", + "no_NFTs_found": "No NFTs found.", "dashboard_collectible_menu_all": "All ({{count}})", "days": "Every {{days}} days", "decrypted_postbox_add_recipients": "Append recipients", diff --git a/packages/mask/src/extension/options-page/DashboardComponents/CollectibleList/index.tsx b/packages/mask/src/extension/options-page/DashboardComponents/CollectibleList/index.tsx index 8ae81d75b63b..bdee51d876af 100644 --- a/packages/mask/src/extension/options-page/DashboardComponents/CollectibleList/index.tsx +++ b/packages/mask/src/extension/options-page/DashboardComponents/CollectibleList/index.tsx @@ -290,7 +290,7 @@ export function CollectionList({ return ( - {t('no_nft_at_current_address')} + {t('no_NFTs_found')} ) diff --git a/packages/mask/src/extension/popups/pages/Personas/components/PersonaHeader/UI.tsx b/packages/mask/src/extension/popups/pages/Personas/components/PersonaHeader/UI.tsx index 1deb4238e5e5..50a162b61a8e 100644 --- a/packages/mask/src/extension/popups/pages/Personas/components/PersonaHeader/UI.tsx +++ b/packages/mask/src/extension/popups/pages/Personas/components/PersonaHeader/UI.tsx @@ -7,7 +7,7 @@ import { CopyIconButton } from '../../../../components/CopyIconButton' import { Icons } from '@masknet/icons' import { formatPersonaFingerprint, formatPersonaName } from '@masknet/shared-base' -const useStyles = makeStyles()(() => ({ +const useStyles = makeStyles()((theme) => ({ container: { background: 'linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.8) 100%), linear-gradient(90deg, rgba(98, 126, 234, 0.2) 0%, rgba(59, 153, 252, 0.2) 100%)', @@ -57,6 +57,7 @@ const useStyles = makeStyles()(() => ({ arrow: { fontSize: 20, transition: 'all 300ms', + color: theme.palette.maskColor.secondaryDark, }, })) @@ -89,7 +90,6 @@ export const PersonaHeaderUI = memo(
diff --git a/packages/mask/src/extension/popups/pages/Wallet/components/WalletHeader/UI.tsx b/packages/mask/src/extension/popups/pages/Wallet/components/WalletHeader/UI.tsx index 188f04261735..98ded1c11a1b 100644 --- a/packages/mask/src/extension/popups/pages/Wallet/components/WalletHeader/UI.tsx +++ b/packages/mask/src/extension/popups/pages/Wallet/components/WalletHeader/UI.tsx @@ -61,6 +61,7 @@ const useStyles = makeStyles()((theme) => ({ arrow: { fontSize: 20, transition: 'all 300ms', + color: theme.palette.maskColor.secondaryDark, }, colorChainICon: { borderRadius: '999px!important', @@ -146,7 +147,6 @@ export const WalletHeaderUI = memo( {!disabled ? ( ) : null} @@ -187,7 +187,6 @@ export const WalletHeaderUI = memo( {!disabled ? ( ) : null} diff --git a/packages/mask/src/plugins/NextID/components/NextIdPage.tsx b/packages/mask/src/plugins/NextID/components/NextIdPage.tsx index 4fb86445fd97..27a40e6d1c4f 100644 --- a/packages/mask/src/plugins/NextID/components/NextIdPage.tsx +++ b/packages/mask/src/plugins/NextID/components/NextIdPage.tsx @@ -98,24 +98,24 @@ const useStyles = makeStyles()((theme) => ({ color: theme.palette.maskColor.white, }, item1: { - color: '#767f8d', + color: theme.palette.maskColor.secondaryDark, fontSize: '14px', fontWeight: 400, }, item2: { - color: '#07101B', + color: theme.palette.maskColor.dark, fontSize: '14px', fontWeight: 500, marginLeft: '2px', }, button: { borderRadius: '99px', - backgroundColor: '#07101b', + backgroundColor: theme.palette.maskColor.dark, color: '#fff', marginTop: 'auto', ':hover': { color: 'fff', - backgroundColor: '#07101b', + backgroundColor: theme.palette.maskColor.dark, }, }, content: { diff --git a/packages/mask/src/plugins/Trader/SNSAdaptor/trending/TrendingViewDeck.tsx b/packages/mask/src/plugins/Trader/SNSAdaptor/trending/TrendingViewDeck.tsx index 3eeec1502525..e7fbb4c39e84 100644 --- a/packages/mask/src/plugins/Trader/SNSAdaptor/trending/TrendingViewDeck.tsx +++ b/packages/mask/src/plugins/Trader/SNSAdaptor/trending/TrendingViewDeck.tsx @@ -110,9 +110,6 @@ const useStyles = makeStyles()((theme) => { marginLeft: 'auto', marginBottom: theme.spacing(2), }, - arrowDropIcon: { - color: theme.palette.maskColor.secondaryDark, - }, } }) diff --git a/packages/plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx b/packages/plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx index 785675e1c5a1..dd01759a0179 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx @@ -53,7 +53,7 @@ export function DonationPage({ donations = EMPTY_LIST, loading, address }: Donat const [selectedDonation, setSelectedDonation] = useState() if (loading || !donations.length) { - return + return } return ( diff --git a/packages/plugins/RSS3/src/SNSAdaptor/pages/FeedPage.tsx b/packages/plugins/RSS3/src/SNSAdaptor/pages/FeedPage.tsx index 91334986f260..6a4ac780f28f 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/pages/FeedPage.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/pages/FeedPage.tsx @@ -22,7 +22,7 @@ export function FeedPage({ socialAddress }: FeedPageProps) { if (!socialAddress) return null if (loading || !feed?.list?.length) { - return + return } return ( diff --git a/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx b/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx index 24a258844e41..fc72480c64b1 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx @@ -24,7 +24,7 @@ export function FootprintPage({ footprints = EMPTY_LIST, address, loading }: Foo const [selectedFootprint, setSelectedFootprint] = useState() if (loading || !footprints.length) { - return + return } return ( diff --git a/packages/plugins/RSS3/src/constants.ts b/packages/plugins/RSS3/src/constants.ts index 740971f2929c..015589d74584 100644 --- a/packages/plugins/RSS3/src/constants.ts +++ b/packages/plugins/RSS3/src/constants.ts @@ -10,7 +10,7 @@ export const PLUGIN_NAME = 'RSS3' export const RSS3_DEFAULT_IMAGE = resolveIPFSLink('QmVFq9qimnudPcs6QkQv8ZVEsvwD3aqETHWtS5yXgdbYY5') export enum CollectionType { - donation = 'Donation', - footprint = 'Footprint', - feed = 'Feed', + donations = 'Donations', + footprints = 'Footprints', + feeds = 'Feeds', } diff --git a/packages/plugins/RSS3/src/locales/en-US.json b/packages/plugins/RSS3/src/locales/en-US.json index 703d61e9b6e4..86820193d6a3 100644 --- a/packages/plugins/RSS3/src/locales/en-US.json +++ b/packages/plugins/RSS3/src/locales/en-US.json @@ -2,7 +2,7 @@ "inactive_project": "Inactive Project", "no_activity_time": "No activity time", "attended": "attended", - "no_data": "No {{collection}} at the current address", + "no_data": "No {{collection}} found.", "total_grants": "Total {{count}} Grants", "contribution": "Contribution", "contribution_other": "Contributions", From ec7b6bd0de65ee5f1ce213750855cb7e406cad07 Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Thu, 28 Jul 2022 17:09:25 +0800 Subject: [PATCH 159/179] fix: build error --- .i18n-codegen.json | 11 ----------- .../RSS3/src/SNSAdaptor/hooks/useCollectionFilter.ts | 4 +--- packages/web3-providers/src/rss3/constants.ts | 2 +- packages/web3-providers/src/rss3/index.ts | 4 ++-- packages/web3-providers/src/types/RSS3.ts | 1 + 5 files changed, 5 insertions(+), 17 deletions(-) diff --git a/.i18n-codegen.json b/.i18n-codegen.json index e3882327b8bb..d97c47ff540f 100644 --- a/.i18n-codegen.json +++ b/.i18n-codegen.json @@ -359,17 +359,6 @@ "trans": "Translate", "sourceMap": "inline" } - }, - { - "input": "./packages/mask/src/plugins/Web3Feed/locales/en-US.json", - "output": "./packages/mask/src/plugins/Web3Feed/locales/i18n_generated", - "parser": { "type": "i18next", "contextSeparator": "$", "pluralSeparator": "_" }, - "generator": { - "type": "i18next/react-hooks", - "hooks": "useI18N", - "namespace": "com.maskbook.web3-feed", - "trans": "Translate" - } } ] } diff --git a/packages/plugins/RSS3/src/SNSAdaptor/hooks/useCollectionFilter.ts b/packages/plugins/RSS3/src/SNSAdaptor/hooks/useCollectionFilter.ts index 6b33f2396e6f..3d8171ac9492 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/hooks/useCollectionFilter.ts +++ b/packages/plugins/RSS3/src/SNSAdaptor/hooks/useCollectionFilter.ts @@ -22,8 +22,6 @@ export const useCollectionFilter = ( ) const hiddenList = proof?.content?.[PluginId.Web3Profile]?.unListedCollections?.[address?.address?.toLowerCase()]?.[type] ?? [] - return collections?.filter( - (collection: { id: string }) => hiddenList?.findIndex((url) => url === collection?.id) === -1, - ) + return collections?.filter((collection) => hiddenList?.findIndex((url) => url === collection?.id) === -1) }, [address, currentVisitingProfile?.identifier?.userId, type, hiddenInfo?.length, collections?.length]) } diff --git a/packages/web3-providers/src/rss3/constants.ts b/packages/web3-providers/src/rss3/constants.ts index e137feefb87e..01bb11dd5836 100644 --- a/packages/web3-providers/src/rss3/constants.ts +++ b/packages/web3-providers/src/rss3/constants.ts @@ -5,7 +5,7 @@ export const NEW_RSS3_ENDPOINT = 'https://pregod.rss3.dev/v1.1.0/notes/' export const RSS3_FEED_ENDPOINT = 'https://pregod.rss3.dev/v0.4.0/' -export const NETWORK_PLUGINID = { +export const NETWORK_PLUGIN = { [NetworkPluginID.PLUGIN_EVM]: 'ethereum', [NetworkPluginID.PLUGIN_FLOW]: 'flow', [NetworkPluginID.PLUGIN_SOLANA]: 'solana', diff --git a/packages/web3-providers/src/rss3/index.ts b/packages/web3-providers/src/rss3/index.ts index ef3f4e5e6594..e66d2c2c8a80 100644 --- a/packages/web3-providers/src/rss3/index.ts +++ b/packages/web3-providers/src/rss3/index.ts @@ -1,7 +1,7 @@ import urlcat from 'urlcat' import RSS3 from 'rss3-next' import { ChainId, SchemaType } from '@masknet/web3-shared-evm' -import { NETWORK_PLUGINID, NEW_RSS3_ENDPOINT, RSS3_ENDPOINT, RSS3_FEED_ENDPOINT, TAG, TYPE } from './constants' +import { NETWORK_PLUGIN, NEW_RSS3_ENDPOINT, RSS3_ENDPOINT, RSS3_FEED_ENDPOINT, TAG, TYPE } from './constants' import { NonFungibleTokenAPI, RSS3BaseAPI } from '../types' import { fetchJSON } from '../helpers' import { @@ -120,7 +120,7 @@ export class RSS3API implements RSS3BaseAPI.Provider, NonFungibleTokenAPI.Provid type?: RSS3BaseAPI.FeedType, ) { if (!address) return - const url = `${RSS3_FEED_ENDPOINT}account:${address}@${NETWORK_PLUGINID[networkPluginId]}/notes?limit=100&exclude_tags=POAP&tags=Gitcoin&tags=POAP&tags=NFT&tags=Donation&latest=false` + const url = `${RSS3_FEED_ENDPOINT}account:${address}@${NETWORK_PLUGIN[networkPluginId]}/notes?limit=100&exclude_tags=POAP&tags=Gitcoin&tags=POAP&tags=NFT&tags=Donation&latest=false` const res = fetchJSON(url) return res } diff --git a/packages/web3-providers/src/types/RSS3.ts b/packages/web3-providers/src/types/RSS3.ts index a4a90ba47bdd..3703576f5664 100644 --- a/packages/web3-providers/src/types/RSS3.ts +++ b/packages/web3-providers/src/types/RSS3.ts @@ -61,6 +61,7 @@ export namespace RSS3BaseAPI { trait_type: string }> standard?: string + name?: string } export interface Action { From b7fc0e042d62162a8712b99588f44335220911fe Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Thu, 28 Jul 2022 18:00:54 +0800 Subject: [PATCH 160/179] feat: change style --- .../components/CollectionDetailCard/index.tsx | 20 +++++++++++++------ packages/web3-providers/src/rss3/index.ts | 1 - 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/packages/shared/src/UI/components/CollectionDetailCard/index.tsx b/packages/shared/src/UI/components/CollectionDetailCard/index.tsx index b6413cb0ce53..cad1cbe43e71 100644 --- a/packages/shared/src/UI/components/CollectionDetailCard/index.tsx +++ b/packages/shared/src/UI/components/CollectionDetailCard/index.tsx @@ -124,6 +124,12 @@ const useStyles = makeStyles()((theme) => ({ fontWeight: 400, color: theme.palette.maskColor.second, }, + singleRow: { + maxWidth: 400, + overflow: 'hidden', + whiteSpace: 'nowrap', + textOverflow: 'ellipsis', + }, })) const ChainID = { @@ -181,7 +187,7 @@ export const CollectionDetailCard = memo( }) const days = differenceInCalendarDays(Date.now(), new Date(time ?? 0)) - const hours = differenceInCalendarHours(Date.now(), new Date(time ?? 0)) + const hours = differenceInCalendarHours(Date.now(), new Date(time ?? 0)) % 24 return ( @@ -205,11 +211,13 @@ export const CollectionDetailCard = memo( {title} -
{icons}
+ {icons.length > 0 &&
{icons}
} - - {referenceURL} - + + + {referenceURL} + + {date && ( {date} @@ -245,7 +253,7 @@ export const CollectionDetailCard = memo(
{days > 0 ? `${days} ${t.day({ count: days })} ` : ''} - {hours > 0 ? `${hours} ${t.day({ count: hours })} ` : ''} + {hours > 0 ? `${hours} ${t.hour({ count: hours })} ` : ''} {t.ago()} { const createCollection = (collectionResponse: RSS3BaseAPI.CollectionResponse[]): RSS3BaseAPI.Collection[] => { return collectionResponse.map((collection: RSS3BaseAPI.CollectionResponse) => { const firstAction = first(collection.actions) - console.log({ collection }) return { ...collection, title: firstAction?.metadata?.title || firstAction?.metadata?.name, From 6120d60248fea639ce5ed6b013fb8757d56cb141 Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Thu, 28 Jul 2022 21:14:22 +0800 Subject: [PATCH 161/179] fix: code style --- .../SNSAdaptor/components/DonationCard.tsx | 13 +++-- .../src/SNSAdaptor/components/FeedCard.tsx | 49 +++++++++++++------ .../SNSAdaptor/components/FootprintCard.tsx | 2 +- .../src/SNSAdaptor/pages/DonationsPage.tsx | 2 +- .../components/CollectionDetailCard/index.tsx | 32 ++++++------ packages/web3-providers/src/rss3/index.ts | 10 ++-- packages/web3-providers/src/types/RSS3.ts | 3 +- 7 files changed, 66 insertions(+), 45 deletions(-) diff --git a/packages/plugins/RSS3/src/SNSAdaptor/components/DonationCard.tsx b/packages/plugins/RSS3/src/SNSAdaptor/components/DonationCard.tsx index eff76ceeb3d4..6f384b508357 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/components/DonationCard.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/components/DonationCard.tsx @@ -58,6 +58,9 @@ const useStyles = makeStyles()((theme) => ({ fontColor: { color: theme.palette.maskColor.primary, }, + tokenInfoColor: { + color: theme.palette.maskColor.main, + }, })) export const DonationCard = ({ donation, address, onSelect, className, ...rest }: DonationCardProps) => { @@ -87,10 +90,12 @@ export const DonationCard = ({ donation, address, onSelect, className, ...rest }
- {reversedAddress} {t.contributed()}{' '} - {donation.tokenAmount} - {donation.tokenSymbol ?? 'ETH'} {t.to()}{' '} - {donation.title} + {reversedAddress}{' '} + {t.contributed()}{' '} + {donation.tokenAmount?.toString()} + {donation.tokenSymbol ?? 'ETH'}{' '} + {t.to()}{' '} + {donation.title}
diff --git a/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx b/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx index 154464d32785..6b857c67e142 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx @@ -1,7 +1,7 @@ import { NFTCardStyledAssetPlayer, TokenIcon } from '@masknet/shared' import { makeStyles } from '@masknet/theme' import { Alchemy_EVM, RSS3BaseAPI } from '@masknet/web3-providers' -import { NetworkPluginID } from '@masknet/web3-shared-base' +import { isSameAddress, NetworkPluginID } from '@masknet/web3-shared-base' import { ChainId, resolveIPFSLinkFromURL, ZERO_ADDRESS } from '@masknet/web3-shared-evm' import { Box, Typography, Card } from '@mui/material' import differenceInCalendarDays from 'date-fns/differenceInDays' @@ -34,6 +34,7 @@ const useStyles = makeStyles()((theme) => ({ color: theme.palette.maskColor.third, marginLeft: 10, }, + summary: { textOverflow: 'ellipsis', '-webkit-line-clamp': '1', @@ -41,6 +42,7 @@ const useStyles = makeStyles()((theme) => ({ overflow: 'hidden', display: '-webkit-box', '-webkit-box-orient': 'vertical', + color: theme.palette.maskColor.main, }, defaultImage: { background: theme.palette.maskColor.modalTitleBg, @@ -55,6 +57,9 @@ const useStyles = makeStyles()((theme) => ({ width: 64, height: 64, }, + action: { + color: theme.palette.maskColor.main, + }, })) export const ChainID = { @@ -63,6 +68,15 @@ export const ChainID = { bnb: ChainId.BSC, } +enum TAG { + NFT = 'NFT', + Token = 'Token', + POAP = 'POAP', + Gitcoin = 'Gitcoin', + Mirror = 'Mirror Entry', + ETH = 'ETH', +} + export interface FeedCardProps { feed: RSS3BaseAPI.Web3Feed address?: string @@ -84,18 +98,18 @@ export function FeedCard({ feed, address, onSelect }: FeedCardProps) { const action = useMemo(() => { if (!feed) return - if (feed.tags?.includes('NFT')) { - if (feed.metadata?.from?.toLowerCase() === address) { + if (feed.tags?.includes(TAG.NFT)) { + if (isSameAddress(feed.metadata?.from?.toLowerCase(), address)) { return ( {t.sent_a_NFT_to()} ) } - if (feed.metadata?.from === ZERO_ADDRESS) { + if (isSameAddress(feed.metadata?.from, ZERO_ADDRESS)) { return t.minted_a_NFT() } - if (feed.metadata?.to?.toLowerCase() === address) { + if (isSameAddress(feed.metadata?.to?.toLowerCase(), address)) { return ( {t.acquired_a_NFT_from()} @@ -103,15 +117,15 @@ export function FeedCard({ feed, address, onSelect }: FeedCardProps) { ) } } - if (feed.tags?.includes('Token') || feed.tags?.includes('ETH')) { - if (feed.metadata?.from?.toLowerCase() === address) { + if (feed.tags?.includes(TAG.Token) || feed.tags?.includes(TAG.ETH)) { + if (isSameAddress(feed.metadata?.from?.toLowerCase(), address)) { return ( {t.sent_to()} ) } - if (feed.metadata?.to?.toLowerCase() === address) { + if (isSameAddress(feed.metadata?.to?.toLowerCase(), address)) { return ( {t.received_from()} @@ -119,22 +133,22 @@ export function FeedCard({ feed, address, onSelect }: FeedCardProps) { ) } } - if (feed.tags?.includes('Gitcoin')) { - if (feed.metadata?.from?.toLowerCase() === address) { + if (feed.tags?.includes(TAG.Gitcoin)) { + if (isSameAddress(feed.metadata?.from?.toLowerCase(), address)) { return t.donated() } - if (feed.metadata?.to?.toLowerCase() === address) { + if (isSameAddress(feed.metadata?.to?.toLowerCase(), address)) { return t.received_donation_from() } } - if (feed.metadata?.from?.toLowerCase() === address) { + if (isSameAddress(feed.metadata?.from?.toLowerCase(), address)) { return t.received() } return t.sent() }, [address, feed]) const logo = useMemo(() => { - if (feed.tags?.includes('NFT')) { + if (feed.tags?.includes(TAG.NFT)) { return ( ) } - if (feed.tags.includes('Token') || feed.tags.includes('ETH')) { + if (feed.tags.includes(TAG.Token) || feed.tags.includes(TAG.ETH)) { return ( ) } - if (feed.tags.includes('Gitcoin')) { + if (feed.tags.includes(TAG.Gitcoin)) { return (
<> - {action} {time} + + {action} + {' '} + {time} diff --git a/packages/plugins/RSS3/src/SNSAdaptor/components/FootprintCard.tsx b/packages/plugins/RSS3/src/SNSAdaptor/components/FootprintCard.tsx index 79c3bfebac1e..9cdc0f85e06b 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/components/FootprintCard.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/components/FootprintCard.tsx @@ -28,7 +28,7 @@ const useStyles = makeStyles()((theme) => ({ marginBottom: 8, fontSize: 14, fontWeight: 400, - fontColor: theme.palette.maskColor.main, + color: theme.palette.maskColor.main, }, })) diff --git a/packages/plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx b/packages/plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx index 0558d8aa753b..a5465aac12c0 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx @@ -79,7 +79,7 @@ export function DonationPage({ donations = EMPTY_LIST, loading, address }: Donat type={CollectionType.donations} time={selectedDonation?.timestamp} tokenSymbol={selectedDonation?.tokenSymbol} - tokenAmount={selectedDonation?.tokenAmount} + tokenAmount={selectedDonation?.tokenAmount?.toString()} hash={selectedDonation?.hash} /> diff --git a/packages/shared/src/UI/components/CollectionDetailCard/index.tsx b/packages/shared/src/UI/components/CollectionDetailCard/index.tsx index cad1cbe43e71..ef81227d036f 100644 --- a/packages/shared/src/UI/components/CollectionDetailCard/index.tsx +++ b/packages/shared/src/UI/components/CollectionDetailCard/index.tsx @@ -4,12 +4,11 @@ import { InjectedDialog } from '../../../contexts' import { useSharedI18N } from '../../../locales' import { Box, Card, DialogContent, Link, Typography } from '@mui/material' import type { RSS3BaseAPI } from '@masknet/web3-providers' -import differenceInCalendarDays from 'date-fns/differenceInDays' -import differenceInCalendarHours from 'date-fns/differenceInHours' import { Icons } from '@masknet/icons' import { ChainId, explorerResolver, ZERO_ADDRESS } from '@masknet/web3-shared-evm' import { NFTCardStyledAssetPlayer } from '@masknet/shared' import { EMPTY_LIST } from '@masknet/shared-base' +import formatDistanceToNow from 'date-fns/formatDistanceToNow' interface CollectionDetailCardProps { img?: string @@ -28,7 +27,7 @@ interface CollectionDetailCardProps { }> type: CollectionType time?: string - tokenAmount?: number + tokenAmount?: string tokenSymbol?: string hash?: string } @@ -186,9 +185,6 @@ export const CollectionDetailCard = memo( ) : null }) - const days = differenceInCalendarDays(Date.now(), new Date(time ?? 0)) - const hours = differenceInCalendarHours(Date.now(), new Date(time ?? 0)) % 24 - return ( @@ -252,9 +248,7 @@ export const CollectionDetailCard = memo( {tokenAmount} {tokenSymbol}
- {days > 0 ? `${days} ${t.day({ count: days })} ` : ''} - {hours > 0 ? `${hours} ${t.hour({ count: hours })} ` : ''} - {t.ago()} + {formatDistanceToNow(new Date(time ?? 0))} {t.ago()} (
)} - {traits && ( + {traits && traits.length > 0 && ( {t.properties()} )} - - {traits?.map((trait) => ( -
- {trait.type} - {trait.value} -
- ))} -
+ {traits && traits.length > 0 && ( + + {traits?.map((trait) => ( +
+ {trait.type} + {trait.value} +
+ ))} +
+ )}
) diff --git a/packages/web3-providers/src/rss3/index.ts b/packages/web3-providers/src/rss3/index.ts index 4e3146a9a4a8..904f6b1ce5d1 100644 --- a/packages/web3-providers/src/rss3/index.ts +++ b/packages/web3-providers/src/rss3/index.ts @@ -13,6 +13,7 @@ import { TokenType, } from '@masknet/web3-shared-base' import { first } from 'lodash-unified' +import BigNumber from 'bignumber.js' export class RSS3API implements RSS3BaseAPI.Provider, NonFungibleTokenAPI.Provider { createRSS3( @@ -141,11 +142,12 @@ const createCollection = (collectionResponse: RSS3BaseAPI.CollectionResponse[]): imageURL: firstAction?.metadata?.logo ?? firstAction?.metadata?.image, description: firstAction?.metadata?.description, tokenAmount: collection.actions?.reduce((pre, cur) => { - return ( - pre + - Number(leftShift(cur?.metadata?.token?.value || '0', cur?.metadata?.token?.decimals).toFixed(4)) + return pre.plus( + new BigNumber( + leftShift(cur?.metadata?.token?.value || '0', cur?.metadata?.token?.decimals).toFixed(8), + ), ) - }, 0), + }, new BigNumber(0)), tokenSymbol: firstAction?.metadata?.token?.symbol, location: firstAction?.metadata?.attributes?.find((trait) => trait.trait_type === 'city')?.value || diff --git a/packages/web3-providers/src/types/RSS3.ts b/packages/web3-providers/src/types/RSS3.ts index 3703576f5664..11233cc6d10d 100644 --- a/packages/web3-providers/src/types/RSS3.ts +++ b/packages/web3-providers/src/types/RSS3.ts @@ -1,3 +1,4 @@ +import type BigNumber from 'bignumber.js' import type RSS3 from 'rss3-next' export namespace RSS3BaseAPI { @@ -139,7 +140,7 @@ export namespace RSS3BaseAPI { title?: string description?: string actions?: Action[] - tokenAmount?: number + tokenAmount?: BigNumber tokenSymbol?: string location: string } From 82d0e8512d9b70b42cb4a714659ec425c7c691ce Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Thu, 28 Jul 2022 21:31:00 +0800 Subject: [PATCH 162/179] feat: delete useless code --- .../InjectedComponents/ProfileTabContent.tsx | 73 +++++++++---------- 1 file changed, 33 insertions(+), 40 deletions(-) diff --git a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx index 7bb6904bab67..681e10df4af0 100644 --- a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx +++ b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx @@ -1,5 +1,5 @@ import { useEffect, useMemo, useState } from 'react' -import { useAsyncRetry, useUpdateEffect } from 'react-use' +import { useUpdateEffect } from 'react-use' import { first, uniqBy } from 'lodash-unified' import { createInjectHooksRenderer, @@ -10,7 +10,7 @@ import { } from '@masknet/plugin-infra/content-script' import { useSocialAddressListAll, useAvailablePlugins } from '@masknet/plugin-infra/web3' import { ReversedAddress } from '@masknet/shared' -import { CrossIsolationMessages, EMPTY_LIST, NextIDPlatform } from '@masknet/shared-base' +import { CrossIsolationMessages, EMPTY_LIST } from '@masknet/shared-base' import { makeStyles, MaskTabList, ShadowRootMenu, useStylesExtends, useTabs } from '@masknet/theme' import { Box, Button, CircularProgress, Link, MenuItem, Tab, Typography } from '@mui/material' import { Icons } from '@masknet/icons' @@ -24,7 +24,6 @@ import { useCurrentVisitingSocialIdentity, useIsCurrentVisitingOwnerIdentity, } from '../DataSource/useActivatedUI' -import { NextIDProof } from '@masknet/web3-providers' import { ChainId, explorerResolver } from '@masknet/web3-shared-evm' import { TabContext } from '@mui/lab' @@ -122,6 +121,9 @@ const useStyles = makeStyles()((theme) => ({ selectedIcon: { color: theme.palette.maskColor.primary, }, + gearIcon: { + color: theme.palette.maskColor.dark, + }, })) export interface ProfileTabContentProps extends withClasses<'text' | 'button' | 'root'> {} @@ -140,44 +142,28 @@ export function ProfileTabContent(props: ProfileTabContentProps) { const currentVisitingIdentity = useCurrentVisitingIdentity() const currentVisitingUserId = currentVisitingIdentity.identifier?.userId - const { value: socialAddressList = EMPTY_LIST, loading: loadingSocialAddressList } = useSocialAddressListAll( - currentVisitingIdentity, - [SocialAddressType.NEXT_ID], - ) + const { + value: socialAddressList = EMPTY_LIST, + loading: loadingSocialAddressList, + retry: retrySocialAddress, + } = useSocialAddressListAll(currentVisitingIdentity) const { value: currentVisitingSocialIdentity, loading: loadingCurrentVisitingSocialIdentity } = useCurrentVisitingSocialIdentity() - const { value: personaProof, retry: retryProof } = useAsyncRetry(async () => { - if (!currentVisitingSocialIdentity?.publicKey) return - return NextIDProof.queryExistedBindingByPersona(currentVisitingSocialIdentity?.publicKey) - }, [currentVisitingSocialIdentity?.publicKey]) - useEffect(() => { return MaskMessages.events.ownProofChanged.on(() => { - retryProof() + retrySocialAddress() }) - }, [retryProof]) - - const wallets = personaProof?.proofs?.filter((proof) => proof?.platform === NextIDPlatform.Ethereum) + }, [retrySocialAddress]) - const addressList = useMemo(() => { - if (!wallets?.length || (!isOwnerIdentity && socialAddressList?.length)) { - setSelectedAddress(first(socialAddressList)) - return socialAddressList - } - const addresses = wallets.map((proof) => { - return { - networkSupporterPluginID: NetworkPluginID.PLUGIN_EVM, - type: SocialAddressType.KV, - label: proof?.identity, - address: proof?.identity, - } + useEffect(() => { + socialAddressList.sort((x) => { + if (x.type === SocialAddressType.NEXT_ID) return -1 + return 1 }) - const addressList = [...addresses, ...socialAddressList] - setSelectedAddress(first(addressList)) - return addressList - }, [socialAddressList, wallets?.map((x) => x.identity).join(), isOwnerIdentity]) + setSelectedAddress(first(socialAddressList)) + }, [socialAddressList]) const activatedPlugins = useActivatedPluginsSNSAdaptor('any') const displayPlugins = useAvailablePlugins(activatedPlugins, (plugins) => { @@ -218,8 +204,11 @@ export function ProfileTabContent(props: ProfileTabContentProps) { isTwitter(activatedSocialNetworkUI) && (isWeb3ProfileDisable || (isOwnerIdentity && !currentVisitingSocialIdentity?.hasBinding) || - (isOwnerIdentity && !wallets?.length) || - !addressList?.length) + (isOwnerIdentity && + socialAddressList.findIndex( + (address: { type: SocialAddressType }) => address.type === SocialAddressType.NEXT_ID, + )) === -1 || + !socialAddressList?.length) ) const componentTabId = showNextID ? `${PluginId.NextID}_tabContent` : currentTab @@ -333,14 +322,14 @@ export function ProfileTabContent(props: ProfileTabContentProps) { }} aria-labelledby="demo-positioned-button" onClose={() => setAnchorEl(null)}> - {uniqBy(addressList ?? [], (x) => x.address.toLowerCase()).map((x) => { + {uniqBy(socialAddressList ?? [], (x) => x.address.toLowerCase()).map((x) => { return ( onSelect(x)}>
- {x?.type === SocialAddressType.KV || - x?.type === SocialAddressType.ADDRESS || - selectedAddress?.type === SocialAddressType.NEXT_ID ? ( + {x.type === SocialAddressType.KV || + x.type === SocialAddressType.ADDRESS || + x.type === SocialAddressType.NEXT_ID ? ( - {x?.type === SocialAddressType.KV && ( + {x?.type === SocialAddressType.NEXT_ID && ( @@ -395,7 +384,11 @@ export function ProfileTabContent(props: ProfileTabContentProps) { {t('mask_network')} {isOwnerIdentity ? ( - + ) : ( Date: Fri, 29 Jul 2022 13:48:20 +0800 Subject: [PATCH 163/179] feat: delete useless code --- .../InjectedComponents/ProfileTabContent.tsx | 22 +++++++------- packages/plugin-infra/src/types.ts | 2 -- .../plugins/RSS3/src/SNSAdaptor/TabCard.tsx | 8 ++--- .../SNSAdaptor/components/ReversedAddress.tsx | 26 ---------------- .../plugins/RSS3/src/SNSAdaptor/index.tsx | 30 +++++++++++++++---- .../UI/components/ReversedAddress/index.tsx | 11 +++++-- 6 files changed, 46 insertions(+), 53 deletions(-) delete mode 100644 packages/plugins/RSS3/src/SNSAdaptor/components/ReversedAddress.tsx diff --git a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx index 681e10df4af0..3f06e6d07c19 100644 --- a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx +++ b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx @@ -158,9 +158,10 @@ export function ProfileTabContent(props: ProfileTabContentProps) { }, [retrySocialAddress]) useEffect(() => { - socialAddressList.sort((x) => { - if (x.type === SocialAddressType.NEXT_ID) return -1 - return 1 + socialAddressList.sort((a, z) => { + if (a.type === SocialAddressType.NEXT_ID) return -1 + if (z.type === SocialAddressType.NEXT_ID) return 1 + return 0 }) setSelectedAddress(first(socialAddressList)) }, [socialAddressList]) @@ -169,8 +170,10 @@ export function ProfileTabContent(props: ProfileTabContentProps) { const displayPlugins = useAvailablePlugins(activatedPlugins, (plugins) => { return plugins .flatMap((x) => x.ProfileTabs?.map((y) => ({ ...y, pluginID: x.ID })) ?? EMPTY_LIST) - .filter((x) => x.Utils?.shouldDisplay?.(currentVisitingIdentity, selectedAddress) ?? true) - .filter((x) => x.pluginID !== PluginId.NextID) + .filter((x) => { + const shouldDisplay = x.Utils?.shouldDisplay?.(currentVisitingIdentity, selectedAddress) + return x.pluginID !== PluginId.NextID && (shouldDisplay === undefined || shouldDisplay === true) + }) .sort((a, z) => { // order those tabs from next id first if (a.pluginID === PluginId.NextID) return -1 @@ -216,13 +219,7 @@ export function ProfileTabContent(props: ProfileTabContentProps) { const component = useMemo(() => { const Component = getTabContent(componentTabId) - return ( - - ) + return }, [componentTabId, currentVisitingSocialIdentity?.publicKey, selectedAddress]) useLocationChange(() => { @@ -385,6 +382,7 @@ export function ProfileTabContent(props: ProfileTabContentProps) { {isOwnerIdentity ? ( }> } @@ -965,7 +964,6 @@ export enum PluginId { Referral = 'com.maskbook.referral', Web3Profile = 'io.mask.web3-profile', ScamSniffer = 'io.scamsniffer.mask-plugin', - Web3Feed = 'io.mask.web3-feed', // @masknet/scripts: insert-here } /** diff --git a/packages/plugins/RSS3/src/SNSAdaptor/TabCard.tsx b/packages/plugins/RSS3/src/SNSAdaptor/TabCard.tsx index 7e0b9e10d47d..a54a49043802 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/TabCard.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/TabCard.tsx @@ -16,12 +16,12 @@ export enum TabCardType { } export interface TabCardProps { - persona?: string type: TabCardType socialAddress?: SocialAddress + publicKey?: string } -export function TabCard({ type, socialAddress, persona }: TabCardProps) { +export function TabCard({ type, socialAddress, publicKey }: TabCardProps) { const { value: donations = EMPTY_LIST, loading: loadingDonations } = useDonations( formatEthereumAddress(socialAddress?.address ?? ZERO_ADDRESS), ) @@ -30,7 +30,7 @@ export function TabCard({ type, socialAddress, persona }: TabCardProps) { ) const currentVisitingProfile = useCurrentVisitingProfile() - const { value: kvValue } = useKV(persona) + const { value: kvValue } = useKV(publicKey) const unHiddenDonations = useCollectionFilter( kvValue?.proofs ?? EMPTY_LIST, CollectionType.Donations, @@ -58,7 +58,7 @@ export function TabCard({ type, socialAddress, persona }: TabCardProps) { return } return null - }, [type, socialAddress, persona, unHiddenDonations, unHiddenFootprints]) + }, [type, socialAddress, publicKey, unHiddenDonations, unHiddenFootprints]) if (!socialAddress) return null diff --git a/packages/plugins/RSS3/src/SNSAdaptor/components/ReversedAddress.tsx b/packages/plugins/RSS3/src/SNSAdaptor/components/ReversedAddress.tsx deleted file mode 100644 index 554d7e80e995..000000000000 --- a/packages/plugins/RSS3/src/SNSAdaptor/components/ReversedAddress.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import { memo } from 'react' -import { isSameAddress, NetworkPluginID } from '@masknet/web3-shared-base' -import { useReverseAddress, useWeb3State } from '@masknet/plugin-infra/web3' -import { ZERO_ADDRESS } from '@masknet/web3-shared-evm' - -interface ReverseAddressProps { - address?: string - pluginId?: NetworkPluginID - domainSize?: number - size?: number - fontSize?: string - fontWeight?: number -} - -export const ReversedAddress = memo( - ({ address = ZERO_ADDRESS, pluginId, domainSize, size = 5, fontSize = '14px', fontWeight = 400 }) => { - const { value: domain } = useReverseAddress(pluginId, address) - const { Others } = useWeb3State(pluginId) - if (isSameAddress(address, ZERO_ADDRESS)) return null - - if (!domain || !Others?.formatDomainName) - return {Others?.formatAddress?.(address, size) ?? address} - - return {Others.formatDomainName(domain, domainSize)} - }, -) diff --git a/packages/plugins/RSS3/src/SNSAdaptor/index.tsx b/packages/plugins/RSS3/src/SNSAdaptor/index.tsx index 022d144c1028..3a630bf34441 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/index.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/index.tsx @@ -20,8 +20,14 @@ const sns: Plugin.SNSAdaptor.Definition = { label: 'Donations', priority: 1, UI: { - TabContent: ({ socialAddress, persona }) => { - return + TabContent: ({ socialAddress, identity }) => { + return ( + + ) }, }, Utils: { @@ -33,8 +39,14 @@ const sns: Plugin.SNSAdaptor.Definition = { label: 'Footprints', priority: 2, UI: { - TabContent: ({ socialAddress, persona }) => { - return + TabContent: ({ socialAddress, identity }) => { + return ( + + ) }, }, Utils: { @@ -46,8 +58,14 @@ const sns: Plugin.SNSAdaptor.Definition = { label: 'Feed', priority: 3, UI: { - TabContent: ({ socialAddress, persona }) => { - return + TabContent: ({ socialAddress, identity }) => { + return ( + + ) }, }, Utils: { diff --git a/packages/shared/src/UI/components/ReversedAddress/index.tsx b/packages/shared/src/UI/components/ReversedAddress/index.tsx index 51a2690752a0..610627365766 100644 --- a/packages/shared/src/UI/components/ReversedAddress/index.tsx +++ b/packages/shared/src/UI/components/ReversedAddress/index.tsx @@ -10,21 +10,26 @@ export interface ReverseAddressProps { size?: number fontSize?: string fontWeight?: number + isInline?: boolean } export const ReversedAddress = memo( - ({ address, pluginId, domainSize, size = 5, fontSize = '14px', fontWeight = 700 }) => { + ({ address, pluginId, domainSize, size = 5, fontSize = '14px', fontWeight = 700, isInline = false }) => { const { value: domain } = useReverseAddress(pluginId, address) const { Others } = useWeb3State(pluginId) if (!domain || !Others?.formatDomainName) - return ( + return isInline ? ( + {Others?.formatAddress?.(address, size) ?? address} + ) : ( {Others?.formatAddress?.(address, size) ?? address} ) - return ( + return isInline ? ( + {Others.formatDomainName(domain, domainSize)} + ) : ( {Others.formatDomainName(domain, domainSize)} From 19d50d00ffb8711d80793b1a47a008b7e6f7044b Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Fri, 29 Jul 2022 13:49:16 +0800 Subject: [PATCH 164/179] fix: code style --- .../src/SNSAdaptor/components/FeedCard.tsx | 47 +++++++------------ .../components/CollectionDetailCard/index.tsx | 7 ++- packages/web3-providers/src/rss3/index.ts | 8 ++-- packages/web3-providers/src/types/RSS3.ts | 8 ++-- 4 files changed, 30 insertions(+), 40 deletions(-) diff --git a/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx b/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx index 6b857c67e142..d76d739e9ff9 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx @@ -1,15 +1,13 @@ -import { NFTCardStyledAssetPlayer, TokenIcon } from '@masknet/shared' +import { NFTCardStyledAssetPlayer, ReversedAddress, TokenIcon } from '@masknet/shared' import { makeStyles } from '@masknet/theme' import { Alchemy_EVM, RSS3BaseAPI } from '@masknet/web3-providers' import { isSameAddress, NetworkPluginID } from '@masknet/web3-shared-base' -import { ChainId, resolveIPFSLinkFromURL, ZERO_ADDRESS } from '@masknet/web3-shared-evm' +import { ChainId, formatTokenId, isZeroAddress, resolveIPFSLinkFromURL, ZERO_ADDRESS } from '@masknet/web3-shared-evm' import { Box, Typography, Card } from '@mui/material' -import differenceInCalendarDays from 'date-fns/differenceInDays' -import differenceInCalendarHours from 'date-fns/differenceInHours' import { useMemo } from 'react' -import { ReversedAddress } from './ReversedAddress' import { useI18N } from '../../locales' import { useAsyncRetry } from 'react-use' +import formatDistanceToNow from 'date-fns/formatDistanceToNow' const useStyles = makeStyles()((theme) => ({ wrapper: { @@ -99,49 +97,49 @@ export function FeedCard({ feed, address, onSelect }: FeedCardProps) { const action = useMemo(() => { if (!feed) return if (feed.tags?.includes(TAG.NFT)) { - if (isSameAddress(feed.metadata?.from?.toLowerCase(), address)) { + if (isSameAddress(feed.metadata?.from, address)) { return ( - {t.sent_a_NFT_to()} + {t.sent_a_NFT_to()} ) } - if (isSameAddress(feed.metadata?.from, ZERO_ADDRESS)) { + if (isZeroAddress(feed.metadata?.from)) { return t.minted_a_NFT() } - if (isSameAddress(feed.metadata?.to?.toLowerCase(), address)) { + if (isSameAddress(feed.metadata?.to, address)) { return ( - {t.acquired_a_NFT_from()} + {t.acquired_a_NFT_from()} ) } } if (feed.tags?.includes(TAG.Token) || feed.tags?.includes(TAG.ETH)) { - if (isSameAddress(feed.metadata?.from?.toLowerCase(), address)) { + if (isSameAddress(feed.metadata?.from, address)) { return ( - {t.sent_to()} + {t.sent_to()} ) } - if (isSameAddress(feed.metadata?.to?.toLowerCase(), address)) { + if (isSameAddress(feed.metadata?.to, address)) { return ( - {t.received_from()} + {t.received_from()} ) } } if (feed.tags?.includes(TAG.Gitcoin)) { - if (isSameAddress(feed.metadata?.from?.toLowerCase(), address)) { + if (isSameAddress(feed.metadata?.from, address)) { return t.donated() } - if (isSameAddress(feed.metadata?.to?.toLowerCase(), address)) { + if (isSameAddress(feed.metadata?.to, address)) { return t.received_donation_from() } } - if (isSameAddress(feed.metadata?.from?.toLowerCase(), address)) { + if (isSameAddress(feed.metadata?.from, address)) { return t.received() } return t.sent() @@ -189,15 +187,6 @@ export function FeedCard({ feed, address, onSelect }: FeedCardProps) { return null }, [feed]) - const time = useMemo(() => { - const days = differenceInCalendarDays(new Date(), new Date(feed.date_updated)) - const hours = differenceInCalendarHours(new Date(), new Date(feed.date_updated)) - return [ - days > 0 ? `${days} ${days > 1 ? t.days() : t.day()} ` : '', - hours > 0 ? `${hours} ${hours > 1 ? t.hours() : t.hour()} ` : '', - t.ago(), - ].join('') - }, [feed.date_updated, t]) return ( <> - {action} + {action} {' '} - {time} + {formatDistanceToNow(new Date(feed.date_updated))} {t.ago()} @@ -237,7 +226,7 @@ export function FeedCard({ feed, address, onSelect }: FeedCardProps) { {feed.summary || NFTMetadata?.metadata?.description || NFTMetadata?.collection?.description} || - `#${feed.metadata?.token_id}` + {formatTokenId(feed.metadata?.token_id ?? '0x00')}
diff --git a/packages/shared/src/UI/components/CollectionDetailCard/index.tsx b/packages/shared/src/UI/components/CollectionDetailCard/index.tsx index ef81227d036f..5acd38f96523 100644 --- a/packages/shared/src/UI/components/CollectionDetailCard/index.tsx +++ b/packages/shared/src/UI/components/CollectionDetailCard/index.tsx @@ -80,7 +80,7 @@ const useStyles = makeStyles()((theme) => ({ }, threeLine: { display: '-webkit-box', - '-webkit-line-clamp': 3, + '-webkit-line-clamp': '3', height: 60, fontSize: 14, fontWeight: 400, @@ -129,6 +129,9 @@ const useStyles = makeStyles()((theme) => ({ whiteSpace: 'nowrap', textOverflow: 'ellipsis', }, + linkOutIcon: { + color: theme.palette.mode === 'light' ? 'white' : 'black', + }, })) const ChainID = { @@ -253,7 +256,7 @@ export const CollectionDetailCard = memo( className={classes.linkBox} target="_blank" href={explorerResolver.transactionLink(ChainId.Mainnet, hash ?? ZERO_ADDRESS)}> - +
diff --git a/packages/web3-providers/src/rss3/index.ts b/packages/web3-providers/src/rss3/index.ts index 904f6b1ce5d1..d175daa24e24 100644 --- a/packages/web3-providers/src/rss3/index.ts +++ b/packages/web3-providers/src/rss3/index.ts @@ -11,9 +11,9 @@ import { leftShift, NetworkPluginID, TokenType, + ZERO, } from '@masknet/web3-shared-base' import { first } from 'lodash-unified' -import BigNumber from 'bignumber.js' export class RSS3API implements RSS3BaseAPI.Provider, NonFungibleTokenAPI.Provider { createRSS3( @@ -143,11 +143,9 @@ const createCollection = (collectionResponse: RSS3BaseAPI.CollectionResponse[]): description: firstAction?.metadata?.description, tokenAmount: collection.actions?.reduce((pre, cur) => { return pre.plus( - new BigNumber( - leftShift(cur?.metadata?.token?.value || '0', cur?.metadata?.token?.decimals).toFixed(8), - ), + leftShift(cur?.metadata?.token?.value || '0', cur?.metadata?.token?.decimals).toFixed(8), ) - }, new BigNumber(0)), + }, ZERO), tokenSymbol: firstAction?.metadata?.token?.symbol, location: firstAction?.metadata?.attributes?.find((trait) => trait.trait_type === 'city')?.value || diff --git a/packages/web3-providers/src/types/RSS3.ts b/packages/web3-providers/src/types/RSS3.ts index 11233cc6d10d..3584543c04cd 100644 --- a/packages/web3-providers/src/types/RSS3.ts +++ b/packages/web3-providers/src/types/RSS3.ts @@ -153,7 +153,7 @@ export namespace RSS3BaseAPI { NFT = 'NFT', } - export type Tags = 'NFT' | 'Token' | 'POAP' | 'Gitcoin' | 'Mirror Entry' | 'ETH' + export type Tag = 'NFT' | 'Token' | 'POAP' | 'Gitcoin' | 'Mirror Entry' | 'ETH' export interface NameInfo { rnsName: string @@ -176,7 +176,7 @@ export namespace RSS3BaseAPI { token_address?: string } - export interface Attachments { + export interface Attachment { address?: string mime_type?: string size_in_bytes?: string @@ -184,7 +184,7 @@ export namespace RSS3BaseAPI { } export interface Web3Feed { - attachments?: Attachments[] + attachments?: Attachment[] authors: string[] /* cspell:disable-next-line */ backlinks: string @@ -195,7 +195,7 @@ export namespace RSS3BaseAPI { related_urls?: string[] // this field works different from API doc source: string - tags: Tags[] + tags: Tag[] summary?: string title?: string metadata?: Metadata From 690cf4033ef48a34db78da525bfaed2ed342151c Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Fri, 29 Jul 2022 13:52:55 +0800 Subject: [PATCH 165/179] feat: add inline reversed address --- .../plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx b/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx index d76d739e9ff9..906a51e92c51 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx @@ -100,7 +100,7 @@ export function FeedCard({ feed, address, onSelect }: FeedCardProps) { if (isSameAddress(feed.metadata?.from, address)) { return ( - {t.sent_a_NFT_to()} + {t.sent_a_NFT_to()} ) } @@ -110,7 +110,8 @@ export function FeedCard({ feed, address, onSelect }: FeedCardProps) { if (isSameAddress(feed.metadata?.to, address)) { return ( - {t.acquired_a_NFT_from()} + {t.acquired_a_NFT_from()}{' '} + ) } @@ -119,14 +120,14 @@ export function FeedCard({ feed, address, onSelect }: FeedCardProps) { if (isSameAddress(feed.metadata?.from, address)) { return ( - {t.sent_to()} + {t.sent_to()} ) } if (isSameAddress(feed.metadata?.to, address)) { return ( - {t.received_from()} + {t.received_from()} ) } From 2adeae52fbae4a10365a7463e6ce5f68f42d6c5a Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Fri, 29 Jul 2022 14:08:43 +0800 Subject: [PATCH 166/179] feat: change address menu background color --- .../InjectedComponents/ProfileTabContent.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx index 3f06e6d07c19..de36ea6e0713 100644 --- a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx +++ b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx @@ -59,6 +59,11 @@ const useStyles = makeStyles()((theme) => ({ flexGrow: 1, justifyContent: 'space-between', }, + addressMenu: { + maxHeight: 192, + width: 248, + backgroundColor: theme.palette.maskColor.bottom, + }, addressItem: { display: 'flex', alignItems: 'center', @@ -312,10 +317,7 @@ export function ProfileTabContent(props: ProfileTabContentProps) { anchorEl={anchorEl} open={Boolean(anchorEl)} PaperProps={{ - style: { - maxHeight: 192, - width: 248, - }, + className: classes.addressMenu, }} aria-labelledby="demo-positioned-button" onClose={() => setAnchorEl(null)}> From c98bf36852fbedf787c769bdf41e3bf7de9ba5f1 Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Fri, 29 Jul 2022 14:13:54 +0800 Subject: [PATCH 167/179] feat: change selected icon color --- packages/icons/general/Selected.dark.svg | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/icons/general/Selected.dark.svg b/packages/icons/general/Selected.dark.svg index a1eda20e6b09..98cb38f5c74c 100644 --- a/packages/icons/general/Selected.dark.svg +++ b/packages/icons/general/Selected.dark.svg @@ -1,7 +1,7 @@ - + - \ No newline at end of file From ed3822d980be7ddabf798528fa1cf656c50f87a8 Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Fri, 29 Jul 2022 18:57:31 +0800 Subject: [PATCH 168/179] feat: change address fetch hook --- packages/icons/plugins/WalletUnderTabs.svg | 2 +- .../components/DataSource/useActivatedUI.ts | 4 ++-- .../InjectedComponents/ProfileTabContent.tsx | 8 +++---- .../plugin-infra/src/web3-state/Identity.ts | 6 +++-- .../src/web3/useSocialAddressListAll.ts | 14 +++++++----- .../plugins/EVM/src/state/IdentityService.ts | 22 +++++++++---------- packages/web3-shared/base/src/specs/index.ts | 2 +- 7 files changed, 31 insertions(+), 27 deletions(-) diff --git a/packages/icons/plugins/WalletUnderTabs.svg b/packages/icons/plugins/WalletUnderTabs.svg index adfe652e2ebe..acc3adb1b9c9 100644 --- a/packages/icons/plugins/WalletUnderTabs.svg +++ b/packages/icons/plugins/WalletUnderTabs.svg @@ -1,5 +1,5 @@ - + x.persona === persona?.identifier.publicKeyAsHex.toLowerCase()), } - }, [isOwnerIdentity, identity.identifier?.toText()]) + }, [isOwnerIdentity, identity.identifier?.userId]) } diff --git a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx index de36ea6e0713..3a3391103cf2 100644 --- a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx +++ b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx @@ -147,14 +147,14 @@ export function ProfileTabContent(props: ProfileTabContentProps) { const currentVisitingIdentity = useCurrentVisitingIdentity() const currentVisitingUserId = currentVisitingIdentity.identifier?.userId + const { value: currentVisitingSocialIdentity, loading: loadingCurrentVisitingSocialIdentity } = + useCurrentVisitingSocialIdentity() + const { value: socialAddressList = EMPTY_LIST, loading: loadingSocialAddressList, retry: retrySocialAddress, - } = useSocialAddressListAll(currentVisitingIdentity) - - const { value: currentVisitingSocialIdentity, loading: loadingCurrentVisitingSocialIdentity } = - useCurrentVisitingSocialIdentity() + } = useSocialAddressListAll(currentVisitingSocialIdentity, isOwnerIdentity) useEffect(() => { return MaskMessages.events.ownProofChanged.on(() => { diff --git a/packages/plugin-infra/src/web3-state/Identity.ts b/packages/plugin-infra/src/web3-state/Identity.ts index a5fd3a91d89b..d0cf2f863488 100644 --- a/packages/plugin-infra/src/web3-state/Identity.ts +++ b/packages/plugin-infra/src/web3-state/Identity.ts @@ -26,7 +26,7 @@ export class IdentityServiceState implements Web3SocialIdentityState { throw new Error('Method not implemented.') } - async lookup(identity: SocialIdentity): Promise>> { + async lookup(identity: SocialIdentity, isOwnerIdentity = false): Promise>> { const ID = this.getIdentityID(identity) if (!ID) return EMPTY_LIST @@ -34,7 +34,9 @@ export class IdentityServiceState implements Web3SocialIdentityState { if (fromCache) return fromCache const fromRemote = this.getFromRemote(identity) - this.cache.set(ID, fromRemote) + if (!isOwnerIdentity) { + this.cache.set(ID, fromRemote) + } return fromRemote } diff --git a/packages/plugin-infra/src/web3/useSocialAddressListAll.ts b/packages/plugin-infra/src/web3/useSocialAddressListAll.ts index 301d77e1d569..9668438fb005 100644 --- a/packages/plugin-infra/src/web3/useSocialAddressListAll.ts +++ b/packages/plugin-infra/src/web3/useSocialAddressListAll.ts @@ -17,6 +17,7 @@ const addressCache = new LRUCache({ */ export function useSocialAddressListAll( identity?: SocialIdentity, + isOwnerIdentity?: boolean, includes?: SocialAddressType[], sorter?: (a: SocialAddress, z: SocialAddress) => number, ) { @@ -26,18 +27,21 @@ export function useSocialAddressListAll( return useAsyncRetry(async () => { const userId = identity?.identifier?.userId - if (!userId || userId === '$unknown') return EMPTY_LIST - + const publicKey = identity?.publicKey + if (!userId || userId === '$unknown' || !publicKey) return EMPTY_LIST let cached = addressCache.get(userId) + if (!cached) { cached = Promise.allSettled( - [EVM_IdentityService, SolanaIdentityService].map((x) => x?.lookup(identity) ?? []), + [EVM_IdentityService, SolanaIdentityService].map((x) => x?.lookup(identity, isOwnerIdentity) ?? []), ) - addressCache.set(userId, cached) + if (!isOwnerIdentity) { + addressCache.set(userId, cached) + } } const allSettled = await cached const listOfAddress = allSettled.flatMap((x) => (x.status === 'fulfilled' ? x.value : [])) const sorted = sorter && listOfAddress.length ? listOfAddress.sort(sorter) : listOfAddress return includes?.length ? sorted.filter((x) => includes.includes(x.type)) : sorted - }, [identity, sorter, includes?.join(), EVM_IdentityService?.lookup, SolanaIdentityService?.lookup]) + }, [identity?.publicKey, sorter, includes?.join(), EVM_IdentityService?.lookup, SolanaIdentityService?.lookup]) } diff --git a/packages/plugins/EVM/src/state/IdentityService.ts b/packages/plugins/EVM/src/state/IdentityService.ts index 3c8589a35bf0..b515720236c1 100644 --- a/packages/plugins/EVM/src/state/IdentityService.ts +++ b/packages/plugins/EVM/src/state/IdentityService.ts @@ -36,17 +36,15 @@ function getNextIDPlatform() { return NextIDPlatform.Twitter } -async function getWalletAddressesFromNextID(userId: string) { - if (!userId) return EMPTY_LIST +async function getWalletAddressesFromNextID(userId?: string, publicKey?: string) { + if (!userId || !publicKey) return EMPTY_LIST const bindings = await NextIDProof.queryAllExistedBindingsByPlatform(getNextIDPlatform(), userId) - for (const binding of bindings) { - const identities = binding.proofs - .filter((x) => x.platform === NextIDPlatform.Ethereum && isValidAddress(x.identity)) - .map((y) => y.identity) - if (identities.length) return identities - } - return EMPTY_LIST + const binding = bindings.find((binding) => binding.persona.toLowerCase() === publicKey.toLowerCase()) + return ( + binding?.proofs.filter((x) => x.platform === NextIDPlatform.Ethereum && isValidAddress(x.identity)) ?? + EMPTY_LIST + ) } export class IdentityService extends IdentityServiceState { @@ -75,10 +73,10 @@ export class IdentityService extends IdentityServiceState { } /** Read a social address from NextID. */ - private async getSocialAddressFromNextID({ identifier }: SocialIdentity) { - const listOfAddress = await getWalletAddressesFromNextID(identifier?.userId ?? '') + private async getSocialAddressFromNextID({ identifier, publicKey }: SocialIdentity) { + const listOfAddress = await getWalletAddressesFromNextID(identifier?.userId, publicKey) return listOfAddress - .map((x) => this.createSocialAddress(SocialAddressType.NEXT_ID, x)) + .map((x) => this.createSocialAddress(SocialAddressType.NEXT_ID, x.identity)) .filter(Boolean) as Array> } diff --git a/packages/web3-shared/base/src/specs/index.ts b/packages/web3-shared/base/src/specs/index.ts index b31b8267b088..cf8b93d2a1fb 100644 --- a/packages/web3-shared/base/src/specs/index.ts +++ b/packages/web3-shared/base/src/specs/index.ts @@ -1085,7 +1085,7 @@ export interface HubState< export interface IdentityServiceState { /** Find all social addresses related to the given identity. */ - lookup(identity: SocialIdentity): Promise>> + lookup(identity: SocialIdentity, isOwnerIdentity?:boolean): Promise>> } export interface NameServiceState { /** get address of domain name */ From 4ad5c2ed484e3a78bbad542eaaf73656151d0735 Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Fri, 29 Jul 2022 19:08:34 +0800 Subject: [PATCH 169/179] fix: text color --- packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx b/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx index 906a51e92c51..2e572b190020 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx @@ -215,7 +215,9 @@ export function FeedCard({ feed, address, onSelect }: FeedCardProps) { {action} {' '} - {formatDistanceToNow(new Date(feed.date_updated))} {t.ago()} + + {formatDistanceToNow(new Date(feed.date_updated))} {t.ago()} + From 63e23109faf646a490c2f2dfc104952ef6dccdfb Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Mon, 1 Aug 2022 11:24:25 +0800 Subject: [PATCH 170/179] fix: code style --- .../InjectedComponents/ProfileTabContent.tsx | 14 ++++----- .../plugins/NextID/components/NextIdPage.tsx | 19 +++++++++--- .../src/web3/useSocialAddressListAll.ts | 3 +- .../src/SNSAdaptor/components/FeedCard.tsx | 4 +-- .../UI/components/ReversedAddress/index.tsx | 31 ++++++++++++------- packages/web3-providers/src/rss3/index.ts | 2 +- packages/web3-providers/src/types/RSS3.ts | 3 +- 7 files changed, 45 insertions(+), 31 deletions(-) diff --git a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx index 3a3391103cf2..cd375987da5f 100644 --- a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx +++ b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx @@ -163,12 +163,12 @@ export function ProfileTabContent(props: ProfileTabContentProps) { }, [retrySocialAddress]) useEffect(() => { - socialAddressList.sort((a, z) => { + const sortedList = socialAddressList.slice(0).sort((a, z) => { if (a.type === SocialAddressType.NEXT_ID) return -1 if (z.type === SocialAddressType.NEXT_ID) return 1 return 0 }) - setSelectedAddress(first(socialAddressList)) + setSelectedAddress(first(sortedList)) }, [socialAddressList]) const activatedPlugins = useActivatedPluginsSNSAdaptor('any') @@ -176,8 +176,8 @@ export function ProfileTabContent(props: ProfileTabContentProps) { return plugins .flatMap((x) => x.ProfileTabs?.map((y) => ({ ...y, pluginID: x.ID })) ?? EMPTY_LIST) .filter((x) => { - const shouldDisplay = x.Utils?.shouldDisplay?.(currentVisitingIdentity, selectedAddress) - return x.pluginID !== PluginId.NextID && (shouldDisplay === undefined || shouldDisplay === true) + const shouldDisplay = x.Utils?.shouldDisplay?.(currentVisitingIdentity, selectedAddress) ?? true + return x.pluginID !== PluginId.NextID && shouldDisplay }) .sort((a, z) => { // order those tabs from next id first @@ -213,9 +213,7 @@ export function ProfileTabContent(props: ProfileTabContentProps) { (isWeb3ProfileDisable || (isOwnerIdentity && !currentVisitingSocialIdentity?.hasBinding) || (isOwnerIdentity && - socialAddressList.findIndex( - (address: { type: SocialAddressType }) => address.type === SocialAddressType.NEXT_ID, - )) === -1 || + socialAddressList.findIndex((address) => address.type === SocialAddressType.NEXT_ID)) === -1 || !socialAddressList?.length) ) @@ -289,7 +287,7 @@ export function ProfileTabContent(props: ProfileTabContentProps) { selectedAddress?.type === SocialAddressType.ADDRESS || selectedAddress?.type === SocialAddressType.NEXT_ID ? ( diff --git a/packages/mask/src/plugins/NextID/components/NextIdPage.tsx b/packages/mask/src/plugins/NextID/components/NextIdPage.tsx index a4fdf8b0f6cd..de0b5b84c92b 100644 --- a/packages/mask/src/plugins/NextID/components/NextIdPage.tsx +++ b/packages/mask/src/plugins/NextID/components/NextIdPage.tsx @@ -142,7 +142,6 @@ export function NextIdPage({ persona }: NextIdPageProps) { const t = useI18N() const { classes } = useStyles() - const [description, setDescription] = useState('') const currentProfileIdentifier = useLastRecognizedIdentity() const visitingPersonaIdentifier = useCurrentVisitingIdentity() const personaConnectStatus = usePersonaConnectStatus() @@ -156,7 +155,6 @@ export function NextIdPage({ persona }: NextIdPageProps) { const personaActionButton = useMemo(() => { if (!personaConnectStatus.action) return null const button = personaConnectStatus.hasPersona ? t.connect_persona() : t.create_persona() - setDescription(personaConnectStatus.hasPersona ? '' : t.create_persona_intro()) const icon = personaConnectStatus.hasPersona ? ( ) : ( @@ -187,6 +185,19 @@ export function NextIdPage({ persona }: NextIdPageProps) { ) }, [publicKeyAsHex, visitingPersonaIdentifier, isVerified]) + const description = useMemo(() => { + if (personaConnectStatus.action && !personaConnectStatus.hasPersona) { + return t.create_persona_intro() + } + if (!isOwn) { + return t.others_lack_wallet() + } + if (isAccountVerified) { + return t.add_wallet_intro() + } + return '' + }, [personaConnectStatus, isOwn, isAccountVerified, t]) + const isWeb3ProfileDisable = useIsMinimalMode(PluginId.Web3Profile) const { @@ -218,7 +229,6 @@ export function NextIdPage({ persona }: NextIdPageProps) { const getButton = useMemo(() => { if (!isOwn) { - setDescription(t.others_lack_wallet()) return } if (isWeb3ProfileDisable) { @@ -240,7 +250,6 @@ export function NextIdPage({ persona }: NextIdPageProps) { ) } - setDescription(t.add_wallet_intro()) return (
- {description} + {description} {getButton} diff --git a/packages/plugin-infra/src/web3/useSocialAddressListAll.ts b/packages/plugin-infra/src/web3/useSocialAddressListAll.ts index 9668438fb005..933c4850f497 100644 --- a/packages/plugin-infra/src/web3/useSocialAddressListAll.ts +++ b/packages/plugin-infra/src/web3/useSocialAddressListAll.ts @@ -27,8 +27,7 @@ export function useSocialAddressListAll( return useAsyncRetry(async () => { const userId = identity?.identifier?.userId - const publicKey = identity?.publicKey - if (!userId || userId === '$unknown' || !publicKey) return EMPTY_LIST + if (!userId || userId === '$unknown' || !identity?.publicKey) return EMPTY_LIST let cached = addressCache.get(userId) if (!cached) { diff --git a/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx b/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx index 2e572b190020..ba048547ab3f 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx @@ -211,14 +211,14 @@ export function FeedCard({ feed, address, onSelect }: FeedCardProps) { }) }>
- <> + {action} {' '} {formatDistanceToNow(new Date(feed.date_updated))} {t.ago()} - + {feed.title || diff --git a/packages/shared/src/UI/components/ReversedAddress/index.tsx b/packages/shared/src/UI/components/ReversedAddress/index.tsx index 610627365766..06a66de7323d 100644 --- a/packages/shared/src/UI/components/ReversedAddress/index.tsx +++ b/packages/shared/src/UI/components/ReversedAddress/index.tsx @@ -1,38 +1,45 @@ import { memo } from 'react' import type { NetworkPluginID } from '@masknet/web3-shared-base' import { useReverseAddress, useWeb3State } from '@masknet/plugin-infra/web3' -import { Typography } from '@mui/material' +import { Typography, TypographyProps } from '@mui/material' export interface ReverseAddressProps { address: string pluginId?: NetworkPluginID domainSize?: number size?: number - fontSize?: string - fontWeight?: number + TypographyProps?: TypographyProps isInline?: boolean } export const ReversedAddress = memo( - ({ address, pluginId, domainSize, size = 5, fontSize = '14px', fontWeight = 700, isInline = false }) => { + ({ + address, + pluginId, + domainSize, + size = 5, + TypographyProps = { fontSize: '14px', fontWeight: 700 }, + isInline = false, + }) => { const { value: domain } = useReverseAddress(pluginId, address) const { Others } = useWeb3State(pluginId) + const { fontSize, fontWeight } = TypographyProps if (!domain || !Others?.formatDomainName) return isInline ? ( - {Others?.formatAddress?.(address, size) ?? address} - ) : ( - + {Others?.formatAddress?.(address, size) ?? address} - + + ) : ( + {Others?.formatAddress?.(address, size) ?? address} ) return isInline ? ( - {Others.formatDomainName(domain, domainSize)} - ) : ( - + {Others.formatDomainName(domain, domainSize)} - + + ) : ( + {Others.formatDomainName(domain, domainSize)} ) }, ) diff --git a/packages/web3-providers/src/rss3/index.ts b/packages/web3-providers/src/rss3/index.ts index d175daa24e24..8e05f21c1b3c 100644 --- a/packages/web3-providers/src/rss3/index.ts +++ b/packages/web3-providers/src/rss3/index.ts @@ -117,8 +117,8 @@ export class RSS3API implements RSS3BaseAPI.Provider, NonFungibleTokenAPI.Provid async getWeb3Feed( address: string, - { networkPluginId = NetworkPluginID.PLUGIN_EVM }: HubOptions = {}, type?: RSS3BaseAPI.FeedType, + { networkPluginId = NetworkPluginID.PLUGIN_EVM }: HubOptions = {}, ) { if (!address) return const url = `${RSS3_FEED_ENDPOINT}account:${address}@${NETWORK_PLUGIN[networkPluginId]}/notes?limit=100&exclude_tags=POAP&tags=Gitcoin&tags=POAP&tags=NFT&tags=Donation&latest=false` diff --git a/packages/web3-providers/src/types/RSS3.ts b/packages/web3-providers/src/types/RSS3.ts index 3584543c04cd..14c3a8349986 100644 --- a/packages/web3-providers/src/types/RSS3.ts +++ b/packages/web3-providers/src/types/RSS3.ts @@ -140,7 +140,7 @@ export namespace RSS3BaseAPI { title?: string description?: string actions?: Action[] - tokenAmount?: BigNumber + tokenAmount?: BigNumber.Value tokenSymbol?: string location: string } @@ -223,5 +223,6 @@ export namespace RSS3BaseAPI { getFootprints(address: string): Promise getNameInfo(id: string): Promise getProfileInfo(address: string): Promise + getWeb3Feed(address: string, type: FeedType, option: HubOptions): Promise } } From fd1f2e1a0ba38522ede2d134802e909bd1a2a750 Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Mon, 1 Aug 2022 11:31:29 +0800 Subject: [PATCH 171/179] fix: build error --- packages/web3-providers/src/types/RSS3.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/web3-providers/src/types/RSS3.ts b/packages/web3-providers/src/types/RSS3.ts index 14c3a8349986..d082e02e3cd2 100644 --- a/packages/web3-providers/src/types/RSS3.ts +++ b/packages/web3-providers/src/types/RSS3.ts @@ -1,3 +1,5 @@ +import type { HubOptions } from '@masknet/web3-shared-base' +import type { ChainId } from '@masknet/web3-shared-evm' import type BigNumber from 'bignumber.js' import type RSS3 from 'rss3-next' @@ -223,6 +225,6 @@ export namespace RSS3BaseAPI { getFootprints(address: string): Promise getNameInfo(id: string): Promise getProfileInfo(address: string): Promise - getWeb3Feed(address: string, type: FeedType, option: HubOptions): Promise + getWeb3Feed(address: string, type: FeedType, option: HubOptions): Promise } } From c5eb48833921fab97364b94803a4e32811470e2a Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Mon, 1 Aug 2022 11:33:53 +0800 Subject: [PATCH 172/179] feat: change type --- packages/web3-providers/src/types/RSS3.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/web3-providers/src/types/RSS3.ts b/packages/web3-providers/src/types/RSS3.ts index d082e02e3cd2..8c668f829202 100644 --- a/packages/web3-providers/src/types/RSS3.ts +++ b/packages/web3-providers/src/types/RSS3.ts @@ -225,6 +225,10 @@ export namespace RSS3BaseAPI { getFootprints(address: string): Promise getNameInfo(id: string): Promise getProfileInfo(address: string): Promise - getWeb3Feed(address: string, type: FeedType, option: HubOptions): Promise + getWeb3Feed( + address: string, + type?: FeedType, + option?: HubOptions, + ): Promise } } From a2644908d60d7cabaa3bc8cbcf3c573e39bdbf34 Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Mon, 1 Aug 2022 13:54:44 +0800 Subject: [PATCH 173/179] feat: add Address component --- .../InjectedComponents/ProfileTabContent.tsx | 90 +++++++------------ .../src/UI/components/AddressItem/index.tsx | 63 +++++++++++++ .../UI/components/ReversedAddress/index.tsx | 26 +----- packages/shared/src/UI/components/index.ts | 1 + 4 files changed, 98 insertions(+), 82 deletions(-) create mode 100644 packages/shared/src/UI/components/AddressItem/index.tsx diff --git a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx index cd375987da5f..35fd88205d38 100644 --- a/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx +++ b/packages/mask/src/components/InjectedComponents/ProfileTabContent.tsx @@ -9,7 +9,7 @@ import { usePluginI18NField, } from '@masknet/plugin-infra/content-script' import { useSocialAddressListAll, useAvailablePlugins } from '@masknet/plugin-infra/web3' -import { ReversedAddress } from '@masknet/shared' +import { AddressItem } from '@masknet/shared' import { CrossIsolationMessages, EMPTY_LIST } from '@masknet/shared-base' import { makeStyles, MaskTabList, ShadowRootMenu, useStylesExtends, useTabs } from '@masknet/theme' import { Box, Button, CircularProgress, Link, MenuItem, Tab, Typography } from '@mui/material' @@ -24,7 +24,6 @@ import { useCurrentVisitingSocialIdentity, useIsCurrentVisitingOwnerIdentity, } from '../DataSource/useActivatedUI' -import { ChainId, explorerResolver } from '@masknet/web3-shared-evm' import { TabContext } from '@mui/lab' function getTabContent(tabId?: string) { @@ -114,9 +113,6 @@ const useStyles = makeStyles()((theme) => ({ fontSize: 18, fontWeight: 700, }, - linkOutIcon: { - color: theme.palette.maskColor.secondaryDark, - }, arrowDropIcon: { color: theme.palette.maskColor.dark, }, @@ -129,6 +125,17 @@ const useStyles = makeStyles()((theme) => ({ gearIcon: { color: theme.palette.maskColor.dark, }, + linkOutIcon: { + color: theme.palette.maskColor.secondaryDark, + }, + mainLinkIcon: { + margin: '0px 2px', + color: theme.palette.maskColor.secondaryDark, + }, + secondLinkIcon: { + margin: '4px 2px 0 2px', + color: theme.palette.maskColor.secondaryDark, + }, })) export interface ProfileTabContentProps extends withClasses<'text' | 'button' | 'root'> {} @@ -154,7 +161,7 @@ export function ProfileTabContent(props: ProfileTabContentProps) { value: socialAddressList = EMPTY_LIST, loading: loadingSocialAddressList, retry: retrySocialAddress, - } = useSocialAddressListAll(currentVisitingSocialIdentity, isOwnerIdentity) + } = useSocialAddressListAll(currentVisitingSocialIdentity) useEffect(() => { return MaskMessages.events.ownProofChanged.on(() => { @@ -213,8 +220,7 @@ export function ProfileTabContent(props: ProfileTabContentProps) { (isWeb3ProfileDisable || (isOwnerIdentity && !currentVisitingSocialIdentity?.hasBinding) || (isOwnerIdentity && - socialAddressList.findIndex((address) => address.type === SocialAddressType.NEXT_ID)) === -1 || - !socialAddressList?.length) + socialAddressList.findIndex((address) => address.type === SocialAddressType.NEXT_ID)) === -1) ) const componentTabId = showNextID ? `${PluginId.NextID}_tabContent` : currentTab @@ -282,33 +288,16 @@ export function ProfileTabContent(props: ProfileTabContentProps) { size="small" onClick={onOpen} className={classes.walletButton}> - - {selectedAddress?.type === SocialAddressType.KV || - selectedAddress?.type === SocialAddressType.ADDRESS || - selectedAddress?.type === SocialAddressType.NEXT_ID ? ( - - ) : ( - selectedAddress?.label - )} - - - - + iconProps={classes.mainLinkIcon} + TypographyProps={{ fontSize: '18px', fontWeight: 700 }} + identityAddress={selectedAddress} + /> onSelect(x)}>
- {x.type === SocialAddressType.KV || - x.type === SocialAddressType.ADDRESS || - x.type === SocialAddressType.NEXT_ID ? ( - - ) : ( - - {x.label} - - )} - - - + identityAddress={x} + iconProps={classes.secondLinkIcon} + /> {x?.type === SocialAddressType.NEXT_ID && ( ({ + link: { + cursor: 'pointer', + marginTop: 2, + zIndex: 1, + '&:hover': { + textDecoration: 'none', + }, + }, + linkIcon: { + color: theme.palette.maskColor.second, + margin: '0px 2px 0 2px', + }, +})) + +export interface AddressItemProps { + identityAddress?: SocialAddress + reverse?: boolean + TypographyProps?: TypographyProps + iconProps?: string +} + +export function AddressItem({ + identityAddress, + reverse = true, + TypographyProps = { fontSize: '14px', fontWeight: 700 }, + iconProps, +}: AddressItemProps) { + const { classes } = useStyles() + const { Others } = useWeb3State(identityAddress?.networkSupporterPluginID) + + if (!identityAddress) return null + + return ( + <> + + {reverse ? ( + + ) : ( + {identityAddress.label} + )} + + + + + + ) +} diff --git a/packages/shared/src/UI/components/ReversedAddress/index.tsx b/packages/shared/src/UI/components/ReversedAddress/index.tsx index 06a66de7323d..874e55918c24 100644 --- a/packages/shared/src/UI/components/ReversedAddress/index.tsx +++ b/packages/shared/src/UI/components/ReversedAddress/index.tsx @@ -13,33 +13,13 @@ export interface ReverseAddressProps { } export const ReversedAddress = memo( - ({ - address, - pluginId, - domainSize, - size = 5, - TypographyProps = { fontSize: '14px', fontWeight: 700 }, - isInline = false, - }) => { + ({ address, pluginId, domainSize, size = 5, TypographyProps = { fontSize: '14px', fontWeight: 700 } }) => { const { value: domain } = useReverseAddress(pluginId, address) const { Others } = useWeb3State(pluginId) - const { fontSize, fontWeight } = TypographyProps if (!domain || !Others?.formatDomainName) - return isInline ? ( - - {Others?.formatAddress?.(address, size) ?? address} - - ) : ( - {Others?.formatAddress?.(address, size) ?? address} - ) + return {Others?.formatAddress?.(address, size) ?? address} - return isInline ? ( - - {Others.formatDomainName(domain, domainSize)} - - ) : ( - {Others.formatDomainName(domain, domainSize)} - ) + return {Others?.formatDomainName(domain, domainSize)} }, ) diff --git a/packages/shared/src/UI/components/index.ts b/packages/shared/src/UI/components/index.ts index de17c3b9a517..7a343857e2e1 100644 --- a/packages/shared/src/UI/components/index.ts +++ b/packages/shared/src/UI/components/index.ts @@ -24,3 +24,4 @@ export * from './NFTCard' export * from './TokenSecurity' export * from './CollectionDetailCard' export * from './Image' +export * from './AddressItem' From eac379cca5e3ae6ebed415b322478eb0f01a5545 Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Mon, 1 Aug 2022 13:58:06 +0800 Subject: [PATCH 174/179] feat: delete useless code --- .../icons/{plugins => general}/WalletUnderTabs.svg | 0 .../mask/src/components/DataSource/useActivatedUI.ts | 1 + .../src/plugins/Collectible/SNSAdaptor/NFTPage.tsx | 11 ++++++++--- .../mask/src/plugins/NextID/components/NextIdPage.tsx | 1 - .../plugin-infra/src/web3/useSocialAddressListAll.ts | 5 ++--- .../src/UI/components/CollectionDetailCard/index.tsx | 4 +--- packages/web3-providers/src/rss3/constants.ts | 9 +++++++++ packages/web3-shared/base/src/specs/index.ts | 2 ++ 8 files changed, 23 insertions(+), 10 deletions(-) rename packages/icons/{plugins => general}/WalletUnderTabs.svg (100%) diff --git a/packages/icons/plugins/WalletUnderTabs.svg b/packages/icons/general/WalletUnderTabs.svg similarity index 100% rename from packages/icons/plugins/WalletUnderTabs.svg rename to packages/icons/general/WalletUnderTabs.svg diff --git a/packages/mask/src/components/DataSource/useActivatedUI.ts b/packages/mask/src/components/DataSource/useActivatedUI.ts index 9af8b690cf03..3e5297d389fe 100644 --- a/packages/mask/src/components/DataSource/useActivatedUI.ts +++ b/packages/mask/src/components/DataSource/useActivatedUI.ts @@ -141,6 +141,7 @@ export function useCurrentVisitingSocialIdentity() { ) return { ...identity, + isOwner: isOwnerIdentity, publicKey: isOwnerIdentity ? persona?.identifier.publicKeyAsHex : first(sortedBindings)?.persona, hasBinding: !!bindings?.find((x) => x.persona === persona?.identifier.publicKeyAsHex.toLowerCase()), } diff --git a/packages/mask/src/plugins/Collectible/SNSAdaptor/NFTPage.tsx b/packages/mask/src/plugins/Collectible/SNSAdaptor/NFTPage.tsx index 16324ebb00d6..193309373a82 100644 --- a/packages/mask/src/plugins/Collectible/SNSAdaptor/NFTPage.tsx +++ b/packages/mask/src/plugins/Collectible/SNSAdaptor/NFTPage.tsx @@ -5,13 +5,18 @@ import { useCurrentVisitingProfile } from '../hooks/useContext' export interface NFTPageProps { identity?: SocialIdentity socialAddress?: SocialAddress - persona?: string } -export function NFTPage({ socialAddress, persona }: NFTPageProps) { +export function NFTPage({ socialAddress, identity }: NFTPageProps) { const currentVisitingProfile = useCurrentVisitingProfile() if (!socialAddress) return null - return + return ( + + ) } diff --git a/packages/mask/src/plugins/NextID/components/NextIdPage.tsx b/packages/mask/src/plugins/NextID/components/NextIdPage.tsx index de0b5b84c92b..b3a75bf2bbac 100644 --- a/packages/mask/src/plugins/NextID/components/NextIdPage.tsx +++ b/packages/mask/src/plugins/NextID/components/NextIdPage.tsx @@ -222,7 +222,6 @@ export function NextIdPage({ persona }: NextIdPageProps) { const handleAddWallets = () => { Services.Helper.openPopupWindow(PopupRoutes.ConnectedWallets, { - chainId, internal: true, }) } diff --git a/packages/plugin-infra/src/web3/useSocialAddressListAll.ts b/packages/plugin-infra/src/web3/useSocialAddressListAll.ts index 933c4850f497..56d1eecd589a 100644 --- a/packages/plugin-infra/src/web3/useSocialAddressListAll.ts +++ b/packages/plugin-infra/src/web3/useSocialAddressListAll.ts @@ -17,7 +17,6 @@ const addressCache = new LRUCache({ */ export function useSocialAddressListAll( identity?: SocialIdentity, - isOwnerIdentity?: boolean, includes?: SocialAddressType[], sorter?: (a: SocialAddress, z: SocialAddress) => number, ) { @@ -32,9 +31,9 @@ export function useSocialAddressListAll( if (!cached) { cached = Promise.allSettled( - [EVM_IdentityService, SolanaIdentityService].map((x) => x?.lookup(identity, isOwnerIdentity) ?? []), + [EVM_IdentityService, SolanaIdentityService].map((x) => x?.lookup(identity, identity.isOwner) ?? []), ) - if (!isOwnerIdentity) { + if (!identity.isOwner) { addressCache.set(userId, cached) } } diff --git a/packages/shared/src/UI/components/CollectionDetailCard/index.tsx b/packages/shared/src/UI/components/CollectionDetailCard/index.tsx index 5acd38f96523..1c0e56fe00c5 100644 --- a/packages/shared/src/UI/components/CollectionDetailCard/index.tsx +++ b/packages/shared/src/UI/components/CollectionDetailCard/index.tsx @@ -231,9 +231,7 @@ export const CollectionDetailCard = memo( {t.description()} -
- {description} -
+
{description}
{type === CollectionType.donations ? ( <> diff --git a/packages/web3-providers/src/rss3/constants.ts b/packages/web3-providers/src/rss3/constants.ts index 01bb11dd5836..61c79f8ce233 100644 --- a/packages/web3-providers/src/rss3/constants.ts +++ b/packages/web3-providers/src/rss3/constants.ts @@ -17,6 +17,15 @@ export const CollectionType = { footprint: /Mirror.XYZ|xDai.POAP/, } +export enum TAG { + NFT = 'NFT', + Token = 'Token', + POAP = 'POAP', + Gitcoin = 'Gitcoin', + Mirror = 'Mirror Entry', + ETH = 'ETH', +} + export enum NETWORK { ethereum = 'ethereum', ethereum_classic = 'ethereum_classic', diff --git a/packages/web3-shared/base/src/specs/index.ts b/packages/web3-shared/base/src/specs/index.ts index 4886ed1b0280..ed6ce499e710 100644 --- a/packages/web3-shared/base/src/specs/index.ts +++ b/packages/web3-shared/base/src/specs/index.ts @@ -130,6 +130,8 @@ export interface SocialIdentity { hasBinding?: boolean /** The public key of persona in hex */ publicKey?: string + /** Is own user account identity */ + isOwner?:boolean } export interface SocialAddress { From e74e71f04b5a20e7417e12eb71753337bbf535f3 Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Mon, 1 Aug 2022 13:58:50 +0800 Subject: [PATCH 175/179] fix: i18n --- .../src/SNSAdaptor/components/FeedCard.tsx | 29 ++++++++++++++----- .../src/SNSAdaptor/components/StatusBox.tsx | 6 ++-- .../src/SNSAdaptor/pages/DonationsPage.tsx | 2 +- .../RSS3/src/SNSAdaptor/pages/FeedPage.tsx | 2 +- .../src/SNSAdaptor/pages/FootprintPage.tsx | 2 +- packages/plugins/RSS3/src/locales/en-US.json | 14 ++++----- 6 files changed, 35 insertions(+), 20 deletions(-) diff --git a/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx b/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx index ba048547ab3f..0509e35b064f 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx @@ -100,18 +100,25 @@ export function FeedCard({ feed, address, onSelect }: FeedCardProps) { if (isSameAddress(feed.metadata?.from, address)) { return ( - {t.sent_a_NFT_to()} + {t.sent_an_NFT_to()}{' '} + ) } if (isZeroAddress(feed.metadata?.from)) { - return t.minted_a_NFT() + return t.minted_an_NFT() } if (isSameAddress(feed.metadata?.to, address)) { return ( - {t.acquired_a_NFT_from()}{' '} - + {t.acquired_an_NFT_from()}{' '} + ) } @@ -120,14 +127,22 @@ export function FeedCard({ feed, address, onSelect }: FeedCardProps) { if (isSameAddress(feed.metadata?.from, address)) { return ( - {t.sent_to()} + {t.sent_to()}{' '} + ) } if (isSameAddress(feed.metadata?.to, address)) { return ( - {t.received_from()} + {t.received_from()}{' '} + ) } @@ -213,7 +228,7 @@ export function FeedCard({ feed, address, onSelect }: FeedCardProps) {
- {action} + {action} {' '} {formatDistanceToNow(new Date(feed.date_updated))} {t.ago()} diff --git a/packages/plugins/RSS3/src/SNSAdaptor/components/StatusBox.tsx b/packages/plugins/RSS3/src/SNSAdaptor/components/StatusBox.tsx index 799221f4975a..8e634d3011ef 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/components/StatusBox.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/components/StatusBox.tsx @@ -6,7 +6,7 @@ import { useI18N } from '../../locales' interface Props { loading?: boolean empty?: boolean - collection?: string + description?: string } const useStyles = makeStyles()((theme) => ({ @@ -18,7 +18,7 @@ const useStyles = makeStyles()((theme) => ({ }, })) -export const StatusBox: FC = ({ loading, empty, collection = 'Donation' }) => { +export const StatusBox: FC = ({ loading, empty, description }) => { const { classes } = useStyles() const t = useI18N() if (loading) { @@ -32,7 +32,7 @@ export const StatusBox: FC = ({ loading, empty, collection = 'Donation' } if (empty) { return ( - {t.no_data({ collection })} + {description} ) } diff --git a/packages/plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx b/packages/plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx index a5465aac12c0..56f7dc90621a 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/pages/DonationsPage.tsx @@ -53,7 +53,7 @@ export function DonationPage({ donations = EMPTY_LIST, loading, address }: Donat const [selectedDonation, setSelectedDonation] = useState() if (loading || !donations.length) { - return + return } return ( diff --git a/packages/plugins/RSS3/src/SNSAdaptor/pages/FeedPage.tsx b/packages/plugins/RSS3/src/SNSAdaptor/pages/FeedPage.tsx index bdd51a346c8a..f5351dd4b3e4 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/pages/FeedPage.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/pages/FeedPage.tsx @@ -22,7 +22,7 @@ export function FeedPage({ socialAddress }: FeedPageProps) { if (!socialAddress) return null if (loading || !feed?.list?.length) { - return + return } return ( diff --git a/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx b/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx index d7d8915e4c44..a192cf221126 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx @@ -24,7 +24,7 @@ export function FootprintPage({ footprints = EMPTY_LIST, address, loading }: Foo const [selectedFootprint, setSelectedFootprint] = useState() if (loading || !footprints.length) { - return + return } return ( diff --git a/packages/plugins/RSS3/src/locales/en-US.json b/packages/plugins/RSS3/src/locales/en-US.json index 86820193d6a3..b93e38f20dba 100644 --- a/packages/plugins/RSS3/src/locales/en-US.json +++ b/packages/plugins/RSS3/src/locales/en-US.json @@ -3,19 +3,19 @@ "no_activity_time": "No activity time", "attended": "attended", "no_data": "No {{collection}} found.", + "no_NFT_found": "No NFTs found.", + "no_Feed_found": "No Feeds found.", + "no_Donation_found": "No Donations found.", + "no_Footprint_found": "no Footprints found.", "total_grants": "Total {{count}} Grants", "contribution": "Contribution", "contribution_other": "Contributions", "contributed": "contributed", "to": "to", - "day": "day", - "hour": "hour", - "days": "days", - "hours": "hours", "ago": "ago", - "sent_a_NFT_to": "sent a NFT to", - "minted_a_NFT": "minted a NFT", - "acquired_a_NFT_from": "acquired a NFT from", + "sent_an_NFT_to": "sent an NFT to", + "minted_an_NFT": "minted an NFT", + "acquired_an_NFT_from": "acquired an NFT from", "sent_to": "sent to", "received_from": "received from", "donated": "donated", From 325ad93f502a24021e2dffc5b7ebaefe71cc44e5 Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Mon, 1 Aug 2022 13:59:45 +0800 Subject: [PATCH 176/179] feat: change feed api url --- packages/web3-providers/src/rss3/index.ts | 16 +++++++++------- packages/web3-providers/src/types/RSS3.ts | 5 ++--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/packages/web3-providers/src/rss3/index.ts b/packages/web3-providers/src/rss3/index.ts index 8e05f21c1b3c..af72f145a201 100644 --- a/packages/web3-providers/src/rss3/index.ts +++ b/packages/web3-providers/src/rss3/index.ts @@ -115,14 +115,16 @@ export class RSS3API implements RSS3BaseAPI.Provider, NonFungibleTokenAPI.Provid return createPageable(data, createIndicator(indicator)) } - async getWeb3Feed( - address: string, - type?: RSS3BaseAPI.FeedType, - { networkPluginId = NetworkPluginID.PLUGIN_EVM }: HubOptions = {}, - ) { + async getWeb3Feed(address: string, type?: RSS3BaseAPI.FeedType, networkPluginId = NetworkPluginID.PLUGIN_EVM) { if (!address) return - const url = `${RSS3_FEED_ENDPOINT}account:${address}@${NETWORK_PLUGIN[networkPluginId]}/notes?limit=100&exclude_tags=POAP&tags=Gitcoin&tags=POAP&tags=NFT&tags=Donation&latest=false` - const res = fetchJSON(url) + const url = urlcat(RSS3_FEED_ENDPOINT, 'account::address@:network/notes', { + address, + network: NETWORK_PLUGIN[networkPluginId], + limit: 100, + exclude_tags: TAG.POAP, + latest: false, + }) + const res = fetchJSON(url + '&tags=Gitcoin&tags=POAP&tags=NFT&tags=Donation') return res } } diff --git a/packages/web3-providers/src/types/RSS3.ts b/packages/web3-providers/src/types/RSS3.ts index 8c668f829202..c2527a3c3155 100644 --- a/packages/web3-providers/src/types/RSS3.ts +++ b/packages/web3-providers/src/types/RSS3.ts @@ -1,5 +1,4 @@ -import type { HubOptions } from '@masknet/web3-shared-base' -import type { ChainId } from '@masknet/web3-shared-evm' +import type { NetworkPluginID } from '@masknet/web3-shared-base' import type BigNumber from 'bignumber.js' import type RSS3 from 'rss3-next' @@ -228,7 +227,7 @@ export namespace RSS3BaseAPI { getWeb3Feed( address: string, type?: FeedType, - option?: HubOptions, + networkPluginId?: NetworkPluginID, ): Promise } } From b43070aa95b9cf3e439007a8822b814ed01e8caa Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Mon, 1 Aug 2022 14:08:43 +0800 Subject: [PATCH 177/179] fix: i18n error --- packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx | 2 +- packages/plugins/RSS3/src/locales/en-US.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx b/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx index a192cf221126..bdc603ab3001 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/pages/FootprintPage.tsx @@ -24,7 +24,7 @@ export function FootprintPage({ footprints = EMPTY_LIST, address, loading }: Foo const [selectedFootprint, setSelectedFootprint] = useState() if (loading || !footprints.length) { - return + return } return ( diff --git a/packages/plugins/RSS3/src/locales/en-US.json b/packages/plugins/RSS3/src/locales/en-US.json index b93e38f20dba..5f9ee37377e9 100644 --- a/packages/plugins/RSS3/src/locales/en-US.json +++ b/packages/plugins/RSS3/src/locales/en-US.json @@ -6,7 +6,7 @@ "no_NFT_found": "No NFTs found.", "no_Feed_found": "No Feeds found.", "no_Donation_found": "No Donations found.", - "no_Footprint_found": "no Footprints found.", + "no_Footprint_found": "No Footprints found.", "total_grants": "Total {{count}} Grants", "contribution": "Contribution", "contribution_other": "Contributions", From d805447f7692fb00ef644f14180e24048d44f9bd Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Mon, 1 Aug 2022 14:57:30 +0800 Subject: [PATCH 178/179] fix: code style --- packages/plugin-infra/src/web3-state/Identity.ts | 4 ++-- packages/plugin-infra/src/web3/useSocialAddressListAll.ts | 2 +- packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx | 4 +--- packages/web3-shared/base/src/specs/index.ts | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/plugin-infra/src/web3-state/Identity.ts b/packages/plugin-infra/src/web3-state/Identity.ts index d0cf2f863488..a692ae445ed9 100644 --- a/packages/plugin-infra/src/web3-state/Identity.ts +++ b/packages/plugin-infra/src/web3-state/Identity.ts @@ -26,7 +26,7 @@ export class IdentityServiceState implements Web3SocialIdentityState { throw new Error('Method not implemented.') } - async lookup(identity: SocialIdentity, isOwnerIdentity = false): Promise>> { + async lookup(identity: SocialIdentity): Promise>> { const ID = this.getIdentityID(identity) if (!ID) return EMPTY_LIST @@ -34,7 +34,7 @@ export class IdentityServiceState implements Web3SocialIdentityState { if (fromCache) return fromCache const fromRemote = this.getFromRemote(identity) - if (!isOwnerIdentity) { + if (!identity.isOwner) { this.cache.set(ID, fromRemote) } diff --git a/packages/plugin-infra/src/web3/useSocialAddressListAll.ts b/packages/plugin-infra/src/web3/useSocialAddressListAll.ts index 56d1eecd589a..7b6134513b45 100644 --- a/packages/plugin-infra/src/web3/useSocialAddressListAll.ts +++ b/packages/plugin-infra/src/web3/useSocialAddressListAll.ts @@ -31,7 +31,7 @@ export function useSocialAddressListAll( if (!cached) { cached = Promise.allSettled( - [EVM_IdentityService, SolanaIdentityService].map((x) => x?.lookup(identity, identity.isOwner) ?? []), + [EVM_IdentityService, SolanaIdentityService].map((x) => x?.lookup(identity) ?? []), ) if (!identity.isOwner) { addressCache.set(userId, cached) diff --git a/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx b/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx index 0509e35b064f..9e497798b61b 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/components/FeedCard.tsx @@ -35,11 +35,9 @@ const useStyles = makeStyles()((theme) => ({ summary: { textOverflow: 'ellipsis', - '-webkit-line-clamp': '1', maxWidth: '400px', overflow: 'hidden', - display: '-webkit-box', - '-webkit-box-orient': 'vertical', + whiteSpace: 'nowrap', color: theme.palette.maskColor.main, }, defaultImage: { diff --git a/packages/web3-shared/base/src/specs/index.ts b/packages/web3-shared/base/src/specs/index.ts index ed6ce499e710..014f44334c6c 100644 --- a/packages/web3-shared/base/src/specs/index.ts +++ b/packages/web3-shared/base/src/specs/index.ts @@ -1089,7 +1089,7 @@ export interface HubState< export interface IdentityServiceState { /** Find all social addresses related to the given identity. */ - lookup(identity: SocialIdentity, isOwnerIdentity?:boolean): Promise>> + lookup(identity: SocialIdentity): Promise>> } export interface NameServiceState { /** get address of domain name */ From 966007b8fffd8fd4890a3e081b1d128683bc44ac Mon Sep 17 00:00:00 2001 From: Randolph <840094513@qq.com> Date: Mon, 1 Aug 2022 15:01:34 +0800 Subject: [PATCH 179/179] fix: code style --- packages/web3-shared/base/src/specs/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/web3-shared/base/src/specs/index.ts b/packages/web3-shared/base/src/specs/index.ts index 014f44334c6c..fcdb579f242e 100644 --- a/packages/web3-shared/base/src/specs/index.ts +++ b/packages/web3-shared/base/src/specs/index.ts @@ -131,7 +131,7 @@ export interface SocialIdentity { /** The public key of persona in hex */ publicKey?: string /** Is own user account identity */ - isOwner?:boolean + isOwner?: boolean } export interface SocialAddress {