1use {
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#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)]
15pub enum MetaplexError {
16 #[error("Failed to unpack instruction data")]
18 InstructionUnpackError,
19
20 #[error("Lamport balance below rent-exempt threshold")]
22 NotRentExempt,
23
24 #[error("Already initialized")]
26 AlreadyInitialized,
27
28 #[error("Uninitialized")]
30 Uninitialized,
31
32 #[error("Account does not have correct owner")]
34 IncorrectOwner,
35
36 #[error("NumericalOverflowError")]
38 NumericalOverflowError,
39
40 #[error("Token transfer failed")]
42 TokenTransferFailed,
43
44 #[error("Invalid transfer authority provided")]
46 InvalidTransferAuthority,
47
48 #[error("Vault's authority does not match the expected ['metaplex', auction_key]")]
50 VaultAuthorityMismatch,
51
52 #[error(
54 "Auction's authority does not match the expected pda with seed ['metaplex', auction_key]"
55 )]
56 AuctionAuthorityMismatch,
57
58 #[error(
60 "The authority passed to the call does not match the authority on the auction manager!"
61 )]
62 AuctionManagerAuthorityMismatch,
63
64 #[error("Vault given does not match that on given auction manager!")]
66 AuctionManagerVaultMismatch,
67
68 #[error("The safety deposit box given does not belong to the given vault!")]
70 SafetyDepositBoxVaultMismatch,
71
72 #[error("The store given does not belong to the safety deposit box given!")]
74 SafetyDepositBoxStoreMismatch,
75
76 #[error("The metadata given does not match the mint on the safety deposit box given!")]
78 SafetyDepositBoxMetadataMismatch,
79
80 #[error(
82 "The Safety Deposit Box mint does not match the one time auth mint on the master edition!"
83 )]
84 SafetyDepositBoxMasterEditionOneTimeAuthMintMismatch,
85
86 #[error("The mint given does not match the mint on the given safety deposit box!")]
88 SafetyDepositBoxMintMismatch,
89
90 #[error("The token metadata program given does not match the token metadata program on this auction manager!")]
92 AuctionManagerTokenMetadataProgramMismatch,
93
94 #[error(
96 "The mint is owned by a different token program than the one used by this auction manager!"
97 )]
98 TokenProgramMismatch,
99
100 #[error("The auction given does not match the auction on the auction manager!")]
102 AuctionManagerAuctionMismatch,
103
104 #[error(
106 "The auction program given does not match the auction program on the auction manager!"
107 )]
108 AuctionManagerAuctionProgramMismatch,
109
110 #[error("The token program given does not match the token program on the auction manager!")]
112 AuctionManagerTokenProgramMismatch,
113
114 #[error("The token vault program given does not match the token vault program on the auction manager!")]
116 AuctionManagerTokenVaultProgramMismatch,
117
118 #[error("Only combined vaults may be used in auction managers!")]
120 VaultNotCombined,
121
122 #[error("Cannot auction off an empty vault!")]
124 VaultCannotEmpty,
125
126 #[error("Listed a safety deposit box index that does not exist in this vault")]
128 InvalidSafetyDepositBox,
129
130 #[error("Cant use a limited supply edition for an open edition as you may run out of editions to print")]
132 CantUseLimitedSupplyEditionsWithOpenEditionAuction,
133
134 #[error("This safety deposit box is not listed as a prize in this auction manager!")]
136 SafetyDepositBoxNotUsedInAuction,
137
138 #[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 #[error("There are not enough editions available for this auction!")]
144 NotEnoughEditionsAvailableForAuction,
145
146 #[error("The store in the safety deposit is empty, so you have nothing to auction!")]
148 StoreIsEmpty,
149
150 #[error("Not enough tokens to supply winners!")]
152 NotEnoughTokensToSupplyWinners,
153
154 #[error("The auction manager must own the payoff account!")]
156 AuctionManagerMustOwnPayoffAccount,
157
158 #[error("The auction manager must own the oustanding shares account!")]
160 AuctionManagerMustOwnOutstandingSharesAccount,
161
162 #[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 #[error("This prize has already been claimed!")]
168 PrizeAlreadyClaimed,
169
170 #[error("The bid redemption key does not match the expected PDA with seed ['metaplex', auction key, bidder metadata key]")]
172 BidRedemptionMismatch,
173
174 #[error("This bid has already been redeemed!")]
176 BidAlreadyRedeemed,
177
178 #[error("Auction has not ended yet!")]
180 AuctionHasNotEnded,
181
182 #[error("The original authority lookup does not match the expected PDA of ['metaplex', auction key, metadata key]")]
184 OriginalAuthorityLookupKeyMismatch,
185
186 #[error("The original authority given does not match that on the original authority lookup account!")]
188 OriginalAuthorityMismatch,
189
190 #[error("The prize you are attempting to claim needs to be claimed from a different endpoint than this one.")]
192 WrongBidEndpointForPrize,
193
194 #[error("The bidder given is not the bidder on the bidder metadata!")]
196 BidderMetadataBidderMismatch,
197
198 #[error("Printing mint given does not match the mint on master edition!")]
200 MasterEditionMintMismatch,
201
202 #[error("One Time Auth mint given does not match the mint on master edition!")]
204 MasterEditionOneTimeAuthMintMismatch,
205
206 #[error("The printing token account must be of the printing mint type to hold authorization tokens after auction end")]
208 PrintingTokenAccountMintMismatch,
209
210 #[error("Destination does not have the proper mint!")]
212 DestinationMintMismatch,
213
214 #[error("Invalid edition key")]
216 InvalidEditionKey,
217
218 #[error("Token mint to failed")]
220 TokenMintToFailed,
221
222 #[error("The Printing mint authority provided does not match that on the mint")]
224 MasterMintAuthorityMismatch,
225
226 #[error(
228 "The safety deposit box is not using the one time authorization mint of the master edition"
229 )]
230 MasterEditionOneTimeAuthorizationMintMismatch,
231
232 #[error(
234 "The accept payment account for this auction manager must match the auction's token mint!"
235 )]
236 AuctionAcceptPaymentMintMismatch,
237
238 #[error("The accept payment owner must be the auction manager!")]
240 AcceptPaymentOwnerMismatch,
241
242 #[error("The accept payment given does not match the accept payment account on the auction manager!")]
244 AcceptPaymentMismatch,
245
246 #[error("You are not eligible for a participation NFT!")]
248 NotEligibleForParticipation,
249
250 #[error("Auction manager must be validated to start auction!")]
251 AuctionManagerMustBeValidated,
253
254 #[error("The safety deposit mint type must be the Printing mint of the limited edition!")]
256 SafetyDepositBoxMasterMintMismatch,
257
258 #[error("The mints between the accept payment and account provided do not match")]
260 AcceptPaymentMintMismatch,
261
262 #[error("You do not have enough to buy this participation NFT!")]
264 NotEnoughBalanceForParticipation,
265
266 #[error("Derived key invalid")]
268 DerivedKeyInvalid,
269
270 #[error("Creator is not active on this store!")]
272 WhitelistedCreatorInactive,
273
274 #[error("This creator is not whitelisted")]
276 InvalidWhitelistedCreator,
277
278 #[error("Store given does not match store on auction manager!")]
280 AuctionManagerStoreMismatch,
281
282 #[error("Supplied an invalid creator index to empty payment account")]
284 InvalidCreatorIndex,
285
286 #[error("Supplied an invalid winning config index")]
288 InvalidWinningConfigIndex,
289
290 #[error("Metadata has creators and no creator index was supplied!")]
292 CreatorIndexExpected,
293
294 #[error("This winning config does not contain this safety deposit box as one of it's prizes")]
296 WinningConfigSafetyDepositMismatch,
297
298 #[error("The participation prize does not match the safety deposit given")]
300 ParticipationSafetyDepositMismatch,
301
302 #[error("Participation NFT not present on this auction, so cannot collect money for it")]
304 ParticipationNotPresent,
305
306 #[error("Not possible to settle until all bids have been claimed")]
308 NotAllBidsClaimed,
309
310 #[error("Invalid winning config item index provided")]
312 InvalidWinningConfigItemIndex,
313
314 #[error("When using a one time authorization token in a winning config item, you can never have amount > 1")]
316 OneTimeAuthorizationTokenMustBeOne,
317
318 #[error("Adding a reservation list failed")]
320 AddReservationListFailed,
321
322 #[error("Close account command failed")]
324 CloseAccountFailed,
325
326 #[error("A creator on this metadata has not verified it")]
328 CreatorHasNotVerifiedMetadata,
329
330 #[error("Duplicate winning config item detected")]
332 DuplicateWinningConfigItemDetected,
333
334 #[error("The authorization account provided does not match that on the participation state")]
336 PrintingAuthorizationTokenAccountMismatch,
337
338 #[error("The transient account provided does not have the correct mint")]
340 TransientAuthAccountMintMismatch,
341
342 #[error("The participation printing authorization token account is empty. One person needs to call populate on it!")]
344 ParticipationPrintingEmpty,
345
346 #[error("The printing authorization token command failed")]
348 PrintingAuthorizationTokensFailed,
349
350 #[error("Invalid token program")]
352 InvalidTokenProgram,
353
354 #[error("Token metadata program does not match")]
356 AuctionManagerTokenMetadataMismatch,
357
358 #[error("This safety deposit box has already been validated")]
360 AlreadyValidated,
361
362 #[error("Auction must be created")]
364 AuctionMustBeCreated,
365
366 #[error("Accept payment delegate should be none")]
368 DelegateShouldBeNone,
369
370 #[error("Accept payment close authority should be none")]
372 CloseAuthorityShouldBeNone,
373
374 #[error("Data type mismatch")]
376 DataTypeMismatch,
377
378 #[error("Auctioneer can't claim a won prize")]
380 AuctioneerCantClaimWonPrize,
381
382 #[error("Auctioneer is the only one who can override win indices")]
384 MustBeAuctioneer,
385
386 #[error("The auction provided has a different amount of winners set than does the auction manager settings")]
388 WinnerAmountMismatch,
389
390 #[error("Invalid Auction Manager Status")]
392 InvalidStatus,
393
394 #[error("You are not eligible for this edition offset")]
396 InvalidEditionNumber,
397
398 #[error("Invalid operation")]
400 InvalidOperation,
401
402 #[error("The provided account needs to contain one token of this mint type")]
404 ProvidedAccountDoesNotContainOneToken,
405
406 #[error("You are not the winner at this index")]
408 WinnerIndexMismatch,
409
410 #[error("You supplied a safety deposit index in a winning configuration that does not exist")]
412 InvalidWinningConfigSafetyDepositIndex,
413
414 #[error("The order provided on the safety deposit config does not match that on the safety deposit box!")]
416 SafetyDepositConfigOrderMismatch,
417
418 #[error("Winner index not found in safety deposit config ranges")]
420 WinnerIndexNotFound,
421
422 #[error("Currently metaplex auctions are limited to a single participation prize")]
424 AlreadyHasOneParticipationPrize,
425
426 #[error("This winner was not found in any ranges in the unique token type list, this should never happen")]
428 NoTokensForThisWinner,
429
430 #[error("Not allowed to use Master Edition V1 printing with Auction Manager v2")]
432 PrintingV1NotAllowedWithAuctionManagerV2,
433
434 #[error("Invalid system program")]
436 InvalidSystemProgram,
437
438 #[error("Duplicate key detected")]
440 DuplicateKeyDetected,
441
442 #[error("Cant add more than 10 metadata to a cache")]
444 MaxMetadataCacheSizeReached,
445
446 #[error("Invalid cache offset")]
448 InvalidCacheOffset,
449
450 #[error("You needed to provide an auction cache for the element above you but did not")]
452 ExpectedAboveAuctionCacheToBeProvided,
453
454 #[error("You needed to provide an auction cache for the element below you but did not")]
456 ExpectedBelowAuctionCacheToBeProvided,
457
458 #[error("Cache given does not match cache at this offset")]
460 CacheMismatch,
461
462 #[error("Cache above is newer")]
464 CacheAboveIsNewer,
465
466 #[error("Cache below is older")]
468 CacheBelowIsOlder,
469
470 #[error("Auction manager already in finished state")]
472 AuctionManagerInFishedState,
473
474 #[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}