3.0.0: Remove API response int decoding option, support BigInt everywhere #816
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
In release 3.0.0, we are introducing typed responses for algod API calls. One area where these responses could be improved is with respect to integers, since all response integer types are currently
number | bigint
. This union type is not very useful, as you can perform virtually no operations against it without casting to one of the component types (which potential loss in accuracy for bigint -> number conversions).The idea behind this PR is that we will parse everything as a bigint, since that is the most general integer type available to us, and unfortunately the algod API does not distinguish between full uint64s and smaller integer types. There are two advantages to making this change:
bigint
, which is more useful than a union type.JSON.parse
by default for API responses. This parser is unable to produce bigints, so it will provide inaccurate data for large integers, of which there are plenty in our responses. We introduced theIntDecoding
option on requests to provide support for larger integers without breaking backwards compatibility in v2, but there is no reason to keep this around any longer, as it involves unnecessary complexity.Work required
bigint
(PR TypeScript: Use bigints for internal property types generator#67)algosdk.parseJSON
andalgosdk.stringifyJSON
, which support bigintssetIntDecoding
functions from client and request classes