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 77 forks source link

loaders: Add anyabi.xyz #90

Open shazow opened 6 months ago

shazow commented 6 months ago

https://anyabi.xyz/

It's redundant with etherscan and sourcify, but could make it race or a fallback?

k-thornton commented 1 month ago

I had some code using AnyABI which I thought would easily slot in here. The problem is that AnyABI is missing a lot of the details that you're currently expecting from getContract. To add AnyABI, you would need to add the Optional ? to evmVersion, compilerVersion, and runs

export type ContractResult = {
    abi: any[];
    name: string | null;
    evmVersion: string;
    compilerVersion: string;
    runs: number;
    ok: boolean;
    getSources?: () => Promise<ContractSources>;
    loader?: ABILoader;
    loaderResult?: EtherscanContractResult | SourcifyContractMetadata | any;
}

becomes

export type ContractResult = {
    abi: any[];
    name: string | null;
    ok: boolean;
    evmVersion?: string;
    compilerVersion?: string;
    runs?: number;
    getSources?: () => Promise<ContractSources>;
    loader?: ABILoader;
    loaderResult?: EtherscanContractResult | SourcifyContractMetadata | any;
}

gut feel, is it worth it?

shazow commented 1 month ago

I'm down if you are. :) Could also add a AnyABIContractResult for including the full result in loaderResult .

shazow commented 1 month ago

Also looks like they mainly return the loadABI equivalent which is fine. Makes sense for ContractResult to basically be a superset if available, otherwise roughly equivalent.

I'm down to change the type as you mentioned.