Temperature check: More robust type integration
I am looking to help implement a feature, and am creating this issue to see if the changes would be welcome by maintainers.
Right now, contract type information when using Typescript and TypeChain relies heavily on casting, and while is usually "good enough", it's still surface area for human error (especially when copy-pasting boilerplate). It would also just "be nice" if it "just worked". I propose a few things that would help close this gap:
- ~Make
Artifactoptionally generic, allowing you to pass in theContractandContractFactorytypes~ - Enumerate all contracts when generating TypeChain types, adding overloads to
artifacts.readArtifactto return typedArtifactobjects using the above generic - ~Change signature of Waffle's
deployContractto be aware of the passed inArtifact'sContractandContractFactorytypes, returning the correctContracttype and also validating constructor args~ - ~Enumerate all contracts when generating TypeChain types, adding overloads to ethers'
getContractFactoryandgetContractAtto return typed contract factory and contract instances (respectively)~
(see comment below for updated plan)
None of these changes would be breaking changes for existing TypeScript/TypeChain users (or any other users).
I already have most of this working by editing the source files directly, and I would just have to organize the changes into PRs across the various repositories. Let me know if this approach seems reasonable, and also if I forgot anything that would be complementary in this effort.