From 3974f9aa3e49ef9f0fe750d46dfdf4f6376dcd3f Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Thu, 27 Oct 2016 01:30:49 +0100 Subject: [PATCH] Use getAccounts in runTx --- src/universal-dapp.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/universal-dapp.js b/src/universal-dapp.js index b9241c7c88..963b040d71 100644 --- a/src/universal-dapp.js +++ b/src/universal-dapp.js @@ -723,12 +723,21 @@ UniversalDApp.prototype.runTx = function (args, cb) { // NOTE: getAddress should be async if (self.getAddress) { tx.from = self.getAddress() - } else if (self.executionContext.isVM()) { - tx.from = Object.keys(self.accounts)[0] + callback() } else { - tx.from = self.web3.eth.accounts[0] + self.getAccounts(function (err, ret) { + if (err) { + return callback(err) + } + + if (ret.length === 0) { + return callback('No accounts available') + } + + tx.from = ret[0] + callback() + }) } - callback() }, // run transaction function (callback) {