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
use thiserror::Error;

use crate::{DigestIdentifier, KeyIdentifier};

#[derive(Error, Debug, Clone)]
#[allow(dead_code)]
pub enum ApprovalManagerError {
    #[error("Ask not allowed for this module")]
    AskNoAllowed,
    #[error("Governance channel failed")]
    GovernanceChannelFailed,
    #[error("Message channel failed")]
    MessageChannelFailed,
    #[error("Unexpected error")]
    UnexpectedError,
    #[error("Database error")]
    DatabaseError,
    #[error("Hash generation failed")]
    HashGenerationFailed,
    #[error("Sign process failed")]
    SignProcessFailed,
    #[error("Response channel closed")]
    ResponseChannelClosed,
    #[error("Invalid request type found")]
    InvalidRequestTypeFound,
    #[error("Unexpected request type found in database")]
    UnexpectedRequestType,
    #[error("More than one pending approval request detected")]
    MoreRequestThanMaxAllowed,
    #[error("Event Apply failed")]
    EventApplyFailed,
}

#[derive(Error, Debug, Clone)]
pub enum ApprovalErrorResponse {
    #[error("Evaluation is not present at request")]
    NotEvaluationInRequest,
    #[error("API Channel not available")]
    APIChannelNotAvailable,
    #[error("Request already known")]
    RequestAlreadyKnown,
    #[error("No Fact event")]
    NoFactEvent,
    #[error("Previous Event detected")]
    PreviousEventDetected,
    #[error("Governance not found")]
    GovernanceNotFound,
    #[error("Invalid governance ID")]
    InvalidGovernanceID,
    #[error("Invalid Governance version")]
    InvalidGovernanceVersion,
    #[error("Governance version is lower")]
    OurGovIsLower {
        our_id: KeyIdentifier,
        sender: KeyIdentifier,
        gov_id: DigestIdentifier,
    },
    #[error("Governance version is higher")]
    OurGovIsHigher {
        our_id: KeyIdentifier,
        sender: KeyIdentifier,
        gov_id: DigestIdentifier,
    },
    #[error("Subject not found")]
    SubjectNotFound,
    #[error("No correlation between governances id")]
    GovernanceNoCorrelation,
    #[error("Subject not synchronized")]
    SubjectNotSynchronized,
    #[error("Signature is not from suject")]
    SignatureSignerIsNotSubject,
    #[error("Invalid Subject signature")]
    InvalidSubjectSignature,
    #[error("Node is not an approver")]
    NodeIsNotApprover,
    #[error("Invalid evaluator detected")]
    InvalidEvaluator,
    #[error("Invalid Evaluator signature detected")]
    InvalidEvaluatorSignature,
    #[error("Invalid invokator signature")]
    InvalidInvokator,
    #[error("Incokator has no permission")]
    InvalidInvokatorPermission,
    #[error("No Evaluator Quroum reached")]
    NoQuorumReached,
    #[error("Approval request not found")]
    ApprovalRequestNotFound,
    #[error("No hash correlation")]
    NoHashCorrelation,
    #[error("Invalid acceptance")]
    InvalidAcceptance,
    #[error("Error Hashing")]
    ErrorHashing,
    #[error("Invalid state hash specified by request")]
    InvalidStateHashAfterApply,
    #[error("Request not found")]
    RequestNotFound,
    #[error("Request is not pending")]
    NotPendingRequest,
    #[error("Request already Responded")]
    RequestAlreadyResponded,
}