rexdavinci / browser-solidity-compiler

18 stars 7 forks source link

WebWorker do not respond anymore after the first compilation #4

Open Danver97 opened 1 year ago

Danver97 commented 1 year ago

Whenever I call await solidityCompiler({ version:https://binaries.soliditylang.org/bin/${version}, contractBody: content, options, }) The promise of any subsequent call won't resolve. It seems that the webworker do not respond anymore. Any clue of the cause?

nikola-bozin-org commented 1 year ago

Hey, i fixed this issue in this branch: https://github.com/nikola-bozin-org/browser-solidity-compiler/tree/feature/fixing-web-runner

Example usage in react project:

import { solidityCompiler } from "../../browser-solidity-compiler/src/index";

  const compile = async() =>{
    const version = 'soljson-v0.8.20+commit.a1b79de6.js'; 
    const result = await solidityCompiler({
      version: `https://binaries.soliditylang.org/bin/${version}`,
      contractBody: contractCode,
      options:{optimizer:{enabled:true,runs:1000}}
    })
    return result;
  }