This repository has been archived by the owner on Jul 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 80
/
tx_error.rs
92 lines (85 loc) · 2.86 KB
/
tx_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
use chain_core::init::coin::{Coin, CoinError};
use mls::extras::{self};
#[derive(thiserror::Error, Debug)]
pub enum TxError {
#[error("deserialize TxAux failed: {0}")]
DeserializeTx(#[from] parity_scale_codec::Error),
#[error("enclave tx validation failed: {0}")]
Enclave(#[from] chain_tx_validation::Error),
#[error("public tx process failed: {0}")]
Public(#[from] PublicTxError),
#[error("FIXME/WIP payload for MLS handshake (not yet supported)")]
WIPMLSData,
}
#[derive(thiserror::Error, Debug)]
pub enum PublicTxError {
#[error("public tx wrong chain_hex_id")]
WrongChainHexId,
#[error("public tx unsupported version")]
UnsupportedVersion,
#[error("verify staking witness failed: {0}")]
StakingWitnessVerify(#[from] secp256k1::Error),
#[error("staking witness and address don't match")]
StakingWitnessNotMatch,
#[error("tx nonce don't match staking state")]
IncorrectNonce,
#[error("unjail tx process failed: {0}")]
Unjail(#[from] UnjailError),
#[error("node join tx process failed: {0}")]
NodeJoin(#[from] NodeJoinError),
#[error("unbond tx process failed: {0}")]
Unbond(#[from] UnbondError),
}
#[derive(thiserror::Error, Debug)]
pub enum UnjailError {
#[error("the staking address is not jailed")]
NotJailed,
#[error("the jail duration is not reached yet")]
JailTimeNotExpired,
}
#[derive(thiserror::Error, Debug)]
pub enum NodeJoinError {
#[error("bonded coins not enough to become validator")]
BondedNotEnough,
#[error("validator address already exists")]
DuplicateValidatorAddress,
#[error("the staking address is already active")]
AlreadyJoined,
#[error("the staking address is jailed")]
IsJailed,
#[error("the used_validator_addresses queue is full")]
UsedValidatorAddrFull,
#[error("failed to decode Add proposal and Commit message")]
InvalidMLSInitData,
#[error("invalid mls init data: {0}")]
MLSInitVerifyError(#[from] extras::NodeJoinError),
#[error("FIXME: WIP -- community node not yet supported")]
WIPNotValidator,
}
#[derive(thiserror::Error, Debug)]
pub enum WithdrawError {
#[error("unbonded amount {0} not equal to desired amount: {0}")]
UnbondedSanityCheck(Coin, Coin),
#[error("still in unbonding period")]
InUnbondingPeriod,
#[error("the staking address is jailed")]
IsJailed,
}
#[derive(thiserror::Error, Debug)]
pub enum UnbondError {
#[error("nonce value don't match")]
NonceNotMatch,
#[error("coin error in unbond tx: {0}")]
CoinError(#[from] CoinError),
#[error("the staking address is jailed")]
IsJailed,
#[error("the value of tx is zero")]
ZeroValue,
}
#[derive(thiserror::Error, Debug)]
pub enum DepositError {
#[error("coin error in deposit tx: {0}")]
CoinError(#[from] CoinError),
#[error("the staking address is jailed")]
IsJailed,
}