Skip to content

Conversation

@antico5
Copy link
Contributor

@antico5 antico5 commented Jul 24, 2025

Closes #7038

Predicates support has been added to emitWithArgs and revertWithCustomErrorWithArgs.

The assertion failures when using predicates to match are not displayed the same way as when passing primitive values. This is because for the latter we leverage assert.deepEqual, which shows the diff in the following way:

   AssertionError: The event arguments do not match the expected ones.
   - Expected
   + Received
   
     Array [
   -   2n,
   +   1n,
     ]

When using predicates and the assertion fails, we have to build a custom message and it looks like this:

   AssertionError: The event arguments do not match the expected ones:
   Expected: ["<predicate>"]
   Emitted: ["1"]

@changeset-bot
Copy link

changeset-bot bot commented Jul 24, 2025

🦋 Changeset detected

Latest commit: de38508

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

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

@fvictorio fvictorio left a comment

Choose a reason for hiding this comment

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

I manually tested this a bit and LGTM. I haven't reviewed the code, so let's wait for @ChristopherDedominici's review to merge.

Copy link
Contributor

@ChristopherDedominici ChristopherDedominici left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@kanej
Copy link
Member

kanej commented Jul 30, 2025

Can we add minimal docs on this to the readme?

@antico5 antico5 added this pull request to the merge queue Jul 30, 2025
Merged via the queue into v-next with commit 9f89015 Jul 30, 2025
37 checks passed
@antico5 antico5 deleted the add-predicates-to-viem-assertions branch July 30, 2025 14:52
@github-project-automation github-project-automation bot moved this from Backlog to Done in Hardhat Jul 30, 2025
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 29, 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.

Support predicates in hardhat-viem-matchers

5 participants