use core::fmt;
use crate::UtxoId;
use fuel_types::{AssetId, ContractId, MessageId};
#[cfg(feature = "std")]
use std::{error, io};
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[non_exhaustive]
pub enum CheckError {
InputWitnessIndexBounds {
index: usize,
},
InputPredicateEmpty {
index: usize,
},
InputPredicateLength {
index: usize,
},
InputPredicateDataLength {
index: usize,
},
InputPredicateOwner {
index: usize,
},
InputInvalidSignature {
index: usize,
},
InputContractAssociatedOutputContract {
index: usize,
},
InputMessageDataLength {
index: usize,
},
DuplicateInputUtxoId {
utxo_id: UtxoId,
},
DuplicateMessageInputId {
message_id: MessageId,
},
DuplicateInputContractId {
contract_id: ContractId,
},
OutputContractInputIndex {
index: usize,
},
TransactionCreateInputContract {
index: usize,
},
TransactionCreateMessageData {
index: usize,
},
TransactionCreateOutputContract {
index: usize,
},
TransactionCreateOutputVariable {
index: usize,
},
TransactionCreateOutputChangeNotBaseAsset {
index: usize,
},
TransactionCreateOutputContractCreatedMultiple {
index: usize,
},
TransactionCreateBytecodeLen,
TransactionCreateBytecodeWitnessIndex,
TransactionCreateStorageSlotMax,
TransactionCreateStorageSlotOrder,
TransactionScriptLength,
TransactionScriptDataLength,
TransactionScriptOutputContractCreated {
index: usize,
},
TransactionMintOutputIsNotCoin,
TransactionMintIncorrectBlockHeight,
TransactionGasLimit,
TransactionMaturity,
TransactionInputsMax,
TransactionOutputsMax,
TransactionWitnessesMax,
TransactionOutputCoinAssetIdDuplicated(AssetId),
TransactionOutputChangeAssetIdDuplicated(AssetId),
TransactionOutputChangeAssetIdNotFound(AssetId),
TransactionOutputCoinAssetIdNotFound(AssetId),
InsufficientFeeAmount {
expected: u64,
provided: u64,
},
InsufficientInputAmount {
asset: AssetId,
expected: u64,
provided: u64,
},
ArithmeticOverflow,
PredicateVerificationFailed,
PredicateExhaustedGas,
}
impl fmt::Display for CheckError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{self:?}")
}
}
#[cfg(feature = "std")]
impl error::Error for CheckError {
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
None
}
}
#[cfg(feature = "std")]
impl From<CheckError> for io::Error {
fn from(v: CheckError) -> io::Error {
io::Error::new(io::ErrorKind::Other, v)
}
}