...
 
Commits (18)
......@@ -76,39 +76,39 @@ contract Better {
_;
}
uint[] tmpTest;
uint[] tmpTest2;
//uint[] tmpTest;
//uint[] tmpTest2;
constructor() public {
owner = msg.sender;
//DEBUG temp adds:
tmpTest.length = 2;
tmpTest[0] = 1;
tmpTest[1] = 2;
//tmpTest.length = 2;
//tmpTest[0] = 1;
//tmpTest[1] = 2;
//DEBUG temp adds:
tmpTest2.length = 2;
tmpTest2[0] = 1;
tmpTest2[1] = 2;
//tmpTest2.length = 2;
//tmpTest2[0] = 1;
//tmpTest2[1] = 2;
createEvent(1, 1629829173, "Bulg", "Germ", "Football", tmpTest);
//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);
//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);
//createEvent(2, 1629829173, "Isla", "Germ", "Football", tmpTest2);
//updateBet(2, 1, 420, [uint(5),2], 2043, 1);
updateBet(2, 2, 453, [uint(1),3], 1014, 2);
//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, 100, 1, 321321);
//_placeBetObject(0x123, 90, 2, 453);
//_placeBetObject(0x123, 400, 3, 3562);
}
......@@ -142,14 +142,28 @@ contract Better {
Event storage ev = events[eventID];
Bet storage bet = ev.availableBets[ev.idToIndex[betID]];
return breakDownBet(bet);
id = bet.id;
amount = bet.amount;
betType = bet.betType;
values = bet.values;
odd = bet.odd;
user = bet.user;
number = bet.number;
//return breakDownBet(bet);
}
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];
return breakDownBet(bet);
id = bet.id;
amount = bet.amount;
betType = bet.betType;
values = bet.values;
odd = bet.odd;
user = bet.user;
number = bet.number;
//return breakDownBet(bet);
}
function getEventAvailableBets(uint eventID) public eventExists(eventID) view returns (uint[]) {
......
This diff is collapsed.
......@@ -7,39 +7,20 @@
<Market ID="1112" Number="2" Name="Correct Score Sets">
<Selection ID="11113" Number="1" Description="2 - 1" OddsDecimal="3.53" Participant="HOME" />
<Selection ID="11114" Number="2" Description="2 - 0" OddsDecimal="6.93" Participant="HOME" />
<Selection ID="11115" Number="3" Description="0 - 2" OddsDecimal="10.19" Participant="AWAY" />
<Selection ID="11116" Number="4" Description="1 - 2" OddsDecimal="6.15" Participant="AWAY" />
</Market>
</TennisEvent>
<FootballEvent ID="5097152" EventTime="2018-11-13T19:00:00" Home="Bulgaria" Away="Germany">
<Market ID="25179210" Number="1" Name="Match Result">
<Selection ID="60475643" Number="1" OddsDecimal="2.55" Participant="HOME" />
<Selection ID="60475645" Number="2" OddsDecimal="3.83" Participant="DRAW" />
<Selection ID="60475644" Number="3" OddsDecimal="2.31" Participant="AWAY" />
</Market>
<Market ID="25179211" Number="2" Name="Correct Score">
<Selection ID="60475646" Number="1" Description="0 - 0" OddsDecimal="47.48" Participant="DRAW" />
<Selection ID="60475652" Number="2" Description="1 - 1" OddsDecimal="5.42" Participant="DRAW" />
<Selection ID="60475657" Number="3" Description="2 - 2" OddsDecimal="14.83" Participant="DRAW" />
<Selection ID="60475647" Number="4" Description="1 - 0" OddsDecimal="14.32" Participant="HOME" />
<Selection ID="60475648" Number="5" Description="2 - 0" OddsDecimal="11.52" Participant="HOME" />
<Selection ID="60475653" Number="6" Description="2 - 1" OddsDecimal="6.53" Participant="HOME" />
<Selection ID="60475649" Number="7" Description="3 - 0" OddsDecimal="20.84" Participant="HOME" />
<Selection ID="60475654" Number="8" Description="3 - 1" OddsDecimal="23.65" Participant="HOME" />
<Selection ID="60475650" Number="9" Description="4 - 0" OddsDecimal="100.57" Participant="HOME" />
<Selection ID="60475651" Number="10" Description="0 - 1" OddsDecimal="13.47" Participant="AWAY" />
<Selection ID="60475655" Number="11" Description="0 - 2" OddsDecimal="10.19" Participant="AWAY" />
<Selection ID="60475656" Number="12" Description="1 - 2" OddsDecimal="6.15" Participant="AWAY" />
<Selection ID="60475658" Number="13" Description="0 - 3" OddsDecimal="17.34" Participant="AWAY" />
<Selection ID="60475659" Number="14" Description="1 - 3" OddsDecimal="20.92" Participant="AWAY" />
<Selection ID="60475660" Number="15" Description="0 - 4" OddsDecimal="78.71" Participant="AWAY" />
</Market>
<Market ID="25179248" Number="3" Name="Total Goals">
<Selection ID="60475768" Number="1" Description="0 Goals" OddsDecimal="48.44" />
<Selection ID="60475769" Number="2" Description="1 Goals" OddsDecimal="7.02" />
<Selection ID="60475770" Number="3" Description="2 Goals" OddsDecimal="2.72" />
<Selection ID="60475771" Number="4" Description="3 Goals" OddsDecimal="2.36" />
<Selection ID="60475772" Number="5" Description="4 Goals" OddsDecimal="5.49" />
</Market>
<Market ID="25179221" Number="4" Name="Penalty in Match">
<Selection ID="60475707" Number="1" Description="Yes" OddsDecimal="22.24" />
......
var abi = [{"constant":true,"inputs":[{"name":"eventID","type":"uint256"},{"name":"idx","type":"uint256"}],"name":"getEventPlacedBetByIndex","outputs":[{"name":"amount","type":"uint256"},{"name":"betType","type":"uint256"},{"name":"values","type":"uint256[2]"},{"name":"odd","type":"uint256"},{"name":"user","type":"address"},{"name":"number","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"eventID","type":"uint256"}],"name":"getEventByID","outputs":[{"name":"id","type":"uint256"},{"name":"ts","type":"uint256"},{"name":"home","type":"string"},{"name":"away","type":"string"},{"name":"sport","type":"string"},{"name":"betTypes","type":"uint256[]"},{"name":"closedBetTypes","type":"uint256[]"},{"name":"active","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"value","type":"uint256"}],"name":"withdraw","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getEventIDs","outputs":[{"name":"","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"eventID","type":"uint256"},{"name":"betType","type":"uint256"}],"name":"closeBetType","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"eventID","type":"uint256"},{"name":"betID","type":"uint256"}],"name":"placeBet","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[{"name":"eventID","type":"uint256"}],"name":"getEventPlacedBetsAmount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"eventID","type":"uint256"},{"name":"betType","type":"uint256"},{"name":"values","type":"uint256[2]"}],"name":"announceResult","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"eventID","type":"uint256"},{"name":"betID","type":"uint256"}],"name":"getEventBetByID","outputs":[{"name":"amount","type":"uint256"},{"name":"betType","type":"uint256"},{"name":"values","type":"uint256[2]"},{"name":"odd","type":"uint256"},{"name":"user","type":"address"},{"name":"number","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"eventID","type":"uint256"},{"name":"betType","type":"uint256"},{"name":"betID","type":"uint256"},{"name":"values","type":"uint256[2]"},{"name":"odd","type":"uint256"},{"name":"number","type":"uint256"}],"name":"updateBet","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"id","type":"uint256"},{"name":"ts","type":"uint256"},{"name":"home","type":"string"},{"name":"away","type":"string"},{"name":"sport","type":"string"},{"name":"betTypes","type":"uint256[]"}],"name":"createEvent","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"eventID","type":"uint256"}],"name":"getEventAvailableBets","outputs":[{"name":"","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"isCallerAdmin","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"user","type":"address"},{"indexed":true,"name":"eventID","type":"uint256"},{"indexed":false,"name":"betIndex","type":"uint256"},{"indexed":false,"name":"winnings","type":"uint256"}],"name":"BetWon","type":"event"}];
var abi = [{"constant":true,"inputs":[{"name":"eventID","type":"uint256"},{"name":"idx","type":"uint256"}],"name":"getEventPlacedBetByIndex","outputs":[{"name":"id","type":"uint256"},{"name":"amount","type":"uint256"},{"name":"betType","type":"uint256"},{"name":"values","type":"uint256[2]"},{"name":"odd","type":"uint256"},{"name":"user","type":"address"},{"name":"number","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"eventID","type":"uint256"}],"name":"getEventByID","outputs":[{"name":"id","type":"uint256"},{"name":"ts","type":"uint256"},{"name":"home","type":"string"},{"name":"away","type":"string"},{"name":"sport","type":"string"},{"name":"betTypes","type":"uint256[]"},{"name":"closedBetTypes","type":"uint256[]"},{"name":"active","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"value","type":"uint256"}],"name":"withdraw","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getEventIDs","outputs":[{"name":"","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"eventID","type":"uint256"},{"name":"betType","type":"uint256"}],"name":"closeBetType","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"eventID","type":"uint256"},{"name":"betID","type":"uint256"}],"name":"placeBet","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[{"name":"eventID","type":"uint256"}],"name":"getEventPlacedBetsAmount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"eventID","type":"uint256"},{"name":"betType","type":"uint256"},{"name":"values","type":"uint256[2]"}],"name":"announceResult","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"eventID","type":"uint256"},{"name":"betID","type":"uint256"}],"name":"getEventBetByID","outputs":[{"name":"id","type":"uint256"},{"name":"amount","type":"uint256"},{"name":"betType","type":"uint256"},{"name":"values","type":"uint256[2]"},{"name":"odd","type":"uint256"},{"name":"user","type":"address"},{"name":"number","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"eventID","type":"uint256"},{"name":"betType","type":"uint256"},{"name":"betID","type":"uint256"},{"name":"values","type":"uint256[2]"},{"name":"odd","type":"uint256"},{"name":"number","type":"uint256"}],"name":"updateBet","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"id","type":"uint256"},{"name":"ts","type":"uint256"},{"name":"home","type":"string"},{"name":"away","type":"string"},{"name":"sport","type":"string"},{"name":"betTypes","type":"uint256[]"}],"name":"createEvent","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"eventID","type":"uint256"}],"name":"getEventAvailableBets","outputs":[{"name":"","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"isCallerAdmin","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"user","type":"address"},{"indexed":true,"name":"eventID","type":"uint256"},{"indexed":false,"name":"betIndex","type":"uint256"},{"indexed":false,"name":"winnings","type":"uint256"}],"name":"BetWon","type":"event"}];
function init(){
......@@ -14,7 +14,7 @@ function init(){
var inst;
var address = "0xb7793037b67d46948e3c3d0c43ccbe96ac3ffc40";
var address = "0xd99748782d7643b00c36a4bb296c4a099df98ff3";
var acc;
//temp fix:
......@@ -68,9 +68,7 @@ function getEventIDs() {
}
function getEventByID(eventID) {
console.log(eventID)
return new Promise((accept, reject) => {
console.log("???")
inst.getEventByID.call(eventID, {"from": acc}, function(err, res){
if(!err) {
accept(res);
......@@ -107,7 +105,6 @@ function getEventPlacedBetByIndex(eventID, betIndex) {
function getEventAvailableBets(eventID) {
return new Promise((accept, reject) => {
console.log(eventID)
inst.getEventAvailableBets.call(eventID, {"from": acc}, function(err, res){
if(!err) {
accept(res);
......@@ -132,13 +129,10 @@ function getEventPlacedBetsAmount(eventID) {
async function getEvents(){
let ids = await getEventIDs();
console.log(ids)
objects = []
for(let i=0; i<ids.length; i++) {
console.log("ssss")
let res = await getEventByID(ids[i]);
console.log(res)
objects.push(res);
}
......
......@@ -36,3 +36,31 @@
.active {
background-color: #EEE !important;
}
.bet-item:hover {
background-color: #EEE !important;
}
.admin-page {
margin: auto;
margin-top: 20%;
margin-left: 40%;
}
.xml {
text-align: center;
margin-top: 40% !important;
}
.no-bet {
margin: auto !important;
margin-top: 20% !important;
text-align: center !important;
width: 100% !important;
}
.titles {
border: 0 !important;
border-bottom: 2px solid rgb(88, 204, 88) !important;
width: 100% !important;
}
\ No newline at end of file
......@@ -10,9 +10,80 @@ export default class AdminPage extends Component {
let reader = new FileReader();
reader.onload = (() => {
reader.onload = (async () => {
this.setState({ xml: reader.result })
this.setState({ json: xml2json(reader.result) })
//TODO: solidity calls
let js = JSON.parse(this.state.json);
console.log(js, js.elements, js[0]);
let events = js.elements[0].elements;
console.log(events[0].name, events[1].name)
for(let i=0; i<events.length; i++) {
let ev = events[i];
let attr = ev.attributes;
let ts = (new Date(attr.EventTime).getTime()/1000);
console.log(ts);
let res = await createEvent(attr.ID, ts, attr.Home, attr.Away, ev.name, [1,2]) //eslint-disable-line
console.log(res);
res = await getEventByID(attr.ID); //eslint-disable-line
console.log(res);
let els = ev.elements;
for(let j=0; j<els.length; j++) {
let el = els[j];
let at = el.attributes;
let betType = at.Name;
console.log(el);
for(let k=0; k<el.elements.length; k++) {
let bet = el.elements[k];
let betAt = bet.attributes;
console.log(betAt);
let vals;
if(betAt.hasOwnProperty("Description")) {
if(betAt.Description.search("Goals") >=0){
let k = betAt.Description.split(" ")[0];
vals = [+k, 0];
} else if(betAt.Description == "Yes") {
vals = [1,0];
} else if(betAt.Description == "No") {
vals = [0,0];
} else{
vals = betAt.Description.split(" - ");
}
} else {
if (betAt.Participant == "HOME") {
vals = [0, 0];
} else if (betAt.Participant == "AWAY") {
vals = [1, 0];
} else if (betAt.Participant == "DRAW") {
vals = [2, 0];
}
}
let betTypes = {"Match Result": 1,
"Correct Score Sets": 2, "Correct Score": 2, "Total Goals": 3, "Penalty in Match" : 4}
let odds = (+betAt.OddsDecimal)*100;
console.log(vals, odds);
console.log(attr.ID, betTypes[betType], betAt.ID, vals, odds, betAt.Number);
try{
let res = await updateBet(attr.ID, betTypes[betType], at.ID, vals, odds, betAt.Number) //eslint-disable-line
} catch (e) {
console.log(e, "Error!")
//k--;
}
}
}
}
}).bind(this)
acceptedFiles.forEach((file) => {
......@@ -24,7 +95,6 @@ export default class AdminPage extends Component {
render() {
return (
<div className="admin-page">
АДМИН ПЕЙДЖ
<Dropzone accept=".xml"
onDrop={this.onDrop.bind(this)} >
{({ isDragActive, isDragReject, acceptedFiles, rejectedFiles }) => {
......@@ -37,12 +107,10 @@ export default class AdminPage extends Component {
}
return acceptedFiles.length || rejectedFiles.length
? `Accepted ${acceptedFiles.length}, rejected ${rejectedFiles.length} files`
: "Try dropping some files.";
? <p class="xml"> Accepted {acceptedFiles.length}, rejected {rejectedFiles.length} files </p>
: <p class="xml"> Drop your XML </p>;
}}
</Dropzone>
{this.state.xml}
{this.state.json}
</div>
)
}
......
This diff is collapsed.
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