Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BigInteger JSON serialization should be string if their value is bigger than 2^53 #981

Open
AlexandreBossard opened this issue Oct 18, 2023 · 0 comments

Comments

@AlexandreBossard
Copy link

BigInteger serialization does not respect the JSON specification when value is above 2^53

Expected Behavior

The serialized json value should be of type string, and not number, when value is above the 2^53.

Current Behavior

The value is serialized as number json, which is not guaranteed to be interoperable across json implementation. For example Hardhat refuses it.

Possible Solution

Declaring the C# type as string instead of BigInteger works, at least for Hardhat.

Steps to Reproduce

(coming soon)

Context (Environment)

.Net7 Core on linux + Hardhat 2.17.3 + Nethereum 4.17.1

Detailed Description

Using the EIP2612 Permit model and assigning the deadline field to the max uint256 value 115792089237316195423570985008687907853269984665640564039457584007913129639935 will make Hardhat's eth_signTypedData_v4 call assert.

Possible Implementation

I believe the bug is somewhere around:

private static List<JProperty> GetJProperties(string mainTypeName, MemberValue[] values, TypedDataRaw typedDataRaw)

It should not insert the BigInteger value as is, but check for maximum (and minimum) value and serialize it to string.

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

No branches or pull requests

1 participant