Merge commit 'b32dedc5b54f853cf63bb2663c8bca6aa4272b0b' into natspec
This commit is contained in:
commit
6c4432d417
38
dist/ethereum.js
vendored
38
dist/ethereum.js
vendored
@ -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;
|
||||
|
||||
|
||||
|
4
dist/ethereum.js.map
vendored
4
dist/ethereum.js.map
vendored
File diff suppressed because one or more lines are too long
2
dist/ethereum.min.js
vendored
2
dist/ethereum.min.js
vendored
File diff suppressed because one or more lines are too long
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user