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

Reorganize Cast to expose the cli logic as pub #8421

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 crates/cast/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ workspace = true

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

[build-dependencies]
vergen = { workspace = true, default-features = false, features = [
Expand Down
2 changes: 1 addition & 1 deletion crates/cast/benches/vanity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use criterion::{criterion_group, criterion_main, Criterion};
use rayon::prelude::*;
use std::{hint::black_box, time::Duration};

#[path = "../bin/cmd/wallet/mod.rs"]
#[path = "../src/cmd/wallet/mod.rs"]
#[allow(unused)]
mod wallet;
use wallet::vanity::*;
Expand Down
572 changes: 0 additions & 572 deletions crates/cast/bin/main.rs

This file was deleted.

19 changes: 19 additions & 0 deletions crates/cast/src/cast.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use cast::opts::CastArgs;
use clap::Parser;
use eyre::Result;
use foundry_cli::{handler, utils};

#[cfg(all(feature = "jemalloc", unix))]
#[global_allocator]
static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;

#[tokio::main]
async fn main() -> Result<()> {
handler::install();
utils::load_dotenv();
utils::subscriber();
utils::enable_paint();

let args = CastArgs::parse();
args.cmd.run().await
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::tx::CastTxBuilder;
use crate::{tx::CastTxBuilder, Cast};
use alloy_primitives::TxKind;
use alloy_rpc_types::BlockId;
use cast::Cast;
use clap::Parser;
use eyre::Result;
use foundry_cli::{
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::tx::CastTxBuilder;
use crate::{traces::TraceKind, tx::CastTxBuilder, Cast};
use alloy_primitives::{TxKind, U256};
use alloy_rpc_types::{BlockId, BlockNumberOrTag};
use cast::{traces::TraceKind, Cast};
use clap::Parser;
use eyre::Result;
use foundry_cli::{
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::Cast;
use alloy_provider::Provider;
use cast::Cast;
use clap::Parser;
use eyre::Result;
use foundry_cli::{opts::RpcOpts, utils};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use foundry_common::fs;
use foundry_config::Config;
use itertools::Itertools;
use std::path::{Path, PathBuf};
use tracing::warn;

/// CLI arguments for `cast interface`.
#[derive(Clone, Debug, Parser)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::Cast;
use alloy_dyn_abi::{DynSolType, DynSolValue, Specifier};
use alloy_json_abi::Event;
use alloy_network::AnyNetwork;
use alloy_primitives::{hex::FromHex, Address, B256};
use alloy_rpc_types::{BlockId, BlockNumberOrTag, Filter, FilterBlockOption, FilterSet, Topic};
use cast::Cast;
use clap::Parser;
use eyre::Result;
use foundry_cli::{opts::EthereumOpts, utils};
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use cast::Cast;
use crate::Cast;
use clap::Parser;
use eyre::Result;
use foundry_cli::{opts::RpcOpts, utils};
Expand Down
3 changes: 2 additions & 1 deletion crates/cast/bin/cmd/run.rs → crates/cast/src/cmd/run.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{revm::primitives::EnvWithHandlerCfg, traces::TraceKind};
use alloy_primitives::U256;
use alloy_provider::Provider;
use alloy_rpc_types::BlockTransactions;
use cast::{revm::primitives::EnvWithHandlerCfg, traces::TraceKind};
use clap::Parser;
use eyre::{Result, WrapErr};
use foundry_cli::{
Expand All @@ -16,6 +16,7 @@ use foundry_evm::{
opts::EvmOpts,
utils::configure_tx_env,
};
use tracing::trace;

/// CLI arguments for `cast run`.
#[derive(Clone, Debug, Parser)]
Expand Down
6 changes: 4 additions & 2 deletions crates/cast/bin/cmd/send.rs → crates/cast/src/cmd/send.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use crate::tx::{self, CastTxBuilder};
use crate::{
tx::{self, CastTxBuilder},
Cast,
};
use alloy_network::{AnyNetwork, EthereumWallet};
use alloy_provider::{Provider, ProviderBuilder};
use alloy_rpc_types::TransactionRequest;
use alloy_serde::WithOtherFields;
use alloy_signer::Signer;
use alloy_transport::Transport;
use cast::Cast;
use clap::Parser;
use eyre::Result;
use foundry_cli::{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use crate::opts::parse_slot;
use crate::{opts::parse_slot, Cast};
use alloy_network::AnyNetwork;
use alloy_primitives::{Address, B256, U256};
use alloy_provider::Provider;
use alloy_rpc_types::BlockId;
use alloy_transport::Transport;
use cast::Cast;
use clap::Parser;
use comfy_table::{presets::ASCII_MARKDOWN, Table};
use eyre::Result;
Expand Down
File renamed without changes.
4 changes: 4 additions & 0 deletions crates/cast/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ pub mod base;
pub mod errors;
mod rlp_converter;

pub mod cmd;
pub mod opts;
pub mod tx;

use rlp_converter::Item;

// TODO: CastContract with common contract initializers? Same for CastProviders?
Expand Down
Loading
Loading