use solana_pubkey::Pubkey;
#[derive(thiserror::Error, Debug)]
#[non_exhaustive]
pub enum TokenError {
#[error("RPC call failed: {0}")]
Rpc(#[from] solana_client::client_error::ClientError),
#[error("mint account not found: {0}")]
MintNotFound(Pubkey),
#[error("mint account decode failed: {mint}: {reason}")]
MintDecodeFailed {
mint: Pubkey,
reason: String,
},
#[error("token account decode failed: {token_account}: {reason}")]
TokenAccountDecodeFailed {
token_account: Pubkey,
reason: String,
},
#[error("mints/mint_accounts length mismatch: {mints} vs {mint_accounts}")]
LengthMismatch {
mints: usize,
mint_accounts: usize,
},
#[error("transfer hook detected on mint {mint} (program: {program})")]
TransferHookDetected {
mint: Pubkey,
program: Pubkey,
},
#[error("WithBalance intent on non-SOL mint {0} is not supported")]
WithBalanceNotSupported(Pubkey),
#[error(
"WithBalance intent for native SOL requires WrapSolStrategy::Ata or Keypair, not None"
)]
IncoherentWrapStrategy,
#[error("instruction build failed: {0}")]
InstructionBuild(String),
#[error("token balance insufficient on mint {mint}: required {required}, actual {actual}")]
InsufficientBalance {
mint: Pubkey,
required: u64,
actual: u64,
},
#[error("RequireTokenBalance intent on SOL/wSOL mint {0} is not supported (use WithBalance)")]
RequireBalanceForSolNotSupported(Pubkey),
}