Skip to content

Conversation

@alcuadrado
Copy link
Member

This PR:

  • Renames .reverted() to .revert()
  • Reintroduces .reverted as a property that always throws an error
  • Makes all the matchers that used to receive an EthereumProvider take HardhatEthers now.

The reason for the first two is that while migrating a HH2 project it was easy to forget to call .rejected and just leave it like that, which lead to an unhandled promise rejection.

The latter is for consistency.

@changeset-bot
Copy link

changeset-bot bot commented Aug 11, 2025

🦋 Changeset detected

Latest commit: f61ab8a

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

This PR includes changesets to release 21 packages
Name Type
@nomicfoundation/hardhat-ethers-chai-matchers Patch
@nomicfoundation/hardhat-errors Patch
hardhat Patch
@nomicfoundation/hardhat-ignition Patch
@nomicfoundation/ignition-core Patch
@nomicfoundation/hardhat-ignition-ethers Patch
@nomicfoundation/ignition-ui Patch
@nomicfoundation/hardhat-ignition-viem Patch
@nomicfoundation/hardhat-keystore Patch
@nomicfoundation/hardhat-mocha Patch
@nomicfoundation/hardhat-network-helpers Patch
@nomicfoundation/hardhat-node-test-reporter Patch
@nomicfoundation/hardhat-node-test-runner Patch
@nomicfoundation/hardhat-test-utils Patch
@nomicfoundation/hardhat-typechain Patch
@nomicfoundation/hardhat-utils Patch
@nomicfoundation/hardhat-toolbox-mocha-ethers Patch
@nomicfoundation/hardhat-verify Patch
@nomicfoundation/hardhat-viem Patch
@nomicfoundation/hardhat-viem-assertions Patch
@nomicfoundation/hardhat-zod-utils 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

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the Hardhat Ethers Chai matchers by renaming .reverted() to .revert(), introducing a deprecation warning for the legacy .reverted property, and updating all balance change matchers to accept HardhatEthers instead of EthereumProvider for API consistency.

  • Renames the .reverted() matcher method to .revert() across all test files and implementation
  • Adds a new .reverted property that throws a deprecation error to prevent accidental usage
  • Updates balance change matchers to use HardhatEthers instead of EthereumProvider for consistency

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
v-next/hardhat-ethers-chai-matchers/test/multi-network-connections.ts Updates changeEtherBalance calls to use ethers instead of provider
v-next/hardhat-ethers-chai-matchers/test/matchers/reverted/revert.ts Renames all .reverted() calls to .revert() and updates test descriptions
v-next/hardhat-ethers-chai-matchers/test/matchers/reverted/legacyReverted.ts New test file for the deprecated .reverted property behavior
v-next/hardhat-ethers-chai-matchers/test/matchers/changeTokenBalance.ts Updates all balance change matcher calls to use ethers instead of provider
v-next/hardhat-ethers-chai-matchers/test/matchers/changeEtherBalances.ts Updates balance change matcher calls to use ethers parameter
v-next/hardhat-ethers-chai-matchers/test/matchers/changeEtherBalance.ts Updates balance change matcher calls to use ethers parameter
v-next/hardhat-ethers-chai-matchers/src/type-extensions.ts Updates type definitions to use HardhatEthers instead of EthereumProvider
v-next/hardhat-ethers-chai-matchers/src/internal/utils/balance.ts Refactors balance utilities to use HardhatEthers and direct provider calls
v-next/hardhat-ethers-chai-matchers/src/internal/matchers/reverted/revert.ts Renames matcher from REVERTED_MATCHER to REVERT_MATCHER
v-next/hardhat-ethers-chai-matchers/src/internal/matchers/reverted/legacyReverted.ts New implementation for deprecated .reverted property with error throwing
v-next/hardhat-ethers-chai-matchers/src/internal/matchers/changeTokenBalance.ts Updates to use HardhatEthers and direct provider calls instead of raw requests
v-next/hardhat-ethers-chai-matchers/src/internal/matchers/changeEtherBalances.ts Updates parameter types and function calls to use HardhatEthers
v-next/hardhat-ethers-chai-matchers/src/internal/matchers/changeEtherBalance.ts Updates to use HardhatEthers and direct provider calls
v-next/hardhat-ethers-chai-matchers/src/internal/constants.ts Adds new constants for legacy and new matcher names
v-next/hardhat-ethers-chai-matchers/src/internal/add-chai-matchers.ts Registers both legacy and new matcher implementations
v-next/hardhat-errors/src/descriptors.ts Adds new error descriptor for deprecated matcher usage

@alcuadrado alcuadrado enabled auto-merge August 11, 2025 20:09
@alcuadrado alcuadrado added this pull request to the merge queue Aug 11, 2025
Merged via the queue into v-next with commit 432fa9f Aug 11, 2025
225 checks passed
@alcuadrado alcuadrado deleted the chai-matchers-improvements branch August 11, 2025 20:36
@github-project-automation github-project-automation bot moved this from Backlog to Done in Hardhat Aug 11, 2025
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 10, 2025
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.

3 participants