diff options
Diffstat (limited to 'lib/contract.js')
-rw-r--r-- | lib/contract.js | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/contract.js b/lib/contract.js index 744fc88a4..67fb407ad 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 { @@ -75,11 +79,18 @@ var contract = function (address, desc) { extra.to = address; return abi.methodSignature(desc, method.name).then(function (signature) { extra.data = signature.slice(0, 2 + ETH_METHOD_SIGNATURE_LENGTH * 2) + parsed; + web3._currentAbi = desc; return web3.eth.transact(extra).then(onSuccess); }); } }; }; + + if (contract[displayName] === undefined) { + contract[displayName] = impl; + } + + contract[displayName][typeName] = impl; }); return contract; |