From 8cc485ac943823ce19626a354b28514bb4866b52 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Wed, 9 May 2018 09:17:48 -0400 Subject: [PATCH] add isDev blockchain option --- lib/cmds/blockchain/blockchain.js | 12 ++++++++++-- lib/cmds/blockchain/geth_commands.js | 8 ++++---- templates/boilerplate/config/blockchain.json | 1 + templates/demo/config/blockchain.json | 1 + test/test1/config/blockchain.json | 1 + test_apps/contracts_app/blockchain.json | 1 + test_apps/test_app/config/blockchain.json | 1 + 7 files changed, 19 insertions(+), 6 deletions(-) diff --git a/lib/cmds/blockchain/blockchain.js b/lib/cmds/blockchain/blockchain.js index 9ee2533f..d0fa2137 100644 --- a/lib/cmds/blockchain/blockchain.js +++ b/lib/cmds/blockchain/blockchain.js @@ -50,7 +50,15 @@ var Blockchain = function(options) { this.config.datadir = fs.embarkPath(".embark/development/datadir"); } - this.client = new options.client({config: this.config, env: this.env}); + if (this.blockchainConfig.isDev) { + this.isDev = true; + } else if (this.blockchainConfig.isDev === false) { + this.isDev = false; + } else { + this.isDev = this.env === 'development'; + } + + this.client = new options.client({config: this.config, env: this.env, isDev: this.isDev}); }; Blockchain.prototype.runCommand = function(cmd, options) { @@ -76,7 +84,7 @@ Blockchain.prototype.run = function() { return; } let address = ''; - if (self.env !== "development") { + if (!this.isDev) { address = this.initChainAndGetAddress(); } this.client.mainCommand(address, function(cmd) { diff --git a/lib/cmds/blockchain/geth_commands.js b/lib/cmds/blockchain/geth_commands.js index c7e7dd2c..84d28dcf 100644 --- a/lib/cmds/blockchain/geth_commands.js +++ b/lib/cmds/blockchain/geth_commands.js @@ -5,6 +5,7 @@ class GethCommands { constructor(options) { this.config = options && options.hasOwnProperty('config') ? options.config : {}; this.env = options && options.hasOwnProperty('env') ? options.env : 'development'; + this.isDev = options && options.hasOwnProperty('isDev') ? options.isDev : (this.env === 'development'); this.name = "Go-Ethereum (https://github.com/ethereum/go-ethereum)"; this.geth_bin = this.config.geth_bin || "geth"; } @@ -123,7 +124,6 @@ class GethCommands { let config = this.config; let rpc_api = (this.config.rpcApi || ['eth', 'web3', 'net']); let ws_api = (this.config.wsApi || ['eth', 'web3', 'net']); - const isDev = self.env === 'development'; async.series([ function commonOptions(callback) { @@ -189,7 +189,7 @@ class GethCommands { } else { accountAddress = address; } - if (accountAddress && !isDev) { + if (accountAddress && !self.isDev) { return callback(null, "--unlock=" + accountAddress); } callback(null, ""); @@ -201,13 +201,13 @@ class GethCommands { callback(null, ""); }, function mineWhenNeeded(callback) { - if (config.mineWhenNeeded && !isDev) { + if (config.mineWhenNeeded && !self.isDev) { return callback(null, "js .embark/" + self.env + "/js/mine.js"); } callback(null, ""); }, function isDev(callback) { - if (isDev) { + if (self.isDev) { return callback(null, '--dev'); } callback(null, ''); diff --git a/templates/boilerplate/config/blockchain.json b/templates/boilerplate/config/blockchain.json index afff2072..a7f31878 100644 --- a/templates/boilerplate/config/blockchain.json +++ b/templates/boilerplate/config/blockchain.json @@ -4,6 +4,7 @@ "networkType": "custom", "genesisBlock": "config/development/genesis.json", "datadir": ".embark/development/datadir", + "isDev": true, "mineWhenNeeded": true, "nodiscover": true, "maxpeers": 0, diff --git a/templates/demo/config/blockchain.json b/templates/demo/config/blockchain.json index 638c8167..5743c38d 100644 --- a/templates/demo/config/blockchain.json +++ b/templates/demo/config/blockchain.json @@ -4,6 +4,7 @@ "networkType": "custom", "genesisBlock": "config/development/genesis.json", "datadir": ".embark/development/datadir", + "isDev": true, "mineWhenNeeded": true, "nodiscover": true, "maxpeers": 0, diff --git a/test/test1/config/blockchain.json b/test/test1/config/blockchain.json index 090f4078..fc0ba5e1 100644 --- a/test/test1/config/blockchain.json +++ b/test/test1/config/blockchain.json @@ -3,6 +3,7 @@ "networkType": "custom", "genesisBlock": "config/development/genesis.json", "datadir": ".embark/development/datadir", + "isDev": true, "mineWhenNeeded": true, "nodiscover": true, "rpcHost": "localhost", diff --git a/test_apps/contracts_app/blockchain.json b/test_apps/contracts_app/blockchain.json index 35edfb43..a574d400 100644 --- a/test_apps/contracts_app/blockchain.json +++ b/test_apps/contracts_app/blockchain.json @@ -4,6 +4,7 @@ "networkType": "custom", "genesisBlock": "development/genesis.json", "datadir": ".embark/development/datadir", + "isDev": true, "mineWhenNeeded": true, "nodiscover": true, "maxpeers": 0, diff --git a/test_apps/test_app/config/blockchain.json b/test_apps/test_app/config/blockchain.json index 6acbdfd5..2b9baa50 100644 --- a/test_apps/test_app/config/blockchain.json +++ b/test_apps/test_app/config/blockchain.json @@ -4,6 +4,7 @@ "networkType": "custom", "genesisBlock": "config/development/genesis.json", "datadir": ".embark/development/datadir", + "isDev": true, "mineWhenNeeded": true, "nodiscover": true, "maxpeers": 0,