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

Properly handle BigInt <-> JSON #43

Open
brendanrbrown opened this issue Mar 11, 2024 · 0 comments
Open

Properly handle BigInt <-> JSON #43

brendanrbrown opened this issue Mar 11, 2024 · 0 comments
Labels
enhancement Add or improve a user-facing feature

Comments

@brendanrbrown
Copy link

brendanrbrown commented Mar 11, 2024

We need to serialize BigInt values to JSON in the offchain code. However, BigInt is not supported in JSON, and the standard JavaScript conversions via parse or stringify fail either with runtime exceptions or by silently overflowing.

For now, TrustlessSidechain.Utils.Codecs.bigIntCodec throws an exception when attempting to serialize a value that is out of the range of a PureScript Int.

We can probably do better using an existing JavaScript package like this one for serializing BigInt.

Or, we could reconsider the use of BigInt in the first place for values that need to be serialized to JSON.

For some details see https://github.com/input-output-hk/trustless-sidechain/pull/711#discussion_r1510989411

and the code Note [BigInt values and JSON].

This issue is moot if we move the offchain code to Haskell, as discussed here: https://github.com/input-output-hk/trustless-sidechain/discussions/710


IOG Jira: https://input-output.atlassian.net/browse/ETCM-6865

@jstolarek jstolarek added the enhancement Add or improve a user-facing feature label Mar 12, 2024
@gilligan gilligan transferred this issue from another repository Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Add or improve a user-facing feature
Projects
None yet
Development

No branches or pull requests

2 participants