shazow / whatsabi

Extract the ABI (and resolve proxies, and get other metadata) from Ethereum bytecode, even without source code.
https://shazow.github.io/whatsabi/
MIT License
1.07k stars 76 forks source link

loaders: Add code loading? #111

Closed shazow closed 3 months ago

shazow commented 3 months ago

Right now we just load the metadata, but we're not too far from loading the code too.

I believe the Etherscan loader already returns the code in the response, we just need to plumb it through to the response.

The Sourcify loader would likely need another request to fetch the source, so might need to make it a flag?

kuzdogan commented 3 months ago

Hey just saw this by chance. You can use the /files/any endpoint to get the source code and the metadata at the same time https://sourcify.dev/server/files/any/1/0x07880D44b0f7b75464ad18fc2b980049c40A8bc3/

shazow commented 3 months ago

@kuzdogan Ha thanks, just added that earlier today!! https://github.com/shazow/whatsabi/pull/112/files#diff-e06cc0643d5d32542b35abf16a4c938570ddd0a6d2fb52cc1703b45635e2cb8bR265

Actually I have a question, any reason why the partial /any/ version of the response is a different layout than the full match version? Latter is a list of files, former is contained within an object with {status, files: [...]}.

shazow commented 3 months ago

@kuzdogan Also one more question while I have you here (thanks for dropping by!), should I be replacing my usage of https://repo.sourcify.dev/contracts/partial_match/1/$ADDRESS/metadata.json api with the https://sourcify.dev/server/repository api instead?

kuzdogan commented 3 months ago

Actually I have a question, any reason why the partial /any/ version of the response is a different layout than the full match version? Latter is a list of files, former is contained within an object with {status, files: [...]}.

I don't know... I guess this was how the API has always been before I joined, and we keep it as is. The legacy API is really not clean I know.

@kuzdogan Also one more question while I have you here (thanks for dropping by!), should I be replacing my usage of https://repo.sourcify.dev/contracts/partial_match/1/$ADDRESS/metadata.json api with the https://sourcify.dev/server/repository api instead?

We are redirecting the requests to repo.souricify.dev's static file access to sourcify.dev/server/repository anyways so yes it makes sense.

shazow commented 3 months ago

We are redirecting the requests to repo.souricify.dev's static file access to sourcify.dev/server/repository anyways so yes it makes sense.

Looks like the new endpoint is even worse than the old endpoint wrt handling missing contracts, so I'm going to have to stick with the old one for now: https://x.com/shazow/status/1821931353954201621 Oops I missed the /server prefix.