Merge pull request #785 from ethereum/fixFilter

Fix filter
pull/1/head
yann300 7 years ago committed by GitHub
commit c5a017233a
  1. 4
      src/app/execution/txListener.js
  2. 24
      src/app/execution/txLogger.js
  3. 10
      src/app/panels/editor-panel.js
  4. 29
      src/app/panels/terminal.js

@ -38,7 +38,7 @@ class TxListener {
// in VM mode
// in web3 mode && listen remix txs only
if (!this._isListening) return // we don't listen
if (this._loopId) return // we seems to already listen on the network
if (this._loopId && executionContext.getProvider() !== 'vm') return // we seems to already listen on a "web3" network
executionContext.web3().eth.getTransaction(txResult.transactionHash, (error, tx) => {
if (error) return console.log(error)
if (txResult && txResult.result && txResult.result.vm) tx.returnValue = txResult.result.vm.return
@ -81,7 +81,7 @@ class TxListener {
startListening () {
this.init()
this._isListening = true
if (this._listenOnNetwork) {
if (this._listenOnNetwork && executionContext.getProvider() !== 'vm') {
this._startListenOnNetwork()
}
}

@ -76,16 +76,34 @@ class TxLogger {
var data = args[0]
var el = renderKnownTransaction(this, data)
append(el)
})
}, { activate: true })
this.logUnknownTX = opts.api.editorpanel.registerCommand('unknownTransaction', (args, cmds, append) => {
var data = args[0]
var el = renderUnknownTransaction(this, data)
append(el)
})
}, { activate: false })
this.logEmptyBlock = opts.api.editorpanel.registerCommand('emptyBlock', (args, cmds, append) => {
var data = args[0]
var el = renderEmptyBlock(this, data)
append(el)
}, { activate: true })
opts.api.editorpanel.event.register('terminalFilterChanged', (type, label) => {
if (type === 'deselect') {
if (label === 'only remix transactions') {
opts.api.editorpanel.updateTerminalFilter({ type: 'select', value: 'unknownTransaction' })
} else if (label === 'all transactions') {
opts.api.editorpanel.updateTerminalFilter({ type: 'deselect', value: 'unknownTransaction' })
}
} else if (type === 'select') {
if (label === 'only remix transactions') {
opts.api.editorpanel.updateTerminalFilter({ type: 'deselect', value: 'unknownTransaction' })
} else if (label === 'all transactions') {
opts.api.editorpanel.updateTerminalFilter({ type: 'select', value: 'unknownTransaction' })
}
}
})
opts.events.txListener.register('newBlock', (block) => {
@ -196,7 +214,7 @@ function renderUnknownTransaction (self, data) {
}
function renderEmptyBlock (self, data) {
return yo`<span>block ${data.block.number} - O transactions</span>`
return yo`<span><span class='${css.tx}'>[block:${data.block.number} - 0 transactions]</span></span>`
}
function context (self, opts) {

@ -167,6 +167,9 @@ class EditorPanel {
</div>`
})
}
self._components.terminal.event.register('filterChanged', (type, value) => {
this.event.trigger('terminalFilterChanged', [type, value])
})
self._components.terminal.event.register('resize', delta => self._adjustLayout('top', delta))
if (self._api.txListener) {
self._components.terminal.event.register('listenOnNetWork', (listenOnNetWork) => {
@ -232,9 +235,12 @@ class EditorPanel {
self._adjustLayout('top', self.data._layout.top.offset)
return self._view.el
}
registerCommand (name, command) {
registerCommand (name, command, opts) {
var self = this
return self._components.terminal.registerCommand(name, command)
return self._components.terminal.registerCommand(name, command, opts)
}
updateTerminalFilter (filter) {
this._components.terminal.updateJournal(filter)
}
_renderTabsbar () {
var self = this

@ -143,20 +143,14 @@ class Terminal {
dependencies: {'all transactions': ['only remix transactions'], 'only remix transactions': ['all transactions']}
})
self._components.dropdown.event.register('deselect', function (label) {
if (label === 'only remix transactions') {
self.updateJournal({ type: 'select', value: 'unknownTransaction' })
} else if (label === 'all transactions') {
self.updateJournal({ type: 'deselect', value: 'unknownTransaction' })
} else { // script
self.event.trigger('filterChanged', ['deselect', label])
if (label === 'script') {
self.updateJournal({ type: 'deselect', value: label })
}
})
self._components.dropdown.event.register('select', function (label) {
if (label === 'only remix transactions') {
self.updateJournal({ type: 'deselect', value: 'unknownTransaction' })
} else if (label === 'all transactions') {
self.updateJournal({ type: 'select', value: 'unknownTransaction' })
} else { // script
self.event.trigger('filterChanged', ['select', label])
if (label === 'script') {
self.updateJournal({ type: 'select', value: label })
}
})
@ -171,10 +165,10 @@ class Terminal {
self._INDEX.commandsMain = {}
self.registerCommand('banner', function (args, scopedCommands, append) {
append(args[0])
})
self.registerCommand('log', self._blocksRenderer('log'))
self.registerCommand('info', self._blocksRenderer('info'))
self.registerCommand('error', self._blocksRenderer('error'))
}, { activate: true })
self.registerCommand('log', self._blocksRenderer('log'), { activate: true })
self.registerCommand('info', self._blocksRenderer('info'), { activate: true })
self.registerCommand('error', self._blocksRenderer('error'), { activate: true })
self.registerCommand('script', function execute (args, scopedCommands, append) {
var script = String(args[0])
scopedCommands.log(`> ${script}`)
@ -182,12 +176,11 @@ class Terminal {
if (error) scopedCommands.error(error)
else scopedCommands.log(output)
})
})
}, { activate: true })
self._jsSandboxContext = {}
self._jsSandbox = vm.createContext(self._jsSandboxContext)
if (opts.shell) self._shell = opts.shell
register(self)
self.updateJournal({ type: 'select', value: 'knownTransaction' })
}
render () {
var self = this
@ -545,7 +538,7 @@ class Terminal {
})
return scopedCommands
}
registerCommand (name, command) {
registerCommand (name, command, opts) {
var self = this
name = String(name)
if (self._commands[name]) throw new Error(`command "${name}" exists already`)
@ -584,6 +577,7 @@ class Terminal {
].join('\n')
self.commands[name].toString = _ => { return help }
self.commands[name].help = help
self.data.activeFilters.commands[name] = opts && opts.activate
return self.commands[name]
}
_shell (script, scopedCommands, done) { // default shell
@ -616,6 +610,7 @@ function findDeep (object, fn, found = { break: false, value: undefined }) {
for (var i in object) {
if (found.break) break
var el = object[i]
if (el && el.innerText !== undefined && el.innerText !== null) el = el.innerText
if (!fn(el, i, object)) findDeep(el, fn, found)
else if (found.break = true) return found.value = el // eslint-disable-line
}

Loading…
Cancel
Save