diff --git a/crypto_clash_frontend/app/clash/Reveal.tsx b/crypto_clash_frontend/app/clash/Reveal.tsx index 2fd568c..e039797 100644 --- a/crypto_clash_frontend/app/clash/Reveal.tsx +++ b/crypto_clash_frontend/app/clash/Reveal.tsx @@ -24,6 +24,36 @@ export default function Reveal({ const [playerARevealed, setPlayerARevealed] = useState(""); const [playerBRevealed, setPlayerBRevealed] = useState(""); const [revealTimeLeft, setRevealTimeLeft] = useState(""); + const [outcome, setOutcome] = useState(""); + // getOutcome handler + const handleGetOutcome = async () => { + if (!contract || !web3 || !account) return; + setLoading(true); + setStatus(""); + try { + const tx = contract.methods.getOutcome(); + const gas = await tx.estimateGas({ from: account }); + const result = await (globalThis as any).ethereum.request({ + method: "eth_sendTransaction", + params: [ + { + from: account, + to: config?.GAME_CONTRACT_ADDRESS, + data: tx.encodeABI(), + gas: web3.utils.toHex(gas), + chainId: web3.utils.toHex(await web3.eth.net.getId()), + }, + ], + }); + setStatus("getOutcome tx sent: " + result); + setOutcome("Transaction sent: " + result); + } catch (err: any) { + setStatus("getOutcome failed: " + err.message); + setOutcome(""); + } finally { + setLoading(false); + } + }; // Reveal phase read-only handlers const handleBothRevealed = async () => { @@ -122,6 +152,17 @@ export default function Reveal({ Reveal +
+ + {outcome} +
+