Commit 26f6c38f authored by yann300's avatar yann300

move compilersArtefacts to app.js

parent 351b79ea
...@@ -396,6 +396,9 @@ Please make a backup of your contracts and start using http://remix.ethereum.org ...@@ -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) var offsetToLineColumnConverter = new OffsetToLineColumnConverter(self._components.compiler.event)
registry.put({api: offsetToLineColumnConverter, name: 'offsettolinecolumnconverter'}) 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 ----------------- // ----------------- UniversalDApp -----------------
var udapp = new UniversalDApp({ var udapp = new UniversalDApp({
removable: false, removable: false,
...@@ -412,9 +415,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org ...@@ -412,9 +415,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
var txlistener = new Txlistener({ var txlistener = new Txlistener({
api: { api: {
contracts: function () { contracts: function () {
if (self._components.compiler.lastCompilationResult && self._components.compiler.lastCompilationResult.data) { if (self._components.compilersArtefacts['__last']) return self._components.compilersArtefacts['__last'].getContracts()
return self._components.compiler.lastCompilationResult.data.contracts
}
return null return null
}, },
resolveReceipt: function (tx, cb) { resolveReceipt: function (tx, cb) {
......
...@@ -19,4 +19,8 @@ module.exports = class CompilerAbstract { ...@@ -19,4 +19,8 @@ module.exports = class CompilerAbstract {
visitContracts (calllback) { visitContracts (calllback) {
return txHelper.visitContracts(this.data.contracts, calllback) return txHelper.visitContracts(this.data.contracts, calllback)
} }
getData () {
return this.data
}
} }
...@@ -17,16 +17,14 @@ function Debugger (container, sourceHighlighter, localRegistry) { ...@@ -17,16 +17,14 @@ function Debugger (container, sourceHighlighter, localRegistry) {
this._deps = { this._deps = {
offsetToLineColumnConverter: this._components.registry.get('offsettolinecolumnconverter').api, offsetToLineColumnConverter: this._components.registry.get('offsettolinecolumnconverter').api,
editor: this._components.registry.get('editor').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( this.debugger = new Ethdebugger(
{ {
executionContext: executionContext, executionContext: executionContext,
compilationResult: () => { compilationResult: () => {
var compilationResult = this._deps.compiler.lastCompilationResult if (this._deps.compilersArtefacts['__last']) return this._deps.compilersArtefacts['__last'].getData()
if (compilationResult) {
return compilationResult.data
}
return null return null
} }
}) })
......
...@@ -39,7 +39,6 @@ function runTab (opts, localRegistry) { ...@@ -39,7 +39,6 @@ function runTab (opts, localRegistry) {
} }
self._components = {} self._components = {}
self._components.registry = localRegistry || globlalRegistry self._components.registry = localRegistry || globlalRegistry
self._components.compilersArtefacts = {}
self._components.transactionContextAPI = { self._components.transactionContextAPI = {
getAddress: (cb) => { getAddress: (cb) => {
cb(null, $('#txorigin').val()) cb(null, $('#txorigin').val())
...@@ -79,9 +78,9 @@ function runTab (opts, localRegistry) { ...@@ -79,9 +78,9 @@ function runTab (opts, localRegistry) {
editor: self._components.registry.get('editor').api, editor: self._components.registry.get('editor').api,
logCallback: self._components.registry.get('logCallback').api, logCallback: self._components.registry.get('logCallback').api,
filePanel: self._components.registry.get('filepanel').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._deps.udapp.resetAPI(self._components.transactionContextAPI)
self._view.recorderCount = yo`<span>0</span>` self._view.recorderCount = yo`<span>0</span>`
self._view.instanceContainer = yo`<div class="${css.instanceContainer}"></div>` self._view.instanceContainer = yo`<div class="${css.instanceContainer}"></div>`
...@@ -312,11 +311,18 @@ function contractDropdown (events, self) { ...@@ -312,11 +311,18 @@ function contractDropdown (events, self) {
self._deps.pluginManager.event.register('sendCompilationResult', (file, source, languageVersion, data) => { self._deps.pluginManager.event.register('sendCompilationResult', (file, source, languageVersion, data) => {
// TODO check whether the tab is configured // TODO check whether the tab is configured
let compiler = new CompilerAbstract(languageVersion, data) 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) 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) => { var deployAction = (value) => {
self._view.createPanel.style.display = value self._view.createPanel.style.display = value
...@@ -343,7 +349,7 @@ function contractDropdown (events, self) { ...@@ -343,7 +349,7 @@ function contractDropdown (events, self) {
function getSelectedContract () { function getSelectedContract () {
var contract = selectContractNames.children[selectContractNames.selectedIndex] var contract = selectContractNames.children[selectContractNames.selectedIndex]
var contractName = contract.innerHTML 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 (!compiler) return null
if (contractName) { if (contractName) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment