use std::fmt::Debug;
use primitive_types::U256;
use super::Requirement;
use crate::types::block::{
context_input::ContextInputError,
mana::ManaError,
output::{feature::FeatureError, AccountId, ChainId, NativeTokenError, OutputError, OutputId, TokenId},
payload::PayloadError,
semantic::TransactionFailureReason,
signature::SignatureError,
slot::EpochIndex,
unlock::UnlockError,
BlockError,
};
#[derive(Debug, Eq, PartialEq, thiserror::Error)]
#[non_exhaustive]
pub enum TransactionBuilderError {
#[error("additional inputs required for {0:?}, but additional input selection is disabled")]
AdditionalInputsRequired(Requirement),
#[error("account {0} is already staking")]
AlreadyStaking(AccountId),
#[error("can't burn and transition an output at the same time, chain ID: {0}")]
BurnAndTransition(ChainId),
#[error("account {account_id} cannot end staking until {end_epoch}")]
CannotEndStaking {
account_id: AccountId,
end_epoch: EpochIndex,
},
#[error("mana rewards provided without an associated burn or custom input, output ID: {0}")]
ExtraManaRewards(OutputId),
#[error("insufficient amount: found {found}, required {required}")]
InsufficientAmount {
found: u64,
required: u64,
},
#[error(
"insufficient mana: found {found}, required {required}, slots remaining until enough mana {slots_remaining}"
)]
InsufficientMana {
found: u64,
required: u64,
slots_remaining: u32,
},
#[error("insufficient native token amount: found {found}, required {required}")]
InsufficientNativeTokenAmount {
token_id: TokenId,
found: U256,
required: U256,
},
#[error("invalid amount of inputs: {0}")]
InvalidInputCount(usize),
#[error("invalid amount of outputs: {0}")]
InvalidOutputCount(usize),
#[error("no input with matching ed25519 address provided")]
MissingInputWithEd25519Address,
#[error("no available inputs provided")]
NoAvailableInputsProvided,
#[error("account {0} is not staking")]
NotStaking(AccountId),
#[error("account {0} has no block issuer feature")]
MissingBlockIssuerFeature(AccountId),
#[error("required input {0} is not available")]
RequiredInputIsNotAvailable(OutputId),
#[error("new staking period {additional_epochs} is less than the minimum {min}")]
StakingPeriodLessThanMin { additional_epochs: u32, min: u32 },
#[error("cannot transition non-implicit-account output {0}")]
TransitionNonImplicitAccount(OutputId),
#[error("unfulfillable requirement {0:?}")]
UnfulfillableRequirement(Requirement),
#[error("unsupported address type {0}")]
UnsupportedAddressType(String),
#[error("{0}")]
Block(#[from] BlockError),
#[error("{0}")]
Output(#[from] OutputError),
#[error("{0}")]
Payload(#[from] PayloadError),
#[error("{0}")]
Signature(#[from] SignatureError),
#[error("{0}")]
Mana(#[from] ManaError),
#[error("{0}")]
NativeToken(#[from] NativeTokenError),
#[error("{0}")]
ContextInput(#[from] ContextInputError),
#[error("{0}")]
Unlock(#[from] UnlockError),
#[error("{0}")]
Feature(#[from] FeatureError),
#[error("{0}")]
Semantic(#[from] TransactionFailureReason),
}