From 4baefa5dae67c9f0e77a694c2ba287ad9f780e63 Mon Sep 17 00:00:00 2001 From: MananTank Date: Wed, 23 Apr 2025 13:20:53 +0000 Subject: [PATCH] Dashboard: transfer tab disabled for owner of nft (#6827) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ## PR-Codex overview This PR enhances the `useNFTDrawerTabs` function by improving the owner address comparison for NFTs. It now uses the `checksumAddress` utility to ensure that both the NFT owner and the account address are valid checksummed addresses before comparing them. ### Detailed summary - Added import for `checksumAddress` from `thirdweb/utils`. - Updated the owner address comparison in the `useNFTDrawerTabs` function to use `checksumAddress`. - Ensured that both `accountAddress` and `nft.owner` are checked for validity before comparison. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` --- .../[contractAddress]/nfts/[tokenId]/useNftDrawerTabs.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/nfts/[tokenId]/useNftDrawerTabs.tsx b/apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/nfts/[tokenId]/useNftDrawerTabs.tsx index 6d85dc6b6da..8eb81def2ff 100644 --- a/apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/nfts/[tokenId]/useNftDrawerTabs.tsx +++ b/apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/nfts/[tokenId]/useNftDrawerTabs.tsx @@ -6,6 +6,7 @@ import type { ThirdwebContract } from "thirdweb"; import * as ERC721Ext from "thirdweb/extensions/erc721"; import * as ERC1155Ext from "thirdweb/extensions/erc1155"; import { useReadContract } from "thirdweb/react"; +import { checksumAddress } from "thirdweb/utils"; import type { NFTDrawerTab } from "./types"; type UseNFTDrawerTabsParams = { @@ -108,7 +109,11 @@ export function useNFTDrawerTabs({ return true; } if (isERC721) { - return nft?.owner === accountAddress; + return ( + accountAddress && + nft?.owner && + checksumAddress(nft.owner) === checksumAddress(accountAddress) + ); } return false; })();