Commit 4d5ea4f4 authored by chriseth's avatar chriseth Committed by yann300

Use compilerInput before sending to worker.

parent 9f160f01
'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' ]
}
}
......
'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)
......
......@@ -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})
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment