Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a verification flag to skip contract is verified check #6461

Merged
merged 2 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/forge/bin/cmd/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ impl CreateArgs {
},
flatten: false,
force: false,
skip_is_verified_check: false,
watch: true,
retry: self.retry,
libraries: vec![],
Expand Down Expand Up @@ -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![],
Expand Down
1 change: 1 addition & 0 deletions crates/forge/bin/cmd/script/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
9 changes: 7 additions & 2 deletions crates/forge/bin/cmd/verify/etherscan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 self.is_contract_verified(&etherscan, &verify_args).await? {
if !args.skip_is_verified_check &&
self.is_contract_verified(&etherscan, &verify_args).await?
{
println!(
"\nContract [{}] {:?} is already verified. Skipping verification.",
verify_args.contract_name,
Expand Down Expand Up @@ -89,7 +91,10 @@ 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)
}

Expand Down
4 changes: 4 additions & 0 deletions crates/forge/bin/cmd/verify/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Comment on lines +71 to +73
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that makes sense, I believe etherscan does not verify partially verified contracts though.


/// Wait for verification result after submission.
#[clap(long)]
pub watch: bool,
Expand Down