Skip to content

Commit ba04f1b

Browse files
authored
Fix cargo clippy (#740)
* visualizer: fix cargo clippy * smart-contract-verifier: fix cargo clippy * eth-bytecode-db: fix cargo clippy * eth-bytecode-db-extractors: fix cargo clippy
1 parent 848be76 commit ba04f1b

File tree

12 files changed

+24
-47
lines changed

12 files changed

+24
-47
lines changed

eth-bytecode-db-extractors/blockscout/src/eth_bytecode_db.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
pub use eth_bytecode_db_proto::blockscout::eth_bytecode_db::v2::{
2-
solidity_verifier_client::SolidityVerifierClient, verify_response,
3-
vyper_verifier_client::VyperVerifierClient, BytecodeType, SearchSourcesRequest,
4-
SearchSourcesResponse, Source, VerificationMetadata, VerifyResponse,
2+
verify_response, SearchSourcesRequest, SearchSourcesResponse, Source, VerifyResponse,
53
VerifySolidityMultiPartRequest, VerifySolidityStandardJsonRequest, VerifyVyperMultiPartRequest,
64
};
75

eth-bytecode-db-extractors/smart-contract-fiesta/src/blockscout.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ impl Client {
112112

113113
let tx_hash = response
114114
.result
115-
.get(0)
115+
.first()
116116
.ok_or_else(|| anyhow::anyhow!("result is empty"))?
117117
.tx_hash
118118
.clone();

eth-bytecode-db-extractors/smart-contract-fiesta/src/eth_bytecode_db.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
pub use eth_bytecode_db_proto::blockscout::eth_bytecode_db::v2::{
2-
solidity_verifier_client::SolidityVerifierClient, verify_response,
3-
vyper_verifier_client::VyperVerifierClient, BytecodeType, SearchSourcesRequest,
4-
SearchSourcesResponse, Source, VerificationMetadata, VerifyResponse,
5-
VerifySolidityMultiPartRequest, VerifySolidityStandardJsonRequest, VerifyVyperMultiPartRequest,
2+
verify_response, BytecodeType, SearchSourcesRequest, SearchSourcesResponse, Source,
3+
VerificationMetadata, VerifyResponse, VerifySolidityMultiPartRequest,
4+
VerifySolidityStandardJsonRequest, VerifyVyperMultiPartRequest,
65
};
76

87
use anyhow::Context;

eth-bytecode-db/eth-bytecode-db/src/verification/smart_contract_verifier.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ pub use smart_contract_verifier_proto::blockscout::smart_contract_verifier::v2::
33
source::{MatchType, SourceType},
44
sourcify_verifier_client,
55
verify_response::{extra_data::BytecodePart, ExtraData, Status},
6-
vyper_verifier_client, BytecodeType, ListCompilerVersionsRequest, ListCompilerVersionsResponse,
7-
Source, VerificationMetadata, VerifyFromEtherscanSourcifyRequest, VerifyResponse,
8-
VerifySolidityMultiPartRequest, VerifySolidityStandardJsonRequest, VerifySourcifyRequest,
9-
VerifyVyperMultiPartRequest, VerifyVyperStandardJsonRequest,
6+
vyper_verifier_client, BytecodeType, ListCompilerVersionsRequest, Source, VerificationMetadata,
7+
VerifyFromEtherscanSourcifyRequest, VerifyResponse, VerifySolidityMultiPartRequest,
8+
VerifySolidityStandardJsonRequest, VerifySourcifyRequest, VerifyVyperMultiPartRequest,
9+
VerifyVyperStandardJsonRequest,
1010
};

eth-bytecode-db/eth-bytecode-db/src/verification/verifier_alliance/parsers.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use anyhow::Context;
22
use serde::Deserialize;
33

4-
pub use cbor_auxdata::{parse as parse_cbor_auxdata, CborAuxdata};
4+
pub use cbor_auxdata::parse as parse_cbor_auxdata;
55
mod cbor_auxdata {
66
use super::*;
77
use blockscout_display_bytes::Bytes as DisplayBytes;
@@ -30,7 +30,7 @@ mod cbor_auxdata {
3030
}
3131
}
3232

33-
pub use immutable_references::{parse as parse_immutable_references, ImmutableReferences};
33+
pub use immutable_references::parse as parse_immutable_references;
3434
mod immutable_references {
3535
use super::*;
3636
use std::collections::BTreeMap;
@@ -58,7 +58,7 @@ mod immutable_references {
5858
}
5959
}
6060

61-
pub use link_references::{parse as parse_link_references, LinkReferences};
61+
pub use link_references::parse as parse_link_references;
6262
mod link_references {
6363
use super::*;
6464
use std::collections::BTreeMap;
@@ -89,8 +89,10 @@ mod link_references {
8989
#[cfg(test)]
9090
mod tests {
9191
use super::{
92-
cbor_auxdata::CborAuxdataValue, immutable_references::ImmutableReferenceValue,
93-
link_references::LinkReferenceValue, *,
92+
cbor_auxdata::{CborAuxdata, CborAuxdataValue},
93+
immutable_references::{ImmutableReferenceValue, ImmutableReferences},
94+
link_references::{LinkReferenceValue, LinkReferences},
95+
*,
9496
};
9597
use blockscout_display_bytes::Bytes as DisplayBytes;
9698
use pretty_assertions::assert_eq;

smart-contract-verifier/smart-contract-verifier-http/src/handlers/solidity_multi_part.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,14 @@ impl TryFrom<MultiPartFiles> for solidity::multi_part::MultiFileContent {
5757
type Error = actix_web::Error;
5858

5959
fn try_from(value: MultiPartFiles) -> Result<Self, Self::Error> {
60-
let sources: BTreeMap<PathBuf, String> = value
61-
.sources
62-
.into_iter()
63-
.map(|(name, content)| (name, content))
64-
.collect();
65-
6660
let evm_version = if value.evm_version != "default" {
6761
Some(EvmVersion::from_str(&value.evm_version).map_err(error::ErrorBadRequest)?)
6862
} else {
6963
None
7064
};
7165

7266
Ok(Self {
73-
sources,
67+
sources: value.sources,
7468
evm_version,
7569
optimization_runs: value.optimization_runs,
7670
contract_libraries: value.contract_libraries,

smart-contract-verifier/smart-contract-verifier-http/src/handlers/sourcify.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub async fn verify(
3333
sourcify_client: web::Data<SourcifyApiClient>,
3434
params: Json<ApiRequest>,
3535
) -> Result<Json<VerificationResponse>, actix_web::Error> {
36-
let request = params.into_inner().try_into()?;
36+
let request = params.into_inner().into();
3737

3838
let response = api::verify(sourcify_client.into_inner(), request).await;
3939
let response = match response {

smart-contract-verifier/smart-contract-verifier-http/src/handlers/vyper_multi_part.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,14 @@ impl TryFrom<MultiPartFiles> for vyper::multi_part::MultiFileContent {
5555
type Error = actix_web::Error;
5656

5757
fn try_from(value: MultiPartFiles) -> Result<Self, Self::Error> {
58-
let sources: BTreeMap<PathBuf, String> = value
59-
.sources
60-
.into_iter()
61-
.map(|(name, content)| (name, content))
62-
.collect();
63-
6458
let evm_version = if let Some(version) = value.evm_version {
6559
Some(EvmVersion::from_str(&version).map_err(error::ErrorBadRequest)?)
6660
} else {
6761
None
6862
};
6963

7064
Ok(Self {
71-
sources,
65+
sources: value.sources,
7266
interfaces: Default::default(),
7367
evm_version,
7468
})
Original file line numberDiff line numberDiff line change
@@ -1,10 +1 @@
1-
pub use smart_contract_verifier_proto::blockscout::smart_contract_verifier::v2::{
2-
health_actix, health_check_response, health_server, lookup_methods_response,
3-
solidity_verifier_actix, solidity_verifier_server, source, sourcify_verifier_actix,
4-
sourcify_verifier_server, verify_response, vyper_verifier_actix, vyper_verifier_server,
5-
BytecodeType, HealthCheckRequest, HealthCheckResponse, ListCompilerVersionsRequest,
6-
ListCompilerVersionsResponse, LookupMethodsRequest, LookupMethodsResponse, Source,
7-
VerificationMetadata, VerifyFromEtherscanSourcifyRequest, VerifyResponse,
8-
VerifySolidityMultiPartRequest, VerifySolidityStandardJsonRequest, VerifySourcifyRequest,
9-
VerifyVyperMultiPartRequest, VerifyVyperStandardJsonRequest,
10-
};
1+
pub use smart_contract_verifier_proto::blockscout::smart_contract_verifier::v2::*;

smart-contract-verifier/smart-contract-verifier/src/solidity/multi_part.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ mod tests {
173173
}
174174

175175
fn test_to_input(multi_part: MultiFileContent, expected: Vec<&str>) {
176-
let inputs: Vec<CompilerInput> = multi_part.try_into().unwrap();
176+
let inputs: Vec<CompilerInput> = multi_part.into();
177177
assert_eq!(
178178
inputs.len(),
179179
expected.len(),

smart-contract-verifier/smart-contract-verifier/src/sourcify/api.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ pub async fn verify_from_etherscan(
116116
/// In case of success returns corresponding match type.
117117
fn validate_verification_result(result: Vec<ResultItem>) -> Result<MatchType, Error> {
118118
let item = result
119-
.get(0)
119+
.first()
120120
.ok_or_else(|| {
121121
anyhow::anyhow!("invalid number of result items returned while verification succeeded")
122122
})
+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
pub use visualizer_proto::{
22
blockscout::visualizer::v1::{
3-
health_actix, health_check_response, health_server, solidity_visualizer_actix,
4-
solidity_visualizer_server, HealthCheckRequest, HealthCheckResponse,
5-
VisualizeContractsRequest, VisualizeResponse, VisualizeStorageRequest,
3+
health_check_response, health_server, solidity_visualizer_server, HealthCheckRequest,
4+
HealthCheckResponse, VisualizeContractsRequest, VisualizeResponse, VisualizeStorageRequest,
65
},
76
google::protobuf::FieldMask,
87
};

0 commit comments

Comments
 (0)