Commit afbff250 authored by Zvezdin .'s avatar Zvezdin .

bet fix

parent 2623a8fb
......@@ -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;
//DEBUG temp adds:
tmpTest2.length = 2;
tmpTest2[0] = 1;
tmpTest2[1] = 2;
createEvent(1, 1629829173, "Bulg", "Germ", "Football", tmpTest);
updateBet(1, 2, 123123, [uint(1),3], 7043, 3);
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(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
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