commit
fbd41909b3
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,32 @@
|
||||||
function addValidator(web3, func, validatorViewObj, address, contractAddr, cb) {
|
function addValidator(web3, validatorViewObj, contractAddr, abi, cb) {
|
||||||
var funcParamsNumber = 7;
|
console.log("***Add validator function***");
|
||||||
|
attachToContract(web3, abi, contractAddr, function(err, oraclesContract) {
|
||||||
|
console.log("attach to oracles contract");
|
||||||
|
if (err) {
|
||||||
|
console.log(err)
|
||||||
|
return cb();
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(validatorViewObj);
|
||||||
|
console.log(oraclesContract);
|
||||||
|
|
||||||
|
oraclesContract.addValidator.sendTransaction(
|
||||||
|
validatorViewObj.miningKey,
|
||||||
|
validatorViewObj.zip,
|
||||||
|
validatorViewObj.licenseID,
|
||||||
|
validatorViewObj.licenseExpiredAt,
|
||||||
|
validatorViewObj.fullName,
|
||||||
|
validatorViewObj.streetName,
|
||||||
|
validatorViewObj.state,
|
||||||
|
function(err, txHash) {
|
||||||
|
if (err) {
|
||||||
|
cb(txHash, err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cb(txHash);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
/*var funcParamsNumber = 7;
|
||||||
var standardLength = 32;
|
var standardLength = 32;
|
||||||
|
|
||||||
SHA3Encrypt(web3, func, function(funcEncode) {
|
SHA3Encrypt(web3, func, function(funcEncode) {
|
||||||
|
@ -46,5 +73,5 @@ function addValidator(web3, func, validatorViewObj, address, contractAddr, cb) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});*/
|
||||||
}
|
}
|
|
@ -65,4 +65,19 @@ function getGasPrice(cb) {
|
||||||
|
|
||||||
cb(gasPrice);
|
cb(gasPrice);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function attachToContract(web3, abi, addr, cb) {
|
||||||
|
if(!web3.isConnected()) {
|
||||||
|
if (cb) cb({code: 200, title: "Error", message: "check RPC availability"});
|
||||||
|
} else {
|
||||||
|
web3.eth.defaultAccount = web3.eth.accounts[0];
|
||||||
|
console.log("web3.eth.defaultAccount:" + web3.eth.defaultAccount);
|
||||||
|
|
||||||
|
var MyContract = web3.eth.contract(abi);
|
||||||
|
|
||||||
|
var contractInstance = MyContract.at(addr);
|
||||||
|
|
||||||
|
if (cb) cb(null, contractInstance);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,28 @@
|
||||||
function createKeys(web3, func, keys, address, contractAddr, cb) {
|
function createKeys(web3, keys, contractAddr, abi, cb) {
|
||||||
var funcParamsNumber = 3;
|
console.log("***Create keys function***");
|
||||||
|
attachToContract(web3, abi, contractAddr, function(err, oraclesContract) {
|
||||||
|
console.log("attach to oracles contract");
|
||||||
|
if (err) {
|
||||||
|
console.log(err)
|
||||||
|
return cb();
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(keys);
|
||||||
|
|
||||||
|
oraclesContract.createKeys.sendTransaction(
|
||||||
|
"0x" + keys.miningKey.miningKeyObject.address,
|
||||||
|
"0x" + keys.payoutKey.payoutKeyObject.address,
|
||||||
|
"0x" + keys.votingKey.votingKeyObject.address,
|
||||||
|
function(err, txHash) {
|
||||||
|
if (err) {
|
||||||
|
cb(txHash, err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cb(txHash);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
/*var funcParamsNumber = 3;
|
||||||
var standardLength = 32;
|
var standardLength = 32;
|
||||||
|
|
||||||
var parameterLocation = standardLength*funcParamsNumber;
|
var parameterLocation = standardLength*funcParamsNumber;
|
||||||
|
@ -24,5 +47,5 @@ function createKeys(web3, func, keys, address, contractAddr, cb) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});*/
|
||||||
}
|
}
|
|
@ -2,6 +2,7 @@
|
||||||
function getConfig(cb) {
|
function getConfig(cb) {
|
||||||
$.getJSON("./assets/javascripts/config.json", function(config) {
|
$.getJSON("./assets/javascripts/config.json", function(config) {
|
||||||
var contractAddress = config.Ethereum[config.environment].contractAddress;
|
var contractAddress = config.Ethereum[config.environment].contractAddress;
|
||||||
cb(contractAddress);
|
var abi = config.Ethereum[config.environment].abi;
|
||||||
|
cb(contractAddress, abi);
|
||||||
});
|
});
|
||||||
}
|
}
|
|
@ -14,13 +14,13 @@ function startDapp(web3, isOraclesNetwork) {
|
||||||
};
|
};
|
||||||
|
|
||||||
getAccounts(function(accounts) {
|
getAccounts(function(accounts) {
|
||||||
getConfig(function(contractAddress) {
|
getConfig(function(contractAddress, abi) {
|
||||||
getConfigCallBack(web3, accounts, contractAddress);
|
getConfigCallBack(web3, accounts, contractAddress, abi);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
//getting of config callback
|
//getting of config callback
|
||||||
function getConfigCallBack(web3, accounts, contractAddress) {
|
function getConfigCallBack(web3, accounts, contractAddress, abi) {
|
||||||
//checks if chosen account is valid initial key
|
//checks if chosen account is valid initial key
|
||||||
if (accounts.length == 1) {
|
if (accounts.length == 1) {
|
||||||
var possibleInitialKey = accounts[0].substr(2);
|
var possibleInitialKey = accounts[0].substr(2);
|
||||||
|
@ -40,13 +40,13 @@ function startDapp(web3, isOraclesNetwork) {
|
||||||
$("#initialKeySource").click();
|
$("#initialKeySource").click();
|
||||||
})
|
})
|
||||||
|
|
||||||
$("#initialKeySource").change({contractAddress: contractAddress}, initialKeySourceOnChange);
|
$("#initialKeySource").change({contractAddress: contractAddress, abi:abi}, initialKeySourceOnChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
function initialKeySourceOnChange(ev) {
|
function initialKeySourceOnChange(ev) {
|
||||||
initialKeyChosen(this, ev.data.contractAddress, function(address) {
|
initialKeyChosen(this, ev.data.contractAddress, function(address) {
|
||||||
generateAddresses(keys, function(_keys) {
|
generateAddresses(keys, function(_keys) {
|
||||||
fillContractData(ev.data.contractAddress, _keys, address, function(err, address) {
|
fillContractData(ev.data.contractAddress, ev.data.abi, _keys, address, function(err, address) {
|
||||||
transferCoinsToPayoutKey(err, address, _keys);
|
transferCoinsToPayoutKey(err, address, _keys);
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
@ -133,7 +133,7 @@ function startDapp(web3, isOraclesNetwork) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//Geeneration of all 3 addresses callback
|
//Geeneration of all 3 addresses callback
|
||||||
function fillContractData(contractAddress, keys, address, cb) {
|
function fillContractData(contractAddress, abi, keys, address, cb) {
|
||||||
$(".content").hide();
|
$(".content").hide();
|
||||||
$('.waiting-container').show();
|
$('.waiting-container').show();
|
||||||
$('.waiting-container').empty();
|
$('.waiting-container').empty();
|
||||||
|
@ -149,10 +149,9 @@ function startDapp(web3, isOraclesNetwork) {
|
||||||
};
|
};
|
||||||
//adds notary personal data to contract
|
//adds notary personal data to contract
|
||||||
addValidator(web3,
|
addValidator(web3,
|
||||||
"addValidator(address,uint256,uint256,uint256,string,string,string)",
|
|
||||||
validatorViewObj,
|
validatorViewObj,
|
||||||
address,
|
|
||||||
contractAddress,
|
contractAddress,
|
||||||
|
abi,
|
||||||
function(txHash, err) {
|
function(txHash, err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
loadingFinished();
|
loadingFinished();
|
||||||
|
@ -166,10 +165,9 @@ function startDapp(web3, isOraclesNetwork) {
|
||||||
$('.waiting-container').append("<h2>Adding production keys to Oracles contract...</h2>");
|
$('.waiting-container').append("<h2>Adding production keys to Oracles contract...</h2>");
|
||||||
//activate generated production keys
|
//activate generated production keys
|
||||||
createKeys(web3,
|
createKeys(web3,
|
||||||
"createKeys(address,address,address)",
|
|
||||||
keys,
|
keys,
|
||||||
address,
|
|
||||||
contractAddress,
|
contractAddress,
|
||||||
|
abi,
|
||||||
function(res, err) {
|
function(res, err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
loadingFinished();
|
loadingFinished();
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
<label for="zip">Zip code</label>
|
<label for="zip">Zip code</label>
|
||||||
<input type="number" id="zip">
|
<input type="number" id="zip">
|
||||||
<label for="license-id">License id</label>
|
<label for="license-id">License id</label>
|
||||||
<input id="license-id">
|
<input type="number" id="license-id">
|
||||||
<label for="license-expiration">License expiration</label>
|
<label for="license-expiration">License expiration</label>
|
||||||
<input type="date" id="license-expiration">
|
<input type="date" id="license-expiration">
|
||||||
</div>
|
</div>
|
||||||
|
@ -79,7 +79,7 @@
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
<script src="./assets/javascripts/sweetalert2.min.js" type="text/javascript"></script>
|
<script src="./assets/javascripts/sweetalert2.min.js" type="text/javascript"></script>
|
||||||
<script src="./assets/javascripts/application.js?v=1.36" type="text/javascript"></script>
|
<script src="./assets/javascripts/application.js?v=1.37" type="text/javascript"></script>
|
||||||
<script src="./assets/javascripts/keythereum.min.js" type="text/javascript"></script>
|
<script src="./assets/javascripts/keythereum.min.js" type="text/javascript"></script>
|
||||||
<script src="./assets/javascripts/toastr.min.js" type="text/javascript"></script>
|
<script src="./assets/javascripts/toastr.min.js" type="text/javascript"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
Loading…
Reference in New Issue