typechain ethers-v5 inclusion of hardhat-ethers
See original GitHub issueIn the newest version of typechain, typechain ethers-5 target include types for the plugin hardhat-ethers
This pose problem for plugin that are alternative to hardhat-ethers like hardhat-deploy-ethers
which have different function signature, but use the same hre.ethers object
An option to at least disable hardhat-ethers type generation would be good. AFter all the ethers v5 target should focus on ethers itself.
An alternative would be to create a specific hardhat ethers target
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
@typechain/ethers-v5 - npm
@typechain/ethers-v5. TypeScript icon, indicating that this package has built-in type declarations. 10.2.0 • Public • Published 13 days ago.
Read more >Feature to add a Contracts object to typechain #370 - GitHub
So it's a bit of a pain to use the lib as is with hardhat. First I need to get the SystemFactory, then...
Read more >The New Solidity Dev Stack: Hardhat + Ethers + Waffle + ...
TypeChain is a really cool tool that gives you a full typed interface for your smart contracts. Once it's set up we can...
Read more >How to deploy your first smart contract on Ethereum with ...
Tagged with ethereum, solidity, web3, hardhat. ... yarn add --dev typechain @typechain/hardhat @typechain/ethers-v5.
Read more >TypeChain: TypeScript Bindings for Ethereum Smart Contracts
Under the hood, eth-sdk relies on TypeChain . Usage. CLI. Note: If you use hardhat just use hardhat plugin. typechain --target=(ethers-v5|truffle- ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
As an outsider, I understand the issue results from the hardhat
getContract*
types being hardcoded; the hardcoded types are actually in typechain/ethers-v5, dist/congen/hardhat to be precise.Because hardhat-deploy-ethers exposes new methods (in particular
getContract()
) and because typechain/ethers-v5 is hardcoding the ethers types, the getContract types are not available and, hence, typechain has no idea what getContract is returning (because the type definition never gets created).Currently, the hardhat-deploy-ethers plugin deletes hardhat.d.ts which results in all of the getContract* functions having no type definitions.
Is there a way to create the types “on-the-fly” somehow, in order to take advantage of the extended
getContract()
function? Happy to help if I know I’m interpreting the problem correctly and can be given some guidance in how to potentially solve this issue.So in theory I think it’s possible for hardhat-deploy to ship with Typescript module definition likes (*.d.ts) that could “brute force” overwrite the types but that’s pretty messy
I think it would be better if typechain could offer a way to de-couple itself from the hardhat ethers plugin to support forked plugins (mainly hardhat-deploy). The need for this is growing as other template projects (such as scaffold-eth) now depend internally on hardhat-deploy (which is honestly just a better version that the built in HH plugin).
Unrelated question - are there plans for hardhat-deploy to get unforked with the official HH plugin at some point? Would make the need for fixing this in typechain a lot more clear and present.
One final random note - I’m working around this typechain issue in my hardhat-deploy project by explicitly setting the generic type per the suggestion here. It’s a minor nuisance, but it’s a bummer because Typechain is so cool and it’s so close to just working for hardhat-deploy projects too
https://github.com/wighawag/hardhat-deploy-ethers/issues/23#issuecomment-1101040259