Skip to content

Commit

Permalink
Only show NFTs owned by current principal or wallet address on Verify…
Browse files Browse the repository at this point in the history
… page
  • Loading branch information
rvanasa committed Aug 24, 2023
1 parent 13a52f2 commit 67af713
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/components/NftCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,20 @@ export default function NftCard({ nft, principal, time }: NftCardProps) {
nft.network === 'sepolia' ? 'testnets.' : ''
}opensea.io/assets/${nft.network}/${nft.contract}/${nft.tokenId}`;

console.log(metadata); ///
if (!metadata) {
return null;
}
return (
<a
tw="p-5 bg-white rounded-3xl space-y-3 drop-shadow-2xl cursor-pointer block"
tw="block p-5 bg-white rounded-3xl space-y-3 drop-shadow-2xl cursor-pointer"
href={url}
target="_blank"
rel="noreferrer"
>
{metadata.tokenType === 'NOT_A_CONTRACT' && (
<div tw="text-xl opacity-60">(Not found)</div>
)}
<div tw="flex items-center gap-3">
{!!metadata.media.length && (
<img
Expand Down
10 changes: 8 additions & 2 deletions src/components/WalletArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,20 @@ export default function WalletArea() {
const [nftUrl, setNftUrl] = useSessionStorage('ic-eth.nft-url', '');
const [nftResult, setNftResult] = useState<{ nft: Nft } | { err: string }>();
const [isNftValid, setNftValid] = useState<boolean>();
const nfts = usePublicNfts();

const address = (ethereum?.selectedAddress as string | undefined) || '';
const [isAddressVerified, verifyAddress] = useAddressVerified(
address,
ethereum,
);

const principalString = user?.client.getIdentity().getPrincipal().toString();
const nfts = usePublicNfts();
const ownedNfts =
nfts?.filter(
(nft) => nft.principal === principalString || nft.wallet === address,
) || [];

const parseOpenSeaNft = (nftUrl: string) => {
const groups =
/^https:\/\/(testnets\.)?opensea\.io\/assets\/(\w+)\/(\w+)\/(\d+)/.exec(
Expand Down Expand Up @@ -308,7 +314,7 @@ export default function WalletArea() {
<>
<hr tw="my-5" />
<div tw="text-xl text-gray-600 mb-3">Previously verified:</div>
<NftList items={nfts} />
<NftList items={ownedNfts} />
</>
)}
</>
Expand Down

0 comments on commit 67af713

Please sign in to comment.