Skip to content

Commit

Permalink
implementing the challenge 0 ui
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielaDelPilarR committed Apr 18, 2024
1 parent 4046b77 commit d939b43
Show file tree
Hide file tree
Showing 19 changed files with 3,007 additions and 2,316 deletions.
9 changes: 0 additions & 9 deletions .yarn/plugins/@yarnpkg/plugin-typescript.cjs

This file was deleted.

8 changes: 4 additions & 4 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
compressionLevel: mixed

enableColors: true

enableGlobalCache: false

nmHoistingLimits: workspaces

nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs
spec: "@yarnpkg/plugin-typescript"

yarnPath: .yarn/releases/yarn-3.2.3.cjs
82 changes: 82 additions & 0 deletions packages/nextjs/app/ipfsDownload/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
"use client";

import { lazy, useEffect, useState } from "react";
import type { NextPage } from "next";
import { notification } from "~~/utils/scaffold-stark/notification";
// import { getMetadataFromIPFS } from "~~/utils/simpleNFT/ipfs-fetch";

const LazyReactJson = lazy(() => import("react-json-view"));

const IpfsDownload: NextPage = () => {
const [yourJSON, setYourJSON] = useState({});
const [ipfsPath, setIpfsPath] = useState("");
const [loading, setLoading] = useState(false);
const [mounted, setMounted] = useState(false);
useEffect(() => {
setMounted(true);
}, []);

// const handleIpfsDownload = async () => {
// setLoading(true);
// const notificationId = notification.loading("Getting data from IPFS");
// try {
// const metaData = await getMetadataFromIPFS(ipfsPath);
// notification.remove(notificationId);
// notification.success("Downloaded from IPFS");

// setYourJSON(metaData);
// } catch (error) {
// notification.remove(notificationId);
// notification.error("Error downloading from IPFS");
// console.log(error);
// } finally {
// setLoading(false);
// }
// };

return (
<>
<div className="flex items-center flex-col flex-grow pt-10">
<h1 className="text-center mb-4">
<span className="block text-4xl font-bold">Download from IPFS</span>
</h1>
<div className={`flex border-2 border-accent/95 bg-base-200 rounded-full text-accent w-96`}>
<input
className="input input-ghost focus:outline-none focus:bg-transparent focus:text-secondary-content h-[2.2rem] min-h-[2.2rem] px-4 border w-full font-medium placeholder:text-accent/50 text-secondary-content/75"
placeholder="IPFS CID"
value={ipfsPath}
onChange={e => setIpfsPath(e.target.value)}
autoComplete="off"
/>
</div>
<button
className={`btn btn-secondary my-6 ${loading ? "loading" : ""}`}
disabled={loading}
// onClick={handleIpfsDownload}
>
Download from IPFS
</button>

{mounted && (
<LazyReactJson
style={{ padding: "1rem", borderRadius: "0.75rem" }}
src={yourJSON}
theme="solarized"
enableClipboard={false}
onEdit={edit => {
setYourJSON(edit.updated_src);
}}
onAdd={add => {
setYourJSON(add.updated_src);
}}
onDelete={del => {
setYourJSON(del.updated_src);
}}
/>
)}
</div>
</>
);
};

export default IpfsDownload;
81 changes: 81 additions & 0 deletions packages/nextjs/app/ipfsUpload/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
"use client";

import { lazy, useEffect, useState } from "react";
import type { NextPage } from "next";
import { notification } from "~~/utils/scaffold-stark/notification";
// import { addToIPFS } from "~~/utils/simpleNFT/ipfs-fetch";
import nftsMetadata from "~~/utils/scaffold-stark/simpleNFT/nftsMetadata";

const LazyReactJson = lazy(() => import("react-json-view"));

const IpfsUpload: NextPage = () => {
const [yourJSON, setYourJSON] = useState<object>(nftsMetadata[0]);
const [loading, setLoading] = useState(false);
const [uploadedIpfsPath, setUploadedIpfsPath] = useState("");
const [mounted, setMounted] = useState(false);
useEffect(() => {
setMounted(true);
}, []);

// const handleIpfsUpload = async () => {
// setLoading(true);
// const notificationId = notification.loading("Uploading to IPFS...");
// try {
// const uploadedItem = await addToIPFS(yourJSON);
// notification.remove(notificationId);
// notification.success("Uploaded to IPFS");

// setUploadedIpfsPath(uploadedItem.path);
// } catch (error) {
// notification.remove(notificationId);
// notification.error("Error uploading to IPFS");
// console.log(error);
// } finally {
// setLoading(false);
// }
// };

return (
<>
<div className="flex items-center flex-col flex-grow pt-10">
<h1 className="text-center mb-4">
<span className="block text-4xl font-bold">Upload to IPFS</span>
</h1>

{mounted && (
<LazyReactJson
style={{ padding: "1rem", borderRadius: "0.75rem" }}
src={yourJSON}
theme="solarized"
enableClipboard={false}
onEdit={edit => {
setYourJSON(edit.updated_src);
}}
onAdd={add => {
setYourJSON(add.updated_src);
}}
onDelete={del => {
setYourJSON(del.updated_src);
}}
/>
)}
<button
className={`btn btn-secondary mt-4 ${loading ? "loading" : ""}`}
disabled={loading}
// onClick={handleIpfsUpload}
>
Upload to IPFS
</button>
{/* {uploadedIpfsPath && (
<div className="mt-4">
<a href={`https://ipfs.io/ipfs/${uploadedIpfsPath}`} target="_blank" rel="noreferrer">
{`https://ipfs.io/ipfs/${uploadedIpfsPath}`}
</a>
</div>
)} */}
</div>
</>
);
};

export default IpfsUpload;
16 changes: 16 additions & 0 deletions packages/nextjs/app/myNFTs/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import ButtonStyle from "~~/components/ButtonStyle/ButtonStyle"
import { MyHoldings } from "~~/components/SimpleNFT/MyHoldings"

function Page() {
return (
<main className="flex flex-col flex-1">
<div className="flex flex-col items-center p-10">
<h1>My NFTs</h1>
<ButtonStyle>Mint NFT</ButtonStyle>
<MyHoldings></MyHoldings>
</div>
</main>
)
}

export default Page
89 changes: 33 additions & 56 deletions packages/nextjs/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import Link from "next/link";
import type { NextPage } from "next";
import { BugAntIcon, MagnifyingGlassIcon } from "@heroicons/react/24/outline";
import Image from "next/image";
// import { Address } from "~~/components/scaffold-eth";

const Home: NextPage = () => {
Expand All @@ -23,65 +24,41 @@ const Home: NextPage = () => {
return (
<>
<div className="flex items-center flex-col flex-grow pt-10">
<div className="px-5">
<h1 className="text-center">
<span className="block text-2xl mb-2">Welcome to</span>
<span className="block text-4xl font-bold">Scaffold-Stark 2</span>
</h1>
<div className="flex justify-center items-center space-x-2">
<p className="my-2 font-medium">Connected Address:</p>
{/* <Address address={connectedAddress} /> */}
<div className="px-5 w-[90%] md:w-[75%]">
<h1 className="text-center mb-6">
<span className="block text-2xl mb-2">SpeedRunEthereum</span>
<span className="block text-4xl font-bold">Challenge #0: Simple NFT</span>
</h1>
<div className="flex flex-col items-center justify-center">
<Image
src="/hero.png"
width="727"
height="231"
alt="challenge banner"
className="rounded-xl border-4 border-primary"
/>
<div className="max-w-3xl">
<p className="text-center text-lg mt-8">
🎫 Create a simple NFT to learn basics of 🏗️ Scaffold-ETH 2. You&apos;ll use 👷‍♀️
<a href="https://hardhat.org/getting-started/" target="_blank" rel="noreferrer" className="underline">
HardHat
</a>{" "}
to compile and deploy smart contracts. Then, you&apos;ll use a template React app full of important
Ethereum components and hooks. Finally, you&apos;ll deploy an NFT to a public network to share with
friends! 🚀
</p>
<p className="text-center text-lg">
🌟 The final deliverable is an app that lets users purchase and transfer NFTs. Deploy your contracts to a
testnet then build and upload your app to a public web server. Submit the url on{" "}
<a href="https://speedrunethereum.com/" target="_blank" rel="noreferrer" className="underline">
SpeedRunEthereum.com
</a>{" "}
!
</p>
</div>
<p className="text-center text-lg">
Get started by editing{" "}
<code className="italic bg-base-300 text-base font-bold max-w-full break-words break-all inline-block">
packages/nextjs/app/page.tsx
</code>
</p>
<p className="text-center text-lg">
Edit your smart contract{" "}
<code className="italic bg-base-300 text-base font-bold max-w-full break-words break-all inline-block">
YourContract.sol
</code>{" "}
in{" "}
<code className="italic bg-base-300 text-base font-bold max-w-full break-words break-all inline-block">
packages/hardhat/contracts
</code>
</p>
</div>

<div className="flex-grow bg-base-300 w-full mt-16 px-8 py-12">
<div className="flex justify-center items-center gap-12 flex-col sm:flex-row">
<div className="flex flex-col bg-base-100 px-10 py-10 text-center items-center max-w-xs rounded-3xl">
<BugAntIcon className="h-8 w-8 fill-secondary" />
<p>
Tinker with your smart contract using the{" "}
<Link href="/debug" passHref className="link">
Debug Contracts
</Link>{" "}
tab.
</p>
</div>
<div className="flex flex-col bg-base-100 px-10 py-10 text-center items-center max-w-xs rounded-3xl">
<MagnifyingGlassIcon className="h-8 w-8 fill-secondary" />
<p>
Explore your local transactions with the{" "}
<Link href="/blockexplorer" passHref className="link">
Block Explorer
</Link>{" "}
tab.
</p>
</div>
</div>
</div>
{/* <div
onClick={() => {
writeAsync();
}}
>
TEST TX
</div> */}
</div>
</div>
</>
);
};
Expand Down
75 changes: 75 additions & 0 deletions packages/nextjs/app/transfers/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
"use client";

import type { NextPage } from "next";
import { Address } from "~~/components/scaffold-stark";
// import { useScaffoldEventHistory } from "~~/hooks/scaffold-stark";

const Transfers: NextPage = () => {
// const { data: transferEvents, isLoading } = useScaffoldEventHistory({
// contractName: "YourCollectible",
// eventName: "Transfer",
// // Specify the starting block number from which to read events, this is a bigint.
// fromBlock: 0n,
// });

// if (isLoading)
// return (
// <div className="flex justify-center items-center mt-10">
// <span className="loading loading-spinner loading-xl"></span>
// </div>
// );

const transferEvents=[
{
address:"0x7f982E4f614167DfC7950fdA06e920b9E2514748",
}
]

return (
<>
<div className="flex items-center flex-col flex-grow pt-10">
<div className="px-5">
<h1 className="text-center mb-8">
<span className="block text-4xl font-bold">All Transfers Events</span>
</h1>
</div>
<div className="overflow-x-auto shadow-lg">
<table className="table table-zebra w-full">
<thead>
<tr>
<th className="bg-primary">Token Id</th>
<th className="bg-primary">From</th>
<th className="bg-primary">To</th>
</tr>
</thead>
<tbody>
{!transferEvents || transferEvents.length === 0 ? (
<tr>
<td colSpan={3} className="text-center">
No events found
</td>
</tr>
) : (
transferEvents?.map((event, index) => {
return (
<tr key={index}>
{/* <th className="text-center">{event.args.tokenId?.toString()}</th> */}
<td>
{/* <Address address={event.args.from} /> */}
</td>
<td>
{/* <Address address={event.args.to} /> */}
</td>
</tr>
);
})
)}
</tbody>
</table>
</div>
</div>
</>
);
};

export default Transfers;
12 changes: 12 additions & 0 deletions packages/nextjs/components/ButtonStyle/ButtonStyle.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.base_button__small {
padding-block: 14px;
padding-inline: 24px;
border-radius: 7px;
}

.base_button__large {
width: 490px;
padding: 16px 33px;
border: none;
border-radius: 8px;
}
Loading

0 comments on commit d939b43

Please sign in to comment.