-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Fix web3-eth-abi export types #3587
Conversation
|
@Velenir Apologies for the delay reviewing here... It looks like this issue affects ~16 Web3 sub-modules and various PR's have been opened in piecemeal fashion to address each one as users have run into the bug. One complication with fixing it is that the solution should (ideally) be compatible with near-term plans to rewrite Web3 1.x in TS. Because the types are wrong for constructor usage but people are already using them as definitions, doing this correctly may require a breaking change. TLDR; I think we need to fix this in a consistent way across the project and have a plan for how to manage its implications. Related issues include
cc: @GregTheGreek |
|
FYI We've opened up #3606 to try and track these changes in a more consistent manner. this PR isn't necessarily off the table, I just think we need to asses everything first |
|
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. |
|
|
|
“Tools”,“Interact”,”Contracts” From":"0x0000000000000000000000000000000000000000","contractAddress":"0xed5a231ecc0fa775980ad7b86e49872feacd4c8f","to":"0xc287cf1f50d5bd56de70bdec1f4103d2b733a6d4","value":"8412000000000000000000","tokenName":"LuckyBucks","tokenSymbol":"LBT","tokenDecimal":"18" Malaysia needs a privacy law that protects people, not corporations. @privacy rights act 1974 and Securities Law act 1933 are violated by the Lucky Bucks, LLC., 5820 Live Oak Pkwy Ste 300, Norcross, 30071 Georgia, United States, Phone: +1 (770) 449-4699, E-mail: Inquiries@luckybucksga.com, Website: https://luckybucksga.com (Subsidiary). Head Office address: Seven Aces Limited, 79 Wellington Street West, Suite 1630, PO Box 138, Toronto, Ontario, Canada M5K 1H1, Phone: +1 416.569-3292, Fax: +1 416.477-3401, Website: http://www.sevenaces.com, E-mail: Info@sevenaces.com, Email: Manish@sevenaces.com |
jdevcs
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.
Closing this PR as there is no activity from long time. Recently merged similar fix PR #4937.
Description
Currently if I want to use
web3-eth-abiseparate from the wholeweb3in Typescript I get wrong types on importDeclarations in
index.d.tsspecifyexport class AbiCoderas the only export, so TS expects the following to workBut in reality
src/index.jsexports a singleton instance ofAbiCoderas defaultAnd TS code breaks with
Uncaught TypeError: web3_eth_abi__WEBPACK_IMPORTED_MODULE_1__.AbiCoder is not a constructorTo properly use abi I have to
To sum it up, TS declarations export named export class, whereas real JS export is default of that class instance.
I think there's a similar problem (sans singleton aspect) in
web3-eth-ensandweb3-eth-contract, maybe more. Didn't look too deep into it.This PR switches named export of
class AbiCoderto type only export (as JS doesn't export class at all), and adds a default export ofAbiCoderinstance.As an alternative, you may want to export both class and singleton instance in both JS and TS.
I believe #3198 is a related issue.
Type of change
Type fix
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 build-alland tested the resulting files fromdistfolder in a browser.CHANGELOG.mdfile in the root folder.