Skip to main content

dpp/errors/consensus/
codes.rs

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    /// Returns the error code
11    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, // this should never happen
25        }
26    }
27}
28impl ErrorWithCode for BasicError {
29    fn code(&self) -> u32 {
30        match self {
31            // Versioning Errors: 10000-10099
32            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            // Structure Errors: 10100-10199
41            Self::JsonSchemaCompilationError(..) => 10100,
42            Self::JsonSchemaError(_) => 10101,
43            Self::InvalidIdentifierError { .. } => 10102,
44            Self::ValueError(_) => 10103,
45
46            // DataContract Errors: 10200-10349
47            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
125            // Group Errors: 10350-10399
126            Self::GroupPositionDoesNotExistError(_) => 10350,
127            Self::GroupActionNotAllowedOnTransitionError(_) => 10351,
128            Self::GroupTotalPowerLessThanRequiredError(_) => 10352,
129            Self::GroupNonUnilateralMemberPowerHasLessThanRequiredPowerError(_) => 10353,
130            Self::GroupExceedsMaxMembersError(_) => 10354,
131            Self::GroupMemberHasPowerOfZeroError(_) => 10355,
132            Self::GroupMemberHasPowerOverLimitError(_) => 10356,
133            Self::MainGroupIsNotDefinedError(_) => 10357,
134            Self::GroupRequiredPowerIsInvalidError(_) => 10358,
135            Self::GroupHasTooFewMembersError(_) => 10359,
136
137            // Document Errors: 10400-10449
138            Self::DataContractNotPresentError { .. } => 10400,
139            Self::DuplicateDocumentTransitionsWithIdsError { .. } => 10401,
140            Self::DuplicateDocumentTransitionsWithIndicesError { .. } => 10402,
141            Self::InconsistentCompoundIndexDataError { .. } => 10403,
142            Self::InvalidDocumentTransitionActionError { .. } => 10404,
143            Self::InvalidDocumentTransitionIdError { .. } => 10405,
144            Self::InvalidDocumentTypeError { .. } => 10406,
145            Self::MissingDataContractIdBasicError { .. } => 10407,
146            Self::MissingDocumentTransitionActionError { .. } => 10408,
147            Self::MissingDocumentTransitionTypeError { .. } => 10409,
148            Self::MissingDocumentTypeError { .. } => 10410,
149            Self::MissingPositionsInDocumentTypePropertiesError { .. } => 10411,
150            Self::MaxDocumentsTransitionsExceededError { .. } => 10412,
151            Self::DocumentTransitionsAreAbsentError { .. } => 10413,
152            Self::NonceOutOfBoundsError(_) => 10414,
153            Self::InvalidDocumentTypeNameError(_) => 10415,
154            Self::DocumentCreationNotAllowedError(_) => 10416,
155            Self::DocumentFieldMaxSizeExceededError(_) => 10417,
156            Self::ContestedDocumentsTemporarilyNotAllowedError(_) => 10418,
157
158            // Token Errors: 10450-10499
159            Self::InvalidTokenIdError(_) => 10450,
160            Self::InvalidTokenPositionError(_) => 10451,
161            Self::InvalidActionIdError(_) => 10452,
162            Self::ContractHasNoTokensError(_) => 10453,
163            Self::DestinationIdentityForTokenMintingNotSetError(_) => 10454,
164            Self::ChoosingTokenMintRecipientNotAllowedError(_) => 10455,
165            Self::TokenTransferToOurselfError(_) => 10456,
166            Self::InvalidTokenConfigUpdateNoChangeError(_) => 10457,
167            Self::InvalidTokenAmountError(_) => 10458,
168            Self::InvalidTokenNoteTooBigError(_) => 10459,
169            Self::TokenNoteOnlyAllowedWhenProposerError(_) => 10460,
170            Self::TokenPricingScheduleEmptyError(_) => 10461,
171
172            // Identity Errors: 10500-10599
173            Self::DuplicatedIdentityPublicKeyBasicError(_) => 10500,
174            Self::DuplicatedIdentityPublicKeyIdBasicError(_) => 10501,
175            Self::IdentityAssetLockProofLockedTransactionMismatchError(_) => 10502,
176            Self::IdentityAssetLockTransactionIsNotFoundError(_) => 10503,
177            Self::IdentityAssetLockTransactionOutPointAlreadyConsumedError(_) => 10504,
178            Self::IdentityAssetLockTransactionOutputNotFoundError(_) => 10505,
179            Self::InvalidAssetLockProofCoreChainHeightError(_) => 10506,
180            Self::InvalidAssetLockProofTransactionHeightError(_) => 10507,
181            Self::InvalidAssetLockTransactionOutputReturnSizeError(_) => 10508,
182            Self::InvalidIdentityAssetLockTransactionError(_) => 10509,
183            Self::InvalidIdentityAssetLockTransactionOutputError(_) => 10510,
184            Self::InvalidIdentityPublicKeyDataError(_) => 10511,
185            Self::InvalidInstantAssetLockProofError(_) => 10512,
186            Self::InvalidInstantAssetLockProofSignatureError(_) => 10513,
187            Self::InvalidIdentityAssetLockProofChainLockValidationError(_) => 10514,
188            Self::DataContractBoundsNotPresentError(_) => 10515,
189            Self::DisablingKeyIdAlsoBeingAddedInSameTransitionError(_) => 10516,
190            Self::MissingMasterPublicKeyError(_) => 10517,
191            Self::TooManyMasterPublicKeyError(_) => 10518,
192            Self::InvalidIdentityPublicKeySecurityLevelError(_) => 10519,
193            Self::InvalidIdentityKeySignatureError { .. } => 10520,
194            Self::InvalidCreditWithdrawalTransitionOutputScriptError(_) => 10521,
195            Self::InvalidCreditWithdrawalTransitionCoreFeeError(_) => 10522,
196            Self::NotImplementedCreditWithdrawalTransitionPoolingError(_) => 10523,
197            Self::InvalidIdentityCreditTransferAmountError(_) => 10524,
198            Self::InvalidIdentityCreditWithdrawalTransitionAmountError(_) => 10525,
199            Self::InvalidIdentityUpdateTransitionEmptyError(_) => 10526,
200            Self::InvalidIdentityUpdateTransitionDisableKeysError(_) => 10527,
201            Self::IdentityCreditTransferToSelfError(_) => 10528,
202            Self::MasterPublicKeyUpdateError(_) => 10529,
203            Self::IdentityAssetLockTransactionOutPointNotEnoughBalanceError(_) => 10530,
204            Self::IdentityAssetLockStateTransitionReplayError(_) => 10531,
205            Self::WithdrawalOutputScriptNotAllowedWhenSigningWithOwnerKeyError(_) => 10532,
206            Self::InvalidKeyPurposeForContractBoundsError(_) => 10533,
207            Self::IdentityAssetLockTransactionTooManyInputsError(_) => 10534,
208
209            // State Transition Errors: 10600-10699
210            Self::InvalidStateTransitionTypeError { .. } => 10600,
211            Self::MissingStateTransitionTypeError { .. } => 10601,
212            Self::StateTransitionMaxSizeExceededError { .. } => 10602,
213            Self::StateTransitionNotActiveError(_) => 10603,
214
215            // General Errors 10700-10799
216            Self::OverflowError(_) => 10700,
217
218            // Address Errors: 10800-10899
219            Self::TransitionOverMaxInputsError(_) => 10800,
220            Self::TransitionOverMaxOutputsError(_) => 10801,
221            Self::InputWitnessCountMismatchError(_) => 10802,
222            Self::TransitionNoInputsError(_) => 10803,
223            Self::TransitionNoOutputsError(_) => 10804,
224            Self::FeeStrategyEmptyError(_) => 10805,
225            Self::FeeStrategyDuplicateError(_) => 10806,
226            Self::FeeStrategyIndexOutOfBoundsError(_) => 10807,
227            Self::FeeStrategyTooManyStepsError(_) => 10808,
228            Self::InputBelowMinimumError(_) => 10809,
229            Self::OutputBelowMinimumError(_) => 10810,
230            Self::InputOutputBalanceMismatchError(_) => 10811,
231            Self::OutputsNotGreaterThanInputsError(_) => 10812,
232            Self::WithdrawalBalanceMismatchError(_) => 10813,
233            Self::InsufficientFundingAmountError(_) => 10814,
234            Self::InputsNotLessThanOutputsError(_) => 10815,
235            Self::OutputAddressAlsoInputError(_) => 10816,
236            Self::InvalidRemainderOutputCountError(_) => 10817,
237            Self::WithdrawalBelowMinAmountError(_) => 10818,
238            // Shielded transition errors (10819-10827)
239            Self::ShieldedNoActionsError(_) => 10819,
240            Self::ShieldedEmptyProofError(_) => 10820,
241            Self::ShieldedZeroAnchorError(_) => 10821,
242            Self::ShieldedInvalidValueBalanceError(_) => 10822,
243            Self::ShieldedEncryptedNoteSizeMismatchError(_) => 10823,
244            Self::ShieldedTooManyActionsError(_) => 10825,
245            Self::ShieldedImplicitFeeCapExceededError(_) => 10826,
246            Self::ShieldedInvalidDenominationError(_) => 10827,
247        }
248    }
249}
250
251impl ErrorWithCode for SignatureError {
252    fn code(&self) -> u32 {
253        match self {
254            Self::IdentityNotFoundError { .. } => 20000,
255            Self::InvalidIdentityPublicKeyTypeError { .. } => 20001,
256            Self::InvalidStateTransitionSignatureError { .. } => 20002,
257            Self::MissingPublicKeyError { .. } => 20003,
258            Self::InvalidSignaturePublicKeySecurityLevelError { .. } => 20004,
259            Self::WrongPublicKeyPurposeError { .. } => 20005,
260            Self::PublicKeyIsDisabledError { .. } => 20006,
261            Self::PublicKeySecurityLevelNotMetError { .. } => 20007,
262            Self::SignatureShouldNotBePresentError(_) => 20008,
263            Self::BasicECDSAError(_) => 20009,
264            Self::BasicBLSError(_) => 20010,
265            Self::InvalidSignaturePublicKeyPurposeError(_) => 20011,
266            Self::UncompressedPublicKeyNotAllowedError(_) => 20012,
267        }
268    }
269}
270
271impl ErrorWithCode for FeeError {
272    fn code(&self) -> u32 {
273        match self {
274            Self::BalanceIsNotEnoughError { .. } => 30000,
275        }
276    }
277}
278
279impl ErrorWithCode for StateError {
280    fn code(&self) -> u32 {
281        match self {
282            // Data contract Errors: 40000-40099
283            Self::DataContractAlreadyPresentError { .. } => 40000,
284            Self::DataContractIsReadonlyError { .. } => 40001,
285            Self::DataContractConfigUpdateError { .. } => 40002,
286            Self::DataContractUpdatePermissionError(_) => 40003,
287            Self::DataContractUpdateActionNotAllowedError(_) => 40004,
288            Self::PreProgrammedDistributionTimestampInPastError(_) => 40005,
289            Self::IdentityInTokenConfigurationNotFoundError(_) => 40006,
290            Self::IdentityMemberOfGroupNotFoundError(_) => 40007,
291            Self::DataContractNotFoundError(_) => 40008,
292            Self::InvalidTokenPositionStateError(_) => 40009,
293
294            // Document Errors: 40100-40199
295            Self::DocumentAlreadyPresentError { .. } => 40100,
296            Self::DocumentNotFoundError { .. } => 40101,
297            Self::DocumentOwnerIdMismatchError { .. } => 40102,
298            Self::DocumentTimestampsMismatchError { .. } => 40103,
299            Self::DocumentTimestampWindowViolationError { .. } => 40104,
300            Self::DuplicateUniqueIndexError { .. } => 40105,
301            Self::InvalidDocumentRevisionError { .. } => 40106,
302            Self::DocumentTimestampsAreEqualError(_) => 40107,
303            Self::DocumentNotForSaleError(_) => 40108,
304            Self::DocumentIncorrectPurchasePriceError(_) => 40109,
305            Self::DocumentContestCurrentlyLockedError(_) => 40110,
306            Self::DocumentContestNotJoinableError(_) => 40111,
307            Self::DocumentContestIdentityAlreadyContestantError(_) => 40112,
308            Self::DocumentContestDocumentWithSameIdAlreadyPresentError(_) => 40113,
309            Self::DocumentContestNotPaidForError(_) => 40114,
310            Self::RequiredTokenPaymentInfoNotSetError(_) => 40115,
311            Self::IdentityHasNotAgreedToPayRequiredTokenAmountError(_) => 40116,
312            Self::IdentityTryingToPayWithWrongTokenError(_) => 40117,
313            Self::DocumentContestIndexMismatchError(_) => 40118,
314            Self::DocumentContestNotRequiredError(_) => 40119,
315            Self::ReferencedEntityNotFoundError(_) => 40120,
316            Self::ReferencedDocumentTypeNotFoundError(_) => 40121,
317            Self::ReferencedDocumentTypeDeletableError(_) => 40122,
318            Self::ReferencedIdentityKeyNotFoundError(_) => 40123,
319            Self::ReferencedIdentityKeyDisabledError(_) => 40124,
320            Self::ReferencedKeyIdPropertyInvalidError(_) => 40125,
321            Self::ReferencedDocumentPropertyAgreementInvalidError(_) => 40126,
322            Self::ReferencedDocumentPropertyMismatchError(_) => 40127,
323
324            // Identity Errors: 40200-40299
325            Self::IdentityAlreadyExistsError(_) => 40200,
326            Self::IdentityPublicKeyIsReadOnlyError { .. } => 40201,
327            Self::InvalidIdentityPublicKeyIdError { .. } => 40202,
328            Self::InvalidIdentityRevisionError { .. } => 40203,
329            Self::InvalidIdentityNonceError(_) => 40204,
330            Self::MaxIdentityPublicKeyLimitReachedError { .. } => 40205,
331            Self::DuplicatedIdentityPublicKeyStateError { .. } => 40206,
332            Self::DuplicatedIdentityPublicKeyIdStateError { .. } => 40207,
333            Self::IdentityPublicKeyIsDisabledError { .. } => 40208,
334            Self::MissingIdentityPublicKeyIdsError { .. } => 40209,
335            Self::IdentityInsufficientBalanceError(_) => 40210,
336            Self::IdentityPublicKeyAlreadyExistsForUniqueContractBoundsError(_) => 40211,
337            Self::DocumentTypeUpdateError(_) => 40212,
338            Self::MissingTransferKeyError(_) => 40214,
339            Self::NoTransferKeyForCoreWithdrawalAvailableError(_) => 40215,
340            Self::RecipientIdentityDoesNotExistError(_) => 40216,
341            Self::IdentityToFreezeDoesNotExistError(_) => 40217,
342
343            // Voting Errors: 40300-40399
344            Self::MasternodeNotFoundError(_) => 40300,
345            Self::VotePollNotFoundError(_) => 40301,
346            Self::VotePollNotAvailableForVotingError(_) => 40302,
347            Self::MasternodeVotedTooManyTimesError(_) => 40303,
348            Self::MasternodeVoteAlreadyPresentError(_) => 40304,
349            Self::MasternodeIncorrectVotingAddressError(_) => 40305,
350            Self::MasternodeIncorrectVoterIdentityIdError(_) => 40306,
351
352            // Prefunded specialized balances Errors: 40400-40499
353            Self::PrefundedSpecializedBalanceInsufficientError(_) => 40400,
354            Self::PrefundedSpecializedBalanceNotFoundError(_) => 40401,
355
356            // Data trigger errors: 40500-40699
357            Self::DataTriggerError(ref e) => e.code(),
358
359            // Address errors
360            Self::AddressDoesNotExistError(_) => 40600,
361            Self::AddressNotEnoughFundsError(_) => 40601,
362            Self::AddressesNotEnoughFundsError(_) => 40602,
363            Self::AddressInvalidNonceError(_) => 40603,
364
365            // Token errors: 40700-40799
366            Self::IdentityDoesNotHaveEnoughTokenBalanceError(_) => 40700,
367            Self::UnauthorizedTokenActionError(_) => 40701,
368            Self::IdentityTokenAccountFrozenError(_) => 40702,
369            Self::IdentityTokenAccountNotFrozenError(_) => 40703,
370            Self::TokenSettingMaxSupplyToLessThanCurrentSupplyError(_) => 40704,
371            Self::TokenMintPastMaxSupplyError(_) => 40705,
372            Self::NewTokensDestinationIdentityDoesNotExistError(_) => 40706,
373            Self::NewAuthorizedActionTakerIdentityDoesNotExistError(_) => 40707,
374            Self::NewAuthorizedActionTakerGroupDoesNotExistError(_) => 40708,
375            Self::NewAuthorizedActionTakerMainGroupNotSetError(_) => 40709,
376            Self::InvalidGroupPositionError(_) => 40710,
377            Self::TokenIsPausedError(_) => 40711,
378            Self::IdentityTokenAccountAlreadyFrozenError(_) => 40712,
379            Self::TokenAlreadyPausedError(_) => 40713,
380            Self::TokenNotPausedError(_) => 40714,
381            Self::InvalidTokenClaimPropertyMismatch(_) => 40715,
382            Self::InvalidTokenClaimNoCurrentRewards(_) => 40716,
383            Self::InvalidTokenClaimWrongClaimant(_) => 40717,
384            Self::TokenTransferRecipientIdentityNotExistError(_) => 40718,
385            Self::TokenDirectPurchaseUserPriceTooLow(_) => 40719,
386            Self::TokenAmountUnderMinimumSaleAmount(_) => 40720,
387            Self::TokenNotForDirectSale(_) => 40721,
388
389            // Group errors: 40800-40899
390            Self::IdentityNotMemberOfGroupError(_) => 40800,
391            Self::GroupActionDoesNotExistError(_) => 40801,
392            Self::GroupActionAlreadyCompletedError(_) => 40802,
393            Self::GroupActionAlreadySignedByIdentityError(_) => 40803,
394            Self::ModificationOfGroupActionMainParametersNotPermittedError(_) => 40804,
395
396            // Shielded errors: 40900-40999
397            Self::InvalidAnchorError(_) => 40900,
398            Self::NullifierAlreadySpentError(_) => 40901,
399            Self::InvalidShieldedProofError(_) => 40902,
400            Self::InsufficientPoolNotesError(_) => 40903,
401            Self::InsufficientShieldedFeeError(_) => 40904,
402        }
403    }
404}
405
406impl ErrorWithCode for DataTriggerError {
407    fn code(&self) -> u32 {
408        match self {
409            Self::DataTriggerConditionError { .. } => 40500,
410            Self::DataTriggerExecutionError { .. } => 40501,
411            Self::DataTriggerInvalidResultError { .. } => 40502,
412        }
413    }
414}