Merge pull request #238 from ethereum/runtx

Simplify runTx
pull/1/head
chriseth 8 years ago committed by GitHub
commit ab0593386a
  1. 13
      src/universal-dapp.js

@ -566,7 +566,7 @@ UniversalDApp.prototype.getCallButton = function (args) {
};
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) {
replaceOutput($result, $('<span/>').text(err).addClass('error'));
// VM only
@ -675,7 +675,7 @@ UniversalDApp.prototype.deployLibrary = function (contractName, cb) {
else self.deployLibrary(contractName, cb);
});
} else {
self.runTx(bytecode, { abi: { constant: false }, bytecode: bytecode }, function (err, result) {
self.runTx({ data: bytecode, useCall: false }, function (err, result) {
if (err) {
return cb(err);
}
@ -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 to = args.address;
var constant = args.abi.constant;
var isConstructor = args.bytecode !== undefined;
var to = args.to;
var data = args.data;
if (data.slice(0, 2) !== '0x') {
data = '0x' + data;
}
@ -737,7 +736,7 @@ UniversalDApp.prototype.runTx = function (data, args, cb) {
data: data,
value: value
};
if (constant && !isConstructor) {
if (args.useCall) {
tx.gas = gasLimit;
self.web3.eth.call(tx, cb);
} else {

Loading…
Cancel
Save