UNPKG

@matterlabs/hardhat-zksync-verify

Version:
49 lines 2.77 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CompilerSolcUserConfigNormalizer = exports.OverrideCompilerSolcUserConfigNormalizer = void 0; const utils_1 = require("@matterlabs/hardhat-zksync-solc/dist/src/utils"); const constants_1 = require("./constants"); const errors_1 = require("./errors"); const utils_2 = require("./utils"); class OverrideCompilerSolcUserConfigNormalizer { suituble(_solcUserConfig, _file) { return _solcUserConfig instanceof Map && _file !== undefined; } normalize(_compiler, _zkSolcConfig, _latestEraVersion, _userConfigCompilers, _file) { const compilerInfo = _userConfigCompilers.get(_file); if ((0, utils_1.isBreakableCompilerVersion)(_zkSolcConfig.version)) { return compilerInfo?.eraVersion ? (0, utils_2.getZkVmNormalizedVersion)(_compiler.version, compilerInfo.eraVersion) : (0, utils_2.getZkVmNormalizedVersion)(_compiler.version, _latestEraVersion); } return compilerInfo?.eraVersion ? (0, utils_2.getZkVmNormalizedVersion)(_compiler.version, compilerInfo.eraVersion) : _compiler.version; } } exports.OverrideCompilerSolcUserConfigNormalizer = OverrideCompilerSolcUserConfigNormalizer; class CompilerSolcUserConfigNormalizer { suituble(solcUserConfig, _file) { return solcUserConfig instanceof Array && _file === undefined; } normalize(_compiler, _zkSolcConfig, _latestEraVersion, _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.ZkSyncVerifyPluginError((0, constants_1.COMPILERS_CONFLICT_ZKVM_SOLC)(_compiler.version)); } } const compilerInfo = compilerInfos[0]; if ((0, utils_1.isBreakableCompilerVersion)(_zkSolcConfig.version)) { return compilerInfo?.eraVersion ? (0, utils_2.getZkVmNormalizedVersion)(_compiler.version, compilerInfo.eraVersion) : (0, utils_2.getZkVmNormalizedVersion)(_compiler.version, _latestEraVersion); } return compilerInfo?.eraVersion ? (0, utils_2.getZkVmNormalizedVersion)(_compiler.version, compilerInfo.eraVersion) : _compiler.version; } } exports.CompilerSolcUserConfigNormalizer = CompilerSolcUserConfigNormalizer; //# sourceMappingURL=config-normalizer.js.map