fix compileWithParameters

pull/5370/head
yann300 3 years ago committed by davidzagi93@gmail.com
parent f8e3c7a473
commit 1a38fd9160
  1. 4
      apps/remix-ide/src/app/tabs/compile-tab.js
  2. 17
      apps/solidity-compiler/src/app/compiler-api.ts
  3. 3
      libs/remix-solidity/src/compiler/compiler-utils.ts

@ -56,10 +56,6 @@ class CompileTab extends CompilerApiMixin(ViewPlugin) { // implements ICompilerA
this.renderComponent()
}
setSelectedVersion (version) {
this.selectedVersion = version
}
onSetWorkspace () {
this.renderComponent()
}

@ -41,7 +41,6 @@ export const CompilerApiMixin = (Base) => class extends Base {
this.compileErrors = {}
this.compiledFileName = ''
this.selectedVersion = ''
this.currentFile = ''
}
@ -63,10 +62,6 @@ export const CompilerApiMixin = (Base) => class extends Base {
return this.call('terminal', 'log', content)
}
setSelectedVersion (version) {
this.selectedVersion = version
}
getCompilationResult () {
return this.compileTabLogic.compiler.state.lastCompilationResult
}
@ -99,18 +94,20 @@ export const CompilerApiMixin = (Base) => class extends Base {
* @param {object} settings {evmVersion, optimize, runs, version, language}
*/
async compileWithParameters (compilationTargets, settings) {
settings.version = settings.version || this.selectedVersion
const compilerState = this.getCompilerState()
settings.version = settings.version || compilerState.currentVersion
const res = await compile(compilationTargets, settings, (url, cb) => this.call('contentImport', 'resolveAndSave', url).then((result) => cb(null, result)).catch((error) => cb(error.message)))
return res
}
// This function is used for passing the compiler configuration to 'remix-tests'
getCurrentCompilerConfig () {
const compilerState = this.getCompilerState()
return {
currentVersion: this.selectedVersion,
evmVersion: this.compileTabLogic.evmVersion,
optimize: this.compileTabLogic.optimize,
runs: this.compileTabLogic.runs
currentVersion: compilerState.currentVersion,
evmVersion: compilerState.evmVersion,
optimize: compilerState.optimize,
runs: compilerState.runs
}
}

@ -12,7 +12,7 @@ export const pathToURL = {}
* @param version is the version of compiler with or without 'soljson-v' prefix and .js postfix
*/
export function urlFromVersion (version) {
let url
let url
if (version === 'builtin') {
let location: string | Location = window.document.location
let path = location.pathname
@ -22,6 +22,7 @@ export function urlFromVersion (version) {
if (!location.endsWith('/')) location += '/'
url = `${location}soljson.js`
} else {
version = version.replace('.Emscripten.clang', '')
if (!version.startsWith('soljson-v')) version = 'soljson-v' + version
if (!version.endsWith('.js')) version = version + '.js'
url = `${pathToURL[version]}/${version}`

Loading…
Cancel
Save