Commit ab059338 authored by chriseth's avatar chriseth Committed by GitHub

Merge pull request #238 from ethereum/runtx

Simplify runTx
parents 33c5b428 40c7147c
...@@ -566,7 +566,7 @@ UniversalDApp.prototype.getCallButton = function (args) { ...@@ -566,7 +566,7 @@ UniversalDApp.prototype.getCallButton = function (args) {
}; };
var decoded; var decoded;
self.runTx(data, args, function (err, result) { self.runTx({ to: args.address, data: data, useCall: args.abi.constant && !isConstructor }, function (err, result) {
if (err) { if (err) {
replaceOutput($result, $('<span/>').text(err).addClass('error')); replaceOutput($result, $('<span/>').text(err).addClass('error'));
// VM only // VM only
...@@ -675,7 +675,7 @@ UniversalDApp.prototype.deployLibrary = function (contractName, cb) { ...@@ -675,7 +675,7 @@ UniversalDApp.prototype.deployLibrary = function (contractName, cb) {
else self.deployLibrary(contractName, cb); else self.deployLibrary(contractName, cb);
}); });
} else { } else {
self.runTx(bytecode, { abi: { constant: false }, bytecode: bytecode }, function (err, result) { self.runTx({ data: bytecode, useCall: false }, function (err, result) {
if (err) { if (err) {
return cb(err); return cb(err);
} }
...@@ -702,11 +702,10 @@ function tryTillResponse (web3, txhash, done) { ...@@ -702,11 +702,10 @@ function tryTillResponse (web3, txhash, done) {
}); });
} }
UniversalDApp.prototype.runTx = function (data, args, cb) { UniversalDApp.prototype.runTx = function (args, cb) {
var self = this; var self = this;
var to = args.address; var to = args.to;
var constant = args.abi.constant; var data = args.data;
var isConstructor = args.bytecode !== undefined;
if (data.slice(0, 2) !== '0x') { if (data.slice(0, 2) !== '0x') {
data = '0x' + data; data = '0x' + data;
} }
...@@ -737,7 +736,7 @@ UniversalDApp.prototype.runTx = function (data, args, cb) { ...@@ -737,7 +736,7 @@ UniversalDApp.prototype.runTx = function (data, args, cb) {
data: data, data: data,
value: value value: value
}; };
if (constant && !isConstructor) { if (args.useCall) {
tx.gas = gasLimit; tx.gas = gasLimit;
self.web3.eth.call(tx, cb); self.web3.eth.call(tx, cb);
} else { } else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment