solana_extra_wasm/program/spl_token_2022/
error.rs1use {
4 num_derive::FromPrimitive,
5 solana_sdk::{decode_error::DecodeError, program_error::ProgramError},
6 thiserror::Error,
7};
8
9#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)]
11pub enum TokenError {
12 #[error("Lamport balance below rent-exempt threshold")]
15 NotRentExempt,
16 #[error("Insufficient funds")]
18 InsufficientFunds,
19 #[error("Invalid Mint")]
21 InvalidMint,
22 #[error("Account not associated with this Mint")]
24 MintMismatch,
25 #[error("Owner does not match")]
27 OwnerMismatch,
28
29 #[error("Fixed supply")]
32 FixedSupply,
33 #[error("Already in use")]
35 AlreadyInUse,
36 #[error("Invalid number of provided signers")]
38 InvalidNumberOfProvidedSigners,
39 #[error("Invalid number of required signers")]
41 InvalidNumberOfRequiredSigners,
42 #[error("State is unititialized")]
44 UninitializedState,
45
46 #[error("Instruction does not support native tokens")]
49 NativeNotSupported,
50 #[error("Non-native account can only be closed if its balance is zero")]
52 NonNativeHasBalance,
53 #[error("Invalid instruction")]
55 InvalidInstruction,
56 #[error("State is invalid for requested operation")]
58 InvalidState,
59 #[error("Operation overflowed")]
61 Overflow,
62
63 #[error("Account does not support specified authority type")]
66 AuthorityTypeNotSupported,
67 #[error("This token mint cannot freeze accounts")]
69 MintCannotFreeze,
70 #[error("Account is frozen")]
72 AccountFrozen,
73 #[error("The provided decimals value different from the Mint decimals")]
75 MintDecimalsMismatch,
76 #[error("Instruction does not support non-native tokens")]
78 NonNativeNotSupported,
79
80 #[error("Extension type does not match already existing extensions")]
83 ExtensionTypeMismatch,
84 #[error("Extension does not match the base type provided")]
86 ExtensionBaseMismatch,
87 #[error("Extension already initialized on this account")]
89 ExtensionAlreadyInitialized,
90 #[error("An account can only be closed if its confidential balance is zero")]
92 ConfidentialTransferAccountHasBalance,
93 #[error("Account not approved for confidential transfers")]
95 ConfidentialTransferAccountNotApproved,
96
97 #[error("Account not accepting deposits or transfers")]
100 ConfidentialTransferDepositsAndTransfersDisabled,
101 #[error("ElGamal public key mismatch")]
103 ConfidentialTransferElGamalPubkeyMismatch,
104 #[error("Balance mismatch")]
106 ConfidentialTransferBalanceMismatch,
107 #[error("Mint has non-zero supply. Burn all tokens before closing the mint")]
109 MintHasSupply,
110 #[error("No authority exists to perform the desired operation")]
112 NoAuthorityExists,
113
114 #[error("Transfer fee exceeds maximum of 10,000 basis points")]
117 TransferFeeExceedsMaximum,
118 #[error("Mint required for this account to transfer tokens, use `transfer_checked` or `transfer_checked_with_fee`")]
120 MintRequiredForTransfer,
121 #[error("Calculated fee does not match expected fee")]
123 FeeMismatch,
124 #[error(
126 "Fee parameters associated with zero-knowledge proofs do not match fee parameters in mint"
127 )]
128 FeeParametersMismatch,
129 #[error("The owner authority cannot be changed")]
131 ImmutableOwner,
132
133 #[error("An account can only be closed if its withheld fee balance is zero, harvest fees to the mint and try again")]
137 AccountHasWithheldTransferFees,
138
139 #[error("No memo in previous instruction; required for recipient to receive a transfer")]
141 NoMemo,
142 #[error("Transfer is disabled for this mint")]
144 NonTransferable,
145 #[error("Non-transferable tokens can't be minted to an account without immutable ownership")]
147 NonTransferableNeedsImmutableOwnership,
148 #[error(
151 "The total number of `Deposit` and `Transfer` instructions to an account cannot exceed
152 the associated `maximum_pending_balance_credit_counter`"
153 )]
154 MaximumPendingBalanceCreditCounterExceeded,
155}
156impl From<TokenError> for ProgramError {
157 fn from(e: TokenError) -> Self {
158 ProgramError::Custom(e as u32)
159 }
160}
161impl<T> DecodeError<T> for TokenError {
162 fn type_of() -> &'static str {
163 "TokenError"
164 }
165}