Skip to content
Merged
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
2 changes: 1 addition & 1 deletion packages/example-project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"devDependencies": {
"@tsconfig/node22": "^22.0.2",
"@types/node": "^22.11.0",
"hardhat": "^3.0.11",
"hardhat": "^3.4.0",
"hardhat-my-plugin": "workspace:*",
"typescript": "~5.8.0",
"forge-std": "github:foundry-rs/forge-std#v1.9.4"
Expand Down
2 changes: 1 addition & 1 deletion packages/example-project/scripts/example-script.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { network } from "hardhat";

console.log("Running example script");
const { provider } = await network.connect();
const { provider } = await network.create();

const accounts = await provider.send("eth_accounts", []);

Expand Down
2 changes: 1 addition & 1 deletion packages/example-project/scripts/my-account-example.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { network } from "hardhat";

const connection = await network.connect();
const connection = await network.create();

console.log("connection.myAccount:", connection.myAccount);
4 changes: 1 addition & 3 deletions packages/plugin/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@ import eslint from "@eslint/js";
import { defineConfig } from "eslint/config";
import tseslint from "typescript-eslint";
import * as importPlugin from "eslint-plugin-import";
import path from "node:path";

export default defineConfig(
{
languageOptions: {
ecmaVersion: 2022,
parser: tseslint.parser,
parserOptions: {
project: path.join(import.meta.dirname, "tsconfig.json"),
tsconfigRootDir: path.join(import.meta.dirname, "tsconfig.json"),
tsconfigRootDir: import.meta.dirname,
projectService: true,
},
},
Expand Down
6 changes: 3 additions & 3 deletions packages/plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,21 @@
],
"devDependencies": {
"@eslint/js": "^9.35.0",
"@nomicfoundation/hardhat-node-test-reporter": "^3.0.0",
"@nomicfoundation/hardhat-node-test-reporter": "^3.0.4",
"@tsconfig/node22": "^22.0.2",
"@types/node": "^22.11.0",
"c8": "^9.1.0",
"eslint": "^9.35.0",
"eslint-import-resolver-typescript": "^4.4.4",
"eslint-plugin-import": "^2.32.0",
"hardhat": "^3.0.11",
"hardhat": "^3.3.0",
"prettier": "3.6.2",
"rimraf": "^5.0.5",
"tsx": "^4.19.3",
"typescript": "~5.8.0",
"typescript-eslint": "^8.43.0"
},
"peerDependencies": {
"hardhat": "^3.0.11"
"hardhat": "^3.4.0"
}
}
2 changes: 1 addition & 1 deletion packages/plugin/src/tasks/my-account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default async function (
taskArguments: MyAccountTaskArguments,
hre: HardhatRuntimeEnvironment,
) {
const conn = await hre.network.connect();
const conn = await hre.network.create();
console.log(taskArguments.title);
console.log(conn.myAccount);
}
13 changes: 5 additions & 8 deletions packages/plugin/test/myAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,30 @@ describe("myAccount initialization on network connection", () => {
it("should initialize the myAccount field on the network connection", async () => {
const hre = await createFixtureProjectHRE("base-project");

await assertMyAccount(await hre.network.connect("withMyAccountIndex"), 1);
await assertMyAccount(
await hre.network.connect("withoutMyAccountIndex"),
0,
);
await assertMyAccount(await hre.network.create("withMyAccountIndex"), 1);
await assertMyAccount(await hre.network.create("withoutMyAccountIndex"), 0);
});

it("should take into account the `accounts` field", async () => {
const hre = await createFixtureProjectHRE("base-project");

await assertMyAccount(await hre.network.connect("withCustomAccounts"), 0);
await assertMyAccount(await hre.network.create("withCustomAccounts"), 0);
});

it("should throw a plugin error if the myAccountIndex is too high with respect to the accounts", async () => {
const hre = await createFixtureProjectHRE("base-project");

await assert.rejects(
async () => {
await hre.network.connect("withMyAccountIndexTooHigh");
await hre.network.create("withMyAccountIndexTooHigh");
},
HardhatPluginError,
"hardhat-plugin-template: Invalid index 100000 for myAccount when connecting to network withMyAccountIndexTooHigh",
);

await assert.rejects(
async () => {
await hre.network.connect("withoutAccounts");
await hre.network.create("withoutAccounts");
},
HardhatPluginError,
"hardhat-plugin-template: Invalid index 0 for myAccount when connecting to network withoutAccounts",
Expand Down
Loading
Loading