mirror of
https://github.com/fluencelabs/lazy-snark
synced 2025-06-09 21:11:26 +00:00
Version ready for deploy
This commit is contained in:
parent
1610284b41
commit
ff7e3ce92b
@ -6,7 +6,6 @@
|
|||||||
<title>Lazy snark dashboard</title>
|
<title>Lazy snark dashboard</title>
|
||||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||||
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
|
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
|
||||||
<!-- <script src="https://cdn.jsdelivr.net/npm/web3@1.0.0-beta.55/dist/web3.umd.min.js"></script>-->
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
@ -38,6 +37,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-sm-3">
|
<div class="col-sm-3">
|
||||||
<button type="button" class="btn btn-primary" id="challenge-0">Challenge on Fluence!</button>
|
<button type="button" class="btn btn-primary" id="challenge-0">Challenge on Fluence!</button>
|
||||||
|
<p><a id = "link-0" target="_blank"></a></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row 2">
|
<div class="row 2">
|
||||||
@ -49,6 +49,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-sm-3">
|
<div class="col-sm-3">
|
||||||
<button type="button" class="btn btn-primary" id="challenge-1">Challenge on Fluence!</button>
|
<button type="button" class="btn btn-primary" id="challenge-1">Challenge on Fluence!</button>
|
||||||
|
<p><a id = "link-1" target="_blank"></a></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row 3">
|
<div class="row 3">
|
||||||
@ -60,6 +61,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-sm-3">
|
<div class="col-sm-3">
|
||||||
<button type="button" class="btn btn-primary" id="challenge-2">Challenge on Fluence!</button>
|
<button type="button" class="btn btn-primary" id="challenge-2">Challenge on Fluence!</button>
|
||||||
|
<p><a id = "link-2" target="_blank"></a></p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row 4">
|
<div class="row 4">
|
||||||
@ -71,6 +74,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-sm-3">
|
<div class="col-sm-3">
|
||||||
<button type="button" class="btn btn-primary" id="challenge-3">Challenge on Fluence!</button>
|
<button type="button" class="btn btn-primary" id="challenge-3">Challenge on Fluence!</button>
|
||||||
|
<p><a id = "link-3" target="_blank"></a></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row 5">
|
<div class="row 5">
|
||||||
@ -82,6 +86,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-sm-3">
|
<div class="col-sm-3">
|
||||||
<button type="button" class="btn btn-primary" id="challenge-4">Challenge on Fluence!</button>
|
<button type="button" class="btn btn-primary" id="challenge-4">Challenge on Fluence!</button>
|
||||||
|
<p><a id = "link-4" target="_blank"></a></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//CONNECT FLUENCE
|
//CONNECT FLUENCE
|
||||||
import * as fluence from "fluence";
|
import * as fluence from "fluence";
|
||||||
|
|
||||||
let session;
|
//let session;
|
||||||
window.onload = function () {
|
window.onload = function () {
|
||||||
let contractAddress = "0xeFF91455de6D4CF57C141bD8bF819E5f873c1A01";
|
let contractAddress = "0xeFF91455de6D4CF57C141bD8bF819E5f873c1A01";
|
||||||
|
|
||||||
@ -14,25 +14,17 @@ window.onload = function () {
|
|||||||
// create a session between client and backend application, and then join the game
|
// create a session between client and backend application, and then join the game
|
||||||
fluence.connect(contractAddress, appId, ethUrl).then((s) => {
|
fluence.connect(contractAddress, appId, ethUrl).then((s) => {
|
||||||
console.log("Session created");
|
console.log("Session created");
|
||||||
session = s;
|
window.session = s;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
window.getResultAsString = function (result) {
|
||||||
|
return result.result().then((r) => r.asString())
|
||||||
|
};
|
||||||
|
|
||||||
var contractInstance;
|
var contractInstance;
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
// window.addEventListener('load', () => {
|
|
||||||
// if (typeof Web3 !== 'undefined') {
|
|
||||||
// let web3js = new Web3(web3.currentProvider);
|
|
||||||
// } else {
|
|
||||||
// console.log('No web3? You should consider trying MetaMask!');
|
|
||||||
// let web3js = new Web3(new Web3.providers.HttpProvider('http://localhost:8080'));
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
// console.log('provider');
|
|
||||||
// console.log(web3js);
|
|
||||||
|
|
||||||
var controllerAddress = '0x1cca1f0be338c747b11a16aba8d0905251628bdf';
|
var controllerAddress = '0x1cca1f0be338c747b11a16aba8d0905251628bdf';
|
||||||
let ControllerAbi = [
|
let ControllerAbi = [
|
||||||
@ -377,17 +369,19 @@ $(document).ready(function() {
|
|||||||
];
|
];
|
||||||
let ControllerContract = web3.eth.contract(ControllerAbi);
|
let ControllerContract = web3.eth.contract(ControllerAbi);
|
||||||
contractInstance = ControllerContract.at(controllerAddress);
|
contractInstance = ControllerContract.at(controllerAddress);
|
||||||
|
window.ethereum.enable();
|
||||||
|
|
||||||
contractInstance.tasksNum(function (err, result) {
|
contractInstance.tasksNum(function (err, result) {
|
||||||
console.log(result);
|
|
||||||
let maxLen = Math.min(result, 5);
|
let maxLen = Math.min(result, 5);
|
||||||
for (let i = 0; i < maxLen; i++) {
|
for (let i = 0; i < maxLen; i++) {
|
||||||
let data = result - 1 - i;
|
let data = result - 1 - i;
|
||||||
// let fluenceResponse = session.request(`{"action": "Check", "proof_id": ${data}}`);
|
$('#state-id-' + i).text(data);
|
||||||
// console.log(fluenceResponse);
|
let fluenceResponse_check = session.request(`{"action": "Check", "proof_id": ${data}}`);
|
||||||
$('#state-id-' + i).text(result - 1 - i);
|
getResultAsString(fluenceResponse_check).then(function (str) {
|
||||||
if (fluenceResponse.hasOwnProperty('verified')) {
|
let fluenceResponse = JSON.parse(str);
|
||||||
if (fluenceResponse.verified) {
|
console.log(fluenceResponse);
|
||||||
|
if (fluenceResponse.hasOwnProperty('verifed')) {
|
||||||
|
if (fluenceResponse.verifed) {
|
||||||
// все хорошо - мы проверили в флюенсе
|
// все хорошо - мы проверили в флюенсе
|
||||||
$('#state-status-fluence-' + i).text('TRUE by Fluence.');
|
$('#state-status-fluence-' + i).text('TRUE by Fluence.');
|
||||||
$('#challenge-' + i).prop('disabled', true);
|
$('#challenge-' + i).prop('disabled', true);
|
||||||
@ -396,7 +390,10 @@ $(document).ready(function() {
|
|||||||
$('#state-status-fluence-' + i).text('FALSE by Fluence.');
|
$('#state-status-fluence-' + i).text('FALSE by Fluence.');
|
||||||
$('#challenge-' + i).text('Challenge on Ethereum!')
|
$('#challenge-' + i).text('Challenge on Ethereum!')
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
console.log('Task N ' + data + ' is not checked on Fluence!')
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -410,10 +407,11 @@ $('button').click(function () {
|
|||||||
let public_par = result.slice(0, 5);
|
let public_par = result.slice(0, 5);
|
||||||
let proof = result.slice(5, 13);
|
let proof = result.slice(5, 13);
|
||||||
|
|
||||||
let fluenceResponse = session.request(`{"action": "Verify", "proof_id": ${data}, "public_par": ${public_par}, "proof": ${proof}}`);
|
let fluenceResponse_ver = session.request(`{"action": "Verify", "proof_id": ${data}, "public_par": [${public_par}], "proof": [${proof}]}`);
|
||||||
|
getResultAsString(fluenceResponse_ver).then(function (str) {
|
||||||
|
let fluenceResponse = JSON.parse(str);
|
||||||
|
let success = fluenceResponse.result === 1;
|
||||||
console.log(fluenceResponse);
|
console.log(fluenceResponse);
|
||||||
// let success = fluenceResponse.result === 1;
|
|
||||||
let success = false;
|
|
||||||
if (success) {
|
if (success) {
|
||||||
// все хорошо - мы проверили в флюенсе
|
// все хорошо - мы проверили в флюенсе
|
||||||
$('#state-status-fluence-' + id).text('TRUE by Fluence.');
|
$('#state-status-fluence-' + id).text('TRUE by Fluence.');
|
||||||
@ -424,14 +422,19 @@ $('button').click(function () {
|
|||||||
$('#challenge-' + id).text('Challenge on Ethereum!')
|
$('#challenge-' + id).text('Challenge on Ethereum!')
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
} else if ($(this)[0].textContent === 'Challenge on Ethereum!') {
|
||||||
|
challengeEthereum(id, data);
|
||||||
} else {
|
} else {
|
||||||
challengeEthereum(data);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function challengeEthereum(jobId) {
|
function challengeEthereum(id, data) {
|
||||||
console.log(jobId);
|
console.log('Challenging task N ' + data + ' on Ethereum!');
|
||||||
contractInstance.challenge.sendTransaction(jobId, function (err, txHash) {
|
contractInstance.challenge.sendTransaction(data, function (err, txHash) {
|
||||||
$('#challenge-' + jobId).text('See tx on Etherscan!').attr("href", "https://ropsten.etherscan.io/tx/" + txHash);
|
$('#challenge-' + id).remove();
|
||||||
|
$('#link-' + id).text('See tx on Etherscan!').attr("href", "https://rinkeby.etherscan.io/tx/" + txHash);
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ module.exports = {
|
|||||||
contentBase: './bundle',
|
contentBase: './bundle',
|
||||||
hot: true
|
hot: true
|
||||||
},
|
},
|
||||||
mode: "development",
|
mode: "production",
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user