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() let filePanel = new FilePanel()
registry.put({api: filePanel, name: '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( let run = new RunTab(
registry.get('udapp').api, registry.get('udapp').api,
registry.get('udappUI').api, registry.get('udappUI').api,

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

@ -21,7 +21,7 @@ import { ApiFactory } from 'remix-plugin'
class CompileTab extends ApiFactory { class CompileTab extends ApiFactory {
constructor (registry) { constructor (editor, config, renderer, swarmfileProvider, fileManager, fileProviders, pluginManager) {
super() super()
this.events = new EventEmitter() this.events = new EventEmitter()
this._view = { this._view = {
@ -34,27 +34,26 @@ class CompileTab extends ApiFactory {
this.queryParams = new QueryParams() this.queryParams = new QueryParams()
// dependencies // dependencies
this._deps = { this.editor = editor
editor: registry.get('editor').api, this.config = config
config: registry.get('config').api, this.renderer = renderer
renderer: registry.get('renderer').api, this.swarmfileProvider = swarmfileProvider
swarmfileProvider: registry.get('fileproviders/swarm').api, this.fileManager = fileManager
fileManager: registry.get('filemanager').api, this.fileProviders = fileProviders
fileProviders: registry.get('fileproviders').api, this.pluginManager = pluginManager
pluginManager: registry.get('pluginmanager').api
}
this.data = { this.data = {
contractsDetails: {} 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.compiler = this.compileTabLogic.compiler
this.compileTabLogic.init() this.compileTabLogic.init()
this.compilerContainer = new CompilerContainer( this.compilerContainer = new CompilerContainer(
this.compileTabLogic, this.compileTabLogic,
this._deps.editor, this.editor,
this._deps.config, this.config,
this.queryParams 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.compilerContainer.currentFile = name
}) })
this.compiler.event.register('compilationFinished', (success, data, source) => { this.compiler.event.register('compilationFinished', (success, data, source) => {
@ -106,7 +105,7 @@ class CompileTab extends ApiFactory {
yo.update(this._view.contractSelection, contractSelection) yo.update(this._view.contractSelection, contractSelection)
if (data['error']) { 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') { if (data['error'].mode === 'panic') {
return modalDialogCustom.alert(yo`<div><i class="fa fa-exclamation-circle ${css.panicError}" aria-hidden="true"></i> 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> 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) { if (data.errors && data.errors.length) {
data.errors.forEach((err) => { data.errors.forEach((err) => {
if (this._deps.config.get('hideWarnings')) { if (this.config.get('hideWarnings')) {
if (err.severity !== 'warning') { 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 { } 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) { 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.') 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 { } else {
publishOnSwarm(contract, this._deps.fileManager, function (err, uploaded) { publishOnSwarm(contract, this.fileManager, function (err, uploaded) {
if (err) { if (err) {
try { try {
err = JSON.stringify(err) err = JSON.stringify(err)
@ -229,7 +228,7 @@ class CompileTab extends ApiFactory {
modalDialogCustom.alert(yo`<span>Metadata published successfully.<br> <pre>${result}</pre> </span>`) 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) }, (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.errorContainer = yo`<div></div>`
this._view.contractSelection = this.contractSelection() this._view.contractSelection = this.contractSelection()
this._view.compilerContainer = this.compilerContainer.render() this._view.compilerContainer = this.compilerContainer.render()
const currentFile = this._deps.fileManager.currentFile() const currentFile = this.fileManager.currentFile()
if (currentFile) this.compilerContainer.currentFile = currentFile if (currentFile) this.compilerContainer.currentFile = currentFile
this._view.el = yo` this._view.el = yo`

Loading…
Cancel
Save