UNPKG

@matterlabs/hardhat-zksync-solc

Version:
53 lines 2.36 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.linkWithBinary = exports.compileWithBinary = void 0; const child_process_1 = require("child_process"); const utils_1 = require("../utils"); async function compileWithBinary(input, config, solcPath, detectMissingLibrariesMode = false) { const { compilerPath, debugOutputDir } = config.settings; let processCommand = `${compilerPath} --standard-json --solc ${solcPath} ${debugOutputDir ? `--debug-output-dir ${debugOutputDir}` : ''}`; if (!(0, utils_1.isBreakableCompilerVersion)(config.version)) { const { enableEraVMExtensions, forceEVMLA } = config.settings; processCommand += `${detectMissingLibrariesMode ? ' --detect-missing-libraries' : ''} ${enableEraVMExtensions ? '--system-mode' : ''} ${forceEVMLA ? '--force-evmla' : ''}`; } if ((0, utils_1.isBreakableCompilerVersion)(config.version)) { input.settings.detectMissingLibraries = detectMissingLibrariesMode; } const output = await new Promise((resolve, reject) => { const process = (0, child_process_1.exec)(processCommand, { maxBuffer: 1024 * 1024 * 500, }, (err, stdout, _stderr) => { if (err !== null) { return reject(err); } resolve(stdout); }); process.stdin.write(JSON.stringify(input)); process.stdin.end(); }); return JSON.parse(output); } exports.compileWithBinary = compileWithBinary; async function linkWithBinary(config, linkLibraries) { const { compilerPath } = config.settings; let processCommand = `${compilerPath} --link ${linkLibraries.contractZbinPath}`; if (linkLibraries.libraries) { processCommand += ` --libraries ${Object.entries(linkLibraries.libraries) .map((lib) => `${lib[0]}=${lib[1]}`) .join(' ')}`; } const output = await new Promise((resolve, reject) => { const process = (0, child_process_1.exec)(processCommand, { maxBuffer: 1024 * 1024 * 500, }, (err, stdout, _stderr) => { if (err !== null) { return reject(err); } resolve(stdout); }); process.stdin.end(); }); return JSON.parse(output); } exports.linkWithBinary = linkWithBinary; //# sourceMappingURL=binary.js.map