|
|
@ -13,6 +13,7 @@ var helper = require('../../lib/helper') |
|
|
|
var executionContext = require('../../execution-context') |
|
|
|
var executionContext = require('../../execution-context') |
|
|
|
var modalDialog = require('../ui/modal-dialog-custom') |
|
|
|
var modalDialog = require('../ui/modal-dialog-custom') |
|
|
|
var typeConversion = remixLib.execution.typeConversion |
|
|
|
var typeConversion = remixLib.execution.typeConversion |
|
|
|
|
|
|
|
var globlalRegistry = require('../../global/registry') |
|
|
|
|
|
|
|
|
|
|
|
var css = csjs` |
|
|
|
var css = csjs` |
|
|
|
.log { |
|
|
|
.log { |
|
|
@ -123,9 +124,8 @@ var css = csjs` |
|
|
|
* |
|
|
|
* |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
class TxLogger { |
|
|
|
class TxLogger { |
|
|
|
constructor (opts = {}) { |
|
|
|
constructor (localRegistry) { |
|
|
|
this.event = new EventManager() |
|
|
|
this.event = new EventManager() |
|
|
|
this.opts = opts |
|
|
|
|
|
|
|
this.seen = {} |
|
|
|
this.seen = {} |
|
|
|
function filterTx (value, query) { |
|
|
|
function filterTx (value, query) { |
|
|
|
if (value.length) { |
|
|
|
if (value.length) { |
|
|
@ -134,7 +134,17 @@ class TxLogger { |
|
|
|
return false |
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.logKnownTX = opts.api.editorpanel.registerCommand('knownTransaction', (args, cmds, append) => { |
|
|
|
this._components = {} |
|
|
|
|
|
|
|
this._components.registry = localRegistry || globlalRegistry |
|
|
|
|
|
|
|
// dependencies
|
|
|
|
|
|
|
|
this._deps = { |
|
|
|
|
|
|
|
editorPanel: this._components.registry.get('editorpanel').api, |
|
|
|
|
|
|
|
txListener: this._components.registry.get('txlistener').api, |
|
|
|
|
|
|
|
eventsDecoder: this._components.registry.get('eventsdecoder').api, |
|
|
|
|
|
|
|
compiler: this._components.registry.get('compiler').api |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.logKnownTX = this._deps.editorPanel.registerCommand('knownTransaction', (args, cmds, append) => { |
|
|
|
var data = args[0] |
|
|
|
var data = args[0] |
|
|
|
var el |
|
|
|
var el |
|
|
|
if (data.tx.isCall) { |
|
|
|
if (data.tx.isCall) { |
|
|
@ -146,46 +156,46 @@ class TxLogger { |
|
|
|
append(el) |
|
|
|
append(el) |
|
|
|
}, { activate: true, filterFn: filterTx }) |
|
|
|
}, { activate: true, filterFn: filterTx }) |
|
|
|
|
|
|
|
|
|
|
|
this.logUnknownTX = opts.api.editorpanel.registerCommand('unknownTransaction', (args, cmds, append) => { |
|
|
|
this.logUnknownTX = this._deps.editorPanel.registerCommand('unknownTransaction', (args, cmds, append) => { |
|
|
|
var data = args[0] |
|
|
|
var data = args[0] |
|
|
|
var el = renderUnknownTransaction(this, data) |
|
|
|
var el = renderUnknownTransaction(this, data) |
|
|
|
append(el) |
|
|
|
append(el) |
|
|
|
}, { activate: false, filterFn: filterTx }) |
|
|
|
}, { activate: false, filterFn: filterTx }) |
|
|
|
|
|
|
|
|
|
|
|
this.logEmptyBlock = opts.api.editorpanel.registerCommand('emptyBlock', (args, cmds, append) => { |
|
|
|
this.logEmptyBlock = this._deps.editorPanel.registerCommand('emptyBlock', (args, cmds, append) => { |
|
|
|
var data = args[0] |
|
|
|
var data = args[0] |
|
|
|
var el = renderEmptyBlock(this, data) |
|
|
|
var el = renderEmptyBlock(this, data) |
|
|
|
append(el) |
|
|
|
append(el) |
|
|
|
}, { activate: true }) |
|
|
|
}, { activate: true }) |
|
|
|
|
|
|
|
|
|
|
|
opts.api.editorpanel.event.register('terminalFilterChanged', (type, label) => { |
|
|
|
this._deps.editorPanel.event.register('terminalFilterChanged', (type, label) => { |
|
|
|
if (type === 'deselect') { |
|
|
|
if (type === 'deselect') { |
|
|
|
if (label === 'only remix transactions') { |
|
|
|
if (label === 'only remix transactions') { |
|
|
|
opts.api.editorpanel.updateTerminalFilter({ type: 'select', value: 'unknownTransaction' }) |
|
|
|
this._deps.editorPanel.updateTerminalFilter({ type: 'select', value: 'unknownTransaction' }) |
|
|
|
} else if (label === 'all transactions') { |
|
|
|
} else if (label === 'all transactions') { |
|
|
|
opts.api.editorpanel.updateTerminalFilter({ type: 'deselect', value: 'unknownTransaction' }) |
|
|
|
this._deps.editorPanel.updateTerminalFilter({ type: 'deselect', value: 'unknownTransaction' }) |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (type === 'select') { |
|
|
|
} else if (type === 'select') { |
|
|
|
if (label === 'only remix transactions') { |
|
|
|
if (label === 'only remix transactions') { |
|
|
|
opts.api.editorpanel.updateTerminalFilter({ type: 'deselect', value: 'unknownTransaction' }) |
|
|
|
this._deps.editorPanel.updateTerminalFilter({ type: 'deselect', value: 'unknownTransaction' }) |
|
|
|
} else if (label === 'all transactions') { |
|
|
|
} else if (label === 'all transactions') { |
|
|
|
opts.api.editorpanel.updateTerminalFilter({ type: 'select', value: 'unknownTransaction' }) |
|
|
|
this._deps.editorPanel.updateTerminalFilter({ type: 'select', value: 'unknownTransaction' }) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
opts.events.txListener.register('newBlock', (block) => { |
|
|
|
this._deps.txListener.event.register('newBlock', (block) => { |
|
|
|
if (!block.transactions.length) { |
|
|
|
if (!block.transactions.length) { |
|
|
|
this.logEmptyBlock({ block: block }) |
|
|
|
this.logEmptyBlock({ block: block }) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
opts.events.txListener.register('newTransaction', (tx, receipt) => { |
|
|
|
this._deps.txListener.event.register('newTransaction', (tx, receipt) => { |
|
|
|
log(this, tx, receipt, opts.api) |
|
|
|
log(this, tx, receipt) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
opts.events.txListener.register('newCall', (tx) => { |
|
|
|
this._deps.txListener.event.register('newCall', (tx) => { |
|
|
|
log(this, tx, null, opts.api) |
|
|
|
log(this, tx, null) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -199,10 +209,14 @@ function debug (e, data, self) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function log (self, tx, receipt, api) { |
|
|
|
function log (self, tx, receipt) { |
|
|
|
var resolvedTransaction = api.resolvedTransaction(tx.hash) |
|
|
|
var resolvedTransaction = self._deps.txListener.resolvedTransaction(tx.hash) |
|
|
|
if (resolvedTransaction) { |
|
|
|
if (resolvedTransaction) { |
|
|
|
api.parseLogs(tx, resolvedTransaction.contractName, api.compiledContracts(), (error, logs) => { |
|
|
|
var compiledContracts = null |
|
|
|
|
|
|
|
if (self._deps.compiler.lastCompilationResult && self._deps.compiler.lastCompilationResult.data) { |
|
|
|
|
|
|
|
compiledContracts = self._deps.compiler.lastCompilationResult.data.contracts |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
self._deps.eventsDecoder.parseLogs(tx, resolvedTransaction.contractName, compiledContracts, (error, logs) => { |
|
|
|
if (!error) { |
|
|
|
if (!error) { |
|
|
|
self.logKnownTX({ tx: tx, receipt: receipt, resolvedData: resolvedTransaction, logs: logs }) |
|
|
|
self.logKnownTX({ tx: tx, receipt: receipt, resolvedData: resolvedTransaction, logs: logs }) |
|
|
|
} |
|
|
|
} |
|
|
|