iotaledger / iotaledger/notarization
[Bug]: TS - "TypeError: Do not know how to serialize a BigInt" on JSON.stringify(notarization)
- Dominant language
- Rust
- Stars
- 5
- Forks
- 7
- Avg merge
- 10h 34m
- Merged PRs (30d)
- 11
Description
### Bug description
When trying to call `JSON.stringify()` on an `OnChainNotarization` object, you'll get a `TypeError: Do not know how to serialize a BigInt"`.
This is caused by `u64` values used for the Rust `OnChainNotarization` type:
```rs
pub struct OnChainNotarization {
...
/// The timestamp of the last state change.
pub last_state_change_at: u64,
/// The number of state changes.
pub state_version_count: u64,
...
}
```
Which is bound to `BigInt` values for `lastStateChangeAt` and `stateVersionCount` in the TS `OnChainNotarization` class.
Implementation:
In general u64 should be used internally to prevent having a [year 2038 problem](https://en.wikipedia.org/wiki/Year_2038_problem)
The equivalent `getter` implementations should return `string` values as this type is also used for BCS deserialization in the [TS BCS library](https://docs.iota.org/developer/ts-sdk/bcs#basic-types).
### Expected behavior
1. Calling `JSON.stringify()` on an `OnChainNotarization` object must work
2. Having a [year 2038 problem](https://en.wikipedia.org/wiki/Year_2038_problem) must be avoided
### Can the issue reliably be reproduced?
Yes
### Example repository
_No response_
### Steps to reproduce
-
### Language
Node.js
### Language Version
-
### Version
0.1.0
### Hardware specifications
-
### Additional info
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.