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

Fix lint Errors and Client CI passing #85

Merged
merged 5 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
17,421 changes: 9,636 additions & 7,785 deletions client/pnpm-lock.yaml
0xibs marked this conversation as resolved.
Show resolved Hide resolved

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const App = () => {
setBoard(newBoard);
};

const setGameData = useCallback((game: any) => {
const setGameData = useCallback((game: object) => {
setGameState(game);
}, []);

Expand Down
1 change: 1 addition & 0 deletions client/src/components/Control.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ const Control = ({
}: {
toggleActiveWindow: (window: string) => void;
}) => {
/* eslint-disable @typescript-eslint/no-unused-vars */
const [windows, setWindows] = useState(
WINDOW_CONFIGS.map((config) => ({ ...config, show: false, zIndex: 0 }))
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from "react";
import Draggable from "react-draggable";
import { FiXSquare } from "react-icons/fi";
import "../../styles/ControlWindowLayout.scss";

Expand Down
21 changes: 10 additions & 11 deletions client/src/components/ControlWindows/GameAccount.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import React, { useEffect, useState } from "react";
import {
useAccount,
useConnect,
useDisconnect,
useNetwork,
useStarkProfile,
} from "@starknet-react/core";
import { useMemo } from "react";
import { useEffect, useMemo, useState } from "react";
import { FaArrowAltCircleRight } from "react-icons/fa";
import { useDojo } from "../../dojo/useDojo";
import "../../styles/GameAccount.scss";
import {
convertHexToText,
createGameProfile,
getGameProfilesFromAddress,
getGameProfilesFromAddress
} from "../../utils/helpers";
import { FaArrowAltCircleRight } from "react-icons/fa";
import { useDojo } from "../../dojo/useDojo";

const ConnectWallet = () => {
const { connectors, connect } = useConnect();
Expand All @@ -39,6 +37,7 @@ const ConnectWallet = () => {
);
};

/* eslint-disable @typescript-eslint/no-unused-vars */
const ProfilePage = () => {
return <div style={{ color: "white" }}>Profile page</div>;
};
Expand Down Expand Up @@ -89,15 +88,15 @@ const GameAccount = () => {
getGameProfilesFromAddress(address, setGameProfiles);
}

return () => {};
return () => undefined;
}, [address]);

const enum pagesName {
MAIN_PAGE = "MAIN_PAGE",
PROFILE_PAGE = "PROFILE_PAGE",
}

let mainPage = {
const mainPage = {
name: pagesName.MAIN_PAGE,
content: (
<div>
Expand Down Expand Up @@ -216,16 +215,16 @@ const GameAccount = () => {
),
};

let profilePage = {
const profilePage = {
name: pagesName.PROFILE_PAGE,
content: <div>Profile</div>,
};

let pages = [mainPage, profilePage];
const pages = [mainPage, profilePage];

const resolvePageToReturn = () => {
// Get last page name
let lastPage =
const lastPage =
pagesStack[pagesStack.length - 1 > 0 ? pagesStack.length - 1 : 0];

let pageToReturn;
Expand Down
9 changes: 4 additions & 5 deletions client/src/components/Dice.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useContext,useRef } from "react";
import React, { useState, useContext, useRef } from "react";
import { useGame } from "../hooks/game-hook";
import { Row, Col } from "react-simple-flex-grid";
import "../styles/Dice.scss";
Expand Down Expand Up @@ -53,13 +53,12 @@ const Dice = () => {

// The is the argument for the rollDie function
const randomRollAmount = () => {
let rollAmount = Math.floor(Math.random() * 30 + 15);
return rollAmount;
return Math.floor(Math.random() * 30 + 15);
};

// The end result is simply a random number picked between 1 and 6
const randomRollResult = async () => {
let rollResult: number = 6;
let rollResult = 6;

rollResult = Math.floor(Math.random() * 6 + 1);

Expand All @@ -77,7 +76,7 @@ const Dice = () => {
if (counter >= numberOfRolls) {
clearInterval(rolling);
// The result on die
let x = await randomRollResult();
const x = await randomRollResult();
makeDots(x);
stopDiceSound();
moveValidator(x); // Validate move after rolling
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/OptionCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default function OptionCard({
}: {
active?: boolean;
onSelect?: () => void;
option?: any;
option?: { name: string };
}) {
return (
<button
Expand All @@ -17,7 +17,7 @@ export default function OptionCard({
>
<div className="option">
<img src={boardImg} alt="board" />
<div className="option-label">{option.name}</div>
<div className="option-label">{option?.name}</div>
</div>
</button>
);
Expand Down
16 changes: 11 additions & 5 deletions client/src/components/RestartGame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ const RestartGame: React.FC = () => {
const [restart, setRestart] = useState(false);

function handleRestartGame() {
setRestart(true);
setRestart(true);
}

function handleConfirm() {
restartGame();
setRestart(false);
restartGame();
setRestart(false);
}

function handleCancle() {
setRestart(false);
setRestart(false);
}

return (
Expand All @@ -32,7 +32,13 @@ const RestartGame: React.FC = () => {
</div>
</div>
)}
{restart && <RestartModal message="Are you sure you want to restart the gane?" onConfirm={handleConfirm} onCancel={handleCancle} />}
{restart && (
<RestartModal
message="Are you sure you want to restart the gane?"
onConfirm={handleConfirm}
onCancel={handleCancle}
/>
)}
</React.Fragment>
);
};
Expand Down
2 changes: 1 addition & 1 deletion client/src/context/board-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ interface BoardContextType {

export const BoardContext = createContext<BoardContextType>({
board: "",
toggleBoard: () => {},
toggleBoard: () => undefined,
});
8 changes: 5 additions & 3 deletions client/src/context/game-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import { createContext } from "react";
import { OptionsProps } from "../types";

export const GameContext = createContext<{
/* eslint-disable @typescript-eslint/no-explicit-any */
gameState: { [key: string]: string | any };
setGameData: (game: { [key: string]: string }) => void;
options: OptionsProps;
setGameOptions: (newOption: {}) => void;
setGameOptions: (newOption: object) => void;
}>({
gameState: {},
setGameData: (game) => {},
/* eslint-disable @typescript-eslint/no-unused-vars */
setGameData: (game) => undefined,
options: {
gameIsOngoing: false,
playersLength: 0,
Expand All @@ -18,5 +20,5 @@ export const GameContext = createContext<{
winners: [],
gameCondition: [],
},
setGameOptions: (newOption) => {},
setGameOptions: (newOption) => undefined,
});
4 changes: 3 additions & 1 deletion client/src/dojo/createSystemCalls.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getEvents } from "@dojoengine/utils";
import { Account, AccountInterface } from "starknet";
import { AccountInterface } from "starknet";
import { ClientComponents } from "./createClientComponents";

import type { IWorld } from "./typescript/contracts.gen";
Expand All @@ -8,8 +8,10 @@ export type SystemCalls = ReturnType<typeof createSystemCalls>;

export function createSystemCalls(
{ client }: { client: IWorld },
/* eslint-disable @typescript-eslint/no-unused-vars */
contractComponents: ClientComponents
) {
/* eslint-disable @typescript-eslint/no-explicit-any */
const createUsername = async (account: AccountInterface, username: any) => {
try {
const { transaction_hash } = await client.PlayerActions.create({
Expand Down
1 change: 1 addition & 0 deletions client/src/dojo/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export async function setup({ ...config }: DojoConfig) {

const eventSync = getSyncEvents(
toriiClient,
/* eslint-disable @typescript-eslint/no-explicit-any */
contractComponents as any,
undefined,
[]
Expand Down
2 changes: 1 addition & 1 deletion client/src/dojo/typescript/contracts.gen.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Generated by dojo-bindgen on Mon, 30 Sep 2024 04:07:50 +0000. Do not modify this file manually.
// Import the necessary types from the recs SDK
// generate again with `sozo build --typescript`
import { Account, AccountInterface, byteArray } from "starknet";
import { DojoProvider } from "@dojoengine/core";
import { Account, AccountInterface } from "starknet";
import * as models from "./models.gen";

export type IWorld = Awaited<ReturnType<typeof setupWorld>>;
Expand Down
76 changes: 38 additions & 38 deletions client/src/dojo/typescript/models.gen.ts
0xibs marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ export const LayoutDefinition = {

// Type definition for `core::byte_array::ByteArray` struct
export interface ByteArray {
data: String[];
pending_word: BigInt;
pending_word_len: Number;
data: string[];
pending_word: bigint;
pending_word_len: number;
}
export const ByteArrayDefinition = {
data: RecsType.StringArray,
Expand All @@ -54,7 +54,7 @@ export const ByteArrayDefinition = {

// Type definition for `dojo::model::layout::FieldLayout` struct
export interface FieldLayout {
selector: BigInt;
selector: bigint;
layout: Layout;
}
export const FieldLayoutDefinition = {
Expand All @@ -69,40 +69,40 @@ export const U256Definition = {

// Type definition for `starkludo::models::game::Game` struct
export interface Game {
id: Number;
created_by: BigInt;
id: number;
created_by: bigint;
game_status: GameStatus;
game_mode: GameMode;
player_green: BigInt;
player_yellow: BigInt;
player_blue: BigInt;
player_red: BigInt;
winner_1: BigInt;
winner_2: BigInt;
winner_3: BigInt;
next_player: BigInt;
number_of_players: Number;
player_green: bigint;
player_yellow: bigint;
player_blue: bigint;
player_red: bigint;
winner_1: bigint;
winner_2: bigint;
winner_3: bigint;
next_player: bigint;
number_of_players: number;
rolls_count: U256;
rolls_times: U256;
dice_face: Number;
player_chance: BigInt;
has_thrown_dice: Boolean;
b0: BigInt;
b1: BigInt;
b2: BigInt;
b3: BigInt;
g0: BigInt;
g1: BigInt;
g2: BigInt;
g3: BigInt;
r0: BigInt;
r1: BigInt;
r2: BigInt;
r3: BigInt;
y0: BigInt;
y1: BigInt;
y2: BigInt;
y3: BigInt;
dice_face: number;
player_chance: bigint;
has_thrown_dice: boolean;
b0: bigint;
b1: bigint;
b2: bigint;
b3: bigint;
g0: bigint;
g1: bigint;
g2: bigint;
g3: bigint;
r0: bigint;
r1: bigint;
r2: bigint;
r3: bigint;
y0: bigint;
y1: bigint;
y2: bigint;
y3: bigint;
}
export const GameDefinition = {
id: RecsType.Number,
Expand Down Expand Up @@ -143,14 +143,14 @@ export const GameDefinition = {

// Type definition for `core::integer::u256` struct
export interface U256 {
low: BigInt;
high: BigInt;
low: bigint;
high: bigint;
}

// Type definition for `starkludo::models::player::Player` struct
export interface Player {
username: BigInt;
owner: BigInt;
username: bigint;
owner: bigint;
total_games_played: U256;
total_games_won: U256;
}
Expand Down
Loading