-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Improve typings for contracts #1384
Comments
Heya! Yes, I remember you. :) I have that exact thing in v6 right now, even the same name, I’m also hoping the next version of TS includes the PR for lifting the requirement of string indexes, and allows subsets of strings (e.g. keyof T, where T is passed into the Contract, which means things like TypeChain and the ethers-ts tool can simply define an interface to template against ;)). I don’t think it is safe to make that change in v5 though... but I will consider porting the change back after I think about it a bit... it might be. |
I can't find a reason why this wouldn't be safe to change in the current codebase 🤔 Also what about 2)? |
It may be. I just need to think more about it. Simple changes have broke things before, especially when they change .d.ts files.
|
@ricmoo when sending (not calling) a tx which one should I use? I think it should be |
Correct. When sending a transaction, it should use either Overrides or PayableOverrides. For either of those In ethers, providers don't have a notion of an account. It just happens that JsonRpcProvider has a method to fetch accounts, because that type of Provider has them. But it helps keep the distinction between a Provider and Signer. To accomplish changing the Make sense? |
It does, but somehow passing Perhaps it only works in hardhat like environments (custom providers or something?) 🤔 |
Anyway, regarding 1) did you make up your mind? 😆 maybe we could release a beta version with |
It’s a Hackathon weekend (NFTHack), so I won’t get a chance to dig in until after the weekend and after sleep. ;) |
@ricmoo have you got a chance to think about this? I am still up for making a PR to fix 1) |
I’ve made the change locally and am playing with it. I’ve also decided a lot is changing in this version, so I’ve bumped the minor version, which has required a lot of changes in the build process, extra scripts, etc., so I’m taking things extra careful. And I’m using this as an opportunity to update a few other things that should only be made during a minor version bump. I may get it out tonight or tomorrow, or I may need to spend a few more days looking at the changes more broadly. But it’s coming along. :) |
Okay, great to hear. Thanks! I am working on the next major version of TypeChain and I wanted to ship it with this fix but it still needs more work. Probably I will release it sometime next weekend so it seems like it should be doable to get this included. |
This is now in 5.1.0. Try it out and let me know how it goes. :) |
It seems to work great. Thanks! I'll close it for now and I will re-open it in case of any problems. |
Awesome! :) |
@ricmoo I wanted to come up with some reasonable fix and get back to you but maybe you have some good ideas how to fix this. Maybe using I will reopen that issue for now, I should have time to work on this very soon. |
Does this still need to be open? I think it is difficult to make safe backwards compatible changes needed to directly facilitate this. In v6, I’m still hoping for a wider index signature to make it into TypeScript which will make things more elegant. :) |
@ricmoo closing this now. The problem that I described above was caused by ethers version mismatch. Thanks! Ethers & TypeChain work great together now! |
Hey Richard!
I am the maintainer of TypeChain and I would like to forward some ideas that would greatly improve our generated types. I am more than happy to make PRs to fix this - I just want to discuss these ideas first here.
packages/contracts/src.ts/index.ts
/Contract
class. The problem is that this class has index signatures for functions which we can't override in any way.Example:
readonly functions: { [ name: string ]: ContractFunction };
Despite the fact that we generate exact typings for all contract methods it's possible to mistype a method name and use a generic ContractFunction. This should result in a type error. I would propose extracting
BaseContract
interface without any index signatures so both ethers'sContract
and TypeChain generated types can extend that.Related to: dethcrypto/TypeChain#276 and dethcrypto/TypeChain#351
packages/contracts/src.ts/index.ts
/Overrides
is missing{ from?: string | Promise<string> }
. I would like to add it.Related to: dethcrypto/TypeChain#345
WDYT? As I mentioned already I can prepare PR if you approve these changes.
The text was updated successfully, but these errors were encountered: