Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions v-next/example-project/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ const exampleEmptyTask = emptyTask("empty", "An example empty task").build();

const exampleEmptySubtask = task(["empty", "task"])
.setDescription("An example empty subtask task")
.setAction(async () => ({
.setLazyAction(async () => ({
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, this was confusing on my end, sorry. I think from the POV of a user we should change it. I was referring only to the field in the builder and definitions.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this does look like a breaking change without a real benefit otherwise

default: async (_, _hre) => {
console.log("empty task");
},
}))
.build();

const exampleTaskOverride = task("example2")
.setAction(async () => ({
.setLazyAction(async () => ({
default: async (_, _hre) => {
console.log("from an override");
},
Expand Down Expand Up @@ -76,23 +76,23 @@ const greeting = task("hello", "Print a greeting")
defaultValue: false,
hidden: true,
})
.setAction(async () => ({
.setLazyAction(async () => ({
default: async ({ greeting }, _) => {
console.log(greeting);
},
}))
.build();

const printConfig = task("config", "Print the config")
.setAction(async () => ({
.setLazyAction(async () => ({
default: async ({}, hre) => {
console.log(util.inspect(hre.config, { colors: true, depth: null }));
},
}))
.build();

const printAccounts = task("accounts", "Print the accounts")
.setAction(async () => ({
.setLazyAction(async () => ({
default: async ({}, hre) => {
const { provider } = await hre.network.connect();
console.log(await provider.request({ method: "eth_accounts" }));
Expand All @@ -109,7 +109,7 @@ const pluginExample = {
description: "The greeting to print",
defaultValue: "Hello, World from community-plugin!",
})
.setAction(async () => ({
.setLazyAction(async () => ({
default: async ({ greeting }, _) => {
console.log(greeting);

Expand Down
8 changes: 4 additions & 4 deletions v-next/hardhat-errors/src/descriptors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -559,12 +559,12 @@ Please install a version of the peer dependency that meets the plugin's requirem
},
},
TASK_DEFINITIONS: {
INVALID_FILE_ACTION: {
INVALID_LAZY_ACTION: {
number: 400,
messageTemplate:
"Invalid file action: {action} is not a valid file URL",
websiteTitle: "Invalid file action",
websiteDescription: `The setAction function was called with a string parameter that is not a valid file URL. A valid file URL must start with 'file://'.
websiteDescription: `The setLazyAction function was called with a string parameter that is not a valid file URL. A valid file URL must start with 'file://'.

Please ensure that you are providing a correct file URL.`,
},
Expand Down Expand Up @@ -704,9 +704,9 @@ Please define the action in a separate file and reference it.`,
},
ACTION_ALREADY_SET: {
number: 418,
messageTemplate: `The action for task "{task}" has already been set. You can only call "setAction" or "setInlineAction" once per task definition.`,
messageTemplate: `The action for task "{task}" has already been set. You can only call "setLazyAction" or "setInlineAction" once per task definition.`,
websiteTitle: "Task action already set",
websiteDescription: `A task definition can only have one action. You cannot call "setAction" or "setInlineAction" more than once on the same task builder.
websiteDescription: `A task definition can only have one action. You cannot call "setLazyAction" or "setInlineAction" more than once on the same task builder.

Please remove the duplicate call.`,
},
Expand Down
18 changes: 9 additions & 9 deletions v-next/hardhat-ignition/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,18 @@ const hardhatIgnitionPlugin: HardhatPlugin = {
description:
"Write deployment information to disk when deploying to the in-memory network",
})
.setAction(() => import("./internal/tasks/deploy.js"))
.setLazyAction(() => import("./internal/tasks/deploy.js"))
.build(),
task(["ignition", "status"], "Show the current status of a deployment")
.addPositionalArgument({
name: "deploymentId",
type: ArgumentType.STRING,
description: "The id of the deployment to show",
})
.setAction(() => import("./internal/tasks/status.js"))
.setLazyAction(() => import("./internal/tasks/status.js"))
.build(),
task(["ignition", "deployments"], "List all deployment IDs")
.setAction(() => import("./internal/tasks/deployments.js"))
.setLazyAction(() => import("./internal/tasks/deployments.js"))
.build(),
task(
["ignition", "transactions"],
Expand All @@ -85,7 +85,7 @@ const hardhatIgnitionPlugin: HardhatPlugin = {
type: ArgumentType.STRING,
description: "The id of the deployment to show transactions for",
})
.setAction(() => import("./internal/tasks/transactions.js"))
.setLazyAction(() => import("./internal/tasks/transactions.js"))
.build(),
task(["ignition", "wipe"], "Reset a deployment's future to allow rerunning")
.addPositionalArgument({
Expand All @@ -98,7 +98,7 @@ const hardhatIgnitionPlugin: HardhatPlugin = {
type: ArgumentType.STRING,
description: "The id of the future to wipe",
})
.setAction(() => import("./internal/tasks/wipe.js"))
.setLazyAction(() => import("./internal/tasks/wipe.js"))
.build(),
task(["ignition", "visualize"], "Visualize a module as an HTML report")
.addPositionalArgument({
Expand All @@ -110,7 +110,7 @@ const hardhatIgnitionPlugin: HardhatPlugin = {
name: "noOpen",
description: "Disables opening report in browser",
})
.setAction(() => import("./internal/tasks/visualize.js"))
.setLazyAction(() => import("./internal/tasks/visualize.js"))
.build(),

task(
Expand All @@ -126,7 +126,7 @@ const hardhatIgnitionPlugin: HardhatPlugin = {
name: "force",
description: "Force verification",
})
.setAction(() => import("./internal/tasks/verify.js"))
.setLazyAction(() => import("./internal/tasks/verify.js"))
.build(),
task(
["ignition", "track-tx"],
Expand All @@ -142,7 +142,7 @@ const hardhatIgnitionPlugin: HardhatPlugin = {
type: ArgumentType.STRING,
description: "The id of the deployment to add the tx to",
})
.setAction(() => import("./internal/tasks/track-tx.js"))
.setLazyAction(() => import("./internal/tasks/track-tx.js"))
.build(),
task(
["ignition", "migrate"],
Expand All @@ -153,7 +153,7 @@ const hardhatIgnitionPlugin: HardhatPlugin = {
type: ArgumentType.STRING,
description: "The id of the deployment to migrate",
})
.setAction(() => import("./internal/tasks/migrate.js"))
.setLazyAction(() => import("./internal/tasks/migrate.js"))
.build(),
],
};
Expand Down
2 changes: 1 addition & 1 deletion v-next/hardhat-ignition/test/deploy/build-profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe("build profile", function () {
plugins: [hardhatIgnitionPlugin],
tasks: [
overrideTask("build")
.setAction(async () => ({
.setLazyAction(async () => ({
default: async (args, _hre, runSuper) => {
defaultBuildProfile = args.defaultBuildProfile;

Expand Down
12 changes: 6 additions & 6 deletions v-next/hardhat-keystore/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const hardhatKeystorePlugin: HardhatPlugin = {
description:
"Use the development keystore instead of the production one",
})
.setAction(() => import("./internal/tasks/set.js"))
.setLazyAction(() => import("./internal/tasks/set.js"))
.build(),

task(["keystore", "get"], "Get a value given a key")
Expand All @@ -49,7 +49,7 @@ const hardhatKeystorePlugin: HardhatPlugin = {
type: ArgumentType.STRING,
description: "Specify the key to retrieve the value for",
})
.setAction(() => import("./internal/tasks/get.js"))
.setLazyAction(() => import("./internal/tasks/get.js"))
.build(),

task(["keystore", "list"], "List all keys in the keystore")
Expand All @@ -58,7 +58,7 @@ const hardhatKeystorePlugin: HardhatPlugin = {
description:
"Use the development keystore instead of the production one",
})
.setAction(() => import("./internal/tasks/list.js"))
.setLazyAction(() => import("./internal/tasks/list.js"))
.build(),

task(["keystore", "delete"], "Delete a key from the keystore")
Expand All @@ -77,7 +77,7 @@ const hardhatKeystorePlugin: HardhatPlugin = {
description:
"Force to not throw an error if the key does not exist during deletion.",
})
.setAction(() => import("./internal/tasks/delete.js"))
.setLazyAction(() => import("./internal/tasks/delete.js"))
.build(),

task(["keystore", "path"], "Display the path where the keystore is stored")
Expand All @@ -86,7 +86,7 @@ const hardhatKeystorePlugin: HardhatPlugin = {
description:
"Use the development keystore instead of the production one",
})
.setAction(() => import("./internal/tasks/path.js"))
.setLazyAction(() => import("./internal/tasks/path.js"))
.build(),

task(
Expand All @@ -98,7 +98,7 @@ const hardhatKeystorePlugin: HardhatPlugin = {
description:
"Use the development keystore instead of the production one",
})
.setAction(() => import("./internal/tasks/change-password.js"))
.setLazyAction(() => import("./internal/tasks/change-password.js"))
.build(),
],
npmPackage: "@nomicfoundation/hardhat-keystore",
Expand Down
2 changes: 1 addition & 1 deletion v-next/hardhat-mocha/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const hardhatPlugin: HardhatPlugin = {
name: "noCompile",
description: "Don't compile the project before running the tests",
})
.setAction(() => import("./task-action.js"))
.setLazyAction(() => import("./task-action.js"))
.build(),
],
hookHandlers: {
Expand Down
2 changes: 1 addition & 1 deletion v-next/hardhat-node-test-runner/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const hardhatPlugin: HardhatPlugin = {
defaultValue: 0,
hidden: true,
})
.setAction(() => import("./task-action.js"))
.setLazyAction(() => import("./task-action.js"))
.build(),
],
hookHandlers: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { extendWithVerificationArgs } from "../utils.js";
const verifyBlockscoutTask: PluginTaskDefinition = extendWithVerificationArgs(
task(["verify", "blockscout"], "Verify a contract on Blockscout"),
)
.setAction(() => import("./task-action.js"))
.setLazyAction(() => import("./task-action.js"))
.build();

export default verifyBlockscoutTask;
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { extendWithVerificationArgs } from "../utils.js";
const verifyEtherscanTask: PluginTaskDefinition = extendWithVerificationArgs(
task(["verify", "etherscan"], "Verify a contract on Etherscan"),
)
.setAction(() => import("./task-action.js"))
.setLazyAction(() => import("./task-action.js"))
.build();

export default verifyEtherscanTask;
2 changes: 1 addition & 1 deletion v-next/hardhat-verify/src/internal/tasks/verify/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const verifyTask: PluginTaskDefinition = extendWithSourcifyArgs(
task("verify", "Verify a contract on all supported explorers"),
),
)
.setAction(() => import("./task-action.js"))
.setLazyAction(() => import("./task-action.js"))
.build();

export default verifyTask;
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const verifySourcifyTask: PluginTaskDefinition = extendWithSourcifyArgs(
),
false,
)
.setAction(() => import("./task-action.js"))
.setLazyAction(() => import("./task-action.js"))
.build();

export default verifySourcifyTask;
2 changes: 1 addition & 1 deletion v-next/hardhat/src/internal/builtin-plugins/clean/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const hardhatPlugin: HardhatPlugin = {
name: "global",
description: "Clear the global cache",
})
.setAction(async () => import("./task-action.js"))
.setLazyAction(async () => import("./task-action.js"))
.build(),
],
npmPackage: "hardhat",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const hardhatPlugin: HardhatPlugin = {
description: "Commands to run when the console starts",
defaultValue: [],
})
.setAction(async () => import("./task-action.js"))
.setLazyAction(async () => import("./task-action.js"))
.build(),
],
dependencies: () => [import("../solidity/index.js")],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const hardhatPlugin: HardhatPlugin = {
description: "An optional list of files to flatten",
type: ArgumentType.FILE,
})
.setAction(async () => import("./task-action.js"))
.setLazyAction(async () => import("./task-action.js"))
.build(),
],
};
Expand Down
2 changes: 1 addition & 1 deletion v-next/hardhat/src/internal/builtin-plugins/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const hardhatPlugin: HardhatPlugin = {
type: ArgumentType.INT,
defaultValue: -1,
})
.setAction(async () => import("./task-action.js"))
.setLazyAction(async () => import("./task-action.js"))
.build(),
],
dependencies: () => [import("../network-manager/index.js")],
Expand Down
2 changes: 1 addition & 1 deletion v-next/hardhat/src/internal/builtin-plugins/run/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const hardhatPlugin: HardhatPlugin = {
name: "noCompile",
description: "Do not compile the project before running the script",
})
.setAction(async () => import("./task-action.js"))
.setLazyAction(async () => import("./task-action.js"))
.build(),
],
dependencies: () => [import("../solidity/index.js")],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const hardhatPlugin: HardhatPlugin = {
defaultValue: 0,
hidden: true,
})
.setAction(async () => import("./task-action.js"))
.setLazyAction(async () => import("./task-action.js"))
.build(),
],
dependencies: () => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const buildTask = task("build", "Build project")
name: "noContracts",
description: "Skip solidity contracts compilation",
})
.setAction(async () => import("./tasks/build.js"))
.setLazyAction(async () => import("./tasks/build.js"))
.build();

const hardhatPlugin: HardhatPlugin = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const hardhatPlugin: HardhatPlugin = {
name: "disable",
description: "Disable telemetry",
})
.setAction(async () => import("./task-action.js"))
.setLazyAction(async () => import("./task-action.js"))
.build(),
],
npmPackage: "hardhat",
Expand Down
2 changes: 1 addition & 1 deletion v-next/hardhat/src/internal/builtin-plugins/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const hardhatPlugin: HardhatPlugin = {
description: "Verbosity level of the test output",
defaultValue: DEFAULT_VERBOSITY,
})
.setAction(async () => import("./task-action.js"))
.setLazyAction(async () => import("./task-action.js"))
.build(),
],
dependencies: () => [import("../solidity/index.js")],
Expand Down
22 changes: 11 additions & 11 deletions v-next/hardhat/src/internal/core/config-validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,33 +339,33 @@ export function validateTaskOverride(
}

function validateActionFields(
task: { action?: unknown; inlineAction?: unknown },
task: { lazyAction?: unknown; inlineAction?: unknown },
path: Array<string | number>,
): HardhatUserConfigValidationError[] {
const validationErrors: HardhatUserConfigValidationError[] = [];

// Mutual exclusivity: cannot have both action and inlineAction
if (task.action !== undefined && task.inlineAction !== undefined) {
// Mutual exclusivity: cannot have both lazyAction and inlineAction
if (task.lazyAction !== undefined && task.inlineAction !== undefined) {
validationErrors.push({
path: [...path],
message: 'task cannot define both "action" and "inlineAction"',
message: 'task cannot define both "lazyAction" and "inlineAction"',
});
}

// At least one action must be defined
if (task.action === undefined && task.inlineAction === undefined) {
if (task.lazyAction === undefined && task.inlineAction === undefined) {
validationErrors.push({
path: [...path, "action"],
message: 'task must define either "action" or "inlineAction"',
path: [...path, "lazyAction"],
message: 'task must define either "lazyAction" or "inlineAction"',
});
}

if (task.action !== undefined) {
if (typeof task.action !== "function") {
if (task.lazyAction !== undefined) {
if (typeof task.lazyAction !== "function") {
validationErrors.push({
path: [...path, "action"],
path: [...path, "lazyAction"],
message:
"task action must be a lazy import function returning a module with a default export",
"task lazyAction must be a lazy import function returning a module with a default export",
});
}
}
Expand Down
Loading