Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add constraint conditions and increase the readability #1418

Merged
merged 1 commit into from
Mar 13, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions lib/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,22 @@ var transformToFullName = function (json) {
* @returns {String} display name for function/event eg. multiply(uint256) -> multiply
*/
var extractDisplayName = function (name) {
var length = name.indexOf('(');
return length !== -1 ? name.substr(0, length) : name;
var stBracket = name.indexOf('(');
var endBracket = name.indexOf(')');
return (stBracket !== -1 && endBracket !== -1) ? name.substr(0, stBracket) : name;
};

/// @returns overloaded part of function/event name
/**
* Should be called to get type name of contract function
*
* @method extractTypeName
* @param {String} name of function/event
* @returns {String} type name for function/event eg. multiply(uint256) -> uint256
*/
var extractTypeName = function (name) {
/// TODO: make it invulnerable
var length = name.indexOf('(');
return length !== -1 ? name.substr(length + 1, name.length - 1 - (length + 1)).replace(' ', '') : "";
var stBracket = name.indexOf('(');
var endBracket = name.indexOf(')');
return (stBracket !== -1 && endBracket !== -1) ? name.substr(stBracket + 1, endBracket - stBracket - 1).replace(' ', '') : "";
};

/**
Expand Down