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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
use crate::proto;
#[derive(Debug, Copy, Clone, PartialEq)]
#[repr(u8)]
pub enum Status {
// the transaction passed the precheck
Ok = 0,
// For any error not handled by specific error codes listed below.
InvalidTransaction = 1,
// Payer account does not exist.
PayerAccountNotFound = 2,
// Node Account provided does not match the node account of the node the transaction was submitted to.
InvalidNodeAccount = 3,
// Pre-Check TransactionValidStart + transactionValidDuration is less than current consensus time.
TransactionExpired = 4,
// Transaction start time is greater than current consensus time
InvalidTransactionStart = 5,
// valid transaction duration is a positive non zero number that does not exceed 120 seconds
InvalidTransactionDuration = 6,
// the transaction signature is not valid
InvalidSignature = 7,
// Transaction memo size exceeded 100 bytes
MemoTooLong = 8,
// the transaction fee is insufficient for this type of transaction
InsufficientTxFee = 9,
// the payer account has insufficient cryptocurrency to pay the transaction fee
InsufficientPayerBalance = 10,
// This transaction ID is a duplicate of one that was submitted to this node or reached consensus in the last 180 seconds (receipt period).
DuplicateTransaction = 11,
// If API is throttled out
Busy = 12,
// not supported API
NotSupported = 13,
// the file id is invalid or does not exist
InvalidFileId = 14,
//the account id is invalid or does not exist
InvalidAccountId = 15,
//the contract id is invalid or does ont exist
InvalidContractId = 16,
//transaction id is not valid
InvalidTransactionId = 17,
//receipt for given transaction id does not exist
ReceiptNotFound = 18,
//record for given transaction id does not exist
RecordNotFound = 19,
//the solidity id is invalid or entity with this solidity id does not exist
InvalidSolidityId = 20,
// hasn't yet reached consensus, or has already expired
Unknown = 21,
// the transaction succeeded
Success = 22,
// the transaction failed because it is invalid
FailInvalid = 23,
// the transaction fee was insufficient
FailFee = 24,
// the paying account had insufficient cryptocurrency
FailBalance = 25,
// Key not provided in the transaction body
KeyRequired = 26,
// Unsupported algorithm/encoding used for keys in the transaction
BadEncoding = 27,
// When the account balance is not sufficient for the transfer
InsufficientAccountBalance = 28,
//During an update transaction when the system is not able to find the Users Solidity address
InvalidSolidityAddress = 29,
//Not enough gas was supplied to execute tranasction
InsufficientGas = 30,
//contract byte code size is over the limit
ContractSizeLimitExceeded = 31,
//local execution (query) is requested for a function which changes state
LocalCallModificationException = 32,
//Contract REVERT OPCODE executed
ContractRevertExecuted = 33,
//For any contract execution related error not handled by specific error codes listed above.
ContractExecutionException = 34,
//In Query validation, account with +ve(amount) value should be Receiving node account, the receiver account should be only one account in the list
InvalidReceivingNodeAccount = 35,
// Header is missing in Query request
MissingQueryHeader = 36,
// the update of the account failed
AccountUpdateFailed = 37,
InvalidKeyEncoding = 38,
// null solidity address
NullSolidityAddress = 39,
// update of the contract failed
ContractUpdateFailed = 40,
// the query header is invalid
InvalidQueryHeader = 41,
// Invalid fee submitted*/
InvalidFeeSubmitted = 42,
// payer signature is invalid
InvalidPayerSignature = 43,
KeyNotProvided = 44,
InvalidExpirationTime = 45,
NoWaclKey = 46,
FileContentEmpty = 47,
// The crypto transfer credit and debit don't equal to 0
InvalidAccountAmounts = 48,
// transaction body is empty
EmptyTransactionBody = 49,
// invalid transaction body
InvalidTransactionBody = 50,
}
impl From<proto::ResponseCode::ResponseCodeEnum> for Status {
fn from(code: proto::ResponseCode::ResponseCodeEnum) -> Self {
use self::proto::ResponseCode::ResponseCodeEnum::*;
match code {
OK => Status::Ok,
INVALID_TRANSACTION => Status::InvalidTransaction,
PAYER_ACCOUNT_NOT_FOUND => Status::PayerAccountNotFound,
INVALID_NODE_ACCOUNT => Status::InvalidNodeAccount,
TRANSACTION_EXPIRED => Status::TransactionExpired,
INVALID_TRANSACTION_START => Status::InvalidTransactionStart,
INVALID_TRANSACTION_DURATION => Status::InvalidTransactionDuration,
INVALID_SIGNATURE => Status::InvalidSignature,
MEMO_TOO_LONG => Status::MemoTooLong,
INSUFFICIENT_TX_FEE => Status::InsufficientTxFee,
INSUFFICIENT_PAYER_BALANCE => Status::InsufficientPayerBalance,
DUPLICATE_TRANSACTION => Status::DuplicateTransaction,
BUSY => Status::Busy,
NOT_SUPPORTED => Status::NotSupported,
INVALID_FILE_ID => Status::InvalidFileId,
INVALID_ACCOUNT_ID => Status::InvalidAccountId,
INVALID_CONTRACT_ID => Status::InvalidContractId,
INVALID_TRANSACTION_ID => Status::InvalidTransactionId,
RECEIPT_NOT_FOUND => Status::ReceiptNotFound,
RECORD_NOT_FOUND => Status::RecordNotFound,
INVALID_SOLIDITY_ID => Status::InvalidSolidityId,
UNKNOWN => Status::Unknown,
SUCCESS => Status::Success,
FAIL_INVALID => Status::FailInvalid,
FAIL_FEE => Status::FailFee,
FAIL_BALANCE => Status::FailBalance,
KEY_REQUIRED => Status::KeyRequired,
BAD_ENCODING => Status::BadEncoding,
INSUFFICIENT_ACCOUNT_BALANCE => Status::InsufficientAccountBalance,
INVALID_SOLIDITY_ADDRESS => Status::InvalidSolidityAddress,
INSUFFICIENT_GAS => Status::InsufficientGas,
CONTRACT_SIZE_LIMIT_EXCEEDED => Status::ContractSizeLimitExceeded,
LOCAL_CALL_MODIFICATION_EXCEPTION => Status::LocalCallModificationException,
CONTRACT_REVERT_EXECUTED => Status::ContractRevertExecuted,
CONTRACT_EXECUTION_EXCEPTION => Status::ContractExecutionException,
INVALID_RECEIVING_NODE_ACCOUNT => Status::InvalidReceivingNodeAccount,
MISSING_QUERY_HEADER => Status::MissingQueryHeader,
ACCOUNT_UPDATE_FAILED => Status::AccountUpdateFailed,
INVALID_KEY_ENCODING => Status::InvalidKeyEncoding,
NULL_SOLIDITY_ADDRESS => Status::NullSolidityAddress,
CONTRACT_UPDATE_FAILED => Status::ContractUpdateFailed,
INVALID_QUERY_HEADER => Status::InvalidQueryHeader,
INVALID_FEE_SUBMITTED => Status::InvalidFeeSubmitted,
INVALID_PAYER_SIGNATURE => Status::InvalidPayerSignature,
KEY_NOT_PROVIDED => Status::KeyNotProvided,
INVALID_EXPIRATION_TIME => Status::InvalidExpirationTime,
NO_WACL_KEY => Status::NoWaclKey,
FILE_CONTENT_EMPTY => Status::FileContentEmpty,
INVALID_ACCOUNT_AMOUNTS => Status::InvalidAccountAmounts,
EMPTY_TRANSACTION_BODY => Status::EmptyTransactionBody,
INVALID_TRANSACTION_BODY => Status::InvalidTransactionBody,
}
}
}