@matterlabs/hardhat-zksync-solc
Version:
Hardhat plugin to compile smart contracts for the ZKsync network
46 lines • 2.18 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CompilerSolcUserConfigUpdater = exports.OverrideCompilerSolcUserConfigUpdater = void 0;
const constants_1 = require("./constants");
const errors_1 = require("./errors");
const utils_1 = require("./utils");
class OverrideCompilerSolcUserConfigUpdater {
suituble(_solcUserConfig, _file) {
return _solcUserConfig instanceof Map && _file !== undefined;
}
update(_compiler, _latestEraVersion, _zksolc, _userConfigCompilers, _file) {
const compilerInfo = _userConfigCompilers.get(_file);
if (compilerInfo?.eraVersion) {
_compiler.eraVersion = compilerInfo.eraVersion;
return;
}
if ((0, utils_1.isBreakableCompilerVersion)(_zksolc.version)) {
_compiler.eraVersion = _latestEraVersion;
}
}
}
exports.OverrideCompilerSolcUserConfigUpdater = OverrideCompilerSolcUserConfigUpdater;
class CompilerSolcUserConfigUpdater {
suituble(solcUserConfig, _file) {
return solcUserConfig instanceof Array && _file === undefined;
}
update(_compiler, _latestEraVersion, _zksolc, _userConfigCompilers, _file) {
const compilerInfos = _userConfigCompilers.filter((userCompilerInfo) => userCompilerInfo.version === _compiler.version);
if (compilerInfos.length > 1) {
const compilerInfosWithEraVersion = compilerInfos.filter((userCompilerInfo) => userCompilerInfo.eraVersion);
if (compilerInfosWithEraVersion.length > 0 && compilerInfosWithEraVersion.length !== compilerInfos.length) {
throw new errors_1.ZkSyncSolcPluginError((0, constants_1.COMPILERS_CONFLICT_ZKVM_SOLC)(_compiler.version));
}
}
const compilerInfo = compilerInfos[0];
if (compilerInfo?.eraVersion) {
_compiler.eraVersion = compilerInfo.eraVersion;
return;
}
if ((0, utils_1.isBreakableCompilerVersion)(_zksolc.version)) {
_compiler.eraVersion = _latestEraVersion;
}
}
}
exports.CompilerSolcUserConfigUpdater = CompilerSolcUserConfigUpdater;
//# sourceMappingURL=config-update.js.map