pull/3094/head
yann300 7 years ago
parent 242122739b
commit 1525cb3b55
  1. 22
      src/app.js
  2. 50
      src/app/execution/txLogger.js
  3. 2
      src/app/tabs/test-tab.js

@ -382,7 +382,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
}) })
// ----------------- Compiler ----------------- // ----------------- Compiler -----------------
self._components.compiler = new Compiler(self.importFileCb) self._components.compiler = new Compiler((url, cb) => self.importFileCb(url, cb))
var compiler = self._components.compiler var compiler = self._components.compiler
registry.put({api: compiler, name: 'compiler'}) registry.put({api: compiler, name: 'compiler'})
@ -461,7 +461,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
} }
} }
}) })
registry.put({api: eventsDecoder, name: 'eventsDecoder'}) registry.put({api: eventsDecoder, name: 'eventsdecoder'})
txlistener.startListening() txlistener.startListening()
@ -671,23 +671,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
self._view.transactionDebugger.addProvider('web3', executionContext.internalWeb3()) self._view.transactionDebugger.addProvider('web3', executionContext.internalWeb3())
self._view.transactionDebugger.switchProvider(executionContext.getProvider()) self._view.transactionDebugger.switchProvider(executionContext.getProvider())
var txLogger = new TxLogger({ var txLogger = new TxLogger()
api: {
editorpanel: self._components.editorpanel,
resolvedTransaction: function (hash) {
return txlistener.resolvedTransaction(hash)
},
parseLogs: function (tx, contractName, contracts, cb) {
eventsDecoder.parseLogs(tx, contractName, contracts, cb)
},
compiledContracts: function () {
return compiledContracts()
}
},
events: {
txListener: txlistener.event
}
})
txLogger.event.register('debugRequested', (hash) => { txLogger.event.register('debugRequested', (hash) => {
self.startdebugging(hash) self.startdebugging(hash)

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

@ -77,7 +77,7 @@ module.exports = class TestTab {
remixTests.runTestSources(runningTest, testCallback, resultsCallback, (error, result) => { remixTests.runTestSources(runningTest, testCallback, resultsCallback, (error, result) => {
updateFinalResult(error, result) updateFinalResult(error, result)
callback(error) callback(error)
}, this._deps.app.importFileCb) }, (url, cb) => { this._deps.app.importFileCb(url, cb) })
} }
}) })
} }

Loading…
Cancel
Save