@solvprotocol/upgrade-safe-transpiler
Version:
Solidity preprocessor used to generate OpenZeppelin Contracts Upgrade Safe.
24 lines • 1.13 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getBuildInfo = void 0;
const hardhat_1 = __importDefault(require("hardhat"));
const fs_1 = require("fs");
const path_1 = __importDefault(require("path"));
async function getBuildInfo(version) {
const buildInfoPath = path_1.default.join(hardhat_1.default.config.paths.artifacts, 'build-info');
const filenames = await fs_1.promises.readdir(buildInfoPath);
const buildInfos = await Promise.all(filenames.map(async (f) => JSON.parse(await fs_1.promises.readFile(path_1.default.join(buildInfoPath, f), 'utf8'))));
const matching = buildInfos.filter(i => i.solcVersion.startsWith(version));
if (matching.length > 1) {
throw new Error('More than 1 matching compilation found');
}
else if (matching.length < 1) {
throw new Error('Compilation not found');
}
return matching[0];
}
exports.getBuildInfo = getBuildInfo;
//# sourceMappingURL=get-build-info.js.map