-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy patherror.rs
125 lines (120 loc) · 4.22 KB
/
error.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
// Copyright 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
//! Error handling for transaction builder.
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,
};
/// Errors related to transaction builder.
#[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),
/// Can't burn and transition an output at the same time.
#[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),
/// Insufficient amount provided.
#[error("insufficient amount: found {found}, required {required}")]
InsufficientAmount {
/// The amount found.
found: u64,
/// The required amount.
required: u64,
},
/// Insufficient mana provided.
#[error("insufficient mana: found {found}, required {required}")]
InsufficientMana {
/// The amount found.
found: u64,
/// The required amount.
required: u64,
},
/// Insufficient native token amount provided.
#[error("insufficient native token amount: found {found}, required {required}")]
InsufficientNativeTokenAmount {
/// The token ID.
token_id: TokenId,
/// The amount found.
found: U256,
/// The required amount.
required: U256,
},
/// Invalid amount of inputs.
#[error("invalid amount of inputs: {0}")]
InvalidInputCount(usize),
/// Invalid amount of outputs.
#[error("invalid amount of outputs: {0}")]
InvalidOutputCount(usize),
/// No input with matching ed25519 address provided.
#[error("no input with matching ed25519 address provided")]
MissingInputWithEd25519Address,
/// No available inputs were provided to transaction builder.
#[error("no available inputs provided")]
NoAvailableInputsProvided,
#[error("account {0} is not staking")]
NotStaking(AccountId),
/// Required input is not available.
#[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),
/// Unfulfillable requirement.
#[error("unfulfillable requirement {0:?}")]
UnfulfillableRequirement(Requirement),
/// Unsupported address type.
#[error("unsupported address type {0}")]
// TODO replace with string when 2.0 has Address::kind_str
UnsupportedAddressType(u8),
/// Block error.
#[error("{0}")]
Block(#[from] BlockError),
/// Output errors.
#[error("{0}")]
Output(#[from] OutputError),
/// Payload errors.
#[error("{0}")]
Payload(#[from] PayloadError),
/// Signature errors.
#[error("{0}")]
Signature(#[from] SignatureError),
/// Mana errors.
#[error("{0}")]
Mana(#[from] ManaError),
/// Native token errors.
#[error("{0}")]
NativeToken(#[from] NativeTokenError),
/// Context input errors.
#[error("{0}")]
ContextInput(#[from] ContextInputError),
/// Unlock errors.
#[error("{0}")]
Unlock(#[from] UnlockError),
/// Feature errors.
#[error("{0}")]
Feature(#[from] FeatureError),
/// Semantic errors.
#[error("{0}")]
Semantic(#[from] TransactionFailureReason),
}