Skip to content
This repository has been archived by the owner on Feb 17, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1 from Firstbloodio/develop
Browse files Browse the repository at this point in the history
Minor changes (see comment)
  • Loading branch information
zackcoburn authored Oct 18, 2018
2 parents b15d01c + b825845 commit fb7b11d
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 378 deletions.
2 changes: 1 addition & 1 deletion dapp/app/frontend/assets/css/default.css
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ img{ max-width:100%; }

.icon-info{ padding-left:26px; background:url("../images/icon-info.png") no-repeat left center; }
/* Login page start */
.box-login{ height:100%; display:flex; justify-content:center; align-items:center; color:#FFF; }
.box-login{ height:100%; overflow-y: scroll; display:flex; justify-content:center; color:#FFF; }
#login-form{ max-width:650px; padding:40px; border-radius:8px; background-color:rgba(255,255,255,0.05); }
#logo-login{ display:block; margin:auto auto 24px; }
.input-mainGroup{ padding-bottom:20px; }
Expand Down
345 changes: 0 additions & 345 deletions dapp/app/resources/routes/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,344 +52,6 @@ router.get('/checkConfig', function(req, res, next) {
});
});


router.get('/respond', function(req, res, next) {
Promise.resolve(respond()).then(function(result) {
res.send("ok")
}).catch(function(e) {
console.log('storeNetworkLogs : error ->', e);
return false;
});

});


const respond = async() => {
try {
const selectedAccount = {
"address": '0xb91B6Ecd8D1F21b3553DA809eB446cde0de06aA4',
"privateKey": '58bd152483f7c8aef652ebe83b8582ad6cf47004c552b202f1d7f4d7c49bd344'
};
const contracts = {
"1ST": {
"type": 'StandardToken',
"address": '0xe49c32368d1045f0dc1e4fd527d66762b64328f3'
},
"WitnessJury": {
"type": 'WitnessJury',
"address": '0x66534c223df067f4a029cf880157b0df0954f660'
},
"ChallengeFactory": {
"type": 'ChallengeFactory',
"address": '0x20f5c4e09fda42f2242fc9126a099d02c7dd9825'
},
"Challenge": {
"type": 'Challenge',
"address": '0xe9E68FEe4D78c180f90C54cc6DE4773Bd5464681'
}
};
const amountToFund = toWei(1);
const value = 0;
const gasLimit = 7000000;
const gasPrice = "4000000000";
const pk = selectedAccount.privateKey;
const referrer = '0x0';
const addressNonce = await getNonce(selectedAccount.address);
const txHash1 = await sendData(contracts['Challenge'].type, contracts['Challenge'].address, 'respond', ["0x2A10018Aa6B50f2bBDf65c2e953f155A68896F83", 'appy_neo'], value, gasLimit, gasPrice, pk, addressNonce);
console.log(txHash1);
return txHash1;
} catch (err) {
console.log(err);
}
};


router.get('/approve2', function(req, res, next) {
Promise.resolve(approve2()).then(function(result) {
res.send("ok")
}).catch(function(e) {
console.log('storeNetworkLogs : error ->', e);
return false;
});
});




const approve2 = async() => {
try {
const selectedAccount = {
"address": '0xb91B6Ecd8D1F21b3553DA809eB446cde0de06aA4',
"privateKey": '58bd152483f7c8aef652ebe83b8582ad6cf47004c552b202f1d7f4d7c49bd344'
};
const contracts = {
"1ST": {
"type": 'StandardToken',
"address": '0xe49c32368d1045f0dc1e4fd527d66762b64328f3'
},
"WitnessJury": {
"type": 'WitnessJury',
"address": '0x66534c223df067f4a029cf880157b0df0954f660'
},
"ChallengeFactory": {
"type": 'ChallengeFactory',
"address": '0x20f5c4e09fda42f2242fc9126a099d02c7dd9825'
},
"Challenge": {
"type": 'Challenge',
"address": '0xe9E68FEe4D78c180f90C54cc6DE4773Bd5464681'
}
};
const amountToFund = toWei(1);
const value = 0;
const gasLimit = 7000000;
const gasPrice = "4000000000";
const pk = selectedAccount.privateKey;
const referrer = '0x0';
const addressNonce = await getNonce(selectedAccount.address);
const txHash1 = await sendData(
contracts['1ST'].type, contracts['1ST'].address, 'approve', ["0x2A10018Aa6B50f2bBDf65c2e953f155A68896F83", amountToFund], value, gasLimit, gasPrice, pk, addressNonce);
console.log(txHash1);
return txHash1;
} catch (err) {
console.log(err);
}
};

router.get('/fund', function(req, res, next) {
Promise.resolve(fund()).then(function(result) {
res.send("ok")
}).catch(function(e) {
console.log('storeNetworkLogs : error ->', e);
return false;
});
});

const fund = async() => {
try {
const selectedAccount = {
"address": '0xb91B6Ecd8D1F21b3553DA809eB446cde0de06aA4',
"privateKey": '58bd152483f7c8aef652ebe83b8582ad6cf47004c552b202f1d7f4d7c49bd344'
};
const contracts = {
"1ST": {
"type": 'StandardToken',
"address": '0xe49c32368d1045f0dc1e4fd527d66762b64328f3'
},
"WitnessJury": {
"type": 'WitnessJury',
"address": '0x66534c223df067f4a029cf880157b0df0954f660'
},
"ChallengeFactory": {
"type": 'ChallengeFactory',
"address": '0x20f5c4e09fda42f2242fc9126a099d02c7dd9825'
},
"Challenge": {
"type": 'Challenge',
"address": '0x180c5e32880362ab1420b6b32bd9602c41bdba05'
}
};
const amountToFund = toWei(1);
const value = 0;
const gasLimit = 7000000;
const gasPrice = "40000000000";
const pk = selectedAccount.privateKey;
const referrer = '0x0';
const addressNonce = await getNonce(selectedAccount.address);
const txHash1 = await sendData(
contracts['Challenge'].type, contracts['Challenge'].address, 'fund', [], value, gasLimit, gasPrice, pk, addressNonce);
console.log(txHash1);
return txHash1;
} catch (err) {
console.log(err);
}
};

router.get('/approve_challenge', function(req, res, next) {
Promise.resolve(approveChallnge()).then(function(result) {
res.send("ok")
}).catch(function(e) {
console.log('storeNetworkLogs : error ->', e);
return false;
});
});



const approveChallnge = async() => {
try {
const selectedAccount = {
"address": '0xb91B6Ecd8D1F21b3553DA809eB446cde0de06aA4',
"privateKey": '58bd152483f7c8aef652ebe83b8582ad6cf47004c552b202f1d7f4d7c49bd344'
};
const contracts = {
"1ST": {
"type": 'StandardToken',
"address": '0xe49c32368d1045f0dc1e4fd527d66762b64328f3'
},
"WitnessJury": {
"type": 'WitnessJury',
"address": '0x66534c223df067f4a029cf880157b0df0954f660'
},
"ChallengeFactory": {
"type": 'ChallengeFactory',
"address": '0x20f5c4e09fda42f2242fc9126a099d02c7dd9825'
}
};
const amountToFund = toWei(1);
const value = 0;
const gasLimit = 7000000;
const gasPrice = "40000000000";
const pk = selectedAccount.privateKey;
const referrer = '0x0';
const addressNonce = await getNonce(selectedAccount.address);
const txHash1 = await sendData(
contracts['1ST'].type, contracts['1ST'].address, 'approve', ["0xe9E68FEe4D78c180f90C54cc6DE4773Bd5464681", amountToFund], value, gasLimit, gasPrice, pk, addressNonce);
console.log(txHash1);
return txHash1;
fund();
} catch (err) {
console.log(err);
}
};



router.get('/create_challenge', function(req, res, next) {
Promise.resolve(deployChallnge()).then(function(result) {
res.send("ok")
}).catch(function(e) {
console.log('storeNetworkLogs : error ->', e);
return false;
});
});
const deployChallnge = async() => {
try {
var account = "0xb91b6ecd8d1f21b3553da809eb446cde0de06aa4";
var username = "test";

const selectedAccount = {
"address": '0xb91B6Ecd8D1F21b3553DA809eB446cde0de06aA4',
"privateKey": '58bd152483f7c8aef652ebe83b8582ad6cf47004c552b202f1d7f4d7c49bd344'
};
const contracts = {
"1ST": {
"type": 'StandardToken',
"address": '0xe49c32368d1045f0dc1e4fd527d66762b64328f3'
},
"WitnessJury": {
"type": 'WitnessJury',
"address": '0x66534c223df067f4a029cf880157b0df0954f660'
},
"ChallengeFactory": {
"type": 'ChallengeFactory',
"address": '0x20f5c4e09fda42f2242fc9126a099d02c7dd9825'
}
};
const amountToFund = toWei(1);
const value = 0;
const gasLimit = 7000000;
const gasPrice = "40000000000";
const pk = selectedAccount.privateKey;
const referrer = '0x0';
const addressNonce = await getNonce(selectedAccount.address);
const txHash1 = await sendData(
contracts['ChallengeFactory'].type, contracts['ChallengeFactory'].address, 'newChallenge', [amountToFund, account, username, referrer], value, gasLimit, gasPrice, pk, addressNonce);
console.log(txHash1);

getTransactionDetails(txHash1);
return txHash1;
} catch (err) {
console.log(err);
}
};


router.get('/createtoken', function(req, res, next) {
Promise.resolve(createtoken()).then(function(result) {
res.send("ok")
}).catch(function(e) {
console.log('storeNetworkLogs : error ->', e);
return false;
});

});




const createtoken = async() => {
try {
const selectedAccount = {
"address": '0xb91B6Ecd8D1F21b3553DA809eB446cde0de06aA4',
"privateKey": '58bd152483f7c8aef652ebe83b8582ad6cf47004c552b202f1d7f4d7c49bd344'
};
const contracts = {
"1ST": {
"type": 'StandardToken',
"address": '0xe49c32368d1045f0dc1e4fd527d66762b64328f3'
},
"WitnessJury": {
"type": 'WitnessJury',
"address": '0x66534c223df067f4a029cf880157b0df0954f660'
},
"ChallengeFactory": {
"type": 'ChallengeFactory',
"address": '0x20f5c4e09fda42f2242fc9126a099d02c7dd9825'
},
"Challenge": {
"type": 'Challenge',
"address": '0xa5F8548c63FE827b9bb78F7F3139FdbC947B35Ef'
}
};
const amountToCreate = toWei(1);
const value = 0;
const gasLimit = 7000000;
const gasPrice = "4000000000";
const pk = selectedAccount.privateKey;
const referrer = '0x0';
const addressNonce = await getNonce(selectedAccount.address);
const txHash1 = await sendData(
'ReserveToken', contracts['1ST'].address, 'create', [selectedAccount.address, amountToCreate], value, gasLimit, gasPrice, pk, addressNonce);
console.log(txHash1);
return txHash1;
} catch (err) {
console.log(err);
}
};

router.get('/report', function(req, res, next) {
Promise.resolve(report()).then(function(result) {
res.send("ok")
}).catch(function(e) {
console.log('storeNetworkLogs : error ->', e);
return false;
});
});

const report = async() => {
try {

const value = 0;
const gasLimit = 7000000;
const gasPrice = "4000000000";

const pk = "510F8855A244D218987A0A6ABBE3BB431D8257CEC8E36A2905F29EF3C5E905E3";
const witnessAccountAddress = ethUtil.privateToAddress(Buffer.from(pk, 'hex')).toString("hex");

const addressNonce = await getNonce('0x'+witnessAccountAddress);
const match_data = {"match_id":"4062775817","start_time":1534422884,"duration":65,"game_mode":"DOTA_GAMEMODE_1V1MID","players":[{"account_id":0,"hero_id":84,"kills":2,"deaths":0,"assists":0,"items":[12,0,40,0,0,46],"player_slot":0},{"account_id":0,"hero_id":42,"kills":0,"deaths":2,"assists":0,"items":[0,0,0,0,0,46],"player_slot":128}],"match_outcome":"k_EMatchOutcome_RadVictory"};
const txHash1 = await sendData(
'WitnessJury', "0xfba5cedcd1eedf88d9bcbe8740e03f9e063328c4", 'report', [8, JSON.stringify(match_data), 1 ], value, gasLimit, gasPrice, pk, addressNonce);


console.log(txHash1);
return txHash1;
} catch (err) {
console.log(err);
}
};

function generateRawTransaction(pkIn, nonceIn, to, data, valueIn, gasLimitIn, gasPriceIn) {
const value = web3.toHex(web3.toWei(valueIn, 'Ether'));
const gasLimit = web3.toHex(gasLimitIn);
Expand Down Expand Up @@ -439,13 +101,6 @@ function sendData(contractType, contractAddr, fn, args, value, gasLimit, gasPric
});
}

function getTransactionDetails(transactionHash) {
web3.eth.getTransactionReceipt("0xf68de4db3d90c6df2d0abb672c4636d0a45eed765a279d519ea61d22f10c67fb", (err, result) => {
console.log(err);
console.log(result);
});
}

function toWei(amount) {
return web3.toWei(amount, 'ether');
}
Expand Down
4 changes: 2 additions & 2 deletions dapp/app/resources/routes/cron.js
Original file line number Diff line number Diff line change
Expand Up @@ -1602,8 +1602,8 @@ async function getMyJobs(ethereumPrivateKey) {
async function reportMyJob(contractType, contractAddr, fn, witnessJuryRequestNum, witnessAccountAddress, match_id, pk, needToSteamConnect, witnessName, steamPassword) {
try {
const value = 0;
const gasLimit = 7000000;
const gasPrice = "4000000000";
const gasLimit = 400000;
const gasPrice = "10000000000";
const addressNonce = await getNonce(witnessAccountAddress);
const match_data = await getMatchDetails(match_id, needToSteamConnect, witnessName, steamPassword);
if (match_data && (match_data.match_outcome == 2 || match_data.match_outcome == 3)) {
Expand Down
Loading

0 comments on commit fb7b11d

Please sign in to comment.