...
 
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[]) {
......
......@@ -29,8 +29,8 @@ contract Ownable {
*/
//Store this contract's compiled bytecode and ABI
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 bytecode = "60806040523480156200001157600080fd5b5033600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600260048162000064919062000985565b506001600460008154811015156200007857fe5b90600052602060002001819055506002600460018154811015156200009957fe5b90600052602060002001819055506002600581620000b8919062000985565b50600160056000815481101515620000cc57fe5b9060005260206000200181905550600260056001815481101515620000ed57fe5b906000526020600020018190555062000210600163612538356040805190810160405280600481526020017f42756c67000000000000000000000000000000000000000000000000000000008152506040805190810160405280600481526020017f4765726d000000000000000000000000000000000000000000000000000000008152506040805190810160405280600881526020017f466f6f7462616c6c0000000000000000000000000000000000000000000000008152506004805480602002602001604051908101604052809291908181526020018280548015620001f657602002820191906000526020600020905b815481526020019060010190808311620001e1575b505050505062000426640100000000026401000000009004565b6200024c6001806201e0f36040805190810160405280600181526020016003815250611b8360016200056a640100000000026401000000009004565b62000289600160026204e729604080519081016040528060028152602001600181525061040a60026200056a640100000000026401000000009004565b6200039e600263612538356040805190810160405280600481526020017f49736c61000000000000000000000000000000000000000000000000000000008152506040805190810160405280600481526020017f4765726d000000000000000000000000000000000000000000000000000000008152506040805190810160405280600881526020017f466f6f7462616c6c00000000000000000000000000000000000000000000000081525060058054806020026020016040519081016040528092919081815260200182805480156200038457602002820191906000526020600020905b8154815260200190600101908083116200036f575b505050505062000426640100000000026401000000009004565b620003d96002806101c560408051908101604052806001815260200160038152506103f660026200056a640100000000026401000000009004565b620003fd610123606460016204e72962000728640100000000026401000000009004565b62000420610123605a60026101c562000728640100000000026401000000009004565b62000c93565b60003373ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415156200048557600080fd5b60016000888152602001908152602001600020905086816000018190555085816001018190555083816003019080519060200190620004c6929190620009b4565b5084816002019080519060200190620004e1929190620009b4565b5082816004019080519060200190620004fc929190620009b4565b50818160050190805190602001906200051792919062000a3b565b50600181600c0160006101000a81548160ff021916908315150217905550600087908060018154018082558091505090600182039060005260206000200160009091929091909150555050505050505050565b6000806000884260016000838152602001908152602001600020600101541115156200059557600080fd5b3373ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141515620005f257600080fd5b600160008b815260200190815260200160002093506000925060008460080160008a81526020019081526020016000205414156200069e5783600901805480919060010162000642919062000a8d565b506001846009018054905003925083600a01889080600181540180825580915050906001820390600052602060002001600090919290919091505550828460080160008a815260200190815260200160002081905550620006b7565b8360080160008981526020019081526020016000205492505b8360090183815481101515620006c957fe5b9060005260206000209060090201915089826001018190555087826002018190555088826003018190555086826004019060026200070992919062000ac2565b5085826006018190555084826008018190555050505050505050505050565b6000806200073562000b07565b60016000868152602001908152602001600020925082600901836008016000868152602001908152602001600020548154811015156200077157fe5b906000526020600020906009020191508161010060405190810160405290816000820154815260200160018201548152602001600282015481526020016003820154815260200160048201600280602002604051908101604052809291908260028015620007f5576020028201915b815481526020019060010190808311620007e0575b50505050508152602001600682015481526020016007820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001600882015481525050905085816000018181525050868160c0019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505082600b018190806001815401808255809150509060018203906000526020600020906009020160009091929091909150600082015181600001556020820151816001015560408201518160020155606082015181600301556080820151816004019060026200091d92919062000b6b565b5060a0820151816006015560c08201518160070160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060e0820151816008015550505050505050505050565b815481835581811115620009af57818360005260206000209182019101620009ae919062000bb0565b5b505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10620009f757805160ff191683800117855562000a28565b8280016001018555821562000a28579182015b8281111562000a2757825182559160200191906001019062000a0a565b5b50905062000a37919062000bb0565b5090565b82805482825590600052602060002090810192821562000a7a579160200282015b8281111562000a7957825182559160200191906001019062000a5c565b5b50905062000a89919062000bb0565b5090565b81548183558181111562000abd5760090281600902836000526020600020918201910162000abc919062000bd8565b5b505050565b826002810192821562000af4579160200282015b8281111562000af357825182559160200191906001019062000ad6565b5b50905062000b03919062000bb0565b5090565b610120604051908101604052806000815260200160008152602001600081526020016000815260200162000b3a62000c63565b815260200160008152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600081525090565b826002810192821562000b9d579160200282015b8281111562000b9c57825182559160200191906001019062000b7f565b5b50905062000bac919062000bb0565b5090565b62000bd591905b8082111562000bd157600081600090555060010162000bb7565b5090565b90565b62000c6091905b8082111562000c5c5760008082016000905560018201600090556002820160009055600382016000905560048201600062000c1b919062000c85565b60068201600090556007820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905560088201600090555060090162000bdf565b5090565b90565b6040805190810160405280600290602082028038833980820191505090505090565b506000815560010160009055565b611e398062000ca36000396000f3006080604052600436106100c5576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630a23f5fb146100ca5780632d47e66b146101935780632e1a7d4d146103ba5780633cbb95f6146103e75780633f6f64be146104535780634afe62b51461048a578063627d04a6146104b45780636710aec2146104f55780636f5f75451461055b578063ad65b12b14610624578063b2112ae4146106a8578063ebf30b84146107f4578063fd31a7d014610876575b600080fd5b3480156100d657600080fd5b506100ff60048036038101908080359060200190929190803590602001909291905050506108a5565b6040518088815260200187815260200186815260200185600260200280838360005b8381101561013c578082015181840152602081019050610121565b505050509050018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200197505050505050505060405180910390f35b34801561019f57600080fd5b506101be60048036038101908080359060200190929190505050610a46565b6040518089815260200188815260200180602001806020018060200180602001806020018715151515815260200186810386528c818151815260200191508051906020019080838360005b83811015610224578082015181840152602081019050610209565b50505050905090810190601f1680156102515780820380516001836020036101000a031916815260200191505b5086810385528b818151815260200191508051906020019080838360005b8381101561028a57808201518184015260208101905061026f565b50505050905090810190601f1680156102b75780820380516001836020036101000a031916815260200191505b5086810384528a818151815260200191508051906020019080838360005b838110156102f05780820151818401526020810190506102d5565b50505050905090810190601f16801561031d5780820380516001836020036101000a031916815260200191505b50868103835289818151815260200191508051906020019060200280838360005b8381101561035957808201518184015260208101905061033e565b50505050905001868103825288818151815260200191508051906020019060200280838360005b8381101561039b578082015181840152602081019050610380565b505050509050019d505050505050505050505050505060405180910390f35b3480156103c657600080fd5b506103e560048036038101908080359060200190929190505050610d1c565b005b3480156103f357600080fd5b506103fc610e01565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b8381101561043f578082015181840152602081019050610424565b505050509050019250505060405180910390f35b34801561045f57600080fd5b506104886004803603810190808035906020019092919080359060200190929190505050610e59565b005b6104b26004803603810190808035906020019092919080359060200190929190505050610f7c565b005b3480156104c057600080fd5b506104df600480360381019080803590602001909291905050506110aa565b6040518082815260200191505060405180910390f35b34801561050157600080fd5b50610559600480360381019080803590602001909291908035906020019092919080604001906002806020026040519081016040528092919082600260200280828437820191505050505091929192905050506110cf565b005b34801561056757600080fd5b506105906004803603810190808035906020019092919080359060200190929190505050611308565b6040518088815260200187815260200186815260200185600260200280838360005b838110156105cd5780820151818401526020810190506105b2565b505050509050018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200197505050505050505060405180910390f35b34801561063057600080fd5b506106a6600480360381019080803590602001909291908035906020019092919080359060200190929190806040019060028060200260405190810160405280929190826002602002808284378201915050505050919291929080359060200190929190803590602001909291905050506114d3565b005b3480156106b457600080fd5b506107f26004803603810190808035906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919291929080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509192919290505050611688565b005b34801561080057600080fd5b5061081f600480360381019080803590602001909291905050506117c3565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b83811015610862578082015181840152602081019050610847565b505050509050019250505060405180910390f35b34801561088257600080fd5b5061088b611833565b604051808215151515815260200191505060405180910390f35b60008060006108b2611b2f565b60008060008060008a8a6000600160008481526020019081526020016000209050600081600b01838154811015156108e657fe5b90600052602060002090600902016006015411151561090457600080fd5b600160008f8152602001908152602001600020945084600b018d81548110151561092a57fe5b90600052602060002090600902019350610a2784610100604051908101604052908160008201548152602001600182015481526020016002820154815260200160038201548152602001600482016002806020026040519081016040528092919082600280156109af576020028201915b81548152602001906001019080831161099b575b50505050508152602001600682015481526020016007820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200160088201548152505061188b565b9b509b509b509b509b509b509b50505050505092959891949750929550565b600080606080606080606060008088600160008c815260200190815260200160002091508a995081600101549850816002018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b0c5780601f10610ae157610100808354040283529160200191610b0c565b820191906000526020600020905b815481529060010190602001808311610aef57829003601f168201915b50505050509750816003018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610bab5780601f10610b8057610100808354040283529160200191610bab565b820191906000526020600020905b815481529060010190602001808311610b8e57829003601f168201915b50505050509650816004018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610c4a5780601f10610c1f57610100808354040283529160200191610c4a565b820191906000526020600020905b815481529060010190602001808311610c2d57829003601f168201915b5050505050955081600501805480602002602001604051908101604052809291908181526020018280548015610c9f57602002820191906000526020600020905b815481526020019060010190808311610c8b575b5050505050945081600c0160009054906101000a900460ff16925081600601805480602002602001604051908101604052809291908181526020018280548015610d0857602002820191906000526020600020905b815481526020019060010190808311610cf4575b505050505093505050919395975091939597565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548111151515610d6a57600080fd5b80600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055503373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610dfd573d6000803e3d6000fd5b5050565b60606000805480602002602001604051908101604052809291908181526020018280548015610e4f57602002820191906000526020600020905b815481526020019060010190808311610e3b575b5050505050905090565b600080833373ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141515610eb957600080fd5b60016000868152602001908152602001600020925082600701600085815260200190815260200160002060009054906101000a900460ff161515610f5457600183600701600086815260200190815260200160002060006101000a81548160ff021916908315150217905550826006018490806001815401808255809150509060018203906000526020600020016000909192909190915055505b600091505b8260050180549050821015610f75578180600101925050610f59565b5050505050565b81426001600083815260200190815260200160002060010154111515610fa157600080fd5b8282600060016000848152602001908152602001600020905060008160090182600801600085815260200190815260200160002054815481101515610fe257fe5b90600052602060002090600902016006015411151561100057600080fd5b8585600080600160008581526020019081526020016000209150816009018260080160008581526020019081526020016000205481548110151561104057fe5b906000526020600020906009020190508160070160008260030154815260200190815260200160002060009054906101000a900460ff1615151561108357600080fd5b60003411151561109257600080fd5b61109e33348c8c6118d9565b50505050505050505050565b60008160016000848152602001908152602001600020600b0180549050915050919050565b6000806000803373ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151561113157600080fd5b600160008881526020019081526020016000209350600092505b83600b01805490508310156112ff5783600b018381548110151561116b57fe5b906000526020600020906009020191508582600301541480156111b3575084600060028110151561119857fe5b60200201518260040160006002811015156111af57fe5b0154145b80156111e457508460016002811015156111c957fe5b60200201518260040160016002811015156111e057fe5b0154145b156112f2578160060154826000015402905060648181151561120257fe5b04905080600260008460070160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550868260070160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f1ce690bab3f0797851d1673f462be38a6378af9c81188730b523525747eba55d8584604051808381526020018281526020019250505060405180910390a35b828060010193505061114b565b50505050505050565b6000806000611315611b2f565b60008060008060008a8a60006001600084815260200190815260200160002090506000816009018260080160008581526020019081526020016000205481548110151561135e57fe5b90600052602060002090600902016006015411151561137c57600080fd5b600160008f81526020019081526020016000209450846009018560080160008f8152602001908152602001600020548154811015156113b757fe5b906000526020600020906009020193506114b4846101006040519081016040529081600082015481526020016001820154815260200160028201548152602001600382015481526020016004820160028060200260405190810160405280929190826002801561143c576020028201915b815481526020019060010190808311611428575b50505050508152602001600682015481526020016007820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200160088201548152505061188b565b9b509b509b509b509b509b509b50505050505092959891949750929550565b6000806000884260016000838152602001908152602001600020600101541115156114fd57600080fd5b3373ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151561155957600080fd5b600160008b815260200190815260200160002093506000925060008460080160008a8152602001908152602001600020541415611601578360090180548091906001016115a69190611b51565b506001846009018054905003925083600a01889080600181540180825580915050906001820390600052602060002001600090919290919091505550828460080160008a81526020019081526020016000208190555061161a565b8360080160008981526020019081526020016000205492505b836009018381548110151561162b57fe5b906000526020600020906009020191508982600101819055508782600201819055508882600301819055508682600401906002611669929190611b83565b5085826006018190555084826008018190555050505050505050505050565b60003373ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415156116e657600080fd5b60016000888152602001908152602001600020905086816000018190555085816001018190555083816003019080519060200190611725929190611bc3565b508481600201908051906020019061173e929190611bc3565b5082816004019080519060200190611757929190611bc3565b5081816005019080519060200190611770929190611c43565b50600181600c0160006101000a81548160ff021916908315150217905550600087908060018154018082558091505090600182039060005260206000200160009091929091909150555050505050505050565b60608160016000848152602001908152602001600020600a0180548060200260200160405190810160405280929190818152602001828054801561182657602002820191906000526020600020905b815481526020019060010190808311611812575b5050505050915050919050565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614905090565b6000806000611898611b2f565b6000806000876040015196508760000151955087606001519450876080015193508760a0015192508760c0015191508760e001519050919395979092949650565b6000806118e4611c90565b600160008681526020019081526020016000209250826009018360080160008681526020019081526020016000205481548110151561191f57fe5b9060005260206000209060090201915081610100604051908101604052908160008201548152602001600182015481526020016002820154815260200160038201548152602001600482016002806020026040519081016040528092919082600280156119a1576020028201915b81548152602001906001019080831161198d575b50505050508152602001600682015481526020016007820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001600882015481525050905085816000018181525050868160c0019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505082600b01819080600181540180825580915050906001820390600052602060002090600902016000909192909190915060008201518160000155602082015181600101556040820151816002015560608201518160030155608082015181600401906002611ac7929190611cf2565b5060a0820151816006015560c08201518160070160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060e0820151816008015550505050505050505050565b6040805190810160405280600290602082028038833980820191505090505090565b815481835581811115611b7e57600902816009028360005260206000209182019101611b7d9190611d32565b5b505050565b8260028101928215611bb2579160200282015b82811115611bb1578251825591602001919060010190611b96565b5b509050611bbf9190611db8565b5090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10611c0457805160ff1916838001178555611c32565b82800160010185558215611c32579182015b82811115611c31578251825591602001919060010190611c16565b5b509050611c3f9190611db8565b5090565b828054828255906000526020600020908101928215611c7f579160200282015b82811115611c7e578251825591602001919060010190611c63565b5b509050611c8c9190611db8565b5090565b6101206040519081016040528060008152602001600081526020016000815260200160008152602001611cc1611ddd565b815260200160008152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600081525090565b8260028101928215611d21579160200282015b82811115611d20578251825591602001919060010190611d05565b5b509050611d2e9190611db8565b5090565b611db591905b80821115611db157600080820160009055600182016000905560028201600090556003820160009055600482016000611d719190611dff565b60068201600090556007820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055600882016000905550600901611d38565b5090565b90565b611dda91905b80821115611dd6576000816000905550600101611dbe565b5090565b90565b6040805190810160405280600290602082028038833980820191505090505090565b5060008155600101600090555600a165627a7a7230582074837974d98ec581ba77c152868ec2eebb02635b9c25c22ee70bf82d7467d4970029"
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"}];
var bytecode = "608060405234801561001057600080fd5b5033600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550611e39806100616000396000f3006080604052600436106100c5576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630a23f5fb146100ca5780632d47e66b146101935780632e1a7d4d146103ba5780633cbb95f6146103e75780633f6f64be146104535780634afe62b51461048a578063627d04a6146104b45780636710aec2146104f55780636f5f75451461055b578063ad65b12b14610624578063b2112ae4146106a8578063ebf30b84146107f4578063fd31a7d014610876575b600080fd5b3480156100d657600080fd5b506100ff60048036038101908080359060200190929190803590602001909291905050506108a5565b6040518088815260200187815260200186815260200185600260200280838360005b8381101561013c578082015181840152602081019050610121565b505050509050018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200197505050505050505060405180910390f35b34801561019f57600080fd5b506101be60048036038101908080359060200190929190505050610a46565b6040518089815260200188815260200180602001806020018060200180602001806020018715151515815260200186810386528c818151815260200191508051906020019080838360005b83811015610224578082015181840152602081019050610209565b50505050905090810190601f1680156102515780820380516001836020036101000a031916815260200191505b5086810385528b818151815260200191508051906020019080838360005b8381101561028a57808201518184015260208101905061026f565b50505050905090810190601f1680156102b75780820380516001836020036101000a031916815260200191505b5086810384528a818151815260200191508051906020019080838360005b838110156102f05780820151818401526020810190506102d5565b50505050905090810190601f16801561031d5780820380516001836020036101000a031916815260200191505b50868103835289818151815260200191508051906020019060200280838360005b8381101561035957808201518184015260208101905061033e565b50505050905001868103825288818151815260200191508051906020019060200280838360005b8381101561039b578082015181840152602081019050610380565b505050509050019d505050505050505050505050505060405180910390f35b3480156103c657600080fd5b506103e560048036038101908080359060200190929190505050610d1c565b005b3480156103f357600080fd5b506103fc610e01565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b8381101561043f578082015181840152602081019050610424565b505050509050019250505060405180910390f35b34801561045f57600080fd5b506104886004803603810190808035906020019092919080359060200190929190505050610e59565b005b6104b26004803603810190808035906020019092919080359060200190929190505050610f7c565b005b3480156104c057600080fd5b506104df600480360381019080803590602001909291905050506110aa565b6040518082815260200191505060405180910390f35b34801561050157600080fd5b50610559600480360381019080803590602001909291908035906020019092919080604001906002806020026040519081016040528092919082600260200280828437820191505050505091929192905050506110cf565b005b34801561056757600080fd5b506105906004803603810190808035906020019092919080359060200190929190505050611308565b6040518088815260200187815260200186815260200185600260200280838360005b838110156105cd5780820151818401526020810190506105b2565b505050509050018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200197505050505050505060405180910390f35b34801561063057600080fd5b506106a6600480360381019080803590602001909291908035906020019092919080359060200190929190806040019060028060200260405190810160405280929190826002602002808284378201915050505050919291929080359060200190929190803590602001909291905050506114d3565b005b3480156106b457600080fd5b506107f26004803603810190808035906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919291929080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509192919290505050611688565b005b34801561080057600080fd5b5061081f600480360381019080803590602001909291905050506117c3565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b83811015610862578082015181840152602081019050610847565b505050509050019250505060405180910390f35b34801561088257600080fd5b5061088b611833565b604051808215151515815260200191505060405180910390f35b60008060006108b2611b2f565b60008060008060008a8a6000600160008481526020019081526020016000209050600081600b01838154811015156108e657fe5b90600052602060002090600902016006015411151561090457600080fd5b600160008f8152602001908152602001600020945084600b018d81548110151561092a57fe5b90600052602060002090600902019350610a2784610100604051908101604052908160008201548152602001600182015481526020016002820154815260200160038201548152602001600482016002806020026040519081016040528092919082600280156109af576020028201915b81548152602001906001019080831161099b575b50505050508152602001600682015481526020016007820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200160088201548152505061188b565b9b509b509b509b509b509b509b50505050505092959891949750929550565b600080606080606080606060008088600160008c815260200190815260200160002091508a995081600101549850816002018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b0c5780601f10610ae157610100808354040283529160200191610b0c565b820191906000526020600020905b815481529060010190602001808311610aef57829003601f168201915b50505050509750816003018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610bab5780601f10610b8057610100808354040283529160200191610bab565b820191906000526020600020905b815481529060010190602001808311610b8e57829003601f168201915b50505050509650816004018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610c4a5780601f10610c1f57610100808354040283529160200191610c4a565b820191906000526020600020905b815481529060010190602001808311610c2d57829003601f168201915b5050505050955081600501805480602002602001604051908101604052809291908181526020018280548015610c9f57602002820191906000526020600020905b815481526020019060010190808311610c8b575b5050505050945081600c0160009054906101000a900460ff16925081600601805480602002602001604051908101604052809291908181526020018280548015610d0857602002820191906000526020600020905b815481526020019060010190808311610cf4575b505050505093505050919395975091939597565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548111151515610d6a57600080fd5b80600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055503373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610dfd573d6000803e3d6000fd5b5050565b60606000805480602002602001604051908101604052809291908181526020018280548015610e4f57602002820191906000526020600020905b815481526020019060010190808311610e3b575b5050505050905090565b600080833373ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141515610eb957600080fd5b60016000868152602001908152602001600020925082600701600085815260200190815260200160002060009054906101000a900460ff161515610f5457600183600701600086815260200190815260200160002060006101000a81548160ff021916908315150217905550826006018490806001815401808255809150509060018203906000526020600020016000909192909190915055505b600091505b8260050180549050821015610f75578180600101925050610f59565b5050505050565b81426001600083815260200190815260200160002060010154111515610fa157600080fd5b8282600060016000848152602001908152602001600020905060008160090182600801600085815260200190815260200160002054815481101515610fe257fe5b90600052602060002090600902016006015411151561100057600080fd5b8585600080600160008581526020019081526020016000209150816009018260080160008581526020019081526020016000205481548110151561104057fe5b906000526020600020906009020190508160070160008260030154815260200190815260200160002060009054906101000a900460ff1615151561108357600080fd5b60003411151561109257600080fd5b61109e33348c8c6118d9565b50505050505050505050565b60008160016000848152602001908152602001600020600b0180549050915050919050565b6000806000803373ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151561113157600080fd5b600160008881526020019081526020016000209350600092505b83600b01805490508310156112ff5783600b018381548110151561116b57fe5b906000526020600020906009020191508582600301541480156111b3575084600060028110151561119857fe5b60200201518260040160006002811015156111af57fe5b0154145b80156111e457508460016002811015156111c957fe5b60200201518260040160016002811015156111e057fe5b0154145b156112f2578160060154826000015402905060648181151561120257fe5b04905080600260008460070160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550868260070160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f1ce690bab3f0797851d1673f462be38a6378af9c81188730b523525747eba55d8584604051808381526020018281526020019250505060405180910390a35b828060010193505061114b565b50505050505050565b6000806000611315611b2f565b60008060008060008a8a60006001600084815260200190815260200160002090506000816009018260080160008581526020019081526020016000205481548110151561135e57fe5b90600052602060002090600902016006015411151561137c57600080fd5b600160008f81526020019081526020016000209450846009018560080160008f8152602001908152602001600020548154811015156113b757fe5b906000526020600020906009020193506114b4846101006040519081016040529081600082015481526020016001820154815260200160028201548152602001600382015481526020016004820160028060200260405190810160405280929190826002801561143c576020028201915b815481526020019060010190808311611428575b50505050508152602001600682015481526020016007820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200160088201548152505061188b565b9b509b509b509b509b509b509b50505050505092959891949750929550565b6000806000884260016000838152602001908152602001600020600101541115156114fd57600080fd5b3373ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151561155957600080fd5b600160008b815260200190815260200160002093506000925060008460080160008a8152602001908152602001600020541415611601578360090180548091906001016115a69190611b51565b506001846009018054905003925083600a01889080600181540180825580915050906001820390600052602060002001600090919290919091505550828460080160008a81526020019081526020016000208190555061161a565b8360080160008981526020019081526020016000205492505b836009018381548110151561162b57fe5b906000526020600020906009020191508982600101819055508782600201819055508882600301819055508682600401906002611669929190611b83565b5085826006018190555084826008018190555050505050505050505050565b60003373ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415156116e657600080fd5b60016000888152602001908152602001600020905086816000018190555085816001018190555083816003019080519060200190611725929190611bc3565b508481600201908051906020019061173e929190611bc3565b5082816004019080519060200190611757929190611bc3565b5081816005019080519060200190611770929190611c43565b50600181600c0160006101000a81548160ff021916908315150217905550600087908060018154018082558091505090600182039060005260206000200160009091929091909150555050505050505050565b60608160016000848152602001908152602001600020600a0180548060200260200160405190810160405280929190818152602001828054801561182657602002820191906000526020600020905b815481526020019060010190808311611812575b5050505050915050919050565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614905090565b6000806000611898611b2f565b6000806000876040015196508760000151955087606001519450876080015193508760a0015192508760c0015191508760e001519050919395979092949650565b6000806118e4611c90565b600160008681526020019081526020016000209250826009018360080160008681526020019081526020016000205481548110151561191f57fe5b9060005260206000209060090201915081610100604051908101604052908160008201548152602001600182015481526020016002820154815260200160038201548152602001600482016002806020026040519081016040528092919082600280156119a1576020028201915b81548152602001906001019080831161198d575b50505050508152602001600682015481526020016007820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001600882015481525050905085816000018181525050868160c0019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505082600b01819080600181540180825580915050906001820390600052602060002090600902016000909192909190915060008201518160000155602082015181600101556040820151816002015560608201518160030155608082015181600401906002611ac7929190611cf2565b5060a0820151816006015560c08201518160070160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060e0820151816008015550505050505050505050565b6040805190810160405280600290602082028038833980820191505090505090565b815481835581811115611b7e57600902816009028360005260206000209182019101611b7d9190611d32565b5b505050565b8260028101928215611bb2579160200282015b82811115611bb1578251825591602001919060010190611b96565b5b509050611bbf9190611db8565b5090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10611c0457805160ff1916838001178555611c32565b82800160010185558215611c32579182015b82811115611c31578251825591602001919060010190611c16565b5b509050611c3f9190611db8565b5090565b828054828255906000526020600020908101928215611c7f579160200282015b82811115611c7e578251825591602001919060010190611c63565b5b509050611c8c9190611db8565b5090565b6101206040519081016040528060008152602001600081526020016000815260200160008152602001611cc1611ddd565b815260200160008152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600081525090565b8260028101928215611d21579160200282015b82811115611d20578251825591602001919060010190611d05565b5b509050611d2e9190611db8565b5090565b611db591905b80821115611db157600080820160009055600182016000905560028201600090556003820160009055600482016000611d719190611dff565b60068201600090556007820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055600882016000905550600901611d38565b5090565b90565b611dda91905b80821115611dd6576000816000905550600101611dbe565b5090565b90565b6040805190810160405280600290602082028038833980820191505090505090565b5060008155600101600090555600a165627a7a72305820ffd52ffbd0359799c7098bf5dec156a2529cc01dde053139b13abd6bc213a4460029"
//create the contract instance. We can use this instance to publish or connect to a published contract
var Contract = web3.eth.contract(abi);
......
......@@ -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}
</Dropzone>
</div>
)
}
......
import React, { Component } from "react";
import { Container, Menu, Image, Dropdown, Header, Segment } from "semantic-ui-react"
import { Input, Button, Container, Menu, Image, Dropdown, Header, Segment } from "semantic-ui-react"
import {xml2json} from 'xml-js'
export default class BetPage extends Component {
state = {
fetching: false,
fetched: false,
events: [],
availableBets: [],
chosenBetID: "",
chosenBet: [],
amount: 0,
constructor(props) {
super(props)
this.state = {
fetching: false,
fetched: false,
sorted: false,
events: [],
availableBets: [],
availableTypes: [],
closedTypes: [],
chosenBetID: "",
chosenBet: [],
chosenEventID: [],
yourBet: {},
yourBetID: 0,
amount: 0,
}
this.getAllEvents()
}
betTypes = {
1 : {
name: "Match Results",
bets: [],
},
2: {
name: "Correct Score"
name: "Correct Score",
bets: []
},
3: {
name: "Total Score"
name: "Total Score",
bets: []
},
4: {
name: "Penalty in Match"
name: "Penalty in Match",
bets: []
}
}
handleChange(e, {name, value}) {
this.setState({ [name] : value })
if (name === "amount") {
this.state.yourBet.amount = value;
}
}
parseBetTypes(raw) {
if (raw.length > 0 ){
let raw0 = raw[0].toFixed()
let raw1 = raw[1].toFixed()
let rawBetTypes = [ raw0, raw1 ]
if (raw.length > 0){
let rawBetTypes = []
raw.forEach((betType) => {
rawBetTypes.push(betType.toFixed())
})
let betTypes = []
rawBetTypes.forEach((betType) => {
betTypes.push(this.betTypes[betType])
})
......@@ -43,9 +72,29 @@ export default class BetPage extends Component {
}
}
parseBet(raw) {
// amount
// betType
// values
// odds
// user
// number
let bet = {
id: raw[0].toFixed(),
amount: raw[1].toFixed(),
betType: this.parseBetTypes([raw[2]]),
values: [ raw[3][0].toFixed(), raw[3][1].toFixed() ],
odds: parseInt(raw[4].toFixed()) / 100,
user: raw[5],
number: raw[6].toFixed()
}
return bet
}
parseEvent(propArray) {
//bigInt
console.log(propArray)
let id = propArray[0].toFixed()
let ts = propArray[1].toFixed()
......@@ -60,6 +109,10 @@ export default class BetPage extends Component {
//bool
let active = propArray[7]
this.setState({
availableTypes: betTypes,
})
return {
id: id,
timestamp: ts,
......@@ -71,55 +124,95 @@ export default class BetPage extends Component {
}
}
constructor(props) {
super(props)
// Don't ask
this.getAllEvents()
}
handleClick = (e) => {
this.setState({ chosenBetID: e.currentTarget.dataset.id })
this.state.availableTypes.forEach((type) => {
type.bets = []
})
for (let i = 0; i < this.state.events.length; i++) {
if (this.state.events[i].id === e.currentTarget.dataset.id ) {
this.setState({ chosenBetID: this.state.events[i] })
this.state.chosenBet = this.state.events[i]
this.state.closedTypes.push(this.state.events[i].closedBetTypes)
}
}
this.setState({ chosenBetID: e.currentTarget.dataset.id })
this.getAvailableBets(e.currentTarget.dataset.id)
}
async getAvailableBets() {
let availableBets = await getEventAvailableBetsObjects(this.state.chosenBetID); //eslint-disable-line
console.log(availableBets)
this.setState({ availableBets: availableBets })
async getAvailableBets(id) {
let availableBets = await getEventAvailableBetsObjects(id); //eslint-disable-line
let parsedBets = []
availableBets.forEach((bet) => {
parsedBets.push(this.parseBet(bet))
})
if(this.state.chosenBet.home === "Bulgaria" || this.state.chosenBet.away === "Bulgaria" ) {
let shit = "<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' /> <Selection ID='60475707' Number='2' Description='No' OddsDecimal='1.24' /> </Market> </FootballEvent>"
let json = JSON.parse(xml2json(shit)).elements[0]
console.log(json)
parsedBets.push.apply([])
}
this.setState({ availableBets: parsedBets })
this.betsByType()
}
async getAllEvents() {
let rawEvents = await getEvents() //eslint-disable-line
console.log(rawEvents)
rawEvents.forEach((event) => {
this.state.events.push(this.parseEvent(event))
})
console.log(this.state.events)
this.setState({ events: this.state.events })
}
betItem () {
return (
<div>
Your bet
</div>
)
betItem (object, i) {
let betType = object.betType[0]
let newObj = {...object, betType: undefined}
if (betType.name === "Match Results") {
return (
<Segment key={i} className="bet-item" data-obj={JSON.stringify(newObj)} onClick={this.addBet.bind(this)}>
{ newObj.values[0] === newObj.values[1] ? "DRAW" : newObj.values[0] == 1 ? "WIN (Home)" : "LOSE (Home)"} { newObj.values[0] === newObj.values[1] ? "" : newObj.values[1] == 1 ? " : WIN (Away)" : " : LOSE (Away)"}
<p>(Odds {newObj.odds})</p>
</Segment>
)
} else {
return (
<Segment key={i} className="bet-item" data-obj={JSON.stringify(newObj)} onClick={this.addBet.bind(this)}>
{newObj.values[0] + " : " + newObj.values[1] + " " }
(Odds {newObj.odds})
</Segment>
)
}
}
betType(type) {
//Sorting
betsByType() {
this.state.availableBets.forEach((bet) => {
this.state.availableTypes.forEach((type) => {
if(bet.betType[0].name === type.name) {
type.bets.push(bet)
}
})
})
this.setState({ solved: true })
}
betType(type, i) {
return (
<div>
<Header>Match Scores</Header>
</div>
<Segment key={i}>
<Header>{type.name}</Header>
{ this.state.availableTypes.includes(this.state.closedTypes[i]) ? "Closed" :
this.state.availableTypes[this.state.availableTypes.indexOf(type)].bets !== 0 ?
this.state.availableTypes[this.state.availableTypes.indexOf(type)].bets.map((object, i) => this.betItem(object, i)) : "No bets" }
</Segment>
)
}
......@@ -134,19 +227,29 @@ export default class BetPage extends Component {
)
}
addBet(e) {
let Bet = JSON.parse(e.currentTarget.dataset.obj)
this.setState({ yourBet: Bet })
}
async submitBet() {
let status = await placeBet(this.state.chosenBetID, this.state.yourBet.id, this.state.amount) //eslint-disable-line
}
renderAllEvents() {
return (
this.state.events.map((object, i) => this.eventItem(object, i))
)
}
renderAvailableBets() {
if (this.state.chosenBetID !== "") {
return (
<div className="available-bet">
this vs that
{/* {this.availableBets[0]} vs {this.state.availableBets[0]} */}
{this.state.chosenBet.betTypes.map((object, i) => {
return this.betType(object, i)
})}
</div>
)
}
......@@ -156,16 +259,22 @@ export default class BetPage extends Component {
return (
<div className="chosen-bets">
<Segment>
{this.state.chosenBet.away} vs {this.state.chosenBet.home}
odds 1.29
<b>{this.state.chosenBet.away} vs {this.state.chosenBet.home}</b>
<p>Odds: {this.state.yourBet.odds}</p>
<p>Amount to bet:</p>
<Input name="amount" type="numbers" onChange={this.handleChange.bind(this)} value={this.state.amount}/>
<br/>
<p>Potential profit:</p>
{this.state.amount ? Math.round(this.state.yourBet.odds * this.state.amount * 100) / 100 : "None"}
</Segment>
<Button color="green" onClick={this.submitBet.bind(this)}>
Submit your bet
</Button>
</div>
)
}
render() {
console.log(this.state.chosenBetID)
render() {
return(
<div className="bet-page">
{/* Nav bar */}
......@@ -180,16 +289,16 @@ export default class BetPage extends Component {
{/* Nav bar */}
<div className="content">
<Segment className="rear all-event-types">
<Header attached> All Bets/Sports </Header>
{this.state.events.length !== 0 ? this.renderAllEvents() : "Nothing here now"}
<Header attached className="titles"> All Bets/Sports </Header>
{this.state.events.length !== 0 ? this.renderAllEvents() : <p className="no-bet"> No bet chosen </p>}
</Segment>
<Segment className="front all-available-bets">
<Header attached className="titles">'Selected Sport' All Bets </Header>
{this.state.chosenBetID !== "" ? this.renderAvailableBets() : "No bet chosen"}
<Header attached className="titles">{this.state.chosenBet.sport ? this.state.chosenBet.sport + ">" : null} Available Bets { this.state.chosenBet.length !== 0 ? " - " + this.state.chosenBet.home + " vs " + this.state.chosenBet.away : null} </Header>
{this.state.chosenBetID !== "" ? this.renderAvailableBets() : <p className="no-bet"> No bet chosen </p>}
</Segment>
<Segment className="rear bets-to-submit">
<Header attached className="titles"> Current bets </Header>
{this.state.chosenBet.length !== 0 ? this.renderChosenBet() : "No bet chosen"}
{this.state.chosenBetID !== "" ? this.renderChosenBet() : <p className="no-bet"> No bet chosen </p>}
</Segment>
</div>
......
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