aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/abi.js2
-rw-r--r--lib/web3.js4
2 files changed, 5 insertions, 1 deletions
diff --git a/lib/abi.js b/lib/abi.js
index 0989f4e15..ba47dca73 100644
--- a/lib/abi.js
+++ b/lib/abi.js
@@ -211,6 +211,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 +223,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);
};
diff --git a/lib/web3.js b/lib/web3.js
index 7cf624c9c..622be29b6 100644
--- a/lib/web3.js
+++ b/lib/web3.js
@@ -233,7 +233,9 @@ var web3 = {
/// @returns decimal representaton of hex value prefixed by 0x
toDecimal: function (val) {
- return (new BigNumber(val.substring(2), 16).toString(10));
+ // remove 0x and place 0, if it's required
+ val = val.length > 2 ? val.substring(2) : "0";
+ return (new BigNumber(val, 16).toString(10));
},
/// @returns hex representation (prefixed by 0x) of decimal value