Skip to content

Commit

Permalink
updated Verifications
Browse files Browse the repository at this point in the history
  • Loading branch information
Devilla committed May 14, 2024
1 parent 7d1f3d8 commit 5d401e6
Showing 1 changed file with 261 additions and 21 deletions.
282 changes: 261 additions & 21 deletions src/components/Verification.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,244 @@
<div className="VerificationUI-Stake" className="table-responsive" style={{ display: verification ? 'block' : 'none', fontSize: '11px' }}>
import React, { Component } from 'react';
import SweetAlert from 'react-bootstrap-sweetalert';
import { getBetData, getBetDataStake, getBetDataPrimeDice, getBetDataCryptoGames } from '../services/verificationService';
import { getServerSeed } from '../services/verificationService';
import { getServerSeedPrimeDice } from '../services/verificationService';
import { getServerSeedCryptoGames } from '../services/verificationService';
import { getServerSeedHash } from '../services/verificationService';
import { getServerSeedHashPrimeDice } from '../services/verificationService';
import { getServerSeedHashCryptoGames } from '../services/verificationService';

class Verification extends Component {
constructor(props) {
super(props);
this.state = {
gettingStarted: false,
settings: false,
verification: false,
operators: false,
primeDice: false,

verify: false,
showAlert: false,
diceVerify: '',

betData: [],
serverSeed: '',
serverSeedHash: '',
clientSeed: '',
nonce: '',
numberBetsVerFailed: 0,
isNonceManipulated: false,
active_game: '',
popupResult: [],
cryptoGames: false,
apiKey: '',


}
}

componentDidMount() {
this.setState({ verification: this.props.verification });
}

handleVerifyBet = (serverSeed, clientSeed, nonce) => {
this.setState({ verify: true });
this.setState({ diceVerify: this.verifyBet(serverSeed, clientSeed, nonce) });

};


handleVerifyBetPrimeDice = (serverSeed, clientSeed, nonce) => {

this.setState({ verify: true });

this.setState({ diceVerify: this.verifyBetPrimeDice(serverSeed, clientSeed, nonce) });
};



handleVerifyBetCryptoGames = (serverSeed, clientSeed, nonce) => {
this.setState({ verify: true });
this.setState({ diceVerify: this.verifyBetCryptoGames(serverSeed, clientSeed, nonce) });
};

verifyBet = (serverSeed, clientSeed, nonce) => {
let hash = getServerSeedHash(serverSeed, clientSeed, nonce);
let roll = parseInt(hash.substr(0, 8), 16);
let result = roll % 10000;


return result;

};

verifyBetPrimeDice = (serverSeed, clientSeed, nonce) => {
let hash = getServerSeedHashPrimeDice(serverSeed, clientSeed, nonce);
let roll = parseInt(hash.substr(0, 8), 16);
let result = roll % 10000;

return result;

};

verifyBetCryptoGames = (serverSeed, clientSeed, nonce) => {
let hash = getServerSeedHashCryptoGames(serverSeed, clientSeed, nonce);
let roll = parseInt(hash.substr(0, 8), 16);
let result = roll % 10000;

return result;

};



processBets = () => {
let betData = getBetData();
let numberBetsVerFailed = 0;
let isNonceManipulated = false;
betData.forEach((element) => {
let hash = getServerSeedHash(this.state.serverSeed, element.clientSeed, element.nonce);
let roll = parseInt(hash.substr(0, 8), 16);
let result = roll % 10000;
element.isVerified = result < element.target;
if (!element.isVerified) {
numberBetsVerFailed++;
}

if (element.nonce !== this.state.nonce) {
isNonceManipulated = true;
}

});


this.setState({ betData, numberBetsVerFailed, isNonceManipulated });

};

processBetsStake = () => {

let betData = getBetDataStake();



let numberBetsVerFailed = 0;


let isNonceManipulated = false;

betData.forEach((element) => {
let hash = getServerSeedHash(this.state.serverSeed, element.clientSeed, element.nonce);
let roll = parseInt(hash.substr(0, 8), 16);
let result = roll % 10000;

element.isVerified = result < element.target;

if (!element.isVerified) {
numberBetsVerFailed++;
}



if (element.nonce !== this.state.nonce) {

isNonceManipulated = true;
}

});

this.setState({ betData, numberBetsVerFailed, isNonceManipulated });



};




processBetsPrimeDice = () => {
let betData = getBetDataPrimeDice();
let numberBetsVerFailed = 0;
let isNonceManipulated = false;
betData.forEach((element) => {
let hash = getServerSeedHashPrimeDice(this.state.serverSeed, element.clientSeed, element.nonce);
let roll = parseInt(hash.substr(0, 8), 16);

let result = roll % 10000;

element.isVerified = result < element.target;



if (!element.isVerified) {
numberBetsVerFailed++;

}

if (element.nonce !== this.state.nonce) {
isNonceManipulated = true;
}


});

this.setState({ betData, numberBetsVerFailed, isNonceManipulated });

};

processBetsCryptoGames = () => {
let betData = getBetDataCryptoGames();
let numberBetsVerFailed = 0;
let isNonceManipulated = false;
betData.forEach((element) => {
let hash = getServerSeedHashCryptoGames(this.state.serverSeed, element.clientSeed, element.nonce);
let roll = parseInt(hash.substr(0, 8), 16);
let result = roll % 10000;
element.isVerified = result < element.target;
if (!element.isVerified) {
numberBetsVerFailed++;
}

if (element.nonce !== this.state.nonce) {
isNonceManipulated = true;
}

});


this.setState({ betData, numberBetsVerFailed, isNonceManipulated });

};

getServerSeed = (apiKey) => {
let serverSeed = getServerSeed(apiKey);
this.setState({ serverSeed });
};

getServerSeedPrimeDice = (apiKey) => {
let serverSeed = getServerSeedPrimeDice(apiKey);
this.setState({ serverSeed });
};

getServerSeedCryptoGames = (apiKey) => {
let serverSeed = getServerSeedCryptoGames(apiKey);
this.setState({ serverSeed });
};

hideAlertConfirm = () => {
this.setState({ showAlert: false });
};


render() {
const { verification, betData, numberBetsVerFailed, isNonceManipulated, diceVerify, verify, showAlert, serverSeed, clientSeed, nonce, cryptoGames, primeDice, apiKey } = this.state;

return (



<><div className="VerificationUI-Stake table-responsive" style={{ display: verification ? 'block' : 'none', fontSize: '11px' }}>

<span className="alert alert-success p-2">
<span>Nonce</span>
Expand Down Expand Up @@ -49,10 +289,9 @@
<td>
{item.element.isVerified
? <a href="#" className="badge badge-pill badge-success">Success</a>
: <a href="#" className="badge badge-pill badge-danger">Failed</a>
}
: <a href="#" className="badge badge-pill badge-danger">Failed</a>}
</td>
</tr>
</tr>;
})}
</tbody>
</table>
Expand Down Expand Up @@ -88,9 +327,8 @@
{(item.element.game === 'baccarat' || item.element.game === 'hilo' || item.element.game === 'blackjack' || item.element.game === 'diamondPoker' || item.element.game === 'videoPoker' || item.element.game === 'mines' || item.element.game === 'keno' || item.element.game === 'plinko')
? <button className="btn btn-info" onClick={() => {
this.setState({ showAlert: true, active_game: item.element.game, popupResult: item.element.isVerified });
}} title="Results"> </button>
: item.element.isVerified
}
} } title="Results"> </button>
: item.element.isVerified}

{showAlert &&
<SweetAlert
Expand All @@ -113,9 +351,9 @@
{numOfRows.map((i) => {
return <td key={nonce + '' + j * 5 + i}>
<img src={require((popupResult[0] === ((j) * 5 + (i))) || (popupResult[1] === ((j) * 5 + (i))) || (popupResult[2] === ((j) * 5 + (i))) ? './images/mine.png' : './images/gem.png')} style={{ width: "90%" }} />
</td>
</td>;
})}
</tr>)
</tr>);
})}
</tbody>
</table>
Expand All @@ -129,7 +367,7 @@
<button className={(popupResult[0] === ((j) * 8 + (i))) || (popupResult[1] === ((j) * 8 + (i))) || (popupResult[2] === ((j) * 8 + (i))) || (popupResult[4] === ((j) * 8 + (i))) || (popupResult[4] === ((j) * 8 + (i))) || (popupResult[5] === ((j) * 8 + (i))) || (popupResult[6] === ((j) * 8 + (i))) || (popupResult[7] === ((j) * 8 + (i))) || (popupResult[8] === ((j) * 8 + (i))) || (popupResult[9] === ((j) * 8 + (i))) ? 'btn btn-success' : 'btn btn-info'}>{(j) * 8 + i + 1} </button>
</td>);
})}
</tr>)
</tr>);
})}
</tbody>
</table>
Expand All @@ -140,32 +378,29 @@
})}
</SweetAlert>}
</td>
</tr>
</tr>;
})}
</tbody>
</table>
</div>

</div>


<div className="VerificationUI-CryptoGames table-responsive" style={{ display: verification && cryptoGames ? 'block' : 'none', fontSize: '11px' }}>
</div><div className="VerificationUI-CryptoGames table-responsive" style={{ display: verification && cryptoGames ? 'block' : 'none', fontSize: '11px' }}>
<div className="nav-wrapper">
<ul className="nav nav-pills nav-fill flex-md-row" id="tabs-icons-text" role="tablist">
<li className="nav-item" onClick={() => {
this.setState({ gettingStarted: false, settings: true, verification: false, operators: false });
this.getServerSeed(apiKey)
}}>
this.getServerSeed(apiKey);
} }>
<a className="nav-link mb-sm-3 mb-md-0" id="tabs-icons-text-1-tab" data-toggle="tab" href="#tabs-icons-text-1" role="tab" aria-controls="tabs-icons-text-1" aria-selected="true"><i className="fa fa-cloud-upload-96 mr-2"></i>Settings</a>
</li>
<li className="nav-item show" onClick={() => {
this.setState({ gettingStarted: false, settings: false, verification: true, operators: false });
}}>
} }>
<a className="nav-link mb-sm-3 mb-md-0" id="tabs-icons-text-2-tab" data-toggle="tab" href="#tabs-icons-text-2" role="tab" aria-controls="tabs-icons-text-2" aria-selected="false"><i className="fa fa-bell-55 mr-2"></i>Veri-----fication</a>
</li>
<li className="nav-item" onClick={() => {
this.setState({ gettingStarted: false, settings: false, verification: false, operators: true });
}}>
} }>
<a className="nav-link mb-sm-3 mb-md-0" id="tabs-icons-text-3-tab" data-toggle="tab" href="#tabs-icons-text-3" role="tab" aria-controls="tabs-icons-text-3" aria-selected="false"><i className="fa fa-calendar-grid-58 mr-2"></i>Casinos</a>
</li>
</ul>
Expand All @@ -176,7 +411,7 @@
<button type="button" className="btn btn-secondary m-2" onClick={() => {
this.handleVerifyBetPrimeDice(serverSeedHash, clientSeed, nonce);
console.log(serverSeedHash, clientSeed, nonce);
}}> Verify</button>
} }> Verify</button>

</div>

Expand All @@ -193,4 +428,9 @@
Client Seed : {clientSeed}
</div>
</div>
</div>
</div></>
)
}
}

export default Verification;

0 comments on commit 5d401e6

Please sign in to comment.