diff --git a/src/TxBrowser.js b/src/TxBrowser.js index adc1b1fd66..3e1e8b7e6b 100644 --- a/src/TxBrowser.js +++ b/src/TxBrowser.js @@ -4,6 +4,7 @@ var EventManager = require('./lib/eventManager') var traceHelper = require('./helpers/traceHelper') var yo = require('yo-yo') var ui = require('./helpers/ui') +var init = require('./helpers/init') function TxBrowser (_web3) { util.extend(this, new EventManager()) @@ -31,6 +32,8 @@ TxBrowser.prototype.setDefaultValues = function () { this.hash = ' - ' this.blockNumber = null this.txNumber = '0xcda2b2835add61af54cf83bd076664d98d7908c6cd98d86423b3b48d8b8e51ff' + this.connectInfo = '' + this.checkWeb3() } TxBrowser.prototype.submit = function () { @@ -66,6 +69,22 @@ TxBrowser.prototype.submit = function () { yo.update(this.view, this.render()) } +TxBrowser.prototype.updateWeb3Url = function (ev) { + init.setProvider(this.web3, ev.target.value) + this.checkWeb3() + yo.update(this.view, this.render()) +} + +TxBrowser.prototype.checkWeb3 = function () { + try { + console.log('block ' + this.web3.eth.blockNumber) + this.connectInfo = 'Connected to ' + this.web3.currentProvider.host + } catch (e) { + console.log(e) + this.connectInfo = e.message + } +} + TxBrowser.prototype.updateBlockN = function (ev) { this.blockNumber = ev.target.value } @@ -82,8 +101,12 @@ TxBrowser.prototype.init = function (ev) { TxBrowser.prototype.render = function () { var self = this var view = yo`
- - + Node URL: + ${this.connectInfo} +
+
+ + diff --git a/src/helpers/init.js b/src/helpers/init.js index 7fd4196646..bc1712165b 100644 --- a/src/helpers/init.js +++ b/src/helpers/init.js @@ -8,5 +8,9 @@ module.exports = { web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545')) Web3Admin.extend(web3) return web3 + }, + + setProvider: function (web3, url) { + web3.setProvider(new web3.providers.HttpProvider(url)) } }