diff options
Diffstat (limited to 'dist/ethereum.js')
-rw-r--r-- | dist/ethereum.js | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/dist/ethereum.js b/dist/ethereum.js index 3f601303f..a4c68d486 100644 --- a/dist/ethereum.js +++ b/dist/ethereum.js @@ -456,12 +456,24 @@ var abi = require('./abi'); * @returns contract object */ -var contract = function contract (address, desc) { +var contract = function (address, desc) { var inputParser = abi.inputParser(desc); var outputParser = abi.outputParser(desc); var result = {}; + result.call = function (options) { + result._isTransact = false; + result._options = options; + return result; + }; + + result.transact = function (options) { + result._isTransact = true; + result._options = options; + return result; + }; + desc.forEach(function (method) { var displayName = abi.methodDisplayName(method.name); @@ -472,12 +484,12 @@ var contract = function contract (address, desc) { var signature = abi.methodSignature(method.name); var parsed = inputParser[displayName][typeName].apply(null, params); - var options = contract._options || {}; + var options = result._options || {}; options.to = address; options.data = signature + parsed; var output = ""; - if (contract._isTransact) { + if (result._isTransact) { // it's used byt natspec.js // TODO: figure out better way to solve this web3._currentContractAbi = desc; @@ -488,6 +500,10 @@ var contract = function contract (address, desc) { output = web3.eth.call(options); } + // reset + result._options = {}; + result._isTransact = false; + return outputParser[displayName][typeName](output); }; @@ -498,24 +514,10 @@ var contract = function contract (address, desc) { result[displayName][typeName] = impl; }); - return result; -}; - -var transact = function (options) { - contract._isTransact = true; - contract._options = options; - return contract; -}; -var call = function (options) { - contract._isTransact = false; - contract._options = options; - return contract; + return result; }; -contract.transact = transact; -contract.call = call; - module.exports = contract; |