22
33use { crate :: error:: TokenError , pinocchio:: program_error:: ProgramError } ;
44
5+
56/// Instructions supported by the token program.
67#[ repr( u8 ) ]
78#[ derive( Clone , Debug , PartialEq ) ]
@@ -536,6 +537,8 @@ pub enum TokenInstruction {
536537 /// other `batch` instruction; an error will be raised when this is
537538 /// detected.
538539 Batch = 255 ,
540+
541+
539542 // Any new variants also need to be added to program-2022 `TokenInstruction`, so that the
540543 // latter remains a superset of this instruction set. New variants also need to be added to
541544 // token/js/src/instructions/types.ts to maintain @solana/spl-token compatibility
@@ -547,7 +550,7 @@ impl TryFrom<u8> for TokenInstruction {
547550 fn try_from ( value : u8 ) -> Result < Self , Self :: Error > {
548551 match value {
549552 // SAFETY: `value` is guaranteed to be in the range of the enum variants.
550- 0 ..=24 | 38 | 255 => Ok ( unsafe { core:: mem:: transmute :: < u8 , TokenInstruction > ( value) } ) ,
553+ 0 ..=24 | 38 | 45 | 255 => Ok ( unsafe { core:: mem:: transmute :: < u8 , TokenInstruction > ( value) } ) ,
551554 _ => Err ( TokenError :: InvalidInstruction . into ( ) ) ,
552555 }
553556 }
@@ -566,6 +569,7 @@ pub enum AuthorityType {
566569 AccountOwner ,
567570 /// Authority to close a token account
568571 CloseAccount ,
572+
569573}
570574
571575impl TryFrom < u8 > for AuthorityType {
@@ -595,10 +599,13 @@ mod tests {
595599 assert_eq ! (
596600 TokenInstruction :: from_repr( variant_u8) ,
597601 Some ( TokenInstruction :: try_from( variant_u8) . unwrap( ) )
602+
598603 ) ;
599604 assert_eq ! ( TokenInstruction :: try_from( variant_u8) . unwrap( ) , variant) ;
600605 }
601606 }
607+
608+
602609
603610 #[ test]
604611 fn test_authority_type_from_u8_exhaustive ( ) {
0 commit comments