Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Commit

Permalink
feat(calculate-hashes): "--check-only" flag added
Browse files Browse the repository at this point in the history
  • Loading branch information
benceharomi committed Oct 8, 2023
1 parent d732a3e commit 6355c20
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions scripts/calculate-hashes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ const getHashes = (
};

const main = async () => {
const checkOnly = process.argv.includes("--check-only");

const bootloaderSourceCode = readFileAsHexString(
BOOTLOADER_SOURCE_CODE_PATH,
"Failed to read Bootloader source code. Make sure to run `yarn build-yul` before you run this script!"
Expand Down Expand Up @@ -92,10 +94,19 @@ const main = async () => {
const oldSystemContractsHashes = fs.readFileSync(OUTPUT_FILE_PATH, "utf8");

if (oldSystemContractsHashes === newSystemContractsHashes) {
console.log("SystemContractsHashes.json is up to date");
console.log(
"Calculated hashes match the hashes in the SystemContractsHashes.json file."
);
return;
} else if (checkOnly) {
console.error(
"Calculated hashes differ from the hashes in the SystemContractsHashes.json file. Exiting..."
);
process.exit(1);
} else {
console.log("SystemContractsHashes.json is outdated. Updating...");
console.log(
"Calculated hashes differ from the hashes in the SystemContractsHashes.json file. Updating..."
);

fs.writeFileSync(OUTPUT_FILE_PATH, newSystemContractsHashes);
console.log("Update finished. New hashes:");
Expand Down

0 comments on commit 6355c20

Please sign in to comment.