etherface
etherface copied to clipboard
Support querying by named parameters of a signature
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.
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. [...]
in many cases it will be enough to get the ABI, e.g. https://etherscan.io/address/0xbe6161704f1f5cd89f49f790137f33cef2bb8554#code
Only works for Etherscan though, because most GitHub repositories don't provide an ABI.
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.