Skip to content

Commit

Permalink
removed some unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
itssunny322 committed Apr 20, 2022
1 parent da2cccb commit b3fcf1e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import MatchDetail from './components/MatchDetail';
import Bet from './components/Bet';
import Store from './components/Store';
import AdminPage from './components/AdminPage';
import Loader from './components/Loader';
import BetHistory from './components/BetHistory';



Expand All @@ -24,6 +26,8 @@ function App() {
<Route path="/detail/:id" element={<MatchDetail/>} />
<Route path="/store" element={<Store/>} />
<Route path="/admin" element={<AdminPage/>} />
<Route path="/loader" element={<Loader/>} />
<Route path="/betHistory" element={<BetHistory/>} />
</Routes>
</Router>
</div>
Expand Down
21 changes: 19 additions & 2 deletions src/components/Bet.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import React from "react";
import { useParams } from "react-router-dom";
import { ethers, wordlists } from "ethers";

import Loader from "./Loader";

import DAIABI from "../abis/DAI.json";
import BetABI from "../abis/Bet.json";
import BetOracleABI from "../abis/BetOracle.json";
import { useEffect, useState } from "react";

export default function Bet() {
Expand All @@ -13,6 +14,7 @@ export default function Bet() {
const [amountToBet, setamount] = useState();
const [tokens, setTokens] = useState([]);
const [selectToken, setselectedtoken] = useState();
const [loader, setLoader] = useState(false);

const DAIContractAddress = process.env.REACT_APP_DAI_CONTRACT_ADDRESS;
const BetContractAddress = process.env.REACT_APP_Bet_CONTRACT_ADDRESS;
Expand Down Expand Up @@ -42,13 +44,27 @@ export default function Bet() {
}, []);

const handleBet =async(id,team,amount)=>{
console.log("bet initiated");
const betContract = new ethers.Contract(
BetContractAddress,
BetABI,
signer
);
const bet = await betContract.placeBet(id,team,amount)

console.log("bet confirming");
let txConfirm = await provider.getTransaction(bet.hash)
console.log(txConfirm)
// wait for transaction to be mined
setLoader(true)
console.log(loader)
while (txConfirm.blockNumber === null) {
txConfirm = await provider.getTransaction(bet.hash)
// create a loader
console.log("waiting for transaction to be mined")
}
console.log(loader)
setLoader(false)
console.log("transaction mined")
}

const handleFlashBet =async(id,team,amount,selectToken)=>{
Expand Down Expand Up @@ -83,6 +99,7 @@ export default function Bet() {
<br/>
<br/>
<h3>Bet</h3>
{loader ? <Loader /> : <> </>}
{event &&
<form >
<lebel>Select Team:</lebel>
Expand Down
2 changes: 1 addition & 1 deletion src/components/MatchDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default function MatchDetail(props) {
);
const betOddsA = await betOracleContract.getOddsA(eventId);
const a = parseInt(betOddsA._hex.slice(2), 16);
const realvalA = a / 100
const realvalA = a / 100;
setOddA(realvalA);
const betOddsB = await betOracleContract.getOddsB(eventId);
const b = parseInt(betOddsB._hex.slice(2), 16);
Expand Down
5 changes: 4 additions & 1 deletion src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@ code {
height: 100%;
background-color: #282c34;
color: white;
}
}



0 comments on commit b3fcf1e

Please sign in to comment.