Skip to content

Commit 57d04c7

Browse files
committed
Make global parameters map name consistent across the codebase
1 parent 1b4dafb commit 57d04c7

File tree

8 files changed

+49
-49
lines changed

8 files changed

+49
-49
lines changed

v-next/core/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ export async function createHardhatRuntimeEnvironment(
2828
}
2929

3030
export { resolvePluginList } from "./internal/plugins/resolve-plugin-list.js";
31-
export { buildGlobalParameterMap } from "./internal/global-parameters.js";
31+
export { buildGlobalParametersMap } from "./internal/global-parameters.js";

v-next/core/src/internal/global-parameters.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { ParameterTypeToValueType } from "../types/common.js";
22
import type {
33
GlobalArguments,
44
GlobalParameter,
5-
GlobalParameterMap,
5+
GlobalParametersMap,
66
} from "../types/global-parameters.js";
77
import type { HardhatPlugin } from "../types/plugins.js";
88

@@ -23,18 +23,18 @@ import {
2323
* shouldn't be consider validated. Hence, we should validate the global
2424
* parameters.
2525
*/
26-
export function buildGlobalParameterMap(
26+
export function buildGlobalParametersMap(
2727
resolvedPlugins: HardhatPlugin[],
28-
): GlobalParameterMap {
29-
const globalParametersIndex: GlobalParameterMap = new Map();
28+
): GlobalParametersMap {
29+
const globalParametersMap: GlobalParametersMap = new Map();
3030

3131
for (const plugin of resolvedPlugins) {
3232
if (plugin.globalParameters === undefined) {
3333
continue;
3434
}
3535

3636
for (const param of plugin.globalParameters) {
37-
const existingByName = globalParametersIndex.get(param.name);
37+
const existingByName = globalParametersMap.get(param.name);
3838
if (existingByName !== undefined) {
3939
throw new HardhatError(
4040
HardhatError.ERRORS.GENERAL.GLOBAL_PARAMETER_ALREADY_DEFINED,
@@ -48,16 +48,16 @@ export function buildGlobalParameterMap(
4848

4949
const validatedGlobalParam = buildGlobalParameterDefinition(param);
5050

51-
const indexEntry = {
51+
const mapEntry = {
5252
pluginId: plugin.id,
5353
param: validatedGlobalParam,
5454
};
5555

56-
globalParametersIndex.set(validatedGlobalParam.name, indexEntry);
56+
globalParametersMap.set(validatedGlobalParam.name, mapEntry);
5757
}
5858
}
5959

60-
return globalParametersIndex;
60+
return globalParametersMap;
6161
}
6262

6363
export function buildGlobalParameterDefinition<T extends ParameterType>({
@@ -106,7 +106,7 @@ export function buildGlobalParameterDefinition<T extends ParameterType>({
106106

107107
export function resolveGlobalArguments(
108108
userProvidedGlobalArguments: Partial<GlobalArguments>,
109-
_globalParametersMap: GlobalParameterMap,
109+
_globalParametersMap: GlobalParametersMap,
110110
): GlobalArguments {
111111
// TODO: Validate the userProvidedGlobalArguments and get the remaining ones
112112
// from env variables

v-next/core/src/internal/hre.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { UnsafeHardhatRuntimeEnvironmentOptions } from "../types/cli.js";
22
import type { HardhatUserConfig, HardhatConfig } from "../types/config.js";
33
import type {
44
GlobalArguments,
5-
GlobalParameterMap,
5+
GlobalParametersMap,
66
} from "../types/global-parameters.js";
77
import type {
88
HardhatUserConfigValidationError,
@@ -16,7 +16,7 @@ import type { UserInterruptionManager } from "../types/user-interruptions.js";
1616

1717
import { ResolvedConfigurationVariableImplementation } from "./configuration-variables.js";
1818
import {
19-
buildGlobalParameterMap,
19+
buildGlobalParametersMap,
2020
resolveGlobalArguments,
2121
} from "./global-parameters.js";
2222
import { HookManagerImplementation } from "./hook-manager.js";
@@ -85,13 +85,13 @@ export class HardhatRuntimeEnvironmentImplementation
8585
plugins: resolvedPlugins,
8686
};
8787

88-
const globalParametersIndex =
89-
unsafeOptions?.globalParameterMap ??
90-
buildGlobalParameterMap(resolvedPlugins);
88+
const globalParametersMap =
89+
unsafeOptions?.globalParametersMap ??
90+
buildGlobalParametersMap(resolvedPlugins);
9191

9292
const globalArguments = resolveGlobalArguments(
9393
userProvidedGlobalArguments,
94-
globalParametersIndex,
94+
globalParametersMap,
9595
);
9696

9797
// Set the HookContext in the hook manager so that non-config hooks can
@@ -114,7 +114,7 @@ export class HardhatRuntimeEnvironmentImplementation
114114
hooks,
115115
interruptions,
116116
globalArguments,
117-
globalParametersIndex,
117+
globalParametersMap,
118118
);
119119

120120
await hooks.runSequentialHandlers("hre", "created", [hre]);
@@ -130,9 +130,9 @@ export class HardhatRuntimeEnvironmentImplementation
130130
public readonly hooks: HookManager,
131131
public readonly interruptions: UserInterruptionManager,
132132
public readonly globalArguments: GlobalArguments,
133-
globalParametersIndex: GlobalParameterMap,
133+
globalParametersMap: GlobalParametersMap,
134134
) {
135-
this.tasks = new TaskManagerImplementation(this, globalParametersIndex);
135+
this.tasks = new TaskManagerImplementation(this, globalParametersMap);
136136
}
137137
}
138138

v-next/core/src/internal/tasks/task-manager.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { GlobalParameterMap } from "../../types/global-parameters.js";
1+
import type { GlobalParametersMap } from "../../types/global-parameters.js";
22
import type { HardhatRuntimeEnvironment } from "../../types/hre.js";
33
import type {
44
Task,
@@ -24,7 +24,7 @@ export class TaskManagerImplementation implements TaskManager {
2424

2525
constructor(
2626
hre: HardhatRuntimeEnvironment,
27-
globalParameterIndex: GlobalParameterMap,
27+
globalParametersMap: GlobalParametersMap,
2828
) {
2929
this.#hre = hre;
3030

@@ -36,7 +36,7 @@ export class TaskManagerImplementation implements TaskManager {
3636

3737
for (const taskDefinition of plugin.tasks) {
3838
this.#reduceTaskDefinition(
39-
globalParameterIndex,
39+
globalParametersMap,
4040
taskDefinition,
4141
plugin.id,
4242
);
@@ -45,7 +45,7 @@ export class TaskManagerImplementation implements TaskManager {
4545

4646
// reduce global user defined tasks
4747
for (const taskDefinition of this.#hre.config.tasks) {
48-
this.#reduceTaskDefinition(globalParameterIndex, taskDefinition);
48+
this.#reduceTaskDefinition(globalParametersMap, taskDefinition);
4949
}
5050
}
5151

@@ -136,7 +136,7 @@ export class TaskManagerImplementation implements TaskManager {
136136
}
137137

138138
#reduceTaskDefinition(
139-
globalParameterIndex: GlobalParameterMap,
139+
globalParametersMap: GlobalParametersMap,
140140
taskDefinition: TaskDefinition,
141141
pluginId?: string,
142142
) {
@@ -154,7 +154,7 @@ export class TaskManagerImplementation implements TaskManager {
154154
}
155155
case TaskDefinitionType.NEW_TASK: {
156156
this.#validateClashesWithGlobalParams(
157-
globalParameterIndex,
157+
globalParametersMap,
158158
taskDefinition,
159159
pluginId,
160160
);
@@ -174,7 +174,7 @@ export class TaskManagerImplementation implements TaskManager {
174174
}
175175
case TaskDefinitionType.TASK_OVERRIDE: {
176176
this.#validateClashesWithGlobalParams(
177-
globalParameterIndex,
177+
globalParametersMap,
178178
taskDefinition,
179179
pluginId,
180180
);
@@ -186,7 +186,7 @@ export class TaskManagerImplementation implements TaskManager {
186186
}
187187

188188
#validateClashesWithGlobalParams(
189-
globalParameterIndex: GlobalParameterMap,
189+
globalParametersMap: GlobalParametersMap,
190190
taskDefinition: NewTaskDefinition | TaskOverrideDefinition,
191191
pluginId?: string,
192192
) {
@@ -197,7 +197,7 @@ export class TaskManagerImplementation implements TaskManager {
197197
: [];
198198

199199
[...namedParamNames, ...positionalParamNames].forEach((paramName) => {
200-
const globalParamEntry = globalParameterIndex.get(paramName);
200+
const globalParamEntry = globalParametersMap.get(paramName);
201201
if (globalParamEntry !== undefined) {
202202
throw new HardhatError(
203203
HardhatError.ERRORS.TASK_DEFINITIONS.TASK_PARAMETER_ALREADY_DEFINED,

v-next/core/src/types/cli.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { GlobalParameterMap } from "./global-parameters.js";
1+
import type { GlobalParametersMap } from "./global-parameters.js";
22
import type { HardhatPlugin } from "./plugins.js";
33

44
/**
@@ -7,5 +7,5 @@ import type { HardhatPlugin } from "./plugins.js";
77
*/
88
export interface UnsafeHardhatRuntimeEnvironmentOptions {
99
resolvedPlugins?: HardhatPlugin[];
10-
globalParameterMap?: GlobalParameterMap;
10+
globalParametersMap?: GlobalParametersMap;
1111
}

v-next/core/src/types/global-parameters.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ export interface GlobalParameter<T extends ParameterType = ParameterType> {
2828
export interface GlobalArguments {}
2929

3030
/**
31-
* An entry in the global parameter map.
32-
* @see GlobalParameterMap
31+
* An entry in the global parameters map.
32+
* @see GlobalParametersMap
3333
*/
34-
export interface GlobalParameterMapEntry {
34+
export interface GlobalParametersMapEntry {
3535
pluginId: string;
3636
param: GlobalParameter;
3737
}
3838

3939
/**
4040
* A map with all the `GlobalParameter`s and which plugin defined them.
4141
*/
42-
export type GlobalParameterMap = Map<string, GlobalParameterMapEntry>;
42+
export type GlobalParametersMap = Map<string, GlobalParametersMapEntry>;

v-next/hardhat/src/internal/cli/main.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { ParameterValue } from "@nomicfoundation/hardhat-core/types/common"
22
import type {
33
GlobalArguments,
44
GlobalParameter,
5-
GlobalParameterMap,
5+
GlobalParametersMap,
66
} from "@nomicfoundation/hardhat-core/types/global-parameters";
77
import type { HardhatRuntimeEnvironment } from "@nomicfoundation/hardhat-core/types/hre";
88
import type {
@@ -15,7 +15,7 @@ import type {
1515
import "tsx"; // NOTE: This is important, it allows us to load .ts files form the CLI
1616

1717
import {
18-
buildGlobalParameterMap,
18+
buildGlobalParametersMap,
1919
resolvePluginList,
2020
} from "@nomicfoundation/hardhat-core";
2121
import { ParameterType } from "@nomicfoundation/hardhat-core/types/common";
@@ -66,9 +66,9 @@ export async function main(cliArguments: string[]) {
6666
hardhatSpecialArgs.configPath,
6767
);
6868

69-
const globalParameterMap = buildGlobalParameterMap(resolvedPlugins);
69+
const globalParametersMap = buildGlobalParametersMap(resolvedPlugins);
7070
const userProvidedGlobalArguments = parseGlobalArguments(
71-
globalParameterMap,
71+
globalParametersMap,
7272
cliArguments,
7373
usedCliArguments,
7474
);
@@ -78,7 +78,7 @@ export async function main(cliArguments: string[]) {
7878
userProvidedGlobalArguments,
7979
{
8080
resolvedPlugins,
81-
globalParameterMap,
81+
globalParametersMap,
8282
},
8383
);
8484

@@ -209,14 +209,14 @@ export async function parseHardhatSpecialArguments(
209209
}
210210

211211
export async function parseGlobalArguments(
212-
globalParamsIndex: GlobalParameterMap,
212+
globalParametersMap: GlobalParametersMap,
213213
cliArguments: string[],
214214
usedCliArguments: boolean[],
215215
): Promise<Partial<GlobalArguments>> {
216216
const globalArguments: Partial<GlobalArguments> = {};
217217

218218
const parameters = new Map(
219-
[...globalParamsIndex].map(([key, value]) => [key, value.param]),
219+
[...globalParametersMap].map(([key, value]) => [key, value.param]),
220220
);
221221

222222
parseDoubleDashArgs(

v-next/hardhat/test/internal/cli/main.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type {
2-
GlobalParameterMap,
3-
GlobalParameterMapEntry,
2+
GlobalParametersMap,
3+
GlobalParametersMapEntry,
44
} from "@nomicfoundation/hardhat-core/types/global-parameters";
55
import type { HardhatRuntimeEnvironment } from "@nomicfoundation/hardhat-core/types/hre";
66
import type {
@@ -141,7 +141,7 @@ describe("main", function () {
141141
// The function "parseGlobalArguments" uses the same function "parseDoubleDashArgs" that is used to parse named parameters.
142142
// Most of the tests to check the "parseDoubleDashArgs" logic are in the named parameter section of these tests.
143143

144-
let globalParamsIndex: GlobalParameterMap;
144+
let globalParametersMap: GlobalParametersMap;
145145

146146
before(function () {
147147
const GLOBAL_PARAM = globalParameter({
@@ -156,7 +156,7 @@ describe("main", function () {
156156
description: "",
157157
});
158158

159-
globalParamsIndex = new Map<string, GlobalParameterMapEntry>([
159+
globalParametersMap = new Map<string, GlobalParametersMapEntry>([
160160
["param", { pluginId: "1", param: GLOBAL_PARAM }],
161161
["flag", { pluginId: "1", param: GLOBAL_FLAG }],
162162
]);
@@ -169,7 +169,7 @@ describe("main", function () {
169169
const usedCliArguments = new Array(cliArguments.length).fill(false);
170170

171171
const globalArguments = await parseGlobalArguments(
172-
globalParamsIndex,
172+
globalParametersMap,
173173
cliArguments,
174174
usedCliArguments,
175175
);
@@ -187,7 +187,7 @@ describe("main", function () {
187187
const usedCliArguments = new Array(cliArguments.length).fill(false);
188188

189189
const globalArguments = await parseGlobalArguments(
190-
globalParamsIndex,
190+
globalParametersMap,
191191
cliArguments,
192192
usedCliArguments,
193193
);
@@ -205,7 +205,7 @@ describe("main", function () {
205205
const usedCliArguments = new Array(cliArguments.length).fill(false);
206206

207207
const globalArguments = await parseGlobalArguments(
208-
globalParamsIndex,
208+
globalParametersMap,
209209
cliArguments,
210210
usedCliArguments,
211211
);
@@ -223,7 +223,7 @@ describe("main", function () {
223223
const usedCliArguments = new Array(cliArguments.length).fill(false);
224224

225225
const globalArguments = await parseGlobalArguments(
226-
globalParamsIndex,
226+
globalParametersMap,
227227
cliArguments,
228228
usedCliArguments,
229229
);

0 commit comments

Comments
 (0)