fix some PR comments

This commit is contained in:
Jonathan Rainville 2018-05-18 13:27:01 -04:00
parent 09cdab7e2b
commit 4c17aa9d40
2 changed files with 10 additions and 1 deletions

View File

@ -125,6 +125,7 @@ Blockchain.prototype.initChainAndGetAddress = function() {
};
var BlockchainClient = function(blockchainConfig, client, env, isDev) {
// TODO add other clients at some point
if (client === 'geth') {
return new Blockchain({blockchainConfig, client: GethCommands, env, isDev});
} else {

View File

@ -29,15 +29,23 @@ class AccountParser {
if (!accountConfig.privateKey.startsWith('0x')) {
accountConfig.privateKey = '0x' + accountConfig.privateKey;
}
if (!web3.utils.isHexStrict(accountConfig.privateKey)) {
logger.warn(`Private key ending with ${accountConfig.privateKey.substr(accountConfig.privateKey.length - 5)} is not a HEX string`);
return null;
}
return web3.eth.accounts.privateKeyToAccount(accountConfig.privateKey);
}
if (accountConfig.privateKeyFile) {
let fileContent = fs.readFileSync(fs.dappPath(accountConfig.privateKeyFile)).toString();
fileContent = fileContent.trim().split(/[,;]/);
return fileContent.map(key => {
return fileContent.map((key, index) => {
if (!key.startsWith('0x')) {
key = '0x' + key;
}
if (!web3.utils.isHexStrict(key)) {
logger.warn(`Private key is not a HEX string in file ${accountConfig.privateKeyFile} at index ${index}`);
return null;
}
return web3.eth.accounts.privateKeyToAccount(key);
});
}