Skip to content

Commit 5604169

Browse files
kshyun28alcuadrado
authored andcommitted
Revert config validation for empty network or forking url
1 parent f65dc7c commit 5604169

File tree

2 files changed

+0
-72
lines changed

2 files changed

+0
-72
lines changed

packages/hardhat-core/src/internal/core/config/config-validation.ts

-34
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,6 @@ function getMessage(e: ValidationError): string {
5858
);
5959
}
6060

61-
function getEmptyErrorMessage(path: string, value: any, expectedType: string) {
62-
return `Empty value ${stringify(
63-
value
64-
)} for ${path} - Expected a non-empty value of type ${expectedType}.`;
65-
}
66-
6761
function getErrorMessage(path: string, value: any, expectedType: string) {
6862
return `Invalid value ${stringify(
6963
value
@@ -154,14 +148,6 @@ function isDecimalString(v: unknown): v is string {
154148
return v.match(DEC_STRING_REGEX) !== null;
155149
}
156150

157-
function isEmptyString(v: unknown): v is string {
158-
if (typeof v !== "string") {
159-
return false;
160-
}
161-
162-
return v.trim().length === 0;
163-
}
164-
165151
export const hexString = new t.Type<string>(
166152
"hex string",
167153
isHexString,
@@ -401,18 +387,6 @@ export function getValidationErrors(config: any): string[] {
401387
);
402388
}
403389

404-
if (hardhatNetwork.forking !== undefined) {
405-
if (isEmptyString(hardhatNetwork.forking.url)) {
406-
errors.push(
407-
getEmptyErrorMessage(
408-
`HardhatConfig.networks.${HARDHAT_NETWORK_NAME}.forking.url`,
409-
hardhatNetwork.forking.url,
410-
"string"
411-
)
412-
);
413-
}
414-
}
415-
416390
// Validating the accounts with io-ts leads to very confusing errors messages
417391
const { accounts, ...configExceptAccounts } = hardhatNetwork;
418392

@@ -561,14 +535,6 @@ export function getValidationErrors(config: any): string[] {
561535
"string"
562536
)
563537
);
564-
} else if (isEmptyString(netConfig.url)) {
565-
errors.push(
566-
getEmptyErrorMessage(
567-
`HardhatConfig.networks.${networkName}.url`,
568-
netConfig.url,
569-
"string"
570-
)
571-
);
572538
}
573539
}
574540

packages/hardhat-core/test/internal/core/config/config-validation.ts

-38
Original file line numberDiff line numberDiff line change
@@ -857,30 +857,6 @@ describe("Config validation", function () {
857857
ERRORS.GENERAL.INVALID_CONFIG
858858
);
859859

860-
expectHardhatError(
861-
() =>
862-
validateConfig({
863-
networks: {
864-
[HARDHAT_NETWORK_NAME]: {
865-
forking: { url: "" },
866-
},
867-
},
868-
}),
869-
ERRORS.GENERAL.INVALID_CONFIG
870-
);
871-
872-
expectHardhatError(
873-
() =>
874-
validateConfig({
875-
networks: {
876-
[HARDHAT_NETWORK_NAME]: {
877-
forking: { url: " " },
878-
},
879-
},
880-
}),
881-
ERRORS.GENERAL.INVALID_CONFIG
882-
);
883-
884860
expectHardhatError(
885861
() =>
886862
validateConfig({
@@ -1195,20 +1171,6 @@ describe("Config validation", function () {
11951171
);
11961172
});
11971173

1198-
it("Should fail if an empty url is set for custom networks", function () {
1199-
// Empty string
1200-
expectHardhatError(
1201-
() => validateConfig({ networks: { custom: { url: "" } } }),
1202-
ERRORS.GENERAL.INVALID_CONFIG
1203-
);
1204-
1205-
// Empty string with at least 1 whitespace
1206-
expectHardhatError(
1207-
() => validateConfig({ networks: { custom: { url: " " } } }),
1208-
ERRORS.GENERAL.INVALID_CONFIG
1209-
);
1210-
});
1211-
12121174
it("Shouldn't fail if no url is set for localhost network", function () {
12131175
const errors = getValidationErrors({ networks: { localhost: {} } });
12141176
assert.isEmpty(errors);

0 commit comments

Comments
 (0)