Last active
October 16, 2018 09:53
-
-
Save merlox/1ebb8c26b4c66b6b6af8ed068ef7004b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function placeBet(bet) { | |
if(parseInt(bet) > parseInt(getGameBalance())) return status("You can't bet more than your current balance") | |
if(parseInt(bet) > parseInt(getOtherGameBalance())) return status("You can't bet more than your opponent's current balance") | |
if(parseInt(bet) > parseInt(getGameEscrow())) return status("You can't bet more than your escrow") | |
const nonce = Math.floor(Math.random() * 1e16) | |
const hash = generateHash(nonce, activeDice, bet, getGameBalance(), sequence) | |
const signedMessage = await signMessage(hash) | |
let data = { | |
signedMessage: signedMessage, | |
nonce: nonce, | |
call: activeDice, | |
bet: bet, | |
sequence: sequence, | |
sender: web3.eth.defaultAccount | |
} | |
if(isThisPlayer1) { | |
socket.emit('signed-message-player-1', data) | |
} else { | |
socket.emit('signed-message-player-2', data) | |
} | |
sequence++ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment