Commit 7ff0654b authored by Alex Beregszaszi's avatar Alex Beregszaszi

Split out UI settings from runTx

parent 0e37be07
...@@ -679,11 +679,6 @@ function tryTillResponse (web3, txhash, done) { ...@@ -679,11 +679,6 @@ function tryTillResponse (web3, txhash, done) {
UniversalDApp.prototype.runTx = function (args, cb) { UniversalDApp.prototype.runTx = function (args, cb) {
var self = this var self = this
var to = args.to
var data = args.data
if (data.slice(0, 2) !== '0x') {
data = '0x' + data
}
var gasLimit = 3000000 var gasLimit = 3000000
if (self.getGasLimit) { if (self.getGasLimit) {
...@@ -703,10 +698,39 @@ UniversalDApp.prototype.runTx = function (args, cb) { ...@@ -703,10 +698,39 @@ UniversalDApp.prototype.runTx = function (args, cb) {
} }
} }
var from
if (self.getAddress) {
from = self.getAddress()
} else if (self.executionContext.isVM()) {
from = Object.keys(self.accounts)[0]
} else {
from = self.web3.eth.accounts[0]
}
return this.rawRunTx({
from: args.from,
to: args.to,
data: args.data,
value: value,
gasLimit: gasLimit
}, cb)
}
UniversalDApp.prototype.rawRunTx = function (args, cb) {
var self = this
var from = args.from
var to = args.to
var data = args.data
if (data.slice(0, 2) !== '0x') {
data = '0x' + data
}
var value = args.value
var gasLimit = args.gasLimit
var tx var tx
if (!self.executionContext.isVM()) { if (!self.executionContext.isVM()) {
tx = { tx = {
from: self.getAddress ? self.getAddress() : self.web3.eth.accounts[0], from: from,
to: to, to: to,
data: data, data: data,
value: value value: value
...@@ -739,8 +763,7 @@ UniversalDApp.prototype.runTx = function (args, cb) { ...@@ -739,8 +763,7 @@ UniversalDApp.prototype.runTx = function (args, cb) {
} }
} else { } else {
try { try {
var address = self.getAddress ? self.getAddress() : Object.keys(self.accounts)[0] var account = self.accounts[from]
var account = self.accounts[address]
if (!account) { if (!account) {
return cb('Invalid account selected') return cb('Invalid account selected')
} }
......
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