mirror of https://github.com/embarklabs/embark.git
Applying simulatorAccounts configuration for "embark simulator".
This commit is contained in:
parent
e24937cadc
commit
3edf7c2419
|
@ -32,6 +32,25 @@ class Simulator {
|
||||||
cmds.push("--mnemonic \"" + (simulatorMnemonic) +"\"");
|
cmds.push("--mnemonic \"" + (simulatorMnemonic) +"\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// the simulatorAccounts configuration overrides a mnemonic
|
||||||
|
let simulatorAccounts = this.blockchainConfig.simulatorAccounts || options.simulatorAccounts;
|
||||||
|
if (simulatorAccounts && simulatorAccounts.length > 0) {
|
||||||
|
simulatorAccounts.forEach((account, index) => {
|
||||||
|
let hexBalance = '0x8AC7230489E80000'; // 10 ether;
|
||||||
|
if (account.hexBalance) { // TODO: ensure it is 0x-prefixed hex
|
||||||
|
if (account.hexBalance.match(/0x[a-f0-9]+/i)) {
|
||||||
|
hexBalance = 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);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// adding blocktime only if it is defined in the blockchainConfig or options
|
// adding blocktime only if it is defined in the blockchainConfig or options
|
||||||
let simulatorBlocktime = this.blockchainConfig.simulatorBlocktime || options.simulatorBlocktime;
|
let simulatorBlocktime = this.blockchainConfig.simulatorBlocktime || options.simulatorBlocktime;
|
||||||
if (simulatorBlocktime) {
|
if (simulatorBlocktime) {
|
||||||
|
|
Loading…
Reference in New Issue