1use crate::consensus::signature::SignatureError;
2use crate::consensus::state::data_trigger::DataTriggerError;
3use crate::data_contract::errors::DataContractError;
4
5use crate::errors::consensus::{
6 basic::BasicError, fee::fee_error::FeeError, state::state_error::StateError, ConsensusError,
7};
8
9pub trait ErrorWithCode {
10 fn code(&self) -> u32;
12}
13
14impl ErrorWithCode for ConsensusError {
15 fn code(&self) -> u32 {
16 match self {
17 Self::BasicError(e) => e.code(),
18 Self::SignatureError(e) => e.code(),
19 Self::StateError(e) => e.code(),
20 Self::FeeError(e) => e.code(),
21
22 #[cfg(test)]
23 ConsensusError::TestConsensusError(_) => 1000,
24 ConsensusError::DefaultError => 1, }
26 }
27}
28impl ErrorWithCode for BasicError {
29 fn code(&self) -> u32 {
30 match self {
31 Self::UnsupportedVersionError(_) => 10000,
33 Self::ProtocolVersionParsingError { .. } => 10001,
34 Self::SerializedObjectParsingError { .. } => 10002,
35 Self::UnsupportedProtocolVersionError(_) => 10003,
36 Self::IncompatibleProtocolVersionError(_) => 10004,
37 Self::VersionError(_) => 10005,
38 Self::UnsupportedFeatureError(_) => 10006,
39
40 Self::JsonSchemaCompilationError(..) => 10100,
42 Self::JsonSchemaError(_) => 10101,
43 Self::InvalidIdentifierError { .. } => 10102,
44 Self::ValueError(_) => 10103,
45
46 Self::DataContractMaxDepthExceedError { .. } => 10200,
48 Self::DuplicateIndexError { .. } => 10201,
49 Self::IncompatibleRe2PatternError { .. } => 10202,
50 Self::InvalidCompoundIndexError { .. } => 10203,
51 Self::InvalidDataContractIdError { .. } => 10204,
52 Self::InvalidIndexedPropertyConstraintError { .. } => 10205,
53 Self::InvalidIndexPropertyTypeError { .. } => 10206,
54 Self::InvalidJsonSchemaRefError { .. } => 10207,
55 Self::SystemPropertyIndexAlreadyPresentError { .. } => 10208,
56 Self::UndefinedIndexPropertyError { .. } => 10209,
57 Self::UniqueIndicesLimitReachedError { .. } => 10210,
58 Self::DuplicateIndexNameError { .. } => 10211,
59 Self::InvalidDataContractVersionError { .. } => 10212,
60 Self::IncompatibleDataContractSchemaError { .. } => 10213,
61 Self::ContractError(DataContractError::DocumentTypesAreMissingError { .. }) => 10214,
62 Self::DataContractImmutablePropertiesUpdateError { .. } => 10215,
63 Self::DataContractUniqueIndicesChangedError { .. } => 10216,
64 Self::DataContractInvalidIndexDefinitionUpdateError { .. } => 10217,
65 Self::DataContractHaveNewUniqueIndexError { .. } => 10218,
66 Self::InvalidDocumentTypeRequiredSecurityLevelError { .. } => 10219,
67 Self::UnknownSecurityLevelError { .. } => 10220,
68 Self::UnknownStorageKeyRequirementsError { .. } => 10221,
69 Self::ContractError(DataContractError::DecodingContractError { .. }) => 10222,
70 Self::ContractError(DataContractError::DecodingDocumentError { .. }) => 10223,
71 Self::ContractError(DataContractError::InvalidDocumentTypeError { .. }) => 10224,
72 Self::ContractError(DataContractError::MissingRequiredKey(_)) => 10225,
73 Self::ContractError(DataContractError::FieldRequirementUnmet(_)) => 10226,
74 Self::ContractError(DataContractError::KeyWrongType(_)) => 10227,
75 Self::ContractError(DataContractError::ValueWrongType(_)) => 10228,
76 Self::ContractError(DataContractError::ValueDecodingError(_)) => 10229,
77 Self::ContractError(DataContractError::EncodingDataStructureNotSupported(_)) => 10230,
78 Self::ContractError(DataContractError::InvalidContractStructure(_)) => 10231,
79 Self::ContractError(DataContractError::DocumentTypeNotFound(_)) => 10232,
80 Self::ContractError(DataContractError::DocumentTypeFieldNotFound(_)) => 10233,
81 Self::ContractError(DataContractError::ReferenceDefinitionNotFound(_)) => 10234,
82 Self::ContractError(DataContractError::DocumentOwnerIdMissing(_)) => 10235,
83 Self::ContractError(DataContractError::DocumentIdMissing(_)) => 10236,
84 Self::ContractError(DataContractError::Unsupported(_)) => 10237,
85 Self::ContractError(DataContractError::CorruptedSerialization(_)) => 10238,
86 Self::ContractError(DataContractError::JsonSchema(_)) => 10239,
87 Self::ContractError(DataContractError::InvalidURI(_)) => 10240,
88 Self::ContractError(DataContractError::KeyWrongBounds(_)) => 10241,
89 Self::ContractError(DataContractError::KeyValueMustExist(_)) => 10242,
90 Self::UnknownTransferableTypeError { .. } => 10243,
91 Self::UnknownTradeModeError { .. } => 10244,
92 Self::UnknownDocumentCreationRestrictionModeError { .. } => 10245,
93 Self::IncompatibleDocumentTypeSchemaError { .. } => 10246,
94 Self::ContractError(DataContractError::RegexError(_)) => 10247,
95 Self::ContestedUniqueIndexOnMutableDocumentTypeError(_) => 10248,
96 Self::ContestedUniqueIndexWithUniqueIndexError(_) => 10249,
97 Self::DataContractTokenConfigurationUpdateError { .. } => 10250,
98 Self::InvalidTokenBaseSupplyError(_) => 10251,
99 Self::NonContiguousContractGroupPositionsError(_) => 10252,
100 Self::NonContiguousContractTokenPositionsError(_) => 10253,
101 Self::InvalidTokenDistributionFunctionDivideByZeroError(_) => 10254,
102 Self::InvalidTokenDistributionFunctionInvalidParameterError(_) => 10255,
103 Self::InvalidTokenDistributionFunctionInvalidParameterTupleError(_) => 10256,
104 Self::InvalidTokenDistributionFunctionIncoherenceError(_) => 10257,
105 Self::MissingDefaultLocalizationError(_) => 10258,
106 Self::UnknownGasFeesPaidByError(_) => 10259,
107 Self::UnknownDocumentActionTokenEffectError(_) => 10260,
108 Self::TokenPaymentByBurningOnlyAllowedOnInternalTokenError(_) => 10261,
109 Self::TooManyKeywordsError(_) => 10262,
110 Self::DuplicateKeywordsError(_) => 10263,
111 Self::InvalidDescriptionLengthError(_) => 10264,
112 Self::NewTokensDestinationIdentityOptionRequiredError(_) => 10265,
113 Self::InvalidTokenNameCharacterError(_) => 10266,
114 Self::InvalidTokenNameLengthError(_) => 10267,
115 Self::InvalidTokenLanguageCodeError(_) => 10268,
116 Self::InvalidKeywordCharacterError(_) => 10269,
117 Self::InvalidKeywordLengthError(_) => 10270,
118 Self::DecimalsOverLimitError(_) => 10271,
119 Self::InvalidTokenDistributionBlockIntervalTooShortError(_) => 10272,
120 Self::InvalidTokenDistributionTimeIntervalTooShortError(_) => 10273,
121 Self::InvalidTokenDistributionTimeIntervalNotMinuteAlignedError(_) => 10274,
122 Self::RedundantDocumentPaidForByTokenWithContractId(_) => 10275,
123 Self::DataContractInvalidRequiredFieldsUpdateError { .. } => 10276,
124 Self::PreProgrammedDistributionAmountOverLimitError(_) => 10277,
125 Self::TokenShieldedPoolIncompatibleRulesError(_) => 10278,
126 Self::NonTransferableTokenShieldedPoolError(_) => 10279,
127 Self::NonTransferableTokenPaymentMustBurnError(_) => 10280,
128
129 Self::GroupPositionDoesNotExistError(_) => 10350,
131 Self::GroupActionNotAllowedOnTransitionError(_) => 10351,
132 Self::GroupTotalPowerLessThanRequiredError(_) => 10352,
133 Self::GroupNonUnilateralMemberPowerHasLessThanRequiredPowerError(_) => 10353,
134 Self::GroupExceedsMaxMembersError(_) => 10354,
135 Self::GroupMemberHasPowerOfZeroError(_) => 10355,
136 Self::GroupMemberHasPowerOverLimitError(_) => 10356,
137 Self::MainGroupIsNotDefinedError(_) => 10357,
138 Self::GroupRequiredPowerIsInvalidError(_) => 10358,
139 Self::GroupHasTooFewMembersError(_) => 10359,
140
141 Self::ContractGroupMembershipsOverLimitError(_) => 10360,
143 Self::DuplicateContractGroupMembershipError(_) => 10361,
144 Self::RedundantContractGroupMembershipError(_) => 10362,
145 Self::ContractGroupMemberNotInContractError(_) => 10363,
146 Self::InvalidContractGroupAdminsError(_) => 10364,
147 Self::InvalidContractGroupNameLengthError(_) => 10366,
150 Self::InvalidContractGroupDescriptionLengthError(_) => 10367,
151
152 Self::DataContractNotPresentError { .. } => 10400,
154 Self::DuplicateDocumentTransitionsWithIdsError { .. } => 10401,
155 Self::DuplicateDocumentTransitionsWithIndicesError { .. } => 10402,
156 Self::InconsistentCompoundIndexDataError { .. } => 10403,
157 Self::InvalidDocumentTransitionActionError { .. } => 10404,
158 Self::InvalidDocumentTransitionIdError { .. } => 10405,
159 Self::InvalidDocumentTypeError { .. } => 10406,
160 Self::MissingDataContractIdBasicError { .. } => 10407,
161 Self::MissingDocumentTransitionActionError { .. } => 10408,
162 Self::MissingDocumentTransitionTypeError { .. } => 10409,
163 Self::MissingDocumentTypeError { .. } => 10410,
164 Self::MissingPositionsInDocumentTypePropertiesError { .. } => 10411,
165 Self::MaxDocumentsTransitionsExceededError { .. } => 10412,
166 Self::DocumentTransitionsAreAbsentError { .. } => 10413,
167 Self::NonceOutOfBoundsError(_) => 10414,
168 Self::InvalidDocumentTypeNameError(_) => 10415,
169 Self::DocumentCreationNotAllowedError(_) => 10416,
170 Self::DocumentFieldMaxSizeExceededError(_) => 10417,
171 Self::ContestedDocumentsTemporarilyNotAllowedError(_) => 10418,
172 Self::DocumentPropertyNotDistinctError(_) => 10419,
173 Self::InvalidEncryptedPropertyShapeError(_) => 10420,
174 Self::DocumentPropertyMaxBytesExceededError(_) => 10421,
175 Self::DocumentPropertyConstraintViolatedError(_) => 10422,
176 Self::DocumentReferencePreimageInvalidError(_) => 10423,
177 Self::DocumentPropertyNotGeneratedError(_) => 10424,
178
179 Self::InvalidTokenIdError(_) => 10450,
181 Self::InvalidTokenPositionError(_) => 10451,
182 Self::InvalidActionIdError(_) => 10452,
183 Self::ContractHasNoTokensError(_) => 10453,
184 Self::DestinationIdentityForTokenMintingNotSetError(_) => 10454,
185 Self::ChoosingTokenMintRecipientNotAllowedError(_) => 10455,
186 Self::TokenTransferToOurselfError(_) => 10456,
187 Self::InvalidTokenConfigUpdateNoChangeError(_) => 10457,
188 Self::InvalidTokenAmountError(_) => 10458,
189 Self::InvalidTokenNoteTooBigError(_) => 10459,
190 Self::TokenNoteOnlyAllowedWhenProposerError(_) => 10460,
191 Self::TokenPricingScheduleEmptyError(_) => 10461,
192
193 Self::DuplicatedIdentityPublicKeyBasicError(_) => 10500,
195 Self::DuplicatedIdentityPublicKeyIdBasicError(_) => 10501,
196 Self::IdentityAssetLockProofLockedTransactionMismatchError(_) => 10502,
197 Self::IdentityAssetLockTransactionIsNotFoundError(_) => 10503,
198 Self::IdentityAssetLockTransactionOutPointAlreadyConsumedError(_) => 10504,
199 Self::IdentityAssetLockTransactionOutputNotFoundError(_) => 10505,
200 Self::InvalidAssetLockProofCoreChainHeightError(_) => 10506,
201 Self::InvalidAssetLockProofTransactionHeightError(_) => 10507,
202 Self::InvalidAssetLockTransactionOutputReturnSizeError(_) => 10508,
203 Self::InvalidIdentityAssetLockTransactionError(_) => 10509,
204 Self::InvalidIdentityAssetLockTransactionOutputError(_) => 10510,
205 Self::InvalidIdentityPublicKeyDataError(_) => 10511,
206 Self::InvalidInstantAssetLockProofError(_) => 10512,
207 Self::InvalidInstantAssetLockProofSignatureError(_) => 10513,
208 Self::InvalidIdentityAssetLockProofChainLockValidationError(_) => 10514,
209 Self::DataContractBoundsNotPresentError(_) => 10515,
210 Self::DisablingKeyIdAlsoBeingAddedInSameTransitionError(_) => 10516,
211 Self::MissingMasterPublicKeyError(_) => 10517,
212 Self::TooManyMasterPublicKeyError(_) => 10518,
213 Self::InvalidIdentityPublicKeySecurityLevelError(_) => 10519,
214 Self::InvalidIdentityKeySignatureError { .. } => 10520,
215 Self::InvalidCreditWithdrawalTransitionOutputScriptError(_) => 10521,
216 Self::InvalidCreditWithdrawalTransitionCoreFeeError(_) => 10522,
217 Self::NotImplementedCreditWithdrawalTransitionPoolingError(_) => 10523,
218 Self::InvalidIdentityCreditTransferAmountError(_) => 10524,
219 Self::InvalidIdentityCreditWithdrawalTransitionAmountError(_) => 10525,
220 Self::InvalidIdentityUpdateTransitionEmptyError(_) => 10526,
221 Self::InvalidIdentityUpdateTransitionDisableKeysError(_) => 10527,
222 Self::IdentityCreditTransferToSelfError(_) => 10528,
223 Self::MasterPublicKeyUpdateError(_) => 10529,
224 Self::IdentityAssetLockTransactionOutPointNotEnoughBalanceError(_) => 10530,
225 Self::IdentityAssetLockStateTransitionReplayError(_) => 10531,
226 Self::WithdrawalOutputScriptNotAllowedWhenSigningWithOwnerKeyError(_) => 10532,
227 Self::InvalidKeyPurposeForContractBoundsError(_) => 10533,
228 Self::IdentityAssetLockTransactionTooManyInputsError(_) => 10534,
229 Self::ContractGroupBoundKeyNotAllowedInShieldedIdentityCreationError(_) => 10535,
230 Self::IdentityPublicKeyLimitsNotAllowedError(_) => 10536,
231 Self::InvalidIdentityPublicKeyBudgetError(_) => 10537,
232 Self::IdentityPublicKeyLimitsNotAllowedInShieldedIdentityCreationError(_) => 10538,
233 Self::IdentityKeyLimitsUpdateEmptyError(_) => 10539,
234
235 Self::InvalidStateTransitionTypeError { .. } => 10600,
237 Self::MissingStateTransitionTypeError { .. } => 10601,
238 Self::StateTransitionMaxSizeExceededError { .. } => 10602,
239 Self::StateTransitionNotActiveError(_) => 10603,
240
241 Self::OverflowError(_) => 10700,
243
244 Self::TransitionOverMaxInputsError(_) => 10800,
246 Self::TransitionOverMaxOutputsError(_) => 10801,
247 Self::InputWitnessCountMismatchError(_) => 10802,
248 Self::TransitionNoInputsError(_) => 10803,
249 Self::TransitionNoOutputsError(_) => 10804,
250 Self::FeeStrategyEmptyError(_) => 10805,
251 Self::FeeStrategyDuplicateError(_) => 10806,
252 Self::FeeStrategyIndexOutOfBoundsError(_) => 10807,
253 Self::FeeStrategyTooManyStepsError(_) => 10808,
254 Self::InputBelowMinimumError(_) => 10809,
255 Self::OutputBelowMinimumError(_) => 10810,
256 Self::InputOutputBalanceMismatchError(_) => 10811,
257 Self::OutputsNotGreaterThanInputsError(_) => 10812,
258 Self::WithdrawalBalanceMismatchError(_) => 10813,
259 Self::InsufficientFundingAmountError(_) => 10814,
260 Self::InputsNotLessThanOutputsError(_) => 10815,
261 Self::OutputAddressAlsoInputError(_) => 10816,
262 Self::InvalidRemainderOutputCountError(_) => 10817,
263 Self::WithdrawalBelowMinAmountError(_) => 10818,
264 Self::ShieldedNoActionsError(_) => 10819,
266 Self::ShieldedEmptyProofError(_) => 10820,
267 Self::ShieldedZeroAnchorError(_) => 10821,
268 Self::ShieldedInvalidValueBalanceError(_) => 10822,
269 Self::ShieldedEncryptedNoteSizeMismatchError(_) => 10823,
270 Self::ShieldedTooManyActionsError(_) => 10825,
271 Self::ShieldedImplicitFeeCapExceededError(_) => 10826,
272 Self::ShieldedInvalidDenominationError(_) => 10827,
273 Self::InvalidTokenDistributionEpochIntervalTooShortError(_) => 10828,
274 Self::InvalidTokenOncePerIdentityDistributionAmountError(_) => 10829,
275
276 Self::InvalidContractModerationConfigError(_) => 10900,
278 Self::ContractModerationSelfTargetError(_) => 10901,
279 Self::DocumentActionFeesWithoutModerationError(_) => 10902,
280 Self::ContractModerationReasonTooLongError(_) => 10903,
281 Self::InvalidContractModerationReasonDocumentsError(_) => 10904,
282 Self::InvalidContractModerationDocumentFieldsError(_) => 10905,
283
284 Self::ModerationCharterMalformedFieldError(_) => 11000,
286 Self::ModerationCharterRewardSplitNotOneHundredError(_) => 11001,
287 }
288 }
289}
290
291impl ErrorWithCode for SignatureError {
292 fn code(&self) -> u32 {
293 match self {
294 Self::IdentityNotFoundError { .. } => 20000,
295 Self::InvalidIdentityPublicKeyTypeError { .. } => 20001,
296 Self::InvalidStateTransitionSignatureError { .. } => 20002,
297 Self::MissingPublicKeyError { .. } => 20003,
298 Self::InvalidSignaturePublicKeySecurityLevelError { .. } => 20004,
299 Self::WrongPublicKeyPurposeError { .. } => 20005,
300 Self::PublicKeyIsDisabledError { .. } => 20006,
301 Self::PublicKeySecurityLevelNotMetError { .. } => 20007,
302 Self::SignatureShouldNotBePresentError(_) => 20008,
303 Self::BasicECDSAError(_) => 20009,
304 Self::BasicBLSError(_) => 20010,
305 Self::InvalidSignaturePublicKeyPurposeError(_) => 20011,
306 Self::UncompressedPublicKeyNotAllowedError(_) => 20012,
307 Self::ContractBoundedKeyOutOfBoundsError(_) => 20014,
308 Self::ContractBoundedKeyNonBatchError(_) => 20013,
309 Self::PublicKeyBudgetExhaustedError(_) => 20015,
310 Self::PublicKeyExpiredError(_) => 20016,
311 Self::PublicKeyWithLimitsCannotUpdateKeyLimitsError(_) => 20017,
312 }
313 }
314}
315
316impl ErrorWithCode for FeeError {
317 fn code(&self) -> u32 {
318 match self {
319 Self::BalanceIsNotEnoughError { .. } => 30000,
320 }
321 }
322}
323
324impl ErrorWithCode for StateError {
325 fn code(&self) -> u32 {
326 match self {
327 Self::DataContractAlreadyPresentError { .. } => 40000,
329 Self::DataContractIsReadonlyError { .. } => 40001,
330 Self::DataContractConfigUpdateError { .. } => 40002,
331 Self::DataContractUpdatePermissionError(_) => 40003,
332 Self::DataContractUpdateActionNotAllowedError(_) => 40004,
333 Self::PreProgrammedDistributionTimestampInPastError(_) => 40005,
334 Self::IdentityInTokenConfigurationNotFoundError(_) => 40006,
335 Self::IdentityMemberOfGroupNotFoundError(_) => 40007,
336 Self::DataContractNotFoundError(_) => 40008,
337 Self::InvalidTokenPositionStateError(_) => 40009,
338
339 Self::DocumentAlreadyPresentError { .. } => 40100,
341 Self::DocumentNotFoundError { .. } => 40101,
342 Self::DocumentOwnerIdMismatchError { .. } => 40102,
343 Self::DocumentTimestampsMismatchError { .. } => 40103,
344 Self::DocumentTimestampWindowViolationError { .. } => 40104,
345 Self::DuplicateUniqueIndexError { .. } => 40105,
346 Self::InvalidDocumentRevisionError { .. } => 40106,
347 Self::DocumentTimestampsAreEqualError(_) => 40107,
348 Self::DocumentNotForSaleError(_) => 40108,
349 Self::DocumentIncorrectPurchasePriceError(_) => 40109,
350 Self::DocumentContestCurrentlyLockedError(_) => 40110,
351 Self::DocumentContestNotJoinableError(_) => 40111,
352 Self::DocumentContestIdentityAlreadyContestantError(_) => 40112,
353 Self::DocumentContestDocumentWithSameIdAlreadyPresentError(_) => 40113,
354 Self::DocumentContestNotPaidForError(_) => 40114,
355 Self::RequiredTokenPaymentInfoNotSetError(_) => 40115,
356 Self::IdentityHasNotAgreedToPayRequiredTokenAmountError(_) => 40116,
357 Self::IdentityTryingToPayWithWrongTokenError(_) => 40117,
358 Self::DocumentContestIndexMismatchError(_) => 40118,
359 Self::DocumentContestNotRequiredError(_) => 40119,
360 Self::ReferencedEntityNotFoundError(_) => 40120,
361 Self::ReferencedDocumentTypeNotFoundError(_) => 40121,
362 Self::ReferencedDocumentTypeDeletableError(_) => 40122,
363 Self::ReferencedIdentityKeyNotFoundError(_) => 40123,
364 Self::ReferencedIdentityKeyDisabledError(_) => 40124,
365 Self::ReferencedKeyIdPropertyInvalidError(_) => 40125,
366 Self::ReferencedDocumentPropertyAgreementInvalidError(_) => 40126,
367 Self::ReferencedDocumentPropertyMismatchError(_) => 40127,
368 Self::DocumentImmutablePropertyChangedError(_) => 40128,
369 Self::GasFeesPaidByNotAllowedError(_) => 40129,
370 Self::InconsistentGasFeesPaidByInBatchError(_) => 40130,
371 Self::ReferencedDocumentTypeNotDeletableError(_) => 40131,
372 Self::DocumentActionFeeAgreementNotSetError(_) => 40132,
373 Self::DocumentActionFeeAgreementMismatchError(_) => 40133,
374 Self::DocumentActionFeeMultiplierNotToleratedError(_) => 40134,
375 Self::ReferencedContractRequirementNotMetError(_) => 40135,
376 Self::ReferencedIdentityKeyRequirementNotMetError(_) => 40136,
377 Self::ReferencedDocumentLookupInvalidError(_) => 40137,
378 Self::ReferencedDocumentListInvalidError(_) => 40138,
379 Self::DocumentActionFeeModeratorsShareMismatchError(_) => 40139,
380 Self::DocumentExpiredError(_) => 40140,
381 Self::DocumentContestMaximumContendersReachedError(_) => 40141,
382 Self::ReferencedDocumentRequirementNotMetError(_) => 40142,
383 Self::ReferencedDocumentTypeNotModeratedError(_) => 40143,
384 Self::ReferencedDocumentTypeModeratedError(_) => 40144,
385 Self::ReferencedDocumentRemovedError(_) => 40145,
386 Self::ReferencedDocumentTypeIndexOnlyError(_) => 40146,
387 Self::DocumentDeleteConstraintViolatedError(_) => 40147,
388 Self::ReferencedDocumentRuleReadInvalidError(_) => 40148,
389 Self::ReferencedDocumentPrecededError(_) => 40149,
390
391 Self::IdentityAlreadyExistsError(_) => 40200,
393 Self::IdentityPublicKeyIsReadOnlyError { .. } => 40201,
394 Self::InvalidIdentityPublicKeyIdError { .. } => 40202,
395 Self::InvalidIdentityRevisionError { .. } => 40203,
396 Self::InvalidIdentityNonceError(_) => 40204,
397 Self::MaxIdentityPublicKeyLimitReachedError { .. } => 40205,
398 Self::DuplicatedIdentityPublicKeyStateError { .. } => 40206,
399 Self::DuplicatedIdentityPublicKeyIdStateError { .. } => 40207,
400 Self::IdentityPublicKeyIsDisabledError { .. } => 40208,
401 Self::MissingIdentityPublicKeyIdsError { .. } => 40209,
402 Self::IdentityInsufficientBalanceError(_) => 40210,
403 Self::IdentityPublicKeyAlreadyExistsForUniqueContractBoundsError(_) => 40211,
404 Self::DocumentTypeUpdateError(_) => 40212,
405 Self::MissingTransferKeyError(_) => 40214,
406 Self::NoTransferKeyForCoreWithdrawalAvailableError(_) => 40215,
407 Self::RecipientIdentityDoesNotExistError(_) => 40216,
408 Self::IdentityToFreezeDoesNotExistError(_) => 40217,
409 Self::IdentityPublicKeyBudgetExceededError(_) => 40218,
410 Self::IdentityPublicKeyAlreadyExpiredError(_) => 40219,
411 Self::IdentityPublicKeyLimitNotSetError(_) => 40220,
412 Self::IdentityPublicKeyLimitNotRaisedError(_) => 40221,
413 Self::GasSponsorInsufficientBalanceError(_) => 40222,
414
415 Self::MasternodeNotFoundError(_) => 40300,
417 Self::VotePollNotFoundError(_) => 40301,
418 Self::VotePollNotAvailableForVotingError(_) => 40302,
419 Self::MasternodeVotedTooManyTimesError(_) => 40303,
420 Self::MasternodeVoteAlreadyPresentError(_) => 40304,
421 Self::MasternodeIncorrectVotingAddressError(_) => 40305,
422 Self::MasternodeIncorrectVoterIdentityIdError(_) => 40306,
423 Self::VoteChoiceNotAllowedForVotePollError(_) => 40307,
424
425 Self::PrefundedSpecializedBalanceInsufficientError(_) => 40400,
427 Self::PrefundedSpecializedBalanceNotFoundError(_) => 40401,
428
429 Self::DataTriggerError(ref e) => e.code(),
431
432 Self::AddressDoesNotExistError(_) => 40600,
434 Self::AddressNotEnoughFundsError(_) => 40601,
435 Self::AddressesNotEnoughFundsError(_) => 40602,
436 Self::AddressInvalidNonceError(_) => 40603,
437
438 Self::IdentityDoesNotHaveEnoughTokenBalanceError(_) => 40700,
440 Self::UnauthorizedTokenActionError(_) => 40701,
441 Self::IdentityTokenAccountFrozenError(_) => 40702,
442 Self::IdentityTokenAccountNotFrozenError(_) => 40703,
443 Self::TokenSettingMaxSupplyToLessThanCurrentSupplyError(_) => 40704,
444 Self::TokenMintPastMaxSupplyError(_) => 40705,
445 Self::NewTokensDestinationIdentityDoesNotExistError(_) => 40706,
446 Self::NewAuthorizedActionTakerIdentityDoesNotExistError(_) => 40707,
447 Self::NewAuthorizedActionTakerGroupDoesNotExistError(_) => 40708,
448 Self::NewAuthorizedActionTakerMainGroupNotSetError(_) => 40709,
449 Self::InvalidGroupPositionError(_) => 40710,
450 Self::TokenIsPausedError(_) => 40711,
451 Self::IdentityTokenAccountAlreadyFrozenError(_) => 40712,
452 Self::TokenAlreadyPausedError(_) => 40713,
453 Self::TokenNotPausedError(_) => 40714,
454 Self::InvalidTokenClaimPropertyMismatch(_) => 40715,
455 Self::InvalidTokenClaimNoCurrentRewards(_) => 40716,
456 Self::InvalidTokenClaimWrongClaimant(_) => 40717,
457 Self::TokenTransferRecipientIdentityNotExistError(_) => 40718,
458 Self::TokenDirectPurchaseUserPriceTooLow(_) => 40719,
459 Self::TokenAmountUnderMinimumSaleAmount(_) => 40720,
460 Self::TokenNotForDirectSale(_) => 40721,
461 Self::TokenOncePerIdentityDistributionAlreadyClaimedError(_) => 40722,
462 Self::TokenShieldedPoolNotEnabledError(_) => 40723,
463 Self::TokenShieldedPaymentAmountMismatchError(_) => 40724,
464 Self::TokenShieldedPaymentNotRequiredError(_) => 40725,
465 Self::TokenNotTransferableError(_) => 40726,
466
467 Self::IdentityNotMemberOfGroupError(_) => 40800,
469 Self::GroupActionDoesNotExistError(_) => 40801,
470 Self::GroupActionAlreadyCompletedError(_) => 40802,
471 Self::GroupActionAlreadySignedByIdentityError(_) => 40803,
472 Self::ModificationOfGroupActionMainParametersNotPermittedError(_) => 40804,
473
474 Self::InvalidAnchorError(_) => 40900,
476 Self::NullifierAlreadySpentError(_) => 40901,
477 Self::InvalidShieldedProofError(_) => 40902,
478 Self::InsufficientPoolNotesError(_) => 40903,
479 Self::InsufficientShieldedFeeError(_) => 40904,
480
481 Self::ContractGroupAlreadyExistsError(_) => 41000,
483 Self::ContractGroupNotFoundError(_) => 41001,
484 Self::IdentityNotContractGroupOwnerOrAdminError(_) => 41002,
485 Self::ContractGroupAdminNotFoundError(_) => 41003,
486
487 Self::ContractModerationNotEnabledError(_) => 41100,
489 Self::IdentityNotContractModeratorError(_) => 41101,
490 Self::ContractModerationTargetNotAllowedError(_) => 41102,
491 Self::ContractUserAlreadyBannedError(_) => 41103,
492 Self::ContractUserNotBannedError(_) => 41104,
493 Self::ContractUserNotSuspendedError(_) => 41105,
494 Self::ContractSuspensionNotInFutureError(_) => 41106,
495 Self::ContractUserBannedError(_) => 41107,
496 Self::ContractUserSuspendedError(_) => 41108,
497 Self::ContractModerationTargetNotFoundError(_) => 41109,
498 Self::ContractModeratorIdentityNotFoundError(_) => 41110,
499 Self::ContractFeesAlreadyClaimedThisEpochError(_) => 41111,
500 Self::ContractFeesNothingToClaimError(_) => 41112,
501 Self::ContractFeeClaimNotAllowedError(_) => 41113,
502 Self::ContractModerationCounterpartyBarredError(_) => 41114,
503 Self::DocumentTypeNotDeletableByModeratorsError(_) => 41115,
504 Self::DocumentModerationWindowElapsedError(_) => 41116,
505 Self::ContractUserNotWarnedError(_) => 41117,
506 Self::ContractUserWarningLimitReachedError(_) => 41118,
507 Self::ContractDocumentRemovalNotFoundError(_) => 41119,
508 Self::DocumentRestoreWindowElapsedError(_) => 41120,
509 Self::DocumentRestoreHashMismatchError(_) => 41121,
510 Self::ContractDocumentAlreadyRestoredError(_) => 41122,
511 Self::DocumentFieldNotChangeableByModeratorsError(_) => 41123,
512 Self::DocumentModeratorFieldNotWritableError(_) => 41124,
513
514 Self::ContractModeratedDocumentTypeNotYetUsableError(_) => 41200,
516 Self::ContractModerationAbilityNotGrantedError(_) => 41201,
517 Self::ModerationCharterAddedModeratorLimitReachedError(_) => 41202,
518 Self::ModerationReasonNotListedError(_) => 41203,
519 Self::DocumentTypeNotDeletableOnceSettledError(_) => 41204,
520 Self::ContractModerationTeamNotSeatedError(_) => 41205,
521 Self::DocumentNotSettledError(_) => 41206,
522 Self::ContractTeamActionDoesNotExistError(_) => 41207,
523 Self::ContractTeamActionAlreadySignedError(_) => 41208,
524 Self::SettledDeletionNotRestorableError(_) => 41209,
525 Self::ContractTeamActionAlreadyCompletedError(_) => 41210,
526 Self::ContractTeamActionDocumentChangedError(_) => 41211,
527 Self::ContractTeamMemberAddedAfterDocumentError(_) => 41212,
528 }
529 }
530}
531
532impl ErrorWithCode for DataTriggerError {
533 fn code(&self) -> u32 {
534 match self {
535 Self::DataTriggerConditionError { .. } => 40500,
536 Self::DataTriggerExecutionError { .. } => 40501,
537 Self::DataTriggerInvalidResultError { .. } => 40502,
538 }
539 }
540}