Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Network Manager M1 remaining tasks #5762

Merged
merged 9 commits into from
Sep 28, 2024
Merged

Conversation

schaable
Copy link
Member

This PR addresses most of the tasks outlined in this document, except for the "Types" section, which will be addressed in a separate PR. I suggest reviewing one commit at a time for an easier review process.

Summary:

  • Added tests for:
    • All config hooks (extendUserConfig, validateUserConfig, resolveUserConfig).
    • HTTPProvider: jsonRpcWrapper and close functions.
    • NetworkManager: connect function and all network hooks (newConnection, closeConnection, onRequest).
    • NetworkConnection: class initialization and close function (through NetworkManager)
  • Fixed bugs found during testing.
  • Refactored code for better readability and to facilitate testing.

@schaable schaable added the v-next A Hardhat v3 development task label Sep 18, 2024
@schaable schaable self-assigned this Sep 18, 2024
Copy link

vercel bot commented Sep 18, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hardhat ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 28, 2024 5:23pm

Copy link

changeset-bot bot commented Sep 18, 2024

⚠️ No Changeset found

Latest commit: ae00903

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions bot added the status:ready This issue is ready to be worked on label Sep 18, 2024
@schaable schaable changed the title Improve gas config validation Network Manager M1 remaining tasks Sep 18, 2024
validationErrors.length > 0,
"validation errors should be present",
);
// TODO: the error message should be "Expected a URL or a Configuration Variable"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The interesting thing is that this validation uses conditionalUnionType behind the scenes, so it might be bugged as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is working as intended concerning the conditionalUnionType. Its main idea is to return errors that are as specific as possible.

unionType does the contrary. It always returns a less specific error message.

Maybe for this particular case we should use unionType.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the problem is that unionType expects the first argument to be an array of zod types, and we're using isObject in sensitiveUrlType. Maybe we could replace it with z.object() or z.record(), but we'd need to make it generic.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated sensitiveUrlType and sensitiveStringType to use unionType (and renamed them to schemas). However, there's a bug in Zod that prevents the union from using the provided errorMap when the string schema is z.string().url() (and likely other validations). See:

* TODO: The custom error message in the unionType function doesn't work
* correctly when using string().url() for validation, see:
* https://github.com/colinhacks/zod/issues/2940
* As a workaround, we provide the error message directly in the url() call.
* We should remove this when the issue is fixed.

Copy link
Member

@alcuadrado alcuadrado left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a few comments, but LGTM

Merged via the queue into v-next with commit ce77ee9 Sep 28, 2024
39 checks passed
@schaable schaable deleted the network-manager-m1-cleanup branch September 28, 2024 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v-next A Hardhat v3 development task
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants