block-explorers icon indicating copy to clipboard operation
block-explorers copied to clipboard

Do not error if the source code is not verified

Open scrogson opened this issue 1 year ago • 2 comments

When fetching the source code for a proxy contract, the source code is most likely not verified. In the current implementation, the code returns an error and makes it impossible to detect the implementation address in order to make the same request against that address.

This change makes it possible to proceed with the request even if the source code is not verified, and allow the caller to control the flow from there.

I could see a potentially different implementation where we return a different error that contains the address of the implementation contract if that is preferred.

Wdyt?

scrogson avatar Nov 21 '23 02:11 scrogson

If the source code is not verified, what would the object that source_code returns look like?

DaniPopes avatar Nov 23 '23 22:11 DaniPopes

If the source code is not verified, what would the object that source_code returns look like?

Here's an example with my changes:

Metadata {
    source_code: SourceCode(""),
    abi: "Contract source code not verified",
    contract_name: "",
    compiler_version: "",
    optimization_used: 0,
    runs: 0,
    constructor_arguments: Bytes(0x),
    evm_version: "Default",
    library: "",
    license_type: "Unknown",
    proxy: 1,
    implementation: Some(0xa12dd5e3f3f1d932ecb2d6b7a3f22e1df5e3403c),
    swarm_source: "",
}

scrogson avatar Nov 24 '23 15:11 scrogson