diff --git a/eth/hardhat.config.ts b/eth/hardhat.config.ts index 9d7fe61..e08d0ae 100644 --- a/eth/hardhat.config.ts +++ b/eth/hardhat.config.ts @@ -10,7 +10,7 @@ import "@nomicfoundation/hardhat-verify"; import { HardhatUserConfig } from "hardhat/types"; import "solidity-coverage"; -//import "./tasks"; +import "./tasks"; //import("./tasks").catch((e) => console.log("Cannot load tasks", e.toString())); diff --git a/eth/tasks/admin.ts b/eth/tasks/admin.ts index e18152c..590ffb6 100644 --- a/eth/tasks/admin.ts +++ b/eth/tasks/admin.ts @@ -1,27 +1,26 @@ import { task } from "hardhat/config"; import { TreasureHuntCreator } from "../typechain"; -import { CID } from "multiformats"; import { loadChapters, loadContract } from "./utils"; task("root-set", "Set root CID") - .addPositionalParam("cid", "The file with all chapters") - .setAction(async ({ cid }: { cid: string }, hre) => { - throw "not implemented"; + .addPositionalParam("root", "The file with all chapters") + .setAction(async ({ root }: { root: string }, hre) => { + //throw "not implemented"; const thcContract = (await loadContract( hre, "TreasureHuntCreator" )) as TreasureHuntCreator; console.log( - `Setting root CID ${cid} for contract ${thcContract.getAddress()}` + `Setting root ${root} for contract ${thcContract.getAddress()}` ); - const cidBytes = CID.parse(cid).bytes; - const tx = await thcContract.setup(cidBytes); + const tx = await thcContract.setup(root); console.log(` Transaction submitted. Waiting for 3 confirmation....`); const receipt = await tx.wait(3); console.log(` Root CID successfully set. Receipt: ${receipt?.hash}`); }); +/* import * as readline from "readline"; const rl = readline.createInterface({ input: process.stdin, @@ -87,3 +86,4 @@ task("leaderboard", "Check leaderboard") const leaderboard = await thcContract.getLeaderboard(page); console.log(leaderboard); }); +*/ diff --git a/web/src/Leaderboard.tsx b/web/src/Leaderboard.tsx index ae71616..250fcad 100644 --- a/web/src/Leaderboard.tsx +++ b/web/src/Leaderboard.tsx @@ -40,8 +40,6 @@ function Leaderboard() { }); useEffect(() => { - console.log(data); - console.log(status); if (data) { const bitmaps = data as unknown as bigint[]; const pageContent: LeaderBoardEntry[] = []; @@ -70,7 +68,7 @@ function Leaderboard() { pages[Number(page)] = pageContent; setPages(pages); } else { - setPages(pages.concat([pageContent])); + setPages((prevPages) => [...prevPages, ...[pageContent]]); } if (pageContent.length === 32) { @@ -81,7 +79,8 @@ function Leaderboard() { }, [data]); function sortedLeaderboard() { - return pages.flat().sort((x, y) => y.chapter - x.chapter); + const flattened = pages.flat().sort((x, y) => y.chapter - x.chapter); + return flattened; } function shortenAddress(address: string | undefined) { @@ -103,7 +102,7 @@ function Leaderboard() { {sortedLeaderboard().map((entry: LeaderBoardEntry) => { return ( - + { + if (result.data !== root) { + if (root !== "" && root !== undefined) { + toast({ + title: "Info", + description: "Chapters have been updated!", + status: "info", + duration: 9000, + isClosable: true, + }); + } + + setRoot(result.data as string); + } + }, [result.data]); - return result.data; + return root; } function useCurrentSmartContractChapterIndex(address?: string) { @@ -52,7 +74,6 @@ function useCurrentSmartContractChapterIndex(address?: string) { useEffect(() => { if (result.data !== undefined) { setChapter(Number(result.data as bigint)); - console.log(result.data); } }); @@ -86,7 +107,6 @@ export function useChapter() { async function updateChapterContent(chapter: number) { const response = await fetch(`game-data/${rootCID}/${chapter}`); const data = await response.text(); - console.log(currentSmartContractChapterIndex); if (chapter > 0) { const chapterPassword = getChapterPassword(chapter - 1); const text = await decrypt(data, chapterPassword); diff --git a/web/src/hooks/useInterval.tsx b/web/src/hooks/useInterval.tsx index 48381c8..c006326 100644 --- a/web/src/hooks/useInterval.tsx +++ b/web/src/hooks/useInterval.tsx @@ -4,7 +4,6 @@ export function useInterval(isOn: boolean, interval: number) { const [rounds, setRounds] = useState(0); useEffect(() => { - console.log(`${rounds} rounds ${isOn}`); if (isOn) { const intervalTimer = setTimeout(() => { setRounds(rounds + 1); diff --git a/web/src/hooks/useSideQuest.tsx b/web/src/hooks/useSideQuest.tsx index 5080fb1..3634028 100644 --- a/web/src/hooks/useSideQuest.tsx +++ b/web/src/hooks/useSideQuest.tsx @@ -36,7 +36,6 @@ function useCurrentSmartContractSideQuestIndex(address?: string) { .split("") .filter((k) => k === "1").length; setSideQuest(solvedKeys); - console.log(solvedKeys); } }); diff --git a/web/src/hooks/useUnifiedAccount.tsx b/web/src/hooks/useUnifiedAccount.tsx index 721c5b1..0257618 100644 --- a/web/src/hooks/useUnifiedAccount.tsx +++ b/web/src/hooks/useUnifiedAccount.tsx @@ -14,7 +14,6 @@ export function useAccount(): UnifiedSigner | undefined { const { burnerWallet, mnemonic } = useBurnerWallet(); // Your custom HDAccount const seed = mnemonicToSeedSync(mnemonic); const { privateKey } = HDKey.fromMasterSeed(seed); - console.log(burnerWallet, privateKey); /*const { data: wagmiSigner } = useSigner(); // Wagmi's signer const account = useWagmiAccount();