hardhat icon indicating copy to clipboard operation
hardhat copied to clipboard

issues/4652: added support for library linking in `hardhat-viem`

Open Chlebamaticon opened this issue 1 year ago • 3 comments

Related to: https://github.com/NomicFoundation/hardhat/issues/4652,

Scope of changes: hardhat-core, hardhat-ethers, hardhat-viem.

Hi guys, that's my very first contribution to your project. Thanks for the all work you've done so far I really enjoy working with hardhat!

Motivation for this change's basically lack of support for linking the libraries within the hardhat-viem plugin and as I've stumbled upon that in another project and been blocked by it; I've come up with a workaround, so I decided to share that work with the rest of the community here.

What I've done so far is;

  • moved type definitions that were allocated within the hardhat-ethers into the hardhat-core that were related to libraries - will appreciate your feedback on that,
  • once types were shared I could use it within the hardhat-viem and that's where I have added linking functionality that mimics the interface of what we already have in hardhat-ethers,
    • you're able to deploy a contract using;
      • deployContract("ContractName", [], { libraries: { LibraryName: "0xLibraryAddress" }),
      • sendDeploymentTransaction("ContractName", [], { libraries: { LibraryName: "0xLibraryAddress" } }),
    • tried to replicate errors;
      • AmbigousLibraryNameError, thrown whenever library name is just not enough and fully qualified name is recommended,
      • UnnecessaryLibraryLinkError, thrown once linked library is not referenced by the contract we try to deploy,
      • MissingLibraryAddressError, thrown whenever at least one library link is missing,
      • InvalidLibraryAddressError, thrown anytime the linked address is in incorrect format,
  • covered that with tests in integration.ts spec file,

I wasn't sure If hardhat-core should be aware of libraries linking, so I am looking forward towards your feedback. 🙌

Chlebamaticon avatar Dec 18 '23 17:12 Chlebamaticon

🦋 Changeset detected

Latest commit: 581ae2ba06d6b54a67bf59561a2edb6d096f0eb6

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

This PR includes changesets to release 1 package
Name Type
@nomicfoundation/hardhat-viem 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

changeset-bot[bot] avatar Dec 18 '23 17:12 changeset-bot[bot]

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 Apr 19, 2024 9:15pm

vercel[bot] avatar Dec 18 '23 17:12 vercel[bot]

Hi @Chlebamaticon, sorry for the delay with your PR. I'll do my best to review it during next week.

schaable avatar Mar 05 '24 13:03 schaable

Hi @Chlebamaticon, sorry for the delay with your PR. I'll do my best to review it during next week.

@schaable just rebased to ease the review. Will appreciate your feedback. 🙌

Chlebamaticon avatar Mar 15 '24 15:03 Chlebamaticon

Howdy? @schaable

Chlebamaticon avatar Apr 01 '24 21:04 Chlebamaticon

Hi @Chlebamaticon, sorry again for the delay in reviewing this PR. I made a initial pass through the code and added some suggestions. Feel free to ask if you need any help or further clarification.

Thanks @schaable for your feedback; will apply desired changes later Today.

Chlebamaticon avatar Apr 15 '24 11:04 Chlebamaticon

Hi @Chlebamaticon, sorry again for the delay in reviewing this PR. I made a initial pass through the code and added some suggestions. Feel free to ask if you need any help or further clarification.

Made all suggested changes. 🙌

Chlebamaticon avatar Apr 16 '24 09:04 Chlebamaticon