@@ -20,15 +20,13 @@ use {
20
20
native_mint,
21
21
state:: { Account , AccountState , Mint , Multisig } ,
22
22
} ,
23
- num_traits:: FromPrimitive ,
24
23
solana_program:: {
25
24
account_info:: { next_account_info, AccountInfo } ,
26
25
clock:: Clock ,
27
- decode_error:: DecodeError ,
28
26
entrypoint:: ProgramResult ,
29
27
msg,
30
28
program:: { invoke, invoke_signed, set_return_data} ,
31
- program_error:: { PrintProgramError , ProgramError } ,
29
+ program_error:: ProgramError ,
32
30
program_memory:: sol_memset,
33
31
program_option:: COption ,
34
32
program_pack:: Pack ,
@@ -1390,110 +1388,6 @@ impl Processor {
1390
1388
}
1391
1389
}
1392
1390
1393
- impl PrintProgramError for TokenError {
1394
- fn print < E > ( & self )
1395
- where
1396
- E : ' static + std:: error:: Error + DecodeError < E > + PrintProgramError + FromPrimitive ,
1397
- {
1398
- match self {
1399
- TokenError :: NotRentExempt => msg ! ( "Error: Lamport balance below rent-exempt threshold" ) ,
1400
- TokenError :: InsufficientFunds => msg ! ( "Error: insufficient funds" ) ,
1401
- TokenError :: InvalidMint => msg ! ( "Error: Invalid Mint" ) ,
1402
- TokenError :: MintMismatch => msg ! ( "Error: Account not associated with this Mint" ) ,
1403
- TokenError :: OwnerMismatch => msg ! ( "Error: owner does not match" ) ,
1404
- TokenError :: FixedSupply => msg ! ( "Error: the total supply of this token is fixed" ) ,
1405
- TokenError :: AlreadyInUse => msg ! ( "Error: account or token already in use" ) ,
1406
- TokenError :: InvalidNumberOfProvidedSigners => {
1407
- msg ! ( "Error: Invalid number of provided signers" )
1408
- }
1409
- TokenError :: InvalidNumberOfRequiredSigners => {
1410
- msg ! ( "Error: Invalid number of required signers" )
1411
- }
1412
- TokenError :: UninitializedState => msg ! ( "Error: State is uninitialized" ) ,
1413
- TokenError :: NativeNotSupported => {
1414
- msg ! ( "Error: Instruction does not support native tokens" )
1415
- }
1416
- TokenError :: NonNativeHasBalance => {
1417
- msg ! ( "Error: Non-native account can only be closed if its balance is zero" )
1418
- }
1419
- TokenError :: InvalidInstruction => msg ! ( "Error: Invalid instruction" ) ,
1420
- TokenError :: InvalidState => msg ! ( "Error: Invalid account state for operation" ) ,
1421
- TokenError :: Overflow => msg ! ( "Error: Operation overflowed" ) ,
1422
- TokenError :: AuthorityTypeNotSupported => {
1423
- msg ! ( "Error: Account does not support specified authority type" )
1424
- }
1425
- TokenError :: MintCannotFreeze => msg ! ( "Error: This token mint cannot freeze accounts" ) ,
1426
- TokenError :: AccountFrozen => msg ! ( "Error: Account is frozen" ) ,
1427
- TokenError :: MintDecimalsMismatch => {
1428
- msg ! ( "Error: decimals different from the Mint decimals" )
1429
- }
1430
- TokenError :: NonNativeNotSupported => {
1431
- msg ! ( "Error: Instruction does not support non-native tokens" )
1432
- }
1433
- TokenError :: ExtensionTypeMismatch => {
1434
- msg ! ( "Error: New extension type does not match already existing extensions" )
1435
- }
1436
- TokenError :: ExtensionBaseMismatch => {
1437
- msg ! ( "Error: Extension does not match the base type provided" )
1438
- }
1439
- TokenError :: ExtensionAlreadyInitialized => {
1440
- msg ! ( "Error: Extension already initialized on this account" )
1441
- }
1442
- TokenError :: ConfidentialTransferAccountHasBalance => {
1443
- msg ! ( "Error: An account can only be closed if its confidential balance is zero" )
1444
- }
1445
- TokenError :: ConfidentialTransferAccountNotApproved => {
1446
- msg ! ( "Error: Account not approved for confidential transfers" )
1447
- }
1448
- TokenError :: ConfidentialTransferDepositsAndTransfersDisabled => {
1449
- msg ! ( "Error: Account not accepting deposits or transfers" )
1450
- }
1451
- TokenError :: ConfidentialTransferElGamalPubkeyMismatch => {
1452
- msg ! ( "Error: ElGamal public key mismatch" )
1453
- }
1454
- TokenError :: ConfidentialTransferBalanceMismatch => {
1455
- msg ! ( "Error: Balance mismatch" )
1456
- }
1457
- TokenError :: MintHasSupply => {
1458
- msg ! ( "Error: Mint has non-zero supply. Burn all tokens before closing the mint" )
1459
- }
1460
- TokenError :: NoAuthorityExists => {
1461
- msg ! ( "Error: No authority exists to perform the desired operation" ) ;
1462
- }
1463
- TokenError :: TransferFeeExceedsMaximum => {
1464
- msg ! ( "Error: Transfer fee exceeds maximum of 10,000 basis points" ) ;
1465
- }
1466
- TokenError :: MintRequiredForTransfer => {
1467
- msg ! ( "Mint required for this account to transfer tokens, use `transfer_checked` or `transfer_checked_with_fee`" ) ;
1468
- }
1469
- TokenError :: FeeMismatch => {
1470
- msg ! ( "Calculated fee does not match expected fee" ) ;
1471
- }
1472
- TokenError :: FeeParametersMismatch => {
1473
- msg ! ( "Fee parameters associated with zero-knowledge proofs do not match fee parameters in mint" )
1474
- }
1475
- TokenError :: ImmutableOwner => {
1476
- msg ! ( "The owner authority cannot be changed" ) ;
1477
- }
1478
- TokenError :: AccountHasWithheldTransferFees => {
1479
- msg ! ( "Error: An account can only be closed if its withheld fee balance is zero, harvest fees to the mint and try again" ) ;
1480
- }
1481
- TokenError :: NoMemo => {
1482
- msg ! ( "Error: No memo in previous instruction; required for recipient to receive a transfer" ) ;
1483
- }
1484
- TokenError :: NonTransferable => {
1485
- msg ! ( "Transfer is disabled for this mint" ) ;
1486
- }
1487
- TokenError :: NonTransferableNeedsImmutableOwnership => {
1488
- msg ! ( "Non-transferable tokens can't be minted to an account without immutable ownership" ) ;
1489
- }
1490
- TokenError :: MaximumPendingBalanceCreditCounterExceeded => {
1491
- msg ! ( "The total number of `Deposit` and `Transfer` instructions to an account cannot exceed the associated `maximum_pending_balance_credit_counter`" ) ;
1492
- }
1493
- }
1494
- }
1495
- }
1496
-
1497
1391
#[ cfg( test) ]
1498
1392
mod tests {
1499
1393
use {
@@ -1506,7 +1400,7 @@ mod tests {
1506
1400
account_info:: IntoAccountInfo ,
1507
1401
clock:: Epoch ,
1508
1402
instruction:: Instruction ,
1509
- program_error,
1403
+ program_error:: { self , PrintProgramError } ,
1510
1404
sysvar:: { clock:: Clock , rent} ,
1511
1405
} ,
1512
1406
solana_sdk:: account:: {
0 commit comments