Merge commit 'b32dedc5b54f853cf63bb2663c8bca6aa4272b0b' into natspec

This commit is contained in:
Marek Kotewicz 2015-01-22 15:18:59 +01:00
commit 6c4432d417
4 changed files with 43 additions and 39 deletions

38
dist/ethereum.js vendored
View File

@ -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;
};
contract.transact = transact;
contract.call = call;
module.exports = contract;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -45,12 +45,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);
@ -61,12 +73,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;
@ -77,6 +89,10 @@ var contract = function contract (address, desc) {
output = web3.eth.call(options);
}
// reset
result._options = {};
result._isTransact = false;
return outputParser[displayName][typeName](output);
};
@ -87,23 +103,9 @@ 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;
};
contract.transact = transact;
contract.call = call;
module.exports = contract;