Skip to content

[Dashboard] Add tokenURI section to the NFT page #5035

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
"use client";

import { WalletAddress } from "@/components/blocks/wallet-address";
import { CopyTextButton } from "@/components/ui/CopyTextButton";
import { Spinner } from "@/components/ui/Spinner/Spinner";
import { useThirdwebClient } from "@/constants/thirdweb.client";
import { useDashboardRouter } from "@/lib/DashboardRouter";
import {
Box,
Expand All @@ -15,15 +17,18 @@ import {
useBreakpointValue,
} from "@chakra-ui/react";
import { useChainSlug } from "hooks/chains/chainSlug";
import { ChevronLeftIcon } from "lucide-react";
import { ChevronLeftIcon, ExternalLinkIcon } from "lucide-react";
import Link from "next/link";
import { useState } from "react";
import type { ThirdwebContract } from "thirdweb";
import { getNFT as getErc721NFT } from "thirdweb/extensions/erc721";
import { getNFT as getErc1155NFT } from "thirdweb/extensions/erc1155";
import { useReadContract } from "thirdweb/react";
import { resolveScheme } from "thirdweb/storage";
import { Badge, Button, Card, CodeBlock, Heading, Text } from "tw-components";
import { AddressCopyButton } from "tw-components/AddressCopyButton";
import { NFTMediaWithEmptyState } from "tw-components/nft-media";
import { shortenString } from "utils/usedapp-external";
import { NftProperty } from "../components/nft-property";
import { useNFTDrawerTabs } from "./useNftDrawerTabs";

Expand Down Expand Up @@ -65,6 +70,8 @@ export const TokenIdPage: React.FC<TokenIdPageProps> = ({
tokenId,
});

const client = useThirdwebClient();

const { data: nft, isPending } = useReadContract(
isErc721 ? getErc721NFT : getErc1155NFT,
{
Expand Down Expand Up @@ -240,6 +247,28 @@ export const TokenIdPage: React.FC<TokenIdPageProps> = ({
</GridItem>
</>
)}
<GridItem colSpan={4}>
<Heading size="label.md">Token URI</Heading>
</GridItem>
<GridItem
colSpan={8}
className="flex flex-row items-center gap-1"
>
<CopyTextButton
textToCopy={nft.tokenURI}
textToShow={shortenString(nft.tokenURI)}
tooltip="The URI of this NFT"
copyIconPosition="right"
/>
<Button variant="ghost">
<Link
href={resolveScheme({ client, uri: nft.tokenURI })}
target="_blank"
>
<ExternalLinkIcon className="size-4" />
</Link>
</Button>
</GridItem>
</SimpleGrid>
</Card>
{properties ? (
Expand Down
Loading