Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kota #9

Merged
merged 2 commits into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/hardhat/test/YourContract.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { expect } from "chai";
import { ethers } from "hardhat";
import { YourContract } from "../typechain-types";
import { ZkTreasure } from "../typechain-types";

describe("YourContract", function () {
describe("ZkTreasure", function () {
// We define a fixture to reuse the same setup in every test.

let yourContract: YourContract;
let yourContract: ZkTreasure;
before(async () => {
const [owner] = await ethers.getSigners();
const yourContractFactory = await ethers.getContractFactory("YourContract");
yourContract = (await yourContractFactory.deploy(owner.address)) as YourContract;
const yourContractFactory = await ethers.getContractFactory("ZkTreasure");
yourContract = (await yourContractFactory.deploy(owner.address)) as ZkTreasure;
await yourContract.waitForDeployment();
});

Expand Down
30 changes: 15 additions & 15 deletions packages/nextjs/app/api/server.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { useScaffoldWatchContractEvent } from "../../hooks/scaffold-eth";
// import { useScaffoldWatchContractEvent } from "../../hooks/scaffold-eth";

function Server() {
useScaffoldWatchContractEvent({
contractName: "zkTreasure",
eventName: "CoordinateCreated",
// function Server() {
// useScaffoldWatchContractEvent({
// contractName: "zkTreasure",
// eventName: "CoordinateCreated",

onLogs: logs => {
logs.map(log => {
const { coordinateId, player, x, y } = log.args;
console.log("📡 CoordinateCreated event:", coordinateId, player, x, y);
});
// execute verification
},
});
}
// onLogs: logs => {
// logs.map(log => {
// const { coordinateId, player, x, y } = log.args;
// console.log("📡 CoordinateCreated event:", coordinateId, player, x, y);
// });
// // execute verification
// },
// // });
// // }

export default Server;
// export default Server;
15 changes: 14 additions & 1 deletion packages/nextjs/app/map/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import React, { useEffect, useState } from "react";
import { useScaffoldWriteContract } from "~~/hooks/scaffold-eth";
import { useScaffoldWatchContractEvent, useScaffoldWriteContract } from "~~/hooks/scaffold-eth";

// Function to transform coordinates to integers
const transformCoordinatesToIntegers = (latitude: number, longitude: number) => {
Expand Down Expand Up @@ -35,6 +35,19 @@ export default function GeolocationMapPage() {
};
}, []);

useScaffoldWatchContractEvent({
contractName: "zkTreasure",
eventName: "CoordinateCreated",

onLogs: logs => {
logs.map(log => {
const { coordinateId, player, x, y } = log.args;
console.log("📡 CoordinateCreated event:", coordinateId, player, x, y);
});
// execute verification
},
});

const initializeMap = () => {
if (window.google) {
const map = new window.google.maps.Map(document.getElementById("map")!, {
Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/scaffold.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export type ScaffoldConfig = {

const scaffoldConfig = {
// The networks on which your DApp is live
targetNetworks: [chains.sepolia, chains.hardhat],
targetNetworks: [chains.sepolia],

// The interval at which your front-end polls the RPC servers for new data
// it has no effect if you only target the local network (default is 4000)
Expand Down
Loading