diff --git a/packages/dashboard/src/pages/Wallets/components/CollectibleCard/index.tsx b/packages/dashboard/src/pages/Wallets/components/CollectibleCard/index.tsx index d93330ba10b8..90ba18321f86 100644 --- a/packages/dashboard/src/pages/Wallets/components/CollectibleCard/index.tsx +++ b/packages/dashboard/src/pages/Wallets/components/CollectibleCard/index.tsx @@ -4,7 +4,7 @@ import { makeStyles, MaskColorVar } from '@masknet/theme' import { CollectiblePlaceholder } from '../CollectiblePlaceHolder' import { useHoverDirty } from 'react-use' import { useDashboardI18N } from '../../../../locales' -import { WalletIcon } from '@masknet/shared' +import { WalletIcon, NFTCardStyledAssetPlayer } from '@masknet/shared' import { ChangeNetworkTip } from '../FungibleTokenTableRow/ChangeNetworkTip' import { useNetworkDescriptor, useWeb3State, Web3Plugin } from '@masknet/plugin-infra' @@ -29,7 +29,9 @@ const useStyles = makeStyles()((theme) => ({ flexDirection: 'column', overflow: 'hidden', }, - imgContainer: { + mediaContainer: { + position: 'absolute', + zIndex: 1, width: '100%', height: 186, backgroundColor: theme.palette.mode === 'dark' ? MaskColorVar.lineLight : '#f6f6f7', @@ -50,6 +52,7 @@ const useStyles = makeStyles()((theme) => ({ top: 8, height: 20, width: 20, + zIndex: 20, }, tip: { padding: theme.spacing(1), @@ -58,15 +61,40 @@ const useStyles = makeStyles()((theme) => ({ tipArrow: { color: '#111432', }, + loadingFailImage: { + minHeight: '0px !important', + maxWidth: 'none', + transform: 'translateY(10px)', + width: 64, + height: 64, + }, + wrapper: { + width: '100%', + minWidth: 140, + height: '100%', + minHeight: 186, + }, + linkWrapper: { + position: 'relative', + width: 140, + height: 186, + }, + blocker: { + position: 'absolute', + zIndex: 2, + width: 140, + height: 186, + }, })) export interface CollectibleCardProps { chainId: number token: Web3Plugin.NonFungibleToken onSend(): void + renderOrder: number } -export const CollectibleCard = memo(({ chainId, token, onSend }) => { +export const CollectibleCard = memo(({ chainId, token, onSend, renderOrder }) => { const t = useDashboardI18N() const { Utils } = useWeb3State() const { classes } = useStyles() @@ -90,6 +118,7 @@ export const CollectibleCard = memo(({ chainId, token, onS (({ chainId, token, onS token.tokenId, ) ?? '#' }> -
- +
+
diff --git a/packages/dashboard/src/pages/Wallets/components/CollectibleList/index.tsx b/packages/dashboard/src/pages/Wallets/components/CollectibleList/index.tsx index 0441a890108a..3e658d457ce4 100644 --- a/packages/dashboard/src/pages/Wallets/components/CollectibleList/index.tsx +++ b/packages/dashboard/src/pages/Wallets/components/CollectibleList/index.tsx @@ -151,11 +151,12 @@ export const CollectibleListUI = memo( ) : (
- {dataSource.map((x) => ( -
+ {dataSource.map((x, index) => ( +
onSend(x as unknown as any)} /> @@ -164,6 +165,7 @@ export const CollectibleListUI = memo(
)} + {showPagination ? ( (({ token, selectedTokenId, onSelect }) => { +export const NFTCard = memo(({ token, selectedTokenId, onSelect, renderOrder }) => { const { classes } = useStyles() - const [loadFailed, setLoadFailed] = useState(false) const [checked, setChecked] = useState(!!selectedTokenId && selectedTokenId === token.tokenId) - + const [name, setName] = useState(token.tokenId) const isDisabled = useMemo( () => !!selectedTokenId && selectedTokenId !== token.tokenId, [selectedTokenId, token.tokenId], @@ -68,11 +86,11 @@ export const NFTCard = memo(({ token, selectedTokenId, onSelect }) background: (theme) => (theme.palette.mode === 'dark' ? MaskColorVar.primaryBackground : '#F9F9FA'), }} classes={{ titleWrap: classes.barTitle }} - subtitle={{token.info.name || token.tokenId}} + subtitle={{name}} position="below" /> ) - }, [token.info.name, token.tokenId]) + }, [name]) return ( (({ token, selectedTokenId, onSelect }) background: (theme) => (theme.palette.mode === 'dark' ? getMaskColor(theme).white : '#F9F9FA'), }} className={isDisabled ? classes.disabled : ''}> - {loadFailed || !token.info.mediaUrl ? ( -
-
- -
-
- ) : ( - setLoadFailed(true)} - src={token.info.mediaUrl} - style={{ width: '100%', height: '100%', borderRadius: '8px 8px 0px 0px', objectFit: 'cover' }} - /> - )} + {NFTNameBar} (({ list, onSelect, selecte gap={12} rowHeight={186} sx={{ width: '100%', height: 'auto', maxHeight: '400px', p: 2, pb: 0.5 }}> - {list.map((token) => ( - + {list.map((token, index) => ( + ))} {renderStatus} diff --git a/packages/icons/brands/MaskPlaceholder.tsx b/packages/icons/brands/MaskPlaceholder.tsx new file mode 100644 index 000000000000..39b7570cf014 --- /dev/null +++ b/packages/icons/brands/MaskPlaceholder.tsx @@ -0,0 +1,33 @@ +import { createPaletteAwareIcon } from '../utils' + +export const MaskPlaceholder = createPaletteAwareIcon( + 'MaskPlaceholder', + + + + , + + + + , + + + + , + '0 0 36 36', +) diff --git a/packages/icons/brands/index.ts b/packages/icons/brands/index.ts index 2d8d1107f11c..107479bd226b 100644 --- a/packages/icons/brands/index.ts +++ b/packages/icons/brands/index.ts @@ -11,3 +11,4 @@ export * from './MaskBlue' export * from './MaskGrey' export * from './Discord' export * from './MaskBanner' +export * from './MaskPlaceholder' diff --git a/packages/mask/src/extension/background-script/EthereumServices/send.ts b/packages/mask/src/extension/background-script/EthereumServices/send.ts index 06bf047d50b0..797977f16cbc 100644 --- a/packages/mask/src/extension/background-script/EthereumServices/send.ts +++ b/packages/mask/src/extension/background-script/EthereumServices/send.ts @@ -288,7 +288,7 @@ export async function INTERNAL_send( // the estimation of metamask of `maxFeePerGas` = 1 * block.baseFeePerGas, // since the estimation of web3.js = 2 * block.baseFeePerGas which is too high // that would almost always causes an undesired warning tip. - if (Flags.EIP1559_enabled && isEIP1559Valid) { + if (Flags.EIP1559_enabled && isEIP1559Valid && isEIP1559Supported(chainIdFinally)) { config.gasPrice = undefined config.maxPriorityFeePerGas = formatGweiToWei(1.5).toString(16) config.maxFeePerGas = (Number.parseInt(config.maxFeePerGas!, 16) * 0.8).toString(16) 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 fce271edfd8b..7386acd3af68 100644 --- a/packages/mask/src/extension/options-page/DashboardComponents/CollectibleList/CollectibleCard.tsx +++ b/packages/mask/src/extension/options-page/DashboardComponents/CollectibleList/CollectibleCard.tsx @@ -1,11 +1,9 @@ -import { useAsyncRetry } from 'react-use' -import { Card, CircularProgress, Link } from '@mui/material' +import { Card, Link } from '@mui/material' import { makeStyles } from '@masknet/theme' import { Wallet, ERC721TokenDetailed, resolveCollectibleLink, NonFungibleAssetProvider } from '@masknet/web3-shared-evm' import { MaskSharpIconOfSize } from '../../../../resources/MaskIcon' +import { NFTCardStyledAssetPlayer } from '@masknet/shared' import { ActionsBarNFT } from '../ActionsBarNFT' -import { Video } from '../../../../components/shared/Video' -import { Image } from '../../../../components/shared/Image' const useStyles = makeStyles()((theme) => ({ root: { @@ -13,8 +11,9 @@ const useStyles = makeStyles()((theme) => ({ alignItems: 'center', justifyContent: 'center', borderRadius: 4, - position: 'relative', - backgroundColor: theme.palette.background.paper, + position: 'absolute', + zIndex: 1, + backgroundColor: theme.palette.background.default, width: 172, height: 172, }, @@ -31,7 +30,24 @@ const useStyles = makeStyles()((theme) => ({ height: 64, opacity: 0.1, }, - video: { + loadingFailImage: { + minHeight: '0px !important', + maxWidth: 'none', + width: 64, + height: 64, + }, + wrapper: { + width: '172px !important', + height: '172px !important', + }, + blocker: { + position: 'absolute', + zIndex: 2, + width: 172, + height: 172, + }, + linkWrapper: { + position: 'relative', width: 172, height: 172, }, @@ -42,65 +58,40 @@ export interface CollectibleCardProps { wallet?: Wallet token: ERC721TokenDetailed readonly?: boolean + renderOrder: number } -const videoTypeRe = /\.(mp4|mp3|m4v|ogg)$/i - export function CollectibleCard(props: CollectibleCardProps) { - const { wallet, token, provider, readonly } = props + const { wallet, token, provider, readonly, renderOrder } = props const { classes } = useStyles() - const mediaUrl = token.info.mediaUrl - const { loading, value } = useAsyncRetry(async () => { - if (!mediaUrl) return - - const blob = await (await fetch(mediaUrl)).blob() - return blob - }, [mediaUrl]) - - const mimeType = value?.type || '' - // some video resources response content-type not video, e.g. application/octet-stream - const isVideo = mediaUrl ? videoTypeRe.test(mediaUrl) || mimeType.startsWith('video') : undefined - const isHtml = mimeType.startsWith('text') - return ( - <> - {loading ? ( - - - - ) : ( - - - {readonly || !wallet ? null : ( - - )} - {token.info.mediaUrl ? ( - isVideo ? ( -