From debd668a90c7b17cef01a3ff67ac5a712fc4291f Mon Sep 17 00:00:00 2001 From: Tmthang1601 Date: Sun, 15 Sep 2024 19:16:50 +0700 Subject: [PATCH 1/2] Improve messages and task descriptions for better consistency - Refactored deprecation warning in cli.ts for clarity - Updated task descriptions in getting-started/index.md for consistency - Clarified 'check' task description in check.ts - Added network parameter example in tasks.md guide Detailed changes: 1. cli.ts: Shortened and clarified deprecation warning message 2. getting-started/index.md: Updated task list with more concise and consistent descriptions 3. check.ts: Improved 'check' task description to be more specific 4. tasks.md: Added example of running a task with network parameter These changes aim to improve the overall consistency and clarity of Hardhat's documentation and messages, making them more user-friendly and informative. --- .../hardhat-runner/docs/getting-started/index.md | 2 +- docs/src/content/hardhat-runner/docs/guides/tasks.md | 8 ++++++++ packages/hardhat-core/src/builtin-tasks/check.ts | 2 +- packages/hardhat-core/src/internal/cli/cli.ts | 10 +++------- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/docs/src/content/hardhat-runner/docs/getting-started/index.md b/docs/src/content/hardhat-runner/docs/getting-started/index.md index 55b9dcbeed..548aab9e0f 100644 --- a/docs/src/content/hardhat-runner/docs/getting-started/index.md +++ b/docs/src/content/hardhat-runner/docs/getting-started/index.md @@ -117,7 +117,7 @@ GLOBAL OPTIONS: AVAILABLE TASKS: - check Check whatever you need + check Runs a user-defined check clean Clears the cache and deletes all artifacts compile Compiles the entire project, building all artifacts console Opens a hardhat console diff --git a/docs/src/content/hardhat-runner/docs/guides/tasks.md b/docs/src/content/hardhat-runner/docs/guides/tasks.md index 8b434ad84e..ce7f654ac6 100644 --- a/docs/src/content/hardhat-runner/docs/guides/tasks.md +++ b/docs/src/content/hardhat-runner/docs/guides/tasks.md @@ -25,6 +25,14 @@ Now you should be able to run it: ``` npx hardhat accounts ``` +For tasks that support network parameters, you can specify the network like this: + + +``` +npx hardhat compile --network localhost +``` +This will run the task on the specified network (in this case, localhost). + We are using the `task` function to define our new task. Its first argument is the name of the task, and it's what we use in the command line to run it. The second argument is the description of the task, which is printed when you use `npx hardhat help`. diff --git a/packages/hardhat-core/src/builtin-tasks/check.ts b/packages/hardhat-core/src/builtin-tasks/check.ts index 5010c9176d..f5bb606247 100644 --- a/packages/hardhat-core/src/builtin-tasks/check.ts +++ b/packages/hardhat-core/src/builtin-tasks/check.ts @@ -2,4 +2,4 @@ import { task } from "../internal/core/config/config-env"; import { TASK_CHECK } from "./task-names"; -task(TASK_CHECK, "Check whatever you need", async () => {}); +task(TASK_CHECK, "Runs a user-defined check", async () => {}); diff --git a/packages/hardhat-core/src/internal/cli/cli.ts b/packages/hardhat-core/src/internal/cli/cli.ts index 967c5dc857..b0b812c560 100755 --- a/packages/hardhat-core/src/internal/cli/cli.ts +++ b/packages/hardhat-core/src/internal/cli/cli.ts @@ -170,14 +170,10 @@ async function main() { // Warning for Hardhat V3 deprecation console.warn( - chalk.yellow.bold("\n\nDEPRECATION WARNING\n\n"), + chalk.yellow.bold("DEPRECATION WARNING: "), chalk.yellow( - `Initializing a project with ${chalk.white.italic( - "npx hardhat" - )} is deprecated and will be removed in the future.\n` - ), - chalk.yellow( - `Please use ${chalk.white.italic("npx hardhat init")} instead.\n\n` + `Using ${chalk.white.italic("npx hardhat")} to initialize a project is deprecated.\n`, + `Please use ${chalk.white.italic("npx hardhat init")} instead.\n` ) ); From f5162cd9eac763a2bdf97b38c19abf31601f9470 Mon Sep 17 00:00:00 2001 From: Tmthang1601 Date: Mon, 16 Sep 2024 12:57:49 +0700 Subject: [PATCH 2/2] Update deployment guide for Hardhat v3 and Hardhat Ignition --- .../docs/getting-started/index.md | 18 ++++++++++++++++++ .../hardhat-runner/docs/guides/deploying.md | 13 +++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/docs/src/content/hardhat-runner/docs/getting-started/index.md b/docs/src/content/hardhat-runner/docs/getting-started/index.md index 548aab9e0f..d32f47614c 100644 --- a/docs/src/content/hardhat-runner/docs/getting-started/index.md +++ b/docs/src/content/hardhat-runner/docs/getting-started/index.md @@ -239,6 +239,24 @@ Compiled 2 Solidity files successfully ### Deploying your contracts +In Hardhat v3, we use Hardhat Ignition for deploying contracts. Hardhat Ignition is a new declarative deployment system that offers several improvements: + +1. Declarative deployments +2. Built-in error handling and recovery +3. Improved testability +4. Enhanced modularity + +To deploy the `Lock` contract, use the following command: + +``` +npx hardhat ignition deploy ./ignition/modules/Lock.js +``` + + +This will deploy the Ignition module located in `./ignition/modules/Lock.js`. + +For more details on Hardhat Ignition and its features in Hardhat v3, refer to the [Hardhat Ignition documentation](/ignition). + Next, to deploy the contract we will use a Hardhat Ignition module. Inside the `ignition/modules` folder you will find a file with the following code: diff --git a/docs/src/content/hardhat-runner/docs/guides/deploying.md b/docs/src/content/hardhat-runner/docs/guides/deploying.md index f0784a2d28..9e6f8bfc01 100644 --- a/docs/src/content/hardhat-runner/docs/guides/deploying.md +++ b/docs/src/content/hardhat-runner/docs/guides/deploying.md @@ -1,8 +1,10 @@ # Deploying your contracts -To deploy your contracts, you can use [Hardhat Ignition](/ignition), our declarative deployment system. You can deploy the `Lock` contract from the sample project by using its accompanying Ignition module. An Ignition module is a TypeScript or JavaScript file that allows you to specify what needs to be deployed. +To deploy your contracts, we recommend using [Hardhat Ignition](/ignition), our declarative deployment system. Hardhat Ignition is now the preferred method for deploying contracts in Hardhat v3. -In the sample project, the Ignition module `LockModule` which deploys the `Lock` contract, is under the `./ignition/modules` directory and looks like this: +In the sample project, you'll find an Ignition module for deploying the `Lock` contract. An Ignition module is a TypeScript or JavaScript file that specifies what needs to be deployed. + +The `LockModule` which deploys the `Lock` contract is located in the `./ignition/modules` directory and looks like this: ::::tabsgroup{options="TypeScript,JavaScript"} @@ -60,4 +62,11 @@ If no network is specified, Hardhat Ignition will run against an in-memory insta In the sample `LockModule` above, two module parameters are used: `unlockTime` which will default to the 1st of Jan 2030 and `lockedAmount` which will default to one Gwei. You can learn more about overriding these values by providing your own module parameters during deployment in our [Deploying a module](/ignition/docs/guides/deploy#defining-parameters-during-deployment) guide. +Hardhat Ignition, introduced in Hardhat v3, brings several improvements to the deployment process: + +1. Declarative deployments: Define your entire deployment pipeline in a single, easy-to-understand module. +2. Built-in error handling and recovery: Automatically resume deployments from where they left off if interrupted. +3. Improved testability: Easily integrate deployments into your test suite. +4. Enhanced modularity: Create reusable deployment modules for different parts of your project. + Read more about Hardhat Ignition generally in the [Hardhat Ignition documentation](/ignition).