Skip to content

Commit d184d71

Browse files
authored
Merge pull request #596 from embark-framework/bug_fix/account
fix account initialization and address use
2 parents de39180 + ffb3ec5 commit d184d71

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

lib/cmds/blockchain/blockchain.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ Blockchain.prototype.isClientInstalled = function(callback) {
204204
Blockchain.prototype.initChainAndGetAddress = function(callback) {
205205
const self = this;
206206
let address = null;
207+
const ALREADY_INITIALIZED = 'already';
207208

208209
// ensure datadir exists, bypassing the interactive liabilities prompt.
209210
self.datadir = '.embark/' + self.env + '/datadir';
@@ -219,14 +220,14 @@ Blockchain.prototype.initChainAndGetAddress = function(callback) {
219220
fs.copy(fs.embarkPath("js"), ".embark/" + self.env + "/js", {overwrite: true}, next);
220221
},
221222
function listAccounts(next) {
222-
self.runCommand(self.client.listAccountsCommand(), {}, (err, stdout, stderr) => {
223-
if (err || stderr || stdout === undefined || stdout.match(/{(\w+)}/) === null || stdout.indexOf("Fatal") >= 0) {
223+
self.runCommand(self.client.listAccountsCommand(), {}, (err, stdout, _stderr) => {
224+
if (err || stdout === undefined || stdout.match(/{(\w+)}/) === null || stdout.indexOf("Fatal") >= 0) {
224225
console.log(__("no accounts found").green);
225226
return next();
226227
}
227228
console.log(__("already initialized").green);
228229
address = stdout.match(/{(\w+)}/)[1];
229-
next();
230+
next(ALREADY_INITIALIZED);
230231
});
231232
},
232233
function genesisBlock(next) {
@@ -248,6 +249,9 @@ Blockchain.prototype.initChainAndGetAddress = function(callback) {
248249
});
249250
}
250251
], (err) => {
252+
if (err === ALREADY_INITIALIZED) {
253+
err = null;
254+
}
251255
callback(err, address);
252256
});
253257
};

lib/cmds/blockchain/geth_commands.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ class GethCommands {
197197
},
198198
function accountToUnlock(callback) {
199199
let accountAddress = "";
200-
if(config.hasOwnProperty('address') && config.account.hasOwnProperty('address')) {
200+
if(config.account && config.account.address) {
201201
accountAddress = config.account.address;
202202
} else {
203203
accountAddress = address;

0 commit comments

Comments
 (0)