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 ( -