Files
openzeppelin-contracts/scripts/checks/compare-layout.js
renovate[bot] 51da8ae490 Update dependency yargs to v18 (#5704)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
2025-06-18 22:01:19 +02:00

29 lines
878 B
JavaScript
Executable File

#!/usr/bin/env node
const fs = require('fs');
const { getStorageUpgradeReport } = require('@openzeppelin/upgrades-core/dist/storage');
const { hideBin } = require('yargs/helpers');
const { argv } = require('yargs/yargs')(hideBin(process.argv))
.env('')
.options({
ref: { type: 'string', required: true },
head: { type: 'string', required: true },
});
const oldLayout = JSON.parse(fs.readFileSync(argv.ref));
const newLayout = JSON.parse(fs.readFileSync(argv.head));
for (const name in oldLayout) {
if (name in newLayout) {
const report = getStorageUpgradeReport(oldLayout[name], newLayout[name], {});
if (!report.ok) {
console.log(`Storage layout incompatibility found in ${name}:`);
console.log(report.explain());
process.exitCode = 1;
}
} else {
console.log(`WARNING: ${name} is missing from the current branch`);
}
}