concordium-node-sdk-js icon indicating copy to clipboard operation
concordium-node-sdk-js copied to clipboard

`TransactionExpiry.toJSON` can fail if the internal `bigint` is not a safe integer

Open lassemoldrup opened this issue 10 months ago • 0 comments

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.

lassemoldrup avatar Apr 09 '24 13:04 lassemoldrup