Skip to content

Commit

Permalink
Merge branch 'v-next' of github.com:NomicFoundation/hardhat into feat…
Browse files Browse the repository at this point in the history
…ure/add-logic-to-send-telemetry-data
  • Loading branch information
ChristopherDedominici committed Aug 15, 2024
2 parents e9ecacc + c59a56d commit 082b407
Show file tree
Hide file tree
Showing 28 changed files with 1,798 additions and 176 deletions.
10 changes: 0 additions & 10 deletions .github/workflows/review-approved-slack-notification.yml

This file was deleted.

10 changes: 0 additions & 10 deletions .github/workflows/review-requested-slack-notification.yml

This file was deleted.

35 changes: 35 additions & 0 deletions .github/workflows/v-next-ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: vNext CI

on:
merge_group:
push:
branches:
- v-next
Expand Down Expand Up @@ -108,6 +109,23 @@ jobs:
- name: Lint
run: pnpm lint

lint-aggregate:
needs: lint

if: ${{ !cancelled() }}

name: lint
runs-on: ubuntu-latest

steps:
- env:
result: ${{ needs.lint.result }}
run: |
if [[ "$result" == "failure" ]]; then
exit 1
fi
shell: bash

ci:
needs: list-packages

Expand Down Expand Up @@ -137,3 +155,20 @@ jobs:
run: pnpm build
- name: Run tests
run: pnpm run test

ci-aggregate:
needs: ci

if: ${{ !cancelled() }}

name: ci
runs-on: ubuntu-latest

steps:
- env:
result: ${{ needs.ci.result }}
run: |
if [[ "$result" == "failure" ]]; then
exit 1
fi
shell: bash
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"hardhat": "workspace:*",
"prettier": "2.4.1",
"shelljs": "^0.8.5",
"typescript": "~5.0.0"
"typescript": "~5.5.0"
},
"scripts": {
"build": "tsc --build packages/hardhat-core packages/hardhat-ethers packages/hardhat-verify packages/hardhat-vyper packages/hardhat-web3-v4 packages/hardhat-chai-matchers packages/hardhat-network-helpers packages/hardhat-toolbox packages/hardhat-foundry packages/hardhat-ledger packages/hardhat-viem packages/hardhat-toolbox-viem",
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 36 additions & 35 deletions v-next/core/src/types/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ export interface ConfigHooks {
* Provide a handler for this hook to extend the user's config, before any
* validation or resolution is done.
*
* @param config - The user's config.
* @param next - A function to call the next handler for this hook.
* @param config The user's config.
* @param next A function to call the next handler for this hook.
* @returns The extended config.
*/
extendUserConfig: (
Expand All @@ -72,7 +72,7 @@ export interface ConfigHooks {
/**
* Provide a handler for this hook to validate the user's config.
*
* @param config - The user's config.
* @param config The user's config.
* @returns An array of validation errors.
*/
validateUserConfig: (
Expand All @@ -88,8 +88,8 @@ export interface ConfigHooks {
* result is typed as `HardhatConfig`, it may actually be incomplete, as other
* plugins may not have resolved their parts of the config yet.
*
* @param userConfig - The user's config.
* @param next - A function to call the next handler for this hook.
* @param userConfig The user's config.
* @param next A function to call the next handler for this hook.
* @returns The resolved config.
*/
resolveUserConfig: (
Expand Down Expand Up @@ -133,9 +133,9 @@ export interface ConfigurationVariableHooks {
* Provide a handler for this hook to customize how to fetch the value
* that a configuration variable represents.
*
* @param context - The hook context.
* @param variable - The configuration variable or string to resolve.
* @param next - A function to call if the handler decides to not handle the
* @param context The hook context.
* @param variable The configuration variable or string to resolve.
* @param next A function to call if the handler decides to not handle the
* resolution of this variable.
*/
fetchValue: (
Expand All @@ -159,11 +159,11 @@ export interface UserInterruptionHooks {
* @see UserInterruptionManager#displayMessage to understand when the returned
* promise should be resolved.
*
* @param context - The hook context.
* @param interruptor - A name or description of the module trying to display
* @param context The hook context.
* @param interruptor A name or description of the module trying to display
* the message.
* @param message - The message to display.
* @param next - A function to call if the handler decides to not handle the
* @param message The message to display.
* @param next A function to call if the handler decides to not handle the
* message.
*/
displayMessage: (
Expand All @@ -181,12 +181,12 @@ export interface UserInterruptionHooks {
* Provide a handler for this hook to customize how the
* `UserInterruptionManager` requests input from the user.
*
* @param context - The hook context.
* @param interruptor - A name or description of the module trying to request
* @param context The hook context.
* @param interruptor A name or description of the module trying to request
* input form the user.
* @param inputDescription - A description of the input that is being
* @param inputDescription A description of the input that is being
* requested.
* @param next - A function to call if the handler decides to not handle the
* @param next A function to call if the handler decides to not handle the
* input request.
*/
requestInput: (
Expand All @@ -207,12 +207,12 @@ export interface UserInterruptionHooks {
* Note that handlers for this hook should take care of to not display the
* user's input in the terminal, and not leak it in any way.
*
* @param context - The hook context.
* @param interruptor - A name or description of the module trying to request
* @param context The hook context.
* @param interruptor A name or description of the module trying to request
* input form the user.
* @param inputDescription - A description of the input that is being
* @param inputDescription A description of the input that is being
* requested.
* @param next - A function to call if the handler decides to not
* @param next A function to call if the handler decides to not
* handle the input request.
*/
requestSecretInput: (
Expand Down Expand Up @@ -240,7 +240,7 @@ export interface HardhatRuntimeEnvironmentHooks {
/**
* An interface with utilities to interact with hooks and their handlers.
*
* This interface provides methods fetch and run hook handlers, as well as
* This interface provides methods to fetch and run hook handlers, as well as
* registering and unregistering dynamic ones.
*
* Using this `HookManager` you can run a hook's handlers in a few different
Expand All @@ -249,6 +249,7 @@ export interface HardhatRuntimeEnvironmentHooks {
* next one.
* - In order, where all handlers are called in the order that `getHooks`
* returns them.
* - In parallel, where all handlers are called at the same time.
*/
export interface HookManager {
/**
Expand All @@ -257,7 +258,7 @@ export interface HookManager {
* The priority is defined like this:
* - Dynamically registered handlers come first, in the reverse order they
* were registered.
* - Plugin handlers come last, in the same reverse of the resolved plugins
* - Plugin handlers come last, in the same reverse of the resolved plugins
* list, as seen in `HardhatConfig#plugins`.
*/
getHandlers<
Expand Down Expand Up @@ -295,15 +296,15 @@ export interface HookManager {
*
* For a hook to work with this method, it should look like this:
*
* `(arg1: Type1, ..., argN: TypeN, n ext: (a1: Type1, ..., aN: TypeN) => Promise<ReturnType>) => Promise<ReturnType>`
* `(arg1: Type1, ..., argN: TypeN, next: (a1: Type1, ..., aN: TypeN) => Promise<ReturnType>) => Promise<ReturnType>`
*
* Note that `next` MUST NOT be called more than once in any handler.
*
* @param hookCategoryName - The name of the category of the hook whose
* @param hookCategoryName The name of the category of the hook whose
* handlers should be run.
* @param hookName - The name of the hook whose handlers should be run.
* @param initialParams - The params to pass to the first handler that is run.
* @param defaultHandler - The last handler in the chain. This can be thought
* @param hookName The name of the hook whose handlers should be run.
* @param initialParams The params to pass to the first handler that is run.
* @param defaultImplementation The last handler in the chain. This can be thought
* as the behavior that this execution should have in the absense of any
* handler.
* @returns The result of executing the chained handlers.
Expand All @@ -316,17 +317,17 @@ export interface HookManager {
hookCategoryName: HookCategoryNameT,
hookName: HookNameT,
initialParams: InitialChainedHookParams<HookCategoryNameT, HookT>,
defaultHandler: LastParameter<HookT>,
defaultImplementation: LastParameter<HookT>,
): Promise<Awaited<Return<HookT>>>;

/**
* Runs all the handlers for a hook in the same order that `getHandlers`
* returns them.
*
* @param hookCategoryName - The name of the category of the hook whose
* @param hookCategoryName The name of the category of the hook whose
* handlers should be run.
* @param hookName - The name of the hook to run.
* @param params - The params to pass to the hooks.
* @param hookName The name of the hook to run.
* @param params The params to pass to the hooks.
*/
runSequentialHandlers<
HookCategoryNameT extends keyof HardhatHooks,
Expand All @@ -341,10 +342,10 @@ export interface HookManager {
/**
* Runs all the handlers for a hook in parallel.
*
* @param hookCategoryName - The name of the category of the hook whose
* @param hookCategoryName The name of the category of the hook whose
* handlers should be run.
* @param hookName - The name of the hook to run.
* @param params - The params to pass to the hooks.
* @param hookName The name of the hook to run.
* @param params The params to pass to the hooks.
*/
runParallelHandlers<
HookCategoryNameT extends keyof HardhatHooks,
Expand Down Expand Up @@ -389,7 +390,7 @@ export type InitialChainedHookParams<
: ParametersExceptFirstAndLast<HookT>;

/**
* The intial parameters to run a chain of hooks.
* The initial parameters to run hooks either sequentially or in parallel.
*/
export type InitialHookParams<
HookCategoryNameT extends keyof HardhatHooks,
Expand Down
45 changes: 45 additions & 0 deletions v-next/hardhat-errors/src/descriptors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export const ERROR_CATEGORIES: {
},
ARGUMENTS: { min: 500, max: 599, websiteTitle: "Arguments related errors" },
BUILTIN_TASKS: { min: 600, max: 699, websiteTitle: "Built-in tasks errors" },
NETWORK: { min: 700, max: 799, websiteTitle: "Network errors" },
};

export const ERRORS = {
Expand Down Expand Up @@ -473,4 +474,48 @@ Please double check your script's path.`,
Please check Hardhat's output for more details.`,
},
},
NETWORK: {
INVALID_URL: {
number: 700,
messageTemplate: "Invalid URL {value} for network or forking.",
websiteTitle: "Invalid URL for network or forking",
websiteDescription: `You are trying to connect to a network with an invalid network or forking URL.
Please check that you are sending a valid URL string for the network or forking \`URL\` parameter.`,
},
INVALID_REQUEST_PARAMS: {
number: 701,
messageTemplate:
"Invalid request arguments: only array parameters are supported.",
websiteTitle: "Invalid method parameters",
websiteDescription:
"The JSON-RPC request parameters are invalid. You are trying to make an EIP-1193 request with object parameters, but only array parameters are supported. Ensure that the 'params' parameter is correctly specified as an array in your JSON-RPC request.",
},
INVALID_JSON_RESPONSE: {
number: 702,
messageTemplate: "Invalid JSON-RPC response received: {response}",
websiteTitle: "Invalid JSON-RPC response",
websiteDescription: `One of your JSON-RPC requests received an invalid response.
Please make sure your node is running, and check your internet connection and networks config.`,
},
CONNECTION_REFUSED: {
number: 703,
messageTemplate: `Cannot connect to the network {network}.
Please make sure your node is running, and check your internet connection and networks config`,
websiteTitle: "Cannot connect to the network",
websiteDescription: `Cannot connect to the network.
Please make sure your node is running, and check your internet connection and networks config.`,
},
NETWORK_TIMEOUT: {
number: 704,
messageTemplate: `Network connection timed out.
Please check your internet connection and networks config`,
websiteTitle: "Network timeout",
websiteDescription: `One of your JSON-RPC requests timed out.
Please make sure your node is running, and check your internet connection and networks config.`,
},
},
} as const;
4 changes: 2 additions & 2 deletions v-next/hardhat-errors/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export class HardhatError<
other: unknown,
descriptor?: ErrorDescriptor,
): other is HardhatError<ErrorDescriptor> {
if (!isObject(other) || other === null) {
if (!isObject(other)) {
return false;
}

Expand Down Expand Up @@ -200,7 +200,7 @@ export class HardhatPluginError extends CustomError {
public static isHardhatPluginError(
other: unknown,
): other is HardhatPluginError {
if (!isObject(other) || other === null) {
if (!isObject(other)) {
return false;
}

Expand Down
Loading

0 comments on commit 082b407

Please sign in to comment.