Skip to content

Commit 1e79c20

Browse files
committed
PR fixes
1 parent e357a28 commit 1e79c20

File tree

6 files changed

+26
-145
lines changed

6 files changed

+26
-145
lines changed

v-next/core/src/internal/tasks/builders.ts

+4-12
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
isValidParamNameCasing,
2020
} from "../parameters.js";
2121

22-
import { formatTaskId, formatValue, isValidActionUrl } from "./utils.js";
22+
import { formatTaskId, isValidActionUrl } from "./utils.js";
2323

2424
export class NewTaskDefinitionBuilderImplementation
2525
implements NewTaskDefinitionBuilder
@@ -97,17 +97,13 @@ export class NewTaskDefinitionBuilderImplementation
9797
throw new HardhatError(
9898
HardhatError.ERRORS.ARGUMENTS.INVALID_VALUE_FOR_TYPE,
9999
{
100-
value: formatValue(defaultValue),
100+
value: defaultValue,
101101
name: "defaultValue",
102102
type: parameterType,
103103
},
104104
);
105105
}
106106

107-
if (type === ParameterType.BOOLEAN && defaultValue === undefined) {
108-
defaultValue = false as ParameterTypeToValueType<T>;
109-
}
110-
111107
this.#usedNames.add(name);
112108

113109
this.#namedParams[name] = {
@@ -235,7 +231,7 @@ export class NewTaskDefinitionBuilderImplementation
235231
throw new HardhatError(
236232
HardhatError.ERRORS.ARGUMENTS.INVALID_VALUE_FOR_TYPE,
237233
{
238-
value: formatValue(defaultValue),
234+
value: defaultValue,
239235
name: "defaultValue",
240236
type: parameterType,
241237
},
@@ -353,17 +349,13 @@ export class TaskOverrideDefinitionBuilderImplementation
353349
throw new HardhatError(
354350
HardhatError.ERRORS.ARGUMENTS.INVALID_VALUE_FOR_TYPE,
355351
{
356-
value: formatValue(defaultValue),
352+
value: defaultValue,
357353
name: "defaultValue",
358354
type: parameterType,
359355
},
360356
);
361357
}
362358

363-
if (type === ParameterType.BOOLEAN && defaultValue === undefined) {
364-
defaultValue = false as ParameterTypeToValueType<T>;
365-
}
366-
367359
this.#namedParams[name] = {
368360
name,
369361
description,
-15
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
import type {
2-
ParameterType,
3-
ParameterTypeToValueType,
4-
} from "../../types/common.js";
5-
61
export function formatTaskId(taskId: string | string[]): string {
72
if (typeof taskId === "string") {
83
return taskId;
@@ -16,13 +11,3 @@ const FILE_PROTOCOL_PATTERN = /^file:\/\/.+/;
1611
export function isValidActionUrl(action: string): boolean {
1712
return FILE_PROTOCOL_PATTERN.test(action);
1813
}
19-
20-
export function formatValue<T extends ParameterType>(
21-
value: ParameterTypeToValueType<T> | Array<ParameterTypeToValueType<T>>,
22-
): string {
23-
if (typeof value === "bigint") {
24-
return `${value}n`;
25-
}
26-
27-
return JSON.stringify(value);
28-
}

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

+11-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ export enum ParameterType {
1010
FILE = "FILE",
1111
}
1212

13-
interface ParameterToValueTypeMap {
13+
/**
14+
* Maps all the `ParameterType` values to their corresponding value types.
15+
*/
16+
export interface ParameterToValueTypeMap {
1417
[ParameterType.STRING]: string;
1518
[ParameterType.BOOLEAN]: boolean;
1619
[ParameterType.INT]: number;
@@ -25,8 +28,13 @@ interface ParameterToValueTypeMap {
2528
* This type takes a `ParameterType` as a type parameter and returns the type
2629
* of the value that should be used for parameters of that type.
2730
*
28-
* For example, `ParameterTypeToValueType<ParameterType.STRING>` would be
29-
* `string`, and `ParameterTypeToValueType<ParameterType.INT>` would be `number`.
31+
* @example
32+
* ParameterTypeToValueType<ParameterType.STRING>
33+
* // ^? "string"
34+
*
35+
* @example
36+
* ParameterTypeToValueType<ParameterType.INT>
37+
* // ^? "number"
3038
*/
3139
export type ParameterTypeToValueType<T extends ParameterType> =
3240
ParameterToValueTypeMap[T];

0 commit comments

Comments
 (0)