mirror of https://github.com/embarklabs/embark.git
[m] Parsing simulatorAccounts using AccountParser .
This commit is contained in:
parent
ab0a3b0735
commit
922a400b5b
|
@ -32,21 +32,14 @@ class Simulator {
|
||||||
cmds.push("--mnemonic \"" + (simulatorMnemonic) +"\"");
|
cmds.push("--mnemonic \"" + (simulatorMnemonic) +"\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
// the simulatorAccounts configuration overrides a mnemonic
|
// as ganache-cli documentation explains, the simulatorAccounts configuration overrides a mnemonic
|
||||||
let simulatorAccounts = this.blockchainConfig.simulatorAccounts || options.simulatorAccounts;
|
let simulatorAccounts = this.blockchainConfig.simulatorAccounts || options.simulatorAccounts;
|
||||||
if (simulatorAccounts && simulatorAccounts.length > 0) {
|
if (simulatorAccounts && simulatorAccounts.length > 0) {
|
||||||
simulatorAccounts.forEach((account, index) => {
|
let web3 = new (require('web3'))();
|
||||||
let hexBalance = '0x8AC7230489E80000'; // 10 ether;
|
let AccountParser = require('../utils/accountParser.js');
|
||||||
if (account.hexBalance) { // TODO: ensure it is 0x-prefixed hex
|
let parsedAccounts = AccountParser.parseAccountsConfig(simulatorAccounts, web3, this.logger);
|
||||||
if (account.hexBalance.match(/0x[a-f0-9]+/i)) {
|
parsedAccounts.forEach((account) => {
|
||||||
hexBalance = account.hexBalance;
|
let cmd = '--account="' + account.privateKey + ','+account.hexBalance + '"';
|
||||||
} else {
|
|
||||||
this.logger.warn('Balance provided for the account #' + index + ' is not a valid hex number. Using 10 ether as a default.');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.logger.warn('No balance has been provided for the account #' + index + '. Using 10 ether as a default.');
|
|
||||||
}
|
|
||||||
let cmd = '--account="' + account.privateKey + ','+hexBalance + '"';
|
|
||||||
cmds.push(cmd);
|
cmds.push(cmd);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue