Skip to content

Commit

Permalink
Bet amount now works and displays properly! (Could be improved)
Browse files Browse the repository at this point in the history
  • Loading branch information
luloxi committed Jan 7, 2024
1 parent 1e85518 commit c1c07ff
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/nextjs/components/tictactoe/CreateChallengeBox.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { useState } from "react";
import { Button, Card, CardBody, Heading, Stack, Text } from "@chakra-ui/react";
// import { ethers } from "ethers";
import { ethers } from "ethers";
import { AddressInput, EtherInput } from "~~/components/scaffold-eth";
import { useScaffoldContractWrite } from "~~/hooks/scaffold-eth";

Expand All @@ -13,7 +13,7 @@ const CreateChallengeBox = ({}) => {
contractName: "TicTacToe",
functionName: "createGame",
args: [player2Address],
// value: betAmount ? betAmount : undefined,
value: betAmount ? ethers.parseEther(betAmount) : undefined,
});

console.log("Bet amount: ", betAmount);
Expand Down
7 changes: 4 additions & 3 deletions packages/nextjs/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { useEffect, useState } from "react";
// import Link from "next/link";
import { NewGameProps } from "../types/TicTacToeTypes";
import { Card, CardBody, Flex, Heading } from "@chakra-ui/react";
// import { ethers } from "ethers";
import { ethers } from "ethers";
import type { NextPage } from "next";
// import { parseEther } from "viem";
// import { BugAntIcon, MagnifyingGlassIcon } from "@heroicons/react/24/outline";
import { MetaHeader } from "~~/components/MetaHeader";
import { Address } from "~~/components/scaffold-eth";
Expand Down Expand Up @@ -51,7 +52,7 @@ const Home: NextPage = () => {
});

const gameCards = gameHistory?.map(game => {
// This is where all events relevant to a single game will be stored and sorted which is a palindrome
// This is where all events relevant to a single game will be stored
return game;
});

Expand Down Expand Up @@ -103,7 +104,7 @@ const Home: NextPage = () => {
<p>
Player 2: <Address address={player2} />
</p>
<p>Bet: {bet.toString()} ETH</p>
<p>Bet: {parseFloat(ethers.formatEther(bet.toString())).toFixed(4)} ETH</p>
</Flex>
<span>------------------------</span>
</>
Expand Down

0 comments on commit c1c07ff

Please sign in to comment.