Skip to content

Migrate to Hardhat3#6542

Open
Amxx wants to merge 124 commits into
masterfrom
hardhat3
Open

Migrate to Hardhat3#6542
Amxx wants to merge 124 commits into
masterfrom
hardhat3

Conversation

@Amxx

@Amxx Amxx commented May 22, 2026

Copy link
Copy Markdown
Collaborator

Replaces #6317

testing

  • migrate test
  • test upgradeable
  • fix remaining faillures
  • slow tests
  • fuzzing & halmos

migrate processes that needs migrating

  • transpilation
  • exposed plugin (minimal)
  • procedural generation
  • gas report + comparaison
  • coverage
    • filtering
    • reporting
  • documentation
    • migrate solidity-docgen

@socket-security

socket-security Bot commented May 22, 2026

Copy link
Copy Markdown

Caution

Review the following alerts detected in dependencies.

According to your organization's Security Policy, you must resolve all "Block" alerts before proceeding. Learn more about Socket for GitHub.

Action Severity Alert  (click "▶" to expand/collapse)
Block High
High CVE: npm fast-uri vulnerable to host confusion via percent-encoded authority delimiters

CVE: GHSA-v39h-62p7-jpjc fast-uri vulnerable to host confusion via percent-encoded authority delimiters (HIGH)

Affected versions: < 3.1.2

Patched version: 3.1.2

From: package-lock.jsonnpm/solhint@6.0.3npm/@openzeppelin/upgrade-safe-transpiler@0.4.1npm/fast-uri@3.1.0

ℹ Read more on: This package | This alert | What is a CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known high severity CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/fast-uri@3.1.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Block High
High CVE: npm fast-uri vulnerable to path traversal via percent-encoded dot segments

CVE: GHSA-q3j6-qgpj-74h6 fast-uri vulnerable to path traversal via percent-encoded dot segments (HIGH)

Affected versions: < 3.1.1

Patched version: 3.1.1

From: package-lock.jsonnpm/solhint@6.0.3npm/@openzeppelin/upgrade-safe-transpiler@0.4.1npm/fast-uri@3.1.0

ℹ Read more on: This package | This alert | What is a CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known high severity CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/fast-uri@3.1.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Block High
High CVE: npm flatted vulnerable to unbounded recursion DoS in parse() revive phase

CVE: GHSA-25h7-pfq9-p65f flatted vulnerable to unbounded recursion DoS in parse() revive phase (HIGH)

Affected versions: < 3.4.0

Patched version: 3.4.0

From: package-lock.jsonnpm/eslint@9.39.2npm/flatted@3.3.3

ℹ Read more on: This package | This alert | What is a CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known high severity CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/flatted@3.3.3. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Block High
High CVE: Prototype Pollution via parse() in NodeJS npm flatted

CVE: GHSA-rf6f-7fwh-wjgh Prototype Pollution via parse() in NodeJS flatted (HIGH)

Affected versions: < 3.4.2

Patched version: 3.4.2

From: package-lock.jsonnpm/eslint@9.39.2npm/flatted@3.3.3

ℹ Read more on: This package | This alert | What is a CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known high severity CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/flatted@3.3.3. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Block High
High CVE: Picomatch has a ReDoS vulnerability via extglob quantifiers

CVE: GHSA-c2c7-rcm5-vvqj Picomatch has a ReDoS vulnerability via extglob quantifiers (HIGH)

Affected versions: >= 4.0.0 < 4.0.4; >= 3.0.0 < 3.0.2; < 2.3.2

Patched version: 2.3.2

From: package-lock.jsonnpm/micromatch@4.0.8npm/@openzeppelin/docs-utils@0.1.6npm/picomatch@2.3.1

ℹ Read more on: This package | This alert | What is a CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known high severity CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/picomatch@2.3.1. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Block High
High CVE: Undici: Malicious WebSocket 64-bit length overflows parser and crashes the client

CVE: GHSA-f269-vfmq-vjvj Undici: Malicious WebSocket 64-bit length overflows parser and crashes the client (HIGH)

Affected versions: >= 6.0.0 < 6.24.0; >= 7.0.0 < 7.24.0

Patched version: 6.24.0

From: package-lock.jsonnpm/@nomicfoundation/hardhat-network-helpers@3.0.4npm/@nomicfoundation/hardhat-mocha@3.0.15npm/@nomicfoundation/hardhat-ethers@4.0.7npm/@nomicfoundation/hardhat-ethers-chai-matchers@3.0.4npm/hardhat@3.5.0npm/undici@6.23.0

ℹ Read more on: This package | This alert | What is a CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known high severity CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/undici@6.23.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Block Low
Potential code anomaly (AI signal): npm @nomicfoundation/edr is 66.0% likely to have a medium risk anomaly

Notes: This module is a native addon loader with a musl/gnu discriminator. The wrapper itself shows no explicit indicators of network exfiltration, credential theft, or script injection; however, it (a) executes a host command ('which ldd') during module initialization in some cases and (b) conditionally loads executable native binaries from either local files or platform-specific @NomicFoundation dependencies. Since the actual behavior is in the .node/native code, the primary security concern is supply-chain/native execution trust and the fail-open musl detection that could cause an unexpected binary to be loaded.

Confidence: 0.66

Severity: 0.50

From: package-lock.jsonnpm/hardhat@3.5.0npm/@nomicfoundation/edr@0.12.0-next.33

ℹ Read more on: This package | This alert | What is an AI-detected potential code anomaly?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: An AI system found a low-risk anomaly in this package. It may still be fine to use, but you should check that it is safe before proceeding.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/@nomicfoundation/edr@0.12.0-next.33. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Block Low
Low CVE: jsnpm diff has a Denial of Service vulnerability in parsePatch and applyPatch

CVE: GHSA-73rr-hh4g-fpgx jsdiff has a Denial of Service vulnerability in parsePatch and applyPatch (LOW)

Affected versions: >= 6.0.0 < 8.0.3; >= 5.0.0 < 5.2.2; >= 4.0.0 < 4.0.4; < 3.5.1

Patched version: 8.0.3

From: package-lock.jsonnpm/@nomicfoundation/hardhat-mocha@3.0.15npm/diff@7.0.0

ℹ Read more on: This package | This alert | What is a mild CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known low severity CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/diff@7.0.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Block Low
Potential code anomaly (AI signal): npm esbuild is 100.0% likely to have a medium risk anomaly

Notes: The code represents a thorough and sophisticated installer for esbuild with multiple fallback mechanisms to acquire platform-appropriate binaries. While largely legitimate, its use of direct tarball downloads, manual extraction without explicit integrity validation, and the override/wrapper mechanism create nontrivial supply-chain and abuse risks. Recommend enabling strict binary integrity checks (checksums/signatures), minimizing or auditing the override/wrapper feature, and implementing tighter error visibility and logging to reduce operational risk and potential misuse.

Confidence: 1.00

Severity: 0.60

From: package-lock.jsonnpm/@nomicfoundation/hardhat-mocha@3.0.15npm/hardhat@3.5.0npm/esbuild@0.27.3

ℹ Read more on: This package | This alert | What is an AI-detected potential code anomaly?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: An AI system found a low-risk anomaly in this package. It may still be fine to use, but you should check that it is safe before proceeding.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/esbuild@0.27.3. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Block Low
Potential code anomaly (AI signal): npm mocha is 100.0% likely to have a medium risk anomaly

Notes: The code is a small, benign utility for cache invalidation in Node.js. It enables reloading behavior but bears potential risk if used on critical modules or without validation. Overall security risk is low to moderate depending on usage context.

Confidence: 1.00

Severity: 0.60

From: package-lock.jsonnpm/@nomicfoundation/hardhat-mocha@3.0.15npm/mocha@11.7.5

ℹ Read more on: This package | This alert | What is an AI-detected potential code anomaly?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: An AI system found a low-risk anomaly in this package. It may still be fine to use, but you should check that it is safe before proceeding.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/mocha@11.7.5. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Block Low
Potential code anomaly (AI signal): npm picomatch is 100.0% likely to have a medium risk anomaly

Notes: The analyzed code is a legitimate, sophisticated glob-to-regex parser (part of picomatch). There is no evidence of malicious behavior, data exfiltration, or backdoors within this fragment. While performance considerations exist due to backtracking and complex state management, and there is a potential for regex-related denial-of-service with pathological inputs, these concerns pertain to usage and input quality rather than intrinsic malware. Overall security risk is low to moderate depending on input handling and option usage; no active threats detected in the provided code alone.

Confidence: 1.00

Severity: 0.60

From: package-lock.jsonnpm/micromatch@4.0.8npm/@openzeppelin/docs-utils@0.1.6npm/picomatch@2.3.1

ℹ Read more on: This package | This alert | What is an AI-detected potential code anomaly?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: An AI system found a low-risk anomaly in this package. It may still be fine to use, but you should check that it is safe before proceeding.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/picomatch@2.3.1. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Block Low
Potential code anomaly (AI signal): npm tsx is 100.0% likely to have a medium risk anomaly

Notes: This fragment appears to be a bundler-generated bootstrap/initialization piece that imports many modules and executes an initialization function (r). No explicit malicious activity is evident within this fragment itself, but the risk stems from side effects of the imported modules on load. A careful review of the implementations of the imported modules (especially those exporting r and those performing initialization, build-time, or network/file operations) is recommended to rule out hidden telemetry, backdoors, or undesired side effects.

Confidence: 1.00

Severity: 0.60

From: package-lock.jsonnpm/@nomicfoundation/hardhat-mocha@3.0.15npm/hardhat@3.5.0npm/tsx@4.21.0

ℹ Read more on: This package | This alert | What is an AI-detected potential code anomaly?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: An AI system found a low-risk anomaly in this package. It may still be fine to use, but you should check that it is safe before proceeding.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/tsx@4.21.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Block Low
Potential code anomaly (AI signal): npm tsx is 100.0% likely to have a medium risk anomaly

Notes: The module installs hidden signal handlers for SIGINT and SIGTERM, hides them from other code by monkey-patching process.listenerCount and process.listeners, forwards signals to an external client callback, and may force exit. That stealthy interception of process signals is suspicious from a supply-chain/security perspective because it can be used to intercept or suppress normal shutdown behavior and to forward events to another module which may perform network I/O or exfiltration. There is no direct evidence in this file of data exfiltration, reverse shell, or explicit malicious payload, but the hiding behavior and delegation to an external client warrant caution and further inspection of the imported client and cjs modules. Recommend auditing the client callback and cjs/index.cjs for network operations or data-leaking behavior before trusting this package.

Confidence: 1.00

Severity: 0.60

From: package-lock.jsonnpm/@nomicfoundation/hardhat-mocha@3.0.15npm/hardhat@3.5.0npm/tsx@4.21.0

ℹ Read more on: This package | This alert | What is an AI-detected potential code anomaly?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: An AI system found a low-risk anomaly in this package. It may still be fine to use, but you should check that it is safe before proceeding.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/tsx@4.21.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Block Low
Potential code anomaly (AI signal): npm tsx is 100.0% likely to have a medium risk anomaly

Notes: This module installs signal handlers and actively hides them from inspection by monkeypatching listener inspection APIs. In the main thread it can forward SIGINT/SIGTERM events to a remote client (via client.connectingToServer) and may exit the process after forwarding. The concealment is a noteworthy red flag: it makes detection and auditing harder and may be used to implement covert telemetry or control. The file alone is not conclusively malicious, but the combination of hiding handlers and forwarding signals to an external component warrants careful review of the client module (client-D6NvIMSC.cjs) and any network destinations it uses before trusting this package in sensitive environments.

Confidence: 1.00

Severity: 0.60

From: package-lock.jsonnpm/@nomicfoundation/hardhat-mocha@3.0.15npm/hardhat@3.5.0npm/tsx@4.21.0

ℹ Read more on: This package | This alert | What is an AI-detected potential code anomaly?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: An AI system found a low-risk anomaly in this package. It may still be fine to use, but you should check that it is safe before proceeding.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/tsx@4.21.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Block Low
Potential code anomaly (AI signal): npm tsx is 100.0% likely to have a medium risk anomaly

Notes: No clear indicators of classic malware (no reverse shell, no network connections, no child_process usage, no hard-coded credentials). The primary risk is information leakage: the loader posts module load events and dependency paths to external consumers via p.port and O.send. In contexts where those channels are controlled by an untrusted or remote party, this could leak local file paths or project structure. The module otherwise performs expected loader duties (file reads, tsconfig handling, transforming CJS to ESM, returning data: URLs). Review runtime consumers of O and any provided p.port to ensure they are trusted before using this loader in a sensitive environment.

Confidence: 1.00

Severity: 0.60

From: package-lock.jsonnpm/@nomicfoundation/hardhat-mocha@3.0.15npm/hardhat@3.5.0npm/tsx@4.21.0

ℹ Read more on: This package | This alert | What is an AI-detected potential code anomaly?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: An AI system found a low-risk anomaly in this package. It may still be fine to use, but you should check that it is safe before proceeding.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/tsx@4.21.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Block Low
Potential code anomaly (AI signal): npm undici is 100.0% likely to have a medium risk anomaly

Notes: The analyzed code appears to implement a standard in-memory cache batch operation flow (put/delete) with careful handling of response bodies by buffering and storing bytes for caching. No signs of malware, data exfiltration, backdoors, or obfuscated behavior were found. The primary security considerations relate to memory usage from buffering potentially large response bodies and ensuring robust validation within batch operations to prevent cache state corruption. Overall risk is moderate, driven by in-memory data handling rather than external communication.

Confidence: 1.00

Severity: 0.60

From: package-lock.jsonnpm/@nomicfoundation/hardhat-network-helpers@3.0.4npm/@nomicfoundation/hardhat-mocha@3.0.15npm/@nomicfoundation/hardhat-ethers@4.0.7npm/@nomicfoundation/hardhat-ethers-chai-matchers@3.0.4npm/hardhat@3.5.0npm/undici@6.23.0

ℹ Read more on: This package | This alert | What is an AI-detected potential code anomaly?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: An AI system found a low-risk anomaly in this package. It may still be fine to use, but you should check that it is safe before proceeding.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/undici@6.23.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Block Low
Potential code anomaly (AI signal): npm undici is 100.0% likely to have a medium risk anomaly

Notes: The script performs an in-place, lossy re-encoding of a local file from UTF-8 to Latin-1 and rewrites it without backups or validation. This is unsafe due to potential data loss and code corruption, and could be exploited to tamper with source files in a supply chain. It does not exhibit active malware behavior, but its destructive nature warrants removal or strict safeguards (backups, explicit intent, error handling).

Confidence: 1.00

Severity: 0.60

From: package-lock.jsonnpm/@nomicfoundation/hardhat-network-helpers@3.0.4npm/@nomicfoundation/hardhat-mocha@3.0.15npm/@nomicfoundation/hardhat-ethers@4.0.7npm/@nomicfoundation/hardhat-ethers-chai-matchers@3.0.4npm/hardhat@3.5.0npm/undici@6.23.0

ℹ Read more on: This package | This alert | What is an AI-detected potential code anomaly?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: An AI system found a low-risk anomaly in this package. It may still be fine to use, but you should check that it is safe before proceeding.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/undici@6.23.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Block Low
Potential code anomaly (AI signal): npm workerpool is 100.0% likely to have a medium risk anomaly

Notes: The fragment is a self-contained, non-native Promise-like utility with cancellation/timeout semantics. It shows no evidence of malware, data exfiltration, or covert backdoors within this module. The primary concern is the execution of untrusted callback code via then/catch/finally, which is expected for any Promise-based flow. The non-standard internals pose integration risks with native Promise semantics but do not constitute malicious behavior.

Confidence: 1.00

Severity: 0.60

From: package-lock.jsonnpm/@nomicfoundation/hardhat-mocha@3.0.15npm/workerpool@9.3.4

ℹ Read more on: This package | This alert | What is an AI-detected potential code anomaly?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: An AI system found a low-risk anomaly in this package. It may still be fine to use, but you should check that it is safe before proceeding.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/workerpool@9.3.4. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Block Low
Potential code anomaly (AI signal): npm ws is 100.0% likely to have a medium risk anomaly

Notes: The code implements a standard EventTarget-like mixin for wrapping event listeners and dispatching events to user callbacks. There are no suspicious patterns such as dynamic code execution, hardcoded secrets, or network activity. The risk is contingent on what the consumer does inside their handlers; the snippet itself does not introduce malware or data leakage mechanisms beyond normal event dispatch. Overall security risk is low in isolation.

Confidence: 1.00

Severity: 0.60

From: package-lock.jsonnpm/hardhat@3.5.0npm/ws@8.19.0

ℹ Read more on: This package | This alert | What is an AI-detected potential code anomaly?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: An AI system found a low-risk anomaly in this package. It may still be fine to use, but you should check that it is safe before proceeding.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/ws@8.19.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Block Low
Potential code anomaly (AI signal): npm zod is 100.0% likely to have a medium risk anomaly

Notes: No explicit network exfiltration, reverse shell, or credential theft is present in this fragment. However, the code assembles and compiles arbitrary code via the Function constructor and invokes passed-in functions immediately (twice). That behavior constitutes a strong dangerous primitive (arbitrary code execution) which can be abused if any inputs (strings or args) are attacker-controlled. Treat this module as risky in threat models where inputs are not fully trusted; review call sites and sanitize/validate inputs or avoid dynamic evaluation.

Confidence: 1.00

Severity: 0.60

From: package-lock.jsonnpm/@nomicfoundation/hardhat-mocha@3.0.15npm/hardhat@3.5.0npm/zod@3.25.76

ℹ Read more on: This package | This alert | What is an AI-detected potential code anomaly?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: An AI system found a low-risk anomaly in this package. It may still be fine to use, but you should check that it is safe before proceeding.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/zod@3.25.76. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

@Amxx Amxx mentioned this pull request May 22, 2026
13 tasks
Comment thread hardhat/hardhat-exposed/internal/expose.ts Fixed
@coderabbitai

coderabbitai Bot commented May 22, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

El cambio migra la configuración, helpers y suite de pruebas a Hardhat 3. Se sustituye la configuración JavaScript por hardhat.config.ts, se añaden plugins locales para contratos expuestos, helpers y transpilation, y se convierten scripts y generadores a ESM. Los workflows de CI actualizan cobertura, gas reports y checkout de submódulos. Los helpers de prueba pasan a depender de conexiones creadas con network.create(). La mayoría de pruebas JavaScript se adaptan a ese modelo, junto con cambios de matchers, utilidades de tiempo y storage, y ajustes del flujo upgradeable.

Suggested labels

tests, CI

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch hardhat3

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 9

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
test/helpers/erc7739.js (1)

42-44: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Return the connected signer from ERC7739Signer.connect

test/helpers/erc7739.js has connect(provider) calling this.#signer.connect(provider) but not returning it, so the method returns undefined and breaks AbstractSigner/signer chaining expectations (ethers’ connect returns a connected Signer).

Proposed fix
  connect(provider) {
-    this.#signer.connect(provider);
+    return new ERC7739Signer(this.#signer.connect(provider), this.#domain);
  }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/helpers/erc7739.js` around lines 42 - 44, The connect(provider) method
on ERC7739Signer currently calls this.#signer.connect(provider) but does not
return the connected signer; update ERC7739Signer.connect to return the
connected signer (i.e., return the result of this.#signer.connect(provider)) so
it matches ethers' Signer.connect chaining expectations and preserves
AbstractSigner behavior. Ensure you reference the private field `#signer` and the
connect method on ERC7739Signer when making the change.
test/helpers/signers.js (1)

194-196: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Fix deterministic signer ordering comparator in MultiERC7913SigningKey.

test/helpers/signers.js:195 subtracts two ethers.keccak256(...) hex strings, forcing JS to coerce them to Number (53-bit precision). This can produce incorrect/unstable ordering versus Solidity-style bytes32 ordering. Compare hashes as bigint instead.

Proposed fix
-    this.#signers = signers.sort(
-      (s1, s2) => ethers.keccak256(s1.bytes ?? s1.address) - ethers.keccak256(s2.bytes ?? s2.address),
-    );
+    this.#signers = signers.sort((s1, s2) => {
+      const h1 = ethers.toBigInt(ethers.keccak256(s1.bytes ?? s1.address));
+      const h2 = ethers.toBigInt(ethers.keccak256(s2.bytes ?? s2.address));
+      return h1 < h2 ? -1 : h1 > h2 ? 1 : 0;
+    });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/helpers/signers.js` around lines 194 - 196, The comparator used when
assigning this.#signers in MultiERC7913SigningKey converts ethers.keccak256(...)
hex strings to Numbers by subtraction, causing unstable ordering; change the
comparator to parse each keccak256 hex string into a BigInt (e.g. BigInt(hash))
and compare those BigInt values (return -1/0/1 or the difference as a Number
derived from the BigInt comparison) to produce a deterministic bytes32 ordering
for the signers.sort call.
🧹 Nitpick comments (8)
test/helpers/access-manager.js (1)

50-55: ⚡ Quick win

Update prepareOperation context contract in docs.

The @requires contract is stale: this function now relies on this.helpers.time (Line 54-Line 55), but that dependency is undocumented.

Proposed doc fix
 /**
- * `@requires` this.{manager, caller, target, calldata}
+ * `@requires` this.helpers.time
  */
 export async function prepareOperation(manager, { caller, target, calldata, delay }) {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/helpers/access-manager.js` around lines 50 - 55, Update the JSDoc
`@requires` for prepareOperation to mention the time helper dependency: the
function prepareOperation(manager, { caller, target, calldata, delay }) now uses
this.helpers.time (calls timestamp() and increaseTo.timestamp()), so add
this.helpers.time to the `@requires` contract alongside this.manager, this.caller,
this.target, and this.calldata to document the time helper dependency.
hardhat/hardhat-oz-contracts-helpers/hook-handlers/network.ts (1)

17-33: ⚡ Quick win

Merge existing connection.helpers instead of overwriting it.

network.ts sets helpers via Object.assign(connection, { helpers: { ... } }), which replaces any connection.helpers already present. This repo’s hardhat-oz-contracts-helpers package only writes helpers from this handler (no other in-package newConnection/helpers mutations found), but preserving existing entries is safer for hook/plugin composition.

♻️ Proposed change
 export default async (): Promise<Partial<NetworkHooks>> => ({
   newConnection: async <ChainTypeT extends ChainType | string>(
     context: HookContext,
     next: (nextContext: HookContext) => Promise<NetworkConnection<ChainTypeT>>,
   ): Promise<NetworkConnection<ChainTypeT>> =>
-    next(context).then(async connection =>
-      Object.assign(connection, {
+    next(context).then(async connection => {
+      const existingHelpers = (connection as NetworkConnection<ChainTypeT> & { helpers?: object }).helpers ?? {};
+      return Object.assign(connection, {
         helpers: {
+          ...existingHelpers,
           chain: await getLocalChain(connection.provider),
           impersonate: impersonate(connection),
           storage: {
             getSlot: getSlot(connection),
             getAddressInSlot: getAddressInSlot(connection),
             setSlot: setSlot(connection),
           },
           time: {
             clock: clock(connection),
             clockFromReceipt: clockFromReceipt(connection),
             increaseBy: increaseBy(connection),
             increaseTo: increaseTo(connection),
             duration: duration(connection),
           },
         },
-      }),
-    ),
+      });
+    }),
 });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@hardhat/hardhat-oz-contracts-helpers/hook-handlers/network.ts` around lines
17 - 33, The current Object.assign call overwrites any existing
connection.helpers; change it to merge with existing helpers instead: read the
existing connection.helpers and merge its entries with the new ones you
construct (including chain via getLocalChain(connection.provider),
impersonate(connection), storage helpers getSlot/getAddressInSlot/setSlot, and
time helpers clock/clockFromReceipt/increaseBy/increaseTo/duration) so you
preserve prior keys; update the Object.assign usage around connection.helpers
(or compute helpers = { ...connection.helpers, ...newHelpers } before assigning)
to ensure additive behavior without removing existing helper entries.
test/metatx/ERC2771Forwarder.test.js (1)

148-163: ⚡ Quick win

Add explicit no-balance-change assertions on revert paths.

These OOG/revert-path tests should also assert that no unintended ether transfer happened (e.g., to.not.changeEtherBalances(...)) in addition to revert and gas checks.

Based on learnings: In tests that exercise revert semantics, use negative balance assertions to verify no ether balance changes occurred.

Also applies to: 165-193, 347-367, 369-398

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/metatx/ERC2771Forwarder.test.js` around lines 148 - 163, Add explicit
assertions that no ether balances changed when the calls revert: in the 'bubbles
out of gas' test (the it block invoking this.forgeRequest with
this.receiver.interface.encodeFunctionData('mockFunctionOutOfGas') and executing
via this.forwarder.execute) wrap the failing call in a balance-check assertion
to assert no balances changed (e.g., use the test helper
expect(...).to.not.changeEtherBalances or equivalent) for the
relayer/sender/receiver addresses; apply the same pattern to the other
OOG/revert-path tests mentioned (the blocks at 165-193, 347-367, 369-398) to
ensure each revert path includes a no-balance-change assertion alongside the
revert and gas checks.
test/helpers/storage.js (1)

36-40: 💤 Low value

Silent error swallowing may hide unexpected failures.

The .then(..., () => offset) pattern catches all errors from readArtifact, not just "artifact not found". If readArtifact fails for another reason (e.g., malformed artifact JSON, filesystem permission error), it will silently return offset instead of surfacing the actual problem.

Consider narrowing the catch to artifact-not-found scenarios if the API provides a specific error type.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/helpers/storage.js` around lines 36 - 40, The current upgradeableSlot
helper swallows any readArtifact error by using the second .then handler; change
this to explicitly handle only the "artifact not found" case and rethrow other
errors. Replace the dual-argument .then with a single .then + .catch on
artifacts.readArtifact in the upgradeableSlot function, and in the .catch
inspect the thrown error (e.g., check a specific error.code or error.message
pattern like /artifact not found/i) to return offset only for that case and
rethrow the error for all other failures so unexpected issues (malformed JSON,
permission errors) surface.
hardhat/hardhat-transpiler/tasks/transpile.ts (2)

20-23: 💤 Low value

Minor typo in comment.

"key the keys intact" should be "keep the keys intact".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@hardhat/hardhat-transpiler/tasks/transpile.ts` around lines 20 - 23, The
comment above function transformKeys contains a typo ("key the keys intact");
update the comment to read "keep the keys intact" so it accurately describes the
function behavior; locate the comment immediately above transformKeys and
replace the erroneous phrase while leaving the rest of the comment and the
function signature unchanged.

48-55: ⚡ Quick win

Non-null assertions may cause runtime crashes if build info paths are missing.

The ! non-null assertion operator is used on file returned by getBuildInfoPath and getBuildInfoOutputPath. If a build ID exists in cacheHits but its build info file is missing or the path returns undefined, this will throw an unhelpful error when trying to read undefined.

Consider adding explicit null checks with descriptive error messages:

🛡️ Suggested defensive handling
-    const { input, solcVersion } = await hre.artifacts
-      .getBuildInfoPath(buildId)
-      .then(file => fs.readFile(file!, 'utf-8'))
-      .then(JSON.parse);
-    const { output } = await hre.artifacts
-      .getBuildInfoOutputPath(buildId)
-      .then(file => fs.readFile(file!, 'utf-8'))
-      .then(JSON.parse);
+    const buildInfoPath = await hre.artifacts.getBuildInfoPath(buildId);
+    assert(buildInfoPath, `Build info path not found for buildId: ${buildId}`);
+    const { input, solcVersion } = JSON.parse(await fs.readFile(buildInfoPath, 'utf-8'));
+
+    const buildInfoOutputPath = await hre.artifacts.getBuildInfoOutputPath(buildId);
+    assert(buildInfoOutputPath, `Build info output path not found for buildId: ${buildId}`);
+    const { output } = JSON.parse(await fs.readFile(buildInfoOutputPath, 'utf-8'));
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@hardhat/hardhat-transpiler/tasks/transpile.ts` around lines 48 - 55, The
non-null assertions on the results of hre.artifacts.getBuildInfoPath(...) and
getBuildInfoOutputPath(...) can crash if they return undefined; update
transpile.ts to explicitly check the returned paths (from getBuildInfoPath and
getBuildInfoOutputPath) before calling fs.readFile, and throw or log a
descriptive error (including the buildId) if a path is undefined or the file is
missing; locate the code using symbols getBuildInfoPath, getBuildInfoOutputPath,
and the variables input/solcVersion/output and perform early null/exists checks
(fs.existsSync or try/catch around fs.readFile) so you read only valid file
paths and provide helpful error messages instead of relying on the `!` operator.
test/account/extensions/ERC7821.behavior.js (1)

53-53: ⚡ Quick win

Use 0n for the EntryPoint nonce equality check (consistency)
The nonce getters in this file are already asserted with equal(0) / equal(1) elsewhere, so the current test is likely fine; switching this one to 0n is an optional consistency improvement and aligns with other bigint-based nonce assertions in the suite.

Proposed fix
-          await expect(this.ethers.predeploy.entrypoint.v09.getNonce(this.mock.target, 0)).to.eventually.equal(0);
+          await expect(this.ethers.predeploy.entrypoint.v09.getNonce(this.mock.target, 0)).to.eventually.equal(0n);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/account/extensions/ERC7821.behavior.js` at line 53, The test uses a
number literal when asserting the EntryPoint nonce; change the assertion to use
a bigint for consistency by comparing the result of
this.ethers.predeploy.entrypoint.v09.getNonce(this.mock.target, 0) against 0n
instead of 0 so it matches other bigint nonce assertions in the suite (look for
getNonce and this.ethers.predeploy.entrypoint.v09 in the test).
test/utils/Context.behavior.js (1)

3-3: 💤 Low value

Unnecessary async keyword.

The function shouldBehaveLikeRegularContext is marked async but contains no await statements. The function body only has synchronous describe blocks. Consider removing the async keyword for clarity.

♻️ Proposed fix
-export async function shouldBehaveLikeRegularContext() {
+export function shouldBehaveLikeRegularContext() {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/utils/Context.behavior.js` at line 3, The function
shouldBehaveLikeRegularContext is erroneously declared async despite having no
await usage; remove the async keyword from its declaration so the function is a
plain synchronous function (locate the declaration "export async function
shouldBehaveLikeRegularContext()" and change it to "export function
shouldBehaveLikeRegularContext()") to make intent clearer and avoid misleading
callers.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/checks.yml:
- Around line 106-108: The checkout step using actions/checkout@v6 currently
allows credential persistence; update the harnesses checkout step to explicitly
set persist-credentials: false so the workflow auth token is not carried forward
to subsequent git commands. Locate the step that uses actions/checkout@v6 (the
harnesses checkout) and add the persist-credentials: false key under its with:
block to disable token persistence.

In `@hardhat/hardhat-exposed/internal/expose.ts`:
- Around line 564-596: The switch on typeName.nodeType contains const bindings
(e.g., typeString, typeDef) that can leak across cases; wrap each case's
statements in a block scope { ... } so declarations like "const { typeString } =
typeName.typeDescriptions;" and "const typeDef = derefUserDefinedTypeName(...)"
are scoped to their case, including nested switch cases for typeDef.nodeType and
their own consts (e.g., the inner "const { typeString } =
typeDef.underlyingType.typeDescriptions;"), and ensure the default case and any
returns remain inside their respective blocks.

In `@hardhat/hardhat-exposed/tasks/generate-exposed-contracts.ts`:
- Around line 28-29: Replace string prefixes checks that use
rootPath.startsWith(hre.config.exposed.outDir) with a path-safe containment
test: resolve/normalize both rootPath and hre.config.exposed.outDir (use
path.resolve/path.normalize) and then use path.relative to determine if rootPath
is inside outDir (i.e., path.relative(outDirResolved, rootPathResolved) does not
start with '..' and is not equal to ''). Update all occurrences of this pattern
(the checks referencing rootPath and hre.config.exposed.outDir around the
current uses in generate-exposed-contracts.ts at the three spots flagged) so
they work correctly for absolute/relative paths and different path separators.

In `@scripts/checks/compare-gas-reports.js`:
- Around line 57-63: The static compare method can throw when update.contracts
or ref.contracts are missing; modify Report.compare (the static compare(update,
ref, opts) function) to guard those fields by defaulting update.contracts and
ref.contracts to {} (or returning an empty array early) before using
Object.entries and .filter; update references to update.contracts and
ref.contracts in this method so they are safely accessed (e.g., const uContracts
= update.contracts ?? {}; const rContracts = ref.contracts ?? {}) and then
operate on uContracts and rContracts in the existing logic.

In `@scripts/checks/inheritance-ordering.js`:
- Around line 28-29: The current check uses micromatch.all which requires the
input to match every pattern and breaks npm-style include/exclude semantics;
change the conditional that reads if (match.all(source.replace(/^project/, ''),
patterns)) to use match.isMatch(source.replace(/^project/, ''), patterns) so
that files are accepted if any include glob matches and negations (!) act as
exclusions; update any import/usage comments around this check (the loop over
findAll('ContractDefinition', solcOutput.sources[source].ast)) to reflect the
corrected matching behavior.

In `@scripts/solc-versions.js`:
- Around line 9-14: The compile function currently uses child_process.exec with
shell-interpolated command (`exec(\`forge build ${source} --use ${version} --out
...\`)`) which allows shell injection from values returned by
getContractsMetadata(); change compile to call a non-shell API
(child_process.execFile or child_process.spawn) with the command and an args
array (e.g., ['build', source, '--use', version, '--out',
`out/solc-${version}`]) so no shell interpolation occurs, preserve the
Promise-based resolve/reject behavior and existing error handling, and keep the
function name compile as the same exported symbol.

In `@scripts/upgradeable/transpile.sh`:
- Line 16: The npx hardhat transpile invocation uses --settings
$DIRNAME/transpile.config.json without quotes which can break on paths with
spaces or special chars; update the command in scripts/upgradeable/transpile.sh
(the line calling npx hardhat transpile --settings ...) to wrap the settings
path in double quotes (e.g., "--settings \"$DIRNAME/transpile.config.json\"") so
the shell treats it as a single argument referencing the $DIRNAME variable
correctly.

In `@test/account/utils/draft-ERC4337Utils.test.js`:
- Line 447: The test suite callback for describe('hash', async function () { is
incorrectly marked async; remove the async modifier from the describe callback
so the suite definition is synchronous, and move any asynchronous logic inside
this suite into individual it(...) tests or into Mocha hooks (before,
beforeEach, after, afterEach) as needed; locate the describe call in
draft-ERC4337Utils.test (the 'hash' suite) and change its signature to
describe('hash', function () { while relocating any await usage into the
appropriate it or hook functions (e.g., before(async () => { ... }) or it('...',
async function () { ... }).

In `@test/utils/cryptography/RSA.helper.js`:
- Line 5: The helper currently calls fs.readFileSync(file, 'utf8') directly
which makes parse() sensitive to the test runner CWD; update the parse function
in RSA.helper.js to detect non-absolute file paths and resolve them relative to
the helper module directory using import.meta.url and fileURLToPath (e.g.,
compute moduleDir = path.dirname(fileURLToPath(import.meta.url)) and join with
the passed file), then call fs.readFileSync on the resolved path (references:
parse function, fs.readFileSync call, variable/data reading).

---

Outside diff comments:
In `@test/helpers/erc7739.js`:
- Around line 42-44: The connect(provider) method on ERC7739Signer currently
calls this.#signer.connect(provider) but does not return the connected signer;
update ERC7739Signer.connect to return the connected signer (i.e., return the
result of this.#signer.connect(provider)) so it matches ethers' Signer.connect
chaining expectations and preserves AbstractSigner behavior. Ensure you
reference the private field `#signer` and the connect method on ERC7739Signer when
making the change.

In `@test/helpers/signers.js`:
- Around line 194-196: The comparator used when assigning this.#signers in
MultiERC7913SigningKey converts ethers.keccak256(...) hex strings to Numbers by
subtraction, causing unstable ordering; change the comparator to parse each
keccak256 hex string into a BigInt (e.g. BigInt(hash)) and compare those BigInt
values (return -1/0/1 or the difference as a Number derived from the BigInt
comparison) to produce a deterministic bytes32 ordering for the signers.sort
call.

---

Nitpick comments:
In `@hardhat/hardhat-oz-contracts-helpers/hook-handlers/network.ts`:
- Around line 17-33: The current Object.assign call overwrites any existing
connection.helpers; change it to merge with existing helpers instead: read the
existing connection.helpers and merge its entries with the new ones you
construct (including chain via getLocalChain(connection.provider),
impersonate(connection), storage helpers getSlot/getAddressInSlot/setSlot, and
time helpers clock/clockFromReceipt/increaseBy/increaseTo/duration) so you
preserve prior keys; update the Object.assign usage around connection.helpers
(or compute helpers = { ...connection.helpers, ...newHelpers } before assigning)
to ensure additive behavior without removing existing helper entries.

In `@hardhat/hardhat-transpiler/tasks/transpile.ts`:
- Around line 20-23: The comment above function transformKeys contains a typo
("key the keys intact"); update the comment to read "keep the keys intact" so it
accurately describes the function behavior; locate the comment immediately above
transformKeys and replace the erroneous phrase while leaving the rest of the
comment and the function signature unchanged.
- Around line 48-55: The non-null assertions on the results of
hre.artifacts.getBuildInfoPath(...) and getBuildInfoOutputPath(...) can crash if
they return undefined; update transpile.ts to explicitly check the returned
paths (from getBuildInfoPath and getBuildInfoOutputPath) before calling
fs.readFile, and throw or log a descriptive error (including the buildId) if a
path is undefined or the file is missing; locate the code using symbols
getBuildInfoPath, getBuildInfoOutputPath, and the variables
input/solcVersion/output and perform early null/exists checks (fs.existsSync or
try/catch around fs.readFile) so you read only valid file paths and provide
helpful error messages instead of relying on the `!` operator.

In `@test/account/extensions/ERC7821.behavior.js`:
- Line 53: The test uses a number literal when asserting the EntryPoint nonce;
change the assertion to use a bigint for consistency by comparing the result of
this.ethers.predeploy.entrypoint.v09.getNonce(this.mock.target, 0) against 0n
instead of 0 so it matches other bigint nonce assertions in the suite (look for
getNonce and this.ethers.predeploy.entrypoint.v09 in the test).

In `@test/helpers/access-manager.js`:
- Around line 50-55: Update the JSDoc `@requires` for prepareOperation to mention
the time helper dependency: the function prepareOperation(manager, { caller,
target, calldata, delay }) now uses this.helpers.time (calls timestamp() and
increaseTo.timestamp()), so add this.helpers.time to the `@requires` contract
alongside this.manager, this.caller, this.target, and this.calldata to document
the time helper dependency.

In `@test/helpers/storage.js`:
- Around line 36-40: The current upgradeableSlot helper swallows any
readArtifact error by using the second .then handler; change this to explicitly
handle only the "artifact not found" case and rethrow other errors. Replace the
dual-argument .then with a single .then + .catch on artifacts.readArtifact in
the upgradeableSlot function, and in the .catch inspect the thrown error (e.g.,
check a specific error.code or error.message pattern like /artifact not found/i)
to return offset only for that case and rethrow the error for all other failures
so unexpected issues (malformed JSON, permission errors) surface.

In `@test/metatx/ERC2771Forwarder.test.js`:
- Around line 148-163: Add explicit assertions that no ether balances changed
when the calls revert: in the 'bubbles out of gas' test (the it block invoking
this.forgeRequest with
this.receiver.interface.encodeFunctionData('mockFunctionOutOfGas') and executing
via this.forwarder.execute) wrap the failing call in a balance-check assertion
to assert no balances changed (e.g., use the test helper
expect(...).to.not.changeEtherBalances or equivalent) for the
relayer/sender/receiver addresses; apply the same pattern to the other
OOG/revert-path tests mentioned (the blocks at 165-193, 347-367, 369-398) to
ensure each revert path includes a no-balance-change assertion alongside the
revert and gas checks.

In `@test/utils/Context.behavior.js`:
- Line 3: The function shouldBehaveLikeRegularContext is erroneously declared
async despite having no await usage; remove the async keyword from its
declaration so the function is a plain synchronous function (locate the
declaration "export async function shouldBehaveLikeRegularContext()" and change
it to "export function shouldBehaveLikeRegularContext()") to make intent clearer
and avoid misleading callers.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: cd7b305b-75b6-4121-92e4-70e235276661

📥 Commits

Reviewing files that changed from the base of the PR and between cd05883 and fe1f223.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (288)
  • .changeset/spotty-teeth-show.md
  • .codecov.yml
  • .github/actions/gas-compare/action.yml
  • .github/actions/setup/action.yml
  • .github/actions/storage-layout/action.yml
  • .github/workflows/checks.yml
  • .github/workflows/formal-verification.yml
  • foundry.toml
  • hardhat.config.js
  • hardhat.config.ts
  • hardhat/env-artifacts.js
  • hardhat/hardhat-exposed/hook-handlers/clean.ts
  • hardhat/hardhat-exposed/hook-handlers/config.ts
  • hardhat/hardhat-exposed/internal/build-info.ts
  • hardhat/hardhat-exposed/internal/expose.ts
  • hardhat/hardhat-exposed/internal/format-lines.ts
  • hardhat/hardhat-exposed/internal/types.ts
  • hardhat/hardhat-exposed/plugin.ts
  • hardhat/hardhat-exposed/tasks/build.ts
  • hardhat/hardhat-exposed/tasks/generate-exposed-contracts.ts
  • hardhat/hardhat-exposed/type-extensions.ts
  • hardhat/hardhat-oz-contracts-helpers/hook-handlers/hre.ts
  • hardhat/hardhat-oz-contracts-helpers/hook-handlers/network.ts
  • hardhat/hardhat-oz-contracts-helpers/hook-handlers/test.ts
  • hardhat/hardhat-oz-contracts-helpers/plugin.ts
  • hardhat/hardhat-oz-contracts-helpers/type-extensions.ts
  • hardhat/hardhat-transpiler/plugin.ts
  • hardhat/hardhat-transpiler/tasks/transpile.ts
  • hardhat/ignore-unreachable-warnings.js
  • hardhat/remappings.js
  • hardhat/skip-foundry-tests.js
  • hardhat/task-test-get-files.js
  • package.json
  • remappings.txt
  • scripts/checks/compare-gas-reports.js
  • scripts/checks/compare-layout.js
  • scripts/checks/coverage.sh
  • scripts/checks/extract-layout.js
  • scripts/checks/inheritance-ordering.js
  • scripts/checks/pragma-validity.js
  • scripts/fetch-common-contracts.js
  • scripts/generate/format-lines.js
  • scripts/generate/helpers/sanitize.js
  • scripts/generate/run.js
  • scripts/generate/templates/Arrays.js
  • scripts/generate/templates/Arrays.opts.js
  • scripts/generate/templates/Checkpoints.js
  • scripts/generate/templates/Checkpoints.opts.js
  • scripts/generate/templates/Checkpoints.t.js
  • scripts/generate/templates/Enumerable.opts.js
  • scripts/generate/templates/EnumerableMap.js
  • scripts/generate/templates/EnumerableSet.js
  • scripts/generate/templates/MerkleProof.js
  • scripts/generate/templates/MerkleProof.opts.js
  • scripts/generate/templates/Packing.js
  • scripts/generate/templates/Packing.opts.js
  • scripts/generate/templates/Packing.t.js
  • scripts/generate/templates/SafeCast.js
  • scripts/generate/templates/Slot.opts.js
  • scripts/generate/templates/SlotDerivation.js
  • scripts/generate/templates/SlotDerivation.t.js
  • scripts/generate/templates/StorageSlot.js
  • scripts/generate/templates/StorageSlotMock.js
  • scripts/generate/templates/TransientSlot.js
  • scripts/generate/templates/TransientSlotMock.js
  • scripts/generate/templates/conversion.js
  • scripts/get-contracts-metadata.js
  • scripts/helpers.js
  • scripts/minimize-pragma.js
  • scripts/prepack.sh
  • scripts/remove-ignored-artifacts.js
  • scripts/solc-versions.js
  • scripts/upgradeable/transpile.config.json
  • scripts/upgradeable/transpile.sh
  • scripts/upgradeable/upgradeable.patch
  • solhint.config.cjs
  • test/access/AccessControl.behavior.js
  • test/access/AccessControl.test.js
  • test/access/Ownable.test.js
  • test/access/Ownable2Step.test.js
  • test/access/extensions/AccessControlDefaultAdminRules.test.js
  • test/access/extensions/AccessControlEnumerable.test.js
  • test/access/manager/AccessManaged.test.js
  • test/access/manager/AccessManager.behavior.js
  • test/access/manager/AccessManager.predicate.js
  • test/access/manager/AccessManager.test.js
  • test/access/manager/AuthorityUtils.test.js
  • test/account/Account.behavior.js
  • test/account/Account.test.js
  • test/account/AccountECDSA.test.js
  • test/account/AccountEIP7702.t.sol
  • test/account/AccountEIP7702.test.js
  • test/account/AccountERC7913.test.js
  • test/account/AccountMultiSigner.test.js
  • test/account/AccountMultiSignerWeighted.test.js
  • test/account/AccountP256.test.js
  • test/account/AccountRSA.test.js
  • test/account/AccountWebAuthn.test.js
  • test/account/examples/AccountEIP7702WithModulesMock.test.js
  • test/account/extensions/AccountERC7579.behavior.js
  • test/account/extensions/AccountERC7579.test.js
  • test/account/extensions/AccountERC7579Hooked.test.js
  • test/account/extensions/ERC7821.behavior.js
  • test/account/utils/EIP7702Utils.test.js
  • test/account/utils/draft-ERC4337Utils.test.js
  • test/account/utils/draft-ERC7579Utils.t.sol
  • test/account/utils/draft-ERC7579Utils.test.js
  • test/crosschain/BridgeERC1155.behavior.js
  • test/crosschain/BridgeERC1155.test.js
  • test/crosschain/BridgeERC20.behavior.js
  • test/crosschain/BridgeERC20.test.js
  • test/crosschain/BridgeERC721.behavior.js
  • test/crosschain/BridgeERC721.test.js
  • test/crosschain/CrosschainExecutor.test.js
  • test/crosschain/ERC7786Recipient.test.js
  • test/finance/VestingWallet.behavior.js
  • test/finance/VestingWallet.test.js
  • test/finance/VestingWalletCliff.test.js
  • test/governance/Governor.test.js
  • test/governance/TimelockController.test.js
  • test/governance/extensions/GovernorCountingFractional.test.js
  • test/governance/extensions/GovernorCountingOverridable.test.js
  • test/governance/extensions/GovernorCrosschain.test.js
  • test/governance/extensions/GovernorERC721.test.js
  • test/governance/extensions/GovernorNoncesKeyed.test.js
  • test/governance/extensions/GovernorPreventLateQuorum.test.js
  • test/governance/extensions/GovernorProposalGuardian.test.js
  • test/governance/extensions/GovernorSequentialProposalId.test.js
  • test/governance/extensions/GovernorStorage.test.js
  • test/governance/extensions/GovernorSuperQuorum.test.js
  • test/governance/extensions/GovernorSuperQuorumGreaterThanQuorum.t.sol
  • test/governance/extensions/GovernorTimelockAccess.test.js
  • test/governance/extensions/GovernorTimelockCompound.test.js
  • test/governance/extensions/GovernorTimelockControl.test.js
  • test/governance/extensions/GovernorVotesQuorumFraction.test.js
  • test/governance/extensions/GovernorVotesSuperQuorumFraction.test.js
  • test/governance/extensions/GovernorWithParams.test.js
  • test/governance/utils/ERC6372.behavior.js
  • test/governance/utils/Votes.behavior.js
  • test/governance/utils/Votes.test.js
  • test/governance/utils/VotesExtended.test.js
  • test/helpers/access-manager.js
  • test/helpers/account.js
  • test/helpers/chains.js
  • test/helpers/constants.js
  • test/helpers/deploy.js
  • test/helpers/eip712-types.js
  • test/helpers/eip712.js
  • test/helpers/enums.js
  • test/helpers/erc4337.js
  • test/helpers/erc7579.js
  • test/helpers/erc7739.js
  • test/helpers/governance.js
  • test/helpers/iterate.js
  • test/helpers/math.js
  • test/helpers/methods.js
  • test/helpers/precompiles.js
  • test/helpers/random.js
  • test/helpers/signers.js
  • test/helpers/storage.js
  • test/helpers/strings.js
  • test/helpers/time.js
  • test/helpers/trie.js
  • test/helpers/txpool.js
  • test/metatx/ERC2771Context.test.js
  • test/metatx/ERC2771Forwarder.t.sol
  • test/metatx/ERC2771Forwarder.test.js
  • test/proxy/Clones.behaviour.js
  • test/proxy/Clones.t.sol
  • test/proxy/Clones.test.js
  • test/proxy/ERC1967/ERC1967Proxy.test.js
  • test/proxy/ERC1967/ERC1967Utils.test.js
  • test/proxy/Proxy.behaviour.js
  • test/proxy/beacon/BeaconProxy.test.js
  • test/proxy/beacon/UpgradeableBeacon.test.js
  • test/proxy/transparent/ProxyAdmin.test.js
  • test/proxy/transparent/TransparentUpgradeableProxy.behaviour.js
  • test/proxy/transparent/TransparentUpgradeableProxy.test.js
  • test/proxy/utils/Initializable.test.js
  • test/proxy/utils/UUPSUpgradeable.test.js
  • test/sanity.test.js
  • test/token/ERC1155/ERC1155.behavior.js
  • test/token/ERC1155/ERC1155.test.js
  • test/token/ERC1155/extensions/ERC1155Burnable.test.js
  • test/token/ERC1155/extensions/ERC1155Crosschain.test.js
  • test/token/ERC1155/extensions/ERC1155Pausable.test.js
  • test/token/ERC1155/extensions/ERC1155Supply.test.js
  • test/token/ERC1155/extensions/ERC1155URIStorage.test.js
  • test/token/ERC1155/utils/ERC1155Holder.test.js
  • test/token/ERC1155/utils/ERC1155Utils.test.js
  • test/token/ERC20/ERC20.behavior.js
  • test/token/ERC20/ERC20.test.js
  • test/token/ERC20/extensions/ERC1363.test.js
  • test/token/ERC20/extensions/ERC20Burnable.test.js
  • test/token/ERC20/extensions/ERC20Capped.test.js
  • test/token/ERC20/extensions/ERC20Crosschain.test.js
  • test/token/ERC20/extensions/ERC20FlashMint.test.js
  • test/token/ERC20/extensions/ERC20Pausable.test.js
  • test/token/ERC20/extensions/ERC20Permit.test.js
  • test/token/ERC20/extensions/ERC20Votes.test.js
  • test/token/ERC20/extensions/ERC20Wrapper.test.js
  • test/token/ERC20/extensions/ERC4626.test.js
  • test/token/ERC20/extensions/draft-ERC20Bridgeable.test.js
  • test/token/ERC20/extensions/draft-ERC20TemporaryApproval.test.js
  • test/token/ERC20/utils/SafeERC20.test.js
  • test/token/ERC6909/ERC6909.behavior.js
  • test/token/ERC6909/ERC6909.test.js
  • test/token/ERC6909/extensions/ERC6909ContentURI.test.js
  • test/token/ERC6909/extensions/ERC6909Metadata.test.js
  • test/token/ERC6909/extensions/ERC6909TokenSupply.test.js
  • test/token/ERC721/ERC721.behavior.js
  • test/token/ERC721/ERC721.test.js
  • test/token/ERC721/ERC721Enumerable.test.js
  • test/token/ERC721/extensions/ERC721Burnable.test.js
  • test/token/ERC721/extensions/ERC721Consecutive.test.js
  • test/token/ERC721/extensions/ERC721Crosschain.test.js
  • test/token/ERC721/extensions/ERC721Pausable.test.js
  • test/token/ERC721/extensions/ERC721Royalty.test.js
  • test/token/ERC721/extensions/ERC721URIStorage.test.js
  • test/token/ERC721/extensions/ERC721Votes.test.js
  • test/token/ERC721/extensions/ERC721Wrapper.test.js
  • test/token/ERC721/utils/ERC721Holder.test.js
  • test/token/ERC721/utils/ERC721Utils.test.js
  • test/token/common/ERC2981.behavior.js
  • test/utils/Address.test.js
  • test/utils/Arrays.test.js
  • test/utils/Base58.test.js
  • test/utils/Base64.test.js
  • test/utils/Blockhash.t.sol
  • test/utils/Blockhash.test.js
  • test/utils/Bytes.test.js
  • test/utils/CAIP.test.js
  • test/utils/Calldata.test.js
  • test/utils/Context.behavior.js
  • test/utils/Context.test.js
  • test/utils/Create2.test.js
  • test/utils/Create3.test.js
  • test/utils/ERC6372Utils.test.js
  • test/utils/LowLevelCall.test.js
  • test/utils/Memory.test.js
  • test/utils/Multicall.test.js
  • test/utils/Nonces.behavior.js
  • test/utils/Nonces.test.js
  • test/utils/NoncesKeyed.test.js
  • test/utils/Packing.test.js
  • test/utils/Panic.test.js
  • test/utils/Pausable.test.js
  • test/utils/RLP.test.js
  • test/utils/ReentrancyGuard.test.js
  • test/utils/RelayedCall.test.js
  • test/utils/ShortStrings.test.js
  • test/utils/SimulatedCall.test.js
  • test/utils/SlotDerivation.test.js
  • test/utils/StorageSlot.test.js
  • test/utils/Strings.test.js
  • test/utils/TransientSlot.test.js
  • test/utils/cryptography/ECDSA.test.js
  • test/utils/cryptography/EIP712.test.js
  • test/utils/cryptography/ERC1271.behavior.js
  • test/utils/cryptography/ERC7739.test.js
  • test/utils/cryptography/ERC7739Utils.test.js
  • test/utils/cryptography/MerkleProof.test.js
  • test/utils/cryptography/MessageHashUtils.test.js
  • test/utils/cryptography/P256.test.js
  • test/utils/cryptography/RSA.helper.js
  • test/utils/cryptography/RSA.test.js
  • test/utils/cryptography/SignatureChecker.test.js
  • test/utils/cryptography/TrieProof.test.js
  • test/utils/draft-InteroperableAddress.t.sol
  • test/utils/draft-InteroperableAddress.test.js
  • test/utils/introspection/ERC165.test.js
  • test/utils/introspection/ERC165Checker.test.js
  • test/utils/introspection/SupportsInterface.behavior.js
  • test/utils/math/Math.test.js
  • test/utils/math/SafeCast.test.js
  • test/utils/math/SignedMath.t.sol
  • test/utils/math/SignedMath.test.js
  • test/utils/structs/BitMap.test.js
  • test/utils/structs/Checkpoints.test.js
  • test/utils/structs/CircularBuffer.test.js
  • test/utils/structs/DoubleEndedQueue.test.js
  • test/utils/structs/EnumerableMap.behavior.js
  • test/utils/structs/EnumerableMap.test.js
  • test/utils/structs/EnumerableSet.behavior.js
  • test/utils/structs/EnumerableSet.test.js
  • test/utils/structs/Heap.test.js
  • test/utils/structs/MerkleTree.test.js
  • test/utils/types/Time.test.js
💤 Files with no reviewable changes (12)
  • test/helpers/deploy.js
  • scripts/fetch-common-contracts.js
  • scripts/checks/coverage.sh
  • hardhat/skip-foundry-tests.js
  • test/account/AccountEIP7702.t.sol
  • foundry.toml
  • hardhat/ignore-unreachable-warnings.js
  • hardhat/remappings.js
  • hardhat.config.js
  • hardhat/task-test-get-files.js
  • hardhat/env-artifacts.js
  • scripts/prepack.sh

Comment on lines 106 to +108
- uses: actions/checkout@v6
with:
submodules: recursive

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find the workflow file
ls -la .github/workflows || true
sed -n '1,220p' .github/workflows/checks.yml | nl -ba | sed -n '80,140p'

# Confirm whether persist-credentials is present anywhere in the file
rg -n "persist-credentials" .github/workflows/checks.yml || true

# Confirm the exact checkout step under "harnesses"
# Print a wider window around the "harnesses" job definition if present
rg -n "^[[:space:]]*harnesses:" .github/workflows/checks.yml || true

Repository: OpenZeppelin/openzeppelin-contracts

Length of output: 775


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Show checks.yml with line numbers around the referenced range (106-108)
awk 'NR>=90 && NR<=130 {printf "%4d:%s\n", NR, $0}' .github/workflows/checks.yml

# Confirm whether persist-credentials is present anywhere in the file
echo "---- persist-credentials matches ----"
rg -n "persist-credentials" .github/workflows/checks.yml || true

# Print the harnesses job section header(s) if present
echo "---- harnesses job matches ----"
rg -n "^[[:space:]]*harnesses:" .github/workflows/checks.yml || true

Repository: OpenZeppelin/openzeppelin-contracts

Length of output: 1418


🌐 Web query:

actions/checkout v6 persist-credentials default value and behavior local git config

💡 Result:

For actions/checkout v6, the input persist-credentials default is effectively true (it’s documented as “Default: true” when configured/unspecified) and it persists the authentication token for later git commands during the job (it’s removed during post-job cleanup). [1][2] Local git config behavior (v6): - The token is persisted in the local git configuration so that subsequent steps can run authenticated git commands (e.g., additional git fetch/push). [1] - In v6, GitHub notes an improvement: persist-credentials stores credentials in a separate file under $RUNNER_TEMP instead of directly in.git/config, and it requires Actions Runner v2.329.0+ for Docker-container action scenarios. [1][3] Opt-out: - Set persist-credentials: false to avoid persisting the token. [1] Practical implication: - If you use actions/checkout v6 with persist-credentials not set (or left at its default), authenticated credentials are available for subsequent git commands in the job, but they should not remain after the job ends (post-job cleanup removes them). [1][2]

Citations:


Disable credential persistence in the harnesses checkout step.

actions/checkout@v6 persists the workflow auth token by default (persist-credentials: true) so subsequent git commands in the same job can use it; add persist-credentials: false to avoid carrying the token forward (the token is later cleaned up after the job).

🔐 Suggested hardening
   harnesses:
 @@
       - uses: actions/checkout@v6
         with:
           submodules: recursive
+          persist-credentials: false
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- uses: actions/checkout@v6
with:
submodules: recursive
- uses: actions/checkout@v6
with:
submodules: recursive
persist-credentials: false
🧰 Tools
🪛 zizmor (1.25.2)

[warning] 106-108: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false

(artipacked)


[error] 106-106: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)

(unpinned-uses)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/checks.yml around lines 106 - 108, The checkout step using
actions/checkout@v6 currently allows credential persistence; update the
harnesses checkout step to explicitly set persist-credentials: false so the
workflow auth token is not carried forward to subsequent git commands. Locate
the step that uses actions/checkout@v6 (the harnesses checkout) and add the
persist-credentials: false key under its with: block to disable token
persistence.

Comment on lines +564 to +596
switch (typeName.nodeType) {
case 'ElementaryTypeName':
case 'ArrayTypeName':
const { typeString } = typeName.typeDescriptions;
assert(typeString != undefined);
return typeString;

case 'UserDefinedTypeName':
const typeDef = derefUserDefinedTypeName(deref, typeName);
switch (typeDef.nodeType) {
case 'UserDefinedValueTypeDefinition':
const { typeString } = typeDef.underlyingType.typeDescriptions;
assert(typeString != undefined);
return typeString;

case 'EnumDefinition':
assert(typeDef.members.length < 256);
return 'uint8';

case 'ContractDefinition':
return 'address';

case 'StructDefinition':
if (location === 'storage') {
throw new Error('Unexpected error'); // is treated separately in getFunctionArguments
} else {
return '(' + typeDef.members.map(v => getVarAbiType(v, context, deref, location)).join(',') + ')';
}
}

default:
throw new Error('Unknown ABI type');
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Wrap switch case declarations in blocks to prevent variable leakage.

Static analysis correctly flags that const declarations in switch cases without block scoping can be accessed erroneously from other cases. Wrap each case body in braces.

🛡️ Proposed fix
 function getAbiType(
   typeName: TypeName,
   context: ContractDefinition,
   deref: ASTDereferencer,
   location: StorageLocation | null,
 ): string {
   switch (typeName.nodeType) {
-    case 'ElementaryTypeName':
-    case 'ArrayTypeName':
-      const { typeString } = typeName.typeDescriptions;
-      assert(typeString != undefined);
-      return typeString;
-
-    case 'UserDefinedTypeName':
-      const typeDef = derefUserDefinedTypeName(deref, typeName);
-      switch (typeDef.nodeType) {
-        case 'UserDefinedValueTypeDefinition':
-          const { typeString } = typeDef.underlyingType.typeDescriptions;
-          assert(typeString != undefined);
-          return typeString;
-
-        case 'EnumDefinition':
-          assert(typeDef.members.length < 256);
-          return 'uint8';
-
-        case 'ContractDefinition':
-          return 'address';
-
-        case 'StructDefinition':
-          if (location === 'storage') {
-            throw new Error('Unexpected error'); // is treated separately in getFunctionArguments
-          } else {
-            return '(' + typeDef.members.map(v => getVarAbiType(v, context, deref, location)).join(',') + ')';
-          }
-      }
-
-    default:
-      throw new Error('Unknown ABI type');
+    case 'ElementaryTypeName':
+    case 'ArrayTypeName': {
+      const { typeString } = typeName.typeDescriptions;
+      assert(typeString != undefined);
+      return typeString;
+    }
+
+    case 'UserDefinedTypeName': {
+      const typeDef = derefUserDefinedTypeName(deref, typeName);
+      switch (typeDef.nodeType) {
+        case 'UserDefinedValueTypeDefinition': {
+          const { typeString } = typeDef.underlyingType.typeDescriptions;
+          assert(typeString != undefined);
+          return typeString;
+        }
+
+        case 'EnumDefinition':
+          assert(typeDef.members.length < 256);
+          return 'uint8';
+
+        case 'ContractDefinition':
+          return 'address';
+
+        case 'StructDefinition':
+          if (location === 'storage') {
+            throw new Error('Unexpected error');
+          } else {
+            return '(' + typeDef.members.map(v => getVarAbiType(v, context, deref, location)).join(',') + ')';
+          }
+      }
+    }
+    // falls through if inner switch doesn't return
+
+    default:
+      throw new Error('Unknown ABI type');
   }
 }
🧰 Tools
🪛 Biome (2.4.15)

[error] 567-567: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.

(lint/correctness/noSwitchDeclarations)


[error] 572-572: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.

(lint/correctness/noSwitchDeclarations)


[error] 575-575: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.

(lint/correctness/noSwitchDeclarations)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@hardhat/hardhat-exposed/internal/expose.ts` around lines 564 - 596, The
switch on typeName.nodeType contains const bindings (e.g., typeString, typeDef)
that can leak across cases; wrap each case's statements in a block scope { ... }
so declarations like "const { typeString } = typeName.typeDescriptions;" and
"const typeDef = derefUserDefinedTypeName(...)" are scoped to their case,
including nested switch cases for typeDef.nodeType and their own consts (e.g.,
the inner "const { typeString } = typeDef.underlyingType.typeDescriptions;"),
and ensure the default case and any returns remain inside their respective
blocks.

Comment thread hardhat/hardhat-exposed/tasks/generate-exposed-contracts.ts Outdated
Comment thread scripts/checks/compare-gas-reports.js
Comment thread scripts/checks/inheritance-ordering.js Outdated
Comment thread scripts/solc-versions.js
Comment thread scripts/upgradeable/transpile.sh Outdated
Comment thread test/account/utils/draft-ERC4337Utils.test.js Outdated
Comment thread test/utils/cryptography/RSA.helper.js Outdated
@@ -0,0 +1,27 @@
import { ContractDefinition, ImportDirective, PragmaDirective, SourceUnit, UsingForDirective } from 'solidity-ast';
import { Node, NodeType, NodeTypeMap } from 'solidity-ast/node';
import { findAll, isNodeType } from 'solidity-ast/utils.js';
import { NatSpec, parseNatspec } from '../utils/natspec';
import { DocItemContext, DOC_ITEM_CONTEXT } from '../site';
import { mapValues } from '../utils/map-values';
import { mapValues } from '../utils/map-values';
import { DocItem, docItemTypes } from '../doc-item';
import { formatVariable } from './helpers';
import { PropertyGetter } from '../templates';
import { promises as fs } from 'fs';
import { render } from './render';
import { Build, buildSite } from './site';
import { ensureArray } from './utils/ensure-array';
@@ -0,0 +1,74 @@
import Handlebars, { RuntimeOptions } from 'handlebars';
import { Site, Page, DocItemWithContext, DOC_ITEM_CONTEXT } from './site';
import path from 'path';
import { ContractDefinition, SourceUnit } from 'solidity-ast';
import { SolcOutput, SolcInput } from 'solidity-ast/solc';
import { astDereferencer, ASTDereferencer, findAll, isNodeType, srcDecoder, SrcDecoder } from 'solidity-ast/utils.js';
@Amxx Amxx force-pushed the hardhat3 branch 10 times, most recently from a1a4ca2 to 15c2da4 Compare May 28, 2026 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants