Concordium / concordium-node-sdk-js

TypeScript SDK for using the Concordium blockchain
http://developer.concordium.software/concordium-node-sdk-js/
Apache License 2.0
20 stars 17 forks source link

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

Open lassemoldrup opened 5 months ago

lassemoldrup commented 5 months ago

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.