import React from "react"; 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 MetaplexNFTHeader({ nftData, address, }: { 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), "parsed"); } }, [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 (
{
Metaplex NFT
}

{metadata.data.name !== "" ? metadata.data.name : "No NFT name was found"}

{getEditionPill(nftData.editionInfo)} {isVerifiedCollection ? getVerifiedCollectionPill() : null}

{metadata.data.symbol !== "" ? metadata.data.symbol : "No Symbol was found"}

{getSaleTypePill(metadata.primarySaleHappened)}
{getIsMutablePill(metadata.isMutable)}
{getCreatorDropdownItems(metadata.data.creators)}
); } type Creator = programs.metadata.Creator; function getCreatorDropdownItems(creators: Creator[] | null) { const CreatorHeader = () => { const creatorTooltip = "Verified creators signed the metadata associated with this NFT when it was created."; const shareTooltip = "The percentage of the proceeds a creator receives when this NFT is sold."; return (
Creator Address
Royalty
); }; const getVerifiedIcon = (isVerified: boolean) => { const className = isVerified ? "fe fe-check" : "fe fe-alert-octagon"; return ; }; const CreatorEntry = (creator: Creator) => { return (
{getVerifiedIcon(creator.verified)} {creator.address}
{`${creator.share}%`}
); }; if (creators && creators.length > 0) { let listOfCreators: JSX.Element[] = []; listOfCreators.push(); creators.forEach((creator) => { listOfCreators.push(); }); return listOfCreators; } return (
No creators are associated with this NFT.
); } function getEditionPill(editionInfo: EditionInfo) { const masterEdition = editionInfo.masterEdition; const edition = editionInfo.edition; return (
{`${ edition && masterEdition ? `Edition ${edition.edition.toNumber()} / ${masterEdition.supply.toNumber()}` : masterEdition ? "Master Edition" : "No Master Edition Information" }`}
); } function getSaleTypePill(hasPrimarySaleHappened: boolean) { const primaryMarketTooltip = "Creator(s) split 100% of the proceeds when this NFT is sold."; const secondaryMarketTooltip = "Creator(s) split the Seller Fee when this NFT is sold. The owner receives the remaining proceeds."; return (
{`${ hasPrimarySaleHappened ? "Secondary Market" : "Primary Market" }`}
); } function getIsMutablePill(isMutable: boolean) { return ( {`${ isMutable ? "Mutable" : "Immutable" }`} ); } function getVerifiedCollectionPill() { const onchainVerifiedToolTip = "This NFT has been verified as a member of an on-chain collection. This tag guarantees authenticity."; return (
{"Verified Collection"}
); }