From ebb7f577fb0191caa5350c1b5142c65dd2d4a05d Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 11 Sep 2017 13:09:29 +0200 Subject: [PATCH 1/4] fix filter --- src/app/panels/terminal.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app/panels/terminal.js b/src/app/panels/terminal.js index 7e6123a951..ab9cfdf10a 100644 --- a/src/app/panels/terminal.js +++ b/src/app/panels/terminal.js @@ -616,6 +616,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 } From f609aec381e1e36827d741e3d49825d5b1425cbf Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 11 Sep 2017 13:23:16 +0200 Subject: [PATCH 2/4] always log emptyblock --- src/app/execution/txLogger.js | 2 +- src/app/panels/editor-panel.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/execution/txLogger.js b/src/app/execution/txLogger.js index 14c2ee2964..1c9342ce3f 100644 --- a/src/app/execution/txLogger.js +++ b/src/app/execution/txLogger.js @@ -196,7 +196,7 @@ function renderUnknownTransaction (self, data) { } function renderEmptyBlock (self, data) { - return yo`block ${data.block.number} - O transactions` + return yo`[block:${data.block.number} - 0 transactions]` } function context (self, opts) { diff --git a/src/app/panels/editor-panel.js b/src/app/panels/editor-panel.js index 43a9edfbe8..54cd96d036 100644 --- a/src/app/panels/editor-panel.js +++ b/src/app/panels/editor-panel.js @@ -167,6 +167,7 @@ class EditorPanel { ` }) } + self._components.terminal.updateJournal({ type: 'select', value: 'emptyBlock' }) self._components.terminal.event.register('resize', delta => self._adjustLayout('top', delta)) if (self._api.txListener) { self._components.terminal.event.register('listenOnNetWork', (listenOnNetWork) => { From 404019644432c78a19c1a71f09ce9e24c3d0f424 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 11 Sep 2017 14:30:00 +0200 Subject: [PATCH 3/4] listen on network only if web3 mode --- src/app/execution/txListener.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/execution/txListener.js b/src/app/execution/txListener.js index 4d6ee736a5..5d6bd19897 100644 --- a/src/app/execution/txListener.js +++ b/src/app/execution/txListener.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() } } From 7bf13dd526832b68427804caa02dc8453658f4db Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 11 Sep 2017 14:31:46 +0200 Subject: [PATCH 4/4] refactor: move filter selection from terminal to txLogger --- src/app/execution/txLogger.js | 22 ++++++++++++++++++++-- src/app/panels/editor-panel.js | 11 ++++++++--- src/app/panels/terminal.js | 28 +++++++++++----------------- 3 files changed, 39 insertions(+), 22 deletions(-) diff --git a/src/app/execution/txLogger.js b/src/app/execution/txLogger.js index 1c9342ce3f..c9f668f6a6 100644 --- a/src/app/execution/txLogger.js +++ b/src/app/execution/txLogger.js @@ -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) => { diff --git a/src/app/panels/editor-panel.js b/src/app/panels/editor-panel.js index 54cd96d036..9cd9b6d9c4 100644 --- a/src/app/panels/editor-panel.js +++ b/src/app/panels/editor-panel.js @@ -167,7 +167,9 @@ class EditorPanel { ` }) } - self._components.terminal.updateJournal({ type: 'select', value: 'emptyBlock' }) + 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) => { @@ -233,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 diff --git a/src/app/panels/terminal.js b/src/app/panels/terminal.js index ab9cfdf10a..c5215a0362 100644 --- a/src/app/panels/terminal.js +++ b/src/app/panels/terminal.js @@ -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