Merge pull request #495 from embark-framework/bug_fix/accounts-with-no-node
change account funding order to enable starting a node before
This commit is contained in:
commit
48c99b4075
|
@ -54,17 +54,21 @@ class Blockchain {
|
|||
};
|
||||
provider = new Provider(providerOptions);
|
||||
|
||||
provider.startWeb3Provider(() => {
|
||||
async.waterfall([
|
||||
function startProvider(next) {
|
||||
provider.startWeb3Provider(next);
|
||||
},
|
||||
function checkNode(next) {
|
||||
self.assertNodeConnection(true, (err) => {
|
||||
if (err && self.web3StartedInProcess) {
|
||||
// Already started blockchain in another node, we really have a node problem
|
||||
self.logger.error(__('Unable to start the blockchain process. Is Geth installed?').red);
|
||||
return cb(err);
|
||||
return next(err);
|
||||
}
|
||||
if (!err) {
|
||||
self.isWeb3Ready = true;
|
||||
self.events.emit(WEB3_READY);
|
||||
return cb();
|
||||
return next();
|
||||
}
|
||||
self.web3StartedInProcess = true;
|
||||
self.startBlockchainNode(() => {
|
||||
|
@ -73,7 +77,11 @@ class Blockchain {
|
|||
self.initWeb3(cb);
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
function fundAccountsIfNeeded(next) {
|
||||
provider.fundAccounts(next);
|
||||
}
|
||||
], cb);
|
||||
} else {
|
||||
throw new Error("contracts config error: unknown deployment type " + this.contractsConfig.deployment.type);
|
||||
}
|
||||
|
|
|
@ -35,18 +35,10 @@ class Provider {
|
|||
self.accounts = AccountParser.parseAccountsConfig(self.accountsConfig, self.web3, self.logger);
|
||||
self.addresses = [];
|
||||
async.waterfall([
|
||||
function fundAccounts(next) {
|
||||
function populateWeb3Wallet(next) {
|
||||
if (!self.accounts.length) {
|
||||
return next(NO_ACCOUNTS);
|
||||
}
|
||||
if (!self.isDev) {
|
||||
return next();
|
||||
}
|
||||
async.each(self.accounts, (account, eachCb) => {
|
||||
fundAccount(self.web3, account.address, eachCb);
|
||||
}, next);
|
||||
},
|
||||
function populateWeb3Wallet(next) {
|
||||
self.accounts.forEach(account => {
|
||||
self.addresses.push(account.address);
|
||||
self.web3.eth.accounts.wallet.add(account);
|
||||
|
@ -64,6 +56,19 @@ class Provider {
|
|||
});
|
||||
}
|
||||
|
||||
fundAccounts(callback) {
|
||||
const self = this;
|
||||
if (!self.accounts.length) {
|
||||
return callback();
|
||||
}
|
||||
if (!self.isDev) {
|
||||
return callback();
|
||||
}
|
||||
async.each(self.accounts, (account, eachCb) => {
|
||||
fundAccount(self.web3, account.address, eachCb);
|
||||
}, callback);
|
||||
}
|
||||
|
||||
stop() {
|
||||
this.engine.stop();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue