From 07fba274b1d5da40b0fbe58263d6c3dc5ed6fa6e Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Fri, 9 Jan 2015 12:43:45 +0100 Subject: module var fix --- lib/websocket.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/websocket.js b/lib/websocket.js index ddb44aed5..5b40075e4 100644 --- a/lib/websocket.js +++ b/lib/websocket.js @@ -74,4 +74,5 @@ Object.defineProperty(WebSocketProvider.prototype, "onmessage", { set: function(provider) { this.onMessage(provider); } }); -module.exports = WebSocketProvider; +if (typeof(module) !== "undefined") + module.exports = WebSocketProvider; -- cgit v1.2.3 From c9015e2e04729a06cbcfd650ebfb0c1e71d96ce3 Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Fri, 9 Jan 2015 12:44:11 +0100 Subject: module var fix --- lib/web3.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/web3.js b/lib/web3.js index b240bdae2..9a85c4d1b 100644 --- a/lib/web3.js +++ b/lib/web3.js @@ -505,4 +505,5 @@ function messageHandler(data) { } } -module.exports = web3; +if (typeof(module) !== "undefined") + module.exports = web3; -- cgit v1.2.3 From 0538c11576a020a0e7fe19652398547fdad4b84b Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Fri, 9 Jan 2015 12:55:04 +0100 Subject: sha3 method signature --- lib/abi.js | 16 ++++++++++++++-- lib/contract.js | 6 ++++-- 2 files changed, 18 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/abi.js b/lib/abi.js index 5a4d64515..80cc0d551 100644 --- a/lib/abi.js +++ b/lib/abi.js @@ -140,7 +140,6 @@ var toAbiInput = function (json, methodName, params) { return; } - bytes = "0x" + padLeft(index.toString(16), 2); var method = json[index]; for (var i = 0; i < method.inputs.length; i++) { @@ -259,7 +258,20 @@ var outputParser = function (json) { return parser; }; +var methodSignature = function (json, name) { + var method = json[findMethodIndex(json, name)]; + var result = name + '('; + var inputTypes = method.inputs.map(function (inp) { + return inp.type; + }); + result += inputTypes.join(','); + result += ')'; + + return web3.sha3(result); +}; + module.exports = { inputParser: inputParser, - outputParser: outputParser + outputParser: outputParser, + methodSignature: methodSignature }; diff --git a/lib/contract.js b/lib/contract.js index b10339003..1a03849bf 100644 --- a/lib/contract.js +++ b/lib/contract.js @@ -46,8 +46,10 @@ var contract = function (address, desc) { call: function (extra) { extra = extra || {}; extra.to = address; - extra.data = parsed; - return web3.eth.call(extra).then(onSuccess); + return abi.methodSignature(desc, method.name).then(function (signature) { + extra.data = signature.slice(0, 10) + parsed; + return web3.eth.call(extra).then(onSuccess); + }); }, transact: function (extra) { extra = extra || {}; -- cgit v1.2.3