few methods moved to utils
This commit is contained in:
34
lib/utils.js
34
lib/utils.js
@ -72,10 +72,42 @@ var fromAscii = function(str, pad) {
|
||||
return "0x" + hex;
|
||||
};
|
||||
|
||||
/// @returns 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;
|
||||
};
|
||||
|
||||
/// @returns overloaded part of function/event name
|
||||
var extractTypeName = function (name) {
|
||||
/// TODO: make it invulnerable
|
||||
var length = name.indexOf('(');
|
||||
return length !== -1 ? name.substr(length + 1, name.length - 1 - (length + 1)) : "";
|
||||
};
|
||||
|
||||
/// Filters all function from input abi
|
||||
/// @returns abi array with filtered objects of type 'function'
|
||||
var filterFunctions = function (json) {
|
||||
return json.filter(function (current) {
|
||||
return current.type === 'function';
|
||||
});
|
||||
};
|
||||
|
||||
/// Filters all events form input abi
|
||||
/// @returns abi array with filtered objects of type 'event'
|
||||
var filterEvents = function (json) {
|
||||
return json.filter(function (current) {
|
||||
return current.type === 'event';
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
findIndex: findIndex,
|
||||
toAscii: toAscii,
|
||||
fromAscii: fromAscii
|
||||
fromAscii: fromAscii,
|
||||
extractDisplayName: extractDisplayName,
|
||||
extractTypeName: extractTypeName,
|
||||
filterFunctions: filterFunctions,
|
||||
filterEvents: filterEvents
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user