Skip to content
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: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ prettyplease.opt-level = 0
lalrpop.opt-level = 0

ethers-contract-abigen.opt-level = 0
ethers-contract-abigen-derive.opt-level = 0
ethers-contract-derive.opt-level = 0
async-recursion.opt-level = 0
miette-derive.opt-level = 0
strum_macros.opt-level = 0
Expand Down
5 changes: 1 addition & 4 deletions anvil/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,7 @@ pub struct CliqueConfig {

pub mod secret_key {
use ethers::{core::k256::SecretKey, signers::LocalWallet, types::Bytes};
use serde::{
de::{self},
Deserialize, Deserializer, Serialize, Serializer,
};
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};

pub fn serialize<S>(value: &Option<LocalWallet>, serializer: S) -> Result<S::Ok, S::Error>
where
Expand Down
6 changes: 3 additions & 3 deletions chisel/src/bin/chisel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use chisel::{
};
use clap::Parser;
use foundry_cli::{
cmd::{forge::build::BuildArgs, LoadConfig},
utils,
opts::CoreBuildArgs,
utils::{self, LoadConfig},
};
use foundry_common::evm::EvmArgs;
use foundry_config::{
Expand Down Expand Up @@ -44,7 +44,7 @@ pub struct ChiselParser {
pub sub: Option<ChiselParserSub>,

#[clap(flatten)]
pub opts: BuildArgs,
pub opts: CoreBuildArgs,

#[clap(flatten)]
pub evm_opts: EvmArgs,
Expand Down
4 changes: 2 additions & 2 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ external-integration-tests = []

[[bin]]
name = "cast"
path = "src/cast.rs"
path = "src/cast/main.rs"
doc = false

[[bin]]
name = "forge"
path = "src/forge.rs"
path = "src/forge/main.rs"
doc = false

[[bench]]
Expand Down
6 changes: 5 additions & 1 deletion cli/benches/cast.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
use criterion::{criterion_group, criterion_main, Criterion};
use foundry_cli::cmd::cast::wallet::vanity::*;
use rayon::prelude::*;
use std::{hint::black_box, time::Duration};

#[path = "../src/cast/cmd/wallet/mod.rs"]
#[allow(unused)]
mod wallet;
use wallet::vanity::*;

/// Benches `cast wallet vanity`
///
/// Left or right matchers, with or without nonce do not change the outcome.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
// cast estimate subcommands
use crate::{
opts::{EthereumOpts, TransactionOpts},
utils::{self},
};
use cast::{Cast, TxBuilder};
use clap::Parser;
use ethers::{
providers::Middleware,
types::{BlockId, NameOrAddress},
};
use eyre::WrapErr;
use foundry_cli::{
opts::{EthereumOpts, TransactionOpts},
utils,
};
use foundry_config::{Chain, Config};
use std::str::FromStr;

Expand Down
2 changes: 1 addition & 1 deletion cli/src/cmd/cast/bind.rs → cli/src/cast/cmd/bind.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::opts::EtherscanOpts;
use clap::{Parser, ValueHint};
use ethers::prelude::{errors::EtherscanError, Abigen, Client, MultiAbigen};
use eyre::Result;
use foundry_cli::opts::EtherscanOpts;
use foundry_config::Config;
use std::path::{Path, PathBuf};

Expand Down
10 changes: 4 additions & 6 deletions cli/src/cmd/cast/call.rs → cli/src/cast/cmd/call.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
// cast estimate subcommands
use crate::{
cmd::utils::{handle_traces, TraceResult},
opts::{EthereumOpts, TransactionOpts},
utils::{self, parse_ether_value},
};
use cast::{Cast, TxBuilder};
use clap::Parser;
use ethers::{
Expand All @@ -12,6 +6,10 @@ use ethers::{
};
use eyre::WrapErr;
use forge::executor::opts::EvmOpts;
use foundry_cli::{
opts::{EthereumOpts, TransactionOpts},
utils::{self, handle_traces, parse_ether_value, TraceResult},
};
use foundry_config::{find_project_root_path, Config};
use foundry_evm::trace::TracingExecutor;
use std::str::FromStr;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//! cast create2 subcommand

use crate::cmd::Cmd;
use cast::SimpleCast;
use clap::Parser;
use ethers::{
Expand All @@ -9,6 +6,7 @@ use ethers::{
utils::{get_create2_address_from_hash, keccak256},
};
use eyre::{Result, WrapErr};
use foundry_cli::utils::Cmd;
use rayon::prelude::*;
use regex::RegexSetBuilder;
use std::{str::FromStr, time::Instant};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// cast estimate subcommands
use crate::{
opts::{EtherscanOpts, RpcOpts},
utils::{self, parse_ether_value},
};
use cast::{Cast, TxBuilder};
use clap::Parser;
use ethers::types::{NameOrAddress, U256};
use eyre::Result;
use foundry_cli::{
opts::{EtherscanOpts, RpcOpts},
utils::{self, parse_ether_value},
};
use foundry_config::{figment::Figment, Config};
use std::str::FromStr;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
//! cast find-block subcommand

use crate::{opts::RpcOpts, utils};
use cast::Cast;
use clap::Parser;
use ethers::prelude::*;
use eyre::Result;
use foundry_cli::{opts::RpcOpts, utils};
use foundry_config::Config;
use futures::join;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::opts::EtherscanOpts;
use cast::{AbiPath, SimpleCast};
use clap::Parser;
use foundry_cli::opts::EtherscanOpts;
use foundry_common::fs;
use foundry_config::Config;
use std::path::{Path, PathBuf};
Expand Down
10 changes: 3 additions & 7 deletions cli/src/cmd/cast/logs.rs → cli/src/cast/cmd/logs.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
// cast estimate subcommands
use crate::{
opts::EthereumOpts,
utils::{self},
};
use cast::Cast;
use clap::Parser;
use ethers::{
abi::{Address, Event, RawTopicFilter, Topic, TopicFilter},
providers::Middleware,
types::{BlockId, BlockNumber, Filter, FilterBlockOption, NameOrAddress, ValueOrArray, H256},
};
use foundry_cli::{opts::EthereumOpts, utils};

use foundry_common::abi::{get_event, parse_tokens};
use foundry_config::Config;
Expand Down Expand Up @@ -220,14 +216,14 @@ fn build_filter_topics(topics: Vec<String>) -> Result<TopicFilter, eyre::Error>

#[cfg(test)]
mod tests {
use ethers::types::H160;

use super::*;
use ethers::types::H160;

const ADDRESS: &str = "0x4D1A2e2bB4F88F0250f26Ffff098B0b30B26BF38";
const TRANSFER_SIG: &str = "Transfer(address indexed,address indexed,uint256)";
const TRANSFER_TOPIC: &str =
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef";

#[test]
fn test_build_filter_basic() {
let from_block = Some(BlockNumber::from(1337));
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion cli/src/cmd/cast/rpc.rs → cli/src/cast/cmd/rpc.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{opts::RpcOpts, utils};
use cast::Cast;
use clap::Parser;
use eyre::Result;
use foundry_cli::{opts::RpcOpts, utils};
use foundry_config::Config;
use itertools::Itertools;

Expand Down
13 changes: 6 additions & 7 deletions cli/src/cmd/cast/run.rs → cli/src/cast/cmd/run.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
use crate::{
cmd::utils::{handle_traces, TraceResult},
init_progress,
opts::RpcOpts,
update_progress, utils,
};

use clap::Parser;
use ethers::{prelude::Middleware, solc::EvmVersion, types::H160};
use eyre::WrapErr;
Expand All @@ -13,6 +6,12 @@ use forge::{
revm::primitives::U256 as rU256,
utils::h256_to_b256,
};
use foundry_cli::{
init_progress,
opts::RpcOpts,
update_progress, utils,
utils::{handle_traces, TraceResult},
};
use foundry_config::{find_project_root_path, Config};
use foundry_evm::{executor::EvmError, trace::TracingExecutor};
use tracing::trace;
Expand Down
9 changes: 4 additions & 5 deletions cli/src/cmd/cast/send.rs → cli/src/cast/cmd/send.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
// cast send subcommands
use crate::{
opts::{EthereumOpts, TransactionOpts},
utils,
};
use cast::{Cast, TxBuilder};
use clap::Parser;
use ethers::{
prelude::MiddlewareBuilder, providers::Middleware, signers::Signer, types::NameOrAddress,
};
use foundry_cli::{
opts::{EthereumOpts, TransactionOpts},
utils,
};
use foundry_common::cli_warn;
use foundry_config::{Chain, Config};
use std::str::FromStr;
Expand Down
12 changes: 6 additions & 6 deletions cli/src/cmd/cast/storage.rs → cli/src/cast/cmd/storage.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
use crate::{
cmd::forge::build,
opts::{cast::parse_slot, EtherscanOpts, RpcOpts},
utils,
};
use crate::opts::parse_slot;
use cast::Cast;
use clap::Parser;
use comfy_table::{presets::ASCII_MARKDOWN, Table};
Expand All @@ -11,6 +7,10 @@ use ethers::{
solc::artifacts::StorageLayout,
};
use eyre::Result;
use foundry_cli::{
opts::{CoreBuildArgs, EtherscanOpts, RpcOpts},
utils,
};
use foundry_common::{
abi::find_source,
compile::{compile, etherscan_project, suppress_compile},
Expand Down Expand Up @@ -53,7 +53,7 @@ pub struct StorageArgs {
etherscan: EtherscanOpts,

#[clap(flatten)]
build: build::CoreBuildArgs,
build: CoreBuildArgs,
}

impl_figment_convert_cast!(StorageArgs);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
//! cast wallet subcommand

pub mod vanity;

use std::path::Path;

use crate::{
cmd::{cast::wallet::vanity::VanityArgs, Cmd},
opts::{RawWallet, Wallet},
};
use cast::SimpleCast;
use clap::Parser;
use ethers::{
Expand All @@ -16,10 +6,18 @@ use ethers::{
types::{transaction::eip712::TypedData, Address, Signature},
};
use eyre::Context;
use foundry_cli::{
opts::{RawWallet, Wallet},
utils::Cmd,
};
use foundry_common::fs;
use foundry_config::Config;
use std::path::Path;
use yansi::Paint;

pub mod vanity;
use vanity::VanityArgs;

/// CLI arguments for `cast wallet`.
#[derive(Debug, Parser)]
pub enum WalletSubcommands {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//! Vanity address generation

use crate::cmd::Cmd;
use cast::SimpleCast;
use clap::{builder::TypedValueParser, Parser};
use ethers::{
Expand All @@ -9,6 +6,7 @@ use ethers::{
types::{H160, U256},
utils::{get_contract_address, secret_key_to_address},
};
use foundry_cli::utils::Cmd;
use rayon::iter::{self, ParallelIterator};
use regex::Regex;
use std::time::Instant;
Expand Down
12 changes: 6 additions & 6 deletions cli/src/cast.rs → cli/src/cast/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@ use ethers::{
types::Address,
utils::keccak256,
};
use foundry_cli::{
cmd::Cmd,
handler,
opts::cast::{Opts, Subcommands, ToBaseArgs},
prompt, stdin, utils,
};
use foundry_cli::{handler, prompt, stdin, utils, utils::Cmd};
use foundry_common::{
abi::{format_tokens, get_event},
fs,
Expand All @@ -24,6 +19,11 @@ use foundry_common::{
use foundry_config::Config;
use std::time::Instant;

pub mod cmd;
pub mod opts;

use opts::{Opts, Subcommands, ToBaseArgs};

#[tokio::main]
async fn main() -> eyre::Result<()> {
utils::load_dotenv();
Expand Down
19 changes: 9 additions & 10 deletions cli/src/opts/cast.rs → cli/src/cast/opts.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
use super::{EtherscanOpts, RpcOpts};
use crate::{
cmd::cast::{
access_list::AccessListArgs, bind::BindArgs, call::CallArgs, create2::Create2Args,
estimate::EstimateArgs, find_block::FindBlockArgs, interface::InterfaceArgs,
logs::LogsArgs, rpc::RpcArgs, run::RunArgs, send::SendTxArgs, storage::StorageArgs,
wallet::WalletSubcommands,
},
utils::parse_u256,
use crate::cmd::{
access_list::AccessListArgs, bind::BindArgs, call::CallArgs, create2::Create2Args,
estimate::EstimateArgs, find_block::FindBlockArgs, interface::InterfaceArgs, logs::LogsArgs,
rpc::RpcArgs, run::RunArgs, send::SendTxArgs, storage::StorageArgs, wallet::WalletSubcommands,
};
use clap::{Parser, Subcommand, ValueHint};
use ethers::{
abi::ethabi::ethereum_types::BigEndianHash,
types::{serde_helpers::Numeric, Address, BlockId, NameOrAddress, H256, U256},
};
use foundry_cli::{
opts::{EtherscanOpts, RpcOpts},
utils::parse_u256,
};
use std::{path::PathBuf, str::FromStr};

#[derive(Debug, Parser)]
#[clap(name = "cast", version = crate::utils::VERSION_MESSAGE)]
#[clap(name = "cast", version = foundry_cli::utils::VERSION_MESSAGE)]
pub struct Opts {
#[clap(subcommand)]
pub sub: Subcommands,
Expand Down
Loading