From 3ac040a5c2bef469fcb603d176c9d4d23f134f8a Mon Sep 17 00:00:00 2001 From: Mark Tyneway Date: Tue, 5 Jul 2022 19:43:01 -0700 Subject: [PATCH 1/2] wip docs --- packages/hardhat-forge/README.md | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/packages/hardhat-forge/README.md b/packages/hardhat-forge/README.md index d875285..946f7cd 100644 --- a/packages/hardhat-forge/README.md +++ b/packages/hardhat-forge/README.md @@ -4,7 +4,9 @@ This Hardhat plugin is for [forge](https://github.com/foundry-rs/foundry/tree/ma ## What -This plugin provides bindings for `forge` commands as hardhat tasks. +This plugin provides bindings for `forge` commands as hardhat tasks. It can +generate hardhat style artifacts that can be used with hardhat tooling such as +[hardhat-deploy](https://github.com/wighawag/hardhat-deploy) or hardhat tasks. ## Installation @@ -28,13 +30,25 @@ import "@foundry-rs/hardhat-forge"; This plugin provides the following tasks: -- "forge::build" for "`forge build` -- "forge::test" for "`forge test` +- `forge:config` returns the forge config +- `compile` overwrites the standard hardhat compile and uses the foundry + toolchain instead ## Configuration See [Foundry](https://github.com/foundry-rs/foundry). +The `HardhatUserConfig` is extended with a `foundry` object that can be used +to configure the plugin as well as `forge`. + +```js +const config: HardhatUserConfig = { + foundry: { + buildInfo: true, + }, +} +``` + ## LICENSE - MIT license ([LICENSE](LICENSE) or https://opensource.org/licenses/MIT) From db90066a08841a2877ec52f17b1ebd8438bd464c Mon Sep 17 00:00:00 2001 From: Mark Tyneway Date: Sun, 24 Jul 2022 04:01:19 -0700 Subject: [PATCH 2/2] docs: more --- packages/hardhat-forge/README.md | 35 +++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/packages/hardhat-forge/README.md b/packages/hardhat-forge/README.md index 946f7cd..5cad74c 100644 --- a/packages/hardhat-forge/README.md +++ b/packages/hardhat-forge/README.md @@ -4,10 +4,16 @@ This Hardhat plugin is for [forge](https://github.com/foundry-rs/foundry/tree/ma ## What -This plugin provides bindings for `forge` commands as hardhat tasks. It can -generate hardhat style artifacts that can be used with hardhat tooling such as +This plugin enables projects to use both foundry and hardhat. It provides +bindings for `forge` commands as hardhat tasks. It generates hardhat style +artifacts that can be used with hardhat tooling such as [hardhat-deploy](https://github.com/wighawag/hardhat-deploy) or hardhat tasks. +It is useful for projects that already have hardhat tooling and want to take +advantage of features only found in foundry such as writing tests in solidity +or fuzzing. It also allows for projects to write tests in solidity and do +chainops in TypeScript or JavaScript. + ## Installation ```bash @@ -34,12 +40,35 @@ This plugin provides the following tasks: - `compile` overwrites the standard hardhat compile and uses the foundry toolchain instead +## Usage + +The following hardhat task could be used to interact with a contract named +`Contract` that is compiled with the foundry compiler toolchain. + +```js +import { task } from "hardhat/config" +import assert from "assert" + +task("example").setAction(async (args, hre) => { + const contract = await this.hre.artifacts.readArtifact("Contract"); + console.log(contract.abi) + + const info = await this.hre.artifacts.getBuildInfo("Contract"); + assert(typeof info === "object") +}) +``` + ## Configuration See [Foundry](https://github.com/foundry-rs/foundry). The `HardhatUserConfig` is extended with a `foundry` object that can be used -to configure the plugin as well as `forge`. +to configure the plugin as well as `forge`. Configuration that is passed in via +the `HardhatUserConfig` will overwrite values that are configured in the +`foundry.toml`. + +Note that `forge` must be configured to generate hardhat style build info files +for this plugin to function correctly. ```js const config: HardhatUserConfig = {