Skip to content

Commit

Permalink
Add verify_preflight_check for script sequences (#6372)
Browse files Browse the repository at this point in the history
* Add verify_preflight_check for script sequences

* Change error message

* rustfmt

---------

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
  • Loading branch information
klkvr and mattsse authored Nov 28, 2023
1 parent 3ea15cd commit 4a5785a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions crates/forge/bin/cmd/script/broadcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@ impl ScriptArgs {
) -> Result<()> {
trace!(target: "script", "broadcasting single chain deployment");

if self.verify {
deployment_sequence.verify_preflight_check(&script_config.config, &verify)?;
}

let rpc = script_config.total_rpcs.into_iter().next().expect("exists; qed");

deployment_sequence.add_libraries(libraries);
Expand Down
4 changes: 4 additions & 0 deletions crates/forge/bin/cmd/script/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ impl ScriptArgs {
Err(err) => eyre::bail!(err),
};

if self.verify {
deployment_sequence.verify_preflight_check(&script_config.config, &verify)?;
}

receipts::wait_for_pending(provider, &mut deployment_sequence).await?;

if self.resume {
Expand Down
6 changes: 6 additions & 0 deletions crates/forge/bin/cmd/script/multi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ impl ScriptArgs {
eyre::bail!("Libraries are currently not supported on multi deployment setups.");
}

if self.verify {
for sequence in &deployments.deployments {
sequence.verify_preflight_check(config, &verify)?;
}
}

if self.resume {
trace!(target: "script", "resuming multi chain deployment");

Expand Down
14 changes: 14 additions & 0 deletions crates/forge/bin/cmd/script/sequence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,20 @@ impl ScriptSequence {
Ok((broadcast, cache))
}

/// Checks that there is an Etherscan key for the chain id of this sequence.
pub fn verify_preflight_check(&self, config: &Config, verify: &VerifyBundle) -> Result<()> {
if config.get_etherscan_api_key(Some(self.chain.into())).is_none() &&
verify.verifier.verifier == VerificationProviderType::Etherscan
{
eyre::bail!(
"Etherscan API key wasn't found for chain id {}. On-chain execution aborted",
self.chain
)
}

Ok(())
}

/// Given the broadcast log, it matches transactions with receipts, and tries to verify any
/// created contract on etherscan.
pub async fn verify_contracts(
Expand Down

0 comments on commit 4a5785a

Please sign in to comment.