fix using compiler worker

pull/3549/head
yann300 2 years ago committed by Aniket
parent aca95d02ef
commit 5e131358c0
  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 } }
// compile
const compiler = await this.call('solidity', 'getCompiler')
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))
}, compiler.state.worker)
})
// get the vm provider
const contract = compilation.getContract('SolidityScript')

@ -3,14 +3,14 @@ import { canUseWorker, urlFromVersion } from './compiler-utils'
import { CompilerAbstract } from './compiler-abstract'
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) => {
const compiler = new Compiler(contentResolverCallback)
compiler.set('evmVersion', settings.evmVersion)
compiler.set('optimize', settings.optimize)
compiler.set('language', settings.language)
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) => {
resolve(new CompilerAbstract(settings.version, compilationData, source, input))
})

Loading…
Cancel
Save