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

Use ethersjs v6 AddressLike type in hardhat-chai-matchers #4097

Closed
RenanSouza2 opened this issue Jul 1, 2023 · 6 comments · Fixed by #4449
Closed

Use ethersjs v6 AddressLike type in hardhat-chai-matchers #4097

RenanSouza2 opened this issue Jul 1, 2023 · 6 comments · Fixed by #4449
Labels
area:chai-matchers status:ready This issue is ready to be worked on type:feature Feature request

Comments

@RenanSouza2
Copy link
Contributor

RenanSouza2 commented Jul 1, 2023

Describe the feature

ethersjs v6 implements a AddressLike type that improoves the UX by allowing to pass an signer or contract object where an address is expected

hardhat-chai-matchers still expects a string for an address so I suggest using the same treatment,

I thought this was implemented in the ethers.io project so I fist opened this issue: ethers-io/ethers.js#4191

Search terms

No response

@fvictorio
Copy link
Member

Hi @RenanSouza2, which matchers do you think should support AddressLike values? Some examples would be great.

We accept contracts right now, but maybe this is about expanding those types to allow more general Addressable things.

@fvictorio fvictorio added status:needs-more-info There's not enough information to start working on this issue and removed status:triaging labels Jul 5, 2023
@RenanSouza2
Copy link
Contributor Author

In this repository I wrote some examples: https://github.com/RenanSouza2/chai-matchers-example/blob/main/test/Lock.ts

the examples I would like are in comparing returned addresses from contracts to signers

and in the 'withArgs' of events matchers and revertedWithCustomError

@frangio
Copy link
Contributor

frangio commented Jul 5, 2023

We accept contracts right now

Where is this implemented? I can't find it in the code.

@fvictorio
Copy link
Member

@RenanSouza2 thanks for the examples. I agree that having those in the .withArgs would be super nice. For the equality matchers is sadly not possible in the general case, because getAddress is async. We could maybe do it with .target but that doesn't work in some cases.

@frangio for example, you can do this:

await expect(foo.inc()).to.changeEtherBalance(foo, 0)

or this:

await expect(foo.inc()).to.changeEtherBalance(await foo.getAddress(), 0)

That's implemented here.

@fvictorio fvictorio added type:feature Feature request status:ready This issue is ready to be worked on area:chai-matchers and removed status:needs-more-info There's not enough information to start working on this issue labels Jul 6, 2023
@RenanSouza2
Copy link
Contributor Author

@RenanSouza2 thanks for the examples. I agree that having those in the .withArgs would be super nice. For the equality matchers is sadly not possible in the general case, because getAddress is async. We could maybe do it with .target but that doesn't work in some cases.

Makes sense, and besides '.target'there could also work with the '.address'of the 'SignerWithAddress' type.

If there is anything I can do to help here, let me know

@Amxx
Copy link
Contributor

Amxx commented Oct 7, 2023

#4449 should fix that issue. Open to feedback !

@github-project-automation github-project-automation bot moved this to Done in Hardhat Dec 26, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area:chai-matchers status:ready This issue is ready to be worked on type:feature Feature request
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants