1use alloy::primitives::Address;
4use thiserror::Error;
5
6pub type Result<T> = std::result::Result<T, Error>;
8
9#[derive(Debug, Error)]
11pub enum Error {
12 #[error("Provider error: {0}")]
14 Provider(String),
15
16 #[error("Failed to fetch {what}: {reason}")]
18 Fetch { what: &'static str, reason: String },
19
20 #[error("Unsupported chain ID: {0}")]
22 UnsupportedChain(u64),
23
24 #[error("Safe not deployed at {0}")]
26 SafeNotDeployed(Address),
27
28 #[error("MultiSend contract not deployed at {0}")]
30 MultiSendNotDeployed(Address),
31
32 #[error("Signer {signer} is not an owner of Safe {safe}")]
34 NotOwner { signer: Address, safe: Address },
35
36 #[error("Safe threshold is {threshold}, expected 1 for single-owner operations")]
38 InvalidThreshold { threshold: u64 },
39
40 #[error("Simulation failed: {reason}")]
42 SimulationFailed { reason: String },
43
44 #[error("Transaction reverted during simulation: {reason}")]
46 SimulationReverted { reason: String },
47
48 #[error("Execution failed: {reason}")]
50 ExecutionFailed { reason: String },
51
52 #[error("Safe rejected transaction: {reason}")]
54 SafeRejected { reason: String },
55
56 #[error("Failed to sign: {0}")]
58 Signing(String),
59
60 #[error("Encoding error: {0}")]
62 Encoding(String),
63
64 #[error("No calls added to multicall builder")]
66 NoCalls,
67
68 #[error("Gas estimation failed: {0}")]
70 GasEstimation(String),
71
72 #[error("ABI error: {0}")]
74 Abi(String),
75
76 #[error("EIP-712 error: {0}")]
78 Eip712(String),
79
80 #[error("Fork database error: {0}")]
82 ForkDb(String),
83
84 #[error("Revm execution error: {0}")]
86 Revm(String),
87
88 #[error("Failed to send transaction {index}: {reason}")]
90 TransactionSendFailed { index: usize, reason: String },
91
92 #[error("EOA does not support {operation} operation")]
94 UnsupportedEoaOperation { operation: String },
95
96 #[error("Invalid configuration: {0}")]
98 InvalidConfig(String),
99
100 #[error("Simulation has not been performed - call simulate() first")]
102 SimulationNotPerformed,
103}
104
105impl From<alloy::transports::RpcError<alloy::transports::TransportErrorKind>> for Error {
106 fn from(err: alloy::transports::RpcError<alloy::transports::TransportErrorKind>) -> Self {
107 Error::Provider(err.to_string())
108 }
109}
110
111impl From<alloy::contract::Error> for Error {
112 fn from(err: alloy::contract::Error) -> Self {
113 Error::Provider(err.to_string())
114 }
115}
116
117impl From<alloy::signers::Error> for Error {
118 fn from(err: alloy::signers::Error) -> Self {
119 Error::Signing(err.to_string())
120 }
121}