From 99b812b124e3d0d740e83a803100b3b455ffdd20 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 13 Sep 2016 11:37:12 +0100 Subject: [PATCH 1/2] Simplify runTx --- src/universal-dapp.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/universal-dapp.js b/src/universal-dapp.js index 87d6a3f79e..1ffc007c0e 100644 --- a/src/universal-dapp.js +++ b/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, isCall: args.abi.constant && !isConstructor }, function (err, result) { if (err) { replaceOutput($result, $('').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, isCall: 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.isCall) { tx.gas = gasLimit; self.web3.eth.call(tx, cb); } else { From 40c7147cb5ee4ed84f3285db1234dc97980330ec Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Thu, 15 Sep 2016 20:08:55 +0100 Subject: [PATCH 2/2] udapp: Rename isCall to useCall in runTx() --- src/universal-dapp.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/universal-dapp.js b/src/universal-dapp.js index 1ffc007c0e..8b9d59a13e 100644 --- a/src/universal-dapp.js +++ b/src/universal-dapp.js @@ -566,7 +566,7 @@ UniversalDApp.prototype.getCallButton = function (args) { }; var decoded; - self.runTx({ to: args.address, data: data, isCall: args.abi.constant && !isConstructor }, function (err, result) { + self.runTx({ to: args.address, data: data, useCall: args.abi.constant && !isConstructor }, function (err, result) { if (err) { replaceOutput($result, $('').text(err).addClass('error')); // VM only @@ -675,7 +675,7 @@ UniversalDApp.prototype.deployLibrary = function (contractName, cb) { else self.deployLibrary(contractName, cb); }); } else { - self.runTx({ data: bytecode, isCall: false }, function (err, result) { + self.runTx({ data: bytecode, useCall: false }, function (err, result) { if (err) { return cb(err); } @@ -736,7 +736,7 @@ UniversalDApp.prototype.runTx = function (args, cb) { data: data, value: value }; - if (args.isCall) { + if (args.useCall) { tx.gas = gasLimit; self.web3.eth.call(tx, cb); } else {