Skip to content

Commit

Permalink
Merge pull request #3189 from NomicFoundation/solidity-analyzer-errors
Browse files Browse the repository at this point in the history
Fix two `solidity-analyzer`-related errors
  • Loading branch information
fvictorio committed Oct 10, 2022
2 parents 304efcb + 3f38020 commit e4d1162
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 60 deletions.
5 changes: 5 additions & 0 deletions .changeset/twelve-bags-collect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"hardhat": patch
---

Upgrade `solidity-analyzer` and handle NPM's issue #4828.
2 changes: 1 addition & 1 deletion packages/hardhat-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
"@nomicfoundation/ethereumjs-tx": "^4.0.0",
"@nomicfoundation/ethereumjs-util": "^8.0.0",
"@nomicfoundation/ethereumjs-vm": "^6.0.0",
"@nomicfoundation/solidity-analyzer": "^0.0.3",
"@nomicfoundation/solidity-analyzer": "^0.1.0",
"@sentry/node": "^5.18.1",
"@types/bn.js": "^5.1.0",
"@types/lru-cache": "^5.1.0",
Expand Down
15 changes: 15 additions & 0 deletions packages/hardhat-core/src/internal/core/errors-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,21 @@ Either try using a new directory name, or remove the conflicting files.`,
"Hardhat attempted to convert the input value to a BigInt, but no known conversion method was applicable to the given value.",
shouldBeReported: false,
},
CORRUPTED_LOCKFILE: {
number: 18,
message: `You installed Hardhat with a corrupted lockfile due to the NPM bug #4828.
Please delete your node_modules, package-lock.json, reinstall your project, and try again.`,
title: "Corrupted lockfile",
description: `Some versions of NPM are affected [by a bug](https://github.com/npm/cli/issues/4828) that leads to corrupt lockfiles being generated.
This bug can only affect you if you, or someone at your team, installed the project without a lockfile, but with an existing node_modules.
To avoid it, please delete both your node_modules and package-lock.json, and reinstall your project.
Note that you don't need to do this every time you install a new dependency, but please make sure to delete your node_modules every time you delete your package-lock.json.`,
shouldBeReported: false,
},
},
NETWORK: {
CONFIG_NOT_FOUND: {
Expand Down
21 changes: 16 additions & 5 deletions packages/hardhat-core/src/internal/solidity/parse.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type SolidityAnalyzerT from "@nomicfoundation/solidity-analyzer";

import { SolidityFilesCache } from "../../builtin-tasks/utils/solidity-files-cache";
import { HardhatError } from "../core/errors";
import { ERRORS } from "../core/errors-list";

interface ParsedData {
imports: string[];
Expand All @@ -27,13 +29,22 @@ export class Parser {
return cacheResult;
}

const { analyze } =
require("@nomicfoundation/solidity-analyzer") as typeof SolidityAnalyzerT;
const result = analyze(fileContent);
try {
const { analyze } =
require("@nomicfoundation/solidity-analyzer") as typeof SolidityAnalyzerT;
const result = analyze(fileContent);

this._cache.set(contentHash, result);
this._cache.set(contentHash, result);

return result;
return result;
} catch (e: any) {
if (e.code === "MODULE_NOT_FOUND") {
throw new HardhatError(ERRORS.GENERAL.CORRUPTED_LOCKFILE);
}

// eslint-disable-next-line @nomiclabs/hardhat-internal-rules/only-hardhat-error
throw e;
}
}

/**
Expand Down
108 changes: 54 additions & 54 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1146,71 +1146,71 @@
mcl-wasm "^0.7.1"
rustbn.js "~0.2.0"

"@nomicfoundation/solidity-analyzer-darwin-arm64@0.0.3":
version "0.0.3"
resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-darwin-arm64/-/solidity-analyzer-darwin-arm64-0.0.3.tgz#1d49e4ac028831a3011a9f3dca60bd1963185342"
integrity sha512-W+bIiNiZmiy+MTYFZn3nwjyPUO6wfWJ0lnXx2zZrM8xExKObMrhCh50yy8pQING24mHfpPFCn89wEB/iG7vZDw==
"@nomicfoundation/solidity-analyzer-darwin-arm64@0.1.0":
version "0.1.0"
resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-darwin-arm64/-/solidity-analyzer-darwin-arm64-0.1.0.tgz#83a7367342bd053a76d04bbcf4f373fef07cf760"
integrity sha512-vEF3yKuuzfMHsZecHQcnkUrqm8mnTWfJeEVFHpg+cO+le96xQA4lAJYdUan8pXZohQxv1fSReQsn4QGNuBNuCw==

"@nomicfoundation/solidity-analyzer-darwin-x64@0.0.3":
version "0.0.3"
resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-darwin-x64/-/solidity-analyzer-darwin-x64-0.0.3.tgz#c0fccecc5506ff5466225e41e65691abafef3dbe"
integrity sha512-HuJd1K+2MgmFIYEpx46uzwEFjvzKAI765mmoMxy4K+Aqq1p+q7hHRlsFU2kx3NB8InwotkkIq3A5FLU1sI1WDw==
"@nomicfoundation/solidity-analyzer-darwin-x64@0.1.0":
version "0.1.0"
resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-darwin-x64/-/solidity-analyzer-darwin-x64-0.1.0.tgz#1225f7da647ae1ad25a87125664704ecc0af6ccc"
integrity sha512-dlHeIg0pTL4dB1l9JDwbi/JG6dHQaU1xpDK+ugYO8eJ1kxx9Dh2isEUtA4d02cQAl22cjOHTvifAk96A+ItEHA==

"@nomicfoundation/solidity-analyzer-freebsd-x64@0.0.3":
version "0.0.3"
resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-freebsd-x64/-/solidity-analyzer-freebsd-x64-0.0.3.tgz#8261d033f7172b347490cd005931ef8168ab4d73"
integrity sha512-2cR8JNy23jZaO/vZrsAnWCsO73asU7ylrHIe0fEsXbZYqBP9sMr+/+xP3CELDHJxUbzBY8zqGvQt1ULpyrG+Kw==
"@nomicfoundation/solidity-analyzer-freebsd-x64@0.1.0":
version "0.1.0"
resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-freebsd-x64/-/solidity-analyzer-freebsd-x64-0.1.0.tgz#dbc052dcdfd50ae50fd5ae1788b69b4e0fa40040"
integrity sha512-WFCZYMv86WowDA4GiJKnebMQRt3kCcFqHeIomW6NMyqiKqhK1kIZCxSLDYsxqlx396kKLPN1713Q1S8tu68GKg==

"@nomicfoundation/solidity-analyzer-linux-arm64-gnu@0.0.3":
version "0.0.3"
resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-linux-arm64-gnu/-/solidity-analyzer-linux-arm64-gnu-0.0.3.tgz#1ba64b1d76425f8953dedc6367bd7dd46f31dfc5"
integrity sha512-Eyv50EfYbFthoOb0I1568p+eqHGLwEUhYGOxcRNywtlTE9nj+c+MT1LA53HnxD9GsboH4YtOOmJOulrjG7KtbA==
"@nomicfoundation/solidity-analyzer-linux-arm64-gnu@0.1.0":
version "0.1.0"
resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-linux-arm64-gnu/-/solidity-analyzer-linux-arm64-gnu-0.1.0.tgz#e6b2eea633995b557e74e881d2a43eab4760903d"
integrity sha512-DTw6MNQWWlCgc71Pq7CEhEqkb7fZnS7oly13pujs4cMH1sR0JzNk90Mp1zpSCsCs4oKan2ClhMlLKtNat/XRKQ==

"@nomicfoundation/solidity-analyzer-linux-arm64-musl@0.0.3":
version "0.0.3"
resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-linux-arm64-musl/-/solidity-analyzer-linux-arm64-musl-0.0.3.tgz#8d864c49b55e683f7e3b5cce9d10b628797280ac"
integrity sha512-V8grDqI+ivNrgwEt2HFdlwqV2/EQbYAdj3hbOvjrA8Qv+nq4h9jhQUxFpegYMDtpU8URJmNNlXgtfucSrAQwtQ==
"@nomicfoundation/solidity-analyzer-linux-arm64-musl@0.1.0":
version "0.1.0"
resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-linux-arm64-musl/-/solidity-analyzer-linux-arm64-musl-0.1.0.tgz#af81107f5afa794f19988a368647727806e18dc4"
integrity sha512-wUpUnR/3GV5Da88MhrxXh/lhb9kxh9V3Jya2NpBEhKDIRCDmtXMSqPMXHZmOR9DfCwCvG6vLFPr/+YrPCnUN0w==

"@nomicfoundation/solidity-analyzer-linux-x64-gnu@0.0.3":
version "0.0.3"
resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-linux-x64-gnu/-/solidity-analyzer-linux-x64-gnu-0.0.3.tgz#16e769500cf1a8bb42ab9498cee3b93c30f78295"
integrity sha512-uRfVDlxtwT1vIy7MAExWAkRD4r9M79zMG7S09mCrWUn58DbLs7UFl+dZXBX0/8FTGYWHhOT/1Etw1ZpAf5DTrg==
"@nomicfoundation/solidity-analyzer-linux-x64-gnu@0.1.0":
version "0.1.0"
resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-linux-x64-gnu/-/solidity-analyzer-linux-x64-gnu-0.1.0.tgz#6877e1da1a06a9f08446070ab6e0a5347109f868"
integrity sha512-lR0AxK1x/MeKQ/3Pt923kPvwigmGX3OxeU5qNtQ9pj9iucgk4PzhbS3ruUeSpYhUxG50jN4RkIGwUMoev5lguw==

"@nomicfoundation/solidity-analyzer-linux-x64-musl@0.0.3":
version "0.0.3"
resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-linux-x64-musl/-/solidity-analyzer-linux-x64-musl-0.0.3.tgz#75f4e1a25526d54c506e4eba63b3d698b6255b8f"
integrity sha512-8HPwYdLbhcPpSwsE0yiU/aZkXV43vlXT2ycH+XlOjWOnLfH8C41z0njK8DHRtEFnp4OVN6E7E5lHBBKDZXCliA==
"@nomicfoundation/solidity-analyzer-linux-x64-musl@0.1.0":
version "0.1.0"
resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-linux-x64-musl/-/solidity-analyzer-linux-x64-musl-0.1.0.tgz#bb6cd83a0c259eccef4183796b6329a66cf7ebd9"
integrity sha512-A1he/8gy/JeBD3FKvmI6WUJrGrI5uWJNr5Xb9WdV+DK0F8msuOqpEByLlnTdLkXMwW7nSl3awvLezOs9xBHJEg==

"@nomicfoundation/solidity-analyzer-win32-arm64-msvc@0.0.3":
version "0.0.3"
resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-win32-arm64-msvc/-/solidity-analyzer-win32-arm64-msvc-0.0.3.tgz#ef6e20cfad5eedfdb145cc34a44501644cd7d015"
integrity sha512-5WWcT6ZNvfCuxjlpZOY7tdvOqT1kIQYlDF9Q42wMpZ5aTm4PvjdCmFDDmmTvyXEBJ4WTVmY5dWNWaxy8h/E28g==
"@nomicfoundation/solidity-analyzer-win32-arm64-msvc@0.1.0":
version "0.1.0"
resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-win32-arm64-msvc/-/solidity-analyzer-win32-arm64-msvc-0.1.0.tgz#9d4bca1cc9a1333fde985675083b0b7d165f6076"
integrity sha512-7x5SXZ9R9H4SluJZZP8XPN+ju7Mx+XeUMWZw7ZAqkdhP5mK19I4vz3x0zIWygmfE8RT7uQ5xMap0/9NPsO+ykw==

"@nomicfoundation/solidity-analyzer-win32-ia32-msvc@0.0.3":
version "0.0.3"
resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-win32-ia32-msvc/-/solidity-analyzer-win32-ia32-msvc-0.0.3.tgz#98c4e3af9cee68896220fa7e270aefdf7fc89c7b"
integrity sha512-P/LWGZwWkyjSwkzq6skvS2wRc3gabzAbk6Akqs1/Iiuggql2CqdLBkcYWL5Xfv3haynhL+2jlNkak+v2BTZI4A==
"@nomicfoundation/solidity-analyzer-win32-ia32-msvc@0.1.0":
version "0.1.0"
resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-win32-ia32-msvc/-/solidity-analyzer-win32-ia32-msvc-0.1.0.tgz#0db5bfc6aa952bea4098d8d2c8947b4e5c4337ee"
integrity sha512-m7w3xf+hnE774YRXu+2mGV7RiF3QJtUoiYU61FascCkQhX3QMQavh7saH/vzb2jN5D24nT/jwvaHYX/MAM9zUw==

"@nomicfoundation/solidity-analyzer-win32-x64-msvc@0.0.3":
version "0.0.3"
resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-win32-x64-msvc/-/solidity-analyzer-win32-x64-msvc-0.0.3.tgz#12da288e7ef17ec14848f19c1e8561fed20d231d"
integrity sha512-4AcTtLZG1s/S5mYAIr/sdzywdNwJpOcdStGF3QMBzEt+cGn3MchMaS9b1gyhb2KKM2c39SmPF5fUuWq1oBSQZQ==
"@nomicfoundation/solidity-analyzer-win32-x64-msvc@0.1.0":
version "0.1.0"
resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-win32-x64-msvc/-/solidity-analyzer-win32-x64-msvc-0.1.0.tgz#2e0f39a2924dcd77db6b419828595e984fabcb33"
integrity sha512-xCuybjY0sLJQnJhupiFAXaek2EqF0AP0eBjgzaalPXSNvCEN6ZYHvUzdA50ENDVeSYFXcUsYf3+FsD3XKaeptA==

"@nomicfoundation/solidity-analyzer@^0.0.3":
version "0.0.3"
resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer/-/solidity-analyzer-0.0.3.tgz#d1029f872e66cb1082503b02cc8b0be12f8dd95e"
integrity sha512-VFMiOQvsw7nx5bFmrmVp2Q9rhIjw2AFST4DYvWVVO9PMHPE23BY2+kyfrQ4J3xCMFC8fcBbGLt7l4q7m1SlTqg==
"@nomicfoundation/solidity-analyzer@^0.1.0":
version "0.1.0"
resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer/-/solidity-analyzer-0.1.0.tgz#e5ddc43ad5c0aab96e5054520d8e16212e125f50"
integrity sha512-xGWAiVCGOycvGiP/qrlf9f9eOn7fpNbyJygcB0P21a1MDuVPlKt0Srp7rvtBEutYQ48ouYnRXm33zlRnlTOPHg==
optionalDependencies:
"@nomicfoundation/solidity-analyzer-darwin-arm64" "0.0.3"
"@nomicfoundation/solidity-analyzer-darwin-x64" "0.0.3"
"@nomicfoundation/solidity-analyzer-freebsd-x64" "0.0.3"
"@nomicfoundation/solidity-analyzer-linux-arm64-gnu" "0.0.3"
"@nomicfoundation/solidity-analyzer-linux-arm64-musl" "0.0.3"
"@nomicfoundation/solidity-analyzer-linux-x64-gnu" "0.0.3"
"@nomicfoundation/solidity-analyzer-linux-x64-musl" "0.0.3"
"@nomicfoundation/solidity-analyzer-win32-arm64-msvc" "0.0.3"
"@nomicfoundation/solidity-analyzer-win32-ia32-msvc" "0.0.3"
"@nomicfoundation/solidity-analyzer-win32-x64-msvc" "0.0.3"
"@nomicfoundation/solidity-analyzer-darwin-arm64" "0.1.0"
"@nomicfoundation/solidity-analyzer-darwin-x64" "0.1.0"
"@nomicfoundation/solidity-analyzer-freebsd-x64" "0.1.0"
"@nomicfoundation/solidity-analyzer-linux-arm64-gnu" "0.1.0"
"@nomicfoundation/solidity-analyzer-linux-arm64-musl" "0.1.0"
"@nomicfoundation/solidity-analyzer-linux-x64-gnu" "0.1.0"
"@nomicfoundation/solidity-analyzer-linux-x64-musl" "0.1.0"
"@nomicfoundation/solidity-analyzer-win32-arm64-msvc" "0.1.0"
"@nomicfoundation/solidity-analyzer-win32-ia32-msvc" "0.1.0"
"@nomicfoundation/solidity-analyzer-win32-x64-msvc" "0.1.0"

"@nomiclabs/truffle-contract@^4.2.23":
version "4.5.10"
Expand Down

0 comments on commit e4d1162

Please sign in to comment.