From b5c8999b5ab759c0d96a40bdbd80f801bb7f3fa3 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Wed, 4 Feb 2015 16:29:09 +0100 Subject: [PATCH] fixed natspec.js --- libjsqrc/natspec.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libjsqrc/natspec.js b/libjsqrc/natspec.js index d0bbdff17..c8cf07496 100644 --- a/libjsqrc/natspec.js +++ b/libjsqrc/natspec.js @@ -29,10 +29,20 @@ var getContractMethods = function (address, abi) { return web3.eth.contract(address, abi); }; +var getMethodWithName = function(abi, name) { + for (var i = 0; i < abi.length; i++) { + if (abi[i].name === name) { + return abi[i]; + } + } + console.warn('could not find method with name: ' + name); + return undefined; +}; + /// Function called to get all contract method input variables /// @returns hashmap with all contract's method input variables var getContractInputParams = function (abi, methodName, params) { - var method = web3.abi.getMethodWithName(abi, methodName); + var method = getMethodWithName(abi, methodName); return method.inputs.reduce(function (acc, current, index) { acc[current.name] = params[index]; return acc;