1use anchor_lang::prelude::*;
4
5#[error_code]
7pub enum StreamError {
8 #[msg("The stream recipient is empty. Should be a valid address")]
10 EmptyRecipient,
11 #[msg("The stream recipient is the same as the sender. Should be different addresses")]
13 SameSenderAndRecipient,
14 #[msg("The stream sender is the same as the new sender. Should be different addresses")]
16 SameSenders,
17 #[msg("The stream recipient is the same as the new recipient. Should be different addresses")]
19 SameRecipients,
20 #[msg("The new sender is invalid")]
22 InvalidNewSender,
23 #[msg("The sender is invalid")]
25 InvalidSender,
26 #[msg("The recipient is invalid")]
28 InvalidRecipient,
29 #[msg("The stream name is too short. Should be >= 2 chars")]
31 StreamNameTooShort,
32 #[msg("The stream name is too long. Should be <= 100 chars")]
34 StreamNameTooLong,
35 #[msg("The flow interval is 0. Should be > 0")]
37 ZeroFlowInterval,
38 #[msg("The end time is either 0 with prepaid = true, in the past or < starts_at. Should be >= current_time and >= starts_at or if the stream is not prepaid, it can be 0")]
41 InvalidEndsAt,
42 #[msg("The stream will never lead to any payments. Either there should be a initial amount or flow rate and flow duration should be > 0")]
45 ZeroLifetimeAmount,
46 #[msg("The amount cannot be 0. Should be > 0")]
48 ZeroAmount,
49 #[msg("The prepaid amount needed by the stream is out of bounds")]
51 PrepaidAmountNeededOutOfBounds,
52 #[msg("The deposit amount needed by the non-prepaid stream is out of bounds")]
54 DepositAmountNeededOutOfBounds,
55 #[msg("The amount is less than the minimum initial amount needed")]
57 AmountLessThanAmountNeeded,
58 #[msg("The user is not allowed to withdraw. Should be the recipient of the stream")]
60 UserUnauthorizedToWithdraw,
61 #[msg("The withdrawn amount by recipient is more than the amount owed. THIS SHOULD NOT HAVE HAPPENED!!!")]
63 WithdrawnAmountGreaterThanAmountOwed,
64 #[msg("The total withdrawn amount by the recipient of the stream is out of bounds")]
66 WithdrawAmountOutOfBounds,
67 #[msg("The amount available to be withdrawn by the recipient of the stream is out of bounds")]
69 AmountAvailableToWithdrawOutOfBounds,
70 #[msg("The cancellation refund amount to the sender of the stream is out of bounds")]
72 CancellationRefundOutOfBounds,
73 #[msg("The total topup amount by the sender of the stream is out of bounds")]
75 TopupAmountOutOfBounds,
76 #[msg("The topup amount is more than what is needed by the stream")]
78 TopupAmountMoreThanMaxAcceptable,
79 #[msg("The sender has insufficient balance in their token account")]
81 SenderInsufficientFunds,
82 #[msg("The token escrow account has insufficient balance. THIS SHOULD NOT HAVE HAPPENED!!!")]
84 EscrowInsufficientFunds,
85 #[msg("The token escrow account is not rent exempt")]
87 EscrowNotRentExempt,
88 #[msg("The stream has already been cancelled")]
90 StreamAlreadyCancelled,
91 #[msg("The user is not allowed to cancel. Should be the sender or the recipient of the stream")]
93 UserUnauthorizedToCancel,
94 #[msg("The sender is not allowed to cancel permanently or at the moment")]
96 SenderCannotCancel,
97 #[msg("The stream is prepaid. Should be a non-prepaid stream")]
99 StreamIsPrepaid,
100 #[msg("The stream has already stopped. Should be an unstopped stream")]
102 StreamHasStopped,
103 #[msg("The stream is already paused. Should be a non-paused stream")]
105 StreamIsPaused,
106 #[msg("The stream is not paused. Should be a paused stream")]
108 StreamIsNotPaused,
109 #[msg("The stream has no flow payments. Should be a stream stream with a positive flow rate and flow period")]
111 StreamHasNoFlowPayments,
112 #[msg("The sender is not allowed to change sender of the stream permanently or at the moment")]
114 SenderCannotChangeSender,
115 #[msg("The sender is not allowed to pause stream permanently or at the moment")]
117 SenderCannotPause,
118 #[msg("The recipient is not allowed resume a stream paused by sender permanently or at the moment")]
120 RecipientCannotResumePauseBySender,
121 #[msg("The user is not allowed to pause. Should be the sender or the recipient of the stream")]
123 UserUnauthorizedToPause,
124 #[msg("The user is not allowed to resume. Should be the sender or the recipient of the stream")]
126 UserUnauthorizedToResume,
127 #[msg("The stream has not ended. Should have ended and nat been cancelled")]
129 StreamNotEnded,
130}