@matterlabs/hardhat-zksync-solc
Version:
Hardhat plugin to compile smart contracts for the ZKsync network
79 lines • 10.7 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.COMPILER_ZKSOLC_DEPRECATION_FOR_SOLC_VERSION = exports.COMPILER_ZKSOLC_LATEST_DEPRECATION = exports.fallbackLatestEraCompilerVersion = exports.fallbackLatestZkSolcVersion = exports.SOLCJS_EXECUTABLE_CODE = exports.MISSING_LIBRARY_LINK = exports.COMPILE_AND_DEPLOY_LIBRARIES_INSTRUCTIONS = exports.MISSING_LIBRARIES_NOTICE = exports.COMPILERS_CONFLICT_ZKVM_SOLC = exports.ZKVM_SOLC_COMPILER_NEEDS_ERA_VERSION = exports.COMPILER_ZKSOLC_FORCE_EVMLA_USE = exports.COMPILER_ZKSOLC_IS_SYSTEM_USE = exports.COMPILER_ZKSOLC_NEED_EVM_CODEGEN = exports.COMPILER_ZKSOLC_VERSION_WITH_ZKVM_SOLC_WARN = exports.COMPILER_BINARY_CORRUPTION_ERROR_ZKVM_SOLC = exports.COMPILING_INFO_MESSAGE_ZKVM_SOLC = exports.COMPILING_INFO_MESSAGE = exports.COMPILER_BINARY_CORRUPTION_ERROR = exports.COMPILER_VERSION_WARNING = exports.COMPILER_VERSION_RANGE_ERROR = exports.COMPILER_MIN_LINUX_VERSION_WITH_GNU_TOOLCHAIN = exports.COMPILER_VERSION_INFO_FILE_NOT_FOUND_ERROR = exports.DEFAULT_COMPILER_VERSION_INFO_CACHE_PERIOD = exports.ZKVM_SOLC_DEFAULT_COMPILER_VERSION = exports.ZKSOLC_COMPILER_VERSION_MIN_VERSION_WITH_ZKVM_COMPILER = exports.ZKSOLC_COMPILER_MIN_VERSION_BREAKABLE_CHANGE = exports.ZKVM_SOLC_COMPILER_VERSION_MIN_VERSION = exports.ZKVM_SOLC_BIN_REPOSITORY_NAME = exports.ZKSOLC_BIN_REPOSITORY_NAME = exports.ZKSOLC_BIN_OWNER = exports.ZKSOLC_COMPILER_VERSION_MIN_VERSION = exports.ZKSOLC_COMPILER_MIN_VERSION_WITH_FALLBACK_OZ = exports.ZKSOLC_COMPILERS_SELECTOR_MAP = exports.defaultZkSolcConfig = exports.ZKSOLC_COMPILER_VERSION_WITH_LIBRARY_LINKING = exports.TASK_COMPILE_LINK = exports.ZKSOLC_COMPILER_PATH_VERSION = exports.TASK_DOWNLOAD_ZKSOLC = exports.TASK_UPDATE_SOLIDITY_COMPILERS = exports.USER_AGENT = exports.DETECT_MISSING_LIBRARY_MODE_COMPILER_VERSION = exports.DEFAULT_TIMEOUT_MILISECONDS = exports.ZKVM_SOLC_BIN_REPOSITORY = exports.ZKSOLC_BIN_REPOSITORY = exports.ZK_ARTIFACT_FORMAT_VERSION = exports.PLUGIN_NAME = void 0;
exports.PLUGIN_NAME = '@matterlabs/hardhat-zksync-solc';
exports.ZK_ARTIFACT_FORMAT_VERSION = 'hh-zksolc-artifact-1';
exports.ZKSOLC_BIN_REPOSITORY = 'https://github.com/matter-labs/era-compiler-solidity';
exports.ZKVM_SOLC_BIN_REPOSITORY = 'https://github.com/matter-labs/era-solidity';
exports.DEFAULT_TIMEOUT_MILISECONDS = 30000;
exports.DETECT_MISSING_LIBRARY_MODE_COMPILER_VERSION = '1.3.14';
// User agent of MacOSX Chrome 120.0.0.0
exports.USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36';
exports.TASK_UPDATE_SOLIDITY_COMPILERS = 'compile:update-solidity-compilers';
exports.TASK_DOWNLOAD_ZKSOLC = 'compile:zksolc:download';
exports.ZKSOLC_COMPILER_PATH_VERSION = 'local_or_remote';
exports.TASK_COMPILE_LINK = 'compile:link';
exports.ZKSOLC_COMPILER_VERSION_WITH_LIBRARY_LINKING = '1.5.4';
exports.defaultZkSolcConfig = {
version: 'latest',
compilerSource: 'binary',
settings: {
optimizer: {
enabled: true,
mode: '3',
},
compilerPath: '',
missingLibrariesPath: './.zksolc-libraries-cache/missingLibraryDependencies.json',
areLibrariesMissing: false,
experimental: {},
},
};
/* eslint-disable @typescript-eslint/naming-convention */
exports.ZKSOLC_COMPILERS_SELECTOR_MAP = {
'1.3.5': ['abi', 'evm.methodIdentifiers', 'storageLayout', 'irOptimized', 'evm.legacyAssembly', 'ast'],
};
/* eslint-enable @typescript-eslint/naming-convention */
exports.ZKSOLC_COMPILER_MIN_VERSION_WITH_FALLBACK_OZ = '1.3.21';
exports.ZKSOLC_COMPILER_VERSION_MIN_VERSION = '1.3.13';
exports.ZKSOLC_BIN_OWNER = 'matter-labs';
exports.ZKSOLC_BIN_REPOSITORY_NAME = 'zksolc-bin';
exports.ZKVM_SOLC_BIN_REPOSITORY_NAME = 'era-solidity';
exports.ZKVM_SOLC_COMPILER_VERSION_MIN_VERSION = '1.0.0';
exports.ZKSOLC_COMPILER_MIN_VERSION_BREAKABLE_CHANGE = '1.5.0';
exports.ZKSOLC_COMPILER_VERSION_MIN_VERSION_WITH_ZKVM_COMPILER = '1.3.22';
exports.ZKVM_SOLC_DEFAULT_COMPILER_VERSION = '1.0.0';
exports.DEFAULT_COMPILER_VERSION_INFO_CACHE_PERIOD = 24 * 60 * 60 * 1000; // 24 hours
exports.COMPILER_VERSION_INFO_FILE_NOT_FOUND_ERROR = 'Could not find zksolc compiler version info file.';
exports.COMPILER_MIN_LINUX_VERSION_WITH_GNU_TOOLCHAIN = '1.5.3';
const COMPILER_VERSION_RANGE_ERROR = (version, minVersion, latestVersion) => `The zksolc compiler version (${version}) in the hardhat config file is not within the allowed range. Please use versions ${minVersion} to ${latestVersion}.`;
exports.COMPILER_VERSION_RANGE_ERROR = COMPILER_VERSION_RANGE_ERROR;
const COMPILER_VERSION_WARNING = (version, latestVersion) => `The zksolc compiler version in your Hardhat config file (${version}) is not the latest. We recommend using the latest version ${latestVersion}.`;
exports.COMPILER_VERSION_WARNING = COMPILER_VERSION_WARNING;
const COMPILER_BINARY_CORRUPTION_ERROR = (compilerPath) => `The zksolc binary at path ${compilerPath} is corrupted. Please delete it and try again.`;
exports.COMPILER_BINARY_CORRUPTION_ERROR = COMPILER_BINARY_CORRUPTION_ERROR;
const COMPILING_INFO_MESSAGE = (zksolcVersion, solcVersion) => `Compiling contracts for ZKsync Era with zksolc v${zksolcVersion} and solc v${solcVersion}`;
exports.COMPILING_INFO_MESSAGE = COMPILING_INFO_MESSAGE;
const COMPILING_INFO_MESSAGE_ZKVM_SOLC = (zksolcVersion, zkvmSolcVersion) => `Compiling contracts for ZKsync Era with zksolc v${zksolcVersion} and zkvm-solc v${zkvmSolcVersion}`;
exports.COMPILING_INFO_MESSAGE_ZKVM_SOLC = COMPILING_INFO_MESSAGE_ZKVM_SOLC;
const COMPILER_BINARY_CORRUPTION_ERROR_ZKVM_SOLC = (compilerPath) => `The zkvm-solc binary at path ${compilerPath} is corrupted. Please delete it and try again.`;
exports.COMPILER_BINARY_CORRUPTION_ERROR_ZKVM_SOLC = COMPILER_BINARY_CORRUPTION_ERROR_ZKVM_SOLC;
exports.COMPILER_ZKSOLC_VERSION_WITH_ZKVM_SOLC_WARN = `zkVm (eraVersion) compiler is supported only with usage of zksolc version >= ${exports.ZKSOLC_COMPILER_VERSION_MIN_VERSION_WITH_ZKVM_COMPILER}. Switching by default to the native solc compiler.`;
exports.COMPILER_ZKSOLC_NEED_EVM_CODEGEN = `Yul codegen is only supported for solc >= 0.8. Flag forceEVMLA will automatically be set to true by default.`;
exports.COMPILER_ZKSOLC_IS_SYSTEM_USE = `isSystem flag is deprecated. Please use enableEraVMExtensions instead. Automatically switched to the new naming with the provided value.`;
exports.COMPILER_ZKSOLC_FORCE_EVMLA_USE = `forceEvmla flag is deprecated. Please use forceEVMLA instead. Automatically switched to the new naming with the provided value.`;
const ZKVM_SOLC_COMPILER_NEEDS_ERA_VERSION = (eraVersion, solcVersion) => `Using ZKsync edition of solc (ZKsync Era Solidity Compiler) as default with version ${eraVersion} for solidity version ${solcVersion}.`;
exports.ZKVM_SOLC_COMPILER_NEEDS_ERA_VERSION = ZKVM_SOLC_COMPILER_NEEDS_ERA_VERSION;
const COMPILERS_CONFLICT_ZKVM_SOLC = (version) => `Your Hardhat configuration has conflicting Solidity compiler versions for version ${version}. Specify either a compiler version with zkVm support (eraVersion) or one without it.`;
exports.COMPILERS_CONFLICT_ZKVM_SOLC = COMPILERS_CONFLICT_ZKVM_SOLC;
exports.MISSING_LIBRARIES_NOTICE = 'zksolc compiler detected missing libraries! For more details, visit: https://docs.zksync.io/build/tooling/hardhat/compiling-libraries.';
exports.COMPILE_AND_DEPLOY_LIBRARIES_INSTRUCTIONS = 'To compile and deploy libraries, please run: `hardhat deploy-zksync:libraries`';
exports.MISSING_LIBRARY_LINK = 'For more details on how to use deploy-zksync:libraries task from hardhat-zksync-deploy plugin, visit: https://docs.zksync.io/build/tooling/hardhat/hardhat-zksync-deploy.';
exports.SOLCJS_EXECUTABLE_CODE = `
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&("get"in i?t.__esModule:!i.writable&&!i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,i)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&__createBinding(t,e,r);return __setModuleDefault(t,e),t},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports._loadCompilerSources=void 0;const os_1=__importDefault(require("os")),fs_1=__importDefault(require("fs")),path_1=__importDefault(require("path"));function packageExists(e){try{return require.resolve(e),!0}catch(e){return!1}}function findPackagePath(e,t){let r=t,o=r+"/node_modules/"+e;for(;"/"!==r;){if(packageExists(o))return o;r=path_1.default.dirname(r),o=r+"/node_modules/"+e}}async function getSolc(e,t){var r=findPackagePath("solc/wrapper",t);const{default:o}=await Promise.resolve().then(()=>__importStar(require(r)));return o(_loadCompilerSources(e))}function _loadCompilerSources(e){const t=module.constructor;if(void 0===t._extensions)return require(e);var r=t._extensions[".js"];t._extensions[".js"]=function(e,t){var r=fs_1.default.readFileSync(t,"utf8");Object.getPrototypeOf(e)._compile.call(e,r,t)};e=require(e);return t._extensions[".js"]=r,e}exports._loadCompilerSources=_loadCompilerSources;async function readStdin(){return new Promise(e=>{let t="";process.stdin.on("data",e=>t+=e),process.stdin.on("end",()=>e(t))})}!async function(){var e;const t=await getSolc("SOLCJS_PATH","WORKING_DIR");process.argv.includes("--version")?(e=await t.version(),process.stdout.write("solc, the solidity compiler commandline interface"+os_1.default.EOL),process.stdout.write("Version: "+e+os_1.default.EOL)):(e=await readStdin(),e=t.compile(e),process.stdout.write(e))}();`;
exports.fallbackLatestZkSolcVersion = '1.5.12';
exports.fallbackLatestEraCompilerVersion = 'x.x.x-1.0.1';
exports.COMPILER_ZKSOLC_LATEST_DEPRECATION = `The 'latest' version specifier is deprecated. Please specify the version of zksolc explicitly.
To see available versions and changelogs, visit https://github.com/matter-labs/era-compiler-solidity/releases.`;
const COMPILER_ZKSOLC_DEPRECATION_FOR_SOLC_VERSION = (version) => `The solc version ${version} is deprecated and will be removed for security reasons soon. Please update to v1.4.0 or newer.`;
exports.COMPILER_ZKSOLC_DEPRECATION_FOR_SOLC_VERSION = COMPILER_ZKSOLC_DEPRECATION_FOR_SOLC_VERSION;
//# sourceMappingURL=constants.js.map