diff --git a/lib/cmds/blockchain/geth_commands.js b/lib/cmds/blockchain/geth_commands.js index 21a8a2d77..ab71fda80 100644 --- a/lib/cmds/blockchain/geth_commands.js +++ b/lib/cmds/blockchain/geth_commands.js @@ -46,9 +46,9 @@ class GethCommands { determineNetworkType(config) { let cmd; if (config.networkType === 'testnet') { - cmd = "--testnet "; + cmd = "--testnet"; } else if (config.networkType === 'olympic') { - cmd = "--olympic "; + cmd = "--olympic"; } else if (config.networkType === 'custom') { cmd = "--networkid=" + config.networkId; } diff --git a/lib/contracts/blockchain.js b/lib/contracts/blockchain.js index 1fbf4dde1..9f19b9e1b 100644 --- a/lib/contracts/blockchain.js +++ b/lib/contracts/blockchain.js @@ -169,6 +169,10 @@ class Blockchain { self.getBlock(blockNumber, cb); }); + this.events.setCommandHandler("blockchain:gasPrice", function(cb) { + self.getGasPrice(cb); + }); + } defaultAccount() { @@ -191,6 +195,10 @@ class Blockchain { this.web3.eth.getBlock(blockNumber, cb); } + getGasPrice(cb) { + this.web3.eth.getGasPrice(cb); + } + ContractObject(params) { return new this.web3.eth.Contract(params.abi); } diff --git a/lib/contracts/contracts.js b/lib/contracts/contracts.js index f74e38c22..5a544d3a0 100644 --- a/lib/contracts/contracts.js +++ b/lib/contracts/contracts.js @@ -89,7 +89,13 @@ class ContractsManager { } callback(); }, - function prepareContractsFromCompilation(callback) { + function getGasPriceForNetwork(callback) { + if (self.contractsConfig.gasPrice) { + return callback(null, self.contractsConfig.gasPrice); + } + self.events.request("blockchain:gasPrice", callback); + }, + function prepareContractsFromCompilation(gasPrice, callback) { let className, compiledContract, contractConfig, contract; for (className in self.compiledContracts) { compiledContract = self.compiledContracts[className]; @@ -108,7 +114,7 @@ class ContractsManager { contract.gas = (contractConfig && contractConfig.gas) || self.contractsConfig.gas || 'auto'; - contract.gasPrice = contract.gasPrice || self.contractsConfig.gasPrice; + contract.gasPrice = contract.gasPrice || gasPrice; contract.type = 'file'; contract.className = className;