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.
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
Hardhatrefuses it.Possible Solution
Declaring the C# type as
stringinstead ofBigIntegerworks, 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
deadlinefield to the maxuint256value115792089237316195423570985008687907853269984665640564039457584007913129639935will makeHardhat'seth_signTypedData_v4call assert.Possible Implementation
I believe the bug is somewhere around:
Nethereum/src/Nethereum.ABI/EIP712/TypedDataRawJsonConversion.cs
Line 196 in 49a0c1a
It should not insert the BigInteger value as is, but check for maximum (and minimum) value and serialize it to string.