Commit 0023b7a9 authored by Viktor Velev's avatar Viktor Velev

Merge branch 'master' of https://gitlab.com/VikVelev/pun into frontend

parents e80c34c5 21f6f3a1
......@@ -48,7 +48,7 @@ contract Better {
}
modifier eventExists(uint eventID) {
require(events[eventID].ts > 0);
//require(events[eventID].ts > 0);
_;
}
......@@ -77,6 +77,7 @@ contract Better {
}
uint[] tmpTest;
uint[] tmpTest2;
constructor() public {
owner = msg.sender;
......@@ -85,9 +86,30 @@ contract Better {
tmpTest.length = 2;
tmpTest[0] = 1;
tmpTest[1] = 2;
createEvent(1, 100, "Bulg", "Germ", "Football", tmpTest);
//DEBUG temp adds:
tmpTest2.length = 2;
tmpTest2[0] = 1;
tmpTest2[1] = 2;
createEvent(1, 1629829173, "Bulg", "Germ", "Football", tmpTest);
updateBet(1, 1, 123123, [uint(1),3], 7043, 1);
updateBet(1, 2, 321321, [uint(2),1], 1034, 2);
createEvent(2, 1629829173, "Isla", "Germ", "Football", tmpTest2);
updateBet(1, 2, 123123, [uint(1),3], 7043, 3);
//updateBet(2, 1, 420, [uint(5),2], 2043, 1);
updateBet(2, 2, 453, [uint(1),3], 1014, 2);
//createEvent(3, 1629829173, "Germ", "Fran", "Football", tmpTest);
//updateBet(2, 1, 3562, [uint(0),0], 2043, 1);
//updateBet(2, 2, 23748, [uint(1),1], 5034, 2);
_placeBetObject(0x123, 100, 1, 321321);
_placeBetObject(0x123, 90, 2, 453);
//_placeBetObject(0x123, 400, 3, 3562);
}
function getEventIDs() public view returns (uint[]) {
......@@ -106,7 +128,8 @@ contract Better {
closedBetTypes = ev.closedBetTypes;
}
function breakDownBet(Bet bet) private view returns (uint amount, uint betType, uint[2] values, uint odd, address user, uint number) {
function breakDownBet(Bet bet) private view returns (uint id, uint amount, uint betType, uint[2] values, uint odd, address user, uint number) {
id = bet.id;
amount = bet.amount;
betType = bet.betType;
values = bet.values;
......@@ -115,14 +138,14 @@ contract Better {
number = bet.number;
}
function getEventBetByID(uint eventID, uint betID) public betExists(eventID, betID) view returns (uint amount, uint betType, uint[2] values, uint odd, address user, uint number) {
function getEventBetByID(uint eventID, uint betID) public betExists(eventID, betID) view returns (uint id, uint amount, uint betType, uint[2] values, uint odd, address user, uint number) {
Event storage ev = events[eventID];
Bet storage bet = ev.availableBets[ev.idToIndex[betID]];
return breakDownBet(bet);
}
function getEventPlacedBetByIndex(uint eventID, uint idx) public placedBetExists(eventID, idx) view returns (uint amount, uint betType, uint[2] values, uint odd, address user, uint number) {
function getEventPlacedBetByIndex(uint eventID, uint idx) public placedBetExists(eventID, idx) view returns (uint id, uint amount, uint betType, uint[2] values, uint odd, address user, uint number) {
Event storage ev = events[eventID];
Bet storage bet = ev.placedBets[idx];
......@@ -178,19 +201,24 @@ contract Better {
bet.number = number;
}
//only if event is active
//if bet is not closed
function placeBet(uint eventID, uint betID) public eventActive(eventID) betExists(eventID, betID) betOpen(eventID, betID) payable {
require(msg.value > 0);
function _placeBetObject(address sender, uint amount, uint eventID, uint betID) private {
Event storage ev = events[eventID];
Bet storage avBet = ev.availableBets[ev.idToIndex[betID]];
Bet memory b = avBet; // copy to memory
b.amount = msg.value;
b.user = msg.sender;
b.amount = amount;
b.user = sender;
ev.placedBets.push(b);
}
//only if event is active
//if bet is not closed
function placeBet(uint eventID, uint betID) public eventActive(eventID) betExists(eventID, betID) betOpen(eventID, betID) payable {
require(msg.value > 0);
_placeBetObject(msg.sender, msg.value, eventID, betID);
}
function announceResult(uint eventID, uint betType, uint[2] values) public onlyOwner {
Event storage ev = events[eventID];
......
This diff is collapsed.
......@@ -43,7 +43,7 @@
</Market>
<Market ID="25179221" Number="4" Name="Penalty in Match">
<Selection ID="60475707" Number="1" Description="Yes" OddsDecimal="22.24" />
<Selection ID="60475707" Number="2" Description="No" OddsDecimal="1.24" />
<Selection ID="60475708" Number="2" Description="No" OddsDecimal="1.24" />
</Market>
</FootballEvent>
</UpcomingEvents>
\ No newline at end of file
......@@ -4,6 +4,7 @@
"private": true,
"dependencies": {
"ganache-cli": "^6.1.3",
"ml-knn": "^2.1.3",
"mobx": "^5.0.3",
"react": "^16.4.1",
"react-dom": "^16.4.1",
......
......@@ -14,7 +14,7 @@ function init(){
var inst;
var address = "0x8c67fefbf1f71737bc2ed4c38367d842899529a1";
var address = "0xb7793037b67d46948e3c3d0c43ccbe96ac3ffc40";
var acc;
//temp fix:
......
......@@ -3,10 +3,12 @@ import './App.css';
import { Route, Switch, Redirect, BrowserRouter as Router } from 'react-router-dom';
import BetPage from './component/main'
import AdminPage from './component/admin'
import { testNN } from './nn'
class App extends Component {
componentDidMount() {
//init(); //eslint-disable-line
testNN(); //eslint-disable-line
}
routes = {
......
export async function testNN() {
let res = await isCallerAdmin() //eslint-disable-line
console.log("TESTTT", res)//name() //eslint-disable-line
//res = await getEvents() //eslint-disable-line
//console.log(res);
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment