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
use anchor_lang::prelude::*;

#[error_code]
pub enum ErrorCode {
    // subscriber errors ----
    #[msg("Subscriber is not initialized.")]
    SubscriberNotInitialized,

    #[msg("Invalid State account")]
    SubsscriberInvalidStateAccount,

    // subscription errors ----
    #[msg("Subscription is not initialized.")]
    SubscriptionNotInitialized,

    #[msg("User is already subscribed to the plan.")]
    SubscriptionAlreadySubscribed,

    #[msg("User is not subscribed to the plan.")]
    SubscriptionNotSubscribed,

    #[msg("Not enough funds in protocol wallet to subscribe.")]
    SubscriptionNotEnoughFunds,

    #[msg("Next payment timestamp not reached. Please try again later.")]
    SubscriptionNextPaymentTimestampNotReached,

    // subscription plan errors -----
    #[msg("Subscription plan is not initialized.")]
    SubscriptionPlanNotInitialized,

    #[msg("Subscription amount must be in the range of 1 - 1000 USDC.")]
    SubscriptionPlanAmountInvalid,

    #[msg("Subscription plan is inactive.")]
    SubscriptionPlanInactive,

    #[msg("Subscription plan is already closed.")]
    SubscriptionPlanAlreadyClosed,

    // note: 60 second may not be ideal
    #[msg("Subscription plan frequency must be atleast 60 seconds.")]
    SubscriptionPlanFrequencyError,

    #[msg("Unauthorized to close subscription.")]
    SubscriptionPlanUnauthorizedToClose,

    #[msg("Invalid payment account provided.")]
    SubscriptionPlanInvalidPaymentAccount,

    #[msg("Fee percentage must be between 1% and 5%")]
    SubscriptionPlanFeeError,

    // token error ----
    #[msg("Invalid mint.")]
    InvalidMint,

    // node error ----
    #[msg("Unauthorized to perform the action.")]
    NodeErrorUnauthorized,

    #[msg("Node not registered.")]
    NodeNotRegistered,
}