cast/cmd/
bind.rs

1use clap::{Parser, ValueHint};
2use eyre::Result;
3use foundry_cli::opts::EtherscanOpts;
4use std::path::PathBuf;
5
6const DEFAULT_CRATE_NAME: &str = "foundry-contracts";
7const DEFAULT_CRATE_VERSION: &str = "0.0.1";
8
9/// CLI arguments for `cast bind`.
10#[derive(Clone, Debug, Parser)]
11pub struct BindArgs {
12    /// The contract address, or the path to an ABI Directory
13    ///
14    /// If an address is specified, then the ABI is fetched from Etherscan.
15    path_or_address: String,
16
17    /// Path to where bindings will be stored
18    #[arg(
19        short,
20        long,
21        value_hint = ValueHint::DirPath,
22        value_name = "PATH"
23    )]
24    pub output_dir: Option<PathBuf>,
25
26    /// The name of the Rust crate to generate.
27    ///
28    /// This should be a valid crates.io crate name. However, this is currently not validated by
29    /// this command.
30    #[arg(
31        long,
32        default_value = DEFAULT_CRATE_NAME,
33        value_name = "NAME"
34    )]
35    crate_name: String,
36
37    /// The version of the Rust crate to generate.
38    ///
39    /// This should be a standard semver version string. However, it is not currently validated by
40    /// this command.
41    #[arg(
42        long,
43        default_value = DEFAULT_CRATE_VERSION,
44        value_name = "VERSION"
45    )]
46    crate_version: String,
47
48    /// Generate bindings as separate files.
49    #[arg(long)]
50    separate_files: bool,
51
52    #[command(flatten)]
53    etherscan: EtherscanOpts,
54}
55
56impl BindArgs {
57    pub async fn run(self) -> Result<()> {
58        Err(eyre::eyre!(
59            "`cast bind` has been removed.\n\
60             Please use `cast source` to create a Forge project from a block explorer source\n\
61             and `forge bind` to generate the bindings to it instead."
62        ))
63    }
64}