1use anchor_lang::prelude::*;
2use std::result::Result as StdResult;
3pub trait OrArithError<T> {
4 fn or_arith_error(self) -> StdResult<T, error::Error>;
5}
6
7impl OrArithError<u64> for Option<u64> {
8 fn or_arith_error(self) -> StdResult<u64, error::Error> {
9 self.ok_or(HydraError::BadArtithmetic.into())
10 }
11}
12
13impl OrArithError<u32> for Option<u32> {
14 fn or_arith_error(self) -> StdResult<u32, error::Error> {
15 self.ok_or(HydraError::BadArtithmetic.into())
16 }
17}
18
19impl OrArithError<u128> for Option<u128> {
20 fn or_arith_error(self) -> StdResult<u128, error::Error> {
21 self.ok_or(HydraError::BadArtithmetic.into())
22 }
23}
24
25#[error_code]
26pub enum HydraError {
27 #[msg("Encountered an arithmetic error")]
28 BadArtithmetic,
29
30 #[msg("Invalid authority")]
31 InvalidAuthority,
32
33 #[msg("Not Enough Available Shares")]
34 InsufficientShares,
35
36 #[msg("All available shares must be assigned to a member")]
37 SharesArentAtMax,
38
39 #[msg("A New mint account must be provided")]
40 NewMintAccountRequired,
41
42 #[msg("A Token type Fanout requires a Membership Mint")]
43 MintAccountRequired,
44
45 #[msg("Invalid Membership Model")]
46 InvalidMembershipModel,
47
48 #[msg("Invalid Membership Voucher")]
49 InvalidMembershipVoucher,
50
51 #[msg("Invalid Mint for the config")]
52 MintDoesNotMatch,
53
54 #[msg("Holding account does not match the config")]
55 InvalidHoldingAccount,
56
57 #[msg("A Mint holding account must be an ata for the mint owned by the config")]
58 HoldingAccountMustBeAnATA,
59
60 DerivedKeyInvalid,
61
62 IncorrectOwner,
63
64 #[msg("Wallet Does not Own Membership Token")]
65 WalletDoesNotOwnMembershipToken,
66
67 #[msg("The Metadata specified is not valid Token Metadata")]
68 InvalidMetadata,
69
70 NumericalOverflow,
71
72 #[msg("Not enough new balance to distribute")]
73 InsufficientBalanceToDistribute,
74
75 InvalidFanoutForMint,
76
77 #[msg(
78 "This operation must be the instruction right after a distrobution on the same accounts."
79 )]
80 MustDistribute,
81
82 InvalidStakeAta,
83
84 CannotTransferToSelf,
85
86 #[msg("Transfer is not supported on this membership model")]
87 TransferNotSupported,
88
89 #[msg("Remove is not supported on this membership model")]
90 RemoveNotSupported,
91}