Skip to content

Commit

Permalink
review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
klkvr committed Mar 6, 2024
1 parent 2e4c5f3 commit ca3e21d
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 24 deletions.
4 changes: 2 additions & 2 deletions crates/forge/bin/cmd/script/broadcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ impl BundledState {
pub async fn wait_for_pending(mut self) -> Result<Self> {
let futs = self
.sequence
.iter_sequeneces_mut()
.sequeneces_mut()
.map(|sequence| async move {
let rpc_url = sequence.rpc_url();
let provider = Arc::new(get_http_provider(rpc_url));
Expand All @@ -172,7 +172,7 @@ impl BundledState {
pub async fn broadcast(mut self) -> Result<BroadcastedState> {
let required_addresses = self
.sequence
.iter_sequences()
.sequences()
.flat_map(|sequence| {
sequence
.typed_transactions()
Expand Down
5 changes: 1 addition & 4 deletions crates/forge/bin/cmd/script/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
use crate::cmd::script::runner::ScriptRunner;

use self::transaction::AdditionalContract;

use super::{build::BuildArgs, retry::RetryArgs};

use crate::cmd::script::runner::ScriptRunner;
use alloy_json_abi::{Function, JsonAbi};
use alloy_primitives::{Address, Bytes, Log, U256};
use clap::{Parser, ValueHint};
Expand Down
11 changes: 5 additions & 6 deletions crates/forge/bin/cmd/script/resume.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
use ethers_providers::Middleware;
use eyre::Result;
use foundry_common::provider::ethers::try_get_http_provider;
use foundry_compilers::artifacts::Libraries;
use std::sync::Arc;

use super::{
multi_sequence::MultiChainSequence,
sequence::{ScriptSequence, ScriptSequenceKind},
states::{BundledState, PreSimulationState},
};
use ethers_providers::Middleware;
use eyre::Result;
use foundry_common::provider::ethers::try_get_http_provider;
use foundry_compilers::artifacts::Libraries;
use std::sync::Arc;

impl PreSimulationState {
/// Tries loading the resumed state from the cache files, skipping simulation stage.
Expand Down
4 changes: 2 additions & 2 deletions crates/forge/bin/cmd/script/sequence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ impl ScriptSequenceKind {
}
}

pub fn iter_sequences(&self) -> impl Iterator<Item = &ScriptSequence> {
pub fn sequences(&self) -> impl Iterator<Item = &ScriptSequence> {
match self {
ScriptSequenceKind::Single(sequence) => std::slice::from_ref(sequence).iter(),
ScriptSequenceKind::Multi(sequence) => sequence.deployments.iter(),
}
}

pub fn iter_sequeneces_mut(&mut self) -> impl Iterator<Item = &mut ScriptSequence> {
pub fn sequeneces_mut(&mut self) -> impl Iterator<Item = &mut ScriptSequence> {
match self {
ScriptSequenceKind::Single(sequence) => std::slice::from_mut(sequence).iter_mut(),
ScriptSequenceKind::Multi(sequence) => sequence.deployments.iter_mut(),
Expand Down
3 changes: 1 addition & 2 deletions crates/forge/bin/cmd/script/simulate.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use crate::cmd::{init::get_commit_hash, script::broadcast::estimate_gas};

use super::{
artifacts::ArtifactInfo,
multi_sequence::MultiChainSequence,
Expand All @@ -9,6 +7,7 @@ use super::{
states::{BundledState, FilledTransactionsState, PreSimulationState},
transaction::TransactionWithMetadata,
};
use crate::cmd::{init::get_commit_hash, script::broadcast::estimate_gas};
use alloy_primitives::{utils::format_units, Address, U256};
use eyre::{Context, Result};
use forge::{inspectors::cheatcodes::BroadcastableTransactions, traces::render_trace_arena};
Expand Down
6 changes: 2 additions & 4 deletions crates/forge/bin/cmd/script/states.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
use std::collections::VecDeque;

use forge::inspectors::cheatcodes::ScriptWallets;

use super::{
build::{BuildData, LinkedBuildData},
execute::{ExecutionArtifacts, ExecutionData},
sequence::ScriptSequenceKind,
transaction::TransactionWithMetadata,
ScriptArgs, ScriptConfig, ScriptResult,
};
use forge::inspectors::cheatcodes::ScriptWallets;
use std::collections::VecDeque;

/// First state basically containing only inputs of the user.
pub struct PreprocessedState {
Expand Down
7 changes: 3 additions & 4 deletions crates/forge/bin/cmd/script/verify.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use super::states::{BroadcastedState, BundledState};
use crate::cmd::{
retry::RetryArgs,
verify::{provider::VerificationProviderType, VerifierArgs, VerifyArgs},
Expand All @@ -10,11 +11,9 @@ use foundry_compilers::{info::ContractInfo, Project};
use foundry_config::{Chain, Config};
use semver::Version;

use super::states::{BroadcastedState, BundledState};

impl BundledState {
pub fn verify_preflight_check(&self) -> Result<()> {
for sequence in self.sequence.iter_sequences() {
for sequence in self.sequence.sequences() {
if self.args.verifier.verifier == VerificationProviderType::Etherscan &&
self.script_config
.config
Expand All @@ -41,7 +40,7 @@ impl BroadcastedState {
args.verifier,
);

for sequence in sequence.iter_sequeneces_mut() {
for sequence in sequence.sequeneces_mut() {
sequence.verify_contracts(&script_config.config, verify.clone()).await?;
}

Expand Down

0 comments on commit ca3e21d

Please sign in to comment.