diff options
author | Marek Kotewicz <marek.kotewicz@gmail.com> | 2015-01-29 22:22:55 +0800 |
---|---|---|
committer | Marek Kotewicz <marek.kotewicz@gmail.com> | 2015-01-29 22:22:55 +0800 |
commit | 94e0e5ab7d8ec9adcd03fedc3abe5cf6444a5123 (patch) | |
tree | df0b2e41f5dc9e50b99fa45d597199fd71201678 /lib/abi.js | |
parent | e1c0862658ca80d2a4a85bd15eab38b0482fee1b (diff) | |
parent | 8613382869503c6123c3f47772bfdb192f6d3c76 (diff) | |
download | dexon-94e0e5ab7d8ec9adcd03fedc3abe5cf6444a5123.tar dexon-94e0e5ab7d8ec9adcd03fedc3abe5cf6444a5123.tar.gz dexon-94e0e5ab7d8ec9adcd03fedc3abe5cf6444a5123.tar.bz2 dexon-94e0e5ab7d8ec9adcd03fedc3abe5cf6444a5123.tar.lz dexon-94e0e5ab7d8ec9adcd03fedc3abe5cf6444a5123.tar.xz dexon-94e0e5ab7d8ec9adcd03fedc3abe5cf6444a5123.tar.zst dexon-94e0e5ab7d8ec9adcd03fedc3abe5cf6444a5123.zip |
Merge branch 'cpp' into cpp2
Conflicts:
example/balance.html
Diffstat (limited to 'lib/abi.js')
-rw-r--r-- | lib/abi.js | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/lib/abi.js b/lib/abi.js index 0989f4e15..a0c862593 100644 --- a/lib/abi.js +++ b/lib/abi.js @@ -65,6 +65,22 @@ var getMethodWithName = function (json, methodName) { return json[index]; }; +/// 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'; + }); +}; + /// @param string string to be padded /// @param number of characters that result string should have /// @param sign, by default 0 @@ -211,6 +227,7 @@ var signedIsNegative = function (value) { /// Formats input right-aligned input bytes to int /// @returns right-aligned input bytes formatted to int var formatOutputInt = function (value) { + value = value || "0"; // check if it's negative number // it it is, return two's complement if (signedIsNegative(value)) { @@ -222,6 +239,7 @@ var formatOutputInt = function (value) { /// Formats big right-aligned input bytes to uint /// @returns right-aligned input bytes formatted to uint var formatOutputUInt = function (value) { + value = value || "0"; return new BigNumber(value, 16); }; @@ -349,7 +367,7 @@ var methodTypeName = function (method) { /// @returns input parser object for given json abi var inputParser = function (json) { var parser = {}; - json.forEach(function (method) { + filterFunctions(json).forEach(function (method) { var displayName = methodDisplayName(method.name); var typeName = methodTypeName(method.name); @@ -372,7 +390,7 @@ var inputParser = function (json) { /// @returns output parser for given json abi var outputParser = function (json) { var parser = {}; - json.forEach(function (method) { + filterFunctions(json).forEach(function (method) { var displayName = methodDisplayName(method.name); var typeName = methodTypeName(method.name); @@ -403,6 +421,8 @@ module.exports = { methodSignature: methodSignature, methodDisplayName: methodDisplayName, methodTypeName: methodTypeName, - getMethodWithName: getMethodWithName + getMethodWithName: getMethodWithName, + filterFunctions: filterFunctions, + filterEvents: filterEvents }; |