ywpl_plex/
error.rs

1//! Error types
2
3use {
4    num_derive::FromPrimitive,
5    solana_program::{
6        decode_error::DecodeError,
7        msg,
8        program_error::{PrintProgramError, ProgramError},
9    },
10    thiserror::Error,
11};
12
13/// Errors that may be returned by the Metaplex program.
14#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)]
15pub enum MetaplexError {
16    /// Invalid instruction data passed in.
17    #[error("Failed to unpack instruction data")]
18    InstructionUnpackError,
19
20    /// Lamport balance below rent-exempt threshold.
21    #[error("Lamport balance below rent-exempt threshold")]
22    NotRentExempt,
23
24    /// Already initialized
25    #[error("Already initialized")]
26    AlreadyInitialized,
27
28    /// Uninitialized
29    #[error("Uninitialized")]
30    Uninitialized,
31
32    /// Account does not have correct owner
33    #[error("Account does not have correct owner")]
34    IncorrectOwner,
35
36    /// NumericalOverflowError
37    #[error("NumericalOverflowError")]
38    NumericalOverflowError,
39
40    /// Token transfer failed
41    #[error("Token transfer failed")]
42    TokenTransferFailed,
43
44    /// Invalid transfer authority provided
45    #[error("Invalid transfer authority provided")]
46    InvalidTransferAuthority,
47
48    /// Vault's authority does not match the expected pda with seed ['metaplex', auction_key]
49    #[error("Vault's authority does not match the expected ['metaplex', auction_key]")]
50    VaultAuthorityMismatch,
51
52    /// Auction's authority does not match the expected pda with seed ['metaplex', auction_key]
53    #[error(
54        "Auction's authority does not match the expected pda with seed ['metaplex', auction_key]"
55    )]
56    AuctionAuthorityMismatch,
57
58    /// The authority passed to the call does not match the authority on the auction manager!
59    #[error(
60        "The authority passed to the call does not match the authority on the auction manager!"
61    )]
62    AuctionManagerAuthorityMismatch,
63
64    /// Vault given does not match that on given auction manager!
65    #[error("Vault given does not match that on given auction manager!")]
66    AuctionManagerVaultMismatch,
67
68    /// The safety deposit box given does not belong to the given vault!
69    #[error("The safety deposit box given does not belong to the given vault!")]
70    SafetyDepositBoxVaultMismatch,
71
72    /// The store given does not belong to the safety deposit box given!
73    #[error("The store given does not belong to the safety deposit box given!")]
74    SafetyDepositBoxStoreMismatch,
75
76    /// The metadata given does not match the mint on the safety deposit box given!
77    #[error("The metadata given does not match the mint on the safety deposit box given!")]
78    SafetyDepositBoxMetadataMismatch,
79
80    /// The Safety Deposit Box mint does not match the one time auth mint on the master edition
81    #[error(
82        "The Safety Deposit Box mint does not match the one time auth mint on the master edition!"
83    )]
84    SafetyDepositBoxMasterEditionOneTimeAuthMintMismatch,
85
86    /// The mint given does not match the mint on the given safety deposit box!
87    #[error("The mint given does not match the mint on the given safety deposit box!")]
88    SafetyDepositBoxMintMismatch,
89
90    /// The token metadata program given does not match the token metadata program on this auction manager!
91    #[error("The token metadata program given does not match the token metadata program on this auction manager!")]
92    AuctionManagerTokenMetadataProgramMismatch,
93
94    /// The mint is owned by a different token program than the one used by this auction manager!
95    #[error(
96        "The mint is owned by a different token program than the one used by this auction manager!"
97    )]
98    TokenProgramMismatch,
99
100    /// The auction given does not match the auction on the auction manager!
101    #[error("The auction given does not match the auction on the auction manager!")]
102    AuctionManagerAuctionMismatch,
103
104    /// The auction program given does not match the auction program on the auction manager!
105    #[error(
106        "The auction program given does not match the auction program on the auction manager!"
107    )]
108    AuctionManagerAuctionProgramMismatch,
109
110    /// The token program given does not match the token program on the auction manager!
111    #[error("The token program given does not match the token program on the auction manager!")]
112    AuctionManagerTokenProgramMismatch,
113
114    /// The token vault program given does not match the token vault program on the auction manager!
115    #[error("The token vault program given does not match the token vault program on the auction manager!")]
116    AuctionManagerTokenVaultProgramMismatch,
117
118    /// Only combined vaults may be used in auction managers!
119    #[error("Only combined vaults may be used in auction managers!")]
120    VaultNotCombined,
121
122    /// Cannot auction off an empty vault!
123    #[error("Cannot auction off an empty vault!")]
124    VaultCannotEmpty,
125
126    /// Listed a safety deposit box index that does not exist in this vault
127    #[error("Listed a safety deposit box index that does not exist in this vault")]
128    InvalidSafetyDepositBox,
129
130    /// Cant use a limited supply edition for an open edition as you may run out of editions to print
131    #[error("Cant use a limited supply edition for an open edition as you may run out of editions to print")]
132    CantUseLimitedSupplyEditionsWithOpenEditionAuction,
133
134    /// This safety deposit box is not listed as a prize in this auction manager!
135    #[error("This safety deposit box is not listed as a prize in this auction manager!")]
136    SafetyDepositBoxNotUsedInAuction,
137
138    /// Either you have given a non-existent edition address or you have given the address to a different token-metadata program than was used to make this edition!
139    #[error("Either you have given a non-existent edition address or you have given the address to a different token-metadata program than was used to make this edition!")]
140    InvalidEditionAddress,
141
142    /// There are not enough editions available for this auction!
143    #[error("There are not enough editions available for this auction!")]
144    NotEnoughEditionsAvailableForAuction,
145
146    /// The store in the safety deposit is empty, so you have nothing to auction!
147    #[error("The store in the safety deposit is empty, so you have nothing to auction!")]
148    StoreIsEmpty,
149
150    /// Not enough tokens to supply winners!
151    #[error("Not enough tokens to supply winners!")]
152    NotEnoughTokensToSupplyWinners,
153
154    /// The auction manager must own the payoff account!
155    #[error("The auction manager must own the payoff account!")]
156    AuctionManagerMustOwnPayoffAccount,
157
158    /// The auction manager must own the oustanding shares  account!
159    #[error("The auction manager must own the oustanding shares account!")]
160    AuctionManagerMustOwnOutstandingSharesAccount,
161
162    /// The safety deposit box for your winning bid or participation placement does not match the safety deposit box you provided!
163    #[error("The safety deposit box for your winning bid or participation placement does not match the safety deposit box you provided!")]
164    SafetyDepositIndexMismatch,
165
166    /// This prize has already been claimed!
167    #[error("This prize has already been claimed!")]
168    PrizeAlreadyClaimed,
169
170    /// The bid redemption key does not match the expected PDA with seed ['metaplex', auction key, bidder metadata key]
171    #[error("The bid redemption key does not match the expected PDA with seed ['metaplex', auction key, bidder metadata key]")]
172    BidRedemptionMismatch,
173
174    /// This bid has already been redeemed!
175    #[error("This bid has already been redeemed!")]
176    BidAlreadyRedeemed,
177
178    /// Auction has not ended yet!
179    #[error("Auction has not ended yet!")]
180    AuctionHasNotEnded,
181
182    /// The original authority lookup does not match the expected PDA of ['metaplex', auction key, metadata key]
183    #[error("The original authority lookup does not match the expected PDA of ['metaplex', auction key, metadata key]")]
184    OriginalAuthorityLookupKeyMismatch,
185
186    /// The original authority given does not match that on the original authority lookup account!
187    #[error("The original authority given does not match that on the original authority lookup account!")]
188    OriginalAuthorityMismatch,
189
190    /// The prize you are attempting to claim needs to be claimed from a different endpoint than this one.
191    #[error("The prize you are attempting to claim needs to be claimed from a different endpoint than this one.")]
192    WrongBidEndpointForPrize,
193
194    /// The bidder given is not the bidder on the bidder metadata!
195    #[error("The bidder given is not the bidder on the bidder metadata!")]
196    BidderMetadataBidderMismatch,
197
198    /// Printing mint given does not match the mint on master edition!
199    #[error("Printing mint given does not match the mint on master edition!")]
200    MasterEditionMintMismatch,
201
202    /// One Time Auth mint given does not match the mint on master edition!
203    #[error("One Time Auth mint given does not match the mint on master edition!")]
204    MasterEditionOneTimeAuthMintMismatch,
205
206    /// The printing token account must be of the printing mint type to hold authorization tokens after auction end
207    #[error("The printing token account must be of the printing mint type to hold authorization tokens after auction end")]
208    PrintingTokenAccountMintMismatch,
209
210    /// Destination does not have the proper mint!
211    #[error("Destination does not have the proper mint!")]
212    DestinationMintMismatch,
213
214    /// Invalid edition key
215    #[error("Invalid edition key")]
216    InvalidEditionKey,
217
218    /// Token mint to failed
219    #[error("Token mint to failed")]
220    TokenMintToFailed,
221
222    /// The Printing mint authority provided does not match that on the mint
223    #[error("The Printing mint authority provided does not match that on the mint")]
224    MasterMintAuthorityMismatch,
225
226    /// The safety deposit box is not using the one time authorization mint of the master edition
227    #[error(
228        "The safety deposit box is not using the one time authorization mint of the master edition"
229    )]
230    MasterEditionOneTimeAuthorizationMintMismatch,
231
232    /// The accept payment account for this auction manager must match the auction's token mint!
233    #[error(
234        "The accept payment account for this auction manager must match the auction's token mint!"
235    )]
236    AuctionAcceptPaymentMintMismatch,
237
238    /// The accept payment owner must be the auction manager!
239    #[error("The accept payment owner must be the auction manager!")]
240    AcceptPaymentOwnerMismatch,
241
242    /// The accept payment given does not match the accept payment account on the auction manager!
243    #[error("The accept payment given does not match the accept payment account on the auction manager!")]
244    AcceptPaymentMismatch,
245
246    /// You are not eligible for an participation NFT!
247    #[error("You are not eligible for a participation NFT!")]
248    NotEligibleForParticipation,
249
250    #[error("Auction manager must be validated to start auction!")]
251    /// Auction manager must be validated to start auction!
252    AuctionManagerMustBeValidated,
253
254    /// The safety deposit mint type must be the Printing mint of the limited edition!
255    #[error("The safety deposit mint type must be the Printing mint of the limited edition!")]
256    SafetyDepositBoxMasterMintMismatch,
257
258    /// The mints between the accept payment and account provided do not match
259    #[error("The mints between the accept payment and account provided do not match")]
260    AcceptPaymentMintMismatch,
261
262    /// You do not have enough to buy this participation NFT!
263    #[error("You do not have enough to buy this participation NFT!")]
264    NotEnoughBalanceForParticipation,
265
266    /// Derived key invalid
267    #[error("Derived key invalid")]
268    DerivedKeyInvalid,
269
270    /// Creator is not active on this store!
271    #[error("Creator is not active on this store!")]
272    WhitelistedCreatorInactive,
273
274    /// This creator is not whitelisted
275    #[error("This creator is not whitelisted")]
276    InvalidWhitelistedCreator,
277
278    /// Store given does not match store on auction manager!
279    #[error("Store given does not match store on auction manager!")]
280    AuctionManagerStoreMismatch,
281
282    /// Supplied an invalid creator index to empty payment account
283    #[error("Supplied an invalid creator index to empty payment account")]
284    InvalidCreatorIndex,
285
286    /// Supplied an invalid winning config index
287    #[error("Supplied an invalid winning config index")]
288    InvalidWinningConfigIndex,
289
290    /// Metadata has creators and no creator index was supplied!
291    #[error("Metadata has creators and no creator index was supplied!")]
292    CreatorIndexExpected,
293
294    /// This winning config does not contain this safety deposit box as one of it's prizes
295    #[error("This winning config does not contain this safety deposit box as one of it's prizes")]
296    WinningConfigSafetyDepositMismatch,
297
298    /// The participation prize does not match the safety deposit given
299    #[error("The participation prize does not match the safety deposit given")]
300    ParticipationSafetyDepositMismatch,
301
302    /// Participation NFT not present on this auction, so cannot collect money for it
303    #[error("Participation NFT not present on this auction, so cannot collect money for it")]
304    ParticipationNotPresent,
305
306    /// Not possible to settle until all bids have been claimed
307    #[error("Not possible to settle until all bids have been claimed")]
308    NotAllBidsClaimed,
309
310    /// Invalid winning config item index provided
311    #[error("Invalid winning config item index provided")]
312    InvalidWinningConfigItemIndex,
313
314    /// When using a one time authorization token in a winning config item, you can never have amount > 1
315    #[error("When using a one time authorization token in a winning config item, you can never have amount > 1")]
316    OneTimeAuthorizationTokenMustBeOne,
317
318    /// Adding a reservation list failed
319    #[error("Adding a reservation list failed")]
320    AddReservationListFailed,
321
322    /// Close account command failed
323    #[error("Close account command failed")]
324    CloseAccountFailed,
325
326    /// A creator on this metadata has not verified it
327    #[error("A creator on this metadata has not verified it")]
328    CreatorHasNotVerifiedMetadata,
329
330    /// Duplicate winning config item detected
331    #[error("Duplicate winning config item detected")]
332    DuplicateWinningConfigItemDetected,
333
334    /// The authorization account provided does not match that on the participation state
335    #[error("The authorization account provided does not match that on the participation state")]
336    PrintingAuthorizationTokenAccountMismatch,
337
338    /// The transient account provided does not have the correct mint
339    #[error("The transient account provided does not have the correct mint")]
340    TransientAuthAccountMintMismatch,
341
342    /// The participation printing authorization token account is empty. One person needs to call populate on it!
343    #[error("The participation printing authorization token account is empty. One person needs to call populate on it!")]
344    ParticipationPrintingEmpty,
345
346    /// The printing authorization token command failed
347    #[error("The printing authorization token command failed")]
348    PrintingAuthorizationTokensFailed,
349
350    /// Invalid token program
351    #[error("Invalid token program")]
352    InvalidTokenProgram,
353
354    /// Token metadata program does not match
355    #[error("Token metadata program does not match")]
356    AuctionManagerTokenMetadataMismatch,
357
358    /// This safety deposit box has already been validated
359    #[error("This safety deposit box has already been validated")]
360    AlreadyValidated,
361
362    /// Auction must be created
363    #[error("Auction must be created")]
364    AuctionMustBeCreated,
365
366    /// Accept payment delegate should be none
367    #[error("Accept payment delegate should be none")]
368    DelegateShouldBeNone,
369
370    /// Accept payment close authority should be none
371    #[error("Accept payment close authority should be none")]
372    CloseAuthorityShouldBeNone,
373
374    /// Data type mismatch
375    #[error("Data type mismatch")]
376    DataTypeMismatch,
377
378    /// Auctioneer can't claim a won prize
379    #[error("Auctioneer can't claim a won prize")]
380    AuctioneerCantClaimWonPrize,
381
382    /// Auctioneer is the only one who can override win indices
383    #[error("Auctioneer is the only one who can override win indices")]
384    MustBeAuctioneer,
385
386    /// The auction provided has a different amount of winners set than does the auction manager settings
387    #[error("The auction provided has a different amount of winners set than does the auction manager settings")]
388    WinnerAmountMismatch,
389
390    /// Invalid Auction Manager Status
391    #[error("Invalid Auction Manager Status")]
392    InvalidStatus,
393
394    /// You are not eligible for this edition offset
395    #[error("You are not eligible for this edition offset")]
396    InvalidEditionNumber,
397
398    /// Invalid operation
399    #[error("Invalid operation")]
400    InvalidOperation,
401
402    /// The provided account needs to contain one token of this mint type
403    #[error("The provided account needs to contain one token of this mint type")]
404    ProvidedAccountDoesNotContainOneToken,
405
406    /// You are not the winner at this index
407    #[error("You are not the winner at this index")]
408    WinnerIndexMismatch,
409
410    /// You supplied a safety deposit index in a winning configuration that does not exist
411    #[error("You supplied a safety deposit index in a winning configuration that does not exist")]
412    InvalidWinningConfigSafetyDepositIndex,
413
414    /// The order provided on the safety deposit config does not match that on the safety deposit box!
415    #[error("The order provided on the safety deposit config does not match that on the safety deposit box!")]
416    SafetyDepositConfigOrderMismatch,
417
418    /// Winner index not found in safety deposit config ranges
419    #[error("Winner index not found in safety deposit config ranges")]
420    WinnerIndexNotFound,
421
422    /// Currently metaplex auctions are limited to a single participation prize
423    #[error("Currently metaplex auctions are limited to a single participation prize")]
424    AlreadyHasOneParticipationPrize,
425
426    /// This winner was not found in any ranges in the unique token type list, this should never happen
427    #[error("This winner was not found in any ranges in the unique token type list, this should never happen")]
428    NoTokensForThisWinner,
429
430    /// Not allowed to use Master Edition V1 printing with Auction Manager v2
431    #[error("Not allowed to use Master Edition V1 printing with Auction Manager v2")]
432    PrintingV1NotAllowedWithAuctionManagerV2,
433
434    /// Invalid system
435    #[error("Invalid system program")]
436    InvalidSystemProgram,
437
438    /// Duplicate key detected
439    #[error("Duplicate key detected")]
440    DuplicateKeyDetected,
441
442    /// Max metadata cache size reached
443    #[error("Cant add more than 10 metadata to a cache")]
444    MaxMetadataCacheSizeReached,
445
446    /// Invalid cache offset
447    #[error("Invalid cache offset")]
448    InvalidCacheOffset,
449
450    /// You needed to provide an auction cache for the element above you but did not
451    #[error("You needed to provide an auction cache for the element above you but did not")]
452    ExpectedAboveAuctionCacheToBeProvided,
453
454    /// You needed to provide an auction cache for the element below you but did not
455    #[error("You needed to provide an auction cache for the element below you but did not")]
456    ExpectedBelowAuctionCacheToBeProvided,
457
458    /// Cache given does not match cache at this offset
459    #[error("Cache given does not match cache at this offset")]
460    CacheMismatch,
461
462    /// Cache above is newer
463    #[error("Cache above is newer")]
464    CacheAboveIsNewer,
465
466    /// Cache below is older
467    #[error("Cache below is older")]
468    CacheBelowIsOlder,
469
470    /// Auction manager already in finished state
471    #[error("Auction manager already in finished state")]
472    AuctionManagerInFishedState,
473
474    /// Public keys don't match in assert check.
475    #[error("PublicKeyMismatch")]
476    PublicKeyMismatch,
477}
478
479impl PrintProgramError for MetaplexError {
480    fn print<E>(&self) {
481        msg!(&self.to_string());
482    }
483}
484
485impl From<MetaplexError> for ProgramError {
486    fn from(e: MetaplexError) -> Self {
487        ProgramError::Custom(e as u32)
488    }
489}
490
491impl<T> DecodeError<T> for MetaplexError {
492    fn type_of() -> &'static str {
493        "Metaplex Error"
494    }
495}