Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
Eduardo committed Apr 20, 2024
2 parents c723da0 + d38b490 commit 91758df
Show file tree
Hide file tree
Showing 12 changed files with 964 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .yarn/plugins/@yarnpkg/plugin-typescript.cjs

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions packages/nextjs/app/challenge/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"use client";

import React, { useEffect, useState } from "react";
import ReactMarkdown from "react-markdown";
import { useParams } from "next/navigation";

const PageView: React.FC = () => {
const { id } = useParams();

const [markdown, setMarkdown] = useState<string>();

useEffect(() => {
const getMarkdown = async () => {
const response = await fetch(
`https://raw.githubusercontent.com/Quantum3-Labs/speedrunstark/${id}/README.md`,
);
const markdownData = await response.text();
setMarkdown(markdownData);
};

getMarkdown();
}, [id]);
return (
<div className=" flex items-center w-full justify-center sm:text-[12px] ">
<div className="max-w-[800px] py-20 sm:max-w-[400px] sm:py-5 sm:px-5 ">
<ReactMarkdown>{markdown}</ReactMarkdown>
</div>
</div>
);
};

export default PageView;
1 change: 1 addition & 0 deletions packages/nextjs/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const spaceGrotesk = Space_Grotesk({ subsets: ["latin"] });
export const metadata: Metadata = {
title: "Starknet Speedrun",
description: "Fast track your starknet journey",
icons: "/icon-starknet.svg",
};

const ScaffoldStarkApp = ({ children }: { children: React.ReactNode }) => {
Expand Down
16 changes: 10 additions & 6 deletions packages/nextjs/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import Image from "next/image";
import StepInstruction from "~~/components/StepInstruction/StepInstruction";
import ChallengeCard from "~~/components/ChallengeCard/ChallengeCard";
import { firstChallenges, lastChallenges } from "~~/data-challenges/challenges";
import { useRouter } from "next/navigation";

const Home: NextPage = () => {
const router = useRouter();

return (
<div>
<div className="w-full flex items-center justify-center flex-col bg-landing gap-10 bg-base-100 text-primary sm:gap-3 ">
Expand Down Expand Up @@ -48,15 +52,15 @@ const Home: NextPage = () => {
</div>
<div className="w-full flex justify-center text-lg flex-col items-center text-primary ">
<div className="w-full px-[20px] flex justify-center flex-col items-center sm:pr-[35px]">
{firstChallenges.slice(0, 3).map((challenge, index) => (
{firstChallenges.slice(0, 3).map((challenge) => (
<ChallengeCard
key={index}
key={challenge.id}
challenge={challenge.challenge}
title={challenge.title}
description={challenge.description}
imageUrl={challenge.imageUrl}
buttonText="QUEST"
onButtonClick={() => {}}
onButtonClick={() => router.push(`/challenge/${challenge.id}`)}
end={challenge.end || false}
border={challenge.border !== undefined ? challenge.border : true}
/>
Expand Down Expand Up @@ -86,15 +90,15 @@ const Home: NextPage = () => {
</div>
</div>
<div className="w-full px-[20px] flex justify-center flex-col items-center">
{lastChallenges.slice(1).map((challenge, index) => (
{lastChallenges.slice(1).map((challenge) => (
<ChallengeCard
key={index}
key={challenge.id}
challenge={challenge.challenge}
title={challenge.title}
description={challenge.description}
imageUrl={challenge.imageUrl}
buttonText="LOCK"
onButtonClick={() => {}}
onButtonClick={() => router.push(`/challenge/${challenge.id}`)}
end={challenge.end || false}
border={challenge.border !== undefined ? challenge.border : true}
/>
Expand Down
20 changes: 18 additions & 2 deletions packages/nextjs/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import React, { useCallback, useRef, useState } from "react";
import { BugAntIcon } from "@heroicons/react/24/outline";
import { useOutsideClick } from "~~/hooks/scaffold-stark";
import { CustomConnectButton } from "~~/components/scaffold-stark/CustomConnectButton";
import Image from "next/image";
import { usePathname } from "next/navigation";
import { FaucetButton } from "~~/components/scaffold-stark/FaucetButton";

type HeaderMenuLink = {
Expand All @@ -31,14 +33,28 @@ export const menuLinks: HeaderMenuLink[] = [
export const Header = () => {
const [isDrawerOpen, setIsDrawerOpen] = useState(false);
const burgerMenuRef = useRef<HTMLDivElement>(null);
const pathname = usePathname();
useOutsideClick(
burgerMenuRef,
useCallback(() => setIsDrawerOpen(false), []),
);

return (
<div className="lg:static top-0 navbar min-h-0 flex-shrink-0 justify-between z-20 px-0 sm:px-2 bg-base-100">
<div className="navbar-end flex-grow mr-4">
<div
className={`lg:static top-0 navbar min-h-0 flex-shrink-0 justify-between z-20 px-0 sm:px-2 bg-base-100 ${pathname !== "/" ? "border-b border-[#1c2d49]" : ""}`}
>
<div className="pl-8">
{pathname !== "/" && (
<Image
src={"/logo-header.svg"}
alt={"logo header"}
width={200}
height={65}
className="sm:w-[100px]"
/>
)}
</div>
<div className="navbar-end flex-grow pr-8 py-[8px]">
<CustomConnectButton />
<FaucetButton />
</div>
Expand Down
8 changes: 8 additions & 0 deletions packages/nextjs/data-challenges/challenges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ const allChallenges = [
"🎫 Create a simple NFT to learn basics of scaffold-Stark. You'll use 👷‍♀️ HardHat to compile and deploy smart contracts. Then, you'll use a template React app full of important Ethereum components and hooks. Finally, you'll deploy an NFT to a public network to share with friends! 🚀",
imageUrl: "/simpleNFT.png",
end: true,
id: "challenge0",
},
{
challenge: "Challenge #1",
title: "🥩 Decentralized Staking App",
description:
"🦸 A superpower of Ethereum is allowing you, the builder, to create a simple set of rules that an adversarial group of players can use to work together. In this challenge, you create a decentralized application where users can coordinate a group funding effort. The users only have to trust the code.",
imageUrl: "/stakingToken.png",
id: "challenge-0-simple-nft",
},
{
challenge: "Challenge #2",
Expand All @@ -21,34 +23,39 @@ const allChallenges = [
"🤖 Smart contracts are kind of like always on vending machines that anyone can access. Let's make a decentralized, digital currency (an ERC20 token). Then, let's build an unstoppable vending machine that will buy and sell the currency. We'll learn about the approve pattern for ERC20s and how contract to contract interactions work.",
imageUrl: "/tokenVendor.png",
border: false,
id: "challenge-0-simple-nft",
},
{
challenge: "Challenge #3",
title: "🎲 Dice Game",
description:
"🎰 Randomness is tricky on a public deterministic blockchain. The block hash is the result proof-of-work (for now) and some builders use this as a weak form of randomness. In this challenge you will take advantage of a Dice Game contract by predicting the randomness in order to only roll winning dice!",
imageUrl: "/diceGame.png",
id: "challenge-0-simple-nft",
},
{
challenge: "Challenge #4",
title: "⚖️ Build a DEX",
description:
"💵 Build an exchange that swaps ETH to tokens and tokens to ETH. 💰 This is possible because the smart contract holds reserves of both assets and has a price function based on the ratio of the reserves. Liquidity providers are issued a token that represents their share of the reserves and fees...",
imageUrl: "/dex.png",
id: "challenge-0-simple-nft",
},
{
challenge: "Challenge #5",
title: "📺 A State Channel Application",
description:
"🛣️ The Ethereum blockchain has great decentralization & security properties but these properties come at a price: transaction throughput is low, and transactions can be expensive. This makes many traditional web applications infeasible on a blockchain... or does it? State channels look to solve these problems by allowing participants to securely transact off-chain while keeping interaction with Ethereum Mainnet at a minimum.",
imageUrl: "/state.png",
id: "challenge-0-simple-nft",
},
{
challenge: "Challenge #6",
title: "👛 Multisig Wallet Challenge",
description:
"🛣️ The Ethereum blockchain has great decentralization & security properties but these properties come at a price: transaction throughput is low, and transactions can be expensive. This makes many traditional web applications infeasible on a blockchain... or does it? State channels look to solve these problems by allowing participants to securely transact off-chain while keeping interaction with Ethereum Mainnet at a minimum.",
imageUrl: "/multiSig.png",
id: "challenge-0-simple-nft",
},
{
challenge: "Challenge #7",
Expand All @@ -57,6 +64,7 @@ const allChallenges = [
"🧙 Tinker around with cutting edge smart contracts that render SVGs in Solidity. 🧫 We quickly discovered that the render function needs to be public... 🤔 This allows NFTs that own other NFTs to render their stash. Just wait until you see an Optimistic Loogie and a Fancy Loogie swimming around in the same Loogie Tank!",
imageUrl: "/dynamicSvgNFT.png",
border: false,
id: "challenge-0-simple-nft",
},
];

Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/hooks/scaffold-stark/useTargetNetwork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function useTargetNetwork(): { targetNetwork: ChainWithAttributes } {
return {
targetNetwork: {
...targetNetwork,
// ...NETWORKS_EXTRA_DATA[targetNetwork.id],
// ...NETWORKS_EXTRA_DATA[targetNetwork.page.tsx],
},
};
}
1 change: 1 addition & 0 deletions packages/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"react-copy-to-clipboard": "^5.1.0",
"react-dom": "^18",
"react-hot-toast": "^2.4.1",
"react-markdown": "^9.0.1",
"starknet": "5.25.0",
"starknet-dev": "npm:[email protected]",
"type-fest": "^4.6.0",
Expand Down
27 changes: 27 additions & 0 deletions packages/nextjs/public/icon-starknet.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 91758df

Please sign in to comment.