Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
a0faba2
add v 23
ChristopherDedominici Mar 24, 2025
c9e6d94
Merge branch 'main' of github.com:NomicFoundation/hardhat into add-su…
ChristopherDedominici Mar 24, 2025
c2b8b85
Create short-mangos-watch.md
ChristopherDedominici Mar 24, 2025
b01ac97
update test to warn on old/new supported versions
ChristopherDedominici Mar 24, 2025
c0db515
Merge branch 'add-support-node-v23' of github.com:NomicFoundation/har…
ChristopherDedominici Mar 24, 2025
9dc6799
Update short-mangos-watch.md
ChristopherDedominici Mar 24, 2025
f013981
fix compilation issues for tests in hh-chai-matchers and hh-ethers
ChristopherDedominici Mar 25, 2025
6d71cc7
Merge branch 'add-support-node-v23' of github.com:NomicFoundation/har…
ChristopherDedominici Mar 25, 2025
d143159
modify SUPPORTED_NODE_VERSIONS to use 24 instead of 23
ChristopherDedominici Mar 25, 2025
816fddc
fix private methods starting with `_` + tests
ChristopherDedominici Mar 26, 2025
7480f37
hardhat-ignition: fix private methods in tests
ChristopherDedominici Mar 26, 2025
84fb602
Merge branch 'main' of github.com:NomicFoundation/hardhat into add-su…
ChristopherDedominici May 13, 2025
902403e
23 -> 24
ChristopherDedominici May 13, 2025
09d4ca7
comment out failing test on windows
ChristopherDedominici May 13, 2025
79d1a17
fix comment
ChristopherDedominici May 13, 2025
efbf23d
Update packages/hardhat-core/src/internal/cli/constants.ts
ChristopherDedominici May 14, 2025
811f8b6
still support v 18
ChristopherDedominici May 14, 2025
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
5 changes: 5 additions & 0 deletions .changeset/short-mangos-watch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"hardhat": patch
---

Added support for Node v24.
2 changes: 1 addition & 1 deletion .github/workflows/hardhat-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
matrix:
package: ${{ fromJson(needs.list-packages.outputs.packages) }}
os: [ubuntu-latest, macos-latest, windows-latest]
node: [18, 20, 22]
node: [20, 22, 24]
exclude:
- package: hardhat-vyper
os: windows-latest
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/hardhat-core-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
# TODO: Currently there is no @types/node for Node 22,
# TODO: Currently there is no @types/node for Node 24,
# include it when it is available.
node: [18, 20]
node: [20, 22]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-env
Expand Down
9 changes: 6 additions & 3 deletions packages/hardhat-chai-matchers/test/contracts.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import {
BaseContract,
BaseContractMethod,
// eslint-disable-next-line prettier/prettier
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Needed because otherwise the lint task will fail

type BaseContractMethod,
ContractTransactionResponse,
BigNumberish,
AddressLike,
// eslint-disable-next-line prettier/prettier
type BigNumberish,
// eslint-disable-next-line prettier/prettier
type AddressLike,
} from "ethers";

export type MatchersContract = BaseContract & {
Expand Down
8 changes: 7 additions & 1 deletion packages/hardhat-core/src/internal/cli/constants.ts
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
export const SUPPORTED_NODE_VERSIONS = ["^18.0.0", "^20.0.0", "^22.0.0"];
// TODO: Remove 18 on June 30, 2025
export const SUPPORTED_NODE_VERSIONS = [
"^18.0.0",
"^20.0.0",
"^22.0.0",
"^24.0.0",
];
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export function importCsjOrEsModule(filePath: string): any {
// because Hardhat configs can only be CJS but a .js extension will be interpreted as ESM.
// The kind of error we get in these cases depends on the Node.js version.
const node20Heuristic = e.code === "ERR_REQUIRE_ESM";
// Also works for node v24
const node22Heuristic =
e.message === "module is not defined" ||
e.message === "require is not defined";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ describe("isNodeVersionToWarnOn", function () {

assert.isFalse(isNodeVersionToWarnOn("v22.0.0"));
assert.isFalse(isNodeVersionToWarnOn("v22.3.0"));
});

it("Should not warn on even newer versions even if they are unsupported", function () {
assert.isFalse(isNodeVersionToWarnOn("v24.0.0"));
assert.isFalse(isNodeVersionToWarnOn("v24.3.0"));
});

it("Should not warn on even newer versions even if they are unsupported", function () {
assert.isFalse(isNodeVersionToWarnOn("v26.0.0"));
assert.isFalse(isNodeVersionToWarnOn("v26.3.0"));
});

it("Should warn on unsupported older node versions", function () {
assert(isNodeVersionToWarnOn("v10.0.0"));
assert(isNodeVersionToWarnOn("v10.24.1"));
Expand Down
3 changes: 2 additions & 1 deletion packages/hardhat-ethers/test/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { assert } from "chai";
import { ContractRunner, Signer } from "ethers";
// eslint-disable-next-line prettier/prettier
import { type ContractRunner, type Signer } from "ethers";

export function assertWithin(
value: number | bigint,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,17 @@ function setupMockJsonRpcClient(
}

class MockJsonRpcClient implements JsonRpcClient {
private _blockNumber = 10;
#blockNumber = 10;
#transactions: { [key: string]: TransactionReceipt };
#sendTransaction: (transactionParams: TransactionParams) => Promise<string>;

constructor(
private _sendTransaction: (
transactionParams: TransactionParams
) => Promise<string>,
private _transactions: { [key: string]: TransactionReceipt }
) {}
sendTransaction: (transactionParams: TransactionParams) => Promise<string>,
transactions: { [key: string]: TransactionReceipt }
) {
this.#sendTransaction = sendTransaction;
this.#transactions = transactions;
}

public async getChainId(): Promise<number> {
return 31337;
Expand All @@ -113,7 +116,7 @@ class MockJsonRpcClient implements JsonRpcClient {
}

public async getLatestBlock(): Promise<Block> {
const blockNumber = this._blockNumber++;
const blockNumber = this.#blockNumber++;

return {
hash: `0xblockhash-${blockNumber}`,
Expand Down Expand Up @@ -152,7 +155,7 @@ class MockJsonRpcClient implements JsonRpcClient {
public async sendTransaction(
transactionParams: TransactionParams
): Promise<string> {
return this._sendTransaction(transactionParams);
return this.#sendTransaction(transactionParams);
}

public async sendRawTransaction(_presignedTx: string): Promise<string> {
Expand Down Expand Up @@ -181,11 +184,11 @@ class MockJsonRpcClient implements JsonRpcClient {
txHash: string
): Promise<TransactionReceipt | undefined> {
assertIgnitionInvariant(
txHash in this._transactions,
txHash in this.#transactions,
`No transaction registered in test for the hash ${txHash}`
);

return this._transactions[txHash];
return this.#transactions[txHash];
}

public async getCode(_address: string): Promise<string> {
Expand Down
20 changes: 12 additions & 8 deletions packages/hardhat-ignition-core/test/reconciliation/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,26 +92,30 @@ class MockArtifactResolver implements ArtifactResolver {
}

export class ArtifactMapResolver extends MockArtifactResolver {
constructor(
private readonly _artifactMap: { [artifactId: string]: Artifact } = {}
) {
readonly #artifactMap: { [artifactId: string]: Artifact };

constructor(artifactMap: { [artifactId: string]: Artifact } = {}) {
super();

this.#artifactMap = artifactMap;
}

public async loadArtifact(contractName: string): Promise<Artifact> {
return this._artifactMap[contractName];
return this.#artifactMap[contractName];
}
}

export class ArtifactMapDeploymentLoader extends MockDeploymentLoader {
constructor(
private readonly _artifactMap: { [artifactId: string]: Artifact } = {}
) {
readonly #artifactMap: { [artifactId: string]: Artifact };

constructor(artifactMap: { [artifactId: string]: Artifact } = {}) {
super();

this.#artifactMap = artifactMap;
}

public async loadArtifact(contractName: string): Promise<Artifact> {
return this._artifactMap[contractName];
return this.#artifactMap[contractName];
}
}

Expand Down
25 changes: 13 additions & 12 deletions packages/hardhat-ignition-core/test/track-transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import path from "path";
import { EIP1193Provider, RequestArguments, trackTransaction } from "../src";
import { NetworkTransaction } from "../src/internal/execution/types/jsonrpc";
import { JournalMessageType } from "../src/internal/execution/types/messages";
import { ERRORS } from "../src/internal/errors-list";

const mockFullTx = {
hash: "0x1a3eb512e21fc849f8e8733b250ce49b61178c9c4a670063f969db59eda4a59f",
Expand All @@ -23,10 +24,16 @@ const mockFullTx = {
};

class MockEIP1193Provider implements EIP1193Provider {
public fullTx: NetworkTransaction | null = null;
public confirmations: number = 6;

constructor(
public fullTx: NetworkTransaction | null = null,
public confirmations: number = 6
) {}
fullTx: NetworkTransaction | null = null,
confirmations: number = 6
) {
this.fullTx = fullTx;
this.confirmations = confirmations;
}

public async request(args: RequestArguments): Promise<any> {
if (args.method === "eth_getTransactionByHash") {
Expand Down Expand Up @@ -218,9 +225,7 @@ If this is not the expected behavior, please edit your Hardhat Ignition module a
mockFullTx.hash,
new MockEIP1193Provider(mockFullTx)
),
`The transaction hash that you provided was already present in your deployment.

Please double check the error you are getting when running Hardhat Ignition, and the instructions it's providing.`
ERRORS.TRACK_TRANSACTION.KNOWN_TRANSACTION.message
);
});

Expand All @@ -238,9 +243,7 @@ Please double check the error you are getting when running Hardhat Ignition, and
hash,
new MockEIP1193Provider({ ...mockFullTx, hash }, 2)
),
`The transaction you provided doesn't have enough confirmations yet.

Please try again later.`
ERRORS.TRACK_TRANSACTION.INSUFFICIENT_CONFIRMATIONS.message
);
});

Expand Down Expand Up @@ -274,9 +277,7 @@ Please double check the error you are getting when running Hardhat Ignition, and
mockFullTx.hash,
new MockEIP1193Provider({ ...mockFullTx, value: "0x11" }, 2)
),
`The transaction you provided doesn't have enough confirmations yet.

Please try again later.`
ERRORS.TRACK_TRANSACTION.INSUFFICIENT_CONFIRMATIONS.message
);
});
});
Expand Down
30 changes: 17 additions & 13 deletions packages/hardhat-ignition/test/test-helpers/test-ignition-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,21 @@ export interface TypeChainViemContractByName {
export class TestIgnitionHelper {
public type = "test";

private _provider: EIP1193Provider;
private _deploymentDir: string | undefined;
#hre: HardhatRuntimeEnvironment;
#config?: Partial<DeployConfig>;
#provider: EIP1193Provider;
#deploymentDir: string | undefined;

constructor(
private _hre: HardhatRuntimeEnvironment,
private _config?: Partial<DeployConfig>,
hre: HardhatRuntimeEnvironment,
config?: Partial<DeployConfig>,
provider?: EIP1193Provider,
deploymentDir?: string
) {
this._provider = provider ?? this._hre.network.provider;
this._deploymentDir = deploymentDir;
this.#hre = hre;
this.#config = config;
this.#provider = provider ?? this.#hre.network.provider;
this.#deploymentDir = deploymentDir;
}

public async deploy<
Expand Down Expand Up @@ -86,21 +90,21 @@ export class TestIgnitionHelper {
): Promise<
IgnitionModuleResultsTToViemContracts<ContractNameT, IgnitionModuleResultsT>
> {
const accounts = (await this._hre.network.provider.request({
const accounts = (await this.#hre.network.provider.request({
method: "eth_accounts",
})) as string[];

const artifactResolver = new HardhatArtifactResolver(this._hre);
const artifactResolver = new HardhatArtifactResolver(this.#hre);

const resolvedConfig: Partial<DeployConfig> = {
...this._config,
...this.#config,
...perDeployConfig,
};

const result = await deploy({
config: resolvedConfig,
provider: this._provider,
deploymentDir: this._deploymentDir,
provider: this.#provider,
deploymentDir: this.#deploymentDir,
artifactResolver,
ignitionModule,
deploymentParameters: parameters,
Expand All @@ -118,11 +122,11 @@ export class TestIgnitionHelper {

const publicClient = createPublicClient({
chain: hardhat,
transport: custom(this._hre.network.provider),
transport: custom(this.#hre.network.provider),
});

return this._toViemContracts(
this._hre,
this.#hre,
ignitionModule,
result,
publicClient
Expand Down
28 changes: 18 additions & 10 deletions packages/hardhat-ignition/test/test-helpers/use-ignition-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,22 @@ function setupIgnitionHelperRiggedToThrow(
}

export class TestChainHelper {
#hre: HardhatRuntimeEnvironment;
#deployPromise: Promise<any>;
#exitFn: () => void;

constructor(
private _hre: HardhatRuntimeEnvironment,
private _deployPromise: Promise<any>,
private _exitFn: () => void
) {}
hre: HardhatRuntimeEnvironment,
deployPromise: Promise<any>,
exitFn: () => void
) {
this.#hre = hre;
this.#deployPromise = deployPromise;
this.#exitFn = exitFn;
}

public async waitForPendingTxs(expectedCount: number) {
await waitForPendingTxs(this._hre, expectedCount, this._deployPromise);
await waitForPendingTxs(this.#hre, expectedCount, this.#deployPromise);
}

/**
Expand All @@ -201,24 +209,24 @@ export class TestChainHelper {
*/
public async mineBlock(pendingTxToAwait: number = 0) {
if (pendingTxToAwait > 0) {
await waitForPendingTxs(this._hre, pendingTxToAwait, this._deployPromise);
await waitForPendingTxs(this.#hre, pendingTxToAwait, this.#deployPromise);
}

return this._hre.network.provider.send("evm_mine");
return this.#hre.network.provider.send("evm_mine");
}

public async clearMempool(pendingTxToAwait: number = 0) {
if (pendingTxToAwait > 0) {
await waitForPendingTxs(this._hre, pendingTxToAwait, this._deployPromise);
await waitForPendingTxs(this.#hre, pendingTxToAwait, this.#deployPromise);
}

return clearPendingTransactionsFromMemoryPool(this._hre);
return clearPendingTransactionsFromMemoryPool(this.#hre);
}

/**
* Exit from the deploy on the next block tick.
*/
public exitDeploy() {
this._exitFn();
this.#exitFn();
}
}
Loading
Loading