mirror of https://github.com/embarklabs/embark.git
fix gas settings; add information of gas used with deployment
This commit is contained in:
parent
d05cf90b5b
commit
ae3bcb1060
|
@ -42,20 +42,24 @@ ContractsManager.prototype.build = function() {
|
||||||
contract.gasEstimates = compiledContract.gasEstimates;
|
contract.gasEstimates = compiledContract.gasEstimates;
|
||||||
contract.functionHashes = compiledContract.functionHashes;
|
contract.functionHashes = compiledContract.functionHashes;
|
||||||
contract.abiDefinition = compiledContract.abiDefinition;
|
contract.abiDefinition = compiledContract.abiDefinition;
|
||||||
|
contract.gas = (contractConfig && contractConfig.gas) || this.contractsConfig.gas;
|
||||||
|
|
||||||
if (this.contractsConfig.gas === 'auto') {
|
if (contract.deploy === undefined) {
|
||||||
|
contract.deploy = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (contract.gas === 'auto') {
|
||||||
var maxGas;
|
var maxGas;
|
||||||
if (contract.deploy) {
|
if (contract.deploy) {
|
||||||
maxGas = Math.max(contract.gasEstimates.creation[0], contract.gasEstimates.creation[1], 500000);
|
maxGas = Math.max(contract.gasEstimates.creation[0], contract.gasEstimates.creation[1], 500000);
|
||||||
} else {
|
} else {
|
||||||
maxGas = 500000;
|
maxGas = 500000;
|
||||||
}
|
}
|
||||||
var adjustedGas = Math.round(maxGas * 1.01);
|
// TODO: put a check so it doesn't go over the block limit
|
||||||
|
var adjustedGas = Math.round(maxGas * 1.40);
|
||||||
contract.gas = adjustedGas;
|
contract.gas = adjustedGas;
|
||||||
} else {
|
|
||||||
contract.gas = this.contractsConfig.gas;
|
|
||||||
}
|
}
|
||||||
contract.gasPrice = this.contractsConfig.gasPrice;
|
contract.gasPrice = contract.gasPrice || this.contractsConfig.gasPrice;
|
||||||
contract.type = 'file';
|
contract.type = 'file';
|
||||||
contract.className = className;
|
contract.className = className;
|
||||||
|
|
||||||
|
|
|
@ -117,7 +117,7 @@ Deploy.prototype.deployContract = function(contract, params, callback) {
|
||||||
gasPrice: contract.gasPrice
|
gasPrice: contract.gasPrice
|
||||||
});
|
});
|
||||||
|
|
||||||
self.logger.info("deploying " + contract.className);
|
self.logger.info("deploying " + contract.className + " with " + contract.gas + " gas");
|
||||||
contractParams.push(function(err, transaction) {
|
contractParams.push(function(err, transaction) {
|
||||||
self.logger.contractsState(self.contractsManager.contractsState());
|
self.logger.contractsState(self.contractsManager.contractsState());
|
||||||
|
|
||||||
|
@ -129,6 +129,7 @@ Deploy.prototype.deployContract = function(contract, params, callback) {
|
||||||
} else if (transaction.address !== undefined) {
|
} else if (transaction.address !== undefined) {
|
||||||
self.logger.info(contract.className + " deployed at " + transaction.address);
|
self.logger.info(contract.className + " deployed at " + transaction.address);
|
||||||
contract.deployedAddress = transaction.address;
|
contract.deployedAddress = transaction.address;
|
||||||
|
contract.transactionHash = transaction.transactionHash;
|
||||||
callback(null, transaction.address);
|
callback(null, transaction.address);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue