mirror of
https://github.com/status-im/embark-area-51.git
synced 2025-01-09 21:46:12 +00:00
fix initChain to not always generate an account and the genesis block
This commit is contained in:
parent
8cb372f9ef
commit
b19c073b02
@ -221,6 +221,7 @@ Blockchain.prototype.isClientInstalled = function(callback) {
|
|||||||
Blockchain.prototype.initChainAndGetAddress = function(callback) {
|
Blockchain.prototype.initChainAndGetAddress = function(callback) {
|
||||||
const self = this;
|
const self = this;
|
||||||
let address = null;
|
let address = null;
|
||||||
|
const ALREADY_INITIALIZED = 'already';
|
||||||
|
|
||||||
// ensure datadir exists, bypassing the interactive liabilities prompt.
|
// ensure datadir exists, bypassing the interactive liabilities prompt.
|
||||||
self.datadir = '.embark/' + self.env + '/datadir';
|
self.datadir = '.embark/' + self.env + '/datadir';
|
||||||
@ -236,14 +237,14 @@ Blockchain.prototype.initChainAndGetAddress = function(callback) {
|
|||||||
fs.copy(fs.embarkPath("js"), ".embark/" + self.env + "/js", {overwrite: true}, next);
|
fs.copy(fs.embarkPath("js"), ".embark/" + self.env + "/js", {overwrite: true}, next);
|
||||||
},
|
},
|
||||||
function listAccounts(next) {
|
function listAccounts(next) {
|
||||||
self.runCommand(self.client.listAccountsCommand(), {}, (err, stdout, stderr) => {
|
self.runCommand(self.client.listAccountsCommand(), {}, (err, stdout, _stderr) => {
|
||||||
if (err || stderr || stdout === undefined || stdout.match(/{(\w+)}/) === null || stdout.indexOf("Fatal") >= 0) {
|
if (err || stdout === undefined || stdout.match(/{(\w+)}/) === null || stdout.indexOf("Fatal") >= 0) {
|
||||||
console.log(__("no accounts found").green);
|
console.log(__("no accounts found").green);
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
console.log(__("already initialized").green);
|
console.log(__("already initialized").green);
|
||||||
address = stdout.match(/{(\w+)}/)[1];
|
address = stdout.match(/{(\w+)}/)[1];
|
||||||
next();
|
next(ALREADY_INITIALIZED);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
function genesisBlock(next) {
|
function genesisBlock(next) {
|
||||||
@ -265,6 +266,9 @@ Blockchain.prototype.initChainAndGetAddress = function(callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
], (err) => {
|
], (err) => {
|
||||||
|
if (err === ALREADY_INITIALIZED) {
|
||||||
|
err = null;
|
||||||
|
}
|
||||||
callback(err, address);
|
callback(err, address);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user