use config password file; tolerate somethign going terribly wrong since it wouldnt' affect the blockchain process generally

This commit is contained in:
Iuri Matias 2018-07-19 11:15:16 +03:00
parent 69f356b3f0
commit 71e9eed67b
1 changed files with 17 additions and 10 deletions

View File

@ -5,16 +5,20 @@ const {readFileSync, dappPath} = require('../../core/fs');
class DevFunds {
constructor(blockchainConfig) {
this.web3 = null;
this.blockchainConfig = blockchainConfig;
this.accounts = [];
this.numAccounts = this.blockchainConfig.account.numAccounts || 0;
this.password = readFileSync(dappPath('config/development/password'), 'utf8').replace('\n', '');
this.web3 = new Web3();
this.networkId = null;
this.balance = Web3.utils.toWei("1", "ether");
if (this.blockchainConfig.account.balance) {
this.balance = getWeiBalanceFromString(this.blockchainConfig.account.balance, this.web3);
// TODO: temporary to avoid nasty suprises, should be removed
try {
this.web3 = null;
this.blockchainConfig = blockchainConfig;
this.accounts = [];
this.numAccounts = this.blockchainConfig.account.numAccounts || 0;
this.password = readFileSync(dappPath(blockchainConfig.account.password), 'utf8').replace('\n', '');
this.web3 = new Web3();
this.networkId = null;
this.balance = Web3.utils.toWei("1", "ether");
if (this.blockchainConfig.account.balance) {
this.balance = getWeiBalanceFromString(this.blockchainConfig.account.balance, this.web3);
}
} catch(_err) {
}
}
@ -95,6 +99,9 @@ class DevFunds {
}
createFundAndUnlockAccounts(cb) {
if (!this.web3) {
return cb();
}
async.waterfall([
(next) => {
this.connectToNode(next);