trueblocks-core icon indicating copy to clipboard operation
trueblocks-core copied to clipboard

Numbers in JSON are too big

Open dszlachta opened this issue 4 years ago • 2 comments

In the JSON produced by chifra, numbers can exceed JavaScript's Number.MAX_SAFE_INTEGER.

We should use strings for big numbers, as JSON does not have BigInt or any other BigNum type.

dszlachta avatar Sep 23 '21 15:09 dszlachta

I guess the issue here is that we have to send any wei_t, uint256_t, bigint_t (whatever) as a string in our JSON. I thought that was already the case, but maybe not. Not sure how to find these types of issues.

tjayrush avatar Oct 07 '21 19:10 tjayrush

I see that you marked this as completed, but the API (and chifra) still returns these values as numbers in JSON, e.g. this response from transactions:

{
  "data": [
    {
      "hash": "0xf21cbf9844ecc4f5856abea2567c4c000acb8342083363231d5e63abd58412a6",
      "blockHash": "0x680a97b17b1b0b2d3d5cb7abcdbb9f8de8377ba1cfebef0404db203ad404703c",
      "blockNumber": 14853588,
      "transactionIndex": 104,
      "timestamp": 1653646710,
      "from": "0xe126b3e5d052f1f575828f61feba4f4f2603652a",
      "to": "0x0a267cf51ef038fc00e71801f5a524aec06e4f07",
      "value": 97482271565080634,
      "gas": 713087,
      "gasPrice": 22297161915,
      "maxFeePerGas": 39429536191,
      "maxPriorityFeePerGas": 1500000000,
     ...

rkalis avatar Jun 22 '22 14:06 rkalis

This will be fixed naturally as part of the porting to GoLang and will not be fixed in the C++ code. No need to keep track of this issue.

tjayrush avatar Jan 17 '23 03:01 tjayrush