Skip to content

docs: add twoslash compile-checking to Hardhat plugin guide - #94

Merged
PierreJeanjacquot merged 5 commits into
mainfrom
docs/hardhat-guide-twoslash
Aug 4, 2026
Merged

docs: add twoslash compile-checking to Hardhat plugin guide#94
PierreJeanjacquot merged 5 commits into
mainfrom
docs/hardhat-guide-twoslash

Conversation

@claude

@claude claude Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Requested by Pierre Jeanjacquot · Slack thread

Summary

Adds twoslash compile-checking to the TypeScript code examples in
src/guides/build-confidential-smart-contracts/hardhat.md, validated against
@iexec-nox/nox-hardhat-plugin@0.2.0 and its Hardhat toolbox peers.

  • All 7 ts fenced blocks in the guide (including the Viem/Ethers code-group
    tabs) are now type-checked at build time via twoslash.
  • No visible example code changed — every example already compiled correctly
    against the v0.2.0 API, so this is purely an annotation/verification change.
  • 3 blocks needed a small hidden preamble (imported above a // ---cut---
    marker, so it type-checks but never renders) purely to pull in Hardhat's
    ambient type-extension augmentations that a standalone snippet wouldn't
    otherwise see:
    • "Connecting to an http network" — hidden import '@iexec-nox/nox-hardhat-plugin'
      so the nox field on HttpNetworkUserConfig resolves.
    • "Writing a test" (Viem tab) — hidden import '@nomicfoundation/hardhat-toolbox-viem'
      so NetworkConnection.viem resolves.
    • "Writing a test" (Ethers tab) — hidden import '@nomicfoundation/hardhat-ethers'
      so NetworkConnection.ethers resolves.

Dependencies

Added to package.json under dependencies (matching the existing pattern for
other twoslash-checked packages like @iexec-nox/handle, ethers, viem):

  • @iexec-nox/nox-hardhat-plugin@0.2.0
  • @iexec-nox/nox-protocol-contracts and hardhat (required peers, per the
    plugin's peerDependencies)
  • @nomicfoundation/hardhat-toolbox-viem and @nomicfoundation/hardhat-ethers
    (needed so both the Viem and Ethers example tabs keep compiling)

viem/ethers were already present in devDependencies and reused as-is.
package-lock.json was regenerated via npm install.

Testing

  • npm run build passes cleanly (vitepress build, which runs the twoslash
    type-checking).
  • npm run format / npm run check-format both pass with no changes needed.

Convert the TS code blocks in the Hardhat plugin guide to twoslash,
validated against @iexec-nox/nox-hardhat-plugin@0.2.0 and its Hardhat
toolbox peers. Adds hidden ---cut--- preambles where needed to resolve
Hardhat's viem/ethers type-extension augmentations without changing
any rendered example code.
@claude
claude Bot requested review from PierreJeanjacquot and a lite review from Copilot and removed request for Copilot August 4, 2026 08:23
@vercel

vercel Bot commented Aug 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nox-documentation Ready Ready Preview Aug 4, 2026 9:37am

Request Review

@socket-security

socket-security Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​iexec-nox/​nox-hardhat-plugin@​0.2.07610010092100
Added@​iexec-nox/​nox-protocol-contracts@​0.2.4821001009590
Addedhardhat@​3.12.0991008296100
Added@​nomicfoundation/​hardhat-toolbox-viem@​5.0.7831008990100
Added@​nomicfoundation/​hardhat-ethers@​4.0.1510010010095100

View full report

@socket-security

socket-security Bot commented Aug 4, 2026

Copy link
Copy Markdown

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Action Severity Alert  (click "▶" to expand/collapse)
Warn High
License policy violation: npm @iexec-nox/nox-protocol-contracts under BUSL-1.1

License: BUSL-1.1 - The applicable license policy does not permit this license (5) (package/LICENSE)

License: BUSL-1.1 - The applicable license policy does not permit this license (5) (package/contracts/NoxCompute.sol)

License: BUSL-1.1 - The applicable license policy does not permit this license (5) (package/contracts/modules/Compute.sol)

License: BUSL-1.1 - The applicable license policy does not permit this license (5) (package/contracts/modules/ACL.sol)

License: BUSL-1.1 - The applicable license policy does not permit this license (5) (package/contracts/modules/Admin.sol)

License: BUSL-1.1 - The applicable license policy does not permit this license (5) (package/contracts/modules/Common.sol)

From: package-lock.jsonnpm/@iexec-nox/nox-protocol-contracts@0.2.4

ℹ Read more on: This package | This alert | What is a license policy violation?

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: Find a package that does not violate your license policy or adjust your policy to allow this package's license.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/@iexec-nox/nox-protocol-contracts@0.2.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.

View full report

Update the version ranges added for twoslash-checking the Hardhat guide
to match the currently-published releases instead of the plugin's
peerDependency floors. All versions were already what npm resolved to
in the lockfile, so this only changes the package.json range text.
Copilot AI lite review requested due to automatic review settings August 4, 2026 09:04

Copilot AI 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.

Pull request overview

Note

Copilot could not run the full agentic suite for this review because it was automatically requested on a bot-authored pull request. Request a review from Copilot under Reviewers to retry with the full agentic suite. Improved support for bot-authored pull requests is coming soon.

This PR updates the Hardhat guide to use twoslash-enabled TypeScript snippets (for type-checked documentation examples) and adds the required Hardhat/Nox dependencies to support that docs build.

Changes:

  • Convert multiple TypeScript code fences in the Hardhat guide to twoslash and add // ---cut--- scaffolding for cleaner rendered snippets.
  • Add Hardhat, Nox plugin/contracts, and Hardhat plugin dependencies to package.json.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/guides/build-confidential-smart-contracts/hardhat.md Enables twoslash for Hardhat guide snippets and adds hidden imports for typechecking.
package.json Adds Hardhat/Nox/Hardhat-plugin dependencies needed for twoslash compilation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread package.json Outdated
Comment thread src/guides/build-confidential-smart-contracts/hardhat.md
Comment thread src/guides/build-confidential-smart-contracts/hardhat.md
Expand the "Connecting to an http network" example to show the plugin
import, plugins array, and solidity field alongside the networks.nox
block, rather than only the isolated networks fragment. The plugin
import is now visible in the rendered snippet, so the hidden
---cut--- import used only to pull in the nox type-extension
augmentation is no longer needed.
Apply the same treatment as the http network example: show the plugin
import, plugins array, and solidity field alongside the networks
block, rather than only the isolated networks fragment, for
consistency between the two network sections.
Move @iexec-nox/handle and the packages added for the Hardhat guide's
twoslash examples (@iexec-nox/nox-hardhat-plugin,
@iexec-nox/nox-protocol-contracts, hardhat,
@nomicfoundation/hardhat-toolbox-viem, @nomicfoundation/hardhat-ethers)
from dependencies to devDependencies, alongside ethers/viem. This is a
static VitePress site: everything is bundled at build time (including
real site code like PiggyBankDemo.vue, which imports
@iexec-nox/handle), and there is no separate runtime npm install step
that would omit devDependencies, so dependencies is reserved for the
handful of packages the build tooling itself needs unconditionally.

@PierreJeanjacquot PierreJeanjacquot 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.

LGTM

@PierreJeanjacquot
PierreJeanjacquot merged commit e70b2a6 into main Aug 4, 2026
5 checks passed
@PierreJeanjacquot
PierreJeanjacquot deleted the docs/hardhat-guide-twoslash branch August 4, 2026 12:44
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.

3 participants