Skip to content

Commit

Permalink
Fix cargo clippy (#740)
Browse files Browse the repository at this point in the history
* visualizer: fix cargo clippy

* smart-contract-verifier: fix cargo clippy

* eth-bytecode-db: fix cargo clippy

* eth-bytecode-db-extractors: fix cargo clippy
  • Loading branch information
rimrakhimov authored Jan 11, 2024
1 parent 848be76 commit ba04f1b
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 47 deletions.
4 changes: 1 addition & 3 deletions eth-bytecode-db-extractors/blockscout/src/eth_bytecode_db.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
pub use eth_bytecode_db_proto::blockscout::eth_bytecode_db::v2::{
solidity_verifier_client::SolidityVerifierClient, verify_response,
vyper_verifier_client::VyperVerifierClient, BytecodeType, SearchSourcesRequest,
SearchSourcesResponse, Source, VerificationMetadata, VerifyResponse,
verify_response, SearchSourcesRequest, SearchSourcesResponse, Source, VerifyResponse,
VerifySolidityMultiPartRequest, VerifySolidityStandardJsonRequest, VerifyVyperMultiPartRequest,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl Client {

let tx_hash = response
.result
.get(0)
.first()
.ok_or_else(|| anyhow::anyhow!("result is empty"))?
.tx_hash
.clone();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
pub use eth_bytecode_db_proto::blockscout::eth_bytecode_db::v2::{
solidity_verifier_client::SolidityVerifierClient, verify_response,
vyper_verifier_client::VyperVerifierClient, BytecodeType, SearchSourcesRequest,
SearchSourcesResponse, Source, VerificationMetadata, VerifyResponse,
VerifySolidityMultiPartRequest, VerifySolidityStandardJsonRequest, VerifyVyperMultiPartRequest,
verify_response, BytecodeType, SearchSourcesRequest, SearchSourcesResponse, Source,
VerificationMetadata, VerifyResponse, VerifySolidityMultiPartRequest,
VerifySolidityStandardJsonRequest, VerifyVyperMultiPartRequest,
};

use anyhow::Context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ pub use smart_contract_verifier_proto::blockscout::smart_contract_verifier::v2::
source::{MatchType, SourceType},
sourcify_verifier_client,
verify_response::{extra_data::BytecodePart, ExtraData, Status},
vyper_verifier_client, BytecodeType, ListCompilerVersionsRequest, ListCompilerVersionsResponse,
Source, VerificationMetadata, VerifyFromEtherscanSourcifyRequest, VerifyResponse,
VerifySolidityMultiPartRequest, VerifySolidityStandardJsonRequest, VerifySourcifyRequest,
VerifyVyperMultiPartRequest, VerifyVyperStandardJsonRequest,
vyper_verifier_client, BytecodeType, ListCompilerVersionsRequest, Source, VerificationMetadata,
VerifyFromEtherscanSourcifyRequest, VerifyResponse, VerifySolidityMultiPartRequest,
VerifySolidityStandardJsonRequest, VerifySourcifyRequest, VerifyVyperMultiPartRequest,
VerifyVyperStandardJsonRequest,
};
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::Context;
use serde::Deserialize;

pub use cbor_auxdata::{parse as parse_cbor_auxdata, CborAuxdata};
pub use cbor_auxdata::parse as parse_cbor_auxdata;
mod cbor_auxdata {
use super::*;
use blockscout_display_bytes::Bytes as DisplayBytes;
Expand Down Expand Up @@ -30,7 +30,7 @@ mod cbor_auxdata {
}
}

pub use immutable_references::{parse as parse_immutable_references, ImmutableReferences};
pub use immutable_references::parse as parse_immutable_references;
mod immutable_references {
use super::*;
use std::collections::BTreeMap;
Expand Down Expand Up @@ -58,7 +58,7 @@ mod immutable_references {
}
}

pub use link_references::{parse as parse_link_references, LinkReferences};
pub use link_references::parse as parse_link_references;
mod link_references {
use super::*;
use std::collections::BTreeMap;
Expand Down Expand Up @@ -89,8 +89,10 @@ mod link_references {
#[cfg(test)]
mod tests {
use super::{
cbor_auxdata::CborAuxdataValue, immutable_references::ImmutableReferenceValue,
link_references::LinkReferenceValue, *,
cbor_auxdata::{CborAuxdata, CborAuxdataValue},
immutable_references::{ImmutableReferenceValue, ImmutableReferences},
link_references::{LinkReferenceValue, LinkReferences},
*,
};
use blockscout_display_bytes::Bytes as DisplayBytes;
use pretty_assertions::assert_eq;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,14 @@ impl TryFrom<MultiPartFiles> for solidity::multi_part::MultiFileContent {
type Error = actix_web::Error;

fn try_from(value: MultiPartFiles) -> Result<Self, Self::Error> {
let sources: BTreeMap<PathBuf, String> = value
.sources
.into_iter()
.map(|(name, content)| (name, content))
.collect();

let evm_version = if value.evm_version != "default" {
Some(EvmVersion::from_str(&value.evm_version).map_err(error::ErrorBadRequest)?)
} else {
None
};

Ok(Self {
sources,
sources: value.sources,
evm_version,
optimization_runs: value.optimization_runs,
contract_libraries: value.contract_libraries,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub async fn verify(
sourcify_client: web::Data<SourcifyApiClient>,
params: Json<ApiRequest>,
) -> Result<Json<VerificationResponse>, actix_web::Error> {
let request = params.into_inner().try_into()?;
let request = params.into_inner().into();

let response = api::verify(sourcify_client.into_inner(), request).await;
let response = match response {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,14 @@ impl TryFrom<MultiPartFiles> for vyper::multi_part::MultiFileContent {
type Error = actix_web::Error;

fn try_from(value: MultiPartFiles) -> Result<Self, Self::Error> {
let sources: BTreeMap<PathBuf, String> = value
.sources
.into_iter()
.map(|(name, content)| (name, content))
.collect();

let evm_version = if let Some(version) = value.evm_version {
Some(EvmVersion::from_str(&version).map_err(error::ErrorBadRequest)?)
} else {
None
};

Ok(Self {
sources,
sources: value.sources,
interfaces: Default::default(),
evm_version,
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
pub use smart_contract_verifier_proto::blockscout::smart_contract_verifier::v2::{
health_actix, health_check_response, health_server, lookup_methods_response,
solidity_verifier_actix, solidity_verifier_server, source, sourcify_verifier_actix,
sourcify_verifier_server, verify_response, vyper_verifier_actix, vyper_verifier_server,
BytecodeType, HealthCheckRequest, HealthCheckResponse, ListCompilerVersionsRequest,
ListCompilerVersionsResponse, LookupMethodsRequest, LookupMethodsResponse, Source,
VerificationMetadata, VerifyFromEtherscanSourcifyRequest, VerifyResponse,
VerifySolidityMultiPartRequest, VerifySolidityStandardJsonRequest, VerifySourcifyRequest,
VerifyVyperMultiPartRequest, VerifyVyperStandardJsonRequest,
};
pub use smart_contract_verifier_proto::blockscout::smart_contract_verifier::v2::*;
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ mod tests {
}

fn test_to_input(multi_part: MultiFileContent, expected: Vec<&str>) {
let inputs: Vec<CompilerInput> = multi_part.try_into().unwrap();
let inputs: Vec<CompilerInput> = multi_part.into();
assert_eq!(
inputs.len(),
expected.len(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ pub async fn verify_from_etherscan(
/// In case of success returns corresponding match type.
fn validate_verification_result(result: Vec<ResultItem>) -> Result<MatchType, Error> {
let item = result
.get(0)
.first()
.ok_or_else(|| {
anyhow::anyhow!("invalid number of result items returned while verification succeeded")
})
Expand Down
5 changes: 2 additions & 3 deletions visualizer/visualizer-server/src/proto.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
pub use visualizer_proto::{
blockscout::visualizer::v1::{
health_actix, health_check_response, health_server, solidity_visualizer_actix,
solidity_visualizer_server, HealthCheckRequest, HealthCheckResponse,
VisualizeContractsRequest, VisualizeResponse, VisualizeStorageRequest,
health_check_response, health_server, solidity_visualizer_server, HealthCheckRequest,
HealthCheckResponse, VisualizeContractsRequest, VisualizeResponse, VisualizeStorageRequest,
},
google::protobuf::FieldMask,
};

0 comments on commit ba04f1b

Please sign in to comment.