refactor compile tab

pull/1/head
Iuri Matias 6 years ago committed by yann300
parent 3e8ccdf610
commit b3fdafee17
  1. 10
      src/app.js
  2. 3
      src/app/tabs/analysis-tab.js
  3. 41
      src/app/tabs/compile-tab.js

@ -432,7 +432,15 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
let filePanel = new FilePanel()
registry.put({api: filePanel, name: 'filepanel'})
let compileTab = new CompileTab(registry)
let compileTab = new CompileTab(
registry.get('editor').api,
registry.get('config').api,
registry.get('renderer').api,
registry.get('fileproviders/swarm').api,
registry.get('filemanager').api,
registry.get('fileproviders').api,
registry.get('pluginmanager').api
)
let run = new RunTab(
registry.get('udapp').api,
registry.get('udappUI').api,

@ -12,6 +12,7 @@ class AnalysisTab extends ApiFactory {
this.event = new EventManager()
this.registry = registry
}
get profile () {
return {
name: 'solidityStaticAnalysis',
@ -23,6 +24,7 @@ class AnalysisTab extends ApiFactory {
kind: 'analysis'
}
}
render () {
var staticanalysis = new StaticAnalysis()
this.registry.put({api: staticanalysis, name: 'staticanalysis'})
@ -31,6 +33,7 @@ class AnalysisTab extends ApiFactory {
this.el = yo`<div class="${css.analysisTabView}" id="staticanalysisView">${staticanalysis.render()}</div>`
return this.el
}
}
module.exports = AnalysisTab

@ -21,7 +21,7 @@ import { ApiFactory } from 'remix-plugin'
class CompileTab extends ApiFactory {
constructor (registry) {
constructor (editor, config, renderer, swarmfileProvider, fileManager, fileProviders, pluginManager) {
super()
this.events = new EventEmitter()
this._view = {
@ -34,27 +34,26 @@ class CompileTab extends ApiFactory {
this.queryParams = new QueryParams()
// dependencies
this._deps = {
editor: registry.get('editor').api,
config: registry.get('config').api,
renderer: registry.get('renderer').api,
swarmfileProvider: registry.get('fileproviders/swarm').api,
fileManager: registry.get('filemanager').api,
fileProviders: registry.get('fileproviders').api,
pluginManager: registry.get('pluginmanager').api
}
this.editor = editor
this.config = config
this.renderer = renderer
this.swarmfileProvider = swarmfileProvider
this.fileManager = fileManager
this.fileProviders = fileProviders
this.pluginManager = pluginManager
this.data = {
contractsDetails: {}
}
this.compileTabLogic = new CompileTabLogic(this.queryParams, this._deps.fileManager, this._deps.editor, this._deps.config, this._deps.fileProviders)
this.compileTabLogic = new CompileTabLogic(this.queryParams, this.fileManager, this.editor, this.config, this.fileProviders)
this.compiler = this.compileTabLogic.compiler
this.compileTabLogic.init()
this.compilerContainer = new CompilerContainer(
this.compileTabLogic,
this._deps.editor,
this._deps.config,
this.editor,
this.config,
this.queryParams
)
}
@ -82,7 +81,7 @@ class CompileTab extends ApiFactory {
}
})
this._deps.fileManager.events.on('currentFileChanged', (name) => {
this.fileManager.events.on('currentFileChanged', (name) => {
this.compilerContainer.currentFile = name
})
this.compiler.event.register('compilationFinished', (success, data, source) => {
@ -106,7 +105,7 @@ class CompileTab extends ApiFactory {
yo.update(this._view.contractSelection, contractSelection)
if (data['error']) {
this._deps.renderer.error(data['error'].formattedMessage, this._view.errorContainer, {type: data['error'].severity || 'error'})
this.renderer.error(data['error'].formattedMessage, this._view.errorContainer, {type: data['error'].severity || 'error'})
if (data['error'].mode === 'panic') {
return modalDialogCustom.alert(yo`<div><i class="fa fa-exclamation-circle ${css.panicError}" aria-hidden="true"></i>
The compiler returned with the following internal error: <br> <b>${data['error'].formattedMessage}.<br>
@ -117,12 +116,12 @@ class CompileTab extends ApiFactory {
}
if (data.errors && data.errors.length) {
data.errors.forEach((err) => {
if (this._deps.config.get('hideWarnings')) {
if (this.config.get('hideWarnings')) {
if (err.severity !== 'warning') {
this._deps.renderer.error(err.formattedMessage, this._view.errorContainer, {type: err.severity})
this.renderer.error(err.formattedMessage, this._view.errorContainer, {type: err.severity})
}
} else {
this._deps.renderer.error(err.formattedMessage, this._view.errorContainer, {type: err.severity})
this.renderer.error(err.formattedMessage, this._view.errorContainer, {type: err.severity})
}
})
}
@ -215,7 +214,7 @@ class CompileTab extends ApiFactory {
if (contract.metadata === undefined || contract.metadata.length === 0) {
modalDialogCustom.alert('This contract may be abstract, may not implement an abstract parent\'s methods completely or not invoke an inherited contract\'s constructor correctly.')
} else {
publishOnSwarm(contract, this._deps.fileManager, function (err, uploaded) {
publishOnSwarm(contract, this.fileManager, function (err, uploaded) {
if (err) {
try {
err = JSON.stringify(err)
@ -229,7 +228,7 @@ class CompileTab extends ApiFactory {
modalDialogCustom.alert(yo`<span>Metadata published successfully.<br> <pre>${result}</pre> </span>`)
}
}, (item) => { // triggered each time there's a new verified publish (means hash correspond)
this._deps.swarmfileProvider.addReadOnly(item.hash, item.content)
this.swarmfileProvider.addReadOnly(item.hash, item.content)
})
}
}
@ -339,7 +338,7 @@ class CompileTab extends ApiFactory {
this._view.errorContainer = yo`<div></div>`
this._view.contractSelection = this.contractSelection()
this._view.compilerContainer = this.compilerContainer.render()
const currentFile = this._deps.fileManager.currentFile()
const currentFile = this.fileManager.currentFile()
if (currentFile) this.compilerContainer.currentFile = currentFile
this._view.el = yo`

Loading…
Cancel
Save