From ba771cdc45b361d8d518f13df8e68736460c0027 Mon Sep 17 00:00:00 2001 From: Will Roeder Date: Fri, 4 Mar 2022 18:35:35 -0800 Subject: [PATCH] feat(explorer): adding verified on-chain collection support (#23490) * Adding Verified On-chain Collection tag to help consumers check if their NFTs are authentic * On-chain isn't quite the same as NO-chain * Grammar fix * Added Collection Owner verification to guarantee this is actually a Collection Mint --- .../components/account/MetaplexNFTHeader.tsx | 34 ++++++++++++++++++- .../account/TokenAccountSection.tsx | 12 +++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/explorer/src/components/account/MetaplexNFTHeader.tsx b/explorer/src/components/account/MetaplexNFTHeader.tsx index f60d54db39..a2acfb3e75 100644 --- a/explorer/src/components/account/MetaplexNFTHeader.tsx +++ b/explorer/src/components/account/MetaplexNFTHeader.tsx @@ -1,11 +1,17 @@ +import React from "react"; import "bootstrap/dist/js/bootstrap.min.js"; -import { NFTData } from "providers/accounts"; +import { + NFTData, + useFetchAccountInfo, + useMintAccountInfo, +} from "providers/accounts"; import { programs } from "@metaplex/js"; import { ArtContent } from "components/common/NFTArt"; import { InfoTooltip } from "components/common/InfoTooltip"; import { clusterPath } from "utils/url"; import { Link } from "react-router-dom"; import { EditionInfo } from "providers/accounts/utils/getEditionInfo"; +import { PublicKey } from "@solana/web3.js"; export function NFTHeader({ nftData, @@ -14,8 +20,22 @@ export function NFTHeader({ nftData: NFTData; address: string; }) { + const collectionAddress = nftData.metadata.collection?.key; + const collectionMintInfo = useMintAccountInfo(collectionAddress); + const fetchAccountInfo = useFetchAccountInfo(); + + React.useEffect(() => { + if (collectionAddress && !collectionMintInfo) { + fetchAccountInfo(new PublicKey(collectionAddress)); + } + }, [fetchAccountInfo, collectionAddress]); // eslint-disable-line react-hooks/exhaustive-deps + const metadata = nftData.metadata; const data = nftData.json; + const isVerifiedCollection = + metadata.collection != null && + metadata.collection?.verified && + collectionMintInfo !== undefined; return (
@@ -30,6 +50,7 @@ export function NFTHeader({ : "No NFT name was found"} {getEditionPill(nftData.editionInfo)} + {isVerifiedCollection && getVerifiedCollectionPill()}

{metadata.data.symbol !== "" @@ -174,3 +195,14 @@ function getIsMutablePill(isMutable: boolean) { }`} ); } + +function getVerifiedCollectionPill() { + const onchainVerifiedToolTip = + "This NFT has been verified as a member of an on-chain collection. This tag guarantees authenticity."; + return ( +
+ {"Verified Collection"} + +
+ ); +} diff --git a/explorer/src/components/account/TokenAccountSection.tsx b/explorer/src/components/account/TokenAccountSection.tsx index 2023e612ee..e798388ba1 100644 --- a/explorer/src/components/account/TokenAccountSection.tsx +++ b/explorer/src/components/account/TokenAccountSection.tsx @@ -343,6 +343,18 @@ function NonFungibleTokenMintAccountCard({ )} + {nftData?.metadata.collection?.verified && ( + + Verified Collection Address + +
+ + + )} {mintInfo.mintAuthority && ( Mint Authority