Skip to content

Commit db71142

Browse files
committed
[Dashboard] Add tokenURI section to the NFT page
1 parent 623543e commit db71142

File tree

2 files changed

+33
-2
lines changed
  • apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/nfts/[tokenId]
  • packages/thirdweb/src/extensions/erc1155/write

2 files changed

+33
-2
lines changed

apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/nfts/[tokenId]/token-id.tsx

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
"use client";
22

33
import { WalletAddress } from "@/components/blocks/wallet-address";
4+
import { CopyTextButton } from "@/components/ui/CopyTextButton";
45
import { Spinner } from "@/components/ui/Spinner/Spinner";
6+
import { useThirdwebClient } from "@/constants/thirdweb.client";
57
import { useDashboardRouter } from "@/lib/DashboardRouter";
68
import {
79
Box,
@@ -15,15 +17,18 @@ import {
1517
useBreakpointValue,
1618
} from "@chakra-ui/react";
1719
import { useChainSlug } from "hooks/chains/chainSlug";
18-
import { ChevronLeftIcon } from "lucide-react";
20+
import { ChevronLeftIcon, ExternalLinkIcon } from "lucide-react";
21+
import Link from "next/link";
1922
import { useState } from "react";
2023
import type { ThirdwebContract } from "thirdweb";
2124
import { getNFT as getErc721NFT } from "thirdweb/extensions/erc721";
2225
import { getNFT as getErc1155NFT } from "thirdweb/extensions/erc1155";
2326
import { useReadContract } from "thirdweb/react";
27+
import { resolveScheme } from "thirdweb/storage";
2428
import { Badge, Button, Card, CodeBlock, Heading, Text } from "tw-components";
2529
import { AddressCopyButton } from "tw-components/AddressCopyButton";
2630
import { NFTMediaWithEmptyState } from "tw-components/nft-media";
31+
import { shortenString } from "utils/usedapp-external";
2732
import { NftProperty } from "../components/nft-property";
2833
import { useNFTDrawerTabs } from "./useNftDrawerTabs";
2934

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

73+
const client = useThirdwebClient();
74+
6875
const { data: nft, isPending } = useReadContract(
6976
isErc721 ? getErc721NFT : getErc1155NFT,
7077
{
@@ -240,6 +247,28 @@ export const TokenIdPage: React.FC<TokenIdPageProps> = ({
240247
</GridItem>
241248
</>
242249
)}
250+
<GridItem colSpan={4}>
251+
<Heading size="label.md">Token URI</Heading>
252+
</GridItem>
253+
<GridItem
254+
colSpan={8}
255+
className="flex flex-row items-center gap-2"
256+
>
257+
<CopyTextButton
258+
textToCopy={nft.tokenURI}
259+
textToShow={shortenString(nft.tokenURI)}
260+
tooltip="The URI of this NFT"
261+
copyIconPosition="right"
262+
/>
263+
<Button>
264+
<Link
265+
href={resolveScheme({ client, uri: nft.tokenURI })}
266+
target="_blank"
267+
>
268+
<ExternalLinkIcon className="size-4" />
269+
</Link>
270+
</Button>
271+
</GridItem>
243272
</SimpleGrid>
244273
</Card>
245274
{properties ? (

packages/thirdweb/src/extensions/erc1155/write/mintToBatch.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ describe("ERC1155 Edition: mintToBatch", () => {
3030
}),
3131
});
3232

33-
await sendAndConfirmTransaction({
33+
const tx = await sendAndConfirmTransaction({
3434
account,
3535
transaction: mintToBatch({
3636
contract,
@@ -43,6 +43,8 @@ describe("ERC1155 Edition: mintToBatch", () => {
4343
}),
4444
});
4545

46+
console.log(tx);
47+
4648
const nfts = await getNFTs({ contract });
4749
expect(nfts).toStrictEqual([
4850
{

0 commit comments

Comments
 (0)