Skip to content

Improve waffle warning and migration guides #2976

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

Merged
merged 5 commits into from
Feb 9, 2023

Conversation

fvictorio
Copy link
Member

@fvictorio fvictorio commented Jul 21, 2022

There are two important changes in this PR.

The first one is how the docs talk about migrating from hardhat-waffle. The previous version was confusing, because some sections were about migrating only to the chai matchers, and others about migrating to the toolbox. Now migrating to the toolbox is the default and more prominent recommendation. The guide about just migrating from waffle to the chai matchers is still there, but it's not the default path.

The second change is how and when the warning about waffle is shown. We set a global variable in both plugins, and each plugin checks if the other was loaded. If that happens, we throw an error.

edit: test

@fvictorio fvictorio requested review from alcuadrado and feuGeneA July 21, 2022 04:26
@linear
Copy link

linear bot commented Jul 21, 2022

HH-937 Improve the warning that we print if you have waffle installed

It's not clear from the message how it should fixed.

Ideally, we should link to an ad-hoc section of the site, perhaps https://hardhat.org/hardhat-chai-matchers/docs/migrate-from-waffle

@vercel
Copy link

vercel bot commented Jul 21, 2022

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

Name Status Preview Updated
hardhat ✅ Ready (Inspect) Visit Preview Sep 28, 2022 at 11:39AM (UTC)
hardhat-storybook ✅ Ready (Inspect) Visit Preview Sep 28, 2022 at 11:39AM (UTC)

@changeset-bot
Copy link

changeset-bot bot commented Jul 21, 2022

🦋 Changeset detected

Latest commit: 8fa00c9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@nomicfoundation/hardhat-chai-matchers Patch
@nomiclabs/hardhat-waffle Patch

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

@github-actions
Copy link
Contributor

Thanks for submitting this PR!

Unfortunately, it has some linter errors, so we can't merge it yet. Can you please fix them?

Running yarn lint:fix in the root of the repository may fix them automatically.

@vercel vercel bot temporarily deployed to Preview – hardhat-storybook July 21, 2022 04:34 Inactive
@vercel vercel bot temporarily deployed to Preview – hardhat July 21, 2022 04:34 Inactive
:::tab{value="npm 7+"}

```
npm uninstall @nomiclabs/hardhat-waffle ethereum-waffle @nomiclabs/hardhat-ethers @nomiclabs/hardhat-etherscan chai ethers hardhat-gas-reporter solidity-coverage @typechain/hardhat typechain @typechain/ethers-v5 @ethersproject/abi @ethersproject/providers
Copy link
Member Author

Choose a reason for hiding this comment

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

We remove everything to avoid potential conflicting versions when the toolbox is later installed. For example, it might happen that the user has an old version of @typechain/ethers-v5 than the peer dependency of the toolbox, which causes issues.

:::tab{value=yarn}

```
yarn remove @nomiclabs/hardhat-waffle ethereum-waffle
Copy link
Member Author

Choose a reason for hiding this comment

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

For yarn we can't do a big remove like we do with npm, because removing a package that is not installed causes an error. Since yarn doesn't install peer dependencies and the next command just adds everything needed, the problem mentioned in the previous comment is not relevant here, so this is fine.

Copy link
Contributor

@feuGeneA feuGeneA left a comment

Choose a reason for hiding this comment

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

A few suggestions, but overall LGTM.

@alcuadrado may I suggest you double check the waffle incompatibility check, which was removed from
packages/hardhat-chai-matchers/src/internal/checkIfWaffleIsInstalled.ts
and added to both
packages/hardhat-chai-matchers/src/internal/hardhatWaffleIncompatibilityCheck.ts and
packages/hardhat-waffle/src/hardhatChaiMatchersIncompatibilityCheck.ts,
and invoked from
packages/hardhat-waffle/src/index.ts.

@github-actions github-actions bot added the Stale label Aug 21, 2022
@github-actions github-actions bot removed the Stale label Sep 10, 2022
Co-authored-by: F. Eugene Aumson <feuGeneA@users.noreply.github.com>
@vercel vercel bot temporarily deployed to Preview – hardhat-storybook September 28, 2022 11:34 Inactive
@vercel vercel bot temporarily deployed to Preview – hardhat September 28, 2022 11:35 Inactive
@vercel vercel bot temporarily deployed to Preview – hardhat-storybook September 28, 2022 11:39 Inactive
@vercel vercel bot temporarily deployed to Preview – hardhat September 28, 2022 11:39 Inactive
@fvictorio fvictorio requested a review from feuGeneA September 28, 2022 11:40
@github-actions github-actions bot added the Stale label Oct 31, 2022
@fvictorio fvictorio removed the Stale label Dec 22, 2022
@alcuadrado
Copy link
Member

test

@alcuadrado alcuadrado merged commit 0edcf75 into main Feb 9, 2023
@alcuadrado alcuadrado deleted the francovictorio/hh-937/improve-waffle-warning branch February 9, 2023 15:46
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

3 participants