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

[ethers] Mark exported ABI as const for better type analysis #782

Closed
kdembler opened this issue Oct 14, 2022 · 0 comments · Fixed by #783
Closed

[ethers] Mark exported ABI as const for better type analysis #782

kdembler opened this issue Oct 14, 2022 · 0 comments · Fixed by #783

Comments

@kdembler
Copy link
Contributor

Hey, thanks for this awesome library!

After #368, contract ABI is exported as a static member on the contract's factory. However, because _abi that's defined in generated code is not marked with const assertion, ABI type definition is very simplified, as almost every field will be marked as string instead of string literal that narrows down possible values.

This is problematic because it won't allow some tools to take ABI from generated typechain bindings and extract rich data from it. For example, with release 0.7, wagmi library added support for type-safe contract calls, as long as abi passed is const asserted, allowing TS compiler to infer contract args, etc. You can find more info here: https://wagmi.sh/docs/typescript#type-inference

I propose as const is added to generated _abi code so that more type info can be extracted from bindings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant