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