-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 BigInts UX #280
Comments
On SwaySwap |
nice catch @AlicanC I didn't know it. as mentioned in Serialize JSON - step 10. as bigint was created to address it natively, but still have its problems. I think we should never expose something that can break in a command often used like Instead of going with native BN.js is a good one:
It supports sizes that we need and it's pretty complete with a lot of helpers. I think we should create a lib that uses BN.js in the background and have some additional helpers that we will need, like some presents in SwaySwap swayswap/math.js.
When stringifyed it exposes a hex which will work as JSON common string and not break anything |
We moved from Ethers v5 BigNumbers to native JS BigInts in #258.
While the UX has been generally fine, the native
JSON.stringify
does not support BigInts so the users might getDo not know how to serialize a BigInt
errors, both from their own usage of it (which they could fix) and also from the libraries they use (which they might not be able to).One example issue is this, where Jest fails to render the actual error if the error involves a BigInt: jestjs/jest#11617 (comment)
(The solution is starting Jest with
--maxWorkers 1
which probably disables the thing that can't handle BigInts.)We should further investigate the UX of native BigInts. If we find them unworthy then we can stop using them in output positions so users never get BigInts while we can keep using them.
(Or maybe we could make the build system polyfill BigInts.)
The text was updated successfully, but these errors were encountered: