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

Use compilerInput before sending to worker.

parent 9f160f01
'use strict' 'use strict'
/*
opts:
- optimize
- { file_name: { library_name: address } }
*/
module.exports = (sources, opts) => { module.exports = (sources, opts) => {
var target = opts.target ? opts.target : '*'
return JSON.stringify({ return JSON.stringify({
target: opts.target,
language: 'Solidity', language: 'Solidity',
sources: sources, sources: sources,
settings: { settings: {
...@@ -18,7 +13,7 @@ module.exports = (sources, opts) => { ...@@ -18,7 +13,7 @@ module.exports = (sources, opts) => {
}, },
libraries: opts.libraries, libraries: opts.libraries,
outputSelection: { outputSelection: {
'*': { [target]: {
'*': [ 'metadata', 'evm.bytecode', 'evm.deployedBytecode', 'abi', 'legacyAST', 'metadata', 'evm.assembly', 'evm.methodIdentifiers', 'evm.gasEstimates' ] '*': [ 'metadata', 'evm.bytecode', 'evm.deployedBytecode', 'abi', 'legacyAST', 'metadata', 'evm.assembly', 'evm.methodIdentifiers', 'evm.gasEstimates' ]
} }
} }
......
'use strict' 'use strict'
var solc = require('solc/wrapper') var solc = require('solc/wrapper')
var compilerInput = require('./compiler-input')
var compileJSON = function () { return '' } var compileJSON = function () { return '' }
var missingInputs = [] var missingInputs = []
...@@ -21,11 +20,9 @@ module.exports = function (self) { ...@@ -21,11 +20,9 @@ module.exports = function (self) {
var compiler = solc(self.Module) var compiler = solc(self.Module)
compileJSON = function (input, optimize) { compileJSON = function (input) {
try { try {
input = JSON.parse(input) return compiler.compileStandardWrapper(input, function (path) {
var inputStandard = compilerInput(input.sources, {optimize: optimize, target: input.target})
return compiler.compileStandardWrapper(inputStandard, function (path) {
missingInputs.push(path) missingInputs.push(path)
return { 'error': 'Deferred import' } return { 'error': 'Deferred import' }
}) })
...@@ -42,7 +39,7 @@ module.exports = function (self) { ...@@ -42,7 +39,7 @@ module.exports = function (self) {
break break
case 'compile': case 'compile':
missingInputs.length = 0 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 break
} }
}, false) }, false)
......
...@@ -288,7 +288,7 @@ function Compiler (handleImportCall) { ...@@ -288,7 +288,7 @@ function Compiler (handleImportCall) {
}) })
compileJSON = function (source, optimize) { compileJSON = function (source, optimize) {
jobs.push({sources: source}) 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}) 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