From 380c1522ac450fdafe9bfb8e2d2f60fdfe918745 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Tue, 20 Jan 2015 15:06:05 +0100 Subject: solidity methods "overloading" --- lib/contract.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'lib/contract.js') diff --git a/lib/contract.js b/lib/contract.js index 744fc88a4..2e8ef8ce4 100644 --- a/lib/contract.js +++ b/lib/contract.js @@ -53,12 +53,16 @@ var contract = function (address, desc) { var contract = {}; desc.forEach(function (method) { - contract[method.name] = function () { + + var displayName = abi.methodDisplayName(method.name); + var typeName = abi.methodTypeName(method.name); + + var impl = function () { var params = Array.prototype.slice.call(arguments); - var parsed = inputParser[method.name].apply(null, params); + var parsed = inputParser[displayName][typeName].apply(null, params); var onSuccess = function (result) { - return outputParser[method.name](result); + return outputParser[displayName][typeName](result); }; return { @@ -80,6 +84,12 @@ var contract = function (address, desc) { } }; }; + + if (contract[displayName] === undefined) { + contract[displayName] = impl; + } + + contract[displayName][typeName] = impl; }); return contract; -- cgit v1.2.3