-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add @nomicfoundation/hardhat-solx plugin #8034
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
612175b
b8f827e
df4184b
a92b222
15c03dd
b3355e1
ded472b
25abf44
1dba2c0
12e7a3e
d939394
aa73e6b
c8d7705
1f1a0ab
eaef43d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "@nomicfoundation/hardhat-solx": major | ||
| "@nomicfoundation/hardhat-errors": patch | ||
| --- | ||
|
|
||
| Add `@nomicfoundation/hardhat-solx` plugin for solx compiler support in test builds ([#8034](https://github.com/NomicFoundation/hardhat/pull/8034)) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # Node modules | ||
| /node_modules | ||
|
|
||
| # Compilation output | ||
| /dist | ||
|
|
||
| # pnpm deploy output | ||
| /bundle | ||
|
|
||
| # test coverage output | ||
| coverage | ||
|
|
||
| # all the tmp folders in the fixture projects | ||
| /test/fixture-projects/tmp/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| /node_modules | ||
| /dist | ||
| /coverage | ||
| CHANGELOG.md | ||
| /test/fixture-projects/**/artifacts | ||
| /test/fixture-projects/**/cache |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| MIT License | ||
|
|
||
| Copyright (c) 2026 Nomic Foundation | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,104 @@ | ||||||||||||||||||||||||||||||||||||||
| # Hardhat Solx plugin | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| This plugin enables the [solx](https://github.com/NomicFoundation/solx) Solidity compiler in Hardhat 3. | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| The `solx` compiler is currently experimental and is not ready for production use-cases. We recommend using the compiler for test builds and test execution locally, and continuing to use `solc` for production use-cases (including during deployment for example with `hardhat-ignition` and in your CI). Care should be taken before enabling compilation with `solx` in other build profiles, see configuration flags further below. | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| ## Installation | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||||||||||
| npm install --save-dev @nomicfoundation/hardhat-solx | ||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| Then add the plugin to your `hardhat.config.ts` and create a `solx` build profile. You must use the build profiles config format, which requires both a `default` and a `solx` profile: | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| ```typescript | ||||||||||||||||||||||||||||||||||||||
| import { defineConfig } from "hardhat/config"; | ||||||||||||||||||||||||||||||||||||||
| import hardhatSolx from "@nomicfoundation/hardhat-solx"; | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+9
to
+17
|
||||||||||||||||||||||||||||||||||||||
| ```bash | |
| npm install --save-dev @nomicfoundation/hardhat-solx | |
| ``` | |
| Then add the plugin to your `hardhat.config.ts` and create a `solx` build profile. You must use the build profiles config format, which requires both a `default` and a `solx` profile: | |
| ```typescript | |
| import { defineConfig } from "hardhat/config"; | |
| import hardhatSolx from "@nomicfoundation/hardhat-solx"; | |
| This plugin is currently experimental and is not published to npm. It is intended to be used from within the Hardhat monorepo or from source. | |
| Once the plugin is available in your project, add it to your `hardhat.config.ts` and create a `solx` build profile. You must use the build profiles config format, which requires both a `default` and a `solx` profile: | |
| ```typescript | |
| import { defineConfig } from "hardhat/config"; | |
| import hardhatSolx from "@nomicfoundation/hardhat-solx"; | |
| import { defineConfig } from "hardhat/config"; | |
| import hardhatSolx from "@nomicfoundation/hardhat-solx"; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import { createConfig } from "../config/eslint.config.js"; | ||
|
|
||
| export default createConfig(import.meta.filename); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| { | ||
| "name": "@nomicfoundation/hardhat-solx", | ||
| "private": true, | ||
| "version": "2.0.0", | ||
| "description": "Hardhat plugin for using solx compiler in test builds", | ||
| "homepage": "https://github.com/NomicFoundation/hardhat/tree/main/packages/hardhat-solx", | ||
|
Comment on lines
+1
to
+6
|
||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/NomicFoundation/hardhat", | ||
| "directory": "packages/hardhat-solx" | ||
| }, | ||
| "author": "Nomic Foundation", | ||
| "license": "MIT", | ||
| "type": "module", | ||
| "types": "dist/src/index.d.ts", | ||
| "exports": { | ||
| ".": "./dist/src/index.js" | ||
| }, | ||
| "keywords": [ | ||
| "ethereum", | ||
| "smart-contracts", | ||
| "hardhat", | ||
| "solx", | ||
| "compiler" | ||
| ], | ||
| "scripts": { | ||
| "lint": "pnpm prettier --check && pnpm eslint", | ||
| "lint:fix": "pnpm prettier --write && pnpm eslint --fix", | ||
| "eslint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", | ||
| "prettier": "prettier \"**/*.{ts,js,md,json}\"", | ||
| "test": "node --import tsx/esm --test --test-reporter=@nomicfoundation/hardhat-node-test-reporter \"test/*.ts\" \"test/!(fixture-projects|helpers)/**/*.ts\"", | ||
| "test:only": "node --import tsx/esm --test --test-only --test-reporter=@nomicfoundation/hardhat-node-test-reporter \"test/*.ts\" \"test/!(fixture-projects|helpers)/**/*.ts\"", | ||
| "test:coverage": "c8 --reporter html --reporter text --all --exclude test --exclude \"src/**/{types,type-extensions}.ts\" --src src node --import tsx/esm --test --test-reporter=@nomicfoundation/hardhat-node-test-reporter \"test/*.ts\" \"test/!(fixture-projects|helpers)/**/*.ts\"", | ||
| "pretest": "pnpm build", | ||
| "pretest:only": "pnpm build", | ||
| "build": "tsc --build .", | ||
| "prepublishOnly": "pnpm build", | ||
| "clean": "rimraf dist" | ||
| }, | ||
| "files": [ | ||
| "dist/src/", | ||
| "src/", | ||
| "CHANGELOG.md", | ||
| "LICENSE", | ||
| "README.md" | ||
| ], | ||
| "devDependencies": { | ||
| "@nomicfoundation/hardhat-node-test-reporter": "workspace:^3.0.0", | ||
| "@nomicfoundation/hardhat-test-utils": "workspace:^", | ||
| "@types/debug": "^4.1.7", | ||
| "@types/node": "^22.0.0", | ||
| "c8": "^9.1.0", | ||
| "eslint": "9.25.1", | ||
| "prettier": "3.2.5", | ||
| "rimraf": "^5.0.5", | ||
| "tsx": "^4.19.3", | ||
| "typescript": "~5.8.0", | ||
| "hardhat": "workspace:^3.1.6" | ||
| }, | ||
| "dependencies": { | ||
| "@nomicfoundation/hardhat-errors": "workspace:^3.0.3", | ||
| "@nomicfoundation/hardhat-utils": "workspace:^3.0.5", | ||
| "@nomicfoundation/hardhat-zod-utils": "workspace:^3.0.0", | ||
| "debug": "^4.3.2", | ||
| "zod": "^3.23.8" | ||
| }, | ||
| "peerDependencies": { | ||
| "hardhat": "workspace:^3.1.6" | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import type { HardhatPlugin } from "hardhat/types/plugins"; | ||
|
|
||
| import "./type-extensions.js"; | ||
|
|
||
| const hardhatSolxPlugin: HardhatPlugin = { | ||
| id: "hardhat-solx", | ||
| npmPackage: "@nomicfoundation/hardhat-solx", | ||
| hookHandlers: { | ||
| config: () => import("./internal/hook-handlers/config.js"), | ||
| solidity: () => import("./internal/hook-handlers/solidity.js"), | ||
| }, | ||
| }; | ||
|
|
||
| export default hardhatSolxPlugin; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import type { SolidityCompilerType } from "hardhat/types/config"; | ||
|
|
||
| /** | ||
| * The compiler type identifier registered by this plugin. | ||
| * Typed as SolidityCompilerType for type-safe comparisons. | ||
| */ | ||
| export const SOLX_COMPILER_TYPE: SolidityCompilerType = "solx"; | ||
|
|
||
| export const SOLX_RELEASES_BASE_URL = | ||
| "https://solx-releases-mirror.hardhat.org"; | ||
|
|
||
| export const SUPPORTED_SOLX_EVM_VERSIONS: readonly string[] = [ | ||
| "cancun", | ||
| "prague", | ||
| "osaka", | ||
| ] as const; | ||
|
|
||
| export const DEFAULT_SOLX_SETTINGS: Record<string, unknown> = { | ||
| viaIR: false, | ||
| LLVMOptimization: "1", | ||
| }; | ||
|
|
||
| /** | ||
| * Maps Solidity compiler versions to the solx version that embeds them. | ||
| * Only stable solx releases are included. | ||
| */ | ||
| export const SOLIDITY_TO_SOLX_VERSION_MAP: Record<string, string> = { | ||
| "0.8.33": "0.1.3", | ||
| "0.8.34": "0.1.4", | ||
| }; |
Uh oh!
There was an error while loading. Please reload this page.