feat: Hardhat plugin package for seamless integration with Hardhat workflows#37
Open
ciynthia wants to merge 2 commits into
Open
feat: Hardhat plugin package for seamless integration with Hardhat workflows#37ciynthia wants to merge 2 commits into
ciynthia wants to merge 2 commits into
Conversation
Introduce @chainproof/hardhat-plugin with chainproof, chainproof:check, and chainproof:report tasks, compile/test hooks, TypeScript config types, and an example Hardhat project. Includes minimal core build fixes required for upstream master compatibility. Closes StellarChainproof#18
Fixes TypeScript compile errors in import-graph and scanner test suites after useMetrics became a required ScanConfig field.
Contributor
|
@ciynthia resolve conflicts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR adds
@chainproof/hardhat-plugin, a first-class Hardhat integration that lets teams run ChainProof as native Hardhat tasks, hook scans into compile/test workflows, and view colorized findings in the Hardhat console — without leaving the Hardhat ecosystem.Related Issue
Closes #18
Changes
🔌 Hardhat Plugin Package
[ADD]
packages/hardhat-plugin/src/index.tsRegisters the plugin entry point with Hardhat config/environment extensions.
Implements
runOnCompileandfailOnCompilehooks on thecompiletask.Adds a ChainProof security summary footer to Hardhat Network test output.
[ADD]
packages/hardhat-plugin/src/type-extensions.tsExtends
HardhatUserConfig/HardhatConfigwith achainproofconfiguration block.Adds TypeScript types for
hardhat.config.tsintegration.[ADD]
packages/hardhat-plugin/src/config.tsResolves plugin config (targets, severity, Slither/LLM flags) relative to the Hardhat project root.
[ADD]
packages/hardhat-plugin/src/runner.tsShared scan runner wrapping
@chainproof/corewith Hardhat-aware error handling.[ADD]
packages/hardhat-plugin/src/console.tsPrints findings with Hardhat console formatting (chalk colors and indentation).
🛠 Hardhat Tasks
[ADD]
packages/hardhat-plugin/src/tasks/scan.tsRegisters
npx hardhat chainprooffor a full audit scan.[ADD]
packages/hardhat-plugin/src/tasks/check.tsRegisters
npx hardhat chainproof:check— fast CI check that fails on critical/high findings.[ADD]
packages/hardhat-plugin/src/tasks/report.tsRegisters
npx hardhat chainproof:report --format markdown --output audit.md.[ADD]
packages/hardhat-plugin/package.jsonPublished as
@chainproof/hardhat-pluginwith public npm publish config.📁 Example Project
examples/hardhat-project/hardhat.config.ts.VulnerableToken.soland a passing test suite.🔧 Core Build Fixes (upstream compatibility)
[MODIFY]
packages/core/src/scanner.tsRestored working scan orchestration required for the plugin to call
@chainproof/core.[MODIFY]
packages/core/src/rules/swc107-reentrancy.ts,swc115-tx-origin.tsFixed broken merge syntax errors blocking TypeScript compilation on upstream
master.[MODIFY]
packages/core/src/ast/import-graph.ts,metrics/complexity.ts,rules/swc116-unprotected-upgrade.tsFixed
ASTNodeimport paths for consistent core package builds.Verification Results
npm run lintnpm run build(packages/core,packages/hardhat-plugin)npm test(packages/core)npx hardhat chainproof(example project)npx hardhat chainproof:check(example project)npx hardhat chainproof:report(example project)npx hardhat testwith Hardhat Network footerpackages/hardhat-pluginscaffoldchainproof,chainproof:check,chainproof:reporttasks registeredHardhatUserConfigextended withchainproofconfiguration blockrunOnCompilehook implementedhardhat.config.tsintegrationexamples/hardhat-project/@chainproof/hardhat-pluginon npmpublishConfig)