refactor format params
This commit is contained in:
parent
f7d5bd0e70
commit
8eb4d41ecd
|
@ -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() {
|
||||||
|
|
Loading…
Reference in New Issue