From 800a2cc2f31f19d760e5c643ffdb95c01ca3e1b2 Mon Sep 17 00:00:00 2001 From: Alex Connolly Date: Tue, 12 Dec 2023 06:02:46 +1100 Subject: [PATCH] Remove forked files from solhint to prevent errors --- .eslintignore | 2 +- .prettierignore | 1 + .solhintignore | 3 ++ hardhat.config.ts | 8 ++-- scripts/build.ts | 95 +++++++++++++++++++++++------------------------ 5 files changed, 55 insertions(+), 54 deletions(-) diff --git a/.eslintignore b/.eslintignore index 8530892a..db694a0e 100644 --- a/.eslintignore +++ b/.eslintignore @@ -4,4 +4,4 @@ cache coverage typechain dist -forks \ No newline at end of file +forks diff --git a/.prettierignore b/.prettierignore index f268596e..c328d919 100644 --- a/.prettierignore +++ b/.prettierignore @@ -3,3 +3,4 @@ artifacts cache coverage* gasReporterOutput.json + diff --git a/.solhintignore b/.solhintignore index 3c3629e6..793e901b 100644 --- a/.solhintignore +++ b/.solhintignore @@ -1 +1,4 @@ node_modules +contracts/passport +contracts/seaport +forks \ No newline at end of file diff --git a/hardhat.config.ts b/hardhat.config.ts index a3384a2c..63ce55b2 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -32,7 +32,7 @@ const config: HardhatUserConfig = { optimizer: { enabled: true, runs: 200, - } + }, }, }, { @@ -41,10 +41,10 @@ const config: HardhatUserConfig = { optimizer: { enabled: true, runs: 200, - } + }, }, - } - ] + }, + ], }, paths: { tests: "./test", diff --git a/scripts/build.ts b/scripts/build.ts index afc2d449..9b8f1c86 100644 --- a/scripts/build.ts +++ b/scripts/build.ts @@ -1,53 +1,50 @@ - -import fs from 'fs'; -import replace from 'replace-in-file'; -import forks from '../forks/forks.json'; -import main from '../package.json'; - -forks.forEach(fork => { - const dest = `contracts/${fork.name}`; - fs.rmSync(dest, { recursive: true, force: true }); - fs.cpSync(`forks/${fork.contracts}`, dest, { - recursive: true, - filter: (src: string, dest: string) => { - const matches = fork.ignore.filter(ig => src.includes(`forks/${fork.contracts}/${ig}`)); - // only include if there are no matches - return matches.length == 0; - } - }); - - const rmTemplate = `DO NOT MODIFY THESE CONTRACTS DIRECTLY. This folder has been automatically extracted from ${fork.upstream} via a submodule in this repository's forks directory. See the upstream repository for full context.` - - fs.writeFileSync(`${dest}/README.md`, rmTemplate); - - if (fork.dependencies) { - const pkg = JSON.parse(fs.readFileSync(`forks/${fork.name}/package.json`)); - fork.dependencies.forEach(dep => { - const depVersion = pkg.dependencies[dep] ? pkg.dependencies[dep] : pkg.devDependencies[dep]; - - const mainDepVersion = (main.dependencies as any)[dep]; - // What happens if the version clashes! - if (mainDepVersion && depVersion != mainDepVersion) { - // Create a custom name e.g. @openzeppelin/contracts/seaport - const customDepName = `${dep}/${fork.name}`; - (main.dependencies as any)[customDepName] = `npm:${dep}@${depVersion}`; - // Now replace all of the references to the dependency - // inside the fork's copied contracts folder - // e.g. '@openzeppelin/contracts/x/y.sol --> @openzeppelin/contracts/seaport/x/y.sol - replace.sync({ - from: dep, - to: customDepName, - files: [`${dest}/**/*.sol`] - }); - } else { - // No clash in the dependencies, just add it - (main.dependencies as any)[dep] = depVersion; - } +import fs from "fs"; +import replace from "replace-in-file"; +import forks from "../forks/forks.json"; +import main from "../package.json"; + +forks.forEach((fork) => { + const dest = `contracts/${fork.name}`; + fs.rmSync(dest, { recursive: true, force: true }); + fs.cpSync(`forks/${fork.contracts}`, dest, { + recursive: true, + filter: (src: string, dest: string) => { + const matches = fork.ignore.filter((ig) => src.includes(`forks/${fork.contracts}/${ig}`)); + // only include if there are no matches + return matches.length === 0; + }, + }); + + const rmTemplate = `DO NOT MODIFY THESE CONTRACTS DIRECTLY. This folder has been automatically extracted from ${fork.upstream} via a submodule in this repository's forks directory. See the upstream repository for full context.`; + + fs.writeFileSync(`${dest}/README.md`, rmTemplate); + + if (fork.dependencies) { + const pkg = JSON.parse(fs.readFileSync(`forks/${fork.name}/package.json`)); + fork.dependencies.forEach((dep) => { + const depVersion = pkg.dependencies[dep] ? pkg.dependencies[dep] : pkg.devDependencies[dep]; + + const mainDepVersion = (main.dependencies as any)[dep]; + // What happens if the version clashes! + if (mainDepVersion && depVersion !== mainDepVersion) { + // Create a custom name e.g. @openzeppelin/contracts/seaport + const customDepName = `${dep}/${fork.name}`; + (main.dependencies as any)[customDepName] = `npm:${dep}@${depVersion}`; + // Now replace all of the references to the dependency + // inside the fork's copied contracts folder + // e.g. '@openzeppelin/contracts/x/y.sol --> @openzeppelin/contracts/seaport/x/y.sol + replace.sync({ + from: dep, + to: customDepName, + files: [`${dest}/**/*.sol`], }); - - } + } else { + // No clash in the dependencies, just add it + (main.dependencies as any)[dep] = depVersion; + } + }); + } }); // Update our main package.json -fs.writeFileSync('package.json', JSON.stringify(main, null, 2), 'utf8'); - +fs.writeFileSync("package.json", JSON.stringify(main, null, 2), "utf8");