Conversation
🦋 Changeset detectedLatest commit: 0a7deea The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Pull request overview
Updates network.createServer to better support non-generic chain types while enforcing that servers can only be created from edr-simulated network configs (mirroring hardhat node behavior).
Changes:
- Generalize
NetworkManager.createServertyping to acceptNetworkConnectionParams<ChainTypeT>sochainType: "op"(and other chain types) type-checks. - Add a runtime guard that throws a dedicated Hardhat error when
createServertargets a non-edr-simulatednetwork (e.g.http/localhost). - Add tests + a new example script demonstrating spinning up a server and sending a tx.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| v-next/hardhat/test/internal/builtin-plugins/network-manager/network-manager.ts | Adds coverage for the new createServer restriction and validates server usage end-to-end. |
| v-next/hardhat/src/types/network.ts | Adjusts the public NetworkManager.createServer type signature to accept non-default chainTypes. |
| v-next/hardhat/src/internal/builtin-plugins/network-manager/network-manager.ts | Enforces createServer is only usable for edr-simulated networks via a new guard + dedicated error. |
| v-next/hardhat-errors/src/descriptors.ts | Introduces CREATE_SERVER_UNSUPPORTED_NETWORK_TYPE error descriptor for the new runtime validation. |
| v-next/example-project/scripts/create-server.ts | Adds an example script demonstrating network.createServer with chainType: "op". |
You can also share your feedback on Copilot code review. Take the survey.
29f4e9b to
abc60d4
Compare
| public async createServer< | ||
| ChainTypeT extends ChainType | string = DefaultChainType, | ||
| >( | ||
| networkOrParams: NetworkConnectionParams<ChainTypeT> | string = "default", |
There was a problem hiding this comment.
This is the key type change. It is backwards compatible.
The alternative is to remove chainType as it does not make sense for createServer (no connection instance is returned).
abc60d4 to
03f4972
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates network.createServer to (1) accept non-"generic" chainTypes in its parameter typing, and (2) fail fast at runtime when called against an http network configuration (matching the behavior pattern used by hardhat node).
Changes:
- Updated
network.createServerTypeScript signature to support typed non-genericchainTypevalues. - Added a runtime guard that throws a dedicated Hardhat error when
createServertargets a non-edr-simulatednetwork config, plus added corresponding tests. - Added a new error descriptor and an example script demonstrating
createServer.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| v-next/hardhat/test/internal/builtin-plugins/network-manager/network-manager.ts | Adds coverage for rejecting createServer on http networks and validates server connectivity. |
| v-next/hardhat/src/types/network.ts | Makes createServer generic over ChainTypeT to allow non-"generic" chain types in params. |
| v-next/hardhat/src/internal/builtin-plugins/network-manager/network-manager.ts | Adds a guard that throws when createServer is invoked for non-edr-simulated network configs. |
| v-next/hardhat-errors/src/descriptors.ts | Introduces CREATE_SERVER_UNSUPPORTED_NETWORK_TYPE error descriptor. |
| v-next/example-project/scripts/create-server.ts | Adds an example using network.createServer and interacting with the resulting JSON-RPC server. |
| .changeset/petite-teams-slide.md | Changeset for the new runtime guard / error. |
| .changeset/cyan-dogs-ask.md | Changeset for the createServer typing update. |
You can also share your feedback on Copilot code review. Take the survey.
The type was stopping `createServer` from passing the `op` chainType as part of the network parameters. The type has been enhanced to generically capture the ChainType.
Match the behaviour of `npx hardhat node` and throw if a network config with a type other than `edr-simulated` is used.
03f4972 to
0e8abcf
Compare
There was a problem hiding this comment.
Pull request overview
Updates network.createServer to better support different chain types at the type level and to fail fast when invoked against unsupported (HTTP) network configurations.
Changes:
- Generalized
NetworkManager.createServertyping to accept non-genericchainTypevalues via generics. - Added a runtime guard that throws a dedicated Hardhat error when
createServertargets a non-edr-simulatednetwork. - Expanded
createServertests and added new error descriptor + changesets.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| v-next/hardhat/test/internal/builtin-plugins/network-manager/network-manager.ts | Adds regression tests for createServer rejecting HTTP networks and validates the server can be used via an HTTP client. |
| v-next/hardhat/src/types/network.ts | Updates the public NetworkManager.createServer signature to be generic over ChainType. |
| v-next/hardhat/src/internal/builtin-plugins/network-manager/network-manager.ts | Implements the runtime guard and updates createServer signature accordingly. |
| v-next/hardhat-errors/src/descriptors.ts | Introduces CREATE_SERVER_UNSUPPORTED_NETWORK_TYPE error descriptor. |
| .changeset/petite-teams-slide.md | Changeset for the new createServer guard behavior. |
| .changeset/cyan-dogs-ask.md | Changeset for the createServer type signature update. |
You can also share your feedback on Copilot code review. Take the survey.
Use the same pattern as `connect` so that the passed default network is used properly.
This includes two small changes but touches the type of
network.createServer.genericcreateServeris used against a network config that is notedr-simulated(copying the pattern innpx hardhat node)The changes are commit at a time.
createServer Type
The current type would show an error for the following code:
This PR accepts
opwithout a type error. An alternative is to say thatchainTypemakes no sense for thecreateServermethod andOmit<>the property from thecreateServerinterface.