Merge pull request #596 from embark-framework/bug_fix/account
fix account initialization and address use
This commit is contained in:
commit
d184d71cc8
|
@ -204,6 +204,7 @@ Blockchain.prototype.isClientInstalled = function(callback) {
|
|||
Blockchain.prototype.initChainAndGetAddress = function(callback) {
|
||||
const self = this;
|
||||
let address = null;
|
||||
const ALREADY_INITIALIZED = 'already';
|
||||
|
||||
// ensure datadir exists, bypassing the interactive liabilities prompt.
|
||||
self.datadir = '.embark/' + self.env + '/datadir';
|
||||
|
@ -219,14 +220,14 @@ Blockchain.prototype.initChainAndGetAddress = function(callback) {
|
|||
fs.copy(fs.embarkPath("js"), ".embark/" + self.env + "/js", {overwrite: true}, next);
|
||||
},
|
||||
function listAccounts(next) {
|
||||
self.runCommand(self.client.listAccountsCommand(), {}, (err, stdout, stderr) => {
|
||||
if (err || stderr || stdout === undefined || stdout.match(/{(\w+)}/) === null || stdout.indexOf("Fatal") >= 0) {
|
||||
self.runCommand(self.client.listAccountsCommand(), {}, (err, stdout, _stderr) => {
|
||||
if (err || stdout === undefined || stdout.match(/{(\w+)}/) === null || stdout.indexOf("Fatal") >= 0) {
|
||||
console.log(__("no accounts found").green);
|
||||
return next();
|
||||
}
|
||||
console.log(__("already initialized").green);
|
||||
address = stdout.match(/{(\w+)}/)[1];
|
||||
next();
|
||||
next(ALREADY_INITIALIZED);
|
||||
});
|
||||
},
|
||||
function genesisBlock(next) {
|
||||
|
@ -248,6 +249,9 @@ Blockchain.prototype.initChainAndGetAddress = function(callback) {
|
|||
});
|
||||
}
|
||||
], (err) => {
|
||||
if (err === ALREADY_INITIALIZED) {
|
||||
err = null;
|
||||
}
|
||||
callback(err, address);
|
||||
});
|
||||
};
|
||||
|
|
|
@ -197,7 +197,7 @@ class GethCommands {
|
|||
},
|
||||
function accountToUnlock(callback) {
|
||||
let accountAddress = "";
|
||||
if(config.hasOwnProperty('address') && config.account.hasOwnProperty('address')) {
|
||||
if(config.account && config.account.address) {
|
||||
accountAddress = config.account.address;
|
||||
} else {
|
||||
accountAddress = address;
|
||||
|
|
Loading…
Reference in New Issue