1use crate::eips::eip712::EIP712Error;
2use alloy_primitives::Address;
3use tides_core_types::TidesChainId;
4use trident_proto_types::ProtoConvError;
5use trident_types::core::{FixedBytes32ConversionError, SpendIntent};
6
7#[derive(thiserror::Error, Debug)]
8pub enum Error {
9 #[error("Invalid service")]
10 InvalidService,
11 #[error("Tonic transport: {0}")]
12 TonicTransport(#[from] tonic::transport::Error),
13 #[error("Grpc Client")]
14 GrpcClient(#[from] tonic::Status),
15 #[error("Unknown chain: {0}")]
16 UnknownChain(TidesChainId),
17 #[error("Unsupported chain type: {0}")]
18 UnsupportedChainType(i32),
19 #[error("Unsupported token: {0}")]
20 UnsupportedToken(Address),
21 #[error("Alloy contract error: {0}")]
22 AlloyContract(#[from] alloy_contract::Error),
23 #[error("Pending transaction error: {0}")]
24 AlloyPendingTx(#[from] alloy_provider::PendingTransactionError),
25 #[error("Alloy signer error: {0}")]
26 AlloySigner(#[from] alloy_signer::Error),
27 #[error("No destination token mapping from {0} on chain {1} to chain {2}")]
28 NoDestinationTokenMapping(Address, TidesChainId, TidesChainId),
29 #[error(
30 "Ambiguous destination token mapping for {0} from chain {1} to chain {2}; specify destination token"
31 )]
32 AmbiguousDestinationTokenMapping(Address, TidesChainId, TidesChainId),
33 #[error("FixedBytes32 conversion: {0}")]
34 Fixed32Conversion(#[from] FixedBytes32ConversionError),
35 #[error("Slice conversion: {0}")]
36 SliceConversion(#[from] std::array::TryFromSliceError),
37 #[error("Conversion error: {0}")]
38 TokenConversion(String),
39 #[error("Block height computation overflowed")]
40 BlockHeightOverflow,
41 #[error("Insufficient balance: need {0}, available {1}")]
42 InsufficientBalance(alloy_primitives::U256, alloy_primitives::U256),
43 #[error("Invalid U256 byte slice")]
44 InvalidU256ByteSlice,
45 #[error(transparent)]
46 EvmDeliveryFailed(#[from] Box<EvmDeliveryFailed>),
47 #[error("Random: {0}")]
48 RandCore(#[from] rand_core::OsError),
49 #[error("EIP712Error: {0}")]
50 EIP712Error(#[from] EIP712Error),
51 #[error("ProtoConvError: {0}")]
52 ProtoConv(#[from] ProtoConvError),
53}
54
55#[derive(thiserror::Error, Debug)]
56#[error("EVM delivery failed: {cause}")]
57pub struct EvmDeliveryFailed {
58 pub spend_intent: SpendIntent,
59 pub attestation_payload: Vec<u8>,
60 pub signature: Vec<u8>,
61 #[source]
62 pub cause: Box<Error>,
63}