waffles_solana_sdk/transaction/
error.rs1use {
2 crate::{
3 instruction::InstructionError,
4 message::{AddressLoaderError, SanitizeMessageError},
5 sanitize::SanitizeError,
6 },
7 serde::Serialize,
8 thiserror::Error,
9};
10
11#[derive(
13 Error, Serialize, Deserialize, Debug, PartialEq, Eq, Clone, AbiExample, AbiEnumVisitor,
14)]
15pub enum TransactionError {
16 #[error("Account in use")]
19 AccountInUse,
20
21 #[error("Account loaded twice")]
24 AccountLoadedTwice,
25
26 #[error("Attempt to debit an account but found no record of a prior credit.")]
28 AccountNotFound,
29
30 #[error("Attempt to load a program that does not exist")]
32 ProgramAccountNotFound,
33
34 #[error("Insufficient funds for fee")]
36 InsufficientFundsForFee,
37
38 #[error("This account may not be used to pay transaction fees")]
40 InvalidAccountForFee,
41
42 #[error("This transaction has already been processed")]
46 AlreadyProcessed,
47
48 #[error("Blockhash not found")]
51 BlockhashNotFound,
52
53 #[error("Error processing Instruction {0}: {1}")]
56 InstructionError(u8, InstructionError),
57
58 #[error("Loader call chain is too deep")]
60 CallChainTooDeep,
61
62 #[error("Transaction requires a fee but has no signature present")]
64 MissingSignatureForFee,
65
66 #[error("Transaction contains an invalid account reference")]
68 InvalidAccountIndex,
69
70 #[error("Transaction did not pass signature verification")]
72 SignatureFailure,
73
74 #[error("This program may not be used for executing instructions")]
76 InvalidProgramForExecution,
77
78 #[error("Transaction failed to sanitize accounts offsets correctly")]
82 SanitizeFailure,
83
84 #[error("Transactions are currently disabled due to cluster maintenance")]
85 ClusterMaintenance,
86
87 #[error("Transaction processing left an account with an outstanding borrowed reference")]
89 AccountBorrowOutstanding,
90
91 #[error("Transaction would exceed max Block Cost Limit")]
93 WouldExceedMaxBlockCostLimit,
94
95 #[error("Transaction version is unsupported")]
97 UnsupportedVersion,
98
99 #[error("Transaction loads a writable account that cannot be written")]
101 InvalidWritableAccount,
102
103 #[error("Transaction would exceed max account limit within the block")]
105 WouldExceedMaxAccountCostLimit,
106
107 #[error("Transaction would exceed account data limit within the block")]
109 WouldExceedAccountDataBlockLimit,
110
111 #[error("Transaction locked too many accounts")]
113 TooManyAccountLocks,
114
115 #[error("Transaction loads an address table account that doesn't exist")]
117 AddressLookupTableNotFound,
118
119 #[error("Transaction loads an address table account with an invalid owner")]
121 InvalidAddressLookupTableOwner,
122
123 #[error("Transaction loads an address table account with invalid data")]
125 InvalidAddressLookupTableData,
126
127 #[error("Transaction address table lookup uses an invalid index")]
129 InvalidAddressLookupTableIndex,
130
131 #[error("Transaction leaves an account with a lower balance than rent-exempt minimum")]
133 InvalidRentPayingAccount,
134
135 #[error("Transaction would exceed max Vote Cost Limit")]
137 WouldExceedMaxVoteCostLimit,
138
139 #[error("Transaction would exceed total account data limit")]
141 WouldExceedAccountDataTotalLimit,
142
143 #[error("Transaction contains a duplicate instruction ({0}) that is not allowed")]
145 DuplicateInstruction(u8),
146
147 #[error(
149 "Transaction results in an account ({account_index}) with insufficient funds for rent"
150 )]
151 InsufficientFundsForRent { account_index: u8 },
152
153 #[error("Transaction exceeded max loaded accounts data size cap")]
155 MaxLoadedAccountsDataSizeExceeded,
156}
157
158impl From<SanitizeError> for TransactionError {
159 fn from(_: SanitizeError) -> Self {
160 Self::SanitizeFailure
161 }
162}
163
164impl From<SanitizeMessageError> for TransactionError {
165 fn from(err: SanitizeMessageError) -> Self {
166 match err {
167 SanitizeMessageError::AddressLoaderError(err) => Self::from(err),
168 _ => Self::SanitizeFailure,
169 }
170 }
171}
172
173impl From<AddressLoaderError> for TransactionError {
174 fn from(err: AddressLoaderError) -> Self {
175 match err {
176 AddressLoaderError::Disabled => Self::UnsupportedVersion,
177 AddressLoaderError::SlotHashesSysvarNotFound => Self::AccountNotFound,
178 AddressLoaderError::LookupTableAccountNotFound => Self::AddressLookupTableNotFound,
179 AddressLoaderError::InvalidAccountOwner => Self::InvalidAddressLookupTableOwner,
180 AddressLoaderError::InvalidAccountData => Self::InvalidAddressLookupTableData,
181 AddressLoaderError::InvalidLookupIndex => Self::InvalidAddressLookupTableIndex,
182 }
183 }
184}