Check storage layout consistency in PRs (#3967)

Co-authored-by: Francisco <frangio.1@gmail.com>
This commit is contained in:
Hadrien Croubois
2023-01-31 21:45:24 +01:00
committed by GitHub
parent 501a78e134
commit a70ee4e3bb
6 changed files with 264 additions and 0 deletions

View File

@ -0,0 +1,20 @@
const fs = require('fs');
const { getStorageUpgradeReport } = require('@openzeppelin/upgrades-core/dist/storage');
const { ref, head } = require('yargs').argv;
const oldLayout = JSON.parse(fs.readFileSync(ref));
const newLayout = JSON.parse(fs.readFileSync(head));
for (const name in oldLayout) {
if (name in newLayout) {
const report = getStorageUpgradeReport(oldLayout[name], newLayout[name], {});
if (!report.ok) {
console.log(`ERROR: Storage incompatibility in ${name}`);
console.log(report.explain());
process.exitCode = 1;
}
} else {
console.log(`WARNING: ${name} is missing from the current branch`);
}
}