diff --git a/src/app/txRunner.js b/src/app/txRunner.js index 7905ac8eb2..7b2aedeab3 100644 --- a/src/app/txRunner.js +++ b/src/app/txRunner.js @@ -4,7 +4,7 @@ var EthJSBlock = require('ethereumjs-block') var ethJSUtil = require('ethereumjs-util') var BN = ethJSUtil.BN -function TxRunner (executionContext, opts) { +function TxRunner (executionContext, vmaccounts, opts) { this.executionContext = executionContext this.web3 = executionContext.web3() this.vm = executionContext.vm() @@ -16,6 +16,7 @@ function TxRunner (executionContext, opts) { } this.running = false this.pendingTxs = [] + this.vmaccounts = vmaccounts } TxRunner.prototype.rawRun = function (args, cb) { @@ -83,15 +84,19 @@ TxRunner.prototype.execute = function () { } } else { try { + var account = self.vmaccounts[from] + if (!account) { + return cb('Invalid account selected') + } tx = new EthJSTX({ - nonce: new BN(from.nonce++), + nonce: new BN(account.nonce++), gasPrice: new BN(1), gasLimit: new BN(gasLimit, 10), to: to, value: new BN(value, 10), data: new Buffer(data.slice(2), 'hex') }) - tx.sign(from.privateKey) + tx.sign(account.privateKey) var block = new EthJSBlock({ header: { // FIXME: support coinbase, difficulty and gasLimit diff --git a/src/universal-dapp.js b/src/universal-dapp.js index 0c95698aab..bb9362745c 100644 --- a/src/universal-dapp.js +++ b/src/universal-dapp.js @@ -33,7 +33,7 @@ function UniversalDApp (executionContext, options, txdebugger) { self.executionContext.event.register('contextChanged', this, function (context) { self.reset(self.contracts) }) - self.txRunner = new TxRunner(executionContext, { + self.txRunner = new TxRunner(executionContext, {}, { queueTxs: true, personalMode: this.personalMode }) @@ -41,10 +41,6 @@ function UniversalDApp (executionContext, options, txdebugger) { UniversalDApp.prototype.reset = function (contracts, getAddress, getValue, getGasLimit, renderer) { this.$el.empty() - this.txRunner = new TxRunner(this.executionContext, { - queueTxs: true, - personalMode: this.personalMode - }) this.contracts = contracts this.getAddress = getAddress this.getValue = getValue @@ -58,6 +54,10 @@ UniversalDApp.prototype.reset = function (contracts, getAddress, getValue, getGa this._addAccount('d74aa6d18aa79a05f3473dd030a97d3305737cbc8337d940344345c1f6b72eea') this._addAccount('71975fbf7fe448e004ac7ae54cad0a383c3906055a65468714156a07385e96ce') } + this.txRunner = new TxRunner(this.executionContext, this.accounts, { + queueTxs: true, + personalMode: this.personalMode + }) } UniversalDApp.prototype.newAccount = function (password) { @@ -728,7 +728,7 @@ UniversalDApp.prototype.runTx = function (args, cb) { return callback(err) } - tx.from = self.executionContext.isVM() ? self.accounts[ret] : ret + tx.from = ret callback() }) @@ -746,7 +746,7 @@ UniversalDApp.prototype.runTx = function (args, cb) { return callback('Invalid account selected') } - tx.from = self.executionContext.isVM() ? self.accounts[ret[0]] : ret[0] + tx.from = ret[0] callback() })