Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasW97 committed Mar 17, 2024
1 parent 565d093 commit eee2151
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 23 deletions.
2 changes: 1 addition & 1 deletion contracts/poker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ contract Poker is Permissioned {
}

function gameState()
public
external
view
returns (
uint256 playerCount,
Expand Down
20 changes: 3 additions & 17 deletions frontend/src/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const Navbar: React.FC = () => {
//const provider = new BrowserProvider(window.ethereum);


const abi = ["function startGame() public", "function joinGame() public", "function bet() public"]
const abi = ["function startGame() public", "function joinGame() public", "function bet() public"];
//const signer = account;

//const signer = await provider.getSigner();
Expand Down Expand Up @@ -76,7 +76,7 @@ const Navbar: React.FC = () => {
try {
provider = getProvider();
const signer = await provider.getSigner();
const contract = new Contract("0x82FBF91aE0093Eeac15D7941cD2a2Db6B4bbbAd2", abi, signer);
const contract = new Contract("0xd386fD42c8C65A345646F4E0683DfF9EcA0c2716", abi, signer);
const tx = await contract.startGame();
await tx.wait();
console.log(tx);
Expand All @@ -90,21 +90,7 @@ const Navbar: React.FC = () => {
try {
provider = getProvider();
const signer = await provider.getSigner();
const contract = new Contract("0x82FBF91aE0093Eeac15D7941cD2a2Db6B4bbbAd2", abi, signer);
const tx = await contract.joinGame();
await tx.wait();
console.log(tx);
} catch (err) {
console.warn("failed to join game..", err);
openNotification();
}
}

const bet = async () => {
try {
provider = getProvider();
const signer = await provider.getSigner();
const contract = new Contract("0x82FBF91aE0093Eeac15D7941cD2a2Db6B4bbbAd2", abi, signer);
const contract = new Contract("0xd386fD42c8C65A345646F4E0683DfF9EcA0c2716", abi, signer);
const tx = await contract.joinGame();
await tx.wait();
console.log(tx);
Expand Down
81 changes: 76 additions & 5 deletions frontend/src/components/Table.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,85 @@
import React, {useState} from "react"
import React, {useState, useEffect} from "react"
import cardBackground from "../CryptoHoldem_assests/Cards new/Card Background.png"

import { Button, Modal, notification } from "antd";


import playerOne from "../CryptoHoldem_assests/Player/head-cat.png"
import playerPlaceholder from "../CryptoHoldem_assests/Player/Placeholder Player/Placeholder Player 3.svg"
import mainPlayer from "../CryptoHoldem_assests/Player/head-whale-alive.png"

import roundTable from "../CryptoHoldem_assests/Rest/Pixel Table.png"
import { Contract, Eip1193Provider, ethers } from 'ethers';

import { BrowserProvider } from "ethers";
import { use } from "chai";

const Table: React.FC = () => {
const [api] = notification.useNotification();

useEffect(() => {
const interval = setInterval(() => {
getState();
}, 500);

return () => clearInterval(interval);
}, []);

const abi = ["function bet() public", "function fold() public", "function getState() public view"];

var provider = new BrowserProvider(window.ethereum as Eip1193Provider);


function getProvider() {
if (provider === null) {
// @ts-ignore
provider = new BrowserProvider(window.ethereum);
}
return provider;
}

const bet = async () => {
try {
provider = getProvider();
const signer = await provider.getSigner();
const contract = new Contract("0xd386fD42c8C65A345646F4E0683DfF9EcA0c2716", abi, signer);
const tx = await contract.bet();
await tx.wait();
console.log(tx);
} catch (err) {
console.warn("failed to bet..", err);
//openNotification();
}
}

const getState = async () => {
try {
provider = getProvider();
const signer = await provider.getSigner();
const contract = new Contract("0xd386fD42c8C65A345646F4E0683DfF9EcA0c2716", abi, signer);
const tx = await contract.getState();
await tx.wait();
console.log(tx);
} catch (err) {
console.warn("failed to get state...", err);
//openNotification();
}
}

const fold = async () => {
try {
provider = getProvider();
const signer = await provider.getSigner();
const contract = new Contract("0xd386fD42c8C65A345646F4E0683DfF9EcA0c2716", abi, signer);
const tx = await contract.fold();
await tx.wait();
console.log(tx);
} catch (err) {
console.warn("failed to fold..", err);
//openNotification();
}
}

return (
<div className={"flex justify-center bg-primary h-[94vH]"}>
<div>
Expand All @@ -19,15 +90,15 @@ const Table: React.FC = () => {
<p className={"bg-cgrey text-primary rounded absolute top-[87%] right-[23%] text-2xl p-1"}>2000$</p>
<div className={"flex flex-col absolute right-[32%] top-[65%] w-[8%] gap-3"}>
<button
className={"text-primary bg-cgrey hover:bg-white rounded text-2xl pr-3 pl-3"}>
className={"text-primary bg-cgrey hover:bg-white rounded text-2xl pr-3 pl-3"} onClick={fold}>
Fold
</button>
<button
className={"text-primary bg-cgrey hover:bg-white rounded text-2xl pr-3 pl-3"}>
className={"text-primary bg-cgrey hover:bg-white rounded text-2xl pr-3 pl-3"} onClick={bet}>
Check
</button>
<button
className={"text-primary bg-cgrey hover:bg-white rounded text-2xl pr-3 pl-3"}>
<button
className={"text-primary bg-cgrey hover:bg-white rounded text-2xl pr-3 pl-3"} onClick={bet}>
Raise
</button>
<input
Expand Down

0 comments on commit eee2151

Please sign in to comment.