Skip to content

fix: bigint support#27

Merged
alanshaw merged 2 commits into
mainfrom
ash/fix/bigint-support
May 27, 2026
Merged

fix: bigint support#27
alanshaw merged 2 commits into
mainfrom
ash/fix/bigint-support

Conversation

@alanshaw

Copy link
Copy Markdown
Member

This PR fixes support for big ints. Instead of leaning on a custom big int type (go-state-types/big), we use native math/big.

It also adds support for big ints when marshaling to/from JSON.

JSON encoded numbers do not have a fixed size, so it's impossible to distingish between int64 and big.Int when decoding, without inventing a custom representation of these different types. The decision here is to decode a number to int64 when the value fits, but otherwise use a big.Int. The trade off is that when encoding "small" big ints, you'll get back an int64 when you decode i.e. they won't round trip.

If you need the round trip to work you should use dag-json-gen to generate encoders/decoders. Alternatively use your own custom type, or string or []bytes to represent the value.

Related alanshaw/dag-json-gen#1 for negative bigint support.

@alanshaw alanshaw requested a review from frrist May 25, 2026 11:52
@alanshaw alanshaw merged commit 517b03b into main May 27, 2026
1 check passed
@alanshaw alanshaw deleted the ash/fix/bigint-support branch May 27, 2026 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants