fix using compiler worker

pull/5370/head
yann300 2 years ago committed by Aniket
parent 910b7ab135
commit db949cc58c
  1. 3
      apps/remix-ide/src/app/plugins/solidity-script.tsx
  2. 4
      libs/remix-solidity/src/compiler/compiler-helpers.ts

@ -29,10 +29,9 @@ export class SolidityScript extends Plugin {
const targets = { 'script.sol': { content } } const targets = { 'script.sol': { content } }
// compile // compile
const compiler = await this.call('solidity', 'getCompiler')
const compilation = await compile(targets, params, async (url, cb) => { const compilation = await compile(targets, params, async (url, cb) => {
await this.call('contentImport', 'resolveAndSave', url).then((result) => cb(null, result)).catch((error) => cb(error.message)) await this.call('contentImport', 'resolveAndSave', url).then((result) => cb(null, result)).catch((error) => cb(error.message))
}, compiler.state.worker) })
// get the vm provider // get the vm provider
const contract = compilation.getContract('SolidityScript') const contract = compilation.getContract('SolidityScript')

@ -3,14 +3,14 @@ import { canUseWorker, urlFromVersion } from './compiler-utils'
import { CompilerAbstract } from './compiler-abstract' import { CompilerAbstract } from './compiler-abstract'
import { Compiler } from './compiler' import { Compiler } from './compiler'
export const compile = (compilationTargets, settings, contentResolverCallback, worker?: any): Promise<CompilerAbstract> => { export const compile = (compilationTargets, settings, contentResolverCallback): Promise<CompilerAbstract> => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const compiler = new Compiler(contentResolverCallback) const compiler = new Compiler(contentResolverCallback)
compiler.set('evmVersion', settings.evmVersion) compiler.set('evmVersion', settings.evmVersion)
compiler.set('optimize', settings.optimize) compiler.set('optimize', settings.optimize)
compiler.set('language', settings.language) compiler.set('language', settings.language)
compiler.set('runs', settings.runs) compiler.set('runs', settings.runs)
compiler.loadVersion(canUseWorker(settings.version), urlFromVersion(settings.version), worker) compiler.loadVersion(canUseWorker(settings.version), urlFromVersion(settings.version))
compiler.event.register('compilationFinished', (success, compilationData, source, input, version) => { compiler.event.register('compilationFinished', (success, compilationData, source, input, version) => {
resolve(new CompilerAbstract(settings.version, compilationData, source, input)) resolve(new CompilerAbstract(settings.version, compilationData, source, input))
}) })

Loading…
Cancel
Save