From 6920ae94815e25a80d07025d62e9ac25b7f63a0d Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sun, 30 Oct 2016 20:21:28 -0400 Subject: [PATCH] refactor to use commonOptions method --- lib/geth_commands.js | 57 ++++++++++++-------------------------------- 1 file changed, 15 insertions(+), 42 deletions(-) diff --git a/lib/geth_commands.js b/lib/geth_commands.js index 46e0e1ad8..88369d35d 100644 --- a/lib/geth_commands.js +++ b/lib/geth_commands.js @@ -4,48 +4,6 @@ var GethCommands = function(options) { this.name = "Go-Ethereum (https://github.com/ethereum/go-ethereum)"; }; -GethCommands.prototype.initGenesisCommmand = function() { - var config = this.config; - var cmd = "geth "; - - if (config.networkType === 'testnet') { - cmd += "--testnet "; - } else if (config.networkType === 'olympic') { - cmd += "--olympic "; - } - - if (config.datadir) { - cmd += "--datadir=\"" + config.datadir + "\" "; - } - - if (config.genesisBlock) { - cmd += "init \"" + config.genesisBlock + "\" "; - } - - return cmd; -}; - -GethCommands.prototype.newAccountCommand = function() { - var config = this.config; - var cmd = "geth "; - - if (config.networkType === 'testnet') { - cmd += "--testnet "; - } else if (config.networkType === 'olympic') { - cmd += "--olympic "; - } - - if (config.datadir) { - cmd += "--datadir=\"" + config.datadir + "\" "; - } - - if (config.account && config.account.password) { - cmd += "--password " + config.account.password + " "; - } - - return cmd + "account new "; -}; - GethCommands.prototype.commonOptions = function() { var config = this.config; var cmd = ""; @@ -69,6 +27,21 @@ GethCommands.prototype.commonOptions = function() { return cmd; }; +GethCommands.prototype.initGenesisCommmand = function() { + var config = this.config; + var cmd = "geth " + this.commonOptions(); + + if (config.genesisBlock) { + cmd += "init \"" + config.genesisBlock + "\" "; + } + + return cmd; +}; + +GethCommands.prototype.newAccountCommand = function() { + return "geth " + this.commonOptions() + "account new "; +}; + GethCommands.prototype.listAccountsCommand = function() { return "geth " + this.commonOptions() + "account list "; };