|
|
@ -48,119 +48,6 @@ class CompileTab extends CompilerApiMixin(ViewPlugin) { |
|
|
|
this.renderComponent() |
|
|
|
this.renderComponent() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/************ |
|
|
|
|
|
|
|
* EVENTS |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
listenToEvents () { |
|
|
|
|
|
|
|
this.data.eventHandlers.onContentChanged = () => { |
|
|
|
|
|
|
|
this.emit('statusChanged', { key: 'edited', title: 'the content has changed, needs recompilation', type: 'info' }) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.editor.event.register('contentChanged', this.data.eventHandlers.onContentChanged) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.data.eventHandlers.onLoadingCompiler = () => { |
|
|
|
|
|
|
|
this.data.loading = true |
|
|
|
|
|
|
|
this.emit('statusChanged', { key: 'loading', title: 'loading compiler...', type: 'info' }) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.compiler.event.register('loadingCompiler', this.data.eventHandlers.onLoadingCompiler) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.data.eventHandlers.onCompilerLoaded = () => { |
|
|
|
|
|
|
|
this.data.loading = false |
|
|
|
|
|
|
|
this.emit('statusChanged', { key: 'none' }) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.compiler.event.register('compilerLoaded', this.data.eventHandlers.onCompilerLoaded) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.data.eventHandlers.onStartingCompilation = () => { |
|
|
|
|
|
|
|
this.emit('statusChanged', { key: 'loading', title: 'compiling...', type: 'info' }) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.data.eventHandlers.onRemoveAnnotations = () => { |
|
|
|
|
|
|
|
this.call('editor', 'clearAnnotations') |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const resetView = (isLocalhost) => { |
|
|
|
|
|
|
|
this.compileTabLogic.isHardhatProject().then((result) => { |
|
|
|
|
|
|
|
if (result && isLocalhost) this.isHardHatProject = true |
|
|
|
|
|
|
|
else this.isHardHatProject = false |
|
|
|
|
|
|
|
this.renderComponent() |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
this.resetResults() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.on('filePanel', 'setWorkspace', (workspace) => { |
|
|
|
|
|
|
|
resetView(workspace.isLocalhost) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.on('remixd', 'rootFolderChanged', () => { |
|
|
|
|
|
|
|
resetView(true) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.compileTabLogic.event.on('startingCompilation', this.data.eventHandlers.onStartingCompilation) |
|
|
|
|
|
|
|
this.compileTabLogic.event.on('removeAnnotations', this.data.eventHandlers.onRemoveAnnotations) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.data.eventHandlers.onCurrentFileChanged = (name) => { |
|
|
|
|
|
|
|
this.currentFile = name |
|
|
|
|
|
|
|
this.renderComponent() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.fileManager.events.on('currentFileChanged', this.data.eventHandlers.onCurrentFileChanged) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.data.eventHandlers.onNoFileSelected = () => { |
|
|
|
|
|
|
|
this.currentFile = '' |
|
|
|
|
|
|
|
this.renderComponent() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.fileManager.events.on('noFileSelected', this.data.eventHandlers.onNoFileSelected) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.data.eventHandlers.onCompilationFinished = (success, data, source) => { |
|
|
|
|
|
|
|
this.setCompileErrors(data) |
|
|
|
|
|
|
|
if (success) { |
|
|
|
|
|
|
|
// forwarding the event to the appManager infra
|
|
|
|
|
|
|
|
this.emit('compilationFinished', source.target, source, 'soljson', data) |
|
|
|
|
|
|
|
if (data.errors && data.errors.length > 0) { |
|
|
|
|
|
|
|
this.emit('statusChanged', { |
|
|
|
|
|
|
|
key: data.errors.length, |
|
|
|
|
|
|
|
title: `compilation finished successful with warning${data.errors.length > 1 ? 's' : ''}`, |
|
|
|
|
|
|
|
type: 'warning' |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} else this.emit('statusChanged', { key: 'succeed', title: 'compilation successful', type: 'success' }) |
|
|
|
|
|
|
|
// Store the contracts
|
|
|
|
|
|
|
|
this.contractsDetails = {} |
|
|
|
|
|
|
|
this.compiler.visitContracts((contract) => { |
|
|
|
|
|
|
|
this.contractsDetails[contract.name] = parseContracts( |
|
|
|
|
|
|
|
contract.name, |
|
|
|
|
|
|
|
contract.object, |
|
|
|
|
|
|
|
this.compiler.getSource(contract.file) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
const count = (data.errors ? data.errors.filter(error => error.severity === 'error').length : 0) + data.error ? 1 : 0 |
|
|
|
|
|
|
|
this.emit('statusChanged', { key: count, title: `compilation failed with ${count} error${count.length > 1 ? 's' : ''}`, type: 'error' }) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// Update contract Selection
|
|
|
|
|
|
|
|
this.contractMap = {} |
|
|
|
|
|
|
|
if (success) this.compiler.visitContracts((contract) => { this.contractMap[contract.name] = contract }) |
|
|
|
|
|
|
|
this.renderComponent() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.compiler.event.register('compilationFinished', this.data.eventHandlers.onCompilationFinished) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.data.eventHandlers.onThemeChanged = (theme) => { |
|
|
|
|
|
|
|
const invert = theme.quality === 'dark' ? 1 : 0 |
|
|
|
|
|
|
|
const img = document.getElementById('swarmLogo') |
|
|
|
|
|
|
|
if (img) { |
|
|
|
|
|
|
|
img.style.filter = `invert(${invert})` |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
globalRegistry.get('themeModule').api.events.on('themeChanged', this.data.eventHandlers.onThemeChanged) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Run the compiler instead of trying to save the website
|
|
|
|
|
|
|
|
$(window).keydown((e) => { |
|
|
|
|
|
|
|
// ctrl+s or command+s
|
|
|
|
|
|
|
|
if ((e.metaKey || e.ctrlKey) && e.keyCode === 83) { |
|
|
|
|
|
|
|
e.preventDefault() |
|
|
|
|
|
|
|
this.compileTabLogic.runCompiler(this.hhCompilation) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onResetResults () { |
|
|
|
onResetResults () { |
|
|
|
this.renderComponent() |
|
|
|
this.renderComponent() |
|
|
|
} |
|
|
|
} |
|
|
|