Skip to content

fix(hardhat): make cofhe.mocks.deployMocks() fall back to the cofhe config - #438

Open
nftpoetrist wants to merge 1 commit into
FhenixProtocol:masterfrom
nftpoetrist:fix/hardhat-deploy-mocks-config
Open

nftpoetrist wants to merge 1 commit into
FhenixProtocol:masterfrom
nftpoetrist:fix/hardhat-deploy-mocks-config

Conversation

@nftpoetrist

@nftpoetrist nftpoetrist commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Hardhat 3: conn.cofhe.mocks.deployMocks() now falls back to the cofhe config for gasWarning, mocksDeployVerbosity and logMocks, the options the deploy on network.connect() already uses. Options passed in still win.
  • Hardhat 2: hre.cofhe.mocks.deployMocks() already took mocksDeployVerbosity from the config and deployMocks reads logMocks itself; it now takes gasWarning too.
  • Add a patch changeset for both plugins.

Root cause

The Hardhat 3 README documents these options as "inherits config", but the connection's deployMocks passed the caller's options straight through (hre.ts#L87-L89), and deployMocks defaults a missing gasWarning to true (deploy.ts#L74). With the default config (gasWarning: false) a re-deploy printed the gas warning, mocksDeployVerbosity: '' was ignored, and logMocks: true was not applied again. #420 wired logMocks into the deploy on connect; this is the other deploy path.

In Hardhat 2 the manual deploy built its defaults from mocksDeployVerbosity only (index.ts#L559-L561), so gasWarning: true never printed the warning on a re-deploy.

Fix

Hardhat 3 passes the resolved hre.config.cofhe to createCofheConnection, and the connection's deployMocks builds its defaults from it, then spreads the caller's options over them. Hardhat 2 adds gasWarning to the defaults it already spreads.

Testing

  • hardhat-3-plugin-test: "logMocks: true turns logging back on when cofhe.mocks.deployMocks() re-deploys" and "follows gasWarning and mocksDeployVerbosity from the config" (spies on console.log). RED on master: logOps stays false, and console.log is called 4 times instead of 0. With the fix: 45 passing.
  • hardhat-plugin-test: "prints the gas warning when gasWarning is true in the config" (snapshot and revert, like the fix(hardhat): apply cofhe.logMocks when deploying the mocks #420 test). RED on master: no warning. With the fix: 103 passing.
  • pnpm check:types, pnpm lint, pnpm check:formatting (tracked files), check:circles, check:pinned-deps: pass.

Scope

Only the defaults of the manual deploy change. The deploy on connect sends the same transactions as before.

Related: #431 also edits hooks/hre.ts. This change stays out of the deploy-on-connect block it touches; merged together locally, the two apply cleanly and hardhat-3-plugin-test passes (47 passing).


Note

Low Risk
Behavior-only default wiring for mock re-deploy console/logging; deploy-on-connect path unchanged.

Overview
Manual cofhe.mocks.deployMocks() re-deploys now inherit gasWarning, mocksDeployVerbosity, and logMocks from the resolved Hardhat cofhe config (same as deploy-on-connect), with explicit call options still overriding.

On Hardhat 3, the connection factory receives hre.config.cofhe and merges those values before calling deployMocks, fixing re-deploys that wrongly showed the gas warning, ignored silent verbosity, and left FHE op logging off after logMocks: true. On Hardhat 2, hre.cofhe.mocks.deployMocks now also passes gasWarning from config (verbosity was already wired).

Tests cover re-deploy logOps restoration and quiet console output when gasWarning: false and empty verbosity; Hardhat 2 adds a gas-warning print assertion. A patch changeset bumps both plugins.

Reviewed by Cursor Bugbot for commit 5dc114f. Bugbot is set up for automated code reviews on this repo. Configure here.

@changeset-bot

changeset-bot Bot commented Oct 16, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5dc114f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@cofhe/hardhat-3-plugin Patch
@cofhe/hardhat-plugin Patch
@cofhe/site Patch
@cofhe/abi Patch
@cofhe/foundry-plugin Patch
@cofhe/mock-contracts Patch
@cofhe/react Patch
@cofhe/sdk Patch
@cofhe/example-react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

This branch has not been deployed

No deployments
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.

1 participant