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

Upgrade hardhat-viem to support viem@2 #4875

Merged
merged 4 commits into from
Feb 20, 2024
Merged

Upgrade hardhat-viem to support viem@2 #4875

merged 4 commits into from
Feb 20, 2024

Conversation

schaable
Copy link
Member

@schaable schaable commented Feb 15, 2024

This PR represents the first part of adding support for viem@2. A subsequent PR will update hardhat-toolbox-viem and the dependencies in packages/hardhat-core/src/internal/cli/project-creation.ts.

Link to second PR.

Copy link

changeset-bot bot commented Feb 15, 2024

🦋 Changeset detected

Latest commit: bdf5520

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-viem Major
@nomicfoundation/hardhat-toolbox-viem Major

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

vercel bot commented Feb 15, 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 Feb 20, 2024 8:15am

@github-actions github-actions bot added the status:ready This issue is ready to be worked on label Feb 15, 2024
@schaable schaable force-pushed the upgrade-viem-to-v2 branch 2 times, most recently from 3774cac to 192edd0 Compare February 15, 2024 19:50
@fvictorio
Copy link
Member

fvictorio commented Feb 16, 2024

I think our own hre.viem.getContractAt should ideally follow the API of viem.getContract. That is, instead of:

await hre.viem.getContract("Foo", "0x1234567890123456789012345678901234567890", {
  walletClient: secondWalletClient
};

it should become:

await hre.viem.getContract("Foo", "0x1234567890123456789012345678901234567890", {
  client: {
    wallet: secondWalletClient
  }
}

Viem also accepts this:

await hre.viem.getContract("Foo", "0x1234567890123456789012345678901234567890", {
  client: extendedClient
}

But I tried to do it, and making the type-inference work was not straightforward. So I think we could start by only supporting the client: { public, wallet } version. Then adding support for client: extendedClient can be done without breaking changes.

Copy link
Member

@kanej kanej left a comment

Choose a reason for hiding this comment

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

LGTM!

@fvictorio fvictorio merged commit 8a1a2b6 into main Feb 20, 2024
19 of 23 checks passed
@fvictorio fvictorio deleted the upgrade-viem-to-v2 branch February 20, 2024 08:14
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status:ready This issue is ready to be worked on
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants