From d15345593c482a1e7d96c3f9af69dff2ea6c4229 Mon Sep 17 00:00:00 2001 From: Rim Rakhimov Date: Wed, 29 Nov 2023 16:44:18 +0300 Subject: [PATCH 1/2] Add 'skip_is_verified_check' flag into 'verify-contract' command --- crates/forge/bin/cmd/create.rs | 2 ++ crates/forge/bin/cmd/script/verify.rs | 1 + crates/forge/bin/cmd/verify/etherscan/mod.rs | 6 ++++-- crates/forge/bin/cmd/verify/mod.rs | 4 ++++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 3faa883d0813..745aa390e85f 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -185,6 +185,7 @@ impl CreateArgs { }, flatten: false, force: false, + skip_is_verified_check: false, watch: true, retry: self.retry, libraries: vec![], @@ -324,6 +325,7 @@ impl CreateArgs { etherscan: EtherscanOpts { key: self.eth.etherscan.key, chain: Some(chain.into()) }, flatten: false, force: false, + skip_is_verified_check: false, watch: true, retry: self.retry, libraries: vec![], diff --git a/crates/forge/bin/cmd/script/verify.rs b/crates/forge/bin/cmd/script/verify.rs index 0c17260dd30e..4c0205fcfc34 100644 --- a/crates/forge/bin/cmd/script/verify.rs +++ b/crates/forge/bin/cmd/script/verify.rs @@ -103,6 +103,7 @@ impl VerifyBundle { etherscan: self.etherscan.clone(), flatten: false, force: false, + skip_is_verified_check: false, watch: true, retry: self.retry, libraries: libraries.to_vec(), diff --git a/crates/forge/bin/cmd/verify/etherscan/mod.rs b/crates/forge/bin/cmd/verify/etherscan/mod.rs index e9a72d85abcb..67c574a47158 100644 --- a/crates/forge/bin/cmd/verify/etherscan/mod.rs +++ b/crates/forge/bin/cmd/verify/etherscan/mod.rs @@ -57,7 +57,7 @@ impl VerificationProvider for EtherscanVerificationProvider { async fn verify(&mut self, args: VerifyArgs) -> Result<()> { let (etherscan, verify_args) = self.prepare_request(&args).await?; - if self.is_contract_verified(ðerscan, &verify_args).await? { + if !args.skip_is_verified_check && self.is_contract_verified(ðerscan, &verify_args).await? { println!( "\nContract [{}] {:?} is already verified. Skipping verification.", verify_args.contract_name, @@ -89,7 +89,9 @@ impl VerificationProvider for EtherscanVerificationProvider { trace!(target: "forge::verify", ?resp, "Received verification response"); if resp.status == "0" { - if resp.result == "Contract source code already verified" { + if resp.result == "Contract source code already verified" + // specific for blockscout response + || resp.result == "Smart-contract already verified." { return Ok(None) } diff --git a/crates/forge/bin/cmd/verify/mod.rs b/crates/forge/bin/cmd/verify/mod.rs index 5544c12f0508..1bcdd4c8baff 100644 --- a/crates/forge/bin/cmd/verify/mod.rs +++ b/crates/forge/bin/cmd/verify/mod.rs @@ -68,6 +68,10 @@ pub struct VerifyArgs { #[clap(short, long)] pub force: bool, + /// Do not check if the contract is already verified before verifying. + #[clap(long)] + pub skip_is_verified_check: bool, + /// Wait for verification result after submission. #[clap(long)] pub watch: bool, From 306cc27a2acc90f242b7b364bce40b2bf86837d7 Mon Sep 17 00:00:00 2001 From: Rim Rakhimov Date: Wed, 29 Nov 2023 16:49:40 +0300 Subject: [PATCH 2/2] cargo fmt --- crates/forge/bin/cmd/verify/etherscan/mod.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/forge/bin/cmd/verify/etherscan/mod.rs b/crates/forge/bin/cmd/verify/etherscan/mod.rs index 67c574a47158..64471ed3fe02 100644 --- a/crates/forge/bin/cmd/verify/etherscan/mod.rs +++ b/crates/forge/bin/cmd/verify/etherscan/mod.rs @@ -57,7 +57,9 @@ impl VerificationProvider for EtherscanVerificationProvider { async fn verify(&mut self, args: VerifyArgs) -> Result<()> { let (etherscan, verify_args) = self.prepare_request(&args).await?; - if !args.skip_is_verified_check && self.is_contract_verified(ðerscan, &verify_args).await? { + if !args.skip_is_verified_check && + self.is_contract_verified(ðerscan, &verify_args).await? + { println!( "\nContract [{}] {:?} is already verified. Skipping verification.", verify_args.contract_name, @@ -91,7 +93,8 @@ impl VerificationProvider for EtherscanVerificationProvider { if resp.status == "0" { if resp.result == "Contract source code already verified" // specific for blockscout response - || resp.result == "Smart-contract already verified." { + || resp.result == "Smart-contract already verified." + { return Ok(None) }