1use derive_more::{From, Into};
2use pyo3::prelude::*;
3use serde::{Deserialize, Serialize};
4use solana_sdk::{
5 instruction::InstructionError as InstructionErrorOriginal,
6 transaction::TransactionError as TransactionErrorOriginal,
7};
8use solders_macros::{common_methods, richcmp_eq_only, EnumIntoPy};
9use solders_traits_core::transaction_status_boilerplate;
10
11#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, From, Into)]
12#[pyclass(module = "solders.transaction_status", subclass)]
13pub struct InstructionErrorCustom(pub u32);
14
15transaction_status_boilerplate!(InstructionErrorCustom);
16
17#[richcmp_eq_only]
18#[common_methods]
19#[pymethods]
20impl InstructionErrorCustom {
21 #[new]
22 pub fn new(code: u32) -> Self {
23 Self(code)
24 }
25
26 #[getter]
27 pub fn code(&self) -> u32 {
28 self.0
29 }
30}
31
32#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, From, Into)]
33#[pyclass(module = "solders.transaction_status", subclass)]
34pub struct InstructionErrorBorshIO(pub String);
35transaction_status_boilerplate!(InstructionErrorBorshIO);
36
37#[richcmp_eq_only]
38#[common_methods]
39#[pymethods]
40impl InstructionErrorBorshIO {
41 #[new]
42 pub fn new(value: String) -> Self {
43 Self(value)
44 }
45
46 #[getter]
47 pub fn value(&self) -> String {
48 self.0.clone()
49 }
50}
51
52#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
53#[pyclass(module = "solders.transaction_status")]
54pub enum InstructionErrorFieldless {
55 GenericError,
56 InvalidArgument,
57 InvalidInstructionData,
58 InvalidAccountData,
59 AccountDataTooSmall,
60 InsufficientFunds,
61 IncorrectProgramId,
62 MissingRequiredSignature,
63 AccountAlreadyInitialized,
64 UninitializedAccount,
65 UnbalancedInstruction,
66 ModifiedProgramId,
67 ExternalAccountLamportSpend,
68 ExternalAccountDataModified,
69 ReadonlyLamportChange,
70 ReadonlyDataModified,
71 DuplicateAccountIndex,
72 ExecutableModified,
73 RentEpochModified,
74 NotEnoughAccountKeys,
75 AccountDataSizeChanged,
76 AccountNotExecutable,
77 AccountBorrowFailed,
78 AccountBorrowOutstanding,
79 DuplicateAccountOutOfSync,
80 InvalidError,
81 ExecutableDataModified,
82 ExecutableLamportChange,
83 ExecutableAccountNotRentExempt,
84 UnsupportedProgramId,
85 CallDepth,
86 MissingAccount,
87 ReentrancyNotAllowed,
88 MaxSeedLengthExceeded,
89 InvalidSeeds,
90 InvalidRealloc,
91 ComputationalBudgetExceeded,
92 PrivilegeEscalation,
93 ProgramEnvironmentSetupFailure,
94 ProgramFailedToComplete,
95 ProgramFailedToCompile,
96 Immutable,
97 IncorrectAuthority,
98 AccountNotRentExempt,
99 InvalidAccountOwner,
100 ArithmeticOverflow,
101 UnsupportedSysvar,
102 IllegalOwner,
103 MaxAccountsDataAllocationsExceeded,
104 MaxAccountsExceeded,
105 MaxInstructionTraceLengthExceeded,
106 BuiltinProgramsMustConsumeComputeUnits,
107}
108
109#[derive(FromPyObject, Clone, PartialEq, Eq, Serialize, Deserialize, Debug, EnumIntoPy)]
110pub enum InstructionErrorTagged {
111 Custom(InstructionErrorCustom),
112 BorshIoError(InstructionErrorBorshIO),
113}
114
115#[derive(FromPyObject, Clone, PartialEq, Eq, Serialize, Deserialize, Debug, EnumIntoPy)]
116#[serde(untagged)]
117pub enum InstructionErrorType {
118 Fieldless(InstructionErrorFieldless),
119 Tagged(InstructionErrorTagged),
120}
121
122impl Default for InstructionErrorType {
123 fn default() -> Self {
124 Self::Fieldless(InstructionErrorFieldless::GenericError)
125 }
126}
127
128impl From<InstructionErrorType> for InstructionErrorOriginal {
129 fn from(w: InstructionErrorType) -> Self {
130 match w {
131 InstructionErrorType::Tagged(t) => match t {
132 InstructionErrorTagged::Custom(custom) => Self::Custom(custom.0),
133 InstructionErrorTagged::BorshIoError(borsh_io) => Self::BorshIoError(borsh_io.0),
134 },
135 InstructionErrorType::Fieldless(f) => match f {
136 InstructionErrorFieldless::GenericError => Self::GenericError,
137 InstructionErrorFieldless::InvalidArgument => Self::InvalidArgument,
138 InstructionErrorFieldless::InvalidInstructionData => Self::InvalidInstructionData,
139 InstructionErrorFieldless::InvalidAccountData => Self::InvalidAccountData,
140 InstructionErrorFieldless::AccountDataTooSmall => Self::AccountDataTooSmall,
141 InstructionErrorFieldless::InsufficientFunds => Self::InsufficientFunds,
142 InstructionErrorFieldless::IncorrectProgramId => Self::IncorrectProgramId,
143 InstructionErrorFieldless::MissingRequiredSignature => {
144 Self::MissingRequiredSignature
145 }
146 InstructionErrorFieldless::AccountAlreadyInitialized => {
147 Self::AccountAlreadyInitialized
148 }
149 InstructionErrorFieldless::UninitializedAccount => Self::UninitializedAccount,
150 InstructionErrorFieldless::UnbalancedInstruction => Self::UnbalancedInstruction,
151 InstructionErrorFieldless::ModifiedProgramId => Self::ModifiedProgramId,
152 InstructionErrorFieldless::ExternalAccountLamportSpend => {
153 Self::ExternalAccountLamportSpend
154 }
155 InstructionErrorFieldless::ExternalAccountDataModified => {
156 Self::ExternalAccountDataModified
157 }
158 InstructionErrorFieldless::ReadonlyLamportChange => Self::ReadonlyLamportChange,
159 InstructionErrorFieldless::ReadonlyDataModified => Self::ReadonlyDataModified,
160 InstructionErrorFieldless::DuplicateAccountIndex => Self::DuplicateAccountIndex,
161 InstructionErrorFieldless::ExecutableModified => Self::ExecutableModified,
162 InstructionErrorFieldless::RentEpochModified => Self::RentEpochModified,
163 InstructionErrorFieldless::NotEnoughAccountKeys => Self::NotEnoughAccountKeys,
164 InstructionErrorFieldless::AccountDataSizeChanged => Self::AccountDataSizeChanged,
165 InstructionErrorFieldless::AccountNotExecutable => Self::AccountNotExecutable,
166 InstructionErrorFieldless::AccountBorrowFailed => Self::AccountBorrowFailed,
167 InstructionErrorFieldless::AccountBorrowOutstanding => {
168 Self::AccountBorrowOutstanding
169 }
170 InstructionErrorFieldless::DuplicateAccountOutOfSync => {
171 Self::DuplicateAccountOutOfSync
172 }
173 InstructionErrorFieldless::InvalidError => Self::InvalidError,
174 InstructionErrorFieldless::ExecutableDataModified => Self::ExecutableDataModified,
175 InstructionErrorFieldless::ExecutableLamportChange => Self::ExecutableLamportChange,
176 InstructionErrorFieldless::ExecutableAccountNotRentExempt => {
177 Self::ExecutableAccountNotRentExempt
178 }
179 InstructionErrorFieldless::UnsupportedProgramId => Self::UnsupportedProgramId,
180 InstructionErrorFieldless::CallDepth => Self::CallDepth,
181 InstructionErrorFieldless::MissingAccount => Self::MissingAccount,
182 InstructionErrorFieldless::ReentrancyNotAllowed => Self::ReentrancyNotAllowed,
183 InstructionErrorFieldless::MaxSeedLengthExceeded => Self::MaxSeedLengthExceeded,
184 InstructionErrorFieldless::InvalidSeeds => Self::InvalidSeeds,
185 InstructionErrorFieldless::InvalidRealloc => Self::InvalidRealloc,
186 InstructionErrorFieldless::ComputationalBudgetExceeded => {
187 Self::ComputationalBudgetExceeded
188 }
189 InstructionErrorFieldless::PrivilegeEscalation => Self::PrivilegeEscalation,
190 InstructionErrorFieldless::ProgramEnvironmentSetupFailure => {
191 Self::ProgramEnvironmentSetupFailure
192 }
193 InstructionErrorFieldless::ProgramFailedToComplete => Self::ProgramFailedToComplete,
194 InstructionErrorFieldless::ProgramFailedToCompile => Self::ProgramFailedToCompile,
195 InstructionErrorFieldless::Immutable => Self::Immutable,
196 InstructionErrorFieldless::IncorrectAuthority => Self::IncorrectAuthority,
197 InstructionErrorFieldless::AccountNotRentExempt => Self::AccountNotRentExempt,
198 InstructionErrorFieldless::InvalidAccountOwner => Self::InvalidAccountOwner,
199 InstructionErrorFieldless::ArithmeticOverflow => Self::ArithmeticOverflow,
200 InstructionErrorFieldless::UnsupportedSysvar => Self::UnsupportedSysvar,
201 InstructionErrorFieldless::IllegalOwner => Self::IllegalOwner,
202 InstructionErrorFieldless::MaxAccountsDataAllocationsExceeded => {
203 Self::MaxAccountsDataAllocationsExceeded
204 }
205 InstructionErrorFieldless::MaxAccountsExceeded => Self::MaxAccountsExceeded,
206 InstructionErrorFieldless::MaxInstructionTraceLengthExceeded => {
207 Self::MaxInstructionTraceLengthExceeded
208 }
209 InstructionErrorFieldless::BuiltinProgramsMustConsumeComputeUnits => {
210 Self::BuiltinProgramsMustConsumeComputeUnits
211 }
212 },
213 }
214 }
215}
216
217impl From<InstructionErrorOriginal> for InstructionErrorType {
218 fn from(e: InstructionErrorOriginal) -> Self {
219 match e {
220 InstructionErrorOriginal::Custom(code) => {
221 Self::Tagged(InstructionErrorTagged::Custom(InstructionErrorCustom(code)))
222 }
223 InstructionErrorOriginal::BorshIoError(val) => Self::Tagged(
224 InstructionErrorTagged::BorshIoError(InstructionErrorBorshIO(val)),
225 ),
226 InstructionErrorOriginal::GenericError => {
227 Self::Fieldless(InstructionErrorFieldless::GenericError)
228 }
229 InstructionErrorOriginal::InvalidArgument => {
230 Self::Fieldless(InstructionErrorFieldless::InvalidArgument)
231 }
232 InstructionErrorOriginal::InvalidInstructionData => {
233 Self::Fieldless(InstructionErrorFieldless::InvalidInstructionData)
234 }
235 InstructionErrorOriginal::InvalidAccountData => {
236 Self::Fieldless(InstructionErrorFieldless::InvalidAccountData)
237 }
238 InstructionErrorOriginal::AccountDataTooSmall => {
239 Self::Fieldless(InstructionErrorFieldless::AccountDataTooSmall)
240 }
241 InstructionErrorOriginal::InsufficientFunds => {
242 Self::Fieldless(InstructionErrorFieldless::InsufficientFunds)
243 }
244 InstructionErrorOriginal::IncorrectProgramId => {
245 Self::Fieldless(InstructionErrorFieldless::IncorrectProgramId)
246 }
247 InstructionErrorOriginal::MissingRequiredSignature => {
248 Self::Fieldless(InstructionErrorFieldless::MissingRequiredSignature)
249 }
250 InstructionErrorOriginal::AccountAlreadyInitialized => {
251 Self::Fieldless(InstructionErrorFieldless::AccountAlreadyInitialized)
252 }
253 InstructionErrorOriginal::UninitializedAccount => {
254 Self::Fieldless(InstructionErrorFieldless::UninitializedAccount)
255 }
256 InstructionErrorOriginal::UnbalancedInstruction => {
257 Self::Fieldless(InstructionErrorFieldless::UnbalancedInstruction)
258 }
259 InstructionErrorOriginal::ModifiedProgramId => {
260 Self::Fieldless(InstructionErrorFieldless::ModifiedProgramId)
261 }
262 InstructionErrorOriginal::ExternalAccountLamportSpend => {
263 Self::Fieldless(InstructionErrorFieldless::ExternalAccountLamportSpend)
264 }
265 InstructionErrorOriginal::ExternalAccountDataModified => {
266 Self::Fieldless(InstructionErrorFieldless::ExternalAccountDataModified)
267 }
268 InstructionErrorOriginal::ReadonlyLamportChange => {
269 Self::Fieldless(InstructionErrorFieldless::ReadonlyLamportChange)
270 }
271 InstructionErrorOriginal::ReadonlyDataModified => {
272 Self::Fieldless(InstructionErrorFieldless::ReadonlyDataModified)
273 }
274 InstructionErrorOriginal::DuplicateAccountIndex => {
275 Self::Fieldless(InstructionErrorFieldless::DuplicateAccountIndex)
276 }
277 InstructionErrorOriginal::ExecutableModified => {
278 Self::Fieldless(InstructionErrorFieldless::ExecutableModified)
279 }
280 InstructionErrorOriginal::RentEpochModified => {
281 Self::Fieldless(InstructionErrorFieldless::RentEpochModified)
282 }
283 InstructionErrorOriginal::NotEnoughAccountKeys => {
284 Self::Fieldless(InstructionErrorFieldless::NotEnoughAccountKeys)
285 }
286 InstructionErrorOriginal::AccountDataSizeChanged => {
287 Self::Fieldless(InstructionErrorFieldless::AccountDataSizeChanged)
288 }
289 InstructionErrorOriginal::AccountNotExecutable => {
290 Self::Fieldless(InstructionErrorFieldless::AccountNotExecutable)
291 }
292 InstructionErrorOriginal::AccountBorrowFailed => {
293 Self::Fieldless(InstructionErrorFieldless::AccountBorrowFailed)
294 }
295 InstructionErrorOriginal::AccountBorrowOutstanding => {
296 Self::Fieldless(InstructionErrorFieldless::AccountBorrowOutstanding)
297 }
298 InstructionErrorOriginal::DuplicateAccountOutOfSync => {
299 Self::Fieldless(InstructionErrorFieldless::DuplicateAccountOutOfSync)
300 }
301 InstructionErrorOriginal::InvalidError => {
302 Self::Fieldless(InstructionErrorFieldless::InvalidError)
303 }
304 InstructionErrorOriginal::ExecutableDataModified => {
305 Self::Fieldless(InstructionErrorFieldless::ExecutableDataModified)
306 }
307 InstructionErrorOriginal::ExecutableLamportChange => {
308 Self::Fieldless(InstructionErrorFieldless::ExecutableLamportChange)
309 }
310 InstructionErrorOriginal::ExecutableAccountNotRentExempt => {
311 Self::Fieldless(InstructionErrorFieldless::ExecutableAccountNotRentExempt)
312 }
313 InstructionErrorOriginal::UnsupportedProgramId => {
314 Self::Fieldless(InstructionErrorFieldless::UnsupportedProgramId)
315 }
316 InstructionErrorOriginal::CallDepth => {
317 Self::Fieldless(InstructionErrorFieldless::CallDepth)
318 }
319 InstructionErrorOriginal::MissingAccount => {
320 Self::Fieldless(InstructionErrorFieldless::MissingAccount)
321 }
322 InstructionErrorOriginal::ReentrancyNotAllowed => {
323 Self::Fieldless(InstructionErrorFieldless::ReentrancyNotAllowed)
324 }
325 InstructionErrorOriginal::MaxSeedLengthExceeded => {
326 Self::Fieldless(InstructionErrorFieldless::MaxSeedLengthExceeded)
327 }
328 InstructionErrorOriginal::InvalidSeeds => {
329 Self::Fieldless(InstructionErrorFieldless::InvalidSeeds)
330 }
331 InstructionErrorOriginal::InvalidRealloc => {
332 Self::Fieldless(InstructionErrorFieldless::InvalidRealloc)
333 }
334 InstructionErrorOriginal::ComputationalBudgetExceeded => {
335 Self::Fieldless(InstructionErrorFieldless::ComputationalBudgetExceeded)
336 }
337 InstructionErrorOriginal::PrivilegeEscalation => {
338 Self::Fieldless(InstructionErrorFieldless::PrivilegeEscalation)
339 }
340 InstructionErrorOriginal::ProgramEnvironmentSetupFailure => {
341 Self::Fieldless(InstructionErrorFieldless::ProgramEnvironmentSetupFailure)
342 }
343 InstructionErrorOriginal::ProgramFailedToComplete => {
344 Self::Fieldless(InstructionErrorFieldless::ProgramFailedToComplete)
345 }
346 InstructionErrorOriginal::ProgramFailedToCompile => {
347 Self::Fieldless(InstructionErrorFieldless::ProgramFailedToCompile)
348 }
349 InstructionErrorOriginal::Immutable => {
350 Self::Fieldless(InstructionErrorFieldless::Immutable)
351 }
352 InstructionErrorOriginal::IncorrectAuthority => {
353 Self::Fieldless(InstructionErrorFieldless::IncorrectAuthority)
354 }
355 InstructionErrorOriginal::AccountNotRentExempt => {
356 Self::Fieldless(InstructionErrorFieldless::AccountNotRentExempt)
357 }
358 InstructionErrorOriginal::InvalidAccountOwner => {
359 Self::Fieldless(InstructionErrorFieldless::InvalidAccountOwner)
360 }
361 InstructionErrorOriginal::ArithmeticOverflow => {
362 Self::Fieldless(InstructionErrorFieldless::ArithmeticOverflow)
363 }
364 InstructionErrorOriginal::UnsupportedSysvar => {
365 Self::Fieldless(InstructionErrorFieldless::UnsupportedSysvar)
366 }
367 InstructionErrorOriginal::IllegalOwner => {
368 Self::Fieldless(InstructionErrorFieldless::IllegalOwner)
369 }
370 InstructionErrorOriginal::MaxAccountsDataAllocationsExceeded => {
371 Self::Fieldless(InstructionErrorFieldless::MaxAccountsDataAllocationsExceeded)
372 }
373 InstructionErrorOriginal::MaxAccountsExceeded => {
374 Self::Fieldless(InstructionErrorFieldless::MaxAccountsExceeded)
375 }
376 InstructionErrorOriginal::MaxInstructionTraceLengthExceeded => {
377 Self::Fieldless(InstructionErrorFieldless::MaxInstructionTraceLengthExceeded)
378 }
379 InstructionErrorOriginal::BuiltinProgramsMustConsumeComputeUnits => {
380 Self::Fieldless(InstructionErrorFieldless::BuiltinProgramsMustConsumeComputeUnits)
381 }
382 }
383 }
384}
385
386#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, From, Into)]
387#[pyclass(module = "solders.transaction_status", subclass)]
388pub struct TransactionErrorInstructionError(pub (u8, InstructionErrorType));
389transaction_status_boilerplate!(TransactionErrorInstructionError);
390
391#[richcmp_eq_only]
392#[common_methods]
393#[pymethods]
394impl TransactionErrorInstructionError {
395 #[new]
396 pub fn new(index: u8, err: InstructionErrorType) -> Self {
397 Self((index, err))
398 }
399
400 #[getter]
401 pub fn index(&self) -> u8 {
402 self.0 .0
403 }
404
405 #[getter]
406 pub fn err(&self) -> InstructionErrorType {
407 self.0 .1.clone()
408 }
409}
410
411#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, From, Into)]
412#[pyclass(module = "solders.transaction_status", subclass)]
413pub struct TransactionErrorDuplicateInstruction(pub u8);
414transaction_status_boilerplate!(TransactionErrorDuplicateInstruction);
415
416#[richcmp_eq_only]
417#[common_methods]
418#[pymethods]
419impl TransactionErrorDuplicateInstruction {
420 #[new]
421 pub fn new(index: u8) -> Self {
422 Self(index)
423 }
424
425 #[getter]
426 pub fn index(&self) -> u8 {
427 self.0
428 }
429}
430
431#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, From, Into)]
432#[pyclass(module = "solders.transaction_status", subclass)]
433pub struct TransactionErrorInsufficientFundsForRent {
434 #[pyo3(get)]
435 account_index: u8,
436}
437transaction_status_boilerplate!(TransactionErrorInsufficientFundsForRent);
438
439#[richcmp_eq_only]
440#[common_methods]
441#[pymethods]
442impl TransactionErrorInsufficientFundsForRent {
443 #[new]
444 pub fn new(account_index: u8) -> Self {
445 Self { account_index }
446 }
447}
448
449#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, From, Into)]
450#[pyclass(module = "solders.transaction_status", subclass)]
451pub struct TransactionErrorProgramExecutionTemporarilyRestricted {
452 #[pyo3(get)]
453 account_index: u8,
454}
455transaction_status_boilerplate!(TransactionErrorProgramExecutionTemporarilyRestricted);
456
457#[richcmp_eq_only]
458#[common_methods]
459#[pymethods]
460impl TransactionErrorProgramExecutionTemporarilyRestricted {
461 #[new]
462 pub fn new(account_index: u8) -> Self {
463 Self { account_index }
464 }
465}
466
467#[pyclass(module = "solders.transaction_status")]
468#[derive(Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq, Hash)]
469pub enum TransactionErrorFieldless {
470 AccountInUse,
471 AccountLoadedTwice,
472 AccountNotFound,
473 ProgramAccountNotFound,
474 InsufficientFundsForFee,
475 InvalidAccountForFee,
476 AlreadyProcessed,
477 BlockhashNotFound,
478 CallChainTooDeep,
479 MissingSignatureForFee,
480 InvalidAccountIndex,
481 SignatureFailure,
482 InvalidProgramForExecution,
483 SanitizeFailure,
484 ClusterMaintenance,
485 AccountBorrowOutstanding,
486 WouldExceedMaxBlockCostLimit,
487 UnsupportedVersion,
488 InvalidWritableAccount,
489 WouldExceedMaxAccountCostLimit,
490 WouldExceedAccountDataBlockLimit,
491 TooManyAccountLocks,
492 AddressLookupTableNotFound,
493 InvalidAddressLookupTableOwner,
494 InvalidAddressLookupTableData,
495 InvalidAddressLookupTableIndex,
496 InvalidRentPayingAccount,
497 WouldExceedMaxVoteCostLimit,
498 WouldExceedAccountDataTotalLimit,
499 MaxLoadedAccountsDataSizeExceeded,
500 ResanitizationNeeded,
501 InvalidLoadedAccountsDataSizeLimit,
502 UnbalancedTransaction,
503}
504
505#[derive(FromPyObject, Clone, PartialEq, Eq, Serialize, Deserialize, Debug, EnumIntoPy)]
506pub enum TransactionErrorTypeTagged {
507 InstructionError(TransactionErrorInstructionError),
508 DuplicateInstruction(TransactionErrorDuplicateInstruction),
509 InsufficientFundsForRent(TransactionErrorInsufficientFundsForRent),
510 ProgramExecutionTemporarilyRestricted(TransactionErrorProgramExecutionTemporarilyRestricted),
511}
512
513#[derive(FromPyObject, Clone, PartialEq, Eq, Serialize, Deserialize, Debug, EnumIntoPy)]
514#[serde(untagged)]
515pub enum TransactionErrorType {
516 Fieldless(TransactionErrorFieldless),
517 Tagged(TransactionErrorTypeTagged),
518}
519
520impl Default for TransactionErrorType {
521 fn default() -> Self {
522 Self::Fieldless(TransactionErrorFieldless::AccountInUse)
523 }
524}
525
526impl From<TransactionErrorType> for TransactionErrorOriginal {
527 fn from(w: TransactionErrorType) -> Self {
528 match w {
529 TransactionErrorType::Tagged(t) => match t {
530 TransactionErrorTypeTagged::InstructionError(e) => {
531 Self::InstructionError(e.0 .0, e.0 .1.into())
532 }
533 TransactionErrorTypeTagged::DuplicateInstruction(e) => {
534 Self::DuplicateInstruction(e.0)
535 }
536 TransactionErrorTypeTagged::InsufficientFundsForRent(e) => {
537 Self::InsufficientFundsForRent {
538 account_index: e.account_index,
539 }
540 }
541 TransactionErrorTypeTagged::ProgramExecutionTemporarilyRestricted(e) => {
542 Self::ProgramExecutionTemporarilyRestricted {
543 account_index: e.account_index,
544 }
545 }
546 },
547 TransactionErrorType::Fieldless(f) => match f {
548 TransactionErrorFieldless::AccountInUse => Self::AccountInUse,
549 TransactionErrorFieldless::AccountLoadedTwice => Self::AccountLoadedTwice,
550 TransactionErrorFieldless::AccountNotFound => Self::AccountNotFound,
551 TransactionErrorFieldless::ProgramAccountNotFound => Self::ProgramAccountNotFound,
552 TransactionErrorFieldless::InsufficientFundsForFee => Self::InsufficientFundsForFee,
553 TransactionErrorFieldless::InvalidAccountForFee => Self::InvalidAccountForFee,
554 TransactionErrorFieldless::AlreadyProcessed => Self::AlreadyProcessed,
555 TransactionErrorFieldless::BlockhashNotFound => Self::BlockhashNotFound,
556 TransactionErrorFieldless::CallChainTooDeep => Self::CallChainTooDeep,
557 TransactionErrorFieldless::MissingSignatureForFee => Self::MissingSignatureForFee,
558 TransactionErrorFieldless::InvalidAccountIndex => Self::InvalidAccountIndex,
559 TransactionErrorFieldless::SignatureFailure => Self::SignatureFailure,
560 TransactionErrorFieldless::InvalidProgramForExecution => {
561 Self::InvalidProgramForExecution
562 }
563 TransactionErrorFieldless::SanitizeFailure => Self::SanitizeFailure,
564 TransactionErrorFieldless::ClusterMaintenance => Self::ClusterMaintenance,
565 TransactionErrorFieldless::AccountBorrowOutstanding => {
566 Self::AccountBorrowOutstanding
567 }
568 TransactionErrorFieldless::WouldExceedMaxBlockCostLimit => {
569 Self::WouldExceedMaxBlockCostLimit
570 }
571 TransactionErrorFieldless::UnsupportedVersion => Self::UnsupportedVersion,
572 TransactionErrorFieldless::InvalidWritableAccount => Self::InvalidWritableAccount,
573 TransactionErrorFieldless::WouldExceedMaxAccountCostLimit => {
574 Self::WouldExceedMaxAccountCostLimit
575 }
576 TransactionErrorFieldless::WouldExceedAccountDataBlockLimit => {
577 Self::WouldExceedAccountDataBlockLimit
578 }
579 TransactionErrorFieldless::TooManyAccountLocks => Self::TooManyAccountLocks,
580 TransactionErrorFieldless::AddressLookupTableNotFound => {
581 Self::AddressLookupTableNotFound
582 }
583 TransactionErrorFieldless::InvalidAddressLookupTableOwner => {
584 Self::InvalidAddressLookupTableOwner
585 }
586 TransactionErrorFieldless::InvalidAddressLookupTableData => {
587 Self::InvalidAddressLookupTableData
588 }
589 TransactionErrorFieldless::InvalidAddressLookupTableIndex => {
590 Self::InvalidAddressLookupTableIndex
591 }
592 TransactionErrorFieldless::InvalidRentPayingAccount => {
593 Self::InvalidRentPayingAccount
594 }
595 TransactionErrorFieldless::WouldExceedMaxVoteCostLimit => {
596 Self::WouldExceedMaxVoteCostLimit
597 }
598 TransactionErrorFieldless::WouldExceedAccountDataTotalLimit => {
599 Self::WouldExceedAccountDataTotalLimit
600 }
601 TransactionErrorFieldless::MaxLoadedAccountsDataSizeExceeded => {
602 Self::MaxLoadedAccountsDataSizeExceeded
603 }
604 TransactionErrorFieldless::ResanitizationNeeded => Self::ResanitizationNeeded,
605 TransactionErrorFieldless::InvalidLoadedAccountsDataSizeLimit => {
606 Self::InvalidLoadedAccountsDataSizeLimit
607 }
608 TransactionErrorFieldless::UnbalancedTransaction => Self::UnbalancedTransaction,
609 },
610 }
611 }
612}
613
614impl From<TransactionErrorOriginal> for TransactionErrorType {
615 fn from(w: TransactionErrorOriginal) -> Self {
616 match w {
617 TransactionErrorOriginal::InstructionError(index, err) => {
618 Self::Tagged(TransactionErrorTypeTagged::InstructionError(
619 TransactionErrorInstructionError((index, err.into())),
620 ))
621 }
622 TransactionErrorOriginal::DuplicateInstruction(index) => {
623 Self::Tagged(TransactionErrorTypeTagged::DuplicateInstruction(
624 TransactionErrorDuplicateInstruction(index),
625 ))
626 }
627 TransactionErrorOriginal::InsufficientFundsForRent { account_index } => {
628 Self::Tagged(TransactionErrorTypeTagged::InsufficientFundsForRent(
629 TransactionErrorInsufficientFundsForRent { account_index },
630 ))
631 }
632 TransactionErrorOriginal::ProgramExecutionTemporarilyRestricted { account_index } => {
633 Self::Tagged(
634 TransactionErrorTypeTagged::ProgramExecutionTemporarilyRestricted(
635 TransactionErrorProgramExecutionTemporarilyRestricted { account_index },
636 ),
637 )
638 }
639 TransactionErrorOriginal::AccountInUse => {
640 Self::Fieldless(TransactionErrorFieldless::AccountInUse)
641 }
642 TransactionErrorOriginal::AccountLoadedTwice => {
643 Self::Fieldless(TransactionErrorFieldless::AccountLoadedTwice)
644 }
645 TransactionErrorOriginal::AccountNotFound => {
646 Self::Fieldless(TransactionErrorFieldless::AccountNotFound)
647 }
648 TransactionErrorOriginal::ProgramAccountNotFound => {
649 Self::Fieldless(TransactionErrorFieldless::ProgramAccountNotFound)
650 }
651 TransactionErrorOriginal::InsufficientFundsForFee => {
652 Self::Fieldless(TransactionErrorFieldless::InsufficientFundsForFee)
653 }
654 TransactionErrorOriginal::InvalidAccountForFee => {
655 Self::Fieldless(TransactionErrorFieldless::InvalidAccountForFee)
656 }
657 TransactionErrorOriginal::AlreadyProcessed => {
658 Self::Fieldless(TransactionErrorFieldless::AlreadyProcessed)
659 }
660 TransactionErrorOriginal::BlockhashNotFound => {
661 Self::Fieldless(TransactionErrorFieldless::BlockhashNotFound)
662 }
663 TransactionErrorOriginal::CallChainTooDeep => {
664 Self::Fieldless(TransactionErrorFieldless::CallChainTooDeep)
665 }
666 TransactionErrorOriginal::MissingSignatureForFee => {
667 Self::Fieldless(TransactionErrorFieldless::MissingSignatureForFee)
668 }
669 TransactionErrorOriginal::InvalidAccountIndex => {
670 Self::Fieldless(TransactionErrorFieldless::InvalidAccountIndex)
671 }
672 TransactionErrorOriginal::SignatureFailure => {
673 Self::Fieldless(TransactionErrorFieldless::SignatureFailure)
674 }
675 TransactionErrorOriginal::InvalidProgramForExecution => {
676 Self::Fieldless(TransactionErrorFieldless::InvalidProgramForExecution)
677 }
678 TransactionErrorOriginal::SanitizeFailure => {
679 Self::Fieldless(TransactionErrorFieldless::SanitizeFailure)
680 }
681 TransactionErrorOriginal::ClusterMaintenance => {
682 Self::Fieldless(TransactionErrorFieldless::ClusterMaintenance)
683 }
684 TransactionErrorOriginal::AccountBorrowOutstanding => {
685 Self::Fieldless(TransactionErrorFieldless::AccountBorrowOutstanding)
686 }
687 TransactionErrorOriginal::WouldExceedMaxBlockCostLimit => {
688 Self::Fieldless(TransactionErrorFieldless::WouldExceedMaxBlockCostLimit)
689 }
690 TransactionErrorOriginal::UnsupportedVersion => {
691 Self::Fieldless(TransactionErrorFieldless::UnsupportedVersion)
692 }
693 TransactionErrorOriginal::InvalidWritableAccount => {
694 Self::Fieldless(TransactionErrorFieldless::InvalidWritableAccount)
695 }
696 TransactionErrorOriginal::WouldExceedMaxAccountCostLimit => {
697 Self::Fieldless(TransactionErrorFieldless::WouldExceedMaxAccountCostLimit)
698 }
699 TransactionErrorOriginal::WouldExceedAccountDataBlockLimit => {
700 Self::Fieldless(TransactionErrorFieldless::WouldExceedAccountDataBlockLimit)
701 }
702 TransactionErrorOriginal::TooManyAccountLocks => {
703 Self::Fieldless(TransactionErrorFieldless::TooManyAccountLocks)
704 }
705 TransactionErrorOriginal::AddressLookupTableNotFound => {
706 Self::Fieldless(TransactionErrorFieldless::AddressLookupTableNotFound)
707 }
708 TransactionErrorOriginal::InvalidAddressLookupTableOwner => {
709 Self::Fieldless(TransactionErrorFieldless::InvalidAddressLookupTableOwner)
710 }
711 TransactionErrorOriginal::InvalidAddressLookupTableData => {
712 Self::Fieldless(TransactionErrorFieldless::InvalidAddressLookupTableData)
713 }
714 TransactionErrorOriginal::InvalidAddressLookupTableIndex => {
715 Self::Fieldless(TransactionErrorFieldless::InvalidAddressLookupTableIndex)
716 }
717 TransactionErrorOriginal::InvalidRentPayingAccount => {
718 Self::Fieldless(TransactionErrorFieldless::InvalidRentPayingAccount)
719 }
720 TransactionErrorOriginal::WouldExceedMaxVoteCostLimit => {
721 Self::Fieldless(TransactionErrorFieldless::WouldExceedMaxVoteCostLimit)
722 }
723 TransactionErrorOriginal::WouldExceedAccountDataTotalLimit => {
724 Self::Fieldless(TransactionErrorFieldless::WouldExceedAccountDataTotalLimit)
725 }
726 TransactionErrorOriginal::MaxLoadedAccountsDataSizeExceeded => {
727 Self::Fieldless(TransactionErrorFieldless::MaxLoadedAccountsDataSizeExceeded)
728 }
729 TransactionErrorOriginal::ResanitizationNeeded => {
730 Self::Fieldless(TransactionErrorFieldless::ResanitizationNeeded)
731 }
732 TransactionErrorOriginal::InvalidLoadedAccountsDataSizeLimit => {
733 Self::Fieldless(TransactionErrorFieldless::InvalidLoadedAccountsDataSizeLimit)
734 }
735 TransactionErrorOriginal::UnbalancedTransaction => {
736 Self::Fieldless(TransactionErrorFieldless::UnbalancedTransaction)
737 }
738 }
739 }
740}