Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
fix(providers): nightly fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
dereksione committed Aug 18, 2023
1 parent e11f6b4 commit 6512c99
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 23 deletions.
32 changes: 15 additions & 17 deletions ethers-providers/src/rpc/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ impl<P: JsonRpcClient> Middleware for Provider<P> {
};
let data = self.call(&tx.into(), None).await?;
if decode_bytes::<Address>(ParamType::Address, data) != owner {
return Err(ProviderError::CustomError("Incorrect owner.".to_string()));
return Err(ProviderError::CustomError("Incorrect owner.".to_string()))
}
}
erc::ERCNFTType::ERC1155 => {
Expand All @@ -851,9 +851,7 @@ impl<P: JsonRpcClient> Middleware for Provider<P> {
};
let data = self.call(&tx.into(), None).await?;
if decode_bytes::<u64>(ParamType::Uint(64), data) == 0 {
return Err(ProviderError::CustomError(
"Incorrect balance.".to_string(),
));
return Err(ProviderError::CustomError("Incorrect balance.".to_string()))
}
}
}
Expand Down Expand Up @@ -1147,7 +1145,7 @@ impl<P: JsonRpcClient> Middleware for Provider<P> {
if fallback.is_err() {
// if the older fallback also resulted in an error, we return the error from the
// initial attempt
return err;
return err
}
fallback
}
Expand Down Expand Up @@ -1181,12 +1179,12 @@ impl<P: JsonRpcClient> Provider<P> {

// otherwise, decode_bytes panics
if data.0.is_empty() {
return Err(ProviderError::EnsError(ens_name.to_string()));
return Err(ProviderError::EnsError(ens_name.to_string()))
}

let resolver_address: Address = decode_bytes(ParamType::Address, data);
if resolver_address == Address::zero() {
return Err(ProviderError::EnsError(ens_name.to_string()));
return Err(ProviderError::EnsError(ens_name.to_string()))
}

if let ParamType::Address = param {
Expand Down Expand Up @@ -1215,7 +1213,7 @@ impl<P: JsonRpcClient> Provider<P> {
if data.is_empty() {
return Err(ProviderError::EnsError(format!(
"`{ens_name}` resolver ({resolver_address:?}) is invalid."
)));
)))
}

let supports_selector = abi::decode(&[ParamType::Bool], data.as_ref())
Expand All @@ -1228,7 +1226,7 @@ impl<P: JsonRpcClient> Provider<P> {
ens_name,
resolver_address,
hex::encode(selector)
)));
)))
}

Ok(())
Expand Down Expand Up @@ -1374,15 +1372,15 @@ impl Provider<MockProvider> {
/// "maxFeePerGas": "0x8b2294336",
/// "chainId": "0x1"
/// }]"#;
///
///
/// let (pr, mut mock) = Provider::mocked();
/// let vec_tx: Vec<Transaction> = serde_json::from_str(tx_json).unwrap();
/// mock.push(vec_tx[0].clone().hash).unwrap();
///
///
/// mock.setup_subscription().await;
///
///
/// let mut subs = pr.subscribe_pending_txs().await.unwrap();
///
///
/// assert_eq!(subs.next().await.unwrap(), vec_tx[0].hash);
/// }
/// ```
Expand Down Expand Up @@ -1563,10 +1561,10 @@ pub fn is_local_endpoint(endpoint: &str) -> bool {
match host {
Host::Domain(domain) => return domain.contains("localhost"),
Host::Ipv4(ipv4) => {
return ipv4 == Ipv4Addr::LOCALHOST
|| ipv4.is_link_local()
|| ipv4.is_loopback()
|| ipv4.is_private()
return ipv4 == Ipv4Addr::LOCALHOST ||
ipv4.is_link_local() ||
ipv4.is_loopback() ||
ipv4.is_private()
}
Host::Ipv6(ipv6) => return ipv6.is_loopback(),
}
Expand Down
8 changes: 2 additions & 6 deletions ethers-providers/src/rpc/transports/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,8 @@ impl MockProvider {
Ok(value) => {
stream.start_send(value).unwrap();
}
Err(MockError::EmptyResponses) => {
return Ok(());
}
Err(e) => {
return Err(e);
}
Err(MockError::EmptyResponses) => return Ok(()),
Err(e) => return Err(e),
}
}
}
Expand Down

0 comments on commit 6512c99

Please sign in to comment.