aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorGav Wood <i@gavwood.com>2015-01-25 10:23:39 +0800
committerGav Wood <i@gavwood.com>2015-01-25 10:23:39 +0800
commit113a3809ab5e92cd0d60a02a5752b260a9ab3331 (patch)
tree1cbb4273c68f89b59186d65104cc9ab588172ee2 /lib
parentfb34c6c7b92b4dcb027c87dc9ca05c0f0c6457cf (diff)
downloaddexon-113a3809ab5e92cd0d60a02a5752b260a9ab3331.tar.gz
dexon-113a3809ab5e92cd0d60a02a5752b260a9ab3331.tar.zst
dexon-113a3809ab5e92cd0d60a02a5752b260a9ab3331.zip
Fix string outputs.
Auto collapse for < 2 returns.
Diffstat (limited to 'lib')
-rw-r--r--lib/abi.js2
-rw-r--r--lib/contract.js11
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/abi.js b/lib/abi.js
index 1dc662152..177a146b0 100644
--- a/lib/abi.js
+++ b/lib/abi.js
@@ -251,7 +251,7 @@ var formatOutputAddress = function (value) {
};
var dynamicBytesLength = function (type) {
- if (arrayType(type) || prefixedType('string')(type))
+ if (arrayType(type) || type == 'string') // only string itself that is dynamic; stringX is static length.
return ETH_PADDING * 2;
return 0;
};
diff --git a/lib/contract.js b/lib/contract.js
index ecabc87fa..418f87df7 100644
--- a/lib/contract.js
+++ b/lib/contract.js
@@ -90,6 +90,7 @@ var contract = function (address, desc) {
options.data = signature + parsed;
var isTransact = result._isTransact === true || (result._isTransact !== false && !method.constant);
+ var collapse = options.collapse !== false;
// reset
result._options = {};
@@ -107,7 +108,15 @@ var contract = function (address, desc) {
}
var output = web3.eth.call(options);
- return outputParser[displayName][typeName](output);
+ var ret = outputParser[displayName][typeName](output);
+ if (collapse)
+ {
+ if (ret.length == 1)
+ ret = ret[0];
+ else if (ret.length == 0)
+ ret = null;
+ }
+ return ret;
};
if (result[displayName] === undefined) {