Skip to content

Commit bb431e1

Browse files
committed
fix: contract
1 parent e182974 commit bb431e1

File tree

5 files changed

+43
-24
lines changed

5 files changed

+43
-24
lines changed

packages/common/contracts/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -770,8 +770,8 @@ export const ERC_20_ABI = [
770770

771771
export const ARCADE_CONTRACT_ADDRESS: { [chainId: number]: string } = {
772772
296: "0xdD049Fc4b926A7857c012354e578c6da1c5B8316", // * INFO: Hedera
773-
31: "0xdD049Fc4b926A7857c012354e578c6DA1C5B8316", // * INFO: Rootstock
774-
2810: "0xeff531D43600A925c0D282f755bA0d39AA82EF14", // * INFO: Morph L2
773+
31: "0x79a24817Ac317549A2D1e00109f0fa7424E45838", // * INFO: Rootstock
774+
2810: "0xfCC7234233082346398D2087f790C48677b8DdA6", // * INFO: Morph L2
775775
};
776776

777777
export const TOKEN_CONTRACT_ADDRESS: { [chainId: number]: string } = {

packages/frontend/src/app/games/[tier_id]/connect-four/components/Game.tsx

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
import AttestModal from "@/shared/AttestModal";
44
import PlayerGameView from "@/shared/PlayerGameView";
55
import StakingModal from "@/shared/StakingModal";
6+
import { API_REST_BASE_URL } from "@/utils/constants/api.constant";
67
import { useSelectedChainContext } from "@/utils/context/selected-chain.context";
78
import { useTierContext } from "@/utils/context/tiers.context";
89
import { useWeb3AuthContext } from "@/utils/context/web3auth.context";
10+
import { ResponseWithData, MappedSeason } from "@/utils/types";
911
import { getSocketManager } from "@/utils/websockets";
1012
import { ConnectFour } from "common";
1113
import { emptyBoard } from "common/connect-four";
1214
import dynamic from "next/dynamic";
13-
import { useEffect, useReducer, useRef } from "react";
15+
import { useEffect, useReducer, useRef, useState } from "react";
1416
import { Socket } from "socket.io-client";
1517

1618
type Props = {
@@ -72,7 +74,8 @@ export default dynamic(
7274
const isFreeTier =
7375
tiers.find((tier) => tier.tier_id === tier_id)?.usd_amount ===
7476
0;
75-
77+
const [currentSeason, setCurrentSeason] =
78+
useState<MappedSeason | null>(null);
7679
const { user } = useWeb3AuthContext();
7780
const { selectedChain } = useSelectedChainContext();
7881

@@ -286,6 +289,19 @@ export default dynamic(
286289
board: emptyBoard,
287290
} satisfies GameState);
288291

292+
useEffect(() => {
293+
(async () => {
294+
const seasonsRes = await fetch(
295+
`${API_REST_BASE_URL}/seasons/current`,
296+
);
297+
const seasonsResponse =
298+
(await seasonsRes.json()) as ResponseWithData<MappedSeason>;
299+
if (seasonsResponse.success) {
300+
setCurrentSeason(seasonsResponse.data);
301+
}
302+
})();
303+
}, []);
304+
289305
useEffect(() => {
290306
const socket = socketRef.current;
291307
socket.on("connect_error", (err) => {
@@ -464,23 +480,26 @@ export default dynamic(
464480
// );
465481
}}
466482
/>
467-
<AttestModal
468-
open={
469-
gameState.state === "gameEnd" &&
470-
player_user_id === gameState.winner_id
471-
}
472-
player_id={
473-
gameState.state === "gameEnd"
474-
? gameState.player.player_id
475-
: undefined
476-
}
477-
room_id={
478-
gameState.state === "gameEnd"
479-
? gameState.room_id
480-
: undefined
481-
}
482-
tier_id={tier_id}
483-
/>
483+
{currentSeason && (
484+
<AttestModal
485+
open={
486+
gameState.state === "gameEnd" &&
487+
player_user_id === gameState.winner_id
488+
}
489+
season_id={currentSeason?.season_id}
490+
player_id={
491+
gameState.state === "gameEnd"
492+
? gameState.player.player_id
493+
: undefined
494+
}
495+
room_id={
496+
gameState.state === "gameEnd"
497+
? gameState.room_id
498+
: undefined
499+
}
500+
tier_id={tier_id}
501+
/>
502+
)}
484503
</main>
485504
);
486505
}),

packages/frontend/src/shared/AttestModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export default function AttestModal({
6060
});
6161

6262
const res = await fetch(
63-
`${API_REST_BASE_URL}/played_games/${room_id}/attestation`,
63+
`${API_REST_BASE_URL}/played-games/${room_id}/attestation`,
6464
{
6565
cache: "no-cache",
6666
method: "POST",

packages/smart-contracts/contracts/Arcade.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ contract Arcade {
189189
uint256 _amount
190190
) external onlyOwner {
191191
uint256 balance = userBalances[_userAddress];
192-
require(balance < _amount, "No rewards to withdraw");
192+
require(balance > _amount, "No rewards to withdraw");
193193

194194
userBalances[_userAddress] -= _amount;
195195
token.approve(address(this), _amount);

packages/smart-contracts/ignition/modules/Arcade.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { buildModule } from "@nomicfoundation/hardhat-ignition/modules";
22

33
const ArcadeModule = buildModule("ArcadeModule", (m) => {
44
const arcade = m.contract("Arcade", [
5-
"0x9E12AD42c4E4d2acFBADE01a96446e48e6764B98",
5+
"0x24C6434B4779Cecd89075A936d11fd6Aec055166",
66
]);
77

88
return { arcade };

0 commit comments

Comments
 (0)