You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have noticed several places in Rust code using U128 and U256 for "amount" type fields these are not compatible with MAX_SAFE_INTEGER and on the rust side they'll serialize fine but on the javascript side they will become floats (number) during JSON.parse leading to loss of precision.
We must do something to address the deserialization of large integers that is better than JSON.parse.
Javascript now has a built in bigint class that is perfect for this kind of thing but no real way of integrating that into JSON.parse yet. We may need to write the json tokenizer/parser or re-use some such existing package such as this one.
I have noticed several places in Rust code using U128 and U256 for "amount" type fields these are not compatible with MAX_SAFE_INTEGER and on the rust side they'll serialize fine but on the javascript side they will become floats (
number
) during JSON.parse leading to loss of precision.We must do something to address the deserialization of large integers that is better than JSON.parse.
Javascript now has a built in bigint class that is perfect for this kind of thing but no real way of integrating that into JSON.parse yet. We may need to write the json tokenizer/parser or re-use some such existing package such as this one.
https://github.com/sidorares/json-bigint
Another alternative is to always serialize integers as strings across the entire ecosystem but that seems unmanageable
The text was updated successfully, but these errors were encountered: