diff --git a/lib/modules/gasEstimator/index.js b/lib/modules/gasEstimator/index.js index 4eb27853..101083a4 100644 --- a/lib/modules/gasEstimator/index.js +++ b/lib/modules/gasEstimator/index.js @@ -23,10 +23,15 @@ class GasEstimator { async.each(contract.abiDefinition, (abiMethod, gasCb) => { let name = abiMethod.name; + console.log("NAME: ", name); + console.log("ABI INPUTS: ", abiMethod.inputs); if (abiMethod.type === "constructor") { // already provided for us - gasCb(null, 'constructor', contract.gasEstimates.creation.totalCost); - } else if (abiMethod.inputs === []) { + gasCb(null, 'constructor', contract.gasEstimates.creation.totalCost.toString()); + } else if (abiMethod.type === "fallback") { + gasCb(null, 'fallback', contract.gasEstimates.external[""].toString()); + } else if (abiMethod.inputs === null || abiMethod.inputs === undefined || abiMethod.inputs.length === 0) { + console.log("Are we hitting here"); // just run it and register it contractObj.methods[name] .apply(contractObj.methods[name], []) @@ -46,7 +51,7 @@ class GasEstimator { }, (err, variance) => { if (err) { gasCb(err) - } else if (variance.reduce(_.isEqual, variance[2])) { + } else if (_.isEqual(variance[0], variance[1]) && _.isEqual(variance[1], variance[2])) { gasMap[name] = variance[0]; } else { gasMap[name] = 'variable'; diff --git a/lib/modules/profiler/index.js b/lib/modules/profiler/index.js index 14b7859a..56a46fe1 100644 --- a/lib/modules/profiler/index.js +++ b/lib/modules/profiler/index.js @@ -21,10 +21,10 @@ class Profiler { console.log("Abi Method Gastimate: ", gastimates[abiMethod.name]); switch(abiMethod.type) { case "constructor": - table.addRow("constructor", abiMethod.payable, abiMethod.stateMutability, this.formatParams(abiMethod.inputs), this.formatParams(abiMethod.outputs), gastimates['constructor']); + table.addRow("constructor", abiMethod.payable, abiMethod.stateMutability, self.formatParams(abiMethod.inputs), self.formatParams(abiMethod.outputs), gastimates['constructor']); break; default: - table.addRow(abiMethod.name, abiMethod.payable, abiMethod.stateMutability, this.formatParams(abiMethod.inputs), this.formatParams(abiMethod.outputs), gastimates[abiMethod.name]); + table.addRow(abiMethod.name, abiMethod.payable, abiMethod.stateMutability, self.formatParams(abiMethod.inputs), self.formatParams(abiMethod.outputs), gastimates[abiMethod.name]); } }); self.logger.info(table.toString());