Add non-value types in EnumerableSet and EnumerableMap (#5658)

Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
This commit is contained in:
Ernesto García
2025-06-03 08:26:06 -06:00
committed by GitHub
parent 4bafedfe72
commit 784d4f71b1
13 changed files with 770 additions and 101 deletions

View File

@ -1,6 +1,6 @@
#!/usr/bin/env node
// const cp = require('child_process');
const cp = require('child_process');
const fs = require('fs');
const path = require('path');
const format = require('./format-lines');
@ -13,7 +13,7 @@ function getVersion(path) {
}
}
function generateFromTemplate(file, template, outputPrefix = '') {
function generateFromTemplate(file, template, outputPrefix = '', lint = false) {
const script = path.relative(path.join(__dirname, '../..'), __filename);
const input = path.join(path.dirname(script), template);
const output = path.join(outputPrefix, file);
@ -27,9 +27,12 @@ function generateFromTemplate(file, template, outputPrefix = '') {
);
fs.writeFileSync(output, content);
// cp.execFileSync('prettier', ['--write', output]);
lint && cp.execFileSync('prettier', ['--write', output]);
}
// Some templates needs to go through the linter after generation
const needsLinter = ['utils/structs/EnumerableMap.sol'];
// Contracts
for (const [file, template] of Object.entries({
'utils/cryptography/MerkleProof.sol': './templates/MerkleProof.js',
@ -45,7 +48,7 @@ for (const [file, template] of Object.entries({
'mocks/StorageSlotMock.sol': './templates/StorageSlotMock.js',
'mocks/TransientSlotMock.sol': './templates/TransientSlotMock.js',
})) {
generateFromTemplate(file, template, './contracts/');
generateFromTemplate(file, template, './contracts/', needsLinter.includes(file));
}
// Tests
@ -54,5 +57,5 @@ for (const [file, template] of Object.entries({
'utils/Packing.t.sol': './templates/Packing.t.js',
'utils/SlotDerivation.t.sol': './templates/SlotDerivation.t.js',
})) {
generateFromTemplate(file, template, './test/');
generateFromTemplate(file, template, './test/', needsLinter.includes(file));
}