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

properly evmMarshal evm_log_params #643

Merged
merged 2 commits into from
Feb 27, 2024
Merged

Conversation

Andrew7234
Copy link
Collaborator

Certain datatypes of the abi-parsed evm_log_params weren't being stored in a json-friendly format. For example, uint256 should be stored as a string, not a number, to avoid issues with float conversion and display properties when retrieved via the json api.

Turns out the function to do this already exists in the abiparse package; this PR utilizes it to properly marshal abi arguments in the abi backfill analyzer.

Testing:

    {
      "body": {
        "address": "mYYzvfbuMqnMpsmiR/QoWW6OZdg=",
        "data": "",
        "topics": [
          "3fJSrRviyJtpwrBo/DeNqpUrp/FjxKEWKPVaTfUjs+8=",
          "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=",
          "AAAAAAAAAAAAAAAAFEG7vhVk0LPkiffFvMTwxexMTNg=",
          "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIQ="
        ]
      },
      "eth_tx_hash": "701bb26dd38138fab220b60b6f93586a6e354334dd88799229084af3e46d71d9",
      "evm_log_name": "Transfer",
      "evm_log_params": [
        {
          "evm_type": "address",
          "name": "from",
          "value": "0x0000000000000000000000000000000000000000"
        },
        {
          "evm_type": "address",
          "name": "to",
          "value": "0x1441bbbe1564d0b3e489f7c5bcc4f0c5ec4c4cd8"
        },
        {
          "evm_type": "uint256",
          "name": "tokenId",
          "value": "132"
        }
      ],
      "round": 410435,
      "timestamp": "2023-05-04T16:10:26-04:00",
      "tx_hash": "49e4c707ee9d4586d98d45c67093473420652a468581ca31851a881d91620d31",
      "tx_index": 0,
      "type": "evm.log"
    }
  ],
  "is_total_count_clipped": false,
  "total_count": 166

^Note the third tokenId parameter is properly returned as a string now

Copy link
Collaborator

@pro-wh pro-wh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alright kool, if it's suitable

Copy link
Contributor

@mitjat mitjat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Looks good, though I suggest waiting for #633 to go in so we can see the effects even better.

@Andrew7234 Andrew7234 force-pushed the andrew7234/abi-int-strings branch from 53b91cb to b0c163b Compare February 27, 2024 02:28
@Andrew7234 Andrew7234 merged commit b102297 into main Feb 27, 2024
10 checks passed
@Andrew7234 Andrew7234 deleted the andrew7234/abi-int-strings branch February 27, 2024 02:39
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.

3 participants