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

fmt: update rustfmt config #16

Merged
merged 2 commits into from
Nov 15, 2023
Merged
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
13 changes: 8 additions & 5 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
reorder_imports = true
imports_granularity = "Crate"
use_field_init_shorthand = true
use_small_heuristics = "Max"

# Nightly
max_width = 100
comment_width = 100
imports_granularity = "Crate"
wrap_comments = true
binop_separator = "Back"
trailing_comma = "Vertical"
trailing_semicolon = false
use_field_init_shorthand = true
format_code_in_doc_comments = true
doc_comment_code_block_width = 100
format_macro_matchers = true
4 changes: 2 additions & 2 deletions src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@ impl Client {
return Err(EtherscanError::RateLimitExceeded);
}

if result.starts_with("Contract source code not verified") ||
resp.message.starts_with("Contract source code not verified")
if result.starts_with("Contract source code not verified")
|| resp.message.starts_with("Contract source code not verified")
{
if let Some(ref cache) = self.cache {
cache.set_abi(address, None);
Expand Down
4 changes: 2 additions & 2 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ pub(crate) fn is_blocked_by_cloudflare_response(txt: &str) -> bool {
/// etherscan/polyscan is protected by cloudflare, which can require captchas to "review the
/// security of your connection before proceeding"
pub(crate) fn is_cloudflare_security_challenge(txt: &str) -> bool {
txt.contains("https://www.cloudflare.com?utm_source=challenge") ||
txt.to_lowercase().contains("checking if the site connection is secure")
txt.contains("https://www.cloudflare.com?utm_source=challenge")
|| txt.to_lowercase().contains("checking if the site connection is secure")
}

#[cfg(test)]
Expand Down
29 changes: 17 additions & 12 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ impl Client {
/// ```rust
/// use alloy_chains::Chain;
/// use foundry_block_explorers::Client;
/// let client = Client::builder().with_api_key("<API KEY>").chain(NamedChain::mainnet()).unwrap().build().unwrap();
/// let client = Client::builder()
/// .with_api_key("<API KEY>")
/// .chain(NamedChain::mainnet())
/// .unwrap()
/// .build()
/// .unwrap();
/// ```
pub fn builder() -> ClientBuilder {
ClientBuilder::default()
Expand Down Expand Up @@ -101,17 +106,17 @@ impl Client {
.map_err(Into::into),

// Backwards compatibility, ideally these should return an error.
NamedChain::Gnosis |
NamedChain::Chiado |
NamedChain::Sepolia |
NamedChain::Rsk |
NamedChain::Sokol |
NamedChain::Poa |
NamedChain::Oasis |
NamedChain::Emerald |
NamedChain::EmeraldTestnet |
NamedChain::Evmos |
NamedChain::EvmosTestnet => Ok(String::new()),
NamedChain::Gnosis
| NamedChain::Chiado
| NamedChain::Sepolia
| NamedChain::Rsk
| NamedChain::Sokol
| NamedChain::Poa
| NamedChain::Oasis
| NamedChain::Emerald
| NamedChain::EmeraldTestnet
| NamedChain::Evmos
| NamedChain::EvmosTestnet => Ok(String::new()),
Comment on lines +109 to +119
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks much nicer

NamedChain::AnvilHardhat | NamedChain::Dev => {
Err(EtherscanError::LocalNetworksNotSupported)
}
Expand Down