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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
use failure::Fail;
use alloc::vec::Vec;
use core::result;
use crate::{
bytesrepr::{self, ToBytes, U8_SERIALIZED_LENGTH},
CLType, CLTyped,
};
#[derive(Fail, Debug, Copy, Clone, PartialEq, Eq)]
#[repr(u8)]
pub enum Error {
#[fail(display = "Not bonded")]
NotBonded = 0,
#[fail(display = "Too many events in queue")]
TooManyEventsInQueue,
#[fail(display = "Cannot unbond last validator")]
CannotUnbondLastValidator,
#[fail(display = "Spread is too high")]
SpreadTooHigh,
#[fail(display = "Multiple requests")]
MultipleRequests,
#[fail(display = "Bond is too small")]
BondTooSmall,
#[fail(display = "Bond is too large")]
BondTooLarge,
#[fail(display = "Unbond is too large")]
UnbondTooLarge,
#[fail(display = "Bond transfer failed")]
BondTransferFailed,
#[fail(display = "Unbond transfer failed")]
UnbondTransferFailed,
#[fail(display = "Time went backwards")]
TimeWentBackwards,
#[fail(display = "Stakes not found")]
StakesNotFound,
#[fail(display = "Payment purse not found")]
PaymentPurseNotFound,
#[fail(display = "Payment purse has unexpected type")]
PaymentPurseKeyUnexpectedType,
#[fail(display = "Payment purse balance not found")]
PaymentPurseBalanceNotFound,
#[fail(display = "Bonding purse not found")]
BondingPurseNotFound,
#[fail(display = "Bonding purse key has unexpected type")]
BondingPurseKeyUnexpectedType,
#[fail(display = "Refund purse key has unexpected type")]
RefundPurseKeyUnexpectedType,
#[fail(display = "Rewards purse not found")]
RewardsPurseNotFound,
#[fail(display = "Rewards purse has unexpected type")]
RewardsPurseKeyUnexpectedType,
#[fail(display = "Failed to deserialize stake's key")]
StakesKeyDeserializationFailed,
#[fail(display = "Failed to deserialize stake's balance")]
StakesDeserializationFailed,
#[fail(display = "System function was called by user account")]
SystemFunctionCalledByUserAccount,
#[fail(display = "Insufficient payment for amount spent")]
InsufficientPaymentForAmountSpent,
#[fail(display = "Transfer to rewards purse has failed")]
FailedTransferToRewardsPurse,
#[fail(display = "Transfer to account's purse failed")]
FailedTransferToAccountPurse,
#[fail(display = "Set refund purse was called outside payment")]
SetRefundPurseCalledOutsidePayment,
#[fail(display = "Unable to get purse balance")]
GetBalance,
#[fail(display = "Unable to put named key")]
PutKey,
#[fail(display = "Unable to remove named key")]
RemoveKey,
#[fail(display = "Failed to transfer funds")]
Transfer,
#[doc(hidden)]
#[fail(display = "GasLimit")]
GasLimit,
}
impl CLTyped for Error {
fn cl_type() -> CLType {
CLType::U8
}
}
impl ToBytes for Error {
fn to_bytes(&self) -> result::Result<Vec<u8>, bytesrepr::Error> {
let value = *self as u8;
value.to_bytes()
}
fn serialized_length(&self) -> usize {
U8_SERIALIZED_LENGTH
}
}
pub type Result<T> = result::Result<T, Error>;