From 7310c2e432323e7cb13342bd5261a0cc484e1b51 Mon Sep 17 00:00:00 2001 From: Jacob Homanics Date: Sat, 24 Feb 2024 23:01:29 -0600 Subject: [PATCH] formatted --- .../blockexplorer/address/[address]/page.tsx | 3 +- packages/nextjs/app/page.tsx | 71 ++++++++----------- packages/nextjs/components/nft-card/Hooks.tsx | 69 +++++++++--------- .../nextjs/components/nft-card/nftCard.tsx | 48 ++++++------- 4 files changed, 86 insertions(+), 105 deletions(-) diff --git a/packages/nextjs/app/blockexplorer/address/[address]/page.tsx b/packages/nextjs/app/blockexplorer/address/[address]/page.tsx index 109f7e4..2f8dc26 100644 --- a/packages/nextjs/app/blockexplorer/address/[address]/page.tsx +++ b/packages/nextjs/app/blockexplorer/address/[address]/page.tsx @@ -1,4 +1,3 @@ - import fs from "fs"; import path from "path"; import { foundry } from "viem/chains"; @@ -83,4 +82,4 @@ const AddressPage = async ({ params }: PageProps) => { return ; }; -export default AddressPage; \ No newline at end of file +export default AddressPage; diff --git a/packages/nextjs/app/page.tsx b/packages/nextjs/app/page.tsx index dc1846c..0caf6bb 100644 --- a/packages/nextjs/app/page.tsx +++ b/packages/nextjs/app/page.tsx @@ -2,12 +2,13 @@ // import Link from "next/link"; import type { NextPage } from "next"; -// import { BugAntIcon, MagnifyingGlassIcon } from "@heroicons/react/24/outline"; -import { NftCard } from "~~/components/nft-card/nftCard"; -import { useScaffoldContract, useScaffoldContractRead } from "~~/hooks/scaffold-eth"; // import { useAccount } from "wagmi"; // import { FormEvent } from 'react' import { useFetches, useGetAllMetadatas } from "~~/components/nft-card/Hooks"; +// import { BugAntIcon, MagnifyingGlassIcon } from "@heroicons/react/24/outline"; +import { NftCard } from "~~/components/nft-card/nftCard"; +import { useScaffoldContract, useScaffoldContractRead } from "~~/hooks/scaffold-eth"; + // import rainey from "~~/components/assets/rainey.jpg" // import houses from "~~/components/assets/houses.jpeg" // import brick from "~~/components/assets/brick.jpeg" @@ -15,48 +16,40 @@ import { useFetches, useGetAllMetadatas } from "~~/components/nft-card/Hooks"; const Home: NextPage = () => { // const account = useAccount(); - // const { data: adminRole } = useScaffoldContractRead({contractName:"RaineyStreetPartnershipNft", functionName: "DEFAULT_ADMIN_ROLE"}); // const { data: hasAdminRole } = useScaffoldContractRead({contractName:"RaineyStreetPartnershipNft", functionName: "hasRole", args: [adminRole, account.address]}); // const { writeAsync: mint } = useScaffoldContractWrite({contractName: "RaineyStreetPartnershipNft", functionName: "mint", args: [""]}); - const { data: partnershipNftContract } = useScaffoldContract({contractName: "RaineyStreetPartnershipNft"}); - const { data: mintCount } = useScaffoldContractRead({contractName:"RaineyStreetPartnershipNft", functionName:"getMintCount"}); + const { data: partnershipNftContract } = useScaffoldContract({ contractName: "RaineyStreetPartnershipNft" }); + const { data: mintCount } = useScaffoldContractRead({ + contractName: "RaineyStreetPartnershipNft", + functionName: "getMintCount", + }); const { data: tokenURIs } = useGetAllMetadatas(partnershipNftContract, mintCount || BigInt(0)); for (let i = 0; i < tokenURIs.length; i++) { - if (tokenURIs[i]) - tokenURIs[i] = tokenURIs[i].replace("ipfs://", "https://ipfs.io/ipfs/"); + if (tokenURIs[i]) tokenURIs[i] = tokenURIs[i].replace("ipfs://", "https://ipfs.io/ipfs/"); } const { data: metadatas } = useFetches(tokenURIs); - const nfts = metadatas!.map((metadata, index) => ( - - )); + const nfts = metadatas!.map((metadata, index) => ); - const { data: sixthPartnershipNftContract } = useScaffoldContract({contractName: "SixthStreetPartnershipNft"}); - const { data: sixthMintCount } = useScaffoldContractRead({contractName:"SixthStreetPartnershipNft", functionName:"getMintCount"}); + const { data: sixthPartnershipNftContract } = useScaffoldContract({ contractName: "SixthStreetPartnershipNft" }); + const { data: sixthMintCount } = useScaffoldContractRead({ + contractName: "SixthStreetPartnershipNft", + functionName: "getMintCount", + }); const { data: sixthTokenURIs } = useGetAllMetadatas(sixthPartnershipNftContract, sixthMintCount || BigInt(0)); console.log(sixthTokenURIs); - + for (let i = 0; i < sixthTokenURIs.length; i++) { - if (sixthTokenURIs[i]) - sixthTokenURIs[i] = sixthTokenURIs[i].replace("ipfs://", "https://ipfs.io/ipfs/"); + if (sixthTokenURIs[i]) sixthTokenURIs[i] = sixthTokenURIs[i].replace("ipfs://", "https://ipfs.io/ipfs/"); } const { data: sixthMetadatas } = useFetches(sixthTokenURIs); - const sixthNfts = sixthMetadatas!.map((metadata, index) => ( - - )); - - - - - - - + const sixthNfts = sixthMetadatas!.map((metadata, index) => ); // async function onFormSubmit(event: any) { // event.preventDefault() @@ -77,28 +70,20 @@ const Home: NextPage = () => { return ( <> - {/*
+ {/*
{ adminOutput }
*/} -
-

Rainey Street

-
- { - nfts - } -
-
-
-

6th Street

-
- { - sixthNfts - } -
-
+
+

Rainey Street

+
{nfts}
+
+
+

6th Street

+
{sixthNfts}
+
); }; diff --git a/packages/nextjs/components/nft-card/Hooks.tsx b/packages/nextjs/components/nft-card/Hooks.tsx index 5eba9b3..04b5ef3 100644 --- a/packages/nextjs/components/nft-card/Hooks.tsx +++ b/packages/nextjs/components/nft-card/Hooks.tsx @@ -1,46 +1,45 @@ import { useEffect, useState } from "react"; export function useGetAllMetadatas(contract: any, mintCount: bigint) { - const [data, setData] = useState([]); + const [data, setData] = useState([]); - useEffect(()=> { - async function get() { - const arr = []; - for (let i = 0; i < mintCount; i++) { - let result = await contract?.read.tokenURI([i]); - arr.push(result); - } + useEffect(() => { + async function get() { + const arr = []; + for (let i = 0; i < mintCount; i++) { + let result = await contract?.read.tokenURI([i]); + arr.push(result); + } - setData([...arr]); - } - get(); - }, [contract?.address, mintCount]) + setData([...arr]); + } + get(); + }, [contract?.address, mintCount]); - return { data } + return { data }; } export function useFetches(uris: string[]) { - const [data, setData] = useState([]); - - useEffect(() => { - async function get() { - const arr = []; - for (let i = 0; i < uris.length; i++) { - try { - const response = await fetch(uris[i]); - const responseJson = await response.json(); - arr.push(responseJson); - } - catch (e) { - console.log('Could not fetch URI'); - arr.push({}); - } + const [data, setData] = useState([]); + + useEffect(() => { + async function get() { + const arr = []; + for (let i = 0; i < uris.length; i++) { + try { + const response = await fetch(uris[i]); + const responseJson = await response.json(); + arr.push(responseJson); + } catch (e) { + console.log("Could not fetch URI"); + arr.push({}); } - - setData([...arr]); } - get(); - }, [uris]); - - return { data }; - } \ No newline at end of file + + setData([...arr]); + } + get(); + }, [uris]); + + return { data }; +} diff --git a/packages/nextjs/components/nft-card/nftCard.tsx b/packages/nextjs/components/nft-card/nftCard.tsx index 63005fd..fa2d7b4 100644 --- a/packages/nextjs/components/nft-card/nftCard.tsx +++ b/packages/nextjs/components/nft-card/nftCard.tsx @@ -1,33 +1,31 @@ interface Nft { - name?: string; - description?: string; - image?: string; + name?: string; + description?: string; + image?: string; } interface NftCardProps { - nft: Nft; + nft: Nft; } -export function NftCard (props: NftCardProps) { +export function NftCard(props: NftCardProps) { + if (props.nft && props.nft.image) { + props.nft.image = props.nft.image.replace("ipfs://", "https://ipfs.io/ipfs/"); + } - if (props.nft && props.nft.image){ - props.nft.image = props.nft.image.replace("ipfs://", "https://ipfs.io/ipfs/"); - } + //flex flex-col items-center justify-center text-center bg-black max-w-xs rounded-lg bg-sky-900 m-1 + return ( +
+
+

Name

+

{props.nft.name}

+
- //flex flex-col items-center justify-center text-center bg-black max-w-xs rounded-lg bg-sky-900 m-1 - return ( -
- -
-

Name

-

{ props.nft.name}

-
- - -
-

Description

-

{ props.nft.description}

-
-
- ) -} \ No newline at end of file + +
+

Description

+

{props.nft.description}

+
+
+ ); +}