refactor format params

This commit is contained in:
Iuri Matias 2018-08-01 15:16:41 -04:00 committed by Pascal Precht
parent f7d5bd0e70
commit 8eb4d41ecd
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
1 changed files with 2 additions and 9 deletions

View File

@ -24,21 +24,14 @@ class Profiler {
let table = new asciiTable(contractName); let table = new asciiTable(contractName);
table.setHeading('Function', 'Payable', 'Mutability', 'Inputs', 'Outputs', 'Gas Estimates'); table.setHeading('Function', 'Payable', 'Mutability', 'Inputs', 'Outputs', 'Gas Estimates');
profileObj.methods.forEach((method) => { profileObj.methods.forEach((method) => {
table.addRow(method.name, method.payable, method.mutability, method.inputs, method.outputs, method.gasEstimates); table.addRow(method.name, method.payable, method.mutability, self.formatParams(method.inputs), self.formatParams(method.outputs), method.gasEstimates);
}); });
callback(null, table.toString()); callback(null, table.toString());
}); });
} }
formatParams(params) { formatParams(params) {
if (!params || !params.length) { return "(" + (params || []).map(param => param.type).join(',') + ")";
return "()";
}
let paramString = "(";
let mappedParams = params.map(param => param.type);
paramString += mappedParams.join(',');
paramString += ")";
return paramString;
} }
registerConsoleCommand() { registerConsoleCommand() {