Skip to content

Commit 5fdefaf

Browse files
authored
Merge pull request #7022 from NomicFoundation/fix/update-ignition-network-connection
Fix to update ignition network connection
2 parents 535ded6 + b3eef2f commit 5fdefaf

File tree

6 files changed

+51
-52
lines changed

6 files changed

+51
-52
lines changed

.changeset/large-suns-shout.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"hardhat": patch
3+
---
4+
5+
Fix `--network` passing as a command line option ([#7022](https://github.com/NomicFoundation/hardhat/pull/7022))

pnpm-lock.yaml

Lines changed: 33 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

v-next/hardhat/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
"typescript": "~5.8.0"
8686
},
8787
"dependencies": {
88-
"@ignored/edr-optimism": "0.13.0-alpha.7",
88+
"@ignored/edr-optimism": "0.13.0-alpha.6",
8989
"@nomicfoundation/hardhat-errors": "workspace:^3.0.0-next.22",
9090
"@nomicfoundation/hardhat-utils": "workspace:^3.0.0-next.22",
9191
"@nomicfoundation/hardhat-zod-utils": "workspace:^3.0.0-next.22",

v-next/hardhat/src/internal/builtin-plugins/network-manager/hook-handlers/hre.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import type { HardhatRuntimeEnvironmentHooks } from "../../../../types/hooks.js";
22
import type { NetworkManager } from "../../../../types/network.js";
33

4+
import { DEFAULT_NETWORK_NAME } from "../../../constants.js";
5+
46
export default async (): Promise<Partial<HardhatRuntimeEnvironmentHooks>> => ({
57
created: async (context, hre) => {
68
let networkManager: NetworkManager | undefined;
@@ -15,6 +17,9 @@ export default async (): Promise<Partial<HardhatRuntimeEnvironmentHooks>> => ({
1517

1618
if (networkManager === undefined) {
1719
networkManager = new NetworkManagerImplementation(
20+
hre.globalOptions.network !== undefined
21+
? hre.globalOptions.network
22+
: DEFAULT_NETWORK_NAME,
1823
hre.config.defaultChainType,
1924
hre.config.networks,
2025
context.hooks,

v-next/hardhat/src/internal/builtin-plugins/network-manager/network-manager.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import { HardhatError } from "@nomicfoundation/hardhat-errors";
2424
import { readBinaryFile } from "@nomicfoundation/hardhat-utils/fs";
2525
import { deepMerge } from "@nomicfoundation/hardhat-utils/lang";
2626

27-
import { DEFAULT_NETWORK_NAME } from "../../constants.js";
2827
import { resolveConfigurationVariable } from "../../core/configuration-variables.js";
2928
import { isSupportedChainType } from "../../edr/chain-type.js";
3029

@@ -40,6 +39,7 @@ export type JsonRpcRequestWrapperFunction = (
4039
) => Promise<JsonRpcResponse>;
4140

4241
export class NetworkManagerImplementation implements NetworkManager {
42+
readonly #defaultNetwork: string;
4343
readonly #defaultChainType: DefaultChainType;
4444
readonly #networkConfigs: Readonly<Record<string, Readonly<NetworkConfig>>>;
4545
readonly #hookManager: Readonly<HookManager>;
@@ -50,13 +50,15 @@ export class NetworkManagerImplementation implements NetworkManager {
5050
#nextConnectionId = 0;
5151

5252
constructor(
53+
defaultNetwork: string,
5354
defaultChainType: DefaultChainType,
5455
networkConfigs: Record<string, NetworkConfig>,
5556
hookManager: HookManager,
5657
artifactsManager: ArtifactManager,
5758
userConfigNetworks: Record<string, NetworkUserConfig> | undefined,
5859
chainDescriptors: ChainDescriptorsConfig,
5960
) {
61+
this.#defaultNetwork = defaultNetwork;
6062
this.#defaultChainType = defaultChainType;
6163
this.#networkConfigs = networkConfigs;
6264
this.#hookManager = hookManager;
@@ -100,7 +102,7 @@ export class NetworkManagerImplementation implements NetworkManager {
100102
chainType?: ChainTypeT,
101103
networkConfigOverride?: NetworkConfigOverride,
102104
): Promise<NetworkConnection<ChainTypeT>> {
103-
const resolvedNetworkName = networkName ?? DEFAULT_NETWORK_NAME;
105+
const resolvedNetworkName = networkName ?? this.#defaultNetwork;
104106

105107
if (this.#networkConfigs[resolvedNetworkName] === undefined) {
106108
throw new HardhatError(

v-next/hardhat/test/internal/builtin-plugins/network-manager/network-manager.ts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -126,25 +126,12 @@ describe("NetworkManagerImplementation", () => {
126126
"",
127127
(varOrStr) => resolveConfigurationVariable(hre.hooks, varOrStr),
128128
),
129-
default: resolveEdrNetwork(
130-
{
131-
type: "edr",
132-
initialDate,
133-
mining: {
134-
auto: true,
135-
mempool: {
136-
order: "priority",
137-
},
138-
},
139-
},
140-
"",
141-
(varOrStr) => resolveConfigurationVariable(hre.hooks, varOrStr),
142-
),
143129
};
144130

145131
chainDescriptors = await resolveChainDescriptors(undefined);
146132

147133
networkManager = new NetworkManagerImplementation(
134+
"localhost",
148135
GENERIC_CHAIN_TYPE,
149136
networks,
150137
hre.hooks,
@@ -157,9 +144,9 @@ describe("NetworkManagerImplementation", () => {
157144
describe("connect", () => {
158145
it("should connect to the default network and chain type if none are provided", async () => {
159146
const networkConnection = await networkManager.connect();
160-
assert.equal(networkConnection.networkName, "default");
147+
assert.equal(networkConnection.networkName, "localhost");
161148
assert.equal(networkConnection.chainType, GENERIC_CHAIN_TYPE);
162-
assert.deepEqual(networkConnection.networkConfig, networks.default);
149+
assert.deepEqual(networkConnection.networkConfig, networks.localhost);
163150
});
164151

165152
it("should connect to the specified network and default chain type if none are provided and the network doesn't have a chain type", async () => {

0 commit comments

Comments
 (0)