|
| 1 | +use light_account_checks::error::AccountError; |
| 2 | +use light_batched_merkle_tree::errors::BatchedMerkleTreeError; |
| 3 | +use light_concurrent_merkle_tree::errors::ConcurrentMerkleTreeError; |
| 4 | +use light_indexed_merkle_tree::errors::IndexedMerkleTreeError; |
| 5 | +use light_zero_copy::errors::ZeroCopyError; |
1 | 6 | use pinocchio::program_error::ProgramError; |
2 | 7 | use thiserror::Error; |
3 | 8 |
|
@@ -107,10 +112,90 @@ pub enum SystemProgramError { |
107 | 112 | InvalidTreeHeight, |
108 | 113 | #[error("TooManyOutputAccounts")] |
109 | 114 | TooManyOutputAccounts, |
| 115 | + #[error("Batched Merkle tree error {0}")] |
| 116 | + BatchedMerkleTreeError(#[from] BatchedMerkleTreeError), |
| 117 | + #[error("Concurrent Merkle tree error {0}")] |
| 118 | + ConcurrentMerkleTreeError(#[from] ConcurrentMerkleTreeError), |
| 119 | + #[error("Indexed Merkle tree error {0}")] |
| 120 | + IndexedMerkleTreeError(#[from] IndexedMerkleTreeError), |
| 121 | + #[error("Account checks error {0}")] |
| 122 | + AccountError(#[from] AccountError), |
| 123 | + #[error("Zero copy error {0}")] |
| 124 | + ZeroCopyError(#[from] ZeroCopyError), |
| 125 | + #[error("Program error code: {0}")] |
| 126 | + ProgramError(u64), |
| 127 | + #[error("Borrowing data failed")] |
| 128 | + BorrowingDataFailed, |
| 129 | +} |
| 130 | + |
| 131 | +impl From<SystemProgramError> for u32 { |
| 132 | + fn from(e: SystemProgramError) -> u32 { |
| 133 | + match e { |
| 134 | + SystemProgramError::SumCheckFailed => 6000, |
| 135 | + SystemProgramError::SignerCheckFailed => 6001, |
| 136 | + SystemProgramError::CpiSignerCheckFailed => 6002, |
| 137 | + SystemProgramError::ComputeInputSumFailed => 6003, |
| 138 | + SystemProgramError::ComputeOutputSumFailed => 6004, |
| 139 | + SystemProgramError::ComputeRpcSumFailed => 6005, |
| 140 | + SystemProgramError::InvalidAddress => 6006, |
| 141 | + SystemProgramError::DeriveAddressError => 6007, |
| 142 | + SystemProgramError::CompressedSolPdaUndefinedForCompressSol => 6008, |
| 143 | + SystemProgramError::DecompressLamportsUndefinedForCompressSol => 6009, |
| 144 | + SystemProgramError::CompressedSolPdaUndefinedForDecompressSol => 6010, |
| 145 | + SystemProgramError::DeCompressLamportsUndefinedForDecompressSol => 6011, |
| 146 | + SystemProgramError::DecompressRecipientUndefinedForDecompressSol => 6012, |
| 147 | + SystemProgramError::WriteAccessCheckFailed => 6013, |
| 148 | + SystemProgramError::InvokingProgramNotProvided => 6014, |
| 149 | + SystemProgramError::InvalidCapacity => 6015, |
| 150 | + SystemProgramError::InvalidMerkleTreeOwner => 6016, |
| 151 | + SystemProgramError::ProofIsNone => 6017, |
| 152 | + SystemProgramError::ProofIsSome => 6018, |
| 153 | + SystemProgramError::EmptyInputs => 6019, |
| 154 | + SystemProgramError::CpiContextAccountUndefined => 6020, |
| 155 | + SystemProgramError::CpiContextEmpty => 6021, |
| 156 | + SystemProgramError::CpiContextMissing => 6022, |
| 157 | + SystemProgramError::DecompressionRecipientDefined => 6023, |
| 158 | + SystemProgramError::SolPoolPdaDefined => 6024, |
| 159 | + SystemProgramError::AppendStateFailed => 6025, |
| 160 | + SystemProgramError::InstructionNotCallable => 6026, |
| 161 | + SystemProgramError::CpiContextFeePayerMismatch => 6027, |
| 162 | + SystemProgramError::CpiContextAssociatedMerkleTreeMismatch => 6028, |
| 163 | + SystemProgramError::NoInputs => 6029, |
| 164 | + SystemProgramError::InputMerkleTreeIndicesNotInOrder => 6030, |
| 165 | + SystemProgramError::OutputMerkleTreeIndicesNotInOrder => 6031, |
| 166 | + SystemProgramError::OutputMerkleTreeNotUnique => 6032, |
| 167 | + SystemProgramError::DataFieldUndefined => 6033, |
| 168 | + SystemProgramError::ReadOnlyAddressAlreadyExists => 6034, |
| 169 | + SystemProgramError::ReadOnlyAccountDoesNotExist => 6035, |
| 170 | + SystemProgramError::HashChainInputsLenghtInconsistent => 6036, |
| 171 | + SystemProgramError::InvalidAddressTreeHeight => 6037, |
| 172 | + SystemProgramError::InvalidStateTreeHeight => 6038, |
| 173 | + SystemProgramError::InvalidArgument => 6039, |
| 174 | + SystemProgramError::InvalidAccount => 6040, |
| 175 | + SystemProgramError::AddressMerkleTreeAccountDiscriminatorMismatch => 6041, |
| 176 | + SystemProgramError::StateMerkleTreeAccountDiscriminatorMismatch => 6042, |
| 177 | + SystemProgramError::ProofVerificationFailed => 6043, |
| 178 | + SystemProgramError::InvalidAccountMode => 6044, |
| 179 | + SystemProgramError::InvalidInstructionDataDiscriminator => 6045, |
| 180 | + SystemProgramError::NewAddressAssignedIndexOutOfBounds => 6046, |
| 181 | + SystemProgramError::AddressIsNone => 6047, |
| 182 | + SystemProgramError::AddressDoesNotMatch => 6048, |
| 183 | + SystemProgramError::CpiContextAlreadySet => 6049, |
| 184 | + SystemProgramError::InvalidTreeHeight => 6050, |
| 185 | + SystemProgramError::TooManyOutputAccounts => 6051, |
| 186 | + SystemProgramError::BatchedMerkleTreeError(e) => e.into(), |
| 187 | + SystemProgramError::IndexedMerkleTreeError(e) => e.into(), |
| 188 | + SystemProgramError::ConcurrentMerkleTreeError(e) => e.into(), |
| 189 | + SystemProgramError::AccountError(e) => e.into(), |
| 190 | + SystemProgramError::ProgramError(e) => u32::try_from(e).unwrap_or(0), |
| 191 | + SystemProgramError::BorrowingDataFailed => 6052, |
| 192 | + SystemProgramError::ZeroCopyError(e) => e.into(), |
| 193 | + } |
| 194 | + } |
110 | 195 | } |
111 | 196 |
|
112 | 197 | impl From<SystemProgramError> for ProgramError { |
113 | 198 | fn from(e: SystemProgramError) -> ProgramError { |
114 | | - ProgramError::Custom(e as u32 + 6000) |
| 199 | + ProgramError::Custom(e.into()) |
115 | 200 | } |
116 | 201 | } |
0 commit comments