configs update

This commit is contained in:
viktor 2017-11-23 17:57:03 +03:00
parent 93020d8a5a
commit 0f7279c95c
5 changed files with 1223 additions and 70 deletions

38
assets/javascripts/application.js Executable file → Normal file
View File

@ -19,7 +19,7 @@ function generatePassword() {
}
function addValidator(web3, validatorViewObj, contractAddr, abi, cb) {
console.log("***Add validator function***");
attachToContract(web3, abi, contractAddr, function(err, oraclesContract) {
attachToContract(web3, abi, contractAddr, function(err, ValidatorsStorage) {
console.log("attach to oracles contract");
if (err) {
console.log(err)
@ -27,13 +27,13 @@ function addValidator(web3, validatorViewObj, contractAddr, abi, cb) {
}
console.log(validatorViewObj);
console.log(oraclesContract);
console.log(ValidatorsStorage);
var txHash;
var gasPrice = web3.utils.toWei(new web3.utils.BN(1), 'gwei')
var opts = {from: web3.eth.defaultAccount, gasPrice: gasPrice}
oraclesContract.methods.addValidator(validatorViewObj.miningKey,
ValidatorsStorage.methods.addValidator(validatorViewObj.miningKey,
validatorViewObj.zip,
validatorViewObj.licenseID,
validatorViewObj.licenseExpiredAt,
@ -324,19 +324,19 @@ function startDapp(web3, isOraclesNetwork) {
getAccounts(async function(accounts) {
let config = await getConfig()
getConfigCallBack(web3, accounts, config.contractAddress, config.abi)
getConfigCallBack(web3, accounts, config)
});
//getting of config callback
function getConfigCallBack(web3, accounts, contractAddress, abi) {
function getConfigCallBack(web3, accounts, config) {
//checks if chosen account is valid initial key
if (accounts.length == 1) {
var possibleInitialKey = accounts[0].substr(2);
checkInitialKey(web3,
"checkInitialKey(address)",
possibleInitialKey,
contractAddress,
abi,
config.Ethereum[config.environment].KeysStorage.addr,
config.Ethereum[config.environment].KeysStorage.abi,
function(_isNew) {
_isNew = !!+_isNew;
if (!_isNew) swal("Warning", "Current key isn't valid initial key. Please, choose your initial key in MetaMask and reload the page. Check Oracles network <a href='https://github.com/oraclesorg/oracles-wiki' target='blank'>wiki</a> for more info.", "warning");
@ -349,13 +349,13 @@ function startDapp(web3, isOraclesNetwork) {
$("#initialKeySource").click();
})
$("#initialKeySource").change({contractAddress: contractAddress, abi:abi}, initialKeySourceOnChange);
$("#initialKeySource").change({config: config}, initialKeySourceOnChange);
}
function initialKeySourceOnChange(ev) {
initialKeyChosen(this, ev.data.contractAddress, ev.data.abi, function(address) {
initialKeyChosen(this, ev.data.config, function(address) {
generateAddresses(keys, function(_keys) {
fillContractData(ev.data.contractAddress, ev.data.abi, _keys, address, function(err, address) {
fillContractData(ev.data.config, _keys, address, function(err, address) {
transferCoinsToPayoutKey(err, address, _keys);
})
});
@ -363,11 +363,11 @@ function startDapp(web3, isOraclesNetwork) {
};
//triggers, if initial key is chosen
function initialKeyChosen(el, contractAddress, abi, cb) {
function initialKeyChosen(el, config, cb) {
var file = $(el).prop('files')[0];
$(el).remove();
var newEl = "<input type='file' id='initialKeySource' />";
$(newEl).change({contractAddress: contractAddress, abi:abi}, initialKeySourceOnChange).appendTo($(".create-keys"));
$(newEl).change({config: config}, initialKeySourceOnChange).appendTo($(".create-keys"));
var reader = new FileReader();
reader.readAsText(file, "UTF-8");
reader.onload = function (evt) {
@ -385,8 +385,8 @@ function startDapp(web3, isOraclesNetwork) {
checkInitialKey(web3,
"checkInitialKey(address)",
address,
contractAddress,
abi,
config.Ethereum[config.environment].KeysStorage.addr,
config.Ethereum[config.environment].KeysStorage.abi,
function(_isNew) {
_isNew = !!+_isNew;
@ -443,7 +443,7 @@ function startDapp(web3, isOraclesNetwork) {
}
//Geeneration of all 3 addresses callback
function fillContractData(contractAddress, abi, keys, address, cb) {
function fillContractData(config, keys, address, cb) {
$(".content").hide();
$('.waiting-container').show();
$('.waiting-container').empty();
@ -460,8 +460,8 @@ function startDapp(web3, isOraclesNetwork) {
//adds notary personal data to contract
addValidator(web3,
validatorViewObj,
contractAddress,
abi,
config.Ethereum[config.environment].ValidatorsStorage.addr,
config.Ethereum[config.environment].ValidatorsStorage.abi,
function(txHash, err) {
if (err) {
loadingFinished();
@ -476,8 +476,8 @@ function startDapp(web3, isOraclesNetwork) {
//activate generated production keys
createKeys(web3,
keys,
contractAddress,
abi,
config.Ethereum[config.environment].KeysManager.addr,
config.Ethereum[config.environment].KeysManager.abi,
function(res, err) {
if (err) {
loadingFinished();

View File

@ -1,6 +1,6 @@
function addValidator(web3, validatorViewObj, contractAddr, abi, cb) {
console.log("***Add validator function***");
attachToContract(web3, abi, contractAddr, function(err, oraclesContract) {
attachToContract(web3, abi, contractAddr, function(err, ValidatorsStorage) {
console.log("attach to oracles contract");
if (err) {
console.log(err)
@ -8,13 +8,13 @@ function addValidator(web3, validatorViewObj, contractAddr, abi, cb) {
}
console.log(validatorViewObj);
console.log(oraclesContract);
console.log(ValidatorsStorage);
var txHash;
var gasPrice = web3.utils.toWei(new web3.utils.BN(1), 'gwei')
var opts = {from: web3.eth.defaultAccount, gasPrice: gasPrice}
oraclesContract.methods.addValidator(validatorViewObj.miningKey,
ValidatorsStorage.methods.addValidator(validatorViewObj.miningKey,
validatorViewObj.zip,
validatorViewObj.licenseID,
validatorViewObj.licenseExpiredAt,

View File

@ -15,19 +15,19 @@ function startDapp(web3, isOraclesNetwork) {
getAccounts(async function(accounts) {
let config = await getConfig()
getConfigCallBack(web3, accounts, config.contractAddress, config.abi)
getConfigCallBack(web3, accounts, config)
});
//getting of config callback
function getConfigCallBack(web3, accounts, contractAddress, abi) {
function getConfigCallBack(web3, accounts, config) {
//checks if chosen account is valid initial key
if (accounts.length == 1) {
var possibleInitialKey = accounts[0].substr(2);
checkInitialKey(web3,
"checkInitialKey(address)",
possibleInitialKey,
contractAddress,
abi,
config.Ethereum[config.environment].KeysStorage.addr,
config.Ethereum[config.environment].KeysStorage.abi,
function(_isNew) {
_isNew = !!+_isNew;
if (!_isNew) swal("Warning", "Current key isn't valid initial key. Please, choose your initial key in MetaMask and reload the page. Check Oracles network <a href='https://github.com/oraclesorg/oracles-wiki' target='blank'>wiki</a> for more info.", "warning");
@ -40,13 +40,13 @@ function startDapp(web3, isOraclesNetwork) {
$("#initialKeySource").click();
})
$("#initialKeySource").change({contractAddress: contractAddress, abi:abi}, initialKeySourceOnChange);
$("#initialKeySource").change({config: config}, initialKeySourceOnChange);
}
function initialKeySourceOnChange(ev) {
initialKeyChosen(this, ev.data.contractAddress, ev.data.abi, function(address) {
initialKeyChosen(this, ev.data.config, function(address) {
generateAddresses(keys, function(_keys) {
fillContractData(ev.data.contractAddress, ev.data.abi, _keys, address, function(err, address) {
fillContractData(ev.data.config, _keys, address, function(err, address) {
transferCoinsToPayoutKey(err, address, _keys);
})
});
@ -54,11 +54,11 @@ function startDapp(web3, isOraclesNetwork) {
};
//triggers, if initial key is chosen
function initialKeyChosen(el, contractAddress, abi, cb) {
function initialKeyChosen(el, config, cb) {
var file = $(el).prop('files')[0];
$(el).remove();
var newEl = "<input type='file' id='initialKeySource' />";
$(newEl).change({contractAddress: contractAddress, abi:abi}, initialKeySourceOnChange).appendTo($(".create-keys"));
$(newEl).change({config: config}, initialKeySourceOnChange).appendTo($(".create-keys"));
var reader = new FileReader();
reader.readAsText(file, "UTF-8");
reader.onload = function (evt) {
@ -76,8 +76,8 @@ function startDapp(web3, isOraclesNetwork) {
checkInitialKey(web3,
"checkInitialKey(address)",
address,
contractAddress,
abi,
config.Ethereum[config.environment].KeysStorage.addr,
config.Ethereum[config.environment].KeysStorage.abi,
function(_isNew) {
_isNew = !!+_isNew;
@ -134,7 +134,7 @@ function startDapp(web3, isOraclesNetwork) {
}
//Geeneration of all 3 addresses callback
function fillContractData(contractAddress, abi, keys, address, cb) {
function fillContractData(config, keys, address, cb) {
$(".content").hide();
$('.waiting-container').show();
$('.waiting-container').empty();
@ -151,8 +151,8 @@ function startDapp(web3, isOraclesNetwork) {
//adds notary personal data to contract
addValidator(web3,
validatorViewObj,
contractAddress,
abi,
config.Ethereum[config.environment].ValidatorsStorage.addr,
config.Ethereum[config.environment].ValidatorsStorage.abi,
function(txHash, err) {
if (err) {
loadingFinished();
@ -167,8 +167,8 @@ function startDapp(web3, isOraclesNetwork) {
//activate generated production keys
createKeys(web3,
keys,
contractAddress,
abi,
config.Ethereum[config.environment].KeysManager.addr,
config.Ethereum[config.environment].KeysManager.abi,
function(res, err) {
if (err) {
loadingFinished();

File diff suppressed because one or more lines are too long

View File

@ -23088,29 +23088,36 @@ arguments[4][80][0].apply(exports,arguments)
arguments[4][81][0].apply(exports,arguments)
},{"bn.js":158,"dup":81,"minimalistic-assert":221,"minimalistic-crypto-utils":222}],183:[function(require,module,exports){
module.exports={
"_from": "elliptic@^6.2.3",
"_args": [
[
"elliptic@6.4.0",
"/Users/viktor/Documents/HintsProjects/BlockNotary/Oracles/oracles-dapps-keys-generation"
]
],
"_from": "elliptic@6.4.0",
"_id": "elliptic@6.4.0",
"_inBundle": false,
"_integrity": "sha1-ysmvh2LIWDYYcAPI3+GT5eLq5d8=",
"_location": "/elliptic",
"_phantomChildren": {},
"_requested": {
"type": "range",
"type": "version",
"registry": true,
"raw": "elliptic@^6.2.3",
"raw": "elliptic@6.4.0",
"name": "elliptic",
"escapedName": "elliptic",
"rawSpec": "^6.2.3",
"rawSpec": "6.4.0",
"saveSpec": null,
"fetchSpec": "^6.2.3"
"fetchSpec": "6.4.0"
},
"_requiredBy": [
"/secp256k1"
"/eth-lib",
"/secp256k1",
"/web3-eth-accounts/eth-lib"
],
"_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.0.tgz",
"_shasum": "cac9af8762c85836187003c8dfe193e5e2eae5df",
"_spec": "elliptic@^6.2.3",
"_where": "/Users/viktor/Documents/HintsProjects/BlockNotary/Oracles/oracles-dapps-keys-generation-myfork/node_modules/secp256k1",
"_spec": "6.4.0",
"_where": "/Users/viktor/Documents/HintsProjects/BlockNotary/Oracles/oracles-dapps-keys-generation",
"author": {
"name": "Fedor Indutny",
"email": "fedor@indutny.com"
@ -23118,7 +23125,6 @@ module.exports={
"bugs": {
"url": "https://github.com/indutny/elliptic/issues"
},
"bundleDependencies": false,
"dependencies": {
"bn.js": "^4.4.0",
"brorand": "^1.0.1",
@ -23128,7 +23134,6 @@ module.exports={
"minimalistic-assert": "^1.0.0",
"minimalistic-crypto-utils": "^1.0.0"
},
"deprecated": false,
"description": "EC cryptography",
"devDependencies": {
"brfs": "^1.4.3",
@ -73998,30 +74003,34 @@ module.exports = {
},{"bn.js":321,"eth-lib/lib/hash":186,"number-to-bn":224,"underscore":269,"utf8":271}],325:[function(require,module,exports){
module.exports={
"_from": "web3",
"_args": [
[
"web3@1.0.0-beta.26",
"/Users/viktor/Documents/HintsProjects/BlockNotary/Oracles/oracles-dapps-keys-generation"
]
],
"_from": "web3@1.0.0-beta.26",
"_id": "web3@1.0.0-beta.26",
"_inBundle": false,
"_integrity": "sha1-u0ba9q78MT92iz3jnX9KjXvQZmM=",
"_location": "/web3",
"_phantomChildren": {},
"_requested": {
"type": "tag",
"type": "version",
"registry": true,
"raw": "web3",
"raw": "web3@1.0.0-beta.26",
"name": "web3",
"escapedName": "web3",
"rawSpec": "",
"rawSpec": "1.0.0-beta.26",
"saveSpec": null,
"fetchSpec": "latest"
"fetchSpec": "1.0.0-beta.26"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/web3/-/web3-1.0.0-beta.26.tgz",
"_shasum": "bb46daf6aefc313f768b3de39d7f4a8d7bd06663",
"_spec": "web3",
"_where": "/Users/viktor/Documents/HintsProjects/BlockNotary/Oracles/oracles-dapps-keys-generation-myfork",
"_spec": "1.0.0-beta.26",
"_where": "/Users/viktor/Documents/HintsProjects/BlockNotary/Oracles/oracles-dapps-keys-generation",
"author": {
"name": "ethereum.org"
},
@ -74054,7 +74063,6 @@ module.exports={
"bugs": {
"url": "https://github.com/ethereum/web3.js/issues"
},
"bundleDependencies": false,
"dependencies": {
"web3-bzz": "^1.0.0-beta.26",
"web3-core": "^1.0.0-beta.26",
@ -74064,7 +74072,6 @@ module.exports={
"web3-shh": "^1.0.0-beta.26",
"web3-utils": "^1.0.0-beta.26"
},
"deprecated": false,
"description": "Ethereum JavaScript API",
"keywords": [
"Ethereum",
@ -74207,7 +74214,7 @@ module.exports = require('../package.json').version;
},{"../package.json":329}],329:[function(require,module,exports){
module.exports={
"_from": "git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",
"_from": "websocket@git://github.com/frozeman/WebSocket-Node.git#7004c39c42ac98875ab61126e5b4a925430f592c",
"_id": "websocket@1.0.24",
"_inBundle": false,
"_integrity": "sha1-1bSDGjm26R6Kq7OQxfmv6krmlzo=",
@ -74215,20 +74222,20 @@ module.exports={
"_phantomChildren": {},
"_requested": {
"type": "git",
"raw": "websocket@git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",
"raw": "websocket@git://github.com/frozeman/WebSocket-Node.git#7004c39c42ac98875ab61126e5b4a925430f592c",
"name": "websocket",
"escapedName": "websocket",
"rawSpec": "git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",
"saveSpec": "git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",
"rawSpec": "git://github.com/frozeman/WebSocket-Node.git#7004c39c42ac98875ab61126e5b4a925430f592c",
"saveSpec": "git://github.com/frozeman/WebSocket-Node.git#7004c39c42ac98875ab61126e5b4a925430f592c",
"fetchSpec": "git://github.com/frozeman/WebSocket-Node.git",
"gitCommittish": "browserifyCompatible"
"gitCommittish": "7004c39c42ac98875ab61126e5b4a925430f592c"
},
"_requiredBy": [
"/web3-providers-ws"
],
"_resolved": "git://github.com/frozeman/WebSocket-Node.git#7004c39c42ac98875ab61126e5b4a925430f592c",
"_spec": "websocket@git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",
"_where": "/Users/viktor/Documents/HintsProjects/BlockNotary/Oracles/oracles-dapps-keys-generation-myfork/node_modules/web3-providers-ws",
"_spec": "websocket@git://github.com/frozeman/WebSocket-Node.git#7004c39c42ac98875ab61126e5b4a925430f592c",
"_where": "/Users/viktor/Documents/HintsProjects/BlockNotary/Oracles/oracles-dapps-keys-generation",
"author": {
"name": "Brian McKelvey",
"email": "brian@worlize.com",