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 -----------------
self._components.compiler = new Compiler(self.importFileCb)
self._components.compiler = new Compiler((url, cb) => self.importFileCb(url, cb))
var compiler = self._components.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()
@ -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.switchProvider(executionContext.getProvider())
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
}
})
var txLogger = new TxLogger()
txLogger.event.register('debugRequested', (hash) => {
self.startdebugging(hash)

@ -13,6 +13,7 @@ var helper = require('../../lib/helper')
var executionContext = require('../../execution-context')
var modalDialog = require('../ui/modal-dialog-custom')
var typeConversion = remixLib.execution.typeConversion
var globlalRegistry = require('../../global/registry')
var css = csjs`
.log {
@ -123,9 +124,8 @@ var css = csjs`
*
*/
class TxLogger {
constructor (opts = {}) {
constructor (localRegistry) {
this.event = new EventManager()
this.opts = opts
this.seen = {}
function filterTx (value, query) {
if (value.length) {
@ -134,7 +134,17 @@ class TxLogger {
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 el
if (data.tx.isCall) {
@ -146,46 +156,46 @@ class TxLogger {
append(el)
}, { 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 el = renderUnknownTransaction(this, data)
append(el)
}, { 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 el = renderEmptyBlock(this, data)
append(el)
}, { activate: true })
opts.api.editorpanel.event.register('terminalFilterChanged', (type, label) => {
this._deps.editorPanel.event.register('terminalFilterChanged', (type, label) => {
if (type === 'deselect') {
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') {
opts.api.editorpanel.updateTerminalFilter({ type: 'deselect', value: 'unknownTransaction' })
this._deps.editorPanel.updateTerminalFilter({ type: 'deselect', value: 'unknownTransaction' })
}
} else if (type === 'select') {
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') {
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) {
this.logEmptyBlock({ block: block })
}
})
opts.events.txListener.register('newTransaction', (tx, receipt) => {
log(this, tx, receipt, opts.api)
this._deps.txListener.event.register('newTransaction', (tx, receipt) => {
log(this, tx, receipt)
})
opts.events.txListener.register('newCall', (tx) => {
log(this, tx, null, opts.api)
this._deps.txListener.event.register('newCall', (tx) => {
log(this, tx, null)
})
}
}
@ -199,10 +209,14 @@ function debug (e, data, self) {
}
}
function log (self, tx, receipt, api) {
var resolvedTransaction = api.resolvedTransaction(tx.hash)
function log (self, tx, receipt) {
var resolvedTransaction = self._deps.txListener.resolvedTransaction(tx.hash)
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) {
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) => {
updateFinalResult(error, result)
callback(error)
}, this._deps.app.importFileCb)
}, (url, cb) => { this._deps.app.importFileCb(url, cb) })
}
})
}

Loading…
Cancel
Save