From a2ce98eb88cfb76479becf4e7ea5301053b478ea Mon Sep 17 00:00:00 2001 From: Franco Victorio Date: Fri, 19 Jul 2024 10:24:06 +0200 Subject: [PATCH 1/5] Fix numbered list in docs --- .../ignition/docs/advanced/migrating.md | 84 +++++++++---------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/docs/src/content/ignition/docs/advanced/migrating.md b/docs/src/content/ignition/docs/advanced/migrating.md index be6a950714..4dd71a5943 100644 --- a/docs/src/content/ignition/docs/advanced/migrating.md +++ b/docs/src/content/ignition/docs/advanced/migrating.md @@ -8,73 +8,73 @@ To get started, we’ll uninstall the `hardhat-deploy` plugin and install the Ha 1. Remove the `hardhat-deploy` packages from your project: -::::tabsgroup{options="npm,yarn"} + ::::tabsgroup{options="npm,yarn"} -:::tab{value="npm"} + :::tab{value="npm"} -```sh -npm uninstall hardhat-deploy hardhat-deploy-ethers -``` + ```sh + npm uninstall hardhat-deploy hardhat-deploy-ethers + ``` -::: + ::: -:::tab{value=yarn} + :::tab{value=yarn} -```sh -yarn remove hardhat-deploy hardhat-deploy-ethers -``` + ```sh + yarn remove hardhat-deploy hardhat-deploy-ethers + ``` -::: + ::: -:::: + :::: 2. Install the Hardhat Ignition package and `hardhat-network-helpers` to provide additional testing support as a replacement for `hardhat-deploy` functionality like EVM snapshots: -::::tabsgroup{options="npm,yarn"} + ::::tabsgroup{options="npm,yarn"} -:::tab{value="npm"} + :::tab{value="npm"} -```sh -npm install --save-dev @nomicfoundation/hardhat-ignition-ethers @nomicfoundation/hardhat-network-helpers -``` + ```sh + npm install --save-dev @nomicfoundation/hardhat-ignition-ethers @nomicfoundation/hardhat-network-helpers + ``` -::: + ::: -:::tab{value=yarn} + :::tab{value=yarn} -```sh -yarn add --dev @nomicfoundation/hardhat-ignition-ethers @nomicfoundation/hardhat-network-helpers -``` + ```sh + yarn add --dev @nomicfoundation/hardhat-ignition-ethers @nomicfoundation/hardhat-network-helpers + ``` -::: + ::: -:::: + :::: 3. Update the project’s `hardhat.config` file to remove `hardhat-deploy` and `hardhat-deploy-ethers` and instead import Hardhat Ignition: -::::tabsgroup{options="typescript,javascript"} + ::::tabsgroup{options="typescript,javascript"} -:::tab{value="typescript"} + :::tab{value="typescript"} -```git -- import "hardhat-deploy"; -- import "hardhat-deploy-ethers"; -+ import "@nomicfoundation/hardhat-ignition-ethers"; -``` + ```git + - import "hardhat-deploy"; + - import "hardhat-deploy-ethers"; + + import "@nomicfoundation/hardhat-ignition-ethers"; + ``` -::: + ::: -:::tab{value=javascript} + :::tab{value=javascript} -```git -- require("hardhat-deploy"); -- require("hardhat-deploy-ethers"); -+ require("@nomicfoundation/hardhat-ignition-ethers"); -``` + ```git + - require("hardhat-deploy"); + - require("hardhat-deploy-ethers"); + + require("@nomicfoundation/hardhat-ignition-ethers"); + ``` -::: + ::: -:::: + :::: ## Convert deployment scripts to Ignition Modules @@ -152,7 +152,7 @@ import { buildModule } from "@nomicfoundation/hardhat-ignition/modules"; For instance, you can deploy contracts via `m.contract()`. */ export default buildModule("TokenModule", (m) => { - /* + /* Instead of named accounts, you get access to the configured accounts through the `getAccount()` method. */ @@ -193,7 +193,7 @@ const { buildModule } = require("@nomicfoundation/hardhat-ignition/modules"); For instance, you can deploy contracts via `m.contract()`. */ module.exports = buildModule("TokenModule", (m) => { - /* + /* Instead of named accounts, you get access to the configured accounts through the `getAccount()` method. */ From 0bd8972d39ed4b11dc6b8eca21cb1973fd931036 Mon Sep 17 00:00:00 2001 From: Franco Victorio Date: Fri, 19 Jul 2024 10:33:26 +0200 Subject: [PATCH 2/5] Run prettier --- .../ignition/docs/advanced/migrating.md | 80 +++++++++---------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/docs/src/content/ignition/docs/advanced/migrating.md b/docs/src/content/ignition/docs/advanced/migrating.md index 4dd71a5943..cd501500bc 100644 --- a/docs/src/content/ignition/docs/advanced/migrating.md +++ b/docs/src/content/ignition/docs/advanced/migrating.md @@ -8,73 +8,73 @@ To get started, we’ll uninstall the `hardhat-deploy` plugin and install the Ha 1. Remove the `hardhat-deploy` packages from your project: - ::::tabsgroup{options="npm,yarn"} + ::::tabsgroup{options="npm,yarn"} - :::tab{value="npm"} + :::tab{value="npm"} - ```sh - npm uninstall hardhat-deploy hardhat-deploy-ethers - ``` + ```sh + npm uninstall hardhat-deploy hardhat-deploy-ethers + ``` - ::: + ::: - :::tab{value=yarn} + :::tab{value=yarn} - ```sh - yarn remove hardhat-deploy hardhat-deploy-ethers - ``` + ```sh + yarn remove hardhat-deploy hardhat-deploy-ethers + ``` - ::: + ::: - :::: + :::: 2. Install the Hardhat Ignition package and `hardhat-network-helpers` to provide additional testing support as a replacement for `hardhat-deploy` functionality like EVM snapshots: - ::::tabsgroup{options="npm,yarn"} + ::::tabsgroup{options="npm,yarn"} - :::tab{value="npm"} + :::tab{value="npm"} - ```sh - npm install --save-dev @nomicfoundation/hardhat-ignition-ethers @nomicfoundation/hardhat-network-helpers - ``` + ```sh + npm install --save-dev @nomicfoundation/hardhat-ignition-ethers @nomicfoundation/hardhat-network-helpers + ``` - ::: + ::: - :::tab{value=yarn} + :::tab{value=yarn} - ```sh - yarn add --dev @nomicfoundation/hardhat-ignition-ethers @nomicfoundation/hardhat-network-helpers - ``` + ```sh + yarn add --dev @nomicfoundation/hardhat-ignition-ethers @nomicfoundation/hardhat-network-helpers + ``` - ::: + ::: - :::: + :::: 3. Update the project’s `hardhat.config` file to remove `hardhat-deploy` and `hardhat-deploy-ethers` and instead import Hardhat Ignition: - ::::tabsgroup{options="typescript,javascript"} + ::::tabsgroup{options="typescript,javascript"} - :::tab{value="typescript"} + :::tab{value="typescript"} - ```git - - import "hardhat-deploy"; - - import "hardhat-deploy-ethers"; - + import "@nomicfoundation/hardhat-ignition-ethers"; - ``` + ```git + - import "hardhat-deploy"; + - import "hardhat-deploy-ethers"; + + import "@nomicfoundation/hardhat-ignition-ethers"; + ``` - ::: + ::: - :::tab{value=javascript} + :::tab{value=javascript} - ```git - - require("hardhat-deploy"); - - require("hardhat-deploy-ethers"); - + require("@nomicfoundation/hardhat-ignition-ethers"); - ``` + ```git + - require("hardhat-deploy"); + - require("hardhat-deploy-ethers"); + + require("@nomicfoundation/hardhat-ignition-ethers"); + ``` - ::: + ::: - :::: + :::: ## Convert deployment scripts to Ignition Modules From ca1e0ab5f15c06fd5225a60d8e721a0fc6d5cc19 Mon Sep 17 00:00:00 2001 From: Franco Victorio Date: Fri, 19 Jul 2024 10:33:53 +0200 Subject: [PATCH 3/5] Fix closing backtick --- docs/src/content/ignition/docs/advanced/migrating.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/content/ignition/docs/advanced/migrating.md b/docs/src/content/ignition/docs/advanced/migrating.md index cd501500bc..fccb8cf57f 100644 --- a/docs/src/content/ignition/docs/advanced/migrating.md +++ b/docs/src/content/ignition/docs/advanced/migrating.md @@ -78,7 +78,7 @@ To get started, we’ll uninstall the `hardhat-deploy` plugin and install the Ha ## Convert deployment scripts to Ignition Modules -`hardhat-deploy` represents contract deployments as JavaScript or TypeScript files under the `./deploy/` folder. Hardhat Ignition follows a similar pattern with deployments encapsulated as modules; these are JS/TS files stored under the `./ignition/modules directory`. Each `hardhat-deploy` deploy file will be converted or merged into a Hardhat Ignition module. +`hardhat-deploy` represents contract deployments as JavaScript or TypeScript files under the `./deploy/` folder. Hardhat Ignition follows a similar pattern with deployments encapsulated as modules; these are JS/TS files stored under the `./ignition/modules` directory. Each `hardhat-deploy` deploy file will be converted or merged into a Hardhat Ignition module. Let’s first create the required folder structure under the root of your project: From fbcfb9c18d19aeaee3c113408b588ff3d0b813cc Mon Sep 17 00:00:00 2001 From: Franco Victorio Date: Fri, 19 Jul 2024 10:43:39 +0200 Subject: [PATCH 4/5] Add empty lines in solidity snippet --- docs/src/content/ignition/docs/advanced/migrating.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/src/content/ignition/docs/advanced/migrating.md b/docs/src/content/ignition/docs/advanced/migrating.md index fccb8cf57f..aee7e336dd 100644 --- a/docs/src/content/ignition/docs/advanced/migrating.md +++ b/docs/src/content/ignition/docs/advanced/migrating.md @@ -97,13 +97,16 @@ contract Token { uint256 public totalSupply = 1000000; address public owner; mapping(address => uint256) balances; + constructor(address _owner) { balances[_owner] = totalSupply; owner = _owner; } + function balanceOf(address account) external view returns (uint256) { return balances[account]; } + function transfer(address to, uint256 amount) external { require(balances[msg.sender] >= amount, "Not enough tokens"); balances[msg.sender] -= amount; From f652fc169f63523338ea3393120ebc8adb36e775 Mon Sep 17 00:00:00 2001 From: Franco Victorio Date: Fri, 19 Jul 2024 10:43:56 +0200 Subject: [PATCH 5/5] Use consistent format for multiline comments --- .../ignition/docs/advanced/migrating.md | 58 +++++++++---------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/docs/src/content/ignition/docs/advanced/migrating.md b/docs/src/content/ignition/docs/advanced/migrating.md index aee7e336dd..7e801c9470 100644 --- a/docs/src/content/ignition/docs/advanced/migrating.md +++ b/docs/src/content/ignition/docs/advanced/migrating.md @@ -126,9 +126,9 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const { deployments, getNamedAccounts } = hre; const { deploy } = deployments; /* - The deploy function uses the hardhat-deploy named accounts feature - to set the deployment's `from` and `args` parameters. - */ + The deploy function uses the hardhat-deploy named accounts feature + to set the deployment's `from` and `args` parameters. + */ const { deployer, tokenOwner } = await getNamedAccounts(); await deploy("Token", { from: deployer, @@ -156,28 +156,28 @@ import { buildModule } from "@nomicfoundation/hardhat-ignition/modules"; */ export default buildModule("TokenModule", (m) => { /* - Instead of named accounts, you get access to the configured accounts - through the `getAccount()` method. - */ + Instead of named accounts, you get access to the configured accounts + through the `getAccount()` method. + */ const deployer = m.getAccount(0); const tokenOwner = m.getAccount(1); /* - Deploy `Token` by calling `contract()` with the constructor arguments - as the second argument. The account to use for the deployment transaction - is set through `from` in the third argument, which is an options object. - */ + Deploy `Token` by calling `contract()` with the constructor arguments + as the second argument. The account to use for the deployment transaction + is set through `from` in the third argument, which is an options object. + */ const token = m.contract("Token", [tokenOwner], { from: deployer, }); /* - The call to `m.contract()` returns a future that can be used in other `m.contract()` - calls (e.g. as a constructor argument, where the future will resolve to the - deployed address), but it can also be returned from the module. Contract - futures that are returned from the module can be leveraged in Hardhat tests - and scripts, as will be shown later. - */ + The call to `m.contract()` returns a future that can be used in other `m.contract()` + calls (e.g. as a constructor argument, where the future will resolve to the + deployed address), but it can also be returned from the module. Contract + futures that are returned from the module can be leveraged in Hardhat tests + and scripts, as will be shown later. + */ return { token }; }); ``` @@ -197,28 +197,28 @@ const { buildModule } = require("@nomicfoundation/hardhat-ignition/modules"); */ module.exports = buildModule("TokenModule", (m) => { /* - Instead of named accounts, you get access to the configured accounts - through the `getAccount()` method. - */ + Instead of named accounts, you get access to the configured accounts + through the `getAccount()` method. + */ const deployer = m.getAccount(0); const tokenOwner = m.getAccount(1); /* - Deploy `Token` by calling `contract()` with the constructor arguments - as the second argument. The account to use for the deployment transaction - is set through `from` in the third argument, which is an options object. - */ + Deploy `Token` by calling `contract()` with the constructor arguments + as the second argument. The account to use for the deployment transaction + is set through `from` in the third argument, which is an options object. + */ const token = m.contract("Token", [tokenOwner], { from: deployer, }); /* - The call to `m.contract()` returns a future that can be used in other `m.contract()` - calls (e.g. as a constructor argument, where the future will resolve to the - deployed address), but it can also be returned from the module. Contract - futures that are returned from the module can be leveraged in Hardhat tests - and scripts, as will be shown later. - */ + The call to `m.contract()` returns a future that can be used in other `m.contract()` + calls (e.g. as a constructor argument, where the future will resolve to the + deployed address), but it can also be returned from the module. Contract + futures that are returned from the module can be leveraged in Hardhat tests + and scripts, as will be shown later. + */ return { token }; }); ```