From f28fcc623df09cc0b0cf8838aaff54e50f069523 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 9 Oct 2018 21:35:26 +0200 Subject: [PATCH] move compilersArtefacts to app.js --- src/app.js | 7 ++++--- src/app/compiler/compiler-abstract.js | 4 ++++ src/app/debugger/debugger.js | 8 +++----- src/app/tabs/run-tab.js | 18 ++++++++++++------ 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/app.js b/src/app.js index b3a8b1926f..0cb07b0aa3 100644 --- a/src/app.js +++ b/src/app.js @@ -396,6 +396,9 @@ Please make a backup of your contracts and start using http://remix.ethereum.org var offsetToLineColumnConverter = new OffsetToLineColumnConverter(self._components.compiler.event) registry.put({api: offsetToLineColumnConverter, name: 'offsettolinecolumnconverter'}) + self._components.compilersArtefacts = {} // store all the possible compilation data (key represent a compiler name) + registry.put({api: self._components.compilersArtefacts, name: 'compilersartefacts'}) + // ----------------- UniversalDApp ----------------- var udapp = new UniversalDApp({ removable: false, @@ -412,9 +415,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org var txlistener = new Txlistener({ api: { contracts: function () { - if (self._components.compiler.lastCompilationResult && self._components.compiler.lastCompilationResult.data) { - return self._components.compiler.lastCompilationResult.data.contracts - } + if (self._components.compilersArtefacts['__last']) return self._components.compilersArtefacts['__last'].getContracts() return null }, resolveReceipt: function (tx, cb) { diff --git a/src/app/compiler/compiler-abstract.js b/src/app/compiler/compiler-abstract.js index 1ae9ee6aed..9cd28c4a59 100644 --- a/src/app/compiler/compiler-abstract.js +++ b/src/app/compiler/compiler-abstract.js @@ -19,4 +19,8 @@ module.exports = class CompilerAbstract { visitContracts (calllback) { return txHelper.visitContracts(this.data.contracts, calllback) } + + getData () { + return this.data + } } diff --git a/src/app/debugger/debugger.js b/src/app/debugger/debugger.js index 2cf969d405..9d547a5319 100644 --- a/src/app/debugger/debugger.js +++ b/src/app/debugger/debugger.js @@ -17,16 +17,14 @@ function Debugger (container, sourceHighlighter, localRegistry) { this._deps = { offsetToLineColumnConverter: this._components.registry.get('offsettolinecolumnconverter').api, editor: this._components.registry.get('editor').api, - compiler: this._components.registry.get('compiler').api + compiler: this._components.registry.get('compiler').api, + compilersArtefacts: this._components.registry.get('compilersartefacts').api } this.debugger = new Ethdebugger( { executionContext: executionContext, compilationResult: () => { - var compilationResult = this._deps.compiler.lastCompilationResult - if (compilationResult) { - return compilationResult.data - } + if (this._deps.compilersArtefacts['__last']) return this._deps.compilersArtefacts['__last'].getData() return null } }) diff --git a/src/app/tabs/run-tab.js b/src/app/tabs/run-tab.js index f979bf2d51..3effe04f37 100644 --- a/src/app/tabs/run-tab.js +++ b/src/app/tabs/run-tab.js @@ -39,7 +39,6 @@ function runTab (opts, localRegistry) { } self._components = {} self._components.registry = localRegistry || globlalRegistry - self._components.compilersArtefacts = {} self._components.transactionContextAPI = { getAddress: (cb) => { cb(null, $('#txorigin').val()) @@ -79,9 +78,9 @@ function runTab (opts, localRegistry) { editor: self._components.registry.get('editor').api, logCallback: self._components.registry.get('logCallback').api, filePanel: self._components.registry.get('filepanel').api, - pluginManager: self._components.registry.get('pluginmanager').api + pluginManager: self._components.registry.get('pluginmanager').api, + compilersArtefacts: self._components.registry.get('compilersartefacts').api } - self._components.compilersArtefacts['solidity'] = self._deps.compiler self._deps.udapp.resetAPI(self._components.transactionContextAPI) self._view.recorderCount = yo`0` self._view.instanceContainer = yo`
` @@ -312,11 +311,18 @@ function contractDropdown (events, self) { self._deps.pluginManager.event.register('sendCompilationResult', (file, source, languageVersion, data) => { // TODO check whether the tab is configured let compiler = new CompilerAbstract(languageVersion, data) - self._components.compilersArtefacts[languageVersion] = compiler + self._deps.compilersArtefacts[languageVersion] = compiler + self._deps.compilersArtefacts['__last'] = compiler newlyCompiled(true, data, source, compiler, languageVersion) }) - self._deps.compiler.event.register('compilationFinished', (success, data, source) => { newlyCompiled(success, data, source, self._deps.compiler, 'solidity') }) + self._deps.compiler.event.register('compilationFinished', (success, data, source) => { + var name = 'solidity' + let compiler = new CompilerAbstract(name, data) + self._deps.compilersArtefacts[name] = compiler + self._deps.compilersArtefacts['__last'] = compiler + newlyCompiled(success, data, source, self._deps.compiler, name) + }) var deployAction = (value) => { self._view.createPanel.style.display = value @@ -343,7 +349,7 @@ function contractDropdown (events, self) { function getSelectedContract () { var contract = selectContractNames.children[selectContractNames.selectedIndex] var contractName = contract.innerHTML - var compiler = self._components.compilersArtefacts[contract.getAttribute('compiler')] + var compiler = self._deps.compilersArtefacts[contract.getAttribute('compiler')] if (!compiler) return null if (contractName) {