1+ use serde_json:: { Map , Value , from_str} ;
12use std:: borrow:: Cow ;
23use std:: env:: var;
34use std:: fs:: read_to_string;
45use std:: process:: Command ;
56use std:: process:: Output ;
67use std:: sync:: Arc ;
78use std:: time:: Duration ;
8- use serde_json:: { Value , Map , from_str} ;
99
1010use alloy:: primitives:: { Address , hex} ;
1111use alloy:: transports:: http:: reqwest;
@@ -14,7 +14,10 @@ use log::{error, info, warn};
1414use tokio:: task:: { JoinSet , spawn_blocking} ;
1515use tokio:: time:: sleep;
1616
17- use crate :: types:: config:: { Chain , ContractSpec , EtherscanResponse , PublicClient , WalletClient , SourceCodeResult , GetSourceCodeResponse } ;
17+ use crate :: types:: config:: {
18+ Chain , ContractSpec , EtherscanResponse , GetSourceCodeResponse , PublicClient , SourceCodeResult ,
19+ WalletClient ,
20+ } ;
1821use crate :: types:: constants:: Constants ;
1922use crate :: types:: errors:: VerifierError ;
2023
@@ -25,10 +28,7 @@ fn find_contract_file(source_json: &str, contract_name: &str) -> Option<String>
2528 let parsed: Value = from_str ( source_json) . ok ( ) ?;
2629 let sources: & Map < String , Value > = parsed. get ( "sources" ) ?. as_object ( ) ?;
2730 let suffix: String = format ! ( "{contract_name}.sol" ) ;
28- sources
29- . keys ( )
30- . find ( |k| k. ends_with ( & suffix) )
31- . cloned ( )
31+ sources. keys ( ) . find ( |k| k. ends_with ( & suffix) ) . cloned ( )
3232}
3333
3434async fn fetch_verified_source (
@@ -53,22 +53,30 @@ async fn fetch_verified_source(
5353 . map_err ( |e| VerifierError :: HttpError ( name, e. to_string ( ) ) ) ?;
5454
5555 if resp. status != "1" || resp. result . is_empty ( ) {
56- return Err ( VerifierError :: NotVerifiedOnSource ( format ! ( "chain_id {chain_id}" ) ) ) ;
56+ return Err ( VerifierError :: NotVerifiedOnSource ( format ! (
57+ "chain_id {chain_id}"
58+ ) ) ) ;
5759 }
5860
59- let mut source: SourceCodeResult = resp. result . into_iter ( ) . next ( )
61+ let mut source: SourceCodeResult = resp
62+ . result
63+ . into_iter ( )
64+ . next ( )
6065 . ok_or_else ( || VerifierError :: NotVerifiedOnSource ( format ! ( "chain_id {chain_id}" ) ) ) ?;
6166
6267 if source. source_code . is_empty ( ) || source. contract_name . is_empty ( ) {
63- return Err ( VerifierError :: NotVerifiedOnSource ( format ! ( "chain_id {chain_id}" ) ) ) ;
68+ return Err ( VerifierError :: NotVerifiedOnSource ( format ! (
69+ "chain_id {chain_id}"
70+ ) ) ) ;
6471 }
6572
6673 if source. source_code . starts_with ( "{{" ) && source. source_code . ends_with ( "}}" ) {
6774 source. source_code = source. source_code [ 1 ..source. source_code . len ( ) - 1 ] . to_string ( ) ;
6875 }
6976
7077 if !source. contract_name . contains ( ':' ) {
71- let contract_file: Option < String > = find_contract_file ( & source. source_code , & source. contract_name ) ;
78+ let contract_file: Option < String > =
79+ find_contract_file ( & source. source_code , & source. contract_name ) ;
7280 if let Some ( file) = contract_file {
7381 source. contract_name = format ! ( "{file}:{}" , source. contract_name) ;
7482 }
@@ -479,4 +487,4 @@ pub async fn run_verifications(
479487 error ! ( "Verification task panicked: {e}" ) ;
480488 }
481489 }
482- }
490+ }
0 commit comments