Bump web3 and remove keythereum (#64)

* Update web3 version and remove keythereum

* Minor fix
This commit is contained in:
phahulin 2019-09-19 16:24:37 +03:00 committed by varasev
parent ed36de5151
commit 3c535e1c09
6 changed files with 2220 additions and 842 deletions

13
.gitignore vendored
View File

@ -13,7 +13,18 @@
*.patch
# Account created during test
accounts/keystore/UTC*
accounts/keystore/*
!accounts/keystore/0b2f5e2f3cbd864eaa2c642e3769c1582361caf6.json
!accounts/keystore/b6695f5c2e3f5eff8036b5f5f3a9d83a5310e51e.json
!accounts/keystore/312c230e7d6db05224f60208a656e3541c5c42ba.json
!accounts/keystore/b916e7e1f4bcb13549602ed042d36746fd0d96c9.json
!accounts/keystore/32e4e4c7c5d1cea5db5f9202a9e4d99e56c91a24.json
!accounts/keystore/be69eb0968226a1808975e1a1f2127667f2bffb3.json
!accounts/keystore/720e118ab1006cc97ed2ef6b4b49ac04bb3aa6d9.json
!accounts/keystore/db9cb2478d917719c53862008672166808258577.json
!accounts/keystore/aa94b687d3f9552a453b81b2834ca53778980dc0.json
!accounts/keystore/f67cc5231c5858ad6cc87b105217426e17b824bb.json
# Logs
/parity-data/node[0-9]*/network/

View File

@ -1 +1 @@
{"version":3,"id":"be60c5ac-6c4a-44c4-a12f-9558131ab64a","address":"32e4e4c7c5d1cea5db5f9202a9e4d99e56c91a24","Crypto":{"ciphertext":"68d1202b416408cb22ca60ba4f4deabcbddad7a262e014e1239dbe7354677ebb","cipherparams":{"iv":"a37afd65f955ab252340496defade99d"},"cipher":"aes-128-ctr","kdf":"scrypt","kdfparams":{"dklen":32,"salt":"47fdc45755f6f75072fb8c1a1eea9ec3a06450754eb78f0cc726baef22fed0bf","n":8192,"r":8,"p":1},"mac":"00def76f42948515e1f498b433860ef4a0fca7f9ce7a81eee0abc470f365ceb7"}}
{"version":3,"id":"be60c5ac-6c4a-44c4-a12f-9558131ab64a","address":"32e4e4c7c5d1cea5db5f9202a9e4d99e56c91a24","crypto":{"ciphertext":"68d1202b416408cb22ca60ba4f4deabcbddad7a262e014e1239dbe7354677ebb","cipherparams":{"iv":"a37afd65f955ab252340496defade99d"},"cipher":"aes-128-ctr","kdf":"scrypt","kdfparams":{"dklen":32,"salt":"47fdc45755f6f75072fb8c1a1eea9ec3a06450754eb78f0cc726baef22fed0bf","n":8192,"r":8,"p":1},"mac":"00def76f42948515e1f498b433860ef4a0fca7f9ce7a81eee0abc470f365ceb7"}}

3014
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -24,9 +24,8 @@
"chai-as-promised": "^7.1.1",
"chai-bn": "^0.1.1",
"ethereumjs-tx": "^1.3.7",
"keythereum": "^1.0.4",
"mocha": "^6.1.4",
"solc": "0.5.2",
"web3": "1.0.0-beta.55"
"web3": "^1.2.1"
}
}

View File

@ -18,7 +18,6 @@ const StakingTokenContract = require('../utils/getContract')('StakingToken', web
const sendInStakingWindow = require('../utils/sendInStakingWindow');
const waitForValidatorSetChange = require('../utils/waitForValidatorSetChange');
const pp = require('../utils/prettyPrint');
const keythereum = require('keythereum');
const REVERT_EXCEPTION_MSG = 'The execution failed due to an exception';
const waitForNextStakingEpoch = require('../utils/waitForNextStakingEpoch');
@ -38,19 +37,11 @@ describe('Candidates place stakes on themselves', () => {
minDelegatorStakeBN = new BN(minDelegatorStake.toString());
console.log('**** Delegator addresses are generated');
for (let i = 0; i < delegatorsNumber; i++) {
keythereum.create({}, function (dk) {
keythereum.dump("testnetpoa", dk.privateKey, dk.salt, dk.iv, {}, function (keyObject) {
keythereum.exportToFile(keyObject, "./accounts/keystore", function(keyFile) {
delegators.push(keyObject.address);
});
});
});
}
while (delegators.length < delegatorsNumber) {
await new Promise(r => setTimeout(r, 100));
let acc = web3.eth.accounts.create();
let keystoreObj = web3.eth.accounts.encrypt(acc.privateKey, 'testnetpoa');
delegators.push(acc.address);
fs.writeFileSync(path.join(__dirname, '../accounts/keystore', acc.address.substring(2).toLowerCase() + '.json'), JSON.stringify(keystoreObj), 'utf8');
}
});

View File

@ -1,6 +1,5 @@
'use strict';
const EthereumTx = require('ethereumjs-tx');
const Keythereum = require('keythereum');
const fs = require('fs');
const path = require('path');
/*
@ -27,10 +26,12 @@ const keysPassword = fs.readFileSync(
'utf-8'
).trim();
function getPrivateKey(address) {
var key = Keythereum.importFromFile(address, keysDir);
var privateKey = Keythereum.recover(keysPassword, key);
return privateKey;
function getPrivateKey(web3, address) {
var fname = path.join(keysDir, './keystore/', address.substring(2).toLowerCase() + '.json');
var keystore = require(fname);
var privateKey = web3.eth.accounts.decrypt(keystore, keysPassword).privateKey;
var pkBuff = Buffer.from(privateKey.substring(2), "hex");
return pkBuff;
}
module.exports = async function (web3, tx_details, privateKey) {
@ -75,7 +76,7 @@ module.exports = async function (web3, tx_details, privateKey) {
dbg(' **** chainId =', chainId);
if (privateKey == null) {
privateKey = getPrivateKey(from);
privateKey = getPrivateKey(web3, from);
}
let _tx = {