etherface icon indicating copy to clipboard operation
etherface copied to clipboard

Support querying by named parameters of a signature

Open allenday opened this issue 3 years ago • 4 comments

This will be helpful for ABI and event decoding directly in a database query. For example:

SELECT 
  f.repo_name, f.path, c.content, 
  REGEXP_EXTRACT_ALL(c.content, r'(event\s*?\S*?\s*?\(.*?\))') AS events,
  REGEXP_EXTRACT_ALL(c.content, r'(function\s+?.+?\(.*?\))') AS functions
FROM
  `bigquery-public-data.github_repos.contents` AS c,
  `bigquery-public-data.github_repos.files` AS f
WHERE TRUE
  AND f.id = c.id 
  AND LOWER(f.path) LIKE '%.sol'

Returns a record with this event:

event NewTokenGrant(address indexed from, address indexed to, uint256 value, uint256 grantId)

and this function:

function revokeTokenGrant(address _holder, uint256 _grantId)

While it's useful to have the 4byte method signature, it's also useful to be able to map these, respectively, to:

["from", "to", "value", "grantId"]

and

["_holder", "_grantId"]

for the purpose of creating decoded function/event tables with named parameters.

allenday avatar Nov 23 '22 11:11 allenday

This looks interesting, I think I'll address this in the Etherface re-write. In general this would require changes to the parser.rs module as well as the introduction of a parameter table with a n-m mapping to the signature table.


Edit from #10:

The current approach to scraping function, event and error signatures from source code consists of finding these on Etherscan and GitHub. Once found the parser extracts these signatures with RegEx and inserts them into the database. To support mapping named parameters to their signatures we would need to extract these and insert them into the database also. [...]

volsa avatar Nov 23 '22 12:11 volsa

in many cases it will be enough to get the ABI, e.g. https://etherscan.io/address/0xbe6161704f1f5cd89f49f790137f33cef2bb8554#code

allenday avatar Nov 30 '22 16:11 allenday

Only works for Etherscan though, because most GitHub repositories don't provide an ABI.

volsa avatar Nov 30 '22 19:11 volsa

And #15 Polygon

I'm not sure the overlap but the # of contracts is about 1/10 of what's on ETH

Testnets I think we should ignore.

allenday avatar Dec 01 '22 14:12 allenday