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.functionHashes = compiledContract.functionHashes;
|
||||
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;
|
||||
if (contract.deploy) {
|
||||
maxGas = Math.max(contract.gasEstimates.creation[0], contract.gasEstimates.creation[1], 500000);
|
||||
} else {
|
||||
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;
|
||||
} else {
|
||||
contract.gas = this.contractsConfig.gas;
|
||||
}
|
||||
contract.gasPrice = this.contractsConfig.gasPrice;
|
||||
contract.gasPrice = contract.gasPrice || this.contractsConfig.gasPrice;
|
||||
contract.type = 'file';
|
||||
contract.className = className;
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ Deploy.prototype.deployContract = function(contract, params, callback) {
|
|||
gasPrice: contract.gasPrice
|
||||
});
|
||||
|
||||
self.logger.info("deploying " + contract.className);
|
||||
self.logger.info("deploying " + contract.className + " with " + contract.gas + " gas");
|
||||
contractParams.push(function(err, transaction) {
|
||||
self.logger.contractsState(self.contractsManager.contractsState());
|
||||
|
||||
|
@ -129,6 +129,7 @@ Deploy.prototype.deployContract = function(contract, params, callback) {
|
|||
} else if (transaction.address !== undefined) {
|
||||
self.logger.info(contract.className + " deployed at " + transaction.address);
|
||||
contract.deployedAddress = transaction.address;
|
||||
contract.transactionHash = transaction.transactionHash;
|
||||
callback(null, transaction.address);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue