|
|
@ -416,24 +416,6 @@ UniversalDApp.prototype.runTx = function( data, args, cb) { |
|
|
|
var value = self.options.getValue ? self.options.getValue : 0; |
|
|
|
var value = self.options.getValue ? self.options.getValue : 0; |
|
|
|
|
|
|
|
|
|
|
|
if (!this.vm) { |
|
|
|
if (!this.vm) { |
|
|
|
if (constant && !isConstructor) { |
|
|
|
|
|
|
|
var func = web3.eth.contract( [args.abi] ).at( to ); |
|
|
|
|
|
|
|
var prepareCallArgs = function(callArgs) { |
|
|
|
|
|
|
|
var split = function(str, arr) { |
|
|
|
|
|
|
|
if (str === "") |
|
|
|
|
|
|
|
return arr; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var chunk = str.slice(0, 64); |
|
|
|
|
|
|
|
arr.push("0x" + chunk); |
|
|
|
|
|
|
|
return split(str.slice(64), arr); |
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return split(callArgs, []); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
var argsOnly = data.slice(10); |
|
|
|
|
|
|
|
var callArgs = prepareCallArgs(argsOnly); |
|
|
|
|
|
|
|
callArgs.push(cb); |
|
|
|
|
|
|
|
func[args.abi.name].call.apply(this, callArgs); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
var tx = { |
|
|
|
var tx = { |
|
|
|
from: self.options.getAddress ? self.options.getAddress() : web3.eth.accounts[0], |
|
|
|
from: self.options.getAddress ? self.options.getAddress() : web3.eth.accounts[0], |
|
|
|
to: to, |
|
|
|
to: to, |
|
|
@ -441,11 +423,12 @@ UniversalDApp.prototype.runTx = function( data, args, cb) { |
|
|
|
gas: gas, |
|
|
|
gas: gas, |
|
|
|
value: value |
|
|
|
value: value |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
if (constant && !isConstructor) { |
|
|
|
|
|
|
|
web3.eth.call( tx, cb ); |
|
|
|
|
|
|
|
} else { |
|
|
|
web3.eth.estimateGas( tx, function(err, resp){ |
|
|
|
web3.eth.estimateGas( tx, function(err, resp){ |
|
|
|
tx.gas = resp; |
|
|
|
tx.gas = resp; |
|
|
|
if (!err) web3.eth.sendTransaction( tx, function(err, resp) { |
|
|
|
if (!err) web3.eth.sendTransaction( tx, cb ); |
|
|
|
cb( err, resp ); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
else cb( err, resp); |
|
|
|
else cb( err, resp); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|