diff --git a/src/app/compiler/compiler-input.js b/src/app/compiler/compiler-input.js index e76b10f379..c52c86da4f 100644 --- a/src/app/compiler/compiler-input.js +++ b/src/app/compiler/compiler-input.js @@ -1,13 +1,8 @@ 'use strict' -/* - opts: - - optimize - - { file_name: { library_name: address } } -*/ module.exports = (sources, opts) => { + var target = opts.target ? opts.target : '*' return JSON.stringify({ - target: opts.target, language: 'Solidity', sources: sources, settings: { @@ -18,7 +13,7 @@ module.exports = (sources, opts) => { }, libraries: opts.libraries, outputSelection: { - '*': { + [target]: { '*': [ 'metadata', 'evm.bytecode', 'evm.deployedBytecode', 'abi', 'legacyAST', 'metadata', 'evm.assembly', 'evm.methodIdentifiers', 'evm.gasEstimates' ] } } diff --git a/src/app/compiler/compiler-worker.js b/src/app/compiler/compiler-worker.js index 47c4cbc484..63a41ba791 100644 --- a/src/app/compiler/compiler-worker.js +++ b/src/app/compiler/compiler-worker.js @@ -1,7 +1,6 @@ 'use strict' var solc = require('solc/wrapper') -var compilerInput = require('./compiler-input') var compileJSON = function () { return '' } var missingInputs = [] @@ -21,11 +20,9 @@ module.exports = function (self) { var compiler = solc(self.Module) - compileJSON = function (input, optimize) { + compileJSON = function (input) { try { - input = JSON.parse(input) - var inputStandard = compilerInput(input.sources, {optimize: optimize, target: input.target}) - return compiler.compileStandardWrapper(inputStandard, function (path) { + return compiler.compileStandardWrapper(input, function (path) { missingInputs.push(path) return { 'error': 'Deferred import' } }) @@ -42,7 +39,7 @@ module.exports = function (self) { break case 'compile': missingInputs.length = 0 - self.postMessage({cmd: 'compiled', job: data.job, data: compileJSON(data.source, data.optimize), missingInputs: missingInputs}) + self.postMessage({cmd: 'compiled', job: data.job, data: compileJSON(data.input), missingInputs: missingInputs}) break } }, false) diff --git a/src/app/compiler/compiler.js b/src/app/compiler/compiler.js index be0d984923..0884e2453d 100644 --- a/src/app/compiler/compiler.js +++ b/src/app/compiler/compiler.js @@ -288,7 +288,7 @@ function Compiler (handleImportCall) { }) compileJSON = function (source, optimize) { jobs.push({sources: source}) - worker.postMessage({cmd: 'compile', job: jobs.length - 1, source: JSON.stringify(source), optimize: optimize}) + worker.postMessage({cmd: 'compile', job: jobs.length - 1, input: compilerInput(source.sources, {optimize: optimize, target: source.target})}) } worker.postMessage({cmd: 'loadVersion', data: url}) }