Merge pull request #531 from embark-framework/features/gas-price-network

Get gas price for network and fix testnet
This commit is contained in:
Iuri Matias 2018-06-14 15:26:02 -04:00 committed by GitHub
commit 94bb43fd57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 4 deletions

View File

@ -46,9 +46,9 @@ class GethCommands {
determineNetworkType(config) { determineNetworkType(config) {
let cmd; let cmd;
if (config.networkType === 'testnet') { if (config.networkType === 'testnet') {
cmd = "--testnet "; cmd = "--testnet";
} else if (config.networkType === 'olympic') { } else if (config.networkType === 'olympic') {
cmd = "--olympic "; cmd = "--olympic";
} else if (config.networkType === 'custom') { } else if (config.networkType === 'custom') {
cmd = "--networkid=" + config.networkId; cmd = "--networkid=" + config.networkId;
} }

View File

@ -169,6 +169,10 @@ class Blockchain {
self.getBlock(blockNumber, cb); self.getBlock(blockNumber, cb);
}); });
this.events.setCommandHandler("blockchain:gasPrice", function(cb) {
self.getGasPrice(cb);
});
} }
defaultAccount() { defaultAccount() {
@ -191,6 +195,10 @@ class Blockchain {
this.web3.eth.getBlock(blockNumber, cb); this.web3.eth.getBlock(blockNumber, cb);
} }
getGasPrice(cb) {
this.web3.eth.getGasPrice(cb);
}
ContractObject(params) { ContractObject(params) {
return new this.web3.eth.Contract(params.abi); return new this.web3.eth.Contract(params.abi);
} }

View File

@ -89,7 +89,13 @@ class ContractsManager {
} }
callback(); 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; let className, compiledContract, contractConfig, contract;
for (className in self.compiledContracts) { for (className in self.compiledContracts) {
compiledContract = self.compiledContracts[className]; compiledContract = self.compiledContracts[className];
@ -108,7 +114,7 @@ class ContractsManager {
contract.gas = (contractConfig && contractConfig.gas) || self.contractsConfig.gas || 'auto'; 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.type = 'file';
contract.className = className; contract.className = className;