|
|
@ -25,6 +25,7 @@ export class Compiler { |
|
|
|
compileJSON: null, |
|
|
|
compileJSON: null, |
|
|
|
worker: null, |
|
|
|
worker: null, |
|
|
|
currentVersion: null, |
|
|
|
currentVersion: null, |
|
|
|
|
|
|
|
compilerLicense: null, |
|
|
|
optimize: false, |
|
|
|
optimize: false, |
|
|
|
runs: 200, |
|
|
|
runs: 200, |
|
|
|
evmVersion: null, |
|
|
|
evmVersion: null, |
|
|
@ -94,9 +95,10 @@ export class Compiler { |
|
|
|
* @param version compiler version |
|
|
|
* @param version compiler version |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
onCompilerLoaded (version: string): void { |
|
|
|
onCompilerLoaded (version: string, license: string): void { |
|
|
|
this.state.currentVersion = version |
|
|
|
this.state.currentVersion = version |
|
|
|
this.event.trigger('compilerLoaded', [version]) |
|
|
|
this.state.compilerLicense = license |
|
|
|
|
|
|
|
this.event.trigger('compilerLoaded', [version, license]) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -131,7 +133,7 @@ export class Compiler { |
|
|
|
} |
|
|
|
} |
|
|
|
this.onCompilationFinished(result, missingInputs, source, input, this.state.currentVersion) |
|
|
|
this.onCompilationFinished(result, missingInputs, source, input, this.state.currentVersion) |
|
|
|
} |
|
|
|
} |
|
|
|
this.onCompilerLoaded(compiler.version()) |
|
|
|
this.onCompilerLoaded(compiler.version(), compiler.license()) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -184,6 +186,7 @@ export class Compiler { |
|
|
|
if (err) { |
|
|
|
if (err) { |
|
|
|
console.error('Error in loading remote solc compiler: ', err) |
|
|
|
console.error('Error in loading remote solc compiler: ', err) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
let license |
|
|
|
this.state.compileJSON = (source: SourceWithTarget) => { |
|
|
|
this.state.compileJSON = (source: SourceWithTarget) => { |
|
|
|
const missingInputs: string[] = [] |
|
|
|
const missingInputs: string[] = [] |
|
|
|
const missingInputsCallback = (path: string) => { |
|
|
|
const missingInputsCallback = (path: string) => { |
|
|
@ -203,13 +206,14 @@ export class Compiler { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
result = JSON.parse(remoteCompiler.compile(input, { import: missingInputsCallback })) |
|
|
|
result = JSON.parse(remoteCompiler.compile(input, { import: missingInputsCallback })) |
|
|
|
|
|
|
|
license = remoteCompiler.license() |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (exception) { |
|
|
|
} catch (exception) { |
|
|
|
result = { error: { formattedMessage: 'Uncaught JavaScript exception:\n' + exception, severity: 'error', mode: 'panic' } } |
|
|
|
result = { error: { formattedMessage: 'Uncaught JavaScript exception:\n' + exception, severity: 'error', mode: 'panic' } } |
|
|
|
} |
|
|
|
} |
|
|
|
this.onCompilationFinished(result, missingInputs, source, input, version) |
|
|
|
this.onCompilationFinished(result, missingInputs, source, input, version) |
|
|
|
} |
|
|
|
} |
|
|
|
this.onCompilerLoaded(version) |
|
|
|
this.onCompilerLoaded(version, license) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
@ -273,7 +277,7 @@ export class Compiler { |
|
|
|
const data: MessageFromWorker = msg.data |
|
|
|
const data: MessageFromWorker = msg.data |
|
|
|
switch (data.cmd) { |
|
|
|
switch (data.cmd) { |
|
|
|
case 'versionLoaded': |
|
|
|
case 'versionLoaded': |
|
|
|
if (data.data) this.onCompilerLoaded(data.data) |
|
|
|
if (data.data && data.license) this.onCompilerLoaded(data.data, data.license) |
|
|
|
break |
|
|
|
break |
|
|
|
case 'compiled': |
|
|
|
case 'compiled': |
|
|
|
{ |
|
|
|
{ |
|
|
|