concordium-node-sdk-js
concordium-node-sdk-js copied to clipboard
`TransactionExpiry.toJSON` can fail if the internal `bigint` is not a safe integer
Bug Description
TransactionExpiry.toJSON converts a TransactionExpiry to a number as a serializable representation. However, a TransactionExpiry is implemented as a number of seconds from the UNIX epoch as a bigint. Therefore, converting to a number can give imprecise results, e.g. one might not be able to convert back to a TransactionExpiry.
#336 makes the method explicitly throw if the internal bigint is outside the safe range, but ideally a toJSON method should not throw errors.
Solution
Converting to a string instead would fix the problem, but this is a breaking change.