aboutsummaryrefslogtreecommitdiffstats
path: root/lib/contract.js
diff options
context:
space:
mode:
authorMarek Kotewicz <marek.kotewicz@gmail.com>2015-01-22 04:54:51 +0800
committerMarek Kotewicz <marek.kotewicz@gmail.com>2015-01-22 04:54:51 +0800
commitad8e92e9c67b82b0e8156345776bafe1c3e07d51 (patch)
tree9eb59d09860f1600f4048d26580f43576cb45f1e /lib/contract.js
parent81ff253e68bbc700ff093adcff0a21469460b4b8 (diff)
parentedfb874527160cee14cca931377e55187b874cbe (diff)
downloadgo-tangerine-ad8e92e9c67b82b0e8156345776bafe1c3e07d51.tar
go-tangerine-ad8e92e9c67b82b0e8156345776bafe1c3e07d51.tar.gz
go-tangerine-ad8e92e9c67b82b0e8156345776bafe1c3e07d51.tar.bz2
go-tangerine-ad8e92e9c67b82b0e8156345776bafe1c3e07d51.tar.lz
go-tangerine-ad8e92e9c67b82b0e8156345776bafe1c3e07d51.tar.xz
go-tangerine-ad8e92e9c67b82b0e8156345776bafe1c3e07d51.tar.zst
go-tangerine-ad8e92e9c67b82b0e8156345776bafe1c3e07d51.zip
Merge commit 'eb4984c0d036c1420e782ca136810e851e33fb37' into natspec
Diffstat (limited to 'lib/contract.js')
-rw-r--r--lib/contract.js31
1 files changed, 14 insertions, 17 deletions
diff --git a/lib/contract.js b/lib/contract.js
index abd8e5bdf..aa4188d40 100644
--- a/lib/contract.js
+++ b/lib/contract.js
@@ -23,9 +23,6 @@
var web3 = require('./web3'); // jshint ignore:line
var abi = require('./abi');
-/// method signature length in bytes
-var ETH_METHOD_SIGNATURE_LENGTH = 4;
-
/**
* This method should be called when we want to call / transact some solidity method from javascript
* it returns an object which has same methods available as solidity contract description
@@ -60,29 +57,29 @@ var contract = function (address, desc) {
var impl = function () {
var params = Array.prototype.slice.call(arguments);
var parsed = inputParser[displayName][typeName].apply(null, params);
-
- var onSuccess = function (result) {
- return outputParser[displayName][typeName](result);
- };
+ var signature = abi.methodSignature(method.name);
return {
call: function (extra) {
extra = extra || {};
extra.to = address;
- return abi.methodSignature(desc, method.name).then(function (signature) {
- extra.data = signature.slice(0, 2 + ETH_METHOD_SIGNATURE_LENGTH * 2) + parsed;
- return web3.eth.call(extra).then(onSuccess);
- });
+ extra.data = signature + parsed;
+
+ var result = web3.eth.call(extra);
+ return outputParser[displayName][typeName](result);
},
transact: function (extra) {
extra = extra || {};
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._currentContractAbi = desc;
- web3._currentContractAddress = address;
- return web3.eth.transact(extra).then(onSuccess);
- });
+ extra.data = signature + parsed;
+
+ /// it's used by natspec.js
+ /// TODO: figure a better way to solve this
+ web3._currentContractAbi = desc;
+ web3._currentContractAddress = address;
+
+ var result = web3.eth.transact(extra);
+ return outputParser[displayName][typeName](result);
}
};
};