1use foundry_config::Chain;
4use std::fmt;
5
6#[derive(Clone, Debug)]
8pub enum FunctionSignatureError {
9 MissingSignature,
10 MissingEtherscan { sig: String },
11 UnknownChain(Chain),
12 MissingToAddress,
13}
14
15impl fmt::Display for FunctionSignatureError {
16 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
17 match self {
18 Self::MissingSignature => {
19 writeln!(f, "Function signature must be set")
20 }
21 Self::MissingEtherscan { sig } => {
22 writeln!(f, "Failed to determine function signature for `{sig}`")?;
23 writeln!(
24 f,
25 "To lookup a function signature of a deployed contract by name, a valid ETHERSCAN_API_KEY must be set."
26 )?;
27 write!(f, "\tOr did you mean:\t {sig}()")
28 }
29 Self::UnknownChain(chain) => {
30 write!(f, "Resolving via etherscan requires a known chain. Unknown chain: {chain}")
31 }
32 Self::MissingToAddress => f.write_str("Target address must be set"),
33 }
34 }
35}
36
37impl std::error::Error for FunctionSignatureError {}