zksync_web3_rs/zks_wallet/
errors.rs1use ethers::{
2 abi::{Error, ParseError},
3 prelude::{
4 k256::{
5 ecdsa::{RecoveryId, Signature as RecoverableSignature},
6 schnorr::signature::hazmat::PrehashSigner,
7 },
8 signer::SignerMiddlewareError,
9 AbiError, ContractError, SignerMiddleware,
10 },
11 providers::{Middleware, ProviderError},
12 signers::{Wallet, WalletError},
13 types::transaction::eip712::Eip712Error,
14};
15
16use crate::contracts::main_contract::MainContractError;
17
18#[derive(thiserror::Error, Debug)]
19pub enum ZKSWalletError<M, D>
20where
21 M: Middleware,
22 D: PrehashSigner<(RecoverableSignature, RecoveryId)> + Sync + Send,
23{
24 #[error("Provider error: {0}")]
25 ProviderError(#[from] ProviderError),
26 #[error("Middleware error: {0}")]
27 MiddlewareError(#[from] SignerMiddlewareError<M, Wallet<D>>),
28 #[error("Wallet error: {0}")]
29 EthWalletError(#[from] WalletError),
30 #[error("ABI error: {0}")]
31 AbiError(#[from] AbiError),
32 #[error("EIP712 error: {0}")]
33 Eip712Error(#[from] Eip712Error),
34 #[error("No L1 Ethereum provider")]
35 NoL1ProviderError(),
36 #[error("No L2 Ethereum provider")]
37 NoL2ProviderError(),
38 #[error("Contract error: {0}")]
39 ContractError(#[from] ContractError<M>),
40 #[error("Contract error: {0}")]
41 RequestConversionError(#[from] ZKRequestError),
42 #[error("{0}")]
43 CustomError(String),
44 #[error("Main contract error: {0}")]
45 MainContractError(#[from] MainContractError<M, D>),
46}
47
48impl<M, D> From<ContractError<SignerMiddleware<M, Wallet<D>>>> for ZKSWalletError<M, D>
49where
50 M: Middleware,
51 D: PrehashSigner<(RecoverableSignature, RecoveryId)> + Sync + Send,
52{
53 fn from(value: ContractError<SignerMiddleware<M, Wallet<D>>>) -> Self {
54 Self::CustomError(format!("{value:?}"))
55 }
56}
57
58#[derive(thiserror::Error, Debug)]
59pub enum ZKRequestError {
60 #[error("Error parsing function: {0}")]
61 ParseFunctionError(#[from] ParseError),
62 #[error("ABI error: {0}")]
63 AbiError(#[from] AbiError),
64 #[error("Encoding or decoding error: {0}")]
65 Error(#[from] Error),
66 #[error("{0}")]
67 CustomError(String),
68}