-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Fixed web3-eth-abi typing #4100
Conversation
The actual code exports as default a AbiCoder instance. In the previous version the class itself was exported via its name, breaks runtime code. Correctly used it looks like that: ```typescript import abiCoder from 'web3-eth-abi'; const data = abiCoder.encodeParameters(...); ``` The new typings reflects that now correctly.
|
Thanks for the PR, I haven't tested this specifically yet, but from my understanding this doesn't quite solve it and we have a deeper issue that requires breaking the api. AFAIIK Typescript doesn't have a way to export a instantiated classes. Specifically, abicoder looks like: |
|
For me this solved it. We can not use the class AbiCoder in user land as you indicated since it isn't exported in the javascript file.
My PR provides precisely that.
I don't see a deeper issue here. The published TS api is broken and unusable, so fixing it is the only way. No need to change the JS. |
Let me run this tomorrow, last time someone brought this up, it actually didn't solve the problem. But perhaps we were all mistaken! |
|
👋 Alright, let me know if you need anything else. |
|
Would be awesome to see this merged, having the same issue 👐 |
|
I'd like to see this merged as well. Ideally the export would simply be the functions, not a class. These are stateless utilities, why am I having to bind them? I'll definitely take this PR as a fix though, it will let me remove the |
|
This PR has been automatically marked as stale beacause it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment. |
lgtm |
|
can you please merge that? |
|
This PR has been automatically marked as stale beacause it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment. |
|
This PR has been automatically marked as stale beacause it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment. |
|
Can you please merge that? |
|
This PR has been automatically marked as stale beacause it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment. |
| ): { [key: string]: string }; | ||
| } | ||
|
|
||
| declare var coder: AbiCoder; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| declare var coder: AbiCoder; | |
| declare const coder: AbiCoder; |
I think you need to use const here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why need? If it doesn't match you coding style, you can change it afterwards, or close and commit yourself. For me its only important that this bug gets fixed, not how.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just fix it, please. and also check tests. They do not pass after your changes.
nazarhussain
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from feedback from @avkos LGTM
The actual code exports as default a AbiCoder instance. In the previous version the class itself was exported via its name, which breaks runtime code.
Correctly used it looks like that:
The new typings reflects that now correctly.
Description
Please include a summary of the changes and be sure to follow our Contribution Guidelines.
Type of change
Checklist:
npm run dtslintwith success and extended the tests and types if necessary.npm run test:unitwith success.npm run test:covand my test cases cover all the lines and branches of the added code.npm run buildand testeddist/web3.min.jsin a browser.CHANGELOG.mdfile in the root folder.