block-explorers
block-explorers copied to clipboard
Do not error if the source code is not verified
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?
If the source code is not verified, what would the object that source_code returns look like?
If the source code is not verified, what would the object that
source_codereturns 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: "",
}