- node url update

pull/7/head
yann300 8 years ago
parent ea29683c03
commit 043050a38b
  1. 27
      src/TxBrowser.js
  2. 4
      src/helpers/init.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`<div style=${ui.formatCss(style.container)}>
<input onchange=${function () { self.updateBlockN(arguments[0]) }} type='text' placeholder=${'Block number (default 1000110)' + this.blockNumber}></input>
<input onchange=${function () { self.updateTxN(arguments[0]) }} type='text' value=${this.txNumber} placeholder=${'Transaction Number or hash (default 2) ' + this.txNumber}></input>
<span>Node URL: </span><input onkeyup=${function () { self.updateWeb3Url(arguments[0]) }} value=${this.web3.currentProvider ? this.web3.currentProvider.host : ' - none - '} type='text' />
<span>${this.connectInfo}</span>
<br />
<br />
<input onkeyup=${function () { self.updateBlockN(arguments[0]) }} type='text' placeholder=${'Block number (default 1000110)' + this.blockNumber} />
<input onkeyup=${function () { self.updateTxN(arguments[0]) }} type='text' value=${this.txNumber} placeholder=${'Transaction Number or hash (default 2) ' + this.txNumber} />
<button onclick=${function () { self.submit() }}>
Get
</button>

@ -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))
}
}

Loading…
Cancel
Save