Skip to content

Commit

Permalink
feat: remove player's data transform to merkel tree
Browse files Browse the repository at this point in the history
  • Loading branch information
Vivomo committed Oct 4, 2023
1 parent dc2edb8 commit 79e3f7c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
5 changes: 2 additions & 3 deletions packages/client/src/components/Map/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useMemo, useRef } from 'react';
import React, { useMemo, useRef } from 'react';
import { IPlayer } from '../Player';
import MapCell, { ICellClassCache, ICoordinate } from '../MapCell';
import './styles.scss';
Expand Down Expand Up @@ -44,9 +44,8 @@ const Map = (props: IProps) => {

const onMoveTo = (coordinate) => {
const { x, y} = players.find((player) => player.id === curId);
const paths = bfs(simpleMapData, { x, y }, coordinate);
const paths = bfs(simpleMapData, { x, y }, coordinate).slice(1);
onPlayerMove(paths, formatMovePath(paths));
console.log(paths, { x, y }, coordinate);
}


Expand Down
3 changes: 1 addition & 2 deletions packages/client/src/pages/game/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ const Game = () => {
clearInterval(interval);
}
}, 300);
console.log(merkelData);
uploadUserMove(players[curPlayerIndex].x, players[curPlayerIndex].y, merkelData);
uploadUserMove(merkelData);
}

useEffect(() => {
Expand Down
6 changes: 3 additions & 3 deletions packages/client/src/service/user.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ethers } from 'ethers';
import Mississippi from '../../abi/Mississippi.json';

export const uploadUserMove = async (x, y, steps) => {
export const uploadUserMove = async (steps) => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const provider = new ethers.providers.Web3Provider(window.ethereum)
Expand All @@ -11,8 +11,8 @@ export const uploadUserMove = async (x, y, steps) => {

const miss = new ethers.Contract('0xc86c785620e9d9a14374ea203b34b6312bce6d03', Mississippi, signer);

const transaction = await miss.connect(signer).move([x, y, steps]);
const tx = await transaction.wait(1);
const transaction = await miss.connect(signer).move(steps);
const tx = await transaction.wait();

console.log(tx.events)

Expand Down

0 comments on commit 79e3f7c

Please sign in to comment.