mirror of https://github.com/embarklabs/embark.git
get gasPrice if no gasPrice set in contract.json
This commit is contained in:
parent
a09f680ca7
commit
dcbd868b78
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue