SHA3Encrypt refactoring

This commit is contained in:
viktor 2017-11-17 16:39:52 +03:00
parent 92ecd25c52
commit c12fc3a7e9
3 changed files with 189 additions and 197 deletions

37
assets/javascripts/application.js Normal file → Executable file

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
function SHA3Encrypt(web3, str, cb) {
function SHA3Encrypt(web3, str) {
var strEncode = web3.sha3(str);
cb(strEncode);
return strEncode;
}
function estimateGas(web3, acc, contractAddr, data, cb) {
@ -27,7 +27,7 @@ function sendTx(web3, acc, contractAddr, data, estimatedGas, cb) {
}
function call(web3, acc, contractAddr, data, cb) {
var props;
let props;
if (acc) props = { from: acc, data: data, to: contractAddr };
else props = { data: data, to: contractAddr };
@ -37,37 +37,35 @@ function call(web3, acc, contractAddr, data, cb) {
}
function getContractStringDataFromAddressKey(web3, func, inputVal, i, contractAddr, cb) {
var funcParamsNumber = 1;
var standardLength = 32;
const funcParamsNumber = 1;
const standardLength = 32;
var parameterLocation = standardLength*funcParamsNumber;
let parameterLocation = standardLength * funcParamsNumber;
SHA3Encrypt(web3, func, function(funcEncode) {
var funcEncodePart = funcEncode.substring(0,10);
let funcEncode = SHA3Encrypt(web3, func);
let funcEncodePart = funcEncode.substring(0,10);
var data = funcEncodePart
let data = funcEncodePart
+ toUnifiedLengthLeft(inputVal);
call(web3, null, contractAddr, data, function(respHex) {
cb(i, hex2a(respHex));
});
});
}
function getContractIntDataFromAddressKey(web3, func, inputVal, i, contractAddr, cb) {
var funcParamsNumber = 1;
var standardLength = 32;
const funcParamsNumber = 1;
const standardLength = 32;
var parameterLocation = standardLength*funcParamsNumber;
let parameterLocation = standardLength * funcParamsNumber;
SHA3Encrypt(web3, func, function(funcEncode) {
var funcEncodePart = funcEncode.substring(0,10);
let funcEncode = SHA3Encrypt(web3, func);
let funcEncodePart = funcEncode.substring(0,10);
var data = funcEncodePart
let data = funcEncodePart
+ toUnifiedLengthLeft(inputVal);
call(web3, null, contractAddr, data, function(respHex) {
cb(i, parseInt(respHex, 16));
});
});
}

View File

@ -1,5 +1,5 @@
function getValidators(web3, func, contractAddress, disabled, cb) {
SHA3Encrypt(web3, func, function(funcEncode) {
let funcEncode = SHA3Encrypt(web3, func);
var funcEncodePart = funcEncode.substring(0,10);
var data = funcEncodePart;
@ -75,7 +75,6 @@ function getValidators(web3, func, contractAddress, disabled, cb) {
}
}
});
});
}
function getPropertyCallback(prop, resp, _i, iasync, validatorsArray, validatorDataCount, validatorsArrayOut, cb) {