Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not error if the source code is not verified #17

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,14 +391,6 @@ impl Client {
self.create_query("contract", "getsourcecode", HashMap::from([("address", address)]));
let response = self.get(&query).await?;

// Source code is not verified
if response.contains("Contract source code not verified") {
if let Some(ref cache) = self.cache {
cache.set_source(address, None);
}
return Err(EtherscanError::ContractCodeNotVerified(address));
}

let response: Response<ContractMetadata> = self.sanitize_response(response)?;
let result = response.result;

Expand Down
12 changes: 0 additions & 12 deletions tests/it/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,6 @@ async fn can_fetch_contract_source_code() {
.await
}

#[tokio::test]
#[serial]
async fn can_get_error_on_unverified_contract() {
init_tracing();
run_with_client(Chain::mainnet(), |client| async move {
let addr = "0xb5c31a0e22cae98ac08233e512bd627885aa24e5".parse().unwrap();
let err = client.contract_source_code(addr).await.unwrap_err();
assert!(matches!(err, EtherscanError::ContractCodeNotVerified(_)));
})
.await
}

/// Query a contract that has a single string source entry instead of underlying JSON metadata.
#[tokio::test]
#[serial]
Expand Down