finclude transaction cost in gas estimation

This commit is contained in:
Iuri Matias 2017-02-06 21:34:10 -05:00
parent fc2c6a41ee
commit 135c3c06a7
1 changed files with 4 additions and 2 deletions

View File

@ -7,8 +7,9 @@ var async = require('async');
var adjustGas = function(contract) {
var maxGas, adjustedGas;
if (contract.gas === 'auto') {
if (contract.deploy) {
if (contract.deploy || contract.deploy === undefined) {
if (contract.gasEstimates.creation !== undefined) {
// TODO: should sum it instead
maxGas = Math.max(contract.gasEstimates.creation[0], contract.gasEstimates.creation[1], 500000);
} else {
maxGas = 500000;
@ -17,7 +18,8 @@ var adjustGas = function(contract) {
maxGas = 500000;
}
// TODO: put a check so it doesn't go over the block limit
adjustedGas = Math.round(maxGas * 1.40);
adjustedGas = Math.round(maxGas * 1.40);
adjustedGas += 25000;
contract.gas = adjustedGas;
}
};