Skip to content

Commit

Permalink
Merge pull request #9 from funkyenough/Kota
Browse files Browse the repository at this point in the history
Kota
  • Loading branch information
kota5140 authored Aug 24, 2024
2 parents 7189cb8 + 0b74bb3 commit eb4bb91
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 22 deletions.
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

0 comments on commit eb4bb91

Please sign in to comment.